var sp=Object.defineProperty;var Cd=u=>{throw TypeError(u)};var ip=(u,e,t)=>e in u?sp(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var ft=(u,e,t)=>ip(u,typeof e!="symbol"?e+"":e,t),Hl=(u,e,t)=>e.has(u)||Cd("Cannot "+t);var o=(u,e,t)=>(Hl(u,e,"read from private field"),t?t.call(u):e.get(u)),S=(u,e,t)=>e.has(u)?Cd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,t),w=(u,e,t,s)=>(Hl(u,e,"write to private field"),s?s.call(u,t):e.set(u,t),t),E=(u,e,t)=>(Hl(u,e,"access private method"),t);var Le=(u,e,t,s)=>({set _(i){w(u,e,i,t)},get _(){return o(u,e,s)}});import{_ as Qd,r as Vt,A as Jd,a9 as tu,o as bs,b as _a,e as se,ae as Eh,af as Sh,u as np,s as rp,d as ee,w as Je,R as kd,ab as ap,a7 as op,H as hp,k as lp,ag as cp,g as Td,J as dp,F as Rd,h as Pd,l as pa,f as Ul,t as up,ah as Ld,a4 as fp,D as pp,ai as gp,aj as mp,q as bp,v as _p,K as vp,Q as yp,S as Ap}from"./index-Daa5jh-U.js";/* empty css *//* empty css *//* empty css *//* empty css */import"./el-tag-BY50phaj.js";import{_ as wp}from"./index-LzutKPut.js";/* empty css *//* empty css */import"./el-tooltip-l0sNRNKZ.js";/* empty css */import{s as eu}from"./index-B3MU8m7V.js";import{u as Ep}from"./useWebScoket-kRbyd4OX.js";const Sp=u=>eu.get("/api/student/education/resource/page",{params:u}),xp=()=>eu.post("/api/student/subject/list"),Cp={class:"video-container"},kp={class:"video-content"},Tp=["src"],Rp={__name:"index",props:{videoUrl:{type:String,required:!0},poster:{type:String,default:""}},setup(u){const e=u,t=Vt(null);return Jd(()=>{}),tu(()=>{t.value.pause()}),(s,i)=>(bs(),_a("div",Cp,[se("div",kp,[se("video",{src:e.videoUrl,class:"video-player",controls:"",ref_key:"player",ref:t},null,8,Tp)])]))}},Pp=Qd(Rp,[["__scopeId","data-v-f000ad5c"]]);function xh(u){throw new Error('Could not dynamically require "'+u+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Lp={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(u,e){(function(t){u.exports=t()})(function(){return function t(s,i,n){function r(l,c){if(!i[l]){if(!s[l]){var d=typeof xh=="function"&&xh;if(!c&&d)return d(l,!0);if(a)return a(l,!0);var p=new Error("Cannot find module '"+l+"'");throw p.code="MODULE_NOT_FOUND",p}var f=i[l]={exports:{}};s[l][0].call(f.exports,function(g){var m=s[l][1][g];return r(m||g)},f,f.exports,t,s,i,n)}return i[l].exports}for(var a=typeof xh=="function"&&xh,h=0;h>2,f=(3&l)<<4|c>>4,g=1>6:64,m=2>4,c=(15&p)<<4|(f=a.indexOf(h.charAt(m++)))>>2,d=(3&f)<<6|(g=a.indexOf(h.charAt(m++))),A[v++]=l,f!==64&&(A[v++]=c),g!==64&&(A[v++]=d);return A}},{"./support":30,"./utils":32}],2:[function(t,s,i){var n=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),h=t("./stream/DataLengthProbe");function l(c,d,p,f,g){this.compressedSize=c,this.uncompressedSize=d,this.crc32=p,this.compression=f,this.compressedContent=g}l.prototype={getContentWorker:function(){var c=new r(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new h("data_length")),d=this;return c.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new r(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(c,d,p){return c.pipe(new a).pipe(new h("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new h("compressedSize")).withStreamInfo("compression",d)},s.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,s,i){var n=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,s,i){var n=t("./utils"),r=function(){for(var a,h=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;h[l]=a}return h}();s.exports=function(a,h){return a!==void 0&&a.length?n.getTypeOf(a)!=="string"?function(l,c,d,p){var f=r,g=p+d;l^=-1;for(var m=p;m>>8^f[255&(l^c[m])];return-1^l}(0|h,a,a.length,0):function(l,c,d,p){var f=r,g=p+d;l^=-1;for(var m=p;m>>8^f[255&(l^c.charCodeAt(m))];return-1^l}(0|h,a,a.length,0):0}},{"./utils":32}],5:[function(t,s,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,s,i){var n=null;n=typeof Promise<"u"?Promise:t("lie"),s.exports={Promise:n}},{lie:37}],7:[function(t,s,i){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=t("pako"),a=t("./utils"),h=t("./stream/GenericWorker"),l=n?"uint8array":"array";function c(d,p){h.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}i.magic="\b\0",a.inherits(c,h),c.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,d.data),!1)},c.prototype.flush=function(){h.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},i.compressWorker=function(d){return new c("Deflate",d)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,s,i){function n(f,g){var m,v="";for(m=0;m>>=8;return v}function r(f,g,m,v,b,A){var x,k,T=f.file,L=f.compression,I=A!==l.utf8encode,B=a.transformTo("string",A(T.name)),D=a.transformTo("string",l.utf8encode(T.name)),W=T.comment,q=a.transformTo("string",A(W)),P=a.transformTo("string",l.utf8encode(W)),z=D.length!==T.name.length,y=P.length!==W.length,H="",rt="",U="",Q=T.dir,X=T.date,ht={crc32:0,compressedSize:0,uncompressedSize:0};g&&!m||(ht.crc32=f.crc32,ht.compressedSize=f.compressedSize,ht.uncompressedSize=f.uncompressedSize);var M=0;g&&(M|=8),I||!z&&!y||(M|=2048);var O=0,st=0;Q&&(O|=16),b==="UNIX"?(st=798,O|=function(Y,_t){var pt=Y;return Y||(pt=_t?16893:33204),(65535&pt)<<16}(T.unixPermissions,Q)):(st=20,O|=function(Y){return 63&(Y||0)}(T.dosPermissions)),x=X.getUTCHours(),x<<=6,x|=X.getUTCMinutes(),x<<=5,x|=X.getUTCSeconds()/2,k=X.getUTCFullYear()-1980,k<<=4,k|=X.getUTCMonth()+1,k<<=5,k|=X.getUTCDate(),z&&(rt=n(1,1)+n(c(B),4)+D,H+="up"+n(rt.length,2)+rt),y&&(U=n(1,1)+n(c(q),4)+P,H+="uc"+n(U.length,2)+U);var J="";return J+=` \0`,J+=n(M,2),J+=L.magic,J+=n(x,2),J+=n(k,2),J+=n(ht.crc32,4),J+=n(ht.compressedSize,4),J+=n(ht.uncompressedSize,4),J+=n(B.length,2),J+=n(H.length,2),{fileRecord:d.LOCAL_FILE_HEADER+J+B+H,dirRecord:d.CENTRAL_FILE_HEADER+n(st,2)+J+n(q.length,2)+"\0\0\0\0"+n(O,4)+n(v,4)+B+H+q}}var a=t("../utils"),h=t("../stream/GenericWorker"),l=t("../utf8"),c=t("../crc32"),d=t("../signature");function p(f,g,m,v){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=m,this.encodeFileName=v,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,h),p.prototype.push=function(f){var g=f.meta.percent||0,m=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,h.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:m?(g+100*(m-v-1))/m:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var g=this.streamFiles&&!f.file.dir;if(g){var m=r(f,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var g=this.streamFiles&&!f.file.dir,m=r(f,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),g)this.push({data:function(v){return d.DATA_DESCRIPTOR+n(v.crc32,4)+n(v.compressedSize,4)+n(v.uncompressedSize,4)}(f),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,g=0;g=this.index;h--)l=(l<<8)+this.byteAt(h);return this.index+=a,l},readString:function(a){return n.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},s.exports=r},{"../utils":32}],19:[function(t,s,i){var n=t("./Uint8ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){this.checkOffset(a);var h=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,h},s.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,s,i){var n=t("./DataReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.prototype.readData=function(a){this.checkOffset(a);var h=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,h},s.exports=r},{"../utils":32,"./DataReader":18}],21:[function(t,s,i){var n=t("./ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var h=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,h},s.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,s,i){var n=t("../utils"),r=t("../support"),a=t("./ArrayReader"),h=t("./StringReader"),l=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");s.exports=function(d){var p=n.getTypeOf(d);return n.checkSupport(p),p!=="string"||r.uint8array?p==="nodebuffer"?new l(d):r.uint8array?new c(n.transformTo("uint8array",d)):new a(n.transformTo("array",d)):new h(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,s,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,s,i){var n=t("./GenericWorker"),r=t("../utils");function a(h){n.call(this,"ConvertWorker to "+h),this.destType=h}r.inherits(a,n),a.prototype.processChunk=function(h){this.push({data:r.transformTo(this.destType,h.data),meta:h.meta})},s.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,s,i){var n=t("./GenericWorker"),r=t("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,n),a.prototype.processChunk=function(h){this.streamInfo.crc32=r(h.data,this.streamInfo.crc32||0),this.push(h)},s.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,s,i){var n=t("../utils"),r=t("./GenericWorker");function a(h){r.call(this,"DataLengthProbe for "+h),this.propName=h,this.withStreamInfo(h,0)}n.inherits(a,r),a.prototype.processChunk=function(h){if(h){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+h.data.length}r.prototype.processChunk.call(this,h)},s.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,s,i){var n=t("../utils"),r=t("./GenericWorker");function a(h){r.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,h.then(function(c){l.dataIsReady=!0,l.data=c,l.max=c&&c.length||0,l.type=n.getTypeOf(c),l.isPaused||l._tickAndRepeat()},function(c){l.error(c)})}n.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var h=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":h=this.data.substring(this.index,l);break;case"uint8array":h=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":h=this.data.slice(this.index,l)}return this.index=l,this.push({data:h,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,s,i){function n(r){this.name=r||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var h=0;h "+r:r}},s.exports=n},{}],29:[function(t,s,i){var n=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),h=t("../base64"),l=t("../support"),c=t("../external"),d=null;if(l.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,m){return new c.Promise(function(v,b){var A=[],x=g._internalType,k=g._outputType,T=g._mimeType;g.on("data",function(L,I){A.push(L),m&&m(I)}).on("error",function(L){A=[],b(L)}).on("end",function(){try{var L=function(I,B,D){switch(I){case"blob":return n.newBlob(n.transformTo("arraybuffer",B),D);case"base64":return h.encode(B);default:return n.transformTo(I,B)}}(k,function(I,B){var D,W=0,q=null,P=0;for(D=0;D"u")i.blob=!1;else{var n=new ArrayBuffer(0);try{i.blob=new Blob([n],{type:"application/zip"}).size===0}catch{try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(n),i.blob=r.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,s,i){for(var n=t("./utils"),r=t("./support"),a=t("./nodejsUtils"),h=t("./stream/GenericWorker"),l=new Array(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;l[254]=l[254]=1;function d(){h.call(this,"utf-8 decode"),this.leftOver=null}function p(){h.call(this,"utf-8 encode")}i.utf8encode=function(f){return r.nodebuffer?a.newBufferFrom(f,"utf-8"):function(g){var m,v,b,A,x,k=g.length,T=0;for(A=0;A>>6:(v<65536?m[x++]=224|v>>>12:(m[x++]=240|v>>>18,m[x++]=128|v>>>12&63),m[x++]=128|v>>>6&63),m[x++]=128|63&v);return m}(f)},i.utf8decode=function(f){return r.nodebuffer?n.transformTo("nodebuffer",f).toString("utf-8"):function(g){var m,v,b,A,x=g.length,k=new Array(2*x);for(m=v=0;m>10&1023,k[v++]=56320|1023&b)}return k.length!==v&&(k.subarray?k=k.subarray(0,v):k.length=v),n.applyFromCharCode(k)}(f=n.transformTo(r.uint8array?"uint8array":"array",f))},n.inherits(d,h),d.prototype.processChunk=function(f){var g=n.transformTo(r.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var m=g;(g=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),g.set(m,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var v=function(A,x){var k;for((x=x||A.length)>A.length&&(x=A.length),k=x-1;0<=k&&(192&A[k])==128;)k--;return k<0||k===0?x:k+l[A[k]]>x?k:x}(g),b=g;v!==g.length&&(r.uint8array?(b=g.subarray(0,v),this.leftOver=g.subarray(v,g.length)):(b=g.slice(0,v),this.leftOver=g.slice(v,g.length))),this.push({data:i.utf8decode(b),meta:f.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,n.inherits(p,h),p.prototype.processChunk=function(f){this.push({data:i.utf8encode(f.data),meta:f.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,s,i){var n=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),h=t("./external");function l(m){return m}function c(m,v){for(var b=0;b>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=n(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var g,m,v,b=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4>>6:(f<65536?p[v++]=224|f>>>12:(p[v++]=240|f>>>18,p[v++]=128|f>>>12&63),p[v++]=128|f>>>6&63),p[v++]=128|63&f);return p},i.buf2binstring=function(d){return c(d,d.length)},i.binstring2buf=function(d){for(var p=new n.Buf8(d.length),f=0,g=p.length;f>10&1023,A[g++]=56320|1023&m)}return c(A,g)},i.utf8border=function(d,p){var f;for((p=p||d.length)>d.length&&(p=d.length),f=p-1;0<=f&&(192&d[f])==128;)f--;return f<0||f===0?p:f+h[d[f]]>p?f:p}},{"./common":41}],43:[function(t,s,i){s.exports=function(n,r,a,h){for(var l=65535&n|0,c=n>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:r>>>1;a[h]=r}return a}();s.exports=function(r,a,h,l){var c=n,d=l+h;r^=-1;for(var p=l;p>>8^c[255&(r^a[p])];return-1^r}},{}],46:[function(t,s,i){var n,r=t("../utils/common"),a=t("./trees"),h=t("./adler32"),l=t("./crc32"),c=t("./messages"),d=0,p=4,f=0,g=-2,m=-1,v=4,b=2,A=8,x=9,k=286,T=30,L=19,I=2*k+1,B=15,D=3,W=258,q=W+D+1,P=42,z=113,y=1,H=2,rt=3,U=4;function Q(_,G){return _.msg=c[G],G}function X(_){return(_<<1)-(4<_?9:0)}function ht(_){for(var G=_.length;0<=--G;)_[G]=0}function M(_){var G=_.state,j=G.pending;j>_.avail_out&&(j=_.avail_out),j!==0&&(r.arraySet(_.output,G.pending_buf,G.pending_out,j,_.next_out),_.next_out+=j,G.pending_out+=j,_.total_out+=j,_.avail_out-=j,G.pending-=j,G.pending===0&&(G.pending_out=0))}function O(_,G){a._tr_flush_block(_,0<=_.block_start?_.block_start:-1,_.strstart-_.block_start,G),_.block_start=_.strstart,M(_.strm)}function st(_,G){_.pending_buf[_.pending++]=G}function J(_,G){_.pending_buf[_.pending++]=G>>>8&255,_.pending_buf[_.pending++]=255&G}function Y(_,G){var j,R,C=_.max_chain_length,F=_.strstart,$=_.prev_length,V=_.nice_match,N=_.strstart>_.w_size-q?_.strstart-(_.w_size-q):0,K=_.window,it=_.w_mask,Z=_.prev,lt=_.strstart+W,Ft=K[F+$-1],At=K[F+$];_.prev_length>=_.good_match&&(C>>=2),V>_.lookahead&&(V=_.lookahead);do if(K[(j=G)+$]===At&&K[j+$-1]===Ft&&K[j]===K[F]&&K[++j]===K[F+1]){F+=2,j++;do;while(K[++F]===K[++j]&&K[++F]===K[++j]&&K[++F]===K[++j]&&K[++F]===K[++j]&&K[++F]===K[++j]&&K[++F]===K[++j]&&K[++F]===K[++j]&&K[++F]===K[++j]&&FN&&--C!=0);return $<=_.lookahead?$:_.lookahead}function _t(_){var G,j,R,C,F,$,V,N,K,it,Z=_.w_size;do{if(C=_.window_size-_.lookahead-_.strstart,_.strstart>=Z+(Z-q)){for(r.arraySet(_.window,_.window,Z,Z,0),_.match_start-=Z,_.strstart-=Z,_.block_start-=Z,G=j=_.hash_size;R=_.head[--G],_.head[G]=Z<=R?R-Z:0,--j;);for(G=j=Z;R=_.prev[--G],_.prev[G]=Z<=R?R-Z:0,--j;);C+=Z}if(_.strm.avail_in===0)break;if($=_.strm,V=_.window,N=_.strstart+_.lookahead,K=C,it=void 0,it=$.avail_in,K=D)for(F=_.strstart-_.insert,_.ins_h=_.window[F],_.ins_h=(_.ins_h<<_.hash_shift^_.window[F+1])&_.hash_mask;_.insert&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[F+D-1])&_.hash_mask,_.prev[F&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=F,F++,_.insert--,!(_.lookahead+_.insert=D&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+D-1])&_.hash_mask,j=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),j!==0&&_.strstart-j<=_.w_size-q&&(_.match_length=Y(_,j)),_.match_length>=D)if(R=a._tr_tally(_,_.strstart-_.match_start,_.match_length-D),_.lookahead-=_.match_length,_.match_length<=_.max_lazy_match&&_.lookahead>=D){for(_.match_length--;_.strstart++,_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+D-1])&_.hash_mask,j=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart,--_.match_length!=0;);_.strstart++}else _.strstart+=_.match_length,_.match_length=0,_.ins_h=_.window[_.strstart],_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+1])&_.hash_mask;else R=a._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++;if(R&&(O(_,!1),_.strm.avail_out===0))return y}return _.insert=_.strstart=D&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+D-1])&_.hash_mask,j=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),_.prev_length=_.match_length,_.prev_match=_.match_start,_.match_length=D-1,j!==0&&_.prev_length<_.max_lazy_match&&_.strstart-j<=_.w_size-q&&(_.match_length=Y(_,j),_.match_length<=5&&(_.strategy===1||_.match_length===D&&4096<_.strstart-_.match_start)&&(_.match_length=D-1)),_.prev_length>=D&&_.match_length<=_.prev_length){for(C=_.strstart+_.lookahead-D,R=a._tr_tally(_,_.strstart-1-_.prev_match,_.prev_length-D),_.lookahead-=_.prev_length-1,_.prev_length-=2;++_.strstart<=C&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+D-1])&_.hash_mask,j=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),--_.prev_length!=0;);if(_.match_available=0,_.match_length=D-1,_.strstart++,R&&(O(_,!1),_.strm.avail_out===0))return y}else if(_.match_available){if((R=a._tr_tally(_,0,_.window[_.strstart-1]))&&O(_,!1),_.strstart++,_.lookahead--,_.strm.avail_out===0)return y}else _.match_available=1,_.strstart++,_.lookahead--}return _.match_available&&(R=a._tr_tally(_,0,_.window[_.strstart-1]),_.match_available=0),_.insert=_.strstart_.pending_buf_size-5&&(j=_.pending_buf_size-5);;){if(_.lookahead<=1){if(_t(_),_.lookahead===0&&G===d)return y;if(_.lookahead===0)break}_.strstart+=_.lookahead,_.lookahead=0;var R=_.block_start+j;if((_.strstart===0||_.strstart>=R)&&(_.lookahead=_.strstart-R,_.strstart=R,O(_,!1),_.strm.avail_out===0)||_.strstart-_.block_start>=_.w_size-q&&(O(_,!1),_.strm.avail_out===0))return y}return _.insert=0,G===p?(O(_,!0),_.strm.avail_out===0?rt:U):(_.strstart>_.block_start&&(O(_,!1),_.strm.avail_out),y)}),new vt(4,4,8,4,pt),new vt(4,5,16,8,pt),new vt(4,6,32,32,pt),new vt(4,4,16,16,dt),new vt(8,16,32,32,dt),new vt(8,16,128,128,dt),new vt(8,32,128,256,dt),new vt(32,128,258,1024,dt),new vt(32,258,258,4096,dt)],i.deflateInit=function(_,G){return Pe(_,G,A,15,8,0)},i.deflateInit2=Pe,i.deflateReset=We,i.deflateResetKeep=Ot,i.deflateSetHeader=function(_,G){return _&&_.state?_.state.wrap!==2?g:(_.state.gzhead=G,f):g},i.deflate=function(_,G){var j,R,C,F;if(!_||!_.state||5>8&255),st(R,R.gzhead.time>>16&255),st(R,R.gzhead.time>>24&255),st(R,R.level===9?2:2<=R.strategy||R.level<2?4:0),st(R,255&R.gzhead.os),R.gzhead.extra&&R.gzhead.extra.length&&(st(R,255&R.gzhead.extra.length),st(R,R.gzhead.extra.length>>8&255)),R.gzhead.hcrc&&(_.adler=l(_.adler,R.pending_buf,R.pending,0)),R.gzindex=0,R.status=69):(st(R,0),st(R,0),st(R,0),st(R,0),st(R,0),st(R,R.level===9?2:2<=R.strategy||R.level<2?4:0),st(R,3),R.status=z);else{var $=A+(R.w_bits-8<<4)<<8;$|=(2<=R.strategy||R.level<2?0:R.level<6?1:R.level===6?2:3)<<6,R.strstart!==0&&($|=32),$+=31-$%31,R.status=z,J(R,$),R.strstart!==0&&(J(R,_.adler>>>16),J(R,65535&_.adler)),_.adler=1}if(R.status===69)if(R.gzhead.extra){for(C=R.pending;R.gzindex<(65535&R.gzhead.extra.length)&&(R.pending!==R.pending_buf_size||(R.gzhead.hcrc&&R.pending>C&&(_.adler=l(_.adler,R.pending_buf,R.pending-C,C)),M(_),C=R.pending,R.pending!==R.pending_buf_size));)st(R,255&R.gzhead.extra[R.gzindex]),R.gzindex++;R.gzhead.hcrc&&R.pending>C&&(_.adler=l(_.adler,R.pending_buf,R.pending-C,C)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=73)}else R.status=73;if(R.status===73)if(R.gzhead.name){C=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>C&&(_.adler=l(_.adler,R.pending_buf,R.pending-C,C)),M(_),C=R.pending,R.pending===R.pending_buf_size)){F=1;break}F=R.gzindexC&&(_.adler=l(_.adler,R.pending_buf,R.pending-C,C)),F===0&&(R.gzindex=0,R.status=91)}else R.status=91;if(R.status===91)if(R.gzhead.comment){C=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>C&&(_.adler=l(_.adler,R.pending_buf,R.pending-C,C)),M(_),C=R.pending,R.pending===R.pending_buf_size)){F=1;break}F=R.gzindexC&&(_.adler=l(_.adler,R.pending_buf,R.pending-C,C)),F===0&&(R.status=103)}else R.status=103;if(R.status===103&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&M(_),R.pending+2<=R.pending_buf_size&&(st(R,255&_.adler),st(R,_.adler>>8&255),_.adler=0,R.status=z)):R.status=z),R.pending!==0){if(M(_),_.avail_out===0)return R.last_flush=-1,f}else if(_.avail_in===0&&X(G)<=X(j)&&G!==p)return Q(_,-5);if(R.status===666&&_.avail_in!==0)return Q(_,-5);if(_.avail_in!==0||R.lookahead!==0||G!==d&&R.status!==666){var V=R.strategy===2?function(N,K){for(var it;;){if(N.lookahead===0&&(_t(N),N.lookahead===0)){if(K===d)return y;break}if(N.match_length=0,it=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,it&&(O(N,!1),N.strm.avail_out===0))return y}return N.insert=0,K===p?(O(N,!0),N.strm.avail_out===0?rt:U):N.last_lit&&(O(N,!1),N.strm.avail_out===0)?y:H}(R,G):R.strategy===3?function(N,K){for(var it,Z,lt,Ft,At=N.window;;){if(N.lookahead<=W){if(_t(N),N.lookahead<=W&&K===d)return y;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=D&&0N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=D?(it=a._tr_tally(N,1,N.match_length-D),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(it=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),it&&(O(N,!1),N.strm.avail_out===0))return y}return N.insert=0,K===p?(O(N,!0),N.strm.avail_out===0?rt:U):N.last_lit&&(O(N,!1),N.strm.avail_out===0)?y:H}(R,G):n[R.level].func(R,G);if(V!==rt&&V!==U||(R.status=666),V===y||V===rt)return _.avail_out===0&&(R.last_flush=-1),f;if(V===H&&(G===1?a._tr_align(R):G!==5&&(a._tr_stored_block(R,0,0,!1),G===3&&(ht(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),M(_),_.avail_out===0))return R.last_flush=-1,f}return G!==p?f:R.wrap<=0?1:(R.wrap===2?(st(R,255&_.adler),st(R,_.adler>>8&255),st(R,_.adler>>16&255),st(R,_.adler>>24&255),st(R,255&_.total_in),st(R,_.total_in>>8&255),st(R,_.total_in>>16&255),st(R,_.total_in>>24&255)):(J(R,_.adler>>>16),J(R,65535&_.adler)),M(_),0=j.w_size&&(F===0&&(ht(j.head),j.strstart=0,j.block_start=0,j.insert=0),K=new r.Buf8(j.w_size),r.arraySet(K,G,it-j.w_size,j.w_size,0),G=K,it=j.w_size),$=_.avail_in,V=_.next_in,N=_.input,_.avail_in=it,_.next_in=0,_.input=G,_t(j);j.lookahead>=D;){for(R=j.strstart,C=j.lookahead-(D-1);j.ins_h=(j.ins_h<>>=D=B>>>24,x-=D,(D=B>>>16&255)===0)H[c++]=65535&B;else{if(!(16&D)){if(!(64&D)){B=k[(65535&B)+(A&(1<>>=D,x-=D),x<15&&(A+=y[h++]<>>=D=B>>>24,x-=D,!(16&(D=B>>>16&255))){if(!(64&D)){B=T[(65535&B)+(A&(1<>>=D,x-=D,(D=c-d)>3,A&=(1<<(x-=W<<3))-1,n.next_in=h,n.next_out=c,n.avail_in=h>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function A(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x(P){var z;return P&&P.state?(z=P.state,P.total_in=P.total_out=z.total=0,P.msg="",z.wrap&&(P.adler=1&z.wrap),z.mode=g,z.last=0,z.havedict=0,z.dmax=32768,z.head=null,z.hold=0,z.bits=0,z.lencode=z.lendyn=new n.Buf32(m),z.distcode=z.distdyn=new n.Buf32(v),z.sane=1,z.back=-1,p):f}function k(P){var z;return P&&P.state?((z=P.state).wsize=0,z.whave=0,z.wnext=0,x(P)):f}function T(P,z){var y,H;return P&&P.state?(H=P.state,z<0?(y=0,z=-z):(y=1+(z>>4),z<48&&(z&=15)),z&&(z<8||15=U.wsize?(n.arraySet(U.window,z,y-U.wsize,U.wsize,0),U.wnext=0,U.whave=U.wsize):(H<(rt=U.wsize-U.wnext)&&(rt=H),n.arraySet(U.window,z,y-H,rt,U.wnext),(H-=rt)?(n.arraySet(U.window,z,y-H,H,0),U.wnext=H,U.whave=U.wsize):(U.wnext+=rt,U.wnext===U.wsize&&(U.wnext=0),U.whave>>8&255,y.check=a(y.check,F,2,0),O=M=0,y.mode=2;break}if(y.flags=0,y.head&&(y.head.done=!1),!(1&y.wrap)||(((255&M)<<8)+(M>>8))%31){P.msg="incorrect header check",y.mode=30;break}if((15&M)!=8){P.msg="unknown compression method",y.mode=30;break}if(O-=4,_=8+(15&(M>>>=4)),y.wbits===0)y.wbits=_;else if(_>y.wbits){P.msg="invalid window size",y.mode=30;break}y.dmax=1<<_,P.adler=y.check=1,y.mode=512&M?10:12,O=M=0;break;case 2:for(;O<16;){if(X===0)break t;X--,M+=H[U++]<>8&1),512&y.flags&&(F[0]=255&M,F[1]=M>>>8&255,y.check=a(y.check,F,2,0)),O=M=0,y.mode=3;case 3:for(;O<32;){if(X===0)break t;X--,M+=H[U++]<>>8&255,F[2]=M>>>16&255,F[3]=M>>>24&255,y.check=a(y.check,F,4,0)),O=M=0,y.mode=4;case 4:for(;O<16;){if(X===0)break t;X--,M+=H[U++]<>8),512&y.flags&&(F[0]=255&M,F[1]=M>>>8&255,y.check=a(y.check,F,2,0)),O=M=0,y.mode=5;case 5:if(1024&y.flags){for(;O<16;){if(X===0)break t;X--,M+=H[U++]<>>8&255,y.check=a(y.check,F,2,0)),O=M=0}else y.head&&(y.head.extra=null);y.mode=6;case 6:if(1024&y.flags&&(X<(Y=y.length)&&(Y=X),Y&&(y.head&&(_=y.head.extra_len-y.length,y.head.extra||(y.head.extra=new Array(y.head.extra_len)),n.arraySet(y.head.extra,H,U,Y,_)),512&y.flags&&(y.check=a(y.check,H,Y,U)),X-=Y,U+=Y,y.length-=Y),y.length))break t;y.length=0,y.mode=7;case 7:if(2048&y.flags){if(X===0)break t;for(Y=0;_=H[U+Y++],y.head&&_&&y.length<65536&&(y.head.name+=String.fromCharCode(_)),_&&Y>9&1,y.head.done=!0),P.adler=y.check=0,y.mode=12;break;case 10:for(;O<32;){if(X===0)break t;X--,M+=H[U++]<>>=7&O,O-=7&O,y.mode=27;break}for(;O<3;){if(X===0)break t;X--,M+=H[U++]<>>=1)){case 0:y.mode=14;break;case 1:if(W(y),y.mode=20,z!==6)break;M>>>=2,O-=2;break t;case 2:y.mode=17;break;case 3:P.msg="invalid block type",y.mode=30}M>>>=2,O-=2;break;case 14:for(M>>>=7&O,O-=7&O;O<32;){if(X===0)break t;X--,M+=H[U++]<>>16^65535)){P.msg="invalid stored block lengths",y.mode=30;break}if(y.length=65535&M,O=M=0,y.mode=15,z===6)break t;case 15:y.mode=16;case 16:if(Y=y.length){if(X>>=5,O-=5,y.ndist=1+(31&M),M>>>=5,O-=5,y.ncode=4+(15&M),M>>>=4,O-=4,286>>=3,O-=3}for(;y.have<19;)y.lens[$[y.have++]]=0;if(y.lencode=y.lendyn,y.lenbits=7,j={bits:y.lenbits},G=l(0,y.lens,0,19,y.lencode,0,y.work,j),y.lenbits=j.bits,G){P.msg="invalid code lengths set",y.mode=30;break}y.have=0,y.mode=19;case 19:for(;y.have>>16&255,Wt=65535&C,!((dt=C>>>24)<=O);){if(X===0)break t;X--,M+=H[U++]<>>=dt,O-=dt,y.lens[y.have++]=Wt;else{if(Wt===16){for(R=dt+2;O>>=dt,O-=dt,y.have===0){P.msg="invalid bit length repeat",y.mode=30;break}_=y.lens[y.have-1],Y=3+(3&M),M>>>=2,O-=2}else if(Wt===17){for(R=dt+3;O>>=dt)),M>>>=3,O-=3}else{for(R=dt+7;O>>=dt)),M>>>=7,O-=7}if(y.have+Y>y.nlen+y.ndist){P.msg="invalid bit length repeat",y.mode=30;break}for(;Y--;)y.lens[y.have++]=_}}if(y.mode===30)break;if(y.lens[256]===0){P.msg="invalid code -- missing end-of-block",y.mode=30;break}if(y.lenbits=9,j={bits:y.lenbits},G=l(c,y.lens,0,y.nlen,y.lencode,0,y.work,j),y.lenbits=j.bits,G){P.msg="invalid literal/lengths set",y.mode=30;break}if(y.distbits=6,y.distcode=y.distdyn,j={bits:y.distbits},G=l(d,y.lens,y.nlen,y.ndist,y.distcode,0,y.work,j),y.distbits=j.bits,G){P.msg="invalid distances set",y.mode=30;break}if(y.mode=20,z===6)break t;case 20:y.mode=21;case 21:if(6<=X&&258<=ht){P.next_out=Q,P.avail_out=ht,P.next_in=U,P.avail_in=X,y.hold=M,y.bits=O,h(P,J),Q=P.next_out,rt=P.output,ht=P.avail_out,U=P.next_in,H=P.input,X=P.avail_in,M=y.hold,O=y.bits,y.mode===12&&(y.back=-1);break}for(y.back=0;vt=(C=y.lencode[M&(1<>>16&255,Wt=65535&C,!((dt=C>>>24)<=O);){if(X===0)break t;X--,M+=H[U++]<>Ot)])>>>16&255,Wt=65535&C,!(Ot+(dt=C>>>24)<=O);){if(X===0)break t;X--,M+=H[U++]<>>=Ot,O-=Ot,y.back+=Ot}if(M>>>=dt,O-=dt,y.back+=dt,y.length=Wt,vt===0){y.mode=26;break}if(32&vt){y.back=-1,y.mode=12;break}if(64&vt){P.msg="invalid literal/length code",y.mode=30;break}y.extra=15&vt,y.mode=22;case 22:if(y.extra){for(R=y.extra;O>>=y.extra,O-=y.extra,y.back+=y.extra}y.was=y.length,y.mode=23;case 23:for(;vt=(C=y.distcode[M&(1<>>16&255,Wt=65535&C,!((dt=C>>>24)<=O);){if(X===0)break t;X--,M+=H[U++]<>Ot)])>>>16&255,Wt=65535&C,!(Ot+(dt=C>>>24)<=O);){if(X===0)break t;X--,M+=H[U++]<>>=Ot,O-=Ot,y.back+=Ot}if(M>>>=dt,O-=dt,y.back+=dt,64&vt){P.msg="invalid distance code",y.mode=30;break}y.offset=Wt,y.extra=15&vt,y.mode=24;case 24:if(y.extra){for(R=y.extra;O>>=y.extra,O-=y.extra,y.back+=y.extra}if(y.offset>y.dmax){P.msg="invalid distance too far back",y.mode=30;break}y.mode=25;case 25:if(ht===0)break t;if(Y=J-ht,y.offset>Y){if((Y=y.offset-Y)>y.whave&&y.sane){P.msg="invalid distance too far back",y.mode=30;break}_t=Y>y.wnext?(Y-=y.wnext,y.wsize-Y):y.wnext-Y,Y>y.length&&(Y=y.length),pt=y.window}else pt=rt,_t=Q-y.offset,Y=y.length;for(htI?(D=_t[pt+v[z]],O[st+v[z]]):(D=96,0),A=1<>Q)+(x-=A)]=B<<24|D<<16|W|0,x!==0;);for(A=1<>=1;if(A!==0?(M&=A-1,M+=A):M=0,z++,--J[P]==0){if(P===H)break;P=d[p+v[z]]}if(rt>>7)]}function st(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function J(C,F,$){C.bi_valid>b-$?(C.bi_buf|=F<>b-C.bi_valid,C.bi_valid+=$-b):(C.bi_buf|=F<>>=1,$<<=1,0<--F;);return $>>>1}function pt(C,F,$){var V,N,K=new Array(v+1),it=0;for(V=1;V<=v;V++)K[V]=it=it+$[V-1]<<1;for(N=0;N<=F;N++){var Z=C[2*N+1];Z!==0&&(C[2*N]=_t(K[Z]++,Z))}}function dt(C){var F;for(F=0;F>1;1<=$;$--)Ot(C,K,$);for(N=lt;$=C.heap[1],C.heap[1]=C.heap[C.heap_len--],Ot(C,K,1),V=C.heap[1],C.heap[--C.heap_max]=$,C.heap[--C.heap_max]=V,K[2*N]=K[2*$]+K[2*V],C.depth[N]=(C.depth[$]>=C.depth[V]?C.depth[$]:C.depth[V])+1,K[2*$+1]=K[2*V+1]=N,C.heap[1]=N++,Ot(C,K,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(At,Ge){var da,gs,ua,Ht,Ah,zl,Ns=Ge.dyn_tree,Sd=Ge.max_code,Jf=Ge.stat_desc.static_tree,tp=Ge.stat_desc.has_stree,ep=Ge.stat_desc.extra_bits,xd=Ge.stat_desc.extra_base,fa=Ge.stat_desc.max_length,wh=0;for(Ht=0;Ht<=v;Ht++)At.bl_count[Ht]=0;for(Ns[2*At.heap[At.heap_max]+1]=0,da=At.heap_max+1;da>=7;N>>=1)if(1&Ft&&Z.dyn_ltree[2*lt]!==0)return r;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return a;for(lt=32;lt>>3,(K=C.static_len+3+7>>>3)<=N&&(N=K)):N=K=$+5,$+4<=N&&F!==-1?R(C,F,$,V):C.strategy===4||K===N?(J(C,2+(V?1:0),3),We(C,q,P)):(J(C,4+(V?1:0),3),function(Z,lt,Ft,At){var Ge;for(J(Z,lt-257,5),J(Z,Ft-1,5),J(Z,At-4,4),Ge=0;Ge>>8&255,C.pending_buf[C.d_buf+2*C.last_lit+1]=255&F,C.pending_buf[C.l_buf+C.last_lit]=255&$,C.last_lit++,F===0?C.dyn_ltree[2*$]++:(C.matches++,F--,C.dyn_ltree[2*(y[$]+d+1)]++,C.dyn_dtree[2*O(F)]++),C.last_lit===C.lit_bufsize-1},i._tr_align=function(C){J(C,2,3),Y(C,x,q),function(F){F.bi_valid===16?(st(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)}(C)}},{"../utils/common":41}],53:[function(t,s,i){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,s,i){(function(n){(function(r,a){if(!r.setImmediate){var h,l,c,d,p=1,f={},g=!1,m=r.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(r);v=v&&v.setTimeout?v:r,h={}.toString.call(r.process)==="[object process]"?function(k){process.nextTick(function(){A(k)})}:function(){if(r.postMessage&&!r.importScripts){var k=!0,T=r.onmessage;return r.onmessage=function(){k=!1},r.postMessage("","*"),r.onmessage=T,k}}()?(d="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",x,!1):r.attachEvent("onmessage",x),function(k){r.postMessage(d+k,"*")}):r.MessageChannel?((c=new MessageChannel).port1.onmessage=function(k){A(k.data)},function(k){c.port2.postMessage(k)}):m&&"onreadystatechange"in m.createElement("script")?(l=m.documentElement,function(k){var T=m.createElement("script");T.onreadystatechange=function(){A(k),T.onreadystatechange=null,l.removeChild(T),T=null},l.appendChild(T)}):function(k){setTimeout(A,0,k)},v.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var T=new Array(arguments.length-1),L=0;L"u"?n===void 0?this:n:self)}).call(this,typeof Eh<"u"?Eh:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Lp);var dr;(function(u){u.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",u.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",u.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",u.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",u.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",u.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",u.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",u.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",u.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",u.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",u.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",u.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",u.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",u.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",u.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",u.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",u.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",u.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",u.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended"})(dr||(dr={}));var Id;(function(u){u.Continuous="continuous",u.NextPage="nextPage",u.NextColumn="nextColumn",u.EvenPage="evenPage",u.OddPage="oddPage"})(Id||(Id={}));var Lt;(function(u){u.Document="document",u.Paragraph="paragraph",u.Run="run",u.Break="break",u.NoBreakHyphen="noBreakHyphen",u.Table="table",u.Row="row",u.Cell="cell",u.Hyperlink="hyperlink",u.SmartTag="smartTag",u.Drawing="drawing",u.Image="image",u.Text="text",u.Tab="tab",u.Symbol="symbol",u.BookmarkStart="bookmarkStart",u.BookmarkEnd="bookmarkEnd",u.Footer="footer",u.Header="header",u.FootnoteReference="footnoteReference",u.EndnoteReference="endnoteReference",u.Footnote="footnote",u.Endnote="endnote",u.SimpleField="simpleField",u.ComplexField="complexField",u.Instruction="instruction",u.VmlPicture="vmlPicture",u.MmlMath="mmlMath",u.MmlMathParagraph="mmlMathParagraph",u.MmlFraction="mmlFraction",u.MmlFunction="mmlFunction",u.MmlFunctionName="mmlFunctionName",u.MmlNumerator="mmlNumerator",u.MmlDenominator="mmlDenominator",u.MmlRadical="mmlRadical",u.MmlBase="mmlBase",u.MmlDegree="mmlDegree",u.MmlSuperscript="mmlSuperscript",u.MmlSubscript="mmlSubscript",u.MmlPreSubSuper="mmlPreSubSuper",u.MmlSubArgument="mmlSubArgument",u.MmlSuperArgument="mmlSuperArgument",u.MmlNary="mmlNary",u.MmlDelimiter="mmlDelimiter",u.MmlRun="mmlRun",u.MmlEquationArray="mmlEquationArray",u.MmlLimit="mmlLimit",u.MmlLimitLower="mmlLimitLower",u.MmlMatrix="mmlMatrix",u.MmlMatrixRow="mmlMatrixRow",u.MmlBox="mmlBox",u.MmlBar="mmlBar",u.MmlGroupChar="mmlGroupChar",u.VmlElement="vmlElement",u.Inserted="inserted",u.Deleted="deleted",u.DeletedText="deletedText",u.Comment="comment",u.CommentReference="commentReference",u.CommentRangeStart="commentRangeStart",u.CommentRangeEnd="commentRangeEnd"})(Lt||(Lt={}));dr.OfficeDocument,dr.ExtendedProperties,dr.CoreProperties,dr.CustomProperties;Lt.MmlMath,Lt.MmlMathParagraph,Lt.MmlFraction,Lt.MmlFunction,Lt.MmlFunctionName,Lt.MmlNumerator,Lt.MmlDenominator,Lt.MmlRadical,Lt.MmlDegree,Lt.MmlBase,Lt.MmlSuperscript,Lt.MmlSubscript,Lt.MmlPreSubSuper,Lt.MmlSuperArgument,Lt.MmlSubArgument,Lt.MmlDelimiter,Lt.MmlNary,Lt.MmlEquationArray,Lt.MmlLimit,Lt.MmlLimitLower,Lt.MmlMatrix,Lt.MmlMatrixRow,Lt.MmlBox,Lt.MmlBar,Lt.MmlGroupChar;var Fa={};Fa.d=(u,e)=>{for(var t in e)Fa.o(e,t)&&!Fa.o(u,t)&&Object.defineProperty(u,t,{enumerable:!0,get:e[t]})};Fa.o=(u,e)=>Object.prototype.hasOwnProperty.call(u,e);var ct=globalThis.pdfjsLib={};Fa.d(ct,{AbortException:()=>ir,AnnotationEditorLayer:()=>id,AnnotationEditorParamsType:()=>ut,AnnotationEditorType:()=>wt,AnnotationEditorUIManager:()=>Qn,AnnotationLayer:()=>Rm,AnnotationMode:()=>Si,CMapCompressionType:()=>Yl,ColorPicker:()=>hl,DOMSVGFactory:()=>ud,DrawLayer:()=>od,FeatureTest:()=>ke,GlobalWorkerOptions:()=>gi,ImageKind:()=>Lh,InvalidPDFException:()=>iu,MissingPDFException:()=>sr,OPS:()=>es,Outliner:()=>Bc,PDFDataRangeTransport:()=>Qu,PDFDateString:()=>cu,PDFWorker:()=>pr,PasswordResponses:()=>Dp,PermissionFlag:()=>Fp,PixelsPerInch:()=>Vi,RenderingCancelledException:()=>fd,TextLayer:()=>ca,UnexpectedResponseException:()=>Il,Util:()=>at,VerbosityLevel:()=>Rl,XfaLayer:()=>tf,build:()=>lm,createValidAbsoluteUrl:()=>zp,fetchData:()=>Nl,getDocument:()=>tm,getFilenameFromUrl:()=>Yp,getPdfFilenameFromUrl:()=>Kp,getXfaPageViewport:()=>Zp,isDataScheme:()=>pd,isPdfFile:()=>gd,noContextMenu:()=>Re,normalizeUnicode:()=>$p,renderTextLayer:()=>$g,setLayerDimensions:()=>Zn,shadow:()=>Et,updateTextLayer:()=>Vg,version:()=>hm});const me=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),su=[1,0,0,1,0,0],Xl=[.001,0,0,.001,0,0],Ip=1e7,jl=1.35,Ke={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},Si={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Mp="pdfjs_internal_editor_",wt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},ut={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},Fp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},de={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Lh={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},qt={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},ga={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Rl={ERRORS:0,WARNINGS:1,INFOS:5},Yl={NONE:0,BINARY:1},es={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},Dp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Pl=Rl.WARNINGS;function Op(u){Number.isInteger(u)&&(Pl=u)}function Np(){return Pl}function Ll(u){Pl>=Rl.INFOS&&console.log(`Info: ${u}`)}function gt(u){Pl>=Rl.WARNINGS&&console.log(`Warning: ${u}`)}function Rt(u){throw new Error(u)}function Qt(u,e){u||Rt(e)}function Bp(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function zp(u,e=null,t=null){if(!u)return null;try{if(t&&typeof u=="string"){if(t.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(t.tryConvertEncoding)try{u=Gp(u)}catch{}}const s=e?new URL(u,e):new URL(u);if(Bp(s))return s}catch{}return null}function Et(u,e,t,s=!1){return Object.defineProperty(u,e,{value:t,enumerable:!s,configurable:!0,writable:!1}),t}const Yi=function(){function e(t,s){this.constructor===e&&Rt("Cannot initialize BaseException."),this.message=t,this.name=s}return e.prototype=new Error,e.constructor=e,e}();class Kl extends Yi{constructor(e,t){super(e,"PasswordException"),this.code=t}}class Zl extends Yi{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class iu extends Yi{constructor(e){super(e,"InvalidPDFException")}}class sr extends Yi{constructor(e){super(e,"MissingPDFException")}}class Il extends Yi{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class Hp extends Yi{constructor(e){super(e,"FormatError")}}class ir extends Yi{constructor(e){super(e,"AbortException")}}function nu(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&Rt("Invalid argument for bytesToString");const e=u.length,t=8192;if(e>24&255,u>>16&255,u>>8&255,u&255)}function cd(u){const e=Object.create(null);for(const[t,s]of u)e[t]=s;return e}function jp(){const u=new Uint8Array(4);return u[0]=1,new Uint32Array(u.buffer,0,1)[0]===1}function Wp(){try{return new Function(""),!0}catch{return!1}}class ke{static get isLittleEndian(){return Et(this,"isLittleEndian",jp())}static get isEvalSupported(){return Et(this,"isEvalSupported",Wp())}static get isOffscreenCanvasSupported(){return Et(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?Et(this,"platform",{isMac:navigator.platform.includes("Mac")}):Et(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var e,t;return Et(this,"isCSSRoundSupported",(t=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:t.call(e,"width: round(1.5px, 1px)"))}}const Wl=Array.from(Array(256).keys(),u=>u.toString(16).padStart(2,"0"));var bi,Ih,Ql;class at{static makeHexColor(e,t,s){return`#${Wl[e]}${Wl[t]}${Wl[s]}`}static scaleMinMax(e,t){let s;e[0]?(e[0]<0&&(s=t[0],t[0]=t[2],t[2]=s),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(s=t[1],t[1]=t[3],t[3]=s),t[1]*=e[3],t[3]*=e[3]):(s=t[0],t[0]=t[1],t[1]=s,s=t[2],t[2]=t[3],t[3]=s,e[1]<0&&(s=t[1],t[1]=t[3],t[3]=s),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(s=t[0],t[0]=t[2],t[2]=s),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){const s=e[0]*t[0]+e[1]*t[2]+t[4],i=e[0]*t[1]+e[1]*t[3]+t[5];return[s,i]}static applyInverseTransform(e,t){const s=t[0]*t[3]-t[1]*t[2],i=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/s,n=(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/s;return[i,n]}static getAxialAlignedBoundingBox(e,t){const s=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),n=this.applyTransform([e[0],e[3]],t),r=this.applyTransform([e[2],e[1]],t);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],s=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],n=e[2]*t[0]+e[3]*t[2],r=e[2]*t[1]+e[3]*t[3],a=(s+r)/2,h=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,l=a+h||1,c=a-h||1;return[Math.sqrt(l),Math.sqrt(c)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const s=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(s>i)return null;const n=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return n>r?null:[s,n,i,r]}static bezierBoundingBox(e,t,s,i,n,r,a,h,l){return l?(l[0]=Math.min(l[0],e,a),l[1]=Math.min(l[1],t,h),l[2]=Math.max(l[2],e,a),l[3]=Math.max(l[3],t,h)):l=[Math.min(e,a),Math.min(t,h),Math.max(e,a),Math.max(t,h)],E(this,bi,Ql).call(this,e,s,n,a,t,i,r,h,3*(-e+3*(s-n)+a),6*(e-2*s+n),3*(s-e),l),E(this,bi,Ql).call(this,e,s,n,a,t,i,r,h,3*(-t+3*(i-r)+h),6*(t-2*i+r),3*(i-t),l),l}}bi=new WeakSet,Ih=function(e,t,s,i,n,r,a,h,l,c){if(l<=0||l>=1)return;const d=1-l,p=l*l,f=p*l,g=d*(d*(d*e+3*l*t)+3*p*s)+f*i,m=d*(d*(d*n+3*l*r)+3*p*a)+f*h;c[0]=Math.min(c[0],g),c[1]=Math.min(c[1],m),c[2]=Math.max(c[2],g),c[3]=Math.max(c[3],m)},Ql=function(e,t,s,i,n,r,a,h,l,c,d,p){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&E(this,bi,Ih).call(this,e,t,s,i,n,r,a,h,-d/c,p);return}const f=c**2-4*d*l;if(f<0)return;const g=Math.sqrt(f),m=2*l;E(this,bi,Ih).call(this,e,t,s,i,n,r,a,h,(-c+g)/m,p),E(this,bi,Ih).call(this,e,t,s,i,n,r,a,h,(-c-g)/m,p)},S(at,bi);function Gp(u){return decodeURIComponent(escape(u))}let Gl=null,Md=null;function $p(u){return Gl||(Gl=/([\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,Md=new Map([["ſt","ſt"]])),u.replaceAll(Gl,(e,t,s)=>t?t.normalize("NFKC"):Md.get(s))}function Vp(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const u=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(u);else for(let e=0;e<32;e++)u[e]=Math.floor(Math.random()*255);return nu(u)}const ru="pdfjs_internal_id_",Bs={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class Fl{constructor(){this.constructor===Fl&&Rt("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,s,i,n){return"none"}destroy(e=!1){}}var Ba;const yd=class yd{constructor({enableHWA:e=!1}={}){S(this,Ba,!1);this.constructor===yd&&Rt("Cannot initialize BaseCanvasFactory."),w(this,Ba,e)}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(e,t);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!o(this,Ba)})}}reset(e,t,s){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||s<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=s}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Rt("Abstract method `_createCanvas` called.")}};Ba=new WeakMap;let il=yd;class Dl{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===Dl&&Rt("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":""),s=this.isCompressed?Yl.BINARY:Yl.NONE;return this._fetchData(t,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)})}_fetchData(e,t){Rt("Abstract method `_fetchData` called.")}}class Ol{constructor({baseUrl:e=null}){this.constructor===Ol&&Rt("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetchData(t).catch(s=>{throw new Error(`Unable to load font data at: ${t}`)})}_fetchData(e){Rt("Abstract method `_fetchData` called.")}}class dd{constructor(){this.constructor===dd&&Rt("Cannot initialize BaseSVGFactory.")}create(e,t,s=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Rt("Abstract method `_createSVG` called.")}}const Hs="http://www.w3.org/2000/svg",Ji=class Ji{};ft(Ji,"CSS",96),ft(Ji,"PDF",72),ft(Ji,"PDF_TO_CSS_UNITS",Ji.CSS/Ji.PDF);let Vi=Ji;var en,_s,$s,Se,cl,sn,nt,ue,rr,ar,Mh,au,Jl,or,va,ya,tc,Aa;class qp extends Fl{constructor({docId:t,ownerDocument:s=globalThis.document}={}){super();S(this,nt);S(this,en);S(this,_s);S(this,$s);S(this,Se);S(this,cl);S(this,sn,0);w(this,$s,t),w(this,Se,s)}addFilter(t){if(!t)return"none";let s=o(this,nt,ue).get(t);if(s)return s;const[i,n,r]=E(this,nt,Mh).call(this,t),a=t.length===1?i:`${i}${n}${r}`;if(s=o(this,nt,ue).get(a),s)return o(this,nt,ue).set(t,s),s;const h=`g_${o(this,$s)}_transfer_map_${Le(this,sn)._++}`,l=`url(#${h})`;o(this,nt,ue).set(t,l),o(this,nt,ue).set(a,l);const c=E(this,nt,or).call(this,h);return E(this,nt,ya).call(this,i,n,r,c),l}addHCMFilter(t,s){var g;const i=`${t}-${s}`,n="base";let r=o(this,nt,rr).get(n);if((r==null?void 0:r.key)===i||(r?((g=r.filter)==null||g.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},o(this,nt,rr).set(n,r)),!t||!s))return r.url;const a=E(this,nt,Aa).call(this,t);t=at.makeHexColor(...a);const h=E(this,nt,Aa).call(this,s);if(s=at.makeHexColor(...h),o(this,nt,ar).style.color="",t==="#000000"&&s==="#ffffff"||t===s)return r.url;const l=new Array(256);for(let m=0;m<=255;m++){const v=m/255;l[m]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=l.join(","),d=`g_${o(this,$s)}_hcm_filter`,p=r.filter=E(this,nt,or).call(this,d);E(this,nt,ya).call(this,c,c,c,p),E(this,nt,Jl).call(this,p);const f=(m,v)=>{const b=a[m]/255,A=h[m]/255,x=new Array(v+1);for(let k=0;k<=v;k++)x[k]=b+k/v*(A-b);return x.join(",")};return E(this,nt,ya).call(this,f(0,5),f(1,5),f(2,5),p),r.url=`url(#${d})`,r.url}addAlphaFilter(t){let s=o(this,nt,ue).get(t);if(s)return s;const[i]=E(this,nt,Mh).call(this,[t]),n=`alpha_${i}`;if(s=o(this,nt,ue).get(n),s)return o(this,nt,ue).set(t,s),s;const r=`g_${o(this,$s)}_alpha_map_${Le(this,sn)._++}`,a=`url(#${r})`;o(this,nt,ue).set(t,a),o(this,nt,ue).set(n,a);const h=E(this,nt,or).call(this,r);return E(this,nt,tc).call(this,i,h),a}addLuminosityFilter(t){let s=o(this,nt,ue).get(t||"luminosity");if(s)return s;let i,n;if(t?([i]=E(this,nt,Mh).call(this,[t]),n=`luminosity_${i}`):n="luminosity",s=o(this,nt,ue).get(n),s)return o(this,nt,ue).set(t,s),s;const r=`g_${o(this,$s)}_luminosity_map_${Le(this,sn)._++}`,a=`url(#${r})`;o(this,nt,ue).set(t,a),o(this,nt,ue).set(n,a);const h=E(this,nt,or).call(this,r);return E(this,nt,au).call(this,h),t&&E(this,nt,tc).call(this,i,h),a}addHighlightHCMFilter(t,s,i,n,r){var A;const a=`${s}-${i}-${n}-${r}`;let h=o(this,nt,rr).get(t);if((h==null?void 0:h.key)===a||(h?((A=h.filter)==null||A.remove(),h.key=a,h.url="none",h.filter=null):(h={key:a,url:"none",filter:null},o(this,nt,rr).set(t,h)),!s||!i))return h.url;const[l,c]=[s,i].map(E(this,nt,Aa).bind(this));let d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),p=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[f,g]=[n,r].map(E(this,nt,Aa).bind(this));p{const L=new Array(256),I=(p-d)/T,B=x/255,D=(k-x)/(255*T);let W=0;for(let q=0;q<=T;q++){const P=Math.round(d+q*I),z=B+q*D;for(let y=W;y<=P;y++)L[y]=z;W=P+1}for(let q=W;q<256;q++)L[q]=L[W-1];return L.join(",")},v=`g_${o(this,$s)}_hcm_${t}_filter`,b=h.filter=E(this,nt,or).call(this,v);return E(this,nt,Jl).call(this,b),E(this,nt,ya).call(this,m(f[0],g[0],5),m(f[1],g[1],5),m(f[2],g[2],5),b),h.url=`url(#${v})`,h.url}destroy(t=!1){t&&o(this,nt,rr).size!==0||(o(this,_s)&&(o(this,_s).parentNode.parentNode.remove(),w(this,_s,null)),o(this,en)&&(o(this,en).clear(),w(this,en,null)),w(this,sn,0))}}en=new WeakMap,_s=new WeakMap,$s=new WeakMap,Se=new WeakMap,cl=new WeakMap,sn=new WeakMap,nt=new WeakSet,ue=function(){return o(this,en)||w(this,en,new Map)},rr=function(){return o(this,cl)||w(this,cl,new Map)},ar=function(){if(!o(this,_s)){const t=o(this,Se).createElement("div"),{style:s}=t;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=o(this,Se).createElementNS(Hs,"svg");i.setAttribute("width",0),i.setAttribute("height",0),w(this,_s,o(this,Se).createElementNS(Hs,"defs")),t.append(i),i.append(o(this,_s)),o(this,Se).body.append(t)}return o(this,_s)},Mh=function(t){if(t.length===1){const l=t[0],c=new Array(256);for(let p=0;p<256;p++)c[p]=l[p]/255;const d=c.join(",");return[d,d,d]}const[s,i,n]=t,r=new Array(256),a=new Array(256),h=new Array(256);for(let l=0;l<256;l++)r[l]=s[l]/255,a[l]=i[l]/255,h[l]=n[l]/255;return[r.join(","),a.join(","),h.join(",")]},au=function(t){const s=o(this,Se).createElementNS(Hs,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(s)},Jl=function(t){const s=o(this,Se).createElementNS(Hs,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(s)},or=function(t){const s=o(this,Se).createElementNS(Hs,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",t),o(this,nt,ar).append(s),s},va=function(t,s,i){const n=o(this,Se).createElementNS(Hs,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),t.append(n)},ya=function(t,s,i,n){const r=o(this,Se).createElementNS(Hs,"feComponentTransfer");n.append(r),E(this,nt,va).call(this,r,"feFuncR",t),E(this,nt,va).call(this,r,"feFuncG",s),E(this,nt,va).call(this,r,"feFuncB",i)},tc=function(t,s){const i=o(this,Se).createElementNS(Hs,"feComponentTransfer");s.append(i),E(this,nt,va).call(this,i,"feFuncA",t)},Aa=function(t){return o(this,nt,ar).style.color=t,md(getComputedStyle(o(this,nt,ar)).getPropertyValue("color"))};class Xp extends il{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}={}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){const s=this._document.createElement("canvas");return s.width=e,s.height=t,s}}async function Nl(u,e="text"){if(wa(u,document.baseURI)){const t=await fetch(u);if(!t.ok)throw new Error(t.statusText);switch(e){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json()}return t.text()}return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(e){case"arraybuffer":case"blob":case"json":t(i.response);return}t(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class ou extends Dl{_fetchData(e,t){return Nl(e,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):Ml(s),compressionType:t}))}}class hu extends Ol{_fetchData(e){return Nl(e,"arraybuffer").then(t=>new Uint8Array(t))}}class ud extends dd{_createSVG(e){return document.createElementNS(Hs,e)}}class bh{constructor({viewBox:e,scale:t,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=e,this.scale=t,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(e[2]+e[0])/2,h=(e[3]+e[1])/2;let l,c,d,p;switch(s%=360,s<0&&(s+=360),s){case 180:l=-1,c=0,d=0,p=1;break;case 90:l=0,c=1,d=1,p=0;break;case 270:l=0,c=-1,d=-1,p=0;break;case 0:l=1,c=0,d=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,p=-p);let f,g,m,v;l===0?(f=Math.abs(h-e[1])*t+i,g=Math.abs(a-e[0])*t+n,m=(e[3]-e[1])*t,v=(e[2]-e[0])*t):(f=Math.abs(a-e[0])*t+i,g=Math.abs(h-e[1])*t+n,m=(e[2]-e[0])*t,v=(e[3]-e[1])*t),this.transform=[l*t,c*t,d*t,p*t,f-l*t*a-d*t*h,g-c*t*a-p*t*h],this.width=m,this.height=v}get rawDims(){const{viewBox:e}=this;return Et(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new bh({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(e,t){return at.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=at.applyTransform([e[0],e[1]],this.transform),s=at.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],s[0],s[1]]}convertToPdfPoint(e,t){return at.applyInverseTransform([e,t],this.transform)}}class fd extends Yi{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function pd(u){const e=u.length;let t=0;for(;t=1&&i<=12?i-1:0;let n=parseInt(t[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(t[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let h=parseInt(t[6],10);h=h>=0&&h<=59?h:0;const l=t[7]||"Z";let c=parseInt(t[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(t[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(r+=c,a+=d):l==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,i,n,r,a,h))}}function Zp(u,{scale:e=1,rotation:t=0}){const{width:s,height:i}=u.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new bh({viewBox:n,scale:e,rotation:t})}function md(u){if(u.startsWith("#")){const e=parseInt(u.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return u.startsWith("rgb(")?u.slice(4,-1).split(",").map(e=>parseInt(e)):u.startsWith("rgba(")?u.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(gt(`Not a valid color format: "${u}"`),[0,0,0])}function Qp(u){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const t of u.keys()){e.style.color=t;const s=window.getComputedStyle(e).color;u.set(t,md(s))}e.remove()}function Bt(u){const{a:e,b:t,c:s,d:i,e:n,f:r}=u.getTransform();return[e,t,s,i,n,r]}function zs(u){const{a:e,b:t,c:s,d:i,e:n,f:r}=u.getTransform().invertSelf();return[e,t,s,i,n,r]}function Zn(u,e,t=!1,s=!0){if(e instanceof bh){const{pageWidth:i,pageHeight:n}=e.rawDims,{style:r}=u,a=ke.isCSSRoundSupported,h=`var(--scale-factor) * ${i}px`,l=`var(--scale-factor) * ${n}px`,c=a?`round(${h}, 1px)`:`calc(${h})`,d=a?`round(${l}, 1px)`:`calc(${l})`;!t||e.rotation%180===0?(r.width=c,r.height=d):(r.width=d,r.height=c)}s&&u.setAttribute("data-main-rotation",e.rotation)}var nn,rn,Fe,an,dl,du,Ae,uu,fu,Fh,pu,sc;const ul=class ul{constructor(e){S(this,Ae);S(this,nn,null);S(this,rn,null);S(this,Fe);S(this,an,null);w(this,Fe,e)}render(){const e=w(this,nn,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar");const t=o(this,Fe)._uiManager._signal;e.addEventListener("contextmenu",Re,{signal:t}),e.addEventListener("pointerdown",E(ul,dl,du),{signal:t});const s=w(this,an,document.createElement("div"));s.className="buttons",e.append(s);const i=o(this,Fe).toolbarPosition;if(i){const{style:n}=e,r=o(this,Fe)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return E(this,Ae,pu).call(this),e}hide(){var e;o(this,nn).classList.add("hidden"),(e=o(this,rn))==null||e.hideDropdown()}show(){o(this,nn).classList.remove("hidden")}addAltTextButton(e){E(this,Ae,Fh).call(this,e),o(this,an).prepend(e,o(this,Ae,sc))}addColorPicker(e){w(this,rn,e);const t=e.renderButton();E(this,Ae,Fh).call(this,t),o(this,an).prepend(t,o(this,Ae,sc))}remove(){var e;o(this,nn).remove(),(e=o(this,rn))==null||e.destroy(),w(this,rn,null)}};nn=new WeakMap,rn=new WeakMap,Fe=new WeakMap,an=new WeakMap,dl=new WeakSet,du=function(e){e.stopPropagation()},Ae=new WeakSet,uu=function(e){o(this,Fe)._focusEventsAllowed=!1,e.preventDefault(),e.stopPropagation()},fu=function(e){o(this,Fe)._focusEventsAllowed=!0,e.preventDefault(),e.stopPropagation()},Fh=function(e){const t=o(this,Fe)._uiManager._signal;e.addEventListener("focusin",E(this,Ae,uu).bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",E(this,Ae,fu).bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",Re,{signal:t})},pu=function(){const e=document.createElement("button");e.className="delete",e.tabIndex=0,e.setAttribute("data-l10n-id",`pdfjs-editor-remove-${o(this,Fe).editorType}-button`),E(this,Ae,Fh).call(this,e),e.addEventListener("click",t=>{o(this,Fe)._uiManager.delete()},{signal:o(this,Fe)._uiManager._signal}),o(this,an).append(e)},sc=function(){const e=document.createElement("div");return e.className="divider",e},S(ul,dl);let ec=ul;var za,on,hn,qi,gu,mu,bu;class Jp{constructor(e){S(this,qi);S(this,za,null);S(this,on,null);S(this,hn);w(this,hn,e)}show(e,t,s){const[i,n]=E(this,qi,mu).call(this,t,s),{style:r}=o(this,on)||w(this,on,E(this,qi,gu).call(this));e.append(o(this,on)),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){o(this,on).remove()}}za=new WeakMap,on=new WeakMap,hn=new WeakMap,qi=new WeakSet,gu=function(){const e=w(this,on,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",Re,{signal:o(this,hn)._signal});const t=w(this,za,document.createElement("div"));return t.className="buttons",e.append(t),E(this,qi,bu).call(this),e},mu=function(e,t){let s=0,i=0;for(const n of e){const r=n.y+n.height;if(rs){i=a,s=r;continue}t?a>i&&(i=a):a{o(this,hn).highlightSelection("floating_button")},{signal:s}),o(this,za).append(e)};function nl(u,e,t){for(const s of t)e.addEventListener(s,u[s].bind(u))}function tg(u){return Math.round(Math.min(255,Math.max(1,255*u))).toString(16).padStart(2,"0")}var fl;class eg{constructor(){S(this,fl,0)}get id(){return`${Mp}${Le(this,fl)._++}`}}fl=new WeakMap;var Ha,pl,Ve,Ua,nc;const Ad=class Ad{constructor(){S(this,Ua);S(this,Ha,Vp());S(this,pl,0);S(this,Ve,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return Et(this,"_isSVGFittingCanvas",n)}async getFromFile(e){const{lastModified:t,name:s,size:i,type:n}=e;return E(this,Ua,nc).call(this,`${t}_${s}_${i}_${n}`,e)}async getFromUrl(e){return E(this,Ua,nc).call(this,e,e)}async getFromId(e){o(this,Ve)||w(this,Ve,new Map);const t=o(this,Ve).get(e);return t?t.bitmap?(t.refCounter+=1,t):t.file?this.getFromFile(t.file):this.getFromUrl(t.url):null}getSvgUrl(e){const t=o(this,Ve).get(e);return t!=null&&t.isSvg?t.svgUrl:null}deleteId(e){o(this,Ve)||w(this,Ve,new Map);const t=o(this,Ve).get(e);t&&(t.refCounter-=1,t.refCounter===0&&(t.bitmap=null))}isValidId(e){return e.startsWith(`image_${o(this,Ha)}_`)}};Ha=new WeakMap,pl=new WeakMap,Ve=new WeakMap,Ua=new WeakSet,nc=async function(e,t){o(this,Ve)||w(this,Ve,new Map);let s=o(this,Ve).get(e);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${o(this,Ha)}_${Le(this,pl)._++}`,refCounter:0,isSvg:!1});let i;if(typeof t=="string"?(s.url=t,i=await Nl(t,"blob")):i=s.file=t,i.type==="image/svg+xml"){const n=Ad._isSVGFittingCanvas,r=new FileReader,a=new Image,h=new Promise((l,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await h}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return o(this,Ve).set(e,s),s&&o(this,Ve).set(s.id,s),s};let ic=Ad;var Jt,xi,ja,te;class sg{constructor(e=128){S(this,Jt,[]);S(this,xi,!1);S(this,ja);S(this,te,-1);w(this,ja,e)}add({cmd:e,undo:t,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&e(),o(this,xi))return;const h={cmd:e,undo:t,post:s,type:n};if(o(this,te)===-1){o(this,Jt).length>0&&(o(this,Jt).length=0),w(this,te,0),o(this,Jt).push(h);return}if(r&&o(this,Jt)[o(this,te)].type===n){a&&(h.undo=o(this,Jt)[o(this,te)].undo),o(this,Jt)[o(this,te)]=h;return}const l=o(this,te)+1;l===o(this,ja)?o(this,Jt).splice(0,1):(w(this,te,l),ln===t[r]))return ml._colorsMapping.get(s);return t}getHexCode(e){const t=this._colors.get(e);return t?at.makeHexColor(...t):e}};ft(ml,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let rc=ml;var gr,De,Xt,ne,mr,Vs,br,ss,_r,ln,vs,is,cn,Wa,Ga,ys,vr,Ci,As,bl,ki,$a,dn,Va,yr,re,Ct,qs,un,qa,Xa,Ya,Ka,Za,Qa,Ja,to,eo,so,io,no,ro,Ti,ws,Xs,ao,tt,Dh,vu,yu,Oh,Au,wu,Eu,ac,Su,oc,hc,xu,be,Ai,Cu,ku,lc,Tu,Ea,cc;const ur=class ur{constructor(e,t,s,i,n,r,a,h,l){S(this,tt);S(this,gr,new AbortController);S(this,De,null);S(this,Xt,new Map);S(this,ne,new Map);S(this,mr,null);S(this,Vs,null);S(this,br,null);S(this,ss,new sg);S(this,_r,0);S(this,ln,new Set);S(this,vs,null);S(this,is,null);S(this,cn,new Set);S(this,Wa,!1);S(this,Ga,null);S(this,ys,null);S(this,vr,null);S(this,Ci,!1);S(this,As,null);S(this,bl,new eg);S(this,ki,!1);S(this,$a,!1);S(this,dn,null);S(this,Va,null);S(this,yr,null);S(this,re,wt.NONE);S(this,Ct,new Set);S(this,qs,null);S(this,un,null);S(this,qa,null);S(this,Xa,this.blur.bind(this));S(this,Ya,this.focus.bind(this));S(this,Ka,this.copy.bind(this));S(this,Za,this.cut.bind(this));S(this,Qa,this.paste.bind(this));S(this,Ja,this.keydown.bind(this));S(this,to,this.keyup.bind(this));S(this,eo,this.onEditingAction.bind(this));S(this,so,this.onPageChanging.bind(this));S(this,io,this.onScaleChanging.bind(this));S(this,no,this.onRotationChanging.bind(this));S(this,ro,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});S(this,Ti,[0,0]);S(this,ws,null);S(this,Xs,null);S(this,ao,null);this._signal=o(this,gr).signal,w(this,Xs,e),w(this,ao,t),w(this,mr,s),this._eventBus=i,this._eventBus._on("editingaction",o(this,eo)),this._eventBus._on("pagechanging",o(this,so)),this._eventBus._on("scalechanging",o(this,io)),this._eventBus._on("rotationchanging",o(this,no)),E(this,tt,Au).call(this),E(this,tt,xu).call(this),E(this,tt,ac).call(this),w(this,Vs,n.annotationStorage),w(this,Ga,n.filterFactory),w(this,un,r),w(this,vr,a||null),w(this,Wa,h),w(this,yr,l||null),this.viewParameters={realScale:Vi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const e=ur.prototype,t=r=>o(r,Xs).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:h}=a;return h!=="text"&&h!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return Et(this,"_keyboardManager",new _h([[["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:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&o(r,Xs).contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&o(r,Xs).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:t}]]))}destroy(){var e,t,s;(e=o(this,gr))==null||e.abort(),w(this,gr,null),this._signal=null,this._eventBus._off("editingaction",o(this,eo)),this._eventBus._off("pagechanging",o(this,so)),this._eventBus._off("scalechanging",o(this,io)),this._eventBus._off("rotationchanging",o(this,no));for(const i of o(this,ne).values())i.destroy();o(this,ne).clear(),o(this,Xt).clear(),o(this,cn).clear(),w(this,De,null),o(this,Ct).clear(),o(this,ss).destroy(),(t=o(this,mr))==null||t.destroy(),(s=o(this,As))==null||s.hide(),w(this,As,null),o(this,ys)&&(clearTimeout(o(this,ys)),w(this,ys,null)),o(this,ws)&&(clearTimeout(o(this,ws)),w(this,ws,null))}async mlGuess(e){var t;return((t=o(this,yr))==null?void 0:t.guess(e))||null}get hasMLManager(){return!!o(this,yr)}get hcmFilter(){return Et(this,"hcmFilter",o(this,un)?o(this,Ga).addHCMFilter(o(this,un).foreground,o(this,un).background):"none")}get direction(){return Et(this,"direction",getComputedStyle(o(this,Xs)).direction)}get highlightColors(){return Et(this,"highlightColors",o(this,vr)?new Map(o(this,vr).split(",").map(e=>e.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return Et(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setMainHighlightColorPicker(e){w(this,Va,e)}editAltText(e){var t;(t=o(this,mr))==null||t.editAltText(this,e)}onPageChanging({pageNumber:e}){w(this,_r,e-1)}focusMainContainer(){o(this,Xs).focus()}findParent(e,t){for(const s of o(this,ne).values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(e>=i&&e<=i+r&&t>=n&&t<=n+a)return s}return null}disableUserSelect(e=!1){o(this,ao).classList.toggle("noUserSelect",e)}addShouldRescale(e){o(this,cn).add(e)}removeShouldRescale(e){o(this,cn).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Vi.PDF_TO_CSS_UNITS;for(const t of o(this,cn))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=t,a=t.toString(),l=E(this,tt,Dh).call(this,t).closest(".textLayer"),c=this.getSelectionBoxes(l);if(c){t.empty(),o(this,re)===wt.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:wt.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const d of o(this,ne).values())if(d.hasTextLayer(l)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:c,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}addToAnnotationStorage(e){!e.isEmpty()&&o(this,Vs)&&!o(this,Vs).has(e.id)&&o(this,Vs).setValue(e.id,e)}blur(){if(this.isShiftKeyDown=!1,o(this,Ci)&&(w(this,Ci,!1),E(this,tt,Oh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of o(this,Ct))if(t.div.contains(e)){w(this,dn,[t,e]),t._focusEventsAllowed=!1;break}}focus(){if(!o(this,dn))return;const[e,t]=o(this,dn);w(this,dn,null),t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){E(this,tt,ac).call(this),E(this,tt,oc).call(this)}removeEditListeners(){E(this,tt,Su).call(this),E(this,tt,hc).call(this)}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const s of o(this,is))if(s.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const t of e.dataTransfer.items)for(const s of o(this,is))if(s.isHandlingMimeForPasting(t.type)){s.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){var s;if(e.preventDefault(),(s=o(this,De))==null||s.commitOrRemove(),!this.hasSelection)return;const t=[];for(const i of o(this,Ct)){const n=i.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();const{clipboardData:t}=e;for(const n of t.items)for(const r of o(this,is))if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=t.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){gt(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const h of s){const l=i.deserialize(h);if(!l)return;n.push(l)}const r=()=>{for(const h of n)E(this,tt,lc).call(this,h);E(this,tt,cc).call(this,n)},a=()=>{for(const h of n)h.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){gt(`paste: "${n.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),o(this,re)!==wt.NONE&&!this.isEditorHandlingKeyboard&&ur._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,o(this,Ci)&&(w(this,Ci,!1),E(this,tt,Oh).call(this,"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}}setEditingState(e){e?(E(this,tt,wu).call(this),E(this,tt,oc).call(this),E(this,tt,be).call(this,{isEditing:o(this,re)!==wt.NONE,isEmpty:E(this,tt,Ea).call(this),hasSomethingToUndo:o(this,ss).hasSomethingToUndo(),hasSomethingToRedo:o(this,ss).hasSomethingToRedo(),hasSelectedEditor:!1})):(E(this,tt,Eu).call(this),E(this,tt,hc).call(this),E(this,tt,be).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!o(this,is)){w(this,is,e);for(const t of o(this,is))E(this,tt,Ai).call(this,t.defaultPropertiesToUpdate)}}getId(){return o(this,bl).id}get currentLayer(){return o(this,ne).get(o(this,_r))}getLayer(e){return o(this,ne).get(e)}get currentPageIndex(){return o(this,_r)}addLayer(e){o(this,ne).set(e.pageIndex,e),o(this,ki)?e.enable():e.disable()}removeLayer(e){o(this,ne).delete(e.pageIndex)}updateMode(e,t=null,s=!1){if(o(this,re)!==e){if(w(this,re,e),e===wt.NONE){this.setEditingState(!1),E(this,tt,ku).call(this);return}this.setEditingState(!0),E(this,tt,Cu).call(this),this.unselectAll();for(const i of o(this,ne).values())i.updateMode(e);if(!t&&s){this.addNewEditorFromKeyboard();return}if(t){for(const i of o(this,Xt).values())if(i.annotationElementId===t){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==o(this,re)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){var s;if(o(this,is)){switch(e){case ut.CREATE:this.currentLayer.addNewEditor();return;case ut.HIGHLIGHT_DEFAULT_COLOR:(s=o(this,Va))==null||s.updateColor(t);break;case ut.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(o(this,qa)||w(this,qa,new Map)).set(e,t),this.showAllEditors("highlight",t);break}for(const i of o(this,Ct))i.updateParams(e,t);for(const i of o(this,is))i.updateDefaultParams(e,t)}}showAllEditors(e,t,s=!1){var n;for(const r of o(this,Xt).values())r.editorType===e&&r.show(t);(((n=o(this,qa))==null?void 0:n.get(ut.HIGHLIGHT_SHOW_ALL))??!0)!==t&&E(this,tt,Ai).call(this,[[ut.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(o(this,$a)!==e){w(this,$a,e);for(const t of o(this,ne).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}getEditors(e){const t=[];for(const s of o(this,Xt).values())s.pageIndex===e&&t.push(s);return t}getEditor(e){return o(this,Xt).get(e)}addEditor(e){o(this,Xt).set(e.id,e)}removeEditor(e){var t;e.div.contains(document.activeElement)&&(o(this,ys)&&clearTimeout(o(this,ys)),w(this,ys,setTimeout(()=>{this.focusMainContainer(),w(this,ys,null)},0))),o(this,Xt).delete(e.id),this.unselect(e),(!e.annotationElementId||!o(this,ln).has(e.annotationElementId))&&((t=o(this,Vs))==null||t.remove(e.id))}addDeletedAnnotationElement(e){o(this,ln).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return o(this,ln).has(e)}removeDeletedAnnotationElement(e){o(this,ln).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){o(this,De)!==e&&(w(this,De,e),e&&E(this,tt,Ai).call(this,e.propertiesToUpdate))}updateUI(e){o(this,tt,Tu)===e&&E(this,tt,Ai).call(this,e.propertiesToUpdate)}toggleSelected(e){if(o(this,Ct).has(e)){o(this,Ct).delete(e),e.unselect(),E(this,tt,be).call(this,{hasSelectedEditor:this.hasSelection});return}o(this,Ct).add(e),e.select(),E(this,tt,Ai).call(this,e.propertiesToUpdate),E(this,tt,be).call(this,{hasSelectedEditor:!0})}setSelected(e){for(const t of o(this,Ct))t!==e&&t.unselect();o(this,Ct).clear(),o(this,Ct).add(e),e.select(),E(this,tt,Ai).call(this,e.propertiesToUpdate),E(this,tt,be).call(this,{hasSelectedEditor:!0})}isSelected(e){return o(this,Ct).has(e)}get firstSelectedEditor(){return o(this,Ct).values().next().value}unselect(e){e.unselect(),o(this,Ct).delete(e),E(this,tt,be).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return o(this,Ct).size!==0}get isEnterHandled(){return o(this,Ct).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){o(this,ss).undo(),E(this,tt,be).call(this,{hasSomethingToUndo:o(this,ss).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:E(this,tt,Ea).call(this)})}redo(){o(this,ss).redo(),E(this,tt,be).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:o(this,ss).hasSomethingToRedo(),isEmpty:E(this,tt,Ea).call(this)})}addCommands(e){o(this,ss).add(e),E(this,tt,be).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:E(this,tt,Ea).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const e=[...o(this,Ct)],t=()=>{for(const i of e)i.remove()},s=()=>{for(const i of e)E(this,tt,lc).call(this,i)};this.addCommands({cmd:t,undo:s,mustExec:!0})}commitOrRemove(){var e;(e=o(this,De))==null||e.commitOrRemove()}hasSomethingToControl(){return o(this,De)||this.hasSelection}selectAll(){for(const e of o(this,Ct))e.commit();E(this,tt,cc).call(this,o(this,Xt).values())}unselectAll(){if(!(o(this,De)&&(o(this,De).commitOrRemove(),o(this,re)!==wt.NONE))&&this.hasSelection){for(const e of o(this,Ct))e.unselect();o(this,Ct).clear(),E(this,tt,be).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;o(this,Ti)[0]+=e,o(this,Ti)[1]+=t;const[i,n]=o(this,Ti),r=[...o(this,Ct)],a=1e3;o(this,ws)&&clearTimeout(o(this,ws)),w(this,ws,setTimeout(()=>{w(this,ws,null),o(this,Ti)[0]=o(this,Ti)[1]=0,this.addCommands({cmd:()=>{for(const h of r)o(this,Xt).has(h.id)&&h.translateInPage(i,n)},undo:()=>{for(const h of r)o(this,Xt).has(h.id)&&h.translateInPage(-i,-n)},mustExec:!1})},a));for(const h of r)h.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),w(this,vs,new Map);for(const e of o(this,Ct))o(this,vs).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!o(this,vs))return!1;this.disableUserSelect(!1);const e=o(this,vs);w(this,vs,null);let t=!1;for(const[{x:i,y:n,pageIndex:r},a]of e)a.newX=i,a.newY=n,a.newPageIndex=r,t||(t=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex);if(!t)return!1;const s=(i,n,r,a)=>{if(o(this,Xt).has(i.id)){const h=o(this,ne).get(a);h?i._setParentAndPosition(h,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of e)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of e)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(o(this,vs))for(const s of o(this,vs).keys())s.drag(e,t)}rebuild(e){if(e.parent===null){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||o(this,Ct).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return o(this,De)===e}getActive(){return o(this,De)}getMode(){return o(this,re)}get imageManager(){return Et(this,"imageManager",new ic)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let l=0,c=t.rangeCount;l({x:(c-i)/r,y:1-(l+d-s)/n,width:p/r,height:d/n});break;case"180":a=(l,c,d,p)=>({x:1-(l+d-s)/n,y:1-(c+p-i)/r,width:d/n,height:p/r});break;case"270":a=(l,c,d,p)=>({x:1-(c+p-i)/r,y:(l-s)/n,width:p/r,height:d/n});break;default:a=(l,c,d,p)=>({x:(l-s)/n,y:(c-i)/r,width:d/n,height:p/r});break}const h=[];for(let l=0,c=t.rangeCount;l{c.type==="pointerup"&&c.button!==0||(window.removeEventListener("pointerup",l),window.removeEventListener("blur",l),c.type==="pointerup"&&E(this,tt,Oh).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:h}),window.addEventListener("blur",l,{signal:h})}},Oh=function(e=""){o(this,re)===wt.HIGHLIGHT?this.highlightSelection(e):o(this,Wa)&&E(this,tt,vu).call(this)},Au=function(){document.addEventListener("selectionchange",E(this,tt,yu).bind(this),{signal:this._signal})},wu=function(){const e=this._signal;window.addEventListener("focus",o(this,Ya),{signal:e}),window.addEventListener("blur",o(this,Xa),{signal:e})},Eu=function(){window.removeEventListener("focus",o(this,Ya)),window.removeEventListener("blur",o(this,Xa))},ac=function(){const e=this._signal;window.addEventListener("keydown",o(this,Ja),{signal:e}),window.addEventListener("keyup",o(this,to),{signal:e})},Su=function(){window.removeEventListener("keydown",o(this,Ja)),window.removeEventListener("keyup",o(this,to))},oc=function(){const e=this._signal;document.addEventListener("copy",o(this,Ka),{signal:e}),document.addEventListener("cut",o(this,Za),{signal:e}),document.addEventListener("paste",o(this,Qa),{signal:e})},hc=function(){document.removeEventListener("copy",o(this,Ka)),document.removeEventListener("cut",o(this,Za)),document.removeEventListener("paste",o(this,Qa))},xu=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},be=function(e){Object.entries(e).some(([s,i])=>o(this,ro)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(o(this,ro),e)}),o(this,re)===wt.HIGHLIGHT&&e.hasSelectedEditor===!1&&E(this,tt,Ai).call(this,[[ut.HIGHLIGHT_FREE,!0]]))},Ai=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},Cu=function(){if(!o(this,ki)){w(this,ki,!0);for(const e of o(this,ne).values())e.enable();for(const e of o(this,Xt).values())e.enable()}},ku=function(){if(this.unselectAll(),o(this,ki)){w(this,ki,!1);for(const e of o(this,ne).values())e.disable();for(const e of o(this,Xt).values())e.disable()}},lc=function(e){const t=o(this,ne).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Tu=function(){let e=null;for(e of o(this,Ct));return e},Ea=function(){if(o(this,Xt).size===0)return!0;if(o(this,Xt).size===1)for(const e of o(this,Xt).values())return e.isEmpty();return!1},cc=function(e){for(const t of o(this,Ct))t.unselect();o(this,Ct).clear();for(const t of e)t.isEmpty()||(o(this,Ct).add(t),t.select());E(this,tt,be).call(this,{hasSelectedEditor:this.hasSelection})},ft(ur,"TRANSLATE_SMALL",1),ft(ur,"TRANSLATE_BIG",10);let Qn=ur;var Ys,Ks,ns,Zs,Oe,Ar,rs,oo,dc;const Us=class Us{constructor(e){S(this,oo);S(this,Ys,"");S(this,Ks,!1);S(this,ns,null);S(this,Zs,null);S(this,Oe,null);S(this,Ar,!1);S(this,rs,null);w(this,rs,e)}static initialize(e){Us._l10nPromise||(Us._l10nPromise=e)}async render(){const e=w(this,ns,document.createElement("button"));e.className="altText";const t=await Us._l10nPromise.get("pdfjs-editor-alt-text-button-label");e.textContent=t,e.setAttribute("aria-label",t),e.tabIndex="0";const s=o(this,rs)._uiManager._signal;e.addEventListener("contextmenu",Re,{signal:s}),e.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),o(this,rs)._uiManager.editAltText(o(this,rs))};return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",n=>{n.target===e&&n.key==="Enter"&&(w(this,Ar,!0),i(n))},{signal:s}),await E(this,oo,dc).call(this),e}finish(){o(this,ns)&&(o(this,ns).focus({focusVisible:o(this,Ar)}),w(this,Ar,!1))}isEmpty(){return!o(this,Ys)&&!o(this,Ks)}get data(){return{altText:o(this,Ys),decorative:o(this,Ks)}}set data({altText:e,decorative:t}){o(this,Ys)===e&&o(this,Ks)===t||(w(this,Ys,e),w(this,Ks,t),E(this,oo,dc).call(this))}toggle(e=!1){o(this,ns)&&(!e&&o(this,Oe)&&(clearTimeout(o(this,Oe)),w(this,Oe,null)),o(this,ns).disabled=!e)}destroy(){var e;(e=o(this,ns))==null||e.remove(),w(this,ns,null),w(this,Zs,null)}};Ys=new WeakMap,Ks=new WeakMap,ns=new WeakMap,Zs=new WeakMap,Oe=new WeakMap,Ar=new WeakMap,rs=new WeakMap,oo=new WeakSet,dc=async function(){var i;const e=o(this,ns);if(!e)return;if(!o(this,Ys)&&!o(this,Ks)){e.classList.remove("done"),(i=o(this,Zs))==null||i.remove();return}e.classList.add("done"),Us._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(n=>{e.setAttribute("aria-label",n)});let t=o(this,Zs);if(!t){w(this,Zs,t=document.createElement("span")),t.className="tooltip",t.setAttribute("role","tooltip");const n=t.id=`alt-text-tooltip-${o(this,rs).id}`;e.setAttribute("aria-describedby",n);const r=100,a=o(this,rs)._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(o(this,Oe)),w(this,Oe,null)},{once:!0}),e.addEventListener("mouseenter",()=>{w(this,Oe,setTimeout(()=>{w(this,Oe,null),o(this,Zs).classList.add("show"),o(this,rs)._reportTelemetry({action:"alt_text_tooltip"})},r))},{signal:a}),e.addEventListener("mouseleave",()=>{var h;o(this,Oe)&&(clearTimeout(o(this,Oe)),w(this,Oe,null)),(h=o(this,Zs))==null||h.classList.remove("show")},{signal:a})}t.innerText=o(this,Ks)?await Us._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):o(this,Ys),t.parentNode||e.append(t);const s=o(this,rs).getImageForAltText();s==null||s.setAttribute("aria-describedby",t.id)},ft(Us,"_l10nPromise",null);let rl=Us;var fn,as,pe,wr,pn,ae,gn,Er,Sr,ge,ho,mn,Ri,lo,bn,Qs,Es,xr,Cr,qe,co,_l,mt,uc,uo,fc,pc,Ru,Pu,gc,mc,bc,Lu,Iu,Mu,Fu,_c,Sa;const It=class It{constructor(e){S(this,mt);S(this,fn,null);S(this,as,null);S(this,pe,null);S(this,wr,!1);S(this,pn,!1);S(this,ae,null);S(this,gn,null);S(this,Er,this.focusin.bind(this));S(this,Sr,this.focusout.bind(this));S(this,ge,null);S(this,ho,"");S(this,mn,!1);S(this,Ri,null);S(this,lo,!1);S(this,bn,!1);S(this,Qs,!1);S(this,Es,null);S(this,xr,0);S(this,Cr,0);S(this,qe,null);ft(this,"_initialOptions",Object.create(null));ft(this,"_isVisible",!0);ft(this,"_uiManager",null);ft(this,"_focusEventsAllowed",!0);ft(this,"_l10nPromise",null);S(this,co,!1);S(this,_l,It._zIndex++);this.constructor===It&&Rt("Cannot initialize AnnotationEditor."),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;const{rotation:t,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,h]=this.parentDimensions;this.x=e.x/a,this.y=e.y/h,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=It.prototype._resizeWithKeyboard,t=Qn.TRANSLATE_SMALL,s=Qn.TRANSLATE_BIG;return Et(this,"_resizerKeyboardManager",new _h([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],It.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return Et(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new ig({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t,s){if(It._l10nPromise||(It._l10nPromise=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,e.get(n.replaceAll(/([A-Z])/g,r=>`-${r.toLowerCase()}`))]))),s!=null&&s.strings)for(const n of s.strings)It._l10nPromise.set(n,e.get(n));if(It._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);It._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Rt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return o(this,co)}set _isDraggable(e){var t;w(this,co,e),(t=this.div)==null||t.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*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=o(this,_l)}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):E(this,mt,Sa).call(this),this.parent=e}focusin(e){this._focusEventsAllowed&&(o(this,mn)?w(this,mn,!1):this.parent.setSelected(this))}focusout(e){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const t=e.relatedTarget;t!=null&&t.closest(`#${this.id}`)||(e.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(e+s)/n,this.y=(t+i)/r,this.fixAndSetPosition()}translate(e,t){E(this,mt,uc).call(this,this.parentDimensions,e,t)}translateInPage(e,t){o(this,Ri)||w(this,Ri,[this.x,this.y]),E(this,mt,uc).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){o(this,Ri)||w(this,Ri,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=e/s,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:l,y:c}=this.div.getBoundingClientRect();this.parent.findNewParent(this,l,c)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,h]=this.getBaseTranslation();n+=a,r+=h,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!o(this,Ri)&&(o(this,Ri)[0]!==this.x||o(this,Ri)[1]!==this.y)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:s}=It,i=s/e,n=s/t;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const[t,s]=this.pageDimensions;let{x:i,y:n,width:r,height:a}=this;if(r*=t,a*=s,i*=t,n*=s,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(t-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(t-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(t,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(t,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n));break}this.x=i/=t,this.y=n/=s;const[h,l]=this.getBaseTranslation();i+=h,n+=l;const{style:c}=this.div;c.left=`${(100*i).toFixed(2)}%`,c.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,t){var s;return E(s=It,uo,fc).call(s,e,t,this.parentRotation)}pageTranslationToScreen(e,t){var s;return E(s=It,uo,fc).call(s,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,s]}=this,i=t*e,n=s*e;return ke.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(e,t){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*e/s).toFixed(2)}%`,o(this,pn)||(this.div.style.height=`${(100*t/i).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:s}=e,i=s.endsWith("%"),n=!o(this,pn)&&t.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(e.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!o(this,pn)&&!n&&(e.height=`${(100*parseFloat(t)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var e;(e=o(this,pe))==null||e.finish()}async addEditToolbar(){return o(this,ge)||o(this,bn)?o(this,ge):(w(this,ge,new ec(this)),this.div.append(o(this,ge).render()),o(this,pe)&&o(this,ge).addAltTextButton(await o(this,pe).render()),o(this,ge))}removeEditToolbar(){var e;o(this,ge)&&(o(this,ge).remove(),w(this,ge,null),(e=o(this,pe))==null||e.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){o(this,pe)||(rl.initialize(It._l10nPromise),w(this,pe,new rl(this)),o(this,fn)&&(o(this,pe).data=o(this,fn),w(this,fn,null)),await this.addEditToolbar())}get altTextData(){var e;return(e=o(this,pe))==null?void 0:e.data}set altTextData(e){o(this,pe)&&(o(this,pe).data=e)}hasAltText(){var e;return!((e=o(this,pe))!=null&&e.isEmpty())}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=o(this,wr)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const e=this._uiManager._signal;this.div.addEventListener("focusin",o(this,Er),{signal:e}),this.div.addEventListener("focusout",o(this,Sr),{signal:e});const[t,s]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*s/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),nl(this,this.div,["pointerdown"]),this.div}pointerdown(e){const{isMac:t}=ke.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(w(this,mn,!0),this._isDraggable){E(this,mt,Lu).call(this,e);return}E(this,mt,bc).call(this,e)}moveInDOM(){o(this,Es)&&clearTimeout(o(this,Es)),w(this,Es,setTimeout(()=>{var e;w(this,Es,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,s){e.changeParent(this),this.x=t,this.y=s,this.fixAndSetPosition()}getRect(e,t,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,h]=this.pageTranslation,l=e/i,c=t/i,d=this.x*n,p=this.y*r,f=this.width*n,g=this.height*r;switch(s){case 0:return[d+l+a,r-p-c-g+h,d+l+f+a,r-p-c+h];case 90:return[d+c+a,r-p+l+h,d+c+g+a,r-p+l+f+h];case 180:return[d-l-f+a,r-p+c+h,d-l+a,r-p+c+g+h];case 270:return[d-c-g+a,r-p-l-f+h,d-c+a,r-p-l+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[s,i,n,r]=e,a=n-s,h=r-i;switch(this.rotation){case 0:return[s,t-r,a,h];case 90:return[s,t-i,h,a];case 180:return[n,t-i,a,h];case 270:return[n,t-r,h,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){w(this,bn,!0)}disableEditMode(){w(this,bn,!1)}isInEditMode(){return o(this,bn)}shouldGetKeyboardEvents(){return o(this,Qs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var t,s;const e=this._uiManager._signal;(t=this.div)==null||t.addEventListener("focusin",o(this,Er),{signal:e}),(s=this.div)==null||s.addEventListener("focusout",o(this,Sr),{signal:e})}rotate(e){}serialize(e=!1,t=null){Rt("An editor must be serializable")}static deserialize(e,t,s){const i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:s});i.rotation=e.rotation,w(i,fn,e.accessibilityData);const[n,r]=i.pageDimensions,[a,h,l,c]=i.getRectInCurrentCoords(e.rect,r);return i.x=a/n,i.y=h/r,i.width=l/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",o(this,Er)),this.div.removeEventListener("focusout",o(this,Sr)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),o(this,Es)&&(clearTimeout(o(this,Es)),w(this,Es,null)),E(this,mt,Sa).call(this),this.removeEditToolbar(),o(this,qe)){for(const e of o(this,qe).values())clearTimeout(e);w(this,qe,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(E(this,mt,Ru).call(this),o(this,ae).classList.remove("hidden"),nl(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),w(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=o(this,ae).children;if(!o(this,as)){w(this,as,Array.from(t));const r=E(this,mt,Iu).bind(this),a=E(this,mt,Mu).bind(this),h=this._uiManager._signal;for(const l of o(this,as)){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:h}),l.addEventListener("blur",a,{signal:h}),l.addEventListener("focus",E(this,mt,Fu).bind(this,c),{signal:h}),It._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>l.setAttribute("aria-label",d))}}const s=o(this,as)[0];let i=0;for(const r of t){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(o(this,as).length/4);if(n!==i){if(ni)for(let a=0;aa.setAttribute("aria-label",c))}}E(this,mt,_c).call(this,0),w(this,Qs,!0),o(this,ae).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,t){o(this,Qs)&&E(this,mt,mc).call(this,o(this,ho),{movementX:e,movementY:t})}_stopResizingWithKeyboard(){E(this,mt,Sa).call(this),this.div.focus()}select(){var e,t;if(this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!o(this,ge)){this.addEditToolbar().then(()=>{var s,i;(s=this.div)!=null&&s.classList.contains("selectedEditor")&&((i=o(this,ge))==null||i.show())});return}(t=o(this,ge))==null||t.show()}unselect(){var e,t,s,i;(e=o(this,ae))==null||e.classList.add("hidden"),(t=this.div)==null||t.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=o(this,ge))==null||i.hide()}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return o(this,lo)}set isEditing(e){w(this,lo,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){w(this,pn,!0);const s=e/t,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){o(this,qe)||w(this,qe,new Map);const{action:s}=e;let i=o(this,qe).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),o(this,qe).delete(s),o(this,qe).size===0&&w(this,qe,null)},It._telemetryTimeout),o(this,qe).set(s,i);return}e.type||(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),w(this,wr,!1)}disable(){this.div&&(this.div.tabIndex=-1),w(this,wr,!0)}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){const s=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),s.before(t)}return t}resetAnnotationElement(e){const{firstChild:t}=e.container;t.nodeName==="DIV"&&t.classList.contains("annotationContent")&&t.remove()}};fn=new WeakMap,as=new WeakMap,pe=new WeakMap,wr=new WeakMap,pn=new WeakMap,ae=new WeakMap,gn=new WeakMap,Er=new WeakMap,Sr=new WeakMap,ge=new WeakMap,ho=new WeakMap,mn=new WeakMap,Ri=new WeakMap,lo=new WeakMap,bn=new WeakMap,Qs=new WeakMap,Es=new WeakMap,xr=new WeakMap,Cr=new WeakMap,qe=new WeakMap,co=new WeakMap,_l=new WeakMap,mt=new WeakSet,uc=function([e,t],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/e,this.y+=i/t,this.fixAndSetPosition()},uo=new WeakSet,fc=function(e,t,s){switch(s){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}},pc=function(e){switch(e){case 90:{const[t,s]=this.pageDimensions;return[0,-t/s,s/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,s]=this.pageDimensions;return[0,t/s,-s/t,0]}default:return[1,0,0,1]}},Ru=function(){if(o(this,ae))return;w(this,ae,document.createElement("div")),o(this,ae).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const s of e){const i=document.createElement("div");o(this,ae).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",E(this,mt,Pu).bind(this,s),{signal:t}),i.addEventListener("contextmenu",Re,{signal:t}),i.tabIndex=-1}this.div.prepend(o(this,ae))},Pu=function(e,t){var m;t.preventDefault();const{isMac:s}=ke.platform;if(t.button!==0||t.ctrlKey&&s)return;(m=o(this,pe))==null||m.toggle(!1);const i=E(this,mt,mc).bind(this,e),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",Re,{signal:r});const h=this.x,l=this.y,c=this.width,d=this.height,p=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const g=()=>{var v;this.parent.togglePointerEvents(!0),(v=o(this,pe))==null||v.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",Re),this.parent.div.style.cursor=p,this.div.style.cursor=f,E(this,mt,gc).call(this,h,l,c,d)};window.addEventListener("pointerup",g,{signal:r}),window.addEventListener("blur",g,{signal:r})},gc=function(e,t,s,i){const n=this.x,r=this.y,a=this.width,h=this.height;n===e&&r===t&&a===s&&h===i||this.addCommands({cmd:()=>{this.width=a,this.height=h,this.x=n,this.y=r;const[l,c]=this.parentDimensions;this.setDims(l*a,c*h),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=e,this.y=t;const[l,c]=this.parentDimensions;this.setDims(l*s,c*i),this.fixAndSetPosition()},mustExec:!0})},mc=function(e,t){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,h=this.height,l=It.MIN_SIZE/s,c=It.MIN_SIZE/i,d=U=>Math.round(U*1e4)/1e4,p=E(this,mt,pc).call(this,this.rotation),f=(U,Q)=>[p[0]*U+p[2]*Q,p[1]*U+p[3]*Q],g=E(this,mt,pc).call(this,360-this.rotation),m=(U,Q)=>[g[0]*U+g[2]*Q,g[1]*U+g[3]*Q];let v,b,A=!1,x=!1;switch(e){case"topLeft":A=!0,v=(U,Q)=>[0,0],b=(U,Q)=>[U,Q];break;case"topMiddle":v=(U,Q)=>[U/2,0],b=(U,Q)=>[U/2,Q];break;case"topRight":A=!0,v=(U,Q)=>[U,0],b=(U,Q)=>[0,Q];break;case"middleRight":x=!0,v=(U,Q)=>[U,Q/2],b=(U,Q)=>[0,Q/2];break;case"bottomRight":A=!0,v=(U,Q)=>[U,Q],b=(U,Q)=>[0,0];break;case"bottomMiddle":v=(U,Q)=>[U/2,Q],b=(U,Q)=>[U/2,0];break;case"bottomLeft":A=!0,v=(U,Q)=>[0,Q],b=(U,Q)=>[U,0];break;case"middleLeft":x=!0,v=(U,Q)=>[0,Q/2],b=(U,Q)=>[U,Q/2];break}const k=v(a,h),T=b(a,h);let L=f(...T);const I=d(n+L[0]),B=d(r+L[1]);let D=1,W=1,[q,P]=this.screenToPageTranslation(t.movementX,t.movementY);if([q,P]=m(q/s,P/i),A){const U=Math.hypot(a,h);D=W=Math.max(Math.min(Math.hypot(T[0]-k[0]-q,T[1]-k[1]-P)/U,1/a,1/h),l/a,c/h)}else x?D=Math.max(l,Math.min(1,Math.abs(T[0]-k[0]-q)))/a:W=Math.max(c,Math.min(1,Math.abs(T[1]-k[1]-P)))/h;const z=d(a*D),y=d(h*W);L=f(...b(z,y));const H=I-L[0],rt=B-L[1];this.width=z,this.height=y,this.x=H,this.y=rt,this.setDims(s*z,i*y),this.fixAndSetPosition()},bc=function(e){const{isMac:t}=ke.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)},Lu=function(e){const t=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let s,i;const n=this._uiManager._signal;t&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},w(this,xr,e.clientX),w(this,Cr,e.clientY),i=a=>{const{clientX:h,clientY:l}=a,[c,d]=this.screenToPageTranslation(h-o(this,xr),l-o(this,Cr));w(this,xr,h),w(this,Cr,l),this._uiManager.dragSelectedEditors(c,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),t&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),w(this,mn,!1),this._uiManager.endDragSession()||E(this,mt,bc).call(this,e)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})},Iu=function(e){It._resizerKeyboardManager.exec(this,e)},Mu=function(e){var t;o(this,Qs)&&((t=e.relatedTarget)==null?void 0:t.parentNode)!==o(this,ae)&&E(this,mt,Sa).call(this)},Fu=function(e){w(this,ho,o(this,Qs)?e:"")},_c=function(e){if(o(this,as))for(const t of o(this,as))t.tabIndex=e},Sa=function(){if(w(this,Qs,!1),E(this,mt,_c).call(this,-1),o(this,gn)){const{savedX:e,savedY:t,savedWidth:s,savedHeight:i}=o(this,gn);E(this,mt,gc).call(this,e,t,s,i),w(this,gn,null)}},S(It,uo),ft(It,"_borderLineWidth",-1),ft(It,"_colorManager",new rc),ft(It,"_zIndex",1),ft(It,"_telemetryTimeout",1e3);let kt=It;class ig extends kt{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const Od=3285377520,$e=4294901760,ms=65535;class Du{constructor(e){this.h1=e?e&4294967295:Od,this.h2=e?e&4294967295:Od}update(e){let t,s;if(typeof e=="string"){t=new Uint8Array(e.length*2),s=0;for(let m=0,v=e.length;m>>8,t[s++]=b&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),s=t.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(t.buffer,0,i);let a=0,h=0,l=this.h1,c=this.h2;const d=3432918353,p=461845907,f=d&ms,g=p&ms;for(let m=0;m>>17,a=a*p&$e|a*g&ms,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(h=r[m],h=h*d&$e|h*f&ms,h=h<<15|h>>>17,h=h*p&$e|h*g&ms,c^=h,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=t[i*4+2]<<16;case 2:a^=t[i*4+1]<<8;case 1:a^=t[i*4],a=a*d&$e|a*f&ms,a=a<<15|a>>>17,a=a*p&$e|a*g&ms,i&1?l^=a:c^=a}this.h1=l,this.h2=c}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&$e|e*36045&ms,t=t*4283543511&$e|((t<<16|e>>>16)*2950163797&$e)>>>16,e^=t>>>1,e=e*444984403&$e|e*60499&ms,t=t*3301882366&$e|((t<<16|e>>>16)*3120437893&$e)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const vc=Object.freeze({map:null,hash:"",transfer:void 0});var _n,oe,vl,Ou;class bd{constructor(){S(this,vl);S(this,_n,!1);S(this,oe,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const s=o(this,oe).get(e);return s===void 0?t:Object.assign(t,s)}getRawValue(e){return o(this,oe).get(e)}remove(e){if(o(this,oe).delete(e),o(this,oe).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const t of o(this,oe).values())if(t instanceof kt)return;this.onAnnotationEditor(null)}}setValue(e,t){const s=o(this,oe).get(e);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(t))s[n]!==r&&(i=!0,s[n]=r);else i=!0,o(this,oe).set(e,t);i&&E(this,vl,Ou).call(this),t instanceof kt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(t.constructor._type)}has(e){return o(this,oe).has(e)}getAll(){return o(this,oe).size>0?cd(o(this,oe)):null}setAll(e){for(const[t,s]of Object.entries(e))this.setValue(t,s)}get size(){return o(this,oe).size}resetModified(){o(this,_n)&&(w(this,_n,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Nu(this)}get serializable(){if(o(this,oe).size===0)return vc;const e=new Map,t=new Du,s=[],i=Object.create(null);let n=!1;for(const[r,a]of o(this,oe)){const h=a instanceof kt?a.serialize(!1,i):a;h&&(e.set(r,h),t.update(`${r}:${JSON.stringify(h)}`),n||(n=!!h.bitmap))}if(n)for(const r of e.values())r.bitmap&&s.push(r.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:s}:vc}get editorStats(){let e=null;const t=new Map;for(const s of o(this,oe).values()){if(!(s instanceof kt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;t.has(n)||t.set(n,Object.getPrototypeOf(s).constructor),e||(e=Object.create(null));const r=e[n]||(e[n]=new Map);for(const[a,h]of Object.entries(i)){if(a==="type")continue;let l=r.get(a);l||(l=new Map,r.set(a,l));const c=l.get(h)??0;l.set(h,c+1)}}for(const[s,i]of t)e[s]=i.computeTelemetryFinalData(e[s]);return e}}_n=new WeakMap,oe=new WeakMap,vl=new WeakSet,Ou=function(){o(this,_n)||(w(this,_n,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var fo;class Nu extends bd{constructor(t){super();S(this,fo);const{map:s,hash:i,transfer:n}=t.serializable,r=structuredClone(s,n?{transfer:n}:null);w(this,fo,{map:r,hash:i,transfer:n})}get print(){Rt("Should not call PrintAnnotationStorage.print")}get serializable(){return o(this,fo)}}fo=new WeakMap;var kr;class ng{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){S(this,kr,new Set);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 t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),o(this,kr).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||o(this,kr).has(e.loadedName))){if(Qt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=e,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),o(this,kr).add(s),t==null||t(e)}catch{gt(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}Rt("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 gt(`Failed to load font '${s.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){var t;const e=!!((t=this._document)!=null&&t.fonts);return Et(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;return(me||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Et(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){function t(){for(Qt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:t,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 Et(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function s(k,T){return k.charCodeAt(T)<<24|k.charCodeAt(T+1)<<16|k.charCodeAt(T+2)<<8|k.charCodeAt(T+3)&255}function i(k,T,L,I){const B=k.substring(0,T),D=k.substring(T+L);return B+I+D}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const h=a.getContext("2d");let l=0;function c(k,T){if(++l>30){gt("Load test font never loaded."),T();return}if(h.font="30px "+k,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){T();return}setTimeout(c.bind(null,k,T))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let p=this._loadTestFont;p=i(p,976,d.length,d);const g=16,m=1482184792;let v=s(p,g);for(n=0,r=d.length-3;n{x.remove(),t.complete()})}}kr=new WeakMap;class rg{constructor(e,{disableFontFace:t=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in e)this[i]=e[i];this.disableFontFace=t===!0,this._inspectFont=s}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(t=this._inspectFont)==null||t.call(this,this),e}createFontFaceRule(){var i;if(!this.data||this.disableFontFace)return null;const e=nu(this.data),t=`url(data:${this.mimetype};base64,${btoa(e)});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return(i=this._inspectFont)==null||i.call(this,this,t),s}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let s;try{s=e.get(this.loadedName+"_path_"+t)}catch(n){gt(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[t]=function(n,r){};const i=[];for(let n=0,r=s.length;nf.bezierCurveTo(a,h,l,c,d,p)),n+=6}break;case Bs.MOVE_TO:{const[a,h]=s.slice(n,n+2);i.push(l=>l.moveTo(a,h)),n+=2}break;case Bs.LINE_TO:{const[a,h]=s.slice(n,n+2);i.push(l=>l.lineTo(a,h)),n+=2}break;case Bs.QUADRATIC_CURVE_TO:{const[a,h,l,c]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,h,l,c)),n+=4}break;case Bs.RESTORE:i.push(a=>a.restore());break;case Bs.SAVE:i.push(a=>a.save());break;case Bs.SCALE:Qt(i.length===2,"Scale command is only valid at the third position.");break;case Bs.TRANSFORM:{const[a,h,l,c,d,p]=s.slice(n,n+6);i.push(f=>f.transform(a,h,l,c,d,p)),n+=6}break;case Bs.TRANSLATE:{const[a,h]=s.slice(n,n+2);i.push(l=>l.translate(a,h)),n+=2}break}return this.compiledGlyphs[t]=function(r,a){i[0](r),i[1](r),r.scale(a,-a);for(let h=2,l=i.length;h{const e=await Sh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),t=await Sh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await Sh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await Sh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let n,r;return new Map(Object.entries({fs:e,http:t,https:s,url:i,canvas:n,path2d:r}))})().then(e=>{Da=e,yc.resolve()},e=>{gt(`loadPackages: ${e}`),Da=new Map,yc.resolve()})}class Os{static get promise(){return yc.promise}static get(e){return Da==null?void 0:Da.get(e)}}const Bu=function(u){return Os.get("fs").promises.readFile(u).then(t=>new Uint8Array(t))};class ag extends Fl{}class og extends il{_createCanvas(e,t){return Os.get("canvas").createCanvas(e,t)}}class hg extends Dl{_fetchData(e,t){return Bu(e).then(s=>({cMapData:s,compressionType:t}))}}class lg extends Ol{_fetchData(e){return Bu(e)}}const ye={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Ac(u,e){if(!e)return;const t=e[2]-e[0],s=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],t,s),u.clip(i)}class vh{constructor(){this.constructor===vh&&Rt("Cannot initialize BaseShadingPattern.")}getPattern(){Rt("Abstract method `getPattern` called.")}}class cg extends vh{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type==="axial"?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)t.addColorStop(s[0],s[1]);return t}getPattern(e,t,s,i){let n;if(i===ye.STROKE||i===ye.FILL){const r=t.current.getClippedPathBoundingBox(i,Bt(e))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,l=t.cachedCanvases.getCanvas("pattern",a,h,!0),c=l.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=at.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...t.baseTransform),this.matrix&&c.transform(...this.matrix),Ac(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=e.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else Ac(e,this._bbox),n=this._createGradient(e);return n}}function $l(u,e,t,s,i,n,r,a){const h=e.coords,l=e.colors,c=u.data,d=u.width*4;let p;h[t+1]>h[s+1]&&(p=t,t=s,s=p,p=n,n=r,r=p),h[s+1]>h[i+1]&&(p=s,s=i,i=p,p=r,r=a,a=p),h[t+1]>h[s+1]&&(p=t,t=s,s=p,p=n,n=r,r=p);const f=(h[t]+e.offsetX)*e.scaleX,g=(h[t+1]+e.offsetY)*e.scaleY,m=(h[s]+e.offsetX)*e.scaleX,v=(h[s+1]+e.offsetY)*e.scaleY,b=(h[i]+e.offsetX)*e.scaleX,A=(h[i+1]+e.offsetY)*e.scaleY;if(g>=A)return;const x=l[n],k=l[n+1],T=l[n+2],L=l[r],I=l[r+1],B=l[r+2],D=l[a],W=l[a+1],q=l[a+2],P=Math.round(g),z=Math.round(A);let y,H,rt,U,Q,X,ht,M;for(let O=P;O<=z;O++){if(OA?pt=1:v===A?pt=0:pt=(v-O)/(v-A),y=m-(m-b)*pt,H=L-(L-D)*pt,rt=I-(I-W)*pt,U=B-(B-q)*pt}let st;OA?st=1:st=(g-O)/(g-A),Q=f-(f-b)*st,X=x-(x-D)*st,ht=k-(k-W)*st,M=T-(T-q)*st;const J=Math.round(Math.min(y,Q)),Y=Math.round(Math.max(y,Q));let _t=d*O+J*4;for(let pt=J;pt<=Y;pt++)st=(y-pt)/(y-Q),st<0?st=0:st>1&&(st=1),c[_t++]=H-(H-X)*st|0,c[_t++]=rt-(rt-ht)*st|0,c[_t++]=U-(U-M)*st|0,c[_t++]=255}}function dg(u,e,t){const s=e.coords,i=e.colors;let n,r;switch(e.type){case"lattice":const a=e.verticesPerRow,h=Math.floor(s.length/a)-1,l=a-1;for(n=0;n=i?n=i:s=n/e,{scale:s,size:n}}clipBbox(e,t,s,i,n){const r=i-t,a=n-s;e.ctx.rect(t,s,r,a),e.current.updateRectMinMax(Bt(e.ctx),[t,s,i,n]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,s){const i=e.ctx,n=e.current;switch(t){case Nd.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case Nd.UNCOLORED:const a=at.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new Hp(`Unsupported paint type: ${t}`)}}getPattern(e,t,s,i){let n=s;i!==ye.SHADING&&(n=at.transform(n,t.baseTransform),this.matrix&&(n=at.transform(n,this.matrix)));const r=this.createPatternCanvas(t);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const h=e.createPattern(r.canvas,"repeat");return h.setTransform(a),h}};ft(yl,"MAX_PATTERN_SIZE",3e3);let wc=yl;function gg({src:u,srcPos:e=0,dest:t,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=ke.isLittleEndian?4278190080:255,[h,l]=r?[n,a]:[a,n],c=s>>3,d=s&7,p=u.length;t=new Uint32Array(t.buffer);let f=0;for(let g=0;g{u.save=u.__originalSave,u.restore=u.__originalRestore,u.rotate=u.__originalRotate,u.scale=u.__originalScale,u.translate=u.__originalTranslate,u.transform=u.__originalTransform,u.setTransform=u.__originalSetTransform,u.resetTransform=u.__originalResetTransform,u.clip=u.__originalClip,u.moveTo=u.__originalMoveTo,u.lineTo=u.__originalLineTo,u.bezierCurveTo=u.__originalBezierCurveTo,u.rect=u.__originalRect,u.closePath=u.__originalClosePath,u.beginPath=u.__originalBeginPath,delete u._removeMirroring},u.save=function(){e.save(),this.__originalSave()},u.restore=function(){e.restore(),this.__originalRestore()},u.translate=function(s,i){e.translate(s,i),this.__originalTranslate(s,i)},u.scale=function(s,i){e.scale(s,i),this.__originalScale(s,i)},u.transform=function(s,i,n,r,a,h){e.transform(s,i,n,r,a,h),this.__originalTransform(s,i,n,r,a,h)},u.setTransform=function(s,i,n,r,a,h){e.setTransform(s,i,n,r,a,h),this.__originalSetTransform(s,i,n,r,a,h)},u.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},u.rotate=function(s){e.rotate(s),this.__originalRotate(s)},u.clip=function(s){e.clip(s),this.__originalClip(s)},u.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},u.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},u.bezierCurveTo=function(t,s,i,n,r,a){e.bezierCurveTo(t,s,i,n,r,a),this.__originalBezierCurveTo(t,s,i,n,r,a)},u.rect=function(t,s,i,n){e.rect(t,s,i,n),this.__originalRect(t,s,i,n)},u.closePath=function(){e.closePath(),this.__originalClosePath()},u.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class _g{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,s){let i;return this.cache[e]!==void 0?(i=this.cache[e],this.canvasFactory.reset(i,t,s)):(i=this.canvasFactory.create(t,s),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function Ch(u,e,t,s,i,n,r,a,h,l){const[c,d,p,f,g,m]=Bt(u);if(d===0&&p===0){const A=r*c+g,x=Math.round(A),k=a*f+m,T=Math.round(k),L=(r+h)*c+g,I=Math.abs(Math.round(L)-x)||1,B=(a+l)*f+m,D=Math.abs(Math.round(B)-T)||1;return u.setTransform(Math.sign(c),0,0,Math.sign(f),x,T),u.drawImage(e,t,s,i,n,0,0,I,D),u.setTransform(c,d,p,f,g,m),[I,D]}if(c===0&&f===0){const A=a*p+g,x=Math.round(A),k=r*d+m,T=Math.round(k),L=(a+l)*p+g,I=Math.abs(Math.round(L)-x)||1,B=(r+h)*d+m,D=Math.abs(Math.round(B)-T)||1;return u.setTransform(0,Math.sign(d),Math.sign(p),0,x,T),u.drawImage(e,t,s,i,n,0,0,D,I),u.setTransform(c,d,p,f,g,m),[D,I]}u.drawImage(e,t,s,i,n,r,a,h,l);const v=Math.hypot(c,d),b=Math.hypot(p,f);return[v*h,b*l]}function vg(u){const{width:e,height:t}=u;if(e>Ud||t>Ud)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let r=new Uint8Array(n*(t+1)),a,h,l;const c=e+7&-8;let d=new Uint8Array(c*t),p=0;for(const b of u.data){let A=128;for(;A>0;)d[p++]=b&A?0:255,A>>=1}let f=0;for(p=0,d[p]!==0&&(r[0]=1,++f),h=1;h>2)+(d[p+1]?4:0)+(d[p-c+1]?8:0),i[b]&&(r[l+h]=i[b],++f),p++;if(d[p-c]!==d[p]&&(r[l+h]=d[p]?2:4,++f),f>s)return null}for(p=c*(t-1),l=a*n,d[p]!==0&&(r[l]=8,++f),h=1;hs)return null;const g=new Int32Array([0,n,-1,0,-n,0,0,0,1]),m=new Path2D;for(a=0;f&&a<=t;a++){let b=a*n;const A=b+e;for(;b>4,r[b]&=k>>2|k<<2),m.lineTo(b%n,b/n|0),r[b]||--f}while(x!==b);--a}return d=null,r=null,function(b){b.save(),b.scale(1/e,-1/t),b.translate(0,-t),b.fill(m),b.beginPath(),b.restore()}}class jd{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=su,this.textMatrixScale=1,this.fontMatrix=Xl,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=de.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,s){[t,s]=at.applyTransform([t,s],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(e,t){const s=at.applyTransform(t,e),i=at.applyTransform(t.slice(2),e),n=at.applyTransform([t[0],t[3]],e),r=at.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(e,t){at.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,s,i,n,r,a,h,l,c){const d=at.bezierBoundingBox(t,s,i,n,r,a,h,l,c);c||this.updateRectMinMax(e,d)}getPathBoundingBox(e=ye.FILL,t=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(e===ye.STROKE){t||Rt("Stroke bounding box must include transform.");const i=at.singularValueDecompose2dScale(t),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const e=at.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=ye.FILL,t=null){return at.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function Wd(u,e){if(typeof ImageData<"u"&&e instanceof ImageData){u.putImageData(e,0,0);return}const t=e.height,s=e.width,i=t%Ce,n=(t-i)/Ce,r=i===0?n:n+1,a=u.createImageData(s,Ce);let h=0,l;const c=e.data,d=a.data;let p,f,g,m;if(e.kind===Lh.GRAYSCALE_1BPP){const v=c.byteLength,b=new Uint32Array(d.buffer,0,d.byteLength>>2),A=b.length,x=s+7>>3,k=4294967295,T=ke.isLittleEndian?4278190080:255;for(p=0;px?s:L*8-7,D=B&-8;let W=0,q=0;for(;I>=1}for(;l=n&&(g=i,m=s*g),l=0,f=m;f--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;u.putImageData(a,0,p*Ce)}else throw new Error(`bad image kind: ${e.kind}`)}function Gd(u,e){if(e.bitmap){u.drawImage(e.bitmap,0,0);return}const t=e.height,s=e.width,i=t%Ce,n=(t-i)/Ce,r=i===0?n:n+1,a=u.createImageData(s,Ce);let h=0;const l=e.data,c=a.data;for(let d=0;dHd&&typeof s=="function",c=l?Date.now()+mg:0;let d=0;const p=this.commonObjs,f=this.objs;let g;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(g=r[a],g!==es.dependency)this[g].apply(this,n[a]);else for(const m of n[a]){const v=m.startsWith("g_")?p:f;if(!v.has(m))return v.get(m,s),a}if(a++,a===h)return a;if(l&&++d>Hd){if(Date.now()>c)return s(),a;d=0}}}endDrawing(){E(this,Xi,Ec).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),E(this,Xi,Sc).call(this)}_scaleImage(e,t){const s=e.width,i=e.height;let n=Math.max(Math.hypot(t[0],t[1]),1),r=Math.max(Math.hypot(t[2],t[3]),1),a=s,h=i,l="prescale1",c,d;for(;n>2&&a>1||r>2&&h>1;){let p=a,f=h;n>2&&a>1&&(p=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/p),r>2&&h>1&&(f=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,r/=h/f),c=this.cachedCanvases.getCanvas(l,p,f),d=c.context,d.clearRect(0,0,p,f),d.drawImage(e,0,0,a,h,0,0,p,f),e=c.canvas,a=p,h=f,l=l==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:a,paintHeight:h}}_createMaskCanvas(e){const t=this.ctx,{width:s,height:i}=e,n=this.current.fillColor,r=this.current.patternFill,a=Bt(t);let h,l,c,d;if((e.bitmap||e.data)&&e.count>1){const B=e.bitmap||e.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),h=this._cachedBitmapsMap.get(B),h||(h=new Map,this._cachedBitmapsMap.set(B,h));const D=h.get(l);if(D&&!r){const W=Math.round(Math.min(a[0],a[2])+a[4]),q=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:D,offsetX:W,offsetY:q}}c=D}c||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Gd(d.context,e));let p=at.transform(a,[1/s,0,0,-1/i,0,0]);p=at.transform(p,[1,0,0,1,0,-i]);const[f,g,m,v]=at.getAxialAlignedBoundingBox([0,0,s,i],p),b=Math.round(m-f)||1,A=Math.round(v-g)||1,x=this.cachedCanvases.getCanvas("fillCanvas",b,A),k=x.context,T=f,L=g;k.translate(-T,-L),k.transform(...p),c||(c=this._scaleImage(d.canvas,zs(k)),c=c.img,h&&r&&h.set(l,c)),k.imageSmoothingEnabled=$d(Bt(k),e.interpolate),Ch(k,c,0,0,c.width,c.height,0,0,s,i),k.globalCompositeOperation="source-in";const I=at.transform(zs(k),[1,0,0,1,-T,-L]);return k.fillStyle=r?n.getPattern(t,this,I,ye.FILL):n,k.fillRect(0,0,s,i),h&&!r&&(this.cachedCanvases.delete("fillCanvas"),h.set(l,x.canvas)),{canvas:x.canvas,offsetX:Math.round(T),offsetY:Math.round(L)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=yg[e]}setLineJoin(e){this.ctx.lineJoin=Ag[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(e),s.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,s]of e)switch(t){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...Bt(this.suspendedCtx)),ma(this.suspendedCtx,n),bg(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),ma(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,s,i){const n=i[0],r=i[1],a=i[2]-n,h=i[3]-r;a===0||h===0||(this.genericComposeSMask(t.context,s,a,h,t.subtype,t.backdrop,t.transferMap,n,r,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(s.canvas,0,0),e.restore())}genericComposeSMask(e,t,s,i,n,r,a,h,l,c,d){let p=e.canvas,f=h-c,g=l-d;if(r){if(f<0||g<0||f+s>p.width||g+i>p.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),b=v.context;b.drawImage(p,-f,-g),r.some(A=>A!==0)&&(b.globalCompositeOperation="destination-atop",b.fillStyle=at.makeHexColor(...r),b.fillRect(0,0,s,i),b.globalCompositeOperation="source-over"),p=v.canvas,f=g=0}else if(r.some(v=>v!==0)){e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(f,g,s,i),e.clip(v),e.globalCompositeOperation="destination-atop",e.fillStyle=at.makeHexColor(...r),e.fillRect(f,g,s,i),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?t.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(t.filter=this.filterFactory.addLuminosityFilter(a));const m=new Path2D;m.rect(h,l,s,i),t.clip(m),t.globalCompositeOperation="destination-in",t.drawImage(p,f,g,s,i,h,l,s,i),t.restore()}save(){this.inSMaskMode?(ma(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ma(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,s,i,n,r){this.ctx.transform(e,t,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,h,l;const c=Bt(i),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,p=d?s.slice(0):null;for(let f=0,g=0,m=e.length;fzd&&(l=zd),this.current.fontSizeScale=t/l,this.ctx.font=`${h} ${a} ${l}px ${r}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,s,i,n,r){this.current.textMatrix=[e,t,s,i,n,r],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,s,i){const n=this.ctx,r=this.current,a=r.font,h=r.textRenderingMode,l=r.fontSize/r.fontSizeScale,c=h&de.FILL_STROKE_MASK,d=!!(h&de.ADD_TO_PATH_FLAG),p=r.patternFill&&!a.missingFile;let f;(a.disableFontFace||d||p)&&(f=a.getPathGenerator(this.commonObjs,e)),a.disableFontFace||p?(n.save(),n.translate(t,s),n.beginPath(),f(n,l),i&&n.setTransform(...i),(c===de.FILL||c===de.FILL_STROKE)&&n.fill(),(c===de.STROKE||c===de.FILL_STROKE)&&n.stroke(),n.restore()):((c===de.FILL||c===de.FILL_STROKE)&&n.fillText(e,t,s),(c===de.STROKE||c===de.FILL_STROKE)&&n.strokeText(e,t,s)),d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Bt(n),x:t,y:s,fontSize:l,addToPath:f})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i0&&t[i]<255){s=!0;break}return Et(this,"isFontSubpixelAAEnabled",s)}showText(e){const t=this.current,s=t.font;if(s.isType3Font)return this.showType3Text(e);const i=t.fontSize;if(i===0)return;const n=this.ctx,r=t.fontSizeScale,a=t.charSpacing,h=t.wordSpacing,l=t.fontDirection,c=t.textHScale*l,d=e.length,p=s.vertical,f=p?1:-1,g=s.defaultVMetrics,m=i*t.fontMatrix[0],v=t.textRenderingMode===de.FILL&&!s.disableFontFace&&!t.patternFill;n.save(),n.transform(...t.textMatrix),n.translate(t.x,t.y+t.textRise),l>0?n.scale(c,-1):n.scale(c,1);let b;if(t.patternFill){n.save();const L=t.fillColor.getPattern(n,this,zs(n),ye.FILL);b=Bt(n),n.restore(),n.fillStyle=L}let A=t.lineWidth;const x=t.textMatrixScale;if(x===0||A===0){const L=t.textRenderingMode&de.FILL_STROKE_MASK;(L===de.STROKE||L===de.FILL_STROKE)&&(A=this.getSinglePixelWidth())}else A/=x;if(r!==1&&(n.scale(r,r),A/=r),n.lineWidth=A,s.isInvalidPDFjsFont){const L=[];let I=0;for(const B of e)L.push(B.unicode),I+=B.width;n.fillText(L.join(""),0,0),t.x+=I*m*c,n.restore(),this.compose();return}let k=0,T;for(T=0;T0){const H=n.measureText(D).width*1e3/i*r;if(znew wd(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new wc(e,s,this.ctx,n,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,s){const i=at.makeHexColor(e,t,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(e,t,s){const i=at.makeHexColor(e,t,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(e,t=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=pg(this.getObject(e)),this.cachedPatterns.set(e,s)),t&&(s.matrix=t),s}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const s=this._getPattern(e);t.fillStyle=s.getPattern(t,this,zs(t),ye.SHADING);const i=zs(t);if(i){const{width:n,height:r}=t.canvas,[a,h,l,c]=at.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,h,l-a,c-h)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Rt("Should not call beginInlineImage")}beginImageData(){Rt("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Bt(this.ctx),t)){const s=t[2]-t[0],i=t[3]-t[1];this.ctx.rect(t[0],t[1],s,i),this.current.updateRectMinMax(Bt(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||Ll("TODO: Support non-isolated groups."),e.knockout&>("Knockout groups not supported.");const s=Bt(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=at.getAxialAlignedBoundingBox(e.bbox,Bt(t));const n=[0,0,t.canvas.width,t.canvas.height];i=at.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-r,1),l=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,h,l]);let c="groupAt"+this.groupLevel;e.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,h,l),p=d.context;p.translate(-r,-a),p.transform(...s),e.smask?this.smaskStack.push({canvas:d.canvas,context:p,offsetX:r,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(r,a),t.save()),ma(t,p),this.ctx=p,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=Bt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=at.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],i);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,s,i,n){if(E(this,Xi,Ec).call(this),kh(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const r=t[2]-t[0],a=t[3]-t[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=t[0],s[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=r,t[3]=a;const[h,l]=at.singularValueDecompose2dScale(Bt(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),p=Math.ceil(a*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,p);const{canvas:f,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(e,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(h,0,0,-l,0,a*l),kh(this.ctx)}else kh(this.ctx),this.ctx.rect(t[0],t[1],r,a),this.ctx.clip(),this.endPath()}this.current=new jd(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),E(this,Xi,Sc).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;e=this.getObject(e.data,e),e.count=t;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=vg(e)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(e),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,s=0,i=0,n,r){if(!this.contentVisible)return;e=this.getObject(e.data,e);const a=this.ctx;a.save();const h=Bt(a);a.transform(t,s,i,n,0,0);const l=this._createMaskCanvas(e);a.setTransform(1,0,0,1,l.offsetX-h[4],l.offsetY-h[5]);for(let c=0,d=r.length;cd?c/d:1,a=l>d?l/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(t.lineWidth=s||1,i===1&&n===1){t.stroke();return}const r=t.getLineDash();if(e&&t.save(),t.scale(i,n),r.length>0){const a=Math.max(i,n);t.setLineDash(r.map(h=>h/a)),t.lineDashOffset/=a}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Xi=new WeakSet,Ec=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},Sc=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}};let fr=wd;for(const u in es)fr.prototype[u]!==void 0&&(fr.prototype[es[u]]=fr.prototype[u]);var po,go;class gi{static get workerPort(){return o(this,po)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");w(this,po,e)}static get workerSrc(){return o(this,go)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");w(this,go,e)}}po=new WeakMap,go=new WeakMap,S(gi,po,null),S(gi,go,"");const Th={UNKNOWN:0,DATA:1,ERROR:2},Gt={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ie(u){switch(u instanceof Error||typeof u=="object"&&u!==null||Rt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new ir(u.message);case"MissingPDFException":return new sr(u.message);case"PasswordException":return new Kl(u.message,u.code);case"UnexpectedResponseException":return new Il(u.message,u.status);case"UnknownErrorException":return new Zl(u.message,u.details);default:return new Zl(u.message,u.toString())}}var Fs,zu,Hu,Nh;class xa{constructor(e,t,s){S(this,Fs);this.sourceName=e,this.targetName=t,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),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream){E(this,Fs,Hu).call(this,n);return}if(n.callback){const a=n.callbackId,h=this.callbackCapabilities[a];if(!h)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===Th.DATA)h.resolve(n.data);else if(n.callback===Th.ERROR)h.reject(Ie(n.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,h=n.sourceName;new Promise(function(l){l(r(n.data))}).then(function(l){s.postMessage({sourceName:a,targetName:h,callback:Th.DATA,callbackId:n.callbackId,data:l})},function(l){s.postMessage({sourceName:a,targetName:h,callback:Th.ERROR,callbackId:n.callbackId,reason:Ie(l)})});return}if(n.streamId){E(this,Fs,zu).call(this,n);return}r(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(e,t){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=t}send(e,t,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},s)}sendWithPromise(e,t,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(e,t,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,h=this.comObj;return new ReadableStream({start:l=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:a,action:e,streamId:n,data:t,desiredSize:l.desiredSize},i),c.promise},pull:l=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,h.postMessage({sourceName:r,targetName:a,stream:Gt.PULL,streamId:n,desiredSize:l.desiredSize}),c.promise},cancel:l=>{Qt(l instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,h.postMessage({sourceName:r,targetName:a,stream:Gt.CANCEL,streamId:n,reason:Ie(l)}),c.promise}},s)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}Fs=new WeakSet,zu=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,n=this.comObj,r=this,a=this.actionHandler[e.action],h={enqueue(l,c=1,d){if(this.isCancelled)return;const p=this.desiredSize;this.desiredSize-=c,p>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Gt.ENQUEUE,streamId:t,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Gt.CLOSE,streamId:t}),delete r.streamSinks[t])},error(l){Qt(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Gt.ERROR,streamId:t,reason:Ie(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[t]=h,new Promise(function(l){l(a(e.data,h))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Gt.START_COMPLETE,streamId:t,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Gt.START_COMPLETE,streamId:t,reason:Ie(l)})})},Hu=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,n=this.comObj,r=this.streamControllers[t],a=this.streamSinks[t];switch(e.stream){case Gt.START_COMPLETE:e.success?r.startCall.resolve():r.startCall.reject(Ie(e.reason));break;case Gt.PULL_COMPLETE:e.success?r.pullCall.resolve():r.pullCall.reject(Ie(e.reason));break;case Gt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:Gt.PULL_COMPLETE,streamId:t,success:!0});break}a.desiredSize<=0&&e.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=e.desiredSize,new Promise(function(h){var l;h((l=a.onPull)==null?void 0:l.call(a))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Gt.PULL_COMPLETE,streamId:t,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Gt.PULL_COMPLETE,streamId:t,reason:Ie(h)})});break;case Gt.ENQUEUE:if(Qt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(e.chunk);break;case Gt.CLOSE:if(Qt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),E(this,Fs,Nh).call(this,r,t);break;case Gt.ERROR:Qt(r,"error should have stream controller"),r.controller.error(Ie(e.reason)),E(this,Fs,Nh).call(this,r,t);break;case Gt.CANCEL_COMPLETE:e.success?r.cancelCall.resolve():r.cancelCall.reject(Ie(e.reason)),E(this,Fs,Nh).call(this,r,t);break;case Gt.CANCEL:if(!a)break;new Promise(function(h){var l;h((l=a.onCancel)==null?void 0:l.call(a,Ie(e.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Gt.CANCEL_COMPLETE,streamId:t,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Gt.CANCEL_COMPLETE,streamId:t,reason:Ie(h)})}),a.sinkCapability.reject(Ie(e.reason)),a.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},Nh=async function(e,t){var s,i,n;await Promise.allSettled([(s=e.startCall)==null?void 0:s.promise,(i=e.pullCall)==null?void 0:i.promise,(n=e.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[t]};var vn,mo;class Eg{constructor({parsedData:e,rawData:t}){S(this,vn);S(this,mo);w(this,vn,e),w(this,mo,t)}getRaw(){return o(this,mo)}get(e){return o(this,vn).get(e)??null}getAll(){return cd(o(this,vn))}has(e){return o(this,vn).has(e)}}vn=new WeakMap,mo=new WeakMap;const wi=Symbol("INTERNAL");var bo,_o,vo,Tr;class Sg{constructor(e,{name:t,intent:s,usage:i}){S(this,bo,!1);S(this,_o,!1);S(this,vo,!1);S(this,Tr,!0);w(this,bo,!!(e&Ke.DISPLAY)),w(this,_o,!!(e&Ke.PRINT)),this.name=t,this.intent=s,this.usage=i}get visible(){if(o(this,vo))return o(this,Tr);if(!o(this,Tr))return!1;const{print:e,view:t}=this.usage;return o(this,bo)?(t==null?void 0:t.viewState)!=="OFF":o(this,_o)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,t,s=!1){e!==wi&&Rt("Internal method `_setVisible` called."),w(this,vo,s),w(this,Tr,t)}}bo=new WeakMap,_o=new WeakMap,vo=new WeakMap,Tr=new WeakMap;var Pi,Tt,Rr,Pr,yo,xc;class xg{constructor(e,t=Ke.DISPLAY){S(this,yo);S(this,Pi,null);S(this,Tt,new Map);S(this,Rr,null);S(this,Pr,null);if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,w(this,Pr,e.order);for(const s of e.groups)o(this,Tt).set(s.id,new Sg(t,s));if(e.baseState==="OFF")for(const s of o(this,Tt).values())s._setVisible(wi,!1);for(const s of e.on)o(this,Tt).get(s)._setVisible(wi,!0);for(const s of e.off)o(this,Tt).get(s)._setVisible(wi,!1);w(this,Rr,this.getHash())}}isVisible(e){if(o(this,Tt).size===0)return!0;if(!e)return Ll("Optional content group not defined."),!0;if(e.type==="OCG")return o(this,Tt).has(e.id)?o(this,Tt).get(e.id).visible:(gt(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return E(this,yo,xc).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const t of e.ids){if(!o(this,Tt).has(t))return gt(`Optional content group not found: ${t}`),!0;if(o(this,Tt).get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const t of e.ids){if(!o(this,Tt).has(t))return gt(`Optional content group not found: ${t}`),!0;if(!o(this,Tt).get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const t of e.ids){if(!o(this,Tt).has(t))return gt(`Optional content group not found: ${t}`),!0;if(!o(this,Tt).get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const t of e.ids){if(!o(this,Tt).has(t))return gt(`Optional content group not found: ${t}`),!0;if(o(this,Tt).get(t).visible)return!1}return!0}return gt(`Unknown optional content policy ${e.policy}.`),!0}return gt(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0){const s=o(this,Tt).get(e);if(!s){gt(`Optional content group not found: ${e}`);return}s._setVisible(wi,!!t,!0),w(this,Pi,null)}setOCGState({state:e,preserveRB:t}){let s;for(const i of e){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=o(this,Tt).get(i);if(n)switch(s){case"ON":n._setVisible(wi,!0);break;case"OFF":n._setVisible(wi,!1);break;case"Toggle":n._setVisible(wi,!n.visible);break}}w(this,Pi,null)}get hasInitialVisibility(){return o(this,Rr)===null||this.getHash()===o(this,Rr)}getOrder(){return o(this,Tt).size?o(this,Pr)?o(this,Pr).slice():[...o(this,Tt).keys()]:null}getGroups(){return o(this,Tt).size>0?cd(o(this,Tt)):null}getGroup(e){return o(this,Tt).get(e)||null}getHash(){if(o(this,Pi)!==null)return o(this,Pi);const e=new Du;for(const[t,s]of o(this,Tt))e.update(`${t}:${s.visible}`);return w(this,Pi,e.hexdigest())}}Pi=new WeakMap,Tt=new WeakMap,Rr=new WeakMap,Pr=new WeakMap,yo=new WeakSet,xc=function(e){const t=e.length;if(t<2)return!0;const s=e[0];for(let i=1;i0){const h=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(h)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!s,this._isRangeSupported=!t,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((h,l)=>{this._onReceiveData({begin:h,chunk:l})}),e.addProgressListener((h,l)=>{this._onProgress({loaded:h,total:l})}),e.addProgressiveReadListener(h=>{this._onReceiveData({chunk:h})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const s=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==e?!1:(n._enqueue(s),!0)});Qt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var t,s,i,n;e.total===void 0?(s=(t=this._rangeReaders[0])==null?void 0:t.onProgress)==null||s.call(t,{loaded:e.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.call(i,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){Qt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new kg(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=new Tg(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeReaders.slice(0))s.cancel(e);this._pdfDataRangeTransport.abort()}}class kg{constructor(e,t,s=!1,i=null){this._stream=e,this._done=s||!1,this._filename=gd(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Tg{constructor(e,t,s){this._stream=e,this._begin=t,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Rg(u){let e=!0,t=s("filename\\*","i").exec(u);if(t){t=t[1];let c=a(t);return c=unescape(c),c=h(c),c=l(c),n(c)}if(t=r(u),t){const c=l(t);return n(c)}if(t=s("filename","i").exec(u),t){t=t[1];let c=a(t);return c=l(c),n(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const p=new TextDecoder(c,{fatal:!0}),f=Ml(d);d=p.decode(f),e=!1}catch{}}return d}function n(c){return e&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),e&&(c=i("iso-8859-1",c))),c}function r(c){const d=[];let p;const f=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(p=f.exec(c))!==null;){let[,m,v,b]=p;if(m=parseInt(m,10),m in d){if(m===0)break;continue}d[m]=[v,b]}const g=[];for(let m=0;m{if(!Uu(i.status))throw Bl(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=h=>i.headers.get(h),{allowRangeRequests:r,suggestedLength:a}=_d({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=vd(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ir("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:Gu(e),done:!1})}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}}class Lg{constructor(e,t,s){this._stream=e,this._reader=null,this._loaded=0;const i=e.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Wu(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${s-1}`);const n=i.url;fetch(n,ju(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Uu(r.status))throw Bl(r.status,n);this._readCapability.resolve(),this._reader=r.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:Gu(e),done:!1})}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}}const Vl=200,ql=206;function Ig(u){const e=u.response;return typeof e!="string"?e:Ml(e).buffer}class Mg{constructor(e,t={}){this.url=e,this.isHttp=/^https?:/i.test(e),this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null),this.withCredentials=t.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,s){const i={begin:e,end:t};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(e){return this.request(e)}request(e){const t=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const r=this.httpHeaders[n];r!==void 0&&t.setRequestHeader(n,r)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=ql):i.expectedStatus=Vl,t.responseType="arraybuffer",e.onError&&(t.onerror=function(n){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,s),t.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),s}onProgress(e,t){var i;const s=this.pendingRequests[e];s&&((i=s.onProgress)==null||i.call(s,t))}onStateChange(e,t){var h,l,c;const s=this.pendingRequests[e];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],i.status===0&&this.isHttp){(h=s.onError)==null||h.call(s,i.status);return}const n=i.status||Vl;if(!(n===Vl&&s.expectedStatus===ql)&&n!==s.expectedStatus){(l=s.onError)==null||l.call(s,i.status);return}const a=Ig(i);if(n===ql){const d=i.getResponseHeader("Content-Range"),p=/bytes (\d+)-(\d+)\/(\d+)/.exec(d);s.onDone({begin:parseInt(p[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):(c=s.onError)==null||c.call(s,i.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class Fg{constructor(e){this._source=e,this._manager=new Mg(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return Qt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Dg(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const s=new Og(this._manager,e,t);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class Dg{constructor(e,t){this._manager=e;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(s),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e),s=r=>t.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=_d({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=vd(s),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=Bl(e,this._url),this._headersReceivedCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var t;(t=this.onProgress)==null||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersReceivedCapability.reject(e);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Og{constructor(e,t,s){this._manager=e;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError=Bl(e,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var t;this.isStreamingSupported||(t=this.onProgress)==null||t.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const $u=/^file:\/\/\/[a-zA-Z]:\//;function Ng(u){const e=Os.get("url"),t=e.parse(u);return t.protocol==="file:"||t.host?t:/^[a-z]:[/\\]/i.test(u)?e.parse(`file:///${u}`):(t.host||(t.protocol="file:"),t)}class Bg{constructor(e){this.source=e,this.url=Ng(e.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return Qt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Ug(this):new zg(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=this.isFsUrl?new jg(this,e,t):new Hg(this,e,t);return this._rangeRequestReaders.push(s),s}cancelAllRequests(e){var t;(t=this._fullRequestReader)==null||t.cancel(e);for(const s of this._rangeRequestReaders.slice(0))s.cancel(e)}}class Vu{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ir("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class qu{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function al(u,e){return{protocol:u.protocol,auth:u.auth,host:u.hostname,port:u.port,path:u.path,method:"GET",headers:e}}class zg extends Vu{constructor(e){super(e);const t=s=>{if(s.statusCode===404){const a=new sr(`Missing PDF "${this._url}".`);this._storedError=a,this._headersCapability.reject(a);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=_d({getResponseHeader:i,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=vd(i)};if(this._request=null,this._url.protocol==="http:"){const s=Os.get("http");this._request=s.request(al(this._url,e.httpHeaders),t)}else{const s=Os.get("https");this._request=s.request(al(this._url,e.httpHeaders),t)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class Hg extends qu{constructor(e,t,s){super(e),this._httpHeaders={};for(const n in e.httpHeaders){const r=e.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${t}-${s-1}`;const i=n=>{if(n.statusCode===404){const r=new sr(`Missing PDF "${this._url}".`);this._storedError=r;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=Os.get("http");this._request=n.request(al(this._url,this._httpHeaders),i)}else{const n=Os.get("https");this._request=n.request(al(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class Ug extends Vu{constructor(e){super(e);let t=decodeURIComponent(this._url.path);$u.test(this._url.href)&&(t=t.replace(/^\//,""));const s=Os.get("fs");s.promises.lstat(t).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(t)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new sr(`Missing PDF "${t}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class jg extends qu{constructor(e,t,s){super(e);let i=decodeURIComponent(this._url.path);$u.test(this._url.href)&&(i=i.replace(/^\//,""));const n=Os.get("fs");this._setReadableStream(n.createReadStream(i,{start:t,end:s-1}))}}const Wg=1e5,Ee=30,Gg=.8;var Zd,Li,xe,Ao,wo,yn,Js,Eo,So,An,Lr,Ir,Ii,Mr,xo,Fr,wn,Co,ko,En,Sn,Mi,Dr,vi,Xu,Yu,Cc,Ds,Bh,Ku,Zu;const fe=class fe{constructor({textContentSource:e,container:t,viewport:s}){S(this,vi);S(this,Li,Promise.withResolvers());S(this,xe,null);S(this,Ao,!1);S(this,wo,!!((Zd=globalThis.FontInspector)!=null&&Zd.enabled));S(this,yn,null);S(this,Js,null);S(this,Eo,0);S(this,So,0);S(this,An,null);S(this,Lr,null);S(this,Ir,0);S(this,Ii,0);S(this,Mr,Object.create(null));S(this,xo,[]);S(this,Fr,null);S(this,wn,[]);S(this,Co,new WeakMap);S(this,ko,null);var h;if(e instanceof ReadableStream)w(this,Fr,e);else if(typeof e=="object")w(this,Fr,new ReadableStream({start(l){l.enqueue(e),l.close()}}));else throw new Error('No "textContentSource" parameter specified.');w(this,xe,w(this,Lr,t)),w(this,Ii,s.scale*(globalThis.devicePixelRatio||1)),w(this,Ir,s.rotation),w(this,Js,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;w(this,ko,[1,0,0,-1,-r,a+n]),w(this,So,i),w(this,Eo,n),E(h=fe,Ds,Ku).call(h),Zn(t,s),o(this,Li).promise.catch(()=>{}).then(()=>{o(fe,Dr).delete(this),w(this,Js,null),w(this,Mr,null)})}render(){const e=()=>{o(this,An).read().then(({value:t,done:s})=>{if(s){o(this,Li).resolve();return}o(this,yn)??w(this,yn,t.lang),Object.assign(o(this,Mr),t.styles),E(this,vi,Xu).call(this,t.items),e()},o(this,Li).reject)};return w(this,An,o(this,Fr).getReader()),o(fe,Dr).add(this),e(),o(this,Li).promise}update({viewport:e,onBefore:t=null}){var n;const s=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==o(this,Ir)&&(t==null||t(),w(this,Ir,i),Zn(o(this,Lr),{rotation:i})),s!==o(this,Ii)){t==null||t(),w(this,Ii,s);const r={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:E(n=fe,Ds,Bh).call(n,o(this,yn))};for(const a of o(this,wn))r.properties=o(this,Co).get(a),r.div=a,E(this,vi,Cc).call(this,r)}}cancel(){var t;const e=new ir("TextLayer task cancelled.");(t=o(this,An))==null||t.cancel(e).catch(()=>{}),w(this,An,null),o(this,Li).reject(e)}get textDivs(){return o(this,wn)}get textContentItemsStr(){return o(this,xo)}static cleanup(){if(!(o(this,Dr).size>0)){o(this,En).clear();for(const{canvas:e}of o(this,Sn).values())e.remove();o(this,Sn).clear()}}};Li=new WeakMap,xe=new WeakMap,Ao=new WeakMap,wo=new WeakMap,yn=new WeakMap,Js=new WeakMap,Eo=new WeakMap,So=new WeakMap,An=new WeakMap,Lr=new WeakMap,Ir=new WeakMap,Ii=new WeakMap,Mr=new WeakMap,xo=new WeakMap,Fr=new WeakMap,wn=new WeakMap,Co=new WeakMap,ko=new WeakMap,En=new WeakMap,Sn=new WeakMap,Mi=new WeakMap,Dr=new WeakMap,vi=new WeakSet,Xu=function(e){var i,n;if(o(this,Ao))return;(n=o(this,Js)).ctx??(n.ctx=E(i=fe,Ds,Bh).call(i,o(this,yn)));const t=o(this,wn),s=o(this,xo);for(const r of e){if(t.length>Wg){gt("Ignoring additional textDivs for performance reasons."),w(this,Ao,!0);return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const a=o(this,xe);w(this,xe,document.createElement("span")),o(this,xe).classList.add("markedContent"),r.id!==null&&o(this,xe).setAttribute("id",`${r.id}`),a.append(o(this,xe))}else r.type==="endMarkedContent"&&w(this,xe,o(this,xe).parentNode);continue}s.push(r.str),E(this,vi,Yu).call(this,r)}},Yu=function(e){var m;const t=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};o(this,wn).push(t);const i=at.transform(o(this,ko),e.transform);let n=Math.atan2(i[1],i[0]);const r=o(this,Mr)[e.fontName];r.vertical&&(n+=Math.PI/2);const a=o(this,wo)&&r.fontSubstitution||r.fontFamily,h=Math.hypot(i[2],i[3]),l=h*E(m=fe,Ds,Zu).call(m,a,o(this,yn));let c,d;n===0?(c=i[4],d=i[5]-l):(c=i[4]+l*Math.sin(n),d=i[5]-l*Math.cos(n));const p="calc(var(--scale-factor)*",f=t.style;o(this,xe)===o(this,Lr)?(f.left=`${(100*c/o(this,So)).toFixed(2)}%`,f.top=`${(100*d/o(this,Eo)).toFixed(2)}%`):(f.left=`${p}${c.toFixed(2)}px)`,f.top=`${p}${d.toFixed(2)}px)`),f.fontSize=`${p}${(o(fe,Mi)*h).toFixed(2)}px)`,f.fontFamily=a,s.fontSize=h,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,o(this,wo)&&(t.dataset.fontName=r.fontSubstitutionLoadedName||e.fontName),n!==0&&(s.angle=n*(180/Math.PI));let g=!1;if(e.str.length>1)g=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const v=Math.abs(e.transform[0]),b=Math.abs(e.transform[3]);v!==b&&Math.max(v,b)/Math.min(v,b)>1.5&&(g=!0)}if(g&&(s.canvasWidth=r.vertical?e.height:e.width),o(this,Co).set(t,s),o(this,Js).div=t,o(this,Js).properties=s,E(this,vi,Cc).call(this,o(this,Js)),s.hasText&&o(this,xe).append(t),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),o(this,xe).append(v)}},Cc=function(e){const{div:t,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=e,{style:a}=t;let h="";if(o(fe,Mi)>1&&(h=`scale(${1/o(fe,Mi)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=a,{canvasWidth:c,fontSize:d}=s;(n!==d||r!==l)&&(i.font=`${d*o(this,Ii)}px ${l}`,e.prevFontSize=d,e.prevFontFamily=l);const{width:p}=i.measureText(t.textContent);p>0&&(h=`scaleX(${c*o(this,Ii)/p}) ${h}`)}s.angle!==0&&(h=`rotate(${s.angle}deg) ${h}`),h.length>0&&(a.transform=h)},Ds=new WeakSet,Bh=function(e=null){let t=o(this,Sn).get(e||(e=""));if(!t){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=e,document.body.append(s),t=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),o(this,Sn).set(e,t)}return t},Ku=function(){if(o(this,Mi)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.textContent="X",document.body.append(e),w(this,Mi,e.getBoundingClientRect().height),e.remove()},Zu=function(e,t){const s=o(this,En).get(e);if(s)return s;const i=E(this,Ds,Bh).call(this,t),n=i.font;i.canvas.width=i.canvas.height=Ee,i.font=`${Ee}px ${e}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+h);return o(this,En).set(e,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,Ee,Ee),i.strokeText("g",0,0);let l=i.getImageData(0,0,Ee,Ee).data;h=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){h=Math.ceil(d/4/Ee);break}i.clearRect(0,0,Ee,Ee),i.strokeText("A",0,Ee),l=i.getImageData(0,0,Ee,Ee).data,a=0;for(let d=0,p=l.length;d0){a=Ee-Math.floor(d/4/Ee);break}i.canvas.width=i.canvas.height=0,i.font=n;const c=a?a/(a+h):Gg;return o(this,En).set(e,c),c},S(fe,Ds),S(fe,En,new Map),S(fe,Sn,new Map),S(fe,Mi,null),S(fe,Dr,new Set);let ca=fe;function $g(){lu("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:u,container:e,viewport:t,...s}=arguments[0],i=Object.keys(s);i.length>0&>("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new ca({textContentSource:u,container:e,viewport:t}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function Vg(){lu("`updateTextLayer`, please use `TextLayer` instead.")}class Na{static textContent(e){const t=[],s={items:t,styles:Object.create(null)};function i(n){var h;if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(Na.shouldBuildText(a))(h=n==null?void 0:n.attributes)!=null&&h.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&t.push({str:r}),!!n.children)for(const l of n.children)i(l)}return i(e),s}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}const qg=65536,Xg=100,Yg=5e3,Kg=me?og:Xp,Zg=me?hg:ou,Qg=me?ag:qp,Jg=me?lg:hu;function tm(u={}){typeof u=="string"||u instanceof URL?u={url:u}:(u instanceof ArrayBuffer||ArrayBuffer.isView(u))&&(u={data:u});const e=new kc,{docId:t}=e,s=u.url?em(u.url):null,i=u.data?sm(u.data):null,n=u.httpHeaders||null,r=u.withCredentials===!0,a=u.password??null,h=u.range instanceof Qu?u.range:null,l=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:qg;let c=u.worker instanceof pr?u.worker:null;const d=u.verbosity,p=typeof u.docBaseUrl=="string"&&!pd(u.docBaseUrl)?u.docBaseUrl:null,f=typeof u.cMapUrl=="string"?u.cMapUrl:null,g=u.cMapPacked!==!1,m=u.CMapReaderFactory||Zg,v=typeof u.standardFontDataUrl=="string"?u.standardFontDataUrl:null,b=u.StandardFontDataFactory||Jg,A=u.stopAtErrors!==!0,x=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,k=u.isEvalSupported!==!1,T=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!me,L=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,I=typeof u.disableFontFace=="boolean"?u.disableFontFace:me,B=u.fontExtraProperties===!0,D=u.enableXfa===!0,W=u.ownerDocument||globalThis.document,q=u.disableRange===!0,P=u.disableStream===!0,z=u.disableAutoFetch===!0,y=u.pdfBug===!0,H=u.enableHWA===!0,rt=h?h.length:u.length??NaN,U=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!me&&!I,Q=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:m===ou&&b===hu&&f&&v&&wa(f,document.baseURI)&&wa(v,document.baseURI),X=u.canvasFactory||new Kg({ownerDocument:W,enableHWA:H}),ht=u.filterFactory||new Qg({docId:t,ownerDocument:W}),M=null;Op(d);const O={canvasFactory:X,filterFactory:ht};if(Q||(O.cMapReaderFactory=new m({baseUrl:f,isCompressed:g}),O.standardFontDataFactory=new b({baseUrl:v})),!c){const Y={verbosity:d,port:gi.workerPort};c=Y.port?pr.fromPort(Y):new pr(Y),e._worker=c}const st={docId:t,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:z,rangeChunkSize:l,length:rt,docBaseUrl:p,enableXfa:D,evaluatorOptions:{maxImageSize:x,disableFontFace:I,ignoreErrors:A,isEvalSupported:k,isOffscreenCanvasSupported:T,canvasMaxAreaInBytes:L,fontExtraProperties:B,useSystemFonts:U,cMapUrl:Q?f:null,standardFontDataUrl:Q?v:null}},J={disableFontFace:I,fontExtraProperties:B,ownerDocument:W,pdfBug:y,styleElement:M,loadingParams:{disableAutoFetch:z,enableXfa:D}};return c.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Y=c.messageHandler.sendWithPromise("GetDocRequest",st,i?[i.buffer]:null);let _t;if(h)_t=new Cg(h,{disableRange:q,disableStream:P});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");_t=(dt=>me?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&wa(dt.url)?new qd(dt):new Bg(dt):wa(dt.url)?new qd(dt):new Fg(dt))({url:s,length:rt,httpHeaders:n,withCredentials:r,rangeChunkSize:l,disableRange:q,disableStream:P})}return Y.then(pt=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const dt=new xa(t,pt,c.port),vt=new am(dt,e,_t,J,O);e._transport=vt,dt.send("Ready",null)})}).catch(e._capability.reject),e}function em(u){if(u instanceof URL)return u.href;try{return new URL(u,window.location).href}catch{if(me&&typeof u=="string")return u}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function sm(u){if(me&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return Ml(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Xd(u){return typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0}var Al;const wl=class wl{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Le(wl,Al)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var e,t,s;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((t=this._transport)==null?void 0:t.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};Al=new WeakMap,S(wl,Al,0);let kc=wl;class Qu{constructor(e,t,s=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const s of this._rangeListeners)s(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Rt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class im{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Et(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Fi,ti,Ze,hr,zh;class nm{constructor(e,t,s,i=!1){S(this,Ze);S(this,Fi,null);S(this,ti,!1);this._pageIndex=e,this._pageInfo=t,this._transport=s,this._stats=i?new Fd:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Ju,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new bh({viewBox:this.view,scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Et(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,viewport:t,intent:s="display",annotationMode:i=Si.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:h=null,pageColors:l=null,printAnnotationStorage:c=null}){var x,k;(x=this._stats)==null||x.time("Overall");const d=this._transport.getRenderingIntent(s,i,c),{renderingIntent:p,cacheKey:f}=d;w(this,ti,!1),E(this,Ze,zh).call(this),a||(a=this._transport.getOptionalContentConfig(p));let g=this._intentStates.get(f);g||(g=Object.create(null),this._intentStates.set(f,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const m=!!(p&Ke.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(k=this._stats)==null||k.time("Page Request"),this._pumpOperatorList(d));const v=T=>{var L;g.renderTasks.delete(b),(this._maybeCleanupAfterRender||m)&&w(this,ti,!0),E(this,Ze,hr).call(this,!m),T?(b.capability.reject(T),this._abortOperatorList({intentState:g,reason:T instanceof Error?T:new Error(T)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(L=globalThis.Stats)!=null&&L.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new Rc({callback:v,params:{canvasContext:e,viewport:t,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!m,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||(g.renderTasks=new Set)).add(b);const A=b.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([T,L])=>{var I;if(this.destroyed){v();return}if((I=this._stats)==null||I.time("Rendering"),!(L.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:T,optionalContentConfig:L}),b.operatorListChanged()}).catch(v),A}getOperatorList({intent:e="display",annotationMode:t=Si.ENABLE,printAnnotationStorage:s=null}={}){var h;function i(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))}const n=this._transport.getRenderingIntent(e,t,s,!0);let r=this._intentStates.get(n.cacheKey);r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r));let a;return r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=i,r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||(r.renderTasks=new Set)).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Na.textContent(s));const t=this.streamTextContent(e);return new Promise(function(s,i){function n(){r.read().then(function({value:h,done:l}){if(l){s(a);return}a.lang??(a.lang=h.lang),Object.assign(a.styles,h.styles),a.items.push(...h.items),n()},i)}const r=t.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const s of t.renderTasks)e.push(s.completed),s.cancel();return this.objs.clear(),w(this,ti,!1),E(this,Ze,zh).call(this),Promise.all(e)}cleanup(e=!1){w(this,ti,!0);const t=E(this,Ze,hr).call(this,!1);return e&&t&&this._stats&&(this._stats=new Fd),t}_startRenderPage(e,t){var i,n;const s=this._intentStates.get(t);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(e))}_renderPageChunk(e,t){for(let s=0,i=e.length;s{a.read().then(({value:c,done:d})=>{if(d){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(c,h),l())},c=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const d of h.renderTasks)d.operatorListChanged();E(this,Ze,hr).call(this,!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(c);else if(h.opListReadCapability)h.opListReadCapability.reject(c);else throw c}})};l()}_abortOperatorList({intentState:e,reason:t,force:s=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!s){if(e.renderTasks.size>0)return;if(t instanceof fd){let i=Xg;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}if(e.streamReader.cancel(new ir(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===e){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}Fi=new WeakMap,ti=new WeakMap,Ze=new WeakSet,hr=function(e=!1){if(E(this,Ze,zh).call(this),!o(this,ti)||this.destroyed)return!1;if(e)return w(this,Fi,setTimeout(()=>{w(this,Fi,null),E(this,Ze,hr).call(this,!1)},Yg)),!1;for(const{renderTasks:t,operatorList:s}of this._intentStates.values())if(t.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),w(this,ti,!1),!0},zh=function(){o(this,Fi)&&(clearTimeout(o(this,Fi)),w(this,Fi,null))};var xn,El;class rm{constructor(){S(this,xn,new Set);S(this,El,Promise.resolve())}postMessage(e,t){const s={data:structuredClone(e,t?{transfer:t}:null)};o(this,El).then(()=>{for(const i of o(this,xn))i.call(this,s)})}addEventListener(e,t){o(this,xn).add(t)}removeEventListener(e,t){o(this,xn).delete(t)}terminate(){o(this,xn).clear()}}xn=new WeakMap,El=new WeakMap;const Gs={isWorkerDisabled:!1,fakeWorkerId:0};me&&(Gs.isWorkerDisabled=!0,gi.workerSrc||(gi.workerSrc="./pdf.worker.mjs")),Gs.isSameOrigin=function(u,e){let t;try{if(t=new URL(u),!t.origin||t.origin==="null")return!1}catch{return!1}const s=new URL(e,t);return t.origin===s.origin},Gs.createCDNWrapper=function(u){const e=`await import("${u}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};var Cn,Or,Hh,Nr,Uh;const Me=class Me{constructor({name:e=null,port:t=null,verbosity:s=Np()}={}){S(this,Or);var i;if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if((i=o(Me,Cn))!=null&&i.has(t))throw new Error("Cannot use more than one PDFWorker per port.");(o(Me,Cn)||w(Me,Cn,new WeakMap)).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return me?Promise.all([Os.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new xa("main","worker",e),this._messageHandler.on("ready",function(){}),E(this,Or,Hh).call(this)}_initialize(){if(Gs.isWorkerDisabled||o(Me,Nr,Uh)){this._setupFakeWorker();return}let{workerSrc:e}=Me;try{Gs.isSameOrigin(window.location.href,e)||(e=Gs.createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),s=new xa("main","worker",t),i=()=>{n.abort(),s.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;t.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=t,this._webWorker=t,E(this,Or,Hh).call(this)}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{Ll("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Gs.isWorkerDisabled||(gt("Setting up fake worker."),Gs.isWorkerDisabled=!0),Me._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new rm;this._port=t;const s=`fake${Gs.fakeWorkerId++}`,i=new xa(s+"_worker",s,t);e.setup(i,t),this._messageHandler=new xa(s,s+"_worker",t),E(this,Or,Hh).call(this)}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){var e;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(e=o(Me,Cn))==null||e.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){var s;if(!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const t=(s=o(this,Cn))==null?void 0:s.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Me(e)}static get workerSrc(){if(gi.workerSrc)return gi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Et(this,"_setupFakeWorkerGlobal",(async()=>o(this,Nr,Uh)?o(this,Nr,Uh):(await import(this.workerSrc)).WorkerMessageHandler)())}};Cn=new WeakMap,Or=new WeakSet,Hh=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Nr=new WeakSet,Uh=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},S(Me,Nr),S(Me,Cn);let pr=Me;var ei,Ss,Br,zr,xs,kn,Ca;class am{constructor(e,t,s,i,n){S(this,kn);S(this,ei,new Map);S(this,Ss,new Map);S(this,Br,new Map);S(this,zr,new Map);S(this,xs,null);this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Ju,this.fontLoader=new ng({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Et(this,"annotationStorage",new bd)}getRenderingIntent(e,t=Si.ENABLE,s=null,i=!1){let n=Ke.DISPLAY,r=vc;switch(e){case"any":n=Ke.ANY;break;case"display":break;case"print":n=Ke.PRINT;break;default:gt(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case Si.DISABLE:n+=Ke.ANNOTATIONS_DISABLE;break;case Si.ENABLE:break;case Si.ENABLE_FORMS:n+=Ke.ANNOTATIONS_FORMS;break;case Si.ENABLE_STORAGE:n+=Ke.ANNOTATIONS_STORAGE,r=(n&Ke.PRINT&&s instanceof Nu?s:this.annotationStorage).serializable;break;default:gt(`getRenderingIntent - invalid annotationMode: ${t}`)}return i&&(n+=Ke.OPLIST),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=o(this,xs))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const i of o(this,Ss).values())e.push(i._destroy());o(this,Ss).clear(),o(this,Br).clear(),o(this,zr).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),o(this,ei).clear(),this.filterFactory.destroy(),ca.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new ir("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(s,i)=>{Qt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}Qt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),e.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{var r;(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&((r=t.onProgress)==null||r.call(t,this._lastProgress)),n.onProgress=a=>{var h;(h=t.onProgress)==null||h.call(t,{loaded:a.loaded,total:a.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),e.on("GetRangeReader",(s,i)=>{Qt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}Qt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,t._capability.resolve(new im(s,this))}),e.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Kl(s.message,s.code);break;case"InvalidPDFException":i=new iu(s.message);break;case"MissingPDFException":i=new sr(s.message);break;case"UnexpectedResponseException":i=new Il(s.message,s.status);break;case"UnknownErrorException":i=new Zl(s.message,s.details);break;default:Rt("DocException - expected a valid Error.")}t._capability.reject(i)}),e.on("PasswordRequest",s=>{if(w(this,xs,Promise.withResolvers()),t.onPassword){const i=n=>{n instanceof Error?o(this,xs).reject(n):o(this,xs).resolve({password:n})};try{t.onPassword(i,s.code)}catch(n){o(this,xs).reject(n)}}else o(this,xs).reject(new Kl(s.message,s.code));return o(this,xs).promise}),e.on("DataLoaded",s=>{var i;(i=t.onProgress)==null||i.call(t,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),e.on("StartRenderPage",s=>{if(this.destroyed)return;o(this,Ss).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),e.on("commonobj",([s,i,n])=>{var r;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:a,fontExtraProperties:h,pdfBug:l}=this._params;if("error"in n){const f=n.error;gt(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const c=l&&((r=globalThis.FontInspector)!=null&&r.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,d=new rg(n,{disableFontFace:a,inspectFont:c});this.fontLoader.bind(d).catch(()=>e.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h&&d.data&&(d.data=null),this.commonObjs.resolve(s,d)});break;case"CopyLocalImage":const{imageRef:p}=n;Qt(p,"The imageRef must be defined.");for(const f of o(this,Ss).values())for(const[,g]of f.objs)if((g==null?void 0:g.ref)===p)return g.dataLen?(this.commonObjs.resolve(s,structuredClone(g)),g.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),e.on("obj",([s,i,n,r])=>{var h;if(this.destroyed)return;const a=o(this,Ss).get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){(h=r==null?void 0:r.bitmap)==null||h.close();return}switch(n){case"Image":a.objs.resolve(s,r),(r==null?void 0:r.dataLen)>Ip&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),e.on("DocProgress",s=>{var i;this.destroyed||(i=t.onProgress)==null||i.call(t,{loaded:s.loaded,total:s.total})}),e.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),e.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&>("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((s=this._fullReader)==null?void 0:s.filename)??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,s=o(this,Br).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&o(this,zr).set(n.refStr,e);const r=new nm(t,n,this,this._params.pdfBug);return o(this,Ss).set(t,r),r});return o(this,Br).set(t,i),i}getPageIndex(e){return Xd(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return E(this,kn,Ca).call(this,"GetFieldObjects")}hasJSActions(){return E(this,kn,Ca).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return E(this,kn,Ca).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return E(this,kn,Ca).call(this,"GetOptionalContentConfig").then(t=>new xg(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=o(this,ei).get(e);if(t)return t;const s=this.messageHandler.sendWithPromise(e,null).then(i=>{var n,r;return{info:i[0],metadata:i[1]?new Eg(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((r=this._fullReader)==null?void 0:r.contentLength)??null}});return o(this,ei).set(e,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of o(this,Ss).values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),o(this,ei).clear(),this.filterFactory.destroy(!0),ca.cleanup()}}cachedPageNumber(e){if(!Xd(e))return null;const t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return o(this,zr).get(t)??null}}ei=new WeakMap,Ss=new WeakMap,Br=new WeakMap,zr=new WeakMap,xs=new WeakMap,kn=new WeakSet,Ca=function(e,t=null){const s=o(this,ei).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise(e,t);return o(this,ei).set(e,i),i};const Rh=Symbol("INITIAL_DATA");var os,To,Tc;class Ju{constructor(){S(this,To);S(this,os,Object.create(null))}get(e,t=null){if(t){const i=E(this,To,Tc).call(this,e);return i.promise.then(()=>t(i.data)),null}const s=o(this,os)[e];if(!s||s.data===Rh)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return s.data}has(e){const t=o(this,os)[e];return!!t&&t.data!==Rh}resolve(e,t=null){const s=E(this,To,Tc).call(this,e);s.data=t,s.resolve()}clear(){var e;for(const t in o(this,os)){const{data:s}=o(this,os)[t];(e=s==null?void 0:s.bitmap)==null||e.close()}w(this,os,Object.create(null))}*[Symbol.iterator](){for(const e in o(this,os)){const{data:t}=o(this,os)[e];t!==Rh&&(yield[e,t])}}}os=new WeakMap,To=new WeakSet,Tc=function(e){var t;return(t=o(this,os))[e]||(t[e]={...Promise.withResolvers(),data:Rh})};var Di;class om{constructor(e){S(this,Di,null);w(this,Di,e),this.onContinue=null}get promise(){return o(this,Di).capability.promise}cancel(e=0){o(this,Di).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=o(this,Di).operatorList;if(!e)return!1;const{annotationCanvasMap:t}=o(this,Di);return e.form||e.canvas&&(t==null?void 0:t.size)>0}}Di=new WeakMap;var Oi,Tn;const tn=class tn{constructor({callback:e,params:t,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:h,filterFactory:l,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:p=null}){S(this,Oi,null);this.callback=e,this.params=t,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=h,this.filterFactory=l,this._pdfBug=d,this.pageColors=p,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new om(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var a,h;if(this.cancelled)return;if(this._canvas){if(o(tn,Tn).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");o(tn,Tn).add(this._canvas)}this._pdfBug&&((a=globalThis.StepperManager)!=null&&a.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new fr(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:e,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(e=null,t=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),o(this,Oi)&&(window.cancelAnimationFrame(o(this,Oi)),w(this,Oi,null)),o(tn,Tn).delete(this._canvas),this.callback(e||new fd(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){var e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?w(this,Oi,window.requestAnimationFrame(()=>{w(this,Oi,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),o(tn,Tn).delete(this._canvas),this.callback())))}};Oi=new WeakMap,Tn=new WeakMap,S(tn,Tn,new WeakSet);let Rc=tn;const hm="4.4.168",lm="19fbc8998";function Yd(u){return Math.floor(Math.max(0,Math.min(1,u))*255).toString(16).padStart(2,"0")}function ba(u){return Math.max(0,Math.min(255,255*u))}class Kd{static CMYK_G([e,t,s,i]){return["G",1-Math.min(1,.3*e+.59*s+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=ba(e),[e,e,e]}static G_HTML([e]){const t=Yd(e);return`#${t}${t}${t}`}static RGB_G([e,t,s]){return["G",.3*e+.59*t+.11*s]}static RGB_rgb(e){return e.map(ba)}static RGB_HTML(e){return`#${e.map(Yd).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,s,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,s+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,s,i]){return[ba(1-Math.min(1,e+i)),ba(1-Math.min(1,s+i)),ba(1-Math.min(1,t+i))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,s]){const i=1-e,n=1-t,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class tf{static setupStorage(e,t,s,i,n){const r=i.getValue(t,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(e.textContent=r.value),n==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.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"),n==="print")break;e.addEventListener("change",a=>{i.setValue(t,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&e.setAttribute("value",r.value),n==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})})}break;case"select":if(r.value!==null){e.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}e.addEventListener("input",a=>{const h=a.target.options,l=h.selectedIndex===-1?"":h[h.selectedIndex].value;i.setValue(t,{value:l})});break}}static setAttributes({html:e,element:t,storage:s=null,intent:i,linkService:n}){const{attributes:r}=t,a=e instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[h,l]of Object.entries(r))if(l!=null)switch(h){case"class":l.length&&e.setAttribute(h,l.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",l);break;case"style":Object.assign(e.style,l);break;case"textContent":e.textContent=l;break;default:(!a||h!=="href"&&h!=="newWindow")&&e.setAttribute(h,l)}a&&n.addLinkAttributes(e,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(e,r.dataId,t,s)}static render(e){var d,p;const t=e.annotationStorage,s=e.linkService,i=e.xfaHtml,n=e.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",h=e.div;if(h.append(r),e.viewport){const f=`matrix(${e.viewport.transform.join(",")})`;h.style.transform=f}a&&h.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const f=document.createTextNode(i.value);r.append(f),a&&Na.shouldBuildText(i.name)&&l.push(f)}return{textDivs:l}}const c=[[i,-1,r]];for(;c.length>0;){const[f,g,m]=c.at(-1);if(g+1===f.children.length){c.pop();continue}const v=f.children[++c.at(-1)[1]];if(v===null)continue;const{name:b}=v;if(b==="#text"){const x=document.createTextNode(v.value);l.push(x),m.append(x);continue}const A=(d=v==null?void 0:v.attributes)!=null&&d.xmlns?document.createElementNS(v.attributes.xmlns,b):document.createElement(b);if(m.append(A),v.attributes&&this.setAttributes({html:A,element:v,storage:t,intent:n,linkService:s}),((p=v.children)==null?void 0:p.length)>0)c.push([v,-1,A]);else if(v.value){const x=document.createTextNode(v.value);a&&Na.shouldBuildText(b)&&l.push(x),A.append(x)}}for(const f of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))f.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const yh=1e3,cm=9,Jn=new WeakSet;function mi(u){return{width:u[2]-u[0],height:u[3]-u[1]}}class dm{static create(e){switch(e.data.annotationType){case qt.LINK:return new ef(e);case qt.TEXT:return new um(e);case qt.WIDGET:switch(e.data.fieldType){case"Tx":return new fm(e);case"Btn":return e.data.radioButton?new rf(e):e.data.checkBox?new gm(e):new mm(e);case"Ch":return new bm(e);case"Sig":return new pm(e)}return new nr(e);case qt.POPUP:return new Lc(e);case qt.FREETEXT:return new cf(e);case qt.LINE:return new vm(e);case qt.SQUARE:return new ym(e);case qt.CIRCLE:return new Am(e);case qt.POLYLINE:return new df(e);case qt.CARET:return new Em(e);case qt.INK:return new uf(e);case qt.POLYGON:return new wm(e);case qt.HIGHLIGHT:return new Sm(e);case qt.UNDERLINE:return new xm(e);case qt.SQUIGGLY:return new Cm(e);case qt.STRIKEOUT:return new km(e);case qt.STAMP:return new ff(e);case qt.FILEATTACHMENT:return new Tm(e);default:return new jt(e)}}}var Rn,Hr,Ur,Ro,Pc;const Ed=class Ed{constructor(e,{isRenderable:t=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){S(this,Ro);S(this,Rn,null);S(this,Hr,!1);S(this,Ur,null);this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:s}){return!!(e!=null&&e.str||t!=null&&t.str||s!=null&&s.str)}get hasPopupData(){return Ed._hasPopupData(this.data)}updateEdited(e){var s;if(!this.container)return;o(this,Rn)||w(this,Rn,{rect:this.data.rect.slice(0)});const{rect:t}=e;t&&E(this,Ro,Pc).call(this,t),(s=o(this,Ur))==null||s.popup.updateEdited(e)}resetEdited(){var e;o(this,Rn)&&(E(this,Ro,Pc).call(this,o(this,Rn).rect),(e=o(this,Ur))==null||e.popup.resetEdited(),w(this,Rn,null))}_createContainer(e){const{data:t,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",t.id),this instanceof nr||(n.tabIndex=yh);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,t.popupRef&&n.setAttribute("aria-haspopup","dialog"),t.alternativeText&&(n.title=t.alternativeText),t.noRotate&&n.classList.add("norotate"),!t.rect||this instanceof Lc){const{rotation:m}=t;return!t.hasOwnCanvas&&m!==0&&this.setRotation(m,n),n}const{width:a,height:h}=mi(t.rect);if(!e&&t.borderStyle.width>0){r.borderWidth=`${t.borderStyle.width}px`;const m=t.borderStyle.horizontalCornerRadius,v=t.borderStyle.verticalCornerRadius;if(m>0||v>0){const A=`calc(${m}px * var(--scale-factor)) / calc(${v}px * var(--scale-factor))`;r.borderRadius=A}else if(this instanceof rf){const A=`calc(${a}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;r.borderRadius=A}switch(t.borderStyle.style){case ga.SOLID:r.borderStyle="solid";break;case ga.DASHED:r.borderStyle="dashed";break;case ga.BEVELED:gt("Unimplemented border style: beveled");break;case ga.INSET:gt("Unimplemented border style: inset");break;case ga.UNDERLINE:r.borderBottomStyle="solid";break}const b=t.borderColor||null;b?(w(this,Hr,!0),r.borderColor=at.makeHexColor(b[0]|0,b[1]|0,b[2]|0)):r.borderWidth=0}const l=at.normalizeRect([t.rect[0],s.view[3]-t.rect[1]+s.view[1],t.rect[2],s.view[3]-t.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:p,pageY:f}=i.rawDims;r.left=`${100*(l[0]-p)/c}%`,r.top=`${100*(l[1]-f)/d}%`;const{rotation:g}=t;return t.hasOwnCanvas||g===0?(r.width=`${100*a/c}%`,r.height=`${100*h/d}%`):this.setRotation(g,n),n}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=mi(this.data.rect);let a,h;e%180===0?(a=100*n/s,h=100*r/i):(a=100*r/s,h=100*n/i),t.style.width=`${a}%`,t.style.height=`${h}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(t,s,i)=>{const n=i.detail[t],r=n[0],a=n.slice(1);i.target.style[s]=Kd[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:Kd[`${r}_rgb`](a)})};return Et(this,"_commonActions",{display:t=>{const{display:s}=t.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:s}=t.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:t=>{const s=t.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(e,t){const s=this._commonActions;for(const i of Object.keys(t.detail)){const n=e[i]||s[i];n==null||n(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const s=this._commonActions;for(const[i,n]of Object.entries(t)){const r=s[i];if(r){const a={detail:{[i]:n},target:e};r(a),delete t[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,s,i,n]=this.data.rect.map(m=>Math.fround(m));if(e.length===8){const[m,v,b,A]=e.subarray(2,6);if(i===m&&n===v&&t===b&&s===A)return}const{style:r}=this.container;let a;if(o(this,Hr)){const{borderColor:m,borderWidth:v}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const h=i-t,l=n-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const p=c.createElement("defs");d.append(p);const f=c.createElement("clipPath"),g=`clippath_${this.data.id}`;f.setAttribute("id",g),f.setAttribute("clipPathUnits","objectBoundingBox"),p.append(f);for(let m=2,v=e.length;m`)}o(this,Hr)&&(a.push("')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${g})`}_createPopup(){const{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");const s=w(this,Ur,new Lc({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(s.render())}render(){Rt("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[e];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===t)continue;const h=typeof a=="string"?a:null,l=document.querySelector(`[data-element-id="${r}"]`);if(l&&!Jn.has(l)){gt(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:h,domElement:l})}return s}for(const i of document.getElementsByName(e)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==t&&Jn.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}};Rn=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,Ro=new WeakSet,Pc=function(e){const{container:{style:t},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:h}}}}=this;s==null||s.splice(0,4,...e);const{width:l,height:c}=mi(e);t.left=`${100*(e[0]-a)/n}%`,t.top=`${100*(r-e[3]+h)/r}%`,i===0?(t.width=`${100*l/n}%`,t.height=`${100*c/r}%`):this.setRotation(i)};let jt=Ed;var je,Ki,sf,nf;class ef extends jt{constructor(t,s=null){super(t,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});S(this,je);this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let n=!1;return t.url?(s.addLinkAttributes(i,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(i,t.action),n=!0):t.attachment?(E(this,je,sf).call(this,i,t.attachment,t.attachmentDest),n=!0):t.setOCGState?(E(this,je,nf).call(this,i,t.setOCGState),n=!0):t.dest?(this._bindLink(i,t.dest),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),n=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(t,s){t.href=this.linkService.getDestinationHash(s),t.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&E(this,je,Ki).call(this)}_bindNamedAction(t,s){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(s),!1),E(this,je,Ki).call(this)}_bindJSAction(t,s){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const r=i.get(n);r&&(t[r]=()=>{var a;return(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}t.onclick||(t.onclick=()=>!1),E(this,je,Ki).call(this)}_bindResetFormAction(t,s){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),E(this,je,Ki).call(this),!this._fieldObjects){gt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{var d;i==null||i();const{fields:n,refs:r,include:a}=s,h=[];if(n.length!==0||r.length!==0){const p=new Set(r);for(const f of n){const g=this._fieldObjects[f]||[];for(const{id:m}of g)p.add(m)}for(const f of Object.values(this._fieldObjects))for(const g of f)p.has(g.id)===a&&h.push(g)}else for(const p of Object.values(this._fieldObjects))h.push(...p);const l=this.annotationStorage,c=[];for(const p of h){const{id:f}=p;switch(c.push(f),p.type){case"text":{const m=p.defaultValue||"";l.setValue(f,{value:m});break}case"checkbox":case"radiobutton":{const m=p.defaultValue===p.exportValues;l.setValue(f,{value:m});break}case"combobox":case"listbox":{const m=p.defaultValue||"";l.setValue(f,{value:m});break}default:continue}const g=document.querySelector(`[data-element-id="${f}"]`);if(g){if(!Jn.has(g)){gt(`_bindResetFormAction - element not allowed: ${f}`);continue}}else continue;g.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}je=new WeakSet,Ki=function(){this.container.setAttribute("data-internal-link","")},sf=function(t,s,i=null){t.href=this.linkService.getAnchorUrl(""),s.description&&(t.title=s.description),t.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},E(this,je,Ki).call(this)},nf=function(t,s){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(s),!1),E(this,je,Ki).call(this)};class um extends jt{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class nr extends jt{render(){return this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&(((t=e.previousSibling)==null?void 0:t.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return ke.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,s,i,n){s.includes("mouse")?e.addEventListener(s,r=>{var a;(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):e.addEventListener(s,r=>{var a;if(s==="blur"){if(!t.focused||!r.relatedTarget)return;t.focused=!1}else if(s==="focus"){if(t.focused)return;t.focused=!0}n&&((a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}}))})}_setEventListeners(e,t,s,i){var n,r,a;for(const[h,l]of s)(l==="Action"||(n=this.data.actions)!=null&&n[l])&&((l==="Focus"||l==="Blur")&&(t||(t={focused:!1})),this._setEventListener(e,t,h,l,i),l==="Focus"&&!((r=this.data.actions)!=null&&r.Blur)?this._setEventListener(e,t,"blur","Blur",null):l==="Blur"&&!((a=this.data.actions)!=null&&a.Focus)&&this._setEventListener(e,t,"focus","Focus",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":at.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const t=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||cm,n=e.style;let r;const a=2,h=l=>Math.round(10*l)/10;if(this.data.multiLine){const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(l/(jl*i))||1,d=l/c;r=Math.min(i,h(d/jl))}else{const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,h(l/jl))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=at.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class fm extends nr{constructor(e){const t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(e.name,e.id))r.domElement&&(r.domElement[t]=s),n.setValue(r.id,{[i]:s})}render(){var i,n;const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const r=e.getValue(t,{value:this.data.fieldValue});let a=r.value||"";const h=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;h&&a.length>h&&(a=a.slice(0,h));let l=r.formattedValue||((i=this.data.textContent)==null?void 0:i.join(` `))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const c={userValue:a,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=l??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",l??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Jn.add(s),s.setAttribute("data-element-id",t),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=yh,this._setRequired(s,this.data.required),h&&(s.maxLength=h),s.addEventListener("input",p=>{e.setValue(t,{value:p.target.value}),this.setPropertyOnSiblings(s,"value",p.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",p=>{const f=this.data.defaultFieldValue??"";s.value=c.userValue=f,c.formattedValue=null});let d=p=>{const{formattedValue:f}=c;f!=null&&(p.target.value=f),p.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",f=>{var m;if(c.focused)return;const{target:g}=f;c.userValue&&(g.value=c.userValue),c.lastCommittedValue=g.value,c.commitKey=1,(m=this.data.actions)!=null&&m.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",f=>{this.showElementAndHideCanvas(f.target);const g={value(m){c.userValue=m.detail.value??"",e.setValue(t,{value:c.userValue.toString()}),m.target.value=c.userValue},formattedValue(m){const{formattedValue:v}=m.detail;c.formattedValue=v,v!=null&&m.target!==document.activeElement&&(m.target.value=v),e.setValue(t,{formattedValue:v})},selRange(m){m.target.setSelectionRange(...m.detail.selRange)},charLimit:m=>{var x;const{charLimit:v}=m.detail,{target:b}=m;if(v===0){b.removeAttribute("maxLength");return}b.setAttribute("maxLength",v);let A=c.userValue;!A||A.length<=v||(A=A.slice(0,v),b.value=c.userValue=A,e.setValue(t,{value:A}),(x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:A,willCommit:!0,commitKey:1,selStart:b.selectionStart,selEnd:b.selectionEnd}}))}};this._dispatchEventFromSandbox(g,f)}),s.addEventListener("keydown",f=>{var v;c.commitKey=1;let g=-1;if(f.key==="Escape"?g=0:f.key==="Enter"&&!this.data.multiLine?g=2:f.key==="Tab"&&(c.commitKey=3),g===-1)return;const{value:m}=f.target;c.lastCommittedValue!==m&&(c.lastCommittedValue=m,c.userValue=m,(v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:m,willCommit:!0,commitKey:g,selStart:f.target.selectionStart,selEnd:f.target.selectionEnd}}))});const p=d;d=null,s.addEventListener("blur",f=>{var m,v;if(!c.focused||!f.relatedTarget)return;(m=this.data.actions)!=null&&m.Blur||(c.focused=!1);const{value:g}=f.target;c.userValue=g,c.lastCommittedValue!==g&&((v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:g,willCommit:!0,commitKey:c.commitKey,selStart:f.target.selectionStart,selEnd:f.target.selectionEnd}})),p(f)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",f=>{var T;c.lastCommittedValue=null;const{data:g,target:m}=f,{value:v,selectionStart:b,selectionEnd:A}=m;let x=b,k=A;switch(f.inputType){case"deleteWordBackward":{const L=v.substring(0,b).match(/\w*[^\w]*$/);L&&(x-=L[0].length);break}case"deleteWordForward":{const L=v.substring(b).match(/^[^\w]*\w*/);L&&(k+=L[0].length);break}case"deleteContentBackward":b===A&&(x-=1);break;case"deleteContentForward":b===A&&(k+=1);break}f.preventDefault(),(T=this.linkService.eventBus)==null||T.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:v,change:g||"",willCommit:!1,selStart:x,selEnd:k}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],f=>f.target.value)}if(d&&s.addEventListener("blur",d),this.data.comb){const f=(this.data.rect[2]-this.data.rect[0])/h;s.classList.add("comb"),s.style.letterSpacing=`calc(${f}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class pm extends nr{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class gm extends nr{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.exportValue===t.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",e.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Jn.add(n),n.setAttribute("data-element-id",s),n.disabled=t.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=t.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",t.exportValue),n.tabIndex=yh,n.addEventListener("change",r=>{const{name:a,checked:h}=r.target;for(const l of this._getElementsByName(a,s)){const c=h&&l.exportValue===t.exportValue;l.domElement&&(l.domElement.checked=c),e.setValue(l.id,{value:c})}e.setValue(s,{value:h})}),n.addEventListener("resetform",r=>{const a=t.defaultFieldValue||"Off";r.target.checked=a===t.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(h){h.target.checked=h.detail.value!=="Off",e.setValue(s,{value:h.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class rf extends nr{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.fieldValue===t.buttonValue}).value;if(typeof i=="string"&&(i=i!==t.buttonValue,e.setValue(s,{value:i})),i)for(const r of this._getElementsByName(t.fieldName,s))e.setValue(r.id,{value:!1});const n=document.createElement("input");if(Jn.add(n),n.setAttribute("data-element-id",s),n.disabled=t.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=t.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=yh,n.addEventListener("change",r=>{const{name:a,checked:h}=r.target;for(const l of this._getElementsByName(a,s))e.setValue(l.id,{value:!1});e.setValue(s,{value:h})}),n.addEventListener("resetform",r=>{const a=t.defaultFieldValue;r.target.checked=a!=null&&a===t.buttonValue}),this.enableScripting&&this.hasJSActions){const r=t.buttonValue;n.addEventListener("updatefromsandbox",a=>{const h={value:l=>{const c=r===l.detail.value;for(const d of this._getElementsByName(l.target.name)){const p=c&&d.id===s;d.domElement&&(d.domElement.checked=p),e.setValue(d.id,{value:p})}}};this._dispatchEventFromSandbox(h,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class mm extends ef{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),e}}class bm extends nr{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,s=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");Jn.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=yh;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const p of i.options)p.selected=p.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),r=()=>{c.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=c=>{const d=c?"value":"textContent",{options:p,multiple:f}=i;return f?Array.prototype.filter.call(p,g=>g.selected).map(g=>g[d]):p.selectedIndex===-1?null:p[p.selectedIndex][d]};let h=a(!1);const l=c=>{const d=c.target.options;return Array.prototype.map.call(d,p=>({displayValue:p.textContent,exportValue:p.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const d={value(p){r==null||r();const f=p.detail.value,g=new Set(Array.isArray(f)?f:[f]);for(const m of i.options)m.selected=g.has(m.value);e.setValue(t,{value:a(!0)}),h=a(!1)},multipleSelection(p){i.multiple=!0},remove(p){const f=i.options,g=p.detail.remove;f[g].selected=!1,i.remove(g),f.length>0&&Array.prototype.findIndex.call(f,v=>v.selected)===-1&&(f[0].selected=!0),e.setValue(t,{value:a(!0),items:l(p)}),h=a(!1)},clear(p){for(;i.length!==0;)i.remove(0);e.setValue(t,{value:null,items:[]}),h=a(!1)},insert(p){const{index:f,displayValue:g,exportValue:m}=p.detail.insert,v=i.children[f],b=document.createElement("option");b.textContent=g,b.value=m,v?v.before(b):i.append(b),e.setValue(t,{value:a(!0),items:l(p)}),h=a(!1)},items(p){const{items:f}=p.detail;for(;i.length!==0;)i.remove(0);for(const g of f){const{displayValue:m,exportValue:v}=g,b=document.createElement("option");b.textContent=m,b.value=v,i.append(b)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:a(!0),items:l(p)}),h=a(!1)},indices(p){const f=new Set(p.detail.indices);for(const g of p.target.options)g.selected=f.has(g.index);e.setValue(t,{value:a(!0)}),h=a(!1)},editable(p){p.target.disabled=!p.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",c=>{var f;const d=a(!0),p=a(!1);e.setValue(t,{value:d}),c.preventDefault(),(f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:h,change:p,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){e.setValue(t,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Lc extends jt{constructor(e){const{data:t,elements:s}=e;super(e,{isRenderable:jt._hasPopupData(t)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new _m({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const s of this.elements)s.popup=e,t.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(s=>`${ru}${s}`).join(",")),this.container}}var jr,Sl,xl,Wr,Pn,zt,si,Ln,Po,Lo,Gr,ii,hs,ni,Io,ri,Mo,In,Mn,Pt,jh,Ic,af,of,hf,lf,Wh,Gh,Mc;class _m{constructor({container:e,color:t,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:h,rect:l,parentRect:c,open:d}){S(this,Pt);S(this,jr,E(this,Pt,hf).bind(this));S(this,Sl,E(this,Pt,Mc).bind(this));S(this,xl,E(this,Pt,Gh).bind(this));S(this,Wr,E(this,Pt,Wh).bind(this));S(this,Pn,null);S(this,zt,null);S(this,si,null);S(this,Ln,null);S(this,Po,null);S(this,Lo,null);S(this,Gr,null);S(this,ii,!1);S(this,hs,null);S(this,ni,null);S(this,Io,null);S(this,ri,null);S(this,Mo,null);S(this,In,null);S(this,Mn,!1);var p;w(this,zt,e),w(this,Mo,i),w(this,si,r),w(this,ri,a),w(this,Lo,h),w(this,Pn,t),w(this,Io,l),w(this,Gr,c),w(this,Po,s),w(this,Ln,cu.toDateObject(n)),this.trigger=s.flatMap(f=>f.getElementsToTriggerPopup());for(const f of this.trigger)f.addEventListener("click",o(this,Wr)),f.addEventListener("mouseenter",o(this,xl)),f.addEventListener("mouseleave",o(this,Sl)),f.classList.add("popupTriggerArea");for(const f of s)(p=f.container)==null||p.addEventListener("keydown",o(this,jr));o(this,zt).hidden=!0,d&&E(this,Pt,Wh).call(this)}render(){if(o(this,hs))return;const e=w(this,hs,document.createElement("div"));if(e.className="popup",o(this,Pn)){const n=e.style.outlineColor=at.makeHexColor(...o(this,Pn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:e.style.backgroundColor=at.makeHexColor(...o(this,Pn).map(a=>Math.floor(.7*(255-a)+a)))}const t=document.createElement("span");t.className="header";const s=document.createElement("h1");if(t.append(s),{dir:s.dir,str:s.textContent}=o(this,Mo),e.append(t),o(this,Ln)){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),n.setAttribute("data-l10n-args",JSON.stringify({date:o(this,Ln).toLocaleDateString(),time:o(this,Ln).toLocaleTimeString()})),t.append(n)}const i=o(this,Pt,jh);if(i)tf.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(o(this,si));e.append(n)}o(this,zt).append(e)}_formatContents({str:e,dir:t}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=t;const i=e.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n{r.key==="Enter"&&(n?r.metaKey:r.ctrlKey)&&E(this,Ho,Fc).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return o(this,zo)}addHighlightArea(){this.container.classList.add("highlightArea")}}zo=new WeakMap,Ho=new WeakSet,Fc=function(){var t;(t=this.downloadManager)==null||t.openOrDownloadData(this.content,this.filename)};var Uo,Fn,$r,tr,pf,Dc;class Rm{constructor({div:e,accessibilityManager:t,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r}){S(this,tr);S(this,Uo,null);S(this,Fn,null);S(this,$r,new Map);this.div=e,w(this,Uo,t),w(this,Fn,s),this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}async render(e){var r;const{annotations:t}=e,s=this.div;Zn(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new ud,annotationStorage:e.annotationStorage||new bd,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const a of t){if(a.noHTML)continue;const h=a.annotationType===qt.POPUP;if(h){const d=i.get(a.id);if(!d)continue;n.elements=d}else{const{width:d,height:p}=mi(a.rect);if(d<=0||p<=0)continue}n.data=a;const l=dm.create(n);if(!l.isRenderable)continue;if(!h&&a.popupRef){const d=i.get(a.popupRef);d?d.push(l):i.set(a.popupRef,[l])}const c=l.render();a.hidden&&(c.style.visibility="hidden"),E(this,tr,pf).call(this,c,a.id),l.annotationEditorType>0&&(o(this,$r).set(l.data.id,l),(r=this._annotationEditorUIManager)==null||r.renderAnnotationElement(l))}E(this,tr,Dc).call(this)}update({viewport:e}){const t=this.div;this.viewport=e,Zn(t,{rotation:e.rotation}),E(this,tr,Dc).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(o(this,$r).values())}getEditableAnnotation(e){return o(this,$r).get(e)}}Uo=new WeakMap,Fn=new WeakMap,$r=new WeakMap,tr=new WeakSet,pf=function(e,t){var i;const s=e.firstChild||e;s.id=`${ru}${t}`,this.div.append(e),(i=o(this,Uo))==null||i.moveElementInDOM(this.div,e,s,!1)},Dc=function(){if(!o(this,Fn))return;const e=this.div;for(const[t,s]of o(this,Fn)){const i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}o(this,Fn).clear()};const Ph=/\r\n?|\n/g;var jo,Wo,Go,$o,Vo,ls,Ne,qo,Be,Vr,$t,gf,mf,bf,$h,_i,Vh,qh,_f,Nc,vf;const Dt=class Dt extends kt{constructor(t){super({...t,name:"freeTextEditor"});S(this,$t);S(this,jo,this.editorDivBlur.bind(this));S(this,Wo,this.editorDivFocus.bind(this));S(this,Go,this.editorDivInput.bind(this));S(this,$o,this.editorDivKeydown.bind(this));S(this,Vo,this.editorDivPaste.bind(this));S(this,ls);S(this,Ne,"");S(this,qo,`${this.id}-editor`);S(this,Be);S(this,Vr,null);w(this,ls,t.color||Dt._defaultColor||kt._defaultLineColor),w(this,Be,t.fontSize||Dt._defaultFontSize)}static get _keyboardManager(){const t=Dt.prototype,s=r=>r.isEmpty(),i=Qn.TRANSLATE_SMALL,n=Qn.TRANSLATE_BIG;return Et(this,"_keyboardManager",new _h([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(t,s){kt.initialize(t,s,{strings:["pdfjs-free-text-default-content"]});const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,s){switch(t){case ut.FREETEXT_SIZE:Dt._defaultFontSize=s;break;case ut.FREETEXT_COLOR:Dt._defaultColor=s;break}}updateParams(t,s){switch(t){case ut.FREETEXT_SIZE:E(this,$t,gf).call(this,s);break;case ut.FREETEXT_COLOR:E(this,$t,mf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[ut.FREETEXT_SIZE,Dt._defaultFontSize],[ut.FREETEXT_COLOR,Dt._defaultColor||kt._defaultLineColor]]}get propertiesToUpdate(){return[[ut.FREETEXT_SIZE,o(this,Be)],[ut.FREETEXT_COLOR,o(this,ls)]]}_translateEmpty(t,s){this._uiManager.translateSelectedEditors(t,s,!0)}getInitialTranslation(){const t=this.parentScale;return[-Dt._internalPadding*t,-(Dt._internalPadding+o(this,Be))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(wt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",o(this,$o),{signal:t}),this.editorDiv.addEventListener("focus",o(this,Wo),{signal:t}),this.editorDiv.addEventListener("blur",o(this,jo),{signal:t}),this.editorDiv.addEventListener("input",o(this,Go),{signal:t}),this.editorDiv.addEventListener("paste",o(this,Vo),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",o(this,qo)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",o(this,$o)),this.editorDiv.removeEventListener("focus",o(this,Wo)),this.editorDiv.removeEventListener("blur",o(this,jo)),this.editorDiv.removeEventListener("input",o(this,Go)),this.editorDiv.removeEventListener("paste",o(this,Vo)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var t;this.width||(this.enableEditMode(),this.editorDiv.focus(),(t=this._initialOptions)!=null&&t.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=o(this,Ne),s=w(this,Ne,E(this,$t,bf).call(this).trimEnd());if(t===s)return;const i=n=>{if(w(this,Ne,n),!n){this.remove();return}E(this,$t,qh).call(this),this._uiManager.rebuild(this),E(this,$t,$h).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(t)},mustExec:!1}),E(this,$t,$h).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Dt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,s;this.width&&(t=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",o(this,qo)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),kt._l10nPromise.get("pdfjs-free-text-default-content").then(n=>{var r;return(r=this.editorDiv)==null?void 0:r.setAttribute("default-content",n)}),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${o(this,Be)}px * var(--scale-factor))`,i.color=o(this,ls),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),nl(this,this.div,["dblclick","keydown"]),this.width){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:a}=o(this,Vr);let[h,l]=this.getInitialTranslation();[h,l]=this.pageTranslationToScreen(h,l);const[c,d]=this.pageDimensions,[p,f]=this.pageTranslation;let g,m;switch(this.rotation){case 0:g=t+(a[0]-p)/c,m=s+this.height-(a[1]-f)/d;break;case 90:g=t+(a[0]-p)/c,m=s-(a[1]-f)/d,[h,l]=[l,-h];break;case 180:g=t-this.width+(a[0]-p)/c,m=s-(a[1]-f)/d,[h,l]=[-h,-l];break;case 270:g=t+(a[0]-p-this.height*d)/c,m=s+(a[1]-f-this.width*c)/d,[h,l]=[-l,h];break}this.setAt(g*n,m*r,h,l)}else this.setAt(t*n,s*r,this.width*n,this.height*r);E(this,$t,qh).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var g,m,v;const s=t.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;t.preventDefault();const n=E(g=Dt,_i,Nc).call(g,s.getData("text")||"").replaceAll(Ph,` `);if(!n)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const a=r.getRangeAt(0);if(!n.includes(` `)){a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),r.collapseToStart();return}const{startContainer:h,startOffset:l}=a,c=[],d=[];if(h.nodeType===Node.TEXT_NODE){const b=h.parentElement;if(d.push(h.nodeValue.slice(l).replaceAll(Ph,"")),b!==this.editorDiv){let A=c;for(const x of this.editorDiv.childNodes){if(x===b){A=d;continue}A.push(E(m=Dt,_i,Vh).call(m,x))}}c.push(h.nodeValue.slice(0,l).replaceAll(Ph,""))}else if(h===this.editorDiv){let b=c,A=0;for(const x of this.editorDiv.childNodes)A++===l&&(b=d),b.push(E(v=Dt,_i,Vh).call(v,x))}w(this,Ne,`${c.join(` `)}${n}${d.join(` `)}`),E(this,$t,qh).call(this);const p=new Range;let f=c.reduce((b,A)=>b+A.length,0);for(const{firstChild:b}of this.editorDiv.childNodes)if(b.nodeType===Node.TEXT_NODE){const A=b.nodeValue.length;if(f<=A){p.setStart(b,f),p.setEnd(b,f);break}f-=A}r.removeAllRanges(),r.addRange(p)}get contentDiv(){return this.editorDiv}static deserialize(t,s,i){var a;let n=null;if(t instanceof cf){const{data:{defaultAppearanceData:{fontSize:h,fontColor:l},rect:c,rotation:d,id:p},textContent:f,textPosition:g,parent:{page:{pageNumber:m}}}=t;if(!f||f.length===0)return null;n=t={annotationType:wt.FREETEXT,color:Array.from(l),fontSize:h,value:f.join(` `),position:g,pageIndex:m-1,rect:c.slice(0),rotation:d,id:p,deleted:!1}}const r=super.deserialize(t,s,i);return w(r,Be,t.fontSize),w(r,ls,at.makeHexColor(...t.color)),w(r,Ne,E(a=Dt,_i,Nc).call(a,t.value)),r.annotationElementId=t.id||null,w(r,Vr,n),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const s=Dt._internalPadding*this.parentScale,i=this.getRect(s,s),n=kt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:o(this,ls)),r={annotationType:wt.FREETEXT,color:n,fontSize:o(this,Be),value:E(this,$t,_f).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?r:this.annotationElementId&&!E(this,$t,vf).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(t){const s=super.renderAnnotationElement(t);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${o(this,Be)}px * var(--scale-factor))`,i.color=o(this,ls),s.replaceChildren();for(const r of o(this,Ne).split(` `)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}const n=Dt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(n,n),popupContent:o(this,Ne)}),s}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};jo=new WeakMap,Wo=new WeakMap,Go=new WeakMap,$o=new WeakMap,Vo=new WeakMap,ls=new WeakMap,Ne=new WeakMap,qo=new WeakMap,Be=new WeakMap,Vr=new WeakMap,$t=new WeakSet,gf=function(t){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-o(this,Be))*this.parentScale),w(this,Be,n),E(this,$t,$h).call(this)},i=o(this,Be);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},mf=function(t){const s=n=>{w(this,ls,this.editorDiv.style.color=n)},i=o(this,ls);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},bf=function(){var s;const t=[];this.editorDiv.normalize();for(const i of this.editorDiv.childNodes)t.push(E(s=Dt,_i,Vh).call(s,i));return t.join(` `)},$h=function(){const[t,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:r}=this,a=r.style.display,h=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",n.div.append(this.div),i=r.getBoundingClientRect(),r.remove(),r.style.display=a,r.classList.toggle("hidden",h)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/s):(this.width=i.height/t,this.height=i.width/s),this.fixAndSetPosition()},_i=new WeakSet,Vh=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Ph,"")},qh=function(){if(this.editorDiv.replaceChildren(),!!o(this,Ne))for(const t of o(this,Ne).split(` `)){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(s)}},_f=function(){return o(this,Ne).replaceAll(" "," ")},Nc=function(t){return t.replaceAll(" "," ")},vf=function(t){const{value:s,fontSize:i,color:n,pageIndex:r}=o(this,Vr);return this._hasBeenMoved||t.value!==s||t.fontSize!==i||t.color.some((a,h)=>a!==n[h])||t.pageIndex!==r},S(Dt,_i),ft(Dt,"_freeTextDefaultContent",""),ft(Dt,"_internalPadding",0),ft(Dt,"_defaultColor",null),ft(Dt,"_defaultFontSize",10),ft(Dt,"_type","freetext"),ft(Dt,"_editorType",wt.FREETEXT);let Oc=Dt;var Xo,Ni,cs,we,yf,Xh,Af,wf,zc;class Bc{constructor(e,t=0,s=0,i=!0){S(this,we);S(this,Xo);S(this,Ni,[]);S(this,cs,[]);let n=1/0,r=-1/0,a=1/0,h=-1/0;const c=10**-4;for(const{x:b,y:A,width:x,height:k}of e){const T=Math.floor((b-t)/c)*c,L=Math.ceil((b+x+t)/c)*c,I=Math.floor((A-t)/c)*c,B=Math.ceil((A+k+t)/c)*c,D=[T,I,B,!0],W=[L,I,B,!1];o(this,Ni).push(D,W),n=Math.min(n,T),r=Math.max(r,L),a=Math.min(a,I),h=Math.max(h,B)}const d=r-n+2*s,p=h-a+2*s,f=n-s,g=a-s,m=o(this,Ni).at(i?-1:-2),v=[m[0],m[2]];for(const b of o(this,Ni)){const[A,x,k]=b;b[0]=(A-f)/d,b[1]=(x-g)/p,b[2]=(k-g)/p}w(this,Xo,{x:f,y:g,width:d,height:p,lastPoint:v})}getOutlines(){o(this,Ni).sort((t,s)=>t[0]-s[0]||t[1]-s[1]||t[2]-s[2]);const e=[];for(const t of o(this,Ni))t[3]?(e.push(...E(this,we,zc).call(this,t)),E(this,we,Af).call(this,t)):(E(this,we,wf).call(this,t),e.push(...E(this,we,zc).call(this,t)));return E(this,we,yf).call(this,e)}}Xo=new WeakMap,Ni=new WeakMap,cs=new WeakMap,we=new WeakSet,yf=function(e){const t=[],s=new Set;for(const r of e){const[a,h,l]=r;t.push([a,h,r],[a,l,r])}t.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=t.length;r0;){const r=s.values().next().value;let[a,h,l,c,d]=r;s.delete(r);let p=a,f=h;for(n=[a,l],i.push(n);;){let g;if(s.has(c))g=c;else if(s.has(d))g=d;else break;s.delete(g),[a,h,l,c,d]=g,p!==a&&(n.push(p,f,a,f===h?h:l),p=a),f=f===h?l:h}n.push(p,f)}return new Pm(i,o(this,Xo))},Xh=function(e){const t=o(this,cs);let s=0,i=t.length-1;for(;s<=i;){const n=s+i>>1,r=t[n][0];if(r===e)return n;r=0;i--){const[n,r]=o(this,cs)[i];if(n!==e)break;if(n===e&&r===t){o(this,cs).splice(i,1);return}}},zc=function(e){const[t,s,i]=e,n=[[t,s,i]],r=E(this,we,Xh).call(this,i);for(let a=0;a=h){if(f>l)n[c][1]=l;else{if(d===1)return[];n.splice(c,1),c--,d--}continue}n[c][2]=h,f>l&&n.push([t,l,f])}}}return n};class Ef{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(e,t){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof Uc}}var Yo,qr;class Pm extends Ef{constructor(t,s){super();S(this,Yo);S(this,qr);w(this,qr,t),w(this,Yo,s)}toSVGPath(){const t=[];for(const s of o(this,qr)){let[i,n]=s;t.push(`M${i} ${n}`);for(let r=2;r=6;g-=6)isNaN(t[g])?f.push(`L${t[g+4]} ${t[g+5]}`):f.push(`C${t[g]} ${t[g+1]} ${t[g+2]} ${t[g+3]} ${t[g+4]} ${t[g+5]}`);return f.push(`L${t[4]} ${t[5]} Z`),f.join(" ")}getOutlines(){var b;const e=o(this,ks),t=o(this,ai),s=o(this,yt),i=s.subarray(4,6),n=s.subarray(16,18),[r,a,h,l]=o(this,Cs),c=new Float64Array((((b=o(this,Bi))==null?void 0:b.length)??0)+2);for(let A=0,x=c.length-2;A=6;A-=6)for(let x=0;x<6;x+=2){if(isNaN(t[A+x])){m[v]=m[v+1]=NaN,v+=2;continue}m[v]=t[A+x],m[v+1]=t[A+x+1],v+=2}return m.set([NaN,NaN,NaN,NaN,t[4],t[5]],v),new Uc(m,c,o(this,Cs),o(this,Kr),o(this,Xr),o(this,Yr))}};Cs=new WeakMap,ai=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,ks=new WeakMap,yt=new WeakMap,Dn=new WeakMap,On=new WeakMap,Ko=new WeakMap,Zo=new WeakMap,Kr=new WeakMap,Zr=new WeakMap,Bi=new WeakMap,Qo=new WeakMap,Cl=new WeakMap,kl=new WeakMap,Jo=new WeakSet,Hc=function(){const e=o(this,yt).subarray(4,6),t=o(this,yt).subarray(16,18),[s,i,n,r]=o(this,Cs);return[(o(this,Dn)+(e[0]-t[0])/2-s)/n,(o(this,On)+(e[1]-t[1])/2-i)/r,(o(this,Dn)+(t[0]-e[0])/2-s)/n,(o(this,On)+(t[1]-e[1])/2-i)/r]},S(js,Qo,8),S(js,Cl,2),S(js,kl,o(js,Qo)+o(js,Cl));let ol=js;var Qr,Nn,oi,th,ze,eh,Ut,Te,ka,Ta,Sf;class Uc extends Ef{constructor(t,s,i,n,r,a){super();S(this,Te);S(this,Qr);S(this,Nn,null);S(this,oi);S(this,th);S(this,ze);S(this,eh);S(this,Ut);w(this,Ut,t),w(this,ze,s),w(this,Qr,i),w(this,eh,n),w(this,oi,r),w(this,th,a),E(this,Te,Sf).call(this,a);const{x:h,y:l,width:c,height:d}=o(this,Nn);for(let p=0,f=t.length;p-1?(w(this,He,!0),E(this,bt,$c).call(this,t),E(this,bt,Ra).call(this)):(w(this,sa,t.anchorNode),w(this,oh,t.anchorOffset),w(this,hh,t.focusNode),w(this,lh,t.focusOffset),E(this,bt,Gc).call(this),E(this,bt,Ra).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=xt.prototype;return Et(this,"_keyboardManager",new _h([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:o(this,He)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:o(this,Ts),methodOfCreation:o(this,ch)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,s){var i;kt.initialize(t,s),xt._defaultColor||(xt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,s){switch(t){case ut.HIGHLIGHT_DEFAULT_COLOR:xt._defaultColor=s;break;case ut.HIGHLIGHT_THICKNESS:xt._defaultThickness=s;break}}translateInPage(t,s){}get toolbarPosition(){return o(this,na)}updateParams(t,s){switch(t){case ut.HIGHLIGHT_COLOR:E(this,bt,kf).call(this,s);break;case ut.HIGHLIGHT_THICKNESS:E(this,bt,Tf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[ut.HIGHLIGHT_DEFAULT_COLOR,xt._defaultColor],[ut.HIGHLIGHT_THICKNESS,xt._defaultThickness]]}get propertiesToUpdate(){return[[ut.HIGHLIGHT_COLOR,this.color||xt._defaultColor],[ut.HIGHLIGHT_THICKNESS,o(this,Ts)||xt._defaultThickness],[ut.HIGHLIGHT_FREE,o(this,He)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(w(this,ia,new hl({editor:this})),t.addColorPicker(o(this,ia))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(E(this,bt,Pa).call(this))}getBaseTranslation(){return[0,0]}getRect(t,s){return super.getRect(t,s,E(this,bt,Pa).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){E(this,bt,Vc).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(E(this,bt,Ra).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let s=!1;this.parent&&!t?E(this,bt,Vc).call(this):t&&(E(this,bt,Ra).call(this,t),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),s&&this.select()}rotate(t){var n,r,a;const{drawLayer:s}=this.parent;let i;o(this,He)?(t=(t-this.rotation+360)%360,i=E(n=xt,Qe,lr).call(n,o(this,fs).box,t)):i=E(r=xt,Qe,lr).call(r,this,t),s.rotate(o(this,_e),t),s.rotate(o(this,Kt),t),s.updateBox(o(this,_e),i),s.updateBox(o(this,Kt),E(a=xt,Qe,lr).call(a,o(this,Xe).box,t))}render(){if(this.div)return this.div;const t=super.render();o(this,ra)&&(t.setAttribute("aria-label",o(this,ra)),t.setAttribute("role","mark")),o(this,He)?t.classList.add("free"):this.div.addEventListener("keydown",o(this,Tl),{signal:this._uiManager._signal});const s=w(this,Hn,document.createElement("div"));t.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=o(this,zn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),nl(this,o(this,Hn),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(o(this,Kt),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(o(this,Kt),"hovered")}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:E(this,bt,Yh).call(this,!0);break;case 1:case 3:E(this,bt,Yh).call(this,!1);break}}select(){var t,s;super.select(),o(this,Kt)&&((t=this.parent)==null||t.drawLayer.removeClass(o(this,Kt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(o(this,Kt),"selected"))}unselect(){var t;super.unselect(),o(this,Kt)&&((t=this.parent)==null||t.drawLayer.removeClass(o(this,Kt),"selected"),o(this,He)||E(this,bt,Yh).call(this,!1))}get _mustFixPosition(){return!o(this,He)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(o(this,_e),t),this.parent.drawLayer.show(o(this,Kt),t))}static startHighlighting(t,s,{target:i,x:n,y:r}){const{x:a,y:h,width:l,height:c}=i.getBoundingClientRect(),d=v=>{E(this,Qe,Mf).call(this,t,v)},p=t._signal,f={capture:!0,passive:!1,signal:p},g=v=>{v.preventDefault(),v.stopPropagation()},m=v=>{i.removeEventListener("pointermove",d),window.removeEventListener("blur",m),window.removeEventListener("pointerup",m),window.removeEventListener("pointerdown",g,f),window.removeEventListener("contextmenu",Re),E(this,Qe,Ff).call(this,t,v)};window.addEventListener("blur",m,{signal:p}),window.addEventListener("pointerup",m,{signal:p}),window.addEventListener("pointerdown",g,f),window.addEventListener("contextmenu",Re,{signal:p}),i.addEventListener("pointermove",d,{signal:p}),this._freeHighlight=new ol({x:n,y:r},[a,h,l,c],t.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static deserialize(t,s,i){var m;const n=super.deserialize(t,s,i),{rect:[r,a,h,l],color:c,quadPoints:d}=t;n.color=at.makeHexColor(...c),w(n,Un,t.opacity);const[p,f]=n.pageDimensions;n.width=(h-r)/p,n.height=(l-a)/f;const g=w(n,zi,[]);for(let v=0;v=0)w(this,_e,s),w(this,zn,i),this.parent.drawLayer.finalizeLine(s,t),w(this,Kt,this.parent.drawLayer.highlightOutline(o(this,Xe)));else if(this.parent){const f=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(o(this,_e),t),this.parent.drawLayer.updateBox(o(this,_e),E(d=xt,Qe,lr).call(d,o(this,fs).box,(f-this.rotation+360)%360)),this.parent.drawLayer.updateLine(o(this,Kt),o(this,Xe)),this.parent.drawLayer.updateBox(o(this,Kt),E(p=xt,Qe,lr).call(p,o(this,Xe).box,f))}const{x:r,y:a,width:h,height:l}=t.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=h,this.height=l;break;case 90:{const[f,g]=this.parentDimensions;this.x=a,this.y=1-r,this.width=h*g/f,this.height=l*f/g;break}case 180:this.x=1-r,this.y=1-a,this.width=h,this.height=l;break;case 270:{const[f,g]=this.parentDimensions;this.x=1-a,this.y=r,this.width=h*g/f,this.height=l*f/g;break}}const{lastPoint:c}=o(this,Xe).box;w(this,na,[(c[0]-r)/h,(c[1]-a)/l])},kf=function(t){const s=n=>{var r,a;this.color=n,(r=this.parent)==null||r.drawLayer.changeColor(o(this,_e),n),(a=o(this,ia))==null||a.updateColor(n)},i=this.color;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},Tf=function(t){const s=o(this,Ts),i=n=>{w(this,Ts,n),E(this,bt,Rf).call(this,n)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},Rf=function(t){if(!o(this,He))return;E(this,bt,$c).call(this,{highlightOutlines:o(this,fs).getNewOutline(t/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Vc=function(){o(this,_e)===null||!this.parent||(this.parent.drawLayer.remove(o(this,_e)),w(this,_e,null),this.parent.drawLayer.remove(o(this,Kt)),w(this,Kt,null))},Ra=function(t=this.parent){o(this,_e)===null&&({id:Le(this,_e)._,clipPathId:Le(this,zn)._}=t.drawLayer.highlight(o(this,fs),this.color,o(this,Un)),w(this,Kt,t.drawLayer.highlightOutline(o(this,Xe))),o(this,Hn)&&(o(this,Hn).style.clipPath=o(this,zn)))},Qe=new WeakSet,lr=function({x:t,y:s,width:i,height:n},r){switch(r){case 90:return{x:1-s-n,y:t,width:n,height:i};case 180:return{x:1-t-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-t-i,width:n,height:i}}return{x:t,y:s,width:i,height:n}},Pf=function(t){xt._keyboardManager.exec(this,t)},Yh=function(t){if(!o(this,sa))return;const s=window.getSelection();t?s.setPosition(o(this,sa),o(this,oh)):s.setPosition(o(this,hh),o(this,lh))},Pa=function(){return o(this,He)?this.rotation:0},Lf=function(){if(o(this,He))return null;const[t,s]=this.pageDimensions,i=o(this,zi),n=new Float32Array(i.length*8);let r=0;for(const{x:a,y:h,width:l,height:c}of i){const d=a*t,p=(1-h-c)*s;n[r]=n[r+4]=d,n[r+1]=n[r+3]=p,n[r+2]=n[r+6]=d+l*t,n[r+5]=n[r+7]=p+c*s,r+=8}return n},If=function(t){return o(this,fs).serialize(t,E(this,bt,Pa).call(this))},Mf=function(t,s){this._freeHighlight.add(s)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Ff=function(t,s){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(this._freeHighlightId):t.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},S(xt,Qe),ft(xt,"_defaultColor",null),ft(xt,"_defaultOpacity",1),ft(xt,"_defaultThickness",12),ft(xt,"_l10nPromise"),ft(xt,"_type","highlight"),ft(xt,"_editorType",wt.HIGHLIGHT),ft(xt,"_freeHighlightId",-1),ft(xt,"_freeHighlight",null),ft(xt,"_freeHighlightClipId","");let ll=xt;var jn,Wn,dh,uh,fh,Gn,Rs,hi,Ye,$n,Vn,li,qn,Xn,Hi,et,Df,Of,Nf,Bf,Xc,zf,Yc,Hf,Uf,jf,Wf,Gf,Qi,Kc,Kh,Zh,cr,Zc,Qh,yi,$f,Qc,Vf,qf,Jc,Jh,La;const Nt=class Nt extends kt{constructor(t){super({...t,name:"inkEditor"});S(this,et);S(this,jn,0);S(this,Wn,0);S(this,dh,this.canvasPointermove.bind(this));S(this,uh,this.canvasPointerleave.bind(this));S(this,fh,this.canvasPointerup.bind(this));S(this,Gn,this.canvasPointerdown.bind(this));S(this,Rs,null);S(this,hi,new Path2D);S(this,Ye,!1);S(this,$n,!1);S(this,Vn,!1);S(this,li,null);S(this,qn,0);S(this,Xn,0);S(this,Hi,null);this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,s){kt.initialize(t,s)}static updateDefaultParams(t,s){switch(t){case ut.INK_THICKNESS:Nt._defaultThickness=s;break;case ut.INK_COLOR:Nt._defaultColor=s;break;case ut.INK_OPACITY:Nt._defaultOpacity=s/100;break}}updateParams(t,s){switch(t){case ut.INK_THICKNESS:E(this,et,Df).call(this,s);break;case ut.INK_COLOR:E(this,et,Of).call(this,s);break;case ut.INK_OPACITY:E(this,et,Nf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[ut.INK_THICKNESS,Nt._defaultThickness],[ut.INK_COLOR,Nt._defaultColor||kt._defaultLineColor],[ut.INK_OPACITY,Math.round(Nt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[ut.INK_THICKNESS,this.thickness||Nt._defaultThickness],[ut.INK_COLOR,this.color||Nt._defaultColor||kt._defaultLineColor],[ut.INK_OPACITY,Math.round(100*(this.opacity??Nt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(E(this,et,Kh).call(this),E(this,et,Zh).call(this)),this.isAttachedToDOM||(this.parent.add(this),E(this,et,cr).call(this)),E(this,et,La).call(this)))}remove(){var t;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,o(this,Rs)&&(clearTimeout(o(this,Rs)),w(this,Rs,null)),(t=o(this,li))==null||t.disconnect(),w(this,li,null),super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,s]=this.parentDimensions,i=this.width*t,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){o(this,Ye)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",o(this,Gn),{signal:this._uiManager._signal}))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",o(this,Gn)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){o(this,Ye)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),w(this,Ye,!0),this.div.classList.add("disabled"),E(this,et,La).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button!==0||!this.isInEditMode()||o(this,Ye)||(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),E(this,et,zf).call(this,t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),E(this,et,Yc).call(this,t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),E(this,et,Kc).call(this,t)}canvasPointerleave(t){E(this,et,Kc).call(this,t)}get isResizable(){return!this.isEmpty()&&o(this,Ye)}render(){if(this.div)return this.div;let t,s;this.width&&(t=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,r,a]=E(this,et,Bf).call(this);if(this.setAt(i,n,0,0),this.setDims(r,a),E(this,et,Kh).call(this),this.width){const[h,l]=this.parentDimensions;this.setAspectRatio(this.width*h,this.height*l),this.setAt(t*h,s*l,this.width*h,this.height*l),w(this,Vn,!0),E(this,et,cr).call(this),this.setDims(this.width*h,this.height*l),E(this,et,Qi).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return E(this,et,Zh).call(this),this.div}setDimensions(t,s){const i=Math.round(t),n=Math.round(s);if(o(this,qn)===i&&o(this,Xn)===n)return;w(this,qn,i),w(this,Xn,n),this.canvas.style.visibility="hidden";const[r,a]=this.parentDimensions;this.width=t/r,this.height=s/a,this.fixAndSetPosition(),o(this,Ye)&&E(this,et,Zc).call(this,t,s),E(this,et,cr).call(this),E(this,et,Qi).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(t,s,i){var v,b,A;if(t instanceof uf)return null;const n=super.deserialize(t,s,i);n.thickness=t.thickness,n.color=at.makeHexColor(...t.color),n.opacity=t.opacity;const[r,a]=n.pageDimensions,h=n.width*r,l=n.height*a,c=n.parentScale,d=t.thickness/2;w(n,Ye,!0),w(n,qn,Math.round(h)),w(n,Xn,Math.round(l));const{paths:p,rect:f,rotation:g}=t;for(let{bezier:x}of p){x=E(v=Nt,yi,Vf).call(v,x,f,g);const k=[];n.paths.push(k);let T=c*(x[0]-d),L=c*(x[1]-d);for(let B=2,D=x.length;B{this.thickness=n,E(this,et,La).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},Of=function(t){const s=n=>{this.color=n,E(this,et,Qi).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Nf=function(t){const s=n=>{this.opacity=n,E(this,et,Qi).call(this)};t/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ut.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Bf=function(){const{parentRotation:t,parentDimensions:[s,i]}=this;switch(t){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Xc=function(){const{ctx:t,color:s,opacity:i,thickness:n,parentScale:r,scaleFactor:a}=this;t.lineWidth=n*r/a,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${s}${tg(i)}`},zf=function(t,s){const i=this._uiManager._signal;this.canvas.addEventListener("contextmenu",Re,{signal:i}),this.canvas.addEventListener("pointerleave",o(this,uh),{signal:i}),this.canvas.addEventListener("pointermove",o(this,dh),{signal:i}),this.canvas.addEventListener("pointerup",o(this,fh),{signal:i}),this.canvas.removeEventListener("pointerdown",o(this,Gn)),this.isEditing=!0,o(this,Vn)||(w(this,Vn,!0),E(this,et,cr).call(this),this.thickness||(this.thickness=Nt._defaultThickness),this.color||(this.color=Nt._defaultColor||kt._defaultLineColor),this.opacity??(this.opacity=Nt._defaultOpacity)),this.currentPath.push([t,s]),w(this,$n,!1),E(this,et,Xc).call(this),w(this,Hi,()=>{E(this,et,jf).call(this),o(this,Hi)&&window.requestAnimationFrame(o(this,Hi))}),window.requestAnimationFrame(o(this,Hi))},Yc=function(t,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&s===n)return;const r=this.currentPath;let a=o(this,hi);if(r.push([t,s]),w(this,$n,!0),r.length<=2){a.moveTo(...r[0]),a.lineTo(t,s);return}r.length===3&&(w(this,hi,a=new Path2D),a.moveTo(...r[0])),E(this,et,Wf).call(this,a,...r.at(-3),...r.at(-2),t,s)},Hf=function(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);o(this,hi).lineTo(...t)},Uf=function(t,s){w(this,Hi,null),t=Math.min(Math.max(t,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),E(this,et,Yc).call(this,t,s),E(this,et,Hf).call(this);let i;if(this.currentPath.length!==1)i=E(this,et,Gf).call(this);else{const l=[t,s];i=[[l,l.slice(),l.slice(),l]]}const n=o(this,hi),r=this.currentPath;this.currentPath=[],w(this,hi,new Path2D);const a=()=>{this.allRawPaths.push(r),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},h=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(E(this,et,Kh).call(this),E(this,et,Zh).call(this)),E(this,et,La).call(this))};this.addCommands({cmd:a,undo:h,mustExec:!0})},jf=function(){if(!o(this,$n))return;w(this,$n,!1);const t=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(a=>a[0]),n=s.map(a=>a[1]);Math.min(...i)-t,Math.max(...i)+t,Math.min(...n)-t,Math.max(...n)+t;const{ctx:r}=this;r.save(),r.clearRect(0,0,this.canvas.width,this.canvas.height);for(const a of this.bezierPath2D)r.stroke(a);r.stroke(o(this,hi)),r.restore()},Wf=function(t,s,i,n,r,a,h){const l=(s+n)/2,c=(i+r)/2,d=(n+a)/2,p=(r+h)/2;t.bezierCurveTo(l+2*(n-l)/3,c+2*(r-c)/3,d+2*(n-d)/3,p+2*(r-p)/3,d,p)},Gf=function(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const s=[];let i,[n,r]=t[0];for(i=1;i{w(this,Rs,null),this.canvas.removeEventListener("contextmenu",Re)},10)),E(this,et,Uf).call(this,t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Kh=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Zh=function(){w(this,li,new ResizeObserver(t=>{const s=t[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),o(this,li).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=o(this,li))==null||t.disconnect(),w(this,li,null)},{once:!0})},cr=function(){if(!o(this,Vn))return;const[t,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*s),E(this,et,Qh).call(this)},Zc=function(t,s){const i=E(this,et,Jh).call(this),n=(t-i)/o(this,Wn),r=(s-i)/o(this,jn);this.scaleFactor=Math.min(n,r)},Qh=function(){const t=E(this,et,Jh).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)},yi=new WeakSet,$f=function(t){const s=new Path2D;for(let i=0,n=t.length;i`image/${s}`))}static get supportedTypesStr(){return Et(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,s){s.pasteEditor(wt.STAMP,{bitmapFile:t.getAsFile()})}remove(){var t,s;o(this,le)&&(w(this,he,null),this._uiManager.imageManager.deleteId(o(this,le)),(t=o(this,Ps))==null||t.remove(),w(this,Ps,null),(s=o(this,di))==null||s.disconnect(),w(this,di,null),o(this,Ls)&&(clearTimeout(o(this,Ls)),w(this,Ls,null))),super.remove()}rebuild(){if(!this.parent){o(this,le)&&E(this,St,tl).call(this);return}super.rebuild(),this.div!==null&&(o(this,le)&&o(this,Ps)===null&&E(this,St,tl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(o(this,Ui)||o(this,he)||o(this,ci)||o(this,ji)||o(this,le))}get isResizable(){return!0}render(){if(this.div)return this.div;let t,s;if(this.width&&(t=this.x,s=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),o(this,he)?E(this,St,ed).call(this):E(this,St,tl).call(this),this.width){const[i,n]=this.parentDimensions;this.setAt(t*i,s*n,this.width*i,this.height*n)}return this.div}getImageForAltText(){return o(this,Ps)}static deserialize(t,s,i){if(t instanceof ff)return null;const n=super.deserialize(t,s,i),{rect:r,bitmapUrl:a,bitmapId:h,isSvg:l,accessibilityData:c}=t;h&&i.imageManager.isValidId(h)?w(n,le,h):w(n,ci,a),w(n,ps,l);const[d,p]=n.pageDimensions;return n.width=(r[2]-r[0])/d,n.height=(r[3]-r[1])/p,c&&(n.altTextData=c),n}serialize(t=!1,s=null){if(this.isEmpty())return null;const i={annotationType:wt.STAMP,bitmapId:o(this,le),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:o(this,ps),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=E(this,St,el).call(this,!0),i.accessibilityData=this.altTextData,i;const{decorative:n,altText:r}=this.altTextData;if(!n&&r&&(i.accessibilityData={type:"Figure",alt:r}),s===null)return i;s.stamps||(s.stamps=new Map);const a=o(this,ps)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(o(this,le)))s.stamps.set(o(this,le),{area:a,serialized:i}),i.bitmap=E(this,St,el).call(this,!1);else if(o(this,ps)){const h=s.stamps.get(o(this,le));a>h.area&&(h.area=a,h.serialized.bitmap.close(),h.serialized.bitmap=E(this,St,el).call(this,!1))}return i}};he=new WeakMap,le=new WeakMap,Ui=new WeakMap,ci=new WeakMap,ji=new WeakMap,aa=new WeakMap,Ps=new WeakMap,di=new WeakMap,Ls=new WeakMap,ps=new WeakMap,ph=new WeakMap,St=new WeakSet,Ia=function(t,s=!1){if(!t){this.remove();return}w(this,he,t.bitmap),s||(w(this,le,t.id),w(this,ps,t.isSvg)),t.file&&w(this,aa,t.file.name),E(this,St,ed).call(this)},Ma=function(){w(this,Ui,null),this._uiManager.enableWaiting(!1),o(this,Ps)&&this.div.focus()},tl=function(){if(o(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(o(this,le)).then(i=>E(this,St,Ia).call(this,i,!0)).finally(()=>E(this,St,Ma).call(this));return}if(o(this,ci)){const i=o(this,ci);w(this,ci,null),this._uiManager.enableWaiting(!0),w(this,Ui,this._uiManager.imageManager.getFromUrl(i).then(n=>E(this,St,Ia).call(this,n)).finally(()=>E(this,St,Ma).call(this)));return}if(o(this,ji)){const i=o(this,ji);w(this,ji,null),this._uiManager.enableWaiting(!0),w(this,Ui,this._uiManager.imageManager.getFromFile(i).then(n=>E(this,St,Ia).call(this,n)).finally(()=>E(this,St,Ma).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=Oa.supportedTypesStr;const s=this._uiManager._signal;w(this,Ui,new Promise(i=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(t.files[0]);E(this,St,Ia).call(this,n)}i()},{signal:s}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>E(this,St,Ma).call(this))),t.click()},ed=function(){const{div:t}=this;let{width:s,height:i}=o(this,he);const[n,r]=this.pageDimensions,a=.75;if(this.width)s=this.width*n,i=this.height*r;else if(s>a*n||i>a*r){const d=Math.min(a*n/s,a*r/i);s*=d,i*=d}const[h,l]=this.parentDimensions;this.setDims(s*h/n,i*l/r),this._uiManager.enableWaiting(!1);const c=w(this,Ps,document.createElement("canvas"));t.append(c),t.hidden=!1,E(this,St,sd).call(this,s,i),E(this,St,Kf).call(this),o(this,ph)||(this.parent.addUndoableEditor(this),w(this,ph,!0)),this._reportTelemetry({action:"inserted_image"}),o(this,aa)&&c.setAttribute("aria-label",o(this,aa))},Xf=function(t,s){var a;const[i,n]=this.parentDimensions;this.width=t/i,this.height=s/n,this.setDims(t,s),(a=this._initialOptions)!=null&&a.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,o(this,Ls)!==null&&clearTimeout(o(this,Ls)),w(this,Ls,setTimeout(()=>{w(this,Ls,null),E(this,St,sd).call(this,t,s)},200))},Yf=function(t,s){const{width:i,height:n}=o(this,he);let r=i,a=n,h=o(this,he);for(;r>2*t||a>2*s;){const l=r,c=a;r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),a>2*s&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const d=new OffscreenCanvas(r,a);d.getContext("2d").drawImage(h,0,0,l,c,0,0,r,a),h=d.transferToImageBitmap()}return h},sd=function(t,s){t=Math.ceil(t),s=Math.ceil(s);const i=o(this,Ps);if(!i||i.width===t&&i.height===s)return;i.width=t,i.height=s;const n=o(this,ps)?o(this,he):E(this,St,Yf).call(this,t,s);if(this._uiManager.hasMLManager&&!this.hasAltText()){const h=new OffscreenCanvas(t,s).getContext("2d");h.drawImage(n,0,0,n.width,n.height,0,0,t,s),this._uiManager.mlGuess({service:"image-to-text",request:{data:h.getImageData(0,0,t,s).data,width:t,height:s,channels:4}}).then(l=>{const c=(l==null?void 0:l.output)||"";this.parent&&c&&!this.hasAltText()&&(this.altTextData={altText:c,decorative:!1})})}const r=i.getContext("2d");r.filter=this._uiManager.hcmFilter,r.drawImage(n,0,0,n.width,n.height,0,0,t,s)},el=function(t){if(t){if(o(this,ps)){const n=this._uiManager.imageManager.getSvgUrl(o(this,le));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=o(this,he),s.getContext("2d").drawImage(o(this,he),0,0),s.toDataURL()}if(o(this,ps)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Vi.PDF_TO_CSS_UNITS),r=Math.round(this.height*i*Vi.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(n,r);return a.getContext("2d").drawImage(o(this,he),0,0,o(this,he).width,o(this,he).height,0,0,n,r),a.transferToImageBitmap()}return structuredClone(o(this,he))},Kf=function(){this._uiManager._signal&&(w(this,di,new ResizeObserver(t=>{const s=t[0].contentRect;s.width&&s.height&&E(this,St,Xf).call(this,s.width,s.height)})),o(this,di).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=o(this,di))==null||t.disconnect(),w(this,di,null)},{once:!0}))},ft(Oa,"_type","stamp"),ft(Oa,"_editorType",wt.STAMP);let td=Oa;var Yn,oa,Is,Kn,ui,fi,pi,Ue,Wi,ha,la,ve,ot,Gi,ce,Zf,nd,rd,ad,sl;const ts=class ts{constructor({uiManager:e,pageIndex:t,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:r,textLayer:a,viewport:h,l10n:l}){S(this,ce);S(this,Yn);S(this,oa,!1);S(this,Is,null);S(this,Kn,null);S(this,ui,null);S(this,fi,null);S(this,pi,null);S(this,Ue,new Map);S(this,Wi,!1);S(this,ha,!1);S(this,la,!1);S(this,ve,null);S(this,ot);const c=[...o(ts,Gi).values()];if(!ts._initialized){ts._initialized=!0;for(const d of c)d.initialize(l,e)}e.registerEditorTypes(c),w(this,ot,e),this.pageIndex=t,this.div=s,w(this,Yn,i),w(this,Is,n),this.viewport=h,w(this,ve,a),this.drawLayer=r,o(this,ot).addLayer(this)}get isEmpty(){return o(this,Ue).size===0}get isInvisible(){return this.isEmpty&&o(this,ot).getMode()===wt.NONE}updateToolbar(e){o(this,ot).updateToolbar(e)}updateMode(e=o(this,ot).getMode()){switch(E(this,ce,sl).call(this),e){case wt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case wt.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case wt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const s of o(ts,Gi).values())t.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=o(this,ve))==null?void 0:t.div)}addInkEditorIfNeeded(e){if(o(this,ot).getMode()!==wt.INK)return;if(!e){for(const s of o(this,Ue).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(e){o(this,ot).setEditingState(e)}addCommands(e){o(this,ot).addCommands(e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=o(this,Is))==null||t.div.classList.toggle("disabled",!e)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const s of o(this,Ue).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(o(this,ot).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));if(!o(this,Is))return;const t=o(this,Is).getEditableAnnotations();for(const s of t){if(s.hide(),o(this,ot).isDeletedAnnotationElement(s.data.id)||e.has(s.data.id))continue;const i=this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;w(this,la,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const n of o(this,Ue).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){e.set(n.annotationElementId,n);continue}else t.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(o(this,Is)){const n=o(this,Is).getEditableAnnotations();for(const r of n){const{id:a}=r.data;if(o(this,ot).isDeletedAnnotationElement(a))continue;let h=t.get(a);if(h){h.resetAnnotationElement(r),h.show(!1),r.show();continue}h=e.get(a),h&&(o(this,ot).addChangedExistingAnnotation(h),h.renderAnnotationElement(r),h.show(!1)),r.show()}}E(this,ce,sl).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of o(ts,Gi).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),w(this,la,!1)}getEditableAnnotation(e){var t;return((t=o(this,Is))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){o(this,ot).getActive()!==e&&o(this,ot).setActiveEditor(e)}enableTextSelection(){var e;this.div.tabIndex=-1,(e=o(this,ve))!=null&&e.div&&!o(this,fi)&&(w(this,fi,E(this,ce,Zf).bind(this)),o(this,ve).div.addEventListener("pointerdown",o(this,fi),{signal:o(this,ot)._signal}),o(this,ve).div.classList.add("highlighting"))}disableTextSelection(){var e;this.div.tabIndex=0,(e=o(this,ve))!=null&&e.div&&o(this,fi)&&(o(this,ve).div.removeEventListener("pointerdown",o(this,fi)),w(this,fi,null),o(this,ve).div.classList.remove("highlighting"))}enableClick(){if(o(this,ui))return;const e=o(this,ot)._signal;w(this,ui,this.pointerdown.bind(this)),w(this,Kn,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",o(this,ui),{signal:e}),this.div.addEventListener("pointerup",o(this,Kn),{signal:e})}disableClick(){o(this,ui)&&(this.div.removeEventListener("pointerdown",o(this,ui)),this.div.removeEventListener("pointerup",o(this,Kn)),w(this,ui,null),w(this,Kn,null))}attach(e){o(this,Ue).set(e.id,e);const{annotationElementId:t}=e;t&&o(this,ot).isDeletedAnnotationElement(t)&&o(this,ot).removeDeletedAnnotationElement(e)}detach(e){var t;o(this,Ue).delete(e.id),(t=o(this,Yn))==null||t.removePointerInTextLayer(e.contentDiv),!o(this,la)&&e.annotationElementId&&o(this,ot).addDeletedAnnotationElement(e)}remove(e){this.detach(e),o(this,ot).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,o(this,ha)||this.addInkEditorIfNeeded(!1)}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(o(this,ot).addDeletedAnnotationElement(e.annotationElementId),kt.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),o(this,ot).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),o(this,ot).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var s;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!o(this,pi)&&(e._focusEventsAllowed=!1,w(this,pi,setTimeout(()=>{w(this,pi,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:o(this,ot)._signal}),t.focus())},0))),e._structTreeParentId=(s=o(this,Yn))==null?void 0:s.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){const t=()=>e._uiManager.rebuild(e),s=()=>{e.remove()};this.addCommands({cmd:t,undo:s,mustExec:!1})}getNextId(){return o(this,ot).getId()}get _signal(){return o(this,ot)._signal}canCreateNewEmptyEditor(){var e;return(e=o(this,ce,nd))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){o(this,ot).updateToolbar(e),o(this,ot).updateMode(e);const{offsetX:s,offsetY:i}=E(this,ce,ad).call(this),n=this.getNextId(),r=E(this,ce,rd).call(this,{parent:this,id:n,x:s,y:i,uiManager:o(this,ot),isCentered:!0,...t});r&&this.add(r)}deserialize(e){var t;return((t=o(ts,Gi).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,o(this,ot)))||null}createAndAddNewEditor(e,t,s={}){const i=this.getNextId(),n=E(this,ce,rd).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:o(this,ot),isCentered:t,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(E(this,ce,ad).call(this),!0)}setSelected(e){o(this,ot).setSelected(e)}toggleSelected(e){o(this,ot).toggleSelected(e)}isSelected(e){return o(this,ot).isSelected(e)}unselect(e){o(this,ot).unselect(e)}pointerup(e){const{isMac:t}=ke.platform;if(!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&o(this,Wi)){if(w(this,Wi,!1),!o(this,oa)){w(this,oa,!0);return}if(o(this,ot).getMode()===wt.STAMP){o(this,ot).unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(o(this,ot).getMode()===wt.HIGHLIGHT&&this.enableTextSelection(),o(this,Wi)){w(this,Wi,!1);return}const{isMac:t}=ke.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;w(this,Wi,!0);const s=o(this,ot).getActive();w(this,oa,!s||s.isEmpty())}findNewParent(e,t,s){const i=o(this,ot).findParent(t,s);return i===null||i===this?!1:(i.changeParent(e),!0)}destroy(){var e,t;((e=o(this,ot).getActive())==null?void 0:e.parent)===this&&(o(this,ot).commitOrRemove(),o(this,ot).setActiveEditor(null)),o(this,pi)&&(clearTimeout(o(this,pi)),w(this,pi,null));for(const s of o(this,Ue).values())(t=o(this,Yn))==null||t.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,o(this,Ue).clear(),o(this,ot).removeLayer(this)}render({viewport:e}){this.viewport=e,Zn(this.div,e);for(const t of o(this,ot).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){o(this,ot).commitOrRemove(),E(this,ce,sl).call(this);const t=this.viewport.rotation,s=e.rotation;if(this.viewport=e,Zn(this.div,{rotation:s}),t!==s)for(const i of o(this,Ue).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return o(this,ot).viewParameters.realScale}};Yn=new WeakMap,oa=new WeakMap,Is=new WeakMap,Kn=new WeakMap,ui=new WeakMap,fi=new WeakMap,pi=new WeakMap,Ue=new WeakMap,Wi=new WeakMap,ha=new WeakMap,la=new WeakMap,ve=new WeakMap,ot=new WeakMap,Gi=new WeakMap,ce=new WeakSet,Zf=function(e){if(o(this,ot).unselectAll(),e.target===o(this,ve).div){const{isMac:t}=ke.platform;if(e.button!==0||e.ctrlKey&&t)return;o(this,ot).showAllEditors("highlight",!0,!0),o(this,ve).div.classList.add("free"),ll.startHighlighting(this,o(this,ot).direction==="ltr",e),o(this,ve).div.addEventListener("pointerup",()=>{o(this,ve).div.classList.remove("free")},{once:!0,signal:o(this,ot)._signal}),e.preventDefault()}},nd=function(){return o(ts,Gi).get(o(this,ot).getMode())},rd=function(e){const t=o(this,ce,nd);return t?new t.prototype.constructor(e):null},ad=function(){const{x:e,y:t,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,e),r=Math.max(0,t),a=Math.min(window.innerWidth,e+s),h=Math.min(window.innerHeight,t+i),l=(n+a)/2-e,c=(r+h)/2-t,[d,p]=this.viewport.rotation%180===0?[l,c]:[c,l];return{offsetX:d,offsetY:p}},sl=function(){w(this,ha,!0);for(const e of o(this,Ue).values())e.isEmpty()&&e.remove();w(this,ha,!1)},ft(ts,"_initialized",!1),S(ts,Gi,new Map([Oc,qc,td,ll].map(e=>[e._editorType,e])));let id=ts;var Ms,gh,Zt,$i,mh,hd,er,ld,Qf;const ie=class ie{constructor({pageIndex:e}){S(this,er);S(this,Ms,null);S(this,gh,0);S(this,Zt,new Map);S(this,$i,new Map);this.pageIndex=e}setParent(e){if(!o(this,Ms)){w(this,Ms,e);return}if(o(this,Ms)!==e){if(o(this,Zt).size>0)for(const t of o(this,Zt).values())t.remove(),e.append(t);w(this,Ms,e)}}static get _svgFactory(){return Et(this,"_svgFactory",new ud)}highlight(e,t,s,i=!1){const n=Le(this,gh)._++,r=E(this,er,ld).call(this,e.box);r.classList.add("highlight"),e.free&&r.classList.add("free");const a=ie._svgFactory.createElement("defs");r.append(a);const h=ie._svgFactory.createElement("path");a.append(h);const l=`path_p${this.pageIndex}_${n}`;h.setAttribute("id",l),h.setAttribute("d",e.toSVGPath()),i&&o(this,$i).set(n,h);const c=E(this,er,Qf).call(this,a,l),d=ie._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",t),r.setAttribute("fill-opacity",s),d.setAttribute("href",`#${l}`),o(this,Zt).set(n,r),{id:n,clipPathId:`url(#${c})`}}highlightOutline(e){const t=Le(this,gh)._++,s=E(this,er,ld).call(this,e.box);s.classList.add("highlightOutline");const i=ie._svgFactory.createElement("defs");s.append(i);const n=ie._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${t}`;n.setAttribute("id",r),n.setAttribute("d",e.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let a;if(e.free){s.classList.add("free");const c=ie._svgFactory.createElement("mask");i.append(c),a=`mask_p${this.pageIndex}_${t}`,c.setAttribute("id",a),c.setAttribute("maskUnits","objectBoundingBox");const d=ie._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const p=ie._svgFactory.createElement("use");c.append(p),p.setAttribute("href",`#${r}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const h=ie._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${r}`),a&&h.setAttribute("mask",`url(#${a})`);const l=h.cloneNode();return s.append(l),h.classList.add("mainOutline"),l.classList.add("secondaryOutline"),o(this,Zt).set(t,s),t}finalizeLine(e,t){const s=o(this,$i).get(e);o(this,$i).delete(e),this.updateBox(e,t.box),s.setAttribute("d",t.toSVGPath())}updateLine(e,t){o(this,Zt).get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}removeFreeHighlight(e){this.remove(e),o(this,$i).delete(e)}updatePath(e,t){o(this,$i).get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){var s;E(s=ie,mh,hd).call(s,o(this,Zt).get(e),t)}show(e,t){o(this,Zt).get(e).classList.toggle("hidden",!t)}rotate(e,t){o(this,Zt).get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){o(this,Zt).get(e).setAttribute("fill",t)}changeOpacity(e,t){o(this,Zt).get(e).setAttribute("fill-opacity",t)}addClass(e,t){o(this,Zt).get(e).classList.add(t)}removeClass(e,t){o(this,Zt).get(e).classList.remove(t)}remove(e){o(this,Ms)!==null&&(o(this,Zt).get(e).remove(),o(this,Zt).delete(e))}destroy(){w(this,Ms,null);for(const e of o(this,Zt).values())e.remove();o(this,Zt).clear()}};Ms=new WeakMap,gh=new WeakMap,Zt=new WeakMap,$i=new WeakMap,mh=new WeakSet,hd=function(e,{x:t=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=e;r.top=`${100*s}%`,r.left=`${100*t}%`,r.width=`${100*i}%`,r.height=`${100*n}%`},er=new WeakSet,ld=function(e){var s;const t=ie._svgFactory.create(1,1,!0);return o(this,Ms).append(t),t.setAttribute("aria-hidden",!0),E(s=ie,mh,hd).call(s,t,e),t},Qf=function(e,t){const s=ie._svgFactory.createElement("clipPath");e.append(s);const i=`clip_${t}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=ie._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${t}`),n.classList.add("clip"),i},S(ie,mh);let od=ie;ct.AbortException;ct.AnnotationEditorLayer;ct.AnnotationEditorParamsType;ct.AnnotationEditorType;ct.AnnotationEditorUIManager;ct.AnnotationLayer;ct.AnnotationMode;ct.CMapCompressionType;ct.ColorPicker;ct.DOMSVGFactory;ct.DrawLayer;ct.FeatureTest;var Lm=ct.GlobalWorkerOptions;ct.ImageKind;ct.InvalidPDFException;ct.MissingPDFException;ct.OPS;ct.Outliner;ct.PDFDataRangeTransport;ct.PDFDateString;ct.PDFWorker;ct.PasswordResponses;ct.PermissionFlag;ct.PixelsPerInch;ct.RenderingCancelledException;ct.TextLayer;ct.UnexpectedResponseException;ct.Util;ct.VerbosityLevel;ct.XfaLayer;ct.build;ct.createValidAbsoluteUrl;ct.fetchData;ct.getDocument;ct.getFilenameFromUrl;ct.getPdfFilenameFromUrl;ct.getXfaPageViewport;ct.isDataScheme;ct.isPdfFile;ct.noContextMenu;ct.normalizeUnicode;ct.renderTextLayer;ct.setLayerDimensions;ct.shadow;ct.updateTextLayer;ct.version;const Im="/assets/pdf.worker.min-DGf6LXVo.mjs";Lm.workerSrc=Im;const Mm={class:"train-container w-screen h-screen bg-slate-50 flex flex-col items-center"},Fm={class:"list-container container grow relative"},Dm={class:"list-content absolute top-0 bottom-0 left-0 right-0 py-4"},Om={class:"list-wrapper w-full h-full"},Nm={class:"card-wrapper w-full h-full flex flex-col px-8 box-border"},Bm={class:"card-header flex justify-between items-center shrink-0"},zm={class:"header-search flex items-center"},Hm={class:"card-main flex-1 my-5 relative"},Um={class:"main-content absolute top-0 bottom-0 left-0 right-0"},jm={class:"row-info"},Wm={class:"icon"},Gm=["src"],$m={class:"label"},Vm={class:"card-footer flex justify-center mb-7 shrink-0"},qm={class:"image-container"},Xm={key:0,class:"video-container"},Ym={class:"close-btn"},Km={__name:"index",setup(u){const e=np(),{userInfo:t}=rp(e),{status:s,message:i,error:n,connect:r,disconnect:a,sendMessage:h}=Ep({url:"wss://42.193.1.25:8000/websocket/"+t.value.id,heartBeatData:"ping"}),l=Vt(null),c={img:{iconPath:"/static/icons/file_type_image.png",handle:M=>{v.value=!0,A.value=["/api/files/"+M.contentUrl.url],H()}},video:{iconPath:"/static/icons/file_type_video.png",handle:M=>{b.value=!0,k.value=["/api/files/"+M.contentUrl.url],H()}},pdf:{iconPath:"/static/icons/file_type_pdf.png",handle:M=>{m.value=!0,x.value="/api/files/"+M.contentUrl.url,H()}},word:{iconPath:"/static/icons/file_type_word.png",handle:M=>{m.value=!0,x.value="/api/files/"+M.contentUrl.url,H()}},ppt:{iconPath:"/static/icons/file_type_ppt.png",handle:M=>{m.value=!0,x.value="/api/files/"+M.contentUrl.url,H()}},audio:{iconPath:"/static/icons/file_type_audio.png",handle:M=>{console.log(M),b.value=!0,k.value="/api/files/"+M.contentUrl.url,H()}},excel:{iconPath:"/static/icons/file_type_excel.png",handle:M=>{console.log(M),m.value=!0,x.value="/api/files/"+M.contentUrl.url,H()}}},d=Vt(""),p=Vt(""),f=Vt(""),g=Vt(!1),m=Vt(!1),v=Vt(!1),b=Vt(!1),A=Vt([]),x=Vt(""),k=Vt(""),T=Vt([]),L=Vt([]),I=Vt([{name:"视频",value:"video"},{name:"图片",value:"img"},{name:"音频",value:"audio"},{name:"PDF",value:"pdf"},{name:"EXCEL",value:"excel"},{name:"WORD",value:"word"},{name:"PPT",value:"ppt"}]),B=Vt(1),D=Vt(10),W=Vt(0);Vt(!1);const q=M=>{c[M.contentType]&&c[M.contentType].handle(M)},P=()=>{m.value=!1,v.value=!1,b.value=!1,clearInterval(l.value)},z=()=>{g.value=!0,Sp({introduction:d.value,subjectId:p.value,contentType:f.value,pageSize:D.value,pageNum:B.value}).then(M=>{g.value=!1,T.value=M.data,W.value=M.total}).catch(()=>{g.value=!1})};z(),(()=>{g.value=!0,xp().then(M=>{g.value=!1,L.value=M.data}).catch(()=>{g.value=!1})})();const H=()=>{l.value&&clearInterval(l.value),h({id:t.value.id,command:"recordStudyTime"}),l.value=setInterval(()=>{h({id:t.value.id,command:"recordStudyTime"})},5e3)},rt=M=>{if(c[M])return c[M].iconPath},U=M=>{B.value=1,D.value=M,z()},Q=M=>{B.value=M,z()},X=()=>{z()},ht=M=>{window.open(M.visitUrl,"_blank")};return Jd(()=>{r()}),tu(()=>{clearInterval(l.value)}),(M,O)=>{const st=pp,J=gp,Y=mp,_t=hp,pt=bp,dt=_p,vt=vp,Wt=lp,Ot=cp,We=yp,Pe=Ap;return bs(),_a("div",Mm,[ee(wp,{class:"shrink-0"}),se("div",Fm,[se("div",Dm,[se("div",Om,[ee(Wt,{class:"h-full","body-style":{height:"100%"}},{default:Je(()=>[se("div",Nm,[se("div",Bm,[se("div",zm,[ee(st,{modelValue:d.value,"onUpdate:modelValue":O[0]||(O[0]=_=>d.value=_),placeholder:"请输入搜索内容",class:"long-input","prefix-icon":Td(dp)},null,8,["modelValue","prefix-icon"]),ee(Y,{modelValue:p.value,"onUpdate:modelValue":O[1]||(O[1]=_=>p.value=_),placeholder:"请选择科目",class:"ml-4 long-select",clearable:""},{default:Je(()=>[(bs(!0),_a(Rd,null,Pd(L.value,_=>(bs(),pa(J,{key:_.id,label:_.name,value:_.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),ee(Y,{modelValue:f.value,"onUpdate:modelValue":O[2]||(O[2]=_=>f.value=_),placeholder:"请选择文件类型",class:"ml-4 long-select",clearable:""},{default:Je(()=>[(bs(!0),_a(Rd,null,Pd(I.value,_=>(bs(),pa(J,{key:_.value,label:_.name,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),ee(_t,{type:"primary",class:"ml-4",onClick:X},{default:Je(()=>[Ul("搜索")]),_:1})])]),se("div",Hm,[se("div",Um,[kd((bs(),pa(dt,{data:T.value,height:"100%"},{default:Je(()=>[ee(pt,{label:"文件名称"},{default:Je(_=>[se("div",jm,[se("div",Wm,[se("img",{src:rt(_.row.contentType),class:"width-img"},null,8,Gm)]),se("div",$m,up(_.row.introduction),1)])]),_:1}),ee(pt,{prop:"className",label:"班级",align:"center"}),ee(pt,{prop:"typeName",label:"科目",align:"center"}),ee(pt,{prop:"updateTime",label:"上传时间",align:"center"}),ee(pt,null,{default:Je(_=>[_.row.contentType=="video"||_.row.contentType=="audio"?(bs(),pa(_t,{key:0,link:"",type:"primary",onClick:Ld(G=>q(_.row),["prevent"])},{default:Je(()=>[Ul(" 查看 ")]),_:2},1032,["onClick"])):(bs(),pa(_t,{key:1,link:"",type:"primary",onClick:Ld(G=>ht(_.row),["prevent"])},{default:Je(()=>[Ul(" 下载 ")]),_:2},1032,["onClick"]))]),_:1})]),_:1},8,["data"])),[[Pe,g.value]])])]),se("div",Vm,[ee(vt,{background:"",layout:"total, sizes, prev, pager, next, jumper",total:W.value,"page-sizes":[10,20,50],"page-size":D.value,currentPage:B.value,onSizeChange:U,onCurrentChange:Q},null,8,["total","page-size","currentPage"])])])]),_:1})])])]),kd(se("div",qm,[ee(Ot,{"url-list":A.value,onClose:P},null,8,["url-list"])],512),[[ap,v.value]]),b.value?(bs(),_a("div",Xm,[ee(Pp,{videoUrl:k.value},null,8,["videoUrl"]),se("div",Ym,[ee(_t,{type:"danger",size:"large",circle:"",onClick:P},{icon:Je(()=>[ee(We,{size:20},{default:Je(()=>[ee(Td(fp))]),_:1})]),_:1})])])):op("",!0)])}}},db=Qd(Km,[["__scopeId","data-v-e74fc686"]]);export{db as default};