polotno-node 2.15.14 → 2.15.15
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./html2canvas--2MclApJ.js","./chunk-DseTPa7n.js","./index.es-CmkIkXI3.js","./typeof-GPCnPm50.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{t}from"./index-
|
|
2
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{t}from"./index-B1NWkbV5.js";import{t as n}from"./typeof-GPCnPm50.js";var r=Uint8Array,i=Uint16Array,a=Int32Array,o=new r([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]),s=new r([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]),c=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=function(e,t){for(var n=new i(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new a(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return{b:n,r:o}},u=l(o,2),d=u.b,f=u.r;d[28]=258,f[258]=28;var p=l(s,0);p.b;for(var m=p.r,h=new i(32768),g=0;g<32768;++g){var _=(g&43690)>>1|(g&21845)<<1;_=(_&52428)>>2|(_&13107)<<2,_=(_&61680)>>4|(_&3855)<<4,h[g]=((_&65280)>>8|(_&255)<<8)>>1}for(var v=(function(e,t,n){for(var r=e.length,a=0,o=new i(t);a<r;++a)e[a]&&++o[e[a]-1];var s=new i(t);for(a=1;a<t;++a)s[a]=s[a-1]+o[a-1]<<1;var c;if(n){c=new i(1<<t);var l=15-t;for(a=0;a<r;++a)if(e[a])for(var u=a<<4|e[a],d=t-e[a],f=s[e[a]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)c[h[f]>>l]=u}else for(c=new i(r),a=0;a<r;++a)e[a]&&(c[a]=h[s[e[a]-1]++]>>15-e[a]);return c}),y=new r(288),g=0;g<144;++g)y[g]=8;for(var g=144;g<256;++g)y[g]=9;for(var g=256;g<280;++g)y[g]=7;for(var g=280;g<288;++g)y[g]=8;for(var b=new r(32),g=0;g<32;++g)b[g]=5;var x=v(y,9,0);v(y,9,1);var S=v(b,5,0);v(b,5,1);var C=function(e){return(e+7)/8|0},w=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new r(e.subarray(t,n))},T=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},E=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},D=function(e,t){for(var n=[],a=0;a<e.length;++a)e[a]&&n.push({s:a,f:e[a]});var o=n.length,s=n.slice();if(!o)return{t:P,l:0};if(o==1){var c=new r(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],u=n[1],d=0,f=1,p=2;for(n[0]={s:-1,f:l.f+u.f,l,r:u};f!=o-1;)l=n[n[d].f<n[p].f?d++:p++],u=n[d!=f&&n[d].f<n[p].f?d++:p++],n[f++]={s:-1,f:l.f+u.f,l,r:u};for(var m=s[0].s,a=1;a<o;++a)s[a].s>m&&(m=s[a].s);var h=new i(m+1),g=O(n[f-1],h,0);if(g>t){var a=0,_=0,v=g-t,y=1<<v;for(s.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});a<o;++a){var b=s[a].s;if(h[b]>t)_+=y-(1<<g-h[b]),h[b]=t;else break}for(_>>=v;_>0;){var x=s[a].s;h[x]<t?_-=1<<t-h[x]++-1:++a}for(;a>=0&&_;--a){var S=s[a].s;h[S]==t&&(--h[S],++_)}g=t}return{t:new r(h),l:g}},O=function(e,t,n){return e.s==-1?Math.max(O(e.l,t,n+1),O(e.r,t,n+1)):t[e.s]=n},k=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new i(++t),r=0,a=e[0],o=1,s=function(e){n[r++]=e},c=1;c<=t;++c)if(e[c]==a&&c!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(a),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(a);o=1,a=e[c]}return{c:n.subarray(0,r),n:t}},A=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},j=function(e,t,n){var r=n.length,i=C(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},M=function(e,t,n,r,a,l,u,d,f,p,m){T(t,m++,n),++a[256];for(var h=D(a,15),g=h.t,_=h.l,C=D(l,15),w=C.t,O=C.l,M=k(g),N=M.c,P=M.n,F=k(w),I=F.c,L=F.n,R=new i(19),z=0;z<N.length;++z)++R[N[z]&31];for(var z=0;z<I.length;++z)++R[I[z]&31];for(var B=D(R,7),V=B.t,ee=B.l,H=19;H>4&&!V[c[H-1]];--H);var U=p+5<<3,W=A(a,y)+A(l,b)+u,te=A(a,g)+A(l,w)+u+14+3*H+A(R,V)+2*R[16]+3*R[17]+7*R[18];if(f>=0&&U<=W&&U<=te)return j(t,m,e.subarray(f,f+p));var ne,re,ie,ae;if(T(t,m,1+(te<W)),m+=2,te<W){ne=v(g,_,0),re=g,ie=v(w,O,0),ae=w;var oe=v(V,ee,0);T(t,m,P-257),T(t,m+5,L-1),T(t,m+10,H-4),m+=14;for(var z=0;z<H;++z)T(t,m+3*z,V[c[z]]);m+=3*H;for(var G=[N,I],se=0;se<2;++se)for(var ce=G[se],z=0;z<ce.length;++z){var le=ce[z]&31;T(t,m,oe[le]),m+=V[le],le>15&&(T(t,m,ce[z]>>5&127),m+=ce[z]>>12)}}else ne=x,re=y,ie=S,ae=b;for(var z=0;z<d;++z){var ue=r[z];if(ue>255){var le=ue>>18&31;E(t,m,ne[le+257]),m+=re[le+257],le>7&&(T(t,m,ue>>23&31),m+=o[le]);var de=ue&31;E(t,m,ie[de]),m+=ae[de],de>3&&(E(t,m,ue>>5&8191),m+=s[de])}else E(t,m,ne[ue]),m+=re[ue]}return E(t,m,ne[256]),m+re[256]},N=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),P=new r(0),F=function(e,t,n,c,l,u){var d=u.z||e.length,p=new r(c+d+5*(1+Math.ceil(d/7e3))+l),h=p.subarray(c,p.length-l),g=u.l,_=(u.r||0)&7;if(t){_&&(h[0]=u.r>>3);for(var v=N[t-1],y=v>>13,b=v&8191,x=(1<<n)-1,S=u.p||new i(32768),T=u.h||new i(x+1),E=Math.ceil(n/3),D=2*E,O=function(t){return(e[t]^e[t+1]<<E^e[t+2]<<D)&x},k=new a(25e3),A=new i(288),P=new i(32),F=0,I=0,L=u.i||0,R=0,z=u.w||0,B=0;L+2<d;++L){var V=O(L),ee=L&32767,H=T[V];if(S[ee]=H,T[V]=ee,z<=L){var U=d-L;if((F>7e3||R>24576)&&(U>423||!g)){_=M(e,h,0,k,A,P,I,R,B,L-B,_),R=F=I=0,B=L;for(var W=0;W<286;++W)A[W]=0;for(var W=0;W<30;++W)P[W]=0}var te=2,ne=0,re=b,ie=ee-H&32767;if(U>2&&V==O(L-ie))for(var ae=Math.min(y,U)-1,oe=Math.min(32767,L),G=Math.min(258,U);ie<=oe&&--re&&ee!=H;){if(e[L+te]==e[L+te-ie]){for(var se=0;se<G&&e[L+se]==e[L+se-ie];++se);if(se>te){if(te=se,ne=ie,se>ae)break;for(var ce=Math.min(ie,se-2),le=0,W=0;W<ce;++W){var ue=L-ie+W&32767,de=ue-S[ue]&32767;de>le&&(le=de,H=ue)}}}ee=H,H=S[ee],ie+=ee-H&32767}if(ne){k[R++]=268435456|f[te]<<18|m[ne];var fe=f[te]&31,pe=m[ne]&31;I+=o[fe]+s[pe],++A[257+fe],++P[pe],z=L+te,++F}else k[R++]=e[L],++A[e[L]]}}for(L=Math.max(L,z);L<d;++L)k[R++]=e[L],++A[e[L]];_=M(e,h,g,k,A,P,I,R,B,L-B,_),g||(u.r=_&7|h[_/8|0]<<3,_-=7,u.h=T,u.p=S,u.i=L,u.w=z)}else{for(var L=u.w||0;L<d+g;L+=65535){var me=L+65535;me>=d&&(h[_/8|0]=g,me=d),_=j(h,_+1,e.subarray(L,me))}u.i=d}return w(p,0,c+C(_)+l)},I=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},L=function(e,t,n,i,a){if(!a&&(a={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),s=new r(o.length+e.length);s.set(o),s.set(e,o.length),e=s,a.w=o.length}return F(e,t.level==null?6:t.level,t.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,a)},R=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},z=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=I();i.p(t.dictionary),R(e,2,i.d())}};function B(e,t){t||={};var n=I();n.p(e);var r=L(e,t,t.dictionary?6:2,4);return z(r,t),R(r,r.length-4,n.d()),r}var V=typeof TextDecoder<`u`&&new TextDecoder;try{V.decode(P,{stream:!0})}catch{}function ee(e){if(Array.isArray(e))return e}function H(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function U(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function W(e,t){if(e){if(typeof e==`string`)return U(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(e,t):void 0}}function te(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ne(e,t){return ee(e)||H(e,t)||W(e,t)||te()}function re(e,t=`utf8`){return new TextDecoder(t).decode(e)}var ie=new TextEncoder;function ae(e){return ie.encode(e)}var oe=1024*8,G=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),se={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},ce=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=oe,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),r?this.lastWrittenByte=a:this.lastWrittenByte=0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,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(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=se[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===G&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new se[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new se[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return re(this.readBytes(e))}decodeText(e=1,t=`utf8`){return re(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(ae(e))}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)}},le=4,ue=0,de=1,fe=2;function pe(e){let t=e.length;for(;--t>=0;)e[t]=0}var me=0,he=1,ge=2,_e=3,ve=258,ye=29,be=256,xe=be+1+ye,Se=30,Ce=19,we=2*xe+1,Te=15,Ee=16,De=7,Oe=256,ke=16,Ae=17,je=18,Me=new Uint8Array([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]),Ne=new Uint8Array([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]),K=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Pe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fe=512,Ie=Array((xe+2)*2);pe(Ie);var Le=Array(Se*2);pe(Le);var Re=Array(Fe);pe(Re);var q=Array(ve-_e+1);pe(q);var ze=Array(ye);pe(ze);var Be=Array(Se);pe(Be);function Ve(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var He,Ue,We;function Ge(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var Ke=e=>e<256?Re[e]:Re[256+(e>>>7)],qe=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Je=(e,t,n)=>{e.bi_valid>Ee-n?(e.bi_buf|=t<<e.bi_valid&65535,qe(e,e.bi_buf),e.bi_buf=t>>Ee-e.bi_valid,e.bi_valid+=n-Ee):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},Ye=(e,t,n)=>{Je(e,n[t*2],n[t*2+1])},Xe=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},Ze=e=>{e.bi_valid===16?(qe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},Qe=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=Te;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<we;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},$e=(e,t,n)=>{let r=Array(Te+1),i=0,a,o;for(a=1;a<=Te;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=Xe(r[t]++,t))}},et=()=>{let e,t,n,r,i,a=Array(Te+1);for(n=0,r=0;r<ye-1;r++)for(ze[r]=n,e=0;e<1<<Me[r];e++)q[n++]=r;for(q[n-1]=r,i=0,r=0;r<16;r++)for(Be[r]=i,e=0;e<1<<Ne[r];e++)Re[i++]=r;for(i>>=7;r<Se;r++)for(Be[r]=i<<7,e=0;e<1<<Ne[r]-7;e++)Re[256+ i++]=r;for(t=0;t<=Te;t++)a[t]=0;for(e=0;e<=143;)Ie[e*2+1]=8,e++,a[8]++;for(;e<=255;)Ie[e*2+1]=9,e++,a[9]++;for(;e<=279;)Ie[e*2+1]=7,e++,a[7]++;for(;e<=287;)Ie[e*2+1]=8,e++,a[8]++;for($e(Ie,xe+1,a),e=0;e<Se;e++)Le[e*2+1]=5,Le[e*2]=Xe(e,5);He=new Ve(Ie,Me,be+1,xe,Te),Ue=new Ve(Le,Ne,0,Se,Te),We=new Ve([],K,0,Ce,De)},tt=e=>{let t;for(t=0;t<xe;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Se;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Ce;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Oe*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},nt=e=>{e.bi_valid>8?qe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},rt=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},it=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&rt(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!rt(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},at=(e,t,n)=>{let r,i,a=0,o,s;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+ a++]&255,r+=(e.pending_buf[e.sym_buf+ a++]&255)<<8,i=e.pending_buf[e.sym_buf+ a++],r===0?Ye(e,i,t):(o=q[i],Ye(e,o+be+1,t),s=Me[o],s!==0&&(i-=ze[o],Je(e,i,s)),r--,o=Ke(r),Ye(e,o,n),s=Ne[o],s!==0&&(r-=Be[o],Je(e,r,s)));while(a<e.sym_next);Ye(e,Oe,t)},ot=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=we,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)it(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],it(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,it(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Qe(e,t),$e(n,c,e.bl_count)},st=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[Ae*2]++:e.bl_tree[je*2]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[ke*2]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},ct=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do Ye(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(Ye(e,Ae,e.bl_tree),Je(e,s-3,3)):(Ye(e,je,e.bl_tree),Je(e,s-11,7)):(a!==i&&(Ye(e,a,e.bl_tree),s--),Ye(e,ke,e.bl_tree),Je(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},lt=e=>{let t;for(st(e,e.dyn_ltree,e.l_desc.max_code),st(e,e.dyn_dtree,e.d_desc.max_code),ot(e,e.bl_desc),t=Ce-1;t>=3&&e.bl_tree[Pe[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},ut=(e,t,n,r)=>{let i;for(Je(e,t-257,5),Je(e,n-1,5),Je(e,r-4,4),i=0;i<r;i++)Je(e,e.bl_tree[Pe[i]*2+1],3);ct(e,e.dyn_ltree,t-1),ct(e,e.dyn_dtree,n-1)},dt=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return ue;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return de;for(n=32;n<be;n++)if(e.dyn_ltree[n*2]!==0)return de;return ue},ft=!1,pt=e=>{ft||=(et(),!0),e.l_desc=new Ge(e.dyn_ltree,He),e.d_desc=new Ge(e.dyn_dtree,Ue),e.bl_desc=new Ge(e.bl_tree,We),e.bi_buf=0,e.bi_valid=0,tt(e)},mt=(e,t,n,r)=>{Je(e,(me<<1)+(r?1:0),3),nt(e),qe(e,n),qe(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},ht={_tr_init:pt,_tr_stored_block:mt,_tr_flush_block:(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===fe&&(e.strm.data_type=dt(e)),ot(e,e.l_desc),ot(e,e.d_desc),o=lt(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?mt(e,t,n,r):e.strategy===le||a===i?(Je(e,(he<<1)+(r?1:0),3),at(e,Ie,Le)):(Je(e,(ge<<1)+(r?1:0),3),ut(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),at(e,e.dyn_ltree,e.dyn_dtree)),tt(e),r&&nt(e)},_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+ e.sym_next++]=t,e.pending_buf[e.sym_buf+ e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+ e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(q[n]+be+1)*2]++,e.dyn_dtree[Ke(t)*2]++),e.sym_next===e.sym_end),_tr_align:e=>{Je(e,he<<1,3),Ye(e,Oe,Ie),Ze(e)}},gt=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},_t=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),vt=(e,t,n,r)=>{let i=_t,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},yt={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`},bt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:xt,_tr_stored_block:St,_tr_flush_block:Ct,_tr_tally:wt,_tr_align:Tt}=ht,{Z_NO_FLUSH:J,Z_PARTIAL_FLUSH:Et,Z_FULL_FLUSH:Dt,Z_FINISH:Ot,Z_BLOCK:kt,Z_OK:At,Z_STREAM_END:jt,Z_STREAM_ERROR:Mt,Z_DATA_ERROR:Nt,Z_BUF_ERROR:Pt,Z_DEFAULT_COMPRESSION:Ft,Z_FILTERED:It,Z_HUFFMAN_ONLY:Lt,Z_RLE:Rt,Z_FIXED:zt,Z_DEFAULT_STRATEGY:Bt,Z_UNKNOWN:Vt,Z_DEFLATED:Ht}=bt,Ut=9,Wt=15,Gt=8,Kt=286,qt=30,Jt=19,Yt=2*Kt+1,Xt=15,Y=3,Zt=258,Qt=Zt+Y+1,$t=32,en=42,tn=57,nn=69,rn=73,an=91,on=103,sn=113,cn=666,ln=1,un=2,dn=3,fn=4,pn=3,mn=(e,t)=>(e.msg=yt[t],t),hn=e=>e*2-(e>4?9:0),gn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},_n=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)},vn=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,yn=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},bn=(e,t)=>{Ct(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,yn(e.strm)},xn=(e,t)=>{e.pending_buf[e.pending++]=t},Sn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Cn=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=gt(e.adler,t,i,n):e.state.wrap===2&&(e.adler=vt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},wn=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-Qt?e.strstart-(e.w_size-Qt):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+Zt,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=Zt-(f-r),r=f-Zt,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},Tn=e=>{let t=e.w_size,n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Qt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),_n(e),r+=t),e.strm.avail_in===0)break;if(n=Cn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=Y)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=vn(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=vn(e,e.ins_h,e.window[i+Y-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<Y)););}while(e.lookahead<Qt&&e.strm.avail_in!==0)},En=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,a,o=0,s=e.strm.avail_in;do{if(r=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&t!==Ot||t===J||r!==i+e.strm.avail_in)))break;o=t===Ot&&r===i+e.strm.avail_in?1:0,St(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,yn(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(Cn(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(o===0);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?fn:t!==J&&t!==Ot&&e.strm.avail_in===0&&e.strstart===e.block_start?un:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Cn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,n=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=n||(i||t===Ot)&&t!==J&&e.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=t===Ot&&e.strm.avail_in===0&&r===i?1:0,St(e,e.block_start,r,o),e.block_start+=r,yn(e.strm)),o?dn:ln)},Dn=(e,t)=>{let n,r;for(;;){if(e.lookahead<Qt){if(Tn(e),e.lookahead<Qt&&t===J)return ln;if(e.lookahead===0)break}if(n=0,e.lookahead>=Y&&(e.ins_h=vn(e,e.ins_h,e.window[e.strstart+Y-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Qt&&(e.match_length=wn(e,n)),e.match_length>=Y)if(r=wt(e,e.strstart-e.match_start,e.match_length-Y),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Y){e.match_length--;do e.strstart++,e.ins_h=vn(e,e.ins_h,e.window[e.strstart+Y-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=vn(e,e.ins_h,e.window[e.strstart+1]);else r=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(bn(e,!1),e.strm.avail_out===0))return ln}return e.insert=e.strstart<Y-1?e.strstart:Y-1,t===Ot?(bn(e,!0),e.strm.avail_out===0?dn:fn):e.sym_next&&(bn(e,!1),e.strm.avail_out===0)?ln:un},On=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<Qt){if(Tn(e),e.lookahead<Qt&&t===J)return ln;if(e.lookahead===0)break}if(n=0,e.lookahead>=Y&&(e.ins_h=vn(e,e.ins_h,e.window[e.strstart+Y-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Y-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-Qt&&(e.match_length=wn(e,n),e.match_length<=5&&(e.strategy===It||e.match_length===Y&&e.strstart-e.match_start>4096)&&(e.match_length=Y-1)),e.prev_length>=Y&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Y,r=wt(e,e.strstart-1-e.prev_match,e.prev_length-Y),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=vn(e,e.ins_h,e.window[e.strstart+Y-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Y-1,e.strstart++,r&&(bn(e,!1),e.strm.avail_out===0))return ln}else if(e.match_available){if(r=wt(e,0,e.window[e.strstart-1]),r&&bn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return ln}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=wt(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<Y-1?e.strstart:Y-1,t===Ot?(bn(e,!0),e.strm.avail_out===0?dn:fn):e.sym_next&&(bn(e,!1),e.strm.avail_out===0)?ln:un},kn=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=Zt){if(Tn(e),e.lookahead<=Zt&&t===J)return ln;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Y&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+Zt;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=Zt-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Y?(n=wt(e,1,e.match_length-Y),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(bn(e,!1),e.strm.avail_out===0))return ln}return e.insert=0,t===Ot?(bn(e,!0),e.strm.avail_out===0?dn:fn):e.sym_next&&(bn(e,!1),e.strm.avail_out===0)?ln:un},An=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Tn(e),e.lookahead===0)){if(t===J)return ln;break}if(e.match_length=0,n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(bn(e,!1),e.strm.avail_out===0))return ln}return e.insert=0,t===Ot?(bn(e,!0),e.strm.avail_out===0?dn:fn):e.sym_next&&(bn(e,!1),e.strm.avail_out===0)?ln:un};function jn(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var Mn=[new jn(0,0,0,0,En),new jn(4,4,8,4,Dn),new jn(4,5,16,8,Dn),new jn(4,6,32,32,Dn),new jn(4,4,16,16,On),new jn(8,16,32,32,On),new jn(8,16,128,128,On),new jn(8,32,128,256,On),new jn(32,128,258,1024,On),new jn(32,258,258,4096,On)],Nn=e=>{e.window_size=2*e.w_size,gn(e.head),e.max_lazy_match=Mn[e.level].max_lazy,e.good_match=Mn[e.level].good_length,e.nice_match=Mn[e.level].nice_length,e.max_chain_length=Mn[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Y-1,e.match_available=0,e.ins_h=0};function Pn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ht,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Yt*2),this.dyn_dtree=new Uint16Array((2*qt+1)*2),this.bl_tree=new Uint16Array((2*Jt+1)*2),gn(this.dyn_ltree),gn(this.dyn_dtree),gn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Xt+1),this.heap=new Uint16Array(2*Kt+1),gn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Kt+1),gn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Fn=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==en&&t.status!==tn&&t.status!==nn&&t.status!==rn&&t.status!==an&&t.status!==on&&t.status!==sn&&t.status!==cn?1:0},In=e=>{if(Fn(e))return mn(e,Mt);e.total_in=e.total_out=0,e.data_type=Vt;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?tn:t.wrap?en:sn,e.adler=t.wrap===2?0:1,t.last_flush=-2,xt(t),At},Ln=e=>{let t=In(e);return t===At&&Nn(e.state),t},Rn=(e,t)=>Fn(e)||e.state.wrap!==2?Mt:(e.state.gzhead=t,At),zn=(e,t,n,r,i,a)=>{if(!e)return Mt;let o=1;if(t===Ft&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Ut||n!==Ht||r<8||r>15||t<0||t>9||a<0||a>zt||r===8&&o!==1)return mn(e,Mt);r===8&&(r=9);let s=new Pn;return e.state=s,s.strm=e,s.status=en,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+Y-1)/Y),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=t,s.strategy=a,s.method=n,Ln(e)},Bn={deflateInit:(e,t)=>zn(e,t,Ht,Wt,Gt,Bt),deflateInit2:zn,deflateReset:Ln,deflateResetKeep:In,deflateSetHeader:Rn,deflate:(e,t)=>{if(Fn(e)||t>kt||t<0)return e?mn(e,Mt):Mt;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===cn&&t!==Ot)return mn(e,e.avail_out===0?Pt:Mt);let r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(yn(e),e.avail_out===0)return n.last_flush=-1,At}else if(e.avail_in===0&&hn(t)<=hn(r)&&t!==Ot)return mn(e,Pt);if(n.status===cn&&e.avail_in!==0)return mn(e,Pt);if(n.status===en&&n.wrap===0&&(n.status=sn),n.status===en){let t=Ht+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Lt||n.level<2?0:n.level<6?1:n.level===6?2:3,t|=r<<6,n.strstart!==0&&(t|=$t),t+=31-t%31,Sn(n,t),n.strstart!==0&&(Sn(n,e.adler>>>16),Sn(n,e.adler&65535)),e.adler=1,n.status=sn,yn(e),n.pending!==0)return n.last_flush=-1,At}if(n.status===tn){if(e.adler=0,xn(n,31),xn(n,139),xn(n,8),n.gzhead)xn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),xn(n,n.gzhead.time&255),xn(n,n.gzhead.time>>8&255),xn(n,n.gzhead.time>>16&255),xn(n,n.gzhead.time>>24&255),xn(n,n.level===9?2:n.strategy>=Lt||n.level<2?4:0),xn(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(xn(n,n.gzhead.extra.length&255),xn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=vt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=nn;else if(xn(n,0),xn(n,0),xn(n,0),xn(n,0),xn(n,0),xn(n,n.level===9?2:n.strategy>=Lt||n.level<2?4:0),xn(n,pn),n.status=sn,yn(e),n.pending!==0)return n.last_flush=-1,At}if(n.status===nn){if(n.gzhead.extra){let t=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,yn(e),n.pending!==0)return n.last_flush=-1,At;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=rn}if(n.status===rn){if(n.gzhead.name){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),yn(e),n.pending!==0)return n.last_flush=-1,At;t=0}r=n.gzindex<n.gzhead.name.length?n.gzhead.name.charCodeAt(n.gzindex++)&255:0,xn(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=an}if(n.status===an){if(n.gzhead.comment){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),yn(e),n.pending!==0)return n.last_flush=-1,At;t=0}r=n.gzindex<n.gzhead.comment.length?n.gzhead.comment.charCodeAt(n.gzindex++)&255:0,xn(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t))}n.status=on}if(n.status===on){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(yn(e),n.pending!==0))return n.last_flush=-1,At;xn(n,e.adler&255),xn(n,e.adler>>8&255),e.adler=0}if(n.status=sn,yn(e),n.pending!==0)return n.last_flush=-1,At}if(e.avail_in!==0||n.lookahead!==0||t!==J&&n.status!==cn){let r=n.level===0?En(n,t):n.strategy===Lt?An(n,t):n.strategy===Rt?kn(n,t):Mn[n.level].func(n,t);if((r===dn||r===fn)&&(n.status=cn),r===ln||r===dn)return e.avail_out===0&&(n.last_flush=-1),At;if(r===un&&(t===Et?Tt(n):t!==kt&&(St(n,0,0,!1),t===Dt&&(gn(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),yn(e),e.avail_out===0))return n.last_flush=-1,At}return t===Ot?n.wrap<=0?jt:(n.wrap===2?(xn(n,e.adler&255),xn(n,e.adler>>8&255),xn(n,e.adler>>16&255),xn(n,e.adler>>24&255),xn(n,e.total_in&255),xn(n,e.total_in>>8&255),xn(n,e.total_in>>16&255),xn(n,e.total_in>>24&255)):(Sn(n,e.adler>>>16),Sn(n,e.adler&65535)),yn(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending===0?jt:At):At},deflateEnd:e=>{if(Fn(e))return Mt;let t=e.state.status;return e.state=null,t===sn?mn(e,Nt):At},deflateSetDictionary:(e,t)=>{let n=t.length;if(Fn(e))return Mt;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==en||r.lookahead)return Mt;if(i===1&&(e.adler=gt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(gn(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Tn(r);r.lookahead>=Y;){let e=r.strstart,t=r.lookahead-(Y-1);do r.ins_h=vn(r,r.ins_h,r.window[e+Y-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++;while(--t);r.strstart=e,r.lookahead=Y-1,Tn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Y-1,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,At},deflateInfo:`pako deflate (from Nodeca project)`},Vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Hn={assign:function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!=`object`)throw TypeError(n+`must be non-object`);for(let t in n)Vn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n}},Un=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Un=!1}var Wn=new Uint8Array(256);for(let e=0;e<256;e++)Wn[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Wn[254]=Wn[254]=1;var Gn=e=>{if(typeof TextEncoder==`function`&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t},Kn=(e,t)=>{if(t<65534&&e.subarray&&Un)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n=``;for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n},qn={string2buf:Gn,buf2string:(e,t)=>{let n=t||e.length;if(typeof TextDecoder==`function`&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i,a=Array(n*2);for(i=0,r=0;r<n;){let t=e[r++];if(t<128){a[i++]=t;continue}let o=Wn[t];if(o>4){a[i++]=65533,r+=o-1;continue}for(t&=o===2?31:o===3?15:7;o>1&&r<n;)t=t<<6|e[r++]&63,o--;if(o>1){a[i++]=65533;continue}t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|t&1023)}return Kn(a,i)},utf8border:(e,t)=>{t||=e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)==128;)n--;return n<0||n===0?t:n+Wn[e[n]]>t?n:t}};function Jn(){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 Yn=Jn,Xn=Object.prototype.toString,{Z_NO_FLUSH:Zn,Z_SYNC_FLUSH:Qn,Z_FULL_FLUSH:$n,Z_FINISH:er,Z_OK:tr,Z_STREAM_END:nr,Z_DEFAULT_COMPRESSION:rr,Z_DEFAULT_STRATEGY:ir,Z_DEFLATED:ar}=bt;function or(e){this.options=Hn.assign({level:rr,method:ar,chunkSize:16384,windowBits:15,memLevel:8,strategy:ir},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new Yn,this.strm.avail_out=0;let n=Bn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==tr)throw Error(yt[n]);if(t.header&&Bn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=typeof t.dictionary==`string`?qn.string2buf(t.dictionary):Xn.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary,n=Bn.deflateSetDictionary(this.strm,e),n!==tr)throw Error(yt[n]);this._dict_set=!0}}or.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=t===~~t?t:t===!0?er:Zn,typeof e==`string`?n.input=qn.string2buf(e):Xn.call(e)===`[object ArrayBuffer]`?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===Qn||a===$n)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=Bn.deflate(n,a),i===nr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Bn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===tr;if(n.avail_out===0){this.onData(n.output);continue}if(a>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0},or.prototype.onData=function(e){this.chunks.push(e)},or.prototype.onEnd=function(e){e===tr&&(this.result=Hn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function sr(e,t){let n=new or(t);if(n.push(e,!0),n.err)throw n.msg||yt[n.err];return n.result}function cr(e,t){return t||={},t.raw=!0,sr(e,t)}function lr(e,t){return t||={},t.gzip=!0,sr(e,t)}var ur={Deflate:or,deflate:sr,deflateRaw:cr,gzip:lr,constants:bt},dr=16209,fr=16191,pr=function(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,l=E.whave,u=E.wnext,d=E.window,f=E.hold,p=E.bits,m=E.lencode,h=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;top:do{p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=m[f&g];dolen:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y===0)T[i++]=v&65535;else if(y&16){b=v&65535,y&=15,y&&(p<y&&(f+=w[n++]<<p,p+=8),b+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=h[f&_];dodist:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y&16){if(x=v&65535,y&=15,p<y&&(f+=w[n++]<<p,p+=8,p<y&&(f+=w[n++]<<p,p+=8)),x+=f&(1<<y)-1,x>s){e.msg=`invalid distance too far back`,E.mode=dr;break top}if(f>>>=y,p-=y,y=i-a,x>y){if(y=x-y,y>l&&E.sane){e.msg=`invalid distance too far back`,E.mode=dr;break top}if(S=0,C=d,u===0){if(S+=c-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}else if(u<y){if(S+=c+u-y,y-=u,y<b){b-=y;do T[i++]=d[S++];while(--y);if(S=0,u<b){y=u,b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}}else if(S+=u-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}for(;b>2;)T[i++]=C[S++],T[i++]=C[S++],T[i++]=C[S++],b-=3;b&&(T[i++]=C[S++],b>1&&(T[i++]=C[S++]))}else{S=i-x;do T[i++]=T[S++],T[i++]=T[S++],T[i++]=T[S++],b-=3;while(b>2);b&&(T[i++]=T[S++],b>1&&(T[i++]=T[S++]))}}else if(y&64){e.msg=`invalid distance code`,E.mode=dr;break top}else{v=h[(v&65535)+(f&(1<<y)-1)];continue dodist}break}}else if(!(y&64)){v=m[(v&65535)+(f&(1<<y)-1)];continue dolen}else if(y&32){E.mode=fr;break top}else{e.msg=`invalid literal/length code`,E.mode=dr;break top}break}}while(n<r&&i<o);b=p>>3,n-=b,p-=b<<3,f&=(1<<p)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?5+(r-n):5-(n-r),e.avail_out=i<o?257+(o-i):257-(i-o),E.hold=f,E.bits=p},mr=15,hr=852,gr=592,_r=0,vr=1,yr=2,br=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]),xr=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]),Sr=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]),Cr=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]),wr=(e,t,n,r,i,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y,b,x,S,C,w=null,T,E=new Uint16Array(mr+1),D=new Uint16Array(mr+1),O=null,k,A,j;for(l=0;l<=mr;l++)E[l]=0;for(u=0;u<r;u++)E[t[n+u]]++;for(p=c,f=mr;f>=1&&E[f]===0;f--);if(p>f&&(p=f),f===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<f&&E[d]===0;d++);for(p<d&&(p=d),g=1,l=1;l<=mr;l++)if(g<<=1,g-=E[l],g<0)return-1;if(g>0&&(e===_r||f!==1))return-1;for(D[1]=0,l=1;l<mr;l++)D[l+1]=D[l]+E[l];for(u=0;u<r;u++)t[n+u]!==0&&(o[D[t[n+u]]++]=u);if(e===_r?(w=O=o,T=20):e===vr?(w=br,O=xr,T=257):(w=Sr,O=Cr,T=0),v=0,u=0,l=d,C=a,m=p,h=0,x=-1,_=1<<p,S=_-1,e===vr&&_>hr||e===yr&&_>gr)return 1;for(;;){k=l-h,o[u]+1<T?(A=0,j=o[u]):o[u]>=T?(A=O[o[u]-T],j=w[o[u]-T]):(A=96,j=0),y=1<<l-h,b=1<<m,d=b;do b-=y,i[C+(v>>h)+b]=k<<24|A<<16|j|0;while(b!==0);for(y=1<<l-1;v&y;)y>>=1;if(y===0?v=0:(v&=y-1,v+=y),u++,--E[l]===0){if(l===f)break;l=t[n+o[u]]}if(l>p&&(v&S)!==x){for(h===0&&(h=p),C+=d,m=l-h,g=1<<m;m+h<f&&(g-=E[m+h],!(g<=0));)m++,g<<=1;if(_+=1<<m,e===vr&&_>hr||e===yr&&_>gr)return 1;x=v&S,i[x]=p<<24|m<<16|C-a|0}}return v!==0&&(i[C+v]=l-h<<24|4194304),s.bits=p,0},Tr=0,Er=1,Dr=2,{Z_FINISH:Or,Z_BLOCK:kr,Z_TREES:Ar,Z_OK:jr,Z_STREAM_END:Mr,Z_NEED_DICT:Nr,Z_STREAM_ERROR:Pr,Z_DATA_ERROR:Fr,Z_MEM_ERROR:Ir,Z_BUF_ERROR:Lr,Z_DEFLATED:Rr}=bt,zr=16180,Br=16181,Vr=16182,Hr=16183,Ur=16184,Wr=16185,Gr=16186,Kr=16187,qr=16188,Jr=16189,Yr=16190,Xr=16191,Zr=16192,Qr=16193,$r=16194,ei=16195,ti=16196,ni=16197,ri=16198,ii=16199,ai=16200,oi=16201,si=16202,ci=16203,li=16204,ui=16205,di=16206,fi=16207,pi=16208,mi=16209,hi=16210,gi=16211,_i=852,vi=592,yi=15,bi=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function xi(){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}var Si=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<zr||t.mode>gi?1:0},Ci=e=>{if(Si(e))return Pr;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=t.wrap&1),t.mode=zr,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(_i),t.distcode=t.distdyn=new Int32Array(vi),t.sane=1,t.back=-1,jr},wi=e=>{if(Si(e))return Pr;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ci(e)},Ti=(e,t)=>{let n;if(Si(e))return Pr;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Pr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,wi(e))},Ei=(e,t)=>{if(!e)return Pr;let n=new xi;e.state=n,n.strm=e,n.window=null,n.mode=zr;let r=Ti(e,t);return r!==jr&&(e.state=null),r},Di=e=>Ei(e,yi),Oi=!0,ki,Ai,ji=e=>{if(Oi){ki=new Int32Array(512),Ai=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(wr(Er,e.lens,0,288,ki,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;wr(Dr,e.lens,0,32,Ai,0,e.work,{bits:5}),Oi=!1}e.lencode=ki,e.lenbits=9,e.distcode=Ai,e.distbits=5},Mi=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},Ni={inflateReset:wi,inflateReset2:Ti,inflateResetKeep:Ci,inflateInit:Di,inflateInit2:Ei,inflate:(e,t)=>{let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=0,_,v,y,b,x,S,C,w,T=new Uint8Array(4),E,D,O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Si(e)||!e.output||!e.input&&e.avail_in!==0)return Pr;n=e.state,n.mode===Xr&&(n.mode=Zr),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,d=s,f=c,w=jr;inf_leave:for(;;)switch(n.mode){case zr:if(n.wrap===0){n.mode=Zr;break}for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&2&&l===35615){n.wbits===0&&(n.wbits=15),n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=vt(n.check,T,2,0),l=0,u=0,n.mode=Br;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg=`incorrect header check`,n.mode=mi;break}if((l&15)!==Rr){e.msg=`unknown compression method`,n.mode=mi;break}if(l>>>=4,u-=4,C=(l&15)+8,n.wbits===0&&(n.wbits=C),C>15||C>n.wbits){e.msg=`invalid window size`,n.mode=mi;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=l&512?Jr:Xr,l=0,u=0;break;case Br:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==Rr){e.msg=`unknown compression method`,n.mode=mi;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=mi;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=vt(n.check,T,2,0)),l=0,u=0,n.mode=Vr;case Vr:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=vt(n.check,T,4,0)),l=0,u=0,n.mode=Hr;case Hr:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=vt(n.check,T,2,0)),l=0,u=0,n.mode=Ur;case Ur:if(n.flags&1024){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=vt(n.check,T,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=Wr;case Wr:if(n.flags&1024&&(p=n.length,p>s&&(p=s),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+p),C)),n.flags&512&&n.wrap&4&&(n.check=vt(n.check,r,p,a)),s-=p,a+=p,n.length-=p),n.length))break inf_leave;n.length=0,n.mode=Gr;case Gr:if(n.flags&2048){if(s===0)break inf_leave;p=0;do C=r[a+ p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=vt(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=Kr;case Kr:if(n.flags&4096){if(s===0)break inf_leave;p=0;do C=r[a+ p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=vt(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.comment=null);n.mode=qr;case qr:if(n.flags&512){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=mi;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Xr;break;case Jr:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}e.adler=n.check=bi(l),l=0,u=0,n.mode=Yr;case Yr:if(n.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,Nr;e.adler=n.check=1,n.mode=Xr;case Xr:if(t===kr||t===Ar)break inf_leave;case Zr:if(n.last){l>>>=u&7,u-=u&7,n.mode=di;break}for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}switch(n.last=l&1,l>>>=1,--u,l&3){case 0:n.mode=Qr;break;case 1:if(ji(n),n.mode=ii,t===Ar){l>>>=2,u-=2;break inf_leave}break;case 2:n.mode=ti;break;case 3:e.msg=`invalid block type`,n.mode=mi}l>>>=2,u-=2;break;case Qr:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if((l&65535)!=(l>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=mi;break}if(n.length=l&65535,l=0,u=0,n.mode=$r,t===Ar)break inf_leave;case $r:n.mode=ei;case ei:if(p=n.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break inf_leave;i.set(r.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,n.length-=p;break}n.mode=Xr;break;case ti:for(;u<14;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=mi;break}n.have=0,n.mode=ni;case ni:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.lens[O[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[O[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},w=wr(Tr,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid code lengths set`,n.mode=mi;break}n.have=0,n.mode=ri;case ri:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(y<16)l>>>=_,u-=_,n.lens[n.have++]=y;else{if(y===16){for(D=_+2;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l>>>=_,u-=_,n.have===0){e.msg=`invalid bit length repeat`,n.mode=mi;break}C=n.lens[n.have-1],p=3+(l&3),l>>>=2,u-=2}else if(y===17){for(D=_+3;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=3+(l&7),l>>>=3,u-=3}else{for(D=_+7;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=11+(l&127),l>>>=7,u-=7}if(n.have+p>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=mi;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===mi)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=mi;break}if(n.lenbits=9,E={bits:n.lenbits},w=wr(Er,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid literal/lengths set`,n.mode=mi;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},w=wr(Dr,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,w){e.msg=`invalid distances set`,n.mode=mi;break}if(n.mode=ii,t===Ar)break inf_leave;case ii:n.mode=ai;case ai:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,pr(e,f),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===Xr&&(n.back=-1);break}for(n.back=0;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(v&&!(v&240)){for(b=_,x=v,S=y;g=n.lencode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,n.length=y,v===0){n.mode=ui;break}if(v&32){n.back=-1,n.mode=Xr;break}if(v&64){e.msg=`invalid literal/length code`,n.mode=mi;break}n.extra=v&15,n.mode=oi;case oi:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=si;case si:for(;g=n.distcode[l&(1<<n.distbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(!(v&240)){for(b=_,x=v,S=y;g=n.distcode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,v&64){e.msg=`invalid distance code`,n.mode=mi;break}n.offset=y,n.extra=v&15,n.mode=ci;case ci:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=mi;break}n.mode=li;case li:if(c===0)break inf_leave;if(p=f-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=mi;break}p>n.wnext?(p-=n.wnext,m=n.wsize-p):m=n.wnext-p,p>n.length&&(p=n.length),h=n.window}else h=i,m=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do i[o++]=h[m++];while(--p);n.length===0&&(n.mode=ai);break;case ui:if(c===0)break inf_leave;i[o++]=n.length,c--,n.mode=ai;break;case di:if(n.wrap){for(;u<32;){if(s===0)break inf_leave;s--,l|=r[a++]<<u,u+=8}if(f-=c,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?vt(n.check,i,f,o-f):gt(n.check,i,f,o-f)),f=c,n.wrap&4&&(n.flags?l:bi(l))!==n.check){e.msg=`incorrect data check`,n.mode=mi;break}l=0,u=0}n.mode=fi;case fi:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=mi;break}l=0,u=0}n.mode=pi;case pi:w=Mr;break inf_leave;case mi:w=Fr;break inf_leave;case hi:return Ir;case gi:default:return Pr}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||f!==e.avail_out&&n.mode<mi&&(n.mode<di||t!==Or))&&Mi(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?vt(n.check,i,f,e.next_out-f):gt(n.check,i,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Xr?128:0)+(n.mode===ii||n.mode===$r?256:0),(d===0&&f===0||t===Or)&&w===jr&&(w=Lr),w},inflateEnd:e=>{if(Si(e))return Pr;let t=e.state;return t.window&&=null,e.state=null,jr},inflateGetHeader:(e,t)=>{if(Si(e))return Pr;let n=e.state;return n.wrap&2?(n.head=t,t.done=!1,jr):Pr},inflateSetDictionary:(e,t)=>{let n=t.length,r,i,a;return Si(e)||(r=e.state,r.wrap!==0&&r.mode!==Yr)?Pr:r.mode===Yr&&(i=1,i=gt(i,t,n,0),i!==r.check)?Fr:(a=Mi(e,t,n,n),a?(r.mode=hi,Ir):(r.havedict=1,jr))},inflateInfo:`pako inflate (from Nodeca project)`};function Pi(){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 Fi=Pi,Ii=Object.prototype.toString,{Z_NO_FLUSH:Li,Z_FINISH:Ri,Z_OK:zi,Z_STREAM_END:Bi,Z_NEED_DICT:Vi,Z_STREAM_ERROR:Hi,Z_DATA_ERROR:Ui,Z_MEM_ERROR:Wi}=bt;function Gi(e){this.options=Hn.assign({chunkSize:1024*64,windowBits:15,to:``},e||{});let 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&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new Yn,this.strm.avail_out=0;let n=Ni.inflateInit2(this.strm,t.windowBits);if(n!==zi||(this.header=new Fi,Ni.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary==`string`?t.dictionary=qn.string2buf(t.dictionary):Ii.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ni.inflateSetDictionary(this.strm,t.dictionary),n!==zi))))throw Error(yt[n])}Gi.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,a,o,s;if(this.ended)return!1;for(o=t===~~t?t:t===!0?Ri:Li,Ii.call(e)===`[object ArrayBuffer]`?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),a=Ni.inflate(n,o),a===Vi&&i&&(a=Ni.inflateSetDictionary(n,i),a===zi?a=Ni.inflate(n,o):a===Ui&&(a=Vi));n.avail_in>0&&a===Bi&&n.state.wrap>0&&e[n.next_in]!==0;)Ni.inflateReset(n),a=Ni.inflate(n,o);switch(a){case Hi:case Ui:case Vi:case Wi:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||a===Bi))if(this.options.to===`string`){let e=qn.utf8border(n.output,n.next_out),t=n.next_out-e,i=qn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(a===zi&&s===0)){if(a===Bi)return a=Ni.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(n.avail_in===0)break}}return!0},Gi.prototype.onData=function(e){this.chunks.push(e)},Gi.prototype.onEnd=function(e){e===zi&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=Hn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Ki(e,t){let n=new Gi(t);if(n.push(e),n.err)throw n.msg||yt[n.err];return n.result}function qi(e,t){return t||={},t.raw=!0,Ki(e,t)}var Ji={Inflate:Gi,inflate:Ki,inflateRaw:qi,ungzip:Ki,constants:bt},{Deflate:Yi,deflate:Xi,deflateRaw:Zi,gzip:Qi}=ur,{Inflate:$i,inflate:ea,inflateRaw:ta,ungzip:na}=Ji,ra=$i,ia=ea,aa=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;aa[e]=t}var oa=4294967295;function sa(e,t,n){let r=e;for(let e=0;e<n;e++)r=aa[(r^t[e])&255]^r>>>8;return r}function ca(e,t){return(sa(oa,e,t)^oa)>>>0}function la(e,t,n){let r=e.readUint32(),i=ca(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function ua(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function da(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function fa(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function pa(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function ma(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+ha(t[a-i],n[a],n[a-i])&255}}function ha(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function ga(e,t,n,r,i,a){switch(e){case 0:ua(t,n,i);break;case 1:da(t,n,i,a);break;case 2:fa(t,n,r,i);break;case 3:pa(t,n,r,i,a);break;case 4:ma(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var _a=new Uint16Array([255]),va=new Uint8Array(_a.buffer)[0]===255;function ya(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{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}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);ga(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(va)for(let t=0;t<e.length;t++)e[t]=ba(e[t]);return e}else return c}function ba(e){return(e&255)<<8|e>>8&255}var xa=new Uint16Array([255]),Sa=new Uint8Array(xa.buffer)[0]===255,Ca=new Uint8Array;function wa(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=Ca,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:ua(d,f,s);break;case 1:da(d,f,s,o);break;case 2:fa(d,f,l,s);break;case 3:pa(d,f,l,s,o);break;case 4:ma(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(Sa)for(let t=0;t<e.length;t++)e[t]=Ta(e[t]);return e}else return c}function Ta(e){return(e&255)<<8|e>>8&255}var Ea=Uint8Array.of(137,80,78,71,13,10,26,10);function Da(e){if(!Oa(e.readBytes(Ea.length)))throw Error(`wrong PNG signature`)}function Oa(e){if(e.length<Ea.length)return!1;for(let t=0;t<Ea.length;t++)if(e[t]!==Ea[t])return!1;return!0}var ka=`tEXt`,Aa=0,ja=new TextDecoder(`latin1`);function Ma(e){if(Pa(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var Na=/^[\u0000-\u00FF]*$/;function Pa(e){if(!Na.test(e))throw Error(`invalid latin1 text`)}function Fa(e,t,n){let r=Ia(t);e[r]=La(t,n-r.length-1)}function Ia(e){for(e.mark();e.readByte()!==Aa;);let t=e.offset;e.reset();let n=ja.decode(e.readBytes(t-e.offset-1));return e.skip(1),Ma(n),n}function La(e,t){return ja.decode(e.readBytes(t))}var Ra={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},za={UNKNOWN:-1,DEFLATE:0},Ba={UNKNOWN:-1,ADAPTIVE:0},Va={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Ha={NONE:0,BACKGROUND:1,PREVIOUS:2},Ua={SOURCE:0,OVER:1},Wa=class extends ce{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new ra,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,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,this._compressionMethod=za.UNKNOWN,this._filterMethod=Ba.UNKNOWN,this._interlaceMethod=Va.UNKNOWN,this._colorType=Ra.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(Da(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this.decodeImage(),this._png}decodeApng(){for(Da(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case ka:Fa(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e);break}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?la(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e;break}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?la(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=Ga(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case Ra.GREYSCALE:n=1;break;case Ra.TRUECOLOUR:n=3;break;case Ra.INDEXED_COLOUR:n=1;break;case Ra.GREYSCALE_ALPHA:n=2;break;case Ra.TRUECOLOUR_ALPHA:n=4;break;case Ra.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==za.DEFLATE)throw 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(){let e={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};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(n+=4,t-=4,this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case Ra.GREYSCALE:case Ra.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case Ra.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case Ra.UNKNOWN:case Ra.GREYSCALE_ALPHA:case Ra.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=Ia(this),n=this.readUint8();if(n!==za.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:ia(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}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 e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].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)},n=this._frames.at(e);if(n){if(n.data=wa({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case Ha.NONE:break;case Ha.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case Ha.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case Ua.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case Ua.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){if(this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);let e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==Ba.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===Va.NO_INTERLACE)this._png.data=wa({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===Va.ADAM7)this._png.data=ya({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){let e=this._inflator.result,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Ha.NONE,blendOp:Ua.SOURCE,data:e}),this._inflator=new ra,this._writingDataChunks=!1}};function Ga(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}var Ka;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.METRE=1]=`METRE`})(Ka||={});function qa(e,t){return new Wa(e,t).decode()}var X=function(){return typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this}();function Ja(){X.console&&typeof X.console.log==`function`&&X.console.log.apply(X.console,arguments)}var Ya={log:Ja,warn:function(e){X.console&&(typeof X.console.warn==`function`?X.console.warn.apply(X.console,arguments):Ja.call(null,arguments))},error:function(e){X.console&&(typeof X.console.error==`function`?X.console.error.apply(X.console,arguments):Ja(e))}};function Xa(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e),r.responseType=`blob`,r.onload=function(){$a(r.response,t,n)},r.onerror=function(){Ya.error(`could not download file`)},r.send()}function Za(e){var t=new XMLHttpRequest;t.open(`HEAD`,e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function Qa(e){try{e.dispatchEvent(new MouseEvent(`click`))}catch{var t=document.createEvent(`MouseEvents`);t.initMouseEvent(`click`,!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var $a=X.saveAs||((typeof window>`u`?`undefined`:n(window))!==`object`||window!==X?function(){}:typeof HTMLAnchorElement<`u`&&`download`in HTMLAnchorElement.prototype?function(e,t,n){var r=X.URL||X.webkitURL,i=document.createElement(`a`);t=t||e.name||`download`,i.download=t,i.rel=`noopener`,typeof e==`string`?(i.href=e,i.origin===location.origin?Qa(i):Za(i.href)?Xa(e,t,n):Qa(i,i.target=`_blank`)):(i.href=r.createObjectURL(e),setTimeout(function(){r.revokeObjectURL(i.href)},4e4),setTimeout(function(){Qa(i)},0))}:`msSaveOrOpenBlob`in navigator?function(e,t,r){if(t=t||e.name||`download`,typeof e==`string`)if(Za(e))Xa(e,t,r);else{var i=document.createElement(`a`);i.href=e,i.target=`_blank`,setTimeout(function(){Qa(i)})}else navigator.msSaveOrOpenBlob(function(e,t){return t===void 0?t={autoBom:!1}:n(t)!==`object`&&(Ya.warn(`Deprecated: Expected third argument to be a object`),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([``,e],{type:e.type}):e}(e,r),t)}:function(e,t,r,i){if((i||=open(``,`_blank`))&&(i.document.title=i.document.body.innerText=`downloading...`),typeof e==`string`)return Xa(e,t,r);var a=e.type===`application/octet-stream`,o=/constructor/i.test(X.HTMLElement)||X.safari,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||a&&o)&&(typeof FileReader>`u`?`undefined`:n(FileReader))===`object`){var c=new FileReader;c.onloadend=function(){var e=c.result;e=s?e:e.replace(/^data:[^;]*;/,`data:attachment/file;`),i?i.location.href=e:location=e,i=null},c.readAsDataURL(e)}else{var l=X.URL||X.webkitURL,u=l.createObjectURL(e);i?i.location=u:location.href=u,i=null,setTimeout(function(){l.revokeObjectURL(u)},4e4)}});function eo(e){var t;e||=``,this.ok=!1,e.charAt(0)==`#`&&(e=e.substr(1,6)),e={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dodgerblue:`1e90ff`,feldspar:`d19275`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgrey:`d3d3d3`,lightgreen:`90ee90`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslateblue:`8470ff`,lightslategray:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370d8`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`d87093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,violetred:`d02090`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`}[e=(e=e.replace(/ /g,``)).toLowerCase()]||e;for(var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:[`rgb(123, 234, 45)`,`rgb(255,234,245)`],process:function(e){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:[`#00ff00`,`336699`],process:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:[`#fb0`,`f0f`],process:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}}],r=0;r<n.length;r++){var i=n[r].re,a=n[r].process,o=i.exec(e);o&&(t=a(o),this.r=t[0],this.g=t[1],this.b=t[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return`rgb(`+this.r+`, `+this.g+`, `+this.b+`)`},this.toHex=function(){var e=this.r.toString(16),t=this.g.toString(16),n=this.b.toString(16);return e.length==1&&(e=`0`+e),t.length==1&&(t=`0`+t),n.length==1&&(n=`0`+n),`#`+e+t+n}}var to=X.atob.bind(X),no=X.btoa.bind(X);function ro(e,t){var n=e[0],r=e[1],i=e[2],a=e[3];n=ao(n,r,i,a,t[0],7,-680876936),a=ao(a,n,r,i,t[1],12,-389564586),i=ao(i,a,n,r,t[2],17,606105819),r=ao(r,i,a,n,t[3],22,-1044525330),n=ao(n,r,i,a,t[4],7,-176418897),a=ao(a,n,r,i,t[5],12,1200080426),i=ao(i,a,n,r,t[6],17,-1473231341),r=ao(r,i,a,n,t[7],22,-45705983),n=ao(n,r,i,a,t[8],7,1770035416),a=ao(a,n,r,i,t[9],12,-1958414417),i=ao(i,a,n,r,t[10],17,-42063),r=ao(r,i,a,n,t[11],22,-1990404162),n=ao(n,r,i,a,t[12],7,1804603682),a=ao(a,n,r,i,t[13],12,-40341101),i=ao(i,a,n,r,t[14],17,-1502002290),n=oo(n,r=ao(r,i,a,n,t[15],22,1236535329),i,a,t[1],5,-165796510),a=oo(a,n,r,i,t[6],9,-1069501632),i=oo(i,a,n,r,t[11],14,643717713),r=oo(r,i,a,n,t[0],20,-373897302),n=oo(n,r,i,a,t[5],5,-701558691),a=oo(a,n,r,i,t[10],9,38016083),i=oo(i,a,n,r,t[15],14,-660478335),r=oo(r,i,a,n,t[4],20,-405537848),n=oo(n,r,i,a,t[9],5,568446438),a=oo(a,n,r,i,t[14],9,-1019803690),i=oo(i,a,n,r,t[3],14,-187363961),r=oo(r,i,a,n,t[8],20,1163531501),n=oo(n,r,i,a,t[13],5,-1444681467),a=oo(a,n,r,i,t[2],9,-51403784),i=oo(i,a,n,r,t[7],14,1735328473),n=so(n,r=oo(r,i,a,n,t[12],20,-1926607734),i,a,t[5],4,-378558),a=so(a,n,r,i,t[8],11,-2022574463),i=so(i,a,n,r,t[11],16,1839030562),r=so(r,i,a,n,t[14],23,-35309556),n=so(n,r,i,a,t[1],4,-1530992060),a=so(a,n,r,i,t[4],11,1272893353),i=so(i,a,n,r,t[7],16,-155497632),r=so(r,i,a,n,t[10],23,-1094730640),n=so(n,r,i,a,t[13],4,681279174),a=so(a,n,r,i,t[0],11,-358537222),i=so(i,a,n,r,t[3],16,-722521979),r=so(r,i,a,n,t[6],23,76029189),n=so(n,r,i,a,t[9],4,-640364487),a=so(a,n,r,i,t[12],11,-421815835),i=so(i,a,n,r,t[15],16,530742520),n=co(n,r=so(r,i,a,n,t[2],23,-995338651),i,a,t[0],6,-198630844),a=co(a,n,r,i,t[7],10,1126891415),i=co(i,a,n,r,t[14],15,-1416354905),r=co(r,i,a,n,t[5],21,-57434055),n=co(n,r,i,a,t[12],6,1700485571),a=co(a,n,r,i,t[3],10,-1894986606),i=co(i,a,n,r,t[10],15,-1051523),r=co(r,i,a,n,t[1],21,-2054922799),n=co(n,r,i,a,t[8],6,1873313359),a=co(a,n,r,i,t[15],10,-30611744),i=co(i,a,n,r,t[6],15,-1560198380),r=co(r,i,a,n,t[13],21,1309151649),n=co(n,r,i,a,t[4],6,-145523070),a=co(a,n,r,i,t[11],10,-1120210379),i=co(i,a,n,r,t[2],15,718787259),r=co(r,i,a,n,t[9],21,-343485551),e[0]=_o(n,e[0]),e[1]=_o(r,e[1]),e[2]=_o(i,e[2]),e[3]=_o(a,e[3])}function io(e,t,n,r,i,a){return t=_o(_o(t,e),_o(r,a)),_o(t<<i|t>>>32-i,n)}function ao(e,t,n,r,i,a,o){return io(t&n|~t&r,e,t,i,a,o)}function oo(e,t,n,r,i,a,o){return io(t&r|n&~r,e,t,i,a,o)}function so(e,t,n,r,i,a,o){return io(t^n^r,e,t,i,a,o)}function co(e,t,n,r,i,a,o){return io(n^(t|~r),e,t,i,a,o)}function lo(e){var t,n=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)ro(r,uo(e.substring(t-64,t)));e=e.substring(t-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(ro(r,i),t=0;t<16;t++)i[t]=0;return i[14]=8*n,ro(r,i),r}function uo(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}var fo=`0123456789abcdef`.split(``);function po(e){for(var t=``,n=0;n<4;n++)t+=fo[e>>8*n+4&15]+fo[e>>8*n&15];return t}function mo(e){return String.fromCharCode(255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24)}function ho(e){return lo(e).map(mo).join(``)}var go=function(e){for(var t=0;t<e.length;t++)e[t]=po(e[t]);return e.join(``)}(lo(`hello`))!=`5d41402abc4b2a76b9719d911017c592`;function _o(e,t){if(go){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}return e+t&4294967295}function vo(e,t){var n,r,i,a;if(e!==n){for(var o=(i=e,a=1+(256/e.length|0),Array(a+1).join(i)),s=[],c=0;c<256;c++)s[c]=c;var l=0;for(c=0;c<256;c++){var u=s[c];l=(l+u+o.charCodeAt(c))%256,s[c]=s[l],s[l]=u}n=e,r=s}else s=r;var d=t.length,f=0,p=0,m=``;for(c=0;c<d;c++)p=(p+(u=s[f=(f+1)%256]))%256,s[f]=s[p],s[p]=u,o=s[(s[f]+s[p])%256],m+=String.fromCharCode(t.charCodeAt(c)^o);return m}var yo={print:4,modify:8,copy:16,"annot-forms":32};function bo(e,t,n,r){this.v=1,this.r=2;var i=192;e.forEach(function(e){if(yo.perm!==void 0)throw Error(`Invalid permission: `+e);i+=yo[e]}),this.padding=`(¿N^NuAd\0NVÿú\b..\0¶Ðh>/\f©þdSiz`;var a=(t+this.padding).substr(0,32),o=(n+this.padding).substr(0,32);this.O=this.processOwnerPassword(a,o),this.P=-(1+(255^i)),this.encryptionKey=ho(a+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(r)).substr(0,5),this.U=vo(this.encryptionKey,this.padding)}function xo(e){if(/[^\u0000-\u00ff]/.test(e))throw Error(`Invalid PDF Name Object: `+e+`, Only accept ASCII characters.`);for(var t=``,n=e.length,r=0;r<n;r++){var i=e.charCodeAt(r);t+=i<33||i===35||i===37||i===40||i===41||i===47||i===60||i===62||i===91||i===93||i===123||i===125||i>126?`#`+(`0`+i.toString(16)).slice(-2):e[r]}return t}function So(e){if(n(e)!==`object`)throw Error(`Invalid Context passed to initialize PubSub (jsPDF-module)`);var t={};this.subscribe=function(e,n,r){if(r||=!1,typeof e!=`string`||typeof n!=`function`||typeof r!=`boolean`)throw Error(`Invalid arguments passed to PubSub.subscribe (jsPDF-module)`);t.hasOwnProperty(e)||(t[e]={});var i=Math.random().toString(35);return t[e][i]=[n,!!r],i},this.unsubscribe=function(e){for(var n in t)if(t[n][e])return delete t[n][e],Object.keys(t[n]).length===0&&delete t[n],!0;return!1},this.publish=function(n){if(t.hasOwnProperty(n)){var r=Array.prototype.slice.call(arguments,1),i=[];for(var a in t[n]){var o=t[n][a];try{o[0].apply(e,r)}catch(e){X.console&&Ya.error(`jsPDF PubSub Error`,e.message,e)}o[1]&&i.push(a)}i.length&&i.forEach(this.unsubscribe)}},this.getTopics=function(){return t}}function Co(e){if(!(this instanceof Co))return new Co(e);var t=`opacity,stroke-opacity`.split(`,`);for(var n in e)e.hasOwnProperty(n)&&t.indexOf(n)>=0&&(this[n]=e[n]);this.id=``,this.objectNumber=-1}function wo(e,t){this.gState=e,this.matrix=t,this.id=``,this.objectNumber=-1}function To(e,t,n,r,i){if(!(this instanceof To))return new To(e,t,n,r,i);this.type=e===`axial`?2:3,this.coords=t,this.colors=n,wo.call(this,r,i)}function Eo(e,t,n,r,i){if(!(this instanceof Eo))return new Eo(e,t,n,r,i);this.boundingBox=e,this.xStep=t,this.yStep=n,this.stream=``,this.cloneIndex=0,wo.call(this,r,i)}function Z(e){var t,r=typeof arguments[0]==`string`?arguments[0]:`p`,i=arguments[1],a=arguments[2],o=arguments[3],s=[],c=1,l=16,u=`S`,d=null;n(e||={})===`object`&&(r=e.orientation,i=e.unit||i,a=e.format||a,o=e.compress||e.compressPdf||o,(d=e.encryption||null)!==null&&(d.userPassword=d.userPassword||``,d.ownerPassword=d.ownerPassword||``,d.userPermissions=d.userPermissions||[]),c=typeof e.userUnit==`number`?Math.abs(e.userUnit):1,e.precision!==void 0&&(t=e.precision),e.floatPrecision!==void 0&&(l=e.floatPrecision),u=e.defaultPathOperation||`S`),s=e.filters||(!0===o?[`FlateEncode`]:s),i||=`mm`,r=(``+(r||`P`)).toLowerCase();var f=e.putOnlyUsedFonts||!1,p={},m={internal:{},__private__:{}};m.__private__.PubSub=So;var h=`1.3`,g=m.__private__.getPdfVersion=function(){return h};m.__private__.setPdfVersion=function(e){h=e};var _={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};m.__private__.getPageFormats=function(){return _};var v=m.__private__.getPageFormat=function(e){return _[e]};a||=`a4`;var y=`compat`,b=`advanced`,x=y;function S(){this.saveGraphicsState(),G(new q(xe,0,0,-xe,0,vn()*xe).toString()+` cm`),this.setFontSize(this.getFontSize()/xe),u=`n`,x=b}function C(){this.restoreGraphicsState(),u=`S`,x=y}var w=m.__private__.combineFontStyleAndFontWeight=function(e,t){if(e==`bold`&&t==`normal`||e==`bold`&&t==400||e==`normal`&&t==`italic`||e==`bold`&&t==`italic`)throw Error(`Invalid Combination of fontweight and fontstyle`);return t&&(e=t==400||t===`normal`?e===`italic`?`italic`:`normal`:t!=700&&t!==`bold`||e!==`normal`?(t==700?`bold`:t)+``+e:`bold`),e};m.advancedAPI=function(e){var t=x===y;return t&&S.call(this),typeof e!=`function`||(e(this),t&&C.call(this)),this},m.compatAPI=function(e){var t=x===b;return t&&C.call(this),typeof e!=`function`||(e(this),t&&S.call(this)),this},m.isAdvancedAPI=function(){return x===b};var T,E=function(e){if(x!==b)throw Error(e+` is only available in 'advanced' API mode. You need to call advancedAPI() first.`)},D=m.roundToPrecision=m.__private__.roundToPrecision=function(e,n){var r=t||n;if(isNaN(e)||isNaN(r))throw Error(`Invalid argument passed to jsPDF.roundToPrecision`);return e.toFixed(r).replace(/0+$/,``)};T=m.hpf=m.__private__.hpf=typeof l==`number`?function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return D(e,l)}:l===`smart`?function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return D(e,e>-1&&e<1?16:5)}:function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return D(e,16)};var O=m.f2=m.__private__.f2=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.f2`);return D(e,2)},k=m.__private__.f3=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.f3`);return D(e,3)},A=m.scale=m.__private__.scale=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.scale`);return x===y?e*xe:x===b?e:void 0},j=function(e){return A(function(e){return x===y?vn()-e:x===b?e:void 0}(e))};m.__private__.setPrecision=m.setPrecision=function(e){typeof parseInt(e,10)==`number`&&(t=parseInt(e,10))};var M,N=`00000000000000000000000000000000`,P=m.__private__.getFileId=function(){return N},F=m.__private__.setFileId=function(e){return N=e!==void 0&&/^[a-fA-F0-9]{32}$/.test(e)?e.toUpperCase():N.split(``).map(function(){return`ABCDEF0123456789`.charAt(Math.floor(16*Math.random()))}).join(``),d!==null&&(Tt=new bo(d.userPermissions,d.userPassword,d.ownerPassword,N)),N};m.setFileId=function(e){return F(e),this},m.getFileId=function(){return P()};var I=m.__private__.convertDateToPDFDate=function(e){var t=e.getTimezoneOffset(),n=t<0?`+`:`-`,r=Math.floor(Math.abs(t/60)),i=Math.abs(t%60),a=[n,V(r),`'`,V(i),`'`].join(``);return[`D:`,e.getFullYear(),V(e.getMonth()+1),V(e.getDate()),V(e.getHours()),V(e.getMinutes()),V(e.getSeconds()),a].join(``)},L=m.__private__.convertPDFDateToDate=function(e){var t=parseInt(e.substr(2,4),10),n=parseInt(e.substr(6,2),10)-1,r=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),o=parseInt(e.substr(14,2),10);return new Date(t,n,r,i,a,o,0)},R=m.__private__.setCreationDate=function(e){var t;if(e===void 0&&(e=new Date),e instanceof Date)t=I(e);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(e))throw Error(`Invalid argument passed to jsPDF.setCreationDate`);t=e}return M=t},z=m.__private__.getCreationDate=function(e){var t=M;return e===`jsDate`&&(t=L(M)),t};m.setCreationDate=function(e){return R(e),this},m.getCreationDate=function(e){return z(e)};var B,V=m.__private__.padd2=function(e){return(`0`+parseInt(e)).slice(-2)},ee=m.__private__.padd2Hex=function(e){return(`00`+(e=e.toString())).substr(e.length)},H=0,U=[],W=[],te=0,ne=[],re=[],ie=!1,ae=W;m.__private__.setCustomOutputDestination=function(e){ie=!0,ae=e};var oe=function(e){ie||(ae=e)};m.__private__.resetCustomOutputDestination=function(){ie=!1,ae=W};var G=m.__private__.out=function(e){return e=e.toString(),te+=e.length+1,ae.push(e),ae},se=m.__private__.write=function(e){return G(arguments.length===1?e.toString():Array.prototype.join.call(arguments,` `))},ce=m.__private__.getArrayBuffer=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);t--;)r[t]=e.charCodeAt(t);return n},le=[[`Helvetica`,`helvetica`,`normal`,`WinAnsiEncoding`],[`Helvetica-Bold`,`helvetica`,`bold`,`WinAnsiEncoding`],[`Helvetica-Oblique`,`helvetica`,`italic`,`WinAnsiEncoding`],[`Helvetica-BoldOblique`,`helvetica`,`bolditalic`,`WinAnsiEncoding`],[`Courier`,`courier`,`normal`,`WinAnsiEncoding`],[`Courier-Bold`,`courier`,`bold`,`WinAnsiEncoding`],[`Courier-Oblique`,`courier`,`italic`,`WinAnsiEncoding`],[`Courier-BoldOblique`,`courier`,`bolditalic`,`WinAnsiEncoding`],[`Times-Roman`,`times`,`normal`,`WinAnsiEncoding`],[`Times-Bold`,`times`,`bold`,`WinAnsiEncoding`],[`Times-Italic`,`times`,`italic`,`WinAnsiEncoding`],[`Times-BoldItalic`,`times`,`bolditalic`,`WinAnsiEncoding`],[`ZapfDingbats`,`zapfdingbats`,`normal`,null],[`Symbol`,`symbol`,`normal`,null]];m.__private__.getStandardFonts=function(){return le};var ue=e.fontSize||16;m.__private__.setFontSize=m.setFontSize=function(e){return ue=x===b?e/xe:e,this};var de,fe=m.__private__.getFontSize=m.getFontSize=function(){return x===y?ue:ue*xe},pe=e.R2L||!1;m.__private__.setR2L=m.setR2L=function(e){return pe=e,this},m.__private__.getR2L=m.getR2L=function(){return pe};var me,he=m.__private__.setZoomMode=function(e){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(e))de=e;else if(isNaN(e)){if([void 0,null,`fullwidth`,`fullheight`,`fullpage`,`original`].indexOf(e)===-1)throw Error(`zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "`+e+`" is not recognized.`);de=e}else de=parseInt(e,10)};m.__private__.getZoomMode=function(){return de};var ge,_e=m.__private__.setPageMode=function(e){if([void 0,null,`UseNone`,`UseOutlines`,`UseThumbs`,`FullScreen`].indexOf(e)==-1)throw Error(`Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "`+e+`" is not recognized.`);me=e};m.__private__.getPageMode=function(){return me};var ve=m.__private__.setLayoutMode=function(e){if([void 0,null,`continuous`,`single`,`twoleft`,`tworight`,`two`].indexOf(e)==-1)throw Error(`Layout mode must be one of continuous, single, twoleft, tworight. "`+e+`" is not recognized.`);ge=e};m.__private__.getLayoutMode=function(){return ge},m.__private__.setDisplayMode=m.setDisplayMode=function(e,t,n){return he(e),ve(t),_e(n),this};var ye={title:``,subject:``,author:``,keywords:``,creator:``};m.__private__.getDocumentProperty=function(e){if(Object.keys(ye).indexOf(e)===-1)throw Error(`Invalid argument passed to jsPDF.getDocumentProperty`);return ye[e]},m.__private__.getDocumentProperties=function(){return ye},m.__private__.setDocumentProperties=m.setProperties=m.setDocumentProperties=function(e){for(var t in ye)ye.hasOwnProperty(t)&&e[t]&&(ye[t]=e[t]);return this},m.__private__.setDocumentProperty=function(e,t){if(Object.keys(ye).indexOf(e)===-1)throw Error(`Invalid arguments passed to jsPDF.setDocumentProperty`);return ye[e]=t};var be,xe,Se,Ce,we,Te={},Ee={},De=[],Oe={},ke={},Ae={},je={},Me=null,Ne=0,K=[],Pe=new So(m),Fe=e.hotfixes||[],Ie={},Le={},Re=[],q=function e(t,n,r,i,a,o){if(!(this instanceof e))return new e(t,n,r,i,a,o);isNaN(t)&&(t=1),isNaN(n)&&(n=0),isNaN(r)&&(r=0),isNaN(i)&&(i=1),isNaN(a)&&(a=0),isNaN(o)&&(o=0),this._matrix=[t,n,r,i,a,o]};Object.defineProperty(q.prototype,`sx`,{get:function(){return this._matrix[0]},set:function(e){this._matrix[0]=e}}),Object.defineProperty(q.prototype,`shy`,{get:function(){return this._matrix[1]},set:function(e){this._matrix[1]=e}}),Object.defineProperty(q.prototype,`shx`,{get:function(){return this._matrix[2]},set:function(e){this._matrix[2]=e}}),Object.defineProperty(q.prototype,`sy`,{get:function(){return this._matrix[3]},set:function(e){this._matrix[3]=e}}),Object.defineProperty(q.prototype,`tx`,{get:function(){return this._matrix[4]},set:function(e){this._matrix[4]=e}}),Object.defineProperty(q.prototype,`ty`,{get:function(){return this._matrix[5]},set:function(e){this._matrix[5]=e}}),Object.defineProperty(q.prototype,`a`,{get:function(){return this._matrix[0]},set:function(e){this._matrix[0]=e}}),Object.defineProperty(q.prototype,`b`,{get:function(){return this._matrix[1]},set:function(e){this._matrix[1]=e}}),Object.defineProperty(q.prototype,`c`,{get:function(){return this._matrix[2]},set:function(e){this._matrix[2]=e}}),Object.defineProperty(q.prototype,`d`,{get:function(){return this._matrix[3]},set:function(e){this._matrix[3]=e}}),Object.defineProperty(q.prototype,`e`,{get:function(){return this._matrix[4]},set:function(e){this._matrix[4]=e}}),Object.defineProperty(q.prototype,`f`,{get:function(){return this._matrix[5]},set:function(e){this._matrix[5]=e}}),Object.defineProperty(q.prototype,`rotation`,{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(q.prototype,`scaleX`,{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(q.prototype,`scaleY`,{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(q.prototype,`isIdentity`,{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),q.prototype.join=function(e){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(T).join(e)},q.prototype.multiply=function(e){return new q(e.sx*this.sx+e.shy*this.shx,e.sx*this.shy+e.shy*this.sy,e.shx*this.sx+e.sy*this.shx,e.shx*this.shy+e.sy*this.sy,e.tx*this.sx+e.ty*this.shx+this.tx,e.tx*this.shy+e.ty*this.sy+this.ty)},q.prototype.decompose=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=Math.sqrt(e*e+t*t),s=(e/=o)*n+(t/=o)*r;n-=e*s,r-=t*s;var c=Math.sqrt(n*n+r*r);return s/=c,e*(r/=c)<t*(n/=c)&&(e=-e,t=-t,s=-s,o=-o),{scale:new q(o,0,0,c,0,0),translate:new q(1,0,0,1,i,a),rotate:new q(e,t,-t,e,0,0),skew:new q(1,0,s,1,0,0)}},q.prototype.toString=function(e){return this.join(` `)},q.prototype.inversed=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=1/(e*r-t*n),s=r*o,c=-t*o,l=-n*o,u=e*o;return new q(s,c,l,u,-s*i-l*a,-c*i-u*a)},q.prototype.applyToPoint=function(e){return new sn(e.x*this.sx+e.y*this.shx+this.tx,e.x*this.shy+e.y*this.sy+this.ty)},q.prototype.applyToRectangle=function(e){var t=this.applyToPoint(e),n=this.applyToPoint(new sn(e.x+e.w,e.y+e.h));return new cn(t.x,t.y,n.x-t.x,n.y-t.y)},q.prototype.clone=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty;return new q(e,t,n,r,i,a)},m.Matrix=q;var ze=m.matrixMult=function(e,t){return t.multiply(e)},Be=new q(1,0,0,1,0,0);m.unitMatrix=m.identityMatrix=Be;var Ve=function(e,t){if(!ke[e]){var n=(t instanceof To?`Sh`:`P`)+(Object.keys(Oe).length+1).toString(10);t.id=n,ke[e]=n,Oe[n]=t,Pe.publish(`addPattern`,t)}};m.ShadingPattern=To,m.TilingPattern=Eo,m.addShadingPattern=function(e,t){return E(`addShadingPattern()`),Ve(e,t),this},m.beginTilingPattern=function(e){E(`beginTilingPattern()`),un(e.boundingBox[0],e.boundingBox[1],e.boundingBox[2]-e.boundingBox[0],e.boundingBox[3]-e.boundingBox[1],e.matrix)},m.endTilingPattern=function(e,t){E(`endTilingPattern()`),t.stream=re[B].join(`
|
|
4
4
|
`),Ve(e,t),Pe.publish(`endTilingPattern`,t),Re.pop().restore()};var He,Ue=m.__private__.newObject=function(){var e=We();return Ge(e,!0),e},We=m.__private__.newObjectDeferred=function(){return H++,U[H]=function(){return te},H},Ge=function(e,t){return t=typeof t==`boolean`&&t,U[e]=te,t&&G(e+` 0 obj`),e},Ke=m.__private__.newAdditionalObject=function(){var e={objId:We(),content:``};return ne.push(e),e},qe=We(),Je=We(),Ye=m.__private__.decodeColorString=function(e){var t=e.split(` `);if(t.length!==2||t[1]!==`g`&&t[1]!==`G`)t.length!==5||t[4]!==`k`&&t[4]!==`K`||(t=[(1-t[0])*(1-t[3]),(1-t[1])*(1-t[3]),(1-t[2])*(1-t[3]),`r`]);else{var n=parseFloat(t[0]);t=[n,n,n,`r`]}for(var r=`#`,i=0;i<3;i++)r+=(`0`+Math.floor(255*parseFloat(t[i])).toString(16)).slice(-2);return r},Xe=m.__private__.encodeColorString=function(e){var t;typeof e==`string`&&(e={ch1:e});var r=e.ch1,i=e.ch2,a=e.ch3,o=e.ch4,s=e.pdfColorType===`draw`?[`G`,`RG`,`K`]:[`g`,`rg`,`k`];if(typeof r==`string`&&r.charAt(0)!==`#`){var c=new eo(r);if(c.ok)r=c.toHex();else if(!/^\d*\.?\d*$/.test(r))throw Error(`Invalid color "`+r+`" passed to jsPDF.encodeColorString.`)}if(typeof r==`string`&&/^#[0-9A-Fa-f]{3}$/.test(r)&&(r=`#`+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]),typeof r==`string`&&/^#[0-9A-Fa-f]{6}$/.test(r)){var l=parseInt(r.substr(1),16);r=l>>16&255,i=l>>8&255,a=255&l}if(i===void 0||o===void 0&&r===i&&i===a)t=typeof r==`string`?r+` `+s[0]:e.precision===2?O(r/255)+` `+s[0]:k(r/255)+` `+s[0];else if(o===void 0||n(o)===`object`){if(o&&!isNaN(o.a)&&o.a===0)return[`1.`,`1.`,`1.`,s[1]].join(` `);t=typeof r==`string`?[r,i,a,s[1]].join(` `):e.precision===2?[O(r/255),O(i/255),O(a/255),s[1]].join(` `):[k(r/255),k(i/255),k(a/255),s[1]].join(` `)}else t=typeof r==`string`?[r,i,a,o,s[2]].join(` `):e.precision===2?[O(r),O(i),O(a),O(o),s[2]].join(` `):[k(r),k(i),k(a),k(o),s[2]].join(` `);return t},Ze=m.__private__.getFilters=function(){return s},Qe=m.__private__.putStream=function(e){var t=(e||={}).data||``,n=e.filters||Ze(),r=e.alreadyAppliedFilters||[],i=e.addLength1||!1,a=t.length,o=e.objectId,s=function(e){return e};if(d!==null&&o===void 0)throw Error(`ObjectId must be passed to putStream for file encryption`);d!==null&&(s=Tt.encryptor(o,0));var c={};!0===n&&(n=[`FlateEncode`]);var l=e.additionalKeyValues||[],u=(c=Z.API.processDataByFilters===void 0?{data:t,reverseChain:[]}:Z.API.processDataByFilters(t,n)).reverseChain+(Array.isArray(r)?r.join(` `):r.toString());if(c.data.length!==0&&(l.push({key:`Length`,value:c.data.length}),!0===i&&l.push({key:`Length1`,value:a})),u.length!=0)if(u.split(`/`).length-1==1)l.push({key:`Filter`,value:u});else{l.push({key:`Filter`,value:`[`+u+`]`});for(var f=0;f<l.length;f+=1)if(l[f].key===`DecodeParms`){for(var p=[],m=0;m<c.reverseChain.split(`/`).length-1;m+=1)p.push(`null`);p.push(l[f].value),l[f].value=`[`+p.join(` `)+`]`}}G(`<<`);for(var h=0;h<l.length;h++)G(`/`+l[h].key+` `+l[h].value);G(`>>`),c.data.length!==0&&(G(`stream`),G(s(c.data)),G(`endstream`))},$e=m.__private__.putPage=function(e){var t=e.number,n=e.data,r=e.objId,i=e.contentsObjId;Ge(r,!0),G(`<</Type /Page`),G(`/Parent `+e.rootDictionaryObjId+` 0 R`),G(`/Resources `+e.resourceDictionaryObjId+` 0 R`),G(`/MediaBox [`+parseFloat(T(e.mediaBox.bottomLeftX))+` `+parseFloat(T(e.mediaBox.bottomLeftY))+` `+T(e.mediaBox.topRightX)+` `+T(e.mediaBox.topRightY)+`]`),e.cropBox!==null&&G(`/CropBox [`+T(e.cropBox.bottomLeftX)+` `+T(e.cropBox.bottomLeftY)+` `+T(e.cropBox.topRightX)+` `+T(e.cropBox.topRightY)+`]`),e.bleedBox!==null&&G(`/BleedBox [`+T(e.bleedBox.bottomLeftX)+` `+T(e.bleedBox.bottomLeftY)+` `+T(e.bleedBox.topRightX)+` `+T(e.bleedBox.topRightY)+`]`),e.trimBox!==null&&G(`/TrimBox [`+T(e.trimBox.bottomLeftX)+` `+T(e.trimBox.bottomLeftY)+` `+T(e.trimBox.topRightX)+` `+T(e.trimBox.topRightY)+`]`),e.artBox!==null&&G(`/ArtBox [`+T(e.artBox.bottomLeftX)+` `+T(e.artBox.bottomLeftY)+` `+T(e.artBox.topRightX)+` `+T(e.artBox.topRightY)+`]`),typeof e.userUnit==`number`&&e.userUnit!==1&&G(`/UserUnit `+e.userUnit),Pe.publish(`putPage`,{objId:r,pageContext:K[t],pageNumber:t,page:n}),G(`/Contents `+i+` 0 R`),G(`>>`),G(`endobj`);var a=n.join(`
|
|
5
5
|
`);return x===b&&(a+=`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{$ as t,A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,P as _,Q as v,R as ee,S as te,T as ne,U as re,V as ie,W as ae,X as oe,Y as se,Z as ce,_ as le,_t as ue,a as de,at as fe,b as pe,c as me,ct as he,d as ge,dt as _e,et as y,f as ve,ft as ye,g as be,gt as xe,h as Se,ht as b,i as Ce,it as we,j as Te,k as x,l as Ee,lt as S,m as C,mt as w,n as De,nt as T,o as E,ot as Oe,p as ke,pt as Ae,q as je,r as D,rt as Me,s as Ne,st as O,tt as Pe,u as Fe,ut as Ie,v as Le,w as Re,x as ze,y as Be,z as Ve}from"./index-C69ifb8A.js";var He=class{constructor(e){this.mutex=new se,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,n){if(t+=e.source._timestampOffset,t<0)throw Error(`Timestamps must be non-negative (got ${t}s).`);let r=this.trackTimestampInfo.get(e);if(r){if(n&&(r.maxTimestampBeforeLastKeyPacket=r.maxTimestamp),r.maxTimestampBeforeLastKeyPacket!==null&&t<r.maxTimestampBeforeLastKeyPacket)throw Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${r.maxTimestampBeforeLastKeyPacket}s.`);r.maxTimestamp=Math.max(r.maxTimestamp,t)}else{if(!n)throw Error(`First packet must be a key packet.`);r={maxTimestamp:t,maxTimestampBeforeLastKeyPacket:null},this.trackTimestampInfo.set(e,r)}return t}},Ue=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,We=e=>{let t=Math.floor(e/(3600*1e3)),n=Math.floor(e%(3600*1e3)/(60*1e3)),r=Math.floor(e%(60*1e3)/1e3),i=e%1e3;return t.toString().padStart(2,`0`)+`:`+n.toString().padStart(2,`0`)+`:`+r.toString().padStart(2,`0`)+`.`+i.toString().padStart(3,`0`)},Ge=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.writer.write(this.helper);e.length%8!=0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{let t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let n=this.writer.getPos(),r=e.size??n-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(n)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){let t=this.offsets.get(e);y(t!==void 0);let n=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(n)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(let n of e.children)n&&(t+=this.measureBox(n));return t}}},k=new Uint8Array(8),A=new DataView(k.buffer),j=e=>[(e%256+256)%256],M=e=>(A.setUint16(0,e,!1),[k[0],k[1]]),N=e=>(A.setInt16(0,e,!1),[k[0],k[1]]),Ke=e=>(A.setUint32(0,e,!1),[k[1],k[2],k[3]]),P=e=>(A.setUint32(0,e,!1),[k[0],k[1],k[2],k[3]]),F=e=>(A.setInt32(0,e,!1),[k[0],k[1],k[2],k[3]]),I=e=>(A.setUint32(0,Math.floor(e/2**32),!1),A.setUint32(4,e,!1),[k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7]]),qe=e=>(A.setInt16(0,2**8*e,!1),[k[0],k[1]]),L=e=>(A.setInt32(0,2**16*e,!1),[k[0],k[1],k[2],k[3]]),R=e=>(A.setInt32(0,2**30*e,!1),[k[0],k[1],k[2],k[3]]),Je=(e,t)=>{let n=[],r=e;do{let e=r&127;r>>=7,n.length>0&&(e|=128),n.push(e),t!==void 0&&t--}while(r>0||t);return n.reverse()},z=(e,t=!1)=>{let n=Array(e.length).fill(null).map((t,n)=>e.charCodeAt(n));return t&&n.push(0),n},Ye=e=>{let t=null;for(let n of e)(!t||n.timestamp>t.timestamp)&&(t=n);return t},Xe=e=>{let t=e*(Math.PI/180),n=Math.round(Math.cos(t)),r=Math.round(Math.sin(t));return[n,r,0,-r,n,0,0,0,1]},Ze=Xe(0),Qe=e=>[L(e[0]),L(e[1]),R(e[2]),L(e[3]),L(e[4]),R(e[5]),L(e[6]),L(e[7]),R(e[8])],B=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),V=(e,t,n,r,i)=>B(e,[j(t),Ke(n),r??[]],i),$e=e=>e.isQuickTime?B(`ftyp`,[z(`qt `),P(512),z(`qt `)]):e.fragmented?B(`ftyp`,[z(`iso5`),P(512),z(`iso5`),z(`iso6`),z(`mp41`)]):B(`ftyp`,[z(`isom`),P(512),z(`isom`),e.holdsAvc?z(`avc1`):[],z(`mp41`)]),H=e=>({type:`mdat`,largeSize:e}),et=e=>({type:`free`,size:e}),U=e=>B(`moov`,void 0,[tt(e.creationTime,e.trackDatas),...e.trackDatas.map(t=>nt(t,e.creationTime)),e.isFragmented?zt(e.trackDatas):null,en(e)]),tt=(e,t)=>{let n=Y(Math.max(0,...t.filter(e=>e.samples.length>0).map(e=>{let t=Ye(e.samples);return t.timestamp+t.duration})),bn),r=Math.max(0,...t.map(e=>e.track.id))+1,i=!O(e)||!O(n),a=i?I:P;return V(`mvhd`,+i,0,[a(e),a(e),P(bn),a(n),L(1),qe(1),Array(10).fill(0),Qe(Ze),Array(24).fill(0),P(r)])},nt=(e,t)=>{let n=Sn(e);return B(`trak`,void 0,[rt(e,t),it(e,t),n.name===void 0?null:B(`udta`,void 0,[B(`name`,[...w.encode(n.name)])])])},rt=(e,t)=>{let n=Ye(e.samples),r=Y(n?n.timestamp+n.duration:0,bn),i=!O(t)||!O(r),a=i?I:P,o;if(e.type===`video`){let t=e.track.metadata.rotation;o=Xe(t??0)}else o=Ze;let s=2;return e.track.metadata.disposition?.default!==!1&&(s|=1),V(`tkhd`,+i,s,[a(t),a(t),P(e.track.id),P(0),a(r),Array(8).fill(0),M(0),M(e.track.id),qe(e.type===`audio`?1:0),M(0),Qe(o),L(e.type===`video`?e.info.width:0),L(e.type===`video`?e.info.height:0)])},it=(e,t)=>B(`mdia`,void 0,[at(e,t),ct(!0,ot[e.type],st[e.type]),lt(e)]),at=(e,t)=>{let n=Ye(e.samples),r=Y(n?n.timestamp+n.duration:0,e.timescale),i=!O(t)||!O(r),a=i?I:P;return V(`mdhd`,+i,0,[a(t),a(t),P(e.timescale),a(r),M(pn(e.track.metadata.languageCode??`und`)),M(0)])},ot={video:`vide`,audio:`soun`,subtitle:`text`},st={video:`MediabunnyVideoHandler`,audio:`MediabunnySoundHandler`,subtitle:`MediabunnyTextHandler`},ct=(e,t,n,r=`\0\0\0\0`)=>V(`hdlr`,0,0,[e?z(`mhlr`):P(0),z(t),z(r),P(0),P(0),z(n,!0)]),lt=e=>B(`minf`,void 0,[ut[e.type](),dt(),mt(e)]),ut={video:()=>V(`vmhd`,0,1,[M(0),M(0),M(0),M(0)]),audio:()=>V(`smhd`,0,0,[M(0),M(0)]),subtitle:()=>V(`nmhd`,0,0)},dt=()=>B(`dinf`,void 0,[ft()]),ft=()=>V(`dref`,0,0,[P(1)],[pt()]),pt=()=>V(`url `,0,1),mt=e=>{let t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>e.sampleCompositionTimeOffset!==0);return B(`stbl`,void 0,[ht(e),Mt(e),t?Lt(e):null,t?Rt(e):null,Pt(e),Ft(e),It(e),Nt(e)])},ht=e=>{let t;if(e.type===`video`)t=gt(sn(e.track.source._codec,e.info.decoderConfig.codec),e);else if(e.type===`audio`){let n=ln(e.track.source._codec,e.muxer.isQuickTime);y(n),t=Ct(n,e)}else e.type===`subtitle`&&(t=At(dn[e.track.source._codec],e));return y(t),V(`stsd`,0,0,[P(1)],[t])},gt=(e,t)=>B(e,[[,,,,,,].fill(0),M(1),M(0),M(0),Array(12).fill(0),M(t.info.width),M(t.info.height),P(4718592),P(4718592),P(0),M(1),Array(32).fill(0),M(24),N(65535)],[cn[t.track.source._codec](t),_t(t),Me(t.info.decoderConfig.colorSpace)?vt(t):null]),_t=e=>e.info.pixelAspectRatio.num===e.info.pixelAspectRatio.den?null:B(`pasp`,[P(e.info.pixelAspectRatio.num),P(e.info.pixelAspectRatio.den)]),vt=e=>B(`colr`,[z(`nclx`),M(oe[e.info.decoderConfig.colorSpace.primaries]),M(t[e.info.decoderConfig.colorSpace.transfer]),M(v[e.info.decoderConfig.colorSpace.matrix]),j((e.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),yt=e=>e.info.decoderConfig&&B(`avcC`,[...b(e.info.decoderConfig.description)]),bt=e=>e.info.decoderConfig&&B(`hvcC`,[...b(e.info.decoderConfig.description)]),xt=e=>{if(!e.info.decoderConfig)return null;let n=e.info.decoderConfig,r=n.codec.split(`.`),i=Number(r[1]),a=Number(r[2]),o=Number(r[3]),s=r[4]?Number(r[4]):1,c=r[8]?Number(r[8]):Number(n.colorSpace?.fullRange??0),l=(o<<4)+(s<<1)+c,u=r[5]?Number(r[5]):n.colorSpace?.primaries?oe[n.colorSpace.primaries]:2,d=r[6]?Number(r[6]):n.colorSpace?.transfer?t[n.colorSpace.transfer]:2,f=r[7]?Number(r[7]):n.colorSpace?.matrix?v[n.colorSpace.matrix]:2;return V(`vpcC`,1,0,[j(i),j(a),j(l),j(u),j(d),j(f),M(0)])},St=e=>B(`av1C`,h(e.info.decoderConfig.codec)),Ct=(e,t)=>{let n=0,r,i=16,a=g.includes(t.track.source._codec);if(a){let e=t.track.source._codec,{sampleSize:r}=p(e);i=8*r,i>16&&(n=1)}if(t.muxer.isQuickTime&&(n=1),n===0)r=[[,,,,,,].fill(0),M(1),M(n),M(0),P(0),M(t.info.numberOfChannels),M(i),M(0),M(0),M(t.info.sampleRate<2**16?t.info.sampleRate:0),M(0)];else{let e=a?0:-2;r=[[,,,,,,].fill(0),M(1),M(n),M(0),P(0),M(t.info.numberOfChannels),M(Math.min(i,16)),N(e),M(0),M(t.info.sampleRate<2**16?t.info.sampleRate:0),M(0),a?[P(1),P(i/8),P(t.info.numberOfChannels*i/8)]:[P(0),P(0),P(0)],P(2)]}return B(e,r,[un(t.track.source._codec,t.muxer.isQuickTime)?.(t)??null])},W=e=>{let t;switch(e.track.source._codec){case`aac`:t=64;break;case`mp3`:t=107;break;case`vorbis`:t=221;break;default:throw Error(`Unhandled audio codec: ${e.track.source._codec}`)}let n=[...j(t),...j(21),...Ke(0),...P(0),...P(0)];if(e.info.decoderConfig.description){let t=b(e.info.decoderConfig.description);n=[...n,...j(5),...Je(t.byteLength),...t]}return n=[...M(1),...j(0),...j(4),...Je(n.length),...n,...j(6),...j(1),...j(2)],n=[...j(3),...Je(n.length),...n],V(`esds`,0,0,n)},G=e=>B(`wave`,void 0,[wt(e),Tt(e),B(`\0\0\0\0`)]),wt=e=>B(`frma`,[z(ln(e.track.source._codec,e.muxer.isQuickTime))]),Tt=e=>{let{littleEndian:t}=p(e.track.source._codec);return B(`enda`,[M(+t)])},Et=e=>{let t=e.info.numberOfChannels,n=3840,r=e.info.sampleRate,a=0,o=0,s=new Uint8Array,c=e.info.decoderConfig?.description;if(c){y(c.byteLength>=18);let e=i(b(c));t=e.outputChannelCount,n=e.preSkip,r=e.inputSampleRate,a=e.outputGain,o=e.channelMappingFamily,e.channelMappingTable&&(s=e.channelMappingTable)}return B(`dOps`,[j(0),j(t),M(n),P(r),N(a),j(o),...s])},Dt=e=>{let t=e.info.decoderConfig?.description;return y(t),V(`dfLa`,0,0,[...b(t).subarray(4)])},K=e=>{let{littleEndian:t,sampleSize:n}=p(e.track.source._codec);return V(`pcmC`,0,0,[j(+t),j(8*n)])},Ot=e=>{let t=ze(e.info.firstPacket.data);if(!t)throw Error(`Couldn't extract AC-3 frame info from the audio packet. Ensure the packets contain valid AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=new Uint8Array(3),r=new c(n);return r.writeBits(2,t.fscod),r.writeBits(5,t.bsid),r.writeBits(3,t.bsmod),r.writeBits(3,t.acmod),r.writeBits(1,t.lfeon),r.writeBits(5,t.bitRateCode),r.writeBits(5,0),B(`dac3`,[...n])},kt=e=>{let t=te(e.info.firstPacket.data);if(!t)throw Error(`Couldn't extract E-AC-3 frame info from the audio packet. Ensure the packets contain valid E-AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=16;for(let e of t.substreams)n+=23,e.numDepSub>0?n+=9:n+=1;let r=Math.ceil(n/8),i=new Uint8Array(r),a=new c(i);a.writeBits(13,t.dataRate),a.writeBits(3,t.substreams.length-1);for(let e of t.substreams)a.writeBits(2,e.fscod),a.writeBits(5,e.bsid),a.writeBits(1,0),a.writeBits(1,0),a.writeBits(3,e.bsmod),a.writeBits(3,e.acmod),a.writeBits(1,e.lfeon),a.writeBits(3,0),a.writeBits(4,e.numDepSub),e.numDepSub>0?a.writeBits(9,e.chanLoc):a.writeBits(1,0);return B(`dec3`,[...i])},At=(e,t)=>B(e,[[,,,,,,].fill(0),M(1)],[fn[t.track.source._codec](t)]),jt=e=>B(`vttC`,[...w.encode(e.info.config.description)]),Mt=e=>V(`stts`,0,0,[P(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[P(e.sampleCount),P(e.sampleDelta)])]),Nt=e=>{if(e.samples.every(e=>e.type===`key`))return null;let t=[...e.samples.entries()].filter(([,e])=>e.type===`key`);return V(`stss`,0,0,[P(t.length),t.map(([e])=>P(e+1))])},Pt=e=>V(`stsc`,0,0,[P(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[P(e.firstChunk),P(e.samplesPerChunk),P(1)])]),Ft=e=>{if(e.type===`audio`&&e.info.requiresPcmTransformation){let{sampleSize:t}=p(e.track.source._codec);return V(`stsz`,0,0,[P(t*e.info.numberOfChannels),P(e.samples.reduce((t,n)=>t+Y(n.duration,e.timescale),0))])}return V(`stsz`,0,0,[P(0),P(e.samples.length),e.samples.map(e=>P(e.size))])},It=e=>e.finalizedChunks.length>0&&S(e.finalizedChunks).offset>=2**32?V(`co64`,0,0,[P(e.finalizedChunks.length),e.finalizedChunks.map(e=>I(e.offset))]):V(`stco`,0,0,[P(e.finalizedChunks.length),e.finalizedChunks.map(e=>P(e.offset))]),Lt=e=>V(`ctts`,1,0,[P(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>[P(e.sampleCount),F(e.sampleCompositionTimeOffset)])]),Rt=e=>{let t=1/0,n=-1/0,r=1/0,i=-1/0;y(e.compositionTimeOffsetTable.length>0),y(e.samples.length>0);for(let r=0;r<e.compositionTimeOffsetTable.length;r++){let i=e.compositionTimeOffsetTable[r];t=Math.min(t,i.sampleCompositionTimeOffset),n=Math.max(n,i.sampleCompositionTimeOffset)}for(let t=0;t<e.samples.length;t++){let n=e.samples[t];r=Math.min(r,Y(n.timestamp,e.timescale)),i=Math.max(i,Y(n.timestamp+n.duration,e.timescale))}let a=Math.max(-t,0);return i>=2**31?null:V(`cslg`,0,0,[F(a),F(t),F(n),F(r),F(i)])},zt=e=>B(`mvex`,void 0,e.map(Bt)),Bt=e=>V(`trex`,0,0,[P(e.track.id),P(1),P(0),P(0),P(0)]),Vt=(e,t)=>B(`moof`,void 0,[Ht(e),...t.map(Wt)]),Ht=e=>V(`mfhd`,0,0,[P(e)]),Ut=e=>{let t=0,n=0,r=e.type===`delta`;return n|=+r,r?t|=1:t|=2,t<<24|n<<16|0},Wt=e=>B(`traf`,void 0,[Gt(e),Kt(e),qt(e)]),Gt=e=>{y(e.currentChunk);let t=0;t|=8,t|=16,t|=32,t|=131072;let n=e.currentChunk.samples[1]??e.currentChunk.samples[0],r={duration:n.timescaleUnitsToNextSample,size:n.size,flags:Ut(n)};return V(`tfhd`,0,t,[P(e.track.id),P(r.duration),P(r.size),P(r.flags)])},Kt=e=>(y(e.currentChunk),V(`tfdt`,1,0,[I(Y(e.currentChunk.startTimestamp,e.timescale))])),qt=e=>{y(e.currentChunk);let t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),n=e.currentChunk.samples.map(e=>e.size),r=e.currentChunk.samples.map(Ut),i=e.currentChunk.samples.map(t=>Y(t.timestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),o=new Set(n),s=new Set(r),c=new Set(i),l=s.size===2&&r[0]!==r[1],u=a.size>1,d=o.size>1,f=!l&&s.size>1,p=c.size>1||[...c].some(e=>e!==0),m=0;return m|=1,m|=4*l,m|=256*u,m|=512*d,m|=1024*f,m|=2048*p,V(`trun`,1,m,[P(e.currentChunk.samples.length),P(e.currentChunk.offset-e.currentChunk.moofOffset||0),l?P(r[0]):[],e.currentChunk.samples.map((e,a)=>[u?P(t[a]):[],d?P(n[a]):[],f?P(r[a]):[],p?F(i[a]):[]])])},Jt=e=>B(`mfra`,void 0,[...e.map(Yt),Xt()]),Yt=(e,t)=>V(`tfra`,1,0,[P(e.track.id),P(63),P(e.finalizedChunks.length),e.finalizedChunks.map(n=>[I(Y(n.samples[0].timestamp,e.timescale)),I(n.moofOffset),P(t+1),P(1),P(1)])]),Xt=()=>V(`mfro`,0,0,[P(0)]),Zt=()=>B(`vtte`),Qt=(e,t,n,r,i)=>B(`vttc`,void 0,[i===null?null:B(`vsid`,[F(i)]),n===null?null:B(`iden`,[...w.encode(n)]),t===null?null:B(`ctim`,[...w.encode(We(t))]),r===null?null:B(`sttg`,[...w.encode(r)]),B(`payl`,[...w.encode(e)])]),$t=e=>B(`vtta`,[...w.encode(e)]),en=e=>{let t=[],n=e.format._options.metadataFormat??`auto`,r=e.output._metadataTags;if(n===`mdir`||n===`auto`&&!e.isQuickTime){let e=an(r);e&&t.push(e)}else if(n===`mdta`){let e=on(r);e&&t.push(e)}else (n===`udta`||n===`auto`&&e.isQuickTime)&&tn(t,e.output._metadataTags);return t.length===0?null:B(`udta`,void 0,t)},tn=(e,t)=>{for(let{key:n,value:r}of he(t))switch(n){case`title`:e.push(q(`©nam`,r));break;case`description`:e.push(q(`©des`,r));break;case`artist`:e.push(q(`©ART`,r));break;case`album`:e.push(q(`©alb`,r));break;case`albumArtist`:e.push(q(`albr`,r));break;case`genre`:e.push(q(`©gen`,r));break;case`date`:e.push(q(`©day`,r.toISOString().slice(0,10)));break;case`comment`:e.push(q(`©cmt`,r));break;case`lyrics`:e.push(q(`©lyr`,r));break;case`raw`:break;case`discNumber`:case`discsTotal`:case`trackNumber`:case`tracksTotal`:case`images`:break;default:Pe(n)}if(t.raw)for(let n in t.raw){let r=t.raw[n];r==null||n.length!==4||e.some(e=>e.type===n)||(typeof r==`string`?e.push(q(n,r)):r instanceof Uint8Array&&e.push(B(n,Array.from(r))))}},q=(e,t)=>{let n=w.encode(t);return B(e,[M(n.length),M(pn(`und`)),Array.from(n)])},nn={"image/jpeg":13,"image/png":14,"image/bmp":27},rn=(e,t)=>{let n=[];for(let{key:r,value:i}of he(e))switch(r){case`title`:n.push({key:t?`title`:`©nam`,value:J(i)});break;case`description`:n.push({key:t?`description`:`©des`,value:J(i)});break;case`artist`:n.push({key:t?`artist`:`©ART`,value:J(i)});break;case`album`:n.push({key:t?`album`:`©alb`,value:J(i)});break;case`albumArtist`:n.push({key:t?`album_artist`:`aART`,value:J(i)});break;case`comment`:n.push({key:t?`comment`:`©cmt`,value:J(i)});break;case`genre`:n.push({key:t?`genre`:`©gen`,value:J(i)});break;case`lyrics`:n.push({key:t?`lyrics`:`©lyr`,value:J(i)});break;case`date`:n.push({key:t?`date`:`©day`,value:J(i.toISOString().slice(0,10))});break;case`images`:for(let e of i)e.kind===`coverFront`&&n.push({key:`covr`,value:B(`data`,[P(nn[e.mimeType]??0),P(0),Array.from(e.data)])});break;case`trackNumber`:if(t){let t=e.tracksTotal===void 0?i.toString():`${i}/${e.tracksTotal}`;n.push({key:`track`,value:J(t)})}else n.push({key:`trkn`,value:B(`data`,[P(0),P(0),M(0),M(i),M(e.tracksTotal??0),M(0)])});break;case`discNumber`:t||n.push({key:`disc`,value:B(`data`,[P(0),P(0),M(0),M(i),M(e.discsTotal??0),M(0)])});break;case`tracksTotal`:case`discsTotal`:break;case`raw`:break;default:Pe(r)}if(e.raw)for(let r in e.raw){let i=e.raw[r];i==null||!t&&r.length!==4||n.some(e=>e.key===r)||(typeof i==`string`?n.push({key:r,value:J(i)}):i instanceof Uint8Array?n.push({key:r,value:B(`data`,[P(0),P(0),Array.from(i)])}):i instanceof f&&n.push({key:r,value:B(`data`,[P(nn[i.mimeType]??0),P(0),Array.from(i.data)])}))}return n},an=e=>{let t=rn(e,!1);return t.length===0?null:V(`meta`,0,0,void 0,[ct(!1,`mdir`,``,`appl`),B(`ilst`,void 0,t.map(e=>B(e.key,void 0,[e.value])))])},on=e=>{let t=rn(e,!0);return t.length===0?null:B(`meta`,void 0,[ct(!1,`mdta`,``),V(`keys`,0,0,[P(t.length)],t.map(e=>B(`mdta`,[...w.encode(e.key)]))),B(`ilst`,void 0,t.map((e,t)=>B(String.fromCharCode(...P(t+1)),void 0,[e.value])))])},J=e=>B(`data`,[P(1),P(0),...w.encode(e)]),sn=(e,t)=>{switch(e){case`avc`:return t.startsWith(`avc3`)?`avc3`:`avc1`;case`hevc`:return`hvc1`;case`vp8`:return`vp08`;case`vp9`:return`vp09`;case`av1`:return`av01`}},cn={avc:yt,hevc:bt,vp8:xt,vp9:xt,av1:St},ln=(e,t)=>{switch(e){case`aac`:return`mp4a`;case`mp3`:return`mp4a`;case`opus`:return`Opus`;case`vorbis`:return`mp4a`;case`flac`:return`fLaC`;case`ulaw`:return`ulaw`;case`alaw`:return`alaw`;case`pcm-u8`:return`raw `;case`pcm-s8`:return`sowt`;case`ac3`:return`ac-3`;case`eac3`:return`ec-3`}if(t)switch(e){case`pcm-s16`:return`sowt`;case`pcm-s16be`:return`twos`;case`pcm-s24`:return`in24`;case`pcm-s24be`:return`in24`;case`pcm-s32`:return`in32`;case`pcm-s32be`:return`in32`;case`pcm-f32`:return`fl32`;case`pcm-f32be`:return`fl32`;case`pcm-f64`:return`fl64`;case`pcm-f64be`:return`fl64`}else switch(e){case`pcm-s16`:return`ipcm`;case`pcm-s16be`:return`ipcm`;case`pcm-s24`:return`ipcm`;case`pcm-s24be`:return`ipcm`;case`pcm-s32`:return`ipcm`;case`pcm-s32be`:return`ipcm`;case`pcm-f32`:return`fpcm`;case`pcm-f32be`:return`fpcm`;case`pcm-f64`:return`fpcm`;case`pcm-f64be`:return`fpcm`}},un=(e,t)=>{switch(e){case`aac`:return W;case`mp3`:return W;case`opus`:return Et;case`vorbis`:return W;case`flac`:return Dt;case`ac3`:return Ot;case`eac3`:return kt}if(t)switch(e){case`pcm-s24`:return G;case`pcm-s24be`:return G;case`pcm-s32`:return G;case`pcm-s32be`:return G;case`pcm-f32`:return G;case`pcm-f32be`:return G;case`pcm-f64`:return G;case`pcm-f64be`:return G}else switch(e){case`pcm-s16`:return K;case`pcm-s16be`:return K;case`pcm-s24`:return K;case`pcm-s24be`:return K;case`pcm-s32`:return K;case`pcm-s32be`:return K;case`pcm-f32`:return K;case`pcm-f32be`:return K;case`pcm-f64`:return K;case`pcm-f64be`:return K}return null},dn={webvtt:`wvtt`},fn={webvtt:jt},pn=e=>{y(e.length===3);let t=0;for(let n=0;n<3;n++)t<<=5,t+=e.charCodeAt(n)-96;return t},mn=class{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}let n=t+e.byteLength-this.trackedStart,r=this.trackedWrites.byteLength;for(;r<n;)r*=2;if(r!==this.trackedWrites.byteLength){let e=new Uint8Array(r);e.set(this.trackedWrites,0),this.trackedWrites=e}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw Error(`Internal error: Can't get tracked writes since nothing was tracked.`);let e={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,e}},hn=2**16,gn=2**32,_n=class extends mn{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize=`resize`in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(hn,{maxByteLength:gn})}catch{this.buffer=new ArrayBuffer(hn),this.supportsResize=!1}else this.buffer=new ArrayBuffer(hn);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>gn)throw Error(`ArrayBuffer exceeded maximum size of ${gn} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{let e=new ArrayBuffer(t),n=new Uint8Array(e);n.set(this.bytes,0),this.buffer=e,this.bytes=n}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}};e(xe(),1);var vn=class{constructor(){this._output=null,this.onwrite=null}},yn=class extends vn{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new _n(this)}},bn=1e3,xn=2082844800,Sn=e=>{let t={},n=e.track;return n.metadata.name!==void 0&&(t.name=n.metadata.name),t},Y=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},Cn=class extends He{constructor(e,t){super(e),this.auxTarget=new yn,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new Ge(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=Ie(),this.creationTime=Math.floor(Date.now()/1e3)+xn,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new Ge(this.writer),this.isQuickTime=t instanceof Dn;let n=this.writer instanceof _n?`in-memory`:!1;this.fastStart=t._options.fastStart??n,this.isFragmented=this.fastStart===`fragmented`,(this.fastStart===`in-memory`||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){let e=await this.mutex.acquire(),t=this.output._tracks.some(e=>e.type===`video`&&e.source._codec===`avc`);if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox($e({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onFtyp(e,t)}if(this.ftypSize=this.writer.getPos(),this.fastStart!==`in-memory`)if(this.fastStart===`reserve`){for(let e of this.output._tracks)if(e.metadata.maximumPacketCount===void 0)throw Error(`All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.`)}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=H(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(let e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return me({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let i=this.trackDatas.find(t=>t.track===e);if(i)return i;r(n),y(n),y(n.decoderConfig);let a={...n.decoderConfig};y(a.codedWidth!==void 0),y(a.codedHeight!==void 0);let o=!1;if(e.source._codec===`avc`&&!a.description){let e=Le(t.data);if(!e)throw Error(`Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.`);a.description=Re(e),o=!0}else if(e.source._codec===`hevc`&&!a.description){let e=Be(t.data);if(!e)throw Error(`Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.`);a.description=ne(e),o=!0}let s=we(1/(e.metadata.frameRate??57600),1e6).denominator,c=a.displayAspectWidth,l=a.displayAspectHeight,u=c===void 0||l===void 0?{num:1,den:1}:Ae({num:c*a.codedHeight,den:l*a.codedWidth}),d={muxer:this,track:e,type:`video`,info:{width:a.codedWidth,height:a.codedHeight,pixelAspectRatio:u,decoderConfig:a,requiresAnnexBTransformation:o},timescale:s,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(d),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),d}getAudioTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;ee(n),y(n),y(n.decoderConfig);let i={...n.decoderConfig},a=!1;if(e.source._codec===`aac`&&!i.description){let e=Ne(De.tempFromBytes(t.data));if(!e)throw Error(`Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.`);let n=l[e.samplingFrequencyIndex],r=ie[e.channelConfiguration];if(n===void 0||r===void 0)throw Error(`Invalid ADTS frame header.`);i.description=re({objectType:e.objectType,sampleRate:n,numberOfChannels:r}),a=!0}let o={muxer:this,track:e,type:`audio`,info:{numberOfChannels:n.decoderConfig.numberOfChannels,sampleRate:n.decoderConfig.sampleRate,decoderConfig:i,requiresPcmTransformation:!this.isFragmented&&g.includes(e.source._codec),requiresAdtsStripping:a,firstPacket:t},timescale:i.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;Ve(t),y(t),y(t.config);let r={muxer:this,track:e,type:`subtitle`,info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n),i=t.data;if(r.info.requiresAnnexBTransformation){let e=[...pe(i)].map(e=>i.subarray(e.offset,e.offset+e.length));if(e.length===0)throw Error(`Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.`);i=le(e,4)}let a=this.validateAndNormalizeTimestamp(r.track,t.timestamp,t.type===`key`),o=this.createSampleForTrack(r,i,a,t.duration,t.type);await this.registerSample(r,o)}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,t,n),i=t.data;if(r.info.requiresAdtsStripping){let e=Ne(De.tempFromBytes(i));if(!e)throw Error(`Expected ADTS frame, didn't get one.`);let t=e.crcCheck===null?7:9;i=i.subarray(t)}let a=this.validateAndNormalizeTimestamp(r.track,t.timestamp,t.type===`key`),o=this.createSampleForTrack(r,i,a,t.duration,t.type);r.info.requiresPcmTransformation&&await this.maybePadWithSilence(r,a),await this.registerSample(r,o)}finally{r()}}async maybePadWithSilence(e,t){let n=S(e.samples),r=n?n.timestamp+n.duration:0,i=t-r,a=Y(i,e.timescale);if(a>0){let{sampleSize:t,silentValue:n}=p(e.info.decoderConfig.codec),o=a*e.info.numberOfChannels,s=new Uint8Array(t*o).fill(n),c=this.createSampleForTrack(e,new Uint8Array(s.buffer),r,i,`key`);await this.registerSample(e,c)}}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateAndNormalizeTimestamp(r.track,t.timestamp,!0),e.source._codec===`webvtt`&&(r.cueQueue.push(t),await this.processWebVTTCues(r,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){let n=new Set([]);for(let r of e.cueQueue)y(r.timestamp<=t),y(e.lastCueEndTimestamp<=r.timestamp+r.duration),n.add(Math.max(r.timestamp,e.lastCueEndTimestamp)),n.add(r.timestamp+r.duration);let r=[...n].sort((e,t)=>e-t),i=r[0],a=r[1]??i;if(t<a)break;if(e.lastCueEndTimestamp<i){this.auxWriter.seek(0);let t=Zt();this.auxBoxWriter.writeBox(t);let n=this.auxWriter.getSlice(0,this.auxWriter.getPos()),r=this.createSampleForTrack(e,n,e.lastCueEndTimestamp,i-e.lastCueEndTimestamp,`key`);await this.registerSample(e,r),e.lastCueEndTimestamp=i}this.auxWriter.seek(0);for(let t=0;t<e.cueQueue.length;t++){let n=e.cueQueue[t];if(n.timestamp>=a)break;Ue.lastIndex=0;let r=Ue.test(n.text),o=n.timestamp+n.duration,s=e.cueToSourceId.get(n);if(s===void 0&&a<o&&(s=e.nextSourceId++,e.cueToSourceId.set(n,s)),n.notes){let e=$t(n.notes);this.auxBoxWriter.writeBox(e)}let c=Qt(n.text,r?i:null,n.identifier??null,n.settings??null,s??null);this.auxBoxWriter.writeBox(c),o===a&&e.cueQueue.splice(t--,1)}let o=this.auxWriter.getSlice(0,this.auxWriter.getPos()),s=this.createSampleForTrack(e,o,i,a-i,`key`);await this.registerSample(e,s),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,n,r,i){return{timestamp:n,decodeTimestamp:n,duration:r,data:t,size:t.byteLength,type:i,timescaleUnitsToNextSample:Y(r,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type===`audio`&&e.info.requiresPcmTransformation){let t=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){let r=e.timestampProcessingQueue[n],i=Y(r.duration,e.timescale);t+=i}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:t,sampleDelta:1});else{let n=S(e.timeToSampleTable);n.sampleCount+=t}e.timestampProcessingQueue.length=0;return}let n=e.timestampProcessingQueue.map(e=>e.timestamp).sort((e,t)=>e-t);for(let t=0;t<e.timestampProcessingQueue.length;t++){let r=e.timestampProcessingQueue[t];r.decodeTimestamp=n[t],!this.isFragmented&&e.lastTimescaleUnits===null&&(r.decodeTimestamp=0);let i=Y(r.timestamp-r.decodeTimestamp,e.timescale),a=Y(r.duration,e.timescale);if(e.lastTimescaleUnits!==null){y(e.lastSample);let t=Y(r.decodeTimestamp,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);if(y(n>=0),e.lastTimescaleUnits+=n,e.lastSample.timescaleUnitsToNextSample=n,!this.isFragmented){let t=S(e.timeToSampleTable);if(y(t),t.sampleCount===1){t.sampleDelta=n;let r=e.timeToSampleTable[e.timeToSampleTable.length-2];r&&r.sampleDelta===n&&(r.sampleCount++,e.timeToSampleTable.pop(),t=r)}else t.sampleDelta!==n&&(t.sampleCount--,e.timeToSampleTable.push(t={sampleCount:1,sampleDelta:n}));t.sampleDelta===a?t.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});let r=S(e.compositionTimeOffsetTable);y(r),r.sampleCompositionTimeOffset===i?r.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i})}}else e.lastTimescaleUnits=Y(r.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i}));e.lastSample=r}if(e.timestampProcessingQueue.length=0,y(e.lastSample),y(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){y(t.type===`key`);let n=Y(t.timestamp,e.timescale,!1),r=Math.round(n-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=r}}async registerSample(e,t){t.type===`key`&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart===`reserve`?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart===`reserve`)){let t=e.track.metadata.maximumPacketCount;if(y(t!==void 0),e.samples.length>t)throw Error(`Track #${e.track.id} has already reached the maximum packet count (${t}). Either add less packets or increase the maximum packet count.`)}let n=!1;if(!e.currentChunk)n=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);let r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){let i=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.sampleQueue[0];return r?r.type===`key`:n.track.source._closed});r>=this.minimumFragmentDuration&&i&&t.timestamp>this.maxWrittenTimestamp&&(n=!0,await this.finalizeFragment())}else n=r>=.5}n&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),y(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if(y(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type===`audio`&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((t,n)=>t+Y(n.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||S(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart===`in-memory`){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(let t of e.currentChunk.samples)y(t.data),this.writer.write(t.data),t.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if(y(this.isFragmented),!(!e&&!this.allTracksAreKnown()))outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.sampleQueue.length===0&&!r.track.source._closed)break outer;r.sampleQueue.length>0&&r.sampleQueue[0].timestamp<n&&(t=r,n=r.sampleQueue[0].timestamp)}if(!t)break;let r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}async finalizeFragment(e=!0){y(this.isFragmented);let t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();let e=U(this);if(this.boxWriter.writeBox(e),this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}let n=this.trackDatas.filter(e=>e.currentChunk),r=Vt(t,n),i=this.writer.getPos(),a=i+this.boxWriter.measureBox(r),o=a+8,s=1/0;for(let e of n){e.currentChunk.offset=o,e.currentChunk.moofOffset=i;for(let t of e.currentChunk.samples)o+=t.size;s=Math.min(s,e.currentChunk.startTimestamp)}let c=o-a,l=c>=2**32;if(l)for(let e of n)e.currentChunk.offset+=8;this.format._options.onMoof&&this.writer.startTrackingWrites();let u=Vt(t,n);if(this.boxWriter.writeBox(u),this.format._options.onMoof){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoof(e,t,s)}y(this.writer.getPos()===a),this.format._options.onMdat&&this.writer.startTrackingWrites();let d=H(l);d.size=c,this.boxWriter.writeBox(d),this.writer.seek(a+(l?16:8));for(let e of n)for(let t of e.currentChunk.samples)this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}for(let e of n)e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk),e.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){let e=U(this),t=this.boxWriter.measureBox(e)+this.computeSampleTableSizeUpperBound()+4096;y(this.ftypSize!==null),this.writer.seek(this.ftypSize+t),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=H(!0),this.boxWriter.writeBox(this.mdat);for(let e of this.trackDatas){for(let t of e.sampleQueue)await this.addSampleToTrack(e,t);e.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){y(this.fastStart===`reserve`);let e=0;for(let t of this.trackDatas){let n=t.track.metadata.maximumPacketCount;y(n!==void 0),e+=8*Math.ceil(2/3*n),e+=4*n,e+=8*Math.ceil(2/3*n),e+=12*Math.ceil(2/3*n),e+=4*n,e+=8*n}return e}async onTrackClose(e){let t=await this.mutex.acquire(),n=this.trackDatas.find(t=>t.track===e);n&&(n.type===`subtitle`&&e.source._codec===`webvtt`&&await this.processWebVTTCues(n,1/0),this.processTimestamps(n)),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve();for(let e of this.trackDatas)e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);if(this.isFragmented)await this.interleaveSamples(!0),await this.finalizeFragment(!1);else for(let e of this.trackDatas)await this.finalizeCurrentChunk(e);if(this.fastStart===`in-memory`){this.mdat=H(!1);let e;for(let t=0;t<2;t++){let t=U(this),n=this.boxWriter.measureBox(t);e=this.boxWriter.measureBox(this.mdat);let r=this.writer.getPos()+n+e;for(let t of this.finalizedChunks){t.offset=r;for(let{data:n}of t.samples)y(n),r+=n.byteLength,e+=n.byteLength}if(r<2**32)break;e>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();let t=U(this);if(this.boxWriter.writeBox(t),this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=e,this.boxWriter.writeBox(this.mdat);for(let e of this.finalizedChunks)for(let t of e.samples)y(t.data),this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}}else if(this.isFragmented){let e=this.writer.getPos(),t=Jt(this.trackDatas);this.boxWriter.writeBox(t);let n=this.writer.getPos()-e;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(n)}else{y(this.mdat);let e=this.boxWriter.offsets.get(this.mdat);y(e!==void 0);let t=this.writer.getPos()-e;if(this.mdat.size=t,this.mdat.largeSize=t>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}let n=U(this);if(this.fastStart===`reserve`){y(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);let e=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(et(e))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);if(this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}e()}},wn=class{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>n.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>o.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>x.includes(e))}_codecUnsupportedHint(e){return``}},Tn=class extends wn{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.fastStart!==void 0&&![!1,`in-memory`,`reserve`,`fragmented`].includes(e.fastStart))throw TypeError(`options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.`);if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw TypeError(`options.minimumFragmentDuration, when provided, must be a non-negative number.`);if(e.onFtyp!==void 0&&typeof e.onFtyp!=`function`)throw TypeError(`options.onFtyp, when provided, must be a function.`);if(e.onMoov!==void 0&&typeof e.onMoov!=`function`)throw TypeError(`options.onMoov, when provided, must be a function.`);if(e.onMdat!==void 0&&typeof e.onMdat!=`function`)throw TypeError(`options.onMdat, when provided, must be a function.`);if(e.onMoof!==void 0&&typeof e.onMoof!=`function`)throw TypeError(`options.onMoof, when provided, must be a function.`);if(e.metadataFormat!==void 0&&![`mdir`,`mdta`,`udta`,`auto`].includes(e.metadataFormat))throw TypeError(`options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.`);super(),this._options=e}getSupportedTrackCounts(){let e=2**32-1;return{video:{min:0,max:e},audio:{min:0,max:e},subtitle:{min:0,max:e},total:{min:1,max:e}}}get supportsVideoRotationMetadata(){return!0}get supportsTimestampedMediaData(){return!0}_createMuxer(e){return new Cn(e,this)}},En=class extends Tn{constructor(e){super(e)}get _name(){return`MP4`}get fileExtension(){return`.mp4`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...n,...a,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...x]}_codecUnsupportedHint(e){return new Dn().getSupportedCodecs().includes(e)?` Switching to MOV will grant support for this codec.`:``}},Dn=class extends Tn{constructor(e){super(e)}get _name(){return`MOV`}get fileExtension(){return`.mov`}get mimeType(){return`video/quicktime`}getSupportedCodecs(){return[...n,...o]}_codecUnsupportedHint(e){return new En().getSupportedCodecs().includes(e)?` Switching to MP4 will grant support for this codec.`:``}},On=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!n.includes(e.codec))throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${n.join(`, `)}.`);if(!(e.bitrate instanceof X)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate must be a positive integer or a quality.`);if(e.keyFrameInterval!==void 0&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw TypeError(`config.keyFrameInterval, when provided, must be a non-negative number.`);if(e.sizeChangeBehavior!==void 0&&![`deny`,`passThrough`,`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.`);if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedChunk, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);kn(e.codec,e)},kn=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.alpha!==void 0&&![`discard`,`keep`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'discard' or 'keep'.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.latencyMode!==void 0&&![`quality`,`realtime`].includes(t.latencyMode))throw TypeError(`latencyMode, when provided, must be 'quality' or 'realtime'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&u(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(t.hardwareAcceleration!==void 0&&![`no-preference`,`prefer-hardware`,`prefer-software`].includes(t.hardwareAcceleration))throw TypeError(`hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.`);if(t.scalabilityMode!==void 0&&typeof t.scalabilityMode!=`string`)throw TypeError(`scalabilityMode, when provided, must be a string.`);if(t.contentHint!==void 0&&typeof t.contentHint!=`string`)throw TypeError(`contentHint, when provided, must be a string.`)},An=e=>{let t=e.bitrate instanceof X?e.bitrate._toVideoBitrate(e.codec,e.width,e.height):e.bitrate;return{codec:e.fullCodecString??m(e.codec,e.width,e.height,t),width:e.width,height:e.height,displayWidth:e.squarePixelWidth,displayHeight:e.squarePixelHeight,bitrate:t,bitrateMode:e.bitrateMode,alpha:e.alpha??`discard`,framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...s(e.codec)}},jn=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!o.includes(e.codec))throw TypeError(`Invalid audio codec '${e.codec}'. Must be one of: ${o.join(`, `)}.`);if(e.bitrate===void 0&&(!g.includes(e.codec)||e.codec===`flac`))throw TypeError(`config.bitrate must be provided for compressed audio codecs.`);if(e.bitrate!==void 0&&!(e.bitrate instanceof X)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate, when provided, must be a positive integer or a quality.`);if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedChunk, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);Mn(e.codec,e)},Mn=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&u(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`)},Nn=e=>{let t=e.bitrate instanceof X?e.bitrate._toAudioBitrate(e.codec):e.bitrate;return{codec:e.fullCodecString??Te(e.codec,e.numberOfChannels,e.sampleRate),numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,bitrate:t,bitrateMode:e.bitrateMode,..._(e.codec)}},X=class{constructor(e){this._factor=e}_toVideoBitrate(e,t,n){let r=3e6*(t*n/(1920*1080))**.95*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2}[e]*this._factor;return Math.ceil(r/1e3)*1e3}_toAudioBitrate(e){if(g.includes(e)||e===`flac`)return;let t={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3,ac3:384e3,eac3:192e3}[e];if(!t)throw Error(`Unhandled codec: ${e}`);let n=t*this._factor;return e===`aac`?n=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e):e===`opus`||e===`vorbis`?n=Math.max(6e3,n):e===`mp3`&&(n=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e)),Math.round(n/1e3)*1e3}},Pn=new X(2),Fn=async(e,t={})=>{let{width:r=1280,height:i=720,bitrate:a=1e6,...o}=t;if(!n.includes(e))return!1;if(!Number.isInteger(r)||r<=0)throw TypeError(`width must be a positive integer.`);if(!Number.isInteger(i)||i<=0)throw TypeError(`height must be a positive integer.`);if(!(a instanceof X)&&(!Number.isInteger(a)||a<=0))throw TypeError(`bitrate must be a positive integer or a quality.`);kn(e,o);let s=null;return be.length>0&&(s??=An({codec:e,width:r,height:i,bitrate:a,framerate:void 0,...o}),be.some(t=>t.supports(e,s)))?!0:typeof VideoEncoder>`u`||(r%2==1||i%2==1)&&(e===`avc`||e===`hevc`)||(s??=An({codec:e,width:r,height:i,bitrate:a,framerate:void 0,...o,alpha:`discard`}),!(await VideoEncoder.isConfigSupported(s)).supported)?!1:fe()?new Promise(async e=>{try{let t=new VideoEncoder({output:()=>{},error:()=>e(!1)});t.configure(s);let n=new Uint8Array(r*i*4),a=new VideoFrame(n,{format:`RGBA`,codedWidth:r,codedHeight:i,timestamp:0});t.encode(a),a.close(),await t.flush(),e(!0)}catch{e(!1)}}):!0},In=async(e,t={})=>{let{numberOfChannels:n=2,sampleRate:r=48e3,bitrate:i=128e3,...a}=t;if(!o.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`numberOfChannels must be a positive integer.`);if(!Number.isInteger(r)||r<=0)throw TypeError(`sampleRate must be a positive integer.`);if(!(i instanceof X)&&(!Number.isInteger(i)||i<=0))throw TypeError(`bitrate must be a positive integer.`);Mn(e,a);let s=null;return Se.length>0&&(s??=Nn({codec:e,numberOfChannels:n,sampleRate:r,bitrate:i,...a}),Se.some(t=>t.supports(e,s)))||g.includes(e)?!0:typeof AudioEncoder>`u`?!1:(s??=Nn({codec:e,numberOfChannels:n,sampleRate:r,bitrate:i,...a}),(await AudioEncoder.isConfigSupported(s)).supported===!0)},Ln=async(e,t)=>{for(let n of e)if(await Fn(n,t))return n;return null},Rn=async(e,t)=>{for(let n of e)if(await In(n,t))return n;return null},zn=class{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw Error(`Source is not connected to an output track.`);if(this._connectedTrack.output.state===`canceled`)throw Error(`Output has been canceled.`);if(this._connectedTrack.output.state===`finalizing`||this._connectedTrack.output.state===`finalized`)throw Error(`Output has been finalized.`);if(this._connectedTrack.output.state===`pending`)throw Error(`Output has not started.`);if(this._closed)throw Error(`Source is closed.`)}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;let e=this._connectedTrack;if(!e)throw Error(`Cannot call close without connecting the source to an output track.`);if(e.output.state===`pending`)throw Error(`Cannot call close before output has been started.`);this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,!(e.output.state===`finalizing`||e.output.state===`finalized`)&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise??=(async()=>{await this._flushAndClose(e),this._closed=!0})()}},Bn=class extends zn{constructor(e){if(super(),this._connectedTrack=null,!n.includes(e))throw TypeError(`Invalid video codec '${e}'. Must be one of: ${n.join(`, `)}.`);this._codec=e}},Vn=class{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new ce,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null}async add(e,t,n){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight){let n=this.encodingConfig.sizeChangeBehavior??`deny`;if(n!==`passThrough`){if(n===`deny`)throw Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'strict' in the encoding options.`);{let r=!1;this.resizeCanvas||(typeof document<`u`?(this.resizeCanvas=document.createElement(`canvas`),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),r=!0);let i=this.resizeCanvas.getContext(`2d`,{alpha:fe()});y(i),r||(fe()?(i.fillStyle=`black`,i.fillRect(0,0,this.codedWidth,this.codedHeight)):i.clearRect(0,0,this.codedWidth,this.codedHeight)),e.drawWithFit(i,{fit:n}),t&&e.close(),e=new ge(this.resizeCanvas,{timestamp:e.timestamp,duration:e.duration,rotation:e.rotation}),t=!0}}}}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),y(this.encoderInitialized);let r=this.encodingConfig.keyFrameInterval??5,i=Math.floor(e.timestamp/r),a={...n,keyFrame:n?.keyFrame||r===0||i!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=i,this.customEncoder){this.customEncoderQueueSize++;let t=e.clone(),n=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t,a)).then(()=>this.customEncoderQueueSize--).catch(e=>this.error??=e).finally(()=>{t.close()});this.customEncoderQueueSize>=4&&await n}else{y(this.encoder);let n=e.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(n,a),n.close();else if(n.format&&!n.format.includes(`A`)||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(n,a),n.close();else{let e=n.displayWidth,t=n.displayHeight;if(!this.splitter)try{this.splitter=new Hn(e,t)}catch(e){console.error(`Due to an error, only color data will be encoded.`,e),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(n,a),n.close()}if(this.splitter){let e=this.splitter.extractColor(n),t=this.splitter.extractAlpha(n);this.alphaFrameQueue.push(t),this.encoder.encode(e,a),e.close(),n.close()}}t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener(`dequeue`,e,{once:!0}))}await this.muxer.mutex.currentPromise}finally{t&&e.close()}}ensureEncoder(e){this.ensureEncoderPromise=(async()=>{let t=An({width:e.codedWidth,height:e.codedHeight,squarePixelWidth:e.squarePixelWidth,squarePixelHeight:e.squarePixelHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(t);let n=be.find(e=>e.supports(this.encodingConfig.codec,t));if(n)this.customEncoder=new n,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=t,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof C))throw TypeError(`The first argument passed to onPacket must be an EncodedPacket.`);if(t!==void 0&&(!t||typeof t!=`object`))throw TypeError(`The second argument passed to onPacket must be an object or undefined.`);this.encodingConfig.onEncodedPacket?.(e,t),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,e,t).catch(e=>{this.error??=e})},await this.customEncoder.init();else{if(typeof VideoEncoder>`u`)throw Error(`VideoEncoder is not supported by this browser.`);if(t.alpha=`discard`,this.encodingConfig.alpha===`keep`&&(t.latencyMode=`quality`),(t.width%2==1||t.height%2==1)&&(this.encodingConfig.codec===`avc`||this.encodingConfig.codec===`hevc`))throw Error(`The dimensions ${t.width}x${t.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);if(!(await VideoEncoder.isConfigSupported(t)).supported)throw Error(`This specific encoder configuration (${t.codec}, ${t.bitrate} bps, ${t.width}x${t.height}, hardware acceleration: ${t.hardwareAcceleration??`no-preference`}) is not supported by this browser. Consider using another codec or changing your video parameters.`);let e=[],n=[],r=0,i=0,a=(e,t,n)=>{let r={};if(t){let e=new Uint8Array(t.byteLength);t.copyTo(e),r.alpha=e}let i=C.fromEncodedChunk(e,r);this.encodingConfig.onEncodedPacket?.(i,n),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,i,n).catch(e=>{this.error??=e})},o=Error(`Encoding error`).stack;if(this.encoder=new VideoEncoder({output:(t,o)=>{if(!this.alphaEncoder){a(t,null,o);return}let s=this.alphaFrameQueue.shift();y(s!==void 0),s?(this.alphaEncoder.encode(s,{keyFrame:t.type===`key`}),i++,s.close(),e.push({chunk:t,meta:o})):i===0?a(t,null,o):(n.push(r+i),e.push({chunk:t,meta:o}))},error:e=>{e.stack=o,this.error??=e}}),this.encoder.configure(t),this.encodingConfig.alpha===`keep`){let o=Error(`Encoding error`).stack;this.alphaEncoder=new VideoEncoder({output:(t,o)=>{i--;let s=e.shift();for(y(s!==void 0),a(s.chunk,t,s.meta),r++;n.length>0&&n[0]===r;){n.shift();let t=e.shift();y(t!==void 0),a(t.chunk,null,t.meta)}},error:e=>{e.stack=o,this.error??=e}}),this.alphaEncoder.configure(t)}}y(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.error}},Hn=class{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<`u`?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement(`canvas`),this.canvas.width=e,this.canvas.height=t);let n=this.canvas.getContext(`webgl2`,{alpha:!0});if(!n)throw Error(`Couldn't acquire WebGL 2 context.`);this.gl=n,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,`u_resolution`),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,`u_sourceTexture`),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,`u_sourceTexture`),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{$ as t,A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,P as _,Q as v,R as ee,S as te,T as ne,U as re,V as ie,W as ae,X as oe,Y as se,Z as ce,_ as le,_t as ue,a as de,at as fe,b as pe,c as me,ct as he,d as ge,dt as _e,et as y,f as ve,ft as ye,g as be,gt as xe,h as Se,ht as b,i as Ce,it as we,j as Te,k as x,l as Ee,lt as S,m as C,mt as w,n as De,nt as T,o as E,ot as Oe,p as ke,pt as Ae,q as je,r as D,rt as Me,s as Ne,st as O,tt as Pe,u as Fe,ut as Ie,v as Le,w as Re,x as ze,y as Be,z as Ve}from"./index-B1NWkbV5.js";var He=class{constructor(e){this.mutex=new se,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,n){if(t+=e.source._timestampOffset,t<0)throw Error(`Timestamps must be non-negative (got ${t}s).`);let r=this.trackTimestampInfo.get(e);if(r){if(n&&(r.maxTimestampBeforeLastKeyPacket=r.maxTimestamp),r.maxTimestampBeforeLastKeyPacket!==null&&t<r.maxTimestampBeforeLastKeyPacket)throw Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${r.maxTimestampBeforeLastKeyPacket}s.`);r.maxTimestamp=Math.max(r.maxTimestamp,t)}else{if(!n)throw Error(`First packet must be a key packet.`);r={maxTimestamp:t,maxTimestampBeforeLastKeyPacket:null},this.trackTimestampInfo.set(e,r)}return t}},Ue=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,We=e=>{let t=Math.floor(e/(3600*1e3)),n=Math.floor(e%(3600*1e3)/(60*1e3)),r=Math.floor(e%(60*1e3)/1e3),i=e%1e3;return t.toString().padStart(2,`0`)+`:`+n.toString().padStart(2,`0`)+`:`+r.toString().padStart(2,`0`)+`.`+i.toString().padStart(3,`0`)},Ge=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.writer.write(this.helper);e.length%8!=0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{let t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let n=this.writer.getPos(),r=e.size??n-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(n)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){let t=this.offsets.get(e);y(t!==void 0);let n=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(n)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(let n of e.children)n&&(t+=this.measureBox(n));return t}}},k=new Uint8Array(8),A=new DataView(k.buffer),j=e=>[(e%256+256)%256],M=e=>(A.setUint16(0,e,!1),[k[0],k[1]]),N=e=>(A.setInt16(0,e,!1),[k[0],k[1]]),Ke=e=>(A.setUint32(0,e,!1),[k[1],k[2],k[3]]),P=e=>(A.setUint32(0,e,!1),[k[0],k[1],k[2],k[3]]),F=e=>(A.setInt32(0,e,!1),[k[0],k[1],k[2],k[3]]),I=e=>(A.setUint32(0,Math.floor(e/2**32),!1),A.setUint32(4,e,!1),[k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7]]),qe=e=>(A.setInt16(0,2**8*e,!1),[k[0],k[1]]),L=e=>(A.setInt32(0,2**16*e,!1),[k[0],k[1],k[2],k[3]]),R=e=>(A.setInt32(0,2**30*e,!1),[k[0],k[1],k[2],k[3]]),Je=(e,t)=>{let n=[],r=e;do{let e=r&127;r>>=7,n.length>0&&(e|=128),n.push(e),t!==void 0&&t--}while(r>0||t);return n.reverse()},z=(e,t=!1)=>{let n=Array(e.length).fill(null).map((t,n)=>e.charCodeAt(n));return t&&n.push(0),n},Ye=e=>{let t=null;for(let n of e)(!t||n.timestamp>t.timestamp)&&(t=n);return t},Xe=e=>{let t=e*(Math.PI/180),n=Math.round(Math.cos(t)),r=Math.round(Math.sin(t));return[n,r,0,-r,n,0,0,0,1]},Ze=Xe(0),Qe=e=>[L(e[0]),L(e[1]),R(e[2]),L(e[3]),L(e[4]),R(e[5]),L(e[6]),L(e[7]),R(e[8])],B=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),V=(e,t,n,r,i)=>B(e,[j(t),Ke(n),r??[]],i),$e=e=>e.isQuickTime?B(`ftyp`,[z(`qt `),P(512),z(`qt `)]):e.fragmented?B(`ftyp`,[z(`iso5`),P(512),z(`iso5`),z(`iso6`),z(`mp41`)]):B(`ftyp`,[z(`isom`),P(512),z(`isom`),e.holdsAvc?z(`avc1`):[],z(`mp41`)]),H=e=>({type:`mdat`,largeSize:e}),et=e=>({type:`free`,size:e}),U=e=>B(`moov`,void 0,[tt(e.creationTime,e.trackDatas),...e.trackDatas.map(t=>nt(t,e.creationTime)),e.isFragmented?zt(e.trackDatas):null,en(e)]),tt=(e,t)=>{let n=Y(Math.max(0,...t.filter(e=>e.samples.length>0).map(e=>{let t=Ye(e.samples);return t.timestamp+t.duration})),bn),r=Math.max(0,...t.map(e=>e.track.id))+1,i=!O(e)||!O(n),a=i?I:P;return V(`mvhd`,+i,0,[a(e),a(e),P(bn),a(n),L(1),qe(1),Array(10).fill(0),Qe(Ze),Array(24).fill(0),P(r)])},nt=(e,t)=>{let n=Sn(e);return B(`trak`,void 0,[rt(e,t),it(e,t),n.name===void 0?null:B(`udta`,void 0,[B(`name`,[...w.encode(n.name)])])])},rt=(e,t)=>{let n=Ye(e.samples),r=Y(n?n.timestamp+n.duration:0,bn),i=!O(t)||!O(r),a=i?I:P,o;if(e.type===`video`){let t=e.track.metadata.rotation;o=Xe(t??0)}else o=Ze;let s=2;return e.track.metadata.disposition?.default!==!1&&(s|=1),V(`tkhd`,+i,s,[a(t),a(t),P(e.track.id),P(0),a(r),Array(8).fill(0),M(0),M(e.track.id),qe(e.type===`audio`?1:0),M(0),Qe(o),L(e.type===`video`?e.info.width:0),L(e.type===`video`?e.info.height:0)])},it=(e,t)=>B(`mdia`,void 0,[at(e,t),ct(!0,ot[e.type],st[e.type]),lt(e)]),at=(e,t)=>{let n=Ye(e.samples),r=Y(n?n.timestamp+n.duration:0,e.timescale),i=!O(t)||!O(r),a=i?I:P;return V(`mdhd`,+i,0,[a(t),a(t),P(e.timescale),a(r),M(pn(e.track.metadata.languageCode??`und`)),M(0)])},ot={video:`vide`,audio:`soun`,subtitle:`text`},st={video:`MediabunnyVideoHandler`,audio:`MediabunnySoundHandler`,subtitle:`MediabunnyTextHandler`},ct=(e,t,n,r=`\0\0\0\0`)=>V(`hdlr`,0,0,[e?z(`mhlr`):P(0),z(t),z(r),P(0),P(0),z(n,!0)]),lt=e=>B(`minf`,void 0,[ut[e.type](),dt(),mt(e)]),ut={video:()=>V(`vmhd`,0,1,[M(0),M(0),M(0),M(0)]),audio:()=>V(`smhd`,0,0,[M(0),M(0)]),subtitle:()=>V(`nmhd`,0,0)},dt=()=>B(`dinf`,void 0,[ft()]),ft=()=>V(`dref`,0,0,[P(1)],[pt()]),pt=()=>V(`url `,0,1),mt=e=>{let t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>e.sampleCompositionTimeOffset!==0);return B(`stbl`,void 0,[ht(e),Mt(e),t?Lt(e):null,t?Rt(e):null,Pt(e),Ft(e),It(e),Nt(e)])},ht=e=>{let t;if(e.type===`video`)t=gt(sn(e.track.source._codec,e.info.decoderConfig.codec),e);else if(e.type===`audio`){let n=ln(e.track.source._codec,e.muxer.isQuickTime);y(n),t=Ct(n,e)}else e.type===`subtitle`&&(t=At(dn[e.track.source._codec],e));return y(t),V(`stsd`,0,0,[P(1)],[t])},gt=(e,t)=>B(e,[[,,,,,,].fill(0),M(1),M(0),M(0),Array(12).fill(0),M(t.info.width),M(t.info.height),P(4718592),P(4718592),P(0),M(1),Array(32).fill(0),M(24),N(65535)],[cn[t.track.source._codec](t),_t(t),Me(t.info.decoderConfig.colorSpace)?vt(t):null]),_t=e=>e.info.pixelAspectRatio.num===e.info.pixelAspectRatio.den?null:B(`pasp`,[P(e.info.pixelAspectRatio.num),P(e.info.pixelAspectRatio.den)]),vt=e=>B(`colr`,[z(`nclx`),M(oe[e.info.decoderConfig.colorSpace.primaries]),M(t[e.info.decoderConfig.colorSpace.transfer]),M(v[e.info.decoderConfig.colorSpace.matrix]),j((e.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),yt=e=>e.info.decoderConfig&&B(`avcC`,[...b(e.info.decoderConfig.description)]),bt=e=>e.info.decoderConfig&&B(`hvcC`,[...b(e.info.decoderConfig.description)]),xt=e=>{if(!e.info.decoderConfig)return null;let n=e.info.decoderConfig,r=n.codec.split(`.`),i=Number(r[1]),a=Number(r[2]),o=Number(r[3]),s=r[4]?Number(r[4]):1,c=r[8]?Number(r[8]):Number(n.colorSpace?.fullRange??0),l=(o<<4)+(s<<1)+c,u=r[5]?Number(r[5]):n.colorSpace?.primaries?oe[n.colorSpace.primaries]:2,d=r[6]?Number(r[6]):n.colorSpace?.transfer?t[n.colorSpace.transfer]:2,f=r[7]?Number(r[7]):n.colorSpace?.matrix?v[n.colorSpace.matrix]:2;return V(`vpcC`,1,0,[j(i),j(a),j(l),j(u),j(d),j(f),M(0)])},St=e=>B(`av1C`,h(e.info.decoderConfig.codec)),Ct=(e,t)=>{let n=0,r,i=16,a=g.includes(t.track.source._codec);if(a){let e=t.track.source._codec,{sampleSize:r}=p(e);i=8*r,i>16&&(n=1)}if(t.muxer.isQuickTime&&(n=1),n===0)r=[[,,,,,,].fill(0),M(1),M(n),M(0),P(0),M(t.info.numberOfChannels),M(i),M(0),M(0),M(t.info.sampleRate<2**16?t.info.sampleRate:0),M(0)];else{let e=a?0:-2;r=[[,,,,,,].fill(0),M(1),M(n),M(0),P(0),M(t.info.numberOfChannels),M(Math.min(i,16)),N(e),M(0),M(t.info.sampleRate<2**16?t.info.sampleRate:0),M(0),a?[P(1),P(i/8),P(t.info.numberOfChannels*i/8)]:[P(0),P(0),P(0)],P(2)]}return B(e,r,[un(t.track.source._codec,t.muxer.isQuickTime)?.(t)??null])},W=e=>{let t;switch(e.track.source._codec){case`aac`:t=64;break;case`mp3`:t=107;break;case`vorbis`:t=221;break;default:throw Error(`Unhandled audio codec: ${e.track.source._codec}`)}let n=[...j(t),...j(21),...Ke(0),...P(0),...P(0)];if(e.info.decoderConfig.description){let t=b(e.info.decoderConfig.description);n=[...n,...j(5),...Je(t.byteLength),...t]}return n=[...M(1),...j(0),...j(4),...Je(n.length),...n,...j(6),...j(1),...j(2)],n=[...j(3),...Je(n.length),...n],V(`esds`,0,0,n)},G=e=>B(`wave`,void 0,[wt(e),Tt(e),B(`\0\0\0\0`)]),wt=e=>B(`frma`,[z(ln(e.track.source._codec,e.muxer.isQuickTime))]),Tt=e=>{let{littleEndian:t}=p(e.track.source._codec);return B(`enda`,[M(+t)])},Et=e=>{let t=e.info.numberOfChannels,n=3840,r=e.info.sampleRate,a=0,o=0,s=new Uint8Array,c=e.info.decoderConfig?.description;if(c){y(c.byteLength>=18);let e=i(b(c));t=e.outputChannelCount,n=e.preSkip,r=e.inputSampleRate,a=e.outputGain,o=e.channelMappingFamily,e.channelMappingTable&&(s=e.channelMappingTable)}return B(`dOps`,[j(0),j(t),M(n),P(r),N(a),j(o),...s])},Dt=e=>{let t=e.info.decoderConfig?.description;return y(t),V(`dfLa`,0,0,[...b(t).subarray(4)])},K=e=>{let{littleEndian:t,sampleSize:n}=p(e.track.source._codec);return V(`pcmC`,0,0,[j(+t),j(8*n)])},Ot=e=>{let t=ze(e.info.firstPacket.data);if(!t)throw Error(`Couldn't extract AC-3 frame info from the audio packet. Ensure the packets contain valid AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=new Uint8Array(3),r=new c(n);return r.writeBits(2,t.fscod),r.writeBits(5,t.bsid),r.writeBits(3,t.bsmod),r.writeBits(3,t.acmod),r.writeBits(1,t.lfeon),r.writeBits(5,t.bitRateCode),r.writeBits(5,0),B(`dac3`,[...n])},kt=e=>{let t=te(e.info.firstPacket.data);if(!t)throw Error(`Couldn't extract E-AC-3 frame info from the audio packet. Ensure the packets contain valid E-AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=16;for(let e of t.substreams)n+=23,e.numDepSub>0?n+=9:n+=1;let r=Math.ceil(n/8),i=new Uint8Array(r),a=new c(i);a.writeBits(13,t.dataRate),a.writeBits(3,t.substreams.length-1);for(let e of t.substreams)a.writeBits(2,e.fscod),a.writeBits(5,e.bsid),a.writeBits(1,0),a.writeBits(1,0),a.writeBits(3,e.bsmod),a.writeBits(3,e.acmod),a.writeBits(1,e.lfeon),a.writeBits(3,0),a.writeBits(4,e.numDepSub),e.numDepSub>0?a.writeBits(9,e.chanLoc):a.writeBits(1,0);return B(`dec3`,[...i])},At=(e,t)=>B(e,[[,,,,,,].fill(0),M(1)],[fn[t.track.source._codec](t)]),jt=e=>B(`vttC`,[...w.encode(e.info.config.description)]),Mt=e=>V(`stts`,0,0,[P(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[P(e.sampleCount),P(e.sampleDelta)])]),Nt=e=>{if(e.samples.every(e=>e.type===`key`))return null;let t=[...e.samples.entries()].filter(([,e])=>e.type===`key`);return V(`stss`,0,0,[P(t.length),t.map(([e])=>P(e+1))])},Pt=e=>V(`stsc`,0,0,[P(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[P(e.firstChunk),P(e.samplesPerChunk),P(1)])]),Ft=e=>{if(e.type===`audio`&&e.info.requiresPcmTransformation){let{sampleSize:t}=p(e.track.source._codec);return V(`stsz`,0,0,[P(t*e.info.numberOfChannels),P(e.samples.reduce((t,n)=>t+Y(n.duration,e.timescale),0))])}return V(`stsz`,0,0,[P(0),P(e.samples.length),e.samples.map(e=>P(e.size))])},It=e=>e.finalizedChunks.length>0&&S(e.finalizedChunks).offset>=2**32?V(`co64`,0,0,[P(e.finalizedChunks.length),e.finalizedChunks.map(e=>I(e.offset))]):V(`stco`,0,0,[P(e.finalizedChunks.length),e.finalizedChunks.map(e=>P(e.offset))]),Lt=e=>V(`ctts`,1,0,[P(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>[P(e.sampleCount),F(e.sampleCompositionTimeOffset)])]),Rt=e=>{let t=1/0,n=-1/0,r=1/0,i=-1/0;y(e.compositionTimeOffsetTable.length>0),y(e.samples.length>0);for(let r=0;r<e.compositionTimeOffsetTable.length;r++){let i=e.compositionTimeOffsetTable[r];t=Math.min(t,i.sampleCompositionTimeOffset),n=Math.max(n,i.sampleCompositionTimeOffset)}for(let t=0;t<e.samples.length;t++){let n=e.samples[t];r=Math.min(r,Y(n.timestamp,e.timescale)),i=Math.max(i,Y(n.timestamp+n.duration,e.timescale))}let a=Math.max(-t,0);return i>=2**31?null:V(`cslg`,0,0,[F(a),F(t),F(n),F(r),F(i)])},zt=e=>B(`mvex`,void 0,e.map(Bt)),Bt=e=>V(`trex`,0,0,[P(e.track.id),P(1),P(0),P(0),P(0)]),Vt=(e,t)=>B(`moof`,void 0,[Ht(e),...t.map(Wt)]),Ht=e=>V(`mfhd`,0,0,[P(e)]),Ut=e=>{let t=0,n=0,r=e.type===`delta`;return n|=+r,r?t|=1:t|=2,t<<24|n<<16|0},Wt=e=>B(`traf`,void 0,[Gt(e),Kt(e),qt(e)]),Gt=e=>{y(e.currentChunk);let t=0;t|=8,t|=16,t|=32,t|=131072;let n=e.currentChunk.samples[1]??e.currentChunk.samples[0],r={duration:n.timescaleUnitsToNextSample,size:n.size,flags:Ut(n)};return V(`tfhd`,0,t,[P(e.track.id),P(r.duration),P(r.size),P(r.flags)])},Kt=e=>(y(e.currentChunk),V(`tfdt`,1,0,[I(Y(e.currentChunk.startTimestamp,e.timescale))])),qt=e=>{y(e.currentChunk);let t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),n=e.currentChunk.samples.map(e=>e.size),r=e.currentChunk.samples.map(Ut),i=e.currentChunk.samples.map(t=>Y(t.timestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),o=new Set(n),s=new Set(r),c=new Set(i),l=s.size===2&&r[0]!==r[1],u=a.size>1,d=o.size>1,f=!l&&s.size>1,p=c.size>1||[...c].some(e=>e!==0),m=0;return m|=1,m|=4*l,m|=256*u,m|=512*d,m|=1024*f,m|=2048*p,V(`trun`,1,m,[P(e.currentChunk.samples.length),P(e.currentChunk.offset-e.currentChunk.moofOffset||0),l?P(r[0]):[],e.currentChunk.samples.map((e,a)=>[u?P(t[a]):[],d?P(n[a]):[],f?P(r[a]):[],p?F(i[a]):[]])])},Jt=e=>B(`mfra`,void 0,[...e.map(Yt),Xt()]),Yt=(e,t)=>V(`tfra`,1,0,[P(e.track.id),P(63),P(e.finalizedChunks.length),e.finalizedChunks.map(n=>[I(Y(n.samples[0].timestamp,e.timescale)),I(n.moofOffset),P(t+1),P(1),P(1)])]),Xt=()=>V(`mfro`,0,0,[P(0)]),Zt=()=>B(`vtte`),Qt=(e,t,n,r,i)=>B(`vttc`,void 0,[i===null?null:B(`vsid`,[F(i)]),n===null?null:B(`iden`,[...w.encode(n)]),t===null?null:B(`ctim`,[...w.encode(We(t))]),r===null?null:B(`sttg`,[...w.encode(r)]),B(`payl`,[...w.encode(e)])]),$t=e=>B(`vtta`,[...w.encode(e)]),en=e=>{let t=[],n=e.format._options.metadataFormat??`auto`,r=e.output._metadataTags;if(n===`mdir`||n===`auto`&&!e.isQuickTime){let e=an(r);e&&t.push(e)}else if(n===`mdta`){let e=on(r);e&&t.push(e)}else (n===`udta`||n===`auto`&&e.isQuickTime)&&tn(t,e.output._metadataTags);return t.length===0?null:B(`udta`,void 0,t)},tn=(e,t)=>{for(let{key:n,value:r}of he(t))switch(n){case`title`:e.push(q(`©nam`,r));break;case`description`:e.push(q(`©des`,r));break;case`artist`:e.push(q(`©ART`,r));break;case`album`:e.push(q(`©alb`,r));break;case`albumArtist`:e.push(q(`albr`,r));break;case`genre`:e.push(q(`©gen`,r));break;case`date`:e.push(q(`©day`,r.toISOString().slice(0,10)));break;case`comment`:e.push(q(`©cmt`,r));break;case`lyrics`:e.push(q(`©lyr`,r));break;case`raw`:break;case`discNumber`:case`discsTotal`:case`trackNumber`:case`tracksTotal`:case`images`:break;default:Pe(n)}if(t.raw)for(let n in t.raw){let r=t.raw[n];r==null||n.length!==4||e.some(e=>e.type===n)||(typeof r==`string`?e.push(q(n,r)):r instanceof Uint8Array&&e.push(B(n,Array.from(r))))}},q=(e,t)=>{let n=w.encode(t);return B(e,[M(n.length),M(pn(`und`)),Array.from(n)])},nn={"image/jpeg":13,"image/png":14,"image/bmp":27},rn=(e,t)=>{let n=[];for(let{key:r,value:i}of he(e))switch(r){case`title`:n.push({key:t?`title`:`©nam`,value:J(i)});break;case`description`:n.push({key:t?`description`:`©des`,value:J(i)});break;case`artist`:n.push({key:t?`artist`:`©ART`,value:J(i)});break;case`album`:n.push({key:t?`album`:`©alb`,value:J(i)});break;case`albumArtist`:n.push({key:t?`album_artist`:`aART`,value:J(i)});break;case`comment`:n.push({key:t?`comment`:`©cmt`,value:J(i)});break;case`genre`:n.push({key:t?`genre`:`©gen`,value:J(i)});break;case`lyrics`:n.push({key:t?`lyrics`:`©lyr`,value:J(i)});break;case`date`:n.push({key:t?`date`:`©day`,value:J(i.toISOString().slice(0,10))});break;case`images`:for(let e of i)e.kind===`coverFront`&&n.push({key:`covr`,value:B(`data`,[P(nn[e.mimeType]??0),P(0),Array.from(e.data)])});break;case`trackNumber`:if(t){let t=e.tracksTotal===void 0?i.toString():`${i}/${e.tracksTotal}`;n.push({key:`track`,value:J(t)})}else n.push({key:`trkn`,value:B(`data`,[P(0),P(0),M(0),M(i),M(e.tracksTotal??0),M(0)])});break;case`discNumber`:t||n.push({key:`disc`,value:B(`data`,[P(0),P(0),M(0),M(i),M(e.discsTotal??0),M(0)])});break;case`tracksTotal`:case`discsTotal`:break;case`raw`:break;default:Pe(r)}if(e.raw)for(let r in e.raw){let i=e.raw[r];i==null||!t&&r.length!==4||n.some(e=>e.key===r)||(typeof i==`string`?n.push({key:r,value:J(i)}):i instanceof Uint8Array?n.push({key:r,value:B(`data`,[P(0),P(0),Array.from(i)])}):i instanceof f&&n.push({key:r,value:B(`data`,[P(nn[i.mimeType]??0),P(0),Array.from(i.data)])}))}return n},an=e=>{let t=rn(e,!1);return t.length===0?null:V(`meta`,0,0,void 0,[ct(!1,`mdir`,``,`appl`),B(`ilst`,void 0,t.map(e=>B(e.key,void 0,[e.value])))])},on=e=>{let t=rn(e,!0);return t.length===0?null:B(`meta`,void 0,[ct(!1,`mdta`,``),V(`keys`,0,0,[P(t.length)],t.map(e=>B(`mdta`,[...w.encode(e.key)]))),B(`ilst`,void 0,t.map((e,t)=>B(String.fromCharCode(...P(t+1)),void 0,[e.value])))])},J=e=>B(`data`,[P(1),P(0),...w.encode(e)]),sn=(e,t)=>{switch(e){case`avc`:return t.startsWith(`avc3`)?`avc3`:`avc1`;case`hevc`:return`hvc1`;case`vp8`:return`vp08`;case`vp9`:return`vp09`;case`av1`:return`av01`}},cn={avc:yt,hevc:bt,vp8:xt,vp9:xt,av1:St},ln=(e,t)=>{switch(e){case`aac`:return`mp4a`;case`mp3`:return`mp4a`;case`opus`:return`Opus`;case`vorbis`:return`mp4a`;case`flac`:return`fLaC`;case`ulaw`:return`ulaw`;case`alaw`:return`alaw`;case`pcm-u8`:return`raw `;case`pcm-s8`:return`sowt`;case`ac3`:return`ac-3`;case`eac3`:return`ec-3`}if(t)switch(e){case`pcm-s16`:return`sowt`;case`pcm-s16be`:return`twos`;case`pcm-s24`:return`in24`;case`pcm-s24be`:return`in24`;case`pcm-s32`:return`in32`;case`pcm-s32be`:return`in32`;case`pcm-f32`:return`fl32`;case`pcm-f32be`:return`fl32`;case`pcm-f64`:return`fl64`;case`pcm-f64be`:return`fl64`}else switch(e){case`pcm-s16`:return`ipcm`;case`pcm-s16be`:return`ipcm`;case`pcm-s24`:return`ipcm`;case`pcm-s24be`:return`ipcm`;case`pcm-s32`:return`ipcm`;case`pcm-s32be`:return`ipcm`;case`pcm-f32`:return`fpcm`;case`pcm-f32be`:return`fpcm`;case`pcm-f64`:return`fpcm`;case`pcm-f64be`:return`fpcm`}},un=(e,t)=>{switch(e){case`aac`:return W;case`mp3`:return W;case`opus`:return Et;case`vorbis`:return W;case`flac`:return Dt;case`ac3`:return Ot;case`eac3`:return kt}if(t)switch(e){case`pcm-s24`:return G;case`pcm-s24be`:return G;case`pcm-s32`:return G;case`pcm-s32be`:return G;case`pcm-f32`:return G;case`pcm-f32be`:return G;case`pcm-f64`:return G;case`pcm-f64be`:return G}else switch(e){case`pcm-s16`:return K;case`pcm-s16be`:return K;case`pcm-s24`:return K;case`pcm-s24be`:return K;case`pcm-s32`:return K;case`pcm-s32be`:return K;case`pcm-f32`:return K;case`pcm-f32be`:return K;case`pcm-f64`:return K;case`pcm-f64be`:return K}return null},dn={webvtt:`wvtt`},fn={webvtt:jt},pn=e=>{y(e.length===3);let t=0;for(let n=0;n<3;n++)t<<=5,t+=e.charCodeAt(n)-96;return t},mn=class{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}let n=t+e.byteLength-this.trackedStart,r=this.trackedWrites.byteLength;for(;r<n;)r*=2;if(r!==this.trackedWrites.byteLength){let e=new Uint8Array(r);e.set(this.trackedWrites,0),this.trackedWrites=e}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw Error(`Internal error: Can't get tracked writes since nothing was tracked.`);let e={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,e}},hn=2**16,gn=2**32,_n=class extends mn{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize=`resize`in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(hn,{maxByteLength:gn})}catch{this.buffer=new ArrayBuffer(hn),this.supportsResize=!1}else this.buffer=new ArrayBuffer(hn);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>gn)throw Error(`ArrayBuffer exceeded maximum size of ${gn} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{let e=new ArrayBuffer(t),n=new Uint8Array(e);n.set(this.bytes,0),this.buffer=e,this.bytes=n}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}};e(xe(),1);var vn=class{constructor(){this._output=null,this.onwrite=null}},yn=class extends vn{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new _n(this)}},bn=1e3,xn=2082844800,Sn=e=>{let t={},n=e.track;return n.metadata.name!==void 0&&(t.name=n.metadata.name),t},Y=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},Cn=class extends He{constructor(e,t){super(e),this.auxTarget=new yn,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new Ge(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=Ie(),this.creationTime=Math.floor(Date.now()/1e3)+xn,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new Ge(this.writer),this.isQuickTime=t instanceof Dn;let n=this.writer instanceof _n?`in-memory`:!1;this.fastStart=t._options.fastStart??n,this.isFragmented=this.fastStart===`fragmented`,(this.fastStart===`in-memory`||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){let e=await this.mutex.acquire(),t=this.output._tracks.some(e=>e.type===`video`&&e.source._codec===`avc`);if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox($e({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onFtyp(e,t)}if(this.ftypSize=this.writer.getPos(),this.fastStart!==`in-memory`)if(this.fastStart===`reserve`){for(let e of this.output._tracks)if(e.metadata.maximumPacketCount===void 0)throw Error(`All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.`)}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=H(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(let e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return me({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let i=this.trackDatas.find(t=>t.track===e);if(i)return i;r(n),y(n),y(n.decoderConfig);let a={...n.decoderConfig};y(a.codedWidth!==void 0),y(a.codedHeight!==void 0);let o=!1;if(e.source._codec===`avc`&&!a.description){let e=Le(t.data);if(!e)throw Error(`Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.`);a.description=Re(e),o=!0}else if(e.source._codec===`hevc`&&!a.description){let e=Be(t.data);if(!e)throw Error(`Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.`);a.description=ne(e),o=!0}let s=we(1/(e.metadata.frameRate??57600),1e6).denominator,c=a.displayAspectWidth,l=a.displayAspectHeight,u=c===void 0||l===void 0?{num:1,den:1}:Ae({num:c*a.codedHeight,den:l*a.codedWidth}),d={muxer:this,track:e,type:`video`,info:{width:a.codedWidth,height:a.codedHeight,pixelAspectRatio:u,decoderConfig:a,requiresAnnexBTransformation:o},timescale:s,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(d),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),d}getAudioTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;ee(n),y(n),y(n.decoderConfig);let i={...n.decoderConfig},a=!1;if(e.source._codec===`aac`&&!i.description){let e=Ne(De.tempFromBytes(t.data));if(!e)throw Error(`Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.`);let n=l[e.samplingFrequencyIndex],r=ie[e.channelConfiguration];if(n===void 0||r===void 0)throw Error(`Invalid ADTS frame header.`);i.description=re({objectType:e.objectType,sampleRate:n,numberOfChannels:r}),a=!0}let o={muxer:this,track:e,type:`audio`,info:{numberOfChannels:n.decoderConfig.numberOfChannels,sampleRate:n.decoderConfig.sampleRate,decoderConfig:i,requiresPcmTransformation:!this.isFragmented&&g.includes(e.source._codec),requiresAdtsStripping:a,firstPacket:t},timescale:i.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;Ve(t),y(t),y(t.config);let r={muxer:this,track:e,type:`subtitle`,info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n),i=t.data;if(r.info.requiresAnnexBTransformation){let e=[...pe(i)].map(e=>i.subarray(e.offset,e.offset+e.length));if(e.length===0)throw Error(`Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.`);i=le(e,4)}let a=this.validateAndNormalizeTimestamp(r.track,t.timestamp,t.type===`key`),o=this.createSampleForTrack(r,i,a,t.duration,t.type);await this.registerSample(r,o)}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,t,n),i=t.data;if(r.info.requiresAdtsStripping){let e=Ne(De.tempFromBytes(i));if(!e)throw Error(`Expected ADTS frame, didn't get one.`);let t=e.crcCheck===null?7:9;i=i.subarray(t)}let a=this.validateAndNormalizeTimestamp(r.track,t.timestamp,t.type===`key`),o=this.createSampleForTrack(r,i,a,t.duration,t.type);r.info.requiresPcmTransformation&&await this.maybePadWithSilence(r,a),await this.registerSample(r,o)}finally{r()}}async maybePadWithSilence(e,t){let n=S(e.samples),r=n?n.timestamp+n.duration:0,i=t-r,a=Y(i,e.timescale);if(a>0){let{sampleSize:t,silentValue:n}=p(e.info.decoderConfig.codec),o=a*e.info.numberOfChannels,s=new Uint8Array(t*o).fill(n),c=this.createSampleForTrack(e,new Uint8Array(s.buffer),r,i,`key`);await this.registerSample(e,c)}}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateAndNormalizeTimestamp(r.track,t.timestamp,!0),e.source._codec===`webvtt`&&(r.cueQueue.push(t),await this.processWebVTTCues(r,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){let n=new Set([]);for(let r of e.cueQueue)y(r.timestamp<=t),y(e.lastCueEndTimestamp<=r.timestamp+r.duration),n.add(Math.max(r.timestamp,e.lastCueEndTimestamp)),n.add(r.timestamp+r.duration);let r=[...n].sort((e,t)=>e-t),i=r[0],a=r[1]??i;if(t<a)break;if(e.lastCueEndTimestamp<i){this.auxWriter.seek(0);let t=Zt();this.auxBoxWriter.writeBox(t);let n=this.auxWriter.getSlice(0,this.auxWriter.getPos()),r=this.createSampleForTrack(e,n,e.lastCueEndTimestamp,i-e.lastCueEndTimestamp,`key`);await this.registerSample(e,r),e.lastCueEndTimestamp=i}this.auxWriter.seek(0);for(let t=0;t<e.cueQueue.length;t++){let n=e.cueQueue[t];if(n.timestamp>=a)break;Ue.lastIndex=0;let r=Ue.test(n.text),o=n.timestamp+n.duration,s=e.cueToSourceId.get(n);if(s===void 0&&a<o&&(s=e.nextSourceId++,e.cueToSourceId.set(n,s)),n.notes){let e=$t(n.notes);this.auxBoxWriter.writeBox(e)}let c=Qt(n.text,r?i:null,n.identifier??null,n.settings??null,s??null);this.auxBoxWriter.writeBox(c),o===a&&e.cueQueue.splice(t--,1)}let o=this.auxWriter.getSlice(0,this.auxWriter.getPos()),s=this.createSampleForTrack(e,o,i,a-i,`key`);await this.registerSample(e,s),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,n,r,i){return{timestamp:n,decodeTimestamp:n,duration:r,data:t,size:t.byteLength,type:i,timescaleUnitsToNextSample:Y(r,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type===`audio`&&e.info.requiresPcmTransformation){let t=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){let r=e.timestampProcessingQueue[n],i=Y(r.duration,e.timescale);t+=i}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:t,sampleDelta:1});else{let n=S(e.timeToSampleTable);n.sampleCount+=t}e.timestampProcessingQueue.length=0;return}let n=e.timestampProcessingQueue.map(e=>e.timestamp).sort((e,t)=>e-t);for(let t=0;t<e.timestampProcessingQueue.length;t++){let r=e.timestampProcessingQueue[t];r.decodeTimestamp=n[t],!this.isFragmented&&e.lastTimescaleUnits===null&&(r.decodeTimestamp=0);let i=Y(r.timestamp-r.decodeTimestamp,e.timescale),a=Y(r.duration,e.timescale);if(e.lastTimescaleUnits!==null){y(e.lastSample);let t=Y(r.decodeTimestamp,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);if(y(n>=0),e.lastTimescaleUnits+=n,e.lastSample.timescaleUnitsToNextSample=n,!this.isFragmented){let t=S(e.timeToSampleTable);if(y(t),t.sampleCount===1){t.sampleDelta=n;let r=e.timeToSampleTable[e.timeToSampleTable.length-2];r&&r.sampleDelta===n&&(r.sampleCount++,e.timeToSampleTable.pop(),t=r)}else t.sampleDelta!==n&&(t.sampleCount--,e.timeToSampleTable.push(t={sampleCount:1,sampleDelta:n}));t.sampleDelta===a?t.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});let r=S(e.compositionTimeOffsetTable);y(r),r.sampleCompositionTimeOffset===i?r.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i})}}else e.lastTimescaleUnits=Y(r.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i}));e.lastSample=r}if(e.timestampProcessingQueue.length=0,y(e.lastSample),y(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){y(t.type===`key`);let n=Y(t.timestamp,e.timescale,!1),r=Math.round(n-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=r}}async registerSample(e,t){t.type===`key`&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart===`reserve`?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart===`reserve`)){let t=e.track.metadata.maximumPacketCount;if(y(t!==void 0),e.samples.length>t)throw Error(`Track #${e.track.id} has already reached the maximum packet count (${t}). Either add less packets or increase the maximum packet count.`)}let n=!1;if(!e.currentChunk)n=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);let r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){let i=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.sampleQueue[0];return r?r.type===`key`:n.track.source._closed});r>=this.minimumFragmentDuration&&i&&t.timestamp>this.maxWrittenTimestamp&&(n=!0,await this.finalizeFragment())}else n=r>=.5}n&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),y(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if(y(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type===`audio`&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((t,n)=>t+Y(n.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||S(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart===`in-memory`){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(let t of e.currentChunk.samples)y(t.data),this.writer.write(t.data),t.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if(y(this.isFragmented),!(!e&&!this.allTracksAreKnown()))outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.sampleQueue.length===0&&!r.track.source._closed)break outer;r.sampleQueue.length>0&&r.sampleQueue[0].timestamp<n&&(t=r,n=r.sampleQueue[0].timestamp)}if(!t)break;let r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}async finalizeFragment(e=!0){y(this.isFragmented);let t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();let e=U(this);if(this.boxWriter.writeBox(e),this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}let n=this.trackDatas.filter(e=>e.currentChunk),r=Vt(t,n),i=this.writer.getPos(),a=i+this.boxWriter.measureBox(r),o=a+8,s=1/0;for(let e of n){e.currentChunk.offset=o,e.currentChunk.moofOffset=i;for(let t of e.currentChunk.samples)o+=t.size;s=Math.min(s,e.currentChunk.startTimestamp)}let c=o-a,l=c>=2**32;if(l)for(let e of n)e.currentChunk.offset+=8;this.format._options.onMoof&&this.writer.startTrackingWrites();let u=Vt(t,n);if(this.boxWriter.writeBox(u),this.format._options.onMoof){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoof(e,t,s)}y(this.writer.getPos()===a),this.format._options.onMdat&&this.writer.startTrackingWrites();let d=H(l);d.size=c,this.boxWriter.writeBox(d),this.writer.seek(a+(l?16:8));for(let e of n)for(let t of e.currentChunk.samples)this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}for(let e of n)e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk),e.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){let e=U(this),t=this.boxWriter.measureBox(e)+this.computeSampleTableSizeUpperBound()+4096;y(this.ftypSize!==null),this.writer.seek(this.ftypSize+t),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=H(!0),this.boxWriter.writeBox(this.mdat);for(let e of this.trackDatas){for(let t of e.sampleQueue)await this.addSampleToTrack(e,t);e.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){y(this.fastStart===`reserve`);let e=0;for(let t of this.trackDatas){let n=t.track.metadata.maximumPacketCount;y(n!==void 0),e+=8*Math.ceil(2/3*n),e+=4*n,e+=8*Math.ceil(2/3*n),e+=12*Math.ceil(2/3*n),e+=4*n,e+=8*n}return e}async onTrackClose(e){let t=await this.mutex.acquire(),n=this.trackDatas.find(t=>t.track===e);n&&(n.type===`subtitle`&&e.source._codec===`webvtt`&&await this.processWebVTTCues(n,1/0),this.processTimestamps(n)),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve();for(let e of this.trackDatas)e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);if(this.isFragmented)await this.interleaveSamples(!0),await this.finalizeFragment(!1);else for(let e of this.trackDatas)await this.finalizeCurrentChunk(e);if(this.fastStart===`in-memory`){this.mdat=H(!1);let e;for(let t=0;t<2;t++){let t=U(this),n=this.boxWriter.measureBox(t);e=this.boxWriter.measureBox(this.mdat);let r=this.writer.getPos()+n+e;for(let t of this.finalizedChunks){t.offset=r;for(let{data:n}of t.samples)y(n),r+=n.byteLength,e+=n.byteLength}if(r<2**32)break;e>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();let t=U(this);if(this.boxWriter.writeBox(t),this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=e,this.boxWriter.writeBox(this.mdat);for(let e of this.finalizedChunks)for(let t of e.samples)y(t.data),this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}}else if(this.isFragmented){let e=this.writer.getPos(),t=Jt(this.trackDatas);this.boxWriter.writeBox(t);let n=this.writer.getPos()-e;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(n)}else{y(this.mdat);let e=this.boxWriter.offsets.get(this.mdat);y(e!==void 0);let t=this.writer.getPos()-e;if(this.mdat.size=t,this.mdat.largeSize=t>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}let n=U(this);if(this.fastStart===`reserve`){y(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);let e=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(et(e))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);if(this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}e()}},wn=class{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>n.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>o.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>x.includes(e))}_codecUnsupportedHint(e){return``}},Tn=class extends wn{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.fastStart!==void 0&&![!1,`in-memory`,`reserve`,`fragmented`].includes(e.fastStart))throw TypeError(`options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.`);if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw TypeError(`options.minimumFragmentDuration, when provided, must be a non-negative number.`);if(e.onFtyp!==void 0&&typeof e.onFtyp!=`function`)throw TypeError(`options.onFtyp, when provided, must be a function.`);if(e.onMoov!==void 0&&typeof e.onMoov!=`function`)throw TypeError(`options.onMoov, when provided, must be a function.`);if(e.onMdat!==void 0&&typeof e.onMdat!=`function`)throw TypeError(`options.onMdat, when provided, must be a function.`);if(e.onMoof!==void 0&&typeof e.onMoof!=`function`)throw TypeError(`options.onMoof, when provided, must be a function.`);if(e.metadataFormat!==void 0&&![`mdir`,`mdta`,`udta`,`auto`].includes(e.metadataFormat))throw TypeError(`options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.`);super(),this._options=e}getSupportedTrackCounts(){let e=2**32-1;return{video:{min:0,max:e},audio:{min:0,max:e},subtitle:{min:0,max:e},total:{min:1,max:e}}}get supportsVideoRotationMetadata(){return!0}get supportsTimestampedMediaData(){return!0}_createMuxer(e){return new Cn(e,this)}},En=class extends Tn{constructor(e){super(e)}get _name(){return`MP4`}get fileExtension(){return`.mp4`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...n,...a,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...x]}_codecUnsupportedHint(e){return new Dn().getSupportedCodecs().includes(e)?` Switching to MOV will grant support for this codec.`:``}},Dn=class extends Tn{constructor(e){super(e)}get _name(){return`MOV`}get fileExtension(){return`.mov`}get mimeType(){return`video/quicktime`}getSupportedCodecs(){return[...n,...o]}_codecUnsupportedHint(e){return new En().getSupportedCodecs().includes(e)?` Switching to MP4 will grant support for this codec.`:``}},On=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!n.includes(e.codec))throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${n.join(`, `)}.`);if(!(e.bitrate instanceof X)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate must be a positive integer or a quality.`);if(e.keyFrameInterval!==void 0&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw TypeError(`config.keyFrameInterval, when provided, must be a non-negative number.`);if(e.sizeChangeBehavior!==void 0&&![`deny`,`passThrough`,`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.`);if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedChunk, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);kn(e.codec,e)},kn=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.alpha!==void 0&&![`discard`,`keep`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'discard' or 'keep'.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.latencyMode!==void 0&&![`quality`,`realtime`].includes(t.latencyMode))throw TypeError(`latencyMode, when provided, must be 'quality' or 'realtime'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&u(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(t.hardwareAcceleration!==void 0&&![`no-preference`,`prefer-hardware`,`prefer-software`].includes(t.hardwareAcceleration))throw TypeError(`hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.`);if(t.scalabilityMode!==void 0&&typeof t.scalabilityMode!=`string`)throw TypeError(`scalabilityMode, when provided, must be a string.`);if(t.contentHint!==void 0&&typeof t.contentHint!=`string`)throw TypeError(`contentHint, when provided, must be a string.`)},An=e=>{let t=e.bitrate instanceof X?e.bitrate._toVideoBitrate(e.codec,e.width,e.height):e.bitrate;return{codec:e.fullCodecString??m(e.codec,e.width,e.height,t),width:e.width,height:e.height,displayWidth:e.squarePixelWidth,displayHeight:e.squarePixelHeight,bitrate:t,bitrateMode:e.bitrateMode,alpha:e.alpha??`discard`,framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...s(e.codec)}},jn=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!o.includes(e.codec))throw TypeError(`Invalid audio codec '${e.codec}'. Must be one of: ${o.join(`, `)}.`);if(e.bitrate===void 0&&(!g.includes(e.codec)||e.codec===`flac`))throw TypeError(`config.bitrate must be provided for compressed audio codecs.`);if(e.bitrate!==void 0&&!(e.bitrate instanceof X)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate, when provided, must be a positive integer or a quality.`);if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedChunk, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);Mn(e.codec,e)},Mn=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&u(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`)},Nn=e=>{let t=e.bitrate instanceof X?e.bitrate._toAudioBitrate(e.codec):e.bitrate;return{codec:e.fullCodecString??Te(e.codec,e.numberOfChannels,e.sampleRate),numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,bitrate:t,bitrateMode:e.bitrateMode,..._(e.codec)}},X=class{constructor(e){this._factor=e}_toVideoBitrate(e,t,n){let r=3e6*(t*n/(1920*1080))**.95*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2}[e]*this._factor;return Math.ceil(r/1e3)*1e3}_toAudioBitrate(e){if(g.includes(e)||e===`flac`)return;let t={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3,ac3:384e3,eac3:192e3}[e];if(!t)throw Error(`Unhandled codec: ${e}`);let n=t*this._factor;return e===`aac`?n=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e):e===`opus`||e===`vorbis`?n=Math.max(6e3,n):e===`mp3`&&(n=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e)),Math.round(n/1e3)*1e3}},Pn=new X(2),Fn=async(e,t={})=>{let{width:r=1280,height:i=720,bitrate:a=1e6,...o}=t;if(!n.includes(e))return!1;if(!Number.isInteger(r)||r<=0)throw TypeError(`width must be a positive integer.`);if(!Number.isInteger(i)||i<=0)throw TypeError(`height must be a positive integer.`);if(!(a instanceof X)&&(!Number.isInteger(a)||a<=0))throw TypeError(`bitrate must be a positive integer or a quality.`);kn(e,o);let s=null;return be.length>0&&(s??=An({codec:e,width:r,height:i,bitrate:a,framerate:void 0,...o}),be.some(t=>t.supports(e,s)))?!0:typeof VideoEncoder>`u`||(r%2==1||i%2==1)&&(e===`avc`||e===`hevc`)||(s??=An({codec:e,width:r,height:i,bitrate:a,framerate:void 0,...o,alpha:`discard`}),!(await VideoEncoder.isConfigSupported(s)).supported)?!1:fe()?new Promise(async e=>{try{let t=new VideoEncoder({output:()=>{},error:()=>e(!1)});t.configure(s);let n=new Uint8Array(r*i*4),a=new VideoFrame(n,{format:`RGBA`,codedWidth:r,codedHeight:i,timestamp:0});t.encode(a),a.close(),await t.flush(),e(!0)}catch{e(!1)}}):!0},In=async(e,t={})=>{let{numberOfChannels:n=2,sampleRate:r=48e3,bitrate:i=128e3,...a}=t;if(!o.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`numberOfChannels must be a positive integer.`);if(!Number.isInteger(r)||r<=0)throw TypeError(`sampleRate must be a positive integer.`);if(!(i instanceof X)&&(!Number.isInteger(i)||i<=0))throw TypeError(`bitrate must be a positive integer.`);Mn(e,a);let s=null;return Se.length>0&&(s??=Nn({codec:e,numberOfChannels:n,sampleRate:r,bitrate:i,...a}),Se.some(t=>t.supports(e,s)))||g.includes(e)?!0:typeof AudioEncoder>`u`?!1:(s??=Nn({codec:e,numberOfChannels:n,sampleRate:r,bitrate:i,...a}),(await AudioEncoder.isConfigSupported(s)).supported===!0)},Ln=async(e,t)=>{for(let n of e)if(await Fn(n,t))return n;return null},Rn=async(e,t)=>{for(let n of e)if(await In(n,t))return n;return null},zn=class{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw Error(`Source is not connected to an output track.`);if(this._connectedTrack.output.state===`canceled`)throw Error(`Output has been canceled.`);if(this._connectedTrack.output.state===`finalizing`||this._connectedTrack.output.state===`finalized`)throw Error(`Output has been finalized.`);if(this._connectedTrack.output.state===`pending`)throw Error(`Output has not started.`);if(this._closed)throw Error(`Source is closed.`)}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;let e=this._connectedTrack;if(!e)throw Error(`Cannot call close without connecting the source to an output track.`);if(e.output.state===`pending`)throw Error(`Cannot call close before output has been started.`);this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,!(e.output.state===`finalizing`||e.output.state===`finalized`)&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise??=(async()=>{await this._flushAndClose(e),this._closed=!0})()}},Bn=class extends zn{constructor(e){if(super(),this._connectedTrack=null,!n.includes(e))throw TypeError(`Invalid video codec '${e}'. Must be one of: ${n.join(`, `)}.`);this._codec=e}},Vn=class{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new ce,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null}async add(e,t,n){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight){let n=this.encodingConfig.sizeChangeBehavior??`deny`;if(n!==`passThrough`){if(n===`deny`)throw Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'strict' in the encoding options.`);{let r=!1;this.resizeCanvas||(typeof document<`u`?(this.resizeCanvas=document.createElement(`canvas`),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),r=!0);let i=this.resizeCanvas.getContext(`2d`,{alpha:fe()});y(i),r||(fe()?(i.fillStyle=`black`,i.fillRect(0,0,this.codedWidth,this.codedHeight)):i.clearRect(0,0,this.codedWidth,this.codedHeight)),e.drawWithFit(i,{fit:n}),t&&e.close(),e=new ge(this.resizeCanvas,{timestamp:e.timestamp,duration:e.duration,rotation:e.rotation}),t=!0}}}}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),y(this.encoderInitialized);let r=this.encodingConfig.keyFrameInterval??5,i=Math.floor(e.timestamp/r),a={...n,keyFrame:n?.keyFrame||r===0||i!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=i,this.customEncoder){this.customEncoderQueueSize++;let t=e.clone(),n=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t,a)).then(()=>this.customEncoderQueueSize--).catch(e=>this.error??=e).finally(()=>{t.close()});this.customEncoderQueueSize>=4&&await n}else{y(this.encoder);let n=e.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(n,a),n.close();else if(n.format&&!n.format.includes(`A`)||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(n,a),n.close();else{let e=n.displayWidth,t=n.displayHeight;if(!this.splitter)try{this.splitter=new Hn(e,t)}catch(e){console.error(`Due to an error, only color data will be encoded.`,e),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(n,a),n.close()}if(this.splitter){let e=this.splitter.extractColor(n),t=this.splitter.extractAlpha(n);this.alphaFrameQueue.push(t),this.encoder.encode(e,a),e.close(),n.close()}}t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener(`dequeue`,e,{once:!0}))}await this.muxer.mutex.currentPromise}finally{t&&e.close()}}ensureEncoder(e){this.ensureEncoderPromise=(async()=>{let t=An({width:e.codedWidth,height:e.codedHeight,squarePixelWidth:e.squarePixelWidth,squarePixelHeight:e.squarePixelHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(t);let n=be.find(e=>e.supports(this.encodingConfig.codec,t));if(n)this.customEncoder=new n,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=t,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof C))throw TypeError(`The first argument passed to onPacket must be an EncodedPacket.`);if(t!==void 0&&(!t||typeof t!=`object`))throw TypeError(`The second argument passed to onPacket must be an object or undefined.`);this.encodingConfig.onEncodedPacket?.(e,t),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,e,t).catch(e=>{this.error??=e})},await this.customEncoder.init();else{if(typeof VideoEncoder>`u`)throw Error(`VideoEncoder is not supported by this browser.`);if(t.alpha=`discard`,this.encodingConfig.alpha===`keep`&&(t.latencyMode=`quality`),(t.width%2==1||t.height%2==1)&&(this.encodingConfig.codec===`avc`||this.encodingConfig.codec===`hevc`))throw Error(`The dimensions ${t.width}x${t.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);if(!(await VideoEncoder.isConfigSupported(t)).supported)throw Error(`This specific encoder configuration (${t.codec}, ${t.bitrate} bps, ${t.width}x${t.height}, hardware acceleration: ${t.hardwareAcceleration??`no-preference`}) is not supported by this browser. Consider using another codec or changing your video parameters.`);let e=[],n=[],r=0,i=0,a=(e,t,n)=>{let r={};if(t){let e=new Uint8Array(t.byteLength);t.copyTo(e),r.alpha=e}let i=C.fromEncodedChunk(e,r);this.encodingConfig.onEncodedPacket?.(i,n),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,i,n).catch(e=>{this.error??=e})},o=Error(`Encoding error`).stack;if(this.encoder=new VideoEncoder({output:(t,o)=>{if(!this.alphaEncoder){a(t,null,o);return}let s=this.alphaFrameQueue.shift();y(s!==void 0),s?(this.alphaEncoder.encode(s,{keyFrame:t.type===`key`}),i++,s.close(),e.push({chunk:t,meta:o})):i===0?a(t,null,o):(n.push(r+i),e.push({chunk:t,meta:o}))},error:e=>{e.stack=o,this.error??=e}}),this.encoder.configure(t),this.encodingConfig.alpha===`keep`){let o=Error(`Encoding error`).stack;this.alphaEncoder=new VideoEncoder({output:(t,o)=>{i--;let s=e.shift();for(y(s!==void 0),a(s.chunk,t,s.meta),r++;n.length>0&&n[0]===r;){n.shift();let t=e.shift();y(t!==void 0),a(t.chunk,null,t.meta)}},error:e=>{e.stack=o,this.error??=e}}),this.alphaEncoder.configure(t)}}y(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.error}},Hn=class{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<`u`?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement(`canvas`),this.canvas.width=e,this.canvas.height=t);let n=this.canvas.getContext(`webgl2`,{alpha:!0});if(!n)throw Error(`Couldn't acquire WebGL 2 context.`);this.gl=n,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,`u_resolution`),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,`u_sourceTexture`),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,`u_sourceTexture`),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
|
|
2
2
|
in vec2 a_position;
|
|
3
3
|
in vec2 a_texCoord;
|
|
4
4
|
out vec2 v_texCoord;
|
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
</style>
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
11
|
-
<script type="module" crossorigin src="./assets/index-
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-B1NWkbV5.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/chunk-DseTPa7n.js">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.15",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"patch-package": "^8.0.1",
|
|
31
31
|
"pixelmatch": "^7.1.0",
|
|
32
32
|
"pngjs": "^7.0.0",
|
|
33
|
-
"polotno": "^2.38.
|
|
33
|
+
"polotno": "^2.38.2",
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"react-dom": "^18.3.1",
|
|
36
36
|
"vite": "^8.0.0",
|