@mlightcad/cad-simple-viewer-cli 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-runner/assets/cad-html-plugin-DMBhuyxU.js +699 -0
- package/dist-runner/assets/{cad-pdf-plugin-Dy_9cUDz.js → cad-pdf-plugin-D1C1ESem.js} +2 -2
- package/dist-runner/assets/{cad-svg-plugin-H_1erBTJ.js → cad-svg-plugin-BA-XSK8e.js} +6 -6
- package/dist-runner/assets/{index-DBlYvCOi.js → index-4dCU3rib.js} +402 -247
- package/dist-runner/index.html +1 -1
- package/dist-runner/viewer-runtime.iife.js +373 -155
- package/dist-runner/workers/libredwg-parser-worker.js +1 -1
- package/examples/export-html.scr +2 -1
- package/package.json +7 -7
- package/dist-runner/assets/cad-html-plugin-gRQM9D29.js +0 -477
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as nR,j as ZM,x as sR,a8 as AR,a9 as AB,X as aR,aa as p3,z as oR,ab as lR}from"./index-4dCU3rib.js";import{ac as bZ,ad as BZ}from"./index-4dCU3rib.js";import{AcSvgRenderer as g3}from"./cad-svg-plugin-BA-XSK8e.js";var hR=Object.defineProperty,JM=i=>{throw TypeError(i)},cR=(i,t,e)=>t in i?hR(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ut=(i,t,e)=>cR(i,typeof t!="symbol"?t+"":t,e),FS=(i,t,e)=>t.has(i)||JM("Cannot "+e),c=(i,t,e)=>(FS(i,t,"read from private field"),e?e.call(i):t.get(i)),U=(i,t,e)=>t.has(i)?JM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),F=(i,t,e,r)=>(FS(i,t,"write to private field"),t.set(i,e),e),_=(i,t,e)=>(FS(i,t,"access private method"),e),$i=(i,t,e,r)=>({set _(n){F(i,t,n)},get _(){return c(i,t,r)}});function Ze(i){"@babel/helpers - typeof";return Ze=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ze(i)}var da=Uint8Array,_A=Uint16Array,SS=Int32Array,ES=new da([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),kS=new da([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),m3=new da([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),tT=function(i,t){for(var e=new _A(31),r=0;r<31;++r)e[r]=t+=1<<i[r-1];for(var n=new SS(e[30]),r=1;r<30;++r)for(var s=e[r];s<e[r+1];++s)n[s]=s-e[r]<<5|r;return{b:e,r:n}},eT=tT(ES,2),uR=eT.b,Xx=eT.r;uR[28]=258,Xx[258]=28;var dR=tT(kS,0),w3=dR.r,rT=new _A(32768);for(var Tr=0;Tr<32768;++Tr){var Dl=(Tr&43690)>>1|(Tr&21845)<<1;Dl=(Dl&52428)>>2|(Dl&13107)<<2,Dl=(Dl&61680)>>4|(Dl&3855)<<4,rT[Tr]=((Dl&65280)>>8|(Dl&255)<<8)>>1}var Wm=(function(i,t,e){for(var r=i.length,n=0,s=new _A(t);n<r;++n)i[n]&&++s[i[n]-1];var A=new _A(t);for(n=1;n<t;++n)A[n]=A[n-1]+s[n-1]<<1;var a;for(a=new _A(r),n=0;n<r;++n)i[n]&&(a[n]=rT[A[i[n]-1]++]>>15-i[n]);return a}),_u=new da(288);for(var Tr=0;Tr<144;++Tr)_u[Tr]=8;for(var Tr=144;Tr<256;++Tr)_u[Tr]=9;for(var Tr=256;Tr<280;++Tr)_u[Tr]=7;for(var Tr=280;Tr<288;++Tr)_u[Tr]=8;var bv=new da(32);for(var Tr=0;Tr<32;++Tr)bv[Tr]=5;var fR=Wm(_u,9),pR=Wm(bv,5),iT=function(i){return(i+7)/8|0},gR=function(i,t,e){return(e==null||e>i.length)&&(e=i.length),new da(i.subarray(t,e))},So=function(i,t,e){e<<=t&7;var r=t/8|0;i[r]|=e,i[r+1]|=e>>8},$p=function(i,t,e){e<<=t&7;var r=t/8|0;i[r]|=e,i[r+1]|=e>>8,i[r+2]|=e>>16},aB=function(i,t){for(var e=[],r=0;r<i.length;++r)i[r]&&e.push({s:r,f:i[r]});var n=e.length,s=e.slice();if(!n)return{t:sT,l:0};if(n==1){var A=new da(e[0].s+1);return A[e[0].s]=1,{t:A,l:1}}e.sort(function(k,I){return k.f-I.f}),e.push({s:-1,f:25001});var a=e[0],o=e[1],l=0,h=1,u=2;for(e[0]={s:-1,f:a.f+o.f,l:a,r:o};h!=n-1;)a=e[e[l].f<e[u].f?l++:u++],o=e[l!=h&&e[l].f<e[u].f?l++:u++],e[h++]={s:-1,f:a.f+o.f,l:a,r:o};for(var f=s[0].s,r=1;r<n;++r)s[r].s>f&&(f=s[r].s);var d=new _A(f+1),g=Yx(e[h-1],d,0);if(g>t){var r=0,m=0,y=g-t,w=1<<y;for(s.sort(function(I,N){return d[N.s]-d[I.s]||I.f-N.f});r<n;++r){var b=s[r].s;if(d[b]>t)m+=w-(1<<g-d[b]),d[b]=t;else break}for(m>>=y;m>0;){var C=s[r].s;d[C]<t?m-=1<<t-d[C]++-1:++r}for(;r>=0&&m;--r){var S=s[r].s;d[S]==t&&(--d[S],++m)}g=t}return{t:new da(d),l:g}},Yx=function(i,t,e){return i.s==-1?Math.max(Yx(i.l,t,e+1),Yx(i.r,t,e+1)):t[i.s]=e},v3=function(i){for(var t=i.length;t&&!i[--t];);for(var e=new _A(++t),r=0,n=i[0],s=1,A=function(o){e[r++]=o},a=1;a<=t;++a)if(i[a]==n&&a!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)A(32754);s>2&&(A(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(A(n),--s;s>6;s-=6)A(8304);s>2&&(A(s-3<<5|8208),s=0)}for(;s--;)A(n);s=1,n=i[a]}return{c:e.subarray(0,r),n:t}},Zp=function(i,t){for(var e=0,r=0;r<t.length;++r)e+=i[r]*t[r];return e},nT=function(i,t,e){var r=e.length,n=iT(t+2);i[n]=r&255,i[n+1]=r>>8,i[n+2]=i[n]^255,i[n+3]=i[n+1]^255;for(var s=0;s<r;++s)i[n+s+4]=e[s];return(n+4+r)*8},y3=function(i,t,e,r,n,s,A,a,o,l,h){So(t,h++,e),++n[256];for(var u=aB(n,15),f=u.t,d=u.l,g=aB(s,15),m=g.t,y=g.l,w=v3(f),b=w.c,C=w.n,S=v3(m),k=S.c,I=S.n,N=new _A(19),D=0;D<b.length;++D)++N[b[D]&31];for(var D=0;D<k.length;++D)++N[k[D]&31];for(var Q=aB(N,7),K=Q.t,L=Q.l,O=19;O>4&&!K[m3[O-1]];--O);var W=l+5<<3,R=Zp(n,_u)+Zp(s,bv)+A,tt=Zp(n,f)+Zp(s,m)+A+14+3*O+Zp(N,K)+2*N[16]+3*N[17]+7*N[18];if(o>=0&&W<=R&&W<=tt)return nT(t,h,i.subarray(o,o+l));var et,st,nt,at;if(So(t,h,1+(tt<R)),h+=2,tt<R){et=Wm(f,d),st=f,nt=Wm(m,y),at=m;var ft=Wm(K,L);So(t,h,C-257),So(t,h+5,I-1),So(t,h+10,O-4),h+=14;for(var D=0;D<O;++D)So(t,h+3*D,K[m3[D]]);h+=3*O;for(var ht=[b,k],M=0;M<2;++M)for(var G=ht[M],D=0;D<G.length;++D){var X=G[D]&31;So(t,h,ft[X]),h+=K[X],X>15&&(So(t,h,G[D]>>5&127),h+=G[D]>>12)}}else et=fR,st=_u,nt=pR,at=bv;for(var D=0;D<a;++D){var rt=r[D];if(rt>255){var X=rt>>18&31;$p(t,h,et[X+257]),h+=st[X+257],X>7&&(So(t,h,rt>>23&31),h+=ES[X]);var it=rt&31;$p(t,h,nt[it]),h+=at[it],it>3&&($p(t,h,rt>>5&8191),h+=kS[it])}else $p(t,h,et[rt]),h+=st[rt]}return $p(t,h,et[256]),h+st[256]},mR=new SS([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),sT=new da(0),wR=function(i,t,e,r,n,s){var A=s.z||i.length,a=new da(r+A+5*(1+Math.ceil(A/7e3))+n),o=a.subarray(r,a.length-n),l=s.l,h=(s.r||0)&7;if(t){h&&(o[0]=s.r>>3);for(var u=mR[t-1],f=u>>13,d=u&8191,g=(1<<e)-1,m=s.p||new _A(32768),y=s.h||new _A(g+1),w=Math.ceil(e/3),b=2*w,C=function(jt){return(i[jt]^i[jt+1]<<w^i[jt+2]<<b)&g},S=new SS(25e3),k=new _A(288),I=new _A(32),N=0,D=0,Q=s.i||0,K=0,L=s.w||0,O=0;Q+2<A;++Q){var W=C(Q),R=Q&32767,tt=y[W];if(m[R]=tt,y[W]=R,L<=Q){var et=A-Q;if((N>7e3||K>24576)&&(et>423||!l)){h=y3(i,o,0,S,k,I,D,K,O,Q-O,h),K=N=D=0,O=Q;for(var st=0;st<286;++st)k[st]=0;for(var st=0;st<30;++st)I[st]=0}var nt=2,at=0,ft=d,ht=R-tt&32767;if(et>2&&W==C(Q-ht))for(var M=Math.min(f,et)-1,G=Math.min(32767,Q),X=Math.min(258,et);ht<=G&&--ft&&R!=tt;){if(i[Q+nt]==i[Q+nt-ht]){for(var rt=0;rt<X&&i[Q+rt]==i[Q+rt-ht];++rt);if(rt>nt){if(nt=rt,at=ht,rt>M)break;for(var it=Math.min(ht,rt-2),ot=0,st=0;st<it;++st){var gt=Q-ht+st&32767,vt=m[gt],yt=gt-vt&32767;yt>ot&&(ot=yt,tt=gt)}}}R=tt,tt=m[R],ht+=R-tt&32767}if(at){S[K++]=268435456|Xx[nt]<<18|w3[at];var St=Xx[nt]&31,Dt=w3[at]&31;D+=ES[St]+kS[Dt],++k[257+St],++I[Dt],L=Q+nt,++N}else S[K++]=i[Q],++k[i[Q]]}}for(Q=Math.max(Q,L);Q<A;++Q)S[K++]=i[Q],++k[i[Q]];h=y3(i,o,l,S,k,I,D,K,O,Q-O,h),l||(s.r=h&7|o[h/8|0]<<3,h-=7,s.h=y,s.p=m,s.i=Q,s.w=L)}else{for(var Q=s.w||0;Q<A+l;Q+=65535){var Tt=Q+65535;Tt>=A&&(o[h/8|0]=l,Tt=A),h=nT(o,h+1,i.subarray(Q,Tt))}s.i=A}return gR(a,0,r+iT(h)+n)},AT=function(){var i=1,t=0;return{p:function(e){for(var r=i,n=t,s=e.length|0,A=0;A!=s;){for(var a=Math.min(A+2655,s);A<a;++A)n+=r+=e[A];r=(r&65535)+15*(r>>16),n=(n&65535)+15*(n>>16)}i=r,t=n},d:function(){return i%=65521,t%=65521,(i&255)<<24|(i&65280)<<8|(t&255)<<8|t>>8}}},vR=function(i,t,e,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),A=new da(s.length+i.length);A.set(s),A.set(i,s.length),i=A,n.w=s.length}return wR(i,t.level==null?6:t.level,t.mem==null?n.l?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):20:12+t.mem,e,r,n)},aT=function(i,t,e){for(;e;++t)i[t]=e,e>>>=8},yR=function(i,t){var e=t.level,r=e==0?0:e<6?1:e==9?3:2;if(i[0]=120,i[1]=r<<6|(t.dictionary&&32),i[1]|=31-(i[0]<<8|i[1])%31,t.dictionary){var n=AT();n.p(t.dictionary),aT(i,2,n.d())}};function $x(i,t){t||(t={});var e=AT();e.p(i);var r=vR(i,t,t.dictionary?6:2,4);return yR(r,t),aT(r,r.length-4,e.d()),r}var bR=typeof TextDecoder<"u"&&new TextDecoder,BR=0;try{bR.decode(sT,{stream:!0}),BR=1}catch{}function CR(i){if(Array.isArray(i))return i}function xR(i,t){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var r,n,s,A,a=[],o=!0,l=!1;try{if(s=(e=e.call(i)).next,t!==0)for(;!(o=(r=s.call(e)).done)&&(a.push(r.value),a.length!==t);o=!0);}catch(h){l=!0,n=h}finally{try{if(!o&&e.return!=null&&(A=e.return(),Object(A)!==A))return}finally{if(l)throw n}}return a}}function b3(i,t){(t==null||t>i.length)&&(t=i.length);for(var e=0,r=Array(t);e<t;e++)r[e]=i[e];return r}function FR(i,t){if(i){if(typeof i=="string")return b3(i,t);var e={}.toString.call(i).slice(8,-1);return e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set"?Array.from(i):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?b3(i,t):void 0}}function SR(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B3(i,t){return CR(i)||xR(i,t)||FR(i,t)||SR()}function C3(i,t="utf8"){return new TextDecoder(t).decode(i)}const ER=new TextEncoder;function kR(i){return ER.encode(i)}const UR=1024*8,IR=(()=>{const i=new Uint8Array(4),t=new Uint32Array(i.buffer);return!((t[0]=1)&i[0])})(),oB={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class US{constructor(t=UR,e={}){ut(this,"buffer"),ut(this,"byteLength"),ut(this,"byteOffset"),ut(this,"length"),ut(this,"offset"),ut(this,"lastWrittenByte"),ut(this,"littleEndian"),ut(this,"_data"),ut(this,"_mark"),ut(this,"_marks");let r=!1;typeof t=="number"?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);const n=e.offset?e.offset>>>0:0,s=t.byteLength-n;let A=n;(ArrayBuffer.isView(t)||t instanceof US)&&(t.byteLength!==t.buffer.byteLength&&(A=t.byteOffset+n),t=t.buffer),r?this.lastWrittenByte=s:this.lastWrittenByte=0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=A,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,A,s),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const e=(this.offset+t)*2,r=new Uint8Array(e);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=e,this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,e){const r=oB[e].BYTES_PER_ELEMENT*t,n=this.byteOffset+this.offset,s=this.buffer.slice(n,n+r);if(this.littleEndian===IR&&e!=="uint8"&&e!=="int8"){const a=new Uint8Array(this.buffer.slice(n,n+r));a.reverse();const o=new oB[e](a.buffer);return this.offset+=r,o.reverse(),o}const A=new oB[e](s);return this.offset+=r,A}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let e="";for(let r=0;r<t;r++)e+=this.readChar();return e}readUtf8(t=1){return C3(this.readBytes(t))}decodeText(t=1,e="utf8"){return C3(this.readBytes(t),e)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;e<t.length;e++)this._data.setUint8(this.offset++,t[e]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let e=0;e<t.length;e++)this.writeUint8(t.charCodeAt(e));return this}writeUtf8(t){return this.writeBytes(kR(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function Fp(i){let t=i.length;for(;--t>=0;)i[t]=0}const QR=3,LR=258,oT=29,_R=256,MR=_R+1+oT,lT=30,TR=512,NR=new Array((MR+2)*2);Fp(NR);const PR=new Array(lT*2);Fp(PR);const DR=new Array(TR);Fp(DR);const OR=new Array(LR-QR+1);Fp(OR);const RR=new Array(oT);Fp(RR);const HR=new Array(lT);Fp(HR);const VR=(i,t,e,r)=>{let n=i&65535|0,s=i>>>16&65535|0,A=0;for(;e!==0;){A=e>2e3?2e3:e,e-=A;do n=n+t[r++]|0,s=s+n|0;while(--A);n%=65521,s%=65521}return n|s<<16|0};var Zx=VR;const WR=()=>{let i,t=[];for(var e=0;e<256;e++){i=e;for(var r=0;r<8;r++)i=i&1?3988292384^i>>>1:i>>>1;t[e]=i}return t},jR=new Uint32Array(WR()),KR=(i,t,e,r)=>{const n=jR,s=r+e;i^=-1;for(let A=r;A<s;A++)i=i>>>8^n[(i^t[A])&255];return i^-1};var Ia=KR,Jx={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},hT={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const GR=(i,t)=>Object.prototype.hasOwnProperty.call(i,t);var zR=function(i){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)GR(e,r)&&(i[r]=e[r])}}return i},qR=i=>{let t=0;for(let r=0,n=i.length;r<n;r++)t+=i[r].length;const e=new Uint8Array(t);for(let r=0,n=0,s=i.length;r<s;r++){let A=i[r];e.set(A,n),n+=A.length}return e},cT={assign:zR,flattenChunks:qR};let uT=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{uT=!1}const Q0=new Uint8Array(256);for(let i=0;i<256;i++)Q0[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;Q0[254]=Q0[254]=1;var XR=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let t,e,r,n,s,A=i.length,a=0;for(n=0;n<A;n++)e=i.charCodeAt(n),(e&64512)===55296&&n+1<A&&(r=i.charCodeAt(n+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),n++)),a+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(a),s=0,n=0;s<a;n++)e=i.charCodeAt(n),(e&64512)===55296&&n+1<A&&(r=i.charCodeAt(n+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),n++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const YR=(i,t)=>{if(t<65534&&i.subarray&&uT)return String.fromCharCode.apply(null,i.length===t?i:i.subarray(0,t));let e="";for(let r=0;r<t;r++)e+=String.fromCharCode(i[r]);return e};var $R=(i,t)=>{const e=t||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,t));let r,n;const s=new Array(e*2);for(n=0,r=0;r<e;){let A=i[r++];if(A<128){s[n++]=A;continue}let a=Q0[A];if(a>4){s[n++]=65533,r+=a-1;continue}for(A&=a===2?31:a===3?15:7;a>1&&r<e;)A=A<<6|i[r++]&63,a--;if(a>1){s[n++]=65533;continue}A<65536?s[n++]=A:(A-=65536,s[n++]=55296|A>>10&1023,s[n++]=56320|A&1023)}return YR(s,n)},ZR=(i,t)=>{t=t||i.length,t>i.length&&(t=i.length);let e=t-1;for(;e>=0&&(i[e]&192)===128;)e--;return e<0||e===0?t:e+Q0[i[e]]>t?e:t},tF={string2buf:XR,buf2string:$R,utf8border:ZR};function JR(){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}var tH=JR;const O1=16209,eH=16191;var rH=function(i,t){let e,r,n,s,A,a,o,l,h,u,f,d,g,m,y,w,b,C,S,k,I,N,D,Q;const K=i.state;e=i.next_in,D=i.input,r=e+(i.avail_in-5),n=i.next_out,Q=i.output,s=n-(t-i.avail_out),A=n+(i.avail_out-257),a=K.dmax,o=K.wsize,l=K.whave,h=K.wnext,u=K.window,f=K.hold,d=K.bits,g=K.lencode,m=K.distcode,y=(1<<K.lenbits)-1,w=(1<<K.distbits)-1;t:do{d<15&&(f+=D[e++]<<d,d+=8,f+=D[e++]<<d,d+=8),b=g[f&y];e:for(;;){if(C=b>>>24,f>>>=C,d-=C,C=b>>>16&255,C===0)Q[n++]=b&65535;else if(C&16){S=b&65535,C&=15,C&&(d<C&&(f+=D[e++]<<d,d+=8),S+=f&(1<<C)-1,f>>>=C,d-=C),d<15&&(f+=D[e++]<<d,d+=8,f+=D[e++]<<d,d+=8),b=m[f&w];r:for(;;){if(C=b>>>24,f>>>=C,d-=C,C=b>>>16&255,C&16){if(k=b&65535,C&=15,d<C&&(f+=D[e++]<<d,d+=8,d<C&&(f+=D[e++]<<d,d+=8)),k+=f&(1<<C)-1,k>a){i.msg="invalid distance too far back",K.mode=O1;break t}if(f>>>=C,d-=C,C=n-s,k>C){if(C=k-C,C>l&&K.sane){i.msg="invalid distance too far back",K.mode=O1;break t}if(I=0,N=u,h===0){if(I+=o-C,C<S){S-=C;do Q[n++]=u[I++];while(--C);I=n-k,N=Q}}else if(h<C){if(I+=o+h-C,C-=h,C<S){S-=C;do Q[n++]=u[I++];while(--C);if(I=0,h<S){C=h,S-=C;do Q[n++]=u[I++];while(--C);I=n-k,N=Q}}}else if(I+=h-C,C<S){S-=C;do Q[n++]=u[I++];while(--C);I=n-k,N=Q}for(;S>2;)Q[n++]=N[I++],Q[n++]=N[I++],Q[n++]=N[I++],S-=3;S&&(Q[n++]=N[I++],S>1&&(Q[n++]=N[I++]))}else{I=n-k;do Q[n++]=Q[I++],Q[n++]=Q[I++],Q[n++]=Q[I++],S-=3;while(S>2);S&&(Q[n++]=Q[I++],S>1&&(Q[n++]=Q[I++]))}}else if((C&64)===0){b=m[(b&65535)+(f&(1<<C)-1)];continue r}else{i.msg="invalid distance code",K.mode=O1;break t}break}}else if((C&64)===0){b=g[(b&65535)+(f&(1<<C)-1)];continue e}else if(C&32){K.mode=eH;break t}else{i.msg="invalid literal/length code",K.mode=O1;break t}break}}while(e<r&&n<A);S=d>>3,e-=S,d-=S<<3,f&=(1<<d)-1,i.next_in=e,i.next_out=n,i.avail_in=e<r?5+(r-e):5-(e-r),i.avail_out=n<A?257+(A-n):257-(n-A),K.hold=f,K.bits=d};const dd=15,x3=852,F3=592,S3=0,lB=1,E3=2,iH=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),nH=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),sH=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),AH=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),aH=(i,t,e,r,n,s,A,a)=>{const o=a.bits;let l=0,h=0,u=0,f=0,d=0,g=0,m=0,y=0,w=0,b=0,C,S,k,I,N,D=null,Q;const K=new Uint16Array(dd+1),L=new Uint16Array(dd+1);let O=null,W,R,tt;for(l=0;l<=dd;l++)K[l]=0;for(h=0;h<r;h++)K[t[e+h]]++;for(d=o,f=dd;f>=1&&K[f]===0;f--);if(d>f&&(d=f),f===0)return n[s++]=1<<24|64<<16|0,n[s++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<f&&K[u]===0;u++);for(d<u&&(d=u),y=1,l=1;l<=dd;l++)if(y<<=1,y-=K[l],y<0)return-1;if(y>0&&(i===S3||f!==1))return-1;for(L[1]=0,l=1;l<dd;l++)L[l+1]=L[l]+K[l];for(h=0;h<r;h++)t[e+h]!==0&&(A[L[t[e+h]]++]=h);if(i===S3?(D=O=A,Q=20):i===lB?(D=iH,O=nH,Q=257):(D=sH,O=AH,Q=0),b=0,h=0,l=u,N=s,g=d,m=0,k=-1,w=1<<d,I=w-1,i===lB&&w>x3||i===E3&&w>F3)return 1;for(;;){W=l-m,A[h]+1<Q?(R=0,tt=A[h]):A[h]>=Q?(R=O[A[h]-Q],tt=D[A[h]-Q]):(R=96,tt=0),C=1<<l-m,S=1<<g,u=S;do S-=C,n[N+(b>>m)+S]=W<<24|R<<16|tt|0;while(S!==0);for(C=1<<l-1;b&C;)C>>=1;if(C!==0?(b&=C-1,b+=C):b=0,h++,--K[l]===0){if(l===f)break;l=t[e+A[h]]}if(l>d&&(b&I)!==k){for(m===0&&(m=d),N+=u,g=l-m,y=1<<g;g+m<f&&(y-=K[g+m],!(y<=0));)g++,y<<=1;if(w+=1<<g,i===lB&&w>x3||i===E3&&w>F3)return 1;k=b&I,n[k]=d<<24|g<<16|N-s|0}}return b!==0&&(n[N+b]=l-m<<24|64<<16|0),a.bits=d,0};var jm=aH;const oH=0,dT=1,fT=2,{Z_FINISH:k3,Z_BLOCK:lH,Z_TREES:R1,Z_OK:Mu,Z_STREAM_END:hH,Z_NEED_DICT:cH,Z_STREAM_ERROR:fa,Z_DATA_ERROR:pT,Z_MEM_ERROR:gT,Z_BUF_ERROR:uH,Z_DEFLATED:U3}=hT,Iy=16180,I3=16181,Q3=16182,L3=16183,_3=16184,M3=16185,T3=16186,N3=16187,P3=16188,D3=16189,Bv=16190,Eo=16191,hB=16192,O3=16193,cB=16194,R3=16195,H3=16196,V3=16197,W3=16198,H1=16199,V1=16200,j3=16201,K3=16202,G3=16203,z3=16204,q3=16205,uB=16206,X3=16207,Y3=16208,Nr=16209,mT=16210,wT=16211,dH=852,fH=592,pH=15,gH=pH,$3=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function mH(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ou=i=>{if(!i)return 1;const t=i.state;return!t||t.strm!==i||t.mode<Iy||t.mode>wT?1:0},vT=i=>{if(Ou(i))return fa;const t=i.state;return i.total_in=i.total_out=t.total=0,i.msg="",t.wrap&&(i.adler=t.wrap&1),t.mode=Iy,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(dH),t.distcode=t.distdyn=new Int32Array(fH),t.sane=1,t.back=-1,Mu},yT=i=>{if(Ou(i))return fa;const t=i.state;return t.wsize=0,t.whave=0,t.wnext=0,vT(i)},bT=(i,t)=>{let e;if(Ou(i))return fa;const r=i.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?fa:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,yT(i))},BT=(i,t)=>{if(!i)return fa;const e=new mH;i.state=e,e.strm=i,e.window=null,e.mode=Iy;const r=bT(i,t);return r!==Mu&&(i.state=null),r},wH=i=>BT(i,gH);let Z3=!0,dB,fB;const vH=i=>{if(Z3){dB=new Int32Array(512),fB=new Int32Array(32);let t=0;for(;t<144;)i.lens[t++]=8;for(;t<256;)i.lens[t++]=9;for(;t<280;)i.lens[t++]=7;for(;t<288;)i.lens[t++]=8;for(jm(dT,i.lens,0,288,dB,0,i.work,{bits:9}),t=0;t<32;)i.lens[t++]=5;jm(fT,i.lens,0,32,fB,0,i.work,{bits:5}),Z3=!1}i.lencode=dB,i.lenbits=9,i.distcode=fB,i.distbits=5},CT=(i,t,e,r)=>{let n;const s=i.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>r&&(n=r),s.window.set(t.subarray(e-r,e-r+n),s.wnext),r-=n,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0},yH=(i,t)=>{let e,r,n,s,A,a,o,l,h,u,f,d,g,m,y=0,w,b,C,S,k,I,N,D;const Q=new Uint8Array(4);let K,L;const O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ou(i)||!i.output||!i.input&&i.avail_in!==0)return fa;e=i.state,e.mode===Eo&&(e.mode=hB),A=i.next_out,n=i.output,o=i.avail_out,s=i.next_in,r=i.input,a=i.avail_in,l=e.hold,h=e.bits,u=a,f=o,D=Mu;t:for(;;)switch(e.mode){case Iy:if(e.wrap===0){e.mode=hB;break}for(;h<16;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(e.wrap&2&&l===35615){e.wbits===0&&(e.wbits=15),e.check=0,Q[0]=l&255,Q[1]=l>>>8&255,e.check=Ia(e.check,Q,2,0),l=0,h=0,e.mode=I3;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((l&255)<<8)+(l>>8))%31){i.msg="incorrect header check",e.mode=Nr;break}if((l&15)!==U3){i.msg="unknown compression method",e.mode=Nr;break}if(l>>>=4,h-=4,N=(l&15)+8,e.wbits===0&&(e.wbits=N),N>15||N>e.wbits){i.msg="invalid window size",e.mode=Nr;break}e.dmax=1<<e.wbits,e.flags=0,i.adler=e.check=1,e.mode=l&512?D3:Eo,l=0,h=0;break;case I3:for(;h<16;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(e.flags=l,(e.flags&255)!==U3){i.msg="unknown compression method",e.mode=Nr;break}if(e.flags&57344){i.msg="unknown header flags set",e.mode=Nr;break}e.head&&(e.head.text=l>>8&1),e.flags&512&&e.wrap&4&&(Q[0]=l&255,Q[1]=l>>>8&255,e.check=Ia(e.check,Q,2,0)),l=0,h=0,e.mode=Q3;case Q3:for(;h<32;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}e.head&&(e.head.time=l),e.flags&512&&e.wrap&4&&(Q[0]=l&255,Q[1]=l>>>8&255,Q[2]=l>>>16&255,Q[3]=l>>>24&255,e.check=Ia(e.check,Q,4,0)),l=0,h=0,e.mode=L3;case L3:for(;h<16;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}e.head&&(e.head.xflags=l&255,e.head.os=l>>8),e.flags&512&&e.wrap&4&&(Q[0]=l&255,Q[1]=l>>>8&255,e.check=Ia(e.check,Q,2,0)),l=0,h=0,e.mode=_3;case _3:if(e.flags&1024){for(;h<16;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}e.length=l,e.head&&(e.head.extra_len=l),e.flags&512&&e.wrap&4&&(Q[0]=l&255,Q[1]=l>>>8&255,e.check=Ia(e.check,Q,2,0)),l=0,h=0}else e.head&&(e.head.extra=null);e.mode=M3;case M3:if(e.flags&1024&&(d=e.length,d>a&&(d=a),d&&(e.head&&(N=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+d),N)),e.flags&512&&e.wrap&4&&(e.check=Ia(e.check,r,d,s)),a-=d,s+=d,e.length-=d),e.length))break t;e.length=0,e.mode=T3;case T3:if(e.flags&2048){if(a===0)break t;d=0;do N=r[s+d++],e.head&&N&&e.length<65536&&(e.head.name+=String.fromCharCode(N));while(N&&d<a);if(e.flags&512&&e.wrap&4&&(e.check=Ia(e.check,r,d,s)),a-=d,s+=d,N)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=N3;case N3:if(e.flags&4096){if(a===0)break t;d=0;do N=r[s+d++],e.head&&N&&e.length<65536&&(e.head.comment+=String.fromCharCode(N));while(N&&d<a);if(e.flags&512&&e.wrap&4&&(e.check=Ia(e.check,r,d,s)),a-=d,s+=d,N)break t}else e.head&&(e.head.comment=null);e.mode=P3;case P3:if(e.flags&512){for(;h<16;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(e.wrap&4&&l!==(e.check&65535)){i.msg="header crc mismatch",e.mode=Nr;break}l=0,h=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),i.adler=e.check=0,e.mode=Eo;break;case D3:for(;h<32;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}i.adler=e.check=$3(l),l=0,h=0,e.mode=Bv;case Bv:if(e.havedict===0)return i.next_out=A,i.avail_out=o,i.next_in=s,i.avail_in=a,e.hold=l,e.bits=h,cH;i.adler=e.check=1,e.mode=Eo;case Eo:if(t===lH||t===R1)break t;case hB:if(e.last){l>>>=h&7,h-=h&7,e.mode=uB;break}for(;h<3;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}switch(e.last=l&1,l>>>=1,h-=1,l&3){case 0:e.mode=O3;break;case 1:if(vH(e),e.mode=H1,t===R1){l>>>=2,h-=2;break t}break;case 2:e.mode=H3;break;case 3:i.msg="invalid block type",e.mode=Nr}l>>>=2,h-=2;break;case O3:for(l>>>=h&7,h-=h&7;h<32;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if((l&65535)!==(l>>>16^65535)){i.msg="invalid stored block lengths",e.mode=Nr;break}if(e.length=l&65535,l=0,h=0,e.mode=cB,t===R1)break t;case cB:e.mode=R3;case R3:if(d=e.length,d){if(d>a&&(d=a),d>o&&(d=o),d===0)break t;n.set(r.subarray(s,s+d),A),a-=d,s+=d,o-=d,A+=d,e.length-=d;break}e.mode=Eo;break;case H3:for(;h<14;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(e.nlen=(l&31)+257,l>>>=5,h-=5,e.ndist=(l&31)+1,l>>>=5,h-=5,e.ncode=(l&15)+4,l>>>=4,h-=4,e.nlen>286||e.ndist>30){i.msg="too many length or distance symbols",e.mode=Nr;break}e.have=0,e.mode=V3;case V3:for(;e.have<e.ncode;){for(;h<3;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}e.lens[O[e.have++]]=l&7,l>>>=3,h-=3}for(;e.have<19;)e.lens[O[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,K={bits:e.lenbits},D=jm(oH,e.lens,0,19,e.lencode,0,e.work,K),e.lenbits=K.bits,D){i.msg="invalid code lengths set",e.mode=Nr;break}e.have=0,e.mode=W3;case W3:for(;e.have<e.nlen+e.ndist;){for(;y=e.lencode[l&(1<<e.lenbits)-1],w=y>>>24,b=y>>>16&255,C=y&65535,!(w<=h);){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(C<16)l>>>=w,h-=w,e.lens[e.have++]=C;else{if(C===16){for(L=w+2;h<L;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(l>>>=w,h-=w,e.have===0){i.msg="invalid bit length repeat",e.mode=Nr;break}N=e.lens[e.have-1],d=3+(l&3),l>>>=2,h-=2}else if(C===17){for(L=w+3;h<L;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}l>>>=w,h-=w,N=0,d=3+(l&7),l>>>=3,h-=3}else{for(L=w+7;h<L;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}l>>>=w,h-=w,N=0,d=11+(l&127),l>>>=7,h-=7}if(e.have+d>e.nlen+e.ndist){i.msg="invalid bit length repeat",e.mode=Nr;break}for(;d--;)e.lens[e.have++]=N}}if(e.mode===Nr)break;if(e.lens[256]===0){i.msg="invalid code -- missing end-of-block",e.mode=Nr;break}if(e.lenbits=9,K={bits:e.lenbits},D=jm(dT,e.lens,0,e.nlen,e.lencode,0,e.work,K),e.lenbits=K.bits,D){i.msg="invalid literal/lengths set",e.mode=Nr;break}if(e.distbits=6,e.distcode=e.distdyn,K={bits:e.distbits},D=jm(fT,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,K),e.distbits=K.bits,D){i.msg="invalid distances set",e.mode=Nr;break}if(e.mode=H1,t===R1)break t;case H1:e.mode=V1;case V1:if(a>=6&&o>=258){i.next_out=A,i.avail_out=o,i.next_in=s,i.avail_in=a,e.hold=l,e.bits=h,rH(i,f),A=i.next_out,n=i.output,o=i.avail_out,s=i.next_in,r=i.input,a=i.avail_in,l=e.hold,h=e.bits,e.mode===Eo&&(e.back=-1);break}for(e.back=0;y=e.lencode[l&(1<<e.lenbits)-1],w=y>>>24,b=y>>>16&255,C=y&65535,!(w<=h);){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(b&&(b&240)===0){for(S=w,k=b,I=C;y=e.lencode[I+((l&(1<<S+k)-1)>>S)],w=y>>>24,b=y>>>16&255,C=y&65535,!(S+w<=h);){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}l>>>=S,h-=S,e.back+=S}if(l>>>=w,h-=w,e.back+=w,e.length=C,b===0){e.mode=q3;break}if(b&32){e.back=-1,e.mode=Eo;break}if(b&64){i.msg="invalid literal/length code",e.mode=Nr;break}e.extra=b&15,e.mode=j3;case j3:if(e.extra){for(L=e.extra;h<L;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}e.length+=l&(1<<e.extra)-1,l>>>=e.extra,h-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=K3;case K3:for(;y=e.distcode[l&(1<<e.distbits)-1],w=y>>>24,b=y>>>16&255,C=y&65535,!(w<=h);){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if((b&240)===0){for(S=w,k=b,I=C;y=e.distcode[I+((l&(1<<S+k)-1)>>S)],w=y>>>24,b=y>>>16&255,C=y&65535,!(S+w<=h);){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}l>>>=S,h-=S,e.back+=S}if(l>>>=w,h-=w,e.back+=w,b&64){i.msg="invalid distance code",e.mode=Nr;break}e.offset=C,e.extra=b&15,e.mode=G3;case G3:if(e.extra){for(L=e.extra;h<L;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}e.offset+=l&(1<<e.extra)-1,l>>>=e.extra,h-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){i.msg="invalid distance too far back",e.mode=Nr;break}e.mode=z3;case z3:if(o===0)break t;if(d=f-o,e.offset>d){if(d=e.offset-d,d>e.whave&&e.sane){i.msg="invalid distance too far back",e.mode=Nr;break}d>e.wnext?(d-=e.wnext,g=e.wsize-d):g=e.wnext-d,d>e.length&&(d=e.length),m=e.window}else m=n,g=A-e.offset,d=e.length;d>o&&(d=o),o-=d,e.length-=d;do n[A++]=m[g++];while(--d);e.length===0&&(e.mode=V1);break;case q3:if(o===0)break t;n[A++]=e.length,o--,e.mode=V1;break;case uB:if(e.wrap){for(;h<32;){if(a===0)break t;a--,l|=r[s++]<<h,h+=8}if(f-=o,i.total_out+=f,e.total+=f,e.wrap&4&&f&&(i.adler=e.check=e.flags?Ia(e.check,n,f,A-f):Zx(e.check,n,f,A-f)),f=o,e.wrap&4&&(e.flags?l:$3(l))!==e.check){i.msg="incorrect data check",e.mode=Nr;break}l=0,h=0}e.mode=X3;case X3:if(e.wrap&&e.flags){for(;h<32;){if(a===0)break t;a--,l+=r[s++]<<h,h+=8}if(e.wrap&4&&l!==(e.total&4294967295)){i.msg="incorrect length check",e.mode=Nr;break}l=0,h=0}e.mode=Y3;case Y3:D=hH;break t;case Nr:D=pT;break t;case mT:return gT;case wT:default:return fa}return i.next_out=A,i.avail_out=o,i.next_in=s,i.avail_in=a,e.hold=l,e.bits=h,(e.wsize||f!==i.avail_out&&e.mode<Nr&&(e.mode<uB||t!==k3))&&CT(i,i.output,i.next_out,f-i.avail_out),u-=i.avail_in,f-=i.avail_out,i.total_in+=u,i.total_out+=f,e.total+=f,e.wrap&4&&f&&(i.adler=e.check=e.flags?Ia(e.check,n,f,i.next_out-f):Zx(e.check,n,f,i.next_out-f)),i.data_type=e.bits+(e.last?64:0)+(e.mode===Eo?128:0)+(e.mode===H1||e.mode===cB?256:0),(u===0&&f===0||t===k3)&&D===Mu&&(D=uH),D},bH=i=>{if(Ou(i))return fa;let t=i.state;return t.window&&(t.window=null),i.state=null,Mu},BH=(i,t)=>{if(Ou(i))return fa;const e=i.state;return(e.wrap&2)===0?fa:(e.head=t,t.done=!1,Mu)},CH=(i,t)=>{const e=t.length;let r,n,s;return Ou(i)||(r=i.state,r.wrap!==0&&r.mode!==Bv)?fa:r.mode===Bv&&(n=1,n=Zx(n,t,e,0),n!==r.check)?pT:(s=CT(i,t,e,e),s?(r.mode=mT,gT):(r.havedict=1,Mu))};var xH=yT,FH=bT,SH=vT,EH=wH,kH=BT,UH=yH,IH=bH,QH=BH,LH=CH,_H="pako inflate (from Nodeca project)",tl={inflateReset:xH,inflateReset2:FH,inflateResetKeep:SH,inflateInit:EH,inflateInit2:kH,inflate:UH,inflateEnd:IH,inflateGetHeader:QH,inflateSetDictionary:LH,inflateInfo:_H};function MH(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var TH=MH;const xT=Object.prototype.toString,{Z_NO_FLUSH:NH,Z_FINISH:PH,Z_OK:L0,Z_STREAM_END:pB,Z_NEED_DICT:gB,Z_STREAM_ERROR:DH,Z_DATA_ERROR:J3,Z_MEM_ERROR:OH}=hT;function V0(i){this.options=cT.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(i&&i.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tH,this.strm.avail_out=0;let e=tl.inflateInit2(this.strm,t.windowBits);if(e!==L0)throw new Error(Jx[e]);if(this.header=new TH,tl.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=tF.string2buf(t.dictionary):xT.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=tl.inflateSetDictionary(this.strm,t.dictionary),e!==L0)))throw new Error(Jx[e])}V0.prototype.push=function(i,t){const e=this.strm,r=this.options.chunkSize,n=this.options.dictionary;let s,A,a;if(this.ended)return!1;for(t===~~t?A=t:A=t===!0?PH:NH,xT.call(i)==="[object ArrayBuffer]"?e.input=new Uint8Array(i):e.input=i,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=tl.inflate(e,A),s===gB&&n&&(s=tl.inflateSetDictionary(e,n),s===L0?s=tl.inflate(e,A):s===J3&&(s=gB));e.avail_in>0&&s===pB&&e.state.wrap>0&&i[e.next_in]!==0;)tl.inflateReset(e),s=tl.inflate(e,A);switch(s){case DH:case J3:case gB:case OH:return this.onEnd(s),this.ended=!0,!1}if(a=e.avail_out,e.next_out&&(e.avail_out===0||s===pB))if(this.options.to==="string"){let o=tF.utf8border(e.output,e.next_out),l=e.next_out-o,h=tF.buf2string(e.output,o);e.next_out=l,e.avail_out=r-l,l&&e.output.set(e.output.subarray(o,o+l),0),this.onData(h)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===L0&&a===0)){if(s===pB)return s=tl.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};V0.prototype.onData=function(i){this.chunks.push(i)};V0.prototype.onEnd=function(i){i===L0&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=cT.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function RH(i,t){const e=new V0(t);if(e.push(i),e.err)throw e.msg||Jx[e.err];return e.result}var HH=V0,VH=RH,WH={Inflate:HH,inflate:VH};const{Inflate:jH,inflate:KH}=WH;var tk=jH,GH=KH;const FT=[];for(let i=0;i<256;i++){let t=i;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t=t>>>1;FT[i]=t}const ek=4294967295;function zH(i,t,e){let r=i;for(let n=0;n<e;n++)r=FT[(r^t[n])&255]^r>>>8;return r}function qH(i,t){return(zH(ek,i,t)^ek)>>>0}function rk(i,t,e){const r=i.readUint32(),n=qH(new Uint8Array(i.buffer,i.byteOffset+i.offset-t-4,t),t);if(n!==r)throw new Error(`CRC mismatch for chunk ${e}. Expected ${r}, found ${n}`)}function ST(i,t,e){for(let r=0;r<e;r++)t[r]=i[r]}function ET(i,t,e,r){let n=0;for(;n<r;n++)t[n]=i[n];for(;n<e;n++)t[n]=i[n]+t[n-r]&255}function kT(i,t,e,r){let n=0;if(e.length===0)for(;n<r;n++)t[n]=i[n];else for(;n<r;n++)t[n]=i[n]+e[n]&255}function UT(i,t,e,r,n){let s=0;if(e.length===0){for(;s<n;s++)t[s]=i[s];for(;s<r;s++)t[s]=i[s]+(t[s-n]>>1)&255}else{for(;s<n;s++)t[s]=i[s]+(e[s]>>1)&255;for(;s<r;s++)t[s]=i[s]+(t[s-n]+e[s]>>1)&255}}function IT(i,t,e,r,n){let s=0;if(e.length===0){for(;s<n;s++)t[s]=i[s];for(;s<r;s++)t[s]=i[s]+t[s-n]&255}else{for(;s<n;s++)t[s]=i[s]+e[s]&255;for(;s<r;s++)t[s]=i[s]+XH(t[s-n],e[s],e[s-n])&255}}function XH(i,t,e){const r=i+t-e,n=Math.abs(r-i),s=Math.abs(r-t),A=Math.abs(r-e);return n<=s&&n<=A?i:s<=A?t:e}function YH(i,t,e,r,n,s){switch(i){case 0:ST(t,e,n);break;case 1:ET(t,e,n,s);break;case 2:kT(t,e,r,n);break;case 3:UT(t,e,r,n,s);break;case 4:IT(t,e,r,n,s);break;default:throw new Error(`Unsupported filter: ${i}`)}}const $H=new Uint16Array([255]),ZH=new Uint8Array($H.buffer),JH=ZH[0]===255;function t7(i){const{data:t,width:e,height:r,channels:n,depth:s}=i,A=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],a=Math.ceil(s/8)*n,o=new Uint8Array(r*e*a);let l=0;for(let h=0;h<7;h++){const u=A[h],f=Math.ceil((e-u.x)/u.xStep),d=Math.ceil((r-u.y)/u.yStep);if(f<=0||d<=0)continue;const g=f*a,m=new Uint8Array(g);for(let y=0;y<d;y++){const w=t[l++],b=t.subarray(l,l+g);l+=g;const C=new Uint8Array(g);YH(w,b,C,m,g,a),m.set(C);for(let S=0;S<f;S++){const k=u.x+S*u.xStep,I=u.y+y*u.yStep;if(!(k>=e||I>=r))for(let N=0;N<a;N++)o[(I*e+k)*a+N]=C[S*a+N]}}}if(s===16){const h=new Uint16Array(o.buffer);if(JH)for(let u=0;u<h.length;u++)h[u]=e7(h[u]);return h}else return o}function e7(i){return(i&255)<<8|i>>8&255}const r7=new Uint16Array([255]),i7=new Uint8Array(r7.buffer),n7=i7[0]===255,s7=new Uint8Array(0);function ik(i){const{data:t,width:e,height:r,channels:n,depth:s}=i,A=Math.ceil(s/8)*n,a=Math.ceil(s/8*n*e),o=new Uint8Array(r*a);let l=s7,h=0,u,f;for(let d=0;d<r;d++){switch(u=t.subarray(h+1,h+1+a),f=o.subarray(d*a,(d+1)*a),t[h]){case 0:ST(u,f,a);break;case 1:ET(u,f,a,A);break;case 2:kT(u,f,l,a);break;case 3:UT(u,f,l,a,A);break;case 4:IT(u,f,l,a,A);break;default:throw new Error(`Unsupported filter: ${t[h]}`)}l=f,h+=a+1}if(s===16){const d=new Uint16Array(o.buffer);if(n7)for(let g=0;g<d.length;g++)d[g]=A7(d[g]);return d}else return o}function A7(i){return(i&255)<<8|i>>8&255}const Nw=Uint8Array.of(137,80,78,71,13,10,26,10);function nk(i){if(!a7(i.readBytes(Nw.length)))throw new Error("wrong PNG signature")}function a7(i){if(i.length<Nw.length)return!1;for(let t=0;t<Nw.length;t++)if(i[t]!==Nw[t])return!1;return!0}const o7="tEXt",l7=0,QT=new TextDecoder("latin1");function h7(i){if(u7(i),i.length===0||i.length>79)throw new Error("keyword length must be between 1 and 79")}const c7=/^[\u0000-\u00FF]*$/;function u7(i){if(!c7.test(i))throw new Error("invalid latin1 text")}function d7(i,t,e){const r=LT(t);i[r]=f7(t,e-r.length-1)}function LT(i){for(i.mark();i.readByte()!==l7;);const t=i.offset;i.reset();const e=QT.decode(i.readBytes(t-i.offset-1));return i.skip(1),h7(e),e}function f7(i,t){return QT.decode(i.readBytes(t))}const Ks={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},mB={UNKNOWN:-1,DEFLATE:0},sk={UNKNOWN:-1,ADAPTIVE:0},wB={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},W1={NONE:0,BACKGROUND:1,PREVIOUS:2},vB={SOURCE:0,OVER:1};class p7 extends US{constructor(t,e={}){super(t),ut(this,"_checkCrc"),ut(this,"_inflator"),ut(this,"_png"),ut(this,"_apng"),ut(this,"_end"),ut(this,"_hasPalette"),ut(this,"_palette"),ut(this,"_hasTransparency"),ut(this,"_transparency"),ut(this,"_compressionMethod"),ut(this,"_filterMethod"),ut(this,"_interlaceMethod"),ut(this,"_colorType"),ut(this,"_isAnimated"),ut(this,"_numberOfFrames"),ut(this,"_numberOfPlays"),ut(this,"_frames"),ut(this,"_writingDataChunks");const{checkCrc:r=!1}=e;this._checkCrc=r,this._inflator=new tk,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=mB.UNKNOWN,this._filterMethod=sk.UNKNOWN,this._interlaceMethod=wB.UNKNOWN,this._colorType=Ks.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(nk(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeChunk(t,e)}return this.decodeImage(),this._png}decodeApng(){for(nk(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeApngChunk(t,e)}return this.decodeApngImage(),this._apng}decodeChunk(t,e){const r=this.offset;switch(e){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case o7:d7(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-r!==t)throw new Error(`Length mismatch while decoding chunk ${e}`);this._checkCrc?rk(this,t+4,e):this.skip(4)}decodeApngChunk(t,e){const r=this.offset;switch(e!=="fdAT"&&e!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),e){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,e),this.offset=r+t;break}if(this.offset-r!==t)throw new Error(`Length mismatch while decoding chunk ${e}`);this._checkCrc?rk(this,t+4,e):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=g7(this.readUint8());const e=this.readUint8();this._colorType=e;let r;switch(e){case Ks.GREYSCALE:r=1;break;case Ks.TRUECOLOUR:r=3;break;case Ks.INDEXED_COLOUR:r=1;break;case Ks.GREYSCALE_ALPHA:r=2;break;case Ks.TRUECOLOUR_ALPHA:r=4;break;case Ks.UNKNOWN:default:throw new Error(`Unknown color type: ${e}`)}if(this._png.channels=r,this._compressionMethod=this.readUint8(),this._compressionMethod!==mB.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const e=t/3;this._hasPalette=!0;const r=[];this._palette=r;for(let n=0;n<e;n++)r.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;const e=t,r=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,r,e)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let e=t,r=this.offset+this.byteOffset;if(r+=4,e-=4,this._inflator.push(new Uint8Array(this.buffer,r,e)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodetRNS(t){switch(this._colorType){case Ks.GREYSCALE:case Ks.TRUECOLOUR:{if(t%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${t}`);if(t/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let e=0;e<t/2;e++)this._transparency[e]=this.readUint16();break}case Ks.INDEXED_COLOUR:{if(t>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let e=0;for(;e<t;e++){const r=this.readByte();this._palette[e].push(r)}for(;e<this._palette.length;e++)this._palette[e].push(255);break}case Ks.UNKNOWN:case Ks.GREYSCALE_ALPHA:case Ks.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(t){const e=LT(this),r=this.readUint8();if(r!==mB.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${r}`);const n=this.readBytes(t-e.length-2);this._png.iccEmbeddedProfile={name:e,profile:GH(n)}}decodepHYs(){const t=this.readUint32(),e=this.readUint32(),r=this.readByte();this._png.resolution={x:t,y:e,unit:r}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let t=0;t<this._numberOfFrames;t++){const e={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},r=this._frames.at(t);if(r){if(r.data=ik({data:r.data,width:r.width,height:r.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),t===0||r.xOffset===0&&r.yOffset===0&&r.width===this._png.width&&r.height===this._png.height)e.data=r.data;else{const n=this._apng.frames.at(t-1);this.disposeFrame(r,n,e),this.addFrameDataToCanvas(e,r)}this._apng.frames.push(e)}}return this._apng}disposeFrame(t,e,r){switch(t.disposeOp){case W1.NONE:break;case W1.BACKGROUND:for(let n=0;n<this._png.height;n++)for(let s=0;s<this._png.width;s++){const A=(n*t.width+s)*this._png.channels;for(let a=0;a<this._png.channels;a++)r.data[A+a]=0}break;case W1.PREVIOUS:r.data.set(e.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,e){const r=1<<this._png.depth,n=(s,A)=>{const a=((s+e.yOffset)*this._png.width+e.xOffset+A)*this._png.channels,o=(s*e.width+A)*this._png.channels;return{index:a,frameIndex:o}};switch(e.blendOp){case vB.SOURCE:for(let s=0;s<e.height;s++)for(let A=0;A<e.width;A++){const{index:a,frameIndex:o}=n(s,A);for(let l=0;l<this._png.channels;l++)t.data[a+l]=e.data[o+l]}break;case vB.OVER:for(let s=0;s<e.height;s++)for(let A=0;A<e.width;A++){const{index:a,frameIndex:o}=n(s,A);for(let l=0;l<this._png.channels;l++){const h=e.data[o+this._png.channels-1]/r,u=l%(this._png.channels-1)===0?1:e.data[o+l],f=Math.floor(h*u+(1-h)*t.data[a+l]);t.data[a+l]+=f}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){var t;if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const e=this._isAnimated?((t=this._frames)==null?void 0:t.at(0)).data:this._inflator.result;if(this._filterMethod!==sk.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===wB.NO_INTERLACE)this._png.data=ik({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===wB.ADAM7)this._png.data=t7({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const t=this._inflator.result,e=this._frames.at(-1);e?e.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:W1.NONE,blendOp:vB.SOURCE,data:t}),this._inflator=new tk,this._writingDataChunks=!1}}function g7(i){if(i!==1&&i!==2&&i!==4&&i!==8&&i!==16)throw new Error(`invalid bit depth: ${i}`);return i}var Ak;(function(i){i[i.UNKNOWN=0]="UNKNOWN",i[i.METRE=1]="METRE"})(Ak||(Ak={}));function m7(i,t){return new p7(i,t).decode()}/** @license
|
|
3
3
|
*
|
|
4
4
|
* jsPDF - PDF Document creation from JavaScript
|
|
@@ -269,7 +269,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
269
269
|
`),position:b,pageIndex:C-1,rect:l.slice(0),rotation:h,annotationElementId:u,id:u,deleted:!1,popupRef:f,comment:(g==null?void 0:g.str)||null,richText:d,creationDate:m,modificationDate:y}}const A=await super.deserialize(t,e,r);return F(A,SA,t.fontSize),A.color=Nt.makeHexColor(...t.color),F(A,FA,_(n=On,Cu,g4).call(n,t.value)),A._initialData=s,t.comment&&A.setCommentData(t),A}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Vr._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),r=Object.assign(super.serialize(t),{color:e,fontSize:c(this,SA),value:_(this,$s,n6).call(this)});return this.addComment(r),t?(r.isCopy=!0,r):this.annotationElementId&&!_(this,$s,s6).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:r}=e;r.fontSize=`calc(${c(this,SA)}px * var(--total-scale-factor))`,r.color=this.color,e.replaceChildren();for(const n of c(this,FA).split(`
|
|
270
270
|
`)){const s=document.createElement("div");s.append(n?document.createTextNode(n):document.createElement("br")),e.append(s)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:c(this,FA)}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};FA=new WeakMap,q2=new WeakMap,vf=new WeakMap,SA=new WeakMap,$s=new WeakSet,e6=function(i){const t=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-c(this,SA))*this.parentScale),F(this,SA,r),_(this,$s,iy).call(this)},e=c(this,SA);this.addCommands({cmd:t.bind(this,i),undo:t.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},r6=function(i){const t=r=>{this.color=r,this.onUpdatedColor()},e=this.color;this.addCommands({cmd:t.bind(this,i),undo:t.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},i6=function(){var i;const t=[];this.editorDiv.normalize();let e=null;for(const r of this.editorDiv.childNodes)(e==null?void 0:e.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(t.push(_(i=Vo,Cu,ny).call(i,r)),e=r);return t.join(`
|
|
271
271
|
`)},iy=function(){const[i,t]=this.parentDimensions;let e;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{const{currentLayer:r,div:n}=this,s=n.style.display,A=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",r.div.append(this.div),e=n.getBoundingClientRect(),n.remove(),n.style.display=s,n.classList.toggle("hidden",A)}this.rotation%180===this.parentRotation%180?(this.width=e.width/i,this.height=e.height/t):(this.width=e.height/i,this.height=e.width/t),this.fixAndSetPosition()},Cu=new WeakSet,ny=function(i){return(i.nodeType===Node.TEXT_NODE?i.nodeValue:i.innerText).replaceAll(z2,"")},X2=function(){if(this.editorDiv.replaceChildren(),!!c(this,FA))for(const i of c(this,FA).split(`
|
|
272
|
-
`)){const t=document.createElement("div");t.append(i?document.createTextNode(i):document.createElement("br")),this.editorDiv.append(t)}},n6=function(){return c(this,FA).replaceAll(" "," ")},g4=function(i){return i.replaceAll(" "," ")},s6=function(i){const{value:t,fontSize:e,color:r,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||i.value!==t||i.fontSize!==e||i.color.some((s,A)=>s!==r[A])||i.pageIndex!==n},U(Vo,Cu),ut(Vo,"_freeTextDefaultContent",""),ut(Vo,"_internalPadding",0),ut(Vo,"_defaultColor",null),ut(Vo,"_defaultFontSize",10),ut(Vo,"_type","freetext"),ut(Vo,"_editorType",Se.FREETEXT);let VW=Vo;class Jt{toSVGPath(){rr("Abstract method `toSVGPath` must be implemented.")}get box(){rr("Abstract getter `box` must be implemented.")}serialize(t,e){rr("Abstract method `serialize` must be implemented.")}static _rescale(t,e,r,n,s,A){A||(A=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)A[a]=e+t[a]*n,A[a+1]=r+t[a+1]*s;return A}static _rescaleAndSwap(t,e,r,n,s,A){A||(A=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)A[a]=e+t[a+1]*n,A[a+1]=r+t[a]*s;return A}static _translate(t,e,r,n){n||(n=new Float32Array(t.length));for(let s=0,A=t.length;s<A;s+=2)n[s]=e+t[s],n[s+1]=r+t[s+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,r,n,s){switch(s){case 90:return[1-e/r,t/n];case 180:return[1-t/r,1-e/n];case 270:return[e/r,1-t/n];default:return[t/r,e/n]}}static _normalizePagePoint(t,e,r){switch(r){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,r,n,s,A){return[(t+5*r)/6,(e+5*n)/6,(5*r+s)/6,(5*n+A)/6,(r+s)/2,(n+A)/2]}}ut(Jt,"PRECISION",1e-4);var kA,$a,p0,g0,Wo,He,fp,pp,Y2,$2,m0,bm,zc,Z2,YB,m4,UA,ng,A6,a6,o6,l6,h6,c6;const yf=class w4{constructor({x:t,y:e},r,n,s,A,a=0){U(this,UA),U(this,kA),U(this,$a,[]),U(this,p0),U(this,g0),U(this,Wo,[]),U(this,He,new Float32Array(18)),U(this,fp),U(this,pp),U(this,Y2),U(this,$2),U(this,m0),U(this,bm),U(this,zc,[]),F(this,kA,r),F(this,bm,s*n),F(this,g0,A),c(this,He).set([NaN,NaN,NaN,NaN,t,e],6),F(this,p0,a),F(this,$2,c(w4,Z2)*n),F(this,Y2,c(w4,m4)*n),F(this,m0,n),c(this,zc).push(t,e)}isEmpty(){return isNaN(c(this,He)[8])}add({x:t,y:e}){var r;F(this,fp,t),F(this,pp,e);const[n,s,A,a]=c(this,kA);let[o,l,h,u]=c(this,He).subarray(8,12);const f=t-h,d=e-u,g=Math.hypot(f,d);if(g<c(this,Y2))return!1;const m=g-c(this,$2),y=m/g,w=y*f,b=y*d;let C=o,S=l;o=h,l=u,h+=w,u+=b,(r=c(this,zc))==null||r.push(t,e);const k=-b/m,I=w/m,N=k*c(this,bm),D=I*c(this,bm);return c(this,He).set(c(this,He).subarray(2,8),0),c(this,He).set([h+N,u+D],4),c(this,He).set(c(this,He).subarray(14,18),12),c(this,He).set([h-N,u-D],16),isNaN(c(this,He)[6])?(c(this,Wo).length===0&&(c(this,He).set([o+N,l+D],2),c(this,Wo).push(NaN,NaN,NaN,NaN,(o+N-n)/A,(l+D-s)/a),c(this,He).set([o-N,l-D],14),c(this,$a).push(NaN,NaN,NaN,NaN,(o-N-n)/A,(l-D-s)/a)),c(this,He).set([C,S,o,l,h,u],6),!this.isEmpty()):(c(this,He).set([C,S,o,l,h,u],6),Math.abs(Math.atan2(S-l,C-o)-Math.atan2(b,w))<Math.PI/2?([o,l,h,u]=c(this,He).subarray(2,6),c(this,Wo).push(NaN,NaN,NaN,NaN,((o+h)/2-n)/A,((l+u)/2-s)/a),[o,l,C,S]=c(this,He).subarray(14,18),c(this,$a).push(NaN,NaN,NaN,NaN,((C+o)/2-n)/A,((S+l)/2-s)/a),!0):([C,S,o,l,h,u]=c(this,He).subarray(0,6),c(this,Wo).push(((C+5*o)/6-n)/A,((S+5*l)/6-s)/a,((5*o+h)/6-n)/A,((5*l+u)/6-s)/a,((o+h)/2-n)/A,((l+u)/2-s)/a),[h,u,o,l,C,S]=c(this,He).subarray(12,18),c(this,$a).push(((C+5*o)/6-n)/A,((S+5*l)/6-s)/a,((5*o+h)/6-n)/A,((5*l+u)/6-s)/a,((o+h)/2-n)/A,((l+u)/2-s)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=c(this,Wo),e=c(this,$a);if(isNaN(c(this,He)[6])&&!this.isEmpty())return _(this,UA,A6).call(this);const r=[];r.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?r.push(`L${t[n+4]} ${t[n+5]}`):r.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);_(this,UA,o6).call(this,r);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?r.push(`L${e[n+4]} ${e[n+5]}`):r.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return _(this,UA,a6).call(this,r),r.join(" ")}newFreeDrawOutline(t,e,r,n,s,A){return new f6(t,e,r,n,s,A)}getOutlines(){var t;const e=c(this,Wo),r=c(this,$a),n=c(this,He),[s,A,a,o]=c(this,kA),l=new Float32Array((((t=c(this,zc))==null?void 0:t.length)??0)+2);for(let f=0,d=l.length-2;f<d;f+=2)l[f]=(c(this,zc)[f]-s)/a,l[f+1]=(c(this,zc)[f+1]-A)/o;if(l[l.length-2]=(c(this,fp)-s)/a,l[l.length-1]=(c(this,pp)-A)/o,isNaN(n[6])&&!this.isEmpty())return _(this,UA,l6).call(this,l);const h=new Float32Array(c(this,Wo).length+24+c(this,$a).length);let u=e.length;for(let f=0;f<u;f+=2){if(isNaN(e[f])){h[f]=h[f+1]=NaN;continue}h[f]=e[f],h[f+1]=e[f+1]}u=_(this,UA,c6).call(this,h,u);for(let f=r.length-6;f>=6;f-=6)for(let d=0;d<6;d+=2){if(isNaN(r[f+d])){h[u]=h[u+1]=NaN,u+=2;continue}h[u]=r[f+d],h[u+1]=r[f+d+1],u+=2}return _(this,UA,h6).call(this,h,u),this.newFreeDrawOutline(h,l,c(this,kA),c(this,m0),c(this,p0),c(this,g0))}};kA=new WeakMap,$a=new WeakMap,p0=new WeakMap,g0=new WeakMap,Wo=new WeakMap,He=new WeakMap,fp=new WeakMap,pp=new WeakMap,Y2=new WeakMap,$2=new WeakMap,m0=new WeakMap,bm=new WeakMap,zc=new WeakMap,Z2=new WeakMap,YB=new WeakMap,m4=new WeakMap,UA=new WeakSet,ng=function(){const i=c(this,He).subarray(4,6),t=c(this,He).subarray(16,18),[e,r,n,s]=c(this,kA);return[(c(this,fp)+(i[0]-t[0])/2-e)/n,(c(this,pp)+(i[1]-t[1])/2-r)/s,(c(this,fp)+(t[0]-i[0])/2-e)/n,(c(this,pp)+(t[1]-i[1])/2-r)/s]},A6=function(){const[i,t,e,r]=c(this,kA),[n,s,A,a]=_(this,UA,ng).call(this);return`M${(c(this,He)[2]-i)/e} ${(c(this,He)[3]-t)/r} L${(c(this,He)[4]-i)/e} ${(c(this,He)[5]-t)/r} L${n} ${s} L${A} ${a} L${(c(this,He)[16]-i)/e} ${(c(this,He)[17]-t)/r} L${(c(this,He)[14]-i)/e} ${(c(this,He)[15]-t)/r} Z`},a6=function(i){const t=c(this,$a);i.push(`L${t[4]} ${t[5]} Z`)},o6=function(i){const[t,e,r,n]=c(this,kA),s=c(this,He).subarray(4,6),A=c(this,He).subarray(16,18),[a,o,l,h]=_(this,UA,ng).call(this);i.push(`L${(s[0]-t)/r} ${(s[1]-e)/n} L${a} ${o} L${l} ${h} L${(A[0]-t)/r} ${(A[1]-e)/n}`)},l6=function(i){const t=c(this,He),[e,r,n,s]=c(this,kA),[A,a,o,l]=_(this,UA,ng).call(this),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(t[2]-e)/n,(t[3]-r)/s,NaN,NaN,NaN,NaN,(t[4]-e)/n,(t[5]-r)/s,NaN,NaN,NaN,NaN,A,a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,(t[16]-e)/n,(t[17]-r)/s,NaN,NaN,NaN,NaN,(t[14]-e)/n,(t[15]-r)/s],0),this.newFreeDrawOutline(h,i,c(this,kA),c(this,m0),c(this,p0),c(this,g0))},h6=function(i,t){const e=c(this,$a);return i.set([NaN,NaN,NaN,NaN,e[4],e[5]],t),t+=6},c6=function(i,t){const e=c(this,He).subarray(4,6),r=c(this,He).subarray(16,18),[n,s,A,a]=c(this,kA),[o,l,h,u]=_(this,UA,ng).call(this);return i.set([NaN,NaN,NaN,NaN,(e[0]-n)/A,(e[1]-s)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,u,NaN,NaN,NaN,NaN,(r[0]-n)/A,(r[1]-s)/a],t),t+=24},U(yf,Z2,8),U(yf,YB,2),U(yf,m4,c(yf,Z2)+c(yf,YB));let u6=yf;var Bm,Kf,Eh,J2,wA,tv,Ti,v4,d6;class f6 extends Jt{constructor(t,e,r,n,s,A){super(),U(this,v4),U(this,Bm),U(this,Kf,new Float32Array(4)),U(this,Eh),U(this,J2),U(this,wA),U(this,tv),U(this,Ti),F(this,Ti,t),F(this,wA,e),F(this,Bm,r),F(this,tv,n),F(this,Eh,s),F(this,J2,A),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],_(this,v4,d6).call(this,A);const[a,o,l,h]=c(this,Kf);for(let u=0,f=t.length;u<f;u+=2)t[u]=(t[u]-a)/l,t[u+1]=(t[u+1]-o)/h;for(let u=0,f=e.length;u<f;u+=2)e[u]=(e[u]-a)/l,e[u+1]=(e[u+1]-o)/h}toSVGPath(){const t=[`M${c(this,Ti)[4]} ${c(this,Ti)[5]}`];for(let e=6,r=c(this,Ti).length;e<r;e+=6){if(isNaN(c(this,Ti)[e])){t.push(`L${c(this,Ti)[e+4]} ${c(this,Ti)[e+5]}`);continue}t.push(`C${c(this,Ti)[e]} ${c(this,Ti)[e+1]} ${c(this,Ti)[e+2]} ${c(this,Ti)[e+3]} ${c(this,Ti)[e+4]} ${c(this,Ti)[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,r,n],s){const A=r-t,a=n-e;let o,l;switch(s){case 0:o=Jt._rescale(c(this,Ti),t,n,A,-a),l=Jt._rescale(c(this,wA),t,n,A,-a);break;case 90:o=Jt._rescaleAndSwap(c(this,Ti),t,e,A,a),l=Jt._rescaleAndSwap(c(this,wA),t,e,A,a);break;case 180:o=Jt._rescale(c(this,Ti),r,e,-A,a),l=Jt._rescale(c(this,wA),r,e,-A,a);break;case 270:o=Jt._rescaleAndSwap(c(this,Ti),r,n,-A,-a),l=Jt._rescaleAndSwap(c(this,wA),r,n,-A,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return c(this,Kf)}newOutliner(t,e,r,n,s,A=0){return new u6(t,e,r,n,s,A)}getNewOutline(t,e){const[r,n,s,A]=c(this,Kf),[a,o,l,h]=c(this,Bm),u=s*l,f=A*h,d=r*l+a,g=n*h+o,m=this.newOutliner({x:c(this,wA)[0]*u+d,y:c(this,wA)[1]*f+g},c(this,Bm),c(this,tv),t,c(this,J2),e??c(this,Eh));for(let y=2;y<c(this,wA).length;y+=2)m.add({x:c(this,wA)[y]*u+d,y:c(this,wA)[y+1]*f+g});return m.getOutlines()}}Bm=new WeakMap,Kf=new WeakMap,Eh=new WeakMap,J2=new WeakMap,wA=new WeakMap,tv=new WeakMap,Ti=new WeakMap,v4=new WeakSet,d6=function(i){const t=c(this,Ti);let e=t[4],r=t[5];const n=[e,r,e,r];let s=e,A=r,a=e,o=r;const l=i?Math.max:Math.min,h=new Float32Array(4);for(let f=6,d=t.length;f<d;f+=6){const g=t[f+4],m=t[f+5];isNaN(t[f])?(Nt.pointBoundingBox(g,m,n),A>m?(s=g,A=m):A===m&&(s=l(s,g)),o<m?(a=g,o=m):o===m&&(a=l(a,g))):(h.set(fl,0),Nt.bezierBoundingBox(e,r,...t.slice(f,f+6),h),Nt.rectBoundingBox(...h,n),A>h[1]?(s=h[0],A=h[1]):A===h[1]&&(s=l(s,h[0])),o<h[3]?(a=h[2],o=h[3]):o===h[3]&&(a=l(a,h[2]))),e=g,r=m}const u=c(this,Kf);u[0]=n[0]-c(this,Eh),u[1]=n[1]-c(this,Eh),u[2]=n[2]-n[0]+2*c(this,Eh),u[3]=n[3]-n[1]+2*c(this,Eh),this.firstPoint=[s,A],this.lastPoint=[a,o]};var sy,Ay,ay,qc,Ra,ro,p6,sw,g6,m6,y4;class b4{constructor(t,e=0,r=0,n=!0){U(this,ro),U(this,sy),U(this,Ay),U(this,ay),U(this,qc,[]),U(this,Ra,[]);const s=fl.slice(),A=10**-4;for(const{x:m,y,width:w,height:b}of t){const C=Math.floor((m-e)/A)*A,S=Math.ceil((m+w+e)/A)*A,k=Math.floor((y-e)/A)*A,I=Math.ceil((y+b+e)/A)*A,N=[C,k,I,!0],D=[S,k,I,!1];c(this,qc).push(N,D),Nt.rectBoundingBox(C,k,S,I,s)}const a=s[2]-s[0]+2*r,o=s[3]-s[1]+2*r,l=s[0]-r,h=s[1]-r;let u=n?-1/0:1/0,f=1/0;const d=c(this,qc).at(n?-1:-2),g=[d[0],d[2]];for(const m of c(this,qc)){const[y,w,b,C]=m;!C&&n?w<f?(f=w,u=y):w===f&&(u=Math.max(u,y)):C&&!n&&(w<f?(f=w,u=y):w===f&&(u=Math.min(u,y))),m[0]=(y-l)/a,m[1]=(w-h)/o,m[2]=(b-h)/o}F(this,sy,new Float32Array([l,h,a,o])),F(this,Ay,[u,f]),F(this,ay,g)}getOutlines(){c(this,qc).sort((e,r)=>e[0]-r[0]||e[1]-r[1]||e[2]-r[2]);const t=[];for(const e of c(this,qc))e[3]?(t.push(..._(this,ro,y4).call(this,e)),_(this,ro,g6).call(this,e)):(_(this,ro,m6).call(this,e),t.push(..._(this,ro,y4).call(this,e)));return _(this,ro,p6).call(this,t)}}sy=new WeakMap,Ay=new WeakMap,ay=new WeakMap,qc=new WeakMap,Ra=new WeakMap,ro=new WeakSet,p6=function(i){const t=[],e=new Set;for(const s of i){const[A,a,o]=s;t.push([A,a,s],[A,o,s])}t.sort((s,A)=>s[1]-A[1]||s[0]-A[0]);for(let s=0,A=t.length;s<A;s+=2){const a=t[s][2],o=t[s+1][2];a.push(o),o.push(a),e.add(a),e.add(o)}const r=[];let n;for(;e.size>0;){const s=e.values().next().value;let[A,a,o,l,h]=s;e.delete(s);let u=A,f=a;for(n=[A,o],r.push(n);;){let d;if(e.has(l))d=l;else if(e.has(h))d=h;else break;e.delete(d),[A,a,o,l,h]=d,u!==A&&(n.push(u,f,A,f===a?a:o),u=A),f=f===a?o:a}n.push(u,f)}return new WW(r,c(this,sy),c(this,Ay),c(this,ay))},sw=function(i){const t=c(this,Ra);let e=0,r=t.length-1;for(;e<=r;){const n=e+r>>1,s=t[n][0];if(s===i)return n;s<i?e=n+1:r=n-1}return r+1},g6=function([,i,t]){const e=_(this,ro,sw).call(this,i);c(this,Ra).splice(e,0,[i,t])},m6=function([,i,t]){const e=_(this,ro,sw).call(this,i);for(let r=e;r<c(this,Ra).length;r++){const[n,s]=c(this,Ra)[r];if(n!==i)break;if(n===i&&s===t){c(this,Ra).splice(r,1);return}}for(let r=e-1;r>=0;r--){const[n,s]=c(this,Ra)[r];if(n!==i)break;if(n===i&&s===t){c(this,Ra).splice(r,1);return}}},y4=function(i){const[t,e,r]=i,n=[[t,e,r]],s=_(this,ro,sw).call(this,r);for(let A=0;A<s;A++){const[a,o]=c(this,Ra)[A];for(let l=0,h=n.length;l<h;l++){const[,u,f]=n[l];if(!(o<=u||f<=a)){if(u>=a){if(f>o)n[l][1]=o;else{if(h===1)return[];n.splice(l,1),l--,h--}continue}n[l][2]=a,f>o&&n.push([t,o,f])}}}return n};var ev,Cm;class WW extends Jt{constructor(t,e,r,n){super(),U(this,ev),U(this,Cm),F(this,Cm,t),F(this,ev,e),this.firstPoint=r,this.lastPoint=n}toSVGPath(){const t=[];for(const e of c(this,Cm)){let[r,n]=e;t.push(`M${r} ${n}`);for(let s=2;s<e.length;s+=2){const A=e[s],a=e[s+1];A===r?(t.push(`V${a}`),n=a):a===n&&(t.push(`H${A}`),r=A)}t.push("Z")}return t.join(" ")}serialize([t,e,r,n],s){const A=[],a=r-t,o=n-e;for(const l of c(this,Cm)){const h=new Array(l.length);for(let u=0;u<l.length;u+=2)h[u]=t+l[u]*a,h[u+1]=n-l[u+1]*o;A.push(h)}return A}get box(){return c(this,ev)}get classNamesForOutlining(){return["highlightOutline"]}}ev=new WeakMap,Cm=new WeakMap;class B4 extends u6{newFreeDrawOutline(t,e,r,n,s,A){return new jW(t,e,r,n,s,A)}}class jW extends f6{newOutliner(t,e,r,n,s,A=0){return new B4(t,e,r,n,s,A)}}var w0,oy,_h,Gf,rv,Zs,ly,hy,gp,yA,EA,Gn,v0,y0,hs,xm,ha,iv,or,C4,cy,w6,v6,DU,x4,Xc,cl,mp,y6,nv,uy,b6,B6,C6,x6,F6;const xs=class Rn extends Vr{constructor(t){super({...t,name:"highlightEditor"}),U(this,or),U(this,w0,null),U(this,oy,0),U(this,_h),U(this,Gf,null),U(this,rv,null),U(this,Zs,null),U(this,ly,null),U(this,hy,0),U(this,gp,null),U(this,yA,null),U(this,EA,null),U(this,Gn,!1),U(this,v0,null),U(this,y0,null),U(this,hs,null),U(this,xm,""),U(this,ha),U(this,iv,""),this.color=t.color||Rn._defaultColor,F(this,ha,t.thickness||Rn._defaultThickness),this.opacity=t.opacity||Rn._defaultOpacity,F(this,_h,t.boxes||null),F(this,iv,t.methodOfCreation||""),F(this,xm,t.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(F(this,Gn,!0),_(this,or,cy).call(this,t),_(this,or,Xc).call(this)):c(this,_h)&&(F(this,w0,t.anchorNode),F(this,oy,t.anchorOffset),F(this,ly,t.focusNode),F(this,hy,t.focusOffset),_(this,or,C4).call(this),_(this,or,Xc).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const t=Rn.prototype;return ke(this,"_keyboardManager",new $0([[["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:c(this,Gn)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:c(this,ha),methodOfCreation:c(this,iv)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var r;Vr.initialize(t,e),Rn._defaultColor||(Rn._defaultColor=((r=e.highlightColors)==null?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(t,e){switch(t){case _e.HIGHLIGHT_COLOR:Rn._defaultColor=e;break;case _e.HIGHLIGHT_THICKNESS:Rn._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return c(this,y0)}get commentButtonPosition(){return c(this,v0)}updateParams(t,e){switch(t){case _e.HIGHLIGHT_COLOR:_(this,or,w6).call(this,e);break;case _e.HIGHLIGHT_THICKNESS:_(this,or,v6).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[_e.HIGHLIGHT_COLOR,Rn._defaultColor],[_e.HIGHLIGHT_THICKNESS,Rn._defaultThickness]]}get propertiesToUpdate(){return[[_e.HIGHLIGHT_COLOR,this.color||Rn._defaultColor],[_e.HIGHLIGHT_THICKNESS,c(this,ha)||Rn._defaultThickness],[_e.HIGHLIGHT_FREE,c(this,Gn)]]}onUpdatedColor(){var t,e;(t=this.parent)==null||t.drawLayer.updateProperties(c(this,EA),{root:{fill:this.color,"fill-opacity":this.opacity}}),(e=c(this,rv))==null||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",F(this,rv,new zS({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(_(this,or,uy).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,_(this,or,uy).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){_(this,or,x4).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(_(this,or,Xc).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let r=!1;this.parent&&!t?_(this,or,x4).call(this):t&&(_(this,or,Xc).call(this,t),r=!this.parent&&((e=this.div)==null?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),r&&this.select()}rotate(t){var e,r,n;const{drawLayer:s}=this.parent;let A;c(this,Gn)?(t=(t-this.rotation+360)%360,A=_(e=Rn,cl,mp).call(e,c(this,yA).box,t)):A=_(r=Rn,cl,mp).call(r,[this.x,this.y,this.width,this.height],t),s.updateProperties(c(this,EA),{bbox:A,root:{"data-main-rotation":t}}),s.updateProperties(c(this,hs),{bbox:_(n=Rn,cl,mp).call(n,c(this,Zs).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();c(this,xm)&&(t.setAttribute("aria-label",c(this,xm)),t.setAttribute("role","mark")),c(this,Gn)?t.classList.add("free"):this.div.addEventListener("keydown",_(this,or,y6).bind(this),{signal:this._uiManager._signal});const e=F(this,gp,document.createElement("div"));return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=c(this,Gf),this.setDims(),xN(this,c(this,gp),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||(t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:_(this,or,nv).call(this,!0);break;case 1:case 3:_(this,or,nv).call(this,!1);break}}select(){var t;super.select(),c(this,hs)&&((t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),c(this,hs)&&((t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{selected:!1}}),c(this,Gn)||_(this,or,nv).call(this,!1))}get _mustFixPosition(){return!c(this,Gn)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(c(this,EA),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(c(this,hs),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:r,x:n,y:s}){const{x:A,y:a,width:o,height:l}=r.getBoundingClientRect(),h=new AbortController,u=t.combinedSignal(h),f=d=>{h.abort(),_(this,cl,x6).call(this,t,d)};window.addEventListener("blur",f,{signal:u}),window.addEventListener("pointerup",f,{signal:u}),window.addEventListener("pointerdown",Hr,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",AA,{signal:u}),r.addEventListener("pointermove",_(this,cl,C6).bind(this,t),{signal:u}),this._freeHighlight=new B4({x:n,y:s},[A,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(t,e,r){var n,s,A,a;let o=null;if(t instanceof $P){const{data:{quadPoints:C,rect:S,rotation:k,id:I,color:N,opacity:D,popupRef:Q,richText:K,contentsObj:L,creationDate:O,modificationDate:W},parent:{page:{pageNumber:R}}}=t;o=t={annotationType:Se.HIGHLIGHT,color:Array.from(N),opacity:D,quadPoints:C,boxes:null,pageIndex:R-1,rect:S.slice(0),rotation:k,annotationElementId:I,id:I,deleted:!1,popupRef:Q,richText:K,comment:(L==null?void 0:L.str)||null,creationDate:O,modificationDate:W}}else if(t instanceof XS){const{data:{inkLists:C,rect:S,rotation:k,id:I,color:N,borderStyle:{rawWidth:D},popupRef:Q,richText:K,contentsObj:L,creationDate:O,modificationDate:W},parent:{page:{pageNumber:R}}}=t;o=t={annotationType:Se.HIGHLIGHT,color:Array.from(N),thickness:D,inkLists:C,boxes:null,pageIndex:R-1,rect:S.slice(0),rotation:k,annotationElementId:I,id:I,deleted:!1,popupRef:Q,richText:K,comment:(L==null?void 0:L.str)||null,creationDate:O,modificationDate:W}}const{color:l,quadPoints:h,inkLists:u,outlines:f,opacity:d}=t,g=await super.deserialize(t,e,r);g.color=Nt.makeHexColor(...l),g.opacity=d||1,u&&F(g,ha,t.thickness),g._initialData=o,t.comment&&g.setCommentData(t);const[m,y]=g.pageDimensions,[w,b]=g.pageTranslation;if(h){const C=F(g,_h,[]);for(let S=0;S<h.length;S+=8)C.push({x:(h[S]-w)/m,y:1-(h[S+1]-b)/y,width:(h[S+2]-h[S])/m,height:(h[S+1]-h[S+5])/y});_(n=g,or,C4).call(n),_(s=g,or,Xc).call(s),g.rotate(g.rotation)}else if(u||f){F(g,Gn,!0);const C=(u||f.points)[0],S={x:C[0]-w,y:y-(C[1]-b)},k=new B4(S,[0,0,m,y],1,c(g,ha)/2,!0,.001);for(let D=0,Q=C.length;D<Q;D+=2)S.x=C[D]-w,S.y=y-(C[D+1]-b),k.add(S);const{id:I,clipPathId:N}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:g.color,"fill-opacity":g._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);_(A=g,or,cy).call(A,{highlightOutlines:k.getOutlines(),highlightId:I,clipPathId:N}),_(a=g,or,Xc).call(a),g.rotate(g.parentRotation)}return g}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=Vr._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),r=super.serialize(t);return Object.assign(r,{color:e,opacity:this.opacity,thickness:c(this,ha),quadPoints:_(this,or,b6).call(this),outlines:_(this,or,B6).call(this,r.rect)}),this.addComment(r),this.annotationElementId&&!_(this,or,F6).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};w0=new WeakMap,oy=new WeakMap,_h=new WeakMap,Gf=new WeakMap,rv=new WeakMap,Zs=new WeakMap,ly=new WeakMap,hy=new WeakMap,gp=new WeakMap,yA=new WeakMap,EA=new WeakMap,Gn=new WeakMap,v0=new WeakMap,y0=new WeakMap,hs=new WeakMap,xm=new WeakMap,ha=new WeakMap,iv=new WeakMap,or=new WeakSet,C4=function(){const i=new b4(c(this,_h),.001);F(this,yA,i.getOutlines()),[this.x,this.y,this.width,this.height]=c(this,yA).box;const t=new b4(c(this,_h),.0025,.001,this._uiManager.direction==="ltr");F(this,Zs,t.getOutlines());const{firstPoint:e}=c(this,yA);F(this,v0,[(e[0]-this.x)/this.width,(e[1]-this.y)/this.height]);const{lastPoint:r}=c(this,Zs);F(this,y0,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},cy=function({highlightOutlines:i,highlightId:t,clipPathId:e}){var r,n;if(F(this,yA,i),F(this,Zs,i.getNewOutline(c(this,ha)/2+1.5,.0025)),t>=0)F(this,EA,t),F(this,Gf,e),this.parent.drawLayer.finalizeDraw(t,{bbox:i.box,path:{d:i.toSVGPath()}}),F(this,hs,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:c(this,Zs).box,path:{d:c(this,Zs).toSVGPath()}},!0));else if(this.parent){const u=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(c(this,EA),{bbox:_(r=xs,cl,mp).call(r,c(this,yA).box,(u-this.rotation+360)%360),path:{d:i.toSVGPath()}}),this.parent.drawLayer.updateProperties(c(this,hs),{bbox:_(n=xs,cl,mp).call(n,c(this,Zs).box,u),path:{d:c(this,Zs).toSVGPath()}})}const[s,A,a,o]=i.box;switch(this.rotation){case 0:this.x=s,this.y=A,this.width=a,this.height=o;break;case 90:{const[u,f]=this.parentDimensions;this.x=A,this.y=1-s,this.width=a*f/u,this.height=o*u/f;break}case 180:this.x=1-s,this.y=1-A,this.width=a,this.height=o;break;case 270:{const[u,f]=this.parentDimensions;this.x=1-A,this.y=s,this.width=a*f/u,this.height=o*u/f;break}}const{firstPoint:l}=i;F(this,v0,[(l[0]-s)/a,(l[1]-A)/o]);const{lastPoint:h}=c(this,Zs);F(this,y0,[(h[0]-s)/a,(h[1]-A)/o])},w6=function(i){const t=(n,s)=>{this.color=n,this.opacity=s,this.onUpdatedColor()},e=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,i,xs._defaultOpacity),undo:t.bind(this,e,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(i)},!0)},v6=function(i){const t=c(this,ha),e=r=>{F(this,ha,r),_(this,or,DU).call(this,r)};this.addCommands({cmd:e.bind(this,i),undo:e.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:i},!0)},DU=function(i){c(this,Gn)&&(_(this,or,cy).call(this,{highlightOutlines:c(this,yA).getNewOutline(i/2)}),this.fixAndSetPosition(),this.setDims())},x4=function(){c(this,EA)===null||!this.parent||(this.parent.drawLayer.remove(c(this,EA)),F(this,EA,null),this.parent.drawLayer.remove(c(this,hs)),F(this,hs,null))},Xc=function(i=this.parent){c(this,EA)===null&&({id:$i(this,EA)._,clipPathId:$i(this,Gf)._}=i.drawLayer.draw({bbox:c(this,yA).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:c(this,Gn)},path:{d:c(this,yA).toSVGPath()}},!1,!0),F(this,hs,i.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:c(this,Gn)},bbox:c(this,Zs).box,path:{d:c(this,Zs).toSVGPath()}},c(this,Gn))),c(this,gp)&&(c(this,gp).style.clipPath=c(this,Gf)))},cl=new WeakSet,mp=function([i,t,e,r],n){switch(n){case 90:return[1-t-r,i,r,e];case 180:return[1-i-e,1-t-r,e,r];case 270:return[t,1-i-e,r,e]}return[i,t,e,r]},y6=function(i){xs._keyboardManager.exec(this,i)},nv=function(i){if(!c(this,w0))return;const t=window.getSelection();i?t.setPosition(c(this,w0),c(this,oy)):t.setPosition(c(this,ly),c(this,hy))},uy=function(){return c(this,Gn)?this.rotation:0},b6=function(){if(c(this,Gn))return null;const[i,t]=this.pageDimensions,[e,r]=this.pageTranslation,n=c(this,_h),s=new Float32Array(n.length*8);let A=0;for(const{x:a,y:o,width:l,height:h}of n){const u=a*i+e,f=(1-o)*t+r;s[A]=s[A+4]=u,s[A+1]=s[A+3]=f,s[A+2]=s[A+6]=u+l*i,s[A+5]=s[A+7]=f-h*t,A+=8}return s},B6=function(i){return c(this,yA).serialize(i,_(this,or,uy).call(this))},C6=function(i,t){this._freeHighlight.add(t)&&i.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},x6=function(i,t){this._freeHighlight.isEmpty()?i.drawLayer.remove(this._freeHighlightId):i.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},F6=function(i){const{color:t}=this._initialData;return this.hasEditedComment||i.color.some((e,r)=>e!==t[r])},U(xs,cl),ut(xs,"_defaultColor",null),ut(xs,"_defaultOpacity",1),ut(xs,"_defaultThickness",12),ut(xs,"_type","highlight"),ut(xs,"_editorType",Se.HIGHLIGHT),ut(xs,"_freeHighlightId",-1),ut(xs,"_freeHighlight",null),ut(xs,"_freeHighlightClipId","");let OU=xs;var bf;class S6{constructor(){U(this,bf,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,r]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,r)}updateSVGProperty(t,e){c(this,bf)[t]=e}toSVGProperties(){const t=c(this,bf);return F(this,bf,Object.create(null)),{root:t}}reset(){F(this,bf,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){rr("Not implemented")}}bf=new WeakMap;var Us,Fm,pn,zf,qf,Ir,F4,$B,S4,Sm,RU,sv,b0,Bf;const ih=class ar extends Vr{constructor(t){super(t),U(this,Ir),U(this,Us,null),U(this,Fm),ut(this,"_colorPicker",null),ut(this,"_drawId",null),F(this,Fm,t.mustBeCommitted||!1),this._addOutlines(t)}onUpdatedColor(){var t;(t=this._colorPicker)==null||t.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var t,e;(e=(t=this._colorPicker)==null?void 0:t.updateOpacity)==null||e.call(t,this.opacity)}_addOutlines(t){t.drawOutlines&&(_(this,Ir,F4).call(this,t),_(this,Ir,Sm).call(this))}static _mergeSVGProperties(t,e){const r=new Set(Object.keys(t));for(const[n,s]of Object.entries(e))r.has(n)?Object.assign(t[n],s):t[n]=s;return t}static getDefaultDrawingOptions(t){rr("Not implemented")}static get typesMap(){rr("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,e),this._currentParent&&(c(ar,pn).updateProperty(r,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const r=this.constructor.typesMap.get(t);r&&this._updateProperty(t,r,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[r,n]of this.typesMap)t.push([r,e[n]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[r,n]of this.constructor.typesMap)t.push([r,e[n]]);return t}_updateProperty(t,e,r){const n=this._drawingOptions,s=n[e],A=a=>{var o;n.updateProperty(e,a);const l=c(this,Us).updateProperty(e,a);l&&_(this,Ir,b0).call(this,l),(o=this.parent)==null||o.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:A.bind(this,r),undo:A.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){const r=this.constructor.typesMap.get(this.colorType),n=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,A=s[r],a=s[n],o=(l,h)=>{var u;s.updateProperty(r,l),s.updateProperty(n,h),c(this,Us).updateProperty(r,l),c(this,Us).updateProperty(n,h),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,A,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties(c(this,Us).getPathResizingSVGProperties(_(this,Ir,sv).call(this)),{bbox:_(this,Ir,Bf).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties(c(this,Us).getPathResizedSVGProperties(_(this,Ir,sv).call(this)),{bbox:_(this,Ir,Bf).call(this)}))}_onTranslating(t,e){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,{bbox:_(this,Ir,Bf).call(this)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties(c(this,Us).getPathTranslatedSVGProperties(_(this,Ir,sv).call(this),this.parentDimensions),{bbox:_(this,Ir,Bf).call(this)}))}_onStartDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,c(this,Fm)&&(F(this,Fm,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){_(this,Ir,S4).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(_(this,Ir,Sm).call(this),_(this,Ir,b0).call(this,c(this,Us).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let r=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),_(this,Ir,S4).call(this)):t&&(this._uiManager.addShouldRescale(this),_(this,Ir,Sm).call(this,t),r=!this.parent&&((e=this.div)==null?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),r&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties({bbox:_(this,Ir,Bf).call(this)},c(this,Us).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&_(this,Ir,b0).call(this,c(this,Us).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const r=super.render();r.classList.add("draw");const n=document.createElement("div");return r.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),r}static createDrawerInstance(t,e,r,n,s){rr("Not implemented")}static startDrawing(t,e,r,n){var s;const{target:A,offsetX:a,offsetY:o,pointerId:l,pointerType:h}=n;if(Bs.isInitializedAndDifferentPointerType(h))return;const{viewport:{rotation:u}}=t,{width:f,height:d}=A.getBoundingClientRect(),g=F(ar,zf,new AbortController),m=t.combinedSignal(g);if(Bs.setPointer(h,l),window.addEventListener("pointerup",y=>{Bs.isSamePointerIdOrRemove(y.pointerId)&&this._endDraw(y)},{signal:m}),window.addEventListener("pointercancel",y=>{Bs.isSamePointerIdOrRemove(y.pointerId)&&this._currentParent.endDrawingSession()},{signal:m}),window.addEventListener("pointerdown",y=>{Bs.isSamePointerType(y.pointerType)&&(Bs.initializeAndAddPointerId(y.pointerId),c(ar,pn).isCancellable()&&(c(ar,pn).removeLastElement(),c(ar,pn).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",AA,{signal:m}),A.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),A.addEventListener("touchmove",y=>{Bs.isSameTimeStamp(y.timeStamp)&&Hr(y)},{signal:m}),t.toggleDrawing(),(s=e._editorUndoBar)==null||s.hide(),c(ar,pn)){t.drawLayer.updateProperties(this._currentDrawId,c(ar,pn).startNew(a,o,f,d,u));return}e.updateUIForDefaultProperties(this),F(ar,pn,this.createDrawerInstance(a,o,f,d,u)),F(ar,qf,this.getDefaultDrawingOptions()),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(c(ar,qf).toSVGProperties(),c(ar,pn).defaultSVGProperties),!0,!1)}static _drawMove(t){if(Bs.isSameTimeStamp(t.timeStamp),!c(ar,pn))return;const{offsetX:e,offsetY:r,pointerId:n}=t;if(Bs.isSamePointerId(n)){if(Bs.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,c(ar,pn).add(e,r)),Bs.setTimeStamp(t.timeStamp),Hr(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,F(ar,pn,null),F(ar,qf,null),Bs.clearTimeStamp()),c(ar,zf)&&(c(ar,zf).abort(),F(ar,zf,null),Bs.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),(t==null?void 0:t.target)===e.div&&e.drawLayer.updateProperties(this._currentDrawId,c(ar,pn).end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const r=c(ar,pn),n=this._currentDrawId,s=r.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,r.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(n,r.removeLastElement())},mustExec:!1,type:_e.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(_e.DRAW_STEP),!c(ar,pn).isEmpty()){const{pageDimensions:[r,n],scale:s}=e,A=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:c(ar,pn).getOutlines(r*s,n*s,s,this._INNER_MARGIN),drawingOptions:c(ar,qf),mustBeCommitted:!t});return this._cleanup(!0),A}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,r,n,s,A){rr("Not implemented")}static async deserialize(t,e,r){var n,s;const{rawDims:{pageWidth:A,pageHeight:a,pageX:o,pageY:l}}=e.viewport,h=this.deserializeDraw(o,l,A,a,this._INNER_MARGIN,t),u=await super.deserialize(t,e,r);return u.createDrawingOptions(t),_(n=u,Ir,F4).call(n,{drawOutlines:h}),_(s=u,Ir,Sm).call(s),u.onScaleChanging(),u.rotate(),u}serializeDraw(t){const[e,r]=this.pageTranslation,[n,s]=this.pageDimensions;return c(this,Us).serialize([e,r,n,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Us=new WeakMap,Fm=new WeakMap,pn=new WeakMap,zf=new WeakMap,qf=new WeakMap,Ir=new WeakSet,F4=function({drawOutlines:i,drawId:t,drawingOptions:e}){F(this,Us,i),this._drawingOptions||(this._drawingOptions=e),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,i.defaultProperties)):this._drawId=_(this,Ir,$B).call(this,i,this.parent),_(this,Ir,b0).call(this,i.box)},$B=function(i,t){const{id:e}=t.drawLayer.draw(ih._mergeSVGProperties(this._drawingOptions.toSVGProperties(),i.defaultSVGProperties),!1,!1);return e},S4=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Sm=function(i=this.parent){if(!(this._drawId!==null&&this.parent===i)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,i.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=_(this,Ir,$B).call(this,c(this,Us),i)}},RU=function([i,t,e,r]){const{parentDimensions:[n,s],rotation:A}=this;switch(A){case 90:return[t,1-i,e*(s/n),r*(n/s)];case 180:return[1-i,1-t,e,r];case 270:return[1-t,i,e*(s/n),r*(n/s)];default:return[i,t,e,r]}},sv=function(){const{x:i,y:t,width:e,height:r,parentDimensions:[n,s],rotation:A}=this;switch(A){case 90:return[1-t,i,e*(n/s),r*(s/n)];case 180:return[1-i,1-t,e,r];case 270:return[t,1-i,e*(n/s),r*(s/n)];default:return[i,t,e,r]}},b0=function(i){[this.x,this.y,this.width,this.height]=_(this,Ir,RU).call(this,i),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Bf=function(){const{x:i,y:t,width:e,height:r,rotation:n,parentRotation:s,parentDimensions:[A,a]}=this;switch((n*4+s)/90){case 1:return[1-t-r,i,r,e];case 2:return[1-i-e,1-t-r,e,r];case 3:return[t,1-i-e,r,e];case 4:return[i,t-e*(A/a),r*(a/A),e*(A/a)];case 5:return[1-t,i,e*(A/a),r*(a/A)];case 6:return[1-i-r*(a/A),1-t,r*(a/A),e*(A/a)];case 7:return[t-e*(A/a),1-i-r*(a/A),e*(A/a),r*(a/A)];case 8:return[i-e,t-r,e,r];case 9:return[1-t,i-e,r,e];case 10:return[1-i,1-t,e,r];case 11:return[t-r,1-i,r,e];case 12:return[i-r*(a/A),t,r*(a/A),e*(A/a)];case 13:return[1-t-e*(A/a),i-r*(a/A),e*(A/a),r*(a/A)];case 14:return[1-i,1-t-e*(A/a),r*(a/A),e*(A/a)];case 15:return[t,1-i,e*(A/a),r*(a/A)];default:return[i,t,e,r]}},ut(ih,"_currentDrawId",-1),ut(ih,"_currentParent",null),U(ih,pn,null),U(ih,zf,null),U(ih,qf,null),ut(ih,"_INNER_MARGIN",3);let E6=ih;var jo,cn,un,Xf,Em,Fs,dn,na,Cf,Yf,$f,km,Av;class KW{constructor(t,e,r,n,s,A){U(this,km),U(this,jo,new Float64Array(6)),U(this,cn),U(this,un),U(this,Xf),U(this,Em),U(this,Fs),U(this,dn,""),U(this,na,0),U(this,Cf,new Z0),U(this,Yf),U(this,$f),F(this,Yf,r),F(this,$f,n),F(this,Xf,s),F(this,Em,A),[t,e]=_(this,km,Av).call(this,t,e);const a=F(this,cn,[NaN,NaN,NaN,NaN,t,e]);F(this,Fs,[t,e]),F(this,un,[{line:a,points:c(this,Fs)}]),c(this,jo).set(a,0)}updateProperty(t,e){t==="stroke-width"&&F(this,Em,e)}isEmpty(){return!c(this,un)||c(this,un).length===0}isCancellable(){return c(this,Fs).length<=10}add(t,e){[t,e]=_(this,km,Av).call(this,t,e);const[r,n,s,A]=c(this,jo).subarray(2,6),a=t-s,o=e-A;return Math.hypot(c(this,Yf)*a,c(this,$f)*o)<=2?null:(c(this,Fs).push(t,e),isNaN(r)?(c(this,jo).set([s,A,t,e],2),c(this,cn).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(c(this,jo)[0])&&c(this,cn).splice(6,6),c(this,jo).set([r,n,s,A,t,e],0),c(this,cn).push(...Jt.createBezierPoints(r,n,s,A,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(c(this,Fs).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,r,n,s){F(this,Yf,r),F(this,$f,n),F(this,Xf,s),[t,e]=_(this,km,Av).call(this,t,e);const A=F(this,cn,[NaN,NaN,NaN,NaN,t,e]);F(this,Fs,[t,e]);const a=c(this,un).at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),c(this,un).push({line:A,points:c(this,Fs)}),c(this,jo).set(A,0),F(this,na,0),this.toSVGPath(),null}getLastElement(){return c(this,un).at(-1)}setLastElement(t){return c(this,un)?(c(this,un).push(t),F(this,cn,t.line),F(this,Fs,t.points),F(this,na,0),{path:{d:this.toSVGPath()}}):c(this,Cf).setLastElement(t)}removeLastElement(){if(!c(this,un))return c(this,Cf).removeLastElement();c(this,un).pop(),F(this,dn,"");for(let t=0,e=c(this,un).length;t<e;t++){const{line:r,points:n}=c(this,un)[t];F(this,cn,r),F(this,Fs,n),F(this,na,0),this.toSVGPath()}return{path:{d:c(this,dn)}}}toSVGPath(){const t=Jt.svgRound(c(this,cn)[4]),e=Jt.svgRound(c(this,cn)[5]);if(c(this,Fs).length===2)return F(this,dn,`${c(this,dn)} M ${t} ${e} Z`),c(this,dn);if(c(this,Fs).length<=6){const n=c(this,dn).lastIndexOf("M");F(this,dn,`${c(this,dn).slice(0,n)} M ${t} ${e}`),F(this,na,6)}if(c(this,Fs).length===4){const n=Jt.svgRound(c(this,cn)[10]),s=Jt.svgRound(c(this,cn)[11]);return F(this,dn,`${c(this,dn)} L ${n} ${s}`),F(this,na,12),c(this,dn)}const r=[];c(this,na)===0&&(r.push(`M ${t} ${e}`),F(this,na,6));for(let n=c(this,na),s=c(this,cn).length;n<s;n+=6){const[A,a,o,l,h,u]=c(this,cn).slice(n,n+6).map(Jt.svgRound);r.push(`C${A} ${a} ${o} ${l} ${h} ${u}`)}return F(this,dn,c(this,dn)+r.join(" ")),F(this,na,c(this,cn).length),c(this,dn)}getOutlines(t,e,r,n){const s=c(this,un).at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),c(this,Cf).build(c(this,un),t,e,r,c(this,Xf),c(this,Em),n),F(this,jo,null),F(this,cn,null),F(this,un,null),F(this,dn,null),c(this,Cf)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}jo=new WeakMap,cn=new WeakMap,un=new WeakMap,Xf=new WeakMap,Em=new WeakMap,Fs=new WeakMap,dn=new WeakMap,na=new WeakMap,Cf=new WeakMap,Yf=new WeakMap,$f=new WeakMap,km=new WeakSet,Av=function(i,t){return Jt._normalizePoint(i,t,c(this,Yf),c(this,$f),c(this,Xf))};var Is,av,dy,bA,sl,Al,B0,C0,wp,iA,ul,k6,U6,I6;class Z0 extends Jt{constructor(){super(...arguments),U(this,iA),U(this,Is),U(this,av,0),U(this,dy),U(this,bA),U(this,sl),U(this,Al),U(this,B0),U(this,C0),U(this,wp)}build(t,e,r,n,s,A,a){F(this,sl,e),F(this,Al,r),F(this,B0,n),F(this,C0,s),F(this,wp,A),F(this,dy,a??0),F(this,bA,t),_(this,iA,U6).call(this)}get thickness(){return c(this,wp)}setLastElement(t){return c(this,bA).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return c(this,bA).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of c(this,bA)){if(t.push(`M${Jt.svgRound(e[4])} ${Jt.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${Jt.svgRound(e[10])} ${Jt.svgRound(e[11])}`);continue}for(let r=6,n=e.length;r<n;r+=6){const[s,A,a,o,l,h]=e.subarray(r,r+6).map(Jt.svgRound);t.push(`C${s} ${A} ${a} ${o} ${l} ${h}`)}}return t.join("")}serialize([t,e,r,n],s){const A=[],a=[],[o,l,h,u]=_(this,iA,k6).call(this);let f,d,g,m,y,w,b,C,S;switch(c(this,C0)){case 0:S=Jt._rescale,f=t,d=e+n,g=r,m=-n,y=t+o*r,w=e+(1-l-u)*n,b=t+(o+h)*r,C=e+(1-l)*n;break;case 90:S=Jt._rescaleAndSwap,f=t,d=e,g=r,m=n,y=t+l*r,w=e+o*n,b=t+(l+u)*r,C=e+(o+h)*n;break;case 180:S=Jt._rescale,f=t+r,d=e,g=-r,m=n,y=t+(1-o-h)*r,w=e+l*n,b=t+(1-o)*r,C=e+(l+u)*n;break;case 270:S=Jt._rescaleAndSwap,f=t+r,d=e+n,g=-r,m=-n,y=t+(1-l-u)*r,w=e+(1-o-h)*n,b=t+(1-l)*r,C=e+(1-o)*n;break}for(const{line:k,points:I}of c(this,bA))A.push(S(k,f,d,g,m,s?new Array(k.length):null)),a.push(S(I,f,d,g,m,s?new Array(I.length):null));return{lines:A,points:a,rect:[y,w,b,C]}}static deserialize(t,e,r,n,s,{paths:{lines:A,points:a},rotation:o,thickness:l}){const h=[];let u,f,d,g,m;switch(o){case 0:m=Jt._rescale,u=-t/r,f=e/n+1,d=1/r,g=-1/n;break;case 90:m=Jt._rescaleAndSwap,u=-e/n,f=-t/r,d=1/n,g=1/r;break;case 180:m=Jt._rescale,u=t/r+1,f=-e/n,d=-1/r,g=1/n;break;case 270:m=Jt._rescaleAndSwap,u=e/n+1,f=t/r+1,d=-1/n,g=-1/r;break}if(!A){A=[];for(const w of a){const b=w.length;if(b===2){A.push(new Float32Array([NaN,NaN,NaN,NaN,w[0],w[1]]));continue}if(b===4){A.push(new Float32Array([NaN,NaN,NaN,NaN,w[0],w[1],NaN,NaN,NaN,NaN,w[2],w[3]]));continue}const C=new Float32Array(3*(b-2));A.push(C);let[S,k,I,N]=w.subarray(0,4);C.set([NaN,NaN,NaN,NaN,S,k],0);for(let D=4;D<b;D+=2){const Q=w[D],K=w[D+1];C.set(Jt.createBezierPoints(S,k,I,N,Q,K),(D-2)*3),[S,k,I,N]=[I,N,Q,K]}}}for(let w=0,b=A.length;w<b;w++)h.push({line:m(A[w].map(C=>C??NaN),u,f,d,g),points:m(a[w].map(C=>C??NaN),u,f,d,g)});const y=new this.prototype.constructor;return y.build(h,r,n,1,o,l,s),y}get box(){return c(this,Is)}updateProperty(t,e){return t==="stroke-width"?_(this,iA,I6).call(this,e):null}updateParentDimensions([t,e],r){const[n,s]=_(this,iA,ul).call(this);F(this,sl,t),F(this,Al,e),F(this,B0,r);const[A,a]=_(this,iA,ul).call(this),o=A-n,l=a-s,h=c(this,Is);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return F(this,av,t),{path:{transform:this.rotationTransform}}}get viewBox(){return c(this,Is).map(Jt.svgRound).join(" ")}get defaultProperties(){const[t,e]=c(this,Is);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=c(this,Is);let r=0,n=0,s=0,A=0,a=0,o=0;switch(c(this,av)){case 90:n=e/t,s=-t/e,a=t;break;case 180:r=-1,A=-1,a=t,o=e;break;case 270:n=-e/t,s=t/e,o=e;break;default:return""}return`matrix(${r} ${n} ${s} ${A} ${Jt.svgRound(a)} ${Jt.svgRound(o)})`}getPathResizingSVGProperties([t,e,r,n]){const[s,A]=_(this,iA,ul).call(this),[a,o,l,h]=c(this,Is);if(Math.abs(l-s)<=Jt.PRECISION||Math.abs(h-A)<=Jt.PRECISION){const m=t+r/2-(a+l/2),y=e+n/2-(o+h/2);return{path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:`${this.rotationTransform} translate(${m} ${y})`}}}const u=(r-2*s)/(l-2*s),f=(n-2*A)/(h-2*A),d=l/r,g=h/n;return{path:{"transform-origin":`${Jt.svgRound(a)} ${Jt.svgRound(o)}`,transform:`${this.rotationTransform} scale(${d} ${g}) translate(${Jt.svgRound(s)} ${Jt.svgRound(A)}) scale(${u} ${f}) translate(${Jt.svgRound(-s)} ${Jt.svgRound(-A)})`}}}getPathResizedSVGProperties([t,e,r,n]){const[s,A]=_(this,iA,ul).call(this),a=c(this,Is),[o,l,h,u]=a;if(a[0]=t,a[1]=e,a[2]=r,a[3]=n,Math.abs(h-s)<=Jt.PRECISION||Math.abs(u-A)<=Jt.PRECISION){const y=t+r/2-(o+h/2),w=e+n/2-(l+u/2);for(const{line:b,points:C}of c(this,bA))Jt._translate(b,y,w,b),Jt._translate(C,y,w,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const f=(r-2*s)/(h-2*s),d=(n-2*A)/(u-2*A),g=-f*(o+s)+t+s,m=-d*(l+A)+e+A;if(f!==1||d!==1||g!==0||m!==0)for(const{line:y,points:w}of c(this,bA))Jt._rescale(y,g,m,f,d,y),Jt._rescale(w,g,m,f,d,w);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],r){const[n,s]=r,A=c(this,Is),a=t-A[0],o=e-A[1];if(c(this,sl)===n&&c(this,Al)===s)for(const{line:l,points:h}of c(this,bA))Jt._translate(l,a,o,l),Jt._translate(h,a,o,h);else{const l=c(this,sl)/n,h=c(this,Al)/s;F(this,sl,n),F(this,Al,s);for(const{line:u,points:f}of c(this,bA))Jt._rescale(u,a,o,l,h,u),Jt._rescale(f,a,o,l,h,f);A[2]*=l,A[3]*=h}return A[0]=t,A[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`}}}get defaultSVGProperties(){const t=c(this,Is);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Jt.svgRound(t[0])} ${Jt.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}Is=new WeakMap,av=new WeakMap,dy=new WeakMap,bA=new WeakMap,sl=new WeakMap,Al=new WeakMap,B0=new WeakMap,C0=new WeakMap,wp=new WeakMap,iA=new WeakSet,ul=function(i=c(this,wp)){const t=c(this,dy)+i/2*c(this,B0);return c(this,C0)%180===0?[t/c(this,sl),t/c(this,Al)]:[t/c(this,Al),t/c(this,sl)]},k6=function(){const[i,t,e,r]=c(this,Is),[n,s]=_(this,iA,ul).call(this,0);return[i+n,t+s,e-2*n,r-2*s]},U6=function(){const i=F(this,Is,pu.slice());for(const{line:r}of c(this,bA)){if(r.length<=12){for(let A=4,a=r.length;A<a;A+=6)Nt.pointBoundingBox(r[A],r[A+1],i);continue}let n=r[4],s=r[5];for(let A=6,a=r.length;A<a;A+=6){const[o,l,h,u,f,d]=r.subarray(A,A+6);Nt.bezierBoundingBox(n,s,o,l,h,u,f,d,i),n=f,s=d}}const[t,e]=_(this,iA,ul).call(this);i[0]=Mr(i[0]-t,0,1),i[1]=Mr(i[1]-e,0,1),i[2]=Mr(i[2]+t,0,1),i[3]=Mr(i[3]+e,0,1),i[2]-=i[0],i[3]-=i[1]},I6=function(i){const[t,e]=_(this,iA,ul).call(this);F(this,wp,i);const[r,n]=_(this,iA,ul).call(this),[s,A]=[r-t,n-e],a=c(this,Is);return a[0]-=s,a[1]-=A,a[2]+=2*s,a[3]+=2*A,a};class Jy extends S6{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Vr._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Jy(this._viewParameters);return t.updateAll(this),t}}var E4,Q6;const ov=class L6 extends E6{constructor(t){super({...t,name:"inkEditor"}),U(this,E4),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){Vr.initialize(t,e),this._defaultDrawingOptions=new Jy(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return ke(this,"typesMap",new Map([[_e.INK_THICKNESS,"stroke-width"],[_e.INK_COLOR,"stroke"],[_e.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,r,n,s){return new KW(t,e,r,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,r,n,s,A){return Z0.deserialize(t,e,r,n,s,A)}static async deserialize(t,e,r){let n=null;if(t instanceof XS){const{data:{inkLists:A,rect:a,rotation:o,id:l,color:h,opacity:u,borderStyle:{rawWidth:f},popupRef:d,richText:g,contentsObj:m,creationDate:y,modificationDate:w},parent:{page:{pageNumber:b}}}=t;n=t={annotationType:Se.INK,color:Array.from(h),thickness:f,opacity:u,paths:{points:A},boxes:null,pageIndex:b-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:g,comment:(m==null?void 0:m.str)||null,creationDate:y,modificationDate:w}}const s=await super.deserialize(t,e,r);return s._initialData=n,t.comment&&s.setCommentData(t),s}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new VP(this)),[["colorPicker",this._colorPicker]]}get colorType(){return _e.INK_COLOR}get colorAndOpacityType(){return _e.INK_COLOR_AND_OPACITY}get opacityType(){return _e.INK_OPACITY}updateParams(t,e){if(t===_e.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===_e.INK_COLOR_AND_OPACITY){super.updateDefaultParams(_e.INK_COLOR,e.color),super.updateDefaultParams(_e.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:r}=this;e.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:r}){this._drawingOptions=L6.getDefaultDrawingOptions({stroke:Nt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":r})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:r}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":s,"stroke-width":A}}=this,a=Object.assign(super.serialize(t),{color:Vr._colorManager.convert(n),opacity:s,thickness:A,paths:{lines:e,points:r}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!_(this,E4,Q6).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:r}=this.serializeDraw(!1);return t.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}};E4=new WeakSet,Q6=function(i){const{color:t,thickness:e,opacity:r,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||i.color.some((s,A)=>s!==t[A])||i.thickness!==e||i.opacity!==r||i.pageIndex!==n},ut(ov,"_type","ink"),ut(ov,"_editorType",Se.INK),ut(ov,"_defaultDrawingOptions",null);let GW=ov;class k4 extends Z0{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Aw=8,sg=3;var vp,Xi,ZB,_a,HU,VU,U4,aw,_6,M6,T6,I4,Q4,N6;class io{static extractContoursFromText(t,{fontFamily:e,fontStyle:r,fontWeight:n},s,A,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const u=200,f=h.font=`${r} ${n} ${u}px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:g,actualBoundingBoxAscent:m,actualBoundingBoxDescent:y,fontBoundingBoxAscent:w,fontBoundingBoxDescent:b,width:C}=h.measureText(t),S=1.5,k=Math.ceil(Math.max(Math.abs(d)+Math.abs(g)||0,C)*S),I=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||u,Math.abs(w)+Math.abs(b)||u)*S);l=new OffscreenCanvas(k,I),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,k,I),h.fillStyle="black",h.fillText(t,k*(S-1)/2,I*(3-S)/2);const N=_(this,Xi,I4).call(this,h.getImageData(0,0,k,I).data),D=_(this,Xi,T6).call(this,N),Q=_(this,Xi,Q4).call(this,D),K=_(this,Xi,U4).call(this,N,k,I,Q);return this.processDrawnLines({lines:{curves:K,width:k,height:I},pageWidth:s,pageHeight:A,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,r,n,s){const[A,a,o]=_(this,Xi,N6).call(this,t),[l,h]=_(this,Xi,M6).call(this,A,a,o,Math.hypot(a,o)*c(this,vp).sigmaSFactor,c(this,vp).sigmaR,c(this,vp).kernelSize),u=_(this,Xi,Q4).call(this,h),f=_(this,Xi,U4).call(this,l,a,o,u);return this.processDrawnLines({lines:{curves:f,width:a,height:o},pageWidth:e,pageHeight:r,rotation:n,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:r,rotation:n,innerMargin:s,mustSmooth:A,areContours:a}){n%180!==0&&([e,r]=[r,e]);const{curves:o,width:l,height:h}=t,u=t.thickness??0,f=[],d=Math.min(e/l,r/h),g=d/e,m=d/r,y=[];for(const{points:b}of o){const C=A?_(this,Xi,_6).call(this,b):b;if(!C)continue;y.push(C);const S=C.length,k=new Float32Array(S),I=new Float32Array(3*(S===2?2:S-2));if(f.push({line:I,points:k}),S===2){k[0]=C[0]*g,k[1]=C[1]*m,I.set([NaN,NaN,NaN,NaN,k[0],k[1]],0);continue}let[N,D,Q,K]=C;N*=g,D*=m,Q*=g,K*=m,k.set([N,D,Q,K],0),I.set([NaN,NaN,NaN,NaN,N,D],0);for(let L=4;L<S;L+=2){const O=k[L]=C[L]*g,W=k[L+1]=C[L+1]*m;I.set(Jt.createBezierPoints(N,D,Q,K,O,W),(L-2)*3),[N,D,Q,K]=[Q,K,O,W]}}if(f.length===0)return null;const w=a?new k4:new Z0;return w.build(f,e,r,1,n,a?0:u,s),{outline:w,newCurves:y,areContours:a,thickness:u,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:r,width:n,height:s}){let A=1/0,a=-1/0,o=0;for(const w of t){o+=w.length;for(let b=2,C=w.length;b<C;b++){const S=w[b]-w[b-2];A=Math.min(A,S),a=Math.max(a,S)}}let l;A>=-128&&a<=127?l=Int8Array:A>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const h=t.length,u=Aw+sg*h,f=new Uint32Array(u);let d=0;f[d++]=u*Uint32Array.BYTES_PER_ELEMENT+(o-2*h)*l.BYTES_PER_ELEMENT,f[d++]=0,f[d++]=n,f[d++]=s,f[d++]=e?0:1,f[d++]=Math.max(0,Math.floor(r??0)),f[d++]=h,f[d++]=l.BYTES_PER_ELEMENT;for(const w of t)f[d++]=w.length-2,f[d++]=w[0],f[d++]=w[1];const g=new CompressionStream("deflate-raw"),m=g.writable.getWriter();await m.ready,m.write(f);const y=l.prototype.constructor;for(const w of t){const b=new y(w.length-2);for(let C=2,S=w.length;C<S;C++)b[C-2]=w[C]-w[C-2];m.write(b)}return m.close(),(await new Response(g.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:r,writable:n}=new DecompressionStream("deflate-raw"),s=n.getWriter();await s.ready,s.write(e).then(async()=>{await s.ready,await s.close()}).catch(()=>{});let A=null,a=0;for await(const C of r)A||(A=new Uint8Array(new Uint32Array(C.buffer,0,4)[0])),A.set(C,a),a+=C.length;const o=new Uint32Array(A.buffer,0,A.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const h=o[2],u=o[3],f=o[4]===0,d=o[5],g=o[6],m=o[7],y=[],w=(Aw+sg*g)*Uint32Array.BYTES_PER_ELEMENT;let b;switch(m){case Int8Array.BYTES_PER_ELEMENT:b=new Int8Array(A.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:b=new Int16Array(A.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:b=new Int32Array(A.buffer,w);break}a=0;for(let C=0;C<g;C++){const S=o[sg*C+Aw],k=new Float32Array(S+2);y.push(k);for(let I=0;I<sg-1;I++)k[I]=o[sg*C+Aw+I+1];for(let I=0;I<S;I++)k[I+2]=k[I]+b[a++]}return{areContours:f,thickness:d,outlines:y,width:h,height:u}}catch(e){return Me(`decompressSignature: ${e}`),null}}}vp=new WeakMap,Xi=new WeakSet,ZB=function(i,t,e,r){return e-=i,r-=t,e===0?r>0?0:4:e===1?r+6:2-r},_a=new WeakMap,HU=function(i,t,e,r,n,s,A){const a=_(this,Xi,ZB).call(this,e,r,n,s);for(let o=0;o<8;o++){const l=(-o+a-A+16)%8,h=c(this,_a)[2*l],u=c(this,_a)[2*l+1];if(i[(e+h)*t+(r+u)]!==0)return l}return-1},VU=function(i,t,e,r,n,s,A){const a=_(this,Xi,ZB).call(this,e,r,n,s);for(let o=0;o<8;o++){const l=(o+a+A+16)%8,h=c(this,_a)[2*l],u=c(this,_a)[2*l+1];if(i[(e+h)*t+(r+u)]!==0)return l}return-1},U4=function(i,t,e,r){const n=i.length,s=new Int32Array(n);for(let l=0;l<n;l++)s[l]=i[l]<=r?1:0;for(let l=1;l<e-1;l++)s[l*t]=s[l*t+t-1]=0;for(let l=0;l<t;l++)s[l]=s[t*e-1-l]=0;let A=1,a;const o=[];for(let l=1;l<e-1;l++){a=1;for(let h=1;h<t-1;h++){const u=l*t+h,f=s[u];if(f===0)continue;let d=l,g=h;if(f===1&&s[u-1]===0)A+=1,g-=1;else if(f>=1&&s[u+1]===0)A+=1,g+=1,f>1&&(a=f);else{f!==1&&(a=Math.abs(f));continue}const m=[h,l],y=g===h+1,w={isHole:y,points:m,id:A,parent:0};o.push(w);let b;for(const K of o)if(K.id===a){b=K;break}b?b.isHole?w.parent=y?b.parent:a:w.parent=y?a:b.parent:w.parent=y?a:0;const C=_(this,Xi,HU).call(this,s,t,l,h,d,g,0);if(C===-1){s[u]=-A,s[u]!==1&&(a=Math.abs(s[u]));continue}let S=c(this,_a)[2*C],k=c(this,_a)[2*C+1];const I=l+S,N=h+k;d=I,g=N;let D=l,Q=h;for(;;){const K=_(this,Xi,VU).call(this,s,t,D,Q,d,g,1);S=c(this,_a)[2*K],k=c(this,_a)[2*K+1];const L=D+S,O=Q+k;m.push(O,L);const W=D*t+Q;if(s[W+1]===0?s[W]=-A:s[W]===1&&(s[W]=A),L===l&&O===h&&D===I&&Q===N){s[u]!==1&&(a=Math.abs(s[u]));break}else d=D,g=Q,D=L,Q=O}}}return o},aw=function(i,t,e,r){if(e-t<=4){for(let I=t;I<e-2;I+=2)r.push(i[I],i[I+1]);return}const n=i[t],s=i[t+1],A=i[e-4]-n,a=i[e-3]-s,o=Math.hypot(A,a),l=A/o,h=a/o,u=l*s-h*n,f=a/A,d=1/o,g=Math.atan(f),m=Math.cos(g),y=Math.sin(g),w=d*(Math.abs(m)+Math.abs(y)),b=d*(1-w+w**2),C=Math.max(Math.atan(Math.abs(y+m)*b),Math.atan(Math.abs(y-m)*b));let S=0,k=t;for(let I=t+2;I<e-2;I+=2){const N=Math.abs(u-l*i[I+1]+h*i[I]);N>S&&(k=I,S=N)}S>(o*C)**2?(_(this,Xi,aw).call(this,i,t,k+2,r),_(this,Xi,aw).call(this,i,k,e,r)):r.push(n,s)},_6=function(i){const t=[],e=i.length;return _(this,Xi,aw).call(this,i,0,e,t),t.push(i[e-2],i[e-1]),t.length<=4?null:t},M6=function(i,t,e,r,n,s){const A=new Float32Array(s**2),a=-2*r**2,o=s>>1;for(let g=0;g<s;g++){const m=(g-o)**2;for(let y=0;y<s;y++)A[g*s+y]=Math.exp((m+(y-o)**2)/a)}const l=new Float32Array(256),h=-2*n**2;for(let g=0;g<256;g++)l[g]=Math.exp(g**2/h);const u=i.length,f=new Uint8Array(u),d=new Uint32Array(256);for(let g=0;g<e;g++)for(let m=0;m<t;m++){const y=g*t+m,w=i[y];let b=0,C=0;for(let k=0;k<s;k++){const I=g+k-o;if(!(I<0||I>=e))for(let N=0;N<s;N++){const D=m+N-o;if(D<0||D>=t)continue;const Q=i[I*t+D],K=A[k*s+N]*l[Math.abs(Q-w)];b+=Q*K,C+=K}}const S=f[y]=Math.round(b/C);d[S]++}return[f,d]},T6=function(i){const t=new Uint32Array(256);for(const e of i)t[e]++;return t},I4=function(i){const t=i.length,e=new Uint8ClampedArray(t>>2);let r=-1/0,n=1/0;for(let A=0,a=e.length;A<a;A++){const o=e[A]=i[A<<2];r=Math.max(r,o),n=Math.min(n,o)}const s=255/(r-n);for(let A=0,a=e.length;A<a;A++)e[A]=(e[A]-n)*s;return e},Q4=function(i){let t,e=-1/0,r=-1/0;const n=i.findIndex(a=>a!==0);let s=n,A=n;for(t=n;t<256;t++){const a=i[t];a>e&&(t-s>r&&(r=t-s,A=t-1),e=a,s=t)}for(t=A-1;t>=0&&!(i[t]>i[t+1]);t--);return t},N6=function(i){const t=i,{width:e,height:r}=i,{maxDim:n}=c(this,vp);let s=e,A=r;if(e>n||r>n){let l=e,h=r,u=Math.log2(Math.max(e,r)/n);const f=Math.floor(u);u=u===f?f-1:f;for(let g=0;g<u;g++){s=Math.ceil(l/2),A=Math.ceil(h/2);const m=new OffscreenCanvas(s,A);m.getContext("2d").drawImage(i,0,0,l,h,0,0,s,A),l=s,h=A,i!==t&&i.close(),i=m.transferToImageBitmap()}const d=Math.min(n/s,n/A);s=Math.round(s*d),A=Math.round(A*d)}const a=new OffscreenCanvas(s,A).getContext("2d",{willReadFrequently:!0});a.fillStyle="white",a.fillRect(0,0,s,A),a.filter="grayscale(1)",a.drawImage(i,0,0,i.width,i.height,0,0,s,A);const o=a.getImageData(0,0,s,A).data;return[_(this,Xi,I4).call(this,o),s,A]},U(io,Xi),U(io,vp,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),U(io,_a,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class YS extends S6{constructor(){super(),super.updateProperties({fill:Vr._defaultLineColor,"stroke-width":0})}clone(){const t=new YS;return t.updateAll(this),t}}class $S extends Jy{constructor(t){super(t),super.updateProperties({stroke:Vr._defaultLineColor,"stroke-width":1})}clone(){const t=new $S(this._viewParameters);return t.updateAll(this),t}}var Yc,Ko,$c,xf;const lv=class Go extends E6{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),U(this,Yc,!1),U(this,Ko,null),U(this,$c,null),U(this,xf,null),this._willKeepAspectRatio=!0,F(this,$c,t.signatureData||null),F(this,Ko,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){Vr.initialize(t,e),this._defaultDrawingOptions=new YS,this._defaultDrawnSignatureOptions=new $S(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return ke(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!c(this,Ko)}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:r}=this;if(r&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(c(this,$c)){const{lines:n,mustSmooth:s,areContours:A,description:a,uuid:o,heightInPage:l}=c(this,$c),{rawDims:{pageWidth:h,pageHeight:u},rotation:f}=this.parent.viewport,d=io.processDrawnLines({lines:n,pageWidth:h,pageHeight:u,rotation:f,innerMargin:Go._INNER_MARGIN,mustSmooth:s,areContours:A});this.addSignature(d,l,a,o)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:c(this,Ko)||""}));return r&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){F(this,xf,t),this.addEditToolbar()}getUuid(){return c(this,xf)}get description(){return c(this,Ko)}set description(t){F(this,Ko,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e==null||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:r,width:n,height:s}=c(this,$c),A=Math.max(n,s),a=io.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:r,width:n,height:s},pageWidth:A,pageHeight:A,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,r,n){const{x:s,y:A}=this,{outline:a}=F(this,$c,t);F(this,Yc,a instanceof k4),this.description=r;let o;c(this,Yc)?o=Go.getDefaultDrawingOptions():(o=Go._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=s,this.y=A,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:r},rotation:n}=this.parent.viewport;return io.process(t,e,r,n,Go._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:r,pageHeight:n},rotation:s}=this.parent.viewport;return io.extractContoursFromText(t,e,r,n,s,Go._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:r},rotation:n}=this.parent.viewport;return io.processDrawnLines({lines:t,pageWidth:e,pageHeight:r,rotation:n,innerMargin:Go._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Go.getDefaultDrawingOptions():(this._drawingOptions=Go._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:r}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:c(this,Yc),color:[0,0,0],thickness:c(this,Yc)?0:n});return this.addComment(s),t?(s.paths={lines:e,points:r},s.uuid=c(this,xf),s.isCopy=!0):s.lines=e,c(this,Ko)&&(s.accessibilityData={type:"Figure",alt:c(this,Ko)}),s}static deserializeDraw(t,e,r,n,s,A){return A.areContours?k4.deserialize(t,e,r,n,s,A):Z0.deserialize(t,e,r,n,s,A)}static async deserialize(t,e,r){var n;const s=await super.deserialize(t,e,r);return F(s,Yc,t.areContours),s.description=((n=t.accessibilityData)==null?void 0:n.alt)||"",F(s,xf,t.uuid),s}};Yc=new WeakMap,Ko=new WeakMap,$c=new WeakMap,xf=new WeakMap,ut(lv,"_type","signature"),ut(lv,"_editorType",Se.SIGNATURE),ut(lv,"_defaultDrawingOptions",null);let zW=lv;var qr,mn,du,Mh,xu,Um,Th,Ff,zo,IA,x0,_r,Ag,ag,hv,fy,py,L4,cv,P6;class _4 extends Vr{constructor(t){super({...t,name:"stampEditor"}),U(this,_r),U(this,qr,null),U(this,mn,null),U(this,du,null),U(this,Mh,null),U(this,xu,null),U(this,Um,""),U(this,Th,null),U(this,Ff,!1),U(this,zo,null),U(this,IA,!1),U(this,x0,!1),F(this,Mh,t.bitmapUrl),F(this,xu,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){Vr.initialize(t,e)}static isHandlingMimeForPasting(t){return jy.includes(t)}static paste(t,e){e.pasteEditor({mode:Se.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:r}=this._uiManager;if(!r)throw new Error("No ML.");if(!await r.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:s,height:A}=t||this.copyCanvas(null,null,!0).imageData,a=await r.guess({name:"altText",request:{data:n,width:s,height:A,channels:n.length/(s*A)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var t;c(this,mn)&&(F(this,qr,null),this._uiManager.imageManager.deleteId(c(this,mn)),(t=c(this,Th))==null||t.remove(),F(this,Th,null),c(this,zo)&&(clearTimeout(c(this,zo)),F(this,zo,null))),super.remove()}rebuild(){if(!this.parent){c(this,mn)&&_(this,_r,hv).call(this);return}super.rebuild(),this.div!==null&&(c(this,mn)&&c(this,Th)===null&&_(this,_r,hv).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(c(this,du)||c(this,qr)||c(this,Mh)||c(this,xu)||c(this,mn)||c(this,Ff))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),c(this,Ff)||(c(this,qr)?_(this,_r,fy).call(this):_(this,_r,hv).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:r,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),r&&this._uiManager.imageManager.isValidId(r)&&(F(this,mn,r),n&&F(this,qr,n),F(this,Ff,!1),_(this,_r,fy).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(c(this,zo)!==null&&clearTimeout(c(this,zo)),F(this,zo,setTimeout(()=>{F(this,zo,null),_(this,_r,L4).call(this)},200)))}copyCanvas(t,e,r=!1){t||(t=224);const{width:n,height:s}=c(this,qr),A=new pa;let a=c(this,qr),o=n,l=s,h=null;if(e){if(n>e||s>e){const I=Math.min(e/n,e/s);o=Math.floor(n*I),l=Math.floor(s*I)}h=document.createElement("canvas");const f=h.width=Math.ceil(o*A.sx),d=h.height=Math.ceil(l*A.sy);c(this,IA)||(a=_(this,_r,py).call(this,f,d));const g=h.getContext("2d");g.filter=this._uiManager.hcmFilter;let m="white",y="#cfcfd8";this._uiManager.hcmFilter!=="none"?y="black":Z9.isDarkMode&&(m="#8f8f9d",y="#42414d");const w=15,b=w*A.sx,C=w*A.sy,S=new OffscreenCanvas(b*2,C*2),k=S.getContext("2d");k.fillStyle=m,k.fillRect(0,0,b*2,C*2),k.fillStyle=y,k.fillRect(0,0,b,C),k.fillRect(b,C,b,C),g.fillStyle=g.createPattern(S,"repeat"),g.fillRect(0,0,f,d),g.drawImage(a,0,0,a.width,a.height,0,0,f,d)}let u=null;if(r){let f,d;if(A.symmetric&&a.width<t&&a.height<t)f=a.width,d=a.height;else if(a=c(this,qr),n>t||s>t){const m=Math.min(t/n,t/s);f=Math.floor(n*m),d=Math.floor(s*m),c(this,IA)||(a=_(this,_r,py).call(this,f,d))}const g=new OffscreenCanvas(f,d).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,f,d),u={width:f,height:d,data:g.getImageData(0,0,f,d).data}}return{canvas:h,width:o,height:l,imageData:u}}static async deserialize(t,e,r){var n;let s=null,A=!1;if(t instanceof ZP){const{data:{rect:y,rotation:w,id:b,structParent:C,popupRef:S,richText:k,contentsObj:I,creationDate:N,modificationDate:D},container:Q,parent:{page:{pageNumber:K}},canvas:L}=t;let O,W;L?(delete t.canvas,{id:O,bitmap:W}=r.imageManager.getFromCanvas(Q.id,L),L.remove()):(A=!0,t._hasNoCanvas=!0);const R=((n=await e._structTree.getAriaAttributes(`${sp}${b}`))==null?void 0:n.get("aria-label"))||"";s=t={annotationType:Se.STAMP,bitmapId:O,bitmap:W,pageIndex:K-1,rect:y.slice(0),rotation:w,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:C,popupRef:S,richText:k,comment:(I==null?void 0:I.str)||null,creationDate:N,modificationDate:D}}const a=await super.deserialize(t,e,r),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:u,isSvg:f,accessibilityData:d}=t;A?(r.addMissingCanvas(t.id,a),F(a,Ff,!0)):u&&r.imageManager.isValidId(u)?(F(a,mn,u),l&&F(a,qr,l)):F(a,Mh,h),F(a,IA,f);const[g,m]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/m,d&&(a.altTextData=d),a._initialData=s,t.comment&&a.setCommentData(t),F(a,x0,!!s),a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const r=Object.assign(super.serialize(t),{bitmapId:c(this,mn),isSvg:c(this,IA)});if(this.addComment(r),t)return r.bitmapUrl=_(this,_r,cv).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r.isCopy=!0,r;const{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s&&(r.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const a=_(this,_r,P6).call(this,r);return a.isSame?null:(a.isSameAltText?delete r.accessibilityData:r.accessibilityData.structParent=this._initialData.structParent??-1,r.id=this.annotationElementId,delete r.bitmapId,r)}if(e===null)return r;e.stamps||(e.stamps=new Map);const A=c(this,IA)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(!e.stamps.has(c(this,mn)))e.stamps.set(c(this,mn),{area:A,serialized:r}),r.bitmap=_(this,_r,cv).call(this,!1);else if(c(this,IA)){const a=e.stamps.get(c(this,mn));A>a.area&&(a.area=A,a.serialized.bitmap.close(),a.serialized.bitmap=_(this,_r,cv).call(this,!1))}return r}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}qr=new WeakMap,mn=new WeakMap,du=new WeakMap,Mh=new WeakMap,xu=new WeakMap,Um=new WeakMap,Th=new WeakMap,Ff=new WeakMap,zo=new WeakMap,IA=new WeakMap,x0=new WeakMap,_r=new WeakSet,Ag=function(i,t=!1){if(!i){this.remove();return}F(this,qr,i.bitmap),t||(F(this,mn,i.id),F(this,IA,i.isSvg)),i.file&&F(this,Um,i.file.name),_(this,_r,fy).call(this)},ag=function(){if(F(this,du,null),this._uiManager.enableWaiting(!1),!!c(this,Th)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,qr)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,qr)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},hv=function(){if(c(this,mn)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,mn)).then(e=>_(this,_r,Ag).call(this,e,!0)).finally(()=>_(this,_r,ag).call(this));return}if(c(this,Mh)){const e=c(this,Mh);F(this,Mh,null),this._uiManager.enableWaiting(!0),F(this,du,this._uiManager.imageManager.getFromUrl(e).then(r=>_(this,_r,Ag).call(this,r)).finally(()=>_(this,_r,ag).call(this)));return}if(c(this,xu)){const e=c(this,xu);F(this,xu,null),this._uiManager.enableWaiting(!0),F(this,du,this._uiManager.imageManager.getFromFile(e).then(r=>_(this,_r,Ag).call(this,r)).finally(()=>_(this,_r,ag).call(this)));return}const i=document.createElement("input");i.type="file",i.accept=jy.join(",");const t=this._uiManager._signal;F(this,du,new Promise(e=>{i.addEventListener("change",async()=>{if(!i.files||i.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(i.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),_(this,_r,Ag).call(this,r)}e()},{signal:t}),i.addEventListener("cancel",()=>{this.remove(),e()},{signal:t})}).finally(()=>_(this,_r,ag).call(this))),i.click()},fy=function(){var i;const{div:t}=this;let{width:e,height:r}=c(this,qr);const[n,s]=this.pageDimensions,A=.75;if(this.width)e=this.width*n,r=this.height*s;else if(e>A*n||r>A*s){const o=Math.min(A*n/e,A*s/r);e*=o,r*=o}this._uiManager.enableWaiting(!1);const a=F(this,Th,document.createElement("canvas"));a.setAttribute("role","img"),this.addContainer(a),this.width=e/n,this.height=r/s,this.setDims(),(i=this._initialOptions)!=null&&i.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),_(this,_r,L4).call(this),c(this,x0)||(this.parent.addUndoableEditor(this),F(this,x0,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,Um)&&this.div.setAttribute("aria-description",c(this,Um)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},py=function(i,t){const{width:e,height:r}=c(this,qr);let n=e,s=r,A=c(this,qr);for(;n>2*i||s>2*t;){const a=n,o=s;n>2*i&&(n=Math.ceil(n/2)),s>2*t&&(s=Math.ceil(s/2));const l=new OffscreenCanvas(n,s);l.getContext("2d").drawImage(A,0,0,a,o,0,0,n,s),A=l.transferToImageBitmap()}return A},L4=function(){const[i,t]=this.parentDimensions,{width:e,height:r}=this,n=new pa,s=Math.ceil(e*i*n.sx),A=Math.ceil(r*t*n.sy),a=c(this,Th);if(!a||a.width===s&&a.height===A)return;a.width=s,a.height=A;const o=c(this,IA)?c(this,qr):_(this,_r,py).call(this,s,A),l=a.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(o,0,0,o.width,o.height,0,0,s,A)},cv=function(i){if(i){if(c(this,IA)){const e=this._uiManager.imageManager.getSvgUrl(c(this,mn));if(e)return e}const t=document.createElement("canvas");return{width:t.width,height:t.height}=c(this,qr),t.getContext("2d").drawImage(c(this,qr),0,0),t.toDataURL()}if(c(this,IA)){const[t,e]=this.pageDimensions,r=Math.round(this.width*t*Pu.PDF_TO_CSS_UNITS),n=Math.round(this.height*e*Pu.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(r,n);return s.getContext("2d").drawImage(c(this,qr),0,0,c(this,qr).width,c(this,qr).height,0,0,r,n),s.transferToImageBitmap()}return structuredClone(c(this,qr))},P6=function(i){var t;const{pageIndex:e,accessibilityData:{altText:r}}=this._initialData,n=i.pageIndex===e,s=(((t=i.accessibilityData)==null?void 0:t.alt)||"")===r;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}},ut(_4,"_type","stamp"),ut(_4,"_editorType",Se.STAMP);var Sf,Im,Zc,Jc,nh,eA,tu,Qm,Lm,Ha,sh,vn,Ah,eu,_m,oe,Fu,pi,M4,D6,Ka,T4,N4,uv;const dv=class ru{constructor({uiManager:t,pageIndex:e,div:r,structTreeLayer:n,accessibilityManager:s,annotationLayer:A,drawLayer:a,textLayer:o,viewport:l,l10n:h}){U(this,pi),U(this,Sf),U(this,Im,!1),U(this,Zc,null),U(this,Jc,null),U(this,nh,null),U(this,eA,new Map),U(this,tu,!1),U(this,Qm,!1),U(this,Lm,!1),U(this,Ha,null),U(this,sh,null),U(this,vn,null),U(this,Ah,null),U(this,eu,null),U(this,_m,-1),U(this,oe);const u=[...c(ru,Fu).values()];if(!ru._initialized){ru._initialized=!0;for(const f of u)f.initialize(h,t)}t.registerEditorTypes(u),F(this,oe,t),this.pageIndex=e,this.div=r,F(this,Sf,s),F(this,Zc,A),this.viewport=l,F(this,vn,o),this.drawLayer=a,this._structTree=n,c(this,oe).addLayer(this)}get isEmpty(){return c(this,eA).size===0}get isInvisible(){return this.isEmpty&&c(this,oe).getMode()===Se.NONE}updateToolbar(t){c(this,oe).updateToolbar(t)}updateMode(t=c(this,oe).getMode()){switch(_(this,pi,uv).call(this),t){case Se.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Se.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Se.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===Se.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const r of c(ru,Fu).values())e.toggle(`${r._type}Editing`,t===r._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=c(this,vn))==null?void 0:e.div)}setEditingState(t){c(this,oe).setEditingState(t)}addCommands(t){c(this,oe).addCommands(t)}cleanUndoStack(t){c(this,oe).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=c(this,Zc))==null||e.togglePointerEvents(t)}async enable(){var t;F(this,Lm,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(t=c(this,eu))==null||t.abort(),F(this,eu,null);const e=new Set;for(const n of c(this,pi,M4))n.enableEditing(),n.show(!0),n.annotationElementId&&(c(this,oe).removeChangedExistingAnnotation(n),e.add(n.annotationElementId));const r=c(this,Zc);if(r)for(const n of r.getEditableAnnotations()){if(n.hide(),c(this,oe).isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;const s=await this.deserialize(n);s&&(this.addOrRebuild(s),s.enableEditing())}F(this,Lm,!1),c(this,oe)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var t;if(F(this,Qm,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),c(this,vn)&&!c(this,eu)){F(this,eu,new AbortController);const s=c(this,oe).combinedSignal(c(this,eu));c(this,vn).div.addEventListener("pointerdown",A=>{const{clientX:a,clientY:o,timeStamp:l}=A,h=c(this,_m);if(l-h>500){F(this,_m,l);return}F(this,_m,-1);const{classList:u}=this.div;u.toggle("getElements",!0);const f=document.elementsFromPoint(a,o);if(u.toggle("getElements",!1),!this.div.contains(f[0]))return;let d;const g=new RegExp(`^${_0}[0-9]+$`);for(const y of f)if(g.test(y.id)){d=y.id;break}if(!d)return;const m=c(this,eA).get(d);(m==null?void 0:m.annotationElementId)===null&&(Hr(A),m.dblclick(A))},{signal:s,capture:!0})}const e=c(this,Zc),r=[];if(e){const s=new Map,A=new Map;for(const a of c(this,pi,M4)){if(a.disableEditing(),!a.annotationElementId){r.push(a);continue}if(a.serialize()!==null){s.set(a.annotationElementId,a);continue}else A.set(a.annotationElementId,a);(t=this.getEditableAnnotation(a.annotationElementId))==null||t.show(),a.remove()}for(const a of e.getEditableAnnotations()){const{id:o}=a.data;if(c(this,oe).isDeletedAnnotationElement(o)){a.updateEdited({deleted:!0});continue}let l=A.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=s.get(o),l&&(c(this,oe).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}_(this,pi,uv).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const s of c(ru,Fu).values())n.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e==null||e.updateFakeAnnotations(r),F(this,Qm,!1)}getEditableAnnotation(t){var e;return((e=c(this,Zc))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){c(this,oe).getActive()!==t&&c(this,oe).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=c(this,vn))!=null&&t.div&&!c(this,Ah)){F(this,Ah,new AbortController);const e=c(this,oe).combinedSignal(c(this,Ah));c(this,vn).div.addEventListener("pointerdown",_(this,pi,D6).bind(this),{signal:e}),c(this,vn).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=c(this,vn))!=null&&t.div&&c(this,Ah)&&(c(this,Ah).abort(),F(this,Ah,null),c(this,vn).div.classList.remove("highlighting"))}enableClick(){if(c(this,Jc))return;F(this,Jc,new AbortController);const t=c(this,oe).combinedSignal(c(this,Jc));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=c(this,Jc))==null||t.abort(),F(this,Jc,null)}attach(t){c(this,eA).set(t.id,t);const{annotationElementId:e}=t;e&&c(this,oe).isDeletedAnnotationElement(e)&&c(this,oe).removeDeletedAnnotationElement(t)}detach(t){var e;c(this,eA).delete(t.id),(e=c(this,Sf))==null||e.removePointerInTextLayer(t.contentDiv),!c(this,Qm)&&t.annotationElementId&&c(this,oe).addDeletedAnnotationElement(t)}remove(t){this.detach(t),c(this,oe).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(c(this,oe).addDeletedAnnotationElement(t),Vr.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),c(this,oe).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!c(this,Lm)),c(this,oe).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:r}=document;t.div.contains(r)&&!c(this,nh)&&(t._focusEventsAllowed=!1,F(this,nh,setTimeout(()=>{F(this,nh,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:c(this,oe)._signal}),r.focus())},0))),t._structTreeParentId=(e=c(this,Sf))==null?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),r=()=>{t.remove()};this.addCommands({cmd:e,undo:r,mustExec:!1})}getEditorByUID(t){for(const e of c(this,eA).values())if(e.uid===t)return e;return null}combinedSignal(t){return c(this,oe).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=c(this,pi,Ka))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await c(this,oe).updateMode(t.mode);const{offsetX:r,offsetY:n}=_(this,pi,N4).call(this),s=c(this,oe).getId(),A=_(this,pi,T4).call(this,{parent:this,id:s,x:r,y:n,uiManager:c(this,oe),isCentered:!0,...e});A&&this.add(A)}async deserialize(t){var e;return await((e=c(ru,Fu).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,c(this,oe)))||null}createAndAddNewEditor(t,e,r={}){const n=c(this,oe).getId(),s=_(this,pi,T4).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:c(this,oe),isCentered:e,...r});return s&&this.add(s),s}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(_(this,pi,N4).call(this),!0,t)}setSelected(t){c(this,oe).setSelected(t)}toggleSelected(t){c(this,oe).toggleSelected(t)}unselect(t){c(this,oe).unselect(t)}pointerup(t){var e;const{isMac:r}=Fi.platform;if(t.button!==0||t.ctrlKey&&r||t.target!==this.div||!c(this,tu)||(F(this,tu,!1),(e=c(this,pi,Ka))!=null&&e.isDrawer&&c(this,pi,Ka).supportMultipleDrawings))return;if(!c(this,Im)){F(this,Im,!0);return}const n=c(this,oe).getMode();if(n===Se.STAMP||n===Se.POPUP||n===Se.SIGNATURE){c(this,oe).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var e;if(c(this,oe).getMode()===Se.HIGHLIGHT&&this.enableTextSelection(),c(this,tu)){F(this,tu,!1);return}const{isMac:r}=Fi.platform;if(t.button!==0||t.ctrlKey&&r||t.target!==this.div)return;if(F(this,tu,!0),(e=c(this,pi,Ka))!=null&&e.isDrawer){this.startDrawingSession(t);return}const n=c(this,oe).getActive();F(this,Im,!n||n.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),c(this,Ha)){c(this,pi,Ka).startDrawing(this,c(this,oe),!1,t);return}c(this,oe).setCurrentDrawingSession(this),F(this,Ha,new AbortController);const e=c(this,oe).combinedSignal(c(this,Ha));this.div.addEventListener("blur",({relatedTarget:r})=>{r&&!this.div.contains(r)&&(F(this,sh,null),this.commitOrRemove())},{signal:e}),c(this,pi,Ka).startDrawing(this,c(this,oe),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&F(this,sh,e);return}c(this,sh)&&setTimeout(()=>{var e;(e=c(this,sh))==null||e.focus(),F(this,sh,null)},0)}endDrawingSession(t=!1){return c(this,Ha)?(c(this,oe).setCurrentDrawingSession(null),c(this,Ha).abort(),F(this,Ha,null),F(this,sh,null),c(this,pi,Ka).endDrawing(t)):null}findNewParent(t,e,r){const n=c(this,oe).findParent(e,r);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return c(this,Ha)?(this.endDrawingSession(),!0):!1}onScaleChanging(){c(this,Ha)&&c(this,pi,Ka).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=c(this,oe).getActive())==null?void 0:t.parent)===this&&(c(this,oe).commitOrRemove(),c(this,oe).setActiveEditor(null)),c(this,nh)&&(clearTimeout(c(this,nh)),F(this,nh,null));for(const r of c(this,eA).values())(e=c(this,Sf))==null||e.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,c(this,eA).clear(),c(this,oe).removeLayer(this)}async render({viewport:t}){this.viewport=t,Wh(this.div,t);for(const e of c(this,oe).getEditors(this.pageIndex))this.add(e),e.rebuild();await c(this,oe).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){c(this,oe).commitOrRemove(),_(this,pi,uv).call(this);const e=this.viewport.rotation,r=t.rotation;if(this.viewport=t,Wh(this.div,{rotation:r}),e!==r)for(const n of c(this,eA).values())n.rotate(r)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return c(this,oe).viewParameters.realScale}};Sf=new WeakMap,Im=new WeakMap,Zc=new WeakMap,Jc=new WeakMap,nh=new WeakMap,eA=new WeakMap,tu=new WeakMap,Qm=new WeakMap,Lm=new WeakMap,Ha=new WeakMap,sh=new WeakMap,vn=new WeakMap,Ah=new WeakMap,eu=new WeakMap,_m=new WeakMap,oe=new WeakMap,Fu=new WeakMap,pi=new WeakSet,M4=function(){return c(this,eA).size!==0?c(this,eA).values():c(this,oe).getEditors(this.pageIndex)},D6=function(i){c(this,oe).unselectAll();const{target:t}=i;if(t===c(this,vn).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent")||t.classList.contains("textLayerImagePlaceholder"))&&c(this,vn).div.contains(t)){const{isMac:e}=Fi.platform;if(i.button!==0||i.ctrlKey&&e)return;c(this,oe).showAllEditors("highlight",!0,!0),c(this,vn).div.classList.add("free"),this.toggleDrawing(),OU.startHighlighting(this,c(this,oe).direction==="ltr",{target:c(this,vn).div,x:i.x,y:i.y}),c(this,vn).div.addEventListener("pointerup",()=>{c(this,vn).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,oe)._signal}),i.preventDefault()}},Ka=function(){return c(dv,Fu).get(c(this,oe).getMode())},T4=function(i){const t=c(this,pi,Ka);return t?new t.prototype.constructor(i):null},N4=function(){const{x:i,y:t,width:e,height:r}=this.boundingClientRect,n=Math.max(0,i),s=Math.max(0,t),A=Math.min(window.innerWidth,i+e),a=Math.min(window.innerHeight,t+r),o=(n+A)/2-i,l=(s+a)/2-t,[h,u]=this.viewport.rotation%180===0?[o,l]:[l,o];return{offsetX:h,offsetY:u}},uv=function(){for(const i of c(this,eA).values())i.isEmpty()&&i.remove()},ut(dv,"_initialized",!1),U(dv,Fu,new Map([VW,GW,_4,OU,zW].map(i=>[i._editorType,i])));let O6=dv;var Ga,Ss,Ef,gy,P4,R6,iu,D4,H6,O4;const kf=class Xs{constructor(){U(this,iu),U(this,Ga,null),U(this,Ss,new Map),U(this,Ef,new Map)}setParent(t){if(!c(this,Ga)){F(this,Ga,t);return}if(c(this,Ga)!==t){if(c(this,Ss).size>0)for(const e of c(this,Ss).values())e.remove(),t.append(e);F(this,Ga,t)}}static get _svgFactory(){return ke(this,"_svgFactory",new D0)}draw(t,e=!1,r=!1){const n=$i(Xs,gy)._++,s=_(this,iu,D4).call(this),A=Xs._svgFactory.createElement("defs");s.append(A);const a=Xs._svgFactory.createElement("path");A.append(a);const o=`path_${n}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&c(this,Ef).set(n,a);const l=r?_(this,iu,H6).call(this,A,o):null,h=Xs._svgFactory.createElement("use");return s.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(s,t),c(this,Ss).set(n,s),{id:n,clipPathId:`url(#${l})`}}drawOutline(t,e){const r=$i(Xs,gy)._++,n=_(this,iu,D4).call(this),s=Xs._svgFactory.createElement("defs");n.append(s);const A=Xs._svgFactory.createElement("path");s.append(A);const a=`path_${r}`;A.setAttribute("id",a),A.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const u=Xs._svgFactory.createElement("mask");s.append(u),o=`mask_${r}`,u.setAttribute("id",o),u.setAttribute("maskUnits","objectBoundingBox");const f=Xs._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const d=Xs._svgFactory.createElement("use");u.append(d),d.setAttribute("href",`#${a}`),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}const l=Xs._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return n.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(n,t),c(this,Ss).set(r,n),r}finalizeDraw(t,e){c(this,Ef).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var r;if(!e)return;const{root:n,bbox:s,rootClass:A,path:a}=e,o=typeof t=="number"?c(this,Ss).get(t):t;if(o){if(n&&_(this,iu,O4).call(this,o,n),s&&_(r=Xs,P4,R6).call(r,o,s),A){const{classList:l}=o;for(const[h,u]of Object.entries(A))l.toggle(h,u)}if(a){const l=o.firstElementChild.firstElementChild;_(this,iu,O4).call(this,l,a)}}}updateParent(t,e){if(e===this)return;const r=c(this,Ss).get(t);r&&(c(e,Ga).append(r),c(this,Ss).delete(t),c(e,Ss).set(t,r))}remove(t){c(this,Ef).delete(t),c(this,Ga)!==null&&(c(this,Ss).get(t).remove(),c(this,Ss).delete(t))}destroy(){F(this,Ga,null);for(const t of c(this,Ss).values())t.remove();c(this,Ss).clear(),c(this,Ef).clear()}};Ga=new WeakMap,Ss=new WeakMap,Ef=new WeakMap,gy=new WeakMap,P4=new WeakSet,R6=function(i,[t,e,r,n]){const{style:s}=i;s.top=`${100*e}%`,s.left=`${100*t}%`,s.width=`${100*r}%`,s.height=`${100*n}%`},iu=new WeakSet,D4=function(){const i=kf._svgFactory.create(1,1,!0);return c(this,Ga).append(i),i.setAttribute("aria-hidden",!0),i},H6=function(i,t){const e=kf._svgFactory.createElement("clipPath");i.append(e);const r=`clip_${t}`;e.setAttribute("id",r),e.setAttribute("clipPathUnits","objectBoundingBox");const n=kf._svgFactory.createElement("use");return e.append(n),n.setAttribute("href",`#${t}`),n.classList.add("clip"),r},O4=function(i,t){for(const[e,r]of Object.entries(t))r===null?i.removeAttribute(e):i.setAttribute(e,r)},U(kf,P4),U(kf,gy,0);let V6=kf;function ow(i){return`${(i*100).toFixed(2)}%`}var Mm,my,fv,F0,al,ol,wy,R4,W6;const j6=class H4{constructor(t,e,r,n){U(this,R4),U(this,Mm,[]),U(this,my,new Map),U(this,fv,null),U(this,F0,0),U(this,al,0),U(this,ol,0),F(this,F0,t),F(this,Mm,e),F(this,al,r.rawDims.pageWidth),F(this,ol,r.rawDims.pageHeight),F(this,fv,n)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<c(this,Mm).length;e+=6){const r=_(this,R4,W6).call(this,c(this,Mm).subarray(e,e+6));r&&t.append(r)}return t.addEventListener("contextmenu",e=>{var r;if(!(e.target instanceof HTMLCanvasElement))return;const n=e.target,s=c(this,my).get(n);if(!s)return;const A=(r=c(H4,wy))==null?void 0:r.deref();if(A===n)return;A&&(A.width=0,A.height=0),F(H4,wy,new WeakRef(n));const{inverseTransform:a,x1:o,y1:l,width:h,height:u}=s,f=c(this,fv).call(this),d=Math.ceil(o*f.width),g=Math.ceil(l*f.height),m=Math.floor((o+h/c(this,al))*f.width),y=Math.floor((l+u/c(this,ol))*f.height);n.width=m-d,n.height=y-g;const w=n.getContext("2d");w.setTransform(...a),w.translate(-d,-g),w.drawImage(f,0,0)}),t}};Mm=new WeakMap,my=new WeakMap,fv=new WeakMap,F0=new WeakMap,al=new WeakMap,ol=new WeakMap,wy=new WeakMap,R4=new WeakSet,W6=function([i,t,e,r,n,s]){const A=Math.hypot((n-i)*c(this,al),(s-t)*c(this,ol)),a=Math.hypot((e-i)*c(this,al),(r-t)*c(this,ol));if(A<c(this,F0)||a<c(this,F0))return null;const o=[(n-i)*c(this,al)/A,(s-t)*c(this,ol)/A,(e-i)*c(this,al)/a,(r-t)*c(this,ol)/a,0,0],l=Nt.inverseTransform(o),h=document.createElement("canvas");return h.className="textLayerImagePlaceholder",h.width=0,h.height=0,Object.assign(h.style,{opacity:0,position:"absolute",left:ow(i),top:ow(t),width:ow(A/c(this,al)),height:ow(a/c(this,ol)),transformOrigin:"0% 0%",transform:`matrix(${o.join(",")})`}),c(this,my).set(h,{inverseTransform:l,width:A,height:a,x1:i,y1:t}),h},U(j6,wy,null);let K6=j6;globalThis._pdfjsTestingUtils={HighlightOutliner:b4};globalThis.pdfjsLib={AbortException:ml,AnnotationEditorLayer:O6,AnnotationEditorParamsType:_e,AnnotationEditorType:Se,AnnotationEditorUIManager:Cp,AnnotationLayer:t6,AnnotationMode:ll,AnnotationType:gi,applyOpacity:wN,build:RP,ColorPicker:zS,createValidAbsoluteUrl:PS,CSSConstants:mN,DOMSVGFactory:D0,DrawLayer:V6,FeatureTest:Fi,fetchData:Ry,findContrastColor:vN,getDocument:KS,getFilenameFromUrl:fN,getPdfFilenameFromUrl:pN,getRGB:Sp,getRGBA:Wy,getUuid:OS,getXfaPageViewport:gN,GlobalWorkerOptions:so,ImageKind:Km,InvalidPDFException:Fv,isDataScheme:Y0,isPdfFile:Vy,isValidExplicitDest:rP,makeArr:Dy,makeMap:Oy,makeObj:Sv,MathClamp:Mr,noContextMenu:AA,normalizeUnicode:dN,OPS:Ja,OutputScale:pa,PasswordResponses:uN,PDFDataRangeTransport:GS,PDFDateString:N0,PDFWorker:Yv,PermissionFlag:cN,PixelsPerInch:Pu,RenderingCancelledException:Hy,renderRichText:HS,ResponseException:M0,setLayerDimensions:Wh,shadow:ke,SignatureExtractor:io,stopEvent:Hr,SupportedImageMimeTypes:jy,TextLayer:qv,TextLayerImages:K6,TouchManager:VS,updateUrlHash:DS,Util:Nt,VerbosityLevel:q0,version:OP,XfaLayer:RS};const qW=Object.freeze(Object.defineProperty({__proto__:null,AbortException:ml,AnnotationEditorLayer:O6,AnnotationEditorParamsType:_e,AnnotationEditorType:Se,AnnotationEditorUIManager:Cp,AnnotationLayer:t6,AnnotationMode:ll,AnnotationType:gi,CSSConstants:mN,ColorPicker:zS,DOMSVGFactory:D0,DrawLayer:V6,FeatureTest:Fi,GlobalWorkerOptions:so,ImageKind:Km,InvalidPDFException:Fv,MathClamp:Mr,OPS:Ja,OutputScale:pa,PDFDataRangeTransport:GS,PDFDateString:N0,PDFWorker:Yv,PasswordResponses:uN,PermissionFlag:cN,PixelsPerInch:Pu,RenderingCancelledException:Hy,ResponseException:M0,SignatureExtractor:io,SupportedImageMimeTypes:jy,TextLayer:qv,TextLayerImages:K6,TouchManager:VS,Util:Nt,VerbosityLevel:q0,XfaLayer:RS,applyOpacity:wN,build:RP,createValidAbsoluteUrl:PS,fetchData:Ry,findContrastColor:vN,getDocument:KS,getFilenameFromUrl:fN,getPdfFilenameFromUrl:pN,getRGB:Sp,getRGBA:Wy,getUuid:OS,getXfaPageViewport:gN,isDataScheme:Y0,isPdfFile:Vy,isValidExplicitDest:rP,makeArr:Dy,makeMap:Oy,makeObj:Sv,noContextMenu:AA,normalizeUnicode:dN,renderRichText:HS,setLayerDimensions:Wh,shadow:ke,stopEvent:Hr,updateUrlHash:DS,version:OP},Symbol.toStringTag,{value:"Module"}));so.workerSrc="";const WU=25.4/72,JB=8;class XW{importFromFilePicker(t){const e=document.createElement("input");e.type="file",e.accept=".pdf",e.style.display="none",document.body.appendChild(e),e.addEventListener("change",async()=>{var r;const n=(r=e.files)==null?void 0:r[0];if(document.body.removeChild(e),!n)return;const s=await n.arrayBuffer();await this.convert(t,s)}),e.click()}async convert(t,e,r=1){try{const n=await(await KS({data:e}).promise).getPage(r),s=n.getViewport({scale:1}).height,A=await n.getOperatorList(),a=this.extractEntities(A,s);if(a.length===0){AB.warn("[PdfImport] No vector paths found in PDF page.");return}const o=t.doc.database.tables.blockTable.modelSpace;for(const l of a)o.appendEntity(l);AB.info(`[PdfImport] Imported ${a.length} entities from PDF.`)}catch(n){AB.error("[PdfImport] Failed to import PDF:",n)}}extractEntities(t,e){const{OPS:r}=qW,{fnArray:n,argsArray:s}=t,A=[];let a=[],o=[],l=0,h=0;const u=()=>{o.length>1&&a.push(o),o=[]},f=()=>{u();for(const m of a){const y=this.subpathToEntity(m);y&&A.push(y)}a=[]},d=(m,y)=>m*WU,g=(m,y)=>(e-y)*WU;for(let m=0;m<n.length;m++){const y=n[m],w=s[m];switch(y){case r.moveTo:{u(),l=w[0],h=w[1],o=[{x:d(l),y:g(l,h)}];break}case r.lineTo:{l=w[0],h=w[1],o.push({x:d(l),y:g(l,h)});break}case r.curveTo:{const[b,C,S,k,I,N]=w,D=t5({x:l,y:h},{x:b,y:C},{x:S,y:k},{x:I,y:N},JB);for(const Q of D)o.push({x:d(Q.x,Q.y),y:g(Q.x,Q.y)});l=I,h=N;break}case r.curveTo2:{const[b,C,S,k]=w,I=t5({x:l,y:h},{x:l,y:h},{x:b,y:C},{x:S,y:k},JB);for(const N of I)o.push({x:d(N.x,N.y),y:g(N.x,N.y)});l=S,h=k;break}case r.curveTo3:{const[b,C,S,k]=w,I=t5({x:l,y:h},{x:b,y:C},{x:S,y:k},{x:S,y:k},JB);for(const N of I)o.push({x:d(N.x,N.y),y:g(N.x,N.y)});l=S,h=k;break}case r.closePath:{o.length>0&&a.length===0&&o.push({...o[0]}),u();break}case r.stroke:case r.fill:case r.eoFill:case r.fillStroke:case r.eoFillStroke:case r.endPath:{f();break}}}return f(),A}subpathToEntity(t){if(t.length<2)return null;if(t.length===2)return new aR(new p3(t[0].x,t[0].y,0),new p3(t[1].x,t[1].y,0));const e=new oR;for(let a=0;a<t.length;a++)e.addVertexAt(a,new lR(t[a].x,t[a].y));const r=t[0],n=t[t.length-1],s=r.x-n.x,A=r.y-n.y;return Math.sqrt(s*s+A*A)<1e-6&&(e.closed=!0),e}}function t5(i,t,e,r,n){const s=[];for(let A=1;A<=n;A++){const a=A/n,o=1-a,l=o*o*o*i.x+3*o*o*a*t.x+3*o*a*a*e.x+a*a*a*r.x,h=o*o*o*i.y+3*o*o*a*t.y+3*o*a*a*e.y+a*a*a*r.y;s.push({x:l,y:h})}return s}class YW extends ZM{async execute(t){new XW().importFromFilePicker(t)}}const $W="1.6.0",ZW={version:$W};class JW{constructor(){this.name="PdfPlugin",this.version=ZW.version,this.description="PDF export (cpdf) and import (ipdf) commands",this.registeredCommands=[]}onLoad(t,e){const r=nR.SYSTEMT_COMMAND_GROUP_NAME;e.addCommand(r,"cpdf","cpdf",new H9),e.addCommand(r,"ipdf","ipdf",new YW),this.registeredCommands.push({group:r,name:"cpdf"},{group:r,name:"ipdf"})}onUnload(t,e){for(const r of this.registeredCommands)e.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function wZ(){return new JW}/*!
|
|
272
|
+
`)){const t=document.createElement("div");t.append(i?document.createTextNode(i):document.createElement("br")),this.editorDiv.append(t)}},n6=function(){return c(this,FA).replaceAll(" "," ")},g4=function(i){return i.replaceAll(" "," ")},s6=function(i){const{value:t,fontSize:e,color:r,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||i.value!==t||i.fontSize!==e||i.color.some((s,A)=>s!==r[A])||i.pageIndex!==n},U(Vo,Cu),ut(Vo,"_freeTextDefaultContent",""),ut(Vo,"_internalPadding",0),ut(Vo,"_defaultColor",null),ut(Vo,"_defaultFontSize",10),ut(Vo,"_type","freetext"),ut(Vo,"_editorType",Se.FREETEXT);let VW=Vo;class Jt{toSVGPath(){rr("Abstract method `toSVGPath` must be implemented.")}get box(){rr("Abstract getter `box` must be implemented.")}serialize(t,e){rr("Abstract method `serialize` must be implemented.")}static _rescale(t,e,r,n,s,A){A||(A=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)A[a]=e+t[a]*n,A[a+1]=r+t[a+1]*s;return A}static _rescaleAndSwap(t,e,r,n,s,A){A||(A=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)A[a]=e+t[a+1]*n,A[a+1]=r+t[a]*s;return A}static _translate(t,e,r,n){n||(n=new Float32Array(t.length));for(let s=0,A=t.length;s<A;s+=2)n[s]=e+t[s],n[s+1]=r+t[s+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,r,n,s){switch(s){case 90:return[1-e/r,t/n];case 180:return[1-t/r,1-e/n];case 270:return[e/r,1-t/n];default:return[t/r,e/n]}}static _normalizePagePoint(t,e,r){switch(r){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,r,n,s,A){return[(t+5*r)/6,(e+5*n)/6,(5*r+s)/6,(5*n+A)/6,(r+s)/2,(n+A)/2]}}ut(Jt,"PRECISION",1e-4);var kA,$a,p0,g0,Wo,He,fp,pp,Y2,$2,m0,bm,zc,Z2,YB,m4,UA,ng,A6,a6,o6,l6,h6,c6;const yf=class w4{constructor({x:t,y:e},r,n,s,A,a=0){U(this,UA),U(this,kA),U(this,$a,[]),U(this,p0),U(this,g0),U(this,Wo,[]),U(this,He,new Float32Array(18)),U(this,fp),U(this,pp),U(this,Y2),U(this,$2),U(this,m0),U(this,bm),U(this,zc,[]),F(this,kA,r),F(this,bm,s*n),F(this,g0,A),c(this,He).set([NaN,NaN,NaN,NaN,t,e],6),F(this,p0,a),F(this,$2,c(w4,Z2)*n),F(this,Y2,c(w4,m4)*n),F(this,m0,n),c(this,zc).push(t,e)}isEmpty(){return isNaN(c(this,He)[8])}add({x:t,y:e}){var r;F(this,fp,t),F(this,pp,e);const[n,s,A,a]=c(this,kA);let[o,l,h,u]=c(this,He).subarray(8,12);const f=t-h,d=e-u,g=Math.hypot(f,d);if(g<c(this,Y2))return!1;const m=g-c(this,$2),y=m/g,w=y*f,b=y*d;let C=o,S=l;o=h,l=u,h+=w,u+=b,(r=c(this,zc))==null||r.push(t,e);const k=-b/m,I=w/m,N=k*c(this,bm),D=I*c(this,bm);return c(this,He).set(c(this,He).subarray(2,8),0),c(this,He).set([h+N,u+D],4),c(this,He).set(c(this,He).subarray(14,18),12),c(this,He).set([h-N,u-D],16),isNaN(c(this,He)[6])?(c(this,Wo).length===0&&(c(this,He).set([o+N,l+D],2),c(this,Wo).push(NaN,NaN,NaN,NaN,(o+N-n)/A,(l+D-s)/a),c(this,He).set([o-N,l-D],14),c(this,$a).push(NaN,NaN,NaN,NaN,(o-N-n)/A,(l-D-s)/a)),c(this,He).set([C,S,o,l,h,u],6),!this.isEmpty()):(c(this,He).set([C,S,o,l,h,u],6),Math.abs(Math.atan2(S-l,C-o)-Math.atan2(b,w))<Math.PI/2?([o,l,h,u]=c(this,He).subarray(2,6),c(this,Wo).push(NaN,NaN,NaN,NaN,((o+h)/2-n)/A,((l+u)/2-s)/a),[o,l,C,S]=c(this,He).subarray(14,18),c(this,$a).push(NaN,NaN,NaN,NaN,((C+o)/2-n)/A,((S+l)/2-s)/a),!0):([C,S,o,l,h,u]=c(this,He).subarray(0,6),c(this,Wo).push(((C+5*o)/6-n)/A,((S+5*l)/6-s)/a,((5*o+h)/6-n)/A,((5*l+u)/6-s)/a,((o+h)/2-n)/A,((l+u)/2-s)/a),[h,u,o,l,C,S]=c(this,He).subarray(12,18),c(this,$a).push(((C+5*o)/6-n)/A,((S+5*l)/6-s)/a,((5*o+h)/6-n)/A,((5*l+u)/6-s)/a,((o+h)/2-n)/A,((l+u)/2-s)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=c(this,Wo),e=c(this,$a);if(isNaN(c(this,He)[6])&&!this.isEmpty())return _(this,UA,A6).call(this);const r=[];r.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?r.push(`L${t[n+4]} ${t[n+5]}`):r.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);_(this,UA,o6).call(this,r);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?r.push(`L${e[n+4]} ${e[n+5]}`):r.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return _(this,UA,a6).call(this,r),r.join(" ")}newFreeDrawOutline(t,e,r,n,s,A){return new f6(t,e,r,n,s,A)}getOutlines(){var t;const e=c(this,Wo),r=c(this,$a),n=c(this,He),[s,A,a,o]=c(this,kA),l=new Float32Array((((t=c(this,zc))==null?void 0:t.length)??0)+2);for(let f=0,d=l.length-2;f<d;f+=2)l[f]=(c(this,zc)[f]-s)/a,l[f+1]=(c(this,zc)[f+1]-A)/o;if(l[l.length-2]=(c(this,fp)-s)/a,l[l.length-1]=(c(this,pp)-A)/o,isNaN(n[6])&&!this.isEmpty())return _(this,UA,l6).call(this,l);const h=new Float32Array(c(this,Wo).length+24+c(this,$a).length);let u=e.length;for(let f=0;f<u;f+=2){if(isNaN(e[f])){h[f]=h[f+1]=NaN;continue}h[f]=e[f],h[f+1]=e[f+1]}u=_(this,UA,c6).call(this,h,u);for(let f=r.length-6;f>=6;f-=6)for(let d=0;d<6;d+=2){if(isNaN(r[f+d])){h[u]=h[u+1]=NaN,u+=2;continue}h[u]=r[f+d],h[u+1]=r[f+d+1],u+=2}return _(this,UA,h6).call(this,h,u),this.newFreeDrawOutline(h,l,c(this,kA),c(this,m0),c(this,p0),c(this,g0))}};kA=new WeakMap,$a=new WeakMap,p0=new WeakMap,g0=new WeakMap,Wo=new WeakMap,He=new WeakMap,fp=new WeakMap,pp=new WeakMap,Y2=new WeakMap,$2=new WeakMap,m0=new WeakMap,bm=new WeakMap,zc=new WeakMap,Z2=new WeakMap,YB=new WeakMap,m4=new WeakMap,UA=new WeakSet,ng=function(){const i=c(this,He).subarray(4,6),t=c(this,He).subarray(16,18),[e,r,n,s]=c(this,kA);return[(c(this,fp)+(i[0]-t[0])/2-e)/n,(c(this,pp)+(i[1]-t[1])/2-r)/s,(c(this,fp)+(t[0]-i[0])/2-e)/n,(c(this,pp)+(t[1]-i[1])/2-r)/s]},A6=function(){const[i,t,e,r]=c(this,kA),[n,s,A,a]=_(this,UA,ng).call(this);return`M${(c(this,He)[2]-i)/e} ${(c(this,He)[3]-t)/r} L${(c(this,He)[4]-i)/e} ${(c(this,He)[5]-t)/r} L${n} ${s} L${A} ${a} L${(c(this,He)[16]-i)/e} ${(c(this,He)[17]-t)/r} L${(c(this,He)[14]-i)/e} ${(c(this,He)[15]-t)/r} Z`},a6=function(i){const t=c(this,$a);i.push(`L${t[4]} ${t[5]} Z`)},o6=function(i){const[t,e,r,n]=c(this,kA),s=c(this,He).subarray(4,6),A=c(this,He).subarray(16,18),[a,o,l,h]=_(this,UA,ng).call(this);i.push(`L${(s[0]-t)/r} ${(s[1]-e)/n} L${a} ${o} L${l} ${h} L${(A[0]-t)/r} ${(A[1]-e)/n}`)},l6=function(i){const t=c(this,He),[e,r,n,s]=c(this,kA),[A,a,o,l]=_(this,UA,ng).call(this),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(t[2]-e)/n,(t[3]-r)/s,NaN,NaN,NaN,NaN,(t[4]-e)/n,(t[5]-r)/s,NaN,NaN,NaN,NaN,A,a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,(t[16]-e)/n,(t[17]-r)/s,NaN,NaN,NaN,NaN,(t[14]-e)/n,(t[15]-r)/s],0),this.newFreeDrawOutline(h,i,c(this,kA),c(this,m0),c(this,p0),c(this,g0))},h6=function(i,t){const e=c(this,$a);return i.set([NaN,NaN,NaN,NaN,e[4],e[5]],t),t+=6},c6=function(i,t){const e=c(this,He).subarray(4,6),r=c(this,He).subarray(16,18),[n,s,A,a]=c(this,kA),[o,l,h,u]=_(this,UA,ng).call(this);return i.set([NaN,NaN,NaN,NaN,(e[0]-n)/A,(e[1]-s)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,u,NaN,NaN,NaN,NaN,(r[0]-n)/A,(r[1]-s)/a],t),t+=24},U(yf,Z2,8),U(yf,YB,2),U(yf,m4,c(yf,Z2)+c(yf,YB));let u6=yf;var Bm,Kf,Eh,J2,wA,tv,Ti,v4,d6;class f6 extends Jt{constructor(t,e,r,n,s,A){super(),U(this,v4),U(this,Bm),U(this,Kf,new Float32Array(4)),U(this,Eh),U(this,J2),U(this,wA),U(this,tv),U(this,Ti),F(this,Ti,t),F(this,wA,e),F(this,Bm,r),F(this,tv,n),F(this,Eh,s),F(this,J2,A),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],_(this,v4,d6).call(this,A);const[a,o,l,h]=c(this,Kf);for(let u=0,f=t.length;u<f;u+=2)t[u]=(t[u]-a)/l,t[u+1]=(t[u+1]-o)/h;for(let u=0,f=e.length;u<f;u+=2)e[u]=(e[u]-a)/l,e[u+1]=(e[u+1]-o)/h}toSVGPath(){const t=[`M${c(this,Ti)[4]} ${c(this,Ti)[5]}`];for(let e=6,r=c(this,Ti).length;e<r;e+=6){if(isNaN(c(this,Ti)[e])){t.push(`L${c(this,Ti)[e+4]} ${c(this,Ti)[e+5]}`);continue}t.push(`C${c(this,Ti)[e]} ${c(this,Ti)[e+1]} ${c(this,Ti)[e+2]} ${c(this,Ti)[e+3]} ${c(this,Ti)[e+4]} ${c(this,Ti)[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,r,n],s){const A=r-t,a=n-e;let o,l;switch(s){case 0:o=Jt._rescale(c(this,Ti),t,n,A,-a),l=Jt._rescale(c(this,wA),t,n,A,-a);break;case 90:o=Jt._rescaleAndSwap(c(this,Ti),t,e,A,a),l=Jt._rescaleAndSwap(c(this,wA),t,e,A,a);break;case 180:o=Jt._rescale(c(this,Ti),r,e,-A,a),l=Jt._rescale(c(this,wA),r,e,-A,a);break;case 270:o=Jt._rescaleAndSwap(c(this,Ti),r,n,-A,-a),l=Jt._rescaleAndSwap(c(this,wA),r,n,-A,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return c(this,Kf)}newOutliner(t,e,r,n,s,A=0){return new u6(t,e,r,n,s,A)}getNewOutline(t,e){const[r,n,s,A]=c(this,Kf),[a,o,l,h]=c(this,Bm),u=s*l,f=A*h,d=r*l+a,g=n*h+o,m=this.newOutliner({x:c(this,wA)[0]*u+d,y:c(this,wA)[1]*f+g},c(this,Bm),c(this,tv),t,c(this,J2),e??c(this,Eh));for(let y=2;y<c(this,wA).length;y+=2)m.add({x:c(this,wA)[y]*u+d,y:c(this,wA)[y+1]*f+g});return m.getOutlines()}}Bm=new WeakMap,Kf=new WeakMap,Eh=new WeakMap,J2=new WeakMap,wA=new WeakMap,tv=new WeakMap,Ti=new WeakMap,v4=new WeakSet,d6=function(i){const t=c(this,Ti);let e=t[4],r=t[5];const n=[e,r,e,r];let s=e,A=r,a=e,o=r;const l=i?Math.max:Math.min,h=new Float32Array(4);for(let f=6,d=t.length;f<d;f+=6){const g=t[f+4],m=t[f+5];isNaN(t[f])?(Nt.pointBoundingBox(g,m,n),A>m?(s=g,A=m):A===m&&(s=l(s,g)),o<m?(a=g,o=m):o===m&&(a=l(a,g))):(h.set(fl,0),Nt.bezierBoundingBox(e,r,...t.slice(f,f+6),h),Nt.rectBoundingBox(...h,n),A>h[1]?(s=h[0],A=h[1]):A===h[1]&&(s=l(s,h[0])),o<h[3]?(a=h[2],o=h[3]):o===h[3]&&(a=l(a,h[2]))),e=g,r=m}const u=c(this,Kf);u[0]=n[0]-c(this,Eh),u[1]=n[1]-c(this,Eh),u[2]=n[2]-n[0]+2*c(this,Eh),u[3]=n[3]-n[1]+2*c(this,Eh),this.firstPoint=[s,A],this.lastPoint=[a,o]};var sy,Ay,ay,qc,Ra,ro,p6,sw,g6,m6,y4;class b4{constructor(t,e=0,r=0,n=!0){U(this,ro),U(this,sy),U(this,Ay),U(this,ay),U(this,qc,[]),U(this,Ra,[]);const s=fl.slice(),A=10**-4;for(const{x:m,y,width:w,height:b}of t){const C=Math.floor((m-e)/A)*A,S=Math.ceil((m+w+e)/A)*A,k=Math.floor((y-e)/A)*A,I=Math.ceil((y+b+e)/A)*A,N=[C,k,I,!0],D=[S,k,I,!1];c(this,qc).push(N,D),Nt.rectBoundingBox(C,k,S,I,s)}const a=s[2]-s[0]+2*r,o=s[3]-s[1]+2*r,l=s[0]-r,h=s[1]-r;let u=n?-1/0:1/0,f=1/0;const d=c(this,qc).at(n?-1:-2),g=[d[0],d[2]];for(const m of c(this,qc)){const[y,w,b,C]=m;!C&&n?w<f?(f=w,u=y):w===f&&(u=Math.max(u,y)):C&&!n&&(w<f?(f=w,u=y):w===f&&(u=Math.min(u,y))),m[0]=(y-l)/a,m[1]=(w-h)/o,m[2]=(b-h)/o}F(this,sy,new Float32Array([l,h,a,o])),F(this,Ay,[u,f]),F(this,ay,g)}getOutlines(){c(this,qc).sort((e,r)=>e[0]-r[0]||e[1]-r[1]||e[2]-r[2]);const t=[];for(const e of c(this,qc))e[3]?(t.push(..._(this,ro,y4).call(this,e)),_(this,ro,g6).call(this,e)):(_(this,ro,m6).call(this,e),t.push(..._(this,ro,y4).call(this,e)));return _(this,ro,p6).call(this,t)}}sy=new WeakMap,Ay=new WeakMap,ay=new WeakMap,qc=new WeakMap,Ra=new WeakMap,ro=new WeakSet,p6=function(i){const t=[],e=new Set;for(const s of i){const[A,a,o]=s;t.push([A,a,s],[A,o,s])}t.sort((s,A)=>s[1]-A[1]||s[0]-A[0]);for(let s=0,A=t.length;s<A;s+=2){const a=t[s][2],o=t[s+1][2];a.push(o),o.push(a),e.add(a),e.add(o)}const r=[];let n;for(;e.size>0;){const s=e.values().next().value;let[A,a,o,l,h]=s;e.delete(s);let u=A,f=a;for(n=[A,o],r.push(n);;){let d;if(e.has(l))d=l;else if(e.has(h))d=h;else break;e.delete(d),[A,a,o,l,h]=d,u!==A&&(n.push(u,f,A,f===a?a:o),u=A),f=f===a?o:a}n.push(u,f)}return new WW(r,c(this,sy),c(this,Ay),c(this,ay))},sw=function(i){const t=c(this,Ra);let e=0,r=t.length-1;for(;e<=r;){const n=e+r>>1,s=t[n][0];if(s===i)return n;s<i?e=n+1:r=n-1}return r+1},g6=function([,i,t]){const e=_(this,ro,sw).call(this,i);c(this,Ra).splice(e,0,[i,t])},m6=function([,i,t]){const e=_(this,ro,sw).call(this,i);for(let r=e;r<c(this,Ra).length;r++){const[n,s]=c(this,Ra)[r];if(n!==i)break;if(n===i&&s===t){c(this,Ra).splice(r,1);return}}for(let r=e-1;r>=0;r--){const[n,s]=c(this,Ra)[r];if(n!==i)break;if(n===i&&s===t){c(this,Ra).splice(r,1);return}}},y4=function(i){const[t,e,r]=i,n=[[t,e,r]],s=_(this,ro,sw).call(this,r);for(let A=0;A<s;A++){const[a,o]=c(this,Ra)[A];for(let l=0,h=n.length;l<h;l++){const[,u,f]=n[l];if(!(o<=u||f<=a)){if(u>=a){if(f>o)n[l][1]=o;else{if(h===1)return[];n.splice(l,1),l--,h--}continue}n[l][2]=a,f>o&&n.push([t,o,f])}}}return n};var ev,Cm;class WW extends Jt{constructor(t,e,r,n){super(),U(this,ev),U(this,Cm),F(this,Cm,t),F(this,ev,e),this.firstPoint=r,this.lastPoint=n}toSVGPath(){const t=[];for(const e of c(this,Cm)){let[r,n]=e;t.push(`M${r} ${n}`);for(let s=2;s<e.length;s+=2){const A=e[s],a=e[s+1];A===r?(t.push(`V${a}`),n=a):a===n&&(t.push(`H${A}`),r=A)}t.push("Z")}return t.join(" ")}serialize([t,e,r,n],s){const A=[],a=r-t,o=n-e;for(const l of c(this,Cm)){const h=new Array(l.length);for(let u=0;u<l.length;u+=2)h[u]=t+l[u]*a,h[u+1]=n-l[u+1]*o;A.push(h)}return A}get box(){return c(this,ev)}get classNamesForOutlining(){return["highlightOutline"]}}ev=new WeakMap,Cm=new WeakMap;class B4 extends u6{newFreeDrawOutline(t,e,r,n,s,A){return new jW(t,e,r,n,s,A)}}class jW extends f6{newOutliner(t,e,r,n,s,A=0){return new B4(t,e,r,n,s,A)}}var w0,oy,_h,Gf,rv,Zs,ly,hy,gp,yA,EA,Gn,v0,y0,hs,xm,ha,iv,or,C4,cy,w6,v6,DU,x4,Xc,cl,mp,y6,nv,uy,b6,B6,C6,x6,F6;const xs=class Rn extends Vr{constructor(t){super({...t,name:"highlightEditor"}),U(this,or),U(this,w0,null),U(this,oy,0),U(this,_h),U(this,Gf,null),U(this,rv,null),U(this,Zs,null),U(this,ly,null),U(this,hy,0),U(this,gp,null),U(this,yA,null),U(this,EA,null),U(this,Gn,!1),U(this,v0,null),U(this,y0,null),U(this,hs,null),U(this,xm,""),U(this,ha),U(this,iv,""),this.color=t.color||Rn._defaultColor,F(this,ha,t.thickness||Rn._defaultThickness),this.opacity=t.opacity||Rn._defaultOpacity,F(this,_h,t.boxes||null),F(this,iv,t.methodOfCreation||""),F(this,xm,t.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(F(this,Gn,!0),_(this,or,cy).call(this,t),_(this,or,Xc).call(this)):c(this,_h)&&(F(this,w0,t.anchorNode),F(this,oy,t.anchorOffset),F(this,ly,t.focusNode),F(this,hy,t.focusOffset),_(this,or,C4).call(this),_(this,or,Xc).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const t=Rn.prototype;return ke(this,"_keyboardManager",new $0([[["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:c(this,Gn)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:c(this,ha),methodOfCreation:c(this,iv)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var r;Vr.initialize(t,e),Rn._defaultColor||(Rn._defaultColor=((r=e.highlightColors)==null?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(t,e){switch(t){case _e.HIGHLIGHT_COLOR:Rn._defaultColor=e;break;case _e.HIGHLIGHT_THICKNESS:Rn._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return c(this,y0)}get commentButtonPosition(){return c(this,v0)}updateParams(t,e){switch(t){case _e.HIGHLIGHT_COLOR:_(this,or,w6).call(this,e);break;case _e.HIGHLIGHT_THICKNESS:_(this,or,v6).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[_e.HIGHLIGHT_COLOR,Rn._defaultColor],[_e.HIGHLIGHT_THICKNESS,Rn._defaultThickness]]}get propertiesToUpdate(){return[[_e.HIGHLIGHT_COLOR,this.color||Rn._defaultColor],[_e.HIGHLIGHT_THICKNESS,c(this,ha)||Rn._defaultThickness],[_e.HIGHLIGHT_FREE,c(this,Gn)]]}onUpdatedColor(){var t,e;(t=this.parent)==null||t.drawLayer.updateProperties(c(this,EA),{root:{fill:this.color,"fill-opacity":this.opacity}}),(e=c(this,rv))==null||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",F(this,rv,new zS({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(_(this,or,uy).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,_(this,or,uy).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){_(this,or,x4).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(_(this,or,Xc).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let r=!1;this.parent&&!t?_(this,or,x4).call(this):t&&(_(this,or,Xc).call(this,t),r=!this.parent&&((e=this.div)==null?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),r&&this.select()}rotate(t){var e,r,n;const{drawLayer:s}=this.parent;let A;c(this,Gn)?(t=(t-this.rotation+360)%360,A=_(e=Rn,cl,mp).call(e,c(this,yA).box,t)):A=_(r=Rn,cl,mp).call(r,[this.x,this.y,this.width,this.height],t),s.updateProperties(c(this,EA),{bbox:A,root:{"data-main-rotation":t}}),s.updateProperties(c(this,hs),{bbox:_(n=Rn,cl,mp).call(n,c(this,Zs).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();c(this,xm)&&(t.setAttribute("aria-label",c(this,xm)),t.setAttribute("role","mark")),c(this,Gn)?t.classList.add("free"):this.div.addEventListener("keydown",_(this,or,y6).bind(this),{signal:this._uiManager._signal});const e=F(this,gp,document.createElement("div"));return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=c(this,Gf),this.setDims(),xN(this,c(this,gp),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||(t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:_(this,or,nv).call(this,!0);break;case 1:case 3:_(this,or,nv).call(this,!1);break}}select(){var t;super.select(),c(this,hs)&&((t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),c(this,hs)&&((t=this.parent)==null||t.drawLayer.updateProperties(c(this,hs),{rootClass:{selected:!1}}),c(this,Gn)||_(this,or,nv).call(this,!1))}get _mustFixPosition(){return!c(this,Gn)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(c(this,EA),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(c(this,hs),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:r,x:n,y:s}){const{x:A,y:a,width:o,height:l}=r.getBoundingClientRect(),h=new AbortController,u=t.combinedSignal(h),f=d=>{h.abort(),_(this,cl,x6).call(this,t,d)};window.addEventListener("blur",f,{signal:u}),window.addEventListener("pointerup",f,{signal:u}),window.addEventListener("pointerdown",Hr,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",AA,{signal:u}),r.addEventListener("pointermove",_(this,cl,C6).bind(this,t),{signal:u}),this._freeHighlight=new B4({x:n,y:s},[A,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(t,e,r){var n,s,A,a;let o=null;if(t instanceof $P){const{data:{quadPoints:C,rect:S,rotation:k,id:I,color:N,opacity:D,popupRef:Q,richText:K,contentsObj:L,creationDate:O,modificationDate:W},parent:{page:{pageNumber:R}}}=t;o=t={annotationType:Se.HIGHLIGHT,color:Array.from(N),opacity:D,quadPoints:C,boxes:null,pageIndex:R-1,rect:S.slice(0),rotation:k,annotationElementId:I,id:I,deleted:!1,popupRef:Q,richText:K,comment:(L==null?void 0:L.str)||null,creationDate:O,modificationDate:W}}else if(t instanceof XS){const{data:{inkLists:C,rect:S,rotation:k,id:I,color:N,borderStyle:{rawWidth:D},popupRef:Q,richText:K,contentsObj:L,creationDate:O,modificationDate:W},parent:{page:{pageNumber:R}}}=t;o=t={annotationType:Se.HIGHLIGHT,color:Array.from(N),thickness:D,inkLists:C,boxes:null,pageIndex:R-1,rect:S.slice(0),rotation:k,annotationElementId:I,id:I,deleted:!1,popupRef:Q,richText:K,comment:(L==null?void 0:L.str)||null,creationDate:O,modificationDate:W}}const{color:l,quadPoints:h,inkLists:u,outlines:f,opacity:d}=t,g=await super.deserialize(t,e,r);g.color=Nt.makeHexColor(...l),g.opacity=d||1,u&&F(g,ha,t.thickness),g._initialData=o,t.comment&&g.setCommentData(t);const[m,y]=g.pageDimensions,[w,b]=g.pageTranslation;if(h){const C=F(g,_h,[]);for(let S=0;S<h.length;S+=8)C.push({x:(h[S]-w)/m,y:1-(h[S+1]-b)/y,width:(h[S+2]-h[S])/m,height:(h[S+1]-h[S+5])/y});_(n=g,or,C4).call(n),_(s=g,or,Xc).call(s),g.rotate(g.rotation)}else if(u||f){F(g,Gn,!0);const C=(u||f.points)[0],S={x:C[0]-w,y:y-(C[1]-b)},k=new B4(S,[0,0,m,y],1,c(g,ha)/2,!0,.001);for(let D=0,Q=C.length;D<Q;D+=2)S.x=C[D]-w,S.y=y-(C[D+1]-b),k.add(S);const{id:I,clipPathId:N}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:g.color,"fill-opacity":g._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);_(A=g,or,cy).call(A,{highlightOutlines:k.getOutlines(),highlightId:I,clipPathId:N}),_(a=g,or,Xc).call(a),g.rotate(g.parentRotation)}return g}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=Vr._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),r=super.serialize(t);return Object.assign(r,{color:e,opacity:this.opacity,thickness:c(this,ha),quadPoints:_(this,or,b6).call(this),outlines:_(this,or,B6).call(this,r.rect)}),this.addComment(r),this.annotationElementId&&!_(this,or,F6).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};w0=new WeakMap,oy=new WeakMap,_h=new WeakMap,Gf=new WeakMap,rv=new WeakMap,Zs=new WeakMap,ly=new WeakMap,hy=new WeakMap,gp=new WeakMap,yA=new WeakMap,EA=new WeakMap,Gn=new WeakMap,v0=new WeakMap,y0=new WeakMap,hs=new WeakMap,xm=new WeakMap,ha=new WeakMap,iv=new WeakMap,or=new WeakSet,C4=function(){const i=new b4(c(this,_h),.001);F(this,yA,i.getOutlines()),[this.x,this.y,this.width,this.height]=c(this,yA).box;const t=new b4(c(this,_h),.0025,.001,this._uiManager.direction==="ltr");F(this,Zs,t.getOutlines());const{firstPoint:e}=c(this,yA);F(this,v0,[(e[0]-this.x)/this.width,(e[1]-this.y)/this.height]);const{lastPoint:r}=c(this,Zs);F(this,y0,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},cy=function({highlightOutlines:i,highlightId:t,clipPathId:e}){var r,n;if(F(this,yA,i),F(this,Zs,i.getNewOutline(c(this,ha)/2+1.5,.0025)),t>=0)F(this,EA,t),F(this,Gf,e),this.parent.drawLayer.finalizeDraw(t,{bbox:i.box,path:{d:i.toSVGPath()}}),F(this,hs,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:c(this,Zs).box,path:{d:c(this,Zs).toSVGPath()}},!0));else if(this.parent){const u=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(c(this,EA),{bbox:_(r=xs,cl,mp).call(r,c(this,yA).box,(u-this.rotation+360)%360),path:{d:i.toSVGPath()}}),this.parent.drawLayer.updateProperties(c(this,hs),{bbox:_(n=xs,cl,mp).call(n,c(this,Zs).box,u),path:{d:c(this,Zs).toSVGPath()}})}const[s,A,a,o]=i.box;switch(this.rotation){case 0:this.x=s,this.y=A,this.width=a,this.height=o;break;case 90:{const[u,f]=this.parentDimensions;this.x=A,this.y=1-s,this.width=a*f/u,this.height=o*u/f;break}case 180:this.x=1-s,this.y=1-A,this.width=a,this.height=o;break;case 270:{const[u,f]=this.parentDimensions;this.x=1-A,this.y=s,this.width=a*f/u,this.height=o*u/f;break}}const{firstPoint:l}=i;F(this,v0,[(l[0]-s)/a,(l[1]-A)/o]);const{lastPoint:h}=c(this,Zs);F(this,y0,[(h[0]-s)/a,(h[1]-A)/o])},w6=function(i){const t=(n,s)=>{this.color=n,this.opacity=s,this.onUpdatedColor()},e=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,i,xs._defaultOpacity),undo:t.bind(this,e,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(i)},!0)},v6=function(i){const t=c(this,ha),e=r=>{F(this,ha,r),_(this,or,DU).call(this,r)};this.addCommands({cmd:e.bind(this,i),undo:e.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:i},!0)},DU=function(i){c(this,Gn)&&(_(this,or,cy).call(this,{highlightOutlines:c(this,yA).getNewOutline(i/2)}),this.fixAndSetPosition(),this.setDims())},x4=function(){c(this,EA)===null||!this.parent||(this.parent.drawLayer.remove(c(this,EA)),F(this,EA,null),this.parent.drawLayer.remove(c(this,hs)),F(this,hs,null))},Xc=function(i=this.parent){c(this,EA)===null&&({id:$i(this,EA)._,clipPathId:$i(this,Gf)._}=i.drawLayer.draw({bbox:c(this,yA).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:c(this,Gn)},path:{d:c(this,yA).toSVGPath()}},!1,!0),F(this,hs,i.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:c(this,Gn)},bbox:c(this,Zs).box,path:{d:c(this,Zs).toSVGPath()}},c(this,Gn))),c(this,gp)&&(c(this,gp).style.clipPath=c(this,Gf)))},cl=new WeakSet,mp=function([i,t,e,r],n){switch(n){case 90:return[1-t-r,i,r,e];case 180:return[1-i-e,1-t-r,e,r];case 270:return[t,1-i-e,r,e]}return[i,t,e,r]},y6=function(i){xs._keyboardManager.exec(this,i)},nv=function(i){if(!c(this,w0))return;const t=window.getSelection();i?t.setPosition(c(this,w0),c(this,oy)):t.setPosition(c(this,ly),c(this,hy))},uy=function(){return c(this,Gn)?this.rotation:0},b6=function(){if(c(this,Gn))return null;const[i,t]=this.pageDimensions,[e,r]=this.pageTranslation,n=c(this,_h),s=new Float32Array(n.length*8);let A=0;for(const{x:a,y:o,width:l,height:h}of n){const u=a*i+e,f=(1-o)*t+r;s[A]=s[A+4]=u,s[A+1]=s[A+3]=f,s[A+2]=s[A+6]=u+l*i,s[A+5]=s[A+7]=f-h*t,A+=8}return s},B6=function(i){return c(this,yA).serialize(i,_(this,or,uy).call(this))},C6=function(i,t){this._freeHighlight.add(t)&&i.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},x6=function(i,t){this._freeHighlight.isEmpty()?i.drawLayer.remove(this._freeHighlightId):i.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},F6=function(i){const{color:t}=this._initialData;return this.hasEditedComment||i.color.some((e,r)=>e!==t[r])},U(xs,cl),ut(xs,"_defaultColor",null),ut(xs,"_defaultOpacity",1),ut(xs,"_defaultThickness",12),ut(xs,"_type","highlight"),ut(xs,"_editorType",Se.HIGHLIGHT),ut(xs,"_freeHighlightId",-1),ut(xs,"_freeHighlight",null),ut(xs,"_freeHighlightClipId","");let OU=xs;var bf;class S6{constructor(){U(this,bf,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,r]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,r)}updateSVGProperty(t,e){c(this,bf)[t]=e}toSVGProperties(){const t=c(this,bf);return F(this,bf,Object.create(null)),{root:t}}reset(){F(this,bf,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){rr("Not implemented")}}bf=new WeakMap;var Us,Fm,pn,zf,qf,Ir,F4,$B,S4,Sm,RU,sv,b0,Bf;const ih=class ar extends Vr{constructor(t){super(t),U(this,Ir),U(this,Us,null),U(this,Fm),ut(this,"_colorPicker",null),ut(this,"_drawId",null),F(this,Fm,t.mustBeCommitted||!1),this._addOutlines(t)}onUpdatedColor(){var t;(t=this._colorPicker)==null||t.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var t,e;(e=(t=this._colorPicker)==null?void 0:t.updateOpacity)==null||e.call(t,this.opacity)}_addOutlines(t){t.drawOutlines&&(_(this,Ir,F4).call(this,t),_(this,Ir,Sm).call(this))}static _mergeSVGProperties(t,e){const r=new Set(Object.keys(t));for(const[n,s]of Object.entries(e))r.has(n)?Object.assign(t[n],s):t[n]=s;return t}static getDefaultDrawingOptions(t){rr("Not implemented")}static get typesMap(){rr("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,e),this._currentParent&&(c(ar,pn).updateProperty(r,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const r=this.constructor.typesMap.get(t);r&&this._updateProperty(t,r,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[r,n]of this.typesMap)t.push([r,e[n]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[r,n]of this.constructor.typesMap)t.push([r,e[n]]);return t}_updateProperty(t,e,r){const n=this._drawingOptions,s=n[e],A=a=>{var o;n.updateProperty(e,a);const l=c(this,Us).updateProperty(e,a);l&&_(this,Ir,b0).call(this,l),(o=this.parent)==null||o.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:A.bind(this,r),undo:A.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){const r=this.constructor.typesMap.get(this.colorType),n=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,A=s[r],a=s[n],o=(l,h)=>{var u;s.updateProperty(r,l),s.updateProperty(n,h),c(this,Us).updateProperty(r,l),c(this,Us).updateProperty(n,h),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,A,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_e.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties(c(this,Us).getPathResizingSVGProperties(_(this,Ir,sv).call(this)),{bbox:_(this,Ir,Bf).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties(c(this,Us).getPathResizedSVGProperties(_(this,Ir,sv).call(this)),{bbox:_(this,Ir,Bf).call(this)}))}_onTranslating(t,e){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,{bbox:_(this,Ir,Bf).call(this)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties(c(this,Us).getPathTranslatedSVGProperties(_(this,Ir,sv).call(this),this.parentDimensions),{bbox:_(this,Ir,Bf).call(this)}))}_onStartDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,c(this,Fm)&&(F(this,Fm,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){_(this,Ir,S4).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(_(this,Ir,Sm).call(this),_(this,Ir,b0).call(this,c(this,Us).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let r=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),_(this,Ir,S4).call(this)):t&&(this._uiManager.addShouldRescale(this),_(this,Ir,Sm).call(this,t),r=!this.parent&&((e=this.div)==null?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),r&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,ar._mergeSVGProperties({bbox:_(this,Ir,Bf).call(this)},c(this,Us).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&_(this,Ir,b0).call(this,c(this,Us).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const r=super.render();r.classList.add("draw");const n=document.createElement("div");return r.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),r}static createDrawerInstance(t,e,r,n,s){rr("Not implemented")}static startDrawing(t,e,r,n){var s;const{target:A,offsetX:a,offsetY:o,pointerId:l,pointerType:h}=n;if(Bs.isInitializedAndDifferentPointerType(h))return;const{viewport:{rotation:u}}=t,{width:f,height:d}=A.getBoundingClientRect(),g=F(ar,zf,new AbortController),m=t.combinedSignal(g);if(Bs.setPointer(h,l),window.addEventListener("pointerup",y=>{Bs.isSamePointerIdOrRemove(y.pointerId)&&this._endDraw(y)},{signal:m}),window.addEventListener("pointercancel",y=>{Bs.isSamePointerIdOrRemove(y.pointerId)&&this._currentParent.endDrawingSession()},{signal:m}),window.addEventListener("pointerdown",y=>{Bs.isSamePointerType(y.pointerType)&&(Bs.initializeAndAddPointerId(y.pointerId),c(ar,pn).isCancellable()&&(c(ar,pn).removeLastElement(),c(ar,pn).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",AA,{signal:m}),A.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),A.addEventListener("touchmove",y=>{Bs.isSameTimeStamp(y.timeStamp)&&Hr(y)},{signal:m}),t.toggleDrawing(),(s=e._editorUndoBar)==null||s.hide(),c(ar,pn)){t.drawLayer.updateProperties(this._currentDrawId,c(ar,pn).startNew(a,o,f,d,u));return}e.updateUIForDefaultProperties(this),F(ar,pn,this.createDrawerInstance(a,o,f,d,u)),F(ar,qf,this.getDefaultDrawingOptions()),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(c(ar,qf).toSVGProperties(),c(ar,pn).defaultSVGProperties),!0,!1)}static _drawMove(t){if(Bs.isSameTimeStamp(t.timeStamp),!c(ar,pn))return;const{offsetX:e,offsetY:r,pointerId:n}=t;if(Bs.isSamePointerId(n)){if(Bs.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,c(ar,pn).add(e,r)),Bs.setTimeStamp(t.timeStamp),Hr(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,F(ar,pn,null),F(ar,qf,null),Bs.clearTimeStamp()),c(ar,zf)&&(c(ar,zf).abort(),F(ar,zf,null),Bs.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),(t==null?void 0:t.target)===e.div&&e.drawLayer.updateProperties(this._currentDrawId,c(ar,pn).end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const r=c(ar,pn),n=this._currentDrawId,s=r.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,r.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(n,r.removeLastElement())},mustExec:!1,type:_e.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(_e.DRAW_STEP),!c(ar,pn).isEmpty()){const{pageDimensions:[r,n],scale:s}=e,A=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:c(ar,pn).getOutlines(r*s,n*s,s,this._INNER_MARGIN),drawingOptions:c(ar,qf),mustBeCommitted:!t});return this._cleanup(!0),A}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,r,n,s,A){rr("Not implemented")}static async deserialize(t,e,r){var n,s;const{rawDims:{pageWidth:A,pageHeight:a,pageX:o,pageY:l}}=e.viewport,h=this.deserializeDraw(o,l,A,a,this._INNER_MARGIN,t),u=await super.deserialize(t,e,r);return u.createDrawingOptions(t),_(n=u,Ir,F4).call(n,{drawOutlines:h}),_(s=u,Ir,Sm).call(s),u.onScaleChanging(),u.rotate(),u}serializeDraw(t){const[e,r]=this.pageTranslation,[n,s]=this.pageDimensions;return c(this,Us).serialize([e,r,n,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Us=new WeakMap,Fm=new WeakMap,pn=new WeakMap,zf=new WeakMap,qf=new WeakMap,Ir=new WeakSet,F4=function({drawOutlines:i,drawId:t,drawingOptions:e}){F(this,Us,i),this._drawingOptions||(this._drawingOptions=e),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,i.defaultProperties)):this._drawId=_(this,Ir,$B).call(this,i,this.parent),_(this,Ir,b0).call(this,i.box)},$B=function(i,t){const{id:e}=t.drawLayer.draw(ih._mergeSVGProperties(this._drawingOptions.toSVGProperties(),i.defaultSVGProperties),!1,!1);return e},S4=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Sm=function(i=this.parent){if(!(this._drawId!==null&&this.parent===i)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,i.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=_(this,Ir,$B).call(this,c(this,Us),i)}},RU=function([i,t,e,r]){const{parentDimensions:[n,s],rotation:A}=this;switch(A){case 90:return[t,1-i,e*(s/n),r*(n/s)];case 180:return[1-i,1-t,e,r];case 270:return[1-t,i,e*(s/n),r*(n/s)];default:return[i,t,e,r]}},sv=function(){const{x:i,y:t,width:e,height:r,parentDimensions:[n,s],rotation:A}=this;switch(A){case 90:return[1-t,i,e*(n/s),r*(s/n)];case 180:return[1-i,1-t,e,r];case 270:return[t,1-i,e*(n/s),r*(s/n)];default:return[i,t,e,r]}},b0=function(i){[this.x,this.y,this.width,this.height]=_(this,Ir,RU).call(this,i),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Bf=function(){const{x:i,y:t,width:e,height:r,rotation:n,parentRotation:s,parentDimensions:[A,a]}=this;switch((n*4+s)/90){case 1:return[1-t-r,i,r,e];case 2:return[1-i-e,1-t-r,e,r];case 3:return[t,1-i-e,r,e];case 4:return[i,t-e*(A/a),r*(a/A),e*(A/a)];case 5:return[1-t,i,e*(A/a),r*(a/A)];case 6:return[1-i-r*(a/A),1-t,r*(a/A),e*(A/a)];case 7:return[t-e*(A/a),1-i-r*(a/A),e*(A/a),r*(a/A)];case 8:return[i-e,t-r,e,r];case 9:return[1-t,i-e,r,e];case 10:return[1-i,1-t,e,r];case 11:return[t-r,1-i,r,e];case 12:return[i-r*(a/A),t,r*(a/A),e*(A/a)];case 13:return[1-t-e*(A/a),i-r*(a/A),e*(A/a),r*(a/A)];case 14:return[1-i,1-t-e*(A/a),r*(a/A),e*(A/a)];case 15:return[t,1-i,e*(A/a),r*(a/A)];default:return[i,t,e,r]}},ut(ih,"_currentDrawId",-1),ut(ih,"_currentParent",null),U(ih,pn,null),U(ih,zf,null),U(ih,qf,null),ut(ih,"_INNER_MARGIN",3);let E6=ih;var jo,cn,un,Xf,Em,Fs,dn,na,Cf,Yf,$f,km,Av;class KW{constructor(t,e,r,n,s,A){U(this,km),U(this,jo,new Float64Array(6)),U(this,cn),U(this,un),U(this,Xf),U(this,Em),U(this,Fs),U(this,dn,""),U(this,na,0),U(this,Cf,new Z0),U(this,Yf),U(this,$f),F(this,Yf,r),F(this,$f,n),F(this,Xf,s),F(this,Em,A),[t,e]=_(this,km,Av).call(this,t,e);const a=F(this,cn,[NaN,NaN,NaN,NaN,t,e]);F(this,Fs,[t,e]),F(this,un,[{line:a,points:c(this,Fs)}]),c(this,jo).set(a,0)}updateProperty(t,e){t==="stroke-width"&&F(this,Em,e)}isEmpty(){return!c(this,un)||c(this,un).length===0}isCancellable(){return c(this,Fs).length<=10}add(t,e){[t,e]=_(this,km,Av).call(this,t,e);const[r,n,s,A]=c(this,jo).subarray(2,6),a=t-s,o=e-A;return Math.hypot(c(this,Yf)*a,c(this,$f)*o)<=2?null:(c(this,Fs).push(t,e),isNaN(r)?(c(this,jo).set([s,A,t,e],2),c(this,cn).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(c(this,jo)[0])&&c(this,cn).splice(6,6),c(this,jo).set([r,n,s,A,t,e],0),c(this,cn).push(...Jt.createBezierPoints(r,n,s,A,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(c(this,Fs).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,r,n,s){F(this,Yf,r),F(this,$f,n),F(this,Xf,s),[t,e]=_(this,km,Av).call(this,t,e);const A=F(this,cn,[NaN,NaN,NaN,NaN,t,e]);F(this,Fs,[t,e]);const a=c(this,un).at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),c(this,un).push({line:A,points:c(this,Fs)}),c(this,jo).set(A,0),F(this,na,0),this.toSVGPath(),null}getLastElement(){return c(this,un).at(-1)}setLastElement(t){return c(this,un)?(c(this,un).push(t),F(this,cn,t.line),F(this,Fs,t.points),F(this,na,0),{path:{d:this.toSVGPath()}}):c(this,Cf).setLastElement(t)}removeLastElement(){if(!c(this,un))return c(this,Cf).removeLastElement();c(this,un).pop(),F(this,dn,"");for(let t=0,e=c(this,un).length;t<e;t++){const{line:r,points:n}=c(this,un)[t];F(this,cn,r),F(this,Fs,n),F(this,na,0),this.toSVGPath()}return{path:{d:c(this,dn)}}}toSVGPath(){const t=Jt.svgRound(c(this,cn)[4]),e=Jt.svgRound(c(this,cn)[5]);if(c(this,Fs).length===2)return F(this,dn,`${c(this,dn)} M ${t} ${e} Z`),c(this,dn);if(c(this,Fs).length<=6){const n=c(this,dn).lastIndexOf("M");F(this,dn,`${c(this,dn).slice(0,n)} M ${t} ${e}`),F(this,na,6)}if(c(this,Fs).length===4){const n=Jt.svgRound(c(this,cn)[10]),s=Jt.svgRound(c(this,cn)[11]);return F(this,dn,`${c(this,dn)} L ${n} ${s}`),F(this,na,12),c(this,dn)}const r=[];c(this,na)===0&&(r.push(`M ${t} ${e}`),F(this,na,6));for(let n=c(this,na),s=c(this,cn).length;n<s;n+=6){const[A,a,o,l,h,u]=c(this,cn).slice(n,n+6).map(Jt.svgRound);r.push(`C${A} ${a} ${o} ${l} ${h} ${u}`)}return F(this,dn,c(this,dn)+r.join(" ")),F(this,na,c(this,cn).length),c(this,dn)}getOutlines(t,e,r,n){const s=c(this,un).at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),c(this,Cf).build(c(this,un),t,e,r,c(this,Xf),c(this,Em),n),F(this,jo,null),F(this,cn,null),F(this,un,null),F(this,dn,null),c(this,Cf)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}jo=new WeakMap,cn=new WeakMap,un=new WeakMap,Xf=new WeakMap,Em=new WeakMap,Fs=new WeakMap,dn=new WeakMap,na=new WeakMap,Cf=new WeakMap,Yf=new WeakMap,$f=new WeakMap,km=new WeakSet,Av=function(i,t){return Jt._normalizePoint(i,t,c(this,Yf),c(this,$f),c(this,Xf))};var Is,av,dy,bA,sl,Al,B0,C0,wp,iA,ul,k6,U6,I6;class Z0 extends Jt{constructor(){super(...arguments),U(this,iA),U(this,Is),U(this,av,0),U(this,dy),U(this,bA),U(this,sl),U(this,Al),U(this,B0),U(this,C0),U(this,wp)}build(t,e,r,n,s,A,a){F(this,sl,e),F(this,Al,r),F(this,B0,n),F(this,C0,s),F(this,wp,A),F(this,dy,a??0),F(this,bA,t),_(this,iA,U6).call(this)}get thickness(){return c(this,wp)}setLastElement(t){return c(this,bA).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return c(this,bA).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of c(this,bA)){if(t.push(`M${Jt.svgRound(e[4])} ${Jt.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${Jt.svgRound(e[10])} ${Jt.svgRound(e[11])}`);continue}for(let r=6,n=e.length;r<n;r+=6){const[s,A,a,o,l,h]=e.subarray(r,r+6).map(Jt.svgRound);t.push(`C${s} ${A} ${a} ${o} ${l} ${h}`)}}return t.join("")}serialize([t,e,r,n],s){const A=[],a=[],[o,l,h,u]=_(this,iA,k6).call(this);let f,d,g,m,y,w,b,C,S;switch(c(this,C0)){case 0:S=Jt._rescale,f=t,d=e+n,g=r,m=-n,y=t+o*r,w=e+(1-l-u)*n,b=t+(o+h)*r,C=e+(1-l)*n;break;case 90:S=Jt._rescaleAndSwap,f=t,d=e,g=r,m=n,y=t+l*r,w=e+o*n,b=t+(l+u)*r,C=e+(o+h)*n;break;case 180:S=Jt._rescale,f=t+r,d=e,g=-r,m=n,y=t+(1-o-h)*r,w=e+l*n,b=t+(1-o)*r,C=e+(l+u)*n;break;case 270:S=Jt._rescaleAndSwap,f=t+r,d=e+n,g=-r,m=-n,y=t+(1-l-u)*r,w=e+(1-o-h)*n,b=t+(1-l)*r,C=e+(1-o)*n;break}for(const{line:k,points:I}of c(this,bA))A.push(S(k,f,d,g,m,s?new Array(k.length):null)),a.push(S(I,f,d,g,m,s?new Array(I.length):null));return{lines:A,points:a,rect:[y,w,b,C]}}static deserialize(t,e,r,n,s,{paths:{lines:A,points:a},rotation:o,thickness:l}){const h=[];let u,f,d,g,m;switch(o){case 0:m=Jt._rescale,u=-t/r,f=e/n+1,d=1/r,g=-1/n;break;case 90:m=Jt._rescaleAndSwap,u=-e/n,f=-t/r,d=1/n,g=1/r;break;case 180:m=Jt._rescale,u=t/r+1,f=-e/n,d=-1/r,g=1/n;break;case 270:m=Jt._rescaleAndSwap,u=e/n+1,f=t/r+1,d=-1/n,g=-1/r;break}if(!A){A=[];for(const w of a){const b=w.length;if(b===2){A.push(new Float32Array([NaN,NaN,NaN,NaN,w[0],w[1]]));continue}if(b===4){A.push(new Float32Array([NaN,NaN,NaN,NaN,w[0],w[1],NaN,NaN,NaN,NaN,w[2],w[3]]));continue}const C=new Float32Array(3*(b-2));A.push(C);let[S,k,I,N]=w.subarray(0,4);C.set([NaN,NaN,NaN,NaN,S,k],0);for(let D=4;D<b;D+=2){const Q=w[D],K=w[D+1];C.set(Jt.createBezierPoints(S,k,I,N,Q,K),(D-2)*3),[S,k,I,N]=[I,N,Q,K]}}}for(let w=0,b=A.length;w<b;w++)h.push({line:m(A[w].map(C=>C??NaN),u,f,d,g),points:m(a[w].map(C=>C??NaN),u,f,d,g)});const y=new this.prototype.constructor;return y.build(h,r,n,1,o,l,s),y}get box(){return c(this,Is)}updateProperty(t,e){return t==="stroke-width"?_(this,iA,I6).call(this,e):null}updateParentDimensions([t,e],r){const[n,s]=_(this,iA,ul).call(this);F(this,sl,t),F(this,Al,e),F(this,B0,r);const[A,a]=_(this,iA,ul).call(this),o=A-n,l=a-s,h=c(this,Is);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return F(this,av,t),{path:{transform:this.rotationTransform}}}get viewBox(){return c(this,Is).map(Jt.svgRound).join(" ")}get defaultProperties(){const[t,e]=c(this,Is);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=c(this,Is);let r=0,n=0,s=0,A=0,a=0,o=0;switch(c(this,av)){case 90:n=e/t,s=-t/e,a=t;break;case 180:r=-1,A=-1,a=t,o=e;break;case 270:n=-e/t,s=t/e,o=e;break;default:return""}return`matrix(${r} ${n} ${s} ${A} ${Jt.svgRound(a)} ${Jt.svgRound(o)})`}getPathResizingSVGProperties([t,e,r,n]){const[s,A]=_(this,iA,ul).call(this),[a,o,l,h]=c(this,Is);if(Math.abs(l-s)<=Jt.PRECISION||Math.abs(h-A)<=Jt.PRECISION){const m=t+r/2-(a+l/2),y=e+n/2-(o+h/2);return{path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:`${this.rotationTransform} translate(${m} ${y})`}}}const u=(r-2*s)/(l-2*s),f=(n-2*A)/(h-2*A),d=l/r,g=h/n;return{path:{"transform-origin":`${Jt.svgRound(a)} ${Jt.svgRound(o)}`,transform:`${this.rotationTransform} scale(${d} ${g}) translate(${Jt.svgRound(s)} ${Jt.svgRound(A)}) scale(${u} ${f}) translate(${Jt.svgRound(-s)} ${Jt.svgRound(-A)})`}}}getPathResizedSVGProperties([t,e,r,n]){const[s,A]=_(this,iA,ul).call(this),a=c(this,Is),[o,l,h,u]=a;if(a[0]=t,a[1]=e,a[2]=r,a[3]=n,Math.abs(h-s)<=Jt.PRECISION||Math.abs(u-A)<=Jt.PRECISION){const y=t+r/2-(o+h/2),w=e+n/2-(l+u/2);for(const{line:b,points:C}of c(this,bA))Jt._translate(b,y,w,b),Jt._translate(C,y,w,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const f=(r-2*s)/(h-2*s),d=(n-2*A)/(u-2*A),g=-f*(o+s)+t+s,m=-d*(l+A)+e+A;if(f!==1||d!==1||g!==0||m!==0)for(const{line:y,points:w}of c(this,bA))Jt._rescale(y,g,m,f,d,y),Jt._rescale(w,g,m,f,d,w);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],r){const[n,s]=r,A=c(this,Is),a=t-A[0],o=e-A[1];if(c(this,sl)===n&&c(this,Al)===s)for(const{line:l,points:h}of c(this,bA))Jt._translate(l,a,o,l),Jt._translate(h,a,o,h);else{const l=c(this,sl)/n,h=c(this,Al)/s;F(this,sl,n),F(this,Al,s);for(const{line:u,points:f}of c(this,bA))Jt._rescale(u,a,o,l,h,u),Jt._rescale(f,a,o,l,h,f);A[2]*=l,A[3]*=h}return A[0]=t,A[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`}}}get defaultSVGProperties(){const t=c(this,Is);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Jt.svgRound(t[0])} ${Jt.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}Is=new WeakMap,av=new WeakMap,dy=new WeakMap,bA=new WeakMap,sl=new WeakMap,Al=new WeakMap,B0=new WeakMap,C0=new WeakMap,wp=new WeakMap,iA=new WeakSet,ul=function(i=c(this,wp)){const t=c(this,dy)+i/2*c(this,B0);return c(this,C0)%180===0?[t/c(this,sl),t/c(this,Al)]:[t/c(this,Al),t/c(this,sl)]},k6=function(){const[i,t,e,r]=c(this,Is),[n,s]=_(this,iA,ul).call(this,0);return[i+n,t+s,e-2*n,r-2*s]},U6=function(){const i=F(this,Is,pu.slice());for(const{line:r}of c(this,bA)){if(r.length<=12){for(let A=4,a=r.length;A<a;A+=6)Nt.pointBoundingBox(r[A],r[A+1],i);continue}let n=r[4],s=r[5];for(let A=6,a=r.length;A<a;A+=6){const[o,l,h,u,f,d]=r.subarray(A,A+6);Nt.bezierBoundingBox(n,s,o,l,h,u,f,d,i),n=f,s=d}}const[t,e]=_(this,iA,ul).call(this);i[0]=Mr(i[0]-t,0,1),i[1]=Mr(i[1]-e,0,1),i[2]=Mr(i[2]+t,0,1),i[3]=Mr(i[3]+e,0,1),i[2]-=i[0],i[3]-=i[1]},I6=function(i){const[t,e]=_(this,iA,ul).call(this);F(this,wp,i);const[r,n]=_(this,iA,ul).call(this),[s,A]=[r-t,n-e],a=c(this,Is);return a[0]-=s,a[1]-=A,a[2]+=2*s,a[3]+=2*A,a};class Jy extends S6{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Vr._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Jy(this._viewParameters);return t.updateAll(this),t}}var E4,Q6;const ov=class L6 extends E6{constructor(t){super({...t,name:"inkEditor"}),U(this,E4),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){Vr.initialize(t,e),this._defaultDrawingOptions=new Jy(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return ke(this,"typesMap",new Map([[_e.INK_THICKNESS,"stroke-width"],[_e.INK_COLOR,"stroke"],[_e.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,r,n,s){return new KW(t,e,r,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,r,n,s,A){return Z0.deserialize(t,e,r,n,s,A)}static async deserialize(t,e,r){let n=null;if(t instanceof XS){const{data:{inkLists:A,rect:a,rotation:o,id:l,color:h,opacity:u,borderStyle:{rawWidth:f},popupRef:d,richText:g,contentsObj:m,creationDate:y,modificationDate:w},parent:{page:{pageNumber:b}}}=t;n=t={annotationType:Se.INK,color:Array.from(h),thickness:f,opacity:u,paths:{points:A},boxes:null,pageIndex:b-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:g,comment:(m==null?void 0:m.str)||null,creationDate:y,modificationDate:w}}const s=await super.deserialize(t,e,r);return s._initialData=n,t.comment&&s.setCommentData(t),s}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new VP(this)),[["colorPicker",this._colorPicker]]}get colorType(){return _e.INK_COLOR}get colorAndOpacityType(){return _e.INK_COLOR_AND_OPACITY}get opacityType(){return _e.INK_OPACITY}updateParams(t,e){if(t===_e.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===_e.INK_COLOR_AND_OPACITY){super.updateDefaultParams(_e.INK_COLOR,e.color),super.updateDefaultParams(_e.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:r}=this;e.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:r}){this._drawingOptions=L6.getDefaultDrawingOptions({stroke:Nt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":r})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:r}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":s,"stroke-width":A}}=this,a=Object.assign(super.serialize(t),{color:Vr._colorManager.convert(n),opacity:s,thickness:A,paths:{lines:e,points:r}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!_(this,E4,Q6).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:r}=this.serializeDraw(!1);return t.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}};E4=new WeakSet,Q6=function(i){const{color:t,thickness:e,opacity:r,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||i.color.some((s,A)=>s!==t[A])||i.thickness!==e||i.opacity!==r||i.pageIndex!==n},ut(ov,"_type","ink"),ut(ov,"_editorType",Se.INK),ut(ov,"_defaultDrawingOptions",null);let GW=ov;class k4 extends Z0{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Aw=8,sg=3;var vp,Xi,ZB,_a,HU,VU,U4,aw,_6,M6,T6,I4,Q4,N6;class io{static extractContoursFromText(t,{fontFamily:e,fontStyle:r,fontWeight:n},s,A,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const u=200,f=h.font=`${r} ${n} ${u}px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:g,actualBoundingBoxAscent:m,actualBoundingBoxDescent:y,fontBoundingBoxAscent:w,fontBoundingBoxDescent:b,width:C}=h.measureText(t),S=1.5,k=Math.ceil(Math.max(Math.abs(d)+Math.abs(g)||0,C)*S),I=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||u,Math.abs(w)+Math.abs(b)||u)*S);l=new OffscreenCanvas(k,I),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,k,I),h.fillStyle="black",h.fillText(t,k*(S-1)/2,I*(3-S)/2);const N=_(this,Xi,I4).call(this,h.getImageData(0,0,k,I).data),D=_(this,Xi,T6).call(this,N),Q=_(this,Xi,Q4).call(this,D),K=_(this,Xi,U4).call(this,N,k,I,Q);return this.processDrawnLines({lines:{curves:K,width:k,height:I},pageWidth:s,pageHeight:A,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,r,n,s){const[A,a,o]=_(this,Xi,N6).call(this,t),[l,h]=_(this,Xi,M6).call(this,A,a,o,Math.hypot(a,o)*c(this,vp).sigmaSFactor,c(this,vp).sigmaR,c(this,vp).kernelSize),u=_(this,Xi,Q4).call(this,h),f=_(this,Xi,U4).call(this,l,a,o,u);return this.processDrawnLines({lines:{curves:f,width:a,height:o},pageWidth:e,pageHeight:r,rotation:n,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:r,rotation:n,innerMargin:s,mustSmooth:A,areContours:a}){n%180!==0&&([e,r]=[r,e]);const{curves:o,width:l,height:h}=t,u=t.thickness??0,f=[],d=Math.min(e/l,r/h),g=d/e,m=d/r,y=[];for(const{points:b}of o){const C=A?_(this,Xi,_6).call(this,b):b;if(!C)continue;y.push(C);const S=C.length,k=new Float32Array(S),I=new Float32Array(3*(S===2?2:S-2));if(f.push({line:I,points:k}),S===2){k[0]=C[0]*g,k[1]=C[1]*m,I.set([NaN,NaN,NaN,NaN,k[0],k[1]],0);continue}let[N,D,Q,K]=C;N*=g,D*=m,Q*=g,K*=m,k.set([N,D,Q,K],0),I.set([NaN,NaN,NaN,NaN,N,D],0);for(let L=4;L<S;L+=2){const O=k[L]=C[L]*g,W=k[L+1]=C[L+1]*m;I.set(Jt.createBezierPoints(N,D,Q,K,O,W),(L-2)*3),[N,D,Q,K]=[Q,K,O,W]}}if(f.length===0)return null;const w=a?new k4:new Z0;return w.build(f,e,r,1,n,a?0:u,s),{outline:w,newCurves:y,areContours:a,thickness:u,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:r,width:n,height:s}){let A=1/0,a=-1/0,o=0;for(const w of t){o+=w.length;for(let b=2,C=w.length;b<C;b++){const S=w[b]-w[b-2];A=Math.min(A,S),a=Math.max(a,S)}}let l;A>=-128&&a<=127?l=Int8Array:A>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const h=t.length,u=Aw+sg*h,f=new Uint32Array(u);let d=0;f[d++]=u*Uint32Array.BYTES_PER_ELEMENT+(o-2*h)*l.BYTES_PER_ELEMENT,f[d++]=0,f[d++]=n,f[d++]=s,f[d++]=e?0:1,f[d++]=Math.max(0,Math.floor(r??0)),f[d++]=h,f[d++]=l.BYTES_PER_ELEMENT;for(const w of t)f[d++]=w.length-2,f[d++]=w[0],f[d++]=w[1];const g=new CompressionStream("deflate-raw"),m=g.writable.getWriter();await m.ready,m.write(f);const y=l.prototype.constructor;for(const w of t){const b=new y(w.length-2);for(let C=2,S=w.length;C<S;C++)b[C-2]=w[C]-w[C-2];m.write(b)}return m.close(),(await new Response(g.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:r,writable:n}=new DecompressionStream("deflate-raw"),s=n.getWriter();await s.ready,s.write(e).then(async()=>{await s.ready,await s.close()}).catch(()=>{});let A=null,a=0;for await(const C of r)A||(A=new Uint8Array(new Uint32Array(C.buffer,0,4)[0])),A.set(C,a),a+=C.length;const o=new Uint32Array(A.buffer,0,A.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const h=o[2],u=o[3],f=o[4]===0,d=o[5],g=o[6],m=o[7],y=[],w=(Aw+sg*g)*Uint32Array.BYTES_PER_ELEMENT;let b;switch(m){case Int8Array.BYTES_PER_ELEMENT:b=new Int8Array(A.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:b=new Int16Array(A.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:b=new Int32Array(A.buffer,w);break}a=0;for(let C=0;C<g;C++){const S=o[sg*C+Aw],k=new Float32Array(S+2);y.push(k);for(let I=0;I<sg-1;I++)k[I]=o[sg*C+Aw+I+1];for(let I=0;I<S;I++)k[I+2]=k[I]+b[a++]}return{areContours:f,thickness:d,outlines:y,width:h,height:u}}catch(e){return Me(`decompressSignature: ${e}`),null}}}vp=new WeakMap,Xi=new WeakSet,ZB=function(i,t,e,r){return e-=i,r-=t,e===0?r>0?0:4:e===1?r+6:2-r},_a=new WeakMap,HU=function(i,t,e,r,n,s,A){const a=_(this,Xi,ZB).call(this,e,r,n,s);for(let o=0;o<8;o++){const l=(-o+a-A+16)%8,h=c(this,_a)[2*l],u=c(this,_a)[2*l+1];if(i[(e+h)*t+(r+u)]!==0)return l}return-1},VU=function(i,t,e,r,n,s,A){const a=_(this,Xi,ZB).call(this,e,r,n,s);for(let o=0;o<8;o++){const l=(o+a+A+16)%8,h=c(this,_a)[2*l],u=c(this,_a)[2*l+1];if(i[(e+h)*t+(r+u)]!==0)return l}return-1},U4=function(i,t,e,r){const n=i.length,s=new Int32Array(n);for(let l=0;l<n;l++)s[l]=i[l]<=r?1:0;for(let l=1;l<e-1;l++)s[l*t]=s[l*t+t-1]=0;for(let l=0;l<t;l++)s[l]=s[t*e-1-l]=0;let A=1,a;const o=[];for(let l=1;l<e-1;l++){a=1;for(let h=1;h<t-1;h++){const u=l*t+h,f=s[u];if(f===0)continue;let d=l,g=h;if(f===1&&s[u-1]===0)A+=1,g-=1;else if(f>=1&&s[u+1]===0)A+=1,g+=1,f>1&&(a=f);else{f!==1&&(a=Math.abs(f));continue}const m=[h,l],y=g===h+1,w={isHole:y,points:m,id:A,parent:0};o.push(w);let b;for(const K of o)if(K.id===a){b=K;break}b?b.isHole?w.parent=y?b.parent:a:w.parent=y?a:b.parent:w.parent=y?a:0;const C=_(this,Xi,HU).call(this,s,t,l,h,d,g,0);if(C===-1){s[u]=-A,s[u]!==1&&(a=Math.abs(s[u]));continue}let S=c(this,_a)[2*C],k=c(this,_a)[2*C+1];const I=l+S,N=h+k;d=I,g=N;let D=l,Q=h;for(;;){const K=_(this,Xi,VU).call(this,s,t,D,Q,d,g,1);S=c(this,_a)[2*K],k=c(this,_a)[2*K+1];const L=D+S,O=Q+k;m.push(O,L);const W=D*t+Q;if(s[W+1]===0?s[W]=-A:s[W]===1&&(s[W]=A),L===l&&O===h&&D===I&&Q===N){s[u]!==1&&(a=Math.abs(s[u]));break}else d=D,g=Q,D=L,Q=O}}}return o},aw=function(i,t,e,r){if(e-t<=4){for(let I=t;I<e-2;I+=2)r.push(i[I],i[I+1]);return}const n=i[t],s=i[t+1],A=i[e-4]-n,a=i[e-3]-s,o=Math.hypot(A,a),l=A/o,h=a/o,u=l*s-h*n,f=a/A,d=1/o,g=Math.atan(f),m=Math.cos(g),y=Math.sin(g),w=d*(Math.abs(m)+Math.abs(y)),b=d*(1-w+w**2),C=Math.max(Math.atan(Math.abs(y+m)*b),Math.atan(Math.abs(y-m)*b));let S=0,k=t;for(let I=t+2;I<e-2;I+=2){const N=Math.abs(u-l*i[I+1]+h*i[I]);N>S&&(k=I,S=N)}S>(o*C)**2?(_(this,Xi,aw).call(this,i,t,k+2,r),_(this,Xi,aw).call(this,i,k,e,r)):r.push(n,s)},_6=function(i){const t=[],e=i.length;return _(this,Xi,aw).call(this,i,0,e,t),t.push(i[e-2],i[e-1]),t.length<=4?null:t},M6=function(i,t,e,r,n,s){const A=new Float32Array(s**2),a=-2*r**2,o=s>>1;for(let g=0;g<s;g++){const m=(g-o)**2;for(let y=0;y<s;y++)A[g*s+y]=Math.exp((m+(y-o)**2)/a)}const l=new Float32Array(256),h=-2*n**2;for(let g=0;g<256;g++)l[g]=Math.exp(g**2/h);const u=i.length,f=new Uint8Array(u),d=new Uint32Array(256);for(let g=0;g<e;g++)for(let m=0;m<t;m++){const y=g*t+m,w=i[y];let b=0,C=0;for(let k=0;k<s;k++){const I=g+k-o;if(!(I<0||I>=e))for(let N=0;N<s;N++){const D=m+N-o;if(D<0||D>=t)continue;const Q=i[I*t+D],K=A[k*s+N]*l[Math.abs(Q-w)];b+=Q*K,C+=K}}const S=f[y]=Math.round(b/C);d[S]++}return[f,d]},T6=function(i){const t=new Uint32Array(256);for(const e of i)t[e]++;return t},I4=function(i){const t=i.length,e=new Uint8ClampedArray(t>>2);let r=-1/0,n=1/0;for(let A=0,a=e.length;A<a;A++){const o=e[A]=i[A<<2];r=Math.max(r,o),n=Math.min(n,o)}const s=255/(r-n);for(let A=0,a=e.length;A<a;A++)e[A]=(e[A]-n)*s;return e},Q4=function(i){let t,e=-1/0,r=-1/0;const n=i.findIndex(a=>a!==0);let s=n,A=n;for(t=n;t<256;t++){const a=i[t];a>e&&(t-s>r&&(r=t-s,A=t-1),e=a,s=t)}for(t=A-1;t>=0&&!(i[t]>i[t+1]);t--);return t},N6=function(i){const t=i,{width:e,height:r}=i,{maxDim:n}=c(this,vp);let s=e,A=r;if(e>n||r>n){let l=e,h=r,u=Math.log2(Math.max(e,r)/n);const f=Math.floor(u);u=u===f?f-1:f;for(let g=0;g<u;g++){s=Math.ceil(l/2),A=Math.ceil(h/2);const m=new OffscreenCanvas(s,A);m.getContext("2d").drawImage(i,0,0,l,h,0,0,s,A),l=s,h=A,i!==t&&i.close(),i=m.transferToImageBitmap()}const d=Math.min(n/s,n/A);s=Math.round(s*d),A=Math.round(A*d)}const a=new OffscreenCanvas(s,A).getContext("2d",{willReadFrequently:!0});a.fillStyle="white",a.fillRect(0,0,s,A),a.filter="grayscale(1)",a.drawImage(i,0,0,i.width,i.height,0,0,s,A);const o=a.getImageData(0,0,s,A).data;return[_(this,Xi,I4).call(this,o),s,A]},U(io,Xi),U(io,vp,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),U(io,_a,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class YS extends S6{constructor(){super(),super.updateProperties({fill:Vr._defaultLineColor,"stroke-width":0})}clone(){const t=new YS;return t.updateAll(this),t}}class $S extends Jy{constructor(t){super(t),super.updateProperties({stroke:Vr._defaultLineColor,"stroke-width":1})}clone(){const t=new $S(this._viewParameters);return t.updateAll(this),t}}var Yc,Ko,$c,xf;const lv=class Go extends E6{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),U(this,Yc,!1),U(this,Ko,null),U(this,$c,null),U(this,xf,null),this._willKeepAspectRatio=!0,F(this,$c,t.signatureData||null),F(this,Ko,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){Vr.initialize(t,e),this._defaultDrawingOptions=new YS,this._defaultDrawnSignatureOptions=new $S(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return ke(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!c(this,Ko)}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:r}=this;if(r&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(c(this,$c)){const{lines:n,mustSmooth:s,areContours:A,description:a,uuid:o,heightInPage:l}=c(this,$c),{rawDims:{pageWidth:h,pageHeight:u},rotation:f}=this.parent.viewport,d=io.processDrawnLines({lines:n,pageWidth:h,pageHeight:u,rotation:f,innerMargin:Go._INNER_MARGIN,mustSmooth:s,areContours:A});this.addSignature(d,l,a,o)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:c(this,Ko)||""}));return r&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){F(this,xf,t),this.addEditToolbar()}getUuid(){return c(this,xf)}get description(){return c(this,Ko)}set description(t){F(this,Ko,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e==null||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:r,width:n,height:s}=c(this,$c),A=Math.max(n,s),a=io.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:r,width:n,height:s},pageWidth:A,pageHeight:A,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,r,n){const{x:s,y:A}=this,{outline:a}=F(this,$c,t);F(this,Yc,a instanceof k4),this.description=r;let o;c(this,Yc)?o=Go.getDefaultDrawingOptions():(o=Go._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=s,this.y=A,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:r},rotation:n}=this.parent.viewport;return io.process(t,e,r,n,Go._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:r,pageHeight:n},rotation:s}=this.parent.viewport;return io.extractContoursFromText(t,e,r,n,s,Go._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:r},rotation:n}=this.parent.viewport;return io.processDrawnLines({lines:t,pageWidth:e,pageHeight:r,rotation:n,innerMargin:Go._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Go.getDefaultDrawingOptions():(this._drawingOptions=Go._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:r}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:c(this,Yc),color:[0,0,0],thickness:c(this,Yc)?0:n});return this.addComment(s),t?(s.paths={lines:e,points:r},s.uuid=c(this,xf),s.isCopy=!0):s.lines=e,c(this,Ko)&&(s.accessibilityData={type:"Figure",alt:c(this,Ko)}),s}static deserializeDraw(t,e,r,n,s,A){return A.areContours?k4.deserialize(t,e,r,n,s,A):Z0.deserialize(t,e,r,n,s,A)}static async deserialize(t,e,r){var n;const s=await super.deserialize(t,e,r);return F(s,Yc,t.areContours),s.description=((n=t.accessibilityData)==null?void 0:n.alt)||"",F(s,xf,t.uuid),s}};Yc=new WeakMap,Ko=new WeakMap,$c=new WeakMap,xf=new WeakMap,ut(lv,"_type","signature"),ut(lv,"_editorType",Se.SIGNATURE),ut(lv,"_defaultDrawingOptions",null);let zW=lv;var qr,mn,du,Mh,xu,Um,Th,Ff,zo,IA,x0,_r,Ag,ag,hv,fy,py,L4,cv,P6;class _4 extends Vr{constructor(t){super({...t,name:"stampEditor"}),U(this,_r),U(this,qr,null),U(this,mn,null),U(this,du,null),U(this,Mh,null),U(this,xu,null),U(this,Um,""),U(this,Th,null),U(this,Ff,!1),U(this,zo,null),U(this,IA,!1),U(this,x0,!1),F(this,Mh,t.bitmapUrl),F(this,xu,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){Vr.initialize(t,e)}static isHandlingMimeForPasting(t){return jy.includes(t)}static paste(t,e){e.pasteEditor({mode:Se.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:r}=this._uiManager;if(!r)throw new Error("No ML.");if(!await r.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:s,height:A}=t||this.copyCanvas(null,null,!0).imageData,a=await r.guess({name:"altText",request:{data:n,width:s,height:A,channels:n.length/(s*A)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var t;c(this,mn)&&(F(this,qr,null),this._uiManager.imageManager.deleteId(c(this,mn)),(t=c(this,Th))==null||t.remove(),F(this,Th,null),c(this,zo)&&(clearTimeout(c(this,zo)),F(this,zo,null))),super.remove()}rebuild(){if(!this.parent){c(this,mn)&&_(this,_r,hv).call(this);return}super.rebuild(),this.div!==null&&(c(this,mn)&&c(this,Th)===null&&_(this,_r,hv).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(c(this,du)||c(this,qr)||c(this,Mh)||c(this,xu)||c(this,mn)||c(this,Ff))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),c(this,Ff)||(c(this,qr)?_(this,_r,fy).call(this):_(this,_r,hv).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:r,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),r&&this._uiManager.imageManager.isValidId(r)&&(F(this,mn,r),n&&F(this,qr,n),F(this,Ff,!1),_(this,_r,fy).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(c(this,zo)!==null&&clearTimeout(c(this,zo)),F(this,zo,setTimeout(()=>{F(this,zo,null),_(this,_r,L4).call(this)},200)))}copyCanvas(t,e,r=!1){t||(t=224);const{width:n,height:s}=c(this,qr),A=new pa;let a=c(this,qr),o=n,l=s,h=null;if(e){if(n>e||s>e){const I=Math.min(e/n,e/s);o=Math.floor(n*I),l=Math.floor(s*I)}h=document.createElement("canvas");const f=h.width=Math.ceil(o*A.sx),d=h.height=Math.ceil(l*A.sy);c(this,IA)||(a=_(this,_r,py).call(this,f,d));const g=h.getContext("2d");g.filter=this._uiManager.hcmFilter;let m="white",y="#cfcfd8";this._uiManager.hcmFilter!=="none"?y="black":Z9.isDarkMode&&(m="#8f8f9d",y="#42414d");const w=15,b=w*A.sx,C=w*A.sy,S=new OffscreenCanvas(b*2,C*2),k=S.getContext("2d");k.fillStyle=m,k.fillRect(0,0,b*2,C*2),k.fillStyle=y,k.fillRect(0,0,b,C),k.fillRect(b,C,b,C),g.fillStyle=g.createPattern(S,"repeat"),g.fillRect(0,0,f,d),g.drawImage(a,0,0,a.width,a.height,0,0,f,d)}let u=null;if(r){let f,d;if(A.symmetric&&a.width<t&&a.height<t)f=a.width,d=a.height;else if(a=c(this,qr),n>t||s>t){const m=Math.min(t/n,t/s);f=Math.floor(n*m),d=Math.floor(s*m),c(this,IA)||(a=_(this,_r,py).call(this,f,d))}const g=new OffscreenCanvas(f,d).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,f,d),u={width:f,height:d,data:g.getImageData(0,0,f,d).data}}return{canvas:h,width:o,height:l,imageData:u}}static async deserialize(t,e,r){var n;let s=null,A=!1;if(t instanceof ZP){const{data:{rect:y,rotation:w,id:b,structParent:C,popupRef:S,richText:k,contentsObj:I,creationDate:N,modificationDate:D},container:Q,parent:{page:{pageNumber:K}},canvas:L}=t;let O,W;L?(delete t.canvas,{id:O,bitmap:W}=r.imageManager.getFromCanvas(Q.id,L),L.remove()):(A=!0,t._hasNoCanvas=!0);const R=((n=await e._structTree.getAriaAttributes(`${sp}${b}`))==null?void 0:n.get("aria-label"))||"";s=t={annotationType:Se.STAMP,bitmapId:O,bitmap:W,pageIndex:K-1,rect:y.slice(0),rotation:w,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:C,popupRef:S,richText:k,comment:(I==null?void 0:I.str)||null,creationDate:N,modificationDate:D}}const a=await super.deserialize(t,e,r),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:u,isSvg:f,accessibilityData:d}=t;A?(r.addMissingCanvas(t.id,a),F(a,Ff,!0)):u&&r.imageManager.isValidId(u)?(F(a,mn,u),l&&F(a,qr,l)):F(a,Mh,h),F(a,IA,f);const[g,m]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/m,d&&(a.altTextData=d),a._initialData=s,t.comment&&a.setCommentData(t),F(a,x0,!!s),a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const r=Object.assign(super.serialize(t),{bitmapId:c(this,mn),isSvg:c(this,IA)});if(this.addComment(r),t)return r.bitmapUrl=_(this,_r,cv).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r.isCopy=!0,r;const{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s&&(r.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const a=_(this,_r,P6).call(this,r);return a.isSame?null:(a.isSameAltText?delete r.accessibilityData:r.accessibilityData.structParent=this._initialData.structParent??-1,r.id=this.annotationElementId,delete r.bitmapId,r)}if(e===null)return r;e.stamps||(e.stamps=new Map);const A=c(this,IA)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(!e.stamps.has(c(this,mn)))e.stamps.set(c(this,mn),{area:A,serialized:r}),r.bitmap=_(this,_r,cv).call(this,!1);else if(c(this,IA)){const a=e.stamps.get(c(this,mn));A>a.area&&(a.area=A,a.serialized.bitmap.close(),a.serialized.bitmap=_(this,_r,cv).call(this,!1))}return r}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}qr=new WeakMap,mn=new WeakMap,du=new WeakMap,Mh=new WeakMap,xu=new WeakMap,Um=new WeakMap,Th=new WeakMap,Ff=new WeakMap,zo=new WeakMap,IA=new WeakMap,x0=new WeakMap,_r=new WeakSet,Ag=function(i,t=!1){if(!i){this.remove();return}F(this,qr,i.bitmap),t||(F(this,mn,i.id),F(this,IA,i.isSvg)),i.file&&F(this,Um,i.file.name),_(this,_r,fy).call(this)},ag=function(){if(F(this,du,null),this._uiManager.enableWaiting(!1),!!c(this,Th)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,qr)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,qr)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},hv=function(){if(c(this,mn)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,mn)).then(e=>_(this,_r,Ag).call(this,e,!0)).finally(()=>_(this,_r,ag).call(this));return}if(c(this,Mh)){const e=c(this,Mh);F(this,Mh,null),this._uiManager.enableWaiting(!0),F(this,du,this._uiManager.imageManager.getFromUrl(e).then(r=>_(this,_r,Ag).call(this,r)).finally(()=>_(this,_r,ag).call(this)));return}if(c(this,xu)){const e=c(this,xu);F(this,xu,null),this._uiManager.enableWaiting(!0),F(this,du,this._uiManager.imageManager.getFromFile(e).then(r=>_(this,_r,Ag).call(this,r)).finally(()=>_(this,_r,ag).call(this)));return}const i=document.createElement("input");i.type="file",i.accept=jy.join(",");const t=this._uiManager._signal;F(this,du,new Promise(e=>{i.addEventListener("change",async()=>{if(!i.files||i.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(i.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),_(this,_r,Ag).call(this,r)}e()},{signal:t}),i.addEventListener("cancel",()=>{this.remove(),e()},{signal:t})}).finally(()=>_(this,_r,ag).call(this))),i.click()},fy=function(){var i;const{div:t}=this;let{width:e,height:r}=c(this,qr);const[n,s]=this.pageDimensions,A=.75;if(this.width)e=this.width*n,r=this.height*s;else if(e>A*n||r>A*s){const o=Math.min(A*n/e,A*s/r);e*=o,r*=o}this._uiManager.enableWaiting(!1);const a=F(this,Th,document.createElement("canvas"));a.setAttribute("role","img"),this.addContainer(a),this.width=e/n,this.height=r/s,this.setDims(),(i=this._initialOptions)!=null&&i.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),_(this,_r,L4).call(this),c(this,x0)||(this.parent.addUndoableEditor(this),F(this,x0,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,Um)&&this.div.setAttribute("aria-description",c(this,Um)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},py=function(i,t){const{width:e,height:r}=c(this,qr);let n=e,s=r,A=c(this,qr);for(;n>2*i||s>2*t;){const a=n,o=s;n>2*i&&(n=Math.ceil(n/2)),s>2*t&&(s=Math.ceil(s/2));const l=new OffscreenCanvas(n,s);l.getContext("2d").drawImage(A,0,0,a,o,0,0,n,s),A=l.transferToImageBitmap()}return A},L4=function(){const[i,t]=this.parentDimensions,{width:e,height:r}=this,n=new pa,s=Math.ceil(e*i*n.sx),A=Math.ceil(r*t*n.sy),a=c(this,Th);if(!a||a.width===s&&a.height===A)return;a.width=s,a.height=A;const o=c(this,IA)?c(this,qr):_(this,_r,py).call(this,s,A),l=a.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(o,0,0,o.width,o.height,0,0,s,A)},cv=function(i){if(i){if(c(this,IA)){const e=this._uiManager.imageManager.getSvgUrl(c(this,mn));if(e)return e}const t=document.createElement("canvas");return{width:t.width,height:t.height}=c(this,qr),t.getContext("2d").drawImage(c(this,qr),0,0),t.toDataURL()}if(c(this,IA)){const[t,e]=this.pageDimensions,r=Math.round(this.width*t*Pu.PDF_TO_CSS_UNITS),n=Math.round(this.height*e*Pu.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(r,n);return s.getContext("2d").drawImage(c(this,qr),0,0,c(this,qr).width,c(this,qr).height,0,0,r,n),s.transferToImageBitmap()}return structuredClone(c(this,qr))},P6=function(i){var t;const{pageIndex:e,accessibilityData:{altText:r}}=this._initialData,n=i.pageIndex===e,s=(((t=i.accessibilityData)==null?void 0:t.alt)||"")===r;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}},ut(_4,"_type","stamp"),ut(_4,"_editorType",Se.STAMP);var Sf,Im,Zc,Jc,nh,eA,tu,Qm,Lm,Ha,sh,vn,Ah,eu,_m,oe,Fu,pi,M4,D6,Ka,T4,N4,uv;const dv=class ru{constructor({uiManager:t,pageIndex:e,div:r,structTreeLayer:n,accessibilityManager:s,annotationLayer:A,drawLayer:a,textLayer:o,viewport:l,l10n:h}){U(this,pi),U(this,Sf),U(this,Im,!1),U(this,Zc,null),U(this,Jc,null),U(this,nh,null),U(this,eA,new Map),U(this,tu,!1),U(this,Qm,!1),U(this,Lm,!1),U(this,Ha,null),U(this,sh,null),U(this,vn,null),U(this,Ah,null),U(this,eu,null),U(this,_m,-1),U(this,oe);const u=[...c(ru,Fu).values()];if(!ru._initialized){ru._initialized=!0;for(const f of u)f.initialize(h,t)}t.registerEditorTypes(u),F(this,oe,t),this.pageIndex=e,this.div=r,F(this,Sf,s),F(this,Zc,A),this.viewport=l,F(this,vn,o),this.drawLayer=a,this._structTree=n,c(this,oe).addLayer(this)}get isEmpty(){return c(this,eA).size===0}get isInvisible(){return this.isEmpty&&c(this,oe).getMode()===Se.NONE}updateToolbar(t){c(this,oe).updateToolbar(t)}updateMode(t=c(this,oe).getMode()){switch(_(this,pi,uv).call(this),t){case Se.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Se.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Se.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===Se.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const r of c(ru,Fu).values())e.toggle(`${r._type}Editing`,t===r._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=c(this,vn))==null?void 0:e.div)}setEditingState(t){c(this,oe).setEditingState(t)}addCommands(t){c(this,oe).addCommands(t)}cleanUndoStack(t){c(this,oe).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=c(this,Zc))==null||e.togglePointerEvents(t)}async enable(){var t;F(this,Lm,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(t=c(this,eu))==null||t.abort(),F(this,eu,null);const e=new Set;for(const n of c(this,pi,M4))n.enableEditing(),n.show(!0),n.annotationElementId&&(c(this,oe).removeChangedExistingAnnotation(n),e.add(n.annotationElementId));const r=c(this,Zc);if(r)for(const n of r.getEditableAnnotations()){if(n.hide(),c(this,oe).isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;const s=await this.deserialize(n);s&&(this.addOrRebuild(s),s.enableEditing())}F(this,Lm,!1),c(this,oe)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var t;if(F(this,Qm,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),c(this,vn)&&!c(this,eu)){F(this,eu,new AbortController);const s=c(this,oe).combinedSignal(c(this,eu));c(this,vn).div.addEventListener("pointerdown",A=>{const{clientX:a,clientY:o,timeStamp:l}=A,h=c(this,_m);if(l-h>500){F(this,_m,l);return}F(this,_m,-1);const{classList:u}=this.div;u.toggle("getElements",!0);const f=document.elementsFromPoint(a,o);if(u.toggle("getElements",!1),!this.div.contains(f[0]))return;let d;const g=new RegExp(`^${_0}[0-9]+$`);for(const y of f)if(g.test(y.id)){d=y.id;break}if(!d)return;const m=c(this,eA).get(d);(m==null?void 0:m.annotationElementId)===null&&(Hr(A),m.dblclick(A))},{signal:s,capture:!0})}const e=c(this,Zc),r=[];if(e){const s=new Map,A=new Map;for(const a of c(this,pi,M4)){if(a.disableEditing(),!a.annotationElementId){r.push(a);continue}if(a.serialize()!==null){s.set(a.annotationElementId,a);continue}else A.set(a.annotationElementId,a);(t=this.getEditableAnnotation(a.annotationElementId))==null||t.show(),a.remove()}for(const a of e.getEditableAnnotations()){const{id:o}=a.data;if(c(this,oe).isDeletedAnnotationElement(o)){a.updateEdited({deleted:!0});continue}let l=A.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=s.get(o),l&&(c(this,oe).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}_(this,pi,uv).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const s of c(ru,Fu).values())n.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e==null||e.updateFakeAnnotations(r),F(this,Qm,!1)}getEditableAnnotation(t){var e;return((e=c(this,Zc))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){c(this,oe).getActive()!==t&&c(this,oe).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=c(this,vn))!=null&&t.div&&!c(this,Ah)){F(this,Ah,new AbortController);const e=c(this,oe).combinedSignal(c(this,Ah));c(this,vn).div.addEventListener("pointerdown",_(this,pi,D6).bind(this),{signal:e}),c(this,vn).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=c(this,vn))!=null&&t.div&&c(this,Ah)&&(c(this,Ah).abort(),F(this,Ah,null),c(this,vn).div.classList.remove("highlighting"))}enableClick(){if(c(this,Jc))return;F(this,Jc,new AbortController);const t=c(this,oe).combinedSignal(c(this,Jc));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=c(this,Jc))==null||t.abort(),F(this,Jc,null)}attach(t){c(this,eA).set(t.id,t);const{annotationElementId:e}=t;e&&c(this,oe).isDeletedAnnotationElement(e)&&c(this,oe).removeDeletedAnnotationElement(t)}detach(t){var e;c(this,eA).delete(t.id),(e=c(this,Sf))==null||e.removePointerInTextLayer(t.contentDiv),!c(this,Qm)&&t.annotationElementId&&c(this,oe).addDeletedAnnotationElement(t)}remove(t){this.detach(t),c(this,oe).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(c(this,oe).addDeletedAnnotationElement(t),Vr.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),c(this,oe).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!c(this,Lm)),c(this,oe).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:r}=document;t.div.contains(r)&&!c(this,nh)&&(t._focusEventsAllowed=!1,F(this,nh,setTimeout(()=>{F(this,nh,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:c(this,oe)._signal}),r.focus())},0))),t._structTreeParentId=(e=c(this,Sf))==null?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),r=()=>{t.remove()};this.addCommands({cmd:e,undo:r,mustExec:!1})}getEditorByUID(t){for(const e of c(this,eA).values())if(e.uid===t)return e;return null}combinedSignal(t){return c(this,oe).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=c(this,pi,Ka))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await c(this,oe).updateMode(t.mode);const{offsetX:r,offsetY:n}=_(this,pi,N4).call(this),s=c(this,oe).getId(),A=_(this,pi,T4).call(this,{parent:this,id:s,x:r,y:n,uiManager:c(this,oe),isCentered:!0,...e});A&&this.add(A)}async deserialize(t){var e;return await((e=c(ru,Fu).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,c(this,oe)))||null}createAndAddNewEditor(t,e,r={}){const n=c(this,oe).getId(),s=_(this,pi,T4).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:c(this,oe),isCentered:e,...r});return s&&this.add(s),s}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(_(this,pi,N4).call(this),!0,t)}setSelected(t){c(this,oe).setSelected(t)}toggleSelected(t){c(this,oe).toggleSelected(t)}unselect(t){c(this,oe).unselect(t)}pointerup(t){var e;const{isMac:r}=Fi.platform;if(t.button!==0||t.ctrlKey&&r||t.target!==this.div||!c(this,tu)||(F(this,tu,!1),(e=c(this,pi,Ka))!=null&&e.isDrawer&&c(this,pi,Ka).supportMultipleDrawings))return;if(!c(this,Im)){F(this,Im,!0);return}const n=c(this,oe).getMode();if(n===Se.STAMP||n===Se.POPUP||n===Se.SIGNATURE){c(this,oe).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var e;if(c(this,oe).getMode()===Se.HIGHLIGHT&&this.enableTextSelection(),c(this,tu)){F(this,tu,!1);return}const{isMac:r}=Fi.platform;if(t.button!==0||t.ctrlKey&&r||t.target!==this.div)return;if(F(this,tu,!0),(e=c(this,pi,Ka))!=null&&e.isDrawer){this.startDrawingSession(t);return}const n=c(this,oe).getActive();F(this,Im,!n||n.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),c(this,Ha)){c(this,pi,Ka).startDrawing(this,c(this,oe),!1,t);return}c(this,oe).setCurrentDrawingSession(this),F(this,Ha,new AbortController);const e=c(this,oe).combinedSignal(c(this,Ha));this.div.addEventListener("blur",({relatedTarget:r})=>{r&&!this.div.contains(r)&&(F(this,sh,null),this.commitOrRemove())},{signal:e}),c(this,pi,Ka).startDrawing(this,c(this,oe),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&F(this,sh,e);return}c(this,sh)&&setTimeout(()=>{var e;(e=c(this,sh))==null||e.focus(),F(this,sh,null)},0)}endDrawingSession(t=!1){return c(this,Ha)?(c(this,oe).setCurrentDrawingSession(null),c(this,Ha).abort(),F(this,Ha,null),F(this,sh,null),c(this,pi,Ka).endDrawing(t)):null}findNewParent(t,e,r){const n=c(this,oe).findParent(e,r);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return c(this,Ha)?(this.endDrawingSession(),!0):!1}onScaleChanging(){c(this,Ha)&&c(this,pi,Ka).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=c(this,oe).getActive())==null?void 0:t.parent)===this&&(c(this,oe).commitOrRemove(),c(this,oe).setActiveEditor(null)),c(this,nh)&&(clearTimeout(c(this,nh)),F(this,nh,null));for(const r of c(this,eA).values())(e=c(this,Sf))==null||e.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,c(this,eA).clear(),c(this,oe).removeLayer(this)}async render({viewport:t}){this.viewport=t,Wh(this.div,t);for(const e of c(this,oe).getEditors(this.pageIndex))this.add(e),e.rebuild();await c(this,oe).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){c(this,oe).commitOrRemove(),_(this,pi,uv).call(this);const e=this.viewport.rotation,r=t.rotation;if(this.viewport=t,Wh(this.div,{rotation:r}),e!==r)for(const n of c(this,eA).values())n.rotate(r)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return c(this,oe).viewParameters.realScale}};Sf=new WeakMap,Im=new WeakMap,Zc=new WeakMap,Jc=new WeakMap,nh=new WeakMap,eA=new WeakMap,tu=new WeakMap,Qm=new WeakMap,Lm=new WeakMap,Ha=new WeakMap,sh=new WeakMap,vn=new WeakMap,Ah=new WeakMap,eu=new WeakMap,_m=new WeakMap,oe=new WeakMap,Fu=new WeakMap,pi=new WeakSet,M4=function(){return c(this,eA).size!==0?c(this,eA).values():c(this,oe).getEditors(this.pageIndex)},D6=function(i){c(this,oe).unselectAll();const{target:t}=i;if(t===c(this,vn).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent")||t.classList.contains("textLayerImagePlaceholder"))&&c(this,vn).div.contains(t)){const{isMac:e}=Fi.platform;if(i.button!==0||i.ctrlKey&&e)return;c(this,oe).showAllEditors("highlight",!0,!0),c(this,vn).div.classList.add("free"),this.toggleDrawing(),OU.startHighlighting(this,c(this,oe).direction==="ltr",{target:c(this,vn).div,x:i.x,y:i.y}),c(this,vn).div.addEventListener("pointerup",()=>{c(this,vn).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,oe)._signal}),i.preventDefault()}},Ka=function(){return c(dv,Fu).get(c(this,oe).getMode())},T4=function(i){const t=c(this,pi,Ka);return t?new t.prototype.constructor(i):null},N4=function(){const{x:i,y:t,width:e,height:r}=this.boundingClientRect,n=Math.max(0,i),s=Math.max(0,t),A=Math.min(window.innerWidth,i+e),a=Math.min(window.innerHeight,t+r),o=(n+A)/2-i,l=(s+a)/2-t,[h,u]=this.viewport.rotation%180===0?[o,l]:[l,o];return{offsetX:h,offsetY:u}},uv=function(){for(const i of c(this,eA).values())i.isEmpty()&&i.remove()},ut(dv,"_initialized",!1),U(dv,Fu,new Map([VW,GW,_4,OU,zW].map(i=>[i._editorType,i])));let O6=dv;var Ga,Ss,Ef,gy,P4,R6,iu,D4,H6,O4;const kf=class Xs{constructor(){U(this,iu),U(this,Ga,null),U(this,Ss,new Map),U(this,Ef,new Map)}setParent(t){if(!c(this,Ga)){F(this,Ga,t);return}if(c(this,Ga)!==t){if(c(this,Ss).size>0)for(const e of c(this,Ss).values())e.remove(),t.append(e);F(this,Ga,t)}}static get _svgFactory(){return ke(this,"_svgFactory",new D0)}draw(t,e=!1,r=!1){const n=$i(Xs,gy)._++,s=_(this,iu,D4).call(this),A=Xs._svgFactory.createElement("defs");s.append(A);const a=Xs._svgFactory.createElement("path");A.append(a);const o=`path_${n}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&c(this,Ef).set(n,a);const l=r?_(this,iu,H6).call(this,A,o):null,h=Xs._svgFactory.createElement("use");return s.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(s,t),c(this,Ss).set(n,s),{id:n,clipPathId:`url(#${l})`}}drawOutline(t,e){const r=$i(Xs,gy)._++,n=_(this,iu,D4).call(this),s=Xs._svgFactory.createElement("defs");n.append(s);const A=Xs._svgFactory.createElement("path");s.append(A);const a=`path_${r}`;A.setAttribute("id",a),A.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const u=Xs._svgFactory.createElement("mask");s.append(u),o=`mask_${r}`,u.setAttribute("id",o),u.setAttribute("maskUnits","objectBoundingBox");const f=Xs._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const d=Xs._svgFactory.createElement("use");u.append(d),d.setAttribute("href",`#${a}`),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}const l=Xs._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return n.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(n,t),c(this,Ss).set(r,n),r}finalizeDraw(t,e){c(this,Ef).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var r;if(!e)return;const{root:n,bbox:s,rootClass:A,path:a}=e,o=typeof t=="number"?c(this,Ss).get(t):t;if(o){if(n&&_(this,iu,O4).call(this,o,n),s&&_(r=Xs,P4,R6).call(r,o,s),A){const{classList:l}=o;for(const[h,u]of Object.entries(A))l.toggle(h,u)}if(a){const l=o.firstElementChild.firstElementChild;_(this,iu,O4).call(this,l,a)}}}updateParent(t,e){if(e===this)return;const r=c(this,Ss).get(t);r&&(c(e,Ga).append(r),c(this,Ss).delete(t),c(e,Ss).set(t,r))}remove(t){c(this,Ef).delete(t),c(this,Ga)!==null&&(c(this,Ss).get(t).remove(),c(this,Ss).delete(t))}destroy(){F(this,Ga,null);for(const t of c(this,Ss).values())t.remove();c(this,Ss).clear(),c(this,Ef).clear()}};Ga=new WeakMap,Ss=new WeakMap,Ef=new WeakMap,gy=new WeakMap,P4=new WeakSet,R6=function(i,[t,e,r,n]){const{style:s}=i;s.top=`${100*e}%`,s.left=`${100*t}%`,s.width=`${100*r}%`,s.height=`${100*n}%`},iu=new WeakSet,D4=function(){const i=kf._svgFactory.create(1,1,!0);return c(this,Ga).append(i),i.setAttribute("aria-hidden",!0),i},H6=function(i,t){const e=kf._svgFactory.createElement("clipPath");i.append(e);const r=`clip_${t}`;e.setAttribute("id",r),e.setAttribute("clipPathUnits","objectBoundingBox");const n=kf._svgFactory.createElement("use");return e.append(n),n.setAttribute("href",`#${t}`),n.classList.add("clip"),r},O4=function(i,t){for(const[e,r]of Object.entries(t))r===null?i.removeAttribute(e):i.setAttribute(e,r)},U(kf,P4),U(kf,gy,0);let V6=kf;function ow(i){return`${(i*100).toFixed(2)}%`}var Mm,my,fv,F0,al,ol,wy,R4,W6;const j6=class H4{constructor(t,e,r,n){U(this,R4),U(this,Mm,[]),U(this,my,new Map),U(this,fv,null),U(this,F0,0),U(this,al,0),U(this,ol,0),F(this,F0,t),F(this,Mm,e),F(this,al,r.rawDims.pageWidth),F(this,ol,r.rawDims.pageHeight),F(this,fv,n)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<c(this,Mm).length;e+=6){const r=_(this,R4,W6).call(this,c(this,Mm).subarray(e,e+6));r&&t.append(r)}return t.addEventListener("contextmenu",e=>{var r;if(!(e.target instanceof HTMLCanvasElement))return;const n=e.target,s=c(this,my).get(n);if(!s)return;const A=(r=c(H4,wy))==null?void 0:r.deref();if(A===n)return;A&&(A.width=0,A.height=0),F(H4,wy,new WeakRef(n));const{inverseTransform:a,x1:o,y1:l,width:h,height:u}=s,f=c(this,fv).call(this),d=Math.ceil(o*f.width),g=Math.ceil(l*f.height),m=Math.floor((o+h/c(this,al))*f.width),y=Math.floor((l+u/c(this,ol))*f.height);n.width=m-d,n.height=y-g;const w=n.getContext("2d");w.setTransform(...a),w.translate(-d,-g),w.drawImage(f,0,0)}),t}};Mm=new WeakMap,my=new WeakMap,fv=new WeakMap,F0=new WeakMap,al=new WeakMap,ol=new WeakMap,wy=new WeakMap,R4=new WeakSet,W6=function([i,t,e,r,n,s]){const A=Math.hypot((n-i)*c(this,al),(s-t)*c(this,ol)),a=Math.hypot((e-i)*c(this,al),(r-t)*c(this,ol));if(A<c(this,F0)||a<c(this,F0))return null;const o=[(n-i)*c(this,al)/A,(s-t)*c(this,ol)/A,(e-i)*c(this,al)/a,(r-t)*c(this,ol)/a,0,0],l=Nt.inverseTransform(o),h=document.createElement("canvas");return h.className="textLayerImagePlaceholder",h.width=0,h.height=0,Object.assign(h.style,{opacity:0,position:"absolute",left:ow(i),top:ow(t),width:ow(A/c(this,al)),height:ow(a/c(this,ol)),transformOrigin:"0% 0%",transform:`matrix(${o.join(",")})`}),c(this,my).set(h,{inverseTransform:l,width:A,height:a,x1:i,y1:t}),h},U(j6,wy,null);let K6=j6;globalThis._pdfjsTestingUtils={HighlightOutliner:b4};globalThis.pdfjsLib={AbortException:ml,AnnotationEditorLayer:O6,AnnotationEditorParamsType:_e,AnnotationEditorType:Se,AnnotationEditorUIManager:Cp,AnnotationLayer:t6,AnnotationMode:ll,AnnotationType:gi,applyOpacity:wN,build:RP,ColorPicker:zS,createValidAbsoluteUrl:PS,CSSConstants:mN,DOMSVGFactory:D0,DrawLayer:V6,FeatureTest:Fi,fetchData:Ry,findContrastColor:vN,getDocument:KS,getFilenameFromUrl:fN,getPdfFilenameFromUrl:pN,getRGB:Sp,getRGBA:Wy,getUuid:OS,getXfaPageViewport:gN,GlobalWorkerOptions:so,ImageKind:Km,InvalidPDFException:Fv,isDataScheme:Y0,isPdfFile:Vy,isValidExplicitDest:rP,makeArr:Dy,makeMap:Oy,makeObj:Sv,MathClamp:Mr,noContextMenu:AA,normalizeUnicode:dN,OPS:Ja,OutputScale:pa,PasswordResponses:uN,PDFDataRangeTransport:GS,PDFDateString:N0,PDFWorker:Yv,PermissionFlag:cN,PixelsPerInch:Pu,RenderingCancelledException:Hy,renderRichText:HS,ResponseException:M0,setLayerDimensions:Wh,shadow:ke,SignatureExtractor:io,stopEvent:Hr,SupportedImageMimeTypes:jy,TextLayer:qv,TextLayerImages:K6,TouchManager:VS,updateUrlHash:DS,Util:Nt,VerbosityLevel:q0,version:OP,XfaLayer:RS};const qW=Object.freeze(Object.defineProperty({__proto__:null,AbortException:ml,AnnotationEditorLayer:O6,AnnotationEditorParamsType:_e,AnnotationEditorType:Se,AnnotationEditorUIManager:Cp,AnnotationLayer:t6,AnnotationMode:ll,AnnotationType:gi,CSSConstants:mN,ColorPicker:zS,DOMSVGFactory:D0,DrawLayer:V6,FeatureTest:Fi,GlobalWorkerOptions:so,ImageKind:Km,InvalidPDFException:Fv,MathClamp:Mr,OPS:Ja,OutputScale:pa,PDFDataRangeTransport:GS,PDFDateString:N0,PDFWorker:Yv,PasswordResponses:uN,PermissionFlag:cN,PixelsPerInch:Pu,RenderingCancelledException:Hy,ResponseException:M0,SignatureExtractor:io,SupportedImageMimeTypes:jy,TextLayer:qv,TextLayerImages:K6,TouchManager:VS,Util:Nt,VerbosityLevel:q0,XfaLayer:RS,applyOpacity:wN,build:RP,createValidAbsoluteUrl:PS,fetchData:Ry,findContrastColor:vN,getDocument:KS,getFilenameFromUrl:fN,getPdfFilenameFromUrl:pN,getRGB:Sp,getRGBA:Wy,getUuid:OS,getXfaPageViewport:gN,isDataScheme:Y0,isPdfFile:Vy,isValidExplicitDest:rP,makeArr:Dy,makeMap:Oy,makeObj:Sv,noContextMenu:AA,normalizeUnicode:dN,renderRichText:HS,setLayerDimensions:Wh,shadow:ke,stopEvent:Hr,updateUrlHash:DS,version:OP},Symbol.toStringTag,{value:"Module"}));so.workerSrc="";const WU=25.4/72,JB=8;class XW{importFromFilePicker(t){const e=document.createElement("input");e.type="file",e.accept=".pdf",e.style.display="none",document.body.appendChild(e),e.addEventListener("change",async()=>{var r;const n=(r=e.files)==null?void 0:r[0];if(document.body.removeChild(e),!n)return;const s=await n.arrayBuffer();await this.convert(t,s)}),e.click()}async convert(t,e,r=1){try{const n=await(await KS({data:e}).promise).getPage(r),s=n.getViewport({scale:1}).height,A=await n.getOperatorList(),a=this.extractEntities(A,s);if(a.length===0){AB.warn("[PdfImport] No vector paths found in PDF page.");return}const o=t.doc.database.tables.blockTable.modelSpace;for(const l of a)o.appendEntity(l);AB.info(`[PdfImport] Imported ${a.length} entities from PDF.`)}catch(n){AB.error("[PdfImport] Failed to import PDF:",n)}}extractEntities(t,e){const{OPS:r}=qW,{fnArray:n,argsArray:s}=t,A=[];let a=[],o=[],l=0,h=0;const u=()=>{o.length>1&&a.push(o),o=[]},f=()=>{u();for(const m of a){const y=this.subpathToEntity(m);y&&A.push(y)}a=[]},d=(m,y)=>m*WU,g=(m,y)=>(e-y)*WU;for(let m=0;m<n.length;m++){const y=n[m],w=s[m];switch(y){case r.moveTo:{u(),l=w[0],h=w[1],o=[{x:d(l),y:g(l,h)}];break}case r.lineTo:{l=w[0],h=w[1],o.push({x:d(l),y:g(l,h)});break}case r.curveTo:{const[b,C,S,k,I,N]=w,D=t5({x:l,y:h},{x:b,y:C},{x:S,y:k},{x:I,y:N},JB);for(const Q of D)o.push({x:d(Q.x,Q.y),y:g(Q.x,Q.y)});l=I,h=N;break}case r.curveTo2:{const[b,C,S,k]=w,I=t5({x:l,y:h},{x:l,y:h},{x:b,y:C},{x:S,y:k},JB);for(const N of I)o.push({x:d(N.x,N.y),y:g(N.x,N.y)});l=S,h=k;break}case r.curveTo3:{const[b,C,S,k]=w,I=t5({x:l,y:h},{x:b,y:C},{x:S,y:k},{x:S,y:k},JB);for(const N of I)o.push({x:d(N.x,N.y),y:g(N.x,N.y)});l=S,h=k;break}case r.closePath:{o.length>0&&a.length===0&&o.push({...o[0]}),u();break}case r.stroke:case r.fill:case r.eoFill:case r.fillStroke:case r.eoFillStroke:case r.endPath:{f();break}}}return f(),A}subpathToEntity(t){if(t.length<2)return null;if(t.length===2)return new aR(new p3(t[0].x,t[0].y,0),new p3(t[1].x,t[1].y,0));const e=new oR;for(let a=0;a<t.length;a++)e.addVertexAt(a,new lR(t[a].x,t[a].y));const r=t[0],n=t[t.length-1],s=r.x-n.x,A=r.y-n.y;return Math.sqrt(s*s+A*A)<1e-6&&(e.closed=!0),e}}function t5(i,t,e,r,n){const s=[];for(let A=1;A<=n;A++){const a=A/n,o=1-a,l=o*o*o*i.x+3*o*o*a*t.x+3*o*a*a*e.x+a*a*a*r.x,h=o*o*o*i.y+3*o*o*a*t.y+3*o*a*a*e.y+a*a*a*r.y;s.push({x:l,y:h})}return s}class YW extends ZM{async execute(t){new XW().importFromFilePicker(t)}}const $W="1.6.2",ZW={version:$W};class JW{constructor(){this.name="PdfPlugin",this.version=ZW.version,this.description="PDF export (cpdf) and import (ipdf) commands",this.registeredCommands=[]}onLoad(t,e){const r=nR.SYSTEMT_COMMAND_GROUP_NAME;e.addCommand(r,"cpdf","cpdf",new H9),e.addCommand(r,"ipdf","ipdf",new YW),this.registeredCommands.push({group:r,name:"cpdf"},{group:r,name:"ipdf"})}onUnload(t,e){for(const r of this.registeredCommands)e.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function wZ(){return new JW}/*!
|
|
273
273
|
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
274
274
|
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
|
275
275
|
* Released under MIT License
|