@zip.js/zip.js 2.12.0 → 2.13.1

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.
Files changed (41) hide show
  1. package/deno.json +1 -1
  2. package/dist/zip-core-external.js +158 -41
  3. package/dist/zip-core-external.min.js +1 -1
  4. package/dist/zip-core.js +158 -41
  5. package/dist/zip-core.min.js +1 -1
  6. package/dist/zip-fs-core-external.js +159 -42
  7. package/dist/zip-fs-core-external.min.js +1 -1
  8. package/dist/zip-fs-core.js +159 -42
  9. package/dist/zip-fs-core.min.js +1 -1
  10. package/dist/zip-fs-external.js +159 -42
  11. package/dist/zip-fs-external.min.js +1 -1
  12. package/dist/zip-fs-native.js +161 -44
  13. package/dist/zip-fs-native.min.js +1 -1
  14. package/dist/zip-fs.js +160 -43
  15. package/dist/zip-fs.min.js +1 -1
  16. package/dist/zip-legacy.js +160 -43
  17. package/dist/zip-legacy.min.js +1 -1
  18. package/dist/zip-native.js +160 -43
  19. package/dist/zip-native.min.js +1 -1
  20. package/dist/zip-web-worker-native.js +1 -1
  21. package/dist/zip-web-worker.js +1 -1
  22. package/dist/zip.js +159 -42
  23. package/dist/zip.min.js +1 -1
  24. package/index-native.cjs +161 -44
  25. package/index-native.min.js +1 -1
  26. package/index.cjs +160 -43
  27. package/index.d.cts +19 -7
  28. package/index.d.ts +19 -7
  29. package/index.min.js +1 -1
  30. package/lib/core/codec-worker-web.js +96 -30
  31. package/lib/core/codec-worker.js +15 -3
  32. package/lib/core/util/error.js +35 -0
  33. package/lib/core/version.js +1 -1
  34. package/lib/core/web-worker-base.js +43 -7
  35. package/lib/core/web-worker-inline-native.js +1 -1
  36. package/lib/core/web-worker-inline-wasm.js +1 -1
  37. package/lib/core/zip-fs.js +2 -1
  38. package/lib/core/zip-reader.js +9 -4
  39. package/lib/core/zip-writer.js +8 -3
  40. package/package.json +1 -1
  41. package/worker-message-property-names.js +1 -1
package/index.cjs CHANGED
@@ -439,7 +439,7 @@ function resetConfiguration() {
439
439
  Object.assign(config, DEFAULT_CONFIGURATION);
440
440
  }
441
441
 
442
- const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const e$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:u,Promise:l,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,A,x,M,P,B,D,F]=C;class R{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let s=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),o=e-8;for(;s<=o;s+=8){const t=n^r.getInt32(s,!0),e=r.getInt32(s+4,!0);n=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&e]^x[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;s<e;s++)n=n>>>8^I[255&(n^t[s])];this.o=n}get(){return~this.o}}class U extends d{constructor(){let t;const n=new R;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new o(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function W(t,n){const e=new o(t.length+n.length);return e.set(t),e.set(n,t.length),e}function _(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,n){if(0===t.length||0===n.length)return t.concat(n);const e=t[t.length-1],s=T.l(e);return 32===s?t.concat(n):T.h(n,s,0|e,t.slice(0,t.length-1))},bitLength(t){const n=t.length;if(0===n)return 0;const e=t[n-1];return 32*(n-1)+T.l(e)},m(t,n){if(32*t.length<n)return t;const e=(t=t.slice(0,s.ceil(n/32))).length;return n&=31,e>0&&n&&(t[e-1]=T.S(n,t[e-1]&2147483648>>n-1,1)),t},S:(t,n,e)=>32===t?n:(e?0|n:n<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,n,e,s){for(void 0===s&&(s=[]);n>=32;n-=32)s.push(e),e=0;if(0===n)return s.concat(t);for(let r=0;r<t.length;r++)s.push(e|t[r]>>>n),e=t[r]<<32-n;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(n+o&31,n+o>32?e:s.pop(),1)),s}},V={bytes:{v(t){const n=T.bitLength(t)/8,e=new o(n);let s;for(let r=0;r<n;r++)3&r||(s=t[r/4]),e[r]=s>>>24,s<<=8;return e},C(t){const n=[];let e,s=0;for(e=0;e<t.length;e++)s=s<<8|t[e],3&~e||(n.push(s),s=0);return 3&e&&n.push(T.S(8*(3&e),s)),n}}},K=class{constructor(t){const n=this;n.blockSize=512,n.I=[1732584193,4023233417,2562383102,271733878,3285377520],n.A=[1518500249,1859775393,2400959708,3395469782],t?(n.M=t.M.slice(0),n.P=t.P.slice(0),n.B=t.B):n.reset()}reset(){const t=this;return t.M=t.I.slice(0),t.P=[],t.B=0,t}update(t){const n=this;"string"==typeof t&&(t=V.D.C(t));const e=n.P=T.concat(n.P,t),s=n.B,o=n.B=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(e);let a=0;for(let t=n.blockSize+s-(n.blockSize+s&n.blockSize-1);t<=o;t+=n.blockSize)n.F(c.subarray(16*a,16*(a+1))),a+=1;return e.splice(0,16*a),n}R(){const t=this;let n=t.P;const e=t.M;n=T.concat(n,[T.S(1,1)]);for(let t=n.length+2;15&t;t++)n.push(0);for(n.push(s.floor(t.B/4294967296)),n.push(0|t.B);n.length;)t.F(n.splice(0,16));return t.reset(),e}U(t,n,e,s){return t<=19?n&e|~n&s:t<=39?n^e^s:t<=59?n&e|n&s|e&s:t<=79?n^e^s:void 0}W(t,n){return n<<t|n>>>32-t}F(n){const e=this,r=e.M,o=t(80);for(let t=0;t<16;t++)o[t]=n[t];let c=r[0],i=r[1],a=r[2],f=r[3],u=r[4];for(let t=0;t<=79;t++){t>=16&&(o[t]=e.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const n=e.W(5,c)+e.U(t,i,a,f)+u+o[t]+e.A[s.floor(t/20)]|0;u=f,f=a,a=e.W(30,i),i=c,c=n}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+u|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,n,e,s){if(e=e||1e4,s<0||e<0)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,l;const w=new ArrayBuffer(o),h=new u(w);let p=0;const d=T;for(n=V.bytes.C(n),l=1;p<(o||1);l++){for(c=i=t.encrypt(d.concat(n,[l])),a=1;a<e;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;p<(o||1)&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},_:class{constructor(t){const n=this,e=n.V=K,s=[[],[]];n.K=[new e,new e];const r=n.K[0].blockSize/32;t.length>r&&(t=(new e).update(t).R());for(let n=0;n<r;n++)s[0][n]=909522486^t[n],s[1][n]=1549556828^t[n];n.K[0].update(s[0]),n.K[1].update(s[1]),n.L=new e(n.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,n=t.L.R(),e=new t.V(t.K[1]).update(n).R();return t.reset(),e}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="zipjs-abort-check-password";function H(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=n.assign({hash:{name:"HMAC"}},q),J=n.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=b,nt=tt&&h.subtle,et=tt&&typeof nt!=b,st=V.bytes,rt=class{constructor(t){const n=this;n.j=[[[],[],[],[],[]],[[],[],[],[],[]]],n.j[0][0][0]||n.H();const e=n.j[0][4],s=n.j[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(n.A=[i=t.slice(0),a=[]],c=o;c<4*o+28;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=e[t>>>24]<<24^e[t>>16&255]<<16^e[t>>8&255]<<8^e[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const n=i[3&t?c:c-4];a[t]=c<=4||t<4?n:s[0][e[n>>>24]]^s[1][e[n>>16&255]]^s[2][e[n>>8&255]]^s[3][e[255&n]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],n=this.j[1],e=t[4],s=n[4],r=[],o=[];let c,i,a,f;for(let t=0;t<256;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let u=c=0;!e[u];u^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,e[u]=o,s[o]=u,f=r[a=r[i=r[u]]];let l=16843009*f^65537*a^257*i^16843008*u,w=257*r[o]^16843008*o;for(let e=0;e<4;e++)t[e][u]=w=w<<24^w>>>8,n[e][o]=l=l<<24^l>>>8}for(let e=0;e<5;e++)t[e]=t[e].slice(0),n[e]=n[e].slice(0)}N(t,n){if(4!==t.length)throw new r("invalid aes block size");const e=this.A[n],s=e.length/4-2,o=[0,0,0,0],c=this.j[n],i=c[0],a=c[1],f=c[2],u=c[3],l=c[4];let w,h,p,d=t[0]^e[0],y=t[n?3:1]^e[1],m=t[2]^e[2],S=t[n?1:3]^e[3],g=4;for(let t=0;t<s;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^u[255&S]^e[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^u[255&d]^e[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^u[255&y]^e[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^u[255&m]^e[g+3],g+=4,d=w,y=h,m=p;for(let t=0;t<4;t++)o[n?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&S]^e[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,n){this.G=t,this.J=n,this.X=n}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 n=t>>16&255,e=t>>8&255,s=255&t;255===n?(n=0,255===e?(e=0,255===s?s=0:++s):++e):++n,t=0,t+=n<<16,t+=e<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,n,e){let s;if(!(s=n.length))return[];const r=T.bitLength(n);for(let r=0;r<s;r+=4){this.$(e);const s=t.encrypt(e);n[r]^=s[0],n[r+1]^=s[1],n[r+2]^=s[2],n[r+3]^=s[3]}return T.m(n,r)}},ct=E._;let it=tt&&et&&typeof nt.importKey==k,at=tt&&et&&typeof nt.deriveBits==k;class ft extends d{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:c,strength:i,nt:a,ready:f}=e;c?(await async function(t,n,e,s){const o=await ht(t,n,e,dt(s,0,X[n])),c=dt(s,X[n]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)}(e,i,c,dt(t,0,X[i]+2)),t=dt(t,X[i]+2),s?n.error(new r(j)):a()):await f;const u=new o(t.length-Z-(t.length-Z)%N);n.enqueue(wt(e,t,u,0,Z,!0))},async flush(t){const{et:n,st:e,ot:s,ready:o}=this;if(e&&n){await o;const i=dt(s,0,s.length-Z),a=dt(s,s.length-Z);let f=z;if(i.length){const t=mt(st,i);e.update(t);const s=n.update(t);f=yt(st,s)}const u=dt(yt(st,e.digest()),0,Z);let l=s.length<Z?1:0;for(let t=0;t<Z;t++)l|=u[t]^a[t];if(l&&c)throw new r("Invalid authentication code");t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:n,encryptionStrength:e}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:s,strength:r,nt:c,ready:i}=e;let a=z;s?(a=await async function(t,n,e){const s=H(new o(X[n]));return W(s,await ht(t,n,e,s))}(e,r,s),c()):await i;const f=new o(a.length+t.length-t.length%N);f.set(a,0),n.enqueue(wt(e,t,f,a.length,0))},async flush(t){const{et:n,st:e,ot:s,ready:r}=this;if(e&&n){await r;let o=z;if(s.length){const t=n.update(mt(st,s));e.update(t),o=yt(st,t)}const c=yt(st,e.digest()).slice(0,Z);t.enqueue(W(o,c))}}})}}function lt(t,e,s,r){n.assign(t,{ready:new l(n=>t.nt=n),password:pt(e,s),strength:r-1,ot:z})}function wt(t,n,e,s,r,c){const{et:i,st:a,ot:f}=t;f.length&&(n=W(f,n));const u=n.length-r;let l;for(e=function(t,n){if(n&&n>t.length){const e=t;(t=new o(n)).set(e,0)}return t}(e,s+(u-u%N)),l=0;l<=u-N;l+=N){const t=mt(st,dt(n,l,l+N));c&&a.update(t);const r=i.update(t);c||a.update(r),e.set(yt(st,r),l+s)}return t.ot=dt(n,l),e}async function ht(e,s,r,c){e.password=null;const i=await async function(t,n,e,s,r){if(!it)return E.importKey(n);try{return await nt.importKey("raw",n,e,!1,r)}catch{return it=!1,E.importKey(n)}}(0,r,G,0,Q),a=await async function(t,n,e){if(!at)return E.T(n,t.salt,J.iterations,e);try{return await nt.deriveBits(t,n,e)}catch{return at=!1,E.T(n,t.salt,J.iterations,e)}}(n.assign({salt:c},J),i,8*(2*Y[s]+2)),f=new o(a),u=mt(st,dt(f,0,Y[s])),l=mt(st,dt(f,Y[s],2*Y[s])),w=dt(f,2*Y[s]);return n.assign(e,{keys:{key:u,ct:l,passwordVerification:w},et:new ot(new rt(u),t.from($)),st:new ct(l)}),w}function pt(t,n){return n===v?function(t){if(typeof w==b){t=unescape(encodeURIComponent(t));const n=new o(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new w).encode(t)}(t):n}function dt(t,n,e){return t.subarray(n,e)}function yt(t,n){return t.v(n)}function mt(t,n){return t.C(n)}class St extends d{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:s}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=bt(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(O);t=t.subarray(12)}s?n.error(new r(j)):n.enqueue(bt(e,t))}})}}class gt extends d{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;let s,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=H(new o(12));n[11]=e.passwordVerification,s=new o(t.length+n.length),s.set(kt(e,n),0),r=12}else s=new o(t.length),r=0;s.set(kt(e,t),r),n.enqueue(s)}})}}function vt(t,e,s,r){n.assign(t,{password:e,rawPassword:s,passwordVerification:r}),function(t,e,s){const r=[305419896,591751049,878082192];if(n.assign(t,{keys:r,it:new R(r[0]),ft:new R(r[2])}),s)for(let n=0;n<s.length;n++)zt(t,s[n]);else for(let n=0;n<e.length;n++)zt(t,e.charCodeAt(n))}(t,e,s)}function bt(t,n){const e=new o(n.length);for(let s=0;s<n.length;s++)e[s]=Ct(t)^n[s],zt(t,e[s]);return e}function kt(t,n){const e=new o(n.length);for(let s=0;s<n.length;s++)e[s]=Ct(t)^n[s],zt(t,n[s]);return e}function zt(t,n){let[,e]=t.keys;t.it.append([n]);const r=~t.it.get();e=At(s.imul(At(e+It(r)),134775813)+1),t.ft.append([e>>>24]);const o=~t.ft.get();t.keys=[r,e,o]}function Ct(t){const n=2|t.keys[2];return It(s.imul(n,1^n)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){const{value:e,done:s}=await n.read();s?t.close():t.enqueue(e)},cancel:t=>n.cancel(t)})}const Mt=new f;function Pt(t){return Mt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:l,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Pt(w),b=a&&r&&!l&&!v&&(!o||i)&&Boolean(c&&s);if(o&&!i||!a||b||(y=new U,g=Lt(g,y)),r)if(v)g=Ot(g,Kt(v.CompressionStream,w,{level:f,chunkSize:n,compressionMethod:h,uncompressedSize:p}));else if(b)S=new Wt,g=Ot(g,new s(Ft)),g=Lt(g,S);else try{g=Et(g,c,{level:f,chunkSize:n},s,e)}catch(t){let n;try{n=new s(Ft)}catch{throw t}g=Ot(g,n),g=Lt(g,new Wt)}o&&(i?g=Lt(g,new gt(t)):(m=new ut(t),g=Lt(g,m))),Vt(d,g,()=>{o&&!i||!a||(d.crc32=b?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Wt extends d{constructor(){let t,n=10,e=new o(0);super({transform(t,r){if(n){const e=s.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const o=e.length+t.length;if(o<=8)return void(e=W(e,t));const c=o-8,i=s.min(c,e.length);r.enqueue(W(e.subarray(0,i),t.subarray(0,c-i))),e=W(e.subarray(i),t.subarray(c-i))},flush(){const n=_(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class _t extends d{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=Lt(C,new St(t)):(z=new ft(t),C=Lt(C,z))),w){const t=m&&Pt(m);if(t)C=Ot(C,Kt(t.DecompressionStream,m,{chunkSize:n,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Et(C,h,{chunkSize:n,deflate64:p},s,e)}catch(t){if(p||b===v)throw t;let n;try{n=new s(Ft)}catch{throw t}C=function(t,n,e){const s=new R;let c,i,a,f=0,u=!1;const w=new l((t,n)=>{i=t,a=n});w.catch(()=>{}),e||i();const h=new d({start(t){const n=new o(10);n.set(Rt),t.enqueue(n)},transform(t,n){n.enqueue(t)},async flush(t){u=!0,y();try{await w}finally{m()}const n=new o(8),r=_(n);r.setUint32(0,s.get(),!0),r.setUint32(4,e,!0),t.enqueue(n)},cancel(t){a(t)}}),p=new d({transform(t,n){s.append(t),f+=t.length,f>=e?i():u&&y(),n.enqueue(t)},cancel(t){a(t)}});return t=Lt(t,h),Lt(t=Ot(t,n),p);function y(){m(),c=setTimeout(()=>a(new r(Bt)),5e3)}function m(){clearTimeout(c)}}(C,n,b)}C=function(t){const n=t.getReader();return new y({async pull(t){let e;try{e=await n.read()}catch(t){if(t&&t.message)throw t;const n=new r("Invalid compressed data");throw n.cause=t,n}const{value:s,done:o}=e;o?t.close():t.enqueue(s)},cancel:t=>n.cancel(t)})}(C)}a&&(k=new U,C=Lt(C,k)),Vt(this,C,()=>{if(a){const t=new u(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r("Invalid CRC32")}})}}const Tt=new f;function Vt(t,e,s){e=Lt(e,new d({flush:s})),n.defineProperty(t,"readable",{get:()=>e})}function Kt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Et(t,n,e,s,r){const o=n&&s?s:r||s,c=e.deflate64?"deflate64-raw":Dt;let i;try{i=new o(c,e)}catch(t){if(!n||!r||o==r)throw t;i=new r(c,e)}return Ot(t,i)}function Lt(t,n){return xt(t).pipeThrough(n)}function Ot(t,n){const e=n.writable.getWriter(),s=t.getReader();return async function(){try{for(;;){await e.ready;const t=await s.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await async function(t,n){try{await t.abort(n)}catch{}}(e,t),await async function(t,n){try{await t.cancel(n)}catch{}}(s,t)}}(),n.readable}const jt="data",Ht="close",Nt="deflate";class qt extends d{constructor(t,e){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=Ut:o.startsWith("inflate")&&(c=_t),s.outputSize=0;let i=0;const a=new c(t,e),f=super.readable,u=new d({transform(t,n){t&&t.length&&(i+=t.length,n.enqueue(t))},flush(){n.assign(s,{inputSize:i})}}),l=new d({transform(n,e){if(n&&n.length&&(e.enqueue(n),s.outputSize+=n.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Bt)},flush(){const{crc32:t}=a;n.assign(s,{crc32:t,inputSize:i})}});n.defineProperty(s,"readable",{get:()=>f.pipeThrough(u).pipeThrough(a).pipeThrough(l)})}}class Gt extends d{constructor(t){const s=[];let r=0,c=0;function i(){const n=new o(t);let e=0;for(;e<t;){const r=s[0],o=t-e;r.length<=o?(n.set(r,e),e+=r.length,s.shift()):(n.set(r.subarray(0,o),e),s[0]=r.subarray(o),e+=o)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(s.push(n),r+=n.length;r>t;)c+=t,e.enqueue(i())},flush(t){r&&(c+=r,t.enqueue(function(t,n){const e=new o(n);let s=0;for(const n of t)e.set(n,s),s+=n.length;return e}(s,r)))}}),n.defineProperty(this,"outputSize",{get:()=>c})}}let Jt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}const Qt=new f,Xt=new f;let Yt,Zt=0;async function $t(t){let n,o,c;try{const{options:i,config:a}=t;if(i.format)try{await async function(t,n){!Mt.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:s}=n;if(typeof e!=k&&typeof s!=k)throw new r("Invalid codec module");Mt.set(t,{CompressionStream:e,DecompressionStream:s})}(t,await(import(n)))}(i.format,i.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(a.CompressionStream=self.CompressionStream,a.DecompressionStream=self.DecompressionStream,i.compressed&&!i.format)if(i.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=Tt.get(t);e||(e=new f,Tt.set(t,e));let s=e.get(n);if(s===v){try{new t(n),s=!0}catch{s=!1}e.set(n,s)}return s}(i.codecType.startsWith(Nt)?a.CompressionStream:a.DecompressionStream,Dt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{i.useCompressionStream=!0}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const u={highWaterMark:1},w=t.readable?xt(t.readable):new y({async pull(t){const n=new l(t=>Qt.set(Zt,t));tn({type:"pull",messageId:Zt}),Zt=(Zt+1)%e.MAX_SAFE_INTEGER;const{value:s,done:r}=await n;t.enqueue(s),r&&t.close()}},u);c=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const s=new l(t=>n=t);Xt.set(Zt,n),tn({type:jt,value:t,messageId:Zt}),Zt=(Zt+1)%e.MAX_SAFE_INTEGER,await s}},u),n=new qt(i,a),o=new Gt(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?s.max(r,64):65536;var n,r}(a)),Yt=new AbortController;const{signal:h}=Yt;await w.pipeThrough(n).pipeThrough(o).pipeTo(c,{signal:h,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:p,inputSize:d,outputSize:S}=n;tn({type:Ht,result:{crc32:p,inputSize:d,outputSize:S}})}catch(t){if(t.outputSize=o?o.outputSize:0,c&&!c.locked)try{await c.getWriter().close()}catch{}nn(t)}}function tn(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new o(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function nn(t=new r("Unknown error")){const{message:n,stack:e,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:n,stack:e,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:s,done:r}=t;try{if("start"==n&&$t(t),n==jt){const t=Qt.get(e);Qt.delete(e),t({value:s||new o,done:r})}if("ack"==n){const t=Xt.get(e);Xt.delete(e),t()}n==Ht&&Yt.abort()}catch(t){nn(t)}}),p({type:"ready"});const en="deflate",sn="deflate-raw",rn="deflate64-raw",on="gzip";let cn,an,fn,un,ln;function wn(t,n,e={}){if(!cn){const t=new r("WASM module not loaded");throw t.cause=ln,t}const c="number"==typeof e.level?e.level:-1,i="number"==typeof e.outBuffer?e.outBuffer:65536,a="number"==typeof e.inBufferSize?e.inBufferSize:65536;return new d({start(){try{let e;if(this.ut=an(i),this.in=an(a),this.inBufferSize=a,!this.ut||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=cn.deflate_process,this.ht=cn.deflate_last_consumed,this.yt=cn.deflate_end,this.St=cn.deflate_new(),e=n===on?cn.deflate_init_gzip(this.St,c):n===sn?cn.deflate_init_raw(this.St,c):cn.deflate_init(this.St,c)):n===rn?(this.wt=cn.inflate9_process,this.ht=cn.inflate9_last_consumed,this.yt=cn.inflate9_end,this.St=cn.inflate9_new(),e=cn.inflate9_init_raw(this.St)):(this.wt=cn.inflate_process,this.ht=cn.inflate_last_consumed,this.yt=cn.inflate_end,this.St=cn.inflate_new(),e=n===sn?cn.inflate_init_raw(this.St):n===on?cn.inflate_init_gzip(this.St):cn.inflate_init(this.St)),0!==e)throw new r("init failed:"+e)}catch(t){throw f(this),t}},transform(t,n){try{const e=t,c=new o(un.buffer),a=this.wt,f=this.ht,u=this.ut,l=this.lt;let w=0;for(;w<e.length;){const t=s.min(e.length-w,32768);if((!this.in||this.inBufferSize<t)&&(this.in&&fn&&(fn(this.in),this.in=0),this.in=an(t),this.inBufferSize=t,!this.in))throw new r("allocation failed");c.set(e.subarray(w,w+t),this.in);const o=a(this.St,this.in,t,u,i,0),h=o>>24&255,p=128&h?h-256:h;if(p<0)throw new r("process error:"+p);const d=16777215&o;d&&(l.set(c.subarray(u,u+d),0),n.enqueue(l.slice(0,d)));const y=f(this.St);if(0===y&&0===d)break;w+=y}}catch(t){f(this),n.error(t)}},flush(t){try{const n=new o(un.buffer),e=this.wt,s=this.ut,c=this.lt;for(;;){const o=e(this.St,0,0,s,i,4),a=o>>24&255,f=128&a?a-256:a;if(f<0)throw new r("process error:"+f);const u=16777215&o;if(u&&(c.set(n.subarray(s,s+u),0),t.enqueue(c.slice(0,u))),1===a||0===u)break}}catch(n){t.error(n)}finally{const n=f(this);0!==n&&t.error(new r("end error:"+n))}},cancel(){f(this)}});function f(t){let n=0;return t.St&&t.yt&&(n=t.yt(t.St)),t.St=0,t.in&&fn&&fn(t.in),t.in=0,t.ut&&fn&&fn(t.ut),t.ut=0,n}}class hn{constructor(t=en,n){return wn(!0,t,n)}}class pn{constructor(t=en,n){return wn(!1,t,n)}}hn.gt=!0,pn.gt=!0,hn.vt=[en,sn,on],pn.vt=[en,sn,on,rn];let dn=!1;!function(t={}){const{init:n}=t,e=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{n&&await n(t),e&&(t.CompressionStreamFallback=e),s&&(t.DecompressionStreamFallback=s)}}({CompressionStreamFallback:hn,DecompressionStreamFallback:pn,init:t=>async function(t,{baseURI:n}){if(!dn)try{await async function(t,n){let e,s;try{try{s=new URL(t,n)}catch{}const r=await fetch(s);e=await r.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),s=e.length,r=new o(s);for(let t=0;t<s;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}!function(t){if(cn=t,({malloc:an,free:fn,memory:un}=cn),"function"!=typeof an||"function"!=typeof fn||!un)throw cn=an=fn=un=null,new r("Invalid WASM module")}((await WebAssembly.instantiate(e)).instance.exports)}(t,n),dn=!0}catch(t){throw function(t){ln=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+function(t){let n="";const s=t.length;let r=0;for(;r+2<s;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e$1[s>>18&63]+e$1[s>>12&63]+e$1[s>>6&63]+e$1[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e$1[s>>18&63]+e$1[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e$1[s>>18&63]+e$1[s>>12&63]+e$1[s>>6&63]+"=";}return n}(s)}});
442
+ const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const e$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let r='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:u,Promise:l,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,A,x,M,P,B,D,F]=C;class R{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let r=0;if(e>=8&&t.buffer){const s=new u(t.buffer,t.byteOffset,e),o=e-8;for(;r<=o;r+=8){const t=n^s.getInt32(r,!0),e=s.getInt32(r+4,!0);n=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&e]^x[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;r<e;r++)n=n>>>8^I[255&(n^t[r])];this.o=n}get(){return~this.o}}class U extends d{constructor(){let t;const n=new R;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new o(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function V(t,n){const e=new o(t.length+n.length);return e.set(t),e.set(n,t.length),e}function W(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const _={concat(t,n){if(0===t.length||0===n.length)return t.concat(n);const e=t[t.length-1],r=_.l(e);return 32===r?t.concat(n):_.h(n,r,0|e,t.slice(0,t.length-1))},bitLength(t){const n=t.length;if(0===n)return 0;const e=t[n-1];return 32*(n-1)+_.l(e)},m(t,n){if(32*t.length<n)return t;const e=(t=t.slice(0,r.ceil(n/32))).length;return n&=31,e>0&&n&&(t[e-1]=_.S(n,t[e-1]&2147483648>>n-1,1)),t},S:(t,n,e)=>32===t?n:(e?0|n:n<<32-t)+1099511627776*t,l:t=>r.round(t/1099511627776)||32,h(t,n,e,r){for(void 0===r&&(r=[]);n>=32;n-=32)r.push(e),e=0;if(0===n)return r.concat(t);for(let s=0;s<t.length;s++)r.push(e|t[s]>>>n),e=t[s]<<32-n;const s=t.length?t[t.length-1]:0,o=_.l(s);return r.push(_.S(n+o&31,n+o>32?e:r.pop(),1)),r}},T={bytes:{v(t){const n=_.bitLength(t)/8,e=new o(n);let r;for(let s=0;s<n;s++)3&s||(r=t[s/4]),e[s]=r>>>24,r<<=8;return e},C(t){const n=[];let e,r=0;for(e=0;e<t.length;e++)r=r<<8|t[e],3&~e||(n.push(r),r=0);return 3&e&&n.push(_.S(8*(3&e),r)),n}}},K=class{constructor(t){const n=this;n.blockSize=512,n.I=[1732584193,4023233417,2562383102,271733878,3285377520],n.A=[1518500249,1859775393,2400959708,3395469782],t?(n.M=t.M.slice(0),n.P=t.P.slice(0),n.B=t.B):n.reset()}reset(){const t=this;return t.M=t.I.slice(0),t.P=[],t.B=0,t}update(t){const n=this;"string"==typeof t&&(t=T.D.C(t));const e=n.P=_.concat(n.P,t),r=n.B,o=n.B=r+_.bitLength(t);if(o>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new i(e);let a=0;for(let t=n.blockSize+r-(n.blockSize+r&n.blockSize-1);t<=o;t+=n.blockSize)n.F(c.subarray(16*a,16*(a+1))),a+=1;return e.splice(0,16*a),n}R(){const t=this;let n=t.P;const e=t.M;n=_.concat(n,[_.S(1,1)]);for(let t=n.length+2;15&t;t++)n.push(0);for(n.push(r.floor(t.B/4294967296)),n.push(0|t.B);n.length;)t.F(n.splice(0,16));return t.reset(),e}U(t,n,e,r){return t<=19?n&e|~n&r:t<=39?n^e^r:t<=59?n&e|n&r|e&r:t<=79?n^e^r:void 0}V(t,n){return n<<t|n>>>32-t}F(n){const e=this,s=e.M,o=t(80);for(let t=0;t<16;t++)o[t]=n[t];let c=s[0],i=s[1],a=s[2],f=s[3],u=s[4];for(let t=0;t<=79;t++){t>=16&&(o[t]=e.V(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const n=e.V(5,c)+e.U(t,i,a,f)+u+o[t]+e.A[r.floor(t/20)]|0;u=f,f=a,a=e.V(30,i),i=c,c=n}s[0]=s[0]+c|0,s[1]=s[1]+i|0,s[2]=s[2]+a|0,s[3]=s[3]+f|0,s[4]=s[4]+u|0}},j={importKey:t=>new j.W(T.bytes.C(t)),_(t,n,e,r){if(e=e||1e4,r<0||e<0)throw new s("invalid params to pbkdf2");const o=1+(r>>5)<<2;let c,i,a,f,l;const w=new ArrayBuffer(o),h=new u(w);let p=0;const d=_;for(n=T.bytes.C(n),l=1;p<(o||1);l++){for(c=i=t.encrypt(d.concat(n,[l])),a=1;a<e;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;p<(o||1)&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,r/8)},W:class{constructor(t){const n=this,e=n.T=K,r=[[],[]];n.K=[new e,new e];const s=n.K[0].blockSize/32;t.length>s&&(t=(new e).update(t).R());for(let n=0;n<s;n++)r[0][n]=909522486^t[n],r[1][n]=1549556828^t[n];n.K[0].update(r[0]),n.K[1].update(r[1]),n.j=new e(n.K[0])}reset(){const t=this;t.j=new t.T(t.K[0]),t.L=!1}update(t){this.L=!0,this.j.update(t)}digest(){const t=this,n=t.j.R(),e=new t.T(t.K[1]).update(n).R();return t.reset(),e}encrypt(t){if(this.L)throw new s("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},E=typeof h!=b&&typeof h.getRandomValues==k,L="Invalid password",O="zipjs-abort-check-password";function H(t){if(E)return h.getRandomValues(t);throw new s("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=n.assign({hash:{name:"HMAC"}},q),J=n.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=b,nt=tt&&h.subtle,et=tt&&typeof nt!=b,rt=T.bytes,st=class{constructor(t){const n=this;n.O=[[[],[],[],[],[]],[[],[],[],[],[]]],n.O[0][0][0]||n.H();const e=n.O[0][4],r=n.O[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new s("invalid aes key size");for(n.A=[i=t.slice(0),a=[]],c=o;c<4*o+28;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=e[t>>>24]<<24^e[t>>16&255]<<16^e[t>>8&255]<<8^e[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const n=i[3&t?c:c-4];a[t]=c<=4||t<4?n:r[0][e[n>>>24]]^r[1][e[n>>16&255]]^r[2][e[n>>8&255]]^r[3][e[255&n]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.O[0],n=this.O[1],e=t[4],r=n[4],s=[],o=[];let c,i,a,f;for(let t=0;t<256;t++)o[(s[t]=t<<1^283*(t>>7))^t]=t;for(let u=c=0;!e[u];u^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,e[u]=o,r[o]=u,f=s[a=s[i=s[u]]];let l=16843009*f^65537*a^257*i^16843008*u,w=257*s[o]^16843008*o;for(let e=0;e<4;e++)t[e][u]=w=w<<24^w>>>8,n[e][o]=l=l<<24^l>>>8}for(let e=0;e<5;e++)t[e]=t[e].slice(0),n[e]=n[e].slice(0)}N(t,n){if(4!==t.length)throw new s("invalid aes block size");const e=this.A[n],r=e.length/4-2,o=[0,0,0,0],c=this.O[n],i=c[0],a=c[1],f=c[2],u=c[3],l=c[4];let w,h,p,d=t[0]^e[0],y=t[n?3:1]^e[1],m=t[2]^e[2],S=t[n?1:3]^e[3],g=4;for(let t=0;t<r;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^u[255&S]^e[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^u[255&d]^e[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^u[255&y]^e[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^u[255&m]^e[g+3],g+=4,d=w,y=h,m=p;for(let t=0;t<4;t++)o[n?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&S]^e[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,n){this.G=t,this.J=n,this.X=n}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 n=t>>16&255,e=t>>8&255,r=255&t;255===n?(n=0,255===e?(e=0,255===r?r=0:++r):++e):++n,t=0,t+=n<<16,t+=e<<8,t+=r}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,n,e){let r;if(!(r=n.length))return[];const s=_.bitLength(n);for(let s=0;s<r;s+=4){this.$(e);const r=t.encrypt(e);n[s]^=r[0],n[s+1]^=r[1],n[s+2]^=r[2],n[s+3]^=r[3]}return _.m(n,s)}},ct=j.W;let it=tt&&et&&typeof nt.importKey==k,at=tt&&et&&typeof nt.deriveBits==k;class ft extends d{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:c,strength:i,nt:a,ready:f}=e;c?(await async function(t,n,e,r){const o=await ht(t,n,e,dt(r,0,X[n])),c=dt(r,X[n]);if(o[0]!=c[0]||o[1]!=c[1])throw new s(L)}(e,i,c,dt(t,0,X[i]+2)),t=dt(t,X[i]+2),r?n.error(new s(O)):a()):await f;const u=new o(t.length-Z-(t.length-Z)%N);n.enqueue(wt(e,t,u,0,Z,!0))},async flush(t){const{et:n,st:e,ot:r,ready:o}=this;if(e&&n){await o;const i=dt(r,0,r.length-Z),a=dt(r,r.length-Z);let f=z;if(i.length){const t=mt(rt,i);e.update(t);const r=n.update(t);f=yt(rt,r)}const u=dt(yt(rt,e.digest()),0,Z);let l=r.length<Z?1:0;for(let t=0;t<Z;t++)l|=u[t]^a[t];if(l&&c)throw new s("Invalid authentication code");t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:n,encryptionStrength:e}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:r,strength:s,nt:c,ready:i}=e;let a=z;r?(a=await async function(t,n,e){const r=H(new o(X[n]));return V(r,await ht(t,n,e,r))}(e,s,r),c()):await i;const f=new o(a.length+t.length-t.length%N);f.set(a,0),n.enqueue(wt(e,t,f,a.length,0))},async flush(t){const{et:n,st:e,ot:r,ready:s}=this;if(e&&n){await s;let o=z;if(r.length){const t=n.update(mt(rt,r));e.update(t),o=yt(rt,t)}const c=yt(rt,e.digest()).slice(0,Z);t.enqueue(V(o,c))}}})}}function lt(t,e,r,s){n.assign(t,{ready:new l(n=>t.nt=n),password:pt(e,r),strength:s-1,ot:z})}function wt(t,n,e,r,s,c){const{et:i,st:a,ot:f}=t;f.length&&(n=V(f,n));const u=n.length-s;let l;for(e=function(t,n){if(n&&n>t.length){const e=t;(t=new o(n)).set(e,0)}return t}(e,r+(u-u%N)),l=0;l<=u-N;l+=N){const t=mt(rt,dt(n,l,l+N));c&&a.update(t);const s=i.update(t);c||a.update(s),e.set(yt(rt,s),l+r)}return t.ot=dt(n,l),e}async function ht(e,r,s,c){e.password=null;const i=await async function(t,n,e,r,s){if(!it)return j.importKey(n);try{return await nt.importKey("raw",n,e,!1,s)}catch{return it=!1,j.importKey(n)}}(0,s,G,0,Q),a=await async function(t,n,e){if(!at)return j._(n,t.salt,J.iterations,e);try{return await nt.deriveBits(t,n,e)}catch{return at=!1,j._(n,t.salt,J.iterations,e)}}(n.assign({salt:c},J),i,8*(2*Y[r]+2)),f=new o(a),u=mt(rt,dt(f,0,Y[r])),l=mt(rt,dt(f,Y[r],2*Y[r])),w=dt(f,2*Y[r]);return n.assign(e,{keys:{key:u,ct:l,passwordVerification:w},et:new ot(new st(u),t.from($)),st:new ct(l)}),w}function pt(t,n){return n===v?function(t){if(typeof w==b){t=unescape(encodeURIComponent(t));const n=new o(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new w).encode(t)}(t):n}function dt(t,n,e){return t.subarray(n,e)}function yt(t,n){return t.v(n)}function mt(t,n){return t.C(n)}class St extends d{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:r}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=bt(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new s(L);t=t.subarray(12)}r?n.error(new s(O)):n.enqueue(bt(e,t))}})}}class gt extends d{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;let r,s;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=H(new o(12));n[11]=e.passwordVerification,r=new o(t.length+n.length),r.set(kt(e,n),0),s=12}else r=new o(t.length),s=0;r.set(kt(e,t),s),n.enqueue(r)}})}}function vt(t,e,r,s){n.assign(t,{password:e,rawPassword:r,passwordVerification:s}),function(t,e,r){const s=[305419896,591751049,878082192];if(n.assign(t,{keys:s,it:new R(s[0]),ft:new R(s[2])}),r)for(let n=0;n<r.length;n++)zt(t,r[n]);else for(let n=0;n<e.length;n++)zt(t,e.charCodeAt(n))}(t,e,r)}function bt(t,n){const e=new o(n.length);for(let r=0;r<n.length;r++)e[r]=Ct(t)^n[r],zt(t,e[r]);return e}function kt(t,n){const e=new o(n.length);for(let r=0;r<n.length;r++)e[r]=Ct(t)^n[r],zt(t,n[r]);return e}function zt(t,n){let[,e]=t.keys;t.it.append([n]);const s=~t.it.get();e=At(r.imul(At(e+It(s)),134775813)+1),t.ft.append([e>>>24]);const o=~t.ft.get();t.keys=[s,e,o]}function Ct(t){const n=2|t.keys[2];return It(r.imul(n,1^n)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){const{value:e,done:r}=await n.read();r?t.close():t.enqueue(e)},cancel:t=>n.cancel(t)})}const Mt=new f;function Pt(t){return Mt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:l,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Pt(w),b=a&&s&&!l&&!v&&(!o||i)&&Boolean(c&&r);if(o&&!i||!a||b||(y=new U,g=Et(g,y)),s)if(v)g=Lt(g,Kt(v.CompressionStream,w,{level:f,chunkSize:n,compressionMethod:h,uncompressedSize:p}));else if(b)S=new Vt,g=Lt(g,new r(Ft)),g=Et(g,S);else try{g=jt(g,c,{level:f,chunkSize:n},r,e)}catch(t){let n;try{n=new r(Ft)}catch{throw t}g=Lt(g,n),g=Et(g,new Vt)}o&&(i?g=Et(g,new gt(t)):(m=new ut(t),g=Et(g,m))),Tt(d,g,()=>{o&&!i||!a||(d.crc32=b?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Vt extends d{constructor(){let t,n=10,e=new o(0);super({transform(t,s){if(n){const e=r.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const o=e.length+t.length;if(o<=8)return void(e=V(e,t));const c=o-8,i=r.min(c,e.length);s.enqueue(V(e.subarray(0,i),t.subarray(0,c-i))),e=V(e.subarray(i),t.subarray(c-i))},flush(){const n=W(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Wt extends d{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=Et(C,new St(t)):(z=new ft(t),C=Et(C,z))),w){const t=m&&Pt(m);if(t)C=Lt(C,Kt(t.DecompressionStream,m,{chunkSize:n,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=jt(C,h,{chunkSize:n,deflate64:p},r,e)}catch(t){if(p||b===v)throw t;let n;try{n=new r(Ft)}catch{throw t}C=function(t,n,e){const r=new R;let c,i,a,f=0,u=!1;const w=new l((t,n)=>{i=t,a=n});w.catch(()=>{}),e||i();const h=new d({start(t){const n=new o(10);n.set(Rt),t.enqueue(n)},transform(t,n){n.enqueue(t)},async flush(t){u=!0,y();try{await w}finally{m()}const n=new o(8),s=W(n);s.setUint32(0,r.get(),!0),s.setUint32(4,e,!0),t.enqueue(n)},cancel(t){a(t)}}),p=new d({transform(t,n){r.append(t),f+=t.length,f>=e?i():u&&y(),n.enqueue(t)},cancel(t){a(t)}});return t=Et(t,h),Et(t=Lt(t,n),p);function y(){m(),c=setTimeout(()=>a(new s(Bt)),5e3)}function m(){clearTimeout(c)}}(C,n,b)}C=function(t){const n=t.getReader();return new y({async pull(t){let e;try{e=await n.read()}catch(t){if(t&&t.message)throw t;const n=new s("Invalid compressed data");throw n.cause=t,n}const{value:r,done:o}=e;o?t.close():t.enqueue(r)},cancel:t=>n.cancel(t)})}(C)}a&&(k=new U,C=Et(C,k)),Tt(this,C,()=>{if(a){const t=new u(k.value.buffer);if(f!=t.getUint32(0,!1))throw new s("Invalid CRC32")}})}}const _t=new f;function Tt(t,e,r){e=Et(e,new d({flush:r})),n.defineProperty(t,"readable",{get:()=>e})}function Kt(t,n,e){if(!t)throw new s("Compression method not supported");return new t(n,e)}function jt(t,n,e,r,s){const o=n&&r?r:s||r,c=e.deflate64?"deflate64-raw":Dt;let i;try{i=new o(c,e)}catch(t){if(!n||!s||o==s)throw t;i=new s(c,e)}return Lt(t,i)}function Et(t,n){return xt(t).pipeThrough(n)}function Lt(t,n){const e=n.writable.getWriter(),r=t.getReader();return async function(){try{for(;;){await e.ready;const t=await r.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await async function(t,n){try{await t.abort(n)}catch{}}(e,t),await async function(t,n){try{await t.cancel(n)}catch{}}(r,t)}}(),n.readable}const Ot="data",Ht="close",Nt="deflate";class qt extends d{constructor(t,e){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=Ut:o.startsWith("inflate")&&(c=Wt),r.outputSize=0;let i=0;const a=new c(t,e),f=super.readable,u=new d({transform(t,n){t&&t.length&&(i+=t.length,n.enqueue(t))},flush(){n.assign(r,{inputSize:i})}}),l=new d({transform(n,e){if(n&&n.length&&(e.enqueue(n),r.outputSize+=n.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Bt)},flush(){const{crc32:t}=a;n.assign(r,{crc32:t,inputSize:i})}});n.defineProperty(r,"readable",{get:()=>f.pipeThrough(u).pipeThrough(a).pipeThrough(l)})}}class Gt extends d{constructor(t){const r=[];let s=0,c=0;function i(){const n=new o(t);let e=0;for(;e<t;){const s=r[0],o=t-e;s.length<=o?(n.set(s,e),e+=s.length,r.shift()):(n.set(s.subarray(0,o),e),r[0]=s.subarray(o),e+=o)}return s-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(r.push(n),s+=n.length;s>t;)c+=t,e.enqueue(i())},flush(t){s&&(c+=s,t.enqueue(function(t,n){const e=new o(n);let r=0;for(const n of t)e.set(n,r),r+=n.length;return e}(r,s)))}}),n.defineProperty(this,"outputSize",{get:()=>c})}}let Jt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}function Qt(t){return Boolean(t)&&"object"==typeof t}const Xt=new f,Yt=new f,Zt=function(){try{return structuredClone(new s)instanceof s}catch{return!1}}();let $t,tn=0;async function nn(t){let n,o,c;try{const{options:i,config:a}=t;if(i.format)try{await async function(t,n){!Mt.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:r}=n;if(typeof e!=k&&typeof r!=k)throw new s("Invalid codec module");Mt.set(t,{CompressionStream:e,DecompressionStream:r})}(t,await(import(n)))}(i.format,i.codecURI)}catch(t){if(Qt(t))try{t.codecImportFailed=!0}catch{}throw t}if(a.CompressionStream=self.CompressionStream,a.DecompressionStream=self.DecompressionStream,i.compressed&&!i.format)if(i.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=_t.get(t);e||(e=new f,_t.set(t,e));let r=e.get(n);if(r===v){try{new t(n),r=!0}catch{r=!1}e.set(n,r)}return r}(i.codecType.startsWith(Nt)?a.CompressionStream:a.DecompressionStream,Dt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{i.useCompressionStream=!0}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const u={highWaterMark:1},w=t.readable?xt(t.readable):new y({async pull(t){const n=new l(t=>Xt.set(tn,t));en({type:"pull",messageId:tn}),tn=(tn+1)%e.MAX_SAFE_INTEGER;const{value:r,done:s}=await n;t.enqueue(r),s&&t.close()}},u);c=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const r=new l(t=>n=t);Yt.set(tn,n),en({type:Ot,value:t,messageId:tn}),tn=(tn+1)%e.MAX_SAFE_INTEGER,await r}},u),n=new qt(i,a),o=new Gt(function(t){return s="string"==typeof(n=s=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(s)&&s>=1?r.max(s,64):65536;var n,s}(a)),$t=new AbortController;const{signal:h}=$t;await w.pipeThrough(n).pipeThrough(o).pipeTo(c,{signal:h,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:p,inputSize:d,outputSize:S}=n;en({type:Ht,result:{crc32:p,inputSize:d,outputSize:S}})}catch(t){const n=o?o.outputSize:0;if(Qt(t))try{t.outputSize=n}catch{}if(c&&!c.locked)try{await c.getWriter().close()}catch{}rn(t,n)}}function en(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new o(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function rn(t,n){const{message:e,stack:r,code:o,name:c,outputSize:i,cause:a,codecImportFailed:f}=function(t=new s("Unknown error")){return Qt(t)?t:new s(String(t))}(t),u={message:e,stack:r,code:o,name:c,outputSize:i===v?n:i};if(a&&(u.cause={name:a.name,message:a.message}),f&&(u.codecImportFailed=!0),Zt)try{return void p({error:u,errorValue:{value:t}})}catch{}p({error:u})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:r,done:s}=t;try{if("start"==n&&nn(t),n==Ot){const t=Xt.get(e);Xt.delete(e),t({value:r||new o,done:s})}if("ack"==n){const t=Yt.get(e);Yt.delete(e),t()}n==Ht&&$t.abort()}catch(t){rn(t)}}),p({type:"ready"});const sn="deflate",on="deflate-raw",cn="deflate64-raw",an="gzip";let fn,un,ln,wn,hn;function pn(t,n,e={}){if(!fn){const t=new s("WASM module not loaded");throw t.cause=hn,t}const c="number"==typeof e.level?e.level:-1,i="number"==typeof e.outBuffer?e.outBuffer:65536,a="number"==typeof e.inBufferSize?e.inBufferSize:65536;return new d({start(){try{let e;if(this.ut=un(i),this.in=un(a),this.inBufferSize=a,!this.ut||!this.in)throw new s("allocation failed");if(this.lt=new o(i),t?(this.wt=fn.deflate_process,this.ht=fn.deflate_last_consumed,this.yt=fn.deflate_end,this.St=fn.deflate_new(),e=n===an?fn.deflate_init_gzip(this.St,c):n===on?fn.deflate_init_raw(this.St,c):fn.deflate_init(this.St,c)):n===cn?(this.wt=fn.inflate9_process,this.ht=fn.inflate9_last_consumed,this.yt=fn.inflate9_end,this.St=fn.inflate9_new(),e=fn.inflate9_init_raw(this.St)):(this.wt=fn.inflate_process,this.ht=fn.inflate_last_consumed,this.yt=fn.inflate_end,this.St=fn.inflate_new(),e=n===on?fn.inflate_init_raw(this.St):n===an?fn.inflate_init_gzip(this.St):fn.inflate_init(this.St)),0!==e)throw new s("init failed:"+e)}catch(t){throw f(this),t}},transform(t,n){try{const e=t,c=new o(wn.buffer),a=this.wt,f=this.ht,u=this.ut,l=this.lt;let w=0;for(;w<e.length;){const t=r.min(e.length-w,32768);if((!this.in||this.inBufferSize<t)&&(this.in&&ln&&(ln(this.in),this.in=0),this.in=un(t),this.inBufferSize=t,!this.in))throw new s("allocation failed");c.set(e.subarray(w,w+t),this.in);const o=a(this.St,this.in,t,u,i,0),h=o>>24&255,p=128&h?h-256:h;if(p<0)throw new s("process error:"+p);const d=16777215&o;d&&(l.set(c.subarray(u,u+d),0),n.enqueue(l.slice(0,d)));const y=f(this.St);if(0===y&&0===d)break;w+=y}}catch(t){f(this),n.error(t)}},flush(t){try{const n=new o(wn.buffer),e=this.wt,r=this.ut,c=this.lt;for(;;){const o=e(this.St,0,0,r,i,4),a=o>>24&255,f=128&a?a-256:a;if(f<0)throw new s("process error:"+f);const u=16777215&o;if(u&&(c.set(n.subarray(r,r+u),0),t.enqueue(c.slice(0,u))),1===a||0===u)break}}catch(n){t.error(n)}finally{const n=f(this);0!==n&&t.error(new s("end error:"+n))}},cancel(){f(this)}});function f(t){let n=0;return t.St&&t.yt&&(n=t.yt(t.St)),t.St=0,t.in&&ln&&ln(t.in),t.in=0,t.ut&&ln&&ln(t.ut),t.ut=0,n}}class dn{constructor(t=sn,n){return pn(!0,t,n)}}class yn{constructor(t=sn,n){return pn(!1,t,n)}}dn.gt=!0,yn.gt=!0,dn.vt=[sn,on,an],yn.vt=[sn,on,an,cn];let mn=!1;!function(t={}){const{init:n}=t,e=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{n&&await n(t),e&&(t.CompressionStreamFallback=e),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:dn,DecompressionStreamFallback:yn,init:t=>async function(t,{baseURI:n}){if(!mn)try{await async function(t,n){let e,r;try{try{r=new URL(t,n)}catch{}const s=await fetch(r);e=await s.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),r=e.length,s=new o(r);for(let t=0;t<r;++t)s[t]=e.charCodeAt(t);return s.buffer}(t)}!function(t){if(fn=t,({malloc:un,free:ln,memory:wn}=fn),"function"!=typeof un||"function"!=typeof ln||!wn)throw fn=un=ln=wn=null,new s("Invalid WASM module")}((await WebAssembly.instantiate(e)).instance.exports)}(t,n),mn=!0}catch(t){throw function(t){hn=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof r&&(r=(new TextEncoder).encode(r)),t){const t=new Blob([r],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+function(t){let n="";const r=t.length;let s=0;for(;s+2<r;s+=3){const r=t[s]<<16|t[s+1]<<8|t[s+2];n+=e$1[r>>18&63]+e$1[r>>12&63]+e$1[r>>6&63]+e$1[63&r];}const o=r-s;if(1===o){const r=t[s]<<16;n+=e$1[r>>18&63]+e$1[r>>12&63]+"==";}else if(2===o){const r=t[s]<<16|t[s+1]<<8;n+=e$1[r>>18&63]+e$1[r>>12&63]+e$1[r>>6&63]+"=";}return n}(r)}});
443
443
 
444
444
  /*
445
445
  Copyright (c) 2026 Gildas Lormeau. All rights reserved.
@@ -485,6 +485,39 @@ function getDataView(array) {
485
485
  return new DataView(array.buffer, array.byteOffset, array.byteLength);
486
486
  }
487
487
 
488
+ /*
489
+ Copyright (c) 2026 Gildas Lormeau. All rights reserved.
490
+
491
+ Redistribution and use in source and binary forms, with or without
492
+ modification, are permitted provided that the following conditions are met:
493
+
494
+ 1. Redistributions of source code must retain the above copyright notice,
495
+ this list of conditions and the following disclaimer.
496
+
497
+ 2. Redistributions in binary form must reproduce the above copyright
498
+ notice, this list of conditions and the following disclaimer in
499
+ the documentation and/or other materials provided with the distribution.
500
+
501
+ 3. The names of the authors may not be used to endorse or promote products
502
+ derived from this software without specific prior written permission.
503
+
504
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
505
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
506
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
507
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
508
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
509
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
510
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
511
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
512
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
513
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
514
+ */
515
+
516
+
517
+ function isErrorObject(error) {
518
+ return Boolean(error) && typeof error == "object";
519
+ }
520
+
488
521
  /*
489
522
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
490
523
 
@@ -2756,7 +2789,9 @@ function disableWebWorker(workerData) {
2756
2789
 
2757
2790
  class CodecWorker {
2758
2791
 
2759
- constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI, createWorker }, onTaskFinished) {
2792
+ constructor(workerData, { readable, writable }, workerOptions, onTaskFinished) {
2793
+ const { options, config, streamOptions, useWebWorkers, transferStreams, workerURI } = workerOptions;
2794
+ let { createWorker } = workerOptions;
2760
2795
  const { signal } = streamOptions;
2761
2796
  if (createWorkerFailed) {
2762
2797
  createWorker = UNDEFINED_VALUE;
@@ -2769,6 +2804,7 @@ class CodecWorker {
2769
2804
  .pipeThrough(new ProgressWatcherStream(streamOptions), { signal }),
2770
2805
  writable,
2771
2806
  options: Object.assign({}, options),
2807
+ workerOptions,
2772
2808
  workerURI,
2773
2809
  createWorker,
2774
2810
  transferStreams,
@@ -2850,7 +2886,7 @@ function createWorkerInterface(workerData, config) {
2850
2886
  };
2851
2887
  }
2852
2888
 
2853
- async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
2889
+ async function runWorker$1({ options, readable, writable, onTaskFinished, workerOptions }, config) {
2854
2890
  let codecStream, chunkStream;
2855
2891
  try {
2856
2892
  if (options.compressed && !options.format) {
@@ -2891,7 +2927,15 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
2891
2927
  };
2892
2928
  } catch (error) {
2893
2929
  if (codecStream) {
2894
- error.outputSize = chunkStream ? chunkStream.outputSize : 0;
2930
+ const outputSize = chunkStream ? chunkStream.outputSize : 0;
2931
+ workerOptions.outputSize = outputSize;
2932
+ if (isErrorObject(error)) {
2933
+ try {
2934
+ error.outputSize = outputSize;
2935
+ } catch {
2936
+ // ignored
2937
+ }
2938
+ }
2895
2939
  }
2896
2940
  throw error;
2897
2941
  } finally {
@@ -3001,8 +3045,14 @@ async function runWebWorker(workerData, config) {
3001
3045
  const result = new Promise((resolve, reject) => {
3002
3046
  resolveResult = resolve;
3003
3047
  rejectResult = error => {
3004
- if (error && error.outputSize === UNDEFINED_VALUE) {
3005
- error.outputSize = workerData.outputSize;
3048
+ const { outputSize, workerOptions } = workerData;
3049
+ workerOptions.outputSize = outputSize;
3050
+ if (isErrorObject(error)) {
3051
+ try {
3052
+ error.outputSize = outputSize;
3053
+ } catch {
3054
+ // ignored
3055
+ }
3006
3056
  }
3007
3057
  reject(error);
3008
3058
  };
@@ -3011,12 +3061,14 @@ async function runWebWorker(workerData, config) {
3011
3061
  reader: null,
3012
3062
  writer: null,
3013
3063
  outputSize: 0,
3064
+ destinationFailed: false,
3065
+ destinationError: null,
3014
3066
  resolveResult,
3015
3067
  rejectResult,
3016
3068
  result
3017
3069
  });
3018
3070
  const { readable, options } = workerData;
3019
- const { writable, closed, abortPipe } = watchClosedStream(workerData.writable);
3071
+ const { writable, closed, abortPipe } = watchClosedStream(workerData.writable, workerData);
3020
3072
  let streamsTransferred;
3021
3073
  try {
3022
3074
  streamsTransferred = sendMessage({
@@ -3059,7 +3111,18 @@ async function runWebWorker(workerData, config) {
3059
3111
  } catch {
3060
3112
  // ignored
3061
3113
  }
3062
- throw error;
3114
+ const { outputSize, workerOptions, destinationFailed, destinationError } = workerData;
3115
+ workerOptions.outputSize = outputSize;
3116
+ const workerFailed = isErrorObject(error) && (error.codecImportFailed || error.workerStartupFailed);
3117
+ const reportedError = destinationFailed && !workerFailed ? destinationError : error;
3118
+ if (isErrorObject(reportedError)) {
3119
+ try {
3120
+ reportedError.outputSize = outputSize;
3121
+ } catch {
3122
+ // ignored
3123
+ }
3124
+ }
3125
+ throw reportedError;
3063
3126
  }
3064
3127
 
3065
3128
  async function closeWritable() {
@@ -3073,12 +3136,27 @@ async function runWebWorker(workerData, config) {
3073
3136
  }
3074
3137
  }
3075
3138
 
3076
- function watchClosedStream(writableSource) {
3139
+ function watchClosedStream(writableSource, workerData) {
3077
3140
  const abortController = new AbortController();
3078
- const { writable, readable } = new TransformStream();
3141
+ let aborting;
3142
+ const { writable, readable } = new TransformStream({
3143
+ transform(chunk, controller) {
3144
+ workerData.outputSize += chunk.length;
3145
+ controller.enqueue(chunk);
3146
+ }
3147
+ });
3079
3148
  const closed = readable.pipeTo(writableSource, { preventClose: true, preventAbort: true, signal: abortController.signal });
3080
- closed.catch(() => { });
3081
- return { writable, closed, abortPipe: () => abortController.abort() };
3149
+ closed.catch(error => {
3150
+ if (!aborting) {
3151
+ Object.assign(workerData, { destinationFailed: true, destinationError: error });
3152
+ }
3153
+ });
3154
+ return {
3155
+ writable, closed, abortPipe: () => {
3156
+ aborting = true;
3157
+ abortController.abort();
3158
+ }
3159
+ };
3082
3160
  }
3083
3161
 
3084
3162
  function releaseWorkerStreams(workerData) {
@@ -3271,21 +3349,12 @@ function sendMessage(message, { worker, writer, transferStreams, workerAlive })
3271
3349
  }
3272
3350
 
3273
3351
  async function onMessage({ data }, workerData) {
3274
- const { type, value, messageId, result, error } = data;
3352
+ const { type, value, messageId, result, error, errorValue } = data;
3275
3353
  const { reader, writer, resolveResult, rejectResult, onTaskFinished, generation } = workerData;
3276
3354
  const stale = () => workerData.generation != generation;
3277
3355
  try {
3278
3356
  if (error) {
3279
- const { message, stack, code, name, outputSize, cause, codecImportFailed } = error;
3280
- const responseError = new Error(message);
3281
- Object.assign(responseError, { stack, code, name, outputSize });
3282
- if (cause) {
3283
- responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
3284
- }
3285
- if (codecImportFailed) {
3286
- responseError.codecImportFailed = true;
3287
- }
3288
- close(responseError);
3357
+ fail(getResponseError(error, errorValue));
3289
3358
  } else {
3290
3359
  if (type == MESSAGE_PULL) {
3291
3360
  const { value, done } = await reader.read();
@@ -3297,38 +3366,78 @@ async function onMessage({ data }, workerData) {
3297
3366
  const chunk = new Uint8Array(value);
3298
3367
  await writer.ready;
3299
3368
  await writer.write(chunk);
3300
- workerData.outputSize += chunk.length;
3301
3369
  if (!stale()) {
3302
3370
  sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
3303
3371
  }
3304
3372
  }
3305
3373
  if (type == MESSAGE_CLOSE) {
3306
- close(null, result);
3374
+ succeed(result);
3307
3375
  }
3308
3376
  }
3309
3377
  } catch (error) {
3310
3378
  if (!stale()) {
3311
3379
  terminateWorker$1(workerData);
3312
- close(error);
3380
+ fail(error);
3313
3381
  }
3314
3382
  }
3315
3383
 
3316
- function close(error, result) {
3317
- if (stale()) {
3318
- return;
3319
- }
3320
- if (error) {
3384
+ function fail(error) {
3385
+ if (!stale()) {
3321
3386
  rejectResult(error);
3322
- } else {
3387
+ releaseWriter();
3388
+ if (!(isErrorObject(error) && error.codecImportFailed)) {
3389
+ onTaskFinished();
3390
+ }
3391
+ }
3392
+ }
3393
+
3394
+ function succeed(result) {
3395
+ if (!stale()) {
3323
3396
  resolveResult(result);
3397
+ releaseWriter();
3398
+ onTaskFinished();
3324
3399
  }
3400
+ }
3401
+
3402
+ function releaseWriter() {
3325
3403
  if (writer) {
3326
3404
  writer.releaseLock();
3327
3405
  }
3328
- if (!(error && error.codecImportFailed)) {
3329
- onTaskFinished();
3406
+ }
3407
+ }
3408
+
3409
+ function getResponseError(errorData, errorValue) {
3410
+ const { message, stack, code, name, outputSize, cause, codecImportFailed } = errorData;
3411
+ let responseError;
3412
+ if (errorValue) {
3413
+ responseError = errorValue.value;
3414
+ } else {
3415
+ responseError = Object.assign(new Error(message), { stack, code, name });
3416
+ if (cause) {
3417
+ responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
3418
+ }
3419
+ }
3420
+ if (isErrorObject(responseError)) {
3421
+ try {
3422
+ if (outputSize !== UNDEFINED_VALUE) {
3423
+ responseError.outputSize = outputSize;
3424
+ }
3425
+ if (codecImportFailed) {
3426
+ responseError.codecImportFailed = true;
3427
+ }
3428
+ if (errorValue) {
3429
+ if (responseError.name !== name) {
3430
+ responseError.name = name;
3431
+ }
3432
+ if (responseError.code !== code) {
3433
+ responseError.code = code;
3434
+ }
3435
+ }
3436
+ } catch {
3437
+ // ignored
3330
3438
  }
3331
3439
  }
3440
+ return responseError;
3332
3441
  }
3333
3442
 
3334
3443
  /*
@@ -5610,7 +5719,7 @@ let ZipEntry$1 = class ZipEntry {
5610
5719
  readRanges
5611
5720
  });
5612
5721
  }
5613
- let writable, abortError;
5722
+ let writable, abortError, aborted;
5614
5723
  try {
5615
5724
  if (!checkOverlappingEntryOnly) {
5616
5725
  if (checkPasswordOnly) {
@@ -5626,18 +5735,22 @@ let ZipEntry$1 = class ZipEntry {
5626
5735
  writer.size += writtenSize;
5627
5736
  }
5628
5737
  } catch (error) {
5629
- if (error.outputSize !== UNDEFINED_VALUE) {
5738
+ const { outputSize: failedOutputSize } = workerOptions;
5739
+ if (failedOutputSize !== UNDEFINED_VALUE) {
5740
+ writer.size += failedOutputSize;
5741
+ } else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
5630
5742
  writer.size += error.outputSize;
5631
5743
  }
5632
- if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
5744
+ if (!checkPasswordOnly || !isErrorObject(error) || error.message != ERR_ABORT_CHECK_PASSWORD) {
5633
5745
  abortError = error;
5746
+ aborted = true;
5634
5747
  throw error;
5635
5748
  }
5636
5749
  } finally {
5637
5750
  const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5638
5751
  if (!preventClose && writable && !writable.locked) {
5639
5752
  const writableWriter = writable.getWriter();
5640
- if (abortError) {
5753
+ if (aborted) {
5641
5754
  try {
5642
5755
  await writableWriter.abort(abortError);
5643
5756
  } catch {
@@ -6697,7 +6810,7 @@ class ZipWriter {
6697
6810
  await Promise.allSettled(Array.from(pendingAddFileCalls));
6698
6811
  }
6699
6812
  await Promise.allSettled(zipWriter.pendingErrors.map(watcher => watcher.recorded));
6700
- const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.error && !watcher.observed);
6813
+ const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.failed && !watcher.observed);
6701
6814
  if (unobservedWatchers.length) {
6702
6815
  const unobservedErrors = unobservedWatchers.map(watcher => watcher.error);
6703
6816
  unobservedWatchers.forEach(watcher => watcher.observed = true);
@@ -6806,7 +6919,8 @@ function watchPromiseError(zipWriter, promise) {
6806
6919
  const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
6807
6920
  const watcher = {};
6808
6921
  watchedPromise.watcher = watcher;
6809
- watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE, error => watcher.error = error);
6922
+ watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
6923
+ error => Object.assign(watcher, { failed: true, error }));
6810
6924
  zipWriter.pendingErrors.push(watcher);
6811
6925
  return watchedPromise;
6812
6926
  }
@@ -7820,7 +7934,10 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7820
7934
  throw new Error(ERR_UNSUPPORTED_FORMAT);
7821
7935
  }
7822
7936
  } catch (error) {
7823
- if (error.outputSize !== UNDEFINED_VALUE) {
7937
+ const { outputSize: failedOutputSize } = workerOptions;
7938
+ if (failedOutputSize !== UNDEFINED_VALUE) {
7939
+ writer.size += failedOutputSize;
7940
+ } else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
7824
7941
  writer.size += error.outputSize;
7825
7942
  }
7826
7943
  throw error;
@@ -8985,7 +9102,7 @@ function formatSupported(StreamClass, format) {
8985
9102
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8986
9103
  */
8987
9104
 
8988
- const VERSION = "2.12.0";
9105
+ const VERSION = "2.13.1";
8989
9106
 
8990
9107
  /*
8991
9108
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -10020,7 +10137,7 @@ class ZipFileEntry extends ZipEntry {
10020
10137
  }));
10021
10138
  return true;
10022
10139
  } catch (error) {
10023
- if (error.message == ERR_INVALID_PASSWORD) {
10140
+ if (isErrorObject(error) && error.message == ERR_INVALID_PASSWORD) {
10024
10141
  return false;
10025
10142
  } else {
10026
10143
  throw error;
package/index.d.cts CHANGED
@@ -2359,19 +2359,31 @@ export interface LocalDirectory {
2359
2359
  export interface EntryError extends Error {
2360
2360
  /**
2361
2361
  * `true` if the zip file is corrupted because the entry data could not be written entirely.
2362
+ *
2363
+ * @remarks
2364
+ * It is set on the error, so it is absent when the failure reason cannot carry it, i.e. when a
2365
+ * stream is aborted or cancelled with a value that is not an object, or with a frozen one.
2366
+ * {@link ZipWriter#hasCorruptedEntries} reports the same thing on the writer and is always set.
2362
2367
  */
2363
2368
  corruptedEntry?: boolean;
2364
2369
  /**
2365
- * The number of bytes of the entry that reached the writer before the failure, set whenever a
2366
- * compression or decompression stream fails, i.e. on a corrupt entry, an invalid CRC32, a reader
2367
- * erroring mid-entry or an aborted signal.
2370
+ * The number of bytes of the entry that reached the writer before the failure, set on the errors
2371
+ * raised when a compression or decompression stream fails, i.e. on a corrupt entry, an invalid
2372
+ * CRC32, a reader erroring mid-entry or an aborted signal.
2368
2373
  *
2369
2374
  * @remarks
2370
2375
  * It is the counterpart of {@link EntryError#corruptedEntry}: the first says the entry is
2371
- * incomplete, this one says how much of it was written. zip.js reads it itself to keep the offsets
2372
- * of the entries written after the failed one correct, which is what makes the salvage described in
2373
- * {@link ZipWriter#close} possible, so it counts the bytes the writer actually received rather than
2374
- * the bytes the codec produced.
2376
+ * incomplete, this one says how much of it was written, counting the bytes the writer actually
2377
+ * received rather than the bytes the codec produced. Like `corruptedEntry` it is absent when the
2378
+ * failure reason cannot carry it, which does not affect the salvage described in
2379
+ * {@link ZipWriter#close}: zip.js tracks the size of a failed entry on its own, so the offsets of
2380
+ * the entries written afterwards stay correct whatever the reason a stream was aborted with.
2381
+ *
2382
+ * When a stream is aborted or cancelled, the reason the caller passed is what reaches the caller
2383
+ * back, unchanged and with its class and its own properties intact whether or not the codec ran in
2384
+ * a worker, and this property is set on that object. So aborting with an error of your own leaves
2385
+ * that error carrying an `outputSize` afterwards, and aborting with a value that cannot take a new
2386
+ * property, e.g. a frozen error or a value that is not an object, simply leaves it unannotated.
2375
2387
  */
2376
2388
  outputSize?: number;
2377
2389
  /**
package/index.d.ts CHANGED
@@ -2359,19 +2359,31 @@ export interface LocalDirectory {
2359
2359
  export interface EntryError extends Error {
2360
2360
  /**
2361
2361
  * `true` if the zip file is corrupted because the entry data could not be written entirely.
2362
+ *
2363
+ * @remarks
2364
+ * It is set on the error, so it is absent when the failure reason cannot carry it, i.e. when a
2365
+ * stream is aborted or cancelled with a value that is not an object, or with a frozen one.
2366
+ * {@link ZipWriter#hasCorruptedEntries} reports the same thing on the writer and is always set.
2362
2367
  */
2363
2368
  corruptedEntry?: boolean;
2364
2369
  /**
2365
- * The number of bytes of the entry that reached the writer before the failure, set whenever a
2366
- * compression or decompression stream fails, i.e. on a corrupt entry, an invalid CRC32, a reader
2367
- * erroring mid-entry or an aborted signal.
2370
+ * The number of bytes of the entry that reached the writer before the failure, set on the errors
2371
+ * raised when a compression or decompression stream fails, i.e. on a corrupt entry, an invalid
2372
+ * CRC32, a reader erroring mid-entry or an aborted signal.
2368
2373
  *
2369
2374
  * @remarks
2370
2375
  * It is the counterpart of {@link EntryError#corruptedEntry}: the first says the entry is
2371
- * incomplete, this one says how much of it was written. zip.js reads it itself to keep the offsets
2372
- * of the entries written after the failed one correct, which is what makes the salvage described in
2373
- * {@link ZipWriter#close} possible, so it counts the bytes the writer actually received rather than
2374
- * the bytes the codec produced.
2376
+ * incomplete, this one says how much of it was written, counting the bytes the writer actually
2377
+ * received rather than the bytes the codec produced. Like `corruptedEntry` it is absent when the
2378
+ * failure reason cannot carry it, which does not affect the salvage described in
2379
+ * {@link ZipWriter#close}: zip.js tracks the size of a failed entry on its own, so the offsets of
2380
+ * the entries written afterwards stay correct whatever the reason a stream was aborted with.
2381
+ *
2382
+ * When a stream is aborted or cancelled, the reason the caller passed is what reaches the caller
2383
+ * back, unchanged and with its class and its own properties intact whether or not the codec ran in
2384
+ * a worker, and this property is set on that object. So aborting with an error of your own leaves
2385
+ * that error carrying an `outputSize` afterwards, and aborting with a value that cannot take a new
2386
+ * property, e.g. a frozen error or a value that is not an object, simply leaves it unannotated.
2375
2387
  */
2376
2388
  outputSize?: number;
2377
2389
  /**