From 5637be6975fa94e0bf688d98b9461828750adbdc Mon Sep 17 00:00:00 2001 From: Booteille Date: Fri, 15 Nov 2024 01:21:57 +0100 Subject: [PATCH] Use latest Lufi API --- themes/default/public/js/lufi-down.js | 4 ++-- themes/default/public/js/lufi.js | 2 +- themes/default/public/js/worker/download.js | 2 +- themes/default/public/js/worker/main.js | 2 +- themes/default/public/js/worker/remove.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/themes/default/public/js/lufi-down.js b/themes/default/public/js/lufi-down.js index 4726270..e64f010 100755 --- a/themes/default/public/js/lufi-down.js +++ b/themes/default/public/js/lufi-down.js @@ -75,7 +75,7 @@ const startDownload = () => { const pbd = document.getElementById("pbd"); pbd.className = "center-align"; - const blobURL = URL.createObjectURL(job.tmpFile); + const blobURL = URL.createObjectURL(job.downloadedFile); let htmlContent = `

e in t?Ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Qr=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Nt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),en=(t,e)=>{for(var r in e)Ke(t,r,{get:e[r],enumerable:!0})},tn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Kr(e))!Yr.call(t,i)&&i!==r&&Ke(t,i,{get:()=>e[i],enumerable:!(n=$r(e,i))||n.enumerable});return t};var gt=(t,e,r)=>(r=t!=null?Zr(Vr(t)):{},tn(e||!t||!t.__esModule?Ke(r,"default",{value:t,enumerable:!0}):r,t));var d=(t,e,r)=>Xr(t,typeof e!="symbol"?e+"":e,r);var Et=Nt((Xn,wt)=>{"use strict";var Ce=typeof Reflect=="object"?Reflect:null,Jt=Ce&&typeof Ce.apply=="function"?Ce.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Ve;Ce&&typeof Ce.ownKeys=="function"?Ve=Ce.ownKeys:Object.getOwnPropertySymbols?Ve=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ve=function(e){return Object.getOwnPropertyNames(e)};function rn(t){console&&console.warn&&console.warn(t)}var Ht=Number.isNaN||function(e){return e!==e};function z(){z.init.call(this)}wt.exports=z;wt.exports.once=an;z.EventEmitter=z;z.prototype._events=void 0;z.prototype._eventsCount=0;z.prototype._maxListeners=void 0;var Gt=10;function Ye(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(z,"defaultMaxListeners",{enumerable:!0,get:function(){return Gt},set:function(t){if(typeof t!="number"||t<0||Ht(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Gt=t}});z.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};z.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ht(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function qt(t){return t._maxListeners===void 0?z.defaultMaxListeners:t._maxListeners}z.prototype.getMaxListeners=function(){return qt(this)};z.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")Jt(f,this,r);else for(var c=f.length,h=Vt(f,c),n=0;n0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,rn(a)}return t}z.prototype.addListener=function(e,r){return Wt(this,e,r,!1)};z.prototype.on=z.prototype.addListener;z.prototype.prependListener=function(e,r){return Wt(this,e,r,!0)};function nn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Zt(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=nn.bind(n);return i.listener=r,n.wrapFn=i,i}z.prototype.once=function(e,r){return Ye(r),this.on(e,Zt(this,e,r)),this};z.prototype.prependOnceListener=function(e,r){return Ye(r),this.prependListener(e,Zt(this,e,r)),this};z.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Ye(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():on(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};z.prototype.off=z.prototype.removeListener;z.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i=0;i--)this.removeListener(e,r[i]);return this};function $t(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?sn(i):Vt(i,i.length)}z.prototype.listeners=function(e){return $t(this,e,!0)};z.prototype.rawListeners=function(e){return $t(this,e,!1)};z.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Kt.call(t,e)};z.prototype.listenerCount=Kt;function Kt(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}z.prototype.eventNames=function(){return this._eventsCount>0?Ve(this._events):[]};function Vt(t,e){for(var r=new Array(e),n=0;n{"use strict";var u={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};u.cipher.aes=function(t){this.w[0][0][0]||this.C();var e,r,n,i,o=this.w[0][4],s=this.w[1];e=t.length;var a=1;if(e!==4&&e!==6&&e!==8)throw new u.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),i=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[r&255],t%e===0&&(r=r<<8^r>>>24^a<<24,a=a<<1^283*(a>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[e&3?t:t-4],i[e]=4>=t||4>e?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[r&255]]};u.cipher.aes.prototype={encrypt:function(t){return cr(this,t,0)},decrypt:function(t){return cr(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],i,o,s,a=[],f=[],c,h,l,p;for(i=0;256>i;i++)f[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=c||1,s=f[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[o]=l,n[l]=o,h=a[i=a[c=a[o]]],p=16843009*h^65537*i^257*c^16843008*o,h=257*a[l]^16843008*l,i=0;4>i;i++)t[i][o]=h=h<<24^h>>>8,e[i][l]=p=p<<24^p>>>8;for(i=0;5>i;i++)t[i]=t[i].slice(0),e[i]=e[i].slice(0)}};function cr(t,e,r){if(e.length!==4)throw new u.exception.invalid("invalid aes block size");var n=t.b[r],i=e[0]^n[0],o=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,f,c,h=n.length/4-2,l,p=4,v=[0,0,0,0];a=t.w[r],t=a[0];var x=a[1],g=a[2],y=a[3],D=a[4];for(l=0;l>>24]^x[o>>16&255]^g[s>>8&255]^y[e&255]^n[p],f=t[o>>>24]^x[s>>16&255]^g[e>>8&255]^y[i&255]^n[p+1],c=t[s>>>24]^x[e>>16&255]^g[i>>8&255]^y[o&255]^n[p+2],e=t[e>>>24]^x[i>>16&255]^g[o>>8&255]^y[s&255]^n[p+3],p+=4,i=a,o=f,s=c;for(l=0;4>l;l++)v[r?3&-l:l]=D[i>>>24]<<24^D[o>>16&255]<<16^D[s>>8&255]<<8^D[e&255]^n[p++],a=i,i=o,o=s,s=e,e=a;return v}u.bitArray={bitSlice:function(t,e,r){return t=u.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:u.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return((e+r-1^e)&-32?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return t===32?e:(r?e|0:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(u.bitArray.bitLength(t)!==u.bitArray.bitLength(e))return!1;var r=0,n;for(n=0;n>>e),r=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=u.bitArray.getPartial(i),n.push(u.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};u.codec.utf8String={fromBits:function(t){var e="",r=u.bitArray.bitLength(t),n,i;for(n=0;n>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>i)>>>26),6>i?(s=t[r]<<6-i,i+=26,r++):(s<<=6,i-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,i=0,o=u.codec.base64.S,s=0,a;for(e&&(o=o.substr(0,62)+"-_"),n=0;na)throw new u.exception.invalid("this isn't base64!");26>>i),s=a<<32-i):(i+=6,s^=a<<32-i)}return i&56&&r.push(u.bitArray.partial(i&56,s,1)),r}};u.codec.base64url={fromBits:function(t){return u.codec.base64.fromBits(t,1,1)},toBits:function(t){return u.codec.base64.toBits(t,1)}};u.hash.sha256=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};u.hash.sha256.hash=function(t){return new u.hash.sha256().update(t).finalize()};u.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=u.codec.utf8String.toBits(t));var e,r=this.f=u.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+u.bitArray.bitLength(t),9007199254740991e;r++){for(i=!0,n=2;n*n<=r;n++)if(r%n===0){i=!1;break}i&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,i=this.g,o=this.b,s=i[0],a=i[1],f=i[2],c=i[3],h=i[4],l=i[5],p=i[6],v=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+v+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(p^h&(l^p))+o[e],v=p,p=l,l=h,h=c+r|0,c=f,f=a,a=s,s=r+(a&f^c&(a^f))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+f|0,i[3]=i[3]+c|0,i[4]=i[4]+h|0,i[5]=i[5]+l|0,i[6]=i[6]+p|0,i[7]=i[7]+v|0}};u.hash.sha512=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};u.hash.sha512.hash=function(t){return new u.hash.sha512().update(t).finalize()};u.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=u.codec.utf8String.toBits(t));var e,r=this.f=u.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+u.bitArray.bitLength(t),9007199254740991r;n++){for(o=!0,i=2;i*i<=n;i++)if(n%i===0){o=!1;break}o&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,i=this.b,o=n[0],s=n[1],a=n[2],f=n[3],c=n[4],h=n[5],l=n[6],p=n[7],v=n[8],x=n[9],g=n[10],y=n[11],D=n[12],T=n[13],C=n[14],E=n[15],A;if(typeof Uint32Array<"u"){A=Array(160);for(var L=0;32>L;L++)A[L]=t[L]}else A=t;var L=o,b=s,w=a,m=f,k=c,O=h,F=l,V=p,S=v,P=x,j=g,M=y,W=D,G=T,de=C,$=E;for(t=0;80>t;t++){if(16>t)e=A[2*t],r=A[2*t+1];else{r=A[2*(t-15)];var I=A[2*(t-15)+1];e=(I<<31|r>>>1)^(I<<24|r>>>8)^r>>>7;var Y=(r<<31|I>>>1)^(r<<24|I>>>8)^(r<<25|I>>>7);r=A[2*(t-2)];var _=A[2*(t-2)+1],I=(_<<13|r>>>19)^(r<<3|_>>>29)^r>>>6,_=(r<<13|_>>>19)^(_<<3|r>>>29)^(r<<26|_>>>6),re=A[2*(t-7)],te=A[2*(t-16)],ne=A[2*(t-16)+1];r=Y+A[2*(t-7)+1],e=e+re+(r>>>0>>0?1:0),r+=_,e+=I+(r>>>0<_>>>0?1:0),r+=ne,e+=te+(r>>>0>>0?1:0)}A[2*t]=e|=0,A[2*t+1]=r|=0;var re=S&j^~S&W,Q=P&M^~P&G,_=L&w^L&k^w&k,N=b&m^b&O^m&O,te=(b<<4|L>>>28)^(L<<30|b>>>2)^(L<<25|b>>>7),ne=(L<<4|b>>>28)^(b<<30|L>>>2)^(b<<25|L>>>7),we=i[2*t],Ae=i[2*t+1],I=$+((S<<18|P>>>14)^(S<<14|P>>>18)^(P<<23|S>>>9)),Y=de+((P<<18|S>>>14)^(P<<14|S>>>18)^(S<<23|P>>>9))+(I>>>0<$>>>0?1:0),I=I+Q,Y=Y+(re+(I>>>0>>0?1:0)),I=I+Ae,Y=Y+(we+(I>>>0>>0?1:0)),I=I+r|0,Y=Y+(e+(I>>>0>>0?1:0));r=ne+N,e=te+_+(r>>>0>>0?1:0),de=W,$=G,W=j,G=M,j=S,M=P,P=V+I|0,S=F+Y+(P>>>0>>0?1:0)|0,F=k,V=O,k=w,O=m,w=L,m=b,b=I+r|0,L=Y+e+(b>>>0>>0?1:0)|0}s=n[1]=s+b|0,n[0]=o+L+(s>>>0>>0?1:0)|0,f=n[3]=f+m|0,n[2]=a+w+(f>>>0>>0?1:0)|0,h=n[5]=h+O|0,n[4]=c+k+(h>>>0>>0?1:0)|0,p=n[7]=p+V|0,n[6]=l+F+(p>>>0>>0?1:0)|0,x=n[9]=x+P|0,n[8]=v+S+(x>>>0

>>0?1:0)|0,y=n[11]=y+M|0,n[10]=g+j+(y>>>0>>0?1:0)|0,T=n[13]=T+G|0,n[12]=D+W+(T>>>0>>0?1:0)|0,E=n[15]=E+$|0,n[14]=C+de+(E>>>0<$>>>0?1:0)|0}};u.mode.ccm={name:"ccm",F:[],listenProgress:function(t){u.mode.ccm.F.push(t)},unListenProgress:function(t){t=u.mode.ccm.F.indexOf(t),-1f)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&c>>>8*o;o++);return o<15-f&&(o=15-f),r=a.clamp(r,8*(15-o)),e=u.mode.ccm.U(t,e,r,n,i,o),s=u.mode.ccm.V(t,s,r,e,i,o),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o=u.bitArray,s=o.bitLength(r)/8,c=o.bitLength(e),a=o.clamp(e,c-i),f=o.bitSlice(e,c-i),c=(c-i)/8;if(7>s)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&c>>>8*e;e++);if(e<15-s&&(e=15-s),r=o.clamp(r,8*(15-e)),a=u.mode.ccm.V(t,a,r,f,i,e),t=u.mode.ccm.U(t,a.data,r,n,i,e),!o.equal(a.tag,t))throw new u.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,i,o){var s=[],a=u.bitArray,f=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|o-1)],n=a.concat(n,r),n[3]|=i,n=t.encrypt(n),e.length)for(r=a.bitLength(e)/8,65279>=r?s=[a.partial(16,r)]:4294967295>=r&&(s=a.concat([a.partial(16,65534)],[r])),s=a.concat(s,e),e=0;ei||16h&&(u.mode.ccm.da(s/f),h+=l),r[3]++,i=t.encrypt(r),e[s]^=i[0],e[s+1]^=i[1],e[s+2]^=i[2],e[s+3]^=i[3];return{tag:n,data:a.clamp(e,c)}}};u.misc.hmac=function(t,e){this.W=e=e||u.hash.sha256;var r=[[],[]],n,i=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>i&&(t=e.hash(t)),n=0;nn||0>r)throw new u.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=u.codec.utf8String.toBits(t)),typeof e=="string"&&(e=u.codec.utf8String.toBits(e)),i=i||u.misc.hmac,t=new i(t);var o,s,a,f,c=[],h=u.bitArray;for(f=1;32*c.length<(n||1);f++){for(i=o=t.encrypt(h.concat(e,[f])),s=1;ss;s++)i.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=o),this.N++,this.b=u.hash.sha256.hash(this.b.concat(i)),this.K=new u.cipher.aes(this.b),n=0;4>n&&(this.m[n]=this.m[n]+1|0,!this.m[n]);n++);}for(n=0;n>>1;this.h[s].update([n,this.M++,2,e,o,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,o,t.length]),this.h[s].update(t);break;default:f=1}if(f)throw new u.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=e,this.i+=e,a===this.A&&(this.isReady()!==this.A&&hr("seeded",Math.max(this.u,this.i)),hr("progress",this.getProgress()))},isReady:function(t){return t=this.R[t!==void 0?t:this.L],this.u&&this.u>=t?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=t?this.I|this.A:this.A},getProgress:function(t){return t=this.R[t||this.L],this.u>=t||this.i>t?1:this.i/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:_e(this,this.la),mouseCollector:_e(this,this.na),keyboardCollector:_e(this,this.ja),accelerometerCollector:_e(this,this.ca),touchCollector:_e(this,this.pa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new u.exception.bug("can't attach event");this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.J[t][this.ea++]=e},removeEventListener:function(t,e){var r,n,i=this.J[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function _e(t,e){return function(){e.apply(t,arguments)}}u.random=new u.prng(6);e:try{if(tt=typeof Se<"u"&&Se.exports){try{rt=Qr("crypto")}catch{rt=null}tt=et=rt}if(tt&&et.randomBytes)Ne=et.randomBytes(128),Ne=new Uint32Array(new Uint8Array(Ne).buffer),u.random.addEntropy(Ne,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Je=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Je);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Je);else break e;u.random.addEntropy(Je,1024,"crypto['getRandomValues']")}}catch(t){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}var Ne,et,Je,tt,rt;u.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(t,e,r,n){r=r||{},n=n||{};var i=u.json,o=i.j({iv:u.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=u.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=u.codec.base64.toBits(o.iv)),!u.mode[o.mode]||!u.cipher[o.cipher]||typeof t=="string"&&100>=o.iter||o.ts!==64&&o.ts!==96&&o.ts!==128||o.ks!==128&&o.ks!==192&&o.ks!==256||2>o.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4Gr,cancel:()=>_n,compress:()=>Hr,decompress:()=>Nn,download:()=>Jn,events:()=>jt,getFileIndexInQueue:()=>Vn,infos:()=>Gn,pause:()=>Hn,remove:()=>qn,resume:()=>Wn,upload:()=>$n});var Jr=gt(Et());var fn={withStackTrace:!1},er=(t,e,r=fn)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},i=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:i}};function Oe(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{c(n.next(h))}catch(l){s(l)}}function f(h){try{c(n.throw(h))}catch(l){s(l)}}function c(h){h.done?o(h.value):i(h.value).then(a,f)}c((n=n.apply(t,e||[])).next())})}function Xt(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(t){return this instanceof he?(this.v=t,this):new he(t)}function Qt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(v){return function(x){return Promise.resolve(x).then(v,l)}}function a(v,x){n[v]&&(i[v]=function(g){return new Promise(function(y,D){o.push([v,g,y,D])>1||f(v,g)})},x&&(i[v]=x(i[v])))}function f(v,x){try{c(n[v](x))}catch(g){p(o[0][3],g)}}function c(v){v.value instanceof he?Promise.resolve(v.value.v).then(h,l):p(o[0][2],v)}function h(v){f("next",v)}function l(v){f("throw",v)}function p(v,x){v(x),o.shift(),o.length&&f(o[0][0],o[0][1])}}function cn(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,o){e[i]=t[i]?function(s){return(r=!r)?{value:he(t[i](s)),done:!1}:o?o(s):s}:o}}function hn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Xt=="function"?Xt(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(a,f){s=t[o](s),i(a,f,s.done,s.value)})}}function i(o,s,a,f){Promise.resolve(f).then(function(c){o({value:c,done:a})},s)}}var R=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new ie(n));return new t(r)}static fromPromise(e,r){let n=e.then(i=>new ie(i)).catch(i=>new oe(r(i)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(Oe(this,void 0,void 0,function*(){try{return new ie(yield e(...n))}catch(i){return new oe(r?r(i):i)}}))}static combine(e){return ln(e)}static combineWithAllErrors(e){return pn(e)}map(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){return r.isErr()?new oe(r.error):new ie(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){if(r.isErr())return new oe(r.error);let n=yield e(r.value);return n.isErr()?new oe(n.error):new ie(r.value)})))}andTee(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){if(r.isErr())return new oe(r.error);try{yield e(r.value)}catch{}return new ie(r.value)})))}mapErr(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){return r.isOk()?new ie(r.value):new oe(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new oe(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new ie(r.value)})))}match(e,r){return this._promise.then(n=>n.match(e,r))}unwrapOr(e){return this._promise.then(r=>r.unwrapOr(e))}safeUnwrap(){return Qt(this,arguments,function*(){return yield he(yield he(yield*cn(hn(yield he(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Qt(this,arguments,function*(){let r=yield he(this._promise);return r.isErr()&&(yield yield he(H(r.error))),yield he(r.value)})}},Z=t=>new R(Promise.resolve(new ie(t))),H=t=>new R(Promise.resolve(new oe(t))),Qn=R.fromPromise,ei=R.fromSafePromise,ti=R.fromThrowable,tr=t=>{let e=pe([]);for(let r of t)if(r.isErr()){e=le(r.error);break}else e.map(n=>n.push(r.value));return e},ln=t=>R.fromSafePromise(Promise.all(t)).andThen(tr),rr=t=>{let e=pe([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=le([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},pn=t=>R.fromSafePromise(Promise.all(t)).andThen(rr),xt;(function(t){function e(i,o){return(...s)=>{try{let a=i(...s);return pe(a)}catch(a){return le(o?o(a):a)}}}t.fromThrowable=e;function r(i){return tr(i)}t.combine=r;function n(i){return rr(i)}t.combineWithAllErrors=n})(xt||(xt={}));var pe=t=>new ie(t);function le(t){return new oe(t)}var ie=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return pe(e(this.value))}mapErr(e){return pe(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(r=>this.value)}andTee(e){try{e(this.value)}catch{}return pe(this.value)}orElse(e){return pe(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return R.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,r){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw er("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},oe=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return le(this.error)}mapErr(e){return le(e(this.error))}andThrough(e){return le(this.error)}andTee(e){return le(this.error)}andThen(e){return le(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return H(this.error)}asyncAndThrough(e){return H(this.error)}asyncMap(e){return H(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield le(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw er("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},ri=xt.fromThrowable;var Ee=class t{constructor(e,r){d(this,"actionToken","");d(this,"chunksReady",0);d(this,"createdAt",0);d(this,"delay",0);d(this,"delAtFirstView",!1);d(this,"keys",{client:"",server:""});d(this,"name","");d(this,"password","");d(this,"queueIndex",0);d(this,"serverUrl");d(this,"size",0);d(this,"uploadStatus",3);d(this,"totalChunks",0);d(this,"type","");d(this,"zipped",!1);this.serverUrl=e,Object.assign(this,r)}downloadUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}r/${this.keys.server}#${this.keys.client}`)}removeUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}d/${this.keys.server}/${this.actionToken}`)}static fromDownloadUrl(e,r=""){let n=e.pathname.split("r/"),i={client:e.hash.slice(1).split("&")[0],server:n[1]};return new t(e.origin+n[0],{keys:i,password:r})}static fromRemoveUrl(e,r=""){let n=e.pathname.split("d/"),i=n[1].split("/"),o={client:"",server:i[0]};return new t(e.origin+n[0],{keys:o,password:r,actionToken:i[1]})}};var ar=gt(Et());var K=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});d(this,"context");this.name=this.constructor.name,this.context=o}};var Xe=class extends K{constructor(){super(...arguments);d(this,"message","Unable to connect. Is the computer able to access the url?")}};var Qe=class extends K{constructor(){super(...arguments);d(this,"message","The server returned an error")}};var J=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)},ir=t=>{let e=t.href.match(/(.*?)\/?(?:\/[dr]{1}\/|login\/?|files\/?)/),r=e&&e[1]?e[1]:t.origin;return R.fromPromise(fetch(r+"/about/config"),n=>new Xe(void 0,{cause:J(n)})).andThen(n=>n.ok?R.fromPromise(n.json(),i=>J(i)):H(new Qe(void 0,{context:n.statusText})))},or=()=>typeof Deno<"u",At=()=>or()||typeof window<"u"&&(window.isSecureContext||window.location.protocol==="https:"),sr=t=>or()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t==="main"?`worker/${t}`:t}.js`));var xe=class{constructor(e){d(this,"events",new ar.default);d(this,"lufiFile");d(this,"status",2);d(this,"tmpFile");d(this,"tmpChunks",[]);d(this,"worker");d(this,"isTerminated",!1);d(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});d(this,"hasFailed",()=>this.status===1);d(this,"onError",e=>(this.worker.onerror=r=>{e(r)},this));d(this,"onMessage",e=>(this.worker.onmessage=r=>{e&&e(r);let n=r.data.event;n&&(n==="FILE_UPDATED"?Object.assign(this.lufiFile,r.data.lufiFile):this.dispatchEvent(n,r.data.error))},this));d(this,"onMessageError",e=>(this.worker.onmessageerror=r=>{e(r)},this));d(this,"onProgress",e=>(this.events.on("CHUNK_UPLOADED",()=>{e()}),this.events.on("CHUNK_DOWNLOADED",()=>{e()}),this));d(this,"requestMessage",(e,r=[])=>(this.worker.postMessage(e,r),this));d(this,"terminate",()=>(this.worker.terminate(),this));d(this,"waitForCompletion",()=>this.isTerminated?this.status===0?Z(this):H(J("Job has failed")):R.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>J(e)));d(this,"dispatchEvent",(e,r)=>{this.events.emit(e,r)});this.worker=new Worker(sr("main"),{type:"module"}),this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",r=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",r)}),this.onError(r=>console.error(r.error))}};var Pe=(r=>(r[r.Sjcl=0]="Sjcl",r[r.WebCrypto=1]="WebCrypto",r))(Pe||{});var ke=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),i="";for(let o=0;o>2]+this._charset[(n[o]&3)<<4|n[o+1]>>4]+this._charset[(n[o+1]&15)<<2|n[o+2]>>6]+this._charset[n[o+2]&63];return r%3==2?(i=i.substring(0,i.length-1),this._noPadding||(i+="=")):r%3==1&&(i=i.substring(0,i.length-2),this._noPadding||(i+="==")),i}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),i,o,s,a,f=0,c=0;for(;f>4,n[f++]=(o&15)<<4|s>>2,n[f++]=(s&3)<<6|a;return n.buffer}};var Ri=new ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var dn=new ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function Lt(t){return dn.Encode(t)}var Ge=gt(pr());var fe=class extends K{};var Me=class extends fe{constructor(){super(...arguments);d(this,"message","Unable to hash the provided string")}};var vr=()=>{try{return Z(Ge.default.codec.base64.fromBits(Ge.default.random.randomWords(8,10)))}catch(t){return H(new fe("Unable to generate key",{cause:J(t)}))}},mr=t=>{try{return Z(Ge.default.codec.hex.fromBits(Ge.default.hash.sha512.hash(t)))}catch(e){return H(new Me(void 0,{cause:J(e)}))}};var dr=()=>R.fromPromise(new Promise((t,e)=>crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]).then(r=>crypto.subtle.exportKey("raw",r).then(n=>t(Lt(n))).catch(n=>{e(new fe("Unable to base64 encode the url",{cause:J(n)}))})).catch(r=>e(r))),t=>new fe("Unable to generate key",{cause:J(t)})),yr=t=>{let e=async()=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-512",new TextEncoder().encode(t)))).map(r=>r.toString(16).padStart(2,"0")).join("");return R.fromPromise(e(),r=>new Me(void 0,{cause:J(r)}))};var gr=(t=1)=>t===0?vr():dr(),Dt=(t,e)=>e===0?mr(t):yr(t);var wr={},Ln=function(t,e,r,n,i){var o=new Worker(wr[e]||(wr[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(s){var a=s.data,f=a.$e$;if(f){var c=new Error(f[0]);c.code=f[1],c.stack=f[2],i(c,null)}else i(null,a)},o.postMessage(r,n),o},B=Uint8Array,ee=Uint16Array,We=Int32Array,ze=new B([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fe=new B([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),He=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),br=function(t,e){for(var r=new ee(31),n=0;n<31;++n)r[n]=e+=1<>1|(U&21845)<<1,ye=(ye&52428)>>2|(ye&13107)<<2,ye=(ye&61680)>>4|(ye&3855)<<4,qe[U]=((ye&65280)>>8|(ye&255)<<8)>>1;var ye,U,ae=function(t,e,r){for(var n=t.length,i=0,o=new ee(e);i>f]=c}else for(a=new ee(n),i=0;i>15-t[i]);return a},ge=new B(288);for(U=0;U<144;++U)ge[U]=8;var U;for(U=144;U<256;++U)ge[U]=9;var U;for(U=256;U<280;++U)ge[U]=7;var U;for(U=280;U<288;++U)ge[U]=8;var U,Te=new B(32);for(U=0;U<32;++U)Te[U]=5;var U,Pr=ae(ge,9,0),kr=ae(ge,9,1),Sr=ae(Te,5,0),Mr=ae(Te,5,1),it=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},se=function(t,e,r){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&r},ot=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},Ze=function(t){return(t+7)/8|0},Le=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new B(t.subarray(e,r))};var Ur=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],q=function(t,e,r){var n=new Error(e||Ur[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,q),!r)throw n;return n},Rr=function(t,e,r,n){var i=t.length,o=n?n.length:0;if(!i||e.f&&!e.l)return r||new B(0);var s=!r,a=s||e.i!=2,f=e.i;s&&(r=new B(i*3));var c=function(Y){var Be=r.length;if(Y>Be){var De=new B(Math.max(Be*2,Y));De.set(r),r=De}},h=e.f||0,l=e.p||0,p=e.b||0,v=e.l,x=e.d,g=e.m,y=e.n,D=i*8;do{if(!v){h=se(t,l,1);var T=se(t,l+1,3);if(l+=3,T)if(T==1)v=kr,x=Mr,g=9,y=5;else if(T==2){var L=se(t,l,31)+257,b=se(t,l+10,15)+4,w=L+se(t,l+5,31)+1;l+=14;for(var m=new B(w),k=new B(19),O=0;O>4;if(C<16)m[O++]=C;else{var j=0,M=0;for(C==16?(M=3+se(t,l,3),l+=2,j=m[O-1]):C==17?(M=3+se(t,l,7),l+=3):C==18&&(M=11+se(t,l,127),l+=7);M--;)m[O++]=j}}var W=m.subarray(0,L),G=m.subarray(L);g=it(W),y=it(G),v=ae(W,g,1),x=ae(G,y,1)}else q(1);else{var C=Ze(l)+4,E=t[C-4]|t[C-3]<<8,A=C+E;if(A>i){f&&q(0);break}a&&c(p+E),r.set(t.subarray(C,A),p),e.b=p+=E,e.p=l=A*8,e.f=h;continue}if(l>D){f&&q(0);break}}a&&c(p+131072);for(var de=(1<>4;if(l+=j&15,l>D){f&&q(0);break}if(j||q(2),Q<256)r[p++]=Q;else if(Q==256){re=l,v=null;break}else{var _=Q-254;if(Q>264){var O=Q-257,N=ze[O];_=se(t,l,(1<>4;te||q(3),l+=te&15;var G=Or[ne];if(ne>3){var N=Fe[ne];G+=ot(t,l)&(1<D){f&&q(0);break}a&&c(p+131072);var we=p+_;if(p>8},Ue=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8,t[n+2]|=r>>16},st=function(t,e){for(var r=[],n=0;np&&(p=o[n].s);var v=new ee(p+1),x=ut(r[h-1],v,0);if(x>e){var n=0,g=0,y=x-e,D=1<e)g+=D-(1<>=y;g>0;){var C=o[n].s;v[C]=0&&g;--n){var E=o[n].s;v[E]==e&&(--v[E],++g)}x=e}return{t:new B(v),l:x}},ut=function(t,e,r){return t.s==-1?Math.max(ut(t.l,e,r+1),ut(t.r,e,r+1)):e[t.s]=r},Pt=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new ee(++e),n=0,i=t[0],o=1,s=function(f){r[n++]=f},a=1;a<=e;++a)if(t[a]==i&&a!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=t[a]}return{c:r.subarray(0,n),n:e}},Re=function(t,e){for(var r=0,n=0;n>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var o=0;o4&&!k[He[F-1]];--F);var V=c+5<<3,S=Re(i,ge)+Re(o,Te)+s,P=Re(i,p)+Re(o,g)+s+14+3*F+Re(b,k)+2*b[16]+3*b[17]+7*b[18];if(f>=0&&V<=S&&V<=P)return Rt(e,h,t.subarray(f,f+c));var j,M,W,G;if(ve(e,h,1+(P15&&(ve(e,h,Q[w]>>5&127),h+=Q[w]>>12)}}else j=Pr,M=ge,W=Sr,G=Te;for(var w=0;w255){var _=N>>18&31;Ue(e,h,j[_+257]),h+=M[_+257],_>7&&(ve(e,h,N>>23&31),h+=ze[_]);var te=N&31;Ue(e,h,W[te]),h+=G[te],te>3&&(Ue(e,h,N>>5&8191),h+=Fe[te])}else Ue(e,h,j[N]),h+=M[N]}return Ue(e,h,j[256]),h+M[256]},Tr=new We([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Tt=new B(0),zr=function(t,e,r,n,i,o){var s=o.z||t.length,a=new B(n+s+5*(1+Math.ceil(s/7e3))+i),f=a.subarray(n,a.length-i),c=o.l,h=(o.r||0)&7;if(e){h&&(f[0]=o.r>>3);for(var l=Tr[e-1],p=l>>13,v=l&8191,x=(1<7e3||k>24576)&&(j>423||!c)){h=kt(t,f,0,E,A,L,w,k,F,m-F,h),k=b=w=0,F=m;for(var M=0;M<286;++M)A[M]=0;for(var M=0;M<30;++M)L[M]=0}var W=2,G=0,de=v,$=S-P&32767;if(j>2&&V==C(m-$))for(var re=Math.min(p,j)-1,Q=Math.min(32767,m),_=Math.min(258,j);$<=Q&&--de&&S!=P;){if(t[m+W]==t[m+W-$]){for(var N=0;N<_&&t[m+N]==t[m+N-$];++N);if(N>W){if(W=N,G=$,N>re)break;for(var te=Math.min($,N-2),ne=0,M=0;Mne&&(ne=I,P=we)}}}S=P,P=g[S],$+=S-P&32767}if(G){E[k++]=268435456|at[W]<<18|Ot[G];var Y=at[W]&31,Be=Ot[G]&31;w+=ze[Y]+Fe[Be],++A[257+Y],++L[Be],O=m+W,++b}else E[k++]=t[m],++A[t[m]]}}for(m=Math.max(m,O);m=s&&(f[h/8|0]=c,De=s),h=Rt(f,h+1,t.subarray(m,De))}o.i=s}return Le(a,0,n+Ze(h)+i)},bn=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var r=e,n=9;--n;)r=(r&1&&-306674912)^r>>>1;t[e]=r}return t}(),Dn=function(){var t=-1;return{p:function(e){for(var r=t,n=0;n>>8;t=r},d:function(){return~t}}};var Fr=function(t,e,r,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),s=new B(o.length+t.length);s.set(o),s.set(t,o.length),t=s,i.w=o.length}return zr(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,r,n,i)},zt=function(t,e){var r={};for(var n in t)r[n]=t[n];for(var n in e)r[n]=e[n];return r},Er=function(t,e,r){for(var n=t(),i=t.toString(),o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s>>0},Ct=function(t,e){return ce(t,e)+ce(t,e+4)*4294967296},X=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8};function Sn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&q(7),Br(t,e,[kn],function(n){return ct(Ft(n.data[0],n.data[1]))},0,r)}function Ft(t,e){return Fr(t,e||{},0,0)}function Mn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&q(7),Br(t,e,[Pn],function(n){return ct(It(n.data[0],Ir(n.data[1])))},1,r)}function It(t,e){return Rr(t,{i:2},e&&e.out,e&&e.dictionary)}var jr=function(t,e,r,n){for(var i in t){var o=t[i],s=e+i,a=n;Array.isArray(o)&&(a=zt(n,o[1]),o=o[0]),o instanceof B?r[s]=[o,a]:(r[s+="/"]=[new B(0),a],jr(o,s,r,n))}},xr=typeof TextEncoder<"u"&&new TextEncoder,St=typeof TextDecoder<"u"&&new TextDecoder,Un=0;try{St.decode(Tt,{stream:!0}),Un=1}catch{}var Rn=function(t){for(var e="",r=0;;){var n=t[r++],i=(n>127)+(n>223)+(n>239);if(r+i>t.length)return{s:e,r:Le(t,r-1)};i?i==3?(n=((n&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|t[r++]&63):e+=String.fromCharCode((n&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(n)}};function Ar(t,e){if(e){for(var r=new B(t.length),n=0;n>1)),s=0,a=function(h){o[s++]=h},n=0;no.length){var f=new B(s+8+(i-n<<1));f.set(o),o=f}var c=t.charCodeAt(n);c<128||e?a(c):c<2048?(a(192|c>>6),a(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|t.charCodeAt(++n)&1023,a(240|c>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|c&63)):(a(224|c>>12),a(128|c>>6&63),a(128|c&63))}return Le(o,0,s)}function Tn(t,e){if(e){for(var r="",n=0;n65535&&q(9),e+=n+4}return e},Lr=function(t,e,r,n,i,o,s,a){var f=n.length,c=r.extra,h=a&&a.length,l=Mt(c);X(t,e,s!=null?33639248:67324752),e+=4,s!=null&&(t[e++]=20,t[e++]=r.os),t[e]=20,e+=2,t[e++]=r.flag<<1|(o<0&&8),t[e++]=i&&8,t[e++]=r.compression&255,t[e++]=r.compression>>8;var p=new Date(r.mtime==null?Date.now():r.mtime),v=p.getFullYear()-1980;if((v<0||v>119)&&q(10),X(t,e,v<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,o!=-1&&(X(t,e,r.crc),X(t,e+4,o<0?-o-2:o),X(t,e+8,r.size)),X(t,e+12,f),X(t,e+14,l),e+=16,s!=null&&(X(t,e,h),X(t,e+6,r.attrs),X(t,e+10,s),e+=14),t.set(n,e),e+=f,l)for(var x in c){var g=c[x],y=g.length;X(t,e,+x),X(t,e+2,y),t.set(g,e+4),e+=4+y}return h&&(t.set(a,e),e+=h),e},Bn=function(t,e,r,n,i){X(t,e,101010256),X(t,e+8,r),X(t,e+10,r),X(t,e+12,n),X(t,e+16,i)};function _r(t,e,r){r||(r=e,e={}),typeof r!="function"&&q(7);var n={};jr(t,"",n,e);var i=Object.keys(n),o=i.length,s=0,a=0,f=o,c=new Array(o),h=[],l=function(){for(var y=0;y65535&&S(q(11,0,1),null),!V)S(null,C);else if(L<16e4)try{S(null,Ft(C,E))}catch(P){S(P,null)}else h.push(Sn(C,E,S))},g=0;g65558)return s(q(13,0,1),null),i;var f=me(t,a+8);if(f){var c=f,h=ce(t,a+16),l=h==4294967295||c==65535;if(l){var p=ce(t,a-12);l=ce(t,p)==101075792,l&&(c=f=ce(t,p+32),h=ce(t,p+48))}for(var v=e&&e.filter,x=function(y){var D=Fn(t,h,l),T=D[0],C=D[1],E=D[2],A=D[3],L=D[4],b=D[5],w=zn(t,b);h=L;var m=function(O,F){O?(i(),s(O,null)):(F&&(o[A]=F),--f||s(null,o))};if(!v||v({name:A,size:C,originalSize:E,compression:T}))if(!T)m(null,Le(t,w,w+C));else if(T==8){var k=t.subarray(w,w+C);if(E<524288||C>.8*E)try{m(null,It(k,{out:new B(E)}))}catch(O){m(O,null)}else n.push(Mn(k,{size:E},m))}else m(q(14,"unknown compression type "+T,1),null);else m(null,null)},g=0;g{t.terminate();let e=new xe(t.lufiFile);return R.fromPromise(new Promise((r,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(be[e.lufiFile.keys.client].uploadStatus=0,r(e)),i.data.event==="OPERATION_FAILED"&&n(new ue("An error occured while trying to cancel an upload",{cause:i.data.error}))}).requestMessage({action:2,args:{lufiFile:e.lufiFile}})}),r=>J(r))},Gr=(t,e={})=>{let r=async n=>{var i;for(let o of n){let s=((i=o.name.split("/"))==null?void 0:i.pop())||o.name,a=s.split(".").shift(),f=s.split(".").pop(),c=s;if(e[c]!==void 0){let h=1;do c=`${a}_(${h}).${f}`,h++;while(e[c]!==void 0)}jt.emit("ARCHIVE_ADDED_FILE",{name:c,size:o.size}),e[c]=await o.bytes()}};return R.fromPromise(r(t),n=>J(n)).andThen(()=>Z(e))},Hr=(t,e)=>{let r=()=>new Promise((n,i)=>{_r(t,(o,s)=>{o&&i(o),n(s)})});return R.fromPromise(r(),n=>n).andThen(n=>{try{return Z(new File([new Blob([n])],e,{type:"application/zip"}))}catch(i){return H(i)}}).orElse(n=>H(new ht(void 0,{cause:J(n)})))},Nn=t=>{let e=async()=>{let r=await t.bytes();return new Promise((n,i)=>{Nr(r,(o,s)=>{o&&i(o),n(s)})})};return R.fromPromise(e(),r=>r).andThen(r=>{try{let n=[];for(let i in r)n.push(new File([new Blob([r[i]])],i));return Z(n)}catch(n){return H(n)}}).orElse(r=>H(new lt(void 0,{cause:J(r)})))},qr=(t,e)=>e?ir(t).andThen(r=>{if(r.version.tag>"0.07.0"){let n=At()?1:0;return Dt(e,n).andThen(i=>Z(Ee.fromDownloadUrl(t,i)))}else return Z(Ee.fromDownloadUrl(t,e))}):Z(Ee.fromDownloadUrl(t)),Jn=(t,e)=>qr(t,e).andThen(r=>{let n=new xe(r);return R.fromPromise(new Promise((i,o)=>n.onMessage(s=>{Wr(i,o,n,s),s.data.event==="CHUNK_DOWNLOADED"&&(n.tmpChunks[s.data.chunk.index]=new Blob([s.data.chunk.buffer])),s.data.event==="DOWNLOAD_COMPLETE"&&(n.tmpFile=new Blob(n.tmpChunks,{type:r.type}),n.tmpChunks=[],n.complete())}).requestMessage({action:3,args:{lufiFile:r}})),i=>new pt(void 0,{cause:J(i)}))}),Gn=(t,e)=>qr(t,e).andThen(r=>Z(new xe(r))).andThen(r=>R.fromPromise(new Promise((n,i)=>{r.onMessage(o=>{o.data.event==="INFOS_RETRIEVED"&&(r.complete(),n(r)),o.data.event==="OPERATION_FAILED"&&i(new ue("An error occured while trying to retrieve informations of the file",{cause:o.data.error}))}).requestMessage({action:4,args:{lufiFile:r.lufiFile}})}),n=>new vt(void 0,{cause:J(n)}))),Hn=t=>{try{return t.status=3,Z(t.requestMessage({action:5,args:{lufiFile:t.lufiFile}}))}catch(e){return H(new mt(void 0,{cause:J(e)}))}},qn=(t,e)=>{let r=Ee.fromRemoveUrl(t,e),n=new xe(r);return R.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new ue("An error occured while trying to remove a file",{cause:s.data.error()}))}).requestMessage({action:7,args:{lufiFile:r}})}),i=>J(i))},Wn=t=>{try{return t.status=2,Z(t.requestMessage({action:8,args:{lufiFile:t.lufiFile}}))}catch(e){return H(new dt(void 0,{cause:J(e)}))}},Zn=(t,e,r=jn)=>{let n=Math.ceil(t.size/r)||1;be[e].totalChunks=n;let i=[];for(let o=0;o{let f=[];return i?e.length===1&&e[0].type==="application/zip"?f.push(Bt(t,e[0],r,n,i,s,a)):f.push(Gr(e).andThen(c=>Hr(c,o).andThen(h=>(jt.emit("ARCHIVE_CREATED",h),Bt(t,h,r,n,i,s,a))))):e.forEach(c=>{f.push(Bt(t,c,r,n,i,s,a))}),R.combine(f).orElse(c=>H(new $e(void 0,{cause:c})))},Bt=(t,e,r,n,i,o,s)=>gr(s).andThen(a=>o?Dt(o,s).andThen(f=>Z({password:f,clientKey:a})):Z({password:o,clientKey:a})).andThen(({password:a,clientKey:f})=>{be[f]=new Ee(t.toString(),{delay:r,delAtFirstView:n,zipped:i,password:a,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:f,server:""}});let c=new xe(be[f]);return Zn(e,f).asyncAndThen(h=>{be[f].uploadStatus=4;let l=new Promise((v,x)=>{c.onMessage(g=>{switch(Wr(v,x,c,g),g.data.event){case"UPLOAD_COMPLETE":c.complete(),c.lufiFile.uploadStatus=1;break}})}),p=async v=>{for(let[x,g]of v.entries()){let y=await g.arrayBuffer();c.requestMessage({action:9,args:{chunk:{buffer:y,index:x},lufiFile:be[f],algo:s}},[y])}};return R.fromPromise(p(h),v=>new ue("An error occurred while sending chunks",{cause:J(v)})).andThen(()=>R.fromPromise(l,v=>J(v)))}).orElse(h=>H(new $e("An error occured while uploading a file",{cause:h})))}),Wr=(t,e,r,n)=>{n.data.event==="SOCKET_OPENED"&&t(r),n.data.event==="OPERATION_FAILED"&&e(new ue("The job returned an error",{cause:n.data.error}))},Kn=()=>Object.values(be).filter(t=>t.uploadStatus===4),Vn=t=>Object.keys(Kn()).indexOf(t);export{Pe as CryptoAlgorithm,R as ResultAsync,le as err,H as errAsync,At as isSecureContext,_t as lufi,pe as ok,Z as okAsync}; +var Zr=Object.create;var Ke=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Vr=Object.getPrototypeOf,Yr=Object.prototype.hasOwnProperty;var Xr=(t,e,r)=>e in t?Ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Qr=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Nt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),en=(t,e)=>{for(var r in e)Ke(t,r,{get:e[r],enumerable:!0})},tn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Kr(e))!Yr.call(t,i)&&i!==r&&Ke(t,i,{get:()=>e[i],enumerable:!(n=$r(e,i))||n.enumerable});return t};var gt=(t,e,r)=>(r=t!=null?Zr(Vr(t)):{},tn(e||!t||!t.__esModule?Ke(r,"default",{value:t,enumerable:!0}):r,t));var d=(t,e,r)=>Xr(t,typeof e!="symbol"?e+"":e,r);var Et=Nt((Xn,wt)=>{"use strict";var Ce=typeof Reflect=="object"?Reflect:null,Jt=Ce&&typeof Ce.apply=="function"?Ce.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Ve;Ce&&typeof Ce.ownKeys=="function"?Ve=Ce.ownKeys:Object.getOwnPropertySymbols?Ve=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ve=function(e){return Object.getOwnPropertyNames(e)};function rn(t){console&&console.warn&&console.warn(t)}var Ht=Number.isNaN||function(e){return e!==e};function z(){z.init.call(this)}wt.exports=z;wt.exports.once=an;z.EventEmitter=z;z.prototype._events=void 0;z.prototype._eventsCount=0;z.prototype._maxListeners=void 0;var Gt=10;function Ye(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(z,"defaultMaxListeners",{enumerable:!0,get:function(){return Gt},set:function(t){if(typeof t!="number"||t<0||Ht(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Gt=t}});z.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};z.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ht(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function qt(t){return t._maxListeners===void 0?z.defaultMaxListeners:t._maxListeners}z.prototype.getMaxListeners=function(){return qt(this)};z.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")Jt(f,this,r);else for(var c=f.length,h=Vt(f,c),n=0;n0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,rn(a)}return t}z.prototype.addListener=function(e,r){return Wt(this,e,r,!1)};z.prototype.on=z.prototype.addListener;z.prototype.prependListener=function(e,r){return Wt(this,e,r,!0)};function nn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Zt(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=nn.bind(n);return i.listener=r,n.wrapFn=i,i}z.prototype.once=function(e,r){return Ye(r),this.on(e,Zt(this,e,r)),this};z.prototype.prependOnceListener=function(e,r){return Ye(r),this.prependListener(e,Zt(this,e,r)),this};z.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Ye(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():on(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};z.prototype.off=z.prototype.removeListener;z.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i=0;i--)this.removeListener(e,r[i]);return this};function $t(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?sn(i):Vt(i,i.length)}z.prototype.listeners=function(e){return $t(this,e,!0)};z.prototype.rawListeners=function(e){return $t(this,e,!1)};z.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Kt.call(t,e)};z.prototype.listenerCount=Kt;function Kt(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}z.prototype.eventNames=function(){return this._eventsCount>0?Ve(this._events):[]};function Vt(t,e){for(var r=new Array(e),n=0;n{"use strict";var u={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};u.cipher.aes=function(t){this.w[0][0][0]||this.C();var e,r,n,i,o=this.w[0][4],s=this.w[1];e=t.length;var a=1;if(e!==4&&e!==6&&e!==8)throw new u.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),i=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[r&255],t%e===0&&(r=r<<8^r>>>24^a<<24,a=a<<1^283*(a>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[e&3?t:t-4],i[e]=4>=t||4>e?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[r&255]]};u.cipher.aes.prototype={encrypt:function(t){return cr(this,t,0)},decrypt:function(t){return cr(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],i,o,s,a=[],f=[],c,h,l,p;for(i=0;256>i;i++)f[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=c||1,s=f[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[o]=l,n[l]=o,h=a[i=a[c=a[o]]],p=16843009*h^65537*i^257*c^16843008*o,h=257*a[l]^16843008*l,i=0;4>i;i++)t[i][o]=h=h<<24^h>>>8,e[i][l]=p=p<<24^p>>>8;for(i=0;5>i;i++)t[i]=t[i].slice(0),e[i]=e[i].slice(0)}};function cr(t,e,r){if(e.length!==4)throw new u.exception.invalid("invalid aes block size");var n=t.b[r],i=e[0]^n[0],o=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,f,c,h=n.length/4-2,l,p=4,v=[0,0,0,0];a=t.w[r],t=a[0];var x=a[1],g=a[2],y=a[3],D=a[4];for(l=0;l>>24]^x[o>>16&255]^g[s>>8&255]^y[e&255]^n[p],f=t[o>>>24]^x[s>>16&255]^g[e>>8&255]^y[i&255]^n[p+1],c=t[s>>>24]^x[e>>16&255]^g[i>>8&255]^y[o&255]^n[p+2],e=t[e>>>24]^x[i>>16&255]^g[o>>8&255]^y[s&255]^n[p+3],p+=4,i=a,o=f,s=c;for(l=0;4>l;l++)v[r?3&-l:l]=D[i>>>24]<<24^D[o>>16&255]<<16^D[s>>8&255]<<8^D[e&255]^n[p++],a=i,i=o,o=s,s=e,e=a;return v}u.bitArray={bitSlice:function(t,e,r){return t=u.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:u.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return((e+r-1^e)&-32?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return t===32?e:(r?e|0:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(u.bitArray.bitLength(t)!==u.bitArray.bitLength(e))return!1;var r=0,n;for(n=0;n>>e),r=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=u.bitArray.getPartial(i),n.push(u.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};u.codec.utf8String={fromBits:function(t){var e="",r=u.bitArray.bitLength(t),n,i;for(n=0;n>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>i)>>>26),6>i?(s=t[r]<<6-i,i+=26,r++):(s<<=6,i-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,i=0,o=u.codec.base64.S,s=0,a;for(e&&(o=o.substr(0,62)+"-_"),n=0;na)throw new u.exception.invalid("this isn't base64!");26>>i),s=a<<32-i):(i+=6,s^=a<<32-i)}return i&56&&r.push(u.bitArray.partial(i&56,s,1)),r}};u.codec.base64url={fromBits:function(t){return u.codec.base64.fromBits(t,1,1)},toBits:function(t){return u.codec.base64.toBits(t,1)}};u.hash.sha256=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};u.hash.sha256.hash=function(t){return new u.hash.sha256().update(t).finalize()};u.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=u.codec.utf8String.toBits(t));var e,r=this.f=u.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+u.bitArray.bitLength(t),9007199254740991e;r++){for(i=!0,n=2;n*n<=r;n++)if(r%n===0){i=!1;break}i&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,i=this.g,o=this.b,s=i[0],a=i[1],f=i[2],c=i[3],h=i[4],l=i[5],p=i[6],v=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+v+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(p^h&(l^p))+o[e],v=p,p=l,l=h,h=c+r|0,c=f,f=a,a=s,s=r+(a&f^c&(a^f))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+f|0,i[3]=i[3]+c|0,i[4]=i[4]+h|0,i[5]=i[5]+l|0,i[6]=i[6]+p|0,i[7]=i[7]+v|0}};u.hash.sha512=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};u.hash.sha512.hash=function(t){return new u.hash.sha512().update(t).finalize()};u.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=u.codec.utf8String.toBits(t));var e,r=this.f=u.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+u.bitArray.bitLength(t),9007199254740991r;n++){for(o=!0,i=2;i*i<=n;i++)if(n%i===0){o=!1;break}o&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,i=this.b,o=n[0],s=n[1],a=n[2],f=n[3],c=n[4],h=n[5],l=n[6],p=n[7],v=n[8],x=n[9],g=n[10],y=n[11],D=n[12],T=n[13],C=n[14],E=n[15],A;if(typeof Uint32Array<"u"){A=Array(160);for(var L=0;32>L;L++)A[L]=t[L]}else A=t;var L=o,b=s,w=a,m=f,k=c,O=h,F=l,V=p,S=v,P=x,j=g,M=y,W=D,G=T,de=C,$=E;for(t=0;80>t;t++){if(16>t)e=A[2*t],r=A[2*t+1];else{r=A[2*(t-15)];var I=A[2*(t-15)+1];e=(I<<31|r>>>1)^(I<<24|r>>>8)^r>>>7;var Y=(r<<31|I>>>1)^(r<<24|I>>>8)^(r<<25|I>>>7);r=A[2*(t-2)];var _=A[2*(t-2)+1],I=(_<<13|r>>>19)^(r<<3|_>>>29)^r>>>6,_=(r<<13|_>>>19)^(_<<3|r>>>29)^(r<<26|_>>>6),re=A[2*(t-7)],te=A[2*(t-16)],ne=A[2*(t-16)+1];r=Y+A[2*(t-7)+1],e=e+re+(r>>>0>>0?1:0),r+=_,e+=I+(r>>>0<_>>>0?1:0),r+=ne,e+=te+(r>>>0>>0?1:0)}A[2*t]=e|=0,A[2*t+1]=r|=0;var re=S&j^~S&W,Q=P&M^~P&G,_=L&w^L&k^w&k,N=b&m^b&O^m&O,te=(b<<4|L>>>28)^(L<<30|b>>>2)^(L<<25|b>>>7),ne=(L<<4|b>>>28)^(b<<30|L>>>2)^(b<<25|L>>>7),we=i[2*t],Ae=i[2*t+1],I=$+((S<<18|P>>>14)^(S<<14|P>>>18)^(P<<23|S>>>9)),Y=de+((P<<18|S>>>14)^(P<<14|S>>>18)^(S<<23|P>>>9))+(I>>>0<$>>>0?1:0),I=I+Q,Y=Y+(re+(I>>>0>>0?1:0)),I=I+Ae,Y=Y+(we+(I>>>0>>0?1:0)),I=I+r|0,Y=Y+(e+(I>>>0>>0?1:0));r=ne+N,e=te+_+(r>>>0>>0?1:0),de=W,$=G,W=j,G=M,j=S,M=P,P=V+I|0,S=F+Y+(P>>>0>>0?1:0)|0,F=k,V=O,k=w,O=m,w=L,m=b,b=I+r|0,L=Y+e+(b>>>0>>0?1:0)|0}s=n[1]=s+b|0,n[0]=o+L+(s>>>0>>0?1:0)|0,f=n[3]=f+m|0,n[2]=a+w+(f>>>0>>0?1:0)|0,h=n[5]=h+O|0,n[4]=c+k+(h>>>0>>0?1:0)|0,p=n[7]=p+V|0,n[6]=l+F+(p>>>0>>0?1:0)|0,x=n[9]=x+P|0,n[8]=v+S+(x>>>0

>>0?1:0)|0,y=n[11]=y+M|0,n[10]=g+j+(y>>>0>>0?1:0)|0,T=n[13]=T+G|0,n[12]=D+W+(T>>>0>>0?1:0)|0,E=n[15]=E+$|0,n[14]=C+de+(E>>>0<$>>>0?1:0)|0}};u.mode.ccm={name:"ccm",F:[],listenProgress:function(t){u.mode.ccm.F.push(t)},unListenProgress:function(t){t=u.mode.ccm.F.indexOf(t),-1f)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&c>>>8*o;o++);return o<15-f&&(o=15-f),r=a.clamp(r,8*(15-o)),e=u.mode.ccm.U(t,e,r,n,i,o),s=u.mode.ccm.V(t,s,r,e,i,o),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o=u.bitArray,s=o.bitLength(r)/8,c=o.bitLength(e),a=o.clamp(e,c-i),f=o.bitSlice(e,c-i),c=(c-i)/8;if(7>s)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&c>>>8*e;e++);if(e<15-s&&(e=15-s),r=o.clamp(r,8*(15-e)),a=u.mode.ccm.V(t,a,r,f,i,e),t=u.mode.ccm.U(t,a.data,r,n,i,e),!o.equal(a.tag,t))throw new u.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,i,o){var s=[],a=u.bitArray,f=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|o-1)],n=a.concat(n,r),n[3]|=i,n=t.encrypt(n),e.length)for(r=a.bitLength(e)/8,65279>=r?s=[a.partial(16,r)]:4294967295>=r&&(s=a.concat([a.partial(16,65534)],[r])),s=a.concat(s,e),e=0;ei||16h&&(u.mode.ccm.da(s/f),h+=l),r[3]++,i=t.encrypt(r),e[s]^=i[0],e[s+1]^=i[1],e[s+2]^=i[2],e[s+3]^=i[3];return{tag:n,data:a.clamp(e,c)}}};u.misc.hmac=function(t,e){this.W=e=e||u.hash.sha256;var r=[[],[]],n,i=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>i&&(t=e.hash(t)),n=0;nn||0>r)throw new u.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=u.codec.utf8String.toBits(t)),typeof e=="string"&&(e=u.codec.utf8String.toBits(e)),i=i||u.misc.hmac,t=new i(t);var o,s,a,f,c=[],h=u.bitArray;for(f=1;32*c.length<(n||1);f++){for(i=o=t.encrypt(h.concat(e,[f])),s=1;ss;s++)i.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=o),this.N++,this.b=u.hash.sha256.hash(this.b.concat(i)),this.K=new u.cipher.aes(this.b),n=0;4>n&&(this.m[n]=this.m[n]+1|0,!this.m[n]);n++);}for(n=0;n>>1;this.h[s].update([n,this.M++,2,e,o,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,o,t.length]),this.h[s].update(t);break;default:f=1}if(f)throw new u.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=e,this.i+=e,a===this.A&&(this.isReady()!==this.A&&hr("seeded",Math.max(this.u,this.i)),hr("progress",this.getProgress()))},isReady:function(t){return t=this.R[t!==void 0?t:this.L],this.u&&this.u>=t?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=t?this.I|this.A:this.A},getProgress:function(t){return t=this.R[t||this.L],this.u>=t||this.i>t?1:this.i/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:_e(this,this.la),mouseCollector:_e(this,this.na),keyboardCollector:_e(this,this.ja),accelerometerCollector:_e(this,this.ca),touchCollector:_e(this,this.pa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new u.exception.bug("can't attach event");this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.J[t][this.ea++]=e},removeEventListener:function(t,e){var r,n,i=this.J[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function _e(t,e){return function(){e.apply(t,arguments)}}u.random=new u.prng(6);e:try{if(tt=typeof Se<"u"&&Se.exports){try{rt=Qr("crypto")}catch{rt=null}tt=et=rt}if(tt&&et.randomBytes)Ne=et.randomBytes(128),Ne=new Uint32Array(new Uint8Array(Ne).buffer),u.random.addEntropy(Ne,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Je=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Je);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Je);else break e;u.random.addEntropy(Je,1024,"crypto['getRandomValues']")}}catch(t){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}var Ne,et,Je,tt,rt;u.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(t,e,r,n){r=r||{},n=n||{};var i=u.json,o=i.j({iv:u.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=u.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=u.codec.base64.toBits(o.iv)),!u.mode[o.mode]||!u.cipher[o.cipher]||typeof t=="string"&&100>=o.iter||o.ts!==64&&o.ts!==96&&o.ts!==128||o.ks!==128&&o.ks!==192&&o.ks!==256||2>o.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4Gr,cancel:()=>_n,compress:()=>Hr,decompress:()=>Nn,download:()=>Jn,events:()=>jt,getFileIndexInQueue:()=>Vn,infos:()=>Gn,pause:()=>Hn,remove:()=>qn,resume:()=>Wn,upload:()=>$n});var Jr=gt(Et());var fn={withStackTrace:!1},er=(t,e,r=fn)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},i=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:i}};function Oe(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{c(n.next(h))}catch(l){s(l)}}function f(h){try{c(n.throw(h))}catch(l){s(l)}}function c(h){h.done?o(h.value):i(h.value).then(a,f)}c((n=n.apply(t,e||[])).next())})}function Xt(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(t){return this instanceof he?(this.v=t,this):new he(t)}function Qt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(v){return function(x){return Promise.resolve(x).then(v,l)}}function a(v,x){n[v]&&(i[v]=function(g){return new Promise(function(y,D){o.push([v,g,y,D])>1||f(v,g)})},x&&(i[v]=x(i[v])))}function f(v,x){try{c(n[v](x))}catch(g){p(o[0][3],g)}}function c(v){v.value instanceof he?Promise.resolve(v.value.v).then(h,l):p(o[0][2],v)}function h(v){f("next",v)}function l(v){f("throw",v)}function p(v,x){v(x),o.shift(),o.length&&f(o[0][0],o[0][1])}}function cn(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,o){e[i]=t[i]?function(s){return(r=!r)?{value:he(t[i](s)),done:!1}:o?o(s):s}:o}}function hn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Xt=="function"?Xt(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(a,f){s=t[o](s),i(a,f,s.done,s.value)})}}function i(o,s,a,f){Promise.resolve(f).then(function(c){o({value:c,done:a})},s)}}var R=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new ie(n));return new t(r)}static fromPromise(e,r){let n=e.then(i=>new ie(i)).catch(i=>new oe(r(i)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(Oe(this,void 0,void 0,function*(){try{return new ie(yield e(...n))}catch(i){return new oe(r?r(i):i)}}))}static combine(e){return ln(e)}static combineWithAllErrors(e){return pn(e)}map(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){return r.isErr()?new oe(r.error):new ie(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){if(r.isErr())return new oe(r.error);let n=yield e(r.value);return n.isErr()?new oe(n.error):new ie(r.value)})))}andTee(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){if(r.isErr())return new oe(r.error);try{yield e(r.value)}catch{}return new ie(r.value)})))}mapErr(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){return r.isOk()?new ie(r.value):new oe(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new oe(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>Oe(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new ie(r.value)})))}match(e,r){return this._promise.then(n=>n.match(e,r))}unwrapOr(e){return this._promise.then(r=>r.unwrapOr(e))}safeUnwrap(){return Qt(this,arguments,function*(){return yield he(yield he(yield*cn(hn(yield he(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Qt(this,arguments,function*(){let r=yield he(this._promise);return r.isErr()&&(yield yield he(H(r.error))),yield he(r.value)})}},Z=t=>new R(Promise.resolve(new ie(t))),H=t=>new R(Promise.resolve(new oe(t))),Qn=R.fromPromise,ei=R.fromSafePromise,ti=R.fromThrowable,tr=t=>{let e=pe([]);for(let r of t)if(r.isErr()){e=le(r.error);break}else e.map(n=>n.push(r.value));return e},ln=t=>R.fromSafePromise(Promise.all(t)).andThen(tr),rr=t=>{let e=pe([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=le([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},pn=t=>R.fromSafePromise(Promise.all(t)).andThen(rr),xt;(function(t){function e(i,o){return(...s)=>{try{let a=i(...s);return pe(a)}catch(a){return le(o?o(a):a)}}}t.fromThrowable=e;function r(i){return tr(i)}t.combine=r;function n(i){return rr(i)}t.combineWithAllErrors=n})(xt||(xt={}));var pe=t=>new ie(t);function le(t){return new oe(t)}var ie=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return pe(e(this.value))}mapErr(e){return pe(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(r=>this.value)}andTee(e){try{e(this.value)}catch{}return pe(this.value)}orElse(e){return pe(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return R.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,r){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw er("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},oe=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return le(this.error)}mapErr(e){return le(e(this.error))}andThrough(e){return le(this.error)}andTee(e){return le(this.error)}andThen(e){return le(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return H(this.error)}asyncAndThrough(e){return H(this.error)}asyncMap(e){return H(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield le(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw er("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},ri=xt.fromThrowable;var Ee=class t{constructor(e,r){d(this,"actionToken","");d(this,"chunksReady",0);d(this,"createdAt",0);d(this,"delay",0);d(this,"delAtFirstView",!1);d(this,"keys",{client:"",server:""});d(this,"name","");d(this,"password","");d(this,"queueIndex",0);d(this,"serverUrl");d(this,"size",0);d(this,"uploadStatus",3);d(this,"totalChunks",0);d(this,"type","");d(this,"zipped",!1);this.serverUrl=e,Object.assign(this,r)}downloadUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}r/${this.keys.server}#${this.keys.client}`)}removeUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}d/${this.keys.server}/${this.actionToken}`)}static fromDownloadUrl(e,r=""){let n=e.pathname.split("r/"),i={client:e.hash.slice(1).split("&")[0],server:n[1]};return new t(e.origin+n[0],{keys:i,password:r})}static fromRemoveUrl(e,r=""){let n=e.pathname.split("d/"),i=n[1].split("/"),o={client:"",server:i[0]};return new t(e.origin+n[0],{keys:o,password:r,actionToken:i[1]})}};var ar=gt(Et());var K=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});d(this,"context");this.name=this.constructor.name,this.context=o}};var Xe=class extends K{constructor(){super(...arguments);d(this,"message","Unable to connect. Is the computer able to access the url?")}};var Qe=class extends K{constructor(){super(...arguments);d(this,"message","The server returned an error")}};var J=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)},ir=t=>{let e=t.href.match(/(.*?)\/?(?:\/[dr]{1}\/|login\/?|files\/?)/),r=e&&e[1]?e[1]:t.origin;return R.fromPromise(fetch(r+"/about/config"),n=>new Xe(void 0,{cause:J(n)})).andThen(n=>n.ok?R.fromPromise(n.json(),i=>J(i)):H(new Qe(void 0,{context:n.statusText})))},or=()=>typeof Deno<"u",At=()=>or()||globalThis.isSecureContext||globalThis.location.protocol==="https:",sr=t=>or()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t==="main"?`worker/${t}`:t}.js`));var xe=class{constructor(e){d(this,"events",new ar.default);d(this,"lufiFile");d(this,"status",2);d(this,"downloadedFile");d(this,"tmpChunks",[]);d(this,"worker");d(this,"isTerminated",!1);d(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});d(this,"hasFailed",()=>this.status===1);d(this,"onError",e=>(this.worker.onerror=r=>{e(r)},this));d(this,"onMessage",e=>(this.worker.onmessage=r=>{e&&e(r);let n=r.data.event;n&&(n==="FILE_UPDATED"?Object.assign(this.lufiFile,r.data.lufiFile):this.dispatchEvent(n,r.data.error))},this));d(this,"onMessageError",e=>(this.worker.onmessageerror=r=>{e(r)},this));d(this,"onProgress",e=>(this.events.on("CHUNK_UPLOADED",()=>{e()}),this.events.on("CHUNK_DOWNLOADED",()=>{e()}),this));d(this,"requestMessage",(e,r=[])=>(this.worker.postMessage(e,r),this));d(this,"terminate",()=>(this.worker.terminate(),this));d(this,"waitForCompletion",()=>this.isTerminated?this.status===0?Z(this):H(J("Job has failed")):R.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>J(e)));d(this,"dispatchEvent",(e,r)=>{this.events.emit(e,r)});this.worker=new Worker(sr("main"),{type:"module"}),this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",r=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",r)}),this.onError(r=>console.error(r.error))}};var Pe=(r=>(r[r.Sjcl=0]="Sjcl",r[r.WebCrypto=1]="WebCrypto",r))(Pe||{});var ke=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),i="";for(let o=0;o>2]+this._charset[(n[o]&3)<<4|n[o+1]>>4]+this._charset[(n[o+1]&15)<<2|n[o+2]>>6]+this._charset[n[o+2]&63];return r%3==2?(i=i.substring(0,i.length-1),this._noPadding||(i+="=")):r%3==1&&(i=i.substring(0,i.length-2),this._noPadding||(i+="==")),i}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),i,o,s,a,f=0,c=0;for(;f>4,n[f++]=(o&15)<<4|s>>2,n[f++]=(s&3)<<6|a;return n.buffer}};var Ri=new ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var dn=new ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function Lt(t){return dn.Encode(t)}var Ge=gt(pr());var fe=class extends K{};var Me=class extends fe{constructor(){super(...arguments);d(this,"message","Unable to hash the provided string")}};var vr=()=>{try{return Z(Ge.default.codec.base64.fromBits(Ge.default.random.randomWords(8,10)))}catch(t){return H(new fe("Unable to generate key",{cause:J(t)}))}},mr=t=>{try{return Z(Ge.default.codec.hex.fromBits(Ge.default.hash.sha512.hash(t)))}catch(e){return H(new Me(void 0,{cause:J(e)}))}};var dr=()=>R.fromPromise(new Promise((t,e)=>crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]).then(r=>crypto.subtle.exportKey("raw",r).then(n=>t(Lt(n))).catch(n=>{e(new fe("Unable to base64 encode the url",{cause:J(n)}))})).catch(r=>e(r))),t=>new fe("Unable to generate key",{cause:J(t)})),yr=t=>{let e=async()=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-512",new TextEncoder().encode(t)))).map(r=>r.toString(16).padStart(2,"0")).join("");return R.fromPromise(e(),r=>new Me(void 0,{cause:J(r)}))};var gr=(t=1)=>t===0?vr():dr(),Dt=(t,e)=>e===0?mr(t):yr(t);var wr={},Ln=function(t,e,r,n,i){var o=new Worker(wr[e]||(wr[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(s){var a=s.data,f=a.$e$;if(f){var c=new Error(f[0]);c.code=f[1],c.stack=f[2],i(c,null)}else i(null,a)},o.postMessage(r,n),o},B=Uint8Array,ee=Uint16Array,We=Int32Array,ze=new B([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fe=new B([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),He=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),br=function(t,e){for(var r=new ee(31),n=0;n<31;++n)r[n]=e+=1<>1|(U&21845)<<1,ye=(ye&52428)>>2|(ye&13107)<<2,ye=(ye&61680)>>4|(ye&3855)<<4,qe[U]=((ye&65280)>>8|(ye&255)<<8)>>1;var ye,U,ae=function(t,e,r){for(var n=t.length,i=0,o=new ee(e);i>f]=c}else for(a=new ee(n),i=0;i>15-t[i]);return a},ge=new B(288);for(U=0;U<144;++U)ge[U]=8;var U;for(U=144;U<256;++U)ge[U]=9;var U;for(U=256;U<280;++U)ge[U]=7;var U;for(U=280;U<288;++U)ge[U]=8;var U,Te=new B(32);for(U=0;U<32;++U)Te[U]=5;var U,Pr=ae(ge,9,0),kr=ae(ge,9,1),Sr=ae(Te,5,0),Mr=ae(Te,5,1),it=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},se=function(t,e,r){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&r},ot=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},Ze=function(t){return(t+7)/8|0},Le=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new B(t.subarray(e,r))};var Ur=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],q=function(t,e,r){var n=new Error(e||Ur[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,q),!r)throw n;return n},Rr=function(t,e,r,n){var i=t.length,o=n?n.length:0;if(!i||e.f&&!e.l)return r||new B(0);var s=!r,a=s||e.i!=2,f=e.i;s&&(r=new B(i*3));var c=function(Y){var Be=r.length;if(Y>Be){var De=new B(Math.max(Be*2,Y));De.set(r),r=De}},h=e.f||0,l=e.p||0,p=e.b||0,v=e.l,x=e.d,g=e.m,y=e.n,D=i*8;do{if(!v){h=se(t,l,1);var T=se(t,l+1,3);if(l+=3,T)if(T==1)v=kr,x=Mr,g=9,y=5;else if(T==2){var L=se(t,l,31)+257,b=se(t,l+10,15)+4,w=L+se(t,l+5,31)+1;l+=14;for(var m=new B(w),k=new B(19),O=0;O>4;if(C<16)m[O++]=C;else{var j=0,M=0;for(C==16?(M=3+se(t,l,3),l+=2,j=m[O-1]):C==17?(M=3+se(t,l,7),l+=3):C==18&&(M=11+se(t,l,127),l+=7);M--;)m[O++]=j}}var W=m.subarray(0,L),G=m.subarray(L);g=it(W),y=it(G),v=ae(W,g,1),x=ae(G,y,1)}else q(1);else{var C=Ze(l)+4,E=t[C-4]|t[C-3]<<8,A=C+E;if(A>i){f&&q(0);break}a&&c(p+E),r.set(t.subarray(C,A),p),e.b=p+=E,e.p=l=A*8,e.f=h;continue}if(l>D){f&&q(0);break}}a&&c(p+131072);for(var de=(1<>4;if(l+=j&15,l>D){f&&q(0);break}if(j||q(2),Q<256)r[p++]=Q;else if(Q==256){re=l,v=null;break}else{var _=Q-254;if(Q>264){var O=Q-257,N=ze[O];_=se(t,l,(1<>4;te||q(3),l+=te&15;var G=Or[ne];if(ne>3){var N=Fe[ne];G+=ot(t,l)&(1<D){f&&q(0);break}a&&c(p+131072);var we=p+_;if(p>8},Ue=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8,t[n+2]|=r>>16},st=function(t,e){for(var r=[],n=0;np&&(p=o[n].s);var v=new ee(p+1),x=ut(r[h-1],v,0);if(x>e){var n=0,g=0,y=x-e,D=1<e)g+=D-(1<>=y;g>0;){var C=o[n].s;v[C]=0&&g;--n){var E=o[n].s;v[E]==e&&(--v[E],++g)}x=e}return{t:new B(v),l:x}},ut=function(t,e,r){return t.s==-1?Math.max(ut(t.l,e,r+1),ut(t.r,e,r+1)):e[t.s]=r},Pt=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new ee(++e),n=0,i=t[0],o=1,s=function(f){r[n++]=f},a=1;a<=e;++a)if(t[a]==i&&a!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=t[a]}return{c:r.subarray(0,n),n:e}},Re=function(t,e){for(var r=0,n=0;n>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var o=0;o4&&!k[He[F-1]];--F);var V=c+5<<3,S=Re(i,ge)+Re(o,Te)+s,P=Re(i,p)+Re(o,g)+s+14+3*F+Re(b,k)+2*b[16]+3*b[17]+7*b[18];if(f>=0&&V<=S&&V<=P)return Rt(e,h,t.subarray(f,f+c));var j,M,W,G;if(ve(e,h,1+(P15&&(ve(e,h,Q[w]>>5&127),h+=Q[w]>>12)}}else j=Pr,M=ge,W=Sr,G=Te;for(var w=0;w255){var _=N>>18&31;Ue(e,h,j[_+257]),h+=M[_+257],_>7&&(ve(e,h,N>>23&31),h+=ze[_]);var te=N&31;Ue(e,h,W[te]),h+=G[te],te>3&&(Ue(e,h,N>>5&8191),h+=Fe[te])}else Ue(e,h,j[N]),h+=M[N]}return Ue(e,h,j[256]),h+M[256]},Tr=new We([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Tt=new B(0),zr=function(t,e,r,n,i,o){var s=o.z||t.length,a=new B(n+s+5*(1+Math.ceil(s/7e3))+i),f=a.subarray(n,a.length-i),c=o.l,h=(o.r||0)&7;if(e){h&&(f[0]=o.r>>3);for(var l=Tr[e-1],p=l>>13,v=l&8191,x=(1<7e3||k>24576)&&(j>423||!c)){h=kt(t,f,0,E,A,L,w,k,F,m-F,h),k=b=w=0,F=m;for(var M=0;M<286;++M)A[M]=0;for(var M=0;M<30;++M)L[M]=0}var W=2,G=0,de=v,$=S-P&32767;if(j>2&&V==C(m-$))for(var re=Math.min(p,j)-1,Q=Math.min(32767,m),_=Math.min(258,j);$<=Q&&--de&&S!=P;){if(t[m+W]==t[m+W-$]){for(var N=0;N<_&&t[m+N]==t[m+N-$];++N);if(N>W){if(W=N,G=$,N>re)break;for(var te=Math.min($,N-2),ne=0,M=0;Mne&&(ne=I,P=we)}}}S=P,P=g[S],$+=S-P&32767}if(G){E[k++]=268435456|at[W]<<18|Ot[G];var Y=at[W]&31,Be=Ot[G]&31;w+=ze[Y]+Fe[Be],++A[257+Y],++L[Be],O=m+W,++b}else E[k++]=t[m],++A[t[m]]}}for(m=Math.max(m,O);m=s&&(f[h/8|0]=c,De=s),h=Rt(f,h+1,t.subarray(m,De))}o.i=s}return Le(a,0,n+Ze(h)+i)},bn=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var r=e,n=9;--n;)r=(r&1&&-306674912)^r>>>1;t[e]=r}return t}(),Dn=function(){var t=-1;return{p:function(e){for(var r=t,n=0;n>>8;t=r},d:function(){return~t}}};var Fr=function(t,e,r,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),s=new B(o.length+t.length);s.set(o),s.set(t,o.length),t=s,i.w=o.length}return zr(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,r,n,i)},zt=function(t,e){var r={};for(var n in t)r[n]=t[n];for(var n in e)r[n]=e[n];return r},Er=function(t,e,r){for(var n=t(),i=t.toString(),o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s>>0},Ct=function(t,e){return ce(t,e)+ce(t,e+4)*4294967296},X=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8};function Sn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&q(7),Br(t,e,[kn],function(n){return ct(Ft(n.data[0],n.data[1]))},0,r)}function Ft(t,e){return Fr(t,e||{},0,0)}function Mn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&q(7),Br(t,e,[Pn],function(n){return ct(It(n.data[0],Ir(n.data[1])))},1,r)}function It(t,e){return Rr(t,{i:2},e&&e.out,e&&e.dictionary)}var jr=function(t,e,r,n){for(var i in t){var o=t[i],s=e+i,a=n;Array.isArray(o)&&(a=zt(n,o[1]),o=o[0]),o instanceof B?r[s]=[o,a]:(r[s+="/"]=[new B(0),a],jr(o,s,r,n))}},xr=typeof TextEncoder<"u"&&new TextEncoder,St=typeof TextDecoder<"u"&&new TextDecoder,Un=0;try{St.decode(Tt,{stream:!0}),Un=1}catch{}var Rn=function(t){for(var e="",r=0;;){var n=t[r++],i=(n>127)+(n>223)+(n>239);if(r+i>t.length)return{s:e,r:Le(t,r-1)};i?i==3?(n=((n&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|t[r++]&63):e+=String.fromCharCode((n&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(n)}};function Ar(t,e){if(e){for(var r=new B(t.length),n=0;n>1)),s=0,a=function(h){o[s++]=h},n=0;no.length){var f=new B(s+8+(i-n<<1));f.set(o),o=f}var c=t.charCodeAt(n);c<128||e?a(c):c<2048?(a(192|c>>6),a(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|t.charCodeAt(++n)&1023,a(240|c>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|c&63)):(a(224|c>>12),a(128|c>>6&63),a(128|c&63))}return Le(o,0,s)}function Tn(t,e){if(e){for(var r="",n=0;n65535&&q(9),e+=n+4}return e},Lr=function(t,e,r,n,i,o,s,a){var f=n.length,c=r.extra,h=a&&a.length,l=Mt(c);X(t,e,s!=null?33639248:67324752),e+=4,s!=null&&(t[e++]=20,t[e++]=r.os),t[e]=20,e+=2,t[e++]=r.flag<<1|(o<0&&8),t[e++]=i&&8,t[e++]=r.compression&255,t[e++]=r.compression>>8;var p=new Date(r.mtime==null?Date.now():r.mtime),v=p.getFullYear()-1980;if((v<0||v>119)&&q(10),X(t,e,v<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,o!=-1&&(X(t,e,r.crc),X(t,e+4,o<0?-o-2:o),X(t,e+8,r.size)),X(t,e+12,f),X(t,e+14,l),e+=16,s!=null&&(X(t,e,h),X(t,e+6,r.attrs),X(t,e+10,s),e+=14),t.set(n,e),e+=f,l)for(var x in c){var g=c[x],y=g.length;X(t,e,+x),X(t,e+2,y),t.set(g,e+4),e+=4+y}return h&&(t.set(a,e),e+=h),e},Bn=function(t,e,r,n,i){X(t,e,101010256),X(t,e+8,r),X(t,e+10,r),X(t,e+12,n),X(t,e+16,i)};function _r(t,e,r){r||(r=e,e={}),typeof r!="function"&&q(7);var n={};jr(t,"",n,e);var i=Object.keys(n),o=i.length,s=0,a=0,f=o,c=new Array(o),h=[],l=function(){for(var y=0;y65535&&S(q(11,0,1),null),!V)S(null,C);else if(L<16e4)try{S(null,Ft(C,E))}catch(P){S(P,null)}else h.push(Sn(C,E,S))},g=0;g65558)return s(q(13,0,1),null),i;var f=me(t,a+8);if(f){var c=f,h=ce(t,a+16),l=h==4294967295||c==65535;if(l){var p=ce(t,a-12);l=ce(t,p)==101075792,l&&(c=f=ce(t,p+32),h=ce(t,p+48))}for(var v=e&&e.filter,x=function(y){var D=Fn(t,h,l),T=D[0],C=D[1],E=D[2],A=D[3],L=D[4],b=D[5],w=zn(t,b);h=L;var m=function(O,F){O?(i(),s(O,null)):(F&&(o[A]=F),--f||s(null,o))};if(!v||v({name:A,size:C,originalSize:E,compression:T}))if(!T)m(null,Le(t,w,w+C));else if(T==8){var k=t.subarray(w,w+C);if(E<524288||C>.8*E)try{m(null,It(k,{out:new B(E)}))}catch(O){m(O,null)}else n.push(Mn(k,{size:E},m))}else m(q(14,"unknown compression type "+T,1),null);else m(null,null)},g=0;g{t.terminate();let e=new xe(t.lufiFile);return R.fromPromise(new Promise((r,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(be[e.lufiFile.keys.client].uploadStatus=0,r(e)),i.data.event==="OPERATION_FAILED"&&n(new ue("An error occured while trying to cancel an upload",{cause:i.data.error}))}).requestMessage({action:2,args:{lufiFile:e.lufiFile}})}),r=>J(r))},Gr=(t,e={})=>{let r=async n=>{var i;for(let o of n){let s=((i=o.name.split("/"))==null?void 0:i.pop())||o.name,a=s.split(".").shift(),f=s.split(".").pop(),c=s;if(e[c]!==void 0){let h=1;do c=`${a}_(${h}).${f}`,h++;while(e[c]!==void 0)}jt.emit("ARCHIVE_ADDED_FILE",{name:c,size:o.size}),e[c]=await o.bytes()}};return R.fromPromise(r(t),n=>J(n)).andThen(()=>Z(e))},Hr=(t,e)=>{let r=()=>new Promise((n,i)=>{_r(t,(o,s)=>{o&&i(o),n(s)})});return R.fromPromise(r(),n=>n).andThen(n=>{try{return Z(new File([new Blob([n])],e,{type:"application/zip"}))}catch(i){return H(i)}}).orElse(n=>H(new ht(void 0,{cause:J(n)})))},Nn=t=>{let e=async()=>{let r=await t.bytes();return new Promise((n,i)=>{Nr(r,(o,s)=>{o&&i(o),n(s)})})};return R.fromPromise(e(),r=>r).andThen(r=>{try{let n=[];for(let i in r)n.push(new File([new Blob([r[i]])],i));return Z(n)}catch(n){return H(n)}}).orElse(r=>H(new lt(void 0,{cause:J(r)})))},qr=(t,e)=>e?ir(t).andThen(r=>{if(r.version.tag>"0.07.0"){let n=At()?1:0;return Dt(e,n).andThen(i=>Z(Ee.fromDownloadUrl(t,i)))}else return Z(Ee.fromDownloadUrl(t,e))}):Z(Ee.fromDownloadUrl(t)),Jn=(t,e)=>qr(t,e).andThen(r=>{let n=new xe(r);return R.fromPromise(new Promise((i,o)=>n.onMessage(s=>{Wr(i,o,n,s),s.data.event==="CHUNK_DOWNLOADED"&&(n.tmpChunks[s.data.chunk.index]=new Blob([s.data.chunk.buffer])),s.data.event==="DOWNLOAD_COMPLETE"&&(n.downloadedFile=new File(n.tmpChunks,r.name,{type:r.type}),n.tmpChunks=[],n.complete())}).requestMessage({action:3,args:{lufiFile:r}})),i=>new pt(void 0,{cause:J(i)}))}),Gn=(t,e)=>qr(t,e).andThen(r=>Z(new xe(r))).andThen(r=>R.fromPromise(new Promise((n,i)=>{r.onMessage(o=>{o.data.event==="INFOS_RETRIEVED"&&(r.complete(),n(r)),o.data.event==="OPERATION_FAILED"&&i(new ue("An error occured while trying to retrieve informations of the file",{cause:o.data.error}))}).requestMessage({action:4,args:{lufiFile:r.lufiFile}})}),n=>new vt(void 0,{cause:J(n)}))),Hn=t=>{try{return t.status=3,Z(t.requestMessage({action:5,args:{lufiFile:t.lufiFile}}))}catch(e){return H(new mt(void 0,{cause:J(e)}))}},qn=(t,e)=>{let r=Ee.fromRemoveUrl(t,e),n=new xe(r);return R.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new ue("An error occured while trying to remove a file",{cause:s.data.error()}))}).requestMessage({action:7,args:{lufiFile:r}})}),i=>J(i))},Wn=t=>{try{return t.status=2,Z(t.requestMessage({action:8,args:{lufiFile:t.lufiFile}}))}catch(e){return H(new dt(void 0,{cause:J(e)}))}},Zn=(t,e,r=jn)=>{let n=Math.ceil(t.size/r)||1;be[e].totalChunks=n;let i=[];for(let o=0;o{let f=[];return i?e.length===1&&e[0].type==="application/zip"?f.push(Bt(t,e[0],r,n,i,s,a)):f.push(Gr(e).andThen(c=>Hr(c,o).andThen(h=>(jt.emit("ARCHIVE_CREATED",h),Bt(t,h,r,n,i,s,a))))):e.forEach(c=>{f.push(Bt(t,c,r,n,i,s,a))}),R.combine(f).orElse(c=>H(new $e(void 0,{cause:c})))},Bt=(t,e,r,n,i,o,s)=>gr(s).andThen(a=>o?Dt(o,s).andThen(f=>Z({password:f,clientKey:a})):Z({password:o,clientKey:a})).andThen(({password:a,clientKey:f})=>{be[f]=new Ee(t.toString(),{delay:r,delAtFirstView:n,zipped:i,password:a,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:f,server:""}});let c=new xe(be[f]);return Zn(e,f).asyncAndThen(h=>{be[f].uploadStatus=4;let l=new Promise((v,x)=>{c.onMessage(g=>{switch(Wr(v,x,c,g),g.data.event){case"UPLOAD_COMPLETE":c.complete(),c.lufiFile.uploadStatus=1;break}})}),p=async v=>{for(let[x,g]of v.entries()){let y=await g.arrayBuffer();c.requestMessage({action:9,args:{chunk:{buffer:y,index:x},lufiFile:be[f],algo:s}},[y])}};return R.fromPromise(p(h),v=>new ue("An error occurred while sending chunks",{cause:J(v)})).andThen(()=>R.fromPromise(l,v=>J(v)))}).orElse(h=>H(new $e("An error occured while uploading a file",{cause:h})))}),Wr=(t,e,r,n)=>{n.data.event==="SOCKET_OPENED"&&t(r),n.data.event==="OPERATION_FAILED"&&e(new ue("The job returned an error",{cause:n.data.error}))},Kn=()=>Object.values(be).filter(t=>t.uploadStatus===4),Vn=t=>Object.keys(Kn()).indexOf(t);export{Pe as CryptoAlgorithm,R as ResultAsync,le as err,H as errAsync,At as isSecureContext,_t as lufi,pe as ok,Z as okAsync}; diff --git a/themes/default/public/js/worker/download.js b/themes/default/public/js/worker/download.js index 0517ef1..747f440 100644 --- a/themes/default/public/js/worker/download.js +++ b/themes/default/public/js/worker/download.js @@ -1 +1 @@ -var Ar=Object.create;var it=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var Or=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var Dt=t=>{throw TypeError(t)};var _r=(t,e,r)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Dr=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var st=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Cr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Or(e))!br.call(t,o)&&o!==r&&it(t,o,{get:()=>e[o],enumerable:!(n=xr(e,o))||n.enumerable});return t};var at=(t,e,r)=>(r=t!=null?Ar(Lr(t)):{},Cr(e||!t||!t.__esModule?it(r,"default",{value:t,enumerable:!0}):r,t));var U=(t,e,r)=>_r(t,typeof e!="symbol"?e+"":e,r),ct=(t,e,r)=>e.has(t)||Dt("Cannot "+r);var d=(t,e,r)=>(ct(t,e,"read from private field"),r?r.call(t):e.get(t)),x=(t,e,r)=>e.has(t)?Dt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),g=(t,e,r,n)=>(ct(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),O=(t,e,r)=>(ct(t,e,"access private method"),r);var ze=(t,e,r,n)=>({set _(o){g(t,e,o,r)},get _(){return d(t,e,n)}});var Bt=st((vn,ut)=>{"use strict";var se=typeof Reflect=="object"?Reflect:null,Ct=se&&typeof se.apply=="function"?se.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Je;se&&typeof se.ownKeys=="function"?Je=se.ownKeys:Object.getOwnPropertySymbols?Je=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Je=function(e){return Object.getOwnPropertyNames(e)};function Sr(t){console&&console.warn&&console.warn(t)}var kt=Number.isNaN||function(e){return e!==e};function w(){w.init.call(this)}ut.exports=w;ut.exports.once=Tr;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var St=10;function He(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return St},set:function(t){if(typeof t!="number"||t<0||kt(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");St=t}});w.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};w.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||kt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Pt(t){return t._maxListeners===void 0?w.defaultMaxListeners:t._maxListeners}w.prototype.getMaxListeners=function(){return Pt(this)};w.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var u=i[e];if(u===void 0)return!1;if(typeof u=="function")Ct(u,this,r);else for(var f=u.length,h=Ut(u,f),n=0;n0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,Sr(c)}return t}w.prototype.addListener=function(e,r){return Rt(this,e,r,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(e,r){return Rt(this,e,r,!0)};function kr(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Tt(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=kr.bind(n);return o.listener=r,n.wrapFn=o,o}w.prototype.once=function(e,r){return He(r),this.on(e,Tt(this,e,r)),this};w.prototype.prependOnceListener=function(e,r){return He(r),this.prependListener(e,Tt(this,e,r)),this};w.prototype.removeListener=function(e,r){var n,o,i,s,c;if(He(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){c=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():Pr(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this};w.prototype.off=w.prototype.removeListener;w.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function It(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?Rr(o):Ut(o,o.length)}w.prototype.listeners=function(e){return It(this,e,!0)};w.prototype.rawListeners=function(e){return It(this,e,!1)};w.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Mt.call(t,e)};w.prototype.listenerCount=Mt;function Mt(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?Je(this._events):[]};function Ut(t,e){for(var r=new Array(e),n=0;n{"use strict";var a={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};a.cipher.aes=function(t){this.w[0][0][0]||this.C();var e,r,n,o,i=this.w[0][4],s=this.w[1];e=t.length;var c=1;if(e!==4&&e!==6&&e!==8)throw new a.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[r&255],t%e===0&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[e&3?t:t-4],o[e]=4>=t||4>e?r:s[0][i[r>>>24]]^s[1][i[r>>16&255]]^s[2][i[r>>8&255]]^s[3][i[r&255]]};a.cipher.aes.prototype={encrypt:function(t){return Vt(this,t,0)},decrypt:function(t){return Vt(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],o,i,s,c=[],u=[],f,h,l,m;for(o=0;256>o;o++)u[(c[o]=o<<1^283*(o>>7))^o]=o;for(i=s=0;!r[i];i^=f||1,s=u[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[i]=l,n[l]=i,h=c[o=c[f=c[i]]],m=16843009*h^65537*o^257*f^16843008*i,h=257*c[l]^16843008*l,o=0;4>o;o++)t[o][i]=h=h<<24^h>>>8,e[o][l]=m=m<<24^m>>>8;for(o=0;5>o;o++)t[o]=t[o].slice(0),e[o]=e[o].slice(0)}};function Vt(t,e,r){if(e.length!==4)throw new a.exception.invalid("invalid aes block size");var n=t.b[r],o=e[0]^n[0],i=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var c,u,f,h=n.length/4-2,l,m=4,p=[0,0,0,0];c=t.w[r],t=c[0];var A=c[1],M=c[2],F=c[3],Y=c[4];for(l=0;l>>24]^A[i>>16&255]^M[s>>8&255]^F[e&255]^n[m],u=t[i>>>24]^A[s>>16&255]^M[e>>8&255]^F[o&255]^n[m+1],f=t[s>>>24]^A[e>>16&255]^M[o>>8&255]^F[i&255]^n[m+2],e=t[e>>>24]^A[o>>16&255]^M[i>>8&255]^F[s&255]^n[m+3],m+=4,o=c,i=u,s=f;for(l=0;4>l;l++)p[r?3&-l:l]=Y[o>>>24]<<24^Y[i>>16&255]<<16^Y[s>>8&255]<<8^Y[e&255]^n[m++],c=o,o=i,i=s,s=e,e=c;return p}a.bitArray={bitSlice:function(t,e,r){return t=a.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:a.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return((e+r-1^e)&-32?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return t===32?e:(r?e|0:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(a.bitArray.bitLength(t)!==a.bitArray.bitLength(e))return!1;var r=0,n;for(n=0;n>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=a.bitArray.getPartial(o),n.push(a.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};a.codec.utf8String={fromBits:function(t){var e="",r=a.bitArray.bitLength(t),n,o;for(n=0;n>>8>>>8>>>8),o<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>o)>>>26),6>o?(s=t[r]<<6-o,o+=26,r++):(s<<=6,o-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,o=0,i=a.codec.base64.S,s=0,c;for(e&&(i=i.substr(0,62)+"-_"),n=0;nc)throw new a.exception.invalid("this isn't base64!");26>>o),s=c<<32-o):(o+=6,s^=c<<32-o)}return o&56&&r.push(a.bitArray.partial(o&56,s,1)),r}};a.codec.base64url={fromBits:function(t){return a.codec.base64.fromBits(t,1,1)},toBits:function(t){return a.codec.base64.toBits(t,1)}};a.hash.sha256=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};a.hash.sha256.hash=function(t){return new a.hash.sha256().update(t).finalize()};a.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=a.codec.utf8String.toBits(t));var e,r=this.f=a.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+a.bitArray.bitLength(t),9007199254740991e;r++){for(o=!0,n=2;n*n<=r;n++)if(r%n===0){o=!1;break}o&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,o=this.g,i=this.b,s=o[0],c=o[1],u=o[2],f=o[3],h=o[4],l=o[5],m=o[6],p=o[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+p+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(m^h&(l^m))+i[e],p=m,m=l,l=h,h=f+r|0,f=u,u=c,c=s,s=r+(c&u^f&(c^u))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+c|0,o[2]=o[2]+u|0,o[3]=o[3]+f|0,o[4]=o[4]+h|0,o[5]=o[5]+l|0,o[6]=o[6]+m|0,o[7]=o[7]+p|0}};a.hash.sha512=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};a.hash.sha512.hash=function(t){return new a.hash.sha512().update(t).finalize()};a.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=a.codec.utf8String.toBits(t));var e,r=this.f=a.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+a.bitArray.bitLength(t),9007199254740991r;n++){for(i=!0,o=2;o*o<=n;o++)if(n%o===0){i=!1;break}i&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,o=this.b,i=n[0],s=n[1],c=n[2],u=n[3],f=n[4],h=n[5],l=n[6],m=n[7],p=n[8],A=n[9],M=n[10],F=n[11],Y=n[12],Be=n[13],Lt=n[14],je=n[15],C;if(typeof Uint32Array<"u"){C=Array(160);for(var b=0;32>b;b++)C[b]=t[b]}else C=t;var b=i,R=s,ve=c,oe=u,we=f,ie=h,tt=l,ge=m,z=p,T=A,We=M,Ee=F,Fe=Y,Ae=Be,rt=Lt,xe=je;for(t=0;80>t;t++){if(16>t)e=C[2*t],r=C[2*t+1];else{r=C[2*(t-15)];var E=C[2*(t-15)+1];e=(E<<31|r>>>1)^(E<<24|r>>>8)^r>>>7;var J=(r<<31|E>>>1)^(r<<24|E>>>8)^(r<<25|E>>>7);r=C[2*(t-2)];var H=C[2*(t-2)+1],E=(H<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),nt=C[2*(t-7)],ot=C[2*(t-16)],Oe=C[2*(t-16)+1];r=J+C[2*(t-7)+1],e=e+nt+(r>>>0>>0?1:0),r+=H,e+=E+(r>>>0>>0?1:0),r+=Oe,e+=ot+(r>>>0>>0?1:0)}C[2*t]=e|=0,C[2*t+1]=r|=0;var nt=z&We^~z&Fe,bt=T&Ee^~T&Ae,H=b&ve^b&we^ve&we,gr=R&oe^R&ie^oe&ie,ot=(R<<4|b>>>28)^(b<<30|R>>>2)^(b<<25|R>>>7),Oe=(b<<4|R>>>28)^(R<<30|b>>>2)^(R<<25|b>>>7),Er=o[2*t],_t=o[2*t+1],E=xe+((z<<18|T>>>14)^(z<<14|T>>>18)^(T<<23|z>>>9)),J=rt+((T<<18|z>>>14)^(T<<14|z>>>18)^(z<<23|T>>>9))+(E>>>0>>0?1:0),E=E+bt,J=J+(nt+(E>>>0>>0?1:0)),E=E+_t,J=J+(Er+(E>>>0<_t>>>0?1:0)),E=E+r|0,J=J+(e+(E>>>0>>0?1:0));r=Oe+gr,e=ot+H+(r>>>0>>0?1:0),rt=Fe,xe=Ae,Fe=We,Ae=Ee,We=z,Ee=T,T=ge+E|0,z=tt+J+(T>>>0>>0?1:0)|0,tt=we,ge=ie,we=ve,ie=oe,ve=b,oe=R,R=E+r|0,b=J+e+(R>>>0>>0?1:0)|0}s=n[1]=s+R|0,n[0]=i+b+(s>>>0>>0?1:0)|0,u=n[3]=u+oe|0,n[2]=c+ve+(u>>>0>>0?1:0)|0,h=n[5]=h+ie|0,n[4]=f+we+(h>>>0>>0?1:0)|0,m=n[7]=m+ge|0,n[6]=l+tt+(m>>>0>>0?1:0)|0,A=n[9]=A+T|0,n[8]=p+z+(A>>>0>>0?1:0)|0,F=n[11]=F+Ee|0,n[10]=M+We+(F>>>0>>0?1:0)|0,Be=n[13]=Be+Ae|0,n[12]=Y+Fe+(Be>>>0>>0?1:0)|0,je=n[15]=je+xe|0,n[14]=Lt+rt+(je>>>0>>0?1:0)|0}};a.mode.ccm={name:"ccm",F:[],listenProgress:function(t){a.mode.ccm.F.push(t)},unListenProgress:function(t){t=a.mode.ccm.F.indexOf(t),-1u)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(i=2;4>i&&f>>>8*i;i++);return i<15-u&&(i=15-u),r=c.clamp(r,8*(15-i)),e=a.mode.ccm.U(t,e,r,n,o,i),s=a.mode.ccm.V(t,s,r,e,o,i),c.concat(s.data,s.tag)},decrypt:function(t,e,r,n,o){o=o||64,n=n||[];var i=a.bitArray,s=i.bitLength(r)/8,f=i.bitLength(e),c=i.clamp(e,f-o),u=i.bitSlice(e,f-o),f=(f-o)/8;if(7>s)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&f>>>8*e;e++);if(e<15-s&&(e=15-s),r=i.clamp(r,8*(15-e)),c=a.mode.ccm.V(t,c,r,u,o,e),t=a.mode.ccm.U(t,c.data,r,n,o,e),!i.equal(c.tag,t))throw new a.exception.corrupt("ccm: tag doesn't match");return c.data},ma:function(t,e,r,n,o,i){var s=[],c=a.bitArray,u=c.P;if(n=[c.partial(8,(e.length?64:0)|n-2<<2|i-1)],n=c.concat(n,r),n[3]|=o,n=t.encrypt(n),e.length)for(r=c.bitLength(e)/8,65279>=r?s=[c.partial(16,r)]:4294967295>=r&&(s=c.concat([c.partial(16,65534)],[r])),s=c.concat(s,e),e=0;eo||16h&&(a.mode.ccm.da(s/u),h+=l),r[3]++,o=t.encrypt(r),e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3];return{tag:n,data:c.clamp(e,f)}}};a.misc.hmac=function(t,e){this.W=e=e||a.hash.sha256;var r=[[],[]],n,o=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>o&&(t=e.hash(t)),n=0;nn||0>r)throw new a.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=a.codec.utf8String.toBits(t)),typeof e=="string"&&(e=a.codec.utf8String.toBits(e)),o=o||a.misc.hmac,t=new o(t);var i,s,c,u,f=[],h=a.bitArray;for(u=1;32*f.length<(n||1);u++){for(o=i=t.encrypt(h.concat(e,[u])),s=1;ss;s++)o.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=i),this.N++,this.b=a.hash.sha256.hash(this.b.concat(o)),this.K=new a.cipher.aes(this.b),n=0;4>n&&(this.m[n]=this.m[n]+1|0,!this.m[n]);n++);}for(n=0;n>>1;this.h[s].update([n,this.M++,2,e,i,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,i,t.length]),this.h[s].update(t);break;default:u=1}if(u)throw new a.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=e,this.i+=e,c===this.A&&(this.isReady()!==this.A&&Kt("seeded",Math.max(this.u,this.i)),Kt("progress",this.getProgress()))},isReady:function(t){return t=this.R[t!==void 0?t:this.L],this.u&&this.u>=t?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=t?this.I|this.A:this.A},getProgress:function(t){return t=this.R[t||this.L],this.u>=t||this.i>t?1:this.i/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:De(this,this.la),mouseCollector:De(this,this.na),keyboardCollector:De(this,this.ja),accelerometerCollector:De(this,this.ca),touchCollector:De(this,this.pa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new a.exception.bug("can't attach event");this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.J[t][this.ea++]=e},removeEventListener:function(t,e){var r,n,o=this.J[t],i=[];for(n in o)o.hasOwnProperty(n)&&o[n]===e&&i.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function De(t,e){return function(){e.apply(t,arguments)}}a.random=new a.prng(6);e:try{if(Xe=typeof fe<"u"&&fe.exports){try{Ge=Dr("crypto")}catch{Ge=null}Xe=$e=Ge}if(Xe&&$e.randomBytes)Ce=$e.randomBytes(128),Ce=new Uint32Array(new Uint8Array(Ce).buffer),a.random.addEntropy(Ce,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Se=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Se);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Se);else break e;a.random.addEntropy(Se,1024,"crypto['getRandomValues']")}}catch(t){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}var Ce,$e,Se,Xe,Ge;a.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(t,e,r,n){r=r||{},n=n||{};var o=a.json,i=o.j({iv:a.random.randomWords(4,0)},o.defaults),s;if(o.j(i,r),r=i.adata,typeof i.salt=="string"&&(i.salt=a.codec.base64.toBits(i.salt)),typeof i.iv=="string"&&(i.iv=a.codec.base64.toBits(i.iv)),!a.mode[i.mode]||!a.cipher[i.cipher]||typeof t=="string"&&100>=i.iter||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||2>i.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4{"use strict";var hn=Object.prototype.hasOwnProperty,k="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(k=!1));function ln(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function cr(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new ln(r,n||t,o),s=k?k+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],i]:t._events[s].push(i):(t._events[s]=i,t._eventsCount++),t}function qe(t,e){--t._eventsCount===0?t._events=new ke:delete t._events[e]}function D(){this._events=new ke,this._eventsCount=0}D.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)hn.call(r,n)&&e.push(k?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};D.prototype.listeners=function(e){var r=k?k+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:o}};function ae(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function c(h){try{f(n.next(h))}catch(l){s(l)}}function u(h){try{f(n.throw(h))}catch(l){s(l)}}function f(h){h.done?i(h.value):o(h.value).then(c,u)}f((n=n.apply(t,e||[])).next())})}function jt(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(t){return this instanceof $?(this.v=t,this):new $(t)}function Wt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(p){return function(A){return Promise.resolve(A).then(p,l)}}function c(p,A){n[p]&&(o[p]=function(M){return new Promise(function(F,Y){i.push([p,M,F,Y])>1||u(p,M)})},A&&(o[p]=A(o[p])))}function u(p,A){try{f(n[p](A))}catch(M){m(i[0][3],M)}}function f(p){p.value instanceof $?Promise.resolve(p.value.v).then(h,l):m(i[0][2],p)}function h(p){u("next",p)}function l(p){u("throw",p)}function m(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Ur(t){var e,r;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=t[o]?function(s){return(r=!r)?{value:$(t[o](s)),done:!1}:i?i(s):s}:i}}function Nr(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof jt=="function"?jt(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(c,u){s=t[i](s),o(c,u,s.done,s.value)})}}function o(i,s,c,u){Promise.resolve(u).then(function(f){i({value:f,done:c})},s)}}var _=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new N(n));return new t(r)}static fromPromise(e,r){let n=e.then(o=>new N(o)).catch(o=>new B(r(o)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(ae(this,void 0,void 0,function*(){try{return new N(yield e(...n))}catch(o){return new B(r?r(o):o)}}))}static combine(e){return Br(e)}static combineWithAllErrors(e){return jr(e)}map(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){return r.isErr()?new B(r.error):new N(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);let n=yield e(r.value);return n.isErr()?new B(n.error):new N(r.value)})))}andTee(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);try{yield e(r.value)}catch{}return new N(r.value)})))}mapErr(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){return r.isOk()?new N(r.value):new B(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new B(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new N(r.value)})))}match(e,r){return this._promise.then(n=>n.match(e,r))}unwrapOr(e){return this._promise.then(r=>r.unwrapOr(e))}safeUnwrap(){return Wt(this,arguments,function*(){return yield $(yield $(yield*Ur(Nr(yield $(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Wt(this,arguments,function*(){let r=yield $(this._promise);return r.isErr()&&(yield yield $(S(r.error))),yield $(r.value)})}},X=t=>new _(Promise.resolve(new N(t))),S=t=>new _(Promise.resolve(new B(t))),En=_.fromPromise,An=_.fromSafePromise,xn=_.fromThrowable,zt=t=>{let e=re([]);for(let r of t)if(r.isErr()){e=V(r.error);break}else e.map(n=>n.push(r.value));return e},Br=t=>_.fromSafePromise(Promise.all(t)).andThen(zt),Jt=t=>{let e=re([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=V([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},jr=t=>_.fromSafePromise(Promise.all(t)).andThen(Jt),ft;(function(t){function e(o,i){return(...s)=>{try{let c=o(...s);return re(c)}catch(c){return V(i?i(c):c)}}}t.fromThrowable=e;function r(o){return zt(o)}t.combine=r;function n(o){return Jt(o)}t.combineWithAllErrors=n})(ft||(ft={}));var re=t=>new N(t);function V(t){return new B(t)}var N=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return re(e(this.value))}mapErr(e){return re(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(r=>this.value)}andTee(e){try{e(this.value)}catch{}return re(this.value)}orElse(e){return re(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return _.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,r){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw Ft("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},B=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return V(this.error)}mapErr(e){return V(e(this.error))}andThrough(e){return V(this.error)}andTee(e){return V(this.error)}andThen(e){return V(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return S(this.error)}asyncAndThrough(e){return S(this.error)}asyncMap(e){return S(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield V(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw Ft("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},On=ft.fromThrowable;var ee=class extends Error{constructor(r,n={}){let{cause:o,context:i}=n;super(r,{cause:o});U(this,"context");this.name=this.constructor.name,this.context=i}};var ne=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)};var Wr=()=>typeof Deno<"u";var ce=t=>Wr()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t==="main"?`worker/${t}`:t}.js`));var v=new Xt.default,L,Ht=!1;self.onmessage=t=>{Jr(t),Ht||(Ht=!0,v.once("OPERATION_FAILED",()=>{L&&L.terminate()}))};var K=(t,e)=>(Object.assign(t,e),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:t}),t),Gt=(t,e)=>{K(t,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:e})},Jr=(t,e)=>{let{action:r}=t.data;if(r===5||r===8)L.postMessage(t.data);else{switch(r){case 2:L=new Worker(ce("cancel"),{type:"module"}),L.postMessage(t.data);break;case 3:L=new Worker(ce("download"),{type:"module"}),L.postMessage(t.data);break;case 4:L=new Worker(ce("infos"),{type:"module"}),L.postMessage(t.data);break;case 7:L=L||new Worker(ce("remove"),{type:"module"}),L.postMessage(t.data);break;case 9:L=L||new Worker(ce("upload"),{type:"module"}),L.postMessage(t.data);break;default:console.error("Action not found")}L.onmessage=n=>{e&&e(n),self.postMessage(n.data)},L.onerror=n=>{console.error(`Error: ${n.message}`)}}},qt=()=>{v.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),v.once("OPERATION_FAILED",t=>{self.postMessage({event:"OPERATION_FAILED",error:t})})};var G=class extends ee{};var Le=class extends G{constructor(){super(...arguments);U(this,"message","An error occured while trying to connect to WebSocket")}};var ue=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),o="";for(let i=0;i>2]+this._charset[(n[i]&3)<<4|n[i+1]>>4]+this._charset[(n[i+1]&15)<<2|n[i+2]>>6]+this._charset[n[i+2]&63];return r%3==2?(o=o.substring(0,o.length-1),this._noPadding||(o+="=")):r%3==1&&(o=o.substring(0,o.length-2),this._noPadding||(o+="==")),o}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),o,i,s,c,u=0,f=0;for(;u>4,n[u++]=(i&15)<<4|s>>2,n[u++]=(s&3)<<6|c;return n.buffer}};var Hr=new ue("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function be(t){return Hr.Decode(t)}var $r=new ue("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function ht(t){return $r.Decode(t)}var tr=at(Zt());var Q=class extends ee{};var he=class extends Q{constructor(){super(...arguments);U(this,"message","Unable to decrypt the provided data")}};var rr=(t,e)=>{try{let r=typeof e=="string"?e:e.data;return X(be(tr.default.decrypt(t,r)))}catch(r){return S(new he(void 0,{cause:ne(r)}))}};var nr=(t,e)=>Vr(t).andThen(r=>_.fromPromise(crypto.subtle.decrypt({name:"AES-GCM",iv:e.iv},r,be(e.data)),n=>new he(void 0,{cause:ne(n)})));var Vr=t=>_.fromPromise(crypto.subtle.importKey("raw",ht(t),{name:"AES-GCM"},!1,["encrypt","decrypt"]),e=>new Q("Unable to import cryptography key",{cause:ne(e)}));var or=(t,e)=>e.algo===void 0||e.algo===0?rr(t,e):nr(t,e);var I={},ir=5,Zr=t=>(v.emit("UPLOAD_CANCELLED",t.success),X(void 0)),en=(t,e)=>{let r=t.split("XXMOJOXX"),n=r.shift();if(n!==void 0){let o=JSON.parse(n);if(un(o)){let i=r.shift();if(i){let s=JSON.parse(i);return s.iv&&(s.iv=new Uint8Array(Object.values(s.iv))),or(e.keys.client,s).andThen(c=>{let u=typeof c=="string"?new TextEncoder().encode(c).buffer:c;return o.part===0?(K(e,{chunksReady:e.chunksReady+1,delAtFirstView:o.del_at_first_view,delay:o.delay,name:o.name,size:o.size,totalChunks:o.total,type:o.type,zipped:o.zipped}),v.emit("DOWNLOAD_STARTED")):K(e,{chunksReady:e.chunksReady+1}),v.emit("CHUNK_DOWNLOADED",u,o.part),++o.part===o.total?on(e).andThen(()=>(v.emit("DOWNLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED"),X(void 0))):X(void 0)})}else{let s=new G("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",s),S(s)}}else{let i=new G(o.msg);return v.emit("OPERATION_FAILED",i),S(i)}}else{let o=new G("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",o),S(o)}},tn=(t,e)=>{if(t.success)return t.j===0&&(K(e,{keys:{client:e.keys.client,server:t.short},actionToken:t.token,queueIndex:t.i}),v.emit("UPLOAD_STARTED")),K(e,{chunksReady:e.chunksReady+1,createdAt:t.created_at}),v.emit("CHUNK_UPLOADED"),e.chunksReady===e.totalChunks&&(K(e,{uploadStatus:1}),v.emit("UPLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED")),X(void 0);{let r=new G(t.msg);return v.emit("OPERATION_FAILED",r),S(r)}},rn=(t,e)=>{let r=cn(t.data),n;if(r)if(!r.action&&r.msg){let o=new G(r.msg);return v.emit("OPERATION_FAILED",o),S(o)}else"delay"in r?n=tn(r,e):n=Zr(r);else n=en(t.data,e);return n},nn=t=>I!==void 0&&I[t]!==void 0&&I[t].readyState===WebSocket.CONNECTING,dt=t=>I!==void 0&&I[t]!==void 0&&I[t].readyState===WebSocket.OPEN;var pt=(t,e)=>{let r;return t.password?r={part:e,file_pwd:t.password}:r={part:e},mt(ar(t),t,JSON.stringify(r))},on=t=>{let e;return t.password?e={ended:!0,file_pwd:t.password}:e={ended:!0},mt(ar(t),t,JSON.stringify(e))};var mt=(t,e,r)=>dt(t)?(I[t].onmessage=n=>rn(n,e),I[t].send(r),X(void 0)):sr(t).andThen(()=>mt(t,e,r)),sr=(t,e=0)=>(!dt(t)&&!nn(t)&&(I[t]=new WebSocket(t),v.once("SOCKET_OPERATION_TERMINATED",()=>{I[t].close()}),v.once("OPERATION_FAILED",()=>{v.emit("SOCKET_OPERATION_TERMINATED")}),I[t].onopen=()=>{v.emit("SOCKET_OPENED")},I[t].onclose=()=>{},I[t].onerror=()=>++e<=ir?(console.error(`An error happened while trying to connect to WebSocket ${t}. Trying again. ${e} / ${ir}`),sr(t,e)):(v.emit("SOCKET_ONERROR"),S(new Le(`Unable to connect to WebSocket ${t}.`)))),sn(t).andThen(()=>X(t)).orElse(r=>S(r))),sn=t=>_.fromPromise(new Promise((e,r)=>{dt(t)?e(void 0):(v.once("SOCKET_OPENED",()=>{e(void 0)}),v.on("SOCKET_ONERROR",()=>{r(new Le)}))}),e=>ne(e));var an=(t,e)=>{let r=new URL(t);return r.protocol=r.protocol==="http:"?"ws:":"wss:",r.pathname+=e,new URL(r.origin+r.pathname)},ar=t=>an(new URL(t.serverUrl),"download"+`/${t.keys.server}`).toString();var cn=t=>{try{let e=JSON.parse(t);if(e&&typeof e=="object")return e}catch{}return!1},un=t=>typeof t=="object"&&t!==null&&!("msg"in t);var vt=at(ur(),1);var Pe=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},wt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},fr=t=>globalThis.DOMException===void 0?new wt(t):new DOMException(t),hr=t=>{let e=t.reason===void 0?fr("This operation was aborted."):t.reason;return e instanceof Error?e:fr(e)};function gt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,u=new Promise((f,h)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:m}=e;m.aborted&&h(hr(m));let p=()=>{h(hr(m))};m.addEventListener("abort",p,{once:!0}),t.finally(()=>{m.removeEventListener("abort",p)})}if(r===Number.POSITIVE_INFINITY){t.then(f,h);return}let l=new Pe;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(m){h(m)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?f():o instanceof Error?h(o):(l.message=o!=null?o:`Promise timed out after ${r} milliseconds`,h(l))},r),(async()=>{try{f(await t)}catch(m){h(m)}})()}).finally(()=>{u.clear()});return u.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},u}function Et(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var q,Re=class{constructor(){x(this,q,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&d(this,q)[this.size-1].priority>=r.priority){d(this,q).push(n);return}let o=Et(d(this,q),n,(i,s)=>s.priority-i.priority);d(this,q).splice(o,0,n)}dequeue(){let e=d(this,q).shift();return e==null?void 0:e.run}filter(e){return d(this,q).filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return d(this,q).length}};q=new WeakMap;var le,de,te,Ie,pe,Me,j,me,P,Ue,W,ye,Z,Ne,y,lr,dr,pr,mr,yr,Ye,At,xt,Ve,vr,Ke,Te=class extends vt.default{constructor(r){var n,o,i,s;super();x(this,y);x(this,le);x(this,de);x(this,te,0);x(this,Ie);x(this,pe);x(this,Me,0);x(this,j);x(this,me);x(this,P);x(this,Ue);x(this,W,0);x(this,ye);x(this,Z);x(this,Ne);U(this,"timeout");if(r={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Re,...r},!(typeof r.intervalCap=="number"&&r.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(o=(n=r.intervalCap)==null?void 0:n.toString())!=null?o:""}\` (${typeof r.intervalCap})`);if(r.interval===void 0||!(Number.isFinite(r.interval)&&r.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=r.interval)==null?void 0:i.toString())!=null?s:""}\` (${typeof r.interval})`);g(this,le,r.carryoverConcurrencyCount),g(this,de,r.intervalCap===Number.POSITIVE_INFINITY||r.interval===0),g(this,Ie,r.intervalCap),g(this,pe,r.interval),g(this,P,new r.queueClass),g(this,Ue,r.queueClass),this.concurrency=r.concurrency,this.timeout=r.timeout,g(this,Ne,r.throwOnTimeout===!0),g(this,Z,r.autoStart===!1)}get concurrency(){return d(this,ye)}set concurrency(r){if(!(typeof r=="number"&&r>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${r}\` (${typeof r})`);g(this,ye,r),O(this,y,Ve).call(this)}async add(r,n={}){return n={timeout:this.timeout,throwOnTimeout:d(this,Ne),...n},new Promise((o,i)=>{d(this,P).enqueue(async()=>{var s;ze(this,W)._++,ze(this,te)._++;try{(s=n.signal)==null||s.throwIfAborted();let c=r({signal:n.signal});n.timeout&&(c=gt(Promise.resolve(c),{milliseconds:n.timeout})),n.signal&&(c=Promise.race([c,O(this,y,vr).call(this,n.signal)]));let u=await c;o(u),this.emit("completed",u)}catch(c){if(c instanceof Pe&&!n.throwOnTimeout){o();return}i(c),this.emit("error",c)}finally{O(this,y,pr).call(this)}},n),this.emit("add"),O(this,y,Ye).call(this)})}async addAll(r,n){return Promise.all(r.map(async o=>this.add(o,n)))}start(){return d(this,Z)?(g(this,Z,!1),O(this,y,Ve).call(this),this):this}pause(){g(this,Z,!0)}clear(){g(this,P,new(d(this,Ue)))}async onEmpty(){d(this,P).size!==0&&await O(this,y,Ke).call(this,"empty")}async onSizeLessThan(r){d(this,P).sized(this,P).size{O(this,y,mr).call(this)},n)),!0}return!1},Ye=function(){if(d(this,P).size===0)return d(this,j)&&clearInterval(d(this,j)),g(this,j,void 0),this.emit("empty"),d(this,W)===0&&this.emit("idle"),!1;if(!d(this,Z)){let r=!d(this,y,yr);if(d(this,y,lr)&&d(this,y,dr)){let n=d(this,P).dequeue();return n?(this.emit("active"),n(),r&&O(this,y,At).call(this),!0):!1}}return!1},At=function(){d(this,de)||d(this,j)!==void 0||(g(this,j,setInterval(()=>{O(this,y,xt).call(this)},d(this,pe))),g(this,Me,Date.now()+d(this,pe)))},xt=function(){d(this,te)===0&&d(this,W)===0&&d(this,j)&&(clearInterval(d(this,j)),g(this,j,void 0)),g(this,te,d(this,le)?d(this,W):0),O(this,y,Ve).call(this)},Ve=function(){for(;O(this,y,Ye).call(this););},vr=async function(r){return new Promise((n,o)=>{r.addEventListener("abort",()=>{o(r.reason)},{once:!0})})},Ke=async function(r,n){return new Promise(o=>{let i=()=>{n&&!n()||(this.off(r,i),o())};this.on(r,i)})};var dn=[],Ot=navigator.hardwareConcurrency||4,Qe=new Te({concurrency:Ot,autoStart:!1}),Ze=0,wr=!1,et=!1;self.onmessage=t=>{wr||(qt(),wr=!0);let e=t.data;switch(e.action){case 5:et=!0,self.postMessage({event:"JOB_PAUSED"});break;case 8:et=!1,self.postMessage({event:"JOB_RESUMED"});break;default:v.once("DOWNLOAD_COMPLETE",()=>{self.postMessage({event:"DOWNLOAD_COMPLETE"})}),v.on("FILE_UPDATED",K),v.on("CHUNK_DOWNLOADED",(r,n)=>{self.postMessage({event:"CHUNK_DOWNLOADED",chunk:{buffer:r,index:n}})}),pn(e).mapErr(r=>{Gt(e.args.lufiFile,r)})}};var pn=t=>{let{lufiFile:e}=t.args;return v.on("CHUNK_DOWNLOADED",(r,n)=>{dn[n]=r,Ze--,!et&&Ze{for(let r=1;r{await pt(e,r),Ze++,(et||Ze===Ot)&&Qe.pause()});Qe.start()}),pt(e,0)};export{Ot as QUEUE_CONCURRENCY_LIMIT,Ze as itemsInQueue,Qe as queue}; +var Ar=Object.create;var it=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var Or=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,Lr=Object.prototype.hasOwnProperty;var Dt=t=>{throw TypeError(t)};var _r=(t,e,r)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Dr=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var st=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Cr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Or(e))!Lr.call(t,o)&&o!==r&&it(t,o,{get:()=>e[o],enumerable:!(n=xr(e,o))||n.enumerable});return t};var at=(t,e,r)=>(r=t!=null?Ar(br(t)):{},Cr(e||!t||!t.__esModule?it(r,"default",{value:t,enumerable:!0}):r,t));var U=(t,e,r)=>_r(t,typeof e!="symbol"?e+"":e,r),ct=(t,e,r)=>e.has(t)||Dt("Cannot "+r);var d=(t,e,r)=>(ct(t,e,"read from private field"),r?r.call(t):e.get(t)),x=(t,e,r)=>e.has(t)?Dt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),w=(t,e,r,n)=>(ct(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),O=(t,e,r)=>(ct(t,e,"access private method"),r);var ze=(t,e,r,n)=>({set _(o){w(t,e,o,r)},get _(){return d(t,e,n)}});var Bt=st((yn,ut)=>{"use strict";var se=typeof Reflect=="object"?Reflect:null,Ct=se&&typeof se.apply=="function"?se.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Je;se&&typeof se.ownKeys=="function"?Je=se.ownKeys:Object.getOwnPropertySymbols?Je=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Je=function(e){return Object.getOwnPropertyNames(e)};function Sr(t){console&&console.warn&&console.warn(t)}var kt=Number.isNaN||function(e){return e!==e};function g(){g.init.call(this)}ut.exports=g;ut.exports.once=Rr;g.EventEmitter=g;g.prototype._events=void 0;g.prototype._eventsCount=0;g.prototype._maxListeners=void 0;var St=10;function He(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(g,"defaultMaxListeners",{enumerable:!0,get:function(){return St},set:function(t){if(typeof t!="number"||t<0||kt(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");St=t}});g.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};g.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||kt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Pt(t){return t._maxListeners===void 0?g.defaultMaxListeners:t._maxListeners}g.prototype.getMaxListeners=function(){return Pt(this)};g.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var u=i[e];if(u===void 0)return!1;if(typeof u=="function")Ct(u,this,r);else for(var f=u.length,h=Ut(u,f),n=0;n0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,Sr(c)}return t}g.prototype.addListener=function(e,r){return Tt(this,e,r,!1)};g.prototype.on=g.prototype.addListener;g.prototype.prependListener=function(e,r){return Tt(this,e,r,!0)};function kr(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Rt(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=kr.bind(n);return o.listener=r,n.wrapFn=o,o}g.prototype.once=function(e,r){return He(r),this.on(e,Rt(this,e,r)),this};g.prototype.prependOnceListener=function(e,r){return He(r),this.prependListener(e,Rt(this,e,r)),this};g.prototype.removeListener=function(e,r){var n,o,i,s,c;if(He(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){c=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():Pr(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this};g.prototype.off=g.prototype.removeListener;g.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function It(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?Tr(o):Ut(o,o.length)}g.prototype.listeners=function(e){return It(this,e,!0)};g.prototype.rawListeners=function(e){return It(this,e,!1)};g.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Mt.call(t,e)};g.prototype.listenerCount=Mt;function Mt(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}g.prototype.eventNames=function(){return this._eventsCount>0?Je(this._events):[]};function Ut(t,e){for(var r=new Array(e),n=0;n{"use strict";var a={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};a.cipher.aes=function(t){this.w[0][0][0]||this.C();var e,r,n,o,i=this.w[0][4],s=this.w[1];e=t.length;var c=1;if(e!==4&&e!==6&&e!==8)throw new a.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[r&255],t%e===0&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[e&3?t:t-4],o[e]=4>=t||4>e?r:s[0][i[r>>>24]]^s[1][i[r>>16&255]]^s[2][i[r>>8&255]]^s[3][i[r&255]]};a.cipher.aes.prototype={encrypt:function(t){return Vt(this,t,0)},decrypt:function(t){return Vt(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],o,i,s,c=[],u=[],f,h,l,m;for(o=0;256>o;o++)u[(c[o]=o<<1^283*(o>>7))^o]=o;for(i=s=0;!r[i];i^=f||1,s=u[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[i]=l,n[l]=i,h=c[o=c[f=c[i]]],m=16843009*h^65537*o^257*f^16843008*i,h=257*c[l]^16843008*l,o=0;4>o;o++)t[o][i]=h=h<<24^h>>>8,e[o][l]=m=m<<24^m>>>8;for(o=0;5>o;o++)t[o]=t[o].slice(0),e[o]=e[o].slice(0)}};function Vt(t,e,r){if(e.length!==4)throw new a.exception.invalid("invalid aes block size");var n=t.b[r],o=e[0]^n[0],i=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var c,u,f,h=n.length/4-2,l,m=4,p=[0,0,0,0];c=t.w[r],t=c[0];var A=c[1],M=c[2],F=c[3],Y=c[4];for(l=0;l>>24]^A[i>>16&255]^M[s>>8&255]^F[e&255]^n[m],u=t[i>>>24]^A[s>>16&255]^M[e>>8&255]^F[o&255]^n[m+1],f=t[s>>>24]^A[e>>16&255]^M[o>>8&255]^F[i&255]^n[m+2],e=t[e>>>24]^A[o>>16&255]^M[i>>8&255]^F[s&255]^n[m+3],m+=4,o=c,i=u,s=f;for(l=0;4>l;l++)p[r?3&-l:l]=Y[o>>>24]<<24^Y[i>>16&255]<<16^Y[s>>8&255]<<8^Y[e&255]^n[m++],c=o,o=i,i=s,s=e,e=c;return p}a.bitArray={bitSlice:function(t,e,r){return t=a.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:a.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return((e+r-1^e)&-32?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return t===32?e:(r?e|0:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(a.bitArray.bitLength(t)!==a.bitArray.bitLength(e))return!1;var r=0,n;for(n=0;n>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=a.bitArray.getPartial(o),n.push(a.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};a.codec.utf8String={fromBits:function(t){var e="",r=a.bitArray.bitLength(t),n,o;for(n=0;n>>8>>>8>>>8),o<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>o)>>>26),6>o?(s=t[r]<<6-o,o+=26,r++):(s<<=6,o-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,o=0,i=a.codec.base64.S,s=0,c;for(e&&(i=i.substr(0,62)+"-_"),n=0;nc)throw new a.exception.invalid("this isn't base64!");26>>o),s=c<<32-o):(o+=6,s^=c<<32-o)}return o&56&&r.push(a.bitArray.partial(o&56,s,1)),r}};a.codec.base64url={fromBits:function(t){return a.codec.base64.fromBits(t,1,1)},toBits:function(t){return a.codec.base64.toBits(t,1)}};a.hash.sha256=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};a.hash.sha256.hash=function(t){return new a.hash.sha256().update(t).finalize()};a.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=a.codec.utf8String.toBits(t));var e,r=this.f=a.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+a.bitArray.bitLength(t),9007199254740991e;r++){for(o=!0,n=2;n*n<=r;n++)if(r%n===0){o=!1;break}o&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,o=this.g,i=this.b,s=o[0],c=o[1],u=o[2],f=o[3],h=o[4],l=o[5],m=o[6],p=o[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+p+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(m^h&(l^m))+i[e],p=m,m=l,l=h,h=f+r|0,f=u,u=c,c=s,s=r+(c&u^f&(c^u))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+c|0,o[2]=o[2]+u|0,o[3]=o[3]+f|0,o[4]=o[4]+h|0,o[5]=o[5]+l|0,o[6]=o[6]+m|0,o[7]=o[7]+p|0}};a.hash.sha512=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};a.hash.sha512.hash=function(t){return new a.hash.sha512().update(t).finalize()};a.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=a.codec.utf8String.toBits(t));var e,r=this.f=a.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+a.bitArray.bitLength(t),9007199254740991r;n++){for(i=!0,o=2;o*o<=n;o++)if(n%o===0){i=!1;break}i&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,o=this.b,i=n[0],s=n[1],c=n[2],u=n[3],f=n[4],h=n[5],l=n[6],m=n[7],p=n[8],A=n[9],M=n[10],F=n[11],Y=n[12],Be=n[13],bt=n[14],je=n[15],C;if(typeof Uint32Array<"u"){C=Array(160);for(var L=0;32>L;L++)C[L]=t[L]}else C=t;var L=i,T=s,ve=c,oe=u,ge=f,ie=h,tt=l,we=m,z=p,R=A,We=M,Ee=F,Fe=Y,Ae=Be,rt=bt,xe=je;for(t=0;80>t;t++){if(16>t)e=C[2*t],r=C[2*t+1];else{r=C[2*(t-15)];var E=C[2*(t-15)+1];e=(E<<31|r>>>1)^(E<<24|r>>>8)^r>>>7;var J=(r<<31|E>>>1)^(r<<24|E>>>8)^(r<<25|E>>>7);r=C[2*(t-2)];var H=C[2*(t-2)+1],E=(H<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),nt=C[2*(t-7)],ot=C[2*(t-16)],Oe=C[2*(t-16)+1];r=J+C[2*(t-7)+1],e=e+nt+(r>>>0>>0?1:0),r+=H,e+=E+(r>>>0>>0?1:0),r+=Oe,e+=ot+(r>>>0>>0?1:0)}C[2*t]=e|=0,C[2*t+1]=r|=0;var nt=z&We^~z&Fe,Lt=R&Ee^~R&Ae,H=L&ve^L&ge^ve&ge,wr=T&oe^T&ie^oe&ie,ot=(T<<4|L>>>28)^(L<<30|T>>>2)^(L<<25|T>>>7),Oe=(L<<4|T>>>28)^(T<<30|L>>>2)^(T<<25|L>>>7),Er=o[2*t],_t=o[2*t+1],E=xe+((z<<18|R>>>14)^(z<<14|R>>>18)^(R<<23|z>>>9)),J=rt+((R<<18|z>>>14)^(R<<14|z>>>18)^(z<<23|R>>>9))+(E>>>0>>0?1:0),E=E+Lt,J=J+(nt+(E>>>0>>0?1:0)),E=E+_t,J=J+(Er+(E>>>0<_t>>>0?1:0)),E=E+r|0,J=J+(e+(E>>>0>>0?1:0));r=Oe+wr,e=ot+H+(r>>>0>>0?1:0),rt=Fe,xe=Ae,Fe=We,Ae=Ee,We=z,Ee=R,R=we+E|0,z=tt+J+(R>>>0>>0?1:0)|0,tt=ge,we=ie,ge=ve,ie=oe,ve=L,oe=T,T=E+r|0,L=J+e+(T>>>0>>0?1:0)|0}s=n[1]=s+T|0,n[0]=i+L+(s>>>0>>0?1:0)|0,u=n[3]=u+oe|0,n[2]=c+ve+(u>>>0>>0?1:0)|0,h=n[5]=h+ie|0,n[4]=f+ge+(h>>>0>>0?1:0)|0,m=n[7]=m+we|0,n[6]=l+tt+(m>>>0>>0?1:0)|0,A=n[9]=A+R|0,n[8]=p+z+(A>>>0>>0?1:0)|0,F=n[11]=F+Ee|0,n[10]=M+We+(F>>>0>>0?1:0)|0,Be=n[13]=Be+Ae|0,n[12]=Y+Fe+(Be>>>0>>0?1:0)|0,je=n[15]=je+xe|0,n[14]=bt+rt+(je>>>0>>0?1:0)|0}};a.mode.ccm={name:"ccm",F:[],listenProgress:function(t){a.mode.ccm.F.push(t)},unListenProgress:function(t){t=a.mode.ccm.F.indexOf(t),-1u)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(i=2;4>i&&f>>>8*i;i++);return i<15-u&&(i=15-u),r=c.clamp(r,8*(15-i)),e=a.mode.ccm.U(t,e,r,n,o,i),s=a.mode.ccm.V(t,s,r,e,o,i),c.concat(s.data,s.tag)},decrypt:function(t,e,r,n,o){o=o||64,n=n||[];var i=a.bitArray,s=i.bitLength(r)/8,f=i.bitLength(e),c=i.clamp(e,f-o),u=i.bitSlice(e,f-o),f=(f-o)/8;if(7>s)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&f>>>8*e;e++);if(e<15-s&&(e=15-s),r=i.clamp(r,8*(15-e)),c=a.mode.ccm.V(t,c,r,u,o,e),t=a.mode.ccm.U(t,c.data,r,n,o,e),!i.equal(c.tag,t))throw new a.exception.corrupt("ccm: tag doesn't match");return c.data},ma:function(t,e,r,n,o,i){var s=[],c=a.bitArray,u=c.P;if(n=[c.partial(8,(e.length?64:0)|n-2<<2|i-1)],n=c.concat(n,r),n[3]|=o,n=t.encrypt(n),e.length)for(r=c.bitLength(e)/8,65279>=r?s=[c.partial(16,r)]:4294967295>=r&&(s=c.concat([c.partial(16,65534)],[r])),s=c.concat(s,e),e=0;eo||16h&&(a.mode.ccm.da(s/u),h+=l),r[3]++,o=t.encrypt(r),e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3];return{tag:n,data:c.clamp(e,f)}}};a.misc.hmac=function(t,e){this.W=e=e||a.hash.sha256;var r=[[],[]],n,o=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>o&&(t=e.hash(t)),n=0;nn||0>r)throw new a.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=a.codec.utf8String.toBits(t)),typeof e=="string"&&(e=a.codec.utf8String.toBits(e)),o=o||a.misc.hmac,t=new o(t);var i,s,c,u,f=[],h=a.bitArray;for(u=1;32*f.length<(n||1);u++){for(o=i=t.encrypt(h.concat(e,[u])),s=1;ss;s++)o.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=i),this.N++,this.b=a.hash.sha256.hash(this.b.concat(o)),this.K=new a.cipher.aes(this.b),n=0;4>n&&(this.m[n]=this.m[n]+1|0,!this.m[n]);n++);}for(n=0;n>>1;this.h[s].update([n,this.M++,2,e,i,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,i,t.length]),this.h[s].update(t);break;default:u=1}if(u)throw new a.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=e,this.i+=e,c===this.A&&(this.isReady()!==this.A&&Kt("seeded",Math.max(this.u,this.i)),Kt("progress",this.getProgress()))},isReady:function(t){return t=this.R[t!==void 0?t:this.L],this.u&&this.u>=t?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=t?this.I|this.A:this.A},getProgress:function(t){return t=this.R[t||this.L],this.u>=t||this.i>t?1:this.i/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:De(this,this.la),mouseCollector:De(this,this.na),keyboardCollector:De(this,this.ja),accelerometerCollector:De(this,this.ca),touchCollector:De(this,this.pa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new a.exception.bug("can't attach event");this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.J[t][this.ea++]=e},removeEventListener:function(t,e){var r,n,o=this.J[t],i=[];for(n in o)o.hasOwnProperty(n)&&o[n]===e&&i.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function De(t,e){return function(){e.apply(t,arguments)}}a.random=new a.prng(6);e:try{if(Xe=typeof fe<"u"&&fe.exports){try{Ge=Dr("crypto")}catch{Ge=null}Xe=$e=Ge}if(Xe&&$e.randomBytes)Ce=$e.randomBytes(128),Ce=new Uint32Array(new Uint8Array(Ce).buffer),a.random.addEntropy(Ce,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Se=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Se);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Se);else break e;a.random.addEntropy(Se,1024,"crypto['getRandomValues']")}}catch(t){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}var Ce,$e,Se,Xe,Ge;a.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(t,e,r,n){r=r||{},n=n||{};var o=a.json,i=o.j({iv:a.random.randomWords(4,0)},o.defaults),s;if(o.j(i,r),r=i.adata,typeof i.salt=="string"&&(i.salt=a.codec.base64.toBits(i.salt)),typeof i.iv=="string"&&(i.iv=a.codec.base64.toBits(i.iv)),!a.mode[i.mode]||!a.cipher[i.cipher]||typeof t=="string"&&100>=i.iter||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||2>i.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4{"use strict";var hn=Object.prototype.hasOwnProperty,k="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(k=!1));function ln(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function cr(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new ln(r,n||t,o),s=k?k+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],i]:t._events[s].push(i):(t._events[s]=i,t._eventsCount++),t}function qe(t,e){--t._eventsCount===0?t._events=new ke:delete t._events[e]}function D(){this._events=new ke,this._eventsCount=0}D.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)hn.call(r,n)&&e.push(k?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};D.prototype.listeners=function(e){var r=k?k+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:o}};function ae(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function c(h){try{f(n.next(h))}catch(l){s(l)}}function u(h){try{f(n.throw(h))}catch(l){s(l)}}function f(h){h.done?i(h.value):o(h.value).then(c,u)}f((n=n.apply(t,e||[])).next())})}function jt(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(t){return this instanceof $?(this.v=t,this):new $(t)}function Wt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(p){return function(A){return Promise.resolve(A).then(p,l)}}function c(p,A){n[p]&&(o[p]=function(M){return new Promise(function(F,Y){i.push([p,M,F,Y])>1||u(p,M)})},A&&(o[p]=A(o[p])))}function u(p,A){try{f(n[p](A))}catch(M){m(i[0][3],M)}}function f(p){p.value instanceof $?Promise.resolve(p.value.v).then(h,l):m(i[0][2],p)}function h(p){u("next",p)}function l(p){u("throw",p)}function m(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Ur(t){var e,r;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=t[o]?function(s){return(r=!r)?{value:$(t[o](s)),done:!1}:i?i(s):s}:i}}function Nr(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof jt=="function"?jt(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(c,u){s=t[i](s),o(c,u,s.done,s.value)})}}function o(i,s,c,u){Promise.resolve(u).then(function(f){i({value:f,done:c})},s)}}var _=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new N(n));return new t(r)}static fromPromise(e,r){let n=e.then(o=>new N(o)).catch(o=>new B(r(o)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(ae(this,void 0,void 0,function*(){try{return new N(yield e(...n))}catch(o){return new B(r?r(o):o)}}))}static combine(e){return Br(e)}static combineWithAllErrors(e){return jr(e)}map(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){return r.isErr()?new B(r.error):new N(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);let n=yield e(r.value);return n.isErr()?new B(n.error):new N(r.value)})))}andTee(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);try{yield e(r.value)}catch{}return new N(r.value)})))}mapErr(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){return r.isOk()?new N(r.value):new B(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new B(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>ae(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new N(r.value)})))}match(e,r){return this._promise.then(n=>n.match(e,r))}unwrapOr(e){return this._promise.then(r=>r.unwrapOr(e))}safeUnwrap(){return Wt(this,arguments,function*(){return yield $(yield $(yield*Ur(Nr(yield $(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Wt(this,arguments,function*(){let r=yield $(this._promise);return r.isErr()&&(yield yield $(S(r.error))),yield $(r.value)})}},X=t=>new _(Promise.resolve(new N(t))),S=t=>new _(Promise.resolve(new B(t))),wn=_.fromPromise,En=_.fromSafePromise,An=_.fromThrowable,zt=t=>{let e=re([]);for(let r of t)if(r.isErr()){e=V(r.error);break}else e.map(n=>n.push(r.value));return e},Br=t=>_.fromSafePromise(Promise.all(t)).andThen(zt),Jt=t=>{let e=re([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=V([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},jr=t=>_.fromSafePromise(Promise.all(t)).andThen(Jt),ft;(function(t){function e(o,i){return(...s)=>{try{let c=o(...s);return re(c)}catch(c){return V(i?i(c):c)}}}t.fromThrowable=e;function r(o){return zt(o)}t.combine=r;function n(o){return Jt(o)}t.combineWithAllErrors=n})(ft||(ft={}));var re=t=>new N(t);function V(t){return new B(t)}var N=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return re(e(this.value))}mapErr(e){return re(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(r=>this.value)}andTee(e){try{e(this.value)}catch{}return re(this.value)}orElse(e){return re(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return _.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,r){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw Ft("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},B=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return V(this.error)}mapErr(e){return V(e(this.error))}andThrough(e){return V(this.error)}andTee(e){return V(this.error)}andThen(e){return V(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return S(this.error)}asyncAndThrough(e){return S(this.error)}asyncMap(e){return S(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield V(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw Ft("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},xn=ft.fromThrowable;var ee=class extends Error{constructor(r,n={}){let{cause:o,context:i}=n;super(r,{cause:o});U(this,"context");this.name=this.constructor.name,this.context=i}};var ne=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)};var Wr=()=>typeof Deno<"u";var ce=t=>Wr()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t==="main"?`worker/${t}`:t}.js`));var v=new Xt.default,b,Ht=!1;self.onmessage=t=>{Jr(t),Ht||(Ht=!0,v.once("OPERATION_FAILED",()=>{b&&b.terminate()}))};var K=(t,e)=>(Object.assign(t,e),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:t}),t),Gt=(t,e)=>{K(t,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:e})},Jr=(t,e)=>{let{action:r}=t.data;if(r===5||r===8)b.postMessage(t.data);else{switch(r){case 2:b=new Worker(ce("cancel"),{type:"module"}),b.postMessage(t.data);break;case 3:b=new Worker(ce("download"),{type:"module"}),b.postMessage(t.data);break;case 4:b=new Worker(ce("infos"),{type:"module"}),b.postMessage(t.data);break;case 7:b=b||new Worker(ce("remove"),{type:"module"}),b.postMessage(t.data);break;case 9:b=b||new Worker(ce("upload"),{type:"module"}),b.postMessage(t.data);break;default:console.error("Action not found")}b.onmessage=n=>{e&&e(n),self.postMessage(n.data)},b.onerror=n=>{console.error(`Error: ${n.message}`)}}},qt=()=>{v.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),v.once("OPERATION_FAILED",t=>{self.postMessage({event:"OPERATION_FAILED",error:t})})};var G=class extends ee{};var be=class extends G{constructor(){super(...arguments);U(this,"message","An error occured while trying to connect to WebSocket")}};var ue=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),o="";for(let i=0;i>2]+this._charset[(n[i]&3)<<4|n[i+1]>>4]+this._charset[(n[i+1]&15)<<2|n[i+2]>>6]+this._charset[n[i+2]&63];return r%3==2?(o=o.substring(0,o.length-1),this._noPadding||(o+="=")):r%3==1&&(o=o.substring(0,o.length-2),this._noPadding||(o+="==")),o}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),o,i,s,c,u=0,f=0;for(;u>4,n[u++]=(i&15)<<4|s>>2,n[u++]=(s&3)<<6|c;return n.buffer}};var Hr=new ue("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function Le(t){return Hr.Decode(t)}var $r=new ue("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function ht(t){return $r.Decode(t)}var tr=at(Zt());var Q=class extends ee{};var he=class extends Q{constructor(){super(...arguments);U(this,"message","Unable to decrypt the provided data")}};var rr=(t,e)=>{try{let r=typeof e=="string"?e:e.data;return X(Le(tr.default.decrypt(t,r)))}catch(r){return S(new he(void 0,{cause:ne(r)}))}};var nr=(t,e)=>Vr(t).andThen(r=>_.fromPromise(crypto.subtle.decrypt({name:"AES-GCM",iv:e.iv},r,Le(e.data)),n=>new he(void 0,{cause:ne(n)})));var Vr=t=>_.fromPromise(crypto.subtle.importKey("raw",ht(t),{name:"AES-GCM"},!1,["encrypt","decrypt"]),e=>new Q("Unable to import cryptography key",{cause:ne(e)}));var or=(t,e)=>e.algo===void 0||e.algo===0?rr(t,e):nr(t,e);var I={},ir=5,Zr=t=>(v.emit("UPLOAD_CANCELLED",t.success),X(void 0)),en=(t,e)=>{let r=t.split("XXMOJOXX"),n=r.shift();if(n!==void 0){let o=JSON.parse(n);if(un(o)){let i=r.shift();if(i){let s=JSON.parse(i);return s.iv&&(s.iv=new Uint8Array(Object.values(s.iv))),or(e.keys.client,s).andThen(c=>{let u=typeof c=="string"?new TextEncoder().encode(c).buffer:c;return o.part===0?(K(e,{chunksReady:e.chunksReady+1,delAtFirstView:o.del_at_first_view,delay:o.delay,name:o.name,size:o.size,totalChunks:o.total,type:o.type,zipped:o.zipped}),v.emit("DOWNLOAD_STARTED")):K(e,{chunksReady:e.chunksReady+1}),v.emit("CHUNK_DOWNLOADED",u,o.part),++o.part===o.total?on(e).andThen(()=>(v.emit("DOWNLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED"),X(void 0))):X(void 0)})}else{let s=new G("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",s),S(s)}}else{let i=new G(o.msg);return v.emit("OPERATION_FAILED",i),S(i)}}else{let o=new G("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",o),S(o)}},tn=(t,e)=>{if(t.success)return t.j===0&&(K(e,{keys:{client:e.keys.client,server:t.short},actionToken:t.token,queueIndex:t.i}),v.emit("UPLOAD_STARTED")),K(e,{chunksReady:e.chunksReady+1,createdAt:t.created_at}),v.emit("CHUNK_UPLOADED"),e.chunksReady===e.totalChunks&&(K(e,{uploadStatus:1}),v.emit("UPLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED")),X(void 0);{let r=new G(t.msg);return v.emit("OPERATION_FAILED",r),S(r)}},rn=(t,e)=>{let r=cn(t.data),n;if(r)if(!r.action&&r.msg){let o=new G(r.msg);return v.emit("OPERATION_FAILED",o),S(o)}else"delay"in r?n=tn(r,e):n=Zr(r);else n=en(t.data,e);return n},nn=t=>I!==void 0&&I[t]!==void 0&&I[t].readyState===WebSocket.CONNECTING,dt=t=>I!==void 0&&I[t]!==void 0&&I[t].readyState===WebSocket.OPEN;var pt=(t,e)=>{let r;return t.password?r={part:e,file_pwd:t.password}:r={part:e},mt(ar(t),t,JSON.stringify(r))},on=t=>{let e;return t.password?e={ended:!0,file_pwd:t.password}:e={ended:!0},mt(ar(t),t,JSON.stringify(e))};var mt=(t,e,r)=>dt(t)?(I[t].onmessage=n=>rn(n,e),I[t].send(r),X(void 0)):sr(t).andThen(()=>mt(t,e,r)),sr=(t,e=0)=>(!dt(t)&&!nn(t)&&(I[t]=new WebSocket(t),v.once("SOCKET_OPERATION_TERMINATED",()=>{I[t].close()}),v.once("OPERATION_FAILED",()=>{v.emit("SOCKET_OPERATION_TERMINATED")}),I[t].onopen=()=>{v.emit("SOCKET_OPENED")},I[t].onclose=()=>{},I[t].onerror=()=>++e<=ir?(console.error(`An error happened while trying to connect to WebSocket ${t}. Trying again. ${e} / ${ir}`),sr(t,e)):(v.emit("SOCKET_ONERROR"),S(new be(`Unable to connect to WebSocket ${t}.`)))),sn(t).andThen(()=>X(t)).orElse(r=>S(r))),sn=t=>_.fromPromise(new Promise((e,r)=>{dt(t)?e(void 0):(v.once("SOCKET_OPENED",()=>{e(void 0)}),v.on("SOCKET_ONERROR",()=>{r(new be)}))}),e=>ne(e));var an=(t,e)=>{let r=new URL(t);return r.protocol=r.protocol==="http:"?"ws:":"wss:",r.pathname+=e,new URL(r.origin+r.pathname)},ar=t=>an(new URL(t.serverUrl),"download"+`/${t.keys.server}`).toString();var cn=t=>{try{let e=JSON.parse(t);if(e&&typeof e=="object")return e}catch{}return!1},un=t=>typeof t=="object"&&t!==null&&!("msg"in t);var vt=at(ur(),1);var Pe=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},gt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},fr=t=>globalThis.DOMException===void 0?new gt(t):new DOMException(t),hr=t=>{let e=t.reason===void 0?fr("This operation was aborted."):t.reason;return e instanceof Error?e:fr(e)};function wt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,u=new Promise((f,h)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:m}=e;m.aborted&&h(hr(m));let p=()=>{h(hr(m))};m.addEventListener("abort",p,{once:!0}),t.finally(()=>{m.removeEventListener("abort",p)})}if(r===Number.POSITIVE_INFINITY){t.then(f,h);return}let l=new Pe;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(m){h(m)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?f():o instanceof Error?h(o):(l.message=o!=null?o:`Promise timed out after ${r} milliseconds`,h(l))},r),(async()=>{try{f(await t)}catch(m){h(m)}})()}).finally(()=>{u.clear()});return u.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},u}function Et(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var q,Te=class{constructor(){x(this,q,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&d(this,q)[this.size-1].priority>=r.priority){d(this,q).push(n);return}let o=Et(d(this,q),n,(i,s)=>s.priority-i.priority);d(this,q).splice(o,0,n)}dequeue(){let e=d(this,q).shift();return e==null?void 0:e.run}filter(e){return d(this,q).filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return d(this,q).length}};q=new WeakMap;var le,de,te,Ie,pe,Me,j,me,P,Ue,W,ye,Z,Ne,y,lr,dr,pr,mr,yr,Ye,At,xt,Ve,vr,Ke,Re=class extends vt.default{constructor(r){var n,o,i,s;super();x(this,y);x(this,le);x(this,de);x(this,te,0);x(this,Ie);x(this,pe);x(this,Me,0);x(this,j);x(this,me);x(this,P);x(this,Ue);x(this,W,0);x(this,ye);x(this,Z);x(this,Ne);U(this,"timeout");if(r={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...r},!(typeof r.intervalCap=="number"&&r.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(o=(n=r.intervalCap)==null?void 0:n.toString())!=null?o:""}\` (${typeof r.intervalCap})`);if(r.interval===void 0||!(Number.isFinite(r.interval)&&r.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=r.interval)==null?void 0:i.toString())!=null?s:""}\` (${typeof r.interval})`);w(this,le,r.carryoverConcurrencyCount),w(this,de,r.intervalCap===Number.POSITIVE_INFINITY||r.interval===0),w(this,Ie,r.intervalCap),w(this,pe,r.interval),w(this,P,new r.queueClass),w(this,Ue,r.queueClass),this.concurrency=r.concurrency,this.timeout=r.timeout,w(this,Ne,r.throwOnTimeout===!0),w(this,Z,r.autoStart===!1)}get concurrency(){return d(this,ye)}set concurrency(r){if(!(typeof r=="number"&&r>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${r}\` (${typeof r})`);w(this,ye,r),O(this,y,Ve).call(this)}async add(r,n={}){return n={timeout:this.timeout,throwOnTimeout:d(this,Ne),...n},new Promise((o,i)=>{d(this,P).enqueue(async()=>{var s;ze(this,W)._++,ze(this,te)._++;try{(s=n.signal)==null||s.throwIfAborted();let c=r({signal:n.signal});n.timeout&&(c=wt(Promise.resolve(c),{milliseconds:n.timeout})),n.signal&&(c=Promise.race([c,O(this,y,vr).call(this,n.signal)]));let u=await c;o(u),this.emit("completed",u)}catch(c){if(c instanceof Pe&&!n.throwOnTimeout){o();return}i(c),this.emit("error",c)}finally{O(this,y,pr).call(this)}},n),this.emit("add"),O(this,y,Ye).call(this)})}async addAll(r,n){return Promise.all(r.map(async o=>this.add(o,n)))}start(){return d(this,Z)?(w(this,Z,!1),O(this,y,Ve).call(this),this):this}pause(){w(this,Z,!0)}clear(){w(this,P,new(d(this,Ue)))}async onEmpty(){d(this,P).size!==0&&await O(this,y,Ke).call(this,"empty")}async onSizeLessThan(r){d(this,P).sized(this,P).size{O(this,y,mr).call(this)},n)),!0}return!1},Ye=function(){if(d(this,P).size===0)return d(this,j)&&clearInterval(d(this,j)),w(this,j,void 0),this.emit("empty"),d(this,W)===0&&this.emit("idle"),!1;if(!d(this,Z)){let r=!d(this,y,yr);if(d(this,y,lr)&&d(this,y,dr)){let n=d(this,P).dequeue();return n?(this.emit("active"),n(),r&&O(this,y,At).call(this),!0):!1}}return!1},At=function(){d(this,de)||d(this,j)!==void 0||(w(this,j,setInterval(()=>{O(this,y,xt).call(this)},d(this,pe))),w(this,Me,Date.now()+d(this,pe)))},xt=function(){d(this,te)===0&&d(this,W)===0&&d(this,j)&&(clearInterval(d(this,j)),w(this,j,void 0)),w(this,te,d(this,le)?d(this,W):0),O(this,y,Ve).call(this)},Ve=function(){for(;O(this,y,Ye).call(this););},vr=async function(r){return new Promise((n,o)=>{r.addEventListener("abort",()=>{o(r.reason)},{once:!0})})},Ke=async function(r,n){return new Promise(o=>{let i=()=>{n&&!n()||(this.off(r,i),o())};this.on(r,i)})};var Ot=navigator.hardwareConcurrency||4,Qe=new Re({concurrency:Ot,autoStart:!1}),Ze=0,gr=!1,et=!1;self.onmessage=t=>{gr||(qt(),gr=!0);let e=t.data;switch(e.action){case 5:et=!0,self.postMessage({event:"JOB_PAUSED"});break;case 8:et=!1,self.postMessage({event:"JOB_RESUMED"});break;default:v.once("DOWNLOAD_COMPLETE",()=>{self.postMessage({event:"DOWNLOAD_COMPLETE"})}),v.on("FILE_UPDATED",K),v.on("CHUNK_DOWNLOADED",(r,n)=>{self.postMessage({event:"CHUNK_DOWNLOADED",chunk:{buffer:r,index:n}})}),dn(e).mapErr(r=>{Gt(e.args.lufiFile,r)})}};var dn=t=>{let{lufiFile:e}=t.args;return v.on("CHUNK_DOWNLOADED",()=>{Ze--,!et&&Ze{for(let r=1;r{await pt(e,r),Ze++,(et||Ze===Ot)&&Qe.pause()});Qe.start()}),pt(e,0)};export{Ot as QUEUE_CONCURRENCY_LIMIT,Ze as itemsInQueue,Qe as queue}; diff --git a/themes/default/public/js/worker/main.js b/themes/default/public/js/worker/main.js index 7b20f19..8b3268e 100644 --- a/themes/default/public/js/worker/main.js +++ b/themes/default/public/js/worker/main.js @@ -1 +1 @@ -var te=Object.create;var R=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ue=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ae=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of oe(e))!se.call(r,o)&&o!==t&&R(r,o,{get:()=>e[o],enumerable:!(n=ne(e,o))||n.enumerable});return r};var fe=(r,e,t)=>(t=r!=null?te(ie(r)):{},ae(e||!r||!r.__esModule?R(t,"default",{value:r,enumerable:!0}):t,r));var G=ue((Ae,M)=>{"use strict";var b=typeof Reflect=="object"?Reflect:null,U=b&&typeof b.apply=="function"?b.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},P;b&&typeof b.ownKeys=="function"?P=b.ownKeys:Object.getOwnPropertySymbols?P=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:P=function(e){return Object.getOwnPropertyNames(e)};function ce(r){console&&console.warn&&console.warn(r)}var T=Number.isNaN||function(e){return e!==e};function a(){a.init.call(this)}M.exports=a;M.exports.once=de;a.EventEmitter=a;a.prototype._events=void 0;a.prototype._eventsCount=0;a.prototype._maxListeners=void 0;var F=10;function x(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return F},set:function(r){if(typeof r!="number"||r<0||T(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");F=r}});a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};a.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||T(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function j(r){return r._maxListeners===void 0?a.defaultMaxListeners:r._maxListeners}a.prototype.getMaxListeners=function(){return j(this)};a.prototype.emit=function(e){for(var t=[],n=1;n0&&(i=t[0]),i instanceof Error)throw i;var f=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw f.context=i,f}var h=s[e];if(h===void 0)return!1;if(typeof h=="function")U(h,this,t);else for(var m=h.length,u=B(h,m),n=0;n0&&i.length>o&&!i.warned){i.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=i.length,ce(f)}return r}a.prototype.addListener=function(e,t){return N(this,e,t,!1)};a.prototype.on=a.prototype.addListener;a.prototype.prependListener=function(e,t){return N(this,e,t,!0)};function le(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function W(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},o=le.bind(n);return o.listener=t,n.wrapFn=o,o}a.prototype.once=function(e,t){return x(t),this.on(e,W(this,e,t)),this};a.prototype.prependOnceListener=function(e,t){return x(t),this.prependListener(e,W(this,e,t)),this};a.prototype.removeListener=function(e,t){var n,o,s,i,f;if(x(t),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){f=n[i].listener,s=i;break}if(s<0)return this;s===0?n.shift():he(n,s),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};a.prototype.off=a.prototype.removeListener;a.prototype.removeAllListeners=function(e){var t,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),i;for(o=0;o=0;o--)this.removeListener(e,t[o]);return this};function J(r,e,t){var n=r._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?t?[o.listener||o]:[o]:t?pe(o):B(o,o.length)}a.prototype.listeners=function(e){return J(this,e,!0)};a.prototype.rawListeners=function(e){return J(this,e,!1)};a.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):H.call(r,e)};a.prototype.listenerCount=H;function H(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?P(this._events):[]};function B(r,e){for(var t=new Array(e),n=0;n(u[u.ARCHIVE_ADD=0]="ARCHIVE_ADD",u[u.ARCHHIVE_COMPRESS=1]="ARCHHIVE_COMPRESS",u[u.CANCEL=2]="CANCEL",u[u.DOWNLOAD=3]="DOWNLOAD",u[u.INFOS=4]="INFOS",u[u.PAUSE=5]="PAUSE",u[u.PROVIDE_FILE=6]="PROVIDE_FILE",u[u.REMOVE=7]="REMOVE",u[u.RESUME=8]="RESUME",u[u.UPLOAD=9]="UPLOAD",u))(k||{});var ve={withStackTrace:!1},Q=(r,e,t=ve)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=t.withStackTrace?new Error().stack:void 0;return{data:n,message:r,stack:o}};function g(r,e,t,n){function o(s){return s instanceof t?s:new t(function(i){i(s)})}return new(t||(t=Promise))(function(s,i){function f(u){try{m(n.next(u))}catch(_){i(_)}}function h(u){try{m(n.throw(u))}catch(_){i(_)}}function m(u){u.done?s(u.value):o(u.value).then(f,h)}m((n=n.apply(r,e||[])).next())})}function q(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(r){return this instanceof v?(this.v=r,this):new v(r)}function z(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(c){return function(w){return Promise.resolve(w).then(c,_)}}function f(c,w){n[c]&&(o[c]=function(A){return new Promise(function(ee,re){s.push([c,A,ee,re])>1||h(c,A)})},w&&(o[c]=w(o[c])))}function h(c,w){try{m(n[c](w))}catch(A){C(s[0][3],A)}}function m(c){c.value instanceof v?Promise.resolve(c.value.v).then(u,_):C(s[0][2],c)}function u(c){h("next",c)}function _(c){h("throw",c)}function C(c,w){c(w),s.shift(),s.length&&h(s[0][0],s[0][1])}}function ye(r){var e,t;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,s){e[o]=r[o]?function(i){return(t=!t)?{value:v(r[o](i)),done:!1}:s?s(i):i}:s}}function Ee(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof q=="function"?q(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(i){return new Promise(function(f,h){i=r[s](i),o(f,h,i.done,i.value)})}}function o(s,i,f,h){Promise.resolve(h).then(function(m){s({value:m,done:f})},i)}}var y=class r{constructor(e){this._promise=e}static fromSafePromise(e){let t=e.then(n=>new d(n));return new r(t)}static fromPromise(e,t){let n=e.then(o=>new d(o)).catch(o=>new p(t(o)));return new r(n)}static fromThrowable(e,t){return(...n)=>new r(g(this,void 0,void 0,function*(){try{return new d(yield e(...n))}catch(o){return new p(t?t(o):o)}}))}static combine(e){return we(e)}static combineWithAllErrors(e){return Le(e)}map(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){return t.isErr()?new p(t.error):new d(yield e(t.value))})))}andThrough(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){if(t.isErr())return new p(t.error);let n=yield e(t.value);return n.isErr()?new p(n.error):new d(t.value)})))}andTee(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){if(t.isErr())return new p(t.error);try{yield e(t.value)}catch{}return new d(t.value)})))}mapErr(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){return t.isOk()?new d(t.value):new p(yield e(t.error))})))}andThen(e){return new r(this._promise.then(t=>{if(t.isErr())return new p(t.error);let n=e(t.value);return n instanceof r?n._promise:n}))}orElse(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){return t.isErr()?e(t.error):new d(t.value)})))}match(e,t){return this._promise.then(n=>n.match(e,t))}unwrapOr(e){return this._promise.then(t=>t.unwrapOr(e))}safeUnwrap(){return z(this,arguments,function*(){return yield v(yield v(yield*ye(Ee(yield v(this._promise.then(t=>t.safeUnwrap()))))))})}then(e,t){return this._promise.then(e,t)}[Symbol.asyncIterator](){return z(this,arguments,function*(){let t=yield v(this._promise);return t.isErr()&&(yield yield v(O(t.error))),yield v(t.value)})}};var O=r=>new y(Promise.resolve(new p(r))),ke=y.fromPromise,Ie=y.fromSafePromise,Se=y.fromThrowable,Z=r=>{let e=L([]);for(let t of r)if(t.isErr()){e=E(t.error);break}else e.map(n=>n.push(t.value));return e},we=r=>y.fromSafePromise(Promise.all(r)).andThen(Z),X=r=>{let e=L([]);for(let t of r)t.isErr()&&e.isErr()?e.error.push(t.error):t.isErr()&&e.isOk()?e=E([t.error]):t.isOk()&&e.isOk()&&e.value.push(t.value);return e},Le=r=>y.fromSafePromise(Promise.all(r)).andThen(X),I;(function(r){function e(o,s){return(...i)=>{try{let f=o(...i);return L(f)}catch(f){return E(s?s(f):f)}}}r.fromThrowable=e;function t(o){return Z(o)}r.combine=t;function n(o){return X(o)}r.combineWithAllErrors=n})(I||(I={}));var L=r=>new d(r);function E(r){return new p(r)}var d=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return L(e(this.value))}mapErr(e){return L(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(t=>this.value)}andTee(e){try{e(this.value)}catch{}return L(this.value)}orElse(e){return L(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return y.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,t){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw Q("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},p=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return E(this.error)}mapErr(e){return E(e(this.error))}andThrough(e){return E(this.error)}andTee(e){return E(this.error)}andThen(e){return E(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return O(this.error)}asyncAndThrough(e){return O(this.error)}asyncMap(e){return O(this.error)}unwrapOr(e){return e}match(e,t){return t(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield E(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw Q("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},Ce=I.fromThrowable;var be=()=>typeof Deno<"u";var D=r=>be()?new URL(`./worker/${r}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${r==="main"?`worker/${r}`:r}.js`));var S=new V.default,l,K=!1;self.onmessage=r=>{De(r),K||(K=!0,S.once("OPERATION_FAILED",()=>{l&&l.terminate()}))};var ge=(r,e)=>(Object.assign(r,e),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:r}),r),rr=(r,e)=>{ge(r,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:e})},De=(r,e)=>{let{action:t}=r.data;if(t===5||t===8)l.postMessage(r.data);else{switch(t){case 2:l=new Worker(D("cancel"),{type:"module"}),l.postMessage(r.data);break;case 3:l=new Worker(D("download"),{type:"module"}),l.postMessage(r.data);break;case 4:l=new Worker(D("infos"),{type:"module"}),l.postMessage(r.data);break;case 7:l=l||new Worker(D("remove"),{type:"module"}),l.postMessage(r.data);break;case 9:l=l||new Worker(D("upload"),{type:"module"}),l.postMessage(r.data);break;default:console.error("Action not found")}l.onmessage=n=>{e&&e(n),self.postMessage(n.data)},l.onerror=n=>{console.error(`Error: ${n.message}`)}}},tr=()=>{S.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),S.once("OPERATION_FAILED",r=>{self.postMessage({event:"OPERATION_FAILED",error:r})})},nr=r=>typeof r=="object"&&r!==null&&"action"in r&&Object.values(k).includes(r.action);export{S as events,tr as init,nr as isWorkerActionMessage,rr as sendFileError,ge as updateFile}; +var te=Object.create;var R=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var ue=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ae=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of oe(e))!ie.call(r,o)&&o!==t&&R(r,o,{get:()=>e[o],enumerable:!(n=ne(e,o))||n.enumerable});return r};var fe=(r,e,t)=>(t=r!=null?te(se(r)):{},ae(e||!r||!r.__esModule?R(t,"default",{value:r,enumerable:!0}):t,r));var G=ue((Ae,M)=>{"use strict";var b=typeof Reflect=="object"?Reflect:null,U=b&&typeof b.apply=="function"?b.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},P;b&&typeof b.ownKeys=="function"?P=b.ownKeys:Object.getOwnPropertySymbols?P=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:P=function(e){return Object.getOwnPropertyNames(e)};function ce(r){console&&console.warn&&console.warn(r)}var T=Number.isNaN||function(e){return e!==e};function a(){a.init.call(this)}M.exports=a;M.exports.once=me;a.EventEmitter=a;a.prototype._events=void 0;a.prototype._eventsCount=0;a.prototype._maxListeners=void 0;var F=10;function x(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return F},set:function(r){if(typeof r!="number"||r<0||T(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");F=r}});a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};a.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||T(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function j(r){return r._maxListeners===void 0?a.defaultMaxListeners:r._maxListeners}a.prototype.getMaxListeners=function(){return j(this)};a.prototype.emit=function(e){for(var t=[],n=1;n0&&(s=t[0]),s instanceof Error)throw s;var f=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw f.context=s,f}var h=i[e];if(h===void 0)return!1;if(typeof h=="function")U(h,this,t);else for(var d=h.length,u=B(h,d),n=0;n0&&s.length>o&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=s.length,ce(f)}return r}a.prototype.addListener=function(e,t){return N(this,e,t,!1)};a.prototype.on=a.prototype.addListener;a.prototype.prependListener=function(e,t){return N(this,e,t,!0)};function le(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function W(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},o=le.bind(n);return o.listener=t,n.wrapFn=o,o}a.prototype.once=function(e,t){return x(t),this.on(e,W(this,e,t)),this};a.prototype.prependOnceListener=function(e,t){return x(t),this.prependListener(e,W(this,e,t)),this};a.prototype.removeListener=function(e,t){var n,o,i,s,f;if(x(t),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){f=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():he(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};a.prototype.off=a.prototype.removeListener;a.prototype.removeAllListeners=function(e){var t,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,t[o]);return this};function J(r,e,t){var n=r._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?t?[o.listener||o]:[o]:t?pe(o):B(o,o.length)}a.prototype.listeners=function(e){return J(this,e,!0)};a.prototype.rawListeners=function(e){return J(this,e,!1)};a.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):H.call(r,e)};a.prototype.listenerCount=H;function H(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?P(this._events):[]};function B(r,e){for(var t=new Array(e),n=0;n(u[u.ARCHIVE_ADD=0]="ARCHIVE_ADD",u[u.ARCHHIVE_COMPRESS=1]="ARCHHIVE_COMPRESS",u[u.CANCEL=2]="CANCEL",u[u.DOWNLOAD=3]="DOWNLOAD",u[u.INFOS=4]="INFOS",u[u.PAUSE=5]="PAUSE",u[u.PROVIDE_FILE=6]="PROVIDE_FILE",u[u.REMOVE=7]="REMOVE",u[u.RESUME=8]="RESUME",u[u.UPLOAD=9]="UPLOAD",u))(k||{});var ve={withStackTrace:!1},Q=(r,e,t=ve)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=t.withStackTrace?new Error().stack:void 0;return{data:n,message:r,stack:o}};function g(r,e,t,n){function o(i){return i instanceof t?i:new t(function(s){s(i)})}return new(t||(t=Promise))(function(i,s){function f(u){try{d(n.next(u))}catch(_){s(_)}}function h(u){try{d(n.throw(u))}catch(_){s(_)}}function d(u){u.done?i(u.value):o(u.value).then(f,h)}d((n=n.apply(r,e||[])).next())})}function q(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(r){return this instanceof v?(this.v=r,this):new v(r)}function z(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(c){return function(w){return Promise.resolve(w).then(c,_)}}function f(c,w){n[c]&&(o[c]=function(A){return new Promise(function(ee,re){i.push([c,A,ee,re])>1||h(c,A)})},w&&(o[c]=w(o[c])))}function h(c,w){try{d(n[c](w))}catch(A){C(i[0][3],A)}}function d(c){c.value instanceof v?Promise.resolve(c.value.v).then(u,_):C(i[0][2],c)}function u(c){h("next",c)}function _(c){h("throw",c)}function C(c,w){c(w),i.shift(),i.length&&h(i[0][0],i[0][1])}}function ye(r){var e,t;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=r[o]?function(s){return(t=!t)?{value:v(r[o](s)),done:!1}:i?i(s):s}:i}}function Ee(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof q=="function"?q(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=r[i]&&function(s){return new Promise(function(f,h){s=r[i](s),o(f,h,s.done,s.value)})}}function o(i,s,f,h){Promise.resolve(h).then(function(d){i({value:d,done:f})},s)}}var y=class r{constructor(e){this._promise=e}static fromSafePromise(e){let t=e.then(n=>new m(n));return new r(t)}static fromPromise(e,t){let n=e.then(o=>new m(o)).catch(o=>new p(t(o)));return new r(n)}static fromThrowable(e,t){return(...n)=>new r(g(this,void 0,void 0,function*(){try{return new m(yield e(...n))}catch(o){return new p(t?t(o):o)}}))}static combine(e){return we(e)}static combineWithAllErrors(e){return Le(e)}map(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){return t.isErr()?new p(t.error):new m(yield e(t.value))})))}andThrough(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){if(t.isErr())return new p(t.error);let n=yield e(t.value);return n.isErr()?new p(n.error):new m(t.value)})))}andTee(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){if(t.isErr())return new p(t.error);try{yield e(t.value)}catch{}return new m(t.value)})))}mapErr(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){return t.isOk()?new m(t.value):new p(yield e(t.error))})))}andThen(e){return new r(this._promise.then(t=>{if(t.isErr())return new p(t.error);let n=e(t.value);return n instanceof r?n._promise:n}))}orElse(e){return new r(this._promise.then(t=>g(this,void 0,void 0,function*(){return t.isErr()?e(t.error):new m(t.value)})))}match(e,t){return this._promise.then(n=>n.match(e,t))}unwrapOr(e){return this._promise.then(t=>t.unwrapOr(e))}safeUnwrap(){return z(this,arguments,function*(){return yield v(yield v(yield*ye(Ee(yield v(this._promise.then(t=>t.safeUnwrap()))))))})}then(e,t){return this._promise.then(e,t)}[Symbol.asyncIterator](){return z(this,arguments,function*(){let t=yield v(this._promise);return t.isErr()&&(yield yield v(O(t.error))),yield v(t.value)})}};var O=r=>new y(Promise.resolve(new p(r))),ke=y.fromPromise,Ie=y.fromSafePromise,Se=y.fromThrowable,Z=r=>{let e=L([]);for(let t of r)if(t.isErr()){e=E(t.error);break}else e.map(n=>n.push(t.value));return e},we=r=>y.fromSafePromise(Promise.all(r)).andThen(Z),X=r=>{let e=L([]);for(let t of r)t.isErr()&&e.isErr()?e.error.push(t.error):t.isErr()&&e.isOk()?e=E([t.error]):t.isOk()&&e.isOk()&&e.value.push(t.value);return e},Le=r=>y.fromSafePromise(Promise.all(r)).andThen(X),I;(function(r){function e(o,i){return(...s)=>{try{let f=o(...s);return L(f)}catch(f){return E(i?i(f):f)}}}r.fromThrowable=e;function t(o){return Z(o)}r.combine=t;function n(o){return X(o)}r.combineWithAllErrors=n})(I||(I={}));var L=r=>new m(r);function E(r){return new p(r)}var m=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return L(e(this.value))}mapErr(e){return L(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(t=>this.value)}andTee(e){try{e(this.value)}catch{}return L(this.value)}orElse(e){return L(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return y.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,t){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw Q("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},p=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return E(this.error)}mapErr(e){return E(e(this.error))}andThrough(e){return E(this.error)}andTee(e){return E(this.error)}andThen(e){return E(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return O(this.error)}asyncAndThrough(e){return O(this.error)}asyncMap(e){return O(this.error)}unwrapOr(e){return e}match(e,t){return t(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield E(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw Q("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},Ce=I.fromThrowable;var be=()=>typeof Deno<"u";var D=r=>be()?new URL(`./worker/${r}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${r==="main"?`worker/${r}`:r}.js`));var S=new V.default,l,K=!1;self.onmessage=r=>{De(r),K||(K=!0,S.once("OPERATION_FAILED",()=>{l&&l.terminate()}))};var ge=(r,e)=>(Object.assign(r,e),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:r}),r),rr=(r,e)=>{ge(r,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:e})},De=(r,e)=>{let{action:t}=r.data;if(t===5||t===8)l.postMessage(r.data);else{switch(t){case 2:l=new Worker(D("cancel"),{type:"module"}),l.postMessage(r.data);break;case 3:l=new Worker(D("download"),{type:"module"}),l.postMessage(r.data);break;case 4:l=new Worker(D("infos"),{type:"module"}),l.postMessage(r.data);break;case 7:l=l||new Worker(D("remove"),{type:"module"}),l.postMessage(r.data);break;case 9:l=l||new Worker(D("upload"),{type:"module"}),l.postMessage(r.data);break;default:console.error("Action not found")}l.onmessage=n=>{e&&e(n),self.postMessage(n.data)},l.onerror=n=>{console.error(`Error: ${n.message}`)}}},tr=()=>{S.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),S.once("OPERATION_FAILED",r=>{self.postMessage({event:"OPERATION_FAILED",error:r})})},nr=r=>typeof r=="object"&&r!==null&&"action"in r&&Object.values(k).includes(r.action);export{S as events,tr as init,nr as isWorkerActionMessage,rr as sendFileError,ge as updateFile}; diff --git a/themes/default/public/js/worker/remove.js b/themes/default/public/js/worker/remove.js index 0dedcd3..0de5de4 100644 --- a/themes/default/public/js/worker/remove.js +++ b/themes/default/public/js/worker/remove.js @@ -1 +1 @@ -var ue=Object.create;var C=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var he=(r,e,t)=>e in r?C(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var me=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of fe(e))!le.call(r,o)&&o!==t&&C(r,o,{get:()=>e[o],enumerable:!(n=ae(e,o))||n.enumerable});return r};var de=(r,e,t)=>(t=r!=null?ue(ce(r)):{},me(e||!r||!r.__esModule?C(t,"default",{value:r,enumerable:!0}):t,r));var g=(r,e,t)=>he(r,typeof e!="symbol"?e+"":e,t);var ee=pe((Ke,U)=>{"use strict";var A=typeof Reflect=="object"?Reflect:null,$=A&&typeof A.apply=="function"?A.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},P;A&&typeof A.ownKeys=="function"?P=A.ownKeys:Object.getOwnPropertySymbols?P=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:P=function(e){return Object.getOwnPropertyNames(e)};function ge(r){console&&console.warn&&console.warn(r)}var q=Number.isNaN||function(e){return e!==e};function u(){u.init.call(this)}U.exports=u;U.exports.once=Ae;u.EventEmitter=u;u.prototype._events=void 0;u.prototype._eventsCount=0;u.prototype._maxListeners=void 0;var G=10;function M(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return G},set:function(r){if(typeof r!="number"||r<0||q(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");G=r}});u.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};u.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||q(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function z(r){return r._maxListeners===void 0?u.defaultMaxListeners:r._maxListeners}u.prototype.getMaxListeners=function(){return z(this)};u.prototype.emit=function(e){for(var t=[],n=1;n0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")$(l,this,t);else for(var v=l.length,m=K(l,v),n=0;n0&&i.length>o&&!i.warned){i.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=i.length,ge(a)}return r}u.prototype.addListener=function(e,t){return Q(this,e,t,!1)};u.prototype.on=u.prototype.addListener;u.prototype.prependListener=function(e,t){return Q(this,e,t,!0)};function be(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Z(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},o=be.bind(n);return o.listener=t,n.wrapFn=o,o}u.prototype.once=function(e,t){return M(t),this.on(e,Z(this,e,t)),this};u.prototype.prependOnceListener=function(e,t){return M(t),this.prependListener(e,Z(this,e,t)),this};u.prototype.removeListener=function(e,t){var n,o,s,i,a;if(M(t),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){a=n[i].listener,s=i;break}if(s<0)return this;s===0?n.shift():De(n,s),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};u.prototype.off=u.prototype.removeListener;u.prototype.removeAllListeners=function(e){var t,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),i;for(o=0;o=0;o--)this.removeListener(e,t[o]);return this};function X(r,e,t){var n=r._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?t?[o.listener||o]:[o]:t?Oe(o):K(o,o.length)}u.prototype.listeners=function(e){return X(this,e,!0)};u.prototype.rawListeners=function(e){return X(this,e,!1)};u.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Y.call(r,e)};u.prototype.listenerCount=Y;function Y(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}u.prototype.eventNames=function(){return this._eventsCount>0?P(this._events):[]};function K(r,e){for(var t=new Array(e),n=0;n{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=t.withStackTrace?new Error().stack:void 0;return{data:n,message:r,stack:o}};function b(r,e,t,n){function o(s){return s instanceof t?s:new t(function(i){i(s)})}return new(t||(t=Promise))(function(s,i){function a(m){try{v(n.next(m))}catch(_){i(_)}}function l(m){try{v(n.throw(m))}catch(_){i(_)}}function v(m){m.done?s(m.value):o(m.value).then(a,l)}v((n=n.apply(r,e||[])).next())})}function N(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function E(r){return this instanceof E?(this.v=r,this):new E(r)}function W(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(w){return Promise.resolve(w).then(f,_)}}function a(f,w){n[f]&&(o[f]=function(x){return new Promise(function(se,ie){s.push([f,x,se,ie])>1||l(f,x)})},w&&(o[f]=w(o[f])))}function l(f,w){try{v(n[f](w))}catch(x){j(s[0][3],x)}}function v(f){f.value instanceof E?Promise.resolve(f.value.v).then(m,_):j(s[0][2],f)}function m(f){l("next",f)}function _(f){l("throw",f)}function j(f,w){f(w),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Ee(r){var e,t;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,s){e[o]=r[o]?function(i){return(t=!t)?{value:E(r[o](i)),done:!1}:s?s(i):i}:s}}function ye(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof N=="function"?N(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(i){return new Promise(function(a,l){i=r[s](i),o(a,l,i.done,i.value)})}}function o(s,i,a,l){Promise.resolve(l).then(function(v){s({value:v,done:a})},i)}}var p=class r{constructor(e){this._promise=e}static fromSafePromise(e){let t=e.then(n=>new d(n));return new r(t)}static fromPromise(e,t){let n=e.then(o=>new d(o)).catch(o=>new h(t(o)));return new r(n)}static fromThrowable(e,t){return(...n)=>new r(b(this,void 0,void 0,function*(){try{return new d(yield e(...n))}catch(o){return new h(t?t(o):o)}}))}static combine(e){return we(e)}static combineWithAllErrors(e){return Le(e)}map(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){return t.isErr()?new h(t.error):new d(yield e(t.value))})))}andThrough(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){if(t.isErr())return new h(t.error);let n=yield e(t.value);return n.isErr()?new h(n.error):new d(t.value)})))}andTee(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){if(t.isErr())return new h(t.error);try{yield e(t.value)}catch{}return new d(t.value)})))}mapErr(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){return t.isOk()?new d(t.value):new h(yield e(t.error))})))}andThen(e){return new r(this._promise.then(t=>{if(t.isErr())return new h(t.error);let n=e(t.value);return n instanceof r?n._promise:n}))}orElse(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){return t.isErr()?e(t.error):new d(t.value)})))}match(e,t){return this._promise.then(n=>n.match(e,t))}unwrapOr(e){return this._promise.then(t=>t.unwrapOr(e))}safeUnwrap(){return W(this,arguments,function*(){return yield E(yield E(yield*Ee(ye(yield E(this._promise.then(t=>t.safeUnwrap()))))))})}then(e,t){return this._promise.then(e,t)}[Symbol.asyncIterator](){return W(this,arguments,function*(){let t=yield E(this._promise);return t.isErr()&&(yield yield E(k(t.error))),yield E(t.value)})}};var k=r=>new p(Promise.resolve(new h(r))),Ce=p.fromPromise,Fe=p.fromSafePromise,Re=p.fromThrowable,H=r=>{let e=L([]);for(let t of r)if(t.isErr()){e=y(t.error);break}else e.map(n=>n.push(t.value));return e},we=r=>p.fromSafePromise(Promise.all(r)).andThen(H),B=r=>{let e=L([]);for(let t of r)t.isErr()&&e.isErr()?e.error.push(t.error):t.isErr()&&e.isOk()?e=y([t.error]):t.isOk()&&e.isOk()&&e.value.push(t.value);return e},Le=r=>p.fromSafePromise(Promise.all(r)).andThen(B),F;(function(r){function e(o,s){return(...i)=>{try{let a=o(...i);return L(a)}catch(a){return y(s?s(a):a)}}}r.fromThrowable=e;function t(o){return H(o)}r.combine=t;function n(o){return B(o)}r.combineWithAllErrors=n})(F||(F={}));var L=r=>new d(r);function y(r){return new h(r)}var d=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return L(e(this.value))}mapErr(e){return L(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(t=>this.value)}andTee(e){try{e(this.value)}catch{}return L(this.value)}orElse(e){return L(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return p.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,t){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw J("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},h=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return y(this.error)}mapErr(e){return y(e(this.error))}andThrough(e){return y(this.error)}andTee(e){return y(this.error)}andThen(e){return y(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return k(this.error)}asyncAndThrough(e){return k(this.error)}asyncMap(e){return k(this.error)}unwrapOr(e){return e}match(e,t){return t(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield y(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw J("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},Ue=F.fromThrowable;var D=class extends Error{constructor(t,n={}){let{cause:o,context:s}=n;super(t,{cause:o});g(this,"context");this.name=this.constructor.name,this.context=s}};var R=r=>{if(r instanceof Error)return r;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(r)}catch{}return new Error(e)};var _e=()=>typeof Deno<"u";var O=r=>_e()?new URL(`./worker/${r}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${r==="main"?`worker/${r}`:r}.js`));var te=de(ee());var T=new te.default,c,re=!1;self.onmessage=r=>{Pe(r),re||(re=!0,T.once("OPERATION_FAILED",()=>{c&&c.terminate()}))};var Pe=(r,e)=>{let{action:t}=r.data;if(t===5||t===8)c.postMessage(r.data);else{switch(t){case 2:c=new Worker(O("cancel"),{type:"module"}),c.postMessage(r.data);break;case 3:c=new Worker(O("download"),{type:"module"}),c.postMessage(r.data);break;case 4:c=new Worker(O("infos"),{type:"module"}),c.postMessage(r.data);break;case 7:c=c||new Worker(O("remove"),{type:"module"}),c.postMessage(r.data);break;case 9:c=c||new Worker(O("upload"),{type:"module"}),c.postMessage(r.data);break;default:console.error("Action not found")}c.onmessage=n=>{e&&e(n),self.postMessage(n.data)},c.onerror=n=>{console.error(`Error: ${n.message}`)}}},ne=()=>{T.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),T.once("OPERATION_FAILED",r=>{self.postMessage({event:"OPERATION_FAILED",error:r})})};var I=class extends D{};var S=class extends I{constructor(){super(...arguments);g(this,"message","Failed to remove the file")}};var oe=!1;self.onmessage=r=>{oe||(ne(),oe=!0),Me(r.data).map(()=>{self.postMessage({event:"FILE_REMOVED"})}).mapErr(e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var Me=r=>p.fromPromise(new Promise((e,t)=>{let n=r.args.lufiFile;fetch(`${new URL(n.serverUrl).href}d/${n.keys.server}/${n.actionToken}`).then(o=>o.ok?e(void 0):t(new S(void 0,{cause:R(o.statusText)})))}),e=>R(e)); +var ue=Object.create;var C=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var he=(r,e,t)=>e in r?C(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var me=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of fe(e))!le.call(r,o)&&o!==t&&C(r,o,{get:()=>e[o],enumerable:!(n=ae(e,o))||n.enumerable});return r};var de=(r,e,t)=>(t=r!=null?ue(ce(r)):{},me(e||!r||!r.__esModule?C(t,"default",{value:r,enumerable:!0}):t,r));var g=(r,e,t)=>he(r,typeof e!="symbol"?e+"":e,t);var ee=pe((Ke,T)=>{"use strict";var A=typeof Reflect=="object"?Reflect:null,$=A&&typeof A.apply=="function"?A.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},P;A&&typeof A.ownKeys=="function"?P=A.ownKeys:Object.getOwnPropertySymbols?P=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:P=function(e){return Object.getOwnPropertyNames(e)};function ge(r){console&&console.warn&&console.warn(r)}var q=Number.isNaN||function(e){return e!==e};function u(){u.init.call(this)}T.exports=u;T.exports.once=Ae;u.EventEmitter=u;u.prototype._events=void 0;u.prototype._eventsCount=0;u.prototype._maxListeners=void 0;var G=10;function M(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return G},set:function(r){if(typeof r!="number"||r<0||q(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");G=r}});u.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};u.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||q(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function z(r){return r._maxListeners===void 0?u.defaultMaxListeners:r._maxListeners}u.prototype.getMaxListeners=function(){return z(this)};u.prototype.emit=function(e){for(var t=[],n=1;n0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")$(l,this,t);else for(var v=l.length,m=K(l,v),n=0;n0&&i.length>o&&!i.warned){i.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=i.length,ge(a)}return r}u.prototype.addListener=function(e,t){return Q(this,e,t,!1)};u.prototype.on=u.prototype.addListener;u.prototype.prependListener=function(e,t){return Q(this,e,t,!0)};function be(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Z(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},o=be.bind(n);return o.listener=t,n.wrapFn=o,o}u.prototype.once=function(e,t){return M(t),this.on(e,Z(this,e,t)),this};u.prototype.prependOnceListener=function(e,t){return M(t),this.prependListener(e,Z(this,e,t)),this};u.prototype.removeListener=function(e,t){var n,o,s,i,a;if(M(t),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){a=n[i].listener,s=i;break}if(s<0)return this;s===0?n.shift():De(n,s),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};u.prototype.off=u.prototype.removeListener;u.prototype.removeAllListeners=function(e){var t,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),i;for(o=0;o=0;o--)this.removeListener(e,t[o]);return this};function X(r,e,t){var n=r._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?t?[o.listener||o]:[o]:t?Oe(o):K(o,o.length)}u.prototype.listeners=function(e){return X(this,e,!0)};u.prototype.rawListeners=function(e){return X(this,e,!1)};u.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Y.call(r,e)};u.prototype.listenerCount=Y;function Y(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}u.prototype.eventNames=function(){return this._eventsCount>0?P(this._events):[]};function K(r,e){for(var t=new Array(e),n=0;n{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=t.withStackTrace?new Error().stack:void 0;return{data:n,message:r,stack:o}};function b(r,e,t,n){function o(s){return s instanceof t?s:new t(function(i){i(s)})}return new(t||(t=Promise))(function(s,i){function a(m){try{v(n.next(m))}catch(_){i(_)}}function l(m){try{v(n.throw(m))}catch(_){i(_)}}function v(m){m.done?s(m.value):o(m.value).then(a,l)}v((n=n.apply(r,e||[])).next())})}function N(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function E(r){return this instanceof E?(this.v=r,this):new E(r)}function W(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(w){return Promise.resolve(w).then(f,_)}}function a(f,w){n[f]&&(o[f]=function(x){return new Promise(function(se,ie){s.push([f,x,se,ie])>1||l(f,x)})},w&&(o[f]=w(o[f])))}function l(f,w){try{v(n[f](w))}catch(x){j(s[0][3],x)}}function v(f){f.value instanceof E?Promise.resolve(f.value.v).then(m,_):j(s[0][2],f)}function m(f){l("next",f)}function _(f){l("throw",f)}function j(f,w){f(w),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Ee(r){var e,t;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,s){e[o]=r[o]?function(i){return(t=!t)?{value:E(r[o](i)),done:!1}:s?s(i):i}:s}}function ye(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof N=="function"?N(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(i){return new Promise(function(a,l){i=r[s](i),o(a,l,i.done,i.value)})}}function o(s,i,a,l){Promise.resolve(l).then(function(v){s({value:v,done:a})},i)}}var p=class r{constructor(e){this._promise=e}static fromSafePromise(e){let t=e.then(n=>new d(n));return new r(t)}static fromPromise(e,t){let n=e.then(o=>new d(o)).catch(o=>new h(t(o)));return new r(n)}static fromThrowable(e,t){return(...n)=>new r(b(this,void 0,void 0,function*(){try{return new d(yield e(...n))}catch(o){return new h(t?t(o):o)}}))}static combine(e){return we(e)}static combineWithAllErrors(e){return Le(e)}map(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){return t.isErr()?new h(t.error):new d(yield e(t.value))})))}andThrough(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){if(t.isErr())return new h(t.error);let n=yield e(t.value);return n.isErr()?new h(n.error):new d(t.value)})))}andTee(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){if(t.isErr())return new h(t.error);try{yield e(t.value)}catch{}return new d(t.value)})))}mapErr(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){return t.isOk()?new d(t.value):new h(yield e(t.error))})))}andThen(e){return new r(this._promise.then(t=>{if(t.isErr())return new h(t.error);let n=e(t.value);return n instanceof r?n._promise:n}))}orElse(e){return new r(this._promise.then(t=>b(this,void 0,void 0,function*(){return t.isErr()?e(t.error):new d(t.value)})))}match(e,t){return this._promise.then(n=>n.match(e,t))}unwrapOr(e){return this._promise.then(t=>t.unwrapOr(e))}safeUnwrap(){return W(this,arguments,function*(){return yield E(yield E(yield*Ee(ye(yield E(this._promise.then(t=>t.safeUnwrap()))))))})}then(e,t){return this._promise.then(e,t)}[Symbol.asyncIterator](){return W(this,arguments,function*(){let t=yield E(this._promise);return t.isErr()&&(yield yield E(k(t.error))),yield E(t.value)})}};var k=r=>new p(Promise.resolve(new h(r))),Ce=p.fromPromise,Fe=p.fromSafePromise,Re=p.fromThrowable,H=r=>{let e=L([]);for(let t of r)if(t.isErr()){e=y(t.error);break}else e.map(n=>n.push(t.value));return e},we=r=>p.fromSafePromise(Promise.all(r)).andThen(H),B=r=>{let e=L([]);for(let t of r)t.isErr()&&e.isErr()?e.error.push(t.error):t.isErr()&&e.isOk()?e=y([t.error]):t.isOk()&&e.isOk()&&e.value.push(t.value);return e},Le=r=>p.fromSafePromise(Promise.all(r)).andThen(B),F;(function(r){function e(o,s){return(...i)=>{try{let a=o(...i);return L(a)}catch(a){return y(s?s(a):a)}}}r.fromThrowable=e;function t(o){return H(o)}r.combine=t;function n(o){return B(o)}r.combineWithAllErrors=n})(F||(F={}));var L=r=>new d(r);function y(r){return new h(r)}var d=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return L(e(this.value))}mapErr(e){return L(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(t=>this.value)}andTee(e){try{e(this.value)}catch{}return L(this.value)}orElse(e){return L(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return p.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,t){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw J("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},h=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return y(this.error)}mapErr(e){return y(e(this.error))}andThrough(e){return y(this.error)}andTee(e){return y(this.error)}andThen(e){return y(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return k(this.error)}asyncAndThrough(e){return k(this.error)}asyncMap(e){return k(this.error)}unwrapOr(e){return e}match(e,t){return t(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield y(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw J("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},Te=F.fromThrowable;var D=class extends Error{constructor(t,n={}){let{cause:o,context:s}=n;super(t,{cause:o});g(this,"context");this.name=this.constructor.name,this.context=s}};var R=r=>{if(r instanceof Error)return r;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(r)}catch{}return new Error(e)};var _e=()=>typeof Deno<"u";var O=r=>_e()?new URL(`./worker/${r}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${r==="main"?`worker/${r}`:r}.js`));var te=de(ee());var U=new te.default,c,re=!1;self.onmessage=r=>{Pe(r),re||(re=!0,U.once("OPERATION_FAILED",()=>{c&&c.terminate()}))};var Pe=(r,e)=>{let{action:t}=r.data;if(t===5||t===8)c.postMessage(r.data);else{switch(t){case 2:c=new Worker(O("cancel"),{type:"module"}),c.postMessage(r.data);break;case 3:c=new Worker(O("download"),{type:"module"}),c.postMessage(r.data);break;case 4:c=new Worker(O("infos"),{type:"module"}),c.postMessage(r.data);break;case 7:c=c||new Worker(O("remove"),{type:"module"}),c.postMessage(r.data);break;case 9:c=c||new Worker(O("upload"),{type:"module"}),c.postMessage(r.data);break;default:console.error("Action not found")}c.onmessage=n=>{e&&e(n),self.postMessage(n.data)},c.onerror=n=>{console.error(`Error: ${n.message}`)}}},ne=()=>{U.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),U.once("OPERATION_FAILED",r=>{self.postMessage({event:"OPERATION_FAILED",error:r})})};var I=class extends D{};var S=class extends I{constructor(){super(...arguments);g(this,"message","Failed to remove the file")}};var oe=!1;self.onmessage=r=>{oe||(ne(),oe=!0),Me(r.data).map(()=>{self.postMessage({event:"FILE_REMOVED"})}).mapErr(e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var Me=r=>p.fromPromise(new Promise((e,t)=>{let n=r.args.lufiFile;fetch(`${new URL(n.serverUrl).href}d/${n.keys.server}/${n.actionToken}`).then(o=>o.ok?e(void 0):t(new S(void 0,{cause:R(o.statusText)})))}),e=>R(e));