unpdf 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pdfjs.mjs CHANGED
@@ -51,7 +51,7 @@ startxref
51
51
  `);const l=new Rn(i.join(`
52
52
  `)),f=l.dict=new _;f.setIfName("Type","ObjStm"),f.set("N",n.length),f.set("First",i[0].length+1),s.put(e,{data:l})}async writePDF(){await this.#z();const e=this.#A(),[n,s,i]=await this.#k(),[a,r]=await this.#D(),o=[...`%PDF-${this.version}
53
53
  %`.split("").map(l=>l.charCodeAt(0)),250,222,250,206];return ap({originalData:new Uint8Array(o),changes:a,xrefInfo:{startXRef:null,rootRef:this.rootRef,infoRef:this.infoRef,encryptRef:n,newRef:r,fileIds:i||[null,null],infoMap:e},useXrefStream:this.useObjectStreams,xref:{encrypt:s,encryptRef:n}})}}let r6=class{static{p(this,"BasePDFStream")}#e=null;#t=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(e,n,s){this._source=e,this.#e=n,this.#t=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return Bt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#e(this)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const s=new this.#t(this,e,n);return this._rangeReaders.add(s),s}cancelAllRequests(e){this._fullReader?.cancel(e);for(const n of new Set(this._rangeReaders))n.cancel(e)}},o6=class{static{p(this,"BasePDFStreamReader")}onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(e){this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){Ye("Abstract method `read` called")}cancel(e){Ye("Abstract method `cancel` called")}},l6=class{static{p(this,"BasePDFStreamRangeReader")}_stream=null;constructor(e,n,s){this._stream=e}async read(){Ye("Abstract method `read` called")}cancel(e){Ye("Abstract method `cancel` called")}};class f6 extends r6{static{p(this,"PDFWorkerStream")}constructor(e){super(e,c6,h6)}}class c6 extends o6{static{p(this,"PDFWorkerStreamReader")}_reader=null;constructor(e){super(e);const{msgHandler:n}=e._source,s=n.sendWithStream("GetReader");this._reader=s.getReader(),n.sendWithPromise("ReaderHeadersReady").then(i=>{this._contentLength=i.contentLength,this._isStreamingSupported=i.isStreamingSupported,this._isRangeSupported=i.isRangeSupported,this._headersCapability.resolve()},this._headersCapability.reject)}async read(){const{value:e,done:n}=await this._reader.read();return n?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}}class h6 extends l6{static{p(this,"PDFWorkerStreamRangeReader")}_reader=null;constructor(e,n,s){super(e,n,s);const{msgHandler:i}=e._source,a=i.sendWithStream("GetRangeReader",{begin:n,end:s});this._reader=a.getReader()}async read(){const{value:e,done:n}=await this._reader.read();return n?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}}class ni{static{p(this,"WorkerTask")}constructor(e){this.name=e,this.terminated=!1,this._capability=Promise.withResolvers()}get finished(){return this._capability.promise}finish(){this._capability.resolve()}terminate(){this.terminated=!0}ensureNotTerminated(){if(this.terminated)throw new Error("Worker task was terminated")}}class u6{static{p(this,"WorkerMessageHandler")}static{typeof window>"u"&&!qm&&typeof self<"u"&&typeof self.postMessage=="function"&&"onmessage"in self&&this.initializeFromPort(self)}static setup(e,n){let s=!1;e.on("test",i=>{s||(s=!0,e.send("test",i instanceof Uint8Array))}),e.on("configure",i=>{Cm(i.verbosity)}),e.on("GetDocRequest",i=>this.createDocumentHandler(i,n))}static createDocumentHandler(e,n){let s,i=!1,a=null;const r=new Set,o=Im(),{docId:l,apiVersion:f}=e,c="5.6.205";if(f!==c)throw new Error(`The API version "${f}" does not match the Worker version "${c}".`);const h=p((j,v)=>`The \`${j}.prototype\` contains unexpected enumerable property "${v}", thus breaking e.g. \`for...in\` iteration of ${j}s.`,"buildMsg");for(const j in{})throw new Error(h("Object",j));for(const j in[])throw new Error(h("Array",j));const u=l+"_worker";let d=new ep(u,l,n);function m(){if(i)throw new Error("Worker was terminated")}p(m,"ensureNotTerminated");function g(j){r.add(j)}p(g,"startWorkerTask");function b(j){j.finish(),r.delete(j)}p(b,"finishWorkerTask");async function w(j){await s.ensureDoc("checkHeader"),await s.ensureDoc("parseStartXRef"),await s.ensureDoc("parse",[j]),await s.ensureDoc("checkFirstPage",[j]),await s.ensureDoc("checkLastPage",[j]);const v=await s.ensureDoc("isPureXfa");if(v){const S=new ni("loadXfaResources");g(S),await s.ensureDoc("loadXfaResources",[d,S]),b(S)}const[q,A]=await Promise.all([s.ensureDoc("numPages"),s.ensureDoc("fingerprints")]),C=v?await s.ensureDoc("htmlForXfa"):null;return{numPages:q,fingerprints:A,htmlForXfa:C}}p(w,"loadDocument");async function x({data:j,password:v,disableAutoFetch:q,rangeChunkSize:A,docBaseUrl:C,enableXfa:S,evaluatorOptions:I}){const T={source:null,disableAutoFetch:q,docBaseUrl:C,docId:l,enableXfa:S,evaluatorOptions:I,handler:d,length:0,password:v,rangeChunkSize:A};if(j)return T.source=j,new Gc(T);const P=new f6({msgHandler:d}),H=P.getFullReader(),{promise:G,resolve:Z,reject:z}=Promise.withResolvers();let O,N=[];a=p(je=>P.cancelAllRequests(je),"cancelXHRs"),H.headersReady.then(()=>{if(H.isRangeSupported){T.source=P,T.length=H.contentLength,T.disableAutoFetch||=H.isStreamingSupported,O=new U7(T);for(const je of N)O.sendProgressiveData(je);N=null,Z(O),a=null}}).catch(je=>{z(je),a=null});async function oe(){let je=0;for(;;){const{value:Y,done:ye}=await H.read();if(m(),ye)break;je+=Y.byteLength,H.isStreamingSupported||d.send("DocProgress",{loaded:je,total:H.contentLength}),O?O.sendProgressiveData(Y):N.push(Y)}O||(T.source=Yh(N),N=null,O=new Gc(T),Z(O)),a=null}return p(oe,"readData"),oe().catch(je=>{z(je),a=null}),G}p(x,"getPdfManager");function y(j){function v(C){m(),d.send("GetDoc",{pdfInfo:C})}p(v,"onSuccess");function q(C){if(!i)if(C instanceof La){const S=new ni(`PasswordException: response ${C.code}`);g(S),d.sendWithPromise("PasswordRequest",C).then(function({password:I}){b(S),s.updatePassword(I),A()}).catch(function(){b(S),d.send("DocException",C)})}else d.send("DocException",ds(C))}p(q,"onFailure");function A(){m(),w(!1).then(v,function(C){if(m(),!(C instanceof sa)){q(C);return}s.requestLoadedStream().then(function(){m(),w(!0).then(v,q)})})}p(A,"pdfManagerReady"),m(),x(j).then(function(C){if(i)throw C.terminate(new jn("Worker was terminated.")),new Error("Worker was terminated");s=C,s.requestLoadedStream(!0).then(S=>{d.send("DataLoaded",{length:S.bytes.byteLength})})}).then(A,q)}return p(y,"setupDoc"),d.on("GetPage",function(j){return s.getPage(j.pageIndex).then(function(v){return Promise.all([s.ensure(v,"rotate"),s.ensure(v,"ref"),s.ensure(v,"userUnit"),s.ensure(v,"view")]).then(function([q,A,C,S]){return{rotate:q,ref:A,refStr:A?.toString()??null,userUnit:C,view:S}})})}),d.on("GetPageIndex",function(j){const v=ae.get(j.num,j.gen);return s.ensureCatalog("getPageIndex",[v])}),d.on("GetDestinations",function(j){return s.ensureCatalog("destinations")}),d.on("GetDestination",function(j){return s.ensureCatalog("getDestination",[j.id])}),d.on("GetPageLabels",function(j){return s.ensureCatalog("pageLabels")}),d.on("GetPageLayout",function(j){return s.ensureCatalog("pageLayout")}),d.on("GetPageMode",function(j){return s.ensureCatalog("pageMode")}),d.on("GetViewerPreferences",function(j){return s.ensureCatalog("viewerPreferences")}),d.on("GetOpenAction",function(j){return s.ensureCatalog("openAction")}),d.on("GetAttachments",function(j){return s.ensureCatalog("attachments")}),d.on("GetDocJSActions",function(j){return s.ensureCatalog("jsActions")}),d.on("GetPageJSActions",function({pageIndex:j}){return s.getPage(j).then(v=>s.ensure(v,"jsActions"))}),d.on("GetAnnotationsByType",async function({types:j,pageIndexesToSkip:v}){const[q,A]=await Promise.all([s.ensureDoc("numPages"),s.ensureDoc("annotationGlobals")]);if(!A)return null;const C=[],S=[];let I=null;try{for(let P=0,H=q;P<H;P++)v?.has(P)||(I||(I=new ni("GetAnnotationsByType"),g(I)),C.push(s.getPage(P).then(async G=>G?G.collectAnnotationsByType(d,I,j,S,A)||[]:[])));return await Promise.all(C),(await Promise.all(S)).filter(P=>!!P)}finally{I&&b(I)}}),d.on("GetOutline",function(j){return s.ensureCatalog("documentOutline")}),d.on("GetOptionalContentConfig",function(j){return s.ensureCatalog("optionalContentConfig")}),d.on("GetPermissions",function(j){return s.ensureCatalog("permissions")}),d.on("GetMetadata",function(j){return Promise.all([s.ensureDoc("documentInfo"),s.ensureCatalog("metadata"),s.ensureCatalog("hasStructTree")])}),d.on("GetMarkInfo",function(j){return s.ensureCatalog("markInfo")}),d.on("GetData",function(j){return s.requestLoadedStream().then(v=>v.bytes)}),d.on("GetAnnotations",function({pageIndex:j,intent:v}){return s.getPage(j).then(function(q){const A=new ni(`GetAnnotations: page ${j}`);return g(A),q.getAnnotationsData(d,A,v).then(C=>(b(A),C),C=>{throw b(A),C})})}),d.on("GetFieldObjects",function(j){return s.ensureDoc("fieldObjects").then(v=>v?.allFields||null)}),d.on("HasJSActions",function(j){return s.ensureDoc("hasJSActions")}),d.on("GetCalculationOrderIds",function(j){return s.ensureDoc("calculationOrderIds")}),d.on("ExtractPages",async function({pageInfos:j,annotationStorage:v}){if(!j)return F("extractPages: nothing to extract."),null;Array.isArray(j)||(j=[j]);let q=0;for(const C of j)if(C.document===null)C.document=s.pdfDocument;else if(ArrayBuffer.isView(C.document)){const S=new Gc({source:C.document,docId:`${l}_extractPages_${q++}`,handler:d,password:C.password??null,evaluatorOptions:Object.assign({},s.evaluatorOptions)});let I=!1,T=!0;for(;;)try{await S.requestLoadedStream(),await S.ensureDoc("checkHeader"),await S.ensureDoc("parseStartXRef"),await S.ensureDoc("parse",[I]);break}catch(H){if(H instanceof sa)if(I===!1){I=!0;continue}else T=!1,F("extractPages: XRefParseException.");else if(H instanceof La){const G=new ni(`PasswordException: response ${H.code}`);g(G);try{const{password:Z}=await d.sendWithPromise("PasswordRequest",H);S.updatePassword(Z)}catch{T=!1,F("extractPages: invalid password.")}finally{b(G)}}else T=!1,F("extractPages: invalid document.");if(!T)break}T||(C.document=null),await S.ensureDoc("isPureXfa")?(C.document=null,F("extractPages does not support pure XFA documents.")):C.document=S.pdfDocument}else F("extractPages: invalid document.");let A;try{const C=new a6;return A=new ni(`ExtractPages: ${j.length} page(s)`),g(A),await C.extractPages(j,v,d,A)}catch(C){return console.error(C),null}finally{A&&b(A)}}),d.on("SaveDocument",async function({isPureXfa:j,numPages:v,annotationStorage:q,filename:A}){const C=[s.requestLoadedStream(),s.ensureCatalog("acroForm"),s.ensureCatalog("acroFormRef"),s.ensureDoc("startXRef"),s.ensureDoc("xref"),s.ensureCatalog("structTreeRoot")],S=new tn,I=[],T=j?null:gf(q),[P,H,G,Z,z,O]=await Promise.all(C),N=z.trailer.getRaw("Root")||null;let oe;if(T){O?await O.canUpdateStructTree({pdfManager:s,newAnnotationsByPage:T})&&(oe=O):await ea.canCreateStructureTree({catalogRef:N,pdfManager:s,newAnnotationsByPage:T})&&(oe=null);const L=zs.generateImages(q.values(),z,s.evaluatorOptions.isOffscreenCanvasSupported),J=oe===void 0?I:[];for(const[ce,le]of T)J.push(s.getPage(ce).then(se=>{const Te=new ni(`Save (editor): page ${ce}`);return g(Te),se.saveNewAnnotations(d,Te,le,L,S).finally(function(){b(Te)})}));oe===null?I.push(Promise.all(J).then(async()=>{await ea.createStructureTree({newAnnotationsByPage:T,xref:z,catalogRef:N,pdfManager:s,changes:S})})):oe&&I.push(Promise.all(J).then(async()=>{await oe.updateStructureTree({newAnnotationsByPage:T,pdfManager:s,changes:S})}))}if(j)I.push(s.ensureDoc("serializeXfaData",[q]));else for(let L=0;L<v;L++)I.push(s.getPage(L).then(function(J){const ce=new ni(`Save: page ${L}`);return g(ce),J.save(d,ce,q,S).finally(function(){b(ce)})}));const je=await Promise.all(I);let Y=null;if(j){if(Y=je[0],!Y)return P.bytes}else if(S.size===0)return P.bytes;const ye=G&&H instanceof _&&S.values().some(L=>L.needAppearances),qe=H instanceof _&&H.get("XFA")||null;let W=null,K=!1;if(Array.isArray(qe)){for(let L=0,J=qe.length;L<J;L+=2)qe[L]==="datasets"&&(W=qe[L+1],K=!0);W===null&&(W=z.getNewTemporaryRef())}else qe&&F("Unsupported XFA type.");let M=Object.create(null);if(z.trailer){const L=new Map,J=z.trailer.get("Info")||null;if(J instanceof _)for(const[ce,le]of J)typeof le=="string"&&L.set(ce,Je(le));M={rootRef:N,encryptRef:z.trailer.getRaw("Encrypt")||null,newRef:z.getNewTemporaryRef(),infoRef:z.trailer.getRaw("Info")||null,infoMap:L,fileIds:z.trailer.get("ID")||null,startXRef:Z,filename:A}}return ap({originalData:P.bytes,xrefInfo:M,changes:S,xref:z,hasXfa:!!qe,xfaDatasetsRef:W,hasXfaDatasetsEntry:K,needAppearances:ye,acroFormRef:G,acroForm:H,xfaData:Y,useXrefStream:Kh(z.topDict,"XRef")}).finally(()=>{z.resetNewTemporaryRef()})}),d.on("GetOperatorList",function(j,v){const{pageId:q,pageIndex:A}=j;s.getPage(q).then(function(C){const S=new ni(`GetOperatorList: page ${A}`);g(S);const I=o>=Fr.INFOS?Date.now():0;C.getOperatorList({handler:d,sink:v,task:S,intent:j.intent,cacheKey:j.cacheKey,annotationStorage:j.annotationStorage,modifiedIds:j.modifiedIds,pageIndex:A}).then(function(T){b(S),I&&Ke(`page=${A+1} - getOperatorList: time=${Date.now()-I}ms, len=${T.length}`),v.close()},function(T){b(S),!S.terminated&&v.error(T)})})}),d.on("GetTextContent",function(j,v){const{pageId:q,pageIndex:A,includeMarkedContent:C,disableNormalization:S}=j;s.getPage(q).then(function(I){const T=new ni("GetTextContent: page "+A);g(T);const P=o>=Fr.INFOS?Date.now():0;I.extractTextContent({handler:d,task:T,sink:v,includeMarkedContent:C,disableNormalization:S}).then(function(){b(T),P&&Ke(`page=${A+1} - getTextContent: time=${Date.now()-P}ms`),v.close()},function(H){b(T),!T.terminated&&v.error(H)})})}),d.on("GetStructTree",function(j){return s.getPage(j.pageIndex).then(v=>s.ensure(v,"getStructTree"))}),d.on("FontFallback",function(j){return s.fontFallback(j.id,d)}),d.on("Cleanup",function(j){return s.cleanup(!0)}),d.on("Terminate",async function(j){i=!0;const v=[];if(s){s.terminate(new jn("Worker was terminated."));const q=s.cleanup();v.push(q),s=null}else ic();a?.(new jn("Worker was terminated."));for(const q of r)v.push(q.finished),q.terminate();await Promise.all(v),d.destroy(),d=null}),d.on("Ready",function(j){y(e),e=null}),u}static initializeFromPort(e){const n=new ep("worker","main",e);this.setup(n,e),n.send("ready",null)}}globalThis.pdfjsWorker={WorkerMessageHandler:u6};const Ts=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Vc=[.001,0,0,.001,0,0],Kc=1.35,ps={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},vi={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Io="pdfjs_internal_editor_",et={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},gt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},rp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ia={TRIANGLES:1,LATTICE:2},cn={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},To={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Yt={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},fr={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Eo={ERRORS:0,WARNINGS:1,INFOS:5},cr={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Fo={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},op={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let u0=Eo.WARNINGS;function d6(t){Number.isInteger(t)&&(u0=t)}p(d6,"setVerbosityLevel");function p6(){return u0}p(p6,"getVerbosityLevel");function d0(t){u0>=Eo.INFOS&&console.info(`Info: ${t}`)}p(d0,"info");function at(t){u0>=Eo.WARNINGS&&console.warn(`Warning: ${t}`)}p(at,"warn");function It(t){throw new Error(t)}p(It,"unreachable");function Lt(t,e){t||It(e)}p(Lt,"assert");function m6(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}p(m6,"_isValidProtocol");function Xc(t,e=null,n=null){if(!t)return null;if(n&&typeof t=="string"&&(n.addDefaultProtocol&&t.startsWith("www.")&&t.match(/\./g)?.length>=2&&(t=`http://${t}`),n.tryConvertEncoding))try{t=y6(t)}catch{}const s=e?URL.parse(t,e):URL.parse(t);return m6(s)?s:null}p(Xc,"createValidAbsoluteUrl");function Yc(t,e,n=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):n&&Xc(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}p(Yc,"updateUrlHash");function Qc(t){return t.substring(t.lastIndexOf("/")+1)}p(Qc,"stripPath");function st(t,e,n,s=!1){return Object.defineProperty(t,e,{value:n,enumerable:!s,configurable:!0,writable:!1}),n}p(st,"shadow");const Ta=p(function(){function e(n,s){this.message=n,this.name=s}return p(e,"BaseException"),e.prototype=new Error,e.constructor=e,e},"BaseExceptionClosure")();class lp extends Ta{static{p(this,"PasswordException")}constructor(e,n){super(e,"PasswordException"),this.code=n}}class Jc extends Ta{static{p(this,"UnknownErrorException")}constructor(e,n){super(e,"UnknownErrorException"),this.details=n}}class p0 extends Ta{static{p(this,"InvalidPDFException")}constructor(e){super(e,"InvalidPDFException")}}class Bo extends Ta{static{p(this,"ResponseException")}constructor(e,n,s){super(e,"ResponseException"),this.status=n,this.missing=s}}class g6 extends Ta{static{p(this,"FormatError")}constructor(e){super(e,"FormatError")}}class qi extends Ta{static{p(this,"AbortException")}constructor(e){super(e,"AbortException")}}function b6(t){(typeof t!="object"||t?.length===void 0)&&It("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const s=[];for(let i=0;i<e;i+=n){const a=Math.min(i+n,e),r=t.subarray(i,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}p(b6,"bytesToString");function m0(t){typeof t!="string"&&It("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let s=0;s<e;++s)n[s]=t.charCodeAt(s)&255;return n}p(m0,"stringToBytes");function w6(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}p(w6,"string32");function x6(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}p(x6,"isLittleEndian");function k6(){try{return new Function(""),!0}catch{return!1}}p(k6,"isEvalSupported");class rn{static{p(this,"FeatureTest")}static get isLittleEndian(){return st(this,"isLittleEndian",x6())}static get isEvalSupported(){return st(this,"isEvalSupported",k6())}static get isOffscreenCanvasSupported(){return st(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return st(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return st(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return st(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:e,userAgent:n}=navigator;return st(this,"platform",{isAndroid:n.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:n.includes("Firefox")})}static get isCSSRoundSupported(){return st(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Zc=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class Ie{static{p(this,"Util")}static makeHexColor(e,n,s){return`#${Zc[e]}${Zc[n]}${Zc[s]}`}static domMatrixToTransform(e){return[e.a,e.b,e.c,e.d,e.e,e.f]}static scaleMinMax(e,n){let s;e[0]?(e[0]<0&&(s=n[0],n[0]=n[2],n[2]=s),n[0]*=e[0],n[2]*=e[0],e[3]<0&&(s=n[1],n[1]=n[3],n[3]=s),n[1]*=e[3],n[3]*=e[3]):(s=n[0],n[0]=n[1],n[1]=s,s=n[2],n[2]=n[3],n[3]=s,e[1]<0&&(s=n[1],n[1]=n[3],n[3]=s),n[1]*=e[1],n[3]*=e[1],e[2]<0&&(s=n[0],n[0]=n[2],n[2]=s),n[0]*=e[2],n[2]*=e[2]),n[0]+=e[4],n[1]+=e[5],n[2]+=e[4],n[3]+=e[5]}static transform(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}static multiplyByDOMMatrix(e,n){return[e[0]*n.a+e[2]*n.b,e[1]*n.a+e[3]*n.b,e[0]*n.c+e[2]*n.d,e[1]*n.c+e[3]*n.d,e[0]*n.e+e[2]*n.f+e[4],e[1]*n.e+e[3]*n.f+e[5]]}static applyTransform(e,n,s=0){const i=e[s],a=e[s+1];e[s]=i*n[0]+a*n[2]+n[4],e[s+1]=i*n[1]+a*n[3]+n[5]}static applyTransformToBezier(e,n,s=0){const i=n[0],a=n[1],r=n[2],o=n[3],l=n[4],f=n[5];for(let c=0;c<6;c+=2){const h=e[s+c],u=e[s+c+1];e[s+c]=h*i+u*r+l,e[s+c+1]=h*a+u*o+f}}static applyInverseTransform(e,n){const s=e[0],i=e[1],a=n[0]*n[3]-n[1]*n[2];e[0]=(s*n[3]-i*n[2]+n[2]*n[5]-n[4]*n[3])/a,e[1]=(-s*n[1]+i*n[0]+n[4]*n[1]-n[5]*n[0])/a}static axialAlignedBoundingBox(e,n,s){const i=n[0],a=n[1],r=n[2],o=n[3],l=n[4],f=n[5],c=e[0],h=e[1],u=e[2],d=e[3];let m=i*c+l,g=m,b=i*u+l,w=b,x=o*h+f,y=x,j=o*d+f,v=j;if(a!==0||r!==0){const q=a*c,A=a*u,C=r*h,S=r*d;m+=C,w+=C,b+=S,g+=S,x+=q,v+=q,j+=A,y+=A}s[0]=Math.min(s[0],m,b,g,w),s[1]=Math.min(s[1],x,j,y,v),s[2]=Math.max(s[2],m,b,g,w),s[3]=Math.max(s[3],x,j,y,v)}static inverseTransform(e){const n=e[0]*e[3]-e[1]*e[2];return[e[3]/n,-e[1]/n,-e[2]/n,e[0]/n,(e[2]*e[5]-e[4]*e[3])/n,(e[4]*e[1]-e[5]*e[0])/n]}static singularValueDecompose2dScale(e,n){const s=e[0],i=e[1],a=e[2],r=e[3],o=s**2+i**2,l=s*a+i*r,f=a**2+r**2,c=(o+f)/2,h=Math.sqrt(c**2-(o*f-l**2));n[0]=Math.sqrt(c+h||1),n[1]=Math.sqrt(c-h||1)}static normalizeRect(e){const n=e.slice(0);return e[0]>e[2]&&(n[0]=e[2],n[2]=e[0]),e[1]>e[3]&&(n[1]=e[3],n[3]=e[1]),n}static intersect(e,n){const s=Math.max(Math.min(e[0],e[2]),Math.min(n[0],n[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(n[0],n[2]));if(s>i)return null;const a=Math.max(Math.min(e[1],e[3]),Math.min(n[1],n[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(n[1],n[3]));return a>r?null:[s,a,i,r]}static pointBoundingBox(e,n,s){s[0]=Math.min(s[0],e),s[1]=Math.min(s[1],n),s[2]=Math.max(s[2],e),s[3]=Math.max(s[3],n)}static rectBoundingBox(e,n,s,i,a){a[0]=Math.min(a[0],e,s),a[1]=Math.min(a[1],n,i),a[2]=Math.max(a[2],e,s),a[3]=Math.max(a[3],n,i)}static#e(e,n,s,i,a,r,o,l,f,c){if(f<=0||f>=1)return;const h=1-f,u=f*f,d=u*f,m=h*(h*(h*e+3*f*n)+3*u*s)+d*i,g=h*(h*(h*a+3*f*r)+3*u*o)+d*l;c[0]=Math.min(c[0],m),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],m),c[3]=Math.max(c[3],g)}static#t(e,n,s,i,a,r,o,l,f,c,h,u){if(Math.abs(f)<1e-12){Math.abs(c)>=1e-12&&this.#e(e,n,s,i,a,r,o,l,-h/c,u);return}const d=c**2-4*h*f;if(d<0)return;const m=Math.sqrt(d),g=2*f;this.#e(e,n,s,i,a,r,o,l,(-c+m)/g,u),this.#e(e,n,s,i,a,r,o,l,(-c-m)/g,u)}static bezierBoundingBox(e,n,s,i,a,r,o,l,f){f[0]=Math.min(f[0],e,o),f[1]=Math.min(f[1],n,l),f[2]=Math.max(f[2],e,o),f[3]=Math.max(f[3],n,l),this.#t(e,s,a,o,n,i,r,l,3*(-e+3*(s-a)+o),6*(e-2*s+a),3*(s-e),f),this.#t(e,s,a,o,n,i,r,l,3*(-n+3*(i-r)+l),6*(n-2*i+r),3*(i-n),f)}}function y6(t){return decodeURIComponent(escape(t))}p(y6,"stringToUTF8String");let eh=null,fp=null;function cp(t){return eh||(eh=/([\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,fp=new Map([["\uFB05","\u017Ft"]])),t.replaceAll(eh,(e,n,s)=>n?n.normalize("NFKC"):fp.get(s))}p(cp,"normalizeUnicode");function th(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),b6(t)}p(th,"getUuid");const hr="pdfjs_internal_id_";function j6(t,e,n){if(!Array.isArray(n)||n.length<2)return!1;const[s,i,...a]=n;if(!t(s)&&!Number.isInteger(s)||!e(i))return!1;const r=a.length;let o=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;o=!1;break;default:return!1}for(const l of a)if(!(typeof l=="number"||o&&l===null))return!1;return!0}p(j6,"_isValidExplicitDest");const g0=p(()=>[],"makeArr"),b0=p(()=>new Map,"makeMap"),w0=p(()=>Object.create(null),"makeObj");function hn(t,e,n){return Math.min(Math.max(t,e),n)}p(hn,"MathClamp"),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(t){return t.reduce((e,n)=>e+n,0)});class Yo{static{p(this,"XfaText")}static textContent(e){const n=[],s={items:n,styles:Object.create(null)};function i(a){if(!a)return;let r=null;const o=a.name;if(o==="#text")r=a.value;else if(Yo.shouldBuildText(o))a?.attributes?.textContent?r=a.attributes.textContent:a.value&&(r=a.value);else return;if(r!==null&&n.push({str:r}),!!a.children)for(const l of a.children)i(l)}return p(i,"walk"),i(e),s}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class nh{static{p(this,"XfaLayer")}static setupStorage(e,n,s,i,a){const r=i.getValue(n,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(e.textContent=r.value),a==="print")break;e.addEventListener("input",o=>{i.setValue(n,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?e.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&e.removeAttribute("checked"),a==="print")break;e.addEventListener("change",o=>{i.setValue(n,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&e.setAttribute("value",r.value),a==="print")break;e.addEventListener("input",o=>{i.setValue(n,{value:o.target.value})})}break;case"select":if(r.value!==null){e.setAttribute("value",r.value);for(const o of s.children)o.attributes.value===r.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}e.addEventListener("input",o=>{const l=o.target.options,f=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(n,{value:f})});break}}static setAttributes({html:e,element:n,storage:s=null,intent:i,linkService:a}){const{attributes:r}=n,o=e instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[l,f]of Object.entries(r))if(f!=null)switch(l){case"class":f.length&&e.setAttribute(l,f.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",f);break;case"style":Object.assign(e.style,f);break;case"textContent":e.textContent=f;break;default:(!o||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,f)}o&&a.addLinkAttributes(e,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(e,r.dataId,n,s)}static render(e){const n=e.annotationStorage,s=e.linkService,i=e.xfaHtml,a=e.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:a,linkService:s});const o=a!=="richText",l=e.div;if(l.append(r),e.viewport){const h=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=h}o&&l.setAttribute("class","xfaLayer xfaFont");const f=[];if(i.children.length===0){if(i.value){const h=document.createTextNode(i.value);r.append(h),o&&Yo.shouldBuildText(i.name)&&f.push(h)}return{textDivs:f}}const c=[[i,-1,r]];for(;c.length>0;){const[h,u,d]=c.at(-1);if(u+1===h.children.length){c.pop();continue}const m=h.children[++c.at(-1)[1]];if(m===null)continue;const{name:g}=m;if(g==="#text"){const w=document.createTextNode(m.value);f.push(w),d.append(w);continue}const b=m?.attributes?.xmlns?document.createElementNS(m.attributes.xmlns,g):document.createElement(g);if(d.append(b),m.attributes&&this.setAttributes({html:b,element:m,storage:n,intent:a,linkService:s}),m.children?.length>0)c.push([m,-1,b]);else if(m.value){const w=document.createTextNode(m.value);o&&Yo.shouldBuildText(g)&&f.push(w),b.append(w)}}for(const h of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))h.setAttribute("readOnly",!0);return{textDivs:f}}static update(e){const n=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=n,e.div.hidden=!1}}const Ai="http://www.w3.org/2000/svg";class Ea{static{p(this,"PixelsPerInch")}static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function x0(t,e="text"){if(_o(t,document.baseURI)){const n=await fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"blob":return n.blob();case"bytes":return n.bytes();case"json":return n.json()}return n.text()}return new Promise((n,s)=>{const i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e==="bytes"?"arraybuffer":e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(e){case"bytes":n(new Uint8Array(i.response));return;case"blob":case"json":n(i.response);return}n(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}p(x0,"fetchData");class Qo{static{p(this,"PageViewport")}constructor({viewBox:e,userUnit:n,scale:s,rotation:i,offsetX:a=0,offsetY:r=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=n,this.scale=s,this.rotation=i,this.offsetX=a,this.offsetY=r,s*=n;const l=(e[2]+e[0])/2,f=(e[3]+e[1])/2;let c,h,u,d;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,h=0,u=0,d=1;break;case 90:c=0,h=1,u=1,d=0;break;case 270:c=0,h=-1,u=-1,d=0;break;case 0:c=1,h=0,u=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d);let m,g,b,w;c===0?(m=Math.abs(f-e[1])*s+a,g=Math.abs(l-e[0])*s+r,b=(e[3]-e[1])*s,w=(e[2]-e[0])*s):(m=Math.abs(l-e[0])*s+a,g=Math.abs(f-e[1])*s+r,b=(e[2]-e[0])*s,w=(e[3]-e[1])*s),this.transform=[c*s,h*s,u*s,d*s,m-c*s*l-u*s*f,g-h*s*l-d*s*f],this.width=b,this.height=w}get rawDims(){const e=this.viewBox;return st(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:n=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new Qo({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:n,offsetX:s,offsetY:i,dontFlip:a})}convertToViewportPoint(e,n){const s=[e,n];return Ie.applyTransform(s,this.transform),s}convertToViewportRectangle(e){const n=[e[0],e[1]];Ie.applyTransform(n,this.transform);const s=[e[2],e[3]];return Ie.applyTransform(s,this.transform),[n[0],n[1],s[0],s[1]]}convertToPdfPoint(e,n){const s=[e,n];return Ie.applyInverseTransform(s,this.transform),s}}class k0 extends Ta{static{p(this,"RenderingCancelledException")}constructor(e,n=0){super(e,"RenderingCancelledException"),this.extraDelay=n}}function Ro(t){const e=t.length;let n=0;for(;n<e&&t[n].trim()==="";)n++;return t.substring(n,n+5).toLowerCase()==="data:"}p(Ro,"isDataScheme");function y0(t){return typeof t=="string"&&/\.pdf$/i.test(t)}p(y0,"isPdfFile");function hp(t){return[t]=t.split(/[#?]/,1),Qc(t)}p(hp,"getFilenameFromUrl");function up(t,e="document.pdf"){if(typeof t!="string")return e;if(Ro(t))return at('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const s=p(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}},"getURL")(t);if(!s)return e;const i=p(o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=Qc(l),/^\.pdf$/i.test(l))?o:l}catch{return o}},"decode"),a=/\.pdf$/i,r=Qc(s.pathname);if(a.test(r))return i(r);if(s.searchParams.size>0){const o=p(f=>[...f].findLast(c=>a.test(c)),"getLast"),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return e}p(up,"getPdfFilenameFromUrl");class dp{static{p(this,"StatTimer")}#e=new Map;times=[];time(e){this.#e.has(e)&&at(`Timer is already running for ${e}`),this.#e.set(e,Date.now())}timeEnd(e){this.#e.has(e)||at(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.#e.get(e),end:Date.now()}),this.#e.delete(e)}toString(){const e=Math.max(...this.times.map(n=>n.name.length));return this.times.map(n=>`${n.name.padEnd(e)} ${n.end-n.start}ms
54
- `).join("")}}function _o(t,e){const n=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(n?.protocol??"")}p(_o,"isValidFetchUrl");function ms(t){t.preventDefault()}p(ms,"noContextMenu");function Nt(t){t.preventDefault(),t.stopPropagation()}p(Nt,"stopEvent");function v6(t){console.log("Deprecated API usage: "+t)}p(v6,"deprecated");class j0{static{p(this,"PDFDateString")}static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;this.#e||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const n=this.#e.exec(e);if(!n)return null;const s=parseInt(n[1],10);let i=parseInt(n[2],10);i=i>=1&&i<=12?i-1:0;let a=parseInt(n[3],10);a=a>=1&&a<=31?a:1;let r=parseInt(n[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(n[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const f=n[7]||"Z";let c=parseInt(n[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(n[9],10)||0;return h=h>=0&&h<=59?h:0,f==="-"?(r+=c,o+=h):f==="+"&&(r-=c,o-=h),new Date(Date.UTC(s,i,a,r,o,l))}}function pp(t,{scale:e=1,rotation:n=0}){const{width:s,height:i}=t.attributes.style,a=[0,0,parseInt(s),parseInt(i)];return new Qo({viewBox:a,userUnit:1,scale:e,rotation:n})}p(pp,"getXfaPageViewport");function ur(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",",3).map(e=>parseInt(e)):(at(`Not a valid color format: "${t}"`),[0,0,0])}p(ur,"getRGB");function q6(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const s=window.getComputedStyle(e).color;t.set(n,ur(s))}e.remove()}p(q6,"getColorValues");function zt(t){const{a:e,b:n,c:s,d:i,e:a,f:r}=t.getTransform();return[e,n,s,i,a,r]}p(zt,"getCurrentTransform");function si(t){const{a:e,b:n,c:s,d:i,e:a,f:r}=t.getTransform().invertSelf();return[e,n,s,i,a,r]}p(si,"getCurrentTransformInverse");function Ki(t,e,n=!1,s=!0){if(e instanceof Qo){const{pageWidth:i,pageHeight:a}=e.rawDims,{style:r}=t,o=rn.isCSSRoundSupported,l=`var(--total-scale-factor) * ${i}px`,f=`var(--total-scale-factor) * ${a}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,h=o?`round(down, ${f}, var(--scale-round-y))`:`calc(${f})`;!n||e.rotation%180===0?(r.width=c,r.height=h):(r.width=h,r.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}p(Ki,"setLayerDimensions");class Ws{static{p(this,"OutputScale")}constructor(){const{pixelRatio:e}=Ws;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,n,s,i,a=-1){let r=1/0,o=1/0,l=1/0;s=Ws.capPixels(s,a),s>0&&(r=Math.sqrt(s/(e*n))),i!==-1&&(o=i/e,l=i/n);const f=Math.min(r,o,l);return this.sx>f||this.sy>f?(this.sx=f,this.sy=f,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,n){if(n>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+n/100));return e>0?Math.min(e,s):s}return e}}const v0=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class A6{static{p(this,"ColorScheme")}static get isDarkMode(){return st(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class mp{static{p(this,"CSSConstants")}static get commentForegroundColor(){const e=document.createElement("span");e.classList.add("comment","sidebar");const{style:n}=e;n.width=n.height="0",n.display="none",n.color="var(--comment-fg-color)",document.body.append(e);const{color:s}=window.getComputedStyle(e);return e.remove(),st(this,"commentForegroundColor",ur(s))}}function gp(t,e){e=hn(e??1,0,1);const n=255*(1-e);return t.map(s=>Math.round(s*e+n))}p(gp,"applyOpacity");function bp(t,e){const n=t[0]/255,s=t[1]/255,i=t[2]/255,a=Math.max(n,s,i),r=Math.min(n,s,i),o=(a+r)/2;if(a===r)e[0]=e[1]=0;else{const l=a-r;switch(e[1]=o<.5?l/(a+r):l/(2-a-r),a){case n:e[0]=((s-i)/l+(s<i?6:0))*60;break;case s:e[0]=((i-n)/l+2)*60;break;case i:e[0]=((n-s)/l+4)*60;break}}e[2]=o}p(bp,"RGBToHSL");function sh(t,e){const n=t[0],s=t[1],i=t[2],a=(1-Math.abs(2*i-1))*s,r=a*(1-Math.abs(n/60%2-1)),o=i-a/2;switch(Math.floor(n/60)){case 0:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 1:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 2:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 3:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 4:e[0]=r+o,e[1]=o,e[2]=a+o;break;case 5:case 6:e[0]=a+o,e[1]=o,e[2]=r+o;break}}p(sh,"HSLToRGB");function wp(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}p(wp,"computeLuminance");function xp(t,e,n){sh(t,n),n.map(wp);const s=.2126*n[0]+.7152*n[1]+.0722*n[2];sh(e,n),n.map(wp);const i=.2126*n[0]+.7152*n[1]+.0722*n[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}p(xp,"contrastRatio");const kp=new Map;function yp(t,e){const n=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let s=kp.get(n);if(s)return s;const i=new Float32Array(9),a=i.subarray(0,3),r=i.subarray(3,6);bp(t,r);const o=i.subarray(6,9);bp(e,o);const l=o[2]<.5,f=l?12:4.5;if(r[2]=l?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),xp(r,o,a)<f){let c,h;l?(c=r[2],h=1):(c=0,h=r[2]);const u=.005;for(;h-c>u;){const d=r[2]=(c+h)/2;l===xp(r,o,a)<f?c=d:h=d}r[2]=l?h:c}return sh(r,a),s=Ie.makeHexColor(Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255)),kp.set(n,s),s}p(yp,"findContrastColor");function ih({html:t,dir:e,className:n},s){const i=document.createDocumentFragment();if(typeof t=="string"){const a=document.createElement("p");a.dir=e||"auto";const r=t.split(/(?:\r\n?|\n)/);for(let o=0,l=r.length;o<l;++o){const f=r[o];a.append(document.createTextNode(f)),o<l-1&&a.append(document.createElement("br"))}i.append(a)}else nh.render({xfaHtml:t,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",n),s.append(i)}p(ih,"renderRichText");function jp(t){const e=new Path2D;if(!t)return e;for(let n=0,s=t.length;n<s;)switch(t[n++]){case Fo.moveTo:e.moveTo(t[n++],t[n++]);break;case Fo.lineTo:e.lineTo(t[n++],t[n++]);break;case Fo.curveTo:e.bezierCurveTo(t[n++],t[n++],t[n++],t[n++],t[n++],t[n++]);break;case Fo.quadraticCurveTo:e.quadraticCurveTo(t[n++],t[n++],t[n++],t[n++]);break;case Fo.closePath:e.closePath();break;default:at(`Unrecognized drawing path operator: ${t[n-1]}`);break}return e}p(jp,"makePathFromDrawOPS");class Jo{static{p(this,"EditorToolbar")}#e=null;#t=null;#n;#s=null;#i=null;#a=null;#r=null;#o=null;static#l=null;constructor(e){this.#n=e,Jo.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const e=this.#e=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=this.#n._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(e.addEventListener("contextmenu",ms,{signal:n}),e.addEventListener("pointerdown",Jo.#f,{signal:n}));const s=this.#s=document.createElement("div");s.className="buttons",e.append(s);const i=this.#n.toolbarPosition;if(i){const{style:a}=e,r=this.#n._uiManager.direction==="ltr"?1-i[0]:i[0];a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return this.#e}static#f(e){e.stopPropagation()}#u(e){this.#n._focusEventsAllowed=!1,Nt(e)}#c(e){this.#n._focusEventsAllowed=!0,Nt(e)}#d(e){const n=this.#n._uiManager._signal;return!(n instanceof AbortSignal)||n.aborted?!1:(e.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:n}),e.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:n}),e.addEventListener("contextmenu",ms,{signal:n}),!0)}hide(){this.#e.classList.add("hidden"),this.#t?.hideDropdown()}show(){this.#e.classList.remove("hidden"),this.#i?.shown(),this.#a?.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=this.#n,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",Jo.#l[e]),this.#d(s)&&s.addEventListener("click",i=>{n.delete()},{signal:n._signal}),this.#s.append(s)}get#g(){const e=document.createElement("div");return e.className="divider",e}async addAltText(e){const n=await e.render();this.#d(n),this.#s.append(n,this.#g),this.#i=e}addComment(e,n=null){if(this.#a)return;const s=e.renderForToolbar();if(!s)return;this.#d(s);const i=this.#r=this.#g;n?(this.#s.insertBefore(s,n),this.#s.insertBefore(i,n)):this.#s.append(s,i),this.#a=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;const n=e.renderButton();this.#d(n),this.#s.append(n,this.#g)}async addEditSignatureButton(e){const n=this.#o=await e.renderEditButton(this.#n);this.#d(n),this.#s.append(n,this.#g)}removeButton(e){e==="comment"&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null)}async addButton(e,n){switch(e){case"colorPicker":n&&this.addColorPicker(n);break;case"altText":n&&await this.addAltText(n);break;case"editSignature":n&&await this.addEditSignatureButton(n);break;case"delete":this.addDeleteButton();break;case"comment":n&&this.addComment(n);break}}async addButtonBefore(e,n,s){if(!n&&e==="comment")return;const i=this.#s.querySelector(s);i&&e==="comment"&&this.addComment(n,i)}updateEditSignatureButton(e){this.#o&&(this.#o.title=e)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}}class S6{static{p(this,"FloatingToolbar")}#e=null;#t=null;#n;constructor(e){this.#n=e}#s(){const e=this.#t=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar");const n=this.#n._signal;n instanceof AbortSignal&&!n.aborted&&e.addEventListener("contextmenu",ms,{signal:n});const s=this.#e=document.createElement("div");return s.className="buttons",e.append(s),this.#n.hasCommentManager()&&this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#n.commentSelection("floating_button")}),this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#n.highlightSelection("floating_button")}),e}#i(e,n){let s=0,i=0;for(const a of e){const r=a.y+a.height;if(r<s)continue;const o=a.x+(n?a.width:0);if(r>s){i=o,s=r;continue}n?o>i&&(i=o):o<i&&(i=o)}return[n?1-i:i,s]}show(e,n,s){const[i,a]=this.#i(n,s),{style:r}=this.#t||=this.#s();e.append(this.#t),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(e,n,s,i){const a=document.createElement("button");a.classList.add("basic",e),a.tabIndex=0,a.setAttribute("data-l10n-id",n);const r=document.createElement("span");a.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);const o=this.#n._signal;o instanceof AbortSignal&&!o.aborted&&(a.addEventListener("contextmenu",ms,{signal:o}),a.addEventListener("click",i,{signal:o})),this.#e.append(a)}}function vp(t,e,n){for(const s of n)e.addEventListener(s,t[s].bind(t))}p(vp,"bindEvents");class St{static{p(this,"CurrentPointers")}static#e=NaN;static#t=null;static#n=NaN;static#s=null;static initializeAndAddPointerId(e){(St.#t||=new Set).add(e)}static setPointer(e,n){St.#e||=n,St.#s??=e}static setTimeStamp(e){St.#n=e}static isSamePointerId(e){return St.#e===e}static isSamePointerIdOrRemove(e){return St.#e===e?!0:(St.#t?.delete(e),!1)}static isSamePointerType(e){return St.#s===e}static isInitializedAndDifferentPointerType(e){return St.#s!==null&&!St.isSamePointerType(e)}static isSameTimeStamp(e){return St.#n===e}static isUsingMultiplePointers(){return St.#t?.size>=1}static clearPointerType(){St.#s=null}static clearPointerIds(){St.#e=NaN,St.#t=null}static clearTimeStamp(){St.#n=NaN}}class C6{static{p(this,"IdManager")}#e=0;get id(){return`${Io}${this.#e++}`}}class qh{static{p(this,"ImageManager")}#e=th();#t=0;#n=null;static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;const a=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return st(this,"_isSVGFittingCanvas",a)}async#s(e,n){this.#n||=new Map;let s=this.#n.get(e);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let i;if(typeof n=="string"?(s.url=n,i=await x0(n,"blob")):n instanceof File?i=s.file=n:n instanceof Blob&&(i=n),i.type==="image/svg+xml"){const a=qh._isSVGFittingCanvas,r=new FileReader,o=new Image,l=new Promise((f,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,f()},r.onload=async()=>{const h=s.svgUrl=r.result;o.src=await a?`${h}#svgView(preserveAspectRatio(none))`:h},o.onerror=r.onerror=c});r.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){at(i),s=null}return this.#n.set(e,s),s&&this.#n.set(s.id,s),s}async getFromFile(e){const{lastModified:n,name:s,size:i,type:a}=e;return this.#s(`${n}_${s}_${i}_${a}`,e)}async getFromUrl(e){return this.#s(e,e)}async getFromBlob(e,n){const s=await n;return this.#s(e,s)}async getFromId(e){this.#n||=new Map;const n=this.#n.get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:s}=n;return delete n.blobPromise,this.getFromBlob(n.id,s)}return this.getFromUrl(n.url)}getFromCanvas(e,n){this.#n||=new Map;let s=this.#n.get(e);if(s?.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(n.width,n.height);return i.getContext("2d").drawImage(n,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,s),this.#n.set(s.id,s),s}getSvgUrl(e){const n=this.#n.get(e);return n?.isSvg?n.svgUrl:null}deleteId(e){this.#n||=new Map;const n=this.#n.get(e);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:s}=n;if(!n.url&&!n.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),n.blobPromise=i.convertToBlob()}s.close?.(),n.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}}class I6{static{p(this,"CommandManager")}#e=[];#t=!1;#n;#s=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:n,post:s,mustExec:i,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(i&&e(),this.#t)return;const l={cmd:e,undo:n,post:s,type:a};if(this.#s===-1){this.#e.length>0&&(this.#e.length=0),this.#s=0,this.#e.push(l);return}if(r&&this.#e[this.#s].type===a){o&&(l.undo=this.#e[this.#s].undo),this.#e[this.#s]=l;return}const f=this.#s+1;f===this.#n?this.#e.splice(0,1):(this.#s=f,f<this.#e.length&&this.#e.splice(f)),this.#e.push(l)}undo(){if(this.#s===-1)return;this.#t=!0;const{undo:e,post:n}=this.#e[this.#s];e(),n?.(),this.#t=!1,this.#s-=1}redo(){if(this.#s<this.#e.length-1){this.#s+=1,this.#t=!0;const{cmd:e,post:n}=this.#e[this.#s];e(),n?.(),this.#t=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#e.length-1}cleanType(e){if(this.#s!==-1){for(let n=this.#s;n>=0;n--)if(this.#e[n].type!==e){this.#e.splice(n+1,this.#s-n),this.#s=n;return}this.#e.length=0,this.#s=-1}}destroy(){this.#e=null}}class Po{static{p(this,"KeyboardManager")}constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=rn.platform;for(const[s,i,a={}]of e)for(const r of s){const o=r.startsWith("mac+");n&&o?(this.callbacks.set(r.slice(4),{callback:i,options:a}),this.allKeys.add(r.split("+").at(-1))):!n&&!o&&(this.callbacks.set(r,{callback:i,options:a}),this.allKeys.add(r.split("+").at(-1)))}}#e(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const n=this.buffer.join("+");return this.buffer.length=0,n}exec(e,n){if(!this.allKeys.has(n.key))return;const s=this.callbacks.get(this.#e(n));if(!s)return;const{callback:i,options:{bubbles:a=!1,args:r=[],checker:o=null}}=s;o&&!o(e,n)||(i.bind(e,...r,n)(),a||Nt(n))}}class Ah{static{p(this,"ColorManager")}static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return q6(e),st(this,"_colors",e)}convert(e){const n=ur(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[s,i]of this._colors)if(i.every((a,r)=>a===n[r]))return Ah._colorsMapping.get(s);return n}getHexCode(e){const n=this._colors.get(e);return n?Ie.makeHexColor(...n):e}}class Si{static{p(this,"AnnotationEditorUIManager")}#e=new AbortController;#t=null;#n=null;#s=new Map;#i=new Map;#a=null;#r=null;#o=null;#l=null;#f=new I6;#u=null;#c=null;#d=null;#g=0;#m=new Set;#h=null;#p=null;#b=new Set;_editorUndoBar=null;#y=!1;#x=!1;#v=!1;#C=null;#w=null;#q=null;#j=null;#S=!1;#T=null;#E=new C6;#I=!1;#R=!1;#F=!1;#B=null;#_=null;#M=null;#H=null;#z=null;#A=et.NONE;#k=new Set;#D=null;#O=null;#G=null;#X=null;#V=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#W=null;#$=null;#Z=null;#ee=null;#N=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=Si.prototype,n=p(r=>r.#$.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),"arrowChecker"),s=p((r,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},"textInputChecker"),i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return st(this,"_keyboardManager",new Po([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.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"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:p((r,{target:o})=>!(o instanceof HTMLButtonElement)&&r.#$.contains(o)&&!r.isEnterHandled,"checker")}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:p((r,{target:o})=>!(o instanceof HTMLButtonElement)&&r.#$.contains(document.activeElement),"checker")}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,n,s,i,a,r,o,l,f,c,h,u,d,m,g,b){const w=this._signal=this.#e.signal;this.#$=e,this.#Z=n,this.#ee=s,this.#r=i,this.#u=a,this.#O=r,this.#V=l,this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",x=>this.updateParams(x.type,x.value),{signal:w}),window.addEventListener("pointerdown",()=>{this.#R=!0},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{this.#R=!1},{capture:!0,signal:w}),window.addEventListener("beforeunload",this.#ae.bind(this),{capture:!0,signal:w}),this.#le(),this.#pe(),this.#ne(),this.#o=l.annotationStorage,this.#C=l.filterFactory,this.#G=f,this.#j=c||null,this.#y=h,this.#x=u,this.#v=d,this.#z=m||null,this.viewParameters={realScale:Ea.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=b!==!1,a?.setSidebarUiManager(this)}destroy(){this.#N?.resolve(),this.#N=null,this.#e?.abort(),this.#e=null,this._signal=null;for(const e of this.#i.values())e.destroy();this.#i.clear(),this.#s.clear(),this.#b.clear(),this.#H?.clear(),this.#t=null,this.#k.clear(),this.#f.destroy(),this.#r?.destroy(),this.#u?.destroy(),this.#O?.destroy(),this.#T?.hide(),this.#T=null,this.#M?.destroy(),this.#M=null,this.#n=null,this.#w&&(clearTimeout(this.#w),this.#w=null),this.#W&&(clearTimeout(this.#W),this.#W=null),this._editorUndoBar?.destroy(),this.#V=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#z}get useNewAltTextFlow(){return this.#x}get useNewAltTextWhenAddingImage(){return this.#v}get hcmFilter(){return st(this,"hcmFilter",this.#G?this.#C.addHCMFilter(this.#G.foreground,this.#G.background):"none")}get direction(){return st(this,"direction",getComputedStyle(this.#$).direction)}get _highlightColors(){return st(this,"_highlightColors",this.#j?new Map(this.#j.split(",").map(e=>(e=e.split("=").map(n=>n.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return st(this,"highlightColors",null);const n=new Map,s=!!this.#G;for(const[i,a]of e){const r=i.endsWith("_HCM");if(s&&r){n.set(i.replace("_HCM",""),a);continue}!s&&!r&&n.set(i,a)}return st(this,"highlightColors",n)}get highlightColorNames(){return st(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const n=this.highlightColorNames.get(e);return this._highlightColors.get(n)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#d=e}setMainHighlightColorPicker(e){this.#M=e}editAltText(e,n=!1){this.#r?.editAltText(this,e,n)}hasCommentManager(){return!!this.#u}editComment(e,n,s,i){this.#u?.showDialog(this,e,n,s,i)}selectComment(e,n){this.#i.get(e)?.getEditorByUID(n)?.toggleComment(!0,!0)}updateComment(e){this.#u?.updateComment(e.getData())}updatePopupColor(e){this.#u?.updatePopupColor(e)}removeComment(e){this.#u?.removeComments([e.uid])}deleteComment(e,n){const s=p(()=>{e.comment=n},"undo"),i=p(()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),e.comment=null},"cmd");this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(e,n,s=void 0){this.#u?.toggleCommentPopup(e,n,s)}makeCommentColor(e,n){return e&&this.#u?.makeCommentColor(e,n)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(e){if(this.#i.has(e-1))return;const{resolve:n,promise:s}=Promise.withResolvers(),i=p(a=>{a.pageNumber===e&&(this._eventBus._off("editorsrendered",i),n())},"onEditorsRendered");this._eventBus.on("editorsrendered",i),await s}getSignature(e){this.#O?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#O}switchToMode(e,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,n){this._eventBus.dispatch("setpreference",{source:this,name:e,value:n})}onSetPreference({name:e,value:n}){e==="enableNewAltTextWhenAddingImage"&&(this.#v=n)}onPageChanging({pageNumber:e}){this.#g=e-1}deletePage(e){for(const n of this.getEditors(e))n.remove();this.#i.delete(e),this.#g===e&&(this.#g=0)}focusMainContainer(){this.#$.focus()}findParent(e,n){for(const s of this.#i.values()){const{x:i,y:a,width:r,height:o}=s.div.getBoundingClientRect();if(e>=i&&e<=i+r&&n>=a&&n<=a+o)return s}return null}disableUserSelect(e=!1){this.#Z.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#b.add(e)}removeShouldRescale(e){this.#b.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Ea.PDF_TO_CSS_UNITS;for(const n of this.#b)n.onScaleChanging();this.#d?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#J({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#te(e){const{currentLayer:n}=this;if(n.hasTextLayer(e))return n;for(const s of this.#i.values())if(s.hasTextLayer(e))return s;return null}highlightSelection(e="",n=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:a,focusNode:r,focusOffset:o}=s,l=s.toString(),c=this.#J(s).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;s.empty();const u=this.#te(c),d=this.#A===et.NONE,m=p(()=>{const g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:h,anchorNode:i,anchorOffset:a,focusNode:r,focusOffset:o,text:l});d&&this.showAllEditors("highlight",!0,!0),n&&g?.editComment()},"callback");if(d){this.switchToMode(et.HIGHLIGHT,m);return}m()}commentSelection(e=""){this.highlightSelection(e,!0)}#ae(e){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#re(){const e=document.getSelection();if(!e||e.isCollapsed)return;const s=this.#J(e).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#T||=new S6(this),this.#T.show(s,i,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#o)return null;const n=`${Io}${e}`,s=this.#o.getRawValue(n);return s&&this.#o.remove(n),s}addToAnnotationStorage(e){!e.isEmpty()&&this.#o&&!this.#o.has(e.id)&&this.#o.setValue(e.id,e)}a11yAlert(e,n=null){const s=this.#ee;s&&(s.setAttribute("data-l10n-id",e),n?s.setAttribute("data-l10n-args",JSON.stringify(n)):s.removeAttribute("data-l10n-args"))}#oe(){const e=document.getSelection();if(!e||e.isCollapsed){this.#D&&(this.#T?.hide(),this.#D=null,this.#P({hasSelectedText:!1}));return}const{anchorNode:n}=e;if(n===this.#D)return;const i=this.#J(e).closest(".textLayer");if(!i){this.#D&&(this.#T?.hide(),this.#D=null,this.#P({hasSelectedText:!1}));return}if(this.#T?.hide(),this.#D=n,this.#P({hasSelectedText:!0}),!(this.#A!==et.HIGHLIGHT&&this.#A!==et.NONE)&&(this.#A===et.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){const a=this.#A===et.HIGHLIGHT?this.#te(i):null;if(a?.toggleDrawing(),this.#R){const r=new AbortController,o=this.combinedSignal(r),l=p(f=>{f.type==="pointerup"&&f.button!==0||(r.abort(),a?.toggleDrawing(!0),f.type==="pointerup"&&this.#Y("main_toolbar"))},"pointerup");window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}else a?.toggleDrawing(!0),this.#Y("main_toolbar")}}#Y(e=""){this.#A===et.HIGHLIGHT?this.highlightSelection(e):this.#y&&this.#re()}#le(){document.addEventListener("selectionchange",this.#oe.bind(this),{signal:this._signal})}#fe(){if(this.#q)return;this.#q=new AbortController;const e=this.combinedSignal(this.#q);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#ce(){this.#q?.abort(),this.#q=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#Y("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const n of this.#k)if(n.div.contains(e)){this.#_=[n,e],n._focusEventsAllowed=!1;break}}focus(){if(!this.#_)return;const[e,n]=this.#_;this.#_=null,n.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}#ne(){if(this.#B)return;this.#B=new AbortController;const e=this.combinedSignal(this.#B);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#he(){this.#B?.abort(),this.#B=null}#ue(){if(this.#c)return;this.#c=new AbortController;const e=this.combinedSignal(this.#c);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#de(){this.#c?.abort(),this.#c=null}#pe(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ne(),this.setEditingState(!0)}removeEditListeners(){this.#he(),this.setEditingState(!1)}dragOver(e){for(const{type:n}of e.dataTransfer.items)for(const s of this.#p)if(s.isHandlingMimeForPasting(n)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const n of e.dataTransfer.items)for(const s of this.#p)if(s.isHandlingMimeForPasting(n.type)){s.paste(n,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;const n=[];for(const s of this.#k){const i=s.serialize(!0);i&&n.push(i)}n.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:n}=e;for(const a of n.items)for(const r of this.#p)if(r.isHandlingMimeForPasting(a.type)){r.paste(a,this.currentLayer);return}let s=n.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){at(`paste: "${a.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const a=[];for(const l of s){const f=await i.deserialize(l);if(!f)return;a.push(f)}const r=p(()=>{for(const l of a)this.#se(l);this.#ie(a)},"cmd"),o=p(()=>{for(const l of a)l.remove()},"undo");this.addCommands({cmd:r,undo:o,mustExec:!0})}catch(a){at(`paste: "${a.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),this.#A!==et.NONE&&!this.isEditorHandlingKeyboard&&Si._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#Y("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(e,n){for(const i of this.getEditors(e))i.pageIndex=n;const s=this.#a.get(e);s&&(s.pageIndex=n,this.#i.set(n,s),this.#I?s.enable():s.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear()}endUpdatePages(){this.#a=null}clonePage(e,n){for(const s of this.getEditors(e)){const i=s.serialize(s.mode!==et.HIGHLIGHT);i&&(i.pageIndex=n,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#o.setValue(i.id,i))}}findClonesForPage(e){const n=[],{pageIndex:s}=e;for(const[i,a]of this.#o)a.pageIndex===s&&a.isClone&&(this.#o.remove(i),n.push(e.deserialize(a).then(r=>{r&&(r.isClone=!0,e.addOrRebuild(r))})));return Promise.all(n)}#P(e){Object.entries(e).some(([s,i])=>this.#K[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,e)}),this.#A===et.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#U([[gt.HIGHLIGHT_FREE,!0]]))}#U(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#fe(),this.#ue(),this.#P({isEditing:this.#A!==et.NONE,isEmpty:this.#Q(),hasSomethingToUndo:this.#f.hasSomethingToUndo(),hasSomethingToRedo:this.#f.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ce(),this.#de(),this.#P({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#p){this.#p=e;for(const n of this.#p)this.#U(n.defaultPropertiesToUpdate)}}getId(){return this.#E.id}get currentLayer(){return this.#i.get(this.#g)}getLayer(e){return this.#i.get(e)}get currentPageIndex(){return this.#g}addLayer(e){this.#i.set(e.pageIndex,e),this.#I?e.enable():e.disable()}removeLayer(e){this.#i.delete(e.pageIndex)}async updateMode(e,n=null,s=!1,i=!1,a=!1,r=!1){if(this.#A!==e&&!(this.#N&&(await this.#N.promise,!this.#N))){if(this.#N=Promise.withResolvers(),this.#d?.commitOrRemove(),this.#A===et.POPUP&&this.#u?.hideSidebar(),this.#u?.destroyPopup(),this.#A=e,e===et.NONE){this.setEditingState(!1),this.#ge();for(const o of this.#s.values())o.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#N.resolve();return}for(const o of this.#s.values())o.addStandaloneCommentButton();e===et.SIGNATURE&&await this.#O?.loadSignatures(),s&&St.clearPointerType(),this.setEditingState(!0),await this.#me(),this.unselectAll();for(const o of this.#i.values())o.updateMode(e);if(e===et.POPUP){this.#n||=await this.#V.getAnnotationsByType(new Set(this.#p.map(f=>f._editorType)));const o=new Set,l=[];for(const f of this.#s.values()){const{annotationElementId:c,hasComment:h,deleted:u}=f;c&&o.add(c),h&&!u&&l.push(f.getData())}for(const f of this.#n){const{id:c,popupRef:h,contentsObj:u}=f;h&&u?.str&&!o.has(c)&&!this.#m.has(c)&&l.push(f)}this.#u?.showSidebar(l)}if(!n){i&&this.addNewEditorFromKeyboard(),this.#N.resolve();return}for(const o of this.#s.values())o.uid===n?(this.setSelected(o),r?o.editComment():a?o.enterInEditMode():o.focus()):o.unselect();this.#N.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#A&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,n){if(this.#p){switch(e){case gt.CREATE:this.currentLayer.addNewEditor(n);return;case gt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#X||=new Map).set(e,n),this.showAllEditors("highlight",n);break}if(this.hasSelection)for(const s of this.#k)s.updateParams(e,n);else for(const s of this.#p)s.updateDefaultParams(e,n)}}showAllEditors(e,n,s=!1){for(const a of this.#s.values())a.editorType===e&&a.show(n);(this.#X?.get(gt.HIGHLIGHT_SHOW_ALL)??!0)!==n&&this.#U([[gt.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(e=!1){if(this.#F!==e){this.#F=e;for(const n of this.#i.values())e?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",e)}}async#me(){if(!this.#I){this.#I=!0;const e=[];for(const n of this.#i.values())e.push(n.enable());await Promise.all(e);for(const n of this.#s.values())n.enable()}}#ge(){if(this.unselectAll(),this.#I){this.#I=!1;for(const e of this.#i.values())e.disable();for(const e of this.#s.values())e.disable()}}*getEditors(e){for(const n of this.#s.values())n.pageIndex===e&&(yield n)}getEditor(e){return this.#s.get(e)}addEditor(e){this.#s.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.focusMainContainer(),this.#w=null},0)),this.#s.delete(e.id),e.annotationElementId&&this.#H?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#m.has(e.annotationElementId))&&this.#o?.remove(e.id)}addDeletedAnnotationElement(e){this.#m.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#m.has(e)}removeDeletedAnnotationElement(e){this.#m.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#se(e){const n=this.#i.get(e.pageIndex);n?n.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#U(e.propertiesToUpdate))}get#be(){let e=null;for(e of this.#k);return e}updateUI(e){this.#be===e&&this.#U(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#U(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#k.has(e)){this.#k.delete(e),e.unselect(),this.#P({hasSelectedEditor:this.hasSelection});return}this.#k.add(e),e.select(),this.#U(e.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#d?.commitOrRemove();for(const n of this.#k)n!==e&&n.unselect();this.#u?.destroyPopup(),this.#k.clear(),this.#k.add(e),e.select(),this.#U(e.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}isSelected(e){return this.#k.has(e)}get firstSelectedEditor(){return this.#k.values().next().value}unselect(e){e.unselect(),this.#k.delete(e),this.#P({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#k.size!==0}get isEnterHandled(){return this.#k.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#f.undo(),this.#P({hasSomethingToUndo:this.#f.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Q()}),this._editorUndoBar?.hide()}redo(){this.#f.redo(),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:this.#f.hasSomethingToRedo(),isEmpty:this.#Q()})}addCommands(e){this.#f.add(e),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Q()})}cleanUndoStack(e){this.#f.cleanType(e)}#Q(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const e of this.#s.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[...this.#k],s=p(()=>{this._editorUndoBar?.show(i,n.length===1?n[0].editorType:n.length);for(const a of n)a.remove()},"cmd"),i=p(()=>{for(const a of n)this.#se(a)},"undo");this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ie(e){for(const n of this.#k)n.unselect();this.#k.clear();for(const n of e)n.isEmpty()||(this.#k.add(n),n.select());this.#P({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#k)e.commit();this.#ie(this.#s.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#A!==et.NONE))&&!this.#d?.commitOrRemove()&&(this.#u?.destroyPopup(),!!this.hasSelection)){for(const e of this.#k)e.unselect();this.#k.clear(),this.#P({hasSelectedEditor:!1})}}translateSelectedEditors(e,n,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#L[0]+=e,this.#L[1]+=n;const[i,a]=this.#L,r=[...this.#k],o=1e3;this.#W&&clearTimeout(this.#W),this.#W=setTimeout(()=>{this.#W=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:p(()=>{for(const l of r)this.#s.has(l.id)&&(l.translateInPage(i,a),l.translationDone())},"cmd"),undo:p(()=>{for(const l of r)this.#s.has(l.id)&&(l.translateInPage(-i,-a),l.translationDone())},"undo"),mustExec:!1})},o);for(const l of r)l.translateInPage(e,n),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#h=new Map;for(const e of this.#k)this.#h.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#h)return!1;this.disableUserSelect(!1);const e=this.#h;this.#h=null;let n=!1;for(const[{x:i,y:a,pageIndex:r},o]of e)o.newX=i,o.newY=a,o.newPageIndex=r,n||=i!==o.savedX||a!==o.savedY||r!==o.savedPageIndex;if(!n)return!1;const s=p((i,a,r,o)=>{if(this.#s.has(i.id)){const l=this.#i.get(o);l?i._setParentAndPosition(l,a,r):(i.pageIndex=o,i.x=a,i.y=r)}},"move");return this.addCommands({cmd:p(()=>{for(const[i,{newX:a,newY:r,newPageIndex:o}]of e)s(i,a,r,o)},"cmd"),undo:p(()=>{for(const[i,{savedX:a,savedY:r,savedPageIndex:o}]of e)s(i,a,r,o)},"undo"),mustExec:!0}),!0}dragSelectedEditors(e,n){if(this.#h)for(const s of this.#h.keys())s.drag(e,n)}rebuild(e){if(e.parent===null){const n=this.getLayer(e.pageIndex);n?(n.changeParent(e),n.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#k.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#A}isEditingMode(){return this.#A!==et.NONE}get imageManager(){return st(this,"imageManager",new qh)}getSelectionBoxes(e){if(!e)return null;const n=document.getSelection();for(let f=0,c=n.rangeCount;f<c;f++)if(!e.contains(n.getRangeAt(f).commonAncestorContainer))return null;const{x:s,y:i,width:a,height:r}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=p((f,c,h,u)=>({x:(c-i)/r,y:1-(f+h-s)/a,width:u/r,height:h/a}),"rotator");break;case"180":o=p((f,c,h,u)=>({x:1-(f+h-s)/a,y:1-(c+u-i)/r,width:h/a,height:u/r}),"rotator");break;case"270":o=p((f,c,h,u)=>({x:1-(c+u-i)/r,y:(f-s)/a,width:u/r,height:h/a}),"rotator");break;default:o=p((f,c,h,u)=>({x:(f-s)/a,y:(c-i)/r,width:h/a,height:u/r}),"rotator");break}const l=[];for(let f=0,c=n.rangeCount;f<c;f++){const h=n.getRangeAt(f);if(!h.collapsed)for(const{x:u,y:d,width:m,height:g}of h.getClientRects())m===0||g===0||l.push(o(u,d,m,g))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:n}){(this.#l||=new Map).set(e,n)}removeChangedExistingAnnotation({annotationElementId:e}){this.#l?.delete(e)}renderAnnotationElement(e){const n=this.#l?.get(e.data.id);if(!n)return;const s=this.#o.getRawValue(n);s&&(this.#A===et.NONE&&!s.hasBeenModified||s.renderAnnotationElement(e))}setMissingCanvas(e,n,s){const i=this.#H?.get(e);i&&(i.setCanvas(n,s),this.#H.delete(e))}addMissingCanvas(e,n){(this.#H||=new Map).set(e,n)}}class oi{static{p(this,"AltText")}#e=null;#t=!1;#n=null;#s=null;#i=null;#a=null;#r=!1;#o=null;#l=null;#f=null;#u=null;#c=!1;static#d=null;static _l10n=null;constructor(e){this.#l=e,this.#c=e._uiManager.useNewAltTextFlow,oi.#d||=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(e){oi._l10n??=e}async render(){const e=this.#n=document.createElement("button");e.className="altText",e.tabIndex="0";const n=this.#s=document.createElement("span");e.append(n),this.#c?(e.classList.add("new"),e.setAttribute("data-l10n-id",oi.#d.missing),n.setAttribute("data-l10n-id",oi.#d["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#l._uiManager._signal;e.addEventListener("contextmenu",ms,{signal:s}),e.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const i=p(a=>{a.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#c&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})},"onClick");return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",a=>{a.target===e&&a.key==="Enter"&&(this.#r=!0,i(a))},{signal:s}),await this.#m(),e}get#g(){return this.#e&&"added"||this.#e===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#c?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#c?this.#e!==null||!!this.#f:this.isEmpty()}get guessedText(){return this.#f}async setGuessedText(e){this.#e===null&&(this.#f=e,this.#u=await oi._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#c||this.#e){this.#o?.remove(),this.#o=null;return}if(!this.#o){const n=this.#o=document.createElement("div");n.className="noAltTextBadge",this.#l.div.append(n)}this.#o.classList.toggle("hidden",!e)}serialize(e){let n=this.#e;return!e&&this.#f===n&&(n=this.#u),{altText:n,decorative:this.#t,guessedText:this.#f,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:n,guessedText:s,textWithDisclaimer:i,cancel:a=!1}){s&&(this.#f=s,this.#u=i),!(this.#e===e&&this.#t===n)&&(a||(this.#e=e,this.#t=n),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#n?.remove(),this.#n=null,this.#s=null,this.#i=null,this.#o?.remove(),this.#o=null}async#m(){const e=this.#n;if(!e)return;if(this.#c){if(e.classList.toggle("done",!!this.#e),e.setAttribute("data-l10n-id",oi.#d[this.#g]),this.#s?.setAttribute("data-l10n-id",oi.#d[`${this.#g}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){e.classList.remove("done"),this.#i?.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=this.#i;if(!n){this.#i=n=document.createElement("span"),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${this.#l.id}`;const i=100,a=this.#l._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:a}),e.addEventListener("mouseleave",()=>{this.#a&&(clearTimeout(this.#a),this.#a=null),this.#i?.classList.remove("show")},{signal:a})}this.#t?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=this.#e),n.parentNode||e.append(n),this.#l.getElementForAltText()?.setAttribute("aria-describedby",n.id)}}class q0{static{p(this,"Comment")}#e=null;#t=null;#n=!1;#s=null;#i=null;#a=null;#r=null;#o=null;#l=!1;#f=null;constructor(e){this.#s=e}renderForToolbar(){const e=this.#t=document.createElement("button");return e.className="comment",this.#u(e,!1)}renderForStandalone(){const e=this.#e=document.createElement("button");e.className="annotationCommentButton";const n=this.#s.commentButtonPosition;if(n){const{style:s}=e;s.insetInlineEnd=`calc(${100*(this.#s._uiManager.direction==="ltr"?1-n[0]:n[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*n[1]}% - var(--comment-button-dim))`;const i=this.#s.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;const e=this.#s.commentButtonColor;e&&(this.#e.style.backgroundColor=e),this.#s._uiManager.updatePopupColor(this.#s)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#s.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#f)return this.#f;if(!this.#e)return null;const{x:e,y:n,height:s}=this.#e.getBoundingClientRect(),{x:i,y:a,width:r,height:o}=this.#s.parent.boundingClientRect;return[(e-i)/r,(n+s-a)/o]}set commentPopupPositionInLayer(e){this.#f=e}hasDefaultPopupPosition(){return this.#f===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:n}){this.#e&&(this.#e.classList.toggle("selected",e),this.#e.ariaExpanded=n)}#u(e,n){if(!this.#s._uiManager.hasCommentManager())return null;e.tabIndex="0",e.ariaHasPopup="dialog",n?(e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(e.ariaControlsElements=[this.#s._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=this.#s._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return e;e.addEventListener("contextmenu",ms,{signal:s}),n&&(e.addEventListener("focusin",a=>{this.#s._focusEventsAllowed=!1,Nt(a)},{capture:!0,signal:s}),e.addEventListener("focusout",a=>{this.#s._focusEventsAllowed=!0,Nt(a)},{capture:!0,signal:s})),e.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const i=p(a=>{a.preventDefault(),e===this.#t?this.edit():this.#s.toggleComment(!0)},"onClick");return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",a=>{a.target===e&&a.key==="Enter"&&(this.#n=!0,i(a))},{signal:s}),e.addEventListener("pointerenter",()=>{this.#s.toggleComment(!1,!0)},{signal:s}),e.addEventListener("pointerleave",()=>{this.#s.toggleComment(!1,!1)},{signal:s}),e}edit(e){const n=this.commentPopupPositionInLayer;let s,i;if(n)[s,i]=n;else{[s,i]=this.#s.commentButtonPosition;const{width:c,height:h,x:u,y:d}=this.#s;s=u+s*c,i=d+i*h}const a=this.#s.parent.boundingClientRect,{x:r,y:o,width:l,height:f}=a;this.#s._uiManager.editComment(this.#s,r+s*l,o+i*f,{...e,parentDimensions:a})}finish(){this.#t&&(this.#t.focus({focusVisible:this.#n}),this.#n=!1)}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#i}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(e){if(e!==this.#r&&(this.#a=null),e===null){this.#r="",this.#l=!0;return}this.#r=e,this.#o=new Date,this.#l=!1}restoreData({text:e,richText:n,date:s}){this.#r=e,this.#a=n,this.#o=s,this.#l=!1}setInitialText(e,n=null){this.#i=e,this.data=e,this.#o=null,this.#a=n}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#r="",this.#a=null,this.#o=null,this.#s=null,this.#n=!1,this.#l=!1}}class Zo{static{p(this,"TouchManager")}#e;#t=!1;#n=null;#s;#i;#a;#r;#o=null;#l;#f=null;#u;#c=null;constructor({container:e,isPinchingDisabled:n=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:r=null,signal:o}){this.#e=e,this.#n=s,this.#s=n,this.#i=i,this.#a=a,this.#r=r,this.#u=new AbortController,this.#l=AbortSignal.any([o,this.#u.signal]),e.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#l})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ws.pixelRatio}#d(e){if(this.#s?.())return;if(e.touches.length===1){if(this.#o)return;const i=this.#o=new AbortController,a=AbortSignal.any([this.#l,i.signal]),r=this.#e,o={capture:!0,signal:a,passive:!1},l=p(f=>{f.pointerType==="touch"&&(this.#o?.abort(),this.#o=null)},"cancelPointerDown");r.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Nt(f),l(f))},o),r.addEventListener("pointerup",l,o),r.addEventListener("pointercancel",l,o);return}if(!this.#c){this.#c=new AbortController;const i=AbortSignal.any([this.#l,this.#c.signal]),a=this.#e,r={signal:i,capture:!1,passive:!1};a.addEventListener("touchmove",this.#g.bind(this),r);const o=this.#m.bind(this);a.addEventListener("touchend",o,r),a.addEventListener("touchcancel",o,r),r.capture=!0,a.addEventListener("pointerdown",Nt,r),a.addEventListener("pointermove",Nt,r),a.addEventListener("pointercancel",Nt,r),a.addEventListener("pointerup",Nt,r),this.#i?.()}if(Nt(e),e.touches.length!==2||this.#n?.()){this.#f=null;return}let[n,s]=e.touches;n.identifier>s.identifier&&([n,s]=[s,n]),this.#f={touch0X:n.screenX,touch0Y:n.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#g(e){if(!this.#f||e.touches.length!==2)return;Nt(e);let[n,s]=e.touches;n.identifier>s.identifier&&([n,s]=[s,n]);const{screenX:i,screenY:a}=n,{screenX:r,screenY:o}=s,l=this.#f,{touch0X:f,touch0Y:c,touch1X:h,touch1Y:u}=l,d=h-f,m=u-c,g=r-i,b=o-a,w=Math.hypot(g,b)||1,x=Math.hypot(d,m)||1;if(!this.#t&&Math.abs(x-w)<=Zo.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=a,l.touch1X=r,l.touch1Y=o,!this.#t){this.#t=!0;return}const y=[(i+r)/2,(a+o)/2];this.#a?.(y,x,w)}#m(e){e.touches.length>=2||(this.#c&&(this.#c.abort(),this.#c=null,this.#r?.()),this.#f&&(Nt(e),this.#f=null,this.#t=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#o?.abort(),this.#o=null}}class We{static{p(this,"AnnotationEditor")}#e=null;#t=null;#n=null;#s=null;#i=null;#a=!1;#r=null;#o="";#l=null;#f=null;#u=null;#c=null;#d=null;#g="";#m=!1;#h=null;#p=!1;#b=!1;#y=!1;#x=null;#v=0;#C=0;#w=null;#q=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#j=!1;#S=We._zIndex++;static _borderLineWidth=-1;static _colorManager=new Ah;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const e=We.prototype._resizeWithKeyboard,n=Si.TRANSLATE_SMALL,s=Si.TRANSLATE_BIG;return st(this,"_resizerKeyboardManager",new Po([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],We.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;const{rotation:n,rawDims:{pageWidth:s,pageHeight:i,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[a,r];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return st(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const n=new T6({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});n.annotationElementId=e.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(e,n){if(We._l10n??=e,We._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"}),We._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);We._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,n){It("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#j}set _isDraggable(e){this.#j=e,this.div?.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(e*2),this.y+=this.width*e/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(e*2),this.y-=this.width*e/(n*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#S}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):(this.#L(),this.#c?.remove(),this.#c=null),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(e){!this._focusEventsAllowed||!this.isAttachedToDOM||e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,n,s,i){const[a,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(e+s)/a,this.y=(n+i)/r,this.fixAndSetPosition()}_moveAfterPaste(e,n){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(e*s,n*i,this.width*s,this.height*i),this._onTranslated()}#T([e,n],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/e,this.y+=i/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,n){this.#T(this.parentDimensions,e,n)}translateInPage(e,n){this.#h||=[this.x,this.y,this.width,this.height],this.#T(this.pageDimensions,e,n),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,n){this.#h||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,a]}=this;if(this.x+=e/i,this.y+=n/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:o}=this;const[l,f]=this.getBaseTranslation();r+=l,o+=f;const{style:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(r,o),s.scrollIntoView({block:"nearest"})}_onTranslating(e,n){}_onTranslated(e,n){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:s}=We,i=s/e,a=s/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:n},pageDimensions:[s,i]}=this;let{x:a,y:r,width:o,height:l}=this;if(o*=s,l*=i,a*=s,r*=i,this._mustFixPosition)switch(e){case 0:a=hn(a,0,s-o),r=hn(r,0,i-l);break;case 90:a=hn(a,0,s-l),r=hn(r,o,i);break;case 180:a=hn(a,o,s),r=hn(r,l,i);break;case 270:a=hn(a,l,s),r=hn(r,0,i-o);break}this.x=a/=s,this.y=r/=i;const[f,c]=this.getBaseTranslation();a+=f,r+=c,n.left=`${(100*a).toFixed(2)}%`,n.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#E(e,n,s){switch(s){case 90:return[n,-e];case 180:return[-e,-n];case 270:return[-n,e];default:return[e,n]}}screenToPageTranslation(e,n){return We.#E(e,n,this.parentRotation)}pageTranslationToScreen(e,n){return We.#E(e,n,360-this.parentRotation)}#I(e){switch(e){case 90:{const[n,s]=this.pageDimensions;return[0,-n/s,s/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,s]=this.pageDimensions;return[0,n/s,-s/n,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[n,s]}=this;return[n*e,s*e]}setDims(){const{div:{style:e},width:n,height:s}=this;e.width=`${(100*n).toFixed(2)}%`,e.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#R(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const s of e){const i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#F.bind(this,s),{signal:n}),i.addEventListener("contextmenu",ms,{signal:n}),i.tabIndex=-1}this.div.prepend(this.#l)}#F(e,n){n.preventDefault();const{isMac:s}=rn.platform;if(n.button!==0||n.ctrlKey&&s)return;this.#n?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,this.#f=[n.screenX,n.screenY];const a=new AbortController,r=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#M.bind(this,e),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Nt,{passive:!1,signal:r}),window.addEventListener("contextmenu",ms,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const f=p(()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,this.#_()},"pointerUpCallback");window.addEventListener("pointerup",f,{signal:r}),window.addEventListener("blur",f,{signal:r})}#B(e,n,s,i){this.width=s,this.height=i,this.x=e,this.y=n,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#_(){if(!this.#u)return;const{savedX:e,savedY:n,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;const a=this.x,r=this.y,o=this.width,l=this.height;a===e&&r===n&&o===s&&l===i||this.addCommands({cmd:this.#B.bind(this,a,r,o,l),undo:this.#B.bind(this,e,n,s,i),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#M(e,n){const[s,i]=this.parentDimensions,a=this.x,r=this.y,o=this.width,l=this.height,f=We.MIN_SIZE/s,c=We.MIN_SIZE/i,h=this.#I(this.rotation),u=p((z,O)=>[h[0]*z+h[2]*O,h[1]*z+h[3]*O],"transf"),d=this.#I(360-this.rotation),m=p((z,O)=>[d[0]*z+d[2]*O,d[1]*z+d[3]*O],"invTransf");let g,b,w=!1,x=!1;switch(e){case"topLeft":w=!0,g=p((z,O)=>[0,0],"getPoint"),b=p((z,O)=>[z,O],"getOpposite");break;case"topMiddle":g=p((z,O)=>[z/2,0],"getPoint"),b=p((z,O)=>[z/2,O],"getOpposite");break;case"topRight":w=!0,g=p((z,O)=>[z,0],"getPoint"),b=p((z,O)=>[0,O],"getOpposite");break;case"middleRight":x=!0,g=p((z,O)=>[z,O/2],"getPoint"),b=p((z,O)=>[0,O/2],"getOpposite");break;case"bottomRight":w=!0,g=p((z,O)=>[z,O],"getPoint"),b=p((z,O)=>[0,0],"getOpposite");break;case"bottomMiddle":g=p((z,O)=>[z/2,O],"getPoint"),b=p((z,O)=>[z/2,0],"getOpposite");break;case"bottomLeft":w=!0,g=p((z,O)=>[0,O],"getPoint"),b=p((z,O)=>[z,0],"getOpposite");break;case"middleLeft":x=!0,g=p((z,O)=>[0,O/2],"getPoint"),b=p((z,O)=>[z,O/2],"getOpposite");break}const y=g(o,l),j=b(o,l);let v=u(...j);const q=We._round(a+v[0]),A=We._round(r+v[1]);let C=1,S=1,I,T;if(n.fromKeyboard)({deltaX:I,deltaY:T}=n);else{const{screenX:z,screenY:O}=n,[N,oe]=this.#f;[I,T]=this.screenToPageTranslation(z-N,O-oe),this.#f[0]=z,this.#f[1]=O}if([I,T]=m(I/s,T/i),w){const z=Math.hypot(o,l);C=S=Math.max(Math.min(Math.hypot(j[0]-y[0]-I,j[1]-y[1]-T)/z,1/o,1/l),f/o,c/l)}else x?C=hn(Math.abs(j[0]-y[0]-I),f,1)/o:S=hn(Math.abs(j[1]-y[1]-T),c,1)/l;const P=We._round(o*C),H=We._round(l*S);v=u(...b(P,H));const G=q-v[0],Z=A-v[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=P,this.height=H,this.x=G,this.y=Z,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#b)return this._editToolbar;this._editToolbar=new Jo(this),this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[n,s]of e)await this._editToolbar.addButton(n,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#n?.destroy()}addContainer(e){const n=this._editToolbar?.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(oi.initialize(We._l10n),this.#n=new oi(this),this.#e&&(this.#n.data=this.#e,this.#e=null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}focusCommentButton(){this.#s?.focusButton()}addCommentButton(){return this.canAddComment?this.#s||=new q0(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove("hidden");return}this.hasComment&&(this.#i=this.#s.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#s.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add("hidden")}get comment(){if(!this.#s)return null;const{data:{richText:e,text:n,date:s,deleted:i}}=this.#s;return{text:n,richText:e,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){this.#s||=new q0(this),typeof e=="object"&&e!==null?this.#s.restoreData(e):this.#s.data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:n,richText:s}){if(!n||(this.#s||=new q0(this),this.#s.setInitialText(e,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#s?.hasBeenEdited()}get hasDeletedComment(){return this.#s?.isDeleted()}get hasComment(){return!!this.#s&&!this.#s.isEmpty()&&!this.#s.isDeleted()}async editComment(e){this.#s||=new q0(this),this.#s.edit(e)}toggleComment(e,n=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,n)}setSelectedCommentButton(e){this.#s.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){const[,,,i]=e.rect,[a]=this.pageDimensions,[r]=this.pageTranslation,o=r+a+1,l=i-100,f=o+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,f,i]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:n}}){this.#s.data=n?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=this.#a?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),this.#O();const[n,s]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*s/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/s).toFixed(2)}%`);const[i,a]=this.getInitialTranslation();return this.translate(i,a),vp(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#q||=new Zo({container:e,isPinchingDisabled:p(()=>!this.isSelected,"isPinchingDisabled"),onPinchStart:this.#H.bind(this),onPinching:this.#z.bind(this),onPinchEnd:this.#A.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#H(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#z(e,n,s){let a=.7*(s/n)+1-.7;if(a===1)return;const r=this.#I(this.rotation),o=p((q,A)=>[r[0]*q+r[2]*A,r[1]*q+r[3]*A],"transf"),[l,f]=this.parentDimensions,c=this.x,h=this.y,u=this.width,d=this.height,m=We.MIN_SIZE/l,g=We.MIN_SIZE/f;a=Math.max(Math.min(a,1/u,1/d),m/u,g/d);const b=We._round(u*a),w=We._round(d*a);if(b===u&&w===d)return;this.#h||=[c,h,u,d];const x=o(u/2,d/2),y=We._round(c+x[0]),j=We._round(h+x[1]),v=o(b/2,w/2);this.x=y-v[0],this.y=j-v[1],this.width=b,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#A(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#_()}pointerdown(e){const{isMac:n}=rn.platform;if(e.button!==0||e.ctrlKey&&n){e.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#D(e);return}this.#k(e)}#k(e){const{isMac:n}=rn.platform;e.ctrlKey&&!n||e.shiftKey||e.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)}#D(e){const{isSelected:n}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,a=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:a},o=p(f=>{i.abort(),this.#r=null,this.#m=!1,this._uiManager.endDragSession()||this.#k(f),s&&this._onStopDragging()},"cancelDrag");n&&(this.#v=e.clientX,this.#C=e.clientY,this.#r=e.pointerId,this.#o=e.pointerType,window.addEventListener("pointermove",f=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:h,pointerId:u}=f;if(u!==this.#r){Nt(f);return}const[d,m]=this.screenToPageTranslation(c-this.#v,h-this.#C);this.#v=c,this.#C=h,this._uiManager.dragSelectedEditors(d,m)},r),window.addEventListener("touchmove",Nt,r),window.addEventListener("pointerdown",f=>{f.pointerType===this.#o&&(this.#q||f.isPrimary)&&o(f),Nt(f)},r));const l=p(f=>{if(!this.#r||this.#r===f.pointerId){o(f);return}Nt(f)},"pointerUpCallback");window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#x&&clearTimeout(this.#x),this.#x=setTimeout(()=>{this.#x=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,n,s){e.changeParent(this),this.x=n,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(e,n,s=this.rotation){const i=this.parentScale,[a,r]=this.pageDimensions,[o,l]=this.pageTranslation,f=e/i,c=n/i,h=this.x*a,u=this.y*r,d=this.width*a,m=this.height*r;switch(s){case 0:return[h+f+o,r-u-c-m+l,h+f+d+o,r-u-c+l];case 90:return[h+c+o,r-u+f+l,h+c+m+o,r-u+f+d+l];case 180:return[h-f-d+o,r-u+c+l,h-f+o,r-u+c+m+l];case 270:return[h-c-m+o,r-u-f-d+l,h-c+o,r-u-f+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,n){const[s,i,a,r]=e,o=a-s,l=r-i;switch(this.rotation){case 0:return[s,n-r,o,l];case 90:return[s,n-i,l,o];case 180:return[a,n-i,o,l];case 270:return[a,n-r,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&We._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#s?.onUpdatedColor()}getData(){const{comment:{text:e,color:n,date:s,opacity:i,deleted:a,richText:r},uid:o,pageIndex:l,creationDate:f,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:r,contentsObj:{str:e},creationDate:f,modificationDate:s||c,popupRef:!a,color:n,opacity:i}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#b=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#b=!1,!0):!1}isInEditMode(){return this.#b}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:n,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:a,innerWidth:r}=window;return n<r&&i>0&&e<a&&s>0}#O(){if(this.#d||!this.div)return;this.#d=new AbortController;const e=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#O()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,n=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(e,n,s){const i=new this.prototype.constructor({parent:n,id:s.getId(),uiManager:s,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});i.rotation=e.rotation,i.#e=e.accessibilityData,i._isCopy=e.isCopy||!1;const[a,r]=i.pageDimensions,[o,l,f,c]=i.getRectInCurrentCoords(e.rect,r);return i.x=o/a,i.y=l/r,i.width=f/a,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#x&&(clearTimeout(this.#x),this.#x=null),this.#L(),this.removeEditToolbar(),this.#w){for(const e of this.#w.values())clearTimeout(e);this.#w=null}this.parent=null,this.#q?.destroy(),this.#q=null,this.#c?.remove(),this.#c=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#R(),this.#l.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,n]}=this,[s,i,a,r]=this.getPDFRect();return[We._round(s+(a-s)*e),We._round(i+(r-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#s.commentPopupPositionInLayer}set commentPopupPosition(e){this.#s.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#s.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#s.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#s?.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const n=this.#l.children;if(!this.#t){this.#t=Array.from(n);const r=this.#G.bind(this),o=this.#X.bind(this),l=this._uiManager._signal;for(const f of this.#t){const c=f.getAttribute("data-resizer-name");f.setAttribute("role","spinbutton"),f.addEventListener("keydown",r,{signal:l}),f.addEventListener("blur",o,{signal:l}),f.addEventListener("focus",this.#V.bind(this,c),{signal:l}),f.setAttribute("data-l10n-id",We._l10nResizer[c])}}const s=this.#t[0];let i=0;for(const r of n){if(r===s)break;i++}const a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let o=0;o<i-a;o++)this.#l.append(this.#l.firstElementChild);else if(a>i)for(let o=0;o<a-i;o++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(const o of n){const f=this.#t[r++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",We._l10nResizer[f])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#G(e){We._resizerKeyboardManager.exec(this,e)}#X(e){this.#y&&e.relatedTarget?.parentNode!==this.#l&&this.#L()}#V(e){this.#g=this.#y?e:""}#K(e){if(this.#t)for(const n of this.#t)n.tabIndex=e}_resizeWithKeyboard(e,n){this.#y&&this.#M(this.#g,{deltaX:e,deltaY:n,fromKeyboard:!0})}#L(){this.#y=!1,this.#K(-1),this.#_()}_stopResizingWithKeyboard(){this.#L(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,n){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(e){this.#p=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,n=!1){if(n){this.#w||=new Map;const{action:s}=e;let i=this.#w.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},We._telemetryTimeout),this.#w.set(s,i);return}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(e){if(!this.#c&&!this.deleted){this.#c=e.addFakeAnnotation(this);return}if(this.deleted){this.#c.remove(),this.#c=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#c.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let n=e.container.querySelector(".annotationContent");if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),e.container.prepend(n);else if(n.nodeName==="CANVAS"){const s=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),s.before(n)}return n}resetAnnotationElement(e){const{firstElementChild:n}=e.container;n?.nodeName==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}}class T6 extends We{static{p(this,"FakeEditor")}constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const qp=3285377520,Es=4294901760,ii=65535;class Ap{static{p(this,"MurmurHash3_64")}constructor(e){this.h1=e?e&4294967295:qp,this.h2=e?e&4294967295:qp}update(e){let n,s;if(typeof e=="string"){n=new Uint8Array(e.length*2),s=0;for(let g=0,b=e.length;g<b;g++){const w=e.charCodeAt(g);w<=255?n[s++]=w:(n[s++]=w>>>8,n[s++]=w&255)}}else if(ArrayBuffer.isView(e))n=e.slice(),s=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,a=s-i*4,r=new Uint32Array(n.buffer,0,i);let o=0,l=0,f=this.h1,c=this.h2;const h=3432918353,u=461845907,d=h&ii,m=u&ii;for(let g=0;g<i;g++)g&1?(o=r[g],o=o*h&Es|o*d&ii,o=o<<15|o>>>17,o=o*u&Es|o*m&ii,f^=o,f=f<<13|f>>>19,f=f*5+3864292196):(l=r[g],l=l*h&Es|l*d&ii,l=l<<15|l>>>17,l=l*u&Es|l*m&ii,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,a){case 3:o^=n[i*4+2]<<16;case 2:o^=n[i*4+1]<<8;case 1:o^=n[i*4],o=o*h&Es|o*d&ii,o=o<<15|o>>>17,o=o*u&Es|o*m&ii,i&1?f^=o:c^=o}this.h1=f,this.h2=c}hexdigest(){let e=this.h1,n=this.h2;return e^=n>>>1,e=e*3981806797&Es|e*36045&ii,n=n*4283543511&Es|((n<<16|e>>>16)*2950163797&Es)>>>16,e^=n>>>1,e=e*444984403&Es|e*60499&ii,n=n*3301882366&Es|((n<<16|e>>>16)*3120437893&Es)>>>16,e^=n>>>1,(e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const Do=Object.freeze({map:null,hash:"",transfer:void 0});class ah{static{p(this,"AnnotationStorage")}#e=!1;#t=null;#n=null;#s=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,n){const s=this.#s.get(e);return s===void 0?n:Object.assign(n,s)}getRawValue(e){return this.#s.get(e)}remove(e){const n=this.#s.get(e);n!==void 0&&(n instanceof We&&this.#n.delete(n.annotationElementId),this.#s.delete(e),this.#s.size===0&&this.resetModified(),!this.#s.values().some(s=>s instanceof We)&&this.onAnnotationEditor?.(null))}setValue(e,n){const s=this.#s.get(e);let i=!1;if(s!==void 0)for(const[a,r]of Object.entries(n))s[a]!==r&&(i=!0,s[a]=r);else i=!0,this.#s.set(e,n);i&&this.#i(),n instanceof We&&((this.#n||=new Map).set(n.annotationElementId,n),this.onAnnotationEditor?.(n.constructor._type))}has(e){return this.#s.has(e)}get size(){return this.#s.size}#i(){this.#e||(this.#e=!0,this.onSetModified?.())}resetModified(){this.#e&&(this.#e=!1,this.onResetModified?.())}get print(){return new Sp(this)}get serializable(){if(this.#s.size===0)return Do;const e=new Map,n=new Ap,s=[],i=Object.create(null);let a=!1;for(const[r,o]of this.#s){const l=o instanceof We?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(e.set(r,l),n.update(`${r}:${JSON.stringify(l)}`),a||=!!l.bitmap)}if(a)for(const r of e.values())r.bitmap&&s.push(r.bitmap);return e.size>0?{map:e,hash:n.hexdigest(),transfer:s}:Do}get editorStats(){let e=null;const n=new Map;let s=0,i=0;for(const a of this.#s.values()){if(!(a instanceof We)){a.popup&&(a.popup.deleted?i+=1:s+=1);continue}a.isCommentDeleted?i+=1:a.hasEditedComment&&(s+=1);const r=a.telemetryFinalData;if(!r)continue;const{type:o}=r;n.has(o)||n.set(o,Object.getPrototypeOf(a).constructor),e||=Object.create(null);const l=e[o]||=new Map;for(const[f,c]of Object.entries(r)){if(f==="type")continue;const h=l.getOrInsertComputed(f,b0);h.set(c,(h.get(c)??0)+1)}}if((i>0||s>0)&&(e||=Object.create(null),e.comments={deleted:i,edited:s}),!e)return null;for(const[a,r]of n)e[a]=r.computeTelemetryFinalData(e[a]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,n){const s=this.#n?.get(e);return s?(s.updateFromAnnotationLayer(n),!0):!1}getEditor(e){return this.#n?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;const e=[];if(this.#n)for(const n of this.#n.values())n.serialize()&&e.push(n.annotationElementId);return this.#t={ids:new Set(e),hash:e.join(",")}}[Symbol.iterator](){return this.#s.entries()}}class Sp extends ah{static{p(this,"PrintAnnotationStorage")}#e=Do;constructor(e){super();const{serializable:n}=e;if(n===Do)return;const{map:s,hash:i,transfer:a}=n,r=structuredClone(s,a?{transfer:a}:null);this.#e={map:r,hash:i,transfer:[]}}get print(){It("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#e}get modifiedIds(){return st(this,"modifiedIds",{ids:new Set,hash:""})}}const dr="__forcedDependency",{floor:Cp,ceil:Ip}=Math;function Tp(t,e,n,s,i,a){t[e*4+0]=Math.min(t[e*4+0],n),t[e*4+1]=Math.min(t[e*4+1],s),t[e*4+2]=Math.max(t[e*4+2],i),t[e*4+3]=Math.max(t[e*4+3],a)}p(Tp,"expandBBox");const rh=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class E6{static{p(this,"BBoxReader")}#e;#t;constructor(e,n){this.#e=e,this.#t=n}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===rh}minX(e){return this.#t[e*4+0]/256}minY(e){return this.#t[e*4+1]/256}maxX(e){return(this.#t[e*4+2]+1)/256}maxY(e){return(this.#t[e*4+3]+1)/256}}const Ep=p((t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1})),"ensureDebugMetadata");class F6{static{p(this,"CanvasBBoxTracker")}#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#n=new Float64Array([1/0,1/0,-1/0,-1/0]);_pendingBBoxIdx=-1;#s;#i;#a;#r;_savesStack=[];_markedContentStack=[];constructor(e,n){this.#s=e.width,this.#i=e.height,this.#o(n)}growOperationsCount(e){e>=this.#r.length&&this.#o(e,this.#r)}#o(e,n){const s=new ArrayBuffer(e*4);this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),n&&n.length>0?(this.#r.set(n),this.#r.fill(rh,n.length)):this.#r.fill(rh)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,n){const s=Object.getPrototypeOf(this.#t);if(s===null)return this;this.#t=s;const i=this._savesStack.pop();return i!==void 0&&(n?.(i,e),this.#r[e]=this.#r[i]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,n){const s=this._savesStack.pop();return s!==void 0&&(n?.(s,e),this.#r[e]=this.#r[s]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,n){const s=this._markedContentStack.pop();return s!==void 0&&(n?.(s,e),this.#r[e]=this.#r[s]),this}pushBaseTransform(e){return this.#e.push(Ie.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){return this.#e.length>1&&this.#e.pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,this.#n[0]=1/0,this.#n[1]=1/0,this.#n[2]=-1/0,this.#n[3]=-1/0),this}recordClipBox(e,n,s,i,a,r){const o=Ie.multiplyByDOMMatrix(this.#e.at(-1),n.getTransform()),l=[1/0,1/0,-1/0,-1/0];Ie.axialAlignedBoundingBox([s,a,i,r],o,l);const f=Ie.intersect(this.#t,l);return f?(this.#t[0]=f[0],this.#t[1]=f[1],this.#t[2]=f[2],this.#t[3]=f[3]):(this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0),this}recordBBox(e,n,s,i,a,r){const o=this.#t;if(o[0]===1/0)return this;const l=Ie.multiplyByDOMMatrix(this.#e.at(-1),n.getTransform());if(o[0]===-1/0)return Ie.axialAlignedBoundingBox([s,a,i,r],l,this.#n),this;const f=[1/0,1/0,-1/0,-1/0];return Ie.axialAlignedBoundingBox([s,a,i,r],l,f),this.#n[0]=Math.min(this.#n[0],Math.max(f[0],o[0])),this.#n[1]=Math.min(this.#n[1],Math.max(f[1],o[1])),this.#n[2]=Math.max(this.#n[2],Math.min(f[2],o[2])),this.#n[3]=Math.max(this.#n[3],Math.min(f[3],o[3])),this}recordFullPageBBox(e){return this.#n[0]=Math.max(0,this.#t[0]),this.#n[1]=Math.max(0,this.#t[1]),this.#n[2]=Math.min(this.#s,this.#t[2]),this.#n[3]=Math.min(this.#i,this.#t[3]),this}recordOperation(e,n=!1,s){if(this._pendingBBoxIdx!==e)return this;const i=Cp(this.#n[0]*256/this.#s),a=Cp(this.#n[1]*256/this.#i),r=Ip(this.#n[2]*256/this.#s),o=Ip(this.#n[3]*256/this.#i);if(Tp(this.#a,e,i,a,r,o),s)for(const l of s)for(const f of l)f!==e&&Tp(this.#a,f,i,a,r,o);return n||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#n[0]),this.#t[1]=Math.max(this.#t[1],this.#n[1]),this.#t[2]=Math.min(this.#t[2],this.#n[2]),this.#t[3]=Math.min(this.#t[3],this.#n[3])),this}take(){return new E6(this.#r,this.#a)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(e,n){return this}recordIncrementalData(e,n){return this}resetIncrementalData(e,n){return this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,s){return this}recordFutureForcedDependency(e,n){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,n,s,i=1,a=0,r=0,o){return this}getSimpleIndex(e){}recordDependencies(e,n){return this}recordNamedDependency(e,n){return this}recordShowTextOperation(e,n=!1){return this}}class B6{static{p(this,"CanvasDependencyTracker")}#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[dr]:[]};#n=new Map;#s=new Set;#i=new Map;#a;#r;#o;constructor(e,n=!1){this.#o=e,n&&(this.#a=new Map,this.#r=(s,i)=>{Ep(this.#a,i).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(e){this.#o.growOperationsCount(e)}save(e){return this.#e={__proto__:this.#e},this.#t={__proto__:this.#t,transform:{__proto__:this.#t.transform},moveText:{__proto__:this.#t.moveText},sameLineText:{__proto__:this.#t.sameLineText},[dr]:{__proto__:this.#t[dr]}},this.#o.save(e),this}restore(e){this.#o.restore(e,this.#r);const n=Object.getPrototypeOf(this.#e);return n===null?this:(this.#e=n,this.#t=Object.getPrototypeOf(this.#t),this)}recordOpenMarker(e){return this.#o.recordOpenMarker(e,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(e){return this.#o.recordCloseMarker(e,this.#r),this}beginMarkedContent(e){return this.#o.beginMarkedContent(e),this}endMarkedContent(e){return this.#o.endMarkedContent(e,this.#r),this}pushBaseTransform(e){return this.#o.pushBaseTransform(e),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(e,n){return this.#e[e]=n,this}recordIncrementalData(e,n){return this.#t[e].push(n),this}resetIncrementalData(e,n){return this.#t[e].length=0,this}recordNamedData(e,n){return this.#n.set(e,n),this}recordSimpleDataFromNamed(e,n,s){this.#e[e]=this.#n.get(n)??s}recordFutureForcedDependency(e,n){return this.recordIncrementalData(dr,n),this}inheritSimpleDataAsFutureForcedDependencies(e){for(const n of e)n in this.#e&&this.recordFutureForcedDependency(n,this.#e[n]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of this.#s)this.recordFutureForcedDependency(dr,e);return this}resetBBox(e){return this.#o.resetBBox(e),this}recordClipBox(e,n,s,i,a,r){return this.#o.recordClipBox(e,n,s,i,a,r),this}recordBBox(e,n,s,i,a,r){return this.#o.recordBBox(e,n,s,i,a,r),this}recordCharacterBBox(e,n,s,i=1,a=0,r=0,o){const l=s.bbox;let f,c;if(l&&(f=l[2]!==l[0]&&l[3]!==l[1]&&this.#i.get(s),f!==!1&&(c=[0,0,0,0],Ie.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||a!==0||r!==0)&&Ie.scaleMinMax([i,0,0,-i,a,r],c),f)))return this.recordBBox(e,n,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(e);const h=o();return l&&c&&f===void 0&&(f=c[0]<=a-h.actualBoundingBoxLeft&&c[2]>=a+h.actualBoundingBoxRight&&c[1]<=r-h.actualBoundingBoxAscent&&c[3]>=r+h.actualBoundingBoxDescent,this.#i.set(s,f),f)?this.recordBBox(e,n,c[0],c[2],c[1],c[3]):this.recordBBox(e,n,a-h.actualBoundingBoxLeft,a+h.actualBoundingBoxRight,r-h.actualBoundingBoxAscent,r+h.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#o.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,n){const s=this.#s,i=this.#e,a=this.#t;for(const r of n)r in this.#e?s.add(i[r]):r in a&&a[r].forEach(s.add,s);return this}recordNamedDependency(e,n){return this.#n.has(n)&&this.#s.add(this.#n.get(n)),this}recordOperation(e,n=!1){if(this.recordDependencies(e,[dr]),this.#a){const i=Ep(this.#a,e),{dependencies:a}=i;this.#s.forEach(a.add,a),this.#o._savesStack.forEach(a.add,a),this.#o._markedContentStack.forEach(a.add,a),a.delete(e),i.isRenderingOperation=!0}const s=!n&&e===this.#o._pendingBBoxIdx;return this.#o.recordOperation(e,n,[this.#s,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#s.clear(),this}recordShowTextOperation(e,n=!1){const s=Array.from(this.#s);this.recordOperation(e,n),this.recordIncrementalData("sameLineText",e);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(e,n=!1){const s=!n&&e===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(e),s&&this.#s.clear(),this}take(){return this.#i.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class Q0{static{p(this,"CanvasNestedDependencyTracker")}#e;#t;#n;#s=0;#i=0;constructor(e,n,s){if(e instanceof Q0&&e.#n===!!s)return e;this.#e=e,this.#t=n,this.#n=!!s}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(e){return this.#i++,this.#e.save(this.#t),this}restore(e){return this.#i>0&&(this.#e.restore(this.#t),this.#i--),this}recordOpenMarker(e){return this.#s++,this}getOpenMarker(){return this.#s>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#s--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return this.#e.pushBaseTransform(e),this}popBaseTransform(){return this.#e.popBaseTransform(),this}recordSimpleData(e,n){return this.#e.recordSimpleData(e,this.#t),this}recordIncrementalData(e,n){return this.#e.recordIncrementalData(e,this.#t),this}resetIncrementalData(e,n){return this.#e.resetIncrementalData(e,this.#t),this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,s){return this.#e.recordSimpleDataFromNamed(e,n,this.#t),this}recordFutureForcedDependency(e,n){return this.#e.recordFutureForcedDependency(e,this.#t),this}inheritSimpleDataAsFutureForcedDependencies(e){return this.#e.inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#e.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return this.#n||this.#e.resetBBox(this.#t),this}recordClipBox(e,n,s,i,a,r){return this.#n||this.#e.recordClipBox(this.#t,n,s,i,a,r),this}recordBBox(e,n,s,i,a,r){return this.#n||this.#e.recordBBox(this.#t,n,s,i,a,r),this}recordCharacterBBox(e,n,s,i,a,r,o){return this.#n||this.#e.recordCharacterBBox(this.#t,n,s,i,a,r,o),this}recordFullPageBBox(e){return this.#n||this.#e.recordFullPageBBox(this.#t),this}getSimpleIndex(e){return this.#e.getSimpleIndex(e)}recordDependencies(e,n){return this.#e.recordDependencies(this.#t,n),this}recordNamedDependency(e,n){return this.#e.recordNamedDependency(this.#t,n),this}recordOperation(e){return this.#e.recordOperation(this.#t,!0),this}recordShowTextOperation(e){return this.#e.recordShowTextOperation(this.#t,!0),this}bboxToClipBoxDropOperation(e){return this.#n||this.#e.bboxToClipBoxDropOperation(this.#t,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Fs={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class J0{static{p(this,"CanvasImagesTracker")}#e;#t;#n=4;#s=0;#i=new J0.#a(this.#n*6);static#a=rn.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(e,n,s,i){if(this.#s===this.#n){this.#n*=2;const o=new J0.#a(this.#n*6);o.set(this.#i),this.#i=o}const a=Ie.domMatrixToTransform(e.getTransform());let r;if(i[0]!==1/0){const o=[1/0,1/0,-1/0,-1/0];Ie.axialAlignedBoundingBox([0,-s,n,0],a,o);const l=Ie.intersect(i,o);if(!l)return;const[f,c,h,u]=l;if(f!==o[0]||c!==o[1]||h!==o[2]||u!==o[3]){const d=Math.atan2(a[1],a[0]),m=Math.abs(Math.sin(d)),g=Math.abs(Math.cos(d));if(m<1e-6||g<1e-6||Math.abs(m-g)<1e-6)r=[f,c,f,u,h,c];else{const b=h-f,w=u-c,x=m*m,y=g*g,j=g*m,v=y-x,q=(w*y-b*j)/v,A=(w*j-b*x)/v;r=[f+A,c,f,c+q,h,u-q]}}}r||(r=[0,-s,0,0,n,-s],Ie.applyTransform(r,a,0),Ie.applyTransform(r,a,2),Ie.applyTransform(r,a,4)),r[0]/=this.#e,r[1]/=this.#t,r[2]/=this.#e,r[3]/=this.#t,r[4]/=this.#e,r[5]/=this.#t,this.#i.set(r,this.#s*6),this.#s++}take(){return this.#i.subarray(0,this.#s*6)}}class R6{static{p(this,"FontLoader")}#e=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:n=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const n=this.styleElement.sheet;n.insertRule(e,n.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#e.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:n,_inspectFont:s}){if(!(!e||this.#e.has(e.loadedName))){if(Lt(!n,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:a,style:r}=e,o=new FontFace(i,a,r);this.addNativeFontFace(o);try{await o.load(),this.#e.add(i),s?.(e)}catch{at(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}It("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const s=e.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw at(`Failed to load font '${s.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const n=e.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){const e=!!this._document?.fonts;return st(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return st(this,"isSyncFontLoadingSupported",Ts||rn.platform.isFirefox)}_queueLoadingCallback(e){function n(){for(Lt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const a=s.shift();setTimeout(a.callback,0)}}p(n,"completeRequest");const{loadingRequests:s}=this,i={done:!1,complete:n,callback:e};return s.push(i),i}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return st(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,n){function s(j,v){return j.charCodeAt(v)<<24|j.charCodeAt(v+1)<<16|j.charCodeAt(v+2)<<8|j.charCodeAt(v+3)&255}p(s,"int32");function i(j,v,q,A){const C=j.substring(0,v),S=j.substring(v+q);return C+A+S}p(i,"spliceString");let a,r;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let f=0;function c(j,v){if(++f>30){at("Load test font never loaded."),v();return}if(l.font="30px "+j,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){v();return}setTimeout(c.bind(null,j,v))}p(c,"isFontReady");const h=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,h.length,h);const m=16,g=1482184792;let b=s(u,m);for(a=0,r=h.length-3;a<r;a+=4)b=b-g+s(h,a)|0;a<h.length&&(b=b-g+s(h+"XXX",a)|0),u=i(u,m,4,w6(b));const w=`url(data:font/opentype;base64,${btoa(u)});`,x=`@font-face {font-family:"${h}";src:${w}}`;this.insertRule(x);const y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(const j of[e.loadedName,h]){const v=this._document.createElement("span");v.textContent="Hi",v.style.fontFamily=j,y.append(v)}this._document.body.append(y),c(h,()=>{y.remove(),n.complete()})}}class _6{static{p(this,"FontFaceObject")}compiledGlyphs=Object.create(null);#e;constructor(e,n=null,s,i){this.#e=e,this._inspectFont=n,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const n={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(n.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,n)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${e}}`}return this._inspectFont?.(this,e),n}getPathGenerator(e,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const s=this.loadedName+"_path_"+n;let i;try{i=e.get(s)}catch(r){at(`getPathGenerator - ignoring character: "${r}".`)}const a=jp(i?.path);return this.fontExtraProperties||e.delete(s),this.compiledGlyphs[n]=a}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){st(this,"disableFontFace",!!e)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get ascent(){return this.#e.ascent}get defaultWidth(){return this.#e.defaultWidth}get descent(){return this.#e.descent}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.#e.mimetype}get name(){return this.#e.name}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}get defaultVMetrics(){return this.#e.defaultVMetrics}}class P6{static{p(this,"CSS_FONT_INFO")}static strings=["fontFamily","fontWeight","italicAngle"]}class D6{static{p(this,"SYSTEM_FONT_INFO")}static strings=["css","loadedName","baseFontName","src"]}class Us{static{p(this,"FONT_INFO")}static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class Xi{static{p(this,"PATTERN_INFO")}static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class M6{static{p(this,"CssFontInfo")}#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}#s(e){Lt(e<P6.strings.length,"Invalid string index");let n=0;for(let i=0;i<e;i++)n+=this.#n.getUint32(n)+4;const s=this.#n.getUint32(n);return this.#t.decode(new Uint8Array(this.#e,n+4,s))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class H6{static{p(this,"SystemFontInfo")}#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}get guessFallback(){return this.#n.getUint8(0)!==0}#s(e){Lt(e<D6.strings.length,"Invalid string index");let n=5;for(let i=0;i<e;i++)n+=this.#n.getUint32(n)+4;const s=this.#n.getUint32(n);return this.#t.decode(new Uint8Array(this.#e,n+4,s))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let e=1;e+=4+this.#n.getUint32(e);const n=this.#n.getUint32(e),s=this.#t.decode(new Uint8Array(this.#e,e+4,n));e+=4+n;const i=this.#n.getUint32(e),a=this.#t.decode(new Uint8Array(this.#e,e+4,i));return{style:s,weight:a}}}class O6{static{p(this,"FontInfo")}#e;#t=new TextDecoder;#n;constructor({buffer:e,extra:n}){this.#e=e,this.#n=new DataView(e),n&&Object.assign(this,n)}#s(e){Lt(e<Us.bools.length,"Invalid boolean index");const n=Math.floor(e/4),s=e*2%8,i=this.#n.getUint8(n)>>s&3;return i===0?void 0:i===2}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#i(e){return Lt(e<Us.numbers.length,"Invalid number index"),this.#n.getFloat64(Us.OFFSET_NUMBERS+e*8)}get ascent(){return this.#i(0)}get defaultWidth(){return this.#i(1)}get descent(){return this.#i(2)}#a(e,n,s,i){const a=this.#n.getUint8(e);if(a===0)return;Lt(a===n,"Invalid array length."),e+=1;const r=new Array(a);for(let o=0;o<a;o++)r[o]=this.#n[s](e,!0),e+=i;return r}get bbox(){return this.#a(Us.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#a(Us.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#a(Us.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#r(e){Lt(e<Us.strings.length,"Invalid string index");let n=Us.OFFSET_STRINGS+4;for(let i=0;i<e;i++)n+=this.#n.getUint32(n)+4;const s=this.#n.getUint32(n);return this.#t.decode(new Uint8Array(this.#e,n+4,s))}get fallbackName(){return this.#r(0)}get loadedName(){return this.#r(1)}get mimetype(){return this.#r(2)}get name(){return this.#r(3)}#o(){let e=Us.OFFSET_STRINGS;const n=this.#n.getUint32(e);e+=4+n;const s=this.#n.getUint32(e);e+=4+s;const i=this.#n.getUint32(e);e+=4+i;const a=this.#n.getUint32(e);return{offset:e,length:a}}get data(){const{offset:e,length:n}=this.#o();return n===0?void 0:new Uint8Array(this.#e,e+4,n)}clearData(){const{offset:e,length:n}=this.#o();n!==0&&(this.#n.setUint32(e,0),this.#e=new Uint8Array(this.#e,0,e+4).slice().buffer,this.#n=new DataView(this.#e))}get cssFontInfo(){let e=Us.OFFSET_STRINGS;const n=this.#n.getUint32(e);e+=4+n;const s=this.#n.getUint32(e);e+=4+s;const i=this.#n.getUint32(e);if(i===0)return null;const a=new Uint8Array(i);return a.set(new Uint8Array(this.#e,e+4,i)),new M6(a.buffer)}get systemFontInfo(){let e=Us.OFFSET_STRINGS;const n=this.#n.getUint32(e);e+=4+n;const s=this.#n.getUint32(e);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(this.#e,e+4,s)),new H6(i.buffer)}}class L6{static{p(this,"PatternInfo")}constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){const e=this.view,n=this.data[Xi.KIND],s=!!this.data[Xi.HAS_BBOX],i=!!this.data[Xi.HAS_BACKGROUND],a=e.getUint32(Xi.N_COORD,!0),r=e.getUint32(Xi.N_COLOR,!0),o=e.getUint32(Xi.N_STOP,!0),l=e.getUint32(Xi.N_FIGURES,!0);let f=20;const c=new Float32Array(this.buffer,f,a*2);f+=a*8;const h=new Uint8Array(this.buffer,f,r*3);f+=r*3;const u=[];for(let b=0;b<o;++b){const w=e.getFloat32(f,!0);f+=4;const x=e.getUint32(f,!0);f+=4,u.push([w,`#${x.toString(16).padStart(6,"0")}`])}let d=null;if(s){d=[];for(let b=0;b<4;++b)d.push(e.getFloat32(f,!0)),f+=4}let m=null;i&&(m=new Uint8Array(this.buffer,f,3),f+=3);const g=[];for(let b=0;b<l;++b){const w=e.getUint8(f);f+=1,f=Math.ceil(f/4)*4;const x=e.getUint32(f,!0);f+=4;const y=new Int32Array(this.buffer,f,x);f+=x*4;const j=e.getUint32(f,!0);f+=4;const v=new Int32Array(this.buffer,f,j);f+=j*4;const q={type:w,coords:y,colors:v};w===Ia.LATTICE&&(q.verticesPerRow=e.getUint32(f,!0),f+=4),g.push(q)}if(n===1)return["RadialAxial","axial",d,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(n===2)return["RadialAxial","radial",d,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(n===3){const b=this.data[Xi.SHADING_TYPE];let w=null;if(c.length>0){w=[1/0,1/0,-1/0,-1/0];for(let x=0,y=c.length;x<y;x+=2)Ie.pointBoundingBox(c[x],c[x+1],w)}return["Mesh",b,c,h,g,w,d,m]}throw new Error(`Unsupported pattern kind: ${n}`)}}class N6{static{p(this,"FontPathInfo")}#e;constructor(e){this.#e=e}get path(){return rn.isFloat16ArraySupported?new Float16Array(this.#e):new Float32Array(this.#e)}}function z6(t){if(t instanceof URL)return t;if(typeof t=="string"){if(Ts){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);const n=process.getBuiltinModule("url");return new URL(n.pathToFileURL(t))}const e=URL.parse(t,window.location);if(e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}p(z6,"getUrlProp");function U6(t){if(Ts&&typeof Buffer<"u"&&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(typeof t=="string")return m0(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!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.")}p(U6,"getDataProp");function A0(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}p(A0,"getFactoryUrlProp");const oh=p(t=>typeof t=="object"&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,"isRefProxy"),G6=p(t=>typeof t=="object"&&typeof t?.name=="string","isNameProxy"),Fp=j6.bind(null,oh,G6);class W6{static{p(this,"LoopbackPort")}#e=new Map;#t=Promise.resolve();postMessage(e,n){const s={data:structuredClone(e,n?{transfer:n}:null)};this.#t.then(()=>{for(const[i]of this.#e)i.call(this,s)})}addEventListener(e,n,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:a}=s;if(a.aborted){at("LoopbackPort - cannot use an `aborted` signal.");return}const r=p(()=>this.removeEventListener(e,n),"onAbort");i=p(()=>a.removeEventListener("abort",r),"rmAbort"),a.addEventListener("abort",r)}this.#e.set(n,i)}removeEventListener(e,n){this.#e.get(n)?.(),this.#e.delete(n)}terminate(){for(const[,e]of this.#e)e?.();this.#e.clear()}}const S0={DATA:1,ERROR:2},on={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Bp(){}p(Bp,"onFn");function es(t){if(t instanceof qi||t instanceof p0||t instanceof lp||t instanceof Bo||t instanceof Jc)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||It('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new qi(t.message);case"InvalidPDFException":return new p0(t.message);case"PasswordException":return new lp(t.message,t.code);case"ResponseException":return new Bo(t.message,t.status,t.missing);case"UnknownErrorException":return new Jc(t.message,t.details)}return new Jc(t.message,t.toString())}p(es,"wrapReason");class Mo{static{p(this,"MessageHandler")}#e=new AbortController;constructor(e,n,s){this.sourceName=e,this.targetName=n,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",this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#s(e);return}if(e.callback){const s=e.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],e.callback===S0.DATA)i.resolve(e.data);else if(e.callback===S0.ERROR)i.reject(es(e.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const s=this.sourceName,i=e.sourceName,a=this.comObj;Promise.try(n,e.data).then(function(r){a.postMessage({sourceName:s,targetName:i,callback:S0.DATA,callbackId:e.callbackId,data:r})},function(r){a.postMessage({sourceName:s,targetName:i,callback:S0.ERROR,callbackId:e.callbackId,reason:es(r)})});return}if(e.streamId){this.#n(e);return}n(e.data)}on(e,n){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=n}send(e,n,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},s)}sendWithPromise(e,n,s){const i=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[i]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:n},s)}catch(r){a.reject(r)}return a.promise}sendWithStream(e,n,s,i){const a=this.streamId++,r=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:p(f=>{const c=Promise.withResolvers();return this.streamControllers[a]={controller:f,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:r,targetName:o,action:e,streamId:a,data:n,desiredSize:f.desiredSize},i),c.promise},"start"),pull:p(f=>{const c=Promise.withResolvers();return this.streamControllers[a].pullCall=c,l.postMessage({sourceName:r,targetName:o,stream:on.PULL,streamId:a,desiredSize:f.desiredSize}),c.promise},"pull"),cancel:p(f=>{Lt(f instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[a].cancelCall=c,this.streamControllers[a].isClosed=!0,l.postMessage({sourceName:r,targetName:o,stream:on.CANCEL,streamId:a,reason:es(f)}),c.promise},"cancel")},s)}#n(e){const n=e.streamId,s=this.sourceName,i=e.sourceName,a=this.comObj,r=this,o=this.actionHandler[e.action],l={enqueue(f,c=1,h){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:s,targetName:i,stream:on.ENQUEUE,streamId:n,chunk:f},h)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:i,stream:on.CLOSE,streamId:n}),delete r.streamSinks[n])},error(f){Lt(f instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:i,stream:on.ERROR,streamId:n,reason:es(f)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,Promise.try(o,e.data,l).then(function(){a.postMessage({sourceName:s,targetName:i,stream:on.START_COMPLETE,streamId:n,success:!0})},function(f){a.postMessage({sourceName:s,targetName:i,stream:on.START_COMPLETE,streamId:n,reason:es(f)})})}#s(e){const n=e.streamId,s=this.sourceName,i=e.sourceName,a=this.comObj,r=this.streamControllers[n],o=this.streamSinks[n];switch(e.stream){case on.START_COMPLETE:e.success?r.startCall.resolve():r.startCall.reject(es(e.reason));break;case on.PULL_COMPLETE:e.success?r.pullCall.resolve():r.pullCall.reject(es(e.reason));break;case on.PULL:if(!o){a.postMessage({sourceName:s,targetName:i,stream:on.PULL_COMPLETE,streamId:n,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Bp).then(function(){a.postMessage({sourceName:s,targetName:i,stream:on.PULL_COMPLETE,streamId:n,success:!0})},function(f){a.postMessage({sourceName:s,targetName:i,stream:on.PULL_COMPLETE,streamId:n,reason:es(f)})});break;case on.ENQUEUE:if(Lt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(e.chunk);break;case on.CLOSE:if(Lt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#i(r,n);break;case on.ERROR:Lt(r,"error should have stream controller"),r.controller.error(es(e.reason)),this.#i(r,n);break;case on.CANCEL_COMPLETE:e.success?r.cancelCall.resolve():r.cancelCall.reject(es(e.reason)),this.#i(r,n);break;case on.CANCEL:if(!o)break;const l=es(e.reason);Promise.try(o.onCancel||Bp,l).then(function(){a.postMessage({sourceName:s,targetName:i,stream:on.CANCEL_COMPLETE,streamId:n,success:!0})},function(f){a.postMessage({sourceName:s,targetName:i,stream:on.CANCEL_COMPLETE,streamId:n,reason:es(f)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}}async#i(e,n){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[n]}destroy(){this.#e?.abort(),this.#e=null}}class Rp{static{p(this,"BaseBinaryDataFactory")}#e=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:e=null,standardFontDataUrl:n=null,wasmUrl:s=null}){this.cMapUrl=e,this.standardFontDataUrl=n,this.wasmUrl=s}async fetch({kind:e,filename:n}){switch(e){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:It(`Not implemented: ${e}`)}const s=this[e];if(!s)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const i=`${s}${n}`;return this._fetch(i,e).catch(a=>{throw new Error(`Unable to load ${this.#e[e]} data at: ${i}`)})}async _fetch(e,n){It("Abstract method `_fetch` called.")}}class _p extends Rp{static{p(this,"DOMBinaryDataFactory")}async _fetch(e,n){const s=n==="cMapUrl"&&!e.endsWith(".bcmap")?"text":"bytes",i=await x0(e,s);return i instanceof Uint8Array?i:m0(i)}}class Pp{static{p(this,"BaseCanvasFactory")}#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,n){if(e<=0||n<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(e,n);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#e})}}reset({canvas:e},n,s){if(!e)throw new Error("Canvas is not specified");if(n<=0||s<=0)throw new Error("Invalid canvas size");e.width=n,e.height=s}destroy(e){const{canvas:n}=e;if(!n)throw new Error("Canvas is not specified");n.width=n.height=0,e.canvas=null,e.context=null}_createCanvas(e,n){It("Abstract method `_createCanvas` called.")}}class $6 extends Pp{static{p(this,"DOMCanvasFactory")}constructor({ownerDocument:e=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=e}_createCanvas(e,n){const s=this._document.createElement("canvas");return s.width=e,s.height=n,s}}class Dp{static{p(this,"BaseFilterFactory")}addFilter(e){return"none"}addHCMFilter(e,n){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,n,s,i,a){return"none"}destroy(e=!1){}}class V6 extends Dp{static{p(this,"DOMFilterFactory")}#e;#t;#n;#s;#i;#a;#r=0;constructor({docId:e,ownerDocument:n=globalThis.document}){super(),this.#s=e,this.#i=n}get#o(){return this.#t||=new Map}get#l(){return this.#a||=new Map}get#f(){if(!this.#n){const e=this.#i.createElement("div"),{style:n}=e;n.visibility="hidden",n.contain="strict",n.width=n.height=0,n.position="absolute",n.top=n.left=0,n.zIndex=-1;const s=this.#i.createElementNS(Ai,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#n=this.#i.createElementNS(Ai,"defs"),e.append(s),s.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){const l=e[0],f=new Array(256);for(let h=0;h<256;h++)f[h]=l[h]/255;const c=f.join(",");return[c,c,c]}const[n,s,i]=e,a=new Array(256),r=new Array(256),o=new Array(256);for(let l=0;l<256;l++)a[l]=n[l]/255,r[l]=s[l]/255,o[l]=i[l]/255;return[a.join(","),r.join(","),o.join(",")]}#c(e){if(this.#e===void 0){this.#e="";const n=this.#i.URL;n!==this.#i.baseURI&&(Ro(n)?at('#createUrl: ignore "data:"-URL for performance reasons.'):this.#e=Yc(n,""))}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return"none";let n=this.#o.get(e);if(n)return n;const[s,i,a]=this.#u(e),r=e.length===1?s:`${s}${i}${a}`;if(n=this.#o.get(r),n)return this.#o.set(e,n),n;const o=`g_${this.#s}_transfer_map_${this.#r++}`,l=this.#c(o);this.#o.set(e,l),this.#o.set(r,l);const f=this.#m(o);return this.#p(s,i,a,f),l}addHCMFilter(e,n){const s=`${e}-${n}`,i="base";let a=this.#l.get(i);if(a?.key===s||(a?(a.filter?.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},this.#l.set(i,a)),!e||!n))return a.url;const r=this.#y(e);e=Ie.makeHexColor(...r);const o=this.#y(n);if(n=Ie.makeHexColor(...o),this.#f.style.color="",e==="#000000"&&n==="#ffffff"||e===n)return a.url;const l=new Array(256);for(let d=0;d<=255;d++){const m=d/255;l[d]=m<=.03928?m/12.92:((m+.055)/1.055)**2.4}const f=l.join(","),c=`g_${this.#s}_hcm_filter`,h=a.filter=this.#m(c);this.#p(f,f,f,h),this.#g(h);const u=p((d,m)=>{const g=r[d]/255,b=o[d]/255,w=new Array(m+1);for(let x=0;x<=m;x++)w[x]=g+x/m*(b-g);return w.join(",")},"getSteps");return this.#p(u(0,5),u(1,5),u(2,5),h),a.url=this.#c(c),a.url}addAlphaFilter(e){let n=this.#o.get(e);if(n)return n;const[s]=this.#u([e]),i=`alpha_${s}`;if(n=this.#o.get(i),n)return this.#o.set(e,n),n;const a=`g_${this.#s}_alpha_map_${this.#r++}`,r=this.#c(a);this.#o.set(e,r),this.#o.set(i,r);const o=this.#m(a);return this.#b(s,o),r}addLuminosityFilter(e){let n=this.#o.get(e||"luminosity");if(n)return n;let s,i;if(e?([s]=this.#u([e]),i=`luminosity_${s}`):i="luminosity",n=this.#o.get(i),n)return this.#o.set(e,n),n;const a=`g_${this.#s}_luminosity_map_${this.#r++}`,r=this.#c(a);this.#o.set(e,r),this.#o.set(i,r);const o=this.#m(a);return this.#d(o),e&&this.#b(s,o),r}addHighlightHCMFilter(e,n,s,i,a){const r=`${n}-${s}-${i}-${a}`;let o=this.#l.get(e);if(o?.key===r||(o?(o.filter?.remove(),o.key=r,o.url="none",o.filter=null):(o={key:r,url:"none",filter:null},this.#l.set(e,o)),!n||!s))return o.url;const[l,f]=[n,s].map(this.#y.bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),h=Math.round(.2126*f[0]+.7152*f[1]+.0722*f[2]),[u,d]=[i,a].map(this.#y.bind(this));h<c&&([c,h,u,d]=[h,c,d,u]),this.#f.style.color="";const m=p((w,x,y)=>{const j=new Array(256),v=(h-c)/y,q=w/255,A=(x-w)/(255*y);let C=0;for(let S=0;S<=y;S++){const I=Math.round(c+S*v),T=q+S*A;for(let P=C;P<=I;P++)j[P]=T;C=I+1}for(let S=C;S<256;S++)j[S]=j[C-1];return j.join(",")},"getSteps"),g=`g_${this.#s}_hcm_${e}_filter`,b=o.filter=this.#m(g);return this.#g(b),this.#p(m(u[0],d[0],5),m(u[1],d[1],5),m(u[2],d[2],5),b),o.url=this.#c(g),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#r=0)}#d(e){const n=this.#i.createElementNS(Ai,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(n)}#g(e){const n=this.#i.createElementNS(Ai,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(n)}#m(e){const n=this.#i.createElementNS(Ai,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",e),this.#f.append(n),n}#h(e,n,s){const i=this.#i.createElementNS(Ai,n);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),e.append(i)}#p(e,n,s,i){const a=this.#i.createElementNS(Ai,"feComponentTransfer");i.append(a),this.#h(a,"feFuncR",e),this.#h(a,"feFuncG",n),this.#h(a,"feFuncB",s)}#b(e,n){const s=this.#i.createElementNS(Ai,"feComponentTransfer");n.append(s),this.#h(s,"feFuncA",e)}#y(e){return this.#f.style.color=e,ur(getComputedStyle(this.#f).getPropertyValue("color"))}}async function K6(t){const n=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(n)}p(K6,"node_utils_fetchData");class X6 extends Dp{static{p(this,"NodeFilterFactory")}}class Y6 extends Pp{static{p(this,"NodeCanvasFactory")}_createCanvas(e,n){return process.getBuiltinModule("module").createRequire(import.meta.url),new Proxy({},{get(i,a){return()=>{throw new Error("@napi-rs/canvas is not available in this environment")}}}).createCanvas(e,n)}}class Q6 extends Rp{static{p(this,"NodeBinaryDataFactory")}async _fetch(e,n){return K6(e)}}const J6=`
54
+ `).join("")}}function _o(t,e){const n=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(n?.protocol??"")}p(_o,"isValidFetchUrl");function ms(t){t.preventDefault()}p(ms,"noContextMenu");function Nt(t){t.preventDefault(),t.stopPropagation()}p(Nt,"stopEvent");function v6(t){console.log("Deprecated API usage: "+t)}p(v6,"deprecated");class j0{static{p(this,"PDFDateString")}static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;this.#e||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const n=this.#e.exec(e);if(!n)return null;const s=parseInt(n[1],10);let i=parseInt(n[2],10);i=i>=1&&i<=12?i-1:0;let a=parseInt(n[3],10);a=a>=1&&a<=31?a:1;let r=parseInt(n[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(n[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const f=n[7]||"Z";let c=parseInt(n[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(n[9],10)||0;return h=h>=0&&h<=59?h:0,f==="-"?(r+=c,o+=h):f==="+"&&(r-=c,o-=h),new Date(Date.UTC(s,i,a,r,o,l))}}function pp(t,{scale:e=1,rotation:n=0}){const{width:s,height:i}=t.attributes.style,a=[0,0,parseInt(s),parseInt(i)];return new Qo({viewBox:a,userUnit:1,scale:e,rotation:n})}p(pp,"getXfaPageViewport");function ur(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",",3).map(e=>parseInt(e)):(at(`Not a valid color format: "${t}"`),[0,0,0])}p(ur,"getRGB");function q6(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const s=window.getComputedStyle(e).color;t.set(n,ur(s))}e.remove()}p(q6,"getColorValues");function zt(t){const{a:e,b:n,c:s,d:i,e:a,f:r}=t.getTransform();return[e,n,s,i,a,r]}p(zt,"getCurrentTransform");function si(t){const{a:e,b:n,c:s,d:i,e:a,f:r}=t.getTransform().invertSelf();return[e,n,s,i,a,r]}p(si,"getCurrentTransformInverse");function Ki(t,e,n=!1,s=!0){if(e instanceof Qo){const{pageWidth:i,pageHeight:a}=e.rawDims,{style:r}=t,o=rn.isCSSRoundSupported,l=`var(--total-scale-factor) * ${i}px`,f=`var(--total-scale-factor) * ${a}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,h=o?`round(down, ${f}, var(--scale-round-y))`:`calc(${f})`;!n||e.rotation%180===0?(r.width=c,r.height=h):(r.width=h,r.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}p(Ki,"setLayerDimensions");class Ws{static{p(this,"OutputScale")}constructor(){const{pixelRatio:e}=Ws;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,n,s,i,a=-1){let r=1/0,o=1/0,l=1/0;s=Ws.capPixels(s,a),s>0&&(r=Math.sqrt(s/(e*n))),i!==-1&&(o=i/e,l=i/n);const f=Math.min(r,o,l);return this.sx>f||this.sy>f?(this.sx=f,this.sy=f,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,n){if(n>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+n/100));return e>0?Math.min(e,s):s}return e}}const v0=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class A6{static{p(this,"ColorScheme")}static get isDarkMode(){return st(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class mp{static{p(this,"CSSConstants")}static get commentForegroundColor(){const e=document.createElement("span");e.classList.add("comment","sidebar");const{style:n}=e;n.width=n.height="0",n.display="none",n.color="var(--comment-fg-color)",document.body.append(e);const{color:s}=window.getComputedStyle(e);return e.remove(),st(this,"commentForegroundColor",ur(s))}}function gp(t,e){e=hn(e??1,0,1);const n=255*(1-e);return t.map(s=>Math.round(s*e+n))}p(gp,"applyOpacity");function bp(t,e){const n=t[0]/255,s=t[1]/255,i=t[2]/255,a=Math.max(n,s,i),r=Math.min(n,s,i),o=(a+r)/2;if(a===r)e[0]=e[1]=0;else{const l=a-r;switch(e[1]=o<.5?l/(a+r):l/(2-a-r),a){case n:e[0]=((s-i)/l+(s<i?6:0))*60;break;case s:e[0]=((i-n)/l+2)*60;break;case i:e[0]=((n-s)/l+4)*60;break}}e[2]=o}p(bp,"RGBToHSL");function sh(t,e){const n=t[0],s=t[1],i=t[2],a=(1-Math.abs(2*i-1))*s,r=a*(1-Math.abs(n/60%2-1)),o=i-a/2;switch(Math.floor(n/60)){case 0:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 1:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 2:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 3:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 4:e[0]=r+o,e[1]=o,e[2]=a+o;break;case 5:case 6:e[0]=a+o,e[1]=o,e[2]=r+o;break}}p(sh,"HSLToRGB");function wp(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}p(wp,"computeLuminance");function xp(t,e,n){sh(t,n),n.map(wp);const s=.2126*n[0]+.7152*n[1]+.0722*n[2];sh(e,n),n.map(wp);const i=.2126*n[0]+.7152*n[1]+.0722*n[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}p(xp,"contrastRatio");const kp=new Map;function yp(t,e){const n=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let s=kp.get(n);if(s)return s;const i=new Float32Array(9),a=i.subarray(0,3),r=i.subarray(3,6);bp(t,r);const o=i.subarray(6,9);bp(e,o);const l=o[2]<.5,f=l?12:4.5;if(r[2]=l?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),xp(r,o,a)<f){let c,h;l?(c=r[2],h=1):(c=0,h=r[2]);const u=.005;for(;h-c>u;){const d=r[2]=(c+h)/2;l===xp(r,o,a)<f?c=d:h=d}r[2]=l?h:c}return sh(r,a),s=Ie.makeHexColor(Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255)),kp.set(n,s),s}p(yp,"findContrastColor");function ih({html:t,dir:e,className:n},s){const i=document.createDocumentFragment();if(typeof t=="string"){const a=document.createElement("p");a.dir=e||"auto";const r=t.split(/(?:\r\n?|\n)/);for(let o=0,l=r.length;o<l;++o){const f=r[o];a.append(document.createTextNode(f)),o<l-1&&a.append(document.createElement("br"))}i.append(a)}else nh.render({xfaHtml:t,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",n),s.append(i)}p(ih,"renderRichText");function jp(t){const e=new Path2D;if(!t)return e;for(let n=0,s=t.length;n<s;)switch(t[n++]){case Fo.moveTo:e.moveTo(t[n++],t[n++]);break;case Fo.lineTo:e.lineTo(t[n++],t[n++]);break;case Fo.curveTo:e.bezierCurveTo(t[n++],t[n++],t[n++],t[n++],t[n++],t[n++]);break;case Fo.quadraticCurveTo:e.quadraticCurveTo(t[n++],t[n++],t[n++],t[n++]);break;case Fo.closePath:e.closePath();break;default:at(`Unrecognized drawing path operator: ${t[n-1]}`);break}return e}p(jp,"makePathFromDrawOPS");class Jo{static{p(this,"EditorToolbar")}#e=null;#t=null;#n;#s=null;#i=null;#a=null;#r=null;#o=null;static#l=null;constructor(e){this.#n=e,Jo.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const e=this.#e=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=this.#n._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(e.addEventListener("contextmenu",ms,{signal:n}),e.addEventListener("pointerdown",Jo.#f,{signal:n}));const s=this.#s=document.createElement("div");s.className="buttons",e.append(s);const i=this.#n.toolbarPosition;if(i){const{style:a}=e,r=this.#n._uiManager.direction==="ltr"?1-i[0]:i[0];a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return this.#e}static#f(e){e.stopPropagation()}#u(e){this.#n._focusEventsAllowed=!1,Nt(e)}#c(e){this.#n._focusEventsAllowed=!0,Nt(e)}#d(e){const n=this.#n._uiManager._signal;return!(n instanceof AbortSignal)||n.aborted?!1:(e.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:n}),e.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:n}),e.addEventListener("contextmenu",ms,{signal:n}),!0)}hide(){this.#e.classList.add("hidden"),this.#t?.hideDropdown()}show(){this.#e.classList.remove("hidden"),this.#i?.shown(),this.#a?.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=this.#n,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",Jo.#l[e]),this.#d(s)&&s.addEventListener("click",i=>{n.delete()},{signal:n._signal}),this.#s.append(s)}get#g(){const e=document.createElement("div");return e.className="divider",e}async addAltText(e){const n=await e.render();this.#d(n),this.#s.append(n,this.#g),this.#i=e}addComment(e,n=null){if(this.#a)return;const s=e.renderForToolbar();if(!s)return;this.#d(s);const i=this.#r=this.#g;n?(this.#s.insertBefore(s,n),this.#s.insertBefore(i,n)):this.#s.append(s,i),this.#a=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;const n=e.renderButton();this.#d(n),this.#s.append(n,this.#g)}async addEditSignatureButton(e){const n=this.#o=await e.renderEditButton(this.#n);this.#d(n),this.#s.append(n,this.#g)}removeButton(e){e==="comment"&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null)}async addButton(e,n){switch(e){case"colorPicker":n&&this.addColorPicker(n);break;case"altText":n&&await this.addAltText(n);break;case"editSignature":n&&await this.addEditSignatureButton(n);break;case"delete":this.addDeleteButton();break;case"comment":n&&this.addComment(n);break}}async addButtonBefore(e,n,s){if(!n&&e==="comment")return;const i=this.#s.querySelector(s);i&&e==="comment"&&this.addComment(n,i)}updateEditSignatureButton(e){this.#o&&(this.#o.title=e)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}}class S6{static{p(this,"FloatingToolbar")}#e=null;#t=null;#n;constructor(e){this.#n=e}#s(){const e=this.#t=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar");const n=this.#n._signal;n instanceof AbortSignal&&!n.aborted&&e.addEventListener("contextmenu",ms,{signal:n});const s=this.#e=document.createElement("div");return s.className="buttons",e.append(s),this.#n.hasCommentManager()&&this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#n.commentSelection("floating_button")}),this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#n.highlightSelection("floating_button")}),e}#i(e,n){let s=0,i=0;for(const a of e){const r=a.y+a.height;if(r<s)continue;const o=a.x+(n?a.width:0);if(r>s){i=o,s=r;continue}n?o>i&&(i=o):o<i&&(i=o)}return[n?1-i:i,s]}show(e,n,s){const[i,a]=this.#i(n,s),{style:r}=this.#t||=this.#s();e.append(this.#t),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(e,n,s,i){const a=document.createElement("button");a.classList.add("basic",e),a.tabIndex=0,a.setAttribute("data-l10n-id",n);const r=document.createElement("span");a.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);const o=this.#n._signal;o instanceof AbortSignal&&!o.aborted&&(a.addEventListener("contextmenu",ms,{signal:o}),a.addEventListener("click",i,{signal:o})),this.#e.append(a)}}function vp(t,e,n){for(const s of n)e.addEventListener(s,t[s].bind(t))}p(vp,"bindEvents");class St{static{p(this,"CurrentPointers")}static#e=NaN;static#t=null;static#n=NaN;static#s=null;static initializeAndAddPointerId(e){(St.#t||=new Set).add(e)}static setPointer(e,n){St.#e||=n,St.#s??=e}static setTimeStamp(e){St.#n=e}static isSamePointerId(e){return St.#e===e}static isSamePointerIdOrRemove(e){return St.#e===e?!0:(St.#t?.delete(e),!1)}static isSamePointerType(e){return St.#s===e}static isInitializedAndDifferentPointerType(e){return St.#s!==null&&!St.isSamePointerType(e)}static isSameTimeStamp(e){return St.#n===e}static isUsingMultiplePointers(){return St.#t?.size>=1}static clearPointerType(){St.#s=null}static clearPointerIds(){St.#e=NaN,St.#t=null}static clearTimeStamp(){St.#n=NaN}}class C6{static{p(this,"IdManager")}#e=0;get id(){return`${Io}${this.#e++}`}}class qh{static{p(this,"ImageManager")}#e=th();#t=0;#n=null;static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;const a=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return st(this,"_isSVGFittingCanvas",a)}async#s(e,n){this.#n||=new Map;let s=this.#n.get(e);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let i;if(typeof n=="string"?(s.url=n,i=await x0(n,"blob")):n instanceof File?i=s.file=n:n instanceof Blob&&(i=n),i.type==="image/svg+xml"){const a=qh._isSVGFittingCanvas,r=new FileReader,o=new Image,l=new Promise((f,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,f()},r.onload=async()=>{const h=s.svgUrl=r.result;o.src=await a?`${h}#svgView(preserveAspectRatio(none))`:h},o.onerror=r.onerror=c});r.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){at(i),s=null}return this.#n.set(e,s),s&&this.#n.set(s.id,s),s}async getFromFile(e){const{lastModified:n,name:s,size:i,type:a}=e;return this.#s(`${n}_${s}_${i}_${a}`,e)}async getFromUrl(e){return this.#s(e,e)}async getFromBlob(e,n){const s=await n;return this.#s(e,s)}async getFromId(e){this.#n||=new Map;const n=this.#n.get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:s}=n;return delete n.blobPromise,this.getFromBlob(n.id,s)}return this.getFromUrl(n.url)}getFromCanvas(e,n){this.#n||=new Map;let s=this.#n.get(e);if(s?.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(n.width,n.height);return i.getContext("2d").drawImage(n,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,s),this.#n.set(s.id,s),s}getSvgUrl(e){const n=this.#n.get(e);return n?.isSvg?n.svgUrl:null}deleteId(e){this.#n||=new Map;const n=this.#n.get(e);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:s}=n;if(!n.url&&!n.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),n.blobPromise=i.convertToBlob()}s.close?.(),n.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}}class I6{static{p(this,"CommandManager")}#e=[];#t=!1;#n;#s=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:n,post:s,mustExec:i,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(i&&e(),this.#t)return;const l={cmd:e,undo:n,post:s,type:a};if(this.#s===-1){this.#e.length>0&&(this.#e.length=0),this.#s=0,this.#e.push(l);return}if(r&&this.#e[this.#s].type===a){o&&(l.undo=this.#e[this.#s].undo),this.#e[this.#s]=l;return}const f=this.#s+1;f===this.#n?this.#e.splice(0,1):(this.#s=f,f<this.#e.length&&this.#e.splice(f)),this.#e.push(l)}undo(){if(this.#s===-1)return;this.#t=!0;const{undo:e,post:n}=this.#e[this.#s];e(),n?.(),this.#t=!1,this.#s-=1}redo(){if(this.#s<this.#e.length-1){this.#s+=1,this.#t=!0;const{cmd:e,post:n}=this.#e[this.#s];e(),n?.(),this.#t=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#e.length-1}cleanType(e){if(this.#s!==-1){for(let n=this.#s;n>=0;n--)if(this.#e[n].type!==e){this.#e.splice(n+1,this.#s-n),this.#s=n;return}this.#e.length=0,this.#s=-1}}destroy(){this.#e=null}}class Po{static{p(this,"KeyboardManager")}constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=rn.platform;for(const[s,i,a={}]of e)for(const r of s){const o=r.startsWith("mac+");n&&o?(this.callbacks.set(r.slice(4),{callback:i,options:a}),this.allKeys.add(r.split("+").at(-1))):!n&&!o&&(this.callbacks.set(r,{callback:i,options:a}),this.allKeys.add(r.split("+").at(-1)))}}#e(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const n=this.buffer.join("+");return this.buffer.length=0,n}exec(e,n){if(!this.allKeys.has(n.key))return;const s=this.callbacks.get(this.#e(n));if(!s)return;const{callback:i,options:{bubbles:a=!1,args:r=[],checker:o=null}}=s;o&&!o(e,n)||(i.bind(e,...r,n)(),a||Nt(n))}}class Ah{static{p(this,"ColorManager")}static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return q6(e),st(this,"_colors",e)}convert(e){const n=ur(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[s,i]of this._colors)if(i.every((a,r)=>a===n[r]))return Ah._colorsMapping.get(s);return n}getHexCode(e){const n=this._colors.get(e);return n?Ie.makeHexColor(...n):e}}class Si{static{p(this,"AnnotationEditorUIManager")}#e=new AbortController;#t=null;#n=null;#s=new Map;#i=new Map;#a=null;#r=null;#o=null;#l=null;#f=new I6;#u=null;#c=null;#d=null;#g=0;#m=new Set;#h=null;#p=null;#b=new Set;_editorUndoBar=null;#y=!1;#x=!1;#v=!1;#C=null;#w=null;#q=null;#j=null;#S=!1;#T=null;#E=new C6;#I=!1;#R=!1;#F=!1;#B=null;#_=null;#M=null;#H=null;#z=null;#A=et.NONE;#k=new Set;#D=null;#O=null;#G=null;#X=null;#V=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#W=null;#$=null;#Z=null;#ee=null;#N=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=Si.prototype,n=p(r=>r.#$.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),"arrowChecker"),s=p((r,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},"textInputChecker"),i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return st(this,"_keyboardManager",new Po([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.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"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:p((r,{target:o})=>!(o instanceof HTMLButtonElement)&&r.#$.contains(o)&&!r.isEnterHandled,"checker")}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:p((r,{target:o})=>!(o instanceof HTMLButtonElement)&&r.#$.contains(document.activeElement),"checker")}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,n,s,i,a,r,o,l,f,c,h,u,d,m,g,b){const w=this._signal=this.#e.signal;this.#$=e,this.#Z=n,this.#ee=s,this.#r=i,this.#u=a,this.#O=r,this.#V=l,this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",x=>this.updateParams(x.type,x.value),{signal:w}),window.addEventListener("pointerdown",()=>{this.#R=!0},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{this.#R=!1},{capture:!0,signal:w}),window.addEventListener("beforeunload",this.#ae.bind(this),{capture:!0,signal:w}),this.#le(),this.#pe(),this.#ne(),this.#o=l.annotationStorage,this.#C=l.filterFactory,this.#G=f,this.#j=c||null,this.#y=h,this.#x=u,this.#v=d,this.#z=m||null,this.viewParameters={realScale:Ea.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=b!==!1,a?.setSidebarUiManager(this)}destroy(){this.#N?.resolve(),this.#N=null,this.#e?.abort(),this.#e=null,this._signal=null;for(const e of this.#i.values())e.destroy();this.#i.clear(),this.#s.clear(),this.#b.clear(),this.#H?.clear(),this.#t=null,this.#k.clear(),this.#f.destroy(),this.#r?.destroy(),this.#u?.destroy(),this.#O?.destroy(),this.#T?.hide(),this.#T=null,this.#M?.destroy(),this.#M=null,this.#n=null,this.#w&&(clearTimeout(this.#w),this.#w=null),this.#W&&(clearTimeout(this.#W),this.#W=null),this._editorUndoBar?.destroy(),this.#V=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#z}get useNewAltTextFlow(){return this.#x}get useNewAltTextWhenAddingImage(){return this.#v}get hcmFilter(){return st(this,"hcmFilter",this.#G?this.#C.addHCMFilter(this.#G.foreground,this.#G.background):"none")}get direction(){return st(this,"direction",getComputedStyle(this.#$).direction)}get _highlightColors(){return st(this,"_highlightColors",this.#j?new Map(this.#j.split(",").map(e=>(e=e.split("=").map(n=>n.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return st(this,"highlightColors",null);const n=new Map,s=!!this.#G;for(const[i,a]of e){const r=i.endsWith("_HCM");if(s&&r){n.set(i.replace("_HCM",""),a);continue}!s&&!r&&n.set(i,a)}return st(this,"highlightColors",n)}get highlightColorNames(){return st(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const n=this.highlightColorNames.get(e);return this._highlightColors.get(n)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#d=e}setMainHighlightColorPicker(e){this.#M=e}editAltText(e,n=!1){this.#r?.editAltText(this,e,n)}hasCommentManager(){return!!this.#u}editComment(e,n,s,i){this.#u?.showDialog(this,e,n,s,i)}selectComment(e,n){this.#i.get(e)?.getEditorByUID(n)?.toggleComment(!0,!0)}updateComment(e){this.#u?.updateComment(e.getData())}updatePopupColor(e){this.#u?.updatePopupColor(e)}removeComment(e){this.#u?.removeComments([e.uid])}deleteComment(e,n){const s=p(()=>{e.comment=n},"undo"),i=p(()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),e.comment=null},"cmd");this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(e,n,s=void 0){this.#u?.toggleCommentPopup(e,n,s)}makeCommentColor(e,n){return e&&this.#u?.makeCommentColor(e,n)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(e){if(this.#i.has(e-1))return;const{resolve:n,promise:s}=Promise.withResolvers(),i=p(a=>{a.pageNumber===e&&(this._eventBus._off("editorsrendered",i),n())},"onEditorsRendered");this._eventBus.on("editorsrendered",i),await s}getSignature(e){this.#O?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#O}switchToMode(e,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,n){this._eventBus.dispatch("setpreference",{source:this,name:e,value:n})}onSetPreference({name:e,value:n}){e==="enableNewAltTextWhenAddingImage"&&(this.#v=n)}onPageChanging({pageNumber:e}){this.#g=e-1}deletePage(e){for(const n of this.getEditors(e))n.remove();this.#i.delete(e),this.#g===e&&(this.#g=0)}focusMainContainer(){this.#$.focus()}findParent(e,n){for(const s of this.#i.values()){const{x:i,y:a,width:r,height:o}=s.div.getBoundingClientRect();if(e>=i&&e<=i+r&&n>=a&&n<=a+o)return s}return null}disableUserSelect(e=!1){this.#Z.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#b.add(e)}removeShouldRescale(e){this.#b.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Ea.PDF_TO_CSS_UNITS;for(const n of this.#b)n.onScaleChanging();this.#d?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#J({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#te(e){const{currentLayer:n}=this;if(n.hasTextLayer(e))return n;for(const s of this.#i.values())if(s.hasTextLayer(e))return s;return null}highlightSelection(e="",n=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:a,focusNode:r,focusOffset:o}=s,l=s.toString(),c=this.#J(s).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;s.empty();const u=this.#te(c),d=this.#A===et.NONE,m=p(()=>{const g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:h,anchorNode:i,anchorOffset:a,focusNode:r,focusOffset:o,text:l});d&&this.showAllEditors("highlight",!0,!0),n&&g?.editComment()},"callback");if(d){this.switchToMode(et.HIGHLIGHT,m);return}m()}commentSelection(e=""){this.highlightSelection(e,!0)}#ae(e){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#re(){const e=document.getSelection();if(!e||e.isCollapsed)return;const s=this.#J(e).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#T||=new S6(this),this.#T.show(s,i,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#o)return null;const n=`${Io}${e}`,s=this.#o.getRawValue(n);return s&&this.#o.remove(n),s}addToAnnotationStorage(e){!e.isEmpty()&&this.#o&&!this.#o.has(e.id)&&this.#o.setValue(e.id,e)}a11yAlert(e,n=null){const s=this.#ee;s&&(s.setAttribute("data-l10n-id",e),n?s.setAttribute("data-l10n-args",JSON.stringify(n)):s.removeAttribute("data-l10n-args"))}#oe(){const e=document.getSelection();if(!e||e.isCollapsed){this.#D&&(this.#T?.hide(),this.#D=null,this.#P({hasSelectedText:!1}));return}const{anchorNode:n}=e;if(n===this.#D)return;const i=this.#J(e).closest(".textLayer");if(!i){this.#D&&(this.#T?.hide(),this.#D=null,this.#P({hasSelectedText:!1}));return}if(this.#T?.hide(),this.#D=n,this.#P({hasSelectedText:!0}),!(this.#A!==et.HIGHLIGHT&&this.#A!==et.NONE)&&(this.#A===et.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){const a=this.#A===et.HIGHLIGHT?this.#te(i):null;if(a?.toggleDrawing(),this.#R){const r=new AbortController,o=this.combinedSignal(r),l=p(f=>{f.type==="pointerup"&&f.button!==0||(r.abort(),a?.toggleDrawing(!0),f.type==="pointerup"&&this.#Y("main_toolbar"))},"pointerup");window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}else a?.toggleDrawing(!0),this.#Y("main_toolbar")}}#Y(e=""){this.#A===et.HIGHLIGHT?this.highlightSelection(e):this.#y&&this.#re()}#le(){document.addEventListener("selectionchange",this.#oe.bind(this),{signal:this._signal})}#fe(){if(this.#q)return;this.#q=new AbortController;const e=this.combinedSignal(this.#q);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#ce(){this.#q?.abort(),this.#q=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#Y("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const n of this.#k)if(n.div.contains(e)){this.#_=[n,e],n._focusEventsAllowed=!1;break}}focus(){if(!this.#_)return;const[e,n]=this.#_;this.#_=null,n.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}#ne(){if(this.#B)return;this.#B=new AbortController;const e=this.combinedSignal(this.#B);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#he(){this.#B?.abort(),this.#B=null}#ue(){if(this.#c)return;this.#c=new AbortController;const e=this.combinedSignal(this.#c);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#de(){this.#c?.abort(),this.#c=null}#pe(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ne(),this.setEditingState(!0)}removeEditListeners(){this.#he(),this.setEditingState(!1)}dragOver(e){for(const{type:n}of e.dataTransfer.items)for(const s of this.#p)if(s.isHandlingMimeForPasting(n)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const n of e.dataTransfer.items)for(const s of this.#p)if(s.isHandlingMimeForPasting(n.type)){s.paste(n,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;const n=[];for(const s of this.#k){const i=s.serialize(!0);i&&n.push(i)}n.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:n}=e;for(const a of n.items)for(const r of this.#p)if(r.isHandlingMimeForPasting(a.type)){r.paste(a,this.currentLayer);return}let s=n.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){at(`paste: "${a.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const a=[];for(const l of s){const f=await i.deserialize(l);if(!f)return;a.push(f)}const r=p(()=>{for(const l of a)this.#se(l);this.#ie(a)},"cmd"),o=p(()=>{for(const l of a)l.remove()},"undo");this.addCommands({cmd:r,undo:o,mustExec:!0})}catch(a){at(`paste: "${a.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),this.#A!==et.NONE&&!this.isEditorHandlingKeyboard&&Si._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#Y("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(e,n){for(const i of this.getEditors(e))i.pageIndex=n;const s=this.#a.get(e);s&&(s.pageIndex=n,this.#i.set(n,s),this.#I?s.enable():s.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear()}endUpdatePages(){this.#a=null}clonePage(e,n){for(const s of this.getEditors(e)){const i=s.serialize(s.mode!==et.HIGHLIGHT);i&&(i.pageIndex=n,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#o.setValue(i.id,i))}}findClonesForPage(e){const n=[],{pageIndex:s}=e;for(const[i,a]of this.#o)a.pageIndex===s&&a.isClone&&(this.#o.remove(i),n.push(e.deserialize(a).then(r=>{r&&(r.isClone=!0,e.addOrRebuild(r))})));return Promise.all(n)}#P(e){Object.entries(e).some(([s,i])=>this.#K[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,e)}),this.#A===et.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#U([[gt.HIGHLIGHT_FREE,!0]]))}#U(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#fe(),this.#ue(),this.#P({isEditing:this.#A!==et.NONE,isEmpty:this.#Q(),hasSomethingToUndo:this.#f.hasSomethingToUndo(),hasSomethingToRedo:this.#f.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ce(),this.#de(),this.#P({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#p){this.#p=e;for(const n of this.#p)this.#U(n.defaultPropertiesToUpdate)}}getId(){return this.#E.id}get currentLayer(){return this.#i.get(this.#g)}getLayer(e){return this.#i.get(e)}get currentPageIndex(){return this.#g}addLayer(e){this.#i.set(e.pageIndex,e),this.#I?e.enable():e.disable()}removeLayer(e){this.#i.delete(e.pageIndex)}async updateMode(e,n=null,s=!1,i=!1,a=!1,r=!1){if(this.#A!==e&&!(this.#N&&(await this.#N.promise,!this.#N))){if(this.#N=Promise.withResolvers(),this.#d?.commitOrRemove(),this.#A===et.POPUP&&this.#u?.hideSidebar(),this.#u?.destroyPopup(),this.#A=e,e===et.NONE){this.setEditingState(!1),this.#ge();for(const o of this.#s.values())o.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#N.resolve();return}for(const o of this.#s.values())o.addStandaloneCommentButton();e===et.SIGNATURE&&await this.#O?.loadSignatures(),s&&St.clearPointerType(),this.setEditingState(!0),await this.#me(),this.unselectAll();for(const o of this.#i.values())o.updateMode(e);if(e===et.POPUP){this.#n||=await this.#V.getAnnotationsByType(new Set(this.#p.map(f=>f._editorType)));const o=new Set,l=[];for(const f of this.#s.values()){const{annotationElementId:c,hasComment:h,deleted:u}=f;c&&o.add(c),h&&!u&&l.push(f.getData())}for(const f of this.#n){const{id:c,popupRef:h,contentsObj:u}=f;h&&u?.str&&!o.has(c)&&!this.#m.has(c)&&l.push(f)}this.#u?.showSidebar(l)}if(!n){i&&this.addNewEditorFromKeyboard(),this.#N.resolve();return}for(const o of this.#s.values())o.uid===n?(this.setSelected(o),r?o.editComment():a?o.enterInEditMode():o.focus()):o.unselect();this.#N.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#A&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,n){if(this.#p){switch(e){case gt.CREATE:this.currentLayer.addNewEditor(n);return;case gt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#X||=new Map).set(e,n),this.showAllEditors("highlight",n);break}if(this.hasSelection)for(const s of this.#k)s.updateParams(e,n);else for(const s of this.#p)s.updateDefaultParams(e,n)}}showAllEditors(e,n,s=!1){for(const a of this.#s.values())a.editorType===e&&a.show(n);(this.#X?.get(gt.HIGHLIGHT_SHOW_ALL)??!0)!==n&&this.#U([[gt.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(e=!1){if(this.#F!==e){this.#F=e;for(const n of this.#i.values())e?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",e)}}async#me(){if(!this.#I){this.#I=!0;const e=[];for(const n of this.#i.values())e.push(n.enable());await Promise.all(e);for(const n of this.#s.values())n.enable()}}#ge(){if(this.unselectAll(),this.#I){this.#I=!1;for(const e of this.#i.values())e.disable();for(const e of this.#s.values())e.disable()}}*getEditors(e){for(const n of this.#s.values())n.pageIndex===e&&(yield n)}getEditor(e){return this.#s.get(e)}addEditor(e){this.#s.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.focusMainContainer(),this.#w=null},0)),this.#s.delete(e.id),e.annotationElementId&&this.#H?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#m.has(e.annotationElementId))&&this.#o?.remove(e.id)}addDeletedAnnotationElement(e){this.#m.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#m.has(e)}removeDeletedAnnotationElement(e){this.#m.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#se(e){const n=this.#i.get(e.pageIndex);n?n.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#U(e.propertiesToUpdate))}get#be(){let e=null;for(e of this.#k);return e}updateUI(e){this.#be===e&&this.#U(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#U(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#k.has(e)){this.#k.delete(e),e.unselect(),this.#P({hasSelectedEditor:this.hasSelection});return}this.#k.add(e),e.select(),this.#U(e.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#d?.commitOrRemove();for(const n of this.#k)n!==e&&n.unselect();this.#u?.destroyPopup(),this.#k.clear(),this.#k.add(e),e.select(),this.#U(e.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}isSelected(e){return this.#k.has(e)}get firstSelectedEditor(){return this.#k.values().next().value}unselect(e){e.unselect(),this.#k.delete(e),this.#P({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#k.size!==0}get isEnterHandled(){return this.#k.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#f.undo(),this.#P({hasSomethingToUndo:this.#f.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Q()}),this._editorUndoBar?.hide()}redo(){this.#f.redo(),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:this.#f.hasSomethingToRedo(),isEmpty:this.#Q()})}addCommands(e){this.#f.add(e),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Q()})}cleanUndoStack(e){this.#f.cleanType(e)}#Q(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const e of this.#s.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[...this.#k],s=p(()=>{this._editorUndoBar?.show(i,n.length===1?n[0].editorType:n.length);for(const a of n)a.remove()},"cmd"),i=p(()=>{for(const a of n)this.#se(a)},"undo");this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ie(e){for(const n of this.#k)n.unselect();this.#k.clear();for(const n of e)n.isEmpty()||(this.#k.add(n),n.select());this.#P({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#k)e.commit();this.#ie(this.#s.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#A!==et.NONE))&&!this.#d?.commitOrRemove()&&(this.#u?.destroyPopup(),!!this.hasSelection)){for(const e of this.#k)e.unselect();this.#k.clear(),this.#P({hasSelectedEditor:!1})}}translateSelectedEditors(e,n,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#L[0]+=e,this.#L[1]+=n;const[i,a]=this.#L,r=[...this.#k],o=1e3;this.#W&&clearTimeout(this.#W),this.#W=setTimeout(()=>{this.#W=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:p(()=>{for(const l of r)this.#s.has(l.id)&&(l.translateInPage(i,a),l.translationDone())},"cmd"),undo:p(()=>{for(const l of r)this.#s.has(l.id)&&(l.translateInPage(-i,-a),l.translationDone())},"undo"),mustExec:!1})},o);for(const l of r)l.translateInPage(e,n),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#h=new Map;for(const e of this.#k)this.#h.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#h)return!1;this.disableUserSelect(!1);const e=this.#h;this.#h=null;let n=!1;for(const[{x:i,y:a,pageIndex:r},o]of e)o.newX=i,o.newY=a,o.newPageIndex=r,n||=i!==o.savedX||a!==o.savedY||r!==o.savedPageIndex;if(!n)return!1;const s=p((i,a,r,o)=>{if(this.#s.has(i.id)){const l=this.#i.get(o);l?i._setParentAndPosition(l,a,r):(i.pageIndex=o,i.x=a,i.y=r)}},"move");return this.addCommands({cmd:p(()=>{for(const[i,{newX:a,newY:r,newPageIndex:o}]of e)s(i,a,r,o)},"cmd"),undo:p(()=>{for(const[i,{savedX:a,savedY:r,savedPageIndex:o}]of e)s(i,a,r,o)},"undo"),mustExec:!0}),!0}dragSelectedEditors(e,n){if(this.#h)for(const s of this.#h.keys())s.drag(e,n)}rebuild(e){if(e.parent===null){const n=this.getLayer(e.pageIndex);n?(n.changeParent(e),n.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#k.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#A}isEditingMode(){return this.#A!==et.NONE}get imageManager(){return st(this,"imageManager",new qh)}getSelectionBoxes(e){if(!e)return null;const n=document.getSelection();for(let f=0,c=n.rangeCount;f<c;f++)if(!e.contains(n.getRangeAt(f).commonAncestorContainer))return null;const{x:s,y:i,width:a,height:r}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=p((f,c,h,u)=>({x:(c-i)/r,y:1-(f+h-s)/a,width:u/r,height:h/a}),"rotator");break;case"180":o=p((f,c,h,u)=>({x:1-(f+h-s)/a,y:1-(c+u-i)/r,width:h/a,height:u/r}),"rotator");break;case"270":o=p((f,c,h,u)=>({x:1-(c+u-i)/r,y:(f-s)/a,width:u/r,height:h/a}),"rotator");break;default:o=p((f,c,h,u)=>({x:(f-s)/a,y:(c-i)/r,width:h/a,height:u/r}),"rotator");break}const l=[];for(let f=0,c=n.rangeCount;f<c;f++){const h=n.getRangeAt(f);if(!h.collapsed)for(const{x:u,y:d,width:m,height:g}of h.getClientRects())m===0||g===0||l.push(o(u,d,m,g))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:n}){(this.#l||=new Map).set(e,n)}removeChangedExistingAnnotation({annotationElementId:e}){this.#l?.delete(e)}renderAnnotationElement(e){const n=this.#l?.get(e.data.id);if(!n)return;const s=this.#o.getRawValue(n);s&&(this.#A===et.NONE&&!s.hasBeenModified||s.renderAnnotationElement(e))}setMissingCanvas(e,n,s){const i=this.#H?.get(e);i&&(i.setCanvas(n,s),this.#H.delete(e))}addMissingCanvas(e,n){(this.#H||=new Map).set(e,n)}}class oi{static{p(this,"AltText")}#e=null;#t=!1;#n=null;#s=null;#i=null;#a=null;#r=!1;#o=null;#l=null;#f=null;#u=null;#c=!1;static#d=null;static _l10n=null;constructor(e){this.#l=e,this.#c=e._uiManager.useNewAltTextFlow,oi.#d||=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(e){oi._l10n??=e}async render(){const e=this.#n=document.createElement("button");e.className="altText",e.tabIndex="0";const n=this.#s=document.createElement("span");e.append(n),this.#c?(e.classList.add("new"),e.setAttribute("data-l10n-id",oi.#d.missing),n.setAttribute("data-l10n-id",oi.#d["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#l._uiManager._signal;e.addEventListener("contextmenu",ms,{signal:s}),e.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const i=p(a=>{a.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#c&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})},"onClick");return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",a=>{a.target===e&&a.key==="Enter"&&(this.#r=!0,i(a))},{signal:s}),await this.#m(),e}get#g(){return this.#e&&"added"||this.#e===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#c?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#c?this.#e!==null||!!this.#f:this.isEmpty()}get guessedText(){return this.#f}async setGuessedText(e){this.#e===null&&(this.#f=e,this.#u=await oi._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#c||this.#e){this.#o?.remove(),this.#o=null;return}if(!this.#o){const n=this.#o=document.createElement("div");n.className="noAltTextBadge",this.#l.div.append(n)}this.#o.classList.toggle("hidden",!e)}serialize(e){let n=this.#e;return!e&&this.#f===n&&(n=this.#u),{altText:n,decorative:this.#t,guessedText:this.#f,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:n,guessedText:s,textWithDisclaimer:i,cancel:a=!1}){s&&(this.#f=s,this.#u=i),!(this.#e===e&&this.#t===n)&&(a||(this.#e=e,this.#t=n),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#n?.remove(),this.#n=null,this.#s=null,this.#i=null,this.#o?.remove(),this.#o=null}async#m(){const e=this.#n;if(!e)return;if(this.#c){if(e.classList.toggle("done",!!this.#e),e.setAttribute("data-l10n-id",oi.#d[this.#g]),this.#s?.setAttribute("data-l10n-id",oi.#d[`${this.#g}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){e.classList.remove("done"),this.#i?.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=this.#i;if(!n){this.#i=n=document.createElement("span"),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${this.#l.id}`;const i=100,a=this.#l._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:a}),e.addEventListener("mouseleave",()=>{this.#a&&(clearTimeout(this.#a),this.#a=null),this.#i?.classList.remove("show")},{signal:a})}this.#t?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=this.#e),n.parentNode||e.append(n),this.#l.getElementForAltText()?.setAttribute("aria-describedby",n.id)}}class q0{static{p(this,"Comment")}#e=null;#t=null;#n=!1;#s=null;#i=null;#a=null;#r=null;#o=null;#l=!1;#f=null;constructor(e){this.#s=e}renderForToolbar(){const e=this.#t=document.createElement("button");return e.className="comment",this.#u(e,!1)}renderForStandalone(){const e=this.#e=document.createElement("button");e.className="annotationCommentButton";const n=this.#s.commentButtonPosition;if(n){const{style:s}=e;s.insetInlineEnd=`calc(${100*(this.#s._uiManager.direction==="ltr"?1-n[0]:n[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*n[1]}% - var(--comment-button-dim))`;const i=this.#s.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;const e=this.#s.commentButtonColor;e&&(this.#e.style.backgroundColor=e),this.#s._uiManager.updatePopupColor(this.#s)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#s.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#f)return this.#f;if(!this.#e)return null;const{x:e,y:n,height:s}=this.#e.getBoundingClientRect(),{x:i,y:a,width:r,height:o}=this.#s.parent.boundingClientRect;return[(e-i)/r,(n+s-a)/o]}set commentPopupPositionInLayer(e){this.#f=e}hasDefaultPopupPosition(){return this.#f===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:n}){this.#e&&(this.#e.classList.toggle("selected",e),this.#e.ariaExpanded=n)}#u(e,n){if(!this.#s._uiManager.hasCommentManager())return null;e.tabIndex="0",e.ariaHasPopup="dialog",n?(e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(e.ariaControlsElements=[this.#s._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=this.#s._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return e;e.addEventListener("contextmenu",ms,{signal:s}),n&&(e.addEventListener("focusin",a=>{this.#s._focusEventsAllowed=!1,Nt(a)},{capture:!0,signal:s}),e.addEventListener("focusout",a=>{this.#s._focusEventsAllowed=!0,Nt(a)},{capture:!0,signal:s})),e.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const i=p(a=>{a.preventDefault(),e===this.#t?this.edit():this.#s.toggleComment(!0)},"onClick");return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",a=>{a.target===e&&a.key==="Enter"&&(this.#n=!0,i(a))},{signal:s}),e.addEventListener("pointerenter",()=>{this.#s.toggleComment(!1,!0)},{signal:s}),e.addEventListener("pointerleave",()=>{this.#s.toggleComment(!1,!1)},{signal:s}),e}edit(e){const n=this.commentPopupPositionInLayer;let s,i;if(n)[s,i]=n;else{[s,i]=this.#s.commentButtonPosition;const{width:c,height:h,x:u,y:d}=this.#s;s=u+s*c,i=d+i*h}const a=this.#s.parent.boundingClientRect,{x:r,y:o,width:l,height:f}=a;this.#s._uiManager.editComment(this.#s,r+s*l,o+i*f,{...e,parentDimensions:a})}finish(){this.#t&&(this.#t.focus({focusVisible:this.#n}),this.#n=!1)}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#i}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(e){if(e!==this.#r&&(this.#a=null),e===null){this.#r="",this.#l=!0;return}this.#r=e,this.#o=new Date,this.#l=!1}restoreData({text:e,richText:n,date:s}){this.#r=e,this.#a=n,this.#o=s,this.#l=!1}setInitialText(e,n=null){this.#i=e,this.data=e,this.#o=null,this.#a=n}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#r="",this.#a=null,this.#o=null,this.#s=null,this.#n=!1,this.#l=!1}}class Zo{static{p(this,"TouchManager")}#e;#t=!1;#n=null;#s;#i;#a;#r;#o=null;#l;#f=null;#u;#c=null;constructor({container:e,isPinchingDisabled:n=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:r=null,signal:o}){this.#e=e,this.#n=s,this.#s=n,this.#i=i,this.#a=a,this.#r=r,this.#u=new AbortController,this.#l=AbortSignal.any([o,this.#u.signal]),e.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#l})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ws.pixelRatio}#d(e){if(this.#s?.())return;if(e.touches.length===1){if(this.#o)return;const i=this.#o=new AbortController,a=AbortSignal.any([this.#l,i.signal]),r=this.#e,o={capture:!0,signal:a,passive:!1},l=p(f=>{f.pointerType==="touch"&&(this.#o?.abort(),this.#o=null)},"cancelPointerDown");r.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Nt(f),l(f))},o),r.addEventListener("pointerup",l,o),r.addEventListener("pointercancel",l,o);return}if(!this.#c){this.#c=new AbortController;const i=AbortSignal.any([this.#l,this.#c.signal]),a=this.#e,r={signal:i,capture:!1,passive:!1};a.addEventListener("touchmove",this.#g.bind(this),r);const o=this.#m.bind(this);a.addEventListener("touchend",o,r),a.addEventListener("touchcancel",o,r),r.capture=!0,a.addEventListener("pointerdown",Nt,r),a.addEventListener("pointermove",Nt,r),a.addEventListener("pointercancel",Nt,r),a.addEventListener("pointerup",Nt,r),this.#i?.()}if(Nt(e),e.touches.length!==2||this.#n?.()){this.#f=null;return}let[n,s]=e.touches;n.identifier>s.identifier&&([n,s]=[s,n]),this.#f={touch0X:n.screenX,touch0Y:n.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#g(e){if(!this.#f||e.touches.length!==2)return;Nt(e);let[n,s]=e.touches;n.identifier>s.identifier&&([n,s]=[s,n]);const{screenX:i,screenY:a}=n,{screenX:r,screenY:o}=s,l=this.#f,{touch0X:f,touch0Y:c,touch1X:h,touch1Y:u}=l,d=h-f,m=u-c,g=r-i,b=o-a,w=Math.hypot(g,b)||1,x=Math.hypot(d,m)||1;if(!this.#t&&Math.abs(x-w)<=Zo.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=a,l.touch1X=r,l.touch1Y=o,!this.#t){this.#t=!0;return}const y=[(i+r)/2,(a+o)/2];this.#a?.(y,x,w)}#m(e){e.touches.length>=2||(this.#c&&(this.#c.abort(),this.#c=null,this.#r?.()),this.#f&&(Nt(e),this.#f=null,this.#t=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#o?.abort(),this.#o=null}}class We{static{p(this,"AnnotationEditor")}#e=null;#t=null;#n=null;#s=null;#i=null;#a=!1;#r=null;#o="";#l=null;#f=null;#u=null;#c=null;#d=null;#g="";#m=!1;#h=null;#p=!1;#b=!1;#y=!1;#x=null;#v=0;#C=0;#w=null;#q=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#j=!1;#S=We._zIndex++;static _borderLineWidth=-1;static _colorManager=new Ah;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const e=We.prototype._resizeWithKeyboard,n=Si.TRANSLATE_SMALL,s=Si.TRANSLATE_BIG;return st(this,"_resizerKeyboardManager",new Po([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],We.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;const{rotation:n,rawDims:{pageWidth:s,pageHeight:i,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[a,r];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return st(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const n=new T6({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});n.annotationElementId=e.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(e,n){if(We._l10n??=e,We._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"}),We._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);We._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,n){It("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#j}set _isDraggable(e){this.#j=e,this.div?.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(e*2),this.y+=this.width*e/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(e*2),this.y-=this.width*e/(n*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#S}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):(this.#L(),this.#c?.remove(),this.#c=null),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(e){!this._focusEventsAllowed||!this.isAttachedToDOM||e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,n,s,i){const[a,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(e+s)/a,this.y=(n+i)/r,this.fixAndSetPosition()}_moveAfterPaste(e,n){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(e*s,n*i,this.width*s,this.height*i),this._onTranslated()}#T([e,n],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/e,this.y+=i/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,n){this.#T(this.parentDimensions,e,n)}translateInPage(e,n){this.#h||=[this.x,this.y,this.width,this.height],this.#T(this.pageDimensions,e,n),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,n){this.#h||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,a]}=this;if(this.x+=e/i,this.y+=n/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:o}=this;const[l,f]=this.getBaseTranslation();r+=l,o+=f;const{style:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(r,o),s.scrollIntoView({block:"nearest"})}_onTranslating(e,n){}_onTranslated(e,n){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:s}=We,i=s/e,a=s/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:n},pageDimensions:[s,i]}=this;let{x:a,y:r,width:o,height:l}=this;if(o*=s,l*=i,a*=s,r*=i,this._mustFixPosition)switch(e){case 0:a=hn(a,0,s-o),r=hn(r,0,i-l);break;case 90:a=hn(a,0,s-l),r=hn(r,o,i);break;case 180:a=hn(a,o,s),r=hn(r,l,i);break;case 270:a=hn(a,l,s),r=hn(r,0,i-o);break}this.x=a/=s,this.y=r/=i;const[f,c]=this.getBaseTranslation();a+=f,r+=c,n.left=`${(100*a).toFixed(2)}%`,n.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#E(e,n,s){switch(s){case 90:return[n,-e];case 180:return[-e,-n];case 270:return[-n,e];default:return[e,n]}}screenToPageTranslation(e,n){return We.#E(e,n,this.parentRotation)}pageTranslationToScreen(e,n){return We.#E(e,n,360-this.parentRotation)}#I(e){switch(e){case 90:{const[n,s]=this.pageDimensions;return[0,-n/s,s/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,s]=this.pageDimensions;return[0,n/s,-s/n,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[n,s]}=this;return[n*e,s*e]}setDims(){const{div:{style:e},width:n,height:s}=this;e.width=`${(100*n).toFixed(2)}%`,e.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#R(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const s of e){const i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#F.bind(this,s),{signal:n}),i.addEventListener("contextmenu",ms,{signal:n}),i.tabIndex=-1}this.div.prepend(this.#l)}#F(e,n){n.preventDefault();const{isMac:s}=rn.platform;if(n.button!==0||n.ctrlKey&&s)return;this.#n?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,this.#f=[n.screenX,n.screenY];const a=new AbortController,r=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#M.bind(this,e),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Nt,{passive:!1,signal:r}),window.addEventListener("contextmenu",ms,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const f=p(()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,this.#_()},"pointerUpCallback");window.addEventListener("pointerup",f,{signal:r}),window.addEventListener("blur",f,{signal:r})}#B(e,n,s,i){this.width=s,this.height=i,this.x=e,this.y=n,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#_(){if(!this.#u)return;const{savedX:e,savedY:n,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;const a=this.x,r=this.y,o=this.width,l=this.height;a===e&&r===n&&o===s&&l===i||this.addCommands({cmd:this.#B.bind(this,a,r,o,l),undo:this.#B.bind(this,e,n,s,i),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#M(e,n){const[s,i]=this.parentDimensions,a=this.x,r=this.y,o=this.width,l=this.height,f=We.MIN_SIZE/s,c=We.MIN_SIZE/i,h=this.#I(this.rotation),u=p((z,O)=>[h[0]*z+h[2]*O,h[1]*z+h[3]*O],"transf"),d=this.#I(360-this.rotation),m=p((z,O)=>[d[0]*z+d[2]*O,d[1]*z+d[3]*O],"invTransf");let g,b,w=!1,x=!1;switch(e){case"topLeft":w=!0,g=p((z,O)=>[0,0],"getPoint"),b=p((z,O)=>[z,O],"getOpposite");break;case"topMiddle":g=p((z,O)=>[z/2,0],"getPoint"),b=p((z,O)=>[z/2,O],"getOpposite");break;case"topRight":w=!0,g=p((z,O)=>[z,0],"getPoint"),b=p((z,O)=>[0,O],"getOpposite");break;case"middleRight":x=!0,g=p((z,O)=>[z,O/2],"getPoint"),b=p((z,O)=>[0,O/2],"getOpposite");break;case"bottomRight":w=!0,g=p((z,O)=>[z,O],"getPoint"),b=p((z,O)=>[0,0],"getOpposite");break;case"bottomMiddle":g=p((z,O)=>[z/2,O],"getPoint"),b=p((z,O)=>[z/2,0],"getOpposite");break;case"bottomLeft":w=!0,g=p((z,O)=>[0,O],"getPoint"),b=p((z,O)=>[z,0],"getOpposite");break;case"middleLeft":x=!0,g=p((z,O)=>[0,O/2],"getPoint"),b=p((z,O)=>[z,O/2],"getOpposite");break}const y=g(o,l),j=b(o,l);let v=u(...j);const q=We._round(a+v[0]),A=We._round(r+v[1]);let C=1,S=1,I,T;if(n.fromKeyboard)({deltaX:I,deltaY:T}=n);else{const{screenX:z,screenY:O}=n,[N,oe]=this.#f;[I,T]=this.screenToPageTranslation(z-N,O-oe),this.#f[0]=z,this.#f[1]=O}if([I,T]=m(I/s,T/i),w){const z=Math.hypot(o,l);C=S=Math.max(Math.min(Math.hypot(j[0]-y[0]-I,j[1]-y[1]-T)/z,1/o,1/l),f/o,c/l)}else x?C=hn(Math.abs(j[0]-y[0]-I),f,1)/o:S=hn(Math.abs(j[1]-y[1]-T),c,1)/l;const P=We._round(o*C),H=We._round(l*S);v=u(...b(P,H));const G=q-v[0],Z=A-v[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=P,this.height=H,this.x=G,this.y=Z,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#b)return this._editToolbar;this._editToolbar=new Jo(this),this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[n,s]of e)await this._editToolbar.addButton(n,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#n?.destroy()}addContainer(e){const n=this._editToolbar?.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(oi.initialize(We._l10n),this.#n=new oi(this),this.#e&&(this.#n.data=this.#e,this.#e=null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}focusCommentButton(){this.#s?.focusButton()}addCommentButton(){return this.canAddComment?this.#s||=new q0(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove("hidden");return}this.hasComment&&(this.#i=this.#s.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#s.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add("hidden")}get comment(){if(!this.#s)return null;const{data:{richText:e,text:n,date:s,deleted:i}}=this.#s;return{text:n,richText:e,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){this.#s||=new q0(this),typeof e=="object"&&e!==null?this.#s.restoreData(e):this.#s.data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:n,richText:s}){if(!n||(this.#s||=new q0(this),this.#s.setInitialText(e,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#s?.hasBeenEdited()}get hasDeletedComment(){return this.#s?.isDeleted()}get hasComment(){return!!this.#s&&!this.#s.isEmpty()&&!this.#s.isDeleted()}async editComment(e){this.#s||=new q0(this),this.#s.edit(e)}toggleComment(e,n=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,n)}setSelectedCommentButton(e){this.#s.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){const[,,,i]=e.rect,[a]=this.pageDimensions,[r]=this.pageTranslation,o=r+a+1,l=i-100,f=o+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,f,i]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:n}}){this.#s.data=n?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=this.#a?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),this.#O();const[n,s]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*s/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/s).toFixed(2)}%`);const[i,a]=this.getInitialTranslation();return this.translate(i,a),vp(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#q||=new Zo({container:e,isPinchingDisabled:p(()=>!this.isSelected,"isPinchingDisabled"),onPinchStart:this.#H.bind(this),onPinching:this.#z.bind(this),onPinchEnd:this.#A.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#H(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#z(e,n,s){let a=.7*(s/n)+1-.7;if(a===1)return;const r=this.#I(this.rotation),o=p((q,A)=>[r[0]*q+r[2]*A,r[1]*q+r[3]*A],"transf"),[l,f]=this.parentDimensions,c=this.x,h=this.y,u=this.width,d=this.height,m=We.MIN_SIZE/l,g=We.MIN_SIZE/f;a=Math.max(Math.min(a,1/u,1/d),m/u,g/d);const b=We._round(u*a),w=We._round(d*a);if(b===u&&w===d)return;this.#h||=[c,h,u,d];const x=o(u/2,d/2),y=We._round(c+x[0]),j=We._round(h+x[1]),v=o(b/2,w/2);this.x=y-v[0],this.y=j-v[1],this.width=b,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#A(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#_()}pointerdown(e){const{isMac:n}=rn.platform;if(e.button!==0||e.ctrlKey&&n){e.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#D(e);return}this.#k(e)}#k(e){const{isMac:n}=rn.platform;e.ctrlKey&&!n||e.shiftKey||e.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)}#D(e){const{isSelected:n}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,a=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:a},o=p(f=>{i.abort(),this.#r=null,this.#m=!1,this._uiManager.endDragSession()||this.#k(f),s&&this._onStopDragging()},"cancelDrag");n&&(this.#v=e.clientX,this.#C=e.clientY,this.#r=e.pointerId,this.#o=e.pointerType,window.addEventListener("pointermove",f=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:h,pointerId:u}=f;if(u!==this.#r){Nt(f);return}const[d,m]=this.screenToPageTranslation(c-this.#v,h-this.#C);this.#v=c,this.#C=h,this._uiManager.dragSelectedEditors(d,m)},r),window.addEventListener("touchmove",Nt,r),window.addEventListener("pointerdown",f=>{f.pointerType===this.#o&&(this.#q||f.isPrimary)&&o(f),Nt(f)},r));const l=p(f=>{if(!this.#r||this.#r===f.pointerId){o(f);return}Nt(f)},"pointerUpCallback");window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#x&&clearTimeout(this.#x),this.#x=setTimeout(()=>{this.#x=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,n,s){e.changeParent(this),this.x=n,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(e,n,s=this.rotation){const i=this.parentScale,[a,r]=this.pageDimensions,[o,l]=this.pageTranslation,f=e/i,c=n/i,h=this.x*a,u=this.y*r,d=this.width*a,m=this.height*r;switch(s){case 0:return[h+f+o,r-u-c-m+l,h+f+d+o,r-u-c+l];case 90:return[h+c+o,r-u+f+l,h+c+m+o,r-u+f+d+l];case 180:return[h-f-d+o,r-u+c+l,h-f+o,r-u+c+m+l];case 270:return[h-c-m+o,r-u-f-d+l,h-c+o,r-u-f+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,n){const[s,i,a,r]=e,o=a-s,l=r-i;switch(this.rotation){case 0:return[s,n-r,o,l];case 90:return[s,n-i,l,o];case 180:return[a,n-i,o,l];case 270:return[a,n-r,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&We._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#s?.onUpdatedColor()}getData(){const{comment:{text:e,color:n,date:s,opacity:i,deleted:a,richText:r},uid:o,pageIndex:l,creationDate:f,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:r,contentsObj:{str:e},creationDate:f,modificationDate:s||c,popupRef:!a,color:n,opacity:i}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#b=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#b=!1,!0):!1}isInEditMode(){return this.#b}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:n,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:a,innerWidth:r}=window;return n<r&&i>0&&e<a&&s>0}#O(){if(this.#d||!this.div)return;this.#d=new AbortController;const e=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#O()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,n=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(e,n,s){const i=new this.prototype.constructor({parent:n,id:s.getId(),uiManager:s,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});i.rotation=e.rotation,i.#e=e.accessibilityData,i._isCopy=e.isCopy||!1;const[a,r]=i.pageDimensions,[o,l,f,c]=i.getRectInCurrentCoords(e.rect,r);return i.x=o/a,i.y=l/r,i.width=f/a,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#x&&(clearTimeout(this.#x),this.#x=null),this.#L(),this.removeEditToolbar(),this.#w){for(const e of this.#w.values())clearTimeout(e);this.#w=null}this.parent=null,this.#q?.destroy(),this.#q=null,this.#c?.remove(),this.#c=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#R(),this.#l.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,n]}=this,[s,i,a,r]=this.getPDFRect();return[We._round(s+(a-s)*e),We._round(i+(r-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#s.commentPopupPositionInLayer}set commentPopupPosition(e){this.#s.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#s.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#s.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#s?.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const n=this.#l.children;if(!this.#t){this.#t=Array.from(n);const r=this.#G.bind(this),o=this.#X.bind(this),l=this._uiManager._signal;for(const f of this.#t){const c=f.getAttribute("data-resizer-name");f.setAttribute("role","spinbutton"),f.addEventListener("keydown",r,{signal:l}),f.addEventListener("blur",o,{signal:l}),f.addEventListener("focus",this.#V.bind(this,c),{signal:l}),f.setAttribute("data-l10n-id",We._l10nResizer[c])}}const s=this.#t[0];let i=0;for(const r of n){if(r===s)break;i++}const a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let o=0;o<i-a;o++)this.#l.append(this.#l.firstElementChild);else if(a>i)for(let o=0;o<a-i;o++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(const o of n){const f=this.#t[r++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",We._l10nResizer[f])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#G(e){We._resizerKeyboardManager.exec(this,e)}#X(e){this.#y&&e.relatedTarget?.parentNode!==this.#l&&this.#L()}#V(e){this.#g=this.#y?e:""}#K(e){if(this.#t)for(const n of this.#t)n.tabIndex=e}_resizeWithKeyboard(e,n){this.#y&&this.#M(this.#g,{deltaX:e,deltaY:n,fromKeyboard:!0})}#L(){this.#y=!1,this.#K(-1),this.#_()}_stopResizingWithKeyboard(){this.#L(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,n){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(e){this.#p=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,n=!1){if(n){this.#w||=new Map;const{action:s}=e;let i=this.#w.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},We._telemetryTimeout),this.#w.set(s,i);return}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(e){if(!this.#c&&!this.deleted){this.#c=e.addFakeAnnotation(this);return}if(this.deleted){this.#c.remove(),this.#c=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#c.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let n=e.container.querySelector(".annotationContent");if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),e.container.prepend(n);else if(n.nodeName==="CANVAS"){const s=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),s.before(n)}return n}resetAnnotationElement(e){const{firstElementChild:n}=e.container;n?.nodeName==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}}class T6 extends We{static{p(this,"FakeEditor")}constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const qp=3285377520,Es=4294901760,ii=65535;class Ap{static{p(this,"MurmurHash3_64")}constructor(e){this.h1=e?e&4294967295:qp,this.h2=e?e&4294967295:qp}update(e){let n,s;if(typeof e=="string"){n=new Uint8Array(e.length*2),s=0;for(let g=0,b=e.length;g<b;g++){const w=e.charCodeAt(g);w<=255?n[s++]=w:(n[s++]=w>>>8,n[s++]=w&255)}}else if(ArrayBuffer.isView(e))n=e.slice(),s=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,a=s-i*4,r=new Uint32Array(n.buffer,0,i);let o=0,l=0,f=this.h1,c=this.h2;const h=3432918353,u=461845907,d=h&ii,m=u&ii;for(let g=0;g<i;g++)g&1?(o=r[g],o=o*h&Es|o*d&ii,o=o<<15|o>>>17,o=o*u&Es|o*m&ii,f^=o,f=f<<13|f>>>19,f=f*5+3864292196):(l=r[g],l=l*h&Es|l*d&ii,l=l<<15|l>>>17,l=l*u&Es|l*m&ii,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,a){case 3:o^=n[i*4+2]<<16;case 2:o^=n[i*4+1]<<8;case 1:o^=n[i*4],o=o*h&Es|o*d&ii,o=o<<15|o>>>17,o=o*u&Es|o*m&ii,i&1?f^=o:c^=o}this.h1=f,this.h2=c}hexdigest(){let e=this.h1,n=this.h2;return e^=n>>>1,e=e*3981806797&Es|e*36045&ii,n=n*4283543511&Es|((n<<16|e>>>16)*2950163797&Es)>>>16,e^=n>>>1,e=e*444984403&Es|e*60499&ii,n=n*3301882366&Es|((n<<16|e>>>16)*3120437893&Es)>>>16,e^=n>>>1,(e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const Do=Object.freeze({map:null,hash:"",transfer:void 0});class ah{static{p(this,"AnnotationStorage")}#e=!1;#t=null;#n=null;#s=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,n){const s=this.#s.get(e);return s===void 0?n:Object.assign(n,s)}getRawValue(e){return this.#s.get(e)}remove(e){const n=this.#s.get(e);n!==void 0&&(n instanceof We&&this.#n.delete(n.annotationElementId),this.#s.delete(e),this.#s.size===0&&this.resetModified(),!this.#s.values().some(s=>s instanceof We)&&this.onAnnotationEditor?.(null))}setValue(e,n){const s=this.#s.get(e);let i=!1;if(s!==void 0)for(const[a,r]of Object.entries(n))s[a]!==r&&(i=!0,s[a]=r);else i=!0,this.#s.set(e,n);i&&this.#i(),n instanceof We&&((this.#n||=new Map).set(n.annotationElementId,n),this.onAnnotationEditor?.(n.constructor._type))}has(e){return this.#s.has(e)}get size(){return this.#s.size}#i(){this.#e||(this.#e=!0,this.onSetModified?.())}resetModified(){this.#e&&(this.#e=!1,this.onResetModified?.())}get print(){return new Sp(this)}get serializable(){if(this.#s.size===0)return Do;const e=new Map,n=new Ap,s=[],i=Object.create(null);let a=!1;for(const[r,o]of this.#s){const l=o instanceof We?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(e.set(r,l),n.update(`${r}:${JSON.stringify(l)}`),a||=!!l.bitmap)}if(a)for(const r of e.values())r.bitmap&&s.push(r.bitmap);return e.size>0?{map:e,hash:n.hexdigest(),transfer:s}:Do}get editorStats(){let e=null;const n=new Map;let s=0,i=0;for(const a of this.#s.values()){if(!(a instanceof We)){a.popup&&(a.popup.deleted?i+=1:s+=1);continue}a.isCommentDeleted?i+=1:a.hasEditedComment&&(s+=1);const r=a.telemetryFinalData;if(!r)continue;const{type:o}=r;n.has(o)||n.set(o,Object.getPrototypeOf(a).constructor),e||=Object.create(null);const l=e[o]||=new Map;for(const[f,c]of Object.entries(r)){if(f==="type")continue;const h=l.getOrInsertComputed(f,b0);h.set(c,(h.get(c)??0)+1)}}if((i>0||s>0)&&(e||=Object.create(null),e.comments={deleted:i,edited:s}),!e)return null;for(const[a,r]of n)e[a]=r.computeTelemetryFinalData(e[a]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,n){const s=this.#n?.get(e);return s?(s.updateFromAnnotationLayer(n),!0):!1}getEditor(e){return this.#n?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;const e=[];if(this.#n)for(const n of this.#n.values())n.serialize()&&e.push(n.annotationElementId);return this.#t={ids:new Set(e),hash:e.join(",")}}[Symbol.iterator](){return this.#s.entries()}}class Sp extends ah{static{p(this,"PrintAnnotationStorage")}#e=Do;constructor(e){super();const{serializable:n}=e;if(n===Do)return;const{map:s,hash:i,transfer:a}=n,r=structuredClone(s,a?{transfer:a}:null);this.#e={map:r,hash:i,transfer:[]}}get print(){It("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#e}get modifiedIds(){return st(this,"modifiedIds",{ids:new Set,hash:""})}}const dr="__forcedDependency",{floor:Cp,ceil:Ip}=Math;function Tp(t,e,n,s,i,a){t[e*4+0]=Math.min(t[e*4+0],n),t[e*4+1]=Math.min(t[e*4+1],s),t[e*4+2]=Math.max(t[e*4+2],i),t[e*4+3]=Math.max(t[e*4+3],a)}p(Tp,"expandBBox");const rh=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class E6{static{p(this,"BBoxReader")}#e;#t;constructor(e,n){this.#e=e,this.#t=n}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===rh}minX(e){return this.#t[e*4+0]/256}minY(e){return this.#t[e*4+1]/256}maxX(e){return(this.#t[e*4+2]+1)/256}maxY(e){return(this.#t[e*4+3]+1)/256}}const Ep=p((t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1})),"ensureDebugMetadata");class F6{static{p(this,"CanvasBBoxTracker")}#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#n=new Float64Array([1/0,1/0,-1/0,-1/0]);_pendingBBoxIdx=-1;#s;#i;#a;#r;_savesStack=[];_markedContentStack=[];constructor(e,n){this.#s=e.width,this.#i=e.height,this.#o(n)}growOperationsCount(e){e>=this.#r.length&&this.#o(e,this.#r)}#o(e,n){const s=new ArrayBuffer(e*4);this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),n&&n.length>0?(this.#r.set(n),this.#r.fill(rh,n.length)):this.#r.fill(rh)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,n){const s=Object.getPrototypeOf(this.#t);if(s===null)return this;this.#t=s;const i=this._savesStack.pop();return i!==void 0&&(n?.(i,e),this.#r[e]=this.#r[i]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,n){const s=this._savesStack.pop();return s!==void 0&&(n?.(s,e),this.#r[e]=this.#r[s]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,n){const s=this._markedContentStack.pop();return s!==void 0&&(n?.(s,e),this.#r[e]=this.#r[s]),this}pushBaseTransform(e){return this.#e.push(Ie.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){return this.#e.length>1&&this.#e.pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,this.#n[0]=1/0,this.#n[1]=1/0,this.#n[2]=-1/0,this.#n[3]=-1/0),this}recordClipBox(e,n,s,i,a,r){const o=Ie.multiplyByDOMMatrix(this.#e.at(-1),n.getTransform()),l=[1/0,1/0,-1/0,-1/0];Ie.axialAlignedBoundingBox([s,a,i,r],o,l);const f=Ie.intersect(this.#t,l);return f?(this.#t[0]=f[0],this.#t[1]=f[1],this.#t[2]=f[2],this.#t[3]=f[3]):(this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0),this}recordBBox(e,n,s,i,a,r){const o=this.#t;if(o[0]===1/0)return this;const l=Ie.multiplyByDOMMatrix(this.#e.at(-1),n.getTransform());if(o[0]===-1/0)return Ie.axialAlignedBoundingBox([s,a,i,r],l,this.#n),this;const f=[1/0,1/0,-1/0,-1/0];return Ie.axialAlignedBoundingBox([s,a,i,r],l,f),this.#n[0]=Math.min(this.#n[0],Math.max(f[0],o[0])),this.#n[1]=Math.min(this.#n[1],Math.max(f[1],o[1])),this.#n[2]=Math.max(this.#n[2],Math.min(f[2],o[2])),this.#n[3]=Math.max(this.#n[3],Math.min(f[3],o[3])),this}recordFullPageBBox(e){return this.#n[0]=Math.max(0,this.#t[0]),this.#n[1]=Math.max(0,this.#t[1]),this.#n[2]=Math.min(this.#s,this.#t[2]),this.#n[3]=Math.min(this.#i,this.#t[3]),this}recordOperation(e,n=!1,s){if(this._pendingBBoxIdx!==e)return this;const i=Cp(this.#n[0]*256/this.#s),a=Cp(this.#n[1]*256/this.#i),r=Ip(this.#n[2]*256/this.#s),o=Ip(this.#n[3]*256/this.#i);if(Tp(this.#a,e,i,a,r,o),s)for(const l of s)for(const f of l)f!==e&&Tp(this.#a,f,i,a,r,o);return n||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#n[0]),this.#t[1]=Math.max(this.#t[1],this.#n[1]),this.#t[2]=Math.min(this.#t[2],this.#n[2]),this.#t[3]=Math.min(this.#t[3],this.#n[3])),this}take(){return new E6(this.#r,this.#a)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(e,n){return this}recordIncrementalData(e,n){return this}resetIncrementalData(e,n){return this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,s){return this}recordFutureForcedDependency(e,n){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,n,s,i=1,a=0,r=0,o){return this}getSimpleIndex(e){}recordDependencies(e,n){return this}recordNamedDependency(e,n){return this}recordShowTextOperation(e,n=!1){return this}}class B6{static{p(this,"CanvasDependencyTracker")}#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[dr]:[]};#n=new Map;#s=new Set;#i=new Map;#a;#r;#o;constructor(e,n=!1){this.#o=e,n&&(this.#a=new Map,this.#r=(s,i)=>{Ep(this.#a,i).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(e){this.#o.growOperationsCount(e)}save(e){return this.#e={__proto__:this.#e},this.#t={__proto__:this.#t,transform:{__proto__:this.#t.transform},moveText:{__proto__:this.#t.moveText},sameLineText:{__proto__:this.#t.sameLineText},[dr]:{__proto__:this.#t[dr]}},this.#o.save(e),this}restore(e){this.#o.restore(e,this.#r);const n=Object.getPrototypeOf(this.#e);return n===null?this:(this.#e=n,this.#t=Object.getPrototypeOf(this.#t),this)}recordOpenMarker(e){return this.#o.recordOpenMarker(e,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(e){return this.#o.recordCloseMarker(e,this.#r),this}beginMarkedContent(e){return this.#o.beginMarkedContent(e),this}endMarkedContent(e){return this.#o.endMarkedContent(e,this.#r),this}pushBaseTransform(e){return this.#o.pushBaseTransform(e),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(e,n){return this.#e[e]=n,this}recordIncrementalData(e,n){return this.#t[e].push(n),this}resetIncrementalData(e,n){return this.#t[e].length=0,this}recordNamedData(e,n){return this.#n.set(e,n),this}recordSimpleDataFromNamed(e,n,s){this.#e[e]=this.#n.get(n)??s}recordFutureForcedDependency(e,n){return this.recordIncrementalData(dr,n),this}inheritSimpleDataAsFutureForcedDependencies(e){for(const n of e)n in this.#e&&this.recordFutureForcedDependency(n,this.#e[n]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of this.#s)this.recordFutureForcedDependency(dr,e);return this}resetBBox(e){return this.#o.resetBBox(e),this}recordClipBox(e,n,s,i,a,r){return this.#o.recordClipBox(e,n,s,i,a,r),this}recordBBox(e,n,s,i,a,r){return this.#o.recordBBox(e,n,s,i,a,r),this}recordCharacterBBox(e,n,s,i=1,a=0,r=0,o){const l=s.bbox;let f,c;if(l&&(f=l[2]!==l[0]&&l[3]!==l[1]&&this.#i.get(s),f!==!1&&(c=[0,0,0,0],Ie.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||a!==0||r!==0)&&Ie.scaleMinMax([i,0,0,-i,a,r],c),f)))return this.recordBBox(e,n,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(e);const h=o();return l&&c&&f===void 0&&(f=c[0]<=a-h.actualBoundingBoxLeft&&c[2]>=a+h.actualBoundingBoxRight&&c[1]<=r-h.actualBoundingBoxAscent&&c[3]>=r+h.actualBoundingBoxDescent,this.#i.set(s,f),f)?this.recordBBox(e,n,c[0],c[2],c[1],c[3]):this.recordBBox(e,n,a-h.actualBoundingBoxLeft,a+h.actualBoundingBoxRight,r-h.actualBoundingBoxAscent,r+h.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#o.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,n){const s=this.#s,i=this.#e,a=this.#t;for(const r of n)r in this.#e?s.add(i[r]):r in a&&a[r].forEach(s.add,s);return this}recordNamedDependency(e,n){return this.#n.has(n)&&this.#s.add(this.#n.get(n)),this}recordOperation(e,n=!1){if(this.recordDependencies(e,[dr]),this.#a){const i=Ep(this.#a,e),{dependencies:a}=i;this.#s.forEach(a.add,a),this.#o._savesStack.forEach(a.add,a),this.#o._markedContentStack.forEach(a.add,a),a.delete(e),i.isRenderingOperation=!0}const s=!n&&e===this.#o._pendingBBoxIdx;return this.#o.recordOperation(e,n,[this.#s,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#s.clear(),this}recordShowTextOperation(e,n=!1){const s=Array.from(this.#s);this.recordOperation(e,n),this.recordIncrementalData("sameLineText",e);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(e,n=!1){const s=!n&&e===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(e),s&&this.#s.clear(),this}take(){return this.#i.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class Q0{static{p(this,"CanvasNestedDependencyTracker")}#e;#t;#n;#s=0;#i=0;constructor(e,n,s){if(e instanceof Q0&&e.#n===!!s)return e;this.#e=e,this.#t=n,this.#n=!!s}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(e){return this.#i++,this.#e.save(this.#t),this}restore(e){return this.#i>0&&(this.#e.restore(this.#t),this.#i--),this}recordOpenMarker(e){return this.#s++,this}getOpenMarker(){return this.#s>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#s--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return this.#e.pushBaseTransform(e),this}popBaseTransform(){return this.#e.popBaseTransform(),this}recordSimpleData(e,n){return this.#e.recordSimpleData(e,this.#t),this}recordIncrementalData(e,n){return this.#e.recordIncrementalData(e,this.#t),this}resetIncrementalData(e,n){return this.#e.resetIncrementalData(e,this.#t),this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,s){return this.#e.recordSimpleDataFromNamed(e,n,this.#t),this}recordFutureForcedDependency(e,n){return this.#e.recordFutureForcedDependency(e,this.#t),this}inheritSimpleDataAsFutureForcedDependencies(e){return this.#e.inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#e.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return this.#n||this.#e.resetBBox(this.#t),this}recordClipBox(e,n,s,i,a,r){return this.#n||this.#e.recordClipBox(this.#t,n,s,i,a,r),this}recordBBox(e,n,s,i,a,r){return this.#n||this.#e.recordBBox(this.#t,n,s,i,a,r),this}recordCharacterBBox(e,n,s,i,a,r,o){return this.#n||this.#e.recordCharacterBBox(this.#t,n,s,i,a,r,o),this}recordFullPageBBox(e){return this.#n||this.#e.recordFullPageBBox(this.#t),this}getSimpleIndex(e){return this.#e.getSimpleIndex(e)}recordDependencies(e,n){return this.#e.recordDependencies(this.#t,n),this}recordNamedDependency(e,n){return this.#e.recordNamedDependency(this.#t,n),this}recordOperation(e){return this.#e.recordOperation(this.#t,!0),this}recordShowTextOperation(e){return this.#e.recordShowTextOperation(this.#t,!0),this}bboxToClipBoxDropOperation(e){return this.#n||this.#e.bboxToClipBoxDropOperation(this.#t,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Fs={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class J0{static{p(this,"CanvasImagesTracker")}#e;#t;#n=4;#s=0;#i=new J0.#a(this.#n*6);static#a=rn.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(e,n,s,i){if(this.#s===this.#n){this.#n*=2;const o=new J0.#a(this.#n*6);o.set(this.#i),this.#i=o}const a=Ie.domMatrixToTransform(e.getTransform());let r;if(i[0]!==1/0){const o=[1/0,1/0,-1/0,-1/0];Ie.axialAlignedBoundingBox([0,-s,n,0],a,o);const l=Ie.intersect(i,o);if(!l)return;const[f,c,h,u]=l;if(f!==o[0]||c!==o[1]||h!==o[2]||u!==o[3]){const d=Math.atan2(a[1],a[0]),m=Math.abs(Math.sin(d)),g=Math.abs(Math.cos(d));if(m<1e-6||g<1e-6||Math.abs(m-g)<1e-6)r=[f,c,f,u,h,c];else{const b=h-f,w=u-c,x=m*m,y=g*g,j=g*m,v=y-x,q=(w*y-b*j)/v,A=(w*j-b*x)/v;r=[f+A,c,f,c+q,h,u-q]}}}r||(r=[0,-s,0,0,n,-s],Ie.applyTransform(r,a,0),Ie.applyTransform(r,a,2),Ie.applyTransform(r,a,4)),r[0]/=this.#e,r[1]/=this.#t,r[2]/=this.#e,r[3]/=this.#t,r[4]/=this.#e,r[5]/=this.#t,this.#i.set(r,this.#s*6),this.#s++}take(){return this.#i.subarray(0,this.#s*6)}}class R6{static{p(this,"FontLoader")}#e=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:n=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const n=this.styleElement.sheet;n.insertRule(e,n.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#e.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:n,_inspectFont:s}){if(!(!e||this.#e.has(e.loadedName))){if(Lt(!n,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:a,style:r}=e,o=new FontFace(i,a,r);this.addNativeFontFace(o);try{await o.load(),this.#e.add(i),s?.(e)}catch{at(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}It("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const s=e.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw at(`Failed to load font '${s.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const n=e.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){const e=!!this._document?.fonts;return st(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return st(this,"isSyncFontLoadingSupported",Ts||rn.platform.isFirefox)}_queueLoadingCallback(e){function n(){for(Lt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const a=s.shift();setTimeout(a.callback,0)}}p(n,"completeRequest");const{loadingRequests:s}=this,i={done:!1,complete:n,callback:e};return s.push(i),i}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return st(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,n){function s(j,v){return j.charCodeAt(v)<<24|j.charCodeAt(v+1)<<16|j.charCodeAt(v+2)<<8|j.charCodeAt(v+3)&255}p(s,"int32");function i(j,v,q,A){const C=j.substring(0,v),S=j.substring(v+q);return C+A+S}p(i,"spliceString");let a,r;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let f=0;function c(j,v){if(++f>30){at("Load test font never loaded."),v();return}if(l.font="30px "+j,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){v();return}setTimeout(c.bind(null,j,v))}p(c,"isFontReady");const h=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,h.length,h);const m=16,g=1482184792;let b=s(u,m);for(a=0,r=h.length-3;a<r;a+=4)b=b-g+s(h,a)|0;a<h.length&&(b=b-g+s(h+"XXX",a)|0),u=i(u,m,4,w6(b));const w=`url(data:font/opentype;base64,${btoa(u)});`,x=`@font-face {font-family:"${h}";src:${w}}`;this.insertRule(x);const y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(const j of[e.loadedName,h]){const v=this._document.createElement("span");v.textContent="Hi",v.style.fontFamily=j,y.append(v)}this._document.body.append(y),c(h,()=>{y.remove(),n.complete()})}}class _6{static{p(this,"FontFaceObject")}compiledGlyphs=Object.create(null);#e;constructor(e,n=null,s,i){this.#e=e,this._inspectFont=n,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const n={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(n.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,n)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${e}}`}return this._inspectFont?.(this,e),n}getPathGenerator(e,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const s=this.loadedName+"_path_"+n;let i;try{i=e.get(s)}catch(r){at(`getPathGenerator - ignoring character: "${r}".`)}const a=jp(i?.path);return this.fontExtraProperties||e.delete(s),this.compiledGlyphs[n]=a}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){st(this,"disableFontFace",!!e)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get ascent(){return this.#e.ascent}get defaultWidth(){return this.#e.defaultWidth}get descent(){return this.#e.descent}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.#e.mimetype}get name(){return this.#e.name}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}get defaultVMetrics(){return this.#e.defaultVMetrics}}class P6{static{p(this,"CSS_FONT_INFO")}static strings=["fontFamily","fontWeight","italicAngle"]}class D6{static{p(this,"SYSTEM_FONT_INFO")}static strings=["css","loadedName","baseFontName","src"]}class Us{static{p(this,"FONT_INFO")}static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class Xi{static{p(this,"PATTERN_INFO")}static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class M6{static{p(this,"CssFontInfo")}#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}#s(e){Lt(e<P6.strings.length,"Invalid string index");let n=0;for(let i=0;i<e;i++)n+=this.#n.getUint32(n)+4;const s=this.#n.getUint32(n);return this.#t.decode(new Uint8Array(this.#e,n+4,s))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class H6{static{p(this,"SystemFontInfo")}#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}get guessFallback(){return this.#n.getUint8(0)!==0}#s(e){Lt(e<D6.strings.length,"Invalid string index");let n=5;for(let i=0;i<e;i++)n+=this.#n.getUint32(n)+4;const s=this.#n.getUint32(n);return this.#t.decode(new Uint8Array(this.#e,n+4,s))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let e=1;e+=4+this.#n.getUint32(e);const n=this.#n.getUint32(e),s=this.#t.decode(new Uint8Array(this.#e,e+4,n));e+=4+n;const i=this.#n.getUint32(e),a=this.#t.decode(new Uint8Array(this.#e,e+4,i));return{style:s,weight:a}}}class O6{static{p(this,"FontInfo")}#e;#t=new TextDecoder;#n;constructor({buffer:e,extra:n}){this.#e=e,this.#n=new DataView(e),n&&Object.assign(this,n)}#s(e){Lt(e<Us.bools.length,"Invalid boolean index");const n=Math.floor(e/4),s=e*2%8,i=this.#n.getUint8(n)>>s&3;return i===0?void 0:i===2}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#i(e){return Lt(e<Us.numbers.length,"Invalid number index"),this.#n.getFloat64(Us.OFFSET_NUMBERS+e*8)}get ascent(){return this.#i(0)}get defaultWidth(){return this.#i(1)}get descent(){return this.#i(2)}#a(e,n,s,i){const a=this.#n.getUint8(e);if(a===0)return;Lt(a===n,"Invalid array length."),e+=1;const r=new Array(a);for(let o=0;o<a;o++)r[o]=this.#n[s](e,!0),e+=i;return r}get bbox(){return this.#a(Us.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#a(Us.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#a(Us.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#r(e){Lt(e<Us.strings.length,"Invalid string index");let n=Us.OFFSET_STRINGS+4;for(let i=0;i<e;i++)n+=this.#n.getUint32(n)+4;const s=this.#n.getUint32(n);return this.#t.decode(new Uint8Array(this.#e,n+4,s))}get fallbackName(){return this.#r(0)}get loadedName(){return this.#r(1)}get mimetype(){return this.#r(2)}get name(){return this.#r(3)}#o(){let e=Us.OFFSET_STRINGS;const n=this.#n.getUint32(e);e+=4+n;const s=this.#n.getUint32(e);e+=4+s;const i=this.#n.getUint32(e);e+=4+i;const a=this.#n.getUint32(e);return{offset:e,length:a}}get data(){const{offset:e,length:n}=this.#o();return n===0?void 0:new Uint8Array(this.#e,e+4,n)}clearData(){const{offset:e,length:n}=this.#o();n!==0&&(this.#n.setUint32(e,0),this.#e=new Uint8Array(this.#e,0,e+4).slice().buffer,this.#n=new DataView(this.#e))}get cssFontInfo(){let e=Us.OFFSET_STRINGS;const n=this.#n.getUint32(e);e+=4+n;const s=this.#n.getUint32(e);e+=4+s;const i=this.#n.getUint32(e);if(i===0)return null;const a=new Uint8Array(i);return a.set(new Uint8Array(this.#e,e+4,i)),new M6(a.buffer)}get systemFontInfo(){let e=Us.OFFSET_STRINGS;const n=this.#n.getUint32(e);e+=4+n;const s=this.#n.getUint32(e);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(this.#e,e+4,s)),new H6(i.buffer)}}class L6{static{p(this,"PatternInfo")}constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){const e=this.view,n=this.data[Xi.KIND],s=!!this.data[Xi.HAS_BBOX],i=!!this.data[Xi.HAS_BACKGROUND],a=e.getUint32(Xi.N_COORD,!0),r=e.getUint32(Xi.N_COLOR,!0),o=e.getUint32(Xi.N_STOP,!0),l=e.getUint32(Xi.N_FIGURES,!0);let f=20;const c=new Float32Array(this.buffer,f,a*2);f+=a*8;const h=new Uint8Array(this.buffer,f,r*3);f+=r*3;const u=[];for(let b=0;b<o;++b){const w=e.getFloat32(f,!0);f+=4;const x=e.getUint32(f,!0);f+=4,u.push([w,`#${x.toString(16).padStart(6,"0")}`])}let d=null;if(s){d=[];for(let b=0;b<4;++b)d.push(e.getFloat32(f,!0)),f+=4}let m=null;i&&(m=new Uint8Array(this.buffer,f,3),f+=3);const g=[];for(let b=0;b<l;++b){const w=e.getUint8(f);f+=1,f=Math.ceil(f/4)*4;const x=e.getUint32(f,!0);f+=4;const y=new Int32Array(this.buffer,f,x);f+=x*4;const j=e.getUint32(f,!0);f+=4;const v=new Int32Array(this.buffer,f,j);f+=j*4;const q={type:w,coords:y,colors:v};w===Ia.LATTICE&&(q.verticesPerRow=e.getUint32(f,!0),f+=4),g.push(q)}if(n===1)return["RadialAxial","axial",d,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(n===2)return["RadialAxial","radial",d,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(n===3){const b=this.data[Xi.SHADING_TYPE];let w=null;if(c.length>0){w=[1/0,1/0,-1/0,-1/0];for(let x=0,y=c.length;x<y;x+=2)Ie.pointBoundingBox(c[x],c[x+1],w)}return["Mesh",b,c,h,g,w,d,m]}throw new Error(`Unsupported pattern kind: ${n}`)}}class N6{static{p(this,"FontPathInfo")}#e;constructor(e){this.#e=e}get path(){return rn.isFloat16ArraySupported?new Float16Array(this.#e):new Float32Array(this.#e)}}function z6(t){if(t instanceof URL)return t;if(typeof t=="string"){if(Ts){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);const n=process.getBuiltinModule("url");return new URL(n.pathToFileURL(t))}const e=URL.parse(t,window.location);if(e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}p(z6,"getUrlProp");function U6(t){if(Ts&&typeof Buffer<"u"&&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(typeof t=="string")return m0(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!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.")}p(U6,"getDataProp");function A0(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}p(A0,"getFactoryUrlProp");const oh=p(t=>typeof t=="object"&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,"isRefProxy"),G6=p(t=>typeof t=="object"&&typeof t?.name=="string","isNameProxy"),Fp=j6.bind(null,oh,G6);class W6{static{p(this,"LoopbackPort")}#e=new Map;#t=Promise.resolve();postMessage(e,n){const s={data:structuredClone(e,n?{transfer:n}:null)};this.#t.then(()=>{for(const[i]of this.#e)i.call(this,s)})}addEventListener(e,n,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:a}=s;if(a.aborted){at("LoopbackPort - cannot use an `aborted` signal.");return}const r=p(()=>this.removeEventListener(e,n),"onAbort");i=p(()=>a.removeEventListener("abort",r),"rmAbort"),a.addEventListener("abort",r)}this.#e.set(n,i)}removeEventListener(e,n){this.#e.get(n)?.(),this.#e.delete(n)}terminate(){for(const[,e]of this.#e)e?.();this.#e.clear()}}const S0={DATA:1,ERROR:2},on={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Bp(){}p(Bp,"onFn");function es(t){if(t instanceof qi||t instanceof p0||t instanceof lp||t instanceof Bo||t instanceof Jc)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||It('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new qi(t.message);case"InvalidPDFException":return new p0(t.message);case"PasswordException":return new lp(t.message,t.code);case"ResponseException":return new Bo(t.message,t.status,t.missing);case"UnknownErrorException":return new Jc(t.message,t.details)}return new Jc(t.message,t.toString())}p(es,"wrapReason");class Mo{static{p(this,"MessageHandler")}#e=new AbortController;constructor(e,n,s){this.sourceName=e,this.targetName=n,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",this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#s(e);return}if(e.callback){const s=e.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],e.callback===S0.DATA)i.resolve(e.data);else if(e.callback===S0.ERROR)i.reject(es(e.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const s=this.sourceName,i=e.sourceName,a=this.comObj;Promise.try(n,e.data).then(function(r){a.postMessage({sourceName:s,targetName:i,callback:S0.DATA,callbackId:e.callbackId,data:r})},function(r){a.postMessage({sourceName:s,targetName:i,callback:S0.ERROR,callbackId:e.callbackId,reason:es(r)})});return}if(e.streamId){this.#n(e);return}n(e.data)}on(e,n){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=n}send(e,n,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},s)}sendWithPromise(e,n,s){const i=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[i]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:n},s)}catch(r){a.reject(r)}return a.promise}sendWithStream(e,n,s,i){const a=this.streamId++,r=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:p(f=>{const c=Promise.withResolvers();return this.streamControllers[a]={controller:f,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:r,targetName:o,action:e,streamId:a,data:n,desiredSize:f.desiredSize},i),c.promise},"start"),pull:p(f=>{const c=Promise.withResolvers();return this.streamControllers[a].pullCall=c,l.postMessage({sourceName:r,targetName:o,stream:on.PULL,streamId:a,desiredSize:f.desiredSize}),c.promise},"pull"),cancel:p(f=>{Lt(f instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[a].cancelCall=c,this.streamControllers[a].isClosed=!0,l.postMessage({sourceName:r,targetName:o,stream:on.CANCEL,streamId:a,reason:es(f)}),c.promise},"cancel")},s)}#n(e){const n=e.streamId,s=this.sourceName,i=e.sourceName,a=this.comObj,r=this,o=this.actionHandler[e.action],l={enqueue(f,c=1,h){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:s,targetName:i,stream:on.ENQUEUE,streamId:n,chunk:f},h)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:i,stream:on.CLOSE,streamId:n}),delete r.streamSinks[n])},error(f){Lt(f instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:i,stream:on.ERROR,streamId:n,reason:es(f)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,Promise.try(o,e.data,l).then(function(){a.postMessage({sourceName:s,targetName:i,stream:on.START_COMPLETE,streamId:n,success:!0})},function(f){a.postMessage({sourceName:s,targetName:i,stream:on.START_COMPLETE,streamId:n,reason:es(f)})})}#s(e){const n=e.streamId,s=this.sourceName,i=e.sourceName,a=this.comObj,r=this.streamControllers[n],o=this.streamSinks[n];switch(e.stream){case on.START_COMPLETE:e.success?r.startCall.resolve():r.startCall.reject(es(e.reason));break;case on.PULL_COMPLETE:e.success?r.pullCall.resolve():r.pullCall.reject(es(e.reason));break;case on.PULL:if(!o){a.postMessage({sourceName:s,targetName:i,stream:on.PULL_COMPLETE,streamId:n,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Bp).then(function(){a.postMessage({sourceName:s,targetName:i,stream:on.PULL_COMPLETE,streamId:n,success:!0})},function(f){a.postMessage({sourceName:s,targetName:i,stream:on.PULL_COMPLETE,streamId:n,reason:es(f)})});break;case on.ENQUEUE:if(Lt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(e.chunk);break;case on.CLOSE:if(Lt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#i(r,n);break;case on.ERROR:Lt(r,"error should have stream controller"),r.controller.error(es(e.reason)),this.#i(r,n);break;case on.CANCEL_COMPLETE:e.success?r.cancelCall.resolve():r.cancelCall.reject(es(e.reason)),this.#i(r,n);break;case on.CANCEL:if(!o)break;const l=es(e.reason);Promise.try(o.onCancel||Bp,l).then(function(){a.postMessage({sourceName:s,targetName:i,stream:on.CANCEL_COMPLETE,streamId:n,success:!0})},function(f){a.postMessage({sourceName:s,targetName:i,stream:on.CANCEL_COMPLETE,streamId:n,reason:es(f)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}}async#i(e,n){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[n]}destroy(){this.#e?.abort(),this.#e=null}}class Rp{static{p(this,"BaseBinaryDataFactory")}#e=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:e=null,standardFontDataUrl:n=null,wasmUrl:s=null}){this.cMapUrl=e,this.standardFontDataUrl=n,this.wasmUrl=s}async fetch({kind:e,filename:n}){switch(e){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:It(`Not implemented: ${e}`)}const s=this[e];if(!s)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const i=`${s}${n}`;return this._fetch(i,e).catch(a=>{throw new Error(`Unable to load ${this.#e[e]} data at: ${i}`)})}async _fetch(e,n){It("Abstract method `_fetch` called.")}}class _p extends Rp{static{p(this,"DOMBinaryDataFactory")}async _fetch(e,n){const s=n==="cMapUrl"&&!e.endsWith(".bcmap")?"text":"bytes",i=await x0(e,s);return i instanceof Uint8Array?i:m0(i)}}class Pp{static{p(this,"BaseCanvasFactory")}#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,n){if(e<=0||n<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(e,n);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#e})}}reset({canvas:e},n,s){if(!e)throw new Error("Canvas is not specified");if(n<=0||s<=0)throw new Error("Invalid canvas size");e.width=n,e.height=s}destroy(e){const{canvas:n}=e;if(!n)throw new Error("Canvas is not specified");n.width=n.height=0,e.canvas=null,e.context=null}_createCanvas(e,n){It("Abstract method `_createCanvas` called.")}}class $6 extends Pp{static{p(this,"DOMCanvasFactory")}constructor({ownerDocument:e=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=e}_createCanvas(e,n){const s=this._document.createElement("canvas");return s.width=e,s.height=n,s}}class Dp{static{p(this,"BaseFilterFactory")}addFilter(e){return"none"}addHCMFilter(e,n){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,n,s,i,a){return"none"}destroy(e=!1){}}class V6 extends Dp{static{p(this,"DOMFilterFactory")}#e;#t;#n;#s;#i;#a;#r=0;constructor({docId:e,ownerDocument:n=globalThis.document}){super(),this.#s=e,this.#i=n}get#o(){return this.#t||=new Map}get#l(){return this.#a||=new Map}get#f(){if(!this.#n){const e=this.#i.createElement("div"),{style:n}=e;n.visibility="hidden",n.contain="strict",n.width=n.height=0,n.position="absolute",n.top=n.left=0,n.zIndex=-1;const s=this.#i.createElementNS(Ai,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#n=this.#i.createElementNS(Ai,"defs"),e.append(s),s.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){const l=e[0],f=new Array(256);for(let h=0;h<256;h++)f[h]=l[h]/255;const c=f.join(",");return[c,c,c]}const[n,s,i]=e,a=new Array(256),r=new Array(256),o=new Array(256);for(let l=0;l<256;l++)a[l]=n[l]/255,r[l]=s[l]/255,o[l]=i[l]/255;return[a.join(","),r.join(","),o.join(",")]}#c(e){if(this.#e===void 0){this.#e="";const n=this.#i.URL;n!==this.#i.baseURI&&(Ro(n)?at('#createUrl: ignore "data:"-URL for performance reasons.'):this.#e=Yc(n,""))}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return"none";let n=this.#o.get(e);if(n)return n;const[s,i,a]=this.#u(e),r=e.length===1?s:`${s}${i}${a}`;if(n=this.#o.get(r),n)return this.#o.set(e,n),n;const o=`g_${this.#s}_transfer_map_${this.#r++}`,l=this.#c(o);this.#o.set(e,l),this.#o.set(r,l);const f=this.#m(o);return this.#p(s,i,a,f),l}addHCMFilter(e,n){const s=`${e}-${n}`,i="base";let a=this.#l.get(i);if(a?.key===s||(a?(a.filter?.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},this.#l.set(i,a)),!e||!n))return a.url;const r=this.#y(e);e=Ie.makeHexColor(...r);const o=this.#y(n);if(n=Ie.makeHexColor(...o),this.#f.style.color="",e==="#000000"&&n==="#ffffff"||e===n)return a.url;const l=new Array(256);for(let d=0;d<=255;d++){const m=d/255;l[d]=m<=.03928?m/12.92:((m+.055)/1.055)**2.4}const f=l.join(","),c=`g_${this.#s}_hcm_filter`,h=a.filter=this.#m(c);this.#p(f,f,f,h),this.#g(h);const u=p((d,m)=>{const g=r[d]/255,b=o[d]/255,w=new Array(m+1);for(let x=0;x<=m;x++)w[x]=g+x/m*(b-g);return w.join(",")},"getSteps");return this.#p(u(0,5),u(1,5),u(2,5),h),a.url=this.#c(c),a.url}addAlphaFilter(e){let n=this.#o.get(e);if(n)return n;const[s]=this.#u([e]),i=`alpha_${s}`;if(n=this.#o.get(i),n)return this.#o.set(e,n),n;const a=`g_${this.#s}_alpha_map_${this.#r++}`,r=this.#c(a);this.#o.set(e,r),this.#o.set(i,r);const o=this.#m(a);return this.#b(s,o),r}addLuminosityFilter(e){let n=this.#o.get(e||"luminosity");if(n)return n;let s,i;if(e?([s]=this.#u([e]),i=`luminosity_${s}`):i="luminosity",n=this.#o.get(i),n)return this.#o.set(e,n),n;const a=`g_${this.#s}_luminosity_map_${this.#r++}`,r=this.#c(a);this.#o.set(e,r),this.#o.set(i,r);const o=this.#m(a);return this.#d(o),e&&this.#b(s,o),r}addHighlightHCMFilter(e,n,s,i,a){const r=`${n}-${s}-${i}-${a}`;let o=this.#l.get(e);if(o?.key===r||(o?(o.filter?.remove(),o.key=r,o.url="none",o.filter=null):(o={key:r,url:"none",filter:null},this.#l.set(e,o)),!n||!s))return o.url;const[l,f]=[n,s].map(this.#y.bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),h=Math.round(.2126*f[0]+.7152*f[1]+.0722*f[2]),[u,d]=[i,a].map(this.#y.bind(this));h<c&&([c,h,u,d]=[h,c,d,u]),this.#f.style.color="";const m=p((w,x,y)=>{const j=new Array(256),v=(h-c)/y,q=w/255,A=(x-w)/(255*y);let C=0;for(let S=0;S<=y;S++){const I=Math.round(c+S*v),T=q+S*A;for(let P=C;P<=I;P++)j[P]=T;C=I+1}for(let S=C;S<256;S++)j[S]=j[C-1];return j.join(",")},"getSteps"),g=`g_${this.#s}_hcm_${e}_filter`,b=o.filter=this.#m(g);return this.#g(b),this.#p(m(u[0],d[0],5),m(u[1],d[1],5),m(u[2],d[2],5),b),o.url=this.#c(g),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#r=0)}#d(e){const n=this.#i.createElementNS(Ai,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(n)}#g(e){const n=this.#i.createElementNS(Ai,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(n)}#m(e){const n=this.#i.createElementNS(Ai,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",e),this.#f.append(n),n}#h(e,n,s){const i=this.#i.createElementNS(Ai,n);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),e.append(i)}#p(e,n,s,i){const a=this.#i.createElementNS(Ai,"feComponentTransfer");i.append(a),this.#h(a,"feFuncR",e),this.#h(a,"feFuncG",n),this.#h(a,"feFuncB",s)}#b(e,n){const s=this.#i.createElementNS(Ai,"feComponentTransfer");n.append(s),this.#h(s,"feFuncA",e)}#y(e){return this.#f.style.color=e,ur(getComputedStyle(this.#f).getPropertyValue("color"))}}async function K6(t){const n=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(n)}p(K6,"node_utils_fetchData");class X6 extends Dp{static{p(this,"NodeFilterFactory")}}class Y6 extends Pp{static{p(this,"NodeCanvasFactory")}_createCanvas(e,n){return process.getBuiltinModule("module").createRequire(import.meta.url),new Proxy({},{get(i,a){const r=globalThis[Symbol.for("unpdf.canvasModule")];return r?r[a]:()=>{throw new Error("@napi-rs/canvas is not available in this environment")}}}).createCanvas(e,n)}}class Q6 extends Rp{static{p(this,"NodeBinaryDataFactory")}async _fetch(e,n){return K6(e)}}const J6=`
55
55
  struct Uniforms {
56
56
  offsetX : f32,
57
57
  offsetY : f32,