single-file-core 1.5.88 → 1.5.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.88",
3
+ "version": "1.5.89",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -1 +1 @@
1
- !function(){"use strict";const{Array:t,Object:e,Number:n,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:a,Int32Array:i,Map:l,DataView:u,Promise:f,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,v=void 0,k="undefined",z="function",C=new o,b=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;b[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=b[e-1][t];b[e][t]=n>>>8^b[0][255&n]}const[A,I,x,P,M,B,D,F]=b;class _{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let r=0;if(n>=8&&t.buffer){const s=new u(t.buffer,t.byteOffset,n),o=n-8;for(;o>=r;r+=8){const t=e^s.getInt32(r,!0),n=s.getInt32(r+4,!0);e=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^M[t>>>24&255]^P[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>r;r++)e=e>>>8^A[255&(e^t[r])];this.o=e}get(){return~this.o}}class R extends d{constructor(){let t;const e=new _;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new u(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function T(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function U(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const V={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],r=V.l(n);return 32===r?t.concat(e):V.h(e,r,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+V.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,r.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=V.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>r.round(t/1099511627776)||32,h(t,e,n,r){for(void 0===r&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(let s=0;s<t.length;s++)r.push(n|t[s]>>>e),n=t[s]<<32-e;const s=t.length?t[t.length-1]:0,o=V.l(s);return r.push(V.S(e+o&31,e+o>32?n:r.pop(),1)),r}},K={bytes:{v(t){const e=V.bitLength(t)/8,n=new o(e);let r;for(let s=0;e>s;s++)3&s||(r=t[s/4]),n[s]=r>>>24,r<<=8;return n},C(t){const e=[];let n,r=0;for(n=0;n<t.length;n++)r=r<<8|t[n],3&~n||(e.push(r),r=0);return 3&n&&e.push(V.S(8*(3&n),r)),e}}},E=class{constructor(t){const e=this;e.blockSize=512,e.A=[1732584193,4023233417,2562383102,271733878,3285377520],e.I=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.M=t.M.slice(0),e.B=t.B):e.reset()}reset(){const t=this;return t.P=t.A.slice(0),t.M=[],t.B=0,t}update(t){const e=this;"string"==typeof t&&(t=K.D.C(t));const n=e.M=V.concat(e.M,t),r=e.B,o=e.B=r+V.bitLength(t);if(o>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new a(n);let i=0;for(let t=e.blockSize+r-(e.blockSize+r&e.blockSize-1);o>=t;t+=e.blockSize)e.F(c.subarray(16*i,16*(i+1))),i+=1;return n.splice(0,16*i),e}_(){const t=this;let e=t.M;const n=t.P;e=V.concat(e,[V.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(r.floor(t.B/4294967296)),e.push(0|t.B);e.length;)t.F(e.splice(0,16));return t.reset(),n}R(t,e,n,r){return t>19?t>39?t>59?t>79?void 0:e^n^r:e&n|e&r|n&r:e^n^r:e&n|~e&r}T(t,e){return e<<t|e>>>32-t}F(e){const n=this,s=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=s[0],a=s[1],i=s[2],l=s[3],u=s[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.T(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.T(5,c)+n.R(t,a,i,l)+u+o[t]+n.I[r.floor(t/20)]|0;u=l,l=i,i=n.T(30,a),a=c,c=e}s[0]=s[0]+c|0,s[1]=s[1]+a|0,s[2]=s[2]+i|0,s[3]=s[3]+l|0,s[4]=s[4]+u|0}},O={importKey:t=>new O.U(K.bytes.C(t)),V(t,e,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const o=1+(r>>5)<<2;let c,a,i,l,f;const w=new ArrayBuffer(o),h=new u(w);let p=0;const d=V;for(e=K.bytes.C(e),f=1;(o||1)>p;f++){for(c=a=t.encrypt(d.concat(e,[f])),i=1;n>i;i++)for(a=t.encrypt(a),l=0;l<a.length;l++)c[l]^=a[l];for(i=0;(o||1)>p&&i<c.length;i++)h.setInt32(p,c[i]),p+=4}return w.slice(0,r/8)},U:class{constructor(t){const e=this,n=e.K=E,r=[[],[]];e.O=[new n,new n];const s=e.O[0].blockSize/32;t.length>s&&(t=(new n).update(t)._());for(let e=0;s>e;e++)r[0][e]=909522486^t[e],r[1][e]=1549556828^t[e];e.O[0].update(r[0]),e.O[1].update(r[1]),e.W=new n(e.O[0])}reset(){const t=this;t.W=new t.K(t.O[0]),t.j=!1}update(t){this.j=!0,this.W.update(t)}digest(){const t=this,e=t.W._(),n=new t.K(t.O[1]).update(e)._();return t.reset(),n}encrypt(t){if(this.j)throw new s("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},W=typeof h!=k&&typeof h.getRandomValues==z,j="Invalid password",H="Invalid signature",L=H,N="zipjs-abort-check-password";function q(t){if(W)return h.getRandomValues(t);throw new s("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=k,rt=nt&&h.subtle,st=nt&&typeof rt!=k,ot=K.bytes,ct=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.L();const n=e.H[0][4],r=e.H[1],o=t.length;let c,a,i,l=1;if(4!==o&&6!==o&&8!==o)throw new s("invalid aes key size");for(e.I=[a=t.slice(0),i=[]],c=o;4*o+28>c;c++){let t=a[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^l<<24,l=l<<1^283*(l>>7))),a[c]=a[c-o]^t}for(let t=0;c;t++,c--){const e=a[3&t?c:c-4];i[t]=4>=c||4>t?e:r[0][n[e>>>24]]^r[1][n[e>>16&255]]^r[2][n[e>>8&255]]^r[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}L(){const t=this.H[0],e=this.H[1],n=t[4],r=e[4],s=[],o=[];let c,a,i,l;for(let t=0;256>t;t++)o[(s[t]=t<<1^283*(t>>7))^t]=t;for(let u=c=0;!n[u];u^=a||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[u]=o,r[o]=u,l=s[i=s[a=s[u]]];let f=16843009*l^65537*i^257*a^16843008*u,w=257*s[o]^16843008*o;for(let n=0;4>n;n++)t[n][u]=w=w<<24^w>>>8,e[n][o]=f=f<<24^f>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new s("invalid aes block size");const n=this.I[e],r=n.length/4-2,o=[0,0,0,0],c=this.H[e],a=c[0],i=c[1],l=c[2],u=c[3],f=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;r>t;t++)w=a[d>>>24]^i[y>>16&255]^l[m>>8&255]^u[255&g]^n[S],h=a[y>>>24]^i[m>>16&255]^l[g>>8&255]^u[255&d]^n[S+1],p=a[m>>>24]^i[g>>16&255]^l[d>>8&255]^u[255&y]^n[S+2],g=a[g>>>24]^i[d>>16&255]^l[y>>8&255]^u[255&m]^n[S+3],S+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=f[d>>>24]<<24^f[y>>16&255]<<16^f[m>>8&255]<<8^f[255&g]^n[S++],w=d,d=y,y=m,m=g,g=w;return o}},at=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let r;if(!(r=e.length))return[];const s=V.bitLength(e);for(let s=0;r>s;s+=4){this.$(n);const r=t.encrypt(n);e[s]^=r[0],e[s+1]^=r[1],e[s+2]^=r[2],e[s+3]^=r[3]}return V.m(e,s)}},it=O.U;let lt=nt&&st&&typeof rt.importKey==z,ut=nt&&st&&typeof rt.deriveBits==z;class ft extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:a,et:i,ready:l}=n;c?(await(async(t,e,n,r)=>{const o=await dt(t,e,n,mt(r,0,Z[e])),c=mt(r,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new s(j)})(n,a,c,mt(t,0,Z[a]+2)),t=mt(t,Z[a]+2),r?e.error(new s(N)):i()):await l;const u=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,u,0,tt,!0))},async flush(t){const{nt:e,st:n,pending:r,ready:o}=this;if(n&&e){await o;const a=mt(r,0,r.length-tt),i=mt(r,r.length-tt);let l=C;if(a.length){const t=St(ot,a);n.update(t);const r=e.update(t);l=gt(ot,r)}const u=mt(gt(ot,n.digest()),0,tt);let f=r.length<tt?1:0;for(let t=0;tt>t;t++)f|=u[t]^i[t];if(f&&c)throw new s(L);t.enqueue(l)}}})}}class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:r,strength:s,et:c,ready:a}=n;let i=C;r?(i=await(async(t,e,n)=>{const r=q(new o(Z[e]));return T(r,await dt(t,e,n,r))})(n,s,r),c()):await a;const l=new o(i.length+t.length-t.length%G);l.set(i,0),e.enqueue(pt(n,t,l,i.length,0))},async flush(t){const{nt:e,st:n,pending:r,ready:s}=this;if(n&&e){await s;let o=C;if(r.length){const t=e.update(St(ot,r));n.update(t),o=gt(ot,t)}const c=gt(ot,n.digest()).slice(0,tt);t.enqueue(T(o,c))}}})}}function ht(t,n,r,s){e.assign(t,{ready:new f(e=>t.et=e),password:yt(n,r),strength:s-1,pending:C})}function pt(t,e,n,r,s,c){const{nt:a,st:i,pending:l}=t;l.length&&(e=T(l,e));const u=e.length-s;let f;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,r+(u-u%G)),f=0;u-G>=f;f+=G){const t=St(ot,mt(e,f,f+G));c&&i.update(t);const s=a.update(t);c||i.update(s),n.set(gt(ot,s),f+r)}return t.pending=mt(e,f),n}async function dt(n,r,s,c){n.password=null;const a=await(async(t,e,n,r,s)=>{if(!lt)return O.importKey(e);try{return await rt.importKey("raw",e,n,!1,s)}catch{return lt=!1,O.importKey(e)}})(0,s,Q,0,Y),i=await(async(t,e,n)=>{if(!ut)return O.V(e,t.salt,X.iterations,n);try{return await rt.deriveBits(t,e,n)}catch{return ut=!1,O.V(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),a,8*(2*$[r]+2)),l=new o(i),u=St(ot,mt(l,0,$[r])),f=St(ot,mt(l,$[r],2*$[r])),w=mt(l,2*$[r]);return e.assign(n,{keys:{key:u,ot:f,passwordVerification:w},nt:new at(new ct(u),t.from(et)),st:new it(f)}),w}function yt(t,e){return e===v?(t=>{if(typeof w==k){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function gt(t,e){return t.v(e)}function St(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){zt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=Ct(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new s(j);t=t.subarray(12)}r?e.error(new s(N)):e.enqueue(Ct(n,t))}})}}class kt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){zt(this,t,e,n)},transform(t,e){const n=this;let r,s;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=q(new o(12));e[11]=n.passwordVerification,r=new o(t.length+e.length),r.set(bt(n,e),0),s=12}else r=new o(t.length),s=0;r.set(bt(n,t),s),e.enqueue(r)}})}}function zt(t,n,r,s){e.assign(t,{password:n,rawPassword:r,passwordVerification:s}),((t,n,r)=>{const s=[305419896,591751049,878082192];if(e.assign(t,{keys:s,ct:new _(s[0]),it:new _(s[2])}),r)for(let e=0;e<r.length;e++)At(t,r[e]);else for(let e=0;e<n.length;e++)At(t,n.charCodeAt(e))})(t,n,r)}function Ct(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=It(t)^e[r],At(t,n[r]);return n}function bt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=It(t)^e[r],At(t,e[r]);return n}function At(t,e){let[,n]=t.keys;t.ct.append([e]);const s=~t.ct.get();n=Pt(r.imul(Pt(n+xt(s)),134775813)+1),t.it.append([n>>>24]);const o=~t.it.get();t.keys=[s,n,o]}function It(t){const e=2|t.keys[2];return xt(r.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Pt(t){return 4294967295&t}const Mt=new l;function Bt(t){return Mt.get(t)}const Dt="Invalid uncompressed size",Ft=H,_t="deflate-raw",Rt="gzip",Tt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,computeCrc32:i,level:l,deflate64:f,format:w,compressionMethod:h}=t,p=this;let d,y,m,g=super.readable;const S=w&&Bt(w),v=i&&s&&!f&&!S&&(!o||a)&&!(!c||!r);if(o&&!a||!i||v||(d=new R,g=Ht(g,d)),s)if(S)g=Lt(g,Wt(S.CompressionStream,w,{level:l,chunkSize:e,compressionMethod:h}));else if(v)m=new Vt,g=Lt(g,new r(Rt)),g=Ht(g,m);else try{g=jt(g,c,{level:l,chunkSize:e},r,n)}catch(t){let e;try{e=new r(Rt)}catch{throw t}g=Lt(g,e),g=Ht(g,new Vt)}o&&(a?g=Ht(g,new kt(t)):(y=new wt(t),g=Ht(g,y))),Ot(p,g,()=>{o&&!a||!i||(p.crc32=v?m.crc32:new u(d.value.buffer).getUint32(0))})}}class Vt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,s){if(e){const n=r.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=T(n,t));const c=o-8,a=r.min(c,n.length);s.enqueue(T(n.subarray(0,a),t.subarray(0,c-a))),n=T(n.subarray(a),t.subarray(c-a))},flush(){const e=U(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Kt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:a,checkCrc32:i,crc32:l,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:g,rawBitFlag:S,outputSize:k}=t;let z,C,b=super.readable;if(a&&(c?b=Ht(b,new vt(t)):(C=new ft(t),b=Ht(b,C))),w){const t=m&&Bt(m);if(t)b=Lt(b,Wt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:g,rawBitFlag:S,uncompressedSize:k}));else try{b=jt(b,h,{chunkSize:e,deflate64:p},r,n)}catch(t){if(p||k===v)throw t;let e;try{e=new r(Rt)}catch{throw t}b=((t,e,n)=>{const r=new _;let c,a,i,l=0,u=!1;const w=new f((t,e)=>{a=t,i=e});w.catch(()=>{}),n||a();const h=new d({start(t){const e=new o(10);e.set(Tt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){u=!0,y();try{await w}finally{m()}const e=new o(8),s=U(e);s.setUint32(0,r.get(),!0),s.setUint32(4,n,!0),t.enqueue(e)},cancel(t){i(t)}}),p=new d({transform(t,e){r.append(t),l+=t.length,n>l?u&&y():a(),e.enqueue(t)},cancel(t){i(t)}});return t=Ht(t,h),Ht(t=Lt(t,e),p);function y(){m(),c=setTimeout(()=>i(new s(Dt)),5e3)}function m(){clearTimeout(c)}})(b,e,k)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new s("Invalid compressed data");throw e.cause=t,e}const{value:r,done:o}=n;o?t.close():t.enqueue(r)},cancel:t=>e.cancel(t)})})(b)}i&&(z=new R,b=Ht(b,z)),Ot(this,b,()=>{if(i){const t=new u(z.value.buffer);if(l!=t.getUint32(0,!1))throw new s(Ft)}})}}const Et=new l;function Ot(t,n,r){n=Ht(n,new d({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}function Wt(t,e,n){if(!t)throw new s("Compression method not supported");return new t(e,n)}function jt(t,e,n,r,s){const o=e&&r?r:s||r,c=n.deflate64?"deflate64-raw":_t;let a;try{a=new o(c,n)}catch(t){if(!e||!s||o==s)throw t;a=new s(c,n)}return Lt(t,a)}function Ht(t,e){return(t=>{if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:r}=await e.read();r?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})})(t).pipeThrough(e)}function Lt(t,e){const n=e.writable.getWriter(),r=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await r.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(r,t)}})(),e.readable}const Nt="data",qt="close",Gt="deflate";class Jt extends d{constructor(t,n){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Gt)?c=Ut:o.startsWith("inflate")&&(c=Kt),r.outputSize=0;let a=0;const i=new c(t,n),l=super.readable,u=new d({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(r,{inputSize:a})}}),f=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),r.outputSize+=e.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Dt)},flush(){const{crc32:t}=i;e.assign(r,{crc32:t,inputSize:a})}});e.defineProperty(r,"readable",{get:()=>l.pipeThrough(u).pipeThrough(i).pipeThrough(f)})}}class Qt extends d{constructor(t){const e=[];let r=0;function s(){const n=new o(t);let s=0;for(;t>s;){const r=e[0],o=t-s;r.length>o?(n.set(r.subarray(0,o),s),e[0]=r.subarray(o),s+=o):(n.set(r,s),s+=r.length,e.shift())}return r-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),r+=n.length;r>t;)o.enqueue(s())},flush(t){r&&t.enqueue(((t,e)=>{const n=new o(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n})(e,r))}})}}let Xt=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(Xt=navigator.hardwareConcurrency)}catch{}const Yt=new l,Zt=new l;let $t,te=0;async function ee(t){let e,o;try{const{options:c,config:a}=t;if(c.format)try{await(async(t,e)=>{!Mt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:r}=e;if(typeof n!=z&&typeof r!=z)throw new s("Invalid codec module");Mt.set(t,{CompressionStream:n,DecompressionStream:r})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(a.CompressionStream=self.CompressionStream,a.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Et.get(t);n||(n=new l,Et.set(t,n));let r=n.get(e);if(r===v){try{new t(e),r=!0}catch{r=!1}n.set(e,r)}return r})(c.codecType.startsWith(Gt)?a.CompressionStream:a.DecompressionStream,_t))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const i={highWaterMark:1},u=t.readable||new y({async pull(t){const e=new f(t=>Yt.set(te,t));ne({type:"pull",messageId:te}),te=(te+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await e;t.enqueue(r),s&&t.close()}},i);o=t.writable||new m({async write(t){let e;const r=new f(t=>e=t);Zt.set(te,e),ne({type:Nt,value:t,messageId:te}),te=(te+1)%n.MAX_SAFE_INTEGER,await r}},i),e=new Jt(c,a),$t=new AbortController;const{signal:w}=$t;await u.pipeThrough(e).pipeThrough(new Qt((t=>r.max(t.chunkSize,64))(a))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ne({type:qt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}re(t)}}function ne(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function re(t=new s("Unknown error")){const{message:e,stack:n,code:r,name:o,outputSize:c,cause:a,codecImportFailed:i}=t,l={message:e,stack:n,code:r,name:o,outputSize:c};a&&(l.cause={name:a.name,message:a.message}),i&&(l.codecImportFailed=!0),p({error:l})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:r,done:s}=t;try{if("start"==e&&ee(t),e==Nt){const t=Yt.get(n);Yt.delete(n),t({value:r||new o,done:s})}if("ack"==e){const t=Zt.get(n);Zt.delete(n),t()}e==qt&&$t.abort()}catch(t){re(t)}}),p({type:"ready"}),((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),r&&(t.DecompressionStreamFallback=r)}})()}();
1
+ !function(){"use strict";const{Array:t,Object:e,Number:n,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:a,Int32Array:i,Map:u,DataView:f,Promise:l,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,v=void 0,k="undefined",z="function",b=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[I,A,x,P,M,B,D,F]=C;class _{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let r=0;if(n>=8&&t.buffer){const s=new f(t.buffer,t.byteOffset,n),o=n-8;for(;o>=r;r+=8){const t=e^s.getInt32(r,!0),n=s.getInt32(r+4,!0);e=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^M[t>>>24&255]^P[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>r;r++)e=e>>>8^I[255&(e^t[r])];this.o=e}get(){return~this.o}}class R extends d{constructor(){let t;const e=new _;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function T(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function U(t){return new f(t.buffer,t.byteOffset,t.byteLength)}const V={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],r=V.l(n);return 32===r?t.concat(e):V.h(e,r,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+V.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,r.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=V.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>r.round(t/1099511627776)||32,h(t,e,n,r){for(void 0===r&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(let s=0;s<t.length;s++)r.push(n|t[s]>>>e),n=t[s]<<32-e;const s=t.length?t[t.length-1]:0,o=V.l(s);return r.push(V.S(e+o&31,e+o>32?n:r.pop(),1)),r}},K={bytes:{v(t){const e=V.bitLength(t)/8,n=new o(e);let r;for(let s=0;e>s;s++)3&s||(r=t[s/4]),n[s]=r>>>24,r<<=8;return n},C(t){const e=[];let n,r=0;for(n=0;n<t.length;n++)r=r<<8|t[n],3&~n||(e.push(r),r=0);return 3&n&&e.push(V.S(8*(3&n),r)),e}}},E=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.A=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.M=t.M.slice(0),e.B=t.B):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.M=[],t.B=0,t}update(t){const e=this;"string"==typeof t&&(t=K.D.C(t));const n=e.M=V.concat(e.M,t),r=e.B,o=e.B=r+V.bitLength(t);if(o>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new a(n);let i=0;for(let t=e.blockSize+r-(e.blockSize+r&e.blockSize-1);o>=t;t+=e.blockSize)e.F(c.subarray(16*i,16*(i+1))),i+=1;return n.splice(0,16*i),e}_(){const t=this;let e=t.M;const n=t.P;e=V.concat(e,[V.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(r.floor(t.B/4294967296)),e.push(0|t.B);e.length;)t.F(e.splice(0,16));return t.reset(),n}R(t,e,n,r){return t>19?t>39?t>59?t>79?void 0:e^n^r:e&n|e&r|n&r:e^n^r:e&n|~e&r}T(t,e){return e<<t|e>>>32-t}F(e){const n=this,s=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=s[0],a=s[1],i=s[2],u=s[3],f=s[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.T(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.T(5,c)+n.R(t,a,i,u)+f+o[t]+n.A[r.floor(t/20)]|0;f=u,u=i,i=n.T(30,a),a=c,c=e}s[0]=s[0]+c|0,s[1]=s[1]+a|0,s[2]=s[2]+i|0,s[3]=s[3]+u|0,s[4]=s[4]+f|0}},O={importKey:t=>new O.U(K.bytes.C(t)),V(t,e,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const o=1+(r>>5)<<2;let c,a,i,u,l;const w=new ArrayBuffer(o),h=new f(w);let p=0;const d=V;for(e=K.bytes.C(e),l=1;(o||1)>p;l++){for(c=a=t.encrypt(d.concat(e,[l])),i=1;n>i;i++)for(a=t.encrypt(a),u=0;u<a.length;u++)c[u]^=a[u];for(i=0;(o||1)>p&&i<c.length;i++)h.setInt32(p,c[i]),p+=4}return w.slice(0,r/8)},U:class{constructor(t){const e=this,n=e.K=E,r=[[],[]];e.O=[new n,new n];const s=e.O[0].blockSize/32;t.length>s&&(t=(new n).update(t)._());for(let e=0;s>e;e++)r[0][e]=909522486^t[e],r[1][e]=1549556828^t[e];e.O[0].update(r[0]),e.O[1].update(r[1]),e.W=new n(e.O[0])}reset(){const t=this;t.W=new t.K(t.O[0]),t.j=!1}update(t){this.j=!0,this.W.update(t)}digest(){const t=this,e=t.W._(),n=new t.K(t.O[1]).update(e)._();return t.reset(),n}encrypt(t){if(this.j)throw new s("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},W=typeof h!=k&&typeof h.getRandomValues==z,j="Invalid password",H="Invalid signature",L=H,N="zipjs-abort-check-password";function q(t){if(W)return h.getRandomValues(t);throw new s("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=k,rt=nt&&h.subtle,st=nt&&typeof rt!=k,ot=K.bytes,ct=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.L();const n=e.H[0][4],r=e.H[1],o=t.length;let c,a,i,u=1;if(4!==o&&6!==o&&8!==o)throw new s("invalid aes key size");for(e.A=[a=t.slice(0),i=[]],c=o;4*o+28>c;c++){let t=a[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^u<<24,u=u<<1^283*(u>>7))),a[c]=a[c-o]^t}for(let t=0;c;t++,c--){const e=a[3&t?c:c-4];i[t]=4>=c||4>t?e:r[0][n[e>>>24]]^r[1][n[e>>16&255]]^r[2][n[e>>8&255]]^r[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}L(){const t=this.H[0],e=this.H[1],n=t[4],r=e[4],s=[],o=[];let c,a,i,u;for(let t=0;256>t;t++)o[(s[t]=t<<1^283*(t>>7))^t]=t;for(let f=c=0;!n[f];f^=a||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[f]=o,r[o]=f,u=s[i=s[a=s[f]]];let l=16843009*u^65537*i^257*a^16843008*f,w=257*s[o]^16843008*o;for(let n=0;4>n;n++)t[n][f]=w=w<<24^w>>>8,e[n][o]=l=l<<24^l>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new s("invalid aes block size");const n=this.A[e],r=n.length/4-2,o=[0,0,0,0],c=this.H[e],a=c[0],i=c[1],u=c[2],f=c[3],l=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;r>t;t++)w=a[d>>>24]^i[y>>16&255]^u[m>>8&255]^f[255&g]^n[S],h=a[y>>>24]^i[m>>16&255]^u[g>>8&255]^f[255&d]^n[S+1],p=a[m>>>24]^i[g>>16&255]^u[d>>8&255]^f[255&y]^n[S+2],g=a[g>>>24]^i[d>>16&255]^u[y>>8&255]^f[255&m]^n[S+3],S+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&g]^n[S++],w=d,d=y,y=m,m=g,g=w;return o}},at=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let r;if(!(r=e.length))return[];const s=V.bitLength(e);for(let s=0;r>s;s+=4){this.$(n);const r=t.encrypt(n);e[s]^=r[0],e[s+1]^=r[1],e[s+2]^=r[2],e[s+3]^=r[3]}return V.m(e,s)}},it=O.U;let ut=nt&&st&&typeof rt.importKey==z,ft=nt&&st&&typeof rt.deriveBits==z;class lt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:a,et:i,ready:u}=n;c?(await(async(t,e,n,r)=>{const o=await dt(t,e,n,mt(r,0,Z[e])),c=mt(r,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new s(j)})(n,a,c,mt(t,0,Z[a]+2)),t=mt(t,Z[a]+2),r?e.error(new s(N)):i()):await u;const f=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,f,0,tt,!0))},async flush(t){const{nt:e,st:n,ot:r,ready:o}=this;if(n&&e){await o;const a=mt(r,0,r.length-tt),i=mt(r,r.length-tt);let u=b;if(a.length){const t=St(ot,a);n.update(t);const r=e.update(t);u=gt(ot,r)}const f=mt(gt(ot,n.digest()),0,tt);let l=r.length<tt?1:0;for(let t=0;tt>t;t++)l|=f[t]^i[t];if(l&&c)throw new s(L);t.enqueue(u)}}})}}class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:r,strength:s,et:c,ready:a}=n;let i=b;r?(i=await(async(t,e,n)=>{const r=q(new o(Z[e]));return T(r,await dt(t,e,n,r))})(n,s,r),c()):await a;const u=new o(i.length+t.length-t.length%G);u.set(i,0),e.enqueue(pt(n,t,u,i.length,0))},async flush(t){const{nt:e,st:n,ot:r,ready:s}=this;if(n&&e){await s;let o=b;if(r.length){const t=e.update(St(ot,r));n.update(t),o=gt(ot,t)}const c=gt(ot,n.digest()).slice(0,tt);t.enqueue(T(o,c))}}})}}function ht(t,n,r,s){e.assign(t,{ready:new l(e=>t.et=e),password:yt(n,r),strength:s-1,ot:b})}function pt(t,e,n,r,s,c){const{nt:a,st:i,ot:u}=t;u.length&&(e=T(u,e));const f=e.length-s;let l;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,r+(f-f%G)),l=0;f-G>=l;l+=G){const t=St(ot,mt(e,l,l+G));c&&i.update(t);const s=a.update(t);c||i.update(s),n.set(gt(ot,s),l+r)}return t.ot=mt(e,l),n}async function dt(n,r,s,c){n.password=null;const a=await(async(t,e,n,r,s)=>{if(!ut)return O.importKey(e);try{return await rt.importKey("raw",e,n,!1,s)}catch{return ut=!1,O.importKey(e)}})(0,s,Q,0,Y),i=await(async(t,e,n)=>{if(!ft)return O.V(e,t.salt,X.iterations,n);try{return await rt.deriveBits(t,e,n)}catch{return ft=!1,O.V(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),a,8*(2*$[r]+2)),u=new o(i),f=St(ot,mt(u,0,$[r])),l=St(ot,mt(u,$[r],2*$[r])),w=mt(u,2*$[r]);return e.assign(n,{keys:{key:f,ct:l,passwordVerification:w},nt:new at(new ct(f),t.from(et)),st:new it(l)}),w}function yt(t,e){return e===v?(t=>{if(typeof w==k){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function gt(t,e){return t.v(e)}function St(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){zt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=bt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new s(j);t=t.subarray(12)}r?e.error(new s(N)):e.enqueue(bt(n,t))}})}}class kt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){zt(this,t,e,n)},transform(t,e){const n=this;let r,s;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=q(new o(12));e[11]=n.passwordVerification,r=new o(t.length+e.length),r.set(Ct(n,e),0),s=12}else r=new o(t.length),s=0;r.set(Ct(n,t),s),e.enqueue(r)}})}}function zt(t,n,r,s){e.assign(t,{password:n,rawPassword:r,passwordVerification:s}),((t,n,r)=>{const s=[305419896,591751049,878082192];if(e.assign(t,{keys:s,it:new _(s[0]),ut:new _(s[2])}),r)for(let e=0;e<r.length;e++)It(t,r[e]);else for(let e=0;e<n.length;e++)It(t,n.charCodeAt(e))})(t,n,r)}function bt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=At(t)^e[r],It(t,n[r]);return n}function Ct(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=At(t)^e[r],It(t,e[r]);return n}function It(t,e){let[,n]=t.keys;t.it.append([e]);const s=~t.it.get();n=Pt(r.imul(Pt(n+xt(s)),134775813)+1),t.ut.append([n>>>24]);const o=~t.ut.get();t.keys=[s,n,o]}function At(t){const e=2|t.keys[2];return xt(r.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Pt(t){return 4294967295&t}function Mt(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:r}=await e.read();r?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Bt=new u;function Dt(t){return Bt.get(t)}const Ft="Invalid uncompressed size",_t=H,Rt="deflate-raw",Tt="gzip",Ut=[31,139,8];class Vt extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,computeCrc32:i,level:u,deflate64:l,format:w,compressionMethod:h}=t,p=this;let d,y,m,g=super.readable;const S=w&&Dt(w),v=i&&s&&!l&&!S&&(!o||a)&&!(!c||!r);if(o&&!a||!i||v||(d=new R,g=Lt(g,d)),s)if(S)g=Nt(g,jt(S.CompressionStream,w,{level:u,chunkSize:e,compressionMethod:h}));else if(v)m=new Kt,g=Nt(g,new r(Tt)),g=Lt(g,m);else try{g=Ht(g,c,{level:u,chunkSize:e},r,n)}catch(t){let e;try{e=new r(Tt)}catch{throw t}g=Nt(g,e),g=Lt(g,new Kt)}o&&(a?g=Lt(g,new kt(t)):(y=new wt(t),g=Lt(g,y))),Wt(p,g,()=>{o&&!a||!i||(p.crc32=v?m.crc32:new f(d.value.buffer).getUint32(0))})}}class Kt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,s){if(e){const n=r.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=T(n,t));const c=o-8,a=r.min(c,n.length);s.enqueue(T(n.subarray(0,a),t.subarray(0,c-a))),n=T(n.subarray(a),t.subarray(c-a))},flush(){const e=U(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Et extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:a,checkCrc32:i,crc32:u,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:g,rawBitFlag:S,outputSize:k}=t;let z,b,C=super.readable;if(a&&(c?C=Lt(C,new vt(t)):(b=new lt(t),C=Lt(C,b))),w){const t=m&&Dt(m);if(t)C=Nt(C,jt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:g,rawBitFlag:S,uncompressedSize:k}));else try{C=Ht(C,h,{chunkSize:e,deflate64:p},r,n)}catch(t){if(p||k===v)throw t;let e;try{e=new r(Tt)}catch{throw t}C=((t,e,n)=>{const r=new _;let c,a,i,u=0,f=!1;const w=new l((t,e)=>{a=t,i=e});w.catch(()=>{}),n||a();const h=new d({start(t){const e=new o(10);e.set(Ut),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){f=!0,y();try{await w}finally{m()}const e=new o(8),s=U(e);s.setUint32(0,r.get(),!0),s.setUint32(4,n,!0),t.enqueue(e)},cancel(t){i(t)}}),p=new d({transform(t,e){r.append(t),u+=t.length,n>u?f&&y():a(),e.enqueue(t)},cancel(t){i(t)}});return t=Lt(t,h),Lt(t=Nt(t,e),p);function y(){m(),c=setTimeout(()=>i(new s(Ft)),5e3)}function m(){clearTimeout(c)}})(C,e,k)}C=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new s("Invalid compressed data");throw e.cause=t,e}const{value:r,done:o}=n;o?t.close():t.enqueue(r)},cancel:t=>e.cancel(t)})})(C)}i&&(z=new R,C=Lt(C,z)),Wt(this,C,()=>{if(i){const t=new f(z.value.buffer);if(u!=t.getUint32(0,!1))throw new s(_t)}})}}const Ot=new u;function Wt(t,n,r){n=Lt(n,new d({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}function jt(t,e,n){if(!t)throw new s("Compression method not supported");return new t(e,n)}function Ht(t,e,n,r,s){const o=e&&r?r:s||r,c=n.deflate64?"deflate64-raw":Rt;let a;try{a=new o(c,n)}catch(t){if(!e||!s||o==s)throw t;a=new s(c,n)}return Nt(t,a)}function Lt(t,e){return Mt(t).pipeThrough(e)}function Nt(t,e){const n=e.writable.getWriter(),r=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await r.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(r,t)}})(),e.readable}const qt="data",Gt="close",Jt="deflate";class Qt extends d{constructor(t,n){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Jt)?c=Vt:o.startsWith("inflate")&&(c=Et),r.outputSize=0;let a=0;const i=new c(t,n),u=super.readable,f=new d({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(r,{inputSize:a})}}),l=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),r.outputSize+=e.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Ft)},flush(){const{crc32:t}=i;e.assign(r,{crc32:t,inputSize:a})}});e.defineProperty(r,"readable",{get:()=>u.pipeThrough(f).pipeThrough(i).pipeThrough(l)})}}class Xt extends d{constructor(t){const e=[];let r=0;function s(){const n=new o(t);let s=0;for(;t>s;){const r=e[0],o=t-s;r.length>o?(n.set(r.subarray(0,o),s),e[0]=r.subarray(o),s+=o):(n.set(r,s),s+=r.length,e.shift())}return r-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),r+=n.length;r>t;)o.enqueue(s())},flush(t){r&&t.enqueue(((t,e)=>{const n=new o(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n})(e,r))}})}}let Yt=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(Yt=navigator.hardwareConcurrency)}catch{}const Zt=new u,$t=new u;let te,ee=0;async function ne(t){let e,o;try{const{options:c,config:a}=t;if(c.format)try{await(async(t,e)=>{!Bt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:r}=e;if(typeof n!=z&&typeof r!=z)throw new s("Invalid codec module");Bt.set(t,{CompressionStream:n,DecompressionStream:r})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(a.CompressionStream=self.CompressionStream,a.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Ot.get(t);n||(n=new u,Ot.set(t,n));let r=n.get(e);if(r===v){try{new t(e),r=!0}catch{r=!1}n.set(e,r)}return r})(c.codecType.startsWith(Jt)?a.CompressionStream:a.DecompressionStream,Rt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const i={highWaterMark:1},f=t.readable?Mt(t.readable):new y({async pull(t){const e=new l(t=>Zt.set(ee,t));re({type:"pull",messageId:ee}),ee=(ee+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await e;t.enqueue(r),s&&t.close()}},i);o=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const r=new l(t=>e=t);$t.set(ee,e),re({type:qt,value:t,messageId:ee}),ee=(ee+1)%n.MAX_SAFE_INTEGER,await r}},i),e=new Qt(c,a),te=new AbortController;const{signal:w}=te;await f.pipeThrough(e).pipeThrough(new Xt((t=>{return s="string"==typeof(e=s=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(s)&&s>=1?r.max(s,64):65536;var e,s})(a))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;re({type:Gt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}se(t)}}function re(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function se(t=new s("Unknown error")){const{message:e,stack:n,code:r,name:o,outputSize:c,cause:a,codecImportFailed:i}=t,u={message:e,stack:n,code:r,name:o,outputSize:c};a&&(u.cause={name:a.name,message:a.message}),i&&(u.codecImportFailed=!0),p({error:u})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:r,done:s}=t;try{if("start"==e&&ne(t),e==qt){const t=Zt.get(n);Zt.delete(n),t({value:r||new o,done:s})}if("ack"==e){const t=$t.get(n);$t.delete(n),t()}e==Gt&&te.abort()}catch(t){se(t)}}),p({type:"ready"}),((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),r&&(t.DecompressionStreamFallback=r)}})()}();