Comparing version 2.0.7 to 2.0.8
@@ -1,1 +0,1 @@ | ||
var e={913:()=>{try{self["workbox:core:6.5.3"]&&_()}catch(e){}},1:()=>{try{self["workbox:streams:6.5.3"]&&_()}catch(e){}},211:(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,s,o;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)o=i+u,s=o>>>2,a.length<=s&&a.push(0),a[s]|=e[i]<<8*(c+r*(o%4));return{value:a,binLen:8*e.length+n}}function s(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(s=parseInt(e.substr(i,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,o=a>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let s,o,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(s=e.charCodeAt(a),o=[],128>s?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&e.charCodeAt(a)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<o.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(s=e.charCodeAt(a),!0===f&&(u=255&s,s=u<<8|s>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let s,o,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(o=0;o<e.length;o+=4){for(c=e.substr(o,4),u=0,a=0;a<c.length;a+=1)s=r.indexOf(c.charAt(a)),u|=s<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(s=0;s<e.length;s+=1)i=e.charCodeAt(s),a=s+c,o=a>>>2,u.length<=o&&u.push(0),u[o]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function o(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let s,o,a="";const u=t/8,c=-1===n?3:0;for(s=0;s<u;s+=1)o=e[s>>>2]>>>8*(c+n*(s%4)),a+=i.charAt(o>>>4&15)+i.charAt(15&o);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let s,o,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(s=0;s<l;s+=3)for(u=s+1<l?e[s+1>>>2]:0,c=s+2<l?e[s+2>>>2]:0,a=(e[s>>>2]>>>8*(f+n*(s%4))&255)<<16|(u>>>8*(f+n*((s+1)%4))&255)<<8|c>>>8*(f+n*((s+2)%4))&255,o=0;o<4;o+=1)h+=8*s+6*o<=t?r.charAt(a>>>6*(3-o)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,s="";const o=t/8,a=-1===n?3:0;for(r=0;r<o;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,s+=String.fromCharCode(i);return s}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=new ArrayBuffer(i),o=new Uint8Array(s),a=-1===n?3:0;for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return s}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=-1===n?3:0,o=new Uint8Array(i);for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(s+n*(r%4))&255;return o}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function a(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function u(e,t){return e<<t|e>>>32-t}function c(e,t,n){return e^t^n}function h(e,t,n){return e&t^e&n^t&n}function l(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function f(e,t,n,r,i){const s=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function p(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(e,t){let n,r,i,s,o,a,p;const d=[];for(n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],p=0;p<80;p+=1)d[p]=p<16?e[p]:u(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),a=p<20?f(u(n,5),(g=r)&i^~g&s,o,1518500249,d[p]):p<40?f(u(n,5),c(r,i,s),o,1859775393,d[p]):p<60?f(u(n,5),h(r,i,s),o,2400959708,d[p]):f(u(n,5),c(r,i,s),o,3395469782,d[p]),o=s,s=i,i=u(r,30),r=n,n=a;var g;return t[0]=l(n,t[0]),t[1]=l(r,t[1]),t[2]=l(i,t[2]),t[3]=l(s,t[3]),t[4]=l(o,t[4]),t}function g(e,t,n,r){let i;const s=15+(t+65>>>9<<4),o=t+n;for(;e.length<=s;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[s]=4294967295&o,e[s-1]=o/4294967296|0,i=0;i<e.length;i+=16)r=d(e.slice(i,i+16),r);return r}class w extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),s=i.binLen,o=i.value,a=s>>>5;for(t=0;t<a;t+=r)n+this.T<=s&&(this.m=this.g(o.slice(t,t+r),this.m),n+=this.T);return this.A+=n,this.h=o.slice(n>>>5),this.u=s%this.T,this.l=!0,this}getHash(e,t){let n,r,i=this.B;const s=a(t);if(this.v){if(-1===s.outputLen)throw new Error("Output length must be specified in options");i=s.outputLen}const u=o(e,i,this.Y,s);if(this.p&&this.H)return u(this.H(s));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),i),n=1;n<this.numRounds;n+=1)this.v&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.L(this.o),i);return u(r)}setHMACKey(e,t,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=s(t,(n||{}).encoding||"UTF8",this.Y);this.N(r(e))}N(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.L(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const n=a(t);return o(e,this.B,this.Y,n)(this.S())}S(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return e=this.g(this.U,this.L(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-1"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=s(this.t,this.i,this.Y),this.g=d,this.I=function(e){return e.slice()},this.L=p,this.C=g,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return s(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.Y))}}},673:(e,t,n)=>{n.r(t),n.d(t,{default:()=>E});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,s,o;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)o=i+u,s=o>>>2,a.length<=s&&a.push(0),a[s]|=e[i]<<8*(c+r*(o%4));return{value:a,binLen:8*e.length+n}}function s(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(s=parseInt(e.substr(i,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,o=a>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let s,o,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(s=e.charCodeAt(a),o=[],128>s?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&e.charCodeAt(a)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<o.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(s=e.charCodeAt(a),!0===f&&(u=255&s,s=u<<8|s>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let s,o,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(o=0;o<e.length;o+=4){for(c=e.substr(o,4),u=0,a=0;a<c.length;a+=1)s=r.indexOf(c.charAt(a)),u|=s<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(s=0;s<e.length;s+=1)i=e.charCodeAt(s),a=s+c,o=a>>>2,u.length<=o&&u.push(0),u[o]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function o(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let s,o,a="";const u=t/8,c=-1===n?3:0;for(s=0;s<u;s+=1)o=e[s>>>2]>>>8*(c+n*(s%4)),a+=i.charAt(o>>>4&15)+i.charAt(15&o);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let s,o,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(s=0;s<l;s+=3)for(u=s+1<l?e[s+1>>>2]:0,c=s+2<l?e[s+2>>>2]:0,a=(e[s>>>2]>>>8*(f+n*(s%4))&255)<<16|(u>>>8*(f+n*((s+1)%4))&255)<<8|c>>>8*(f+n*((s+2)%4))&255,o=0;o<4;o+=1)h+=8*s+6*o<=t?r.charAt(a>>>6*(3-o)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,s="";const o=t/8,a=-1===n?3:0;for(r=0;r<o;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,s+=String.fromCharCode(i);return s}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=new ArrayBuffer(i),o=new Uint8Array(s),a=-1===n?3:0;for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return s}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=-1===n?3:0,o=new Uint8Array(i);for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(s+n*(r%4))&255;return o}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],c=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function h(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function l(e,t){return e>>>t|e<<32-t}function f(e,t){return e>>>t}function p(e,t,n){return e&t^~e&n}function d(e,t,n){return e&t^e&n^t&n}function g(e){return l(e,2)^l(e,13)^l(e,22)}function w(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function y(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){const s=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function b(e){return l(e,7)^l(e,18)^f(e,3)}function L(e){return l(e,6)^l(e,11)^l(e,25)}function v(e){let t;return t="SHA-224"==e?u.slice():c.slice(),t}function A(e,t){let n,r,i,s,o,u,c,h,v,A,E;const k=[];for(n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],c=t[6],h=t[7],E=0;E<64;E+=1)k[E]=E<16?e[E]:y(l(S=k[E-2],17)^l(S,19)^f(S,10),k[E-7],b(k[E-15]),k[E-16]),v=m(h,L(o),p(o,u,c),a[E],k[E]),A=w(g(n),d(n,r,i)),h=c,c=u,u=o,o=w(s,v),s=i,i=r,r=n,n=w(v,A);var S;return t[0]=w(n,t[0]),t[1]=w(r,t[1]),t[2]=w(i,t[2]),t[3]=w(s,t[3]),t[4]=w(o,t[4]),t[5]=w(u,t[5]),t[6]=w(c,t[6]),t[7]=w(h,t[7]),t}class E extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),s=i.binLen,o=i.value,a=s>>>5;for(t=0;t<a;t+=r)n+this.T<=s&&(this.m=this.g(o.slice(t,t+r),this.m),n+=this.T);return this.l+=n,this.h=o.slice(n>>>5),this.u=s%this.T,this.A=!0,this}getHash(e,t){let n,r,i=this.B;const s=h(t);if(this.H){if(-1===s.outputLen)throw new Error("Output length must be specified in options");i=s.outputLen}const a=o(e,i,this.v,s);if(this.p&&this.Y)return a(this.Y(s));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),i),n=1;n<this.numRounds;n+=1)this.H&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.I(this.o),i);return a(r)}setHMACKey(e,t,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=s(t,(n||{}).encoding||"UTF8",this.v);this.M(r(e))}M(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.I(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(e,t){const n=h(t);return o(e,this.B,this.v,n)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return e=this.g(this.U,this.I(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=s(this.t,this.i,this.v),this.g=A,this.S=function(e){return e.slice()},this.I=v,this.C=function(t,n,r,i){return function(e,t,n,r,i){let s,o;const a=15+(t+65>>>9<<4),u=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&u,e[a-1]=u/4294967296|0,s=0;s<e.length;s+=16)r=A(e.slice(s,s+16),r);return o="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,o}(t,n,r,i,e)},this.m=v(e),this.T=512,this.B="SHA-224"===e?224:256,this.H=!1,r.hmacKey&&this.M(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return s(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.v))}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{n.d(r,{z9:()=>Ae,j$:()=>g,nm:()=>l,Xz:()=>s,ul:()=>a,zo:()=>c,zM:()=>t,pI:()=>p,I4:()=>d,Fl:()=>h,In:()=>i,Cj:()=>o,t6:()=>u,mh:()=>e,LQ:()=>f,R2:()=>q,rJ:()=>$,xI:()=>ve,d:()=>Ee,e9:()=>_,K2:()=>V,ZC:()=>W,iv:()=>P,d2:()=>C,vB:()=>Le,y1:()=>be,Hv:()=>b,Ue:()=>Te,Jx:()=>I,cv:()=>S,Pi:()=>re,um:()=>ie,sK:()=>y,fK:()=>v,Fw:()=>w,zE:()=>Z,RU:()=>Q,Xs:()=>ee,r1:()=>G,Kl:()=>te,A7:()=>me,px:()=>we,ZW:()=>ye,ti:()=>ge,bX:()=>m,Dc:()=>A,fp:()=>L,Ye:()=>pe,Qc:()=>x,hP:()=>fe,LU:()=>le,yQ:()=>T,Zk:()=>B,uh:()=>U});const e=108,t=new Uint8Array([e]),i=100,s=new Uint8Array([i]),o=101,a=new Uint8Array([o]),u=105,c=new Uint8Array([u]),h=58,l=new Uint8Array([h]),f=45,p=new Uint8Array([f]),d=48,g=new Uint8Array([d]);function w(e){return e>=d&&e<=d+9}function y(e,t,n){let r=0,i=e.length;for(;r<i;){const s=r+i>>>1,o=n(e[s],t);if(0===o)return{index:s,result:e[s]};o<0?r=s+1:i=s}return{index:r,result:void 0}}function m(e,t){const n=[];for(const r of e){const{index:e}=y(n,r,t);n.splice(e,0,r)}return n}function b(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.byteLength),0));return e.reduce(((e,n)=>(t.set(n,e),e+n.byteLength)),0),t}function L(e){return 1<<32-Math.clz32(e-1)}function v(){return Math.round(Date.now()/1e3)}async function A(e){if(0===e.length)throw new Error("Empty leaves");const t=new Uint8Array(64);for(;e.length>1;){let r=!1;const i=[];for(const s of e)if(r){let e;t.set(s,32);try{e=new Uint8Array(await crypto.subtle.digest("SHA-256",t))}catch{const{default:r}=await Promise.resolve().then(n.bind(n,673)),i=new r("SHA-256","UINT8ARRAY");i.update(t),e=i.getHash("UINT8ARRAY")}i.push(e),r=!1}else t.set(s),r=!0;e=i}return e[0]}const E=new WeakMap;class k{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;path=[];hookSystem;attachedHooks=new WeakMap;constructor(e,t){this.data=e,this.hookSystem=t,t&&E.set(t,!0)}start(e){if(this.encode(this.data,e),this.hookSystem)for(const e of this.hookSystem.values())this.attachedHooks.get(e)||e({value:void 0,done:!0});e.close()}encode(e,n){if(null!=e)if("boolean"==typeof e)this.encode(e?1:0,n);else if("number"==typeof e){const t=Math.round(e);n.enqueue(this.textEncoder.encode(`i${t}e`)),t!==e&&(console.warn(`WARNING: Possible data corruption detected with value "${e}":`,`Bencoding only defines support for integers, value was converted to "${t}"`),console.trace())}else if("bigint"==typeof e)n.enqueue(this.textEncoder.encode(`i${e}e`));else if("string"==typeof e){const t=this.textEncoder.encode(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(e instanceof ArrayBuffer){const t=new Uint8Array(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(Array.isArray(e)){n.enqueue(t);let r=0;for(const t of e){if(this.path.push(r),this.hookSystem){const e=this.hookSystem.get(this.path);if(e){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0})}else this.encode(t,n)}this.path.pop(),++r}n.enqueue(a)}else if(e instanceof Map){n.enqueue(s);const t=m(e.keys(),((e,t)=>(e="string"==typeof e?e:this.textDecoder.decode(e))<(t="string"==typeof t?t:this.textDecoder.decode(t))?-1:e>t?1:0));for(const r of t){const t=e.get(r);if(void 0!==t&&null!==e)if(r instanceof ArrayBuffer)this.encode(r,n),this.encode(t,n);else{if(this.path.push(r),this.encode(r,n),this.hookSystem){const e=this.hookSystem.get(this.path);if(e){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n)}this.path.pop()}}n.enqueue(a)}else{n.enqueue(s);const t=Object.keys(e).sort();for(const r of t){const t=e[r];if(void 0!==t&&null!==e){if(this.path.push(r),this.encode(r,n),this.hookSystem){const e=this.hookSystem.get(this.path);if(e){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n)}this.path.pop()}}n.enqueue(a)}}}function S(e,t){return new ReadableStream(new k(e,t))}function R(e,t){return new Proxy(e,{get:function(e,n,r){return"enqueue"===n?(n=>{e.enqueue(n),t({value:n,done:!1})}).bind(e):Reflect.get(e,n,r)}})}function U(e,t){const n={controller:null},r=new ReadableStream({start(e){n.controller=e},pull(e){E.get(t)||(console.warn("You need to call encode() first and then consume hooks."),e.close(),n.controller=null)}});return t.set(e,(({value:e,done:t})=>{null!==n.controller&&(t?n.controller.close():n.controller.enqueue(e))})),r}function T(e,t){const n=U(e,t);return new Response(n).arrayBuffer()}function B(e,t){const n=U(e,t);return new Response(n).text()}var P;!function(e){e.Integer="Integer",e.ByteString="ByteString",e.ListStart="ListStart",e.ListEnd="ListEnd",e.DictionaryStart="DictionaryStart",e.DictionaryEnd="DictionaryEnd"}(P||(P={}));class F{endStack=[];token=null;byteStringLength=-1;byteStringOffset=0;transform(e,t){this.tokenize(e,t)}flush(){if(this.endStack.length||this.token||-1!==this.byteStringLength||this.byteStringOffset)throw new SyntaxError("Unexpected end of torrent stream")}tokenize(t,n){if(0!==t.byteLength)if(null===this.token&&-1===this.byteStringLength){const r=t[0];if(r===u)this.token={type:P.Integer,value:new Uint8Array};else if(w(r))this.byteStringLength=r-d;else if(r===e)this.endStack.push(P.ListEnd),n.enqueue({type:P.ListStart});else if(r===i)this.endStack.push(P.DictionaryEnd),n.enqueue({type:P.DictionaryStart});else{if(r!==o)throw new SyntaxError(`Unexpected byte: ${r}`);{const e=this.endStack.pop();if(!e)throw new SyntaxError("Unbalanced delimiter");n.enqueue({type:e})}}this.tokenize(t.subarray(1),n)}else if(this.token&&-1===this.byteStringLength)if(this.token.type===P.Integer){const e=t.indexOf(o);-1===e?this.token.value=this.token.value?b(this.token.value,t):t:(this.token.value=this.token.value?b(this.token.value,t.subarray(0,e)):t.subarray(0,e),n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e+1),n))}else{if(this.token.type!==P.ByteString)throw new Error("This is a bug");{const e=this.token.value.byteLength-this.byteStringOffset,r=t.byteLength;r<e?(this.token.value.set(t,this.byteStringOffset),this.byteStringOffset+=r):(this.token.value.set(t.subarray(0,e),this.byteStringOffset),this.byteStringOffset=0,n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e),n))}}else{if(!(this.byteStringLength>-1&&null===this.token))throw new Error("This is a bug");{let e=-1;for(const[n,r]of t.entries()){if(!w(r)){if(r===h){e=n;break}throw new SyntaxError(`Unexpected byte: ${r}`)}this.byteStringLength=10*this.byteStringLength-d+r}-1!==e&&(this.token={type:P.ByteString,value:new Uint8Array(this.byteStringLength)},this.byteStringLength=-1,this.tokenize(t.subarray(e+1),n))}}}}class C extends TransformStream{constructor(){super(new F)}}async function x(e){let t;const n=[],r=e.getReader();let i;for(;;){const{done:e,value:s}=await r.read();if(e)break;const o=n.at(-1);if(o)if(Array.isArray(o))switch(s.type){case P.Integer:o.push(N(s.value));break;case P.ByteString:o.push(H(s.value));break;case P.DictionaryStart:{const e=Object.create(null);o.push(e),n.push(e);break}case P.ListStart:{const e=[];o.push(e),n.push(e);break}case P.ListEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}else if(void 0===i)switch(s.type){case P.ByteString:i=H(s.value);break;case P.DictionaryEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}else{switch(s.type){case P.Integer:o[i]=N(s.value);break;case P.ByteString:o[i]=H(s.value);break;case P.DictionaryStart:{const e=Object.create(null);o[i]=e,n.push(e);break}case P.ListStart:{const e=[];o[i]=e,n.push(e);break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}i=void 0}else{if(void 0!==t)throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`);switch(s.type){case P.Integer:t=N(s.value);break;case P.ByteString:t=H(s.value);break;case P.DictionaryStart:{const e=Object.create(null);n.push(e),t=e;break}case P.ListStart:{const e=[];n.push(e),t=e;break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}}}if(n.length)throw new Error("Unexpected end of token stream");return t}async function I(e){const t=new C,n=e.pipeThrough(t);return await x(n)}function N(e){let t=0,n=!0;for(const[r,i]of e.entries()){if(0===r&&i===f){n=!1;continue}if(1===r&&!n&&i===d)throw new SyntaxError("Negative zero is not a valid integer");if(1===r&&0===t)throw new SyntaxError("Leading zeros are not allowed");if(!w(i))throw new SyntaxError(`Unexpected byte: ${i}`);const e=i-d;(n&&"number"==typeof t&&t>(Number.MAX_SAFE_INTEGER-e)/10||!n&&"number"==typeof t&&t<(Number.MIN_SAFE_INTEGER+e)/10)&&(t=BigInt(t)),t="number"==typeof t?n?10*t+e:10*t-e:n?10n*t+BigInt(e):10n*t-BigInt(e)}return t}function H(e){return(new TextDecoder).decode(e)}n(913);class M extends Error{constructor(e,t){super(((e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n})(e,t)),this.name=e,this.details=t}}class Y{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function D(e){const t=e.map((e=>Promise.resolve(e).then((e=>function(e){if(e instanceof Response){if(e.body)return e.body.getReader();throw new M("opaque-streams-source",{type:e.type})}return e instanceof ReadableStream?e.getReader():new Response(e).body.getReader()}(e))))),n=new Y;let r=0;const i=new ReadableStream({pull(e){return t[r].then((e=>e.read())).then((i=>{if(i.done)return r++,r>=t.length?(e.close(),void n.resolve()):this.pull(e);e.enqueue(i.value)})).catch((e=>{throw n.reject(e),e}))},cancel(){n.resolve()}});return{done:n.promise,stream:i}}n(1);const O=new Uint8Array(32);class z{blockCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}async transform(e,t){let r;++this.blockCount;try{r=new Uint8Array(await crypto.subtle.digest("SHA-256",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),i=new t("SHA-256","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}this.merkleLeaves.push(r),this.merkleLeaves.length===this.blocksPerPiece&&(t.enqueue(this.merkleLeaves),this.merkleLeaves=[])}flush(e){if(0===this.blockCount)return;let t=0;if(this.blockCount<this.blocksPerPiece)t=L(this.blockCount)-this.blockCount;else{const e=this.blockCount%this.blocksPerPiece;e>0&&(t=this.blocksPerPiece-e)}if(t>0)for(let e=0;e<t;++e)this.merkleLeaves.push(O);this.merkleLeaves.length>0&&e.enqueue(this.merkleLeaves)}}class q extends TransformStream{constructor(e){super(new z(e))}}class K{residuePointer=0;chunkLength;residue;opts;constructor(e,t={padding:!1}){this.chunkLength=e,this.opts=t,this.residue=new Uint8Array(this.chunkLength)}transform(e,t){for(;this.residuePointer+e.byteLength>=this.chunkLength;){const n=this.chunkLength-this.residuePointer;this.residue.set(e.subarray(0,n),this.residuePointer),this.residuePointer=0,t.enqueue(new Uint8Array(this.residue)),e=e.subarray(n)}this.residue.set(e,this.residuePointer),this.residuePointer+=e.byteLength}flush(e){this.residuePointer<=0||(this.opts.padding?(this.residue.set(new Uint8Array(this.chunkLength-this.residuePointer),this.residuePointer),e.enqueue(this.residue)):e.enqueue(this.residue.subarray(0,this.residuePointer)))}}class $ extends TransformStream{constructor(e,t={padding:!1}){super(new K(e,t))}}class X{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){t.enqueue(await A(e)),this.updateProgress&&await this.updateProgress()}}class _ extends TransformStream{constructor(e){super(new X(e))}}class j{leafCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}transform(e){++this.leafCount,this.merkleLeaves.push(e)}async flush(e){const t=L(this.leafCount)-this.leafCount;if(t>0){const e=await this.padLeafPromise;for(let n=0;n<t;++n)this.merkleLeaves.push(e)}e.enqueue(this.merkleLeaves)}get padLeafPromise(){return A(Array(this.blocksPerPiece).fill(new Uint8Array(32)))}}class V extends TransformStream{constructor(e){super(new j(e))}}class J{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){let r;try{r=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),i=new t("SHA-1","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}t.enqueue(r),this.updateProgress&&await this.updateProgress()}}class W extends TransformStream{constructor(e){super(new J(e))}}function Z(e){return e instanceof File}function Q(e){return!ee(e)&&!Z(e)&&e.isDirectory}function G(e){return!ee(e)&&!Z(e)&&e.isFile}function ee(e){try{if(e instanceof FileSystemHandle&&"directory"===e.kind)return!0}catch(e){}return!1}function te(e){try{if(e instanceof FileSystemHandle&&"file"===e.kind)return!0}catch(e){}return!1}function ne(e){return new Promise(((t,n)=>{e.readEntries(t,n)}))}async function*re(e){const t=e.createReader();let n=[];do{n=await ne(t);for(const e of n)yield e}while(n.length>0)}function ie(e){return new Promise(((t,n)=>{e.file(t,n)}))}const se={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let oe;const ae=new Uint8Array(16);function ue(){if(!oe&&(oe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!oe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oe(ae)}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));const he=function(e,t,n){if(se.randomUUID&&!t&&!e)return se.randomUUID();const r=(e=e||{}).random||(e.rng||ue)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(r)};function le(e,t){if(t.size>1||0===t.size)return{name:e||he(),commonDir:void 0};const[n,r]=t.entries().next().value;return ge(r)?{name:e||n,commonDir:void 0}:{name:e||n,commonDir:n}}async function fe(e,{sort:t=!0,compareFunction:n=be,polyfillWebkitRelativePath:r=!0}={sort:!0,compareFunction:be,polyfillWebkitRelativePath:!0}){let i=0,s=0;const o=new WeakMap,a=new WeakMap,u=new WeakMap,c=["file tree",[]],h=[c];let l=!1;for await(const t of e)await f(t);return{fileTree:pe(c[1],l),traverseTree:function*e(t){if(we(t))for(const n of t.values())yield*e(n);else yield[t,u.get(t)]},totalFileSize:i,totalFileCount:s};async function f(e){const p=h.at(-1);if(!p)throw new Error("This is a bug");const d=Z(e),g=ee(e),w=Q(e),m=te(e),b=G(e);if(g||w){const r=e.name,{index:i,result:s}=y(p[1],r,n);let o=s;if(ye(o))throw new Error("A same name file already exists");if(me(o)&&g){const t=a.get(o);if(!t||!await e.isSameEntry(t))throw new Error("File system handle not match")}o||(o=[r,[]],t?p[1].splice(i,0,o):p[1].push(o),g&&a.set(o,e)),h.push(o);for await(const t of g?e.values():re(e))await f(t);o[1]=new Map(o[1]),h.pop()}else if(m||b){const a=e.name,{index:c,result:l}=y(p[1],a,n);let f=l;if(ye(f)&&m){const t=o.get(f);if(!t||!await e.isSameEntry(t))throw new Error("A same name file already exists")}if(me(f))throw new Error("A same name directory already exists");if(f)return;const d=await(m?e.getFile():ie(e)),g=d.size;if(r){const e=h.reduce(((e,t,n)=>0===n?e:e+t[0]+"/"),"")+d.name;Object.defineProperty(d,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e})}const w={"":{length:g}};f=[a,w],t?p[1].splice(c,0,f):p[1].push(f),m&&o.set(f,e),u.set(w,d),i+=g,s+=1}else{if(!d)throw new Error("Unrecognized type of input");{r&&""===e.webkitRelativePath&&Object.defineProperty(e,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e.name});const o=(e.webkitRelativePath||e.name).split("/"),a=[c];for(const[r,c]of o.entries()){r>=1&&(l=!0);const h=a.at(-1);if(!h)throw new Error("This is a bug");const{index:f,result:p}=y(h[1],c,n);if(r<o.length-1){let e=p;if(ye(e))throw new Error("A same name file already exists");e||(e=[c,[]],t?h[1].splice(f,0,e):h[1].push(e)),a.push(e)}else{let n=p;if(me(n))throw new Error("A same name directory already exists");if(n)return;const r=e.size,o={"":{length:r}};n=[c,o],t?h[1].splice(f,0,n):h[1].push(n),u.set(o,e),i+=r,s+=1}}}}}}function pe(e,t=!1){return t&&de(e),new Map(e)}function de(e){for(const t of e)if(me(t)){const e=t[1];de(e),t[1]=new Map(e)}}function ge(e){return!!e&&""in e}function we(e){return e instanceof Map}function ye(e){return!!e&&""in e[1]}function me(e){return!!e&&!(""in e[1])}function be(e,t){return e[0]<t?-1:e[0]>t?1:0}var Le,ve;!function(e){e.V1="v1",e.V2="v2",e.HYBRID="hybrid"}(Le||(Le={})),function(e){e[e["16KB"]=16384]="16KB",e[e["32KB"]=32768]="32KB",e[e["64KB"]=65536]="64KB",e[e["128KB"]=131072]="128KB",e[e["256KB"]=262144]="256KB",e[e["512KB"]=524288]="512KB",e[e["1MB"]=1048576]="1MB",e[e["2MB"]=2097152]="2MB",e[e["4MB"]=4194304]="4MB",e[e["8MB"]=8388608]="8MB",e[e["16MB"]=16777216]="16MB",e[e["32MB"]=33554432]="32MB"}(ve||(ve={}));const Ae=16384,Ee=2,ke={type:Le.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:Ae,pieceLength:NaN,sortFiles:!0,isPrivate:!1},Se={type:Le.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:Ae,pieceLength:NaN,metaVersion:Ee,isPrivate:!1},Re={type:Le.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:Ae,pieceLength:NaN,metaVersion:Ee,isPrivate:!1};function Ue(e,t){let n=0;for(const r of e)n+=Math.ceil(r.size/t);return n}async function Te(e,t={type:Le.V1},n){switch(t.type){case Le.V1:return await async function(e,t,n){const r={...ke,...t},{fileTree:i,traverseTree:s,totalFileCount:o,totalFileSize:a}=await fe(e,{sort:r.sortFiles});if(0===o)return;const u=[];for(const[,e]of s(i))u.push(e);isNaN(r.pieceLength)&&(r.pieceLength=Ne(a,r.blockLength)),0!=(r.pieceLength&r.pieceLength-1)&&console.warn(`piece length ${r.pieceLength} is not a power of 2`),r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ie(r.urlList);const[c,h]=Ce(0,n),{commonDir:l,name:f}=le(r.name,i);let p;if(r.name=f,r.addPaddingFiles){const e=Ue(u,r.pieceLength);await h(e);const t=[],n=o-1;for(let e=n;e>=0;--e){const i=u[e];if(t.unshift(Promise.resolve(Pe(i.stream(),{pieceLength:r.pieceLength,padding:e!==n,updateProgress:c}))),e===n)continue;const s=i.size%r.pieceLength;if(0===s)continue;const o=Fe(r.pieceLength-s,l);u.splice(e+1,0,o)}p=D(t).stream}else{const e=Math.ceil(a/r.pieceLength);await h(e);const{stream:t}=D(u.map((e=>Promise.resolve(e.stream()))));p=Pe(t,{pieceLength:r.pieceLength,padding:!1,updateProgress:c})}return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.7"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{...o>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return l&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},name:r.name,"piece length":r.pieceLength,pieces:await new Response(p).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.V2:return await async function(e,t,n){const r={...Se,...t},{fileTree:i,traverseTree:s,totalFileCount:o,totalFileSize:a}=await fe(e);if(0===o)return;const u=[],c=[];for(const[e,t]of s(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ne(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ie(r.urlList);const l=Ue(u,r.pieceLength),[f]=Ce(l,n),{name:p}=le(r.name,i);r.name=p;const d=new Map;return await Promise.all(c.map((async([e,t])=>{await Be(t.stream(),d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:f})}))),{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.7"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.HYBRID:return await async function(e,t,n){const r={...Re,...t},{fileTree:i,traverseTree:s,totalFileCount:o,totalFileSize:a}=await fe(e);if(0===o)return;const u=[],c=[];for(const[e,t]of s(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ne(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ie(r.urlList);const[l]=Ce(2*Ue(u,r.pieceLength),n),{commonDir:f,name:p}=le(r.name,i);r.name=p;const d=new Map,g=[];let w=o-1,y=-1;for(const[e,t]of c){++y;const[n,i]=t.stream().tee();if(g.unshift(Promise.resolve(Pe(n,{pieceLength:r.pieceLength,padding:y!==w,updateProgress:l}))),await Be(i,d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:l}),y===w)break;const s=t.size%r.pieceLength;if(0===s)continue;const o=Fe(r.pieceLength-s,f);u.splice(++y,0,o),++w}const m=D(g).stream;return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.7"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,...o>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return f&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,pieces:await new Response(m).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n)}}async function Be(e,t,n,r){const{piecesRootReadableStream:i,pieceLayerReadableStream:s}=function(e,t){const n=e.pipeThrough(new $(t.blockLength)).pipeThrough(new q(t.blocksPerPiece)).pipeThrough(new _(t.updateProgress)),[r,i]=n.tee();return{piecesRootReadableStream:i.pipeThrough(new V(t.blocksPerPiece)).pipeThrough(new _),pieceLayerReadableStream:r}}(e,r),o=new Response(i).arrayBuffer();if(n[""].length>r.pieceLength){const e=new Response(s).arrayBuffer();t.set(await o,await e)}n[""].length>0&&(n[""]["pieces root"]=await o)}function Pe(e,t){return e.pipeThrough(new $(t.pieceLength,{padding:t.padding})).pipeThrough(new W(t.updateProgress))}function Fe(e,t){const n=new File([new ArrayBuffer(e)],`${e}`,{type:"application/octet-stream"}),r=`.pad/${e}`,i=void 0===t?r:`${t}/${r}`;return Object.defineProperties(n,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>i},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),n}function Ce(e,t){const n={current:0,total:e};return[async()=>{t&&await t(++n.current,n.total)},async e=>{n.total="number"==typeof e?e:await e(n.total,n.current)}]}function xe(e){if(void 0===e)return;const t=[];for(const n of e)0!==n.length&&t.push(n);return 0!==t.length?t:void 0}function Ie(e){if(void 0!==e&&0!==e.length)return e}function Ne(e,t){return Math.max(t,L(e>>>10))}})();var i=r.z9,s=r.j$,o=r.nm,a=r.Xz,u=r.ul,c=r.zo,h=r.zM,l=r.pI,f=r.I4,p=r.Fl,d=r.In,g=r.Cj,w=r.t6,y=r.mh,m=r.LQ,b=r.R2,L=r.rJ,v=r.xI,A=r.d,E=r.e9,k=r.K2,S=r.ZC,R=r.iv,U=r.d2,T=r.vB,B=r.y1,P=r.Hv,F=r.Ue,C=r.Jx,x=r.cv,I=r.Pi,N=r.um,H=r.sK,M=r.fK,Y=r.Fw,D=r.zE,O=r.RU,z=r.Xs,q=r.r1,K=r.Kl,$=r.A7,X=r.px,j=r.ZW,V=r.ti,J=r.bX,W=r.Dc,Z=r.fp,Q=r.Ye,G=r.Qc,ee=r.hP,te=r.LU,ne=r.yQ,re=r.Zk,ie=r.uh;export{i as BLOCK_LENGTH,s as BUFF_0,o as BUFF_COLON,a as BUFF_D,u as BUFF_E,c as BUFF_I,h as BUFF_L,l as BUFF_MINUS,f as BYTE_0,p as BYTE_COLON,d as BYTE_D,g as BYTE_E,w as BYTE_I,y as BYTE_L,m as BYTE_MINUS,b as BlockHasher,L as ChunkSplitter,v as CommonPieceLength,A as META_VERSION,E as MerkleRootCalculator,k as MerkleTreeBalancer,S as PieceHasher,R as TokenType,U as Tokenizer,T as TorrentType,B as compareEntryNames,P as concatUint8Arrays,F as create,C as decode,x as encode,I as getEntriesOfDirEntry,N as getFileOfFileEntry,H as getSortedIndex,M as getTimeStampSecondsNow,Y as isDigitByte,D as isFile,O as isFileSystemDirectoryEntry,z as isFileSystemDirectoryHandle,q as isFileSystemFileEntry,K as isFileSystemFileHandle,$ as isFileTreeDirEntry,X as isFileTreeDirNode,j as isFileTreeFileEntry,V as isFileTreeFileNode,J as iterableSort,W as merkleRoot,Z as nextPowerOfTwo,Q as packEntriesToDirNode,G as parse,ee as populateFileTree,te as resolveCommonDirAndTorrentName,ne as useArrayBufferPromiseHook,re as useTextPromiseHook,ie as useUint8ArrayStreamHook}; | ||
var e={913:()=>{try{self["workbox:core:6.5.3"]&&_()}catch(e){}},1:()=>{try{self["workbox:streams:6.5.3"]&&_()}catch(e){}},211:(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,s,o;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)o=i+u,s=o>>>2,a.length<=s&&a.push(0),a[s]|=e[i]<<8*(c+r*(o%4));return{value:a,binLen:8*e.length+n}}function s(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(s=parseInt(e.substr(i,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,o=a>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let s,o,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(s=e.charCodeAt(a),o=[],128>s?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&e.charCodeAt(a)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<o.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(s=e.charCodeAt(a),!0===f&&(u=255&s,s=u<<8|s>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let s,o,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(o=0;o<e.length;o+=4){for(c=e.substr(o,4),u=0,a=0;a<c.length;a+=1)s=r.indexOf(c.charAt(a)),u|=s<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(s=0;s<e.length;s+=1)i=e.charCodeAt(s),a=s+c,o=a>>>2,u.length<=o&&u.push(0),u[o]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function o(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let s,o,a="";const u=t/8,c=-1===n?3:0;for(s=0;s<u;s+=1)o=e[s>>>2]>>>8*(c+n*(s%4)),a+=i.charAt(o>>>4&15)+i.charAt(15&o);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let s,o,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(s=0;s<l;s+=3)for(u=s+1<l?e[s+1>>>2]:0,c=s+2<l?e[s+2>>>2]:0,a=(e[s>>>2]>>>8*(f+n*(s%4))&255)<<16|(u>>>8*(f+n*((s+1)%4))&255)<<8|c>>>8*(f+n*((s+2)%4))&255,o=0;o<4;o+=1)h+=8*s+6*o<=t?r.charAt(a>>>6*(3-o)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,s="";const o=t/8,a=-1===n?3:0;for(r=0;r<o;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,s+=String.fromCharCode(i);return s}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=new ArrayBuffer(i),o=new Uint8Array(s),a=-1===n?3:0;for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return s}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=-1===n?3:0,o=new Uint8Array(i);for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(s+n*(r%4))&255;return o}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function a(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function u(e,t){return e<<t|e>>>32-t}function c(e,t,n){return e^t^n}function h(e,t,n){return e&t^e&n^t&n}function l(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function f(e,t,n,r,i){const s=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function p(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(e,t){let n,r,i,s,o,a,p;const d=[];for(n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],p=0;p<80;p+=1)d[p]=p<16?e[p]:u(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),a=p<20?f(u(n,5),(g=r)&i^~g&s,o,1518500249,d[p]):p<40?f(u(n,5),c(r,i,s),o,1859775393,d[p]):p<60?f(u(n,5),h(r,i,s),o,2400959708,d[p]):f(u(n,5),c(r,i,s),o,3395469782,d[p]),o=s,s=i,i=u(r,30),r=n,n=a;var g;return t[0]=l(n,t[0]),t[1]=l(r,t[1]),t[2]=l(i,t[2]),t[3]=l(s,t[3]),t[4]=l(o,t[4]),t}function g(e,t,n,r){let i;const s=15+(t+65>>>9<<4),o=t+n;for(;e.length<=s;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[s]=4294967295&o,e[s-1]=o/4294967296|0,i=0;i<e.length;i+=16)r=d(e.slice(i,i+16),r);return r}class w extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),s=i.binLen,o=i.value,a=s>>>5;for(t=0;t<a;t+=r)n+this.T<=s&&(this.m=this.g(o.slice(t,t+r),this.m),n+=this.T);return this.A+=n,this.h=o.slice(n>>>5),this.u=s%this.T,this.l=!0,this}getHash(e,t){let n,r,i=this.B;const s=a(t);if(this.v){if(-1===s.outputLen)throw new Error("Output length must be specified in options");i=s.outputLen}const u=o(e,i,this.Y,s);if(this.p&&this.H)return u(this.H(s));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),i),n=1;n<this.numRounds;n+=1)this.v&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.L(this.o),i);return u(r)}setHMACKey(e,t,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=s(t,(n||{}).encoding||"UTF8",this.Y);this.N(r(e))}N(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.L(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const n=a(t);return o(e,this.B,this.Y,n)(this.S())}S(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return e=this.g(this.U,this.L(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-1"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=s(this.t,this.i,this.Y),this.g=d,this.I=function(e){return e.slice()},this.L=p,this.C=g,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return s(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.Y))}}},673:(e,t,n)=>{n.r(t),n.d(t,{default:()=>A});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,s,o;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)o=i+u,s=o>>>2,a.length<=s&&a.push(0),a[s]|=e[i]<<8*(c+r*(o%4));return{value:a,binLen:8*e.length+n}}function s(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(s=parseInt(e.substr(i,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,o=a>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let s,o,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(s=e.charCodeAt(a),o=[],128>s?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&e.charCodeAt(a)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<o.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(s=e.charCodeAt(a),!0===f&&(u=255&s,s=u<<8|s>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let s,o,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(o=0;o<e.length;o+=4){for(c=e.substr(o,4),u=0,a=0;a<c.length;a+=1)s=r.indexOf(c.charAt(a)),u|=s<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,s,o,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(s=0;s<e.length;s+=1)i=e.charCodeAt(s),a=s+c,o=a>>>2,u.length<=o&&u.push(0),u[o]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function o(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let s,o,a="";const u=t/8,c=-1===n?3:0;for(s=0;s<u;s+=1)o=e[s>>>2]>>>8*(c+n*(s%4)),a+=i.charAt(o>>>4&15)+i.charAt(15&o);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let s,o,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(s=0;s<l;s+=3)for(u=s+1<l?e[s+1>>>2]:0,c=s+2<l?e[s+2>>>2]:0,a=(e[s>>>2]>>>8*(f+n*(s%4))&255)<<16|(u>>>8*(f+n*((s+1)%4))&255)<<8|c>>>8*(f+n*((s+2)%4))&255,o=0;o<4;o+=1)h+=8*s+6*o<=t?r.charAt(a>>>6*(3-o)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,s="";const o=t/8,a=-1===n?3:0;for(r=0;r<o;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,s+=String.fromCharCode(i);return s}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=new ArrayBuffer(i),o=new Uint8Array(s),a=-1===n?3:0;for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return s}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,s=-1===n?3:0,o=new Uint8Array(i);for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(s+n*(r%4))&255;return o}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],c=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function h(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function l(e,t){return e>>>t|e<<32-t}function f(e,t){return e>>>t}function p(e,t,n){return e&t^~e&n}function d(e,t,n){return e&t^e&n^t&n}function g(e){return l(e,2)^l(e,13)^l(e,22)}function w(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function y(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){const s=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function b(e){return l(e,7)^l(e,18)^f(e,3)}function L(e){return l(e,6)^l(e,11)^l(e,25)}function v(e){let t;return t="SHA-224"==e?u.slice():c.slice(),t}function k(e,t){let n,r,i,s,o,u,c,h,v,k,A;const E=[];for(n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],c=t[6],h=t[7],A=0;A<64;A+=1)E[A]=A<16?e[A]:y(l(S=E[A-2],17)^l(S,19)^f(S,10),E[A-7],b(E[A-15]),E[A-16]),v=m(h,L(o),p(o,u,c),a[A],E[A]),k=w(g(n),d(n,r,i)),h=c,c=u,u=o,o=w(s,v),s=i,i=r,r=n,n=w(v,k);var S;return t[0]=w(n,t[0]),t[1]=w(r,t[1]),t[2]=w(i,t[2]),t[3]=w(s,t[3]),t[4]=w(o,t[4]),t[5]=w(u,t[5]),t[6]=w(c,t[6]),t[7]=w(h,t[7]),t}class A extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),s=i.binLen,o=i.value,a=s>>>5;for(t=0;t<a;t+=r)n+this.T<=s&&(this.m=this.g(o.slice(t,t+r),this.m),n+=this.T);return this.l+=n,this.h=o.slice(n>>>5),this.u=s%this.T,this.A=!0,this}getHash(e,t){let n,r,i=this.B;const s=h(t);if(this.H){if(-1===s.outputLen)throw new Error("Output length must be specified in options");i=s.outputLen}const a=o(e,i,this.v,s);if(this.p&&this.Y)return a(this.Y(s));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),i),n=1;n<this.numRounds;n+=1)this.H&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.I(this.o),i);return a(r)}setHMACKey(e,t,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=s(t,(n||{}).encoding||"UTF8",this.v);this.M(r(e))}M(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.I(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(e,t){const n=h(t);return o(e,this.B,this.v,n)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return e=this.g(this.U,this.I(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=s(this.t,this.i,this.v),this.g=k,this.S=function(e){return e.slice()},this.I=v,this.C=function(t,n,r,i){return function(e,t,n,r,i){let s,o;const a=15+(t+65>>>9<<4),u=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&u,e[a-1]=u/4294967296|0,s=0;s<e.length;s+=16)r=k(e.slice(s,s+16),r);return o="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,o}(t,n,r,i,e)},this.m=v(e),this.T=512,this.B="SHA-224"===e?224:256,this.H=!1,r.hmacKey&&this.M(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return s(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.v))}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{n.d(r,{z9:()=>ke,j$:()=>g,nm:()=>l,Xz:()=>s,ul:()=>a,zo:()=>c,zM:()=>t,pI:()=>p,I4:()=>d,Fl:()=>h,In:()=>i,Cj:()=>o,t6:()=>u,mh:()=>e,LQ:()=>f,R2:()=>q,rJ:()=>$,xI:()=>ve,d:()=>Ae,e9:()=>_,K2:()=>V,ZC:()=>W,iv:()=>P,d2:()=>C,vB:()=>Le,y1:()=>be,Hv:()=>b,Ue:()=>Te,Jx:()=>I,cv:()=>S,Pi:()=>re,um:()=>ie,sK:()=>y,fK:()=>v,Fw:()=>w,zE:()=>Z,RU:()=>Q,Xs:()=>ee,r1:()=>G,Kl:()=>te,A7:()=>me,px:()=>we,ZW:()=>ye,ti:()=>ge,bX:()=>m,Dc:()=>k,fp:()=>L,Ye:()=>pe,Qc:()=>x,hP:()=>fe,LU:()=>le,yQ:()=>T,Zk:()=>B,uh:()=>U});const e=108,t=new Uint8Array([e]),i=100,s=new Uint8Array([i]),o=101,a=new Uint8Array([o]),u=105,c=new Uint8Array([u]),h=58,l=new Uint8Array([h]),f=45,p=new Uint8Array([f]),d=48,g=new Uint8Array([d]);function w(e){return e>=d&&e<=d+9}function y(e,t,n){let r=0,i=e.length;for(;r<i;){const s=r+i>>>1,o=n(e[s],t);if(0===o)return{index:s,result:e[s]};o<0?r=s+1:i=s}return{index:r,result:void 0}}function m(e,t){const n=[];for(const r of e){const{index:e}=y(n,r,t);n.splice(e,0,r)}return n}function b(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.byteLength),0));return e.reduce(((e,n)=>(t.set(n,e),e+n.byteLength)),0),t}function L(e){return 1<<32-Math.clz32(e-1)}function v(){return Math.round(Date.now()/1e3)}async function k(e){if(0===e.length)throw new Error("Empty leaves");const t=new Uint8Array(64);for(;e.length>1;){let r=!1;const i=[];for(const s of e)if(r){let e;t.set(s,32);try{e=new Uint8Array(await crypto.subtle.digest("SHA-256",t))}catch{const{default:r}=await Promise.resolve().then(n.bind(n,673)),i=new r("SHA-256","UINT8ARRAY");i.update(t),e=i.getHash("UINT8ARRAY")}i.push(e),r=!1}else t.set(s),r=!0;e=i}return e[0]}const A=new WeakMap;class E{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;path=[];hookSystem;attachedHooks=new WeakMap;constructor(e,t){this.data=e,this.hookSystem=t,t&&A.set(t,!0)}start(e){if(this.encode(this.data,e),this.hookSystem)for(const e of this.hookSystem.values())this.attachedHooks.get(e)||e({value:void 0,done:!0});e.close()}encode(e,n){if(null!=e)if("boolean"==typeof e)this.encode(e?1:0,n);else if("number"==typeof e){const t=Math.round(e);n.enqueue(this.textEncoder.encode(`i${t}e`)),t!==e&&(console.warn(`WARNING: Possible data corruption detected with value "${e}":`,`Bencoding only defines support for integers, value was converted to "${t}"`),console.trace())}else if("bigint"==typeof e)n.enqueue(this.textEncoder.encode(`i${e}e`));else if("string"==typeof e){const t=this.textEncoder.encode(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(e instanceof ArrayBuffer){const t=new Uint8Array(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(Array.isArray(e)){n.enqueue(t);let r=0;for(const t of e){let e;if(this.path.push(r),this.hookSystem&&(e=this.hookSystem.get(this.path))){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n);this.path.pop(),++r}n.enqueue(a)}else if(e instanceof Map){n.enqueue(s);const t=m(e.keys(),((e,t)=>(e="string"==typeof e?e:this.textDecoder.decode(e))<(t="string"==typeof t?t:this.textDecoder.decode(t))?-1:e>t?1:0));for(const r of t){const t=e.get(r);if(void 0!==t&&null!==e)if(r instanceof ArrayBuffer)this.encode(r,n),this.encode(t,n);else{let e;if(this.path.push(r),this.encode(r,n),this.hookSystem&&(e=this.hookSystem.get(this.path))){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n);this.path.pop()}}n.enqueue(a)}else{n.enqueue(s);const t=Object.keys(e).sort();for(const r of t){const t=e[r];if(void 0===t||null===e)continue;let i;if(this.path.push(r),this.encode(r,n),this.hookSystem&&(i=this.hookSystem.get(this.path))){const e=R(n,i);this.encode(t,e),i({value:void 0,done:!0}),this.attachedHooks.set(i,!0)}else this.encode(t,n);this.path.pop()}n.enqueue(a)}}}function S(e,t){return new ReadableStream(new E(e,t))}function R(e,t){return new Proxy(e,{get:function(e,n,r){return"enqueue"===n?(n=>{e.enqueue(n),t({value:n,done:!1})}).bind(e):Reflect.get(e,n,r)}})}function U(e,t){const n={controller:null},r=new ReadableStream({start(e){n.controller=e},pull(e){A.get(t)||(console.warn("You need to call encode() first and then consume hooks."),e.close(),n.controller=null)}});return t.set(e,(({value:e,done:t})=>{null!==n.controller&&(t?n.controller.close():n.controller.enqueue(e))})),r}function T(e,t){const n=U(e,t);return new Response(n).arrayBuffer()}function B(e,t){const n=U(e,t);return new Response(n).text()}var P;!function(e){e.Integer="Integer",e.ByteString="ByteString",e.ListStart="ListStart",e.ListEnd="ListEnd",e.DictionaryStart="DictionaryStart",e.DictionaryEnd="DictionaryEnd"}(P||(P={}));class F{endStack=[];token=null;byteStringLength=-1;byteStringOffset=0;transform(e,t){this.tokenize(e,t)}flush(){if(this.endStack.length||this.token||-1!==this.byteStringLength||this.byteStringOffset)throw new SyntaxError("Unexpected end of torrent stream")}tokenize(t,n){if(0!==t.byteLength)if(null===this.token&&-1===this.byteStringLength){const r=t[0];if(r===u)this.token={type:P.Integer,value:new Uint8Array};else if(w(r))this.byteStringLength=r-d;else if(r===e)this.endStack.push(P.ListEnd),n.enqueue({type:P.ListStart});else if(r===i)this.endStack.push(P.DictionaryEnd),n.enqueue({type:P.DictionaryStart});else{if(r!==o)throw new SyntaxError(`Unexpected byte: ${r}`);{const e=this.endStack.pop();if(!e)throw new SyntaxError("Unbalanced delimiter");n.enqueue({type:e})}}this.tokenize(t.subarray(1),n)}else if(this.token&&-1===this.byteStringLength)if(this.token.type===P.Integer){const e=t.indexOf(o);-1===e?this.token.value=this.token.value?b(this.token.value,t):t:(this.token.value=this.token.value?b(this.token.value,t.subarray(0,e)):t.subarray(0,e),n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e+1),n))}else{if(this.token.type!==P.ByteString)throw new Error("This is a bug");{const e=this.token.value.byteLength-this.byteStringOffset,r=t.byteLength;r<e?(this.token.value.set(t,this.byteStringOffset),this.byteStringOffset+=r):(this.token.value.set(t.subarray(0,e),this.byteStringOffset),this.byteStringOffset=0,n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e),n))}}else{if(!(this.byteStringLength>-1&&null===this.token))throw new Error("This is a bug");{let e=-1;for(const[n,r]of t.entries()){if(!w(r)){if(r===h){e=n;break}throw new SyntaxError(`Unexpected byte: ${r}`)}this.byteStringLength=10*this.byteStringLength-d+r}-1!==e&&(this.token={type:P.ByteString,value:new Uint8Array(this.byteStringLength)},this.byteStringLength=-1,this.tokenize(t.subarray(e+1),n))}}}}class C extends TransformStream{constructor(){super(new F)}}async function x(e){let t;const n=[],r=e.getReader();let i;for(;;){const{done:e,value:s}=await r.read();if(e)break;const o=n.at(-1);if(o)if(Array.isArray(o))switch(s.type){case P.Integer:o.push(N(s.value));break;case P.ByteString:o.push(H(s.value));break;case P.DictionaryStart:{const e=Object.create(null);o.push(e),n.push(e);break}case P.ListStart:{const e=[];o.push(e),n.push(e);break}case P.ListEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}else if(void 0===i)switch(s.type){case P.ByteString:i=H(s.value);break;case P.DictionaryEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}else{switch(s.type){case P.Integer:o[i]=N(s.value);break;case P.ByteString:o[i]=H(s.value);break;case P.DictionaryStart:{const e=Object.create(null);o[i]=e,n.push(e);break}case P.ListStart:{const e=[];o[i]=e,n.push(e);break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}i=void 0}else{if(void 0!==t)throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`);switch(s.type){case P.Integer:t=N(s.value);break;case P.ByteString:t=H(s.value);break;case P.DictionaryStart:{const e=Object.create(null);n.push(e),t=e;break}case P.ListStart:{const e=[];n.push(e),t=e;break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(s)}`)}}}if(n.length)throw new Error("Unexpected end of token stream");return t}async function I(e){const t=new C,n=e.pipeThrough(t);return await x(n)}function N(e){let t=0,n=!0;for(const[r,i]of e.entries()){if(0===r&&i===f){n=!1;continue}if(1===r&&!n&&i===d)throw new SyntaxError("Negative zero is not a valid integer");if(1===r&&0===t)throw new SyntaxError("Leading zeros are not allowed");if(!w(i))throw new SyntaxError(`Unexpected byte: ${i}`);const e=i-d;(n&&"number"==typeof t&&t>(Number.MAX_SAFE_INTEGER-e)/10||!n&&"number"==typeof t&&t<(Number.MIN_SAFE_INTEGER+e)/10)&&(t=BigInt(t)),t="number"==typeof t?n?10*t+e:10*t-e:n?10n*t+BigInt(e):10n*t-BigInt(e)}return t}function H(e){return(new TextDecoder).decode(e)}n(913);class M extends Error{constructor(e,t){super(((e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n})(e,t)),this.name=e,this.details=t}}class Y{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function D(e){const t=e.map((e=>Promise.resolve(e).then((e=>function(e){if(e instanceof Response){if(e.body)return e.body.getReader();throw new M("opaque-streams-source",{type:e.type})}return e instanceof ReadableStream?e.getReader():new Response(e).body.getReader()}(e))))),n=new Y;let r=0;const i=new ReadableStream({pull(e){return t[r].then((e=>e.read())).then((i=>{if(i.done)return r++,r>=t.length?(e.close(),void n.resolve()):this.pull(e);e.enqueue(i.value)})).catch((e=>{throw n.reject(e),e}))},cancel(){n.resolve()}});return{done:n.promise,stream:i}}n(1);const O=new Uint8Array(32);class z{blockCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}async transform(e,t){let r;++this.blockCount;try{r=new Uint8Array(await crypto.subtle.digest("SHA-256",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),i=new t("SHA-256","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}this.merkleLeaves.push(r),this.merkleLeaves.length===this.blocksPerPiece&&(t.enqueue(this.merkleLeaves),this.merkleLeaves=[])}flush(e){if(0===this.blockCount)return;let t=0;if(this.blockCount<this.blocksPerPiece)t=L(this.blockCount)-this.blockCount;else{const e=this.blockCount%this.blocksPerPiece;e>0&&(t=this.blocksPerPiece-e)}if(t>0)for(let e=0;e<t;++e)this.merkleLeaves.push(O);this.merkleLeaves.length>0&&e.enqueue(this.merkleLeaves)}}class q extends TransformStream{constructor(e){super(new z(e))}}class K{residuePointer=0;chunkLength;residue;opts;constructor(e,t={padding:!1}){this.chunkLength=e,this.opts=t,this.residue=new Uint8Array(this.chunkLength)}transform(e,t){for(;this.residuePointer+e.byteLength>=this.chunkLength;){const n=this.chunkLength-this.residuePointer;this.residue.set(e.subarray(0,n),this.residuePointer),this.residuePointer=0,t.enqueue(new Uint8Array(this.residue)),e=e.subarray(n)}this.residue.set(e,this.residuePointer),this.residuePointer+=e.byteLength}flush(e){this.residuePointer<=0||(this.opts.padding?(this.residue.set(new Uint8Array(this.chunkLength-this.residuePointer),this.residuePointer),e.enqueue(this.residue)):e.enqueue(this.residue.subarray(0,this.residuePointer)))}}class $ extends TransformStream{constructor(e,t={padding:!1}){super(new K(e,t))}}class X{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){t.enqueue(await k(e)),this.updateProgress&&await this.updateProgress()}}class _ extends TransformStream{constructor(e){super(new X(e))}}class j{leafCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}transform(e){++this.leafCount,this.merkleLeaves.push(e)}async flush(e){const t=L(this.leafCount)-this.leafCount;if(t>0){const e=await this.padLeafPromise;for(let n=0;n<t;++n)this.merkleLeaves.push(e)}e.enqueue(this.merkleLeaves)}get padLeafPromise(){return k(Array(this.blocksPerPiece).fill(new Uint8Array(32)))}}class V extends TransformStream{constructor(e){super(new j(e))}}class J{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){let r;try{r=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),i=new t("SHA-1","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}t.enqueue(r),this.updateProgress&&await this.updateProgress()}}class W extends TransformStream{constructor(e){super(new J(e))}}function Z(e){return e instanceof File}function Q(e){return!ee(e)&&!Z(e)&&e.isDirectory}function G(e){return!ee(e)&&!Z(e)&&e.isFile}function ee(e){try{if(e instanceof FileSystemHandle&&"directory"===e.kind)return!0}catch(e){}return!1}function te(e){try{if(e instanceof FileSystemHandle&&"file"===e.kind)return!0}catch(e){}return!1}function ne(e){return new Promise(((t,n)=>{e.readEntries(t,n)}))}async function*re(e){const t=e.createReader();let n=[];do{n=await ne(t);for(const e of n)yield e}while(n.length>0)}function ie(e){return new Promise(((t,n)=>{e.file(t,n)}))}const se={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let oe;const ae=new Uint8Array(16);function ue(){if(!oe&&(oe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!oe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oe(ae)}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));const he=function(e,t,n){if(se.randomUUID&&!t&&!e)return se.randomUUID();const r=(e=e||{}).random||(e.rng||ue)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(r)};function le(e,t){if(t.size>1||0===t.size)return{name:e||he(),commonDir:void 0};const[n,r]=t.entries().next().value;return ge(r)?{name:e||n,commonDir:void 0}:{name:e||n,commonDir:n}}async function fe(e,{sort:t=!0,compareFunction:n=be,polyfillWebkitRelativePath:r=!0}={sort:!0,compareFunction:be,polyfillWebkitRelativePath:!0}){let i=0,s=0;const o=new WeakMap,a=new WeakMap,u=new WeakMap,c=["file tree",[]],h=[c];let l=!1;for await(const t of e)await f(t);return{fileTree:pe(c[1],l),traverseTree:function*e(t){if(we(t))for(const n of t.values())yield*e(n);else yield[t,u.get(t)]},totalFileSize:i,totalFileCount:s};async function f(e){const p=h.at(-1);if(!p)throw new Error("This is a bug");const d=Z(e),g=ee(e),w=Q(e),m=te(e),b=G(e);if(g||w){const r=e.name,{index:i,result:s}=y(p[1],r,n);let o=s;if(ye(o))throw new Error("A same name file already exists");if(me(o)&&g){const t=a.get(o);if(!t||!await e.isSameEntry(t))throw new Error("File system handle not match")}o||(o=[r,[]],t?p[1].splice(i,0,o):p[1].push(o),g&&a.set(o,e)),h.push(o);for await(const t of g?e.values():re(e))await f(t);o[1]=new Map(o[1]),h.pop()}else if(m||b){const a=e.name,{index:c,result:l}=y(p[1],a,n);let f=l;if(ye(f)&&m){const t=o.get(f);if(!t||!await e.isSameEntry(t))throw new Error("A same name file already exists")}if(me(f))throw new Error("A same name directory already exists");if(f)return;const d=await(m?e.getFile():ie(e)),g=d.size;if(r){const e=h.reduce(((e,t,n)=>0===n?e:e+t[0]+"/"),"")+d.name;Object.defineProperty(d,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e})}const w={"":{length:g}};f=[a,w],t?p[1].splice(c,0,f):p[1].push(f),m&&o.set(f,e),u.set(w,d),i+=g,s+=1}else{if(!d)throw new Error("Unrecognized type of input");{r&&""===e.webkitRelativePath&&Object.defineProperty(e,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e.name});const o=(e.webkitRelativePath||e.name).split("/"),a=[c];for(const[r,c]of o.entries()){r>=1&&(l=!0);const h=a.at(-1);if(!h)throw new Error("This is a bug");const{index:f,result:p}=y(h[1],c,n);if(r<o.length-1){let e=p;if(ye(e))throw new Error("A same name file already exists");e||(e=[c,[]],t?h[1].splice(f,0,e):h[1].push(e)),a.push(e)}else{let n=p;if(me(n))throw new Error("A same name directory already exists");if(n)return;const r=e.size,o={"":{length:r}};n=[c,o],t?h[1].splice(f,0,n):h[1].push(n),u.set(o,e),i+=r,s+=1}}}}}}function pe(e,t=!1){return t&&de(e),new Map(e)}function de(e){for(const t of e)if(me(t)){const e=t[1];de(e),t[1]=new Map(e)}}function ge(e){return!!e&&""in e}function we(e){return e instanceof Map}function ye(e){return!!e&&""in e[1]}function me(e){return!!e&&!(""in e[1])}function be(e,t){return e[0]<t?-1:e[0]>t?1:0}var Le,ve;!function(e){e.V1="v1",e.V2="v2",e.HYBRID="hybrid"}(Le||(Le={})),function(e){e[e["16KB"]=16384]="16KB",e[e["32KB"]=32768]="32KB",e[e["64KB"]=65536]="64KB",e[e["128KB"]=131072]="128KB",e[e["256KB"]=262144]="256KB",e[e["512KB"]=524288]="512KB",e[e["1MB"]=1048576]="1MB",e[e["2MB"]=2097152]="2MB",e[e["4MB"]=4194304]="4MB",e[e["8MB"]=8388608]="8MB",e[e["16MB"]=16777216]="16MB",e[e["32MB"]=33554432]="32MB"}(ve||(ve={}));const ke=16384,Ae=2,Ee={type:Le.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:ke,pieceLength:NaN,sortFiles:!0,isPrivate:!1},Se={type:Le.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:ke,pieceLength:NaN,metaVersion:Ae,isPrivate:!1},Re={type:Le.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:ke,pieceLength:NaN,metaVersion:Ae,isPrivate:!1};function Ue(e,t){let n=0;for(const r of e)n+=Math.ceil(r.size/t);return n}async function Te(e,t={type:Le.V1},n){switch(t.type){case Le.V1:return await async function(e,t,n){const r={...Ee,...t},{fileTree:i,traverseTree:s,totalFileCount:o,totalFileSize:a}=await fe(e,{sort:r.sortFiles});if(0===o)return;const u=[];for(const[,e]of s(i))u.push(e);isNaN(r.pieceLength)&&(r.pieceLength=Ne(a,r.blockLength)),0!=(r.pieceLength&r.pieceLength-1)&&console.warn(`piece length ${r.pieceLength} is not a power of 2`),r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ie(r.urlList);const[c,h]=Ce(0,n),{commonDir:l,name:f}=le(r.name,i);let p;if(r.name=f,r.addPaddingFiles){const e=Ue(u,r.pieceLength);await h(e);const t=[],n=o-1;for(let e=n;e>=0;--e){const i=u[e];if(t.unshift(Promise.resolve(Pe(i.stream(),{pieceLength:r.pieceLength,padding:e!==n,updateProgress:c}))),e===n)continue;const s=i.size%r.pieceLength;if(0===s)continue;const o=Fe(r.pieceLength-s,l);u.splice(e+1,0,o)}p=D(t).stream}else{const e=Math.ceil(a/r.pieceLength);await h(e);const{stream:t}=D(u.map((e=>Promise.resolve(e.stream()))));p=Pe(t,{pieceLength:r.pieceLength,padding:!1,updateProgress:c})}return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.8"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{...o>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return l&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},name:r.name,"piece length":r.pieceLength,pieces:await new Response(p).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.V2:return await async function(e,t,n){const r={...Se,...t},{fileTree:i,traverseTree:s,totalFileCount:o,totalFileSize:a}=await fe(e);if(0===o)return;const u=[],c=[];for(const[e,t]of s(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ne(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ie(r.urlList);const l=Ue(u,r.pieceLength),[f]=Ce(l,n),{name:p}=le(r.name,i);r.name=p;const d=new Map;return await Promise.all(c.map((async([e,t])=>{await Be(t.stream(),d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:f})}))),{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.8"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.HYBRID:return await async function(e,t,n){const r={...Re,...t},{fileTree:i,traverseTree:s,totalFileCount:o,totalFileSize:a}=await fe(e);if(0===o)return;const u=[],c=[];for(const[e,t]of s(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ne(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ie(r.urlList);const[l]=Ce(2*Ue(u,r.pieceLength),n),{commonDir:f,name:p}=le(r.name,i);r.name=p;const d=new Map,g=[];let w=o-1,y=-1;for(const[e,t]of c){++y;const[n,i]=t.stream().tee();if(g.unshift(Promise.resolve(Pe(n,{pieceLength:r.pieceLength,padding:y!==w,updateProgress:l}))),await Be(i,d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:l}),y===w)break;const s=t.size%r.pieceLength;if(0===s)continue;const o=Fe(r.pieceLength-s,f);u.splice(++y,0,o),++w}const m=D(g).stream;return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.8"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,...o>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return f&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,pieces:await new Response(m).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n)}}async function Be(e,t,n,r){const{piecesRootReadableStream:i,pieceLayerReadableStream:s}=function(e,t){const n=e.pipeThrough(new $(t.blockLength)).pipeThrough(new q(t.blocksPerPiece)).pipeThrough(new _(t.updateProgress)),[r,i]=n.tee();return{piecesRootReadableStream:i.pipeThrough(new V(t.blocksPerPiece)).pipeThrough(new _),pieceLayerReadableStream:r}}(e,r),o=new Response(i).arrayBuffer();if(n[""].length>r.pieceLength){const e=new Response(s).arrayBuffer();t.set(await o,await e)}n[""].length>0&&(n[""]["pieces root"]=await o)}function Pe(e,t){return e.pipeThrough(new $(t.pieceLength,{padding:t.padding})).pipeThrough(new W(t.updateProgress))}function Fe(e,t){const n=new File([new ArrayBuffer(e)],`${e}`,{type:"application/octet-stream"}),r=`.pad/${e}`,i=void 0===t?r:`${t}/${r}`;return Object.defineProperties(n,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>i},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),n}function Ce(e,t){const n={current:0,total:e};return[async()=>{t&&await t(++n.current,n.total)},async e=>{n.total="number"==typeof e?e:await e(n.total,n.current)}]}function xe(e){if(void 0===e)return;const t=[];for(const n of e)0!==n.length&&t.push(n);return 0!==t.length?t:void 0}function Ie(e){if(void 0!==e&&0!==e.length)return e}function Ne(e,t){return Math.max(t,L(e>>>10))}})();var i=r.z9,s=r.j$,o=r.nm,a=r.Xz,u=r.ul,c=r.zo,h=r.zM,l=r.pI,f=r.I4,p=r.Fl,d=r.In,g=r.Cj,w=r.t6,y=r.mh,m=r.LQ,b=r.R2,L=r.rJ,v=r.xI,k=r.d,A=r.e9,E=r.K2,S=r.ZC,R=r.iv,U=r.d2,T=r.vB,B=r.y1,P=r.Hv,F=r.Ue,C=r.Jx,x=r.cv,I=r.Pi,N=r.um,H=r.sK,M=r.fK,Y=r.Fw,D=r.zE,O=r.RU,z=r.Xs,q=r.r1,K=r.Kl,$=r.A7,X=r.px,j=r.ZW,V=r.ti,J=r.bX,W=r.Dc,Z=r.fp,Q=r.Ye,G=r.Qc,ee=r.hP,te=r.LU,ne=r.yQ,re=r.Zk,ie=r.uh;export{i as BLOCK_LENGTH,s as BUFF_0,o as BUFF_COLON,a as BUFF_D,u as BUFF_E,c as BUFF_I,h as BUFF_L,l as BUFF_MINUS,f as BYTE_0,p as BYTE_COLON,d as BYTE_D,g as BYTE_E,w as BYTE_I,y as BYTE_L,m as BYTE_MINUS,b as BlockHasher,L as ChunkSplitter,v as CommonPieceLength,k as META_VERSION,A as MerkleRootCalculator,E as MerkleTreeBalancer,S as PieceHasher,R as TokenType,U as Tokenizer,T as TorrentType,B as compareEntryNames,P as concatUint8Arrays,F as create,C as decode,x as encode,I as getEntriesOfDirEntry,N as getFileOfFileEntry,H as getSortedIndex,M as getTimeStampSecondsNow,Y as isDigitByte,D as isFile,O as isFileSystemDirectoryEntry,z as isFileSystemDirectoryHandle,q as isFileSystemFileEntry,K as isFileSystemFileHandle,$ as isFileTreeDirEntry,X as isFileTreeDirNode,j as isFileTreeFileEntry,V as isFileTreeFileNode,J as iterableSort,W as merkleRoot,Z as nextPowerOfTwo,Q as packEntriesToDirNode,G as parse,ee as populateFileTree,te as resolveCommonDirAndTorrentName,ne as useArrayBufferPromiseHook,re as useTextPromiseHook,ie as useUint8ArrayStreamHook}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.torrefy=t():e.torrefy=t()}(self,(()=>(()=>{"use strict";var e={913:()=>{try{self["workbox:core:6.5.3"]&&_()}catch(e){}},1:()=>{try{self["workbox:streams:6.5.3"]&&_()}catch(e){}},211:(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,o,s;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)s=i+u,o=s>>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(c+r*(s%4));return{value:a,binLen:8*e.length+n}}function o(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(o=parseInt(e.substr(i,2),16),isNaN(o))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,s=a>>>2;u.length<=s;)u.push(0);u[s]|=o<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let o,s,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(o=e.charCodeAt(a),s=[],128>o?s.push(o):2048>o?(s.push(192|o>>>6),s.push(128|63&o)):55296>o||57344<=o?s.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),s.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u<s.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(o=e.charCodeAt(a),!0===f&&(u=255&o,o=u<<8|o>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let o,s,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<e.length;s+=4){for(c=e.substr(s,4),u=0,a=0;a<c.length;a+=1)o=r.indexOf(c.charAt(a)),u|=o<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<e.length;o+=1)i=e.charCodeAt(o),a=o+c,s=a>>>2,u.length<=s&&u.push(0),u[s]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function s(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let o,s,a="";const u=t/8,c=-1===n?3:0;for(o=0;o<u;o+=1)s=e[o>>>2]>>>8*(c+n*(o%4)),a+=i.charAt(s>>>4&15)+i.charAt(15&s);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let o,s,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(o=0;o<l;o+=3)for(u=o+1<l?e[o+1>>>2]:0,c=o+2<l?e[o+2>>>2]:0,a=(e[o>>>2]>>>8*(f+n*(o%4))&255)<<16|(u>>>8*(f+n*((o+1)%4))&255)<<8|c>>>8*(f+n*((o+2)%4))&255,s=0;s<4;s+=1)h+=8*o+6*s<=t?r.charAt(a>>>6*(3-s)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,o="";const s=t/8,a=-1===n?3:0;for(r=0;r<s;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=new ArrayBuffer(i),s=new Uint8Array(o),a=-1===n?3:0;for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return o}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=-1===n?3:0,s=new Uint8Array(i);for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(o+n*(r%4))&255;return s}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function a(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function u(e,t){return e<<t|e>>>32-t}function c(e,t,n){return e^t^n}function h(e,t,n){return e&t^e&n^t&n}function l(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function f(e,t,n,r,i){const o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function p(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(e,t){let n,r,i,o,s,a,p;const d=[];for(n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],p=0;p<80;p+=1)d[p]=p<16?e[p]:u(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),a=p<20?f(u(n,5),(g=r)&i^~g&o,s,1518500249,d[p]):p<40?f(u(n,5),c(r,i,o),s,1859775393,d[p]):p<60?f(u(n,5),h(r,i,o),s,2400959708,d[p]):f(u(n,5),c(r,i,o),s,3395469782,d[p]),s=o,o=i,i=u(r,30),r=n,n=a;var g;return t[0]=l(n,t[0]),t[1]=l(r,t[1]),t[2]=l(i,t[2]),t[3]=l(o,t[3]),t[4]=l(s,t[4]),t}function g(e,t,n,r){let i;const o=15+(t+65>>>9<<4),s=t+n;for(;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&s,e[o-1]=s/4294967296|0,i=0;i<e.length;i+=16)r=d(e.slice(i,i+16),r);return r}class w extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),o=i.binLen,s=i.value,a=o>>>5;for(t=0;t<a;t+=r)n+this.T<=o&&(this.m=this.g(s.slice(t,t+r),this.m),n+=this.T);return this.A+=n,this.h=s.slice(n>>>5),this.u=o%this.T,this.l=!0,this}getHash(e,t){let n,r,i=this.B;const o=a(t);if(this.v){if(-1===o.outputLen)throw new Error("Output length must be specified in options");i=o.outputLen}const u=s(e,i,this.Y,o);if(this.p&&this.H)return u(this.H(o));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),i),n=1;n<this.numRounds;n+=1)this.v&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.L(this.o),i);return u(r)}setHMACKey(e,t,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=o(t,(n||{}).encoding||"UTF8",this.Y);this.N(r(e))}N(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.L(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const n=a(t);return s(e,this.B,this.Y,n)(this.S())}S(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return e=this.g(this.U,this.L(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-1"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=o(this.t,this.i,this.Y),this.g=d,this.I=function(e){return e.slice()},this.L=p,this.C=g,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return o(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.Y))}}},673:(e,t,n)=>{n.r(t),n.d(t,{default:()=>E});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,o,s;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)s=i+u,o=s>>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(c+r*(s%4));return{value:a,binLen:8*e.length+n}}function o(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(o=parseInt(e.substr(i,2),16),isNaN(o))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,s=a>>>2;u.length<=s;)u.push(0);u[s]|=o<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let o,s,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(o=e.charCodeAt(a),s=[],128>o?s.push(o):2048>o?(s.push(192|o>>>6),s.push(128|63&o)):55296>o||57344<=o?s.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),s.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u<s.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(o=e.charCodeAt(a),!0===f&&(u=255&o,o=u<<8|o>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let o,s,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<e.length;s+=4){for(c=e.substr(s,4),u=0,a=0;a<c.length;a+=1)o=r.indexOf(c.charAt(a)),u|=o<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<e.length;o+=1)i=e.charCodeAt(o),a=o+c,s=a>>>2,u.length<=s&&u.push(0),u[s]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function s(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let o,s,a="";const u=t/8,c=-1===n?3:0;for(o=0;o<u;o+=1)s=e[o>>>2]>>>8*(c+n*(o%4)),a+=i.charAt(s>>>4&15)+i.charAt(15&s);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let o,s,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(o=0;o<l;o+=3)for(u=o+1<l?e[o+1>>>2]:0,c=o+2<l?e[o+2>>>2]:0,a=(e[o>>>2]>>>8*(f+n*(o%4))&255)<<16|(u>>>8*(f+n*((o+1)%4))&255)<<8|c>>>8*(f+n*((o+2)%4))&255,s=0;s<4;s+=1)h+=8*o+6*s<=t?r.charAt(a>>>6*(3-s)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,o="";const s=t/8,a=-1===n?3:0;for(r=0;r<s;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=new ArrayBuffer(i),s=new Uint8Array(o),a=-1===n?3:0;for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return o}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=-1===n?3:0,s=new Uint8Array(i);for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(o+n*(r%4))&255;return s}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],c=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function h(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function l(e,t){return e>>>t|e<<32-t}function f(e,t){return e>>>t}function p(e,t,n){return e&t^~e&n}function d(e,t,n){return e&t^e&n^t&n}function g(e){return l(e,2)^l(e,13)^l(e,22)}function w(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function y(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){const o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function b(e){return l(e,7)^l(e,18)^f(e,3)}function L(e){return l(e,6)^l(e,11)^l(e,25)}function v(e){let t;return t="SHA-224"==e?u.slice():c.slice(),t}function A(e,t){let n,r,i,o,s,u,c,h,v,A,E;const k=[];for(n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],u=t[5],c=t[6],h=t[7],E=0;E<64;E+=1)k[E]=E<16?e[E]:y(l(S=k[E-2],17)^l(S,19)^f(S,10),k[E-7],b(k[E-15]),k[E-16]),v=m(h,L(s),p(s,u,c),a[E],k[E]),A=w(g(n),d(n,r,i)),h=c,c=u,u=s,s=w(o,v),o=i,i=r,r=n,n=w(v,A);var S;return t[0]=w(n,t[0]),t[1]=w(r,t[1]),t[2]=w(i,t[2]),t[3]=w(o,t[3]),t[4]=w(s,t[4]),t[5]=w(u,t[5]),t[6]=w(c,t[6]),t[7]=w(h,t[7]),t}class E extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),o=i.binLen,s=i.value,a=o>>>5;for(t=0;t<a;t+=r)n+this.T<=o&&(this.m=this.g(s.slice(t,t+r),this.m),n+=this.T);return this.l+=n,this.h=s.slice(n>>>5),this.u=o%this.T,this.A=!0,this}getHash(e,t){let n,r,i=this.B;const o=h(t);if(this.H){if(-1===o.outputLen)throw new Error("Output length must be specified in options");i=o.outputLen}const a=s(e,i,this.v,o);if(this.p&&this.Y)return a(this.Y(o));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),i),n=1;n<this.numRounds;n+=1)this.H&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.I(this.o),i);return a(r)}setHMACKey(e,t,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=o(t,(n||{}).encoding||"UTF8",this.v);this.M(r(e))}M(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.I(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(e,t){const n=h(t);return s(e,this.B,this.v,n)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return e=this.g(this.U,this.I(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=o(this.t,this.i,this.v),this.g=A,this.S=function(e){return e.slice()},this.I=v,this.C=function(t,n,r,i){return function(e,t,n,r,i){let o,s;const a=15+(t+65>>>9<<4),u=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&u,e[a-1]=u/4294967296|0,o=0;o<e.length;o+=16)r=A(e.slice(o,o+16),r);return s="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,s}(t,n,r,i,e)},this.m=v(e),this.T=512,this.B="SHA-224"===e?224:256,this.H=!1,r.hmacKey&&this.M(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return o(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.v))}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{BLOCK_LENGTH:()=>Ae,BUFF_0:()=>g,BUFF_COLON:()=>l,BUFF_D:()=>o,BUFF_E:()=>a,BUFF_I:()=>c,BUFF_L:()=>t,BUFF_MINUS:()=>p,BYTE_0:()=>d,BYTE_COLON:()=>h,BYTE_D:()=>i,BYTE_E:()=>s,BYTE_I:()=>u,BYTE_L:()=>e,BYTE_MINUS:()=>f,BlockHasher:()=>z,ChunkSplitter:()=>_,CommonPieceLength:()=>ve,META_VERSION:()=>Ee,MerkleRootCalculator:()=>j,MerkleTreeBalancer:()=>X,PieceHasher:()=>J,TokenType:()=>P,Tokenizer:()=>C,TorrentType:()=>Le,compareEntryNames:()=>be,concatUint8Arrays:()=>b,create:()=>Te,decode:()=>N,encode:()=>S,getEntriesOfDirEntry:()=>re,getFileOfFileEntry:()=>ie,getSortedIndex:()=>y,getTimeStampSecondsNow:()=>v,isDigitByte:()=>w,isFile:()=>G,isFileSystemDirectoryEntry:()=>Z,isFileSystemDirectoryHandle:()=>ee,isFileSystemFileEntry:()=>Q,isFileSystemFileHandle:()=>te,isFileTreeDirEntry:()=>me,isFileTreeDirNode:()=>we,isFileTreeFileEntry:()=>ye,isFileTreeFileNode:()=>ge,iterableSort:()=>m,merkleRoot:()=>A,nextPowerOfTwo:()=>L,packEntriesToDirNode:()=>pe,parse:()=>x,populateFileTree:()=>fe,resolveCommonDirAndTorrentName:()=>le,useArrayBufferPromiseHook:()=>T,useTextPromiseHook:()=>B,useUint8ArrayStreamHook:()=>U});const e=108,t=new Uint8Array([e]),i=100,o=new Uint8Array([i]),s=101,a=new Uint8Array([s]),u=105,c=new Uint8Array([u]),h=58,l=new Uint8Array([h]),f=45,p=new Uint8Array([f]),d=48,g=new Uint8Array([d]);function w(e){return e>=d&&e<=d+9}function y(e,t,n){let r=0,i=e.length;for(;r<i;){const o=r+i>>>1,s=n(e[o],t);if(0===s)return{index:o,result:e[o]};s<0?r=o+1:i=o}return{index:r,result:void 0}}function m(e,t){const n=[];for(const r of e){const{index:e}=y(n,r,t);n.splice(e,0,r)}return n}function b(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.byteLength),0));return e.reduce(((e,n)=>(t.set(n,e),e+n.byteLength)),0),t}function L(e){return 1<<32-Math.clz32(e-1)}function v(){return Math.round(Date.now()/1e3)}async function A(e){if(0===e.length)throw new Error("Empty leaves");const t=new Uint8Array(64);for(;e.length>1;){let r=!1;const i=[];for(const o of e)if(r){let e;t.set(o,32);try{e=new Uint8Array(await crypto.subtle.digest("SHA-256",t))}catch{const{default:r}=await Promise.resolve().then(n.bind(n,673)),i=new r("SHA-256","UINT8ARRAY");i.update(t),e=i.getHash("UINT8ARRAY")}i.push(e),r=!1}else t.set(o),r=!0;e=i}return e[0]}const E=new WeakMap;class k{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;path=[];hookSystem;attachedHooks=new WeakMap;constructor(e,t){this.data=e,this.hookSystem=t,t&&E.set(t,!0)}start(e){if(this.encode(this.data,e),this.hookSystem)for(const e of this.hookSystem.values())this.attachedHooks.get(e)||e({value:void 0,done:!0});e.close()}encode(e,n){if(null!=e)if("boolean"==typeof e)this.encode(e?1:0,n);else if("number"==typeof e){const t=Math.round(e);n.enqueue(this.textEncoder.encode(`i${t}e`)),t!==e&&(console.warn(`WARNING: Possible data corruption detected with value "${e}":`,`Bencoding only defines support for integers, value was converted to "${t}"`),console.trace())}else if("bigint"==typeof e)n.enqueue(this.textEncoder.encode(`i${e}e`));else if("string"==typeof e){const t=this.textEncoder.encode(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(e instanceof ArrayBuffer){const t=new Uint8Array(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(Array.isArray(e)){n.enqueue(t);let r=0;for(const t of e){if(this.path.push(r),this.hookSystem){const e=this.hookSystem.get(this.path);if(e){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0})}else this.encode(t,n)}this.path.pop(),++r}n.enqueue(a)}else if(e instanceof Map){n.enqueue(o);const t=m(e.keys(),((e,t)=>(e="string"==typeof e?e:this.textDecoder.decode(e))<(t="string"==typeof t?t:this.textDecoder.decode(t))?-1:e>t?1:0));for(const r of t){const t=e.get(r);if(void 0!==t&&null!==e)if(r instanceof ArrayBuffer)this.encode(r,n),this.encode(t,n);else{if(this.path.push(r),this.encode(r,n),this.hookSystem){const e=this.hookSystem.get(this.path);if(e){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n)}this.path.pop()}}n.enqueue(a)}else{n.enqueue(o);const t=Object.keys(e).sort();for(const r of t){const t=e[r];if(void 0!==t&&null!==e){if(this.path.push(r),this.encode(r,n),this.hookSystem){const e=this.hookSystem.get(this.path);if(e){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n)}this.path.pop()}}n.enqueue(a)}}}function S(e,t){return new ReadableStream(new k(e,t))}function R(e,t){return new Proxy(e,{get:function(e,n,r){return"enqueue"===n?(n=>{e.enqueue(n),t({value:n,done:!1})}).bind(e):Reflect.get(e,n,r)}})}function U(e,t){const n={controller:null},r=new ReadableStream({start(e){n.controller=e},pull(e){E.get(t)||(console.warn("You need to call encode() first and then consume hooks."),e.close(),n.controller=null)}});return t.set(e,(({value:e,done:t})=>{null!==n.controller&&(t?n.controller.close():n.controller.enqueue(e))})),r}function T(e,t){const n=U(e,t);return new Response(n).arrayBuffer()}function B(e,t){const n=U(e,t);return new Response(n).text()}var P;!function(e){e.Integer="Integer",e.ByteString="ByteString",e.ListStart="ListStart",e.ListEnd="ListEnd",e.DictionaryStart="DictionaryStart",e.DictionaryEnd="DictionaryEnd"}(P||(P={}));class F{endStack=[];token=null;byteStringLength=-1;byteStringOffset=0;transform(e,t){this.tokenize(e,t)}flush(){if(this.endStack.length||this.token||-1!==this.byteStringLength||this.byteStringOffset)throw new SyntaxError("Unexpected end of torrent stream")}tokenize(t,n){if(0!==t.byteLength)if(null===this.token&&-1===this.byteStringLength){const r=t[0];if(r===u)this.token={type:P.Integer,value:new Uint8Array};else if(w(r))this.byteStringLength=r-d;else if(r===e)this.endStack.push(P.ListEnd),n.enqueue({type:P.ListStart});else if(r===i)this.endStack.push(P.DictionaryEnd),n.enqueue({type:P.DictionaryStart});else{if(r!==s)throw new SyntaxError(`Unexpected byte: ${r}`);{const e=this.endStack.pop();if(!e)throw new SyntaxError("Unbalanced delimiter");n.enqueue({type:e})}}this.tokenize(t.subarray(1),n)}else if(this.token&&-1===this.byteStringLength)if(this.token.type===P.Integer){const e=t.indexOf(s);-1===e?this.token.value=this.token.value?b(this.token.value,t):t:(this.token.value=this.token.value?b(this.token.value,t.subarray(0,e)):t.subarray(0,e),n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e+1),n))}else{if(this.token.type!==P.ByteString)throw new Error("This is a bug");{const e=this.token.value.byteLength-this.byteStringOffset,r=t.byteLength;r<e?(this.token.value.set(t,this.byteStringOffset),this.byteStringOffset+=r):(this.token.value.set(t.subarray(0,e),this.byteStringOffset),this.byteStringOffset=0,n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e),n))}}else{if(!(this.byteStringLength>-1&&null===this.token))throw new Error("This is a bug");{let e=-1;for(const[n,r]of t.entries()){if(!w(r)){if(r===h){e=n;break}throw new SyntaxError(`Unexpected byte: ${r}`)}this.byteStringLength=10*this.byteStringLength-d+r}-1!==e&&(this.token={type:P.ByteString,value:new Uint8Array(this.byteStringLength)},this.byteStringLength=-1,this.tokenize(t.subarray(e+1),n))}}}}class C extends TransformStream{constructor(){super(new F)}}async function x(e){let t;const n=[],r=e.getReader();let i;for(;;){const{done:e,value:o}=await r.read();if(e)break;const s=n.at(-1);if(s)if(Array.isArray(s))switch(o.type){case P.Integer:s.push(I(o.value));break;case P.ByteString:s.push(H(o.value));break;case P.DictionaryStart:{const e=Object.create(null);s.push(e),n.push(e);break}case P.ListStart:{const e=[];s.push(e),n.push(e);break}case P.ListEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}else if(void 0===i)switch(o.type){case P.ByteString:i=H(o.value);break;case P.DictionaryEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}else{switch(o.type){case P.Integer:s[i]=I(o.value);break;case P.ByteString:s[i]=H(o.value);break;case P.DictionaryStart:{const e=Object.create(null);s[i]=e,n.push(e);break}case P.ListStart:{const e=[];s[i]=e,n.push(e);break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}i=void 0}else{if(void 0!==t)throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`);switch(o.type){case P.Integer:t=I(o.value);break;case P.ByteString:t=H(o.value);break;case P.DictionaryStart:{const e=Object.create(null);n.push(e),t=e;break}case P.ListStart:{const e=[];n.push(e),t=e;break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}}}if(n.length)throw new Error("Unexpected end of token stream");return t}async function N(e){const t=new C,n=e.pipeThrough(t);return await x(n)}function I(e){let t=0,n=!0;for(const[r,i]of e.entries()){if(0===r&&i===f){n=!1;continue}if(1===r&&!n&&i===d)throw new SyntaxError("Negative zero is not a valid integer");if(1===r&&0===t)throw new SyntaxError("Leading zeros are not allowed");if(!w(i))throw new SyntaxError(`Unexpected byte: ${i}`);const e=i-d;(n&&"number"==typeof t&&t>(Number.MAX_SAFE_INTEGER-e)/10||!n&&"number"==typeof t&&t<(Number.MIN_SAFE_INTEGER+e)/10)&&(t=BigInt(t)),t="number"==typeof t?n?10*t+e:10*t-e:n?10n*t+BigInt(e):10n*t-BigInt(e)}return t}function H(e){return(new TextDecoder).decode(e)}n(913);class M extends Error{constructor(e,t){super(((e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n})(e,t)),this.name=e,this.details=t}}class Y{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function D(e){const t=e.map((e=>Promise.resolve(e).then((e=>function(e){if(e instanceof Response){if(e.body)return e.body.getReader();throw new M("opaque-streams-source",{type:e.type})}return e instanceof ReadableStream?e.getReader():new Response(e).body.getReader()}(e))))),n=new Y;let r=0;const i=new ReadableStream({pull(e){return t[r].then((e=>e.read())).then((i=>{if(i.done)return r++,r>=t.length?(e.close(),void n.resolve()):this.pull(e);e.enqueue(i.value)})).catch((e=>{throw n.reject(e),e}))},cancel(){n.resolve()}});return{done:n.promise,stream:i}}n(1);const O=new Uint8Array(32);class q{blockCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}async transform(e,t){let r;++this.blockCount;try{r=new Uint8Array(await crypto.subtle.digest("SHA-256",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),i=new t("SHA-256","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}this.merkleLeaves.push(r),this.merkleLeaves.length===this.blocksPerPiece&&(t.enqueue(this.merkleLeaves),this.merkleLeaves=[])}flush(e){if(0===this.blockCount)return;let t=0;if(this.blockCount<this.blocksPerPiece)t=L(this.blockCount)-this.blockCount;else{const e=this.blockCount%this.blocksPerPiece;e>0&&(t=this.blocksPerPiece-e)}if(t>0)for(let e=0;e<t;++e)this.merkleLeaves.push(O);this.merkleLeaves.length>0&&e.enqueue(this.merkleLeaves)}}class z extends TransformStream{constructor(e){super(new q(e))}}class ${residuePointer=0;chunkLength;residue;opts;constructor(e,t={padding:!1}){this.chunkLength=e,this.opts=t,this.residue=new Uint8Array(this.chunkLength)}transform(e,t){for(;this.residuePointer+e.byteLength>=this.chunkLength;){const n=this.chunkLength-this.residuePointer;this.residue.set(e.subarray(0,n),this.residuePointer),this.residuePointer=0,t.enqueue(new Uint8Array(this.residue)),e=e.subarray(n)}this.residue.set(e,this.residuePointer),this.residuePointer+=e.byteLength}flush(e){this.residuePointer<=0||(this.opts.padding?(this.residue.set(new Uint8Array(this.chunkLength-this.residuePointer),this.residuePointer),e.enqueue(this.residue)):e.enqueue(this.residue.subarray(0,this.residuePointer)))}}class _ extends TransformStream{constructor(e,t={padding:!1}){super(new $(e,t))}}class K{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){t.enqueue(await A(e)),this.updateProgress&&await this.updateProgress()}}class j extends TransformStream{constructor(e){super(new K(e))}}class V{leafCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}transform(e){++this.leafCount,this.merkleLeaves.push(e)}async flush(e){const t=L(this.leafCount)-this.leafCount;if(t>0){const e=await this.padLeafPromise;for(let n=0;n<t;++n)this.merkleLeaves.push(e)}e.enqueue(this.merkleLeaves)}get padLeafPromise(){return A(Array(this.blocksPerPiece).fill(new Uint8Array(32)))}}class X extends TransformStream{constructor(e){super(new V(e))}}class W{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){let r;try{r=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),i=new t("SHA-1","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}t.enqueue(r),this.updateProgress&&await this.updateProgress()}}class J extends TransformStream{constructor(e){super(new W(e))}}function G(e){return e instanceof File}function Z(e){return!ee(e)&&!G(e)&&e.isDirectory}function Q(e){return!ee(e)&&!G(e)&&e.isFile}function ee(e){try{if(e instanceof FileSystemHandle&&"directory"===e.kind)return!0}catch(e){}return!1}function te(e){try{if(e instanceof FileSystemHandle&&"file"===e.kind)return!0}catch(e){}return!1}function ne(e){return new Promise(((t,n)=>{e.readEntries(t,n)}))}async function*re(e){const t=e.createReader();let n=[];do{n=await ne(t);for(const e of n)yield e}while(n.length>0)}function ie(e){return new Promise(((t,n)=>{e.file(t,n)}))}const oe={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let se;const ae=new Uint8Array(16);function ue(){if(!se&&(se="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!se))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return se(ae)}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));const he=function(e,t,n){if(oe.randomUUID&&!t&&!e)return oe.randomUUID();const r=(e=e||{}).random||(e.rng||ue)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(r)};function le(e,t){if(t.size>1||0===t.size)return{name:e||he(),commonDir:void 0};const[n,r]=t.entries().next().value;return ge(r)?{name:e||n,commonDir:void 0}:{name:e||n,commonDir:n}}async function fe(e,{sort:t=!0,compareFunction:n=be,polyfillWebkitRelativePath:r=!0}={sort:!0,compareFunction:be,polyfillWebkitRelativePath:!0}){let i=0,o=0;const s=new WeakMap,a=new WeakMap,u=new WeakMap,c=["file tree",[]],h=[c];let l=!1;for await(const t of e)await f(t);return{fileTree:pe(c[1],l),traverseTree:function*e(t){if(we(t))for(const n of t.values())yield*e(n);else yield[t,u.get(t)]},totalFileSize:i,totalFileCount:o};async function f(e){const p=h.at(-1);if(!p)throw new Error("This is a bug");const d=G(e),g=ee(e),w=Z(e),m=te(e),b=Q(e);if(g||w){const r=e.name,{index:i,result:o}=y(p[1],r,n);let s=o;if(ye(s))throw new Error("A same name file already exists");if(me(s)&&g){const t=a.get(s);if(!t||!await e.isSameEntry(t))throw new Error("File system handle not match")}s||(s=[r,[]],t?p[1].splice(i,0,s):p[1].push(s),g&&a.set(s,e)),h.push(s);for await(const t of g?e.values():re(e))await f(t);s[1]=new Map(s[1]),h.pop()}else if(m||b){const a=e.name,{index:c,result:l}=y(p[1],a,n);let f=l;if(ye(f)&&m){const t=s.get(f);if(!t||!await e.isSameEntry(t))throw new Error("A same name file already exists")}if(me(f))throw new Error("A same name directory already exists");if(f)return;const d=await(m?e.getFile():ie(e)),g=d.size;if(r){const e=h.reduce(((e,t,n)=>0===n?e:e+t[0]+"/"),"")+d.name;Object.defineProperty(d,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e})}const w={"":{length:g}};f=[a,w],t?p[1].splice(c,0,f):p[1].push(f),m&&s.set(f,e),u.set(w,d),i+=g,o+=1}else{if(!d)throw new Error("Unrecognized type of input");{r&&""===e.webkitRelativePath&&Object.defineProperty(e,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e.name});const s=(e.webkitRelativePath||e.name).split("/"),a=[c];for(const[r,c]of s.entries()){r>=1&&(l=!0);const h=a.at(-1);if(!h)throw new Error("This is a bug");const{index:f,result:p}=y(h[1],c,n);if(r<s.length-1){let e=p;if(ye(e))throw new Error("A same name file already exists");e||(e=[c,[]],t?h[1].splice(f,0,e):h[1].push(e)),a.push(e)}else{let n=p;if(me(n))throw new Error("A same name directory already exists");if(n)return;const r=e.size,s={"":{length:r}};n=[c,s],t?h[1].splice(f,0,n):h[1].push(n),u.set(s,e),i+=r,o+=1}}}}}}function pe(e,t=!1){return t&&de(e),new Map(e)}function de(e){for(const t of e)if(me(t)){const e=t[1];de(e),t[1]=new Map(e)}}function ge(e){return!!e&&""in e}function we(e){return e instanceof Map}function ye(e){return!!e&&""in e[1]}function me(e){return!!e&&!(""in e[1])}function be(e,t){return e[0]<t?-1:e[0]>t?1:0}var Le,ve;!function(e){e.V1="v1",e.V2="v2",e.HYBRID="hybrid"}(Le||(Le={})),function(e){e[e["16KB"]=16384]="16KB",e[e["32KB"]=32768]="32KB",e[e["64KB"]=65536]="64KB",e[e["128KB"]=131072]="128KB",e[e["256KB"]=262144]="256KB",e[e["512KB"]=524288]="512KB",e[e["1MB"]=1048576]="1MB",e[e["2MB"]=2097152]="2MB",e[e["4MB"]=4194304]="4MB",e[e["8MB"]=8388608]="8MB",e[e["16MB"]=16777216]="16MB",e[e["32MB"]=33554432]="32MB"}(ve||(ve={}));const Ae=16384,Ee=2,ke={type:Le.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:Ae,pieceLength:NaN,sortFiles:!0,isPrivate:!1},Se={type:Le.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:Ae,pieceLength:NaN,metaVersion:Ee,isPrivate:!1},Re={type:Le.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:Ae,pieceLength:NaN,metaVersion:Ee,isPrivate:!1};function Ue(e,t){let n=0;for(const r of e)n+=Math.ceil(r.size/t);return n}async function Te(e,t={type:Le.V1},n){switch(t.type){case Le.V1:return await async function(e,t,n){const r={...ke,...t},{fileTree:i,traverseTree:o,totalFileCount:s,totalFileSize:a}=await fe(e,{sort:r.sortFiles});if(0===s)return;const u=[];for(const[,e]of o(i))u.push(e);isNaN(r.pieceLength)&&(r.pieceLength=Ie(a,r.blockLength)),0!=(r.pieceLength&r.pieceLength-1)&&console.warn(`piece length ${r.pieceLength} is not a power of 2`),r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ne(r.urlList);const[c,h]=Ce(0,n),{commonDir:l,name:f}=le(r.name,i);let p;if(r.name=f,r.addPaddingFiles){const e=Ue(u,r.pieceLength);await h(e);const t=[],n=s-1;for(let e=n;e>=0;--e){const i=u[e];if(t.unshift(Promise.resolve(Pe(i.stream(),{pieceLength:r.pieceLength,padding:e!==n,updateProgress:c}))),e===n)continue;const o=i.size%r.pieceLength;if(0===o)continue;const s=Fe(r.pieceLength-o,l);u.splice(e+1,0,s)}p=D(t).stream}else{const e=Math.ceil(a/r.pieceLength);await h(e);const{stream:t}=D(u.map((e=>Promise.resolve(e.stream()))));p=Pe(t,{pieceLength:r.pieceLength,padding:!1,updateProgress:c})}return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.7"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{...s>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return l&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},name:r.name,"piece length":r.pieceLength,pieces:await new Response(p).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.V2:return await async function(e,t,n){const r={...Se,...t},{fileTree:i,traverseTree:o,totalFileCount:s,totalFileSize:a}=await fe(e);if(0===s)return;const u=[],c=[];for(const[e,t]of o(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ie(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ne(r.urlList);const l=Ue(u,r.pieceLength),[f]=Ce(l,n),{name:p}=le(r.name,i);r.name=p;const d=new Map;return await Promise.all(c.map((async([e,t])=>{await Be(t.stream(),d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:f})}))),{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.7"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.HYBRID:return await async function(e,t,n){const r={...Re,...t},{fileTree:i,traverseTree:o,totalFileCount:s,totalFileSize:a}=await fe(e);if(0===s)return;const u=[],c=[];for(const[e,t]of o(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ie(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ne(r.urlList);const[l]=Ce(2*Ue(u,r.pieceLength),n),{commonDir:f,name:p}=le(r.name,i);r.name=p;const d=new Map,g=[];let w=s-1,y=-1;for(const[e,t]of c){++y;const[n,i]=t.stream().tee();if(g.unshift(Promise.resolve(Pe(n,{pieceLength:r.pieceLength,padding:y!==w,updateProgress:l}))),await Be(i,d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:l}),y===w)break;const o=t.size%r.pieceLength;if(0===o)continue;const s=Fe(r.pieceLength-o,f);u.splice(++y,0,s),++w}const m=D(g).stream;return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.7"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,...s>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return f&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,pieces:await new Response(m).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n)}}async function Be(e,t,n,r){const{piecesRootReadableStream:i,pieceLayerReadableStream:o}=function(e,t){const n=e.pipeThrough(new _(t.blockLength)).pipeThrough(new z(t.blocksPerPiece)).pipeThrough(new j(t.updateProgress)),[r,i]=n.tee();return{piecesRootReadableStream:i.pipeThrough(new X(t.blocksPerPiece)).pipeThrough(new j),pieceLayerReadableStream:r}}(e,r),s=new Response(i).arrayBuffer();if(n[""].length>r.pieceLength){const e=new Response(o).arrayBuffer();t.set(await s,await e)}n[""].length>0&&(n[""]["pieces root"]=await s)}function Pe(e,t){return e.pipeThrough(new _(t.pieceLength,{padding:t.padding})).pipeThrough(new J(t.updateProgress))}function Fe(e,t){const n=new File([new ArrayBuffer(e)],`${e}`,{type:"application/octet-stream"}),r=`.pad/${e}`,i=void 0===t?r:`${t}/${r}`;return Object.defineProperties(n,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>i},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),n}function Ce(e,t){const n={current:0,total:e};return[async()=>{t&&await t(++n.current,n.total)},async e=>{n.total="number"==typeof e?e:await e(n.total,n.current)}]}function xe(e){if(void 0===e)return;const t=[];for(const n of e)0!==n.length&&t.push(n);return 0!==t.length?t:void 0}function Ne(e){if(void 0!==e&&0!==e.length)return e}function Ie(e,t){return Math.max(t,L(e>>>10))}})(),r})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.torrefy=t():e.torrefy=t()}(self,(()=>(()=>{"use strict";var e={913:()=>{try{self["workbox:core:6.5.3"]&&_()}catch(e){}},1:()=>{try{self["workbox:streams:6.5.3"]&&_()}catch(e){}},211:(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,o,s;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)s=i+u,o=s>>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(c+r*(s%4));return{value:a,binLen:8*e.length+n}}function o(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(o=parseInt(e.substr(i,2),16),isNaN(o))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,s=a>>>2;u.length<=s;)u.push(0);u[s]|=o<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let o,s,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(o=e.charCodeAt(a),s=[],128>o?s.push(o):2048>o?(s.push(192|o>>>6),s.push(128|63&o)):55296>o||57344<=o?s.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),s.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u<s.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(o=e.charCodeAt(a),!0===f&&(u=255&o,o=u<<8|o>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let o,s,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<e.length;s+=4){for(c=e.substr(s,4),u=0,a=0;a<c.length;a+=1)o=r.indexOf(c.charAt(a)),u|=o<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<e.length;o+=1)i=e.charCodeAt(o),a=o+c,s=a>>>2,u.length<=s&&u.push(0),u[s]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function s(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let o,s,a="";const u=t/8,c=-1===n?3:0;for(o=0;o<u;o+=1)s=e[o>>>2]>>>8*(c+n*(o%4)),a+=i.charAt(s>>>4&15)+i.charAt(15&s);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let o,s,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(o=0;o<l;o+=3)for(u=o+1<l?e[o+1>>>2]:0,c=o+2<l?e[o+2>>>2]:0,a=(e[o>>>2]>>>8*(f+n*(o%4))&255)<<16|(u>>>8*(f+n*((o+1)%4))&255)<<8|c>>>8*(f+n*((o+2)%4))&255,s=0;s<4;s+=1)h+=8*o+6*s<=t?r.charAt(a>>>6*(3-s)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,o="";const s=t/8,a=-1===n?3:0;for(r=0;r<s;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=new ArrayBuffer(i),s=new Uint8Array(o),a=-1===n?3:0;for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return o}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=-1===n?3:0,s=new Uint8Array(i);for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(o+n*(r%4))&255;return s}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function a(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function u(e,t){return e<<t|e>>>32-t}function c(e,t,n){return e^t^n}function h(e,t,n){return e&t^e&n^t&n}function l(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function f(e,t,n,r,i){const o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function p(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(e,t){let n,r,i,o,s,a,p;const d=[];for(n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],p=0;p<80;p+=1)d[p]=p<16?e[p]:u(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),a=p<20?f(u(n,5),(g=r)&i^~g&o,s,1518500249,d[p]):p<40?f(u(n,5),c(r,i,o),s,1859775393,d[p]):p<60?f(u(n,5),h(r,i,o),s,2400959708,d[p]):f(u(n,5),c(r,i,o),s,3395469782,d[p]),s=o,o=i,i=u(r,30),r=n,n=a;var g;return t[0]=l(n,t[0]),t[1]=l(r,t[1]),t[2]=l(i,t[2]),t[3]=l(o,t[3]),t[4]=l(s,t[4]),t}function g(e,t,n,r){let i;const o=15+(t+65>>>9<<4),s=t+n;for(;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&s,e[o-1]=s/4294967296|0,i=0;i<e.length;i+=16)r=d(e.slice(i,i+16),r);return r}class w extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),o=i.binLen,s=i.value,a=o>>>5;for(t=0;t<a;t+=r)n+this.T<=o&&(this.m=this.g(s.slice(t,t+r),this.m),n+=this.T);return this.A+=n,this.h=s.slice(n>>>5),this.u=o%this.T,this.l=!0,this}getHash(e,t){let n,r,i=this.B;const o=a(t);if(this.v){if(-1===o.outputLen)throw new Error("Output length must be specified in options");i=o.outputLen}const u=s(e,i,this.Y,o);if(this.p&&this.H)return u(this.H(o));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),i),n=1;n<this.numRounds;n+=1)this.v&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.L(this.o),i);return u(r)}setHMACKey(e,t,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=o(t,(n||{}).encoding||"UTF8",this.Y);this.N(r(e))}N(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.L(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const n=a(t);return s(e,this.B,this.Y,n)(this.S())}S(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return e=this.g(this.U,this.L(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-1"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=o(this.t,this.i,this.Y),this.g=d,this.I=function(e){return e.slice()},this.L=p,this.C=g,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return o(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.Y))}}},673:(e,t,n)=>{n.r(t),n.d(t,{default:()=>A});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e,t,n,r){let i,o,s;const a=t||[0],u=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<e.length;i+=1)s=i+u,o=s>>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(c+r*(s%4));return{value:a,binLen:8*e.length+n}}function o(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=2){if(o=parseInt(e.substr(i,2),16),isNaN(o))throw new Error("String of HEX type contains invalid characters");for(a=(i>>>1)+c,s=a>>>2;u.length<=s;)u.push(0);u[s]|=o<<8*(h+r*(a%4))}return{value:u,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let o,s,a,u,c,h,l,f,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a<e.length;a+=1)for(o=e.charCodeAt(a),s=[],128>o?s.push(o):2048>o?(s.push(192|o>>>6),s.push(128|63&o)):55296>o||57344<=o?s.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),s.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u<s.length;u+=1){for(h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=s[u]<<8*(l+i*(h%4)),p+=1}else for(l=-1===i?2:0,f="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a<e.length;a+=1){for(o=e.charCodeAt(a),!0===f&&(u=255&o,o=u<<8|o>>>8),h=p+g,c=h>>>2;d.length<=c;)d.push(0);d[c]|=o<<8*(l+i*(h%4)),p+=2}return{value:d,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,i){return function(e,t,n,i){let o,s,a,u,c,h,l,f=0;const p=t||[0],d=(n=n||0)>>>3,g=-1===i?3:0,w=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==w&&w<e.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<e.length;s+=4){for(c=e.substr(s,4),u=0,a=0;a<c.length;a+=1)o=r.indexOf(c.charAt(a)),u|=o<<18-6*a;for(a=0;a<c.length-1;a+=1){for(l=f+d,h=l>>>2;p.length<=h;)p.push(0);p[h]|=(u>>>16-8*a&255)<<8*(g+i*(l%4)),f+=1}}return{value:p,binLen:8*f+n}}(e,t,i,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,o,s,a;const u=t||[0],c=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<e.length;o+=1)i=e.charCodeAt(o),a=o+c,s=a>>>2,u.length<=s&&u.push(0),u[s]|=i<<8*(h+r*(a%4));return{value:u,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,n,r){return i(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return i(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function s(e,t,n,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let o,s,a="";const u=t/8,c=-1===n?3:0;for(o=0;o<u;o+=1)s=e[o>>>2]>>>8*(c+n*(o%4)),a+=i.charAt(s>>>4&15)+i.charAt(15&s);return r.outputUpper?a.toUpperCase():a}(e,t,n,i)};case"B64":return function(e){return function(e,t,n,i){let o,s,a,u,c,h="";const l=t/8,f=-1===n?3:0;for(o=0;o<l;o+=3)for(u=o+1<l?e[o+1>>>2]:0,c=o+2<l?e[o+2>>>2]:0,a=(e[o>>>2]>>>8*(f+n*(o%4))&255)<<16|(u>>>8*(f+n*((o+1)%4))&255)<<8|c>>>8*(f+n*((o+2)%4))&255,s=0;s<4;s+=1)h+=8*o+6*s<=t?r.charAt(a>>>6*(3-s)&63):i.b64Pad;return h}(e,t,n,i)};case"BYTES":return function(e){return function(e,t,n){let r,i,o="";const s=t/8,a=-1===n?3:0;for(r=0;r<s;r+=1)i=e[r>>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,t,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=new ArrayBuffer(i),s=new Uint8Array(o),a=-1===n?3:0;for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return o}(e,t,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){let r;const i=t/8,o=-1===n?3:0,s=new Uint8Array(i);for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(o+n*(r%4))&255;return s}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],c=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function h(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function l(e,t){return e>>>t|e<<32-t}function f(e,t){return e>>>t}function p(e,t,n){return e&t^~e&n}function d(e,t,n){return e&t^e&n^t&n}function g(e){return l(e,2)^l(e,13)^l(e,22)}function w(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function y(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){const o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function b(e){return l(e,7)^l(e,18)^f(e,3)}function L(e){return l(e,6)^l(e,11)^l(e,25)}function v(e){let t;return t="SHA-224"==e?u.slice():c.slice(),t}function k(e,t){let n,r,i,o,s,u,c,h,v,k,A;const E=[];for(n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],u=t[5],c=t[6],h=t[7],A=0;A<64;A+=1)E[A]=A<16?e[A]:y(l(S=E[A-2],17)^l(S,19)^f(S,10),E[A-7],b(E[A-15]),E[A-16]),v=m(h,L(s),p(s,u,c),a[A],E[A]),k=w(g(n),d(n,r,i)),h=c,c=u,u=s,s=w(o,v),o=i,i=r,r=n,n=w(v,k);var S;return t[0]=w(n,t[0]),t[1]=w(r,t[1]),t[2]=w(i,t[2]),t[3]=w(o,t[3]),t[4]=w(s,t[4]),t[5]=w(u,t[5]),t[6]=w(c,t[6]),t[7]=w(h,t[7]),t}class A extends class{constructor(e,t,n){const r=n||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(e){let t,n=0;const r=this.T>>>5,i=this.F(e,this.h,this.u),o=i.binLen,s=i.value,a=o>>>5;for(t=0;t<a;t+=r)n+this.T<=o&&(this.m=this.g(s.slice(t,t+r),this.m),n+=this.T);return this.l+=n,this.h=s.slice(n>>>5),this.u=o%this.T,this.A=!0,this}getHash(e,t){let n,r,i=this.B;const o=h(t);if(this.H){if(-1===o.outputLen)throw new Error("Output length must be specified in options");i=o.outputLen}const a=s(e,i,this.v,o);if(this.p&&this.Y)return a(this.Y(o));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),i),n=1;n<this.numRounds;n+=1)this.H&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.C(r,i,0,this.I(this.o),i);return a(r)}setHMACKey(e,t,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=o(t,(n||{}).encoding||"UTF8",this.v);this.M(r(e))}M(e){const t=this.T>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.C(e.value,e.binLen,0,this.I(this.o),this.B));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^e.value[r],this.U[r]=1549556828^e.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(e,t){const n=h(t);return s(e,this.B,this.v,n)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return e=this.g(this.U,this.I(this.o)),e=this.C(t,this.B,this.T,e,this.B),e}}{constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=o(this.t,this.i,this.v),this.g=k,this.S=function(e){return e.slice()},this.I=v,this.C=function(t,n,r,i){return function(e,t,n,r,i){let o,s;const a=15+(t+65>>>9<<4),u=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&u,e[a-1]=u/4294967296|0,o=0;o<e.length;o+=16)r=k(e.slice(o,o+16),r);return s="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,s}(t,n,r,i,e)},this.m=v(e),this.T=512,this.B="SHA-224"===e?224:256,this.H=!1,r.hmacKey&&this.M(function(e,t,n,r){const i="hmacKey must include a value and format";if(!t)throw new Error(i);if(void 0===t.value||!t.format)throw new Error(i);return o(t.format,t.encoding||"UTF8",n)(t.value)}(0,r.hmacKey,this.v))}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{BLOCK_LENGTH:()=>ke,BUFF_0:()=>g,BUFF_COLON:()=>l,BUFF_D:()=>o,BUFF_E:()=>a,BUFF_I:()=>c,BUFF_L:()=>t,BUFF_MINUS:()=>p,BYTE_0:()=>d,BYTE_COLON:()=>h,BYTE_D:()=>i,BYTE_E:()=>s,BYTE_I:()=>u,BYTE_L:()=>e,BYTE_MINUS:()=>f,BlockHasher:()=>z,ChunkSplitter:()=>_,CommonPieceLength:()=>ve,META_VERSION:()=>Ae,MerkleRootCalculator:()=>j,MerkleTreeBalancer:()=>X,PieceHasher:()=>J,TokenType:()=>P,Tokenizer:()=>C,TorrentType:()=>Le,compareEntryNames:()=>be,concatUint8Arrays:()=>b,create:()=>Te,decode:()=>N,encode:()=>S,getEntriesOfDirEntry:()=>re,getFileOfFileEntry:()=>ie,getSortedIndex:()=>y,getTimeStampSecondsNow:()=>v,isDigitByte:()=>w,isFile:()=>G,isFileSystemDirectoryEntry:()=>Z,isFileSystemDirectoryHandle:()=>ee,isFileSystemFileEntry:()=>Q,isFileSystemFileHandle:()=>te,isFileTreeDirEntry:()=>me,isFileTreeDirNode:()=>we,isFileTreeFileEntry:()=>ye,isFileTreeFileNode:()=>ge,iterableSort:()=>m,merkleRoot:()=>k,nextPowerOfTwo:()=>L,packEntriesToDirNode:()=>pe,parse:()=>x,populateFileTree:()=>fe,resolveCommonDirAndTorrentName:()=>le,useArrayBufferPromiseHook:()=>T,useTextPromiseHook:()=>B,useUint8ArrayStreamHook:()=>U});const e=108,t=new Uint8Array([e]),i=100,o=new Uint8Array([i]),s=101,a=new Uint8Array([s]),u=105,c=new Uint8Array([u]),h=58,l=new Uint8Array([h]),f=45,p=new Uint8Array([f]),d=48,g=new Uint8Array([d]);function w(e){return e>=d&&e<=d+9}function y(e,t,n){let r=0,i=e.length;for(;r<i;){const o=r+i>>>1,s=n(e[o],t);if(0===s)return{index:o,result:e[o]};s<0?r=o+1:i=o}return{index:r,result:void 0}}function m(e,t){const n=[];for(const r of e){const{index:e}=y(n,r,t);n.splice(e,0,r)}return n}function b(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.byteLength),0));return e.reduce(((e,n)=>(t.set(n,e),e+n.byteLength)),0),t}function L(e){return 1<<32-Math.clz32(e-1)}function v(){return Math.round(Date.now()/1e3)}async function k(e){if(0===e.length)throw new Error("Empty leaves");const t=new Uint8Array(64);for(;e.length>1;){let r=!1;const i=[];for(const o of e)if(r){let e;t.set(o,32);try{e=new Uint8Array(await crypto.subtle.digest("SHA-256",t))}catch{const{default:r}=await Promise.resolve().then(n.bind(n,673)),i=new r("SHA-256","UINT8ARRAY");i.update(t),e=i.getHash("UINT8ARRAY")}i.push(e),r=!1}else t.set(o),r=!0;e=i}return e[0]}const A=new WeakMap;class E{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;path=[];hookSystem;attachedHooks=new WeakMap;constructor(e,t){this.data=e,this.hookSystem=t,t&&A.set(t,!0)}start(e){if(this.encode(this.data,e),this.hookSystem)for(const e of this.hookSystem.values())this.attachedHooks.get(e)||e({value:void 0,done:!0});e.close()}encode(e,n){if(null!=e)if("boolean"==typeof e)this.encode(e?1:0,n);else if("number"==typeof e){const t=Math.round(e);n.enqueue(this.textEncoder.encode(`i${t}e`)),t!==e&&(console.warn(`WARNING: Possible data corruption detected with value "${e}":`,`Bencoding only defines support for integers, value was converted to "${t}"`),console.trace())}else if("bigint"==typeof e)n.enqueue(this.textEncoder.encode(`i${e}e`));else if("string"==typeof e){const t=this.textEncoder.encode(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(e instanceof ArrayBuffer){const t=new Uint8Array(e),r=t.byteLength;n.enqueue(this.textEncoder.encode(`${r}:`)),n.enqueue(t)}else if(Array.isArray(e)){n.enqueue(t);let r=0;for(const t of e){let e;if(this.path.push(r),this.hookSystem&&(e=this.hookSystem.get(this.path))){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n);this.path.pop(),++r}n.enqueue(a)}else if(e instanceof Map){n.enqueue(o);const t=m(e.keys(),((e,t)=>(e="string"==typeof e?e:this.textDecoder.decode(e))<(t="string"==typeof t?t:this.textDecoder.decode(t))?-1:e>t?1:0));for(const r of t){const t=e.get(r);if(void 0!==t&&null!==e)if(r instanceof ArrayBuffer)this.encode(r,n),this.encode(t,n);else{let e;if(this.path.push(r),this.encode(r,n),this.hookSystem&&(e=this.hookSystem.get(this.path))){const r=R(n,e);this.encode(t,r),e({value:void 0,done:!0}),this.attachedHooks.set(e,!0)}else this.encode(t,n);this.path.pop()}}n.enqueue(a)}else{n.enqueue(o);const t=Object.keys(e).sort();for(const r of t){const t=e[r];if(void 0===t||null===e)continue;let i;if(this.path.push(r),this.encode(r,n),this.hookSystem&&(i=this.hookSystem.get(this.path))){const e=R(n,i);this.encode(t,e),i({value:void 0,done:!0}),this.attachedHooks.set(i,!0)}else this.encode(t,n);this.path.pop()}n.enqueue(a)}}}function S(e,t){return new ReadableStream(new E(e,t))}function R(e,t){return new Proxy(e,{get:function(e,n,r){return"enqueue"===n?(n=>{e.enqueue(n),t({value:n,done:!1})}).bind(e):Reflect.get(e,n,r)}})}function U(e,t){const n={controller:null},r=new ReadableStream({start(e){n.controller=e},pull(e){A.get(t)||(console.warn("You need to call encode() first and then consume hooks."),e.close(),n.controller=null)}});return t.set(e,(({value:e,done:t})=>{null!==n.controller&&(t?n.controller.close():n.controller.enqueue(e))})),r}function T(e,t){const n=U(e,t);return new Response(n).arrayBuffer()}function B(e,t){const n=U(e,t);return new Response(n).text()}var P;!function(e){e.Integer="Integer",e.ByteString="ByteString",e.ListStart="ListStart",e.ListEnd="ListEnd",e.DictionaryStart="DictionaryStart",e.DictionaryEnd="DictionaryEnd"}(P||(P={}));class F{endStack=[];token=null;byteStringLength=-1;byteStringOffset=0;transform(e,t){this.tokenize(e,t)}flush(){if(this.endStack.length||this.token||-1!==this.byteStringLength||this.byteStringOffset)throw new SyntaxError("Unexpected end of torrent stream")}tokenize(t,n){if(0!==t.byteLength)if(null===this.token&&-1===this.byteStringLength){const r=t[0];if(r===u)this.token={type:P.Integer,value:new Uint8Array};else if(w(r))this.byteStringLength=r-d;else if(r===e)this.endStack.push(P.ListEnd),n.enqueue({type:P.ListStart});else if(r===i)this.endStack.push(P.DictionaryEnd),n.enqueue({type:P.DictionaryStart});else{if(r!==s)throw new SyntaxError(`Unexpected byte: ${r}`);{const e=this.endStack.pop();if(!e)throw new SyntaxError("Unbalanced delimiter");n.enqueue({type:e})}}this.tokenize(t.subarray(1),n)}else if(this.token&&-1===this.byteStringLength)if(this.token.type===P.Integer){const e=t.indexOf(s);-1===e?this.token.value=this.token.value?b(this.token.value,t):t:(this.token.value=this.token.value?b(this.token.value,t.subarray(0,e)):t.subarray(0,e),n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e+1),n))}else{if(this.token.type!==P.ByteString)throw new Error("This is a bug");{const e=this.token.value.byteLength-this.byteStringOffset,r=t.byteLength;r<e?(this.token.value.set(t,this.byteStringOffset),this.byteStringOffset+=r):(this.token.value.set(t.subarray(0,e),this.byteStringOffset),this.byteStringOffset=0,n.enqueue(this.token),this.token=null,this.tokenize(t.subarray(e),n))}}else{if(!(this.byteStringLength>-1&&null===this.token))throw new Error("This is a bug");{let e=-1;for(const[n,r]of t.entries()){if(!w(r)){if(r===h){e=n;break}throw new SyntaxError(`Unexpected byte: ${r}`)}this.byteStringLength=10*this.byteStringLength-d+r}-1!==e&&(this.token={type:P.ByteString,value:new Uint8Array(this.byteStringLength)},this.byteStringLength=-1,this.tokenize(t.subarray(e+1),n))}}}}class C extends TransformStream{constructor(){super(new F)}}async function x(e){let t;const n=[],r=e.getReader();let i;for(;;){const{done:e,value:o}=await r.read();if(e)break;const s=n.at(-1);if(s)if(Array.isArray(s))switch(o.type){case P.Integer:s.push(I(o.value));break;case P.ByteString:s.push(H(o.value));break;case P.DictionaryStart:{const e=Object.create(null);s.push(e),n.push(e);break}case P.ListStart:{const e=[];s.push(e),n.push(e);break}case P.ListEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}else if(void 0===i)switch(o.type){case P.ByteString:i=H(o.value);break;case P.DictionaryEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}else{switch(o.type){case P.Integer:s[i]=I(o.value);break;case P.ByteString:s[i]=H(o.value);break;case P.DictionaryStart:{const e=Object.create(null);s[i]=e,n.push(e);break}case P.ListStart:{const e=[];s[i]=e,n.push(e);break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}i=void 0}else{if(void 0!==t)throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`);switch(o.type){case P.Integer:t=I(o.value);break;case P.ByteString:t=H(o.value);break;case P.DictionaryStart:{const e=Object.create(null);n.push(e),t=e;break}case P.ListStart:{const e=[];n.push(e),t=e;break}default:throw new SyntaxError(`Unexpected token: ${JSON.stringify(o)}`)}}}if(n.length)throw new Error("Unexpected end of token stream");return t}async function N(e){const t=new C,n=e.pipeThrough(t);return await x(n)}function I(e){let t=0,n=!0;for(const[r,i]of e.entries()){if(0===r&&i===f){n=!1;continue}if(1===r&&!n&&i===d)throw new SyntaxError("Negative zero is not a valid integer");if(1===r&&0===t)throw new SyntaxError("Leading zeros are not allowed");if(!w(i))throw new SyntaxError(`Unexpected byte: ${i}`);const e=i-d;(n&&"number"==typeof t&&t>(Number.MAX_SAFE_INTEGER-e)/10||!n&&"number"==typeof t&&t<(Number.MIN_SAFE_INTEGER+e)/10)&&(t=BigInt(t)),t="number"==typeof t?n?10*t+e:10*t-e:n?10n*t+BigInt(e):10n*t-BigInt(e)}return t}function H(e){return(new TextDecoder).decode(e)}n(913);class M extends Error{constructor(e,t){super(((e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n})(e,t)),this.name=e,this.details=t}}class Y{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function D(e){const t=e.map((e=>Promise.resolve(e).then((e=>function(e){if(e instanceof Response){if(e.body)return e.body.getReader();throw new M("opaque-streams-source",{type:e.type})}return e instanceof ReadableStream?e.getReader():new Response(e).body.getReader()}(e))))),n=new Y;let r=0;const i=new ReadableStream({pull(e){return t[r].then((e=>e.read())).then((i=>{if(i.done)return r++,r>=t.length?(e.close(),void n.resolve()):this.pull(e);e.enqueue(i.value)})).catch((e=>{throw n.reject(e),e}))},cancel(){n.resolve()}});return{done:n.promise,stream:i}}n(1);const O=new Uint8Array(32);class q{blockCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}async transform(e,t){let r;++this.blockCount;try{r=new Uint8Array(await crypto.subtle.digest("SHA-256",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),i=new t("SHA-256","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}this.merkleLeaves.push(r),this.merkleLeaves.length===this.blocksPerPiece&&(t.enqueue(this.merkleLeaves),this.merkleLeaves=[])}flush(e){if(0===this.blockCount)return;let t=0;if(this.blockCount<this.blocksPerPiece)t=L(this.blockCount)-this.blockCount;else{const e=this.blockCount%this.blocksPerPiece;e>0&&(t=this.blocksPerPiece-e)}if(t>0)for(let e=0;e<t;++e)this.merkleLeaves.push(O);this.merkleLeaves.length>0&&e.enqueue(this.merkleLeaves)}}class z extends TransformStream{constructor(e){super(new q(e))}}class ${residuePointer=0;chunkLength;residue;opts;constructor(e,t={padding:!1}){this.chunkLength=e,this.opts=t,this.residue=new Uint8Array(this.chunkLength)}transform(e,t){for(;this.residuePointer+e.byteLength>=this.chunkLength;){const n=this.chunkLength-this.residuePointer;this.residue.set(e.subarray(0,n),this.residuePointer),this.residuePointer=0,t.enqueue(new Uint8Array(this.residue)),e=e.subarray(n)}this.residue.set(e,this.residuePointer),this.residuePointer+=e.byteLength}flush(e){this.residuePointer<=0||(this.opts.padding?(this.residue.set(new Uint8Array(this.chunkLength-this.residuePointer),this.residuePointer),e.enqueue(this.residue)):e.enqueue(this.residue.subarray(0,this.residuePointer)))}}class _ extends TransformStream{constructor(e,t={padding:!1}){super(new $(e,t))}}class K{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){t.enqueue(await k(e)),this.updateProgress&&await this.updateProgress()}}class j extends TransformStream{constructor(e){super(new K(e))}}class V{leafCount=0;merkleLeaves=[];blocksPerPiece;constructor(e){this.blocksPerPiece=e}transform(e){++this.leafCount,this.merkleLeaves.push(e)}async flush(e){const t=L(this.leafCount)-this.leafCount;if(t>0){const e=await this.padLeafPromise;for(let n=0;n<t;++n)this.merkleLeaves.push(e)}e.enqueue(this.merkleLeaves)}get padLeafPromise(){return k(Array(this.blocksPerPiece).fill(new Uint8Array(32)))}}class X extends TransformStream{constructor(e){super(new V(e))}}class W{updateProgress;constructor(e){this.updateProgress=e}async transform(e,t){let r;try{r=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),i=new t("SHA-1","UINT8ARRAY");i.update(e),r=i.getHash("UINT8ARRAY")}t.enqueue(r),this.updateProgress&&await this.updateProgress()}}class J extends TransformStream{constructor(e){super(new W(e))}}function G(e){return e instanceof File}function Z(e){return!ee(e)&&!G(e)&&e.isDirectory}function Q(e){return!ee(e)&&!G(e)&&e.isFile}function ee(e){try{if(e instanceof FileSystemHandle&&"directory"===e.kind)return!0}catch(e){}return!1}function te(e){try{if(e instanceof FileSystemHandle&&"file"===e.kind)return!0}catch(e){}return!1}function ne(e){return new Promise(((t,n)=>{e.readEntries(t,n)}))}async function*re(e){const t=e.createReader();let n=[];do{n=await ne(t);for(const e of n)yield e}while(n.length>0)}function ie(e){return new Promise(((t,n)=>{e.file(t,n)}))}const oe={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let se;const ae=new Uint8Array(16);function ue(){if(!se&&(se="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!se))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return se(ae)}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));const he=function(e,t,n){if(oe.randomUUID&&!t&&!e)return oe.randomUUID();const r=(e=e||{}).random||(e.rng||ue)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(r)};function le(e,t){if(t.size>1||0===t.size)return{name:e||he(),commonDir:void 0};const[n,r]=t.entries().next().value;return ge(r)?{name:e||n,commonDir:void 0}:{name:e||n,commonDir:n}}async function fe(e,{sort:t=!0,compareFunction:n=be,polyfillWebkitRelativePath:r=!0}={sort:!0,compareFunction:be,polyfillWebkitRelativePath:!0}){let i=0,o=0;const s=new WeakMap,a=new WeakMap,u=new WeakMap,c=["file tree",[]],h=[c];let l=!1;for await(const t of e)await f(t);return{fileTree:pe(c[1],l),traverseTree:function*e(t){if(we(t))for(const n of t.values())yield*e(n);else yield[t,u.get(t)]},totalFileSize:i,totalFileCount:o};async function f(e){const p=h.at(-1);if(!p)throw new Error("This is a bug");const d=G(e),g=ee(e),w=Z(e),m=te(e),b=Q(e);if(g||w){const r=e.name,{index:i,result:o}=y(p[1],r,n);let s=o;if(ye(s))throw new Error("A same name file already exists");if(me(s)&&g){const t=a.get(s);if(!t||!await e.isSameEntry(t))throw new Error("File system handle not match")}s||(s=[r,[]],t?p[1].splice(i,0,s):p[1].push(s),g&&a.set(s,e)),h.push(s);for await(const t of g?e.values():re(e))await f(t);s[1]=new Map(s[1]),h.pop()}else if(m||b){const a=e.name,{index:c,result:l}=y(p[1],a,n);let f=l;if(ye(f)&&m){const t=s.get(f);if(!t||!await e.isSameEntry(t))throw new Error("A same name file already exists")}if(me(f))throw new Error("A same name directory already exists");if(f)return;const d=await(m?e.getFile():ie(e)),g=d.size;if(r){const e=h.reduce(((e,t,n)=>0===n?e:e+t[0]+"/"),"")+d.name;Object.defineProperty(d,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e})}const w={"":{length:g}};f=[a,w],t?p[1].splice(c,0,f):p[1].push(f),m&&s.set(f,e),u.set(w,d),i+=g,o+=1}else{if(!d)throw new Error("Unrecognized type of input");{r&&""===e.webkitRelativePath&&Object.defineProperty(e,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>e.name});const s=(e.webkitRelativePath||e.name).split("/"),a=[c];for(const[r,c]of s.entries()){r>=1&&(l=!0);const h=a.at(-1);if(!h)throw new Error("This is a bug");const{index:f,result:p}=y(h[1],c,n);if(r<s.length-1){let e=p;if(ye(e))throw new Error("A same name file already exists");e||(e=[c,[]],t?h[1].splice(f,0,e):h[1].push(e)),a.push(e)}else{let n=p;if(me(n))throw new Error("A same name directory already exists");if(n)return;const r=e.size,s={"":{length:r}};n=[c,s],t?h[1].splice(f,0,n):h[1].push(n),u.set(s,e),i+=r,o+=1}}}}}}function pe(e,t=!1){return t&&de(e),new Map(e)}function de(e){for(const t of e)if(me(t)){const e=t[1];de(e),t[1]=new Map(e)}}function ge(e){return!!e&&""in e}function we(e){return e instanceof Map}function ye(e){return!!e&&""in e[1]}function me(e){return!!e&&!(""in e[1])}function be(e,t){return e[0]<t?-1:e[0]>t?1:0}var Le,ve;!function(e){e.V1="v1",e.V2="v2",e.HYBRID="hybrid"}(Le||(Le={})),function(e){e[e["16KB"]=16384]="16KB",e[e["32KB"]=32768]="32KB",e[e["64KB"]=65536]="64KB",e[e["128KB"]=131072]="128KB",e[e["256KB"]=262144]="256KB",e[e["512KB"]=524288]="512KB",e[e["1MB"]=1048576]="1MB",e[e["2MB"]=2097152]="2MB",e[e["4MB"]=4194304]="4MB",e[e["8MB"]=8388608]="8MB",e[e["16MB"]=16777216]="16MB",e[e["32MB"]=33554432]="32MB"}(ve||(ve={}));const ke=16384,Ae=2,Ee={type:Le.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:ke,pieceLength:NaN,sortFiles:!0,isPrivate:!1},Se={type:Le.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:ke,pieceLength:NaN,metaVersion:Ae,isPrivate:!1},Re={type:Le.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:ke,pieceLength:NaN,metaVersion:Ae,isPrivate:!1};function Ue(e,t){let n=0;for(const r of e)n+=Math.ceil(r.size/t);return n}async function Te(e,t={type:Le.V1},n){switch(t.type){case Le.V1:return await async function(e,t,n){const r={...Ee,...t},{fileTree:i,traverseTree:o,totalFileCount:s,totalFileSize:a}=await fe(e,{sort:r.sortFiles});if(0===s)return;const u=[];for(const[,e]of o(i))u.push(e);isNaN(r.pieceLength)&&(r.pieceLength=Ie(a,r.blockLength)),0!=(r.pieceLength&r.pieceLength-1)&&console.warn(`piece length ${r.pieceLength} is not a power of 2`),r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ne(r.urlList);const[c,h]=Ce(0,n),{commonDir:l,name:f}=le(r.name,i);let p;if(r.name=f,r.addPaddingFiles){const e=Ue(u,r.pieceLength);await h(e);const t=[],n=s-1;for(let e=n;e>=0;--e){const i=u[e];if(t.unshift(Promise.resolve(Pe(i.stream(),{pieceLength:r.pieceLength,padding:e!==n,updateProgress:c}))),e===n)continue;const o=i.size%r.pieceLength;if(0===o)continue;const s=Fe(r.pieceLength-o,l);u.splice(e+1,0,s)}p=D(t).stream}else{const e=Math.ceil(a/r.pieceLength);await h(e);const{stream:t}=D(u.map((e=>Promise.resolve(e.stream()))));p=Pe(t,{pieceLength:r.pieceLength,padding:!1,updateProgress:c})}return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.8"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{...s>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return l&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},name:r.name,"piece length":r.pieceLength,pieces:await new Response(p).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.V2:return await async function(e,t,n){const r={...Se,...t},{fileTree:i,traverseTree:o,totalFileCount:s,totalFileSize:a}=await fe(e);if(0===s)return;const u=[],c=[];for(const[e,t]of o(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ie(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ne(r.urlList);const l=Ue(u,r.pieceLength),[f]=Ce(l,n),{name:p}=le(r.name,i);r.name=p;const d=new Map;return await Promise.all(c.map((async([e,t])=>{await Be(t.stream(),d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:f})}))),{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.8"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n);case Le.HYBRID:return await async function(e,t,n){const r={...Re,...t},{fileTree:i,traverseTree:o,totalFileCount:s,totalFileSize:a}=await fe(e);if(0===s)return;const u=[],c=[];for(const[e,t]of o(i))u.push(t),c.push([e,t]);if(isNaN(r.pieceLength)&&(r.pieceLength=Ie(a,r.blockLength)),r.pieceLength<r.blockLength)throw new Error(`piece length ${r.pieceLength} is smaller than block length ${r.blockLength}`);if(0!=(r.pieceLength&r.pieceLength-1))throw new Error(`piece length ${r.pieceLength} is not a power of 2`);const h=r.pieceLength/r.blockLength;r.announceList=xe(r.announceList),void 0===r.announce&&void 0!==r.announceList&&(r.announce=r.announceList[0]?.[0]),r.urlList=Ne(r.urlList);const[l]=Ce(2*Ue(u,r.pieceLength),n),{commonDir:f,name:p}=le(r.name,i);r.name=p;const d=new Map,g=[];let w=s-1,y=-1;for(const[e,t]of c){++y;const[n,i]=t.stream().tee();if(g.unshift(Promise.resolve(Pe(n,{pieceLength:r.pieceLength,padding:y!==w,updateProgress:l}))),await Be(i,d,e,{blockLength:r.blockLength,pieceLength:r.pieceLength,blocksPerPiece:h,updateProgress:l}),y===w)break;const o=t.size%r.pieceLength;if(0===o)continue;const s=Fe(r.pieceLength-o,f);u.splice(++y,0,s),++w}const m=D(g).stream;return{...void 0===r.announce?{}:{announce:r.announce},...r.announceList?{"announce-list":r.announceList}:{},...void 0===r.comment?{}:{comment:r.comment},...r.addCreatedBy?{"created by":"torrefy v2.0.8"}:{},...r.addCreationDate?{"creation date":v()}:{},info:{"file tree":i,...s>1?{files:u.map((e=>{const t=(e.webkitRelativePath||e.name).split("/");return f&&t.shift(),{...e.padding?{attr:"p"}:{},length:e.size,path:t}}))}:{length:a},"meta version":r.metaVersion,name:r.name,"piece length":r.pieceLength,pieces:await new Response(m).arrayBuffer(),...r.isPrivate?{private:!0}:{},...void 0===r.source?{}:{source:r.source}},"piece layers":d,...r.urlList?{"url-list":r.urlList}:{}}}(e,t,n)}}async function Be(e,t,n,r){const{piecesRootReadableStream:i,pieceLayerReadableStream:o}=function(e,t){const n=e.pipeThrough(new _(t.blockLength)).pipeThrough(new z(t.blocksPerPiece)).pipeThrough(new j(t.updateProgress)),[r,i]=n.tee();return{piecesRootReadableStream:i.pipeThrough(new X(t.blocksPerPiece)).pipeThrough(new j),pieceLayerReadableStream:r}}(e,r),s=new Response(i).arrayBuffer();if(n[""].length>r.pieceLength){const e=new Response(o).arrayBuffer();t.set(await s,await e)}n[""].length>0&&(n[""]["pieces root"]=await s)}function Pe(e,t){return e.pipeThrough(new _(t.pieceLength,{padding:t.padding})).pipeThrough(new J(t.updateProgress))}function Fe(e,t){const n=new File([new ArrayBuffer(e)],`${e}`,{type:"application/octet-stream"}),r=`.pad/${e}`,i=void 0===t?r:`${t}/${r}`;return Object.defineProperties(n,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>i},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),n}function Ce(e,t){const n={current:0,total:e};return[async()=>{t&&await t(++n.current,n.total)},async e=>{n.total="number"==typeof e?e:await e(n.total,n.current)}]}function xe(e){if(void 0===e)return;const t=[];for(const n of e)0!==n.length&&t.push(n);return 0!==t.length?t:void 0}function Ne(e){if(void 0!==e&&0!==e.length)return e}function Ie(e,t){return Math.max(t,L(e>>>10))}})(),r})())); |
{ | ||
"name": "torrefy", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "An ESM package that uses Web Streams API to create v1, v2 or hybrid torrents in your web browser.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
122370
0