diff --git a/themes/default/public/js/lufi.js b/themes/default/public/js/lufi.js index c31a3fc..2f0019a 100755 --- a/themes/default/public/js/lufi.js +++ b/themes/default/public/js/lufi.js @@ -1 +1 @@ -var _t=Object.create;var me=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var It=(t,e,r)=>e in t?me(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ft=(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 Ke=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Tt=(t,e)=>{for(var r in e)me(t,r,{get:e[r],enumerable:!0})},Mt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kt(e))!St.call(t,i)&&i!==r&&me(t,i,{get:()=>e[i],enumerable:!(n=Rt(e,i))||n.enumerable});return t};var Ie=(t,e,r)=>(r=t!=null?_t(Pt(t)):{},Mt(e||!t||!t.__esModule?me(r,"default",{value:t,enumerable:!0}):r,t));var l=(t,e,r)=>It(t,typeof e!="symbol"?e+"":e,r);var Te=Ke((wr,Fe)=>{"use strict";var q=typeof Reflect=="object"?Reflect:null,qe=q&&typeof q.apply=="function"?q.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ye;q&&typeof q.ownKeys=="function"?ye=q.ownKeys:Object.getOwnPropertySymbols?ye=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ye=function(e){return Object.getOwnPropertyNames(e)};function Ut(t){console&&console.warn&&console.warn(t)}var Ve=Number.isNaN||function(e){return e!==e};function v(){v.init.call(this)}Fe.exports=v;Fe.exports.once=Jt;v.EventEmitter=v;v.prototype._events=void 0;v.prototype._eventsCount=0;v.prototype._maxListeners=void 0;var $e=10;function ve(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return $e},set:function(t){if(typeof t!="number"||t<0||Ve(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");$e=t}});v.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};v.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ve(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 Qe(t){return t._maxListeners===void 0?v.defaultMaxListeners:t._maxListeners}v.prototype.getMaxListeners=function(){return Qe(this)};v.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 u=o[e];if(u===void 0)return!1;if(typeof u=="function")qe(u,this,r);else for(var f=u.length,h=tt(u,f),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,Ut(a)}return t}v.prototype.addListener=function(e,r){return Xe(this,e,r,!1)};v.prototype.on=v.prototype.addListener;v.prototype.prependListener=function(e,r){return Xe(this,e,r,!0)};function Bt(){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 Ze(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Bt.bind(n);return i.listener=r,n.wrapFn=i,i}v.prototype.once=function(e,r){return ve(r),this.on(e,Ze(this,e,r)),this};v.prototype.prependOnceListener=function(e,r){return ve(r),this.prependListener(e,Ze(this,e,r)),this};v.prototype.removeListener=function(e,r){var n,i,o,s,a;if(ve(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():Nt(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};v.prototype.off=v.prototype.removeListener;v.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 Ye(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?jt(i):tt(i,i.length)}v.prototype.listeners=function(e){return Ye(this,e,!0)};v.prototype.rawListeners=function(e){return Ye(this,e,!1)};v.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):et.call(t,e)};v.prototype.listenerCount=et;function et(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}v.prototype.eventNames=function(){return this._eventsCount>0?ye(this._events):[]};function tt(t,e){for(var r=new Array(e),n=0;n{"use strict";var c={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}}};c.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 c.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]]};c.cipher.aes.prototype={encrypt:function(t){return lt(this,t,0)},decrypt:function(t){return lt(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=[],u=[],f,h,p,d;for(i=0;256>i;i++)u[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=f||1,s=u[s]||1)for(p=s^s<<1^s<<2^s<<3^s<<4,p=p>>8^p&255^99,r[o]=p,n[p]=o,h=a[i=a[f=a[o]]],d=16843009*h^65537*i^257*f^16843008*o,h=257*a[p]^16843008*p,i=0;4>i;i++)t[i][o]=h=h<<24^h>>>8,e[i][p]=d=d<<24^d>>>8;for(i=0;5>i;i++)t[i]=t[i].slice(0),e[i]=e[i].slice(0)}};function lt(t,e,r){if(e.length!==4)throw new c.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,u,f,h=n.length/4-2,p,d=4,m=[0,0,0,0];a=t.w[r],t=a[0];var E=a[1],R=a[2],S=a[3],J=a[4];for(p=0;p>>24]^E[o>>16&255]^R[s>>8&255]^S[e&255]^n[d],u=t[o>>>24]^E[s>>16&255]^R[e>>8&255]^S[i&255]^n[d+1],f=t[s>>>24]^E[e>>16&255]^R[i>>8&255]^S[o&255]^n[d+2],e=t[e>>>24]^E[i>>16&255]^R[o>>8&255]^S[s&255]^n[d+3],d+=4,i=a,o=u,s=f;for(p=0;4>p;p++)m[r?3&-p:p]=J[i>>>24]<<24^J[o>>16&255]<<16^J[s>>8&255]<<8^J[e&255]^n[d++],a=i,i=o,o=s,s=e,e=a;return m}c.bitArray={bitSlice:function(t,e,r){return t=c.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:c.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(c.bitArray.bitLength(t)!==c.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=c.bitArray.getPartial(i),n.push(c.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};c.codec.utf8String={fromBits:function(t){var e="",r=c.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=c.codec.base64.S,s=0,a;for(e&&(o=o.substr(0,62)+"-_"),n=0;na)throw new c.exception.invalid("this isn't base64!");26>>i),s=a<<32-i):(i+=6,s^=a<<32-i)}return i&56&&r.push(c.bitArray.partial(i&56,s,1)),r}};c.codec.base64url={fromBits:function(t){return c.codec.base64.fromBits(t,1,1)},toBits:function(t){return c.codec.base64.toBits(t,1)}};c.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()};c.hash.sha256.hash=function(t){return new c.hash.sha256().update(t).finalize()};c.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=c.codec.utf8String.toBits(t));var e,r=this.f=c.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+c.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],u=i[2],f=i[3],h=i[4],p=i[5],d=i[6],m=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+m+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(d^h&(p^d))+o[e],m=d,d=p,p=h,h=f+r|0,f=u,u=a,a=s,s=r+(a&u^f&(a^u))+(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]+u|0,i[3]=i[3]+f|0,i[4]=i[4]+h|0,i[5]=i[5]+p|0,i[6]=i[6]+d|0,i[7]=i[7]+m|0}};c.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()};c.hash.sha512.hash=function(t){return new c.hash.sha512().update(t).finalize()};c.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=c.codec.utf8String.toBits(t));var e,r=this.f=c.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+c.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],u=n[3],f=n[4],h=n[5],p=n[6],d=n[7],m=n[8],E=n[9],R=n[10],S=n[11],J=n[12],he=n[13],We=n[14],le=n[15],D;if(typeof Uint32Array<"u"){D=Array(160);for(var b=0;32>b;b++)D[b]=t[b]}else D=t;var b=o,C=s,Y=a,G=u,ee=f,K=h,Re=p,te=d,I=m,_=E,pe=R,re=S,de=J,ne=he,ke=We,ie=le;for(t=0;80>t;t++){if(16>t)e=D[2*t],r=D[2*t+1];else{r=D[2*(t-15)];var w=D[2*(t-15)+1];e=(w<<31|r>>>1)^(w<<24|r>>>8)^r>>>7;var F=(r<<31|w>>>1)^(r<<24|w>>>8)^(r<<25|w>>>7);r=D[2*(t-2)];var M=D[2*(t-2)+1],w=(M<<13|r>>>19)^(r<<3|M>>>29)^r>>>6,M=(r<<13|M>>>19)^(M<<3|r>>>29)^(r<<26|M>>>6),Pe=D[2*(t-7)],Se=D[2*(t-16)],oe=D[2*(t-16)+1];r=F+D[2*(t-7)+1],e=e+Pe+(r>>>0>>0?1:0),r+=M,e+=w+(r>>>0>>0?1:0),r+=oe,e+=Se+(r>>>0>>0?1:0)}D[2*t]=e|=0,D[2*t+1]=r|=0;var Pe=I&pe^~I&de,ze=_&re^~_&ne,M=b&Y^b&ee^Y&ee,Ot=C&G^C&K^G&K,Se=(C<<4|b>>>28)^(b<<30|C>>>2)^(b<<25|C>>>7),oe=(b<<4|C>>>28)^(C<<30|b>>>2)^(C<<25|b>>>7),Ct=i[2*t],Ge=i[2*t+1],w=ie+((I<<18|_>>>14)^(I<<14|_>>>18)^(_<<23|I>>>9)),F=ke+((_<<18|I>>>14)^(_<<14|I>>>18)^(I<<23|_>>>9))+(w>>>0>>0?1:0),w=w+ze,F=F+(Pe+(w>>>0>>0?1:0)),w=w+Ge,F=F+(Ct+(w>>>0>>0?1:0)),w=w+r|0,F=F+(e+(w>>>0>>0?1:0));r=oe+Ot,e=Se+M+(r>>>0>>0?1:0),ke=de,ie=ne,de=pe,ne=re,pe=I,re=_,_=te+w|0,I=Re+F+(_>>>0>>0?1:0)|0,Re=ee,te=K,ee=Y,K=G,Y=b,G=C,C=w+r|0,b=F+e+(C>>>0>>0?1:0)|0}s=n[1]=s+C|0,n[0]=o+b+(s>>>0>>0?1:0)|0,u=n[3]=u+G|0,n[2]=a+Y+(u>>>0>>0?1:0)|0,h=n[5]=h+K|0,n[4]=f+ee+(h>>>0>>0?1:0)|0,d=n[7]=d+te|0,n[6]=p+Re+(d>>>0>>0?1:0)|0,E=n[9]=E+_|0,n[8]=m+I+(E>>>0<_>>>0?1:0)|0,S=n[11]=S+re|0,n[10]=R+pe+(S>>>0>>0?1:0)|0,he=n[13]=he+ne|0,n[12]=J+de+(he>>>0>>0?1:0)|0,le=n[15]=le+ie|0,n[14]=We+ke+(le>>>0>>0?1:0)|0}};c.mode.ccm={name:"ccm",F:[],listenProgress:function(t){c.mode.ccm.F.push(t)},unListenProgress:function(t){t=c.mode.ccm.F.indexOf(t),-1u)throw new c.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&f>>>8*o;o++);return o<15-u&&(o=15-u),r=a.clamp(r,8*(15-o)),e=c.mode.ccm.U(t,e,r,n,i,o),s=c.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=c.bitArray,s=o.bitLength(r)/8,f=o.bitLength(e),a=o.clamp(e,f-i),u=o.bitSlice(e,f-i),f=(f-i)/8;if(7>s)throw new c.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=o.clamp(r,8*(15-e)),a=c.mode.ccm.V(t,a,r,u,i,e),t=c.mode.ccm.U(t,a.data,r,n,i,e),!o.equal(a.tag,t))throw new c.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,i,o){var s=[],a=c.bitArray,u=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&&(c.mode.ccm.da(s/u),h+=p),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,f)}}};c.misc.hmac=function(t,e){this.W=e=e||c.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 c.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=c.codec.utf8String.toBits(t)),typeof e=="string"&&(e=c.codec.utf8String.toBits(e)),i=i||c.misc.hmac,t=new i(t);var o,s,a,u,f=[],h=c.bitArray;for(u=1;32*f.length<(n||1);u++){for(i=o=t.encrypt(h.concat(e,[u])),s=1;ss;s++)i.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=o),this.N++,this.b=c.hash.sha256.hash(this.b.concat(i)),this.K=new c.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:u=1}if(u)throw new c.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&&pt("seeded",Math.max(this.u,this.i)),pt("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:ce(this,this.la),mouseCollector:ce(this,this.na),keyboardCollector:ce(this,this.ja),accelerometerCollector:ce(this,this.ca),touchCollector:ce(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 c.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 ce(t,e){return function(){e.apply(t,arguments)}}c.random=new c.prng(6);e:try{if(Ae=typeof X<"u"&&X.exports){try{Le=Ft("crypto")}catch{Le=null}Ae=Ee=Le}if(Ae&&Ee.randomBytes)ae=Ee.randomBytes(128),ae=new Uint32Array(new Uint8Array(ae).buffer),c.random.addEntropy(ae,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(ue=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(ue);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(ue);else break e;c.random.addEntropy(ue,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 ae,Ee,ue,Ae,Le;c.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=c.json,o=i.j({iv:c.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=c.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=c.codec.base64.toBits(o.iv)),!c.mode[o.mode]||!c.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||4Lt,cancel:()=>cr,compress:()=>bt,decompress:()=>ar,download:()=>ur,events:()=>_e,getFileIndexInQueue:()=>vr,infos:()=>fr,pause:()=>hr,remove:()=>lr,resume:()=>pr,upload:()=>mr});var At=Ie(Te());var Wt={withStackTrace:!1},ot=(t,e,r=Wt)=>{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 $(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{f(n.next(h))}catch(p){s(p)}}function u(h){try{f(n.throw(h))}catch(p){s(p)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(t,e||[])).next())})}function nt(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 U(t){return this instanceof U?(this.v=t,this):new U(t)}function it(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(m){return function(E){return Promise.resolve(E).then(m,p)}}function a(m,E){n[m]&&(i[m]=function(R){return new Promise(function(S,J){o.push([m,R,S,J])>1||u(m,R)})},E&&(i[m]=E(i[m])))}function u(m,E){try{f(n[m](E))}catch(R){d(o[0][3],R)}}function f(m){m.value instanceof U?Promise.resolve(m.value.v).then(h,p):d(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function d(m,E){m(E),o.shift(),o.length&&u(o[0][0],o[0][1])}}function zt(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:U(t[i](s)),done:!1}:o?o(s):s}:o}}function Gt(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 nt=="function"?nt(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,u){s=t[o](s),i(a,u,s.done,s.value)})}}function i(o,s,a,u){Promise.resolve(u).then(function(f){o({value:f,done:a})},s)}}var y=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new k(n));return new t(r)}static fromPromise(e,r){let n=e.then(i=>new k(i)).catch(i=>new P(r(i)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t($(this,void 0,void 0,function*(){try{return new k(yield e(...n))}catch(i){return new P(r?r(i):i)}}))}static combine(e){return Kt(e)}static combineWithAllErrors(e){return qt(e)}map(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){return r.isErr()?new P(r.error):new k(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){if(r.isErr())return new P(r.error);let n=yield e(r.value);return n.isErr()?new P(n.error):new k(r.value)})))}andTee(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){if(r.isErr())return new P(r.error);try{yield e(r.value)}catch{}return new k(r.value)})))}mapErr(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){return r.isOk()?new k(r.value):new P(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new P(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new k(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 it(this,arguments,function*(){return yield U(yield U(yield*zt(Gt(yield U(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return it(this,arguments,function*(){let r=yield U(this._promise);return r.isErr()&&(yield yield U(L(r.error))),yield U(r.value)})}},A=t=>new y(Promise.resolve(new k(t))),L=t=>new y(Promise.resolve(new P(t))),Er=y.fromPromise,Ar=y.fromSafePromise,Lr=y.fromThrowable,st=t=>{let e=H([]);for(let r of t)if(r.isErr()){e=B(r.error);break}else e.map(n=>n.push(r.value));return e},Kt=t=>y.fromSafePromise(Promise.all(t)).andThen(st),ct=t=>{let e=H([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=B([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},qt=t=>y.fromSafePromise(Promise.all(t)).andThen(ct),Me;(function(t){function e(i,o){return(...s)=>{try{let a=i(...s);return H(a)}catch(a){return B(o?o(a):a)}}}t.fromThrowable=e;function r(i){return st(i)}t.combine=r;function n(i){return ct(i)}t.combineWithAllErrors=n})(Me||(Me={}));var H=t=>new k(t);function B(t){return new P(t)}var k=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return H(e(this.value))}mapErr(e){return H(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 H(this.value)}orElse(e){return H(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,r){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw ot("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 B(this.error)}mapErr(e){return B(e(this.error))}andThrough(e){return B(this.error)}andTee(e){return B(this.error)}andThen(e){return B(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return L(this.error)}asyncAndThrough(e){return L(this.error)}asyncMap(e){return L(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield B(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw ot("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},br=Me.fromThrowable;var N=class t{constructor(e,r){l(this,"actionToken","");l(this,"chunksReady",0);l(this,"createdAt",0);l(this,"delay",0);l(this,"delAtFirstView",!1);l(this,"keys",{client:"",server:""});l(this,"name","");l(this,"password","");l(this,"queueIndex",0);l(this,"serverUrl");l(this,"size",0);l(this,"uploadStatus",3);l(this,"totalChunks",0);l(this,"type","");l(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 ht=Ie(Te());var x=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});l(this,"context");this.name=this.constructor.name,this.context=o}};var ge=class extends x{constructor(){super(...arguments);l(this,"message","Unable to connect. Is the computer able to access the url?")}};var we=class extends x{constructor(){super(...arguments);l(this,"message","The server returned an error")}};var g=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)},ut=t=>{let e=t.href.match(/(.*?)\/?(?:\/[dr]{1}\/|login\/?|files\/?)/),r=e&&e[1]?e[1]:t.origin;return y.fromPromise(fetch(r+"/about/config"),n=>new ge(void 0,{cause:g(n)})).andThen(n=>n.ok?y.fromPromise(n.json(),i=>g(i)):L(new we(void 0,{context:n.statusText})))},ft=()=>typeof Deno<"u",Ue=()=>ft()||globalThis.isSecureContext||globalThis.location.protocol==="https:",W=t=>ft()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t!=="encrypt"?`worker/${t}`:t}.js`));var j=class{constructor(e,r){l(this,"events",new ht.default);l(this,"lufiFile");l(this,"status",2);l(this,"archiveFile");l(this,"archiveFiles",[]);l(this,"downloadedFile");l(this,"worker");l(this,"isTerminated",!1);l(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});l(this,"hasFailed",()=>this.status===1);l(this,"onError",e=>(this.worker.onerror=r=>{e(r)},this));l(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));l(this,"onMessageError",e=>(this.worker.onmessageerror=r=>{e(r)},this));l(this,"onProgress",e=>(this.events.on("CHUNK_UPLOADED",()=>{e()}),this.events.on("CHUNK_DOWNLOADED",()=>{e()}),this));l(this,"requestMessage",(e,r=[])=>(this.worker.postMessage(e,r),this));l(this,"terminate",()=>(this.worker.terminate(),this));l(this,"waitForCompletion",()=>this.isTerminated?this.status===0?A(this):L(g("Job has failed")):y.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>g(e)));l(this,"waitForStart",()=>y.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("UPLOAD_STARTED",()=>{e(this)}),this.events.once("DOWNLOAD_STARTED",()=>{e(this)})}),e=>g(e)));l(this,"dispatchEvent",(e,r)=>{this.events.emit(e,r)});switch(r){case 0:this.worker=new Worker(W("cancel"),{type:"module"});break;case 1:this.worker=new Worker(W("compress"),{type:"module"});break;case 2:this.worker=new Worker(W("decompress"),{type:"module"});break;case 3:this.worker=new Worker(W("download"),{type:"module"});break;case 4:this.worker=new Worker(W("infos"),{type:"module"});break;case 5:this.worker=new Worker(W("remove"),{type:"module"});break;case 6:this.worker=new Worker(W("upload"),{type:"module"});break}this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",n=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",n)}),this.onError(n=>console.error(n.error))}};var V=(r=>(r[r.Sjcl=0]="Sjcl",r[r.WebCrypto=1]="WebCrypto",r))(V||{});var Q=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,u=0,f=0;for(;u>4,n[u++]=(o&15)<<4|s>>2,n[u++]=(s&3)<<6|a;return n.buffer}};var rn=new Q("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var Xt=new Q("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function Be(t){return Xt.Encode(t)}var fe=Ie(mt());var T=class extends x{};var Z=class extends T{constructor(){super(...arguments);l(this,"message","Unable to hash the provided string")}};var yt=()=>{try{return A(fe.default.codec.base64.fromBits(fe.default.random.randomWords(8,10)))}catch(t){return L(new T("Unable to generate key",{cause:g(t)}))}},vt=t=>{try{return A(fe.default.codec.hex.fromBits(fe.default.hash.sha512.hash(t)))}catch(e){return L(new Z(void 0,{cause:g(e)}))}};var gt=()=>y.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(Be(n))).catch(n=>{e(new T("Unable to base64 encode the url",{cause:g(n)}))})).catch(r=>e(r))),t=>new T("Unable to generate key",{cause:g(t)})),wt=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 y.fromPromise(e(),r=>new Z(void 0,{cause:g(r)}))};var Et=(t=1)=>t===0?yt():gt(),je=(t,e)=>e===0?vt(t):wt(t);var be=class extends x{constructor(){super(...arguments);l(this,"message","An error occured while downloading the data")}};var xe=class extends x{constructor(){super(...arguments);l(this,"message","An error occured while trying to retrieve server informations")}};var O=class extends x{};var De=class extends O{constructor(){super(...arguments);l(this,"message","An error occured while trying to pause the job")}};var Oe=class extends O{constructor(){super(...arguments);l(this,"message","An error occured while trying to resume the job")}};var Ce=class extends x{constructor(){super(...arguments);l(this,"message","An error occured while uploading the data")}};var sr=15e5,z={},_e=new At.default,cr=t=>{t.terminate();let e=new j(t.lufiFile,0);return y.fromPromise(new Promise((r,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(z[e.lufiFile.keys.client].uploadStatus=0,r(e)),i.data.event==="OPERATION_FAILED"&&n(new O("An error occured while trying to cancel an upload",{cause:i.data.error}))}).requestMessage({args:{lufiFile:e.lufiFile}})}),r=>g(r))},Lt=(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(),u=s.split(".").length>1?`.${s.split(".").pop()}`:"",f=s;if(e[f]!==void 0){let h=1;do f=`${a}(${h})${u}`,h++;while(e[f]!==void 0)}_e.emit("ARCHIVE_ADDED_FILE",{name:f,size:o.size}),e[f]=await o.bytes()}};return y.fromPromise(r(t),n=>g(n)).andThen(()=>A(e))},bt=(t,e)=>{let r=new N(""),n=new j(r,1);return y.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="ARCHIVE_CREATED"&&(n.archiveFile=new File([s.data.buffer],e,{type:"application/zip"}),n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new O("An error occured while trying to compress a file",{cause:s.data.error}))}).requestMessage({args:{lufiFile:r,archive:{entries:t}}})}),i=>g(i))},ar=t=>{let e=new N(""),r=new j(e,2);return y.fromPromise(new Promise((n,i)=>{r.onMessage(o=>{o.data.event==="ARCHIVE_DECOMPRESSED"&&(r.complete(),n(r)),o.data.event==="ARCHIVE_RETRIEVED_FILE"&&r.archiveFiles.push(new File([o.data.file.buffer],o.data.file.path)),o.data.event==="OPERATION_FAILED"&&i(new O("An error occured while trying to decompress a file",{cause:o.data.error}))}).requestMessage({args:{lufiFile:e,archive:{file:t}}})}),n=>g(n))},xt=(t,e)=>e?ut(t).andThen(r=>{if(r.version.tag>"0.07.0"){let n=Ue()?1:0;return je(e,n).andThen(i=>A(N.fromDownloadUrl(t,i)))}else return A(N.fromDownloadUrl(t,e))}):A(N.fromDownloadUrl(t)),ur=(t,e)=>xt(t,e).andThen(r=>{let n=new j(r,3);return y.fromPromise(new Promise((i,o)=>{let s=[];return n.onMessage(a=>{Dt(i,o,n,a),a.data.event==="CHUNK_DOWNLOADED"&&(s.push(a.data.chunk.buffer),s.length>=50&&(n.downloadedFile=new File(n.downloadedFile?[n.downloadedFile.slice()].concat(s):s,r.name,{type:r.type}),s.length=0)),a.data.event==="DOWNLOAD_COMPLETE"&&(n.downloadedFile=new File(n.downloadedFile?[n.downloadedFile.slice()].concat(s):s,r.name,{type:r.type}),s.length=0,n.complete())}).requestMessage({args:{lufiFile:r}})}),i=>new be(void 0,{cause:g(i)}))}),fr=(t,e)=>xt(t,e).andThen(r=>A(new j(r,4))).andThen(r=>y.fromPromise(new Promise((n,i)=>{r.onMessage(o=>{o.data.event==="INFOS_RETRIEVED"&&(r.complete(),n(r)),o.data.event==="OPERATION_FAILED"&&i(new O("An error occured while trying to retrieve informations of the file",{cause:o.data.error}))}).requestMessage({args:{lufiFile:r.lufiFile}})}),n=>new xe(void 0,{cause:g(n)}))),hr=t=>{try{return t.status=3,A(t.requestMessage({action:0,args:{lufiFile:t.lufiFile}}))}catch(e){return L(new De(void 0,{cause:g(e)}))}},lr=(t,e)=>{let r=N.fromRemoveUrl(t,e),n=new j(r,5);return y.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new O("An error occured while trying to remove a file",{cause:s.data.error}))}).requestMessage({args:{lufiFile:r}})}),i=>g(i))},pr=t=>{try{return t.status=2,A(t.requestMessage({action:2,args:{lufiFile:t.lufiFile}}))}catch(e){return L(new Oe(void 0,{cause:g(e)}))}},dr=(t,e,r,n=sr)=>{_e.emit("SLICE_STARTED",z[t.lufiFile.keys.client]);let i=Math.ceil(e.size/n)||1,o=navigator.hardwareConcurrency||1;return z[t.lufiFile.keys.client].totalChunks=i,(async()=>{for(let a=0;a{t.events.once("UPLOAD_STARTED",()=>{d(void 0)})}):a%o===0&&await new Promise(d=>{t.events.once("CHUNK_UPLOADED",()=>{d(void 0)})})}})(),A(void 0)},Je=(t,e,r,n,i,o,s)=>Et(s).andThen(a=>o?je(o,s).andThen(u=>A({password:u,clientKey:a})):A({password:o,clientKey:a})).andThen(({password:a,clientKey:u})=>{z[u]=new N(t.toString(),{delay:r,delAtFirstView:n,zipped:i,password:a,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:u,server:""}});let f=new j(z[u],6);return z[u].uploadStatus=4,dr(f,e,s).andThen(()=>y.fromPromise(new Promise((h,p)=>{f.onMessage(d=>{switch(Dt(h,p,f,d),d.data.event){case"UPLOAD_COMPLETE":f.complete(),f.lufiFile.uploadStatus=1;break}})}),h=>g(h)))}),mr=(t,e,r=0,n=!1,i=!1,o="documents.zip",s="",a=1)=>{let u=[];return i?e.length===1&&e[0].type==="application/zip"?u.push(Je(t,e[0],r,n,i,s,a)):u.push(Lt(e).andThen(f=>bt(f,o).andThen(h=>h.archiveFile?(_e.emit("ARCHIVE_CREATED",h.archiveFile),Je(t,h.archiveFile,r,n,i,s,a)):L(new O("archiveFile must be defined"))))):e.forEach(f=>{u.push(Je(t,f,r,n,i,s,a))}),y.combine(u).orElse(f=>L(new Ce(void 0,{cause:f})))},Dt=(t,e,r,n)=>{n.data.event==="SOCKET_OPENED"&&t(r),n.data.event==="OPERATION_FAILED"&&e(new O("The job returned an error",{cause:n.data.error}))},yr=()=>Object.values(z).filter(t=>t.uploadStatus===4),vr=t=>Object.keys(yr()).indexOf(t);export{V as CryptoAlgorithm,y as ResultAsync,B as err,L as errAsync,Ue as isSecureContext,He as lufi,H as ok,A as okAsync}; +var _t=Object.create;var me=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var St=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var It=(t,e,r)=>e in t?me(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ft=(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 Ke=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Tt=(t,e)=>{for(var r in e)me(t,r,{get:e[r],enumerable:!0})},Mt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kt(e))!Pt.call(t,i)&&i!==r&&me(t,i,{get:()=>e[i],enumerable:!(n=Rt(e,i))||n.enumerable});return t};var Ie=(t,e,r)=>(r=t!=null?_t(St(t)):{},Mt(e||!t||!t.__esModule?me(r,"default",{value:t,enumerable:!0}):r,t));var l=(t,e,r)=>It(t,typeof e!="symbol"?e+"":e,r);var Te=Ke((wr,Fe)=>{"use strict";var q=typeof Reflect=="object"?Reflect:null,qe=q&&typeof q.apply=="function"?q.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ye;q&&typeof q.ownKeys=="function"?ye=q.ownKeys:Object.getOwnPropertySymbols?ye=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ye=function(e){return Object.getOwnPropertyNames(e)};function Ut(t){console&&console.warn&&console.warn(t)}var Ve=Number.isNaN||function(e){return e!==e};function y(){y.init.call(this)}Fe.exports=y;Fe.exports.once=Jt;y.EventEmitter=y;y.prototype._events=void 0;y.prototype._eventsCount=0;y.prototype._maxListeners=void 0;var $e=10;function ve(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(y,"defaultMaxListeners",{enumerable:!0,get:function(){return $e},set:function(t){if(typeof t!="number"||t<0||Ve(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");$e=t}});y.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};y.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ve(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 Qe(t){return t._maxListeners===void 0?y.defaultMaxListeners:t._maxListeners}y.prototype.getMaxListeners=function(){return Qe(this)};y.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 u=o[e];if(u===void 0)return!1;if(typeof u=="function")qe(u,this,r);else for(var f=u.length,h=tt(u,f),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,Ut(a)}return t}y.prototype.addListener=function(e,r){return Xe(this,e,r,!1)};y.prototype.on=y.prototype.addListener;y.prototype.prependListener=function(e,r){return Xe(this,e,r,!0)};function Bt(){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 Ze(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Bt.bind(n);return i.listener=r,n.wrapFn=i,i}y.prototype.once=function(e,r){return ve(r),this.on(e,Ze(this,e,r)),this};y.prototype.prependOnceListener=function(e,r){return ve(r),this.prependListener(e,Ze(this,e,r)),this};y.prototype.removeListener=function(e,r){var n,i,o,s,a;if(ve(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():Nt(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};y.prototype.off=y.prototype.removeListener;y.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 Ye(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?jt(i):tt(i,i.length)}y.prototype.listeners=function(e){return Ye(this,e,!0)};y.prototype.rawListeners=function(e){return Ye(this,e,!1)};y.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):et.call(t,e)};y.prototype.listenerCount=et;function et(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}y.prototype.eventNames=function(){return this._eventsCount>0?ye(this._events):[]};function tt(t,e){for(var r=new Array(e),n=0;n{"use strict";var c={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}}};c.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 c.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]]};c.cipher.aes.prototype={encrypt:function(t){return lt(this,t,0)},decrypt:function(t){return lt(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=[],u=[],f,h,p,d;for(i=0;256>i;i++)u[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=f||1,s=u[s]||1)for(p=s^s<<1^s<<2^s<<3^s<<4,p=p>>8^p&255^99,r[o]=p,n[p]=o,h=a[i=a[f=a[o]]],d=16843009*h^65537*i^257*f^16843008*o,h=257*a[p]^16843008*p,i=0;4>i;i++)t[i][o]=h=h<<24^h>>>8,e[i][p]=d=d<<24^d>>>8;for(i=0;5>i;i++)t[i]=t[i].slice(0),e[i]=e[i].slice(0)}};function lt(t,e,r){if(e.length!==4)throw new c.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,u,f,h=n.length/4-2,p,d=4,m=[0,0,0,0];a=t.w[r],t=a[0];var A=a[1],_=a[2],P=a[3],J=a[4];for(p=0;p>>24]^A[o>>16&255]^_[s>>8&255]^P[e&255]^n[d],u=t[o>>>24]^A[s>>16&255]^_[e>>8&255]^P[i&255]^n[d+1],f=t[s>>>24]^A[e>>16&255]^_[i>>8&255]^P[o&255]^n[d+2],e=t[e>>>24]^A[i>>16&255]^_[o>>8&255]^P[s&255]^n[d+3],d+=4,i=a,o=u,s=f;for(p=0;4>p;p++)m[r?3&-p:p]=J[i>>>24]<<24^J[o>>16&255]<<16^J[s>>8&255]<<8^J[e&255]^n[d++],a=i,i=o,o=s,s=e,e=a;return m}c.bitArray={bitSlice:function(t,e,r){return t=c.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:c.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(c.bitArray.bitLength(t)!==c.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=c.bitArray.getPartial(i),n.push(c.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};c.codec.utf8String={fromBits:function(t){var e="",r=c.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=c.codec.base64.S,s=0,a;for(e&&(o=o.substr(0,62)+"-_"),n=0;na)throw new c.exception.invalid("this isn't base64!");26>>i),s=a<<32-i):(i+=6,s^=a<<32-i)}return i&56&&r.push(c.bitArray.partial(i&56,s,1)),r}};c.codec.base64url={fromBits:function(t){return c.codec.base64.fromBits(t,1,1)},toBits:function(t){return c.codec.base64.toBits(t,1)}};c.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()};c.hash.sha256.hash=function(t){return new c.hash.sha256().update(t).finalize()};c.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=c.codec.utf8String.toBits(t));var e,r=this.f=c.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+c.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],u=i[2],f=i[3],h=i[4],p=i[5],d=i[6],m=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+m+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(d^h&(p^d))+o[e],m=d,d=p,p=h,h=f+r|0,f=u,u=a,a=s,s=r+(a&u^f&(a^u))+(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]+u|0,i[3]=i[3]+f|0,i[4]=i[4]+h|0,i[5]=i[5]+p|0,i[6]=i[6]+d|0,i[7]=i[7]+m|0}};c.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()};c.hash.sha512.hash=function(t){return new c.hash.sha512().update(t).finalize()};c.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=c.codec.utf8String.toBits(t));var e,r=this.f=c.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+c.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],u=n[3],f=n[4],h=n[5],p=n[6],d=n[7],m=n[8],A=n[9],_=n[10],P=n[11],J=n[12],he=n[13],We=n[14],le=n[15],D;if(typeof Uint32Array<"u"){D=Array(160);for(var b=0;32>b;b++)D[b]=t[b]}else D=t;var b=o,O=s,Y=a,G=u,ee=f,K=h,Re=p,te=d,I=m,C=A,pe=_,re=P,de=J,ne=he,ke=We,ie=le;for(t=0;80>t;t++){if(16>t)e=D[2*t],r=D[2*t+1];else{r=D[2*(t-15)];var w=D[2*(t-15)+1];e=(w<<31|r>>>1)^(w<<24|r>>>8)^r>>>7;var F=(r<<31|w>>>1)^(r<<24|w>>>8)^(r<<25|w>>>7);r=D[2*(t-2)];var M=D[2*(t-2)+1],w=(M<<13|r>>>19)^(r<<3|M>>>29)^r>>>6,M=(r<<13|M>>>19)^(M<<3|r>>>29)^(r<<26|M>>>6),Se=D[2*(t-7)],Pe=D[2*(t-16)],oe=D[2*(t-16)+1];r=F+D[2*(t-7)+1],e=e+Se+(r>>>0>>0?1:0),r+=M,e+=w+(r>>>0>>0?1:0),r+=oe,e+=Pe+(r>>>0>>0?1:0)}D[2*t]=e|=0,D[2*t+1]=r|=0;var Se=I&pe^~I&de,ze=C&re^~C&ne,M=b&Y^b&ee^Y&ee,Ot=O&G^O&K^G&K,Pe=(O<<4|b>>>28)^(b<<30|O>>>2)^(b<<25|O>>>7),oe=(b<<4|O>>>28)^(O<<30|b>>>2)^(O<<25|b>>>7),Ct=i[2*t],Ge=i[2*t+1],w=ie+((I<<18|C>>>14)^(I<<14|C>>>18)^(C<<23|I>>>9)),F=ke+((C<<18|I>>>14)^(C<<14|I>>>18)^(I<<23|C>>>9))+(w>>>0>>0?1:0),w=w+ze,F=F+(Se+(w>>>0>>0?1:0)),w=w+Ge,F=F+(Ct+(w>>>0>>0?1:0)),w=w+r|0,F=F+(e+(w>>>0>>0?1:0));r=oe+Ot,e=Pe+M+(r>>>0>>0?1:0),ke=de,ie=ne,de=pe,ne=re,pe=I,re=C,C=te+w|0,I=Re+F+(C>>>0>>0?1:0)|0,Re=ee,te=K,ee=Y,K=G,Y=b,G=O,O=w+r|0,b=F+e+(O>>>0>>0?1:0)|0}s=n[1]=s+O|0,n[0]=o+b+(s>>>0>>0?1:0)|0,u=n[3]=u+G|0,n[2]=a+Y+(u>>>0>>0?1:0)|0,h=n[5]=h+K|0,n[4]=f+ee+(h>>>0>>0?1:0)|0,d=n[7]=d+te|0,n[6]=p+Re+(d>>>0>>0?1:0)|0,A=n[9]=A+C|0,n[8]=m+I+(A>>>0>>0?1:0)|0,P=n[11]=P+re|0,n[10]=_+pe+(P>>>0>>0?1:0)|0,he=n[13]=he+ne|0,n[12]=J+de+(he>>>0>>0?1:0)|0,le=n[15]=le+ie|0,n[14]=We+ke+(le>>>0>>0?1:0)|0}};c.mode.ccm={name:"ccm",F:[],listenProgress:function(t){c.mode.ccm.F.push(t)},unListenProgress:function(t){t=c.mode.ccm.F.indexOf(t),-1u)throw new c.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&f>>>8*o;o++);return o<15-u&&(o=15-u),r=a.clamp(r,8*(15-o)),e=c.mode.ccm.U(t,e,r,n,i,o),s=c.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=c.bitArray,s=o.bitLength(r)/8,f=o.bitLength(e),a=o.clamp(e,f-i),u=o.bitSlice(e,f-i),f=(f-i)/8;if(7>s)throw new c.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=o.clamp(r,8*(15-e)),a=c.mode.ccm.V(t,a,r,u,i,e),t=c.mode.ccm.U(t,a.data,r,n,i,e),!o.equal(a.tag,t))throw new c.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,i,o){var s=[],a=c.bitArray,u=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&&(c.mode.ccm.da(s/u),h+=p),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,f)}}};c.misc.hmac=function(t,e){this.W=e=e||c.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 c.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=c.codec.utf8String.toBits(t)),typeof e=="string"&&(e=c.codec.utf8String.toBits(e)),i=i||c.misc.hmac,t=new i(t);var o,s,a,u,f=[],h=c.bitArray;for(u=1;32*f.length<(n||1);u++){for(i=o=t.encrypt(h.concat(e,[u])),s=1;ss;s++)i.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=o),this.N++,this.b=c.hash.sha256.hash(this.b.concat(i)),this.K=new c.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:u=1}if(u)throw new c.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&&pt("seeded",Math.max(this.u,this.i)),pt("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:ce(this,this.la),mouseCollector:ce(this,this.na),keyboardCollector:ce(this,this.ja),accelerometerCollector:ce(this,this.ca),touchCollector:ce(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 c.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 ce(t,e){return function(){e.apply(t,arguments)}}c.random=new c.prng(6);e:try{if(Ae=typeof X<"u"&&X.exports){try{Le=Ft("crypto")}catch{Le=null}Ae=Ee=Le}if(Ae&&Ee.randomBytes)ae=Ee.randomBytes(128),ae=new Uint32Array(new Uint8Array(ae).buffer),c.random.addEntropy(ae,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(ue=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(ue);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(ue);else break e;c.random.addEntropy(ue,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 ae,Ee,ue,Ae,Le;c.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=c.json,o=i.j({iv:c.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=c.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=c.codec.base64.toBits(o.iv)),!c.mode[o.mode]||!c.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||4Lt,cancel:()=>cr,compress:()=>bt,decompress:()=>ar,download:()=>ur,events:()=>_e,getFileIndexInQueue:()=>vr,infos:()=>fr,pause:()=>hr,remove:()=>lr,resume:()=>pr,upload:()=>mr});var At=Ie(Te());var Wt={withStackTrace:!1},ot=(t,e,r=Wt)=>{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 $(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{f(n.next(h))}catch(p){s(p)}}function u(h){try{f(n.throw(h))}catch(p){s(p)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(t,e||[])).next())})}function nt(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 U(t){return this instanceof U?(this.v=t,this):new U(t)}function it(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(m){return function(A){return Promise.resolve(A).then(m,p)}}function a(m,A){n[m]&&(i[m]=function(_){return new Promise(function(P,J){o.push([m,_,P,J])>1||u(m,_)})},A&&(i[m]=A(i[m])))}function u(m,A){try{f(n[m](A))}catch(_){d(o[0][3],_)}}function f(m){m.value instanceof U?Promise.resolve(m.value.v).then(h,p):d(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function d(m,A){m(A),o.shift(),o.length&&u(o[0][0],o[0][1])}}function zt(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:U(t[i](s)),done:!1}:o?o(s):s}:o}}function Gt(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 nt=="function"?nt(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,u){s=t[o](s),i(a,u,s.done,s.value)})}}function i(o,s,a,u){Promise.resolve(u).then(function(f){o({value:f,done:a})},s)}}var v=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new R(n));return new t(r)}static fromPromise(e,r){let n=e.then(i=>new R(i)).catch(i=>new k(r(i)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t($(this,void 0,void 0,function*(){try{return new R(yield e(...n))}catch(i){return new k(r?r(i):i)}}))}static combine(e){return Kt(e)}static combineWithAllErrors(e){return qt(e)}map(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){return r.isErr()?new k(r.error):new R(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){if(r.isErr())return new k(r.error);let n=yield e(r.value);return n.isErr()?new k(n.error):new R(r.value)})))}andTee(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){if(r.isErr())return new k(r.error);try{yield e(r.value)}catch{}return new R(r.value)})))}mapErr(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){return r.isOk()?new R(r.value):new k(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new k(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>$(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new R(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 it(this,arguments,function*(){return yield U(yield U(yield*zt(Gt(yield U(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return it(this,arguments,function*(){let r=yield U(this._promise);return r.isErr()&&(yield yield U(L(r.error))),yield U(r.value)})}},E=t=>new v(Promise.resolve(new R(t))),L=t=>new v(Promise.resolve(new k(t))),Er=v.fromPromise,Ar=v.fromSafePromise,Lr=v.fromThrowable,st=t=>{let e=H([]);for(let r of t)if(r.isErr()){e=B(r.error);break}else e.map(n=>n.push(r.value));return e},Kt=t=>v.fromSafePromise(Promise.all(t)).andThen(st),ct=t=>{let e=H([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=B([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},qt=t=>v.fromSafePromise(Promise.all(t)).andThen(ct),Me;(function(t){function e(i,o){return(...s)=>{try{let a=i(...s);return H(a)}catch(a){return B(o?o(a):a)}}}t.fromThrowable=e;function r(i){return st(i)}t.combine=r;function n(i){return ct(i)}t.combineWithAllErrors=n})(Me||(Me={}));var H=t=>new R(t);function B(t){return new k(t)}var R=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return H(e(this.value))}mapErr(e){return H(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 H(this.value)}orElse(e){return H(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return v.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 ot("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},k=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return B(this.error)}mapErr(e){return B(e(this.error))}andThrough(e){return B(this.error)}andTee(e){return B(this.error)}andThen(e){return B(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return L(this.error)}asyncAndThrough(e){return L(this.error)}asyncMap(e){return L(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield B(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw ot("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},br=Me.fromThrowable;var N=class t{constructor(e,r){l(this,"actionToken","");l(this,"chunksReady",0);l(this,"createdAt",0);l(this,"delay",0);l(this,"delAtFirstView",!1);l(this,"keys",{client:"",server:""});l(this,"name","");l(this,"password","");l(this,"queueIndex",0);l(this,"serverUrl");l(this,"size",0);l(this,"uploadStatus",3);l(this,"totalChunks",0);l(this,"type","");l(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 ht=Ie(Te());var x=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});l(this,"context");this.name=this.constructor.name,this.context=o}};var ge=class extends x{constructor(){super(...arguments);l(this,"message","Unable to connect. Is the computer able to access the url?")}};var we=class extends x{constructor(){super(...arguments);l(this,"message","The server returned an error")}};var g=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)},ut=t=>{let e=t.href.match(/(.*?)\/?(?:\/[dr]{1}\/|login\/?|files\/?)/),r=e&&e[1]?e[1]:t.origin;return v.fromPromise(fetch(r+"/about/config"),n=>new ge(void 0,{cause:g(n)})).andThen(n=>n.ok?v.fromPromise(n.json(),i=>g(i)):L(new we(void 0,{context:n.statusText})))},ft=()=>typeof Deno<"u",Ue=()=>ft()||globalThis.isSecureContext||globalThis.location.protocol==="https:",W=t=>ft()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t!=="encrypt"?`worker/${t}`:t}.js`));var j=class{constructor(e,r){l(this,"events",new ht.default);l(this,"lufiFile");l(this,"status",2);l(this,"archiveFile");l(this,"archiveFiles",[]);l(this,"downloadedFile");l(this,"worker");l(this,"isTerminated",!1);l(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});l(this,"hasFailed",()=>this.status===1);l(this,"onError",e=>(this.worker.onerror=r=>{e(r)},this));l(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));l(this,"onMessageError",e=>(this.worker.onmessageerror=r=>{e(r)},this));l(this,"onProgress",e=>(this.events.on("CHUNK_UPLOADED",()=>{e()}),this.events.on("CHUNK_DOWNLOADED",()=>{e()}),this));l(this,"requestMessage",(e,r=[])=>(this.worker.postMessage(e,r),this));l(this,"terminate",()=>(this.worker.terminate(),this));l(this,"waitForCompletion",()=>this.isTerminated?this.status===0?E(this):L(g("Job has failed")):v.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>g(e)));l(this,"waitForStart",()=>v.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("UPLOAD_STARTED",()=>{e(this)}),this.events.once("DOWNLOAD_STARTED",()=>{e(this)})}),e=>g(e)));l(this,"dispatchEvent",(e,r)=>{this.events.emit(e,r)});switch(r){case 0:this.worker=new Worker(W("cancel"),{type:"module"});break;case 1:this.worker=new Worker(W("compress"),{type:"module"});break;case 2:this.worker=new Worker(W("decompress"),{type:"module"});break;case 3:this.worker=new Worker(W("download"),{type:"module"});break;case 4:this.worker=new Worker(W("infos"),{type:"module"});break;case 5:this.worker=new Worker(W("remove"),{type:"module"});break;case 6:this.worker=new Worker(W("upload"),{type:"module"});break}this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",n=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",n)}),this.onError(n=>console.error(n.error))}};var V=(r=>(r[r.Sjcl=0]="Sjcl",r[r.WebCrypto=1]="WebCrypto",r))(V||{});var Q=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,u=0,f=0;for(;u>4,n[u++]=(o&15)<<4|s>>2,n[u++]=(s&3)<<6|a;return n.buffer}};var rn=new Q("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var Xt=new Q("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function Be(t){return Xt.Encode(t)}var fe=Ie(mt());var T=class extends x{};var Z=class extends T{constructor(){super(...arguments);l(this,"message","Unable to hash the provided string")}};var yt=()=>{try{return E(fe.default.codec.base64.fromBits(fe.default.random.randomWords(8,10)))}catch(t){return L(new T("Unable to generate key",{cause:g(t)}))}},vt=t=>{try{return E(fe.default.codec.hex.fromBits(fe.default.hash.sha512.hash(t)))}catch(e){return L(new Z(void 0,{cause:g(e)}))}};var gt=()=>v.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(Be(n))).catch(n=>{e(new T("Unable to base64 encode the url",{cause:g(n)}))})).catch(r=>e(r))),t=>new T("Unable to generate key",{cause:g(t)})),wt=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 v.fromPromise(e(),r=>new Z(void 0,{cause:g(r)}))};var Et=(t=1)=>t===0?yt():gt(),je=(t,e)=>e===0?vt(t):wt(t);var be=class extends x{constructor(){super(...arguments);l(this,"message","An error occured while downloading the data")}};var xe=class extends x{constructor(){super(...arguments);l(this,"message","An error occured while trying to retrieve server informations")}};var S=class extends x{};var De=class extends S{constructor(){super(...arguments);l(this,"message","An error occured while trying to pause the job")}};var Oe=class extends S{constructor(){super(...arguments);l(this,"message","An error occured while trying to resume the job")}};var Ce=class extends x{constructor(){super(...arguments);l(this,"message","An error occured while uploading the data")}};var sr=15e5,z={},_e=new At.default,cr=t=>{t.terminate();let e=new j(t.lufiFile,0);return v.fromPromise(new Promise((r,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(z[e.lufiFile.keys.client].uploadStatus=0,r(e)),i.data.event==="OPERATION_FAILED"&&n(new S("An error occured while trying to cancel an upload",{cause:i.data.error}))}).requestMessage({args:{lufiFile:e.lufiFile}})}),r=>g(r))},Lt=(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(),u=s.split(".").length>1?`.${s.split(".").pop()}`:"",f=s;if(e[f]!==void 0){let h=1;do f=`${a}(${h})${u}`,h++;while(e[f]!==void 0)}_e.emit("ARCHIVE_ADDED_FILE",{name:f,size:o.size}),e[f]=await o.bytes()}};return v.fromPromise(r(t),n=>g(n)).andThen(()=>E(e))},bt=(t,e)=>{let r=new N(""),n=new j(r,1);return E(n.onMessage(i=>{i.data.event==="ARCHIVE_CREATED"&&(n.archiveFile=new File([i.data.buffer],e,{type:"application/zip"}),n.complete())}).requestMessage({args:{lufiFile:r,archive:{entries:t}}}))},ar=t=>{let e=new N(""),r=new j(e,2);return E(r.onMessage(n=>{n.data.event==="ARCHIVE_DECOMPRESSED"&&r.complete(),n.data.event==="ARCHIVE_RETRIEVED_FILE"&&r.archiveFiles.push(new File([n.data.file.buffer],n.data.file.path))}).requestMessage({args:{lufiFile:e,archive:{file:t}}}))},xt=(t,e)=>e?ut(t).andThen(r=>{if(r.version.tag>"0.07.0"){let n=Ue()?1:0;return je(e,n).andThen(i=>E(N.fromDownloadUrl(t,i)))}else return E(N.fromDownloadUrl(t,e))}):E(N.fromDownloadUrl(t)),ur=(t,e)=>xt(t,e).andThen(r=>{let n=new j(r,3);return v.fromPromise(new Promise((i,o)=>{let s=[];return n.onMessage(a=>{Dt(i,o,n,a),a.data.event==="CHUNK_DOWNLOADED"&&(s.push(a.data.chunk.buffer),s.length>=50&&(n.downloadedFile=new File(n.downloadedFile?[n.downloadedFile.slice()].concat(s):s,r.name,{type:r.type}),s.length=0)),a.data.event==="DOWNLOAD_COMPLETE"&&(n.downloadedFile=new File(n.downloadedFile?[n.downloadedFile.slice()].concat(s):s,r.name,{type:r.type}),s.length=0,n.complete())}).requestMessage({args:{lufiFile:r}})}),i=>new be(void 0,{cause:g(i)}))}),fr=(t,e)=>xt(t,e).andThen(r=>E(new j(r,4))).andThen(r=>v.fromPromise(new Promise((n,i)=>{r.onMessage(o=>{o.data.event==="INFOS_RETRIEVED"&&(r.complete(),n(r)),o.data.event==="OPERATION_FAILED"&&i(new S("An error occured while trying to retrieve informations of the file",{cause:o.data.error}))}).requestMessage({args:{lufiFile:r.lufiFile}})}),n=>new xe(void 0,{cause:g(n)}))),hr=t=>{try{return t.status=3,E(t.requestMessage({action:0,args:{lufiFile:t.lufiFile}}))}catch(e){return L(new De(void 0,{cause:g(e)}))}},lr=(t,e)=>{let r=N.fromRemoveUrl(t,e),n=new j(r,5);return v.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new S("An error occured while trying to remove a file",{cause:s.data.error}))}).requestMessage({args:{lufiFile:r}})}),i=>g(i))},pr=t=>{try{return t.status=2,E(t.requestMessage({action:2,args:{lufiFile:t.lufiFile}}))}catch(e){return L(new Oe(void 0,{cause:g(e)}))}},dr=(t,e,r,n=sr)=>{_e.emit("SLICE_STARTED",z[t.lufiFile.keys.client]);let i=Math.ceil(e.size/n)||1,o=navigator.hardwareConcurrency||1;return z[t.lufiFile.keys.client].totalChunks=i,(async()=>{for(let a=0;a{t.events.once("UPLOAD_STARTED",()=>{d(void 0)})}):a%o===0&&await new Promise(d=>{t.events.once("CHUNK_UPLOADED",()=>{d(void 0)})})}})(),E(void 0)},Je=(t,e,r,n,i,o,s)=>Et(s).andThen(a=>o?je(o,s).andThen(u=>E({password:u,clientKey:a})):E({password:o,clientKey:a})).andThen(({password:a,clientKey:u})=>{z[u]=new N(t.toString(),{delay:r,delAtFirstView:n,zipped:i,password:a,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:u,server:""}});let f=new j(z[u],6);return z[u].uploadStatus=4,dr(f,e,s).andThen(()=>v.fromPromise(new Promise((h,p)=>{f.onMessage(d=>{switch(Dt(h,p,f,d),d.data.event){case"UPLOAD_COMPLETE":f.complete(),f.lufiFile.uploadStatus=1;break}})}),h=>g(h)))}),mr=(t,e,r=0,n=!1,i=!1,o="documents.zip",s="",a=1)=>{let u=[];return i?e.length===1&&e[0].type==="application/zip"?u.push(Je(t,e[0],r,n,i,s,a)):u.push(Lt(e).andThen(f=>bt(f,o).andThen(h=>h.archiveFile?(_e.emit("ARCHIVE_CREATED",h.archiveFile),Je(t,h.archiveFile,r,n,i,s,a)):L(new S("archiveFile must be defined"))))):e.forEach(f=>{u.push(Je(t,f,r,n,i,s,a))}),v.combine(u).orElse(f=>L(new Ce(void 0,{cause:f})))},Dt=(t,e,r,n)=>{n.data.event==="SOCKET_OPENED"&&t(r),n.data.event==="OPERATION_FAILED"&&e(new S("The job returned an error",{cause:n.data.error}))},yr=()=>Object.values(z).filter(t=>t.uploadStatus===4),vr=t=>Object.keys(yr()).indexOf(t);export{V as CryptoAlgorithm,v as ResultAsync,B as err,L as errAsync,Ue as isSecureContext,He as lufi,H as ok,E as okAsync}; diff --git a/themes/default/public/js/worker/upload.js b/themes/default/public/js/worker/upload.js index c489e29..e2bfeeb 100644 --- a/themes/default/public/js/worker/upload.js +++ b/themes/default/public/js/worker/upload.js @@ -1 +1 @@ -var Nr=Object.create;var ht=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var Nt=e=>{throw TypeError(e)};var Jr=(e,t,r)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var zr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var dt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Hr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Br(t))!Wr.call(e,i)&&i!==r&&ht(e,i,{get:()=>t[i],enumerable:!(n=Fr(t,i))||n.enumerable});return e};var Oe=(e,t,r)=>(r=e!=null?Nr(jr(e)):{},Hr(t||!e||!e.__esModule?ht(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>Jr(e,typeof t!="symbol"?t+"":t,r),pt=(e,t,r)=>t.has(e)||Nt("Cannot "+r);var d=(e,t,r)=>(pt(e,t,"read from private field"),r?r.call(e):t.get(e)),D=(e,t,r)=>t.has(e)?Nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),w=(e,t,r,n)=>(pt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),x=(e,t,r)=>(pt(e,t,"access private method"),r);var Ge=(e,t,r,n)=>({set _(i){w(e,t,i,r)},get _(){return d(e,t,n)}});var Ke=dt((ri,vt)=>{"use strict";var se=typeof Reflect=="object"?Reflect:null,zt=se&&typeof se.apply=="function"?se.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},Ve;se&&typeof se.ownKeys=="function"?Ve=se.ownKeys:Object.getOwnPropertySymbols?Ve=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Ve=function(t){return Object.getOwnPropertyNames(t)};function Qr(e){console&&console.warn&&console.warn(e)}var $t=Number.isNaN||function(t){return t!==t};function E(){E.init.call(this)}vt.exports=E;vt.exports.once=tn;E.EventEmitter=E;E.prototype._events=void 0;E.prototype._eventsCount=0;E.prototype._maxListeners=void 0;var Ht=10;function Xe(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(E,"defaultMaxListeners",{enumerable:!0,get:function(){return Ht},set:function(e){if(typeof e!="number"||e<0||$t(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ht=e}});E.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};E.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||$t(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function qt(e){return e._maxListeners===void 0?E.defaultMaxListeners:e._maxListeners}E.prototype.getMaxListeners=function(){return qt(this)};E.prototype.emit=function(t){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=o[t];if(u===void 0)return!1;if(typeof u=="function")zt(u,this,r);else for(var f=u.length,l=Qt(u,f),n=0;n0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,Qr(c)}return e}E.prototype.addListener=function(t,r){return Gt(this,t,r,!1)};E.prototype.on=E.prototype.addListener;E.prototype.prependListener=function(t,r){return Gt(this,t,r,!0)};function Zr(){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 Vt(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Zr.bind(n);return i.listener=r,n.wrapFn=i,i}E.prototype.once=function(t,r){return Xe(r),this.on(t,Vt(this,t,r)),this};E.prototype.prependOnceListener=function(t,r){return Xe(r),this.prependListener(t,Vt(this,t,r)),this};E.prototype.removeListener=function(t,r){var n,i,o,s,c;if(Xe(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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){c=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():Yr(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,c||r)}return this};E.prototype.off=E.prototype.removeListener;E.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i=0;i--)this.removeListener(t,r[i]);return this};function Xt(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?en(i):Qt(i,i.length)}E.prototype.listeners=function(t){return Xt(this,t,!0)};E.prototype.rawListeners=function(t){return Xt(this,t,!1)};E.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Kt.call(e,t)};E.prototype.listenerCount=Kt;function Kt(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}E.prototype.eventNames=function(){return this._eventsCount>0?Ve(this._events):[]};function Qt(e,t){for(var r=new Array(t),n=0;n{"use strict";var a={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};a.cipher.aes=function(e){this.w[0][0][0]||this.C();var t,r,n,i,o=this.w[0][4],s=this.w[1];t=e.length;var c=1;if(t!==4&&t!==6&&t!==8)throw new a.exception.invalid("invalid aes key size");for(this.b=[n=e.slice(0),i=[]],e=t;e<4*t+28;e++)r=n[e-1],(e%t===0||t===8&&e%t===4)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[r&255],e%t===0&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),n[e]=n[e-t]^r;for(t=0;e;t++,e--)r=n[t&3?e:e-4],i[t]=4>=e||4>t?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[r&255]]};a.cipher.aes.prototype={encrypt:function(e){return nr(this,e,0)},decrypt:function(e){return nr(this,e,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var e=this.w[0],t=this.w[1],r=e[4],n=t[4],i,o,s,c=[],u=[],f,l,h,m;for(i=0;256>i;i++)u[(c[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=f||1,s=u[s]||1)for(h=s^s<<1^s<<2^s<<3^s<<4,h=h>>8^h&255^99,r[o]=h,n[h]=o,l=c[i=c[f=c[o]]],m=16843009*l^65537*i^257*f^16843008*o,l=257*c[h]^16843008*h,i=0;4>i;i++)e[i][o]=l=l<<24^l>>>8,t[i][h]=m=m<<24^m>>>8;for(i=0;5>i;i++)e[i]=e[i].slice(0),t[i]=t[i].slice(0)}};function nr(e,t,r){if(t.length!==4)throw new a.exception.invalid("invalid aes block size");var n=e.b[r],i=t[0]^n[0],o=t[r?3:1]^n[1],s=t[2]^n[2];t=t[r?1:3]^n[3];var c,u,f,l=n.length/4-2,h,m=4,p=[0,0,0,0];c=e.w[r],e=c[0];var b=c[1],N=c[2],J=c[3],Q=c[4];for(h=0;h>>24]^b[o>>16&255]^N[s>>8&255]^J[t&255]^n[m],u=e[o>>>24]^b[s>>16&255]^N[t>>8&255]^J[i&255]^n[m+1],f=e[s>>>24]^b[t>>16&255]^N[i>>8&255]^J[o&255]^n[m+2],t=e[t>>>24]^b[i>>16&255]^N[o>>8&255]^J[s&255]^n[m+3],m+=4,i=c,o=u,s=f;for(h=0;4>h;h++)p[r?3&-h:h]=Q[i>>>24]<<24^Q[o>>16&255]<<16^Q[s>>8&255]<<8^Q[t&255]^n[m++],c=i,i=o,o=s,s=t,t=c;return p}a.bitArray={bitSlice:function(e,t,r){return e=a.bitArray.Y(e.slice(t/32),32-(t&31)).slice(1),r===void 0?e:a.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return((t+r-1^t)&-32?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return e===32?t:(r?t|0:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(a.bitArray.bitLength(e)!==a.bitArray.bitLength(t))return!1;var r=0,n;for(n=0;n>>t),r=e[i]<<32-t;return i=e.length?e[e.length-1]:0,e=a.bitArray.getPartial(i),n.push(a.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return e}};a.codec.utf8String={fromBits:function(e){var t="",r=a.bitArray.bitLength(e),n,i;for(n=0;n>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(t))},toBits:function(e){e=unescape(encodeURIComponent(e));var t=[],r,n=0;for(r=0;r>>i)>>>26),6>i?(s=e[r]<<6-i,i+=26,r++):(s<<=6,i-=6);for(;n.length&3&&!t;)n+="=";return n},toBits:function(e,t){e=e.replace(/\s|=/g,"");var r=[],n,i=0,o=a.codec.base64.S,s=0,c;for(t&&(o=o.substr(0,62)+"-_"),n=0;nc)throw new a.exception.invalid("this isn't base64!");26>>i),s=c<<32-i):(i+=6,s^=c<<32-i)}return i&56&&r.push(a.bitArray.partial(i&56,s,1)),r}};a.codec.base64url={fromBits:function(e){return a.codec.base64.fromBits(e,1,1)},toBits:function(e){return a.codec.base64.toBits(e,1)}};a.hash.sha256=function(e){this.b[0]||this.C(),e?(this.g=e.g.slice(0),this.f=e.f.slice(0),this.c=e.c):this.reset()};a.hash.sha256.hash=function(e){return new a.hash.sha256().update(e).finalize()};a.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(e){typeof e=="string"&&(e=a.codec.utf8String.toBits(e));var t,r=this.f=a.bitArray.concat(this.f,e);if(t=this.c,e=this.c=t+a.bitArray.bitLength(e),9007199254740991t;r++){for(i=!0,n=2;n*n<=r;n++)if(r%n===0){i=!1;break}i&&(8>t&&(this.o[t]=e(Math.pow(r,.5))),this.b[t]=e(Math.pow(r,1/3)),t++)}},l:function(e){var t,r,n,i=this.g,o=this.b,s=i[0],c=i[1],u=i[2],f=i[3],l=i[4],h=i[5],m=i[6],p=i[7];for(t=0;64>t;t++)16>t?r=e[t]:(r=e[t+1&15],n=e[t+14&15],r=e[t&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+e[t&15]+e[t+9&15]|0),r=r+p+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(m^l&(h^m))+o[t],p=m,m=h,h=l,l=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;i[0]=i[0]+s|0,i[1]=i[1]+c|0,i[2]=i[2]+u|0,i[3]=i[3]+f|0,i[4]=i[4]+l|0,i[5]=i[5]+h|0,i[6]=i[6]+m|0,i[7]=i[7]+p|0}};a.hash.sha512=function(e){this.b[0]||this.C(),e?(this.g=e.g.slice(0),this.f=e.f.slice(0),this.c=e.c):this.reset()};a.hash.sha512.hash=function(e){return new a.hash.sha512().update(e).finalize()};a.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(e){typeof e=="string"&&(e=a.codec.utf8String.toBits(e));var t,r=this.f=a.bitArray.concat(this.f,e);if(t=this.c,e=this.c=t+a.bitArray.bitLength(e),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]=e(Math.pow(n,.5)),this.o[2*r+1]=t(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=e(Math.pow(n,1/3)),this.b[2*r+1]=t(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(e){var t,r,n=this.g,i=this.b,o=n[0],s=n[1],c=n[2],u=n[3],f=n[4],l=n[5],h=n[6],m=n[7],p=n[8],b=n[9],N=n[10],J=n[11],Q=n[12],ze=n[13],It=n[14],He=n[15],S;if(typeof Uint32Array<"u"){S=Array(160);for(var _=0;32>_;_++)S[_]=e[_]}else S=e;var _=o,I=s,ye=c,ne=u,ve=f,ie=l,ct=h,Ee=m,z=p,U=b,$e=N,ge=J,qe=Q,we=ze,ut=It,Ae=He;for(e=0;80>e;e++){if(16>e)t=S[2*e],r=S[2*e+1];else{r=S[2*(e-15)];var A=S[2*(e-15)+1];t=(A<<31|r>>>1)^(A<<24|r>>>8)^r>>>7;var H=(r<<31|A>>>1)^(r<<24|A>>>8)^(r<<25|A>>>7);r=S[2*(e-2)];var q=S[2*(e-2)+1],A=(q<<13|r>>>19)^(r<<3|q>>>29)^r>>>6,q=(r<<13|q>>>19)^(q<<3|r>>>29)^(r<<26|q>>>6),ft=S[2*(e-7)],lt=S[2*(e-16)],Le=S[2*(e-16)+1];r=H+S[2*(e-7)+1],t=t+ft+(r>>>0>>0?1:0),r+=q,t+=A+(r>>>0>>0?1:0),r+=Le,t+=lt+(r>>>0>>0?1:0)}S[2*e]=t|=0,S[2*e+1]=r|=0;var ft=z&$e^~z&qe,Ut=U&ge^~U&we,q=_&ye^_&ve^ye&ve,Ur=I&ne^I&ie^ne&ie,lt=(I<<4|_>>>28)^(_<<30|I>>>2)^(_<<25|I>>>7),Le=(_<<4|I>>>28)^(I<<30|_>>>2)^(I<<25|_>>>7),Mr=i[2*e],Mt=i[2*e+1],A=Ae+((z<<18|U>>>14)^(z<<14|U>>>18)^(U<<23|z>>>9)),H=ut+((U<<18|z>>>14)^(U<<14|z>>>18)^(z<<23|U>>>9))+(A>>>0>>0?1:0),A=A+Ut,H=H+(ft+(A>>>0>>0?1:0)),A=A+Mt,H=H+(Mr+(A>>>0>>0?1:0)),A=A+r|0,H=H+(t+(A>>>0>>0?1:0));r=Le+Ur,t=lt+q+(r>>>0>>0?1:0),ut=qe,Ae=we,qe=$e,we=ge,$e=z,ge=U,U=Ee+A|0,z=ct+H+(U>>>0>>0?1:0)|0,ct=ve,Ee=ie,ve=ye,ie=ne,ye=_,ne=I,I=A+r|0,_=H+t+(I>>>0>>0?1:0)|0}s=n[1]=s+I|0,n[0]=o+_+(s>>>0>>0?1:0)|0,u=n[3]=u+ne|0,n[2]=c+ye+(u>>>0>>0?1:0)|0,l=n[5]=l+ie|0,n[4]=f+ve+(l>>>0>>0?1:0)|0,m=n[7]=m+Ee|0,n[6]=h+ct+(m>>>0>>0?1:0)|0,b=n[9]=b+U|0,n[8]=p+z+(b>>>0>>0?1:0)|0,J=n[11]=J+ge|0,n[10]=N+$e+(J>>>0>>0?1:0)|0,ze=n[13]=ze+we|0,n[12]=Q+qe+(ze>>>0>>0?1:0)|0,He=n[15]=He+Ae|0,n[14]=It+ut+(He>>>0>>0?1:0)|0}};a.mode.ccm={name:"ccm",F:[],listenProgress:function(e){a.mode.ccm.F.push(e)},unListenProgress:function(e){e=a.mode.ccm.F.indexOf(e),-1u)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&f>>>8*o;o++);return o<15-u&&(o=15-u),r=c.clamp(r,8*(15-o)),t=a.mode.ccm.U(e,t,r,n,i,o),s=a.mode.ccm.V(e,s,r,t,i,o),c.concat(s.data,s.tag)},decrypt:function(e,t,r,n,i){i=i||64,n=n||[];var o=a.bitArray,s=o.bitLength(r)/8,f=o.bitLength(t),c=o.clamp(t,f-i),u=o.bitSlice(t,f-i),f=(f-i)/8;if(7>s)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(t=2;4>t&&f>>>8*t;t++);if(t<15-s&&(t=15-s),r=o.clamp(r,8*(15-t)),c=a.mode.ccm.V(e,c,r,u,i,t),e=a.mode.ccm.U(e,c.data,r,n,i,t),!o.equal(c.tag,e))throw new a.exception.corrupt("ccm: tag doesn't match");return c.data},ma:function(e,t,r,n,i,o){var s=[],c=a.bitArray,u=c.P;if(n=[c.partial(8,(t.length?64:0)|n-2<<2|o-1)],n=c.concat(n,r),n[3]|=i,n=e.encrypt(n),t.length)for(r=c.bitLength(t)/8,65279>=r?s=[c.partial(16,r)]:4294967295>=r&&(s=c.concat([c.partial(16,65534)],[r])),s=c.concat(s,t),t=0;ti||16l&&(a.mode.ccm.da(s/u),l+=h),r[3]++,i=e.encrypt(r),t[s]^=i[0],t[s+1]^=i[1],t[s+2]^=i[2],t[s+3]^=i[3];return{tag:n,data:c.clamp(t,f)}}};a.misc.hmac=function(e,t){this.W=t=t||a.hash.sha256;var r=[[],[]],n,i=t.prototype.blockSize/32;for(this.B=[new t,new t],e.length>i&&(e=t.hash(e)),n=0;nn||0>r)throw new a.exception.invalid("invalid params to pbkdf2");typeof e=="string"&&(e=a.codec.utf8String.toBits(e)),typeof t=="string"&&(t=a.codec.utf8String.toBits(t)),i=i||a.misc.hmac,e=new i(e);var o,s,c,u,f=[],l=a.bitArray;for(u=1;32*f.length<(n||1);u++){for(i=o=e.encrypt(l.concat(t,[u])),s=1;ss;s++)i.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=o),this.N++,this.b=a.hash.sha256.hash(this.b.concat(i)),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,t,o,e.length].concat(e))}break;case"string":t===void 0&&(t=e.length),this.h[s].update([n,this.M++,3,t,o,e.length]),this.h[s].update(e);break;default:u=1}if(u)throw new a.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=t,this.i+=t,c===this.A&&(this.isReady()!==this.A&&ir("seeded",Math.max(this.u,this.i)),ir("progress",this.getProgress()))},isReady:function(e){return e=this.R[e!==void 0?e:this.L],this.u&&this.u>=e?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=e?this.I|this.A:this.A},getProgress:function(e){return e=this.R[e||this.L],this.u>=e||this.i>e?1:this.i/e},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:Ce(this,this.la),mouseCollector:Ce(this,this.na),keyboardCollector:Ce(this,this.ja),accelerometerCollector:Ce(this,this.ca),touchCollector:Ce(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(e,t){this.J[e][this.ea++]=t},removeEventListener:function(e,t){var r,n,i=this.J[e],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===t&&o.push(n);for(r=0;rt&&(e.m[t]=e.m[t]+1|0,!e.m[t]);t++);return e.K.encrypt(e.m)}function Ce(e,t){return function(){t.apply(e,arguments)}}a.random=new a.prng(6);e:try{if(et=typeof ce<"u"&&ce.exports){try{tt=zr("crypto")}catch{tt=null}et=Ye=tt}if(et&&Ye.randomBytes)Re=Ye.randomBytes(128),Re=new Uint32Array(new Uint8Array(Re).buffer),a.random.addEntropy(Re,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(e){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(e))}var Re,Ye,Se,et,tt;a.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(e,t,r,n){r=r||{},n=n||{};var i=a.json,o=i.j({iv:a.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=a.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=a.codec.base64.toBits(o.iv)),!a.mode[o.mode]||!a.cipher[o.cipher]||typeof e=="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=t.iter||t.ts!==64&&t.ts!==96&&t.ts!==128||t.ks!==128&&t.ks!==192&&t.ks!==256||!t.iv||2>t.iv.length||4{"use strict";var Dn=Object.prototype.hasOwnProperty,k="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(k=!1));function xn(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Ar(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new xn(r,n||e,i),s=k?k+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function rt(e,t){--e._eventsCount===0?e._events=new ke:delete e._events[t]}function R(){this._events=new ke,this._eventsCount=0}R.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Dn.call(r,n)&&t.push(k?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};R.prototype.listeners=function(t){var r=k?k+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i{let n=t.isOk()?{type:"Ok",value:t.value}:{type:"Err",value:t.error},i=r.withStackTrace?new Error().stack:void 0;return{data:n,message:e,stack:i}};function oe(e,t,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 c(l){try{f(n.next(l))}catch(h){s(h)}}function u(l){try{f(n.throw(l))}catch(h){s(h)}}function f(l){l.done?o(l.value):i(l.value).then(c,u)}f((n=n.apply(e,t||[])).next())})}function Ft(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function G(e){return this instanceof G?(this.v=e,this):new G(e)}function Bt(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(p){return function(b){return Promise.resolve(b).then(p,h)}}function c(p,b){n[p]&&(i[p]=function(N){return new Promise(function(J,Q){o.push([p,N,J,Q])>1||u(p,N)})},b&&(i[p]=b(i[p])))}function u(p,b){try{f(n[p](b))}catch(N){m(o[0][3],N)}}function f(p){p.value instanceof G?Promise.resolve(p.value.v).then(l,h):m(o[0][2],p)}function l(p){u("next",p)}function h(p){u("throw",p)}function m(p,b){p(b),o.shift(),o.length&&u(o[0][0],o[0][1])}}function qr(e){var t,r;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,o){t[i]=e[i]?function(s){return(r=!r)?{value:G(e[i](s)),done:!1}:o?o(s):s}:o}}function Gr(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof Ft=="function"?Ft(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(s){return new Promise(function(c,u){s=e[o](s),i(c,u,s.done,s.value)})}}function i(o,s,c,u){Promise.resolve(u).then(function(f){o({value:f,done:c})},s)}}var O=class e{constructor(t){this._promise=t}static fromSafePromise(t){let r=t.then(n=>new F(n));return new e(r)}static fromPromise(t,r){let n=t.then(i=>new F(i)).catch(i=>new B(r(i)));return new e(n)}static fromThrowable(t,r){return(...n)=>new e(oe(this,void 0,void 0,function*(){try{return new F(yield t(...n))}catch(i){return new B(r?r(i):i)}}))}static combine(t){return Vr(t)}static combineWithAllErrors(t){return Xr(t)}map(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){return r.isErr()?new B(r.error):new F(yield t(r.value))})))}andThrough(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);let n=yield t(r.value);return n.isErr()?new B(n.error):new F(r.value)})))}andTee(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);try{yield t(r.value)}catch{}return new F(r.value)})))}mapErr(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){return r.isOk()?new F(r.value):new B(yield t(r.error))})))}andThen(t){return new e(this._promise.then(r=>{if(r.isErr())return new B(r.error);let n=t(r.value);return n instanceof e?n._promise:n}))}orElse(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){return r.isErr()?t(r.error):new F(r.value)})))}match(t,r){return this._promise.then(n=>n.match(t,r))}unwrapOr(t){return this._promise.then(r=>r.unwrapOr(t))}safeUnwrap(){return Bt(this,arguments,function*(){return yield G(yield G(yield*qr(Gr(yield G(this._promise.then(r=>r.safeUnwrap()))))))})}then(t,r){return this._promise.then(t,r)}[Symbol.asyncIterator](){return Bt(this,arguments,function*(){let r=yield G(this._promise);return r.isErr()&&(yield yield G(L(r.error))),yield G(r.value)})}},C=e=>new O(Promise.resolve(new F(e))),L=e=>new O(Promise.resolve(new B(e))),Rn=O.fromPromise,Sn=O.fromSafePromise,kn=O.fromThrowable,Wt=e=>{let t=re([]);for(let r of e)if(r.isErr()){t=Z(r.error);break}else t.map(n=>n.push(r.value));return t},Vr=e=>O.fromSafePromise(Promise.all(e)).andThen(Wt),Jt=e=>{let t=re([]);for(let r of e)r.isErr()&&t.isErr()?t.error.push(r.error):r.isErr()&&t.isOk()?t=Z([r.error]):r.isOk()&&t.isOk()&&t.value.push(r.value);return t},Xr=e=>O.fromSafePromise(Promise.all(e)).andThen(Jt),mt;(function(e){function t(i,o){return(...s)=>{try{let c=i(...s);return re(c)}catch(c){return Z(o?o(c):c)}}}e.fromThrowable=t;function r(i){return Wt(i)}e.combine=r;function n(i){return Jt(i)}e.combineWithAllErrors=n})(mt||(mt={}));var re=e=>new F(e);function Z(e){return new B(e)}var F=class{constructor(t){this.value=t}isOk(){return!0}isErr(){return!this.isOk()}map(t){return re(t(this.value))}mapErr(t){return re(this.value)}andThen(t){return t(this.value)}andThrough(t){return t(this.value).map(r=>this.value)}andTee(t){try{t(this.value)}catch{}return re(this.value)}orElse(t){return re(this.value)}asyncAndThen(t){return t(this.value)}asyncAndThrough(t){return t(this.value).map(()=>this.value)}asyncMap(t){return O.fromSafePromise(t(this.value))}unwrapOr(t){return this.value}match(t,r){return t(this.value)}safeUnwrap(){let t=this.value;return function*(){return t}()}_unsafeUnwrap(t){return this.value}_unsafeUnwrapErr(t){throw jt("Called `_unsafeUnwrapErr` on an Ok",this,t)}*[Symbol.iterator](){return this.value}},B=class{constructor(t){this.error=t}isOk(){return!1}isErr(){return!this.isOk()}map(t){return Z(this.error)}mapErr(t){return Z(t(this.error))}andThrough(t){return Z(this.error)}andTee(t){return Z(this.error)}andThen(t){return Z(this.error)}orElse(t){return t(this.error)}asyncAndThen(t){return L(this.error)}asyncAndThrough(t){return L(this.error)}asyncMap(t){return L(this.error)}unwrapOr(t){return t}match(t,r){return r(this.error)}safeUnwrap(){let t=this.error;return function*(){throw yield Z(t),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(t){throw jt("Called `_unsafeUnwrap` on an Err",this,t)}_unsafeUnwrapErr(t){return this.error}*[Symbol.iterator](){let t=this;return yield t,t}},Pn=mt.fromThrowable;var P=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});g(this,"context");this.name=this.constructor.name,this.context=o}};var V=class extends P{};var be=class extends V{constructor(){super(...arguments);g(this,"message","An error occured while trying to connect to WebSocket")}};var $=e=>{if(e instanceof Error)return e;let t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch{}return new Error(t)};var Kr=()=>typeof Deno<"u";var yt=e=>Kr()?new URL(`./worker/${e}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${e!=="encrypt"?`worker/${e}`:e}.js`));var er=Oe(Ke());var v=new er.default,Y=(e,t)=>(Object.assign(e,t),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:e}),e),Et=(e,t)=>{Y(e,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:t})},tr=()=>{v.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),v.once("OPERATION_FAILED",e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var ae=class{constructor(t,r){if(!t||t.length!=64)throw Error("Charset must contain 64 characters");this._charset=t,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(t){let r=t.byteLength;if(!r)return"";let n=new Uint8Array(t),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(t){if(t=(t||"").replace(/[\s]/g,""),!t)return new ArrayBuffer(0);if(!this._valid.test(t))throw Error("Invalid base64 input sequence");let r=Math.floor(t.length*.75);t[t.length-2]=="="?r-=2:t[t.length-1]=="="&&r--;let n=new Uint8Array(r),i,o,s,c,u=0,f=0;for(;u>4,n[u++]=(o&15)<<4|s>>2,n[u++]=(s&3)<<6|c;return n.buffer}};var rr=new ae("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function De(e){return rr.Encode(e)}function xe(e){return rr.Decode(e)}var nn=new ae("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function gt(e){return nn.Decode(e)}var Lt=Oe(sr());var X=class extends P{};var ue=class extends X{constructor(){super(...arguments);g(this,"message","Unable to decrypt the provided data")}};var fe=class extends X{constructor(){super(...arguments);g(this,"message","Unable to encrypt the provided data")}};var ar=(e,t)=>{try{let r=typeof t=="string"?t:t.data;return C(xe(Lt.default.decrypt(e,r)))}catch(r){return L(new ue(void 0,{cause:$(r)}))}},cr=(e,t)=>{try{let r=Lt.default.encrypt(e,De(t));return C({algo:0,data:r,iv:JSON.parse(r).iv})}catch(r){return L(new fe(void 0,{cause:$(r)}))}};var ur=(e,t)=>lr(e).andThen(r=>O.fromPromise(crypto.subtle.decrypt({name:"AES-GCM",iv:t.iv},r,t.data),n=>new ue(void 0,{cause:$(n)}))),fr=(e,t)=>lr(e).andThen(r=>{let n=crypto.getRandomValues(new Uint8Array(12));return O.fromPromise(crypto.subtle.encrypt({name:"AES-GCM",iv:n},r,t),i=>new fe(void 0,{cause:$(i)})).andThen(i=>C({algo:1,data:i,iv:n}))}),lr=e=>O.fromPromise(crypto.subtle.importKey("raw",gt(e),{name:"AES-GCM"},!1,["encrypt","decrypt"]),t=>new X("Unable to import cryptography key",{cause:$(t)}));var hr=(e,t)=>t.algo===void 0||t.algo===0?ar(e,t):ur(e,t),dr=(e,t,r)=>r===0?cr(e,t):fr(e,t);var M={},mr=5,un=e=>(v.emit("UPLOAD_CANCELLED",e.success),C(void 0)),fn=(e,t)=>{let r=e.split("XXMOJOXX"),n=r.shift();if(n!==void 0){let i=JSON.parse(n);if(gn(i)){let o=r.shift();if(o){let s=JSON.parse(o);return s.iv&&(s.iv=new Uint8Array(Object.values(s.iv)),s.data=xe(s.data)),hr(t.keys.client,s).andThen(c=>{let u=typeof c=="string"?new TextEncoder().encode(c).buffer:c;return i.part===0?(Y(t,{chunksReady:t.chunksReady+1,delAtFirstView:i.del_at_first_view,delay:i.delay,name:i.name,size:i.size,totalChunks:i.total,type:i.type,zipped:i.zipped}),v.emit("DOWNLOAD_STARTED")):Y(t,{chunksReady:t.chunksReady+1}),v.emit("CHUNK_DOWNLOADED",u,i.part),t.chunksReady===i.total?pn(t).andThen(()=>(v.emit("DOWNLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED"),C(void 0))):C(void 0)})}else{let s=new V("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",s),L(s)}}else{let o=new V(i.msg);return v.emit("OPERATION_FAILED",o),L(o)}}else{let i=new V("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",i),L(i)}},ln=(e,t)=>{if(e.success)return e.j===0&&(Y(t,{keys:{client:t.keys.client,server:e.short},actionToken:e.token,queueIndex:e.i}),v.emit("UPLOAD_STARTED")),Y(t,{chunksReady:t.chunksReady+1,createdAt:e.created_at}),v.emit("CHUNK_UPLOADED"),t.chunksReady===t.totalChunks&&(Y(t,{uploadStatus:1}),v.emit("UPLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED")),C(void 0);{let r=new V(e.msg);return v.emit("OPERATION_FAILED",r),L(r)}},hn=(e,t)=>{let r=En(e.data),n;if(r)if(!r.action&&r.msg){let i=new V(r.msg);return v.emit("OPERATION_FAILED",i),L(i)}else"delay"in r?n=ln(r,t):n=un(r);else n=fn(e.data,t);return n},dn=e=>M!==void 0&&M[e]!==void 0&&M[e].readyState===WebSocket.CONNECTING,Ot=e=>M!==void 0&&M[e]!==void 0&&M[e].readyState===WebSocket.OPEN;var pn=e=>{let t;return e.password?t={ended:!0,file_pwd:e.password}:t={ended:!0},Dt(yn(e),e,JSON.stringify(t))},bt=(e,t,r)=>(r.data=De(r.data),Dt(vn(e),e,`${JSON.stringify(t)}XXMOJOXX${JSON.stringify(r)}`)),Dt=(e,t,r)=>Ot(e)?(M[e].send(r),C(void 0)):yr(e).andThen(()=>(M[e].onmessage=n=>hn(n,t),Dt(e,t,r))),yr=(e,t=0)=>(!Ot(e)&&!dn(e)&&(M[e]=new WebSocket(e),v.once("SOCKET_OPERATION_TERMINATED",()=>{M[e].close()}),v.once("OPERATION_FAILED",()=>{v.emit("SOCKET_OPERATION_TERMINATED")}),M[e].onopen=()=>{v.emit("SOCKET_OPENED")},M[e].onclose=()=>{},M[e].onerror=()=>++t<=mr?(console.error(`An error happened while trying to connect to WebSocket ${e}. Trying again. ${t} / ${mr}`),yr(e,t)):(v.emit("SOCKET_ONERROR"),L(new be(`Unable to connect to WebSocket ${e}.`)))),mn(e).andThen(()=>C(e)).orElse(r=>L(r))),mn=e=>O.fromPromise(new Promise((t,r)=>{Ot(e)?t(void 0):(v.once("SOCKET_OPENED",()=>{t(void 0)}),v.on("SOCKET_ONERROR",()=>{r(new be)}))}),t=>$(t));var vr=(e,t)=>{let r=new URL(e);return["ws:","wss:"].includes(r.protocol)||(r.protocol=r.protocol==="http:"?"ws:":"wss:"),r.pathname+=t,new URL(r.origin+r.pathname)},yn=e=>vr(new URL(e.serverUrl),"download"+`/${e.keys.server}`).toString(),vn=e=>vr(new URL(e.serverUrl),"upload").toString(),En=e=>{try{let t=JSON.parse(e);if(t&&typeof t=="object")return t}catch{}return!1},gn=e=>typeof e=="object"&&e!==null&&!("msg"in e);var gr=Oe(Ke());var Ln=Oe(Ke());var On={},ds=new gr.default;var bn=()=>Object.values(On).filter(e=>e.uploadStatus===4),wr=e=>Object.keys(bn()).indexOf(e);var _t=Oe(Lr(),1);var Pe=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ct=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},Or=e=>globalThis.DOMException===void 0?new Ct(e):new DOMException(e),br=e=>{let t=e.reason===void 0?Or("This operation was aborted."):e.reason;return t instanceof Error?t:Or(t)};function Rt(e,t){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=t,s,u=new Promise((f,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:m}=t;m.aborted&&l(br(m));let p=()=>{l(br(m))};m.addEventListener("abort",p,{once:!0}),e.finally(()=>{m.removeEventListener("abort",p)})}if(r===Number.POSITIVE_INFINITY){e.then(f,l);return}let h=new Pe;s=o.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(m){l(m)}return}typeof e.cancel=="function"&&e.cancel(),i===!1?f():i instanceof Error?l(i):(h.message=i!=null?i:`Promise timed out after ${r} milliseconds`,l(h))},r),(async()=>{try{f(await e)}catch(m){l(m)}})()}).finally(()=>{u.clear()});return u.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},u}function St(e,t,r){let n=0,i=e.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(e[s],t)<=0?(n=++s,i-=o+1):i=o}return n}var K,Te=class{constructor(){D(this,K,[])}enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&d(this,K)[this.size-1].priority>=r.priority){d(this,K).push(n);return}let i=St(d(this,K),n,(o,s)=>s.priority-o.priority);d(this,K).splice(i,0,n)}dequeue(){let t=d(this,K).shift();return t==null?void 0:t.run}filter(t){return d(this,K).filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return d(this,K).length}};K=new WeakMap;var le,he,te,Ue,de,Me,j,pe,T,Ne,W,me,ee,Fe,y,Dr,xr,_r,Cr,Rr,nt,kt,Pt,it,Sr,ot,Ie=class extends _t.default{constructor(r){var n,i,o,s;super();D(this,y);D(this,le);D(this,he);D(this,te,0);D(this,Ue);D(this,de);D(this,Me,0);D(this,j);D(this,pe);D(this,T);D(this,Ne);D(this,W,0);D(this,me);D(this,ee);D(this,Fe);g(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 \`${(i=(n=r.intervalCap)==null?void 0:n.toString())!=null?i:""}\` (${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=(o=r.interval)==null?void 0:o.toString())!=null?s:""}\` (${typeof r.interval})`);w(this,le,r.carryoverConcurrencyCount),w(this,he,r.intervalCap===Number.POSITIVE_INFINITY||r.interval===0),w(this,Ue,r.intervalCap),w(this,de,r.interval),w(this,T,new r.queueClass),w(this,Ne,r.queueClass),this.concurrency=r.concurrency,this.timeout=r.timeout,w(this,Fe,r.throwOnTimeout===!0),w(this,ee,r.autoStart===!1)}get concurrency(){return d(this,me)}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,me,r),x(this,y,it).call(this)}async add(r,n={}){return n={timeout:this.timeout,throwOnTimeout:d(this,Fe),...n},new Promise((i,o)=>{d(this,T).enqueue(async()=>{var s;Ge(this,W)._++,Ge(this,te)._++;try{(s=n.signal)==null||s.throwIfAborted();let c=r({signal:n.signal});n.timeout&&(c=Rt(Promise.resolve(c),{milliseconds:n.timeout})),n.signal&&(c=Promise.race([c,x(this,y,Sr).call(this,n.signal)]));let u=await c;i(u),this.emit("completed",u)}catch(c){if(c instanceof Pe&&!n.throwOnTimeout){i();return}o(c),this.emit("error",c)}finally{x(this,y,_r).call(this)}},n),this.emit("add"),x(this,y,nt).call(this)})}async addAll(r,n){return Promise.all(r.map(async i=>this.add(i,n)))}start(){return d(this,ee)?(w(this,ee,!1),x(this,y,it).call(this),this):this}pause(){w(this,ee,!0)}clear(){w(this,T,new(d(this,Ne)))}async onEmpty(){d(this,T).size!==0&&await x(this,y,ot).call(this,"empty")}async onSizeLessThan(r){d(this,T).sized(this,T).size{x(this,y,Cr).call(this)},n)),!0}return!1},nt=function(){if(d(this,T).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,ee)){let r=!d(this,y,Rr);if(d(this,y,Dr)&&d(this,y,xr)){let n=d(this,T).dequeue();return n?(this.emit("active"),n(),r&&x(this,y,kt).call(this),!0):!1}}return!1},kt=function(){d(this,he)||d(this,j)!==void 0||(w(this,j,setInterval(()=>{x(this,y,Pt).call(this)},d(this,de))),w(this,Me,Date.now()+d(this,de)))},Pt=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),x(this,y,it).call(this)},it=function(){for(;x(this,y,nt).call(this););},Sr=async function(r){return new Promise((n,i)=>{r.addEventListener("abort",()=>{i(r.reason)},{once:!0})})},ot=async function(r,n){return new Promise(i=>{let o=()=>{n&&!n()||(this.off(r,o),i())};this.on(r,o)})};var st=class extends P{};var Be=class extends st{constructor(){super(...arguments);g(this,"message","Parameter must be defined")}};var kr=!1,Tt=navigator.hardwareConcurrency||1,Je=new Ie({concurrency:Tt,autoStart:!1}),We=0,at=!1,je,Pr=new Worker(yt("encrypt"),{type:"module"});self.onmessage=e=>{if(kr||(tr(),kr=!0,je=e.data.args.lufiFile,v.once("UPLOAD_STARTED",()=>{self.postMessage({event:"UPLOAD_STARTED"})}),v.on("CHUNK_UPLOADED",()=>{self.postMessage({event:"CHUNK_UPLOADED"}),We--,Je.isPaused&&!at&&We{self.postMessage({event:"UPLOAD_COMPLETE"})}),v.on("FILE_UPDATED",Y)),e.data.args.chunk)return e.data.args.lufiFile=je,_n(e.data,wr(je.keys.client)).mapErr(t=>{Et(je,t)});e.data.action===0?(at=!0,Ir()):e.data.action===2?(at=!1,Tr()):Et(je,new Be)};var _n=(e,t)=>{let{lufiFile:r,algo:n}=e.args;if(e.args.chunk&&n)e.args.chunk.index===0?dr(r.keys.client,e.args.chunk.buffer,n).map(i=>{bt(r,{total:r.totalChunks,part:0,size:r.size,name:r.name,type:r.type,delay:r.delay,del_at_first_view:r.delAtFirstView,zipped:r.zipped,id:null,i:t,file_pwd:r.password},i),We++}):Je.add(()=>{if(e.args.chunk){let i=()=>(We++,new Promise(o=>{Pr.onmessage=s=>{o(bt(r,{total:r.totalChunks,part:s.data.chunkIndex,size:r.size,name:r.name,type:r.type,delay:r.delay,del_at_first_view:r.delAtFirstView,zipped:r.zipped,id:r.keys.server,i:t,file_pwd:r.password},s.data.encryptedData))}}));Pr.postMessage(e,[e.args.chunk.buffer]),!Je.isPaused&&(at||We===Tt)&&Ir(),i()}});else return L(new Be("algo must be defined"));return C(void 0)},Ir=()=>{Je.pause(),self.postMessage({event:"JOB_PAUSED"})},Tr=()=>{Je.start(),self.postMessage({event:"JOB_RESUMED"})}; +var Nr=Object.create;var ht=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var Nt=e=>{throw TypeError(e)};var Jr=(e,t,r)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var zr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var pt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Hr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Br(t))!Wr.call(e,i)&&i!==r&&ht(e,i,{get:()=>t[i],enumerable:!(n=Fr(t,i))||n.enumerable});return e};var be=(e,t,r)=>(r=e!=null?Nr(jr(e)):{},Hr(t||!e||!e.__esModule?ht(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>Jr(e,typeof t!="symbol"?t+"":t,r),dt=(e,t,r)=>t.has(e)||Nt("Cannot "+r);var p=(e,t,r)=>(dt(e,t,"read from private field"),r?r.call(e):t.get(e)),D=(e,t,r)=>t.has(e)?Nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),w=(e,t,r,n)=>(dt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),x=(e,t,r)=>(dt(e,t,"access private method"),r);var Ge=(e,t,r,n)=>({set _(i){w(e,t,i,r)},get _(){return p(e,t,n)}});var Ke=pt((ri,vt)=>{"use strict";var se=typeof Reflect=="object"?Reflect:null,zt=se&&typeof se.apply=="function"?se.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},Ve;se&&typeof se.ownKeys=="function"?Ve=se.ownKeys:Object.getOwnPropertySymbols?Ve=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Ve=function(t){return Object.getOwnPropertyNames(t)};function Qr(e){console&&console.warn&&console.warn(e)}var $t=Number.isNaN||function(t){return t!==t};function E(){E.init.call(this)}vt.exports=E;vt.exports.once=tn;E.EventEmitter=E;E.prototype._events=void 0;E.prototype._eventsCount=0;E.prototype._maxListeners=void 0;var Ht=10;function Xe(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(E,"defaultMaxListeners",{enumerable:!0,get:function(){return Ht},set:function(e){if(typeof e!="number"||e<0||$t(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ht=e}});E.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};E.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||$t(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function qt(e){return e._maxListeners===void 0?E.defaultMaxListeners:e._maxListeners}E.prototype.getMaxListeners=function(){return qt(this)};E.prototype.emit=function(t){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=o[t];if(u===void 0)return!1;if(typeof u=="function")zt(u,this,r);else for(var f=u.length,l=Qt(u,f),n=0;n0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,Qr(c)}return e}E.prototype.addListener=function(t,r){return Gt(this,t,r,!1)};E.prototype.on=E.prototype.addListener;E.prototype.prependListener=function(t,r){return Gt(this,t,r,!0)};function Zr(){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 Vt(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Zr.bind(n);return i.listener=r,n.wrapFn=i,i}E.prototype.once=function(t,r){return Xe(r),this.on(t,Vt(this,t,r)),this};E.prototype.prependOnceListener=function(t,r){return Xe(r),this.prependListener(t,Vt(this,t,r)),this};E.prototype.removeListener=function(t,r){var n,i,o,s,c;if(Xe(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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){c=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():Yr(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,c||r)}return this};E.prototype.off=E.prototype.removeListener;E.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i=0;i--)this.removeListener(t,r[i]);return this};function Xt(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?en(i):Qt(i,i.length)}E.prototype.listeners=function(t){return Xt(this,t,!0)};E.prototype.rawListeners=function(t){return Xt(this,t,!1)};E.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Kt.call(e,t)};E.prototype.listenerCount=Kt;function Kt(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}E.prototype.eventNames=function(){return this._eventsCount>0?Ve(this._events):[]};function Qt(e,t){for(var r=new Array(t),n=0;n{"use strict";var a={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};a.cipher.aes=function(e){this.w[0][0][0]||this.C();var t,r,n,i,o=this.w[0][4],s=this.w[1];t=e.length;var c=1;if(t!==4&&t!==6&&t!==8)throw new a.exception.invalid("invalid aes key size");for(this.b=[n=e.slice(0),i=[]],e=t;e<4*t+28;e++)r=n[e-1],(e%t===0||t===8&&e%t===4)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[r&255],e%t===0&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),n[e]=n[e-t]^r;for(t=0;e;t++,e--)r=n[t&3?e:e-4],i[t]=4>=e||4>t?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[r&255]]};a.cipher.aes.prototype={encrypt:function(e){return nr(this,e,0)},decrypt:function(e){return nr(this,e,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var e=this.w[0],t=this.w[1],r=e[4],n=t[4],i,o,s,c=[],u=[],f,l,h,m;for(i=0;256>i;i++)u[(c[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=f||1,s=u[s]||1)for(h=s^s<<1^s<<2^s<<3^s<<4,h=h>>8^h&255^99,r[o]=h,n[h]=o,l=c[i=c[f=c[o]]],m=16843009*l^65537*i^257*f^16843008*o,l=257*c[h]^16843008*h,i=0;4>i;i++)e[i][o]=l=l<<24^l>>>8,t[i][h]=m=m<<24^m>>>8;for(i=0;5>i;i++)e[i]=e[i].slice(0),t[i]=t[i].slice(0)}};function nr(e,t,r){if(t.length!==4)throw new a.exception.invalid("invalid aes block size");var n=e.b[r],i=t[0]^n[0],o=t[r?3:1]^n[1],s=t[2]^n[2];t=t[r?1:3]^n[3];var c,u,f,l=n.length/4-2,h,m=4,d=[0,0,0,0];c=e.w[r],e=c[0];var O=c[1],N=c[2],J=c[3],Q=c[4];for(h=0;h>>24]^O[o>>16&255]^N[s>>8&255]^J[t&255]^n[m],u=e[o>>>24]^O[s>>16&255]^N[t>>8&255]^J[i&255]^n[m+1],f=e[s>>>24]^O[t>>16&255]^N[i>>8&255]^J[o&255]^n[m+2],t=e[t>>>24]^O[i>>16&255]^N[o>>8&255]^J[s&255]^n[m+3],m+=4,i=c,o=u,s=f;for(h=0;4>h;h++)d[r?3&-h:h]=Q[i>>>24]<<24^Q[o>>16&255]<<16^Q[s>>8&255]<<8^Q[t&255]^n[m++],c=i,i=o,o=s,s=t,t=c;return d}a.bitArray={bitSlice:function(e,t,r){return e=a.bitArray.Y(e.slice(t/32),32-(t&31)).slice(1),r===void 0?e:a.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return((t+r-1^t)&-32?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return e===32?t:(r?t|0:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(a.bitArray.bitLength(e)!==a.bitArray.bitLength(t))return!1;var r=0,n;for(n=0;n>>t),r=e[i]<<32-t;return i=e.length?e[e.length-1]:0,e=a.bitArray.getPartial(i),n.push(a.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(r&65280)<<8|r<<24;return e}};a.codec.utf8String={fromBits:function(e){var t="",r=a.bitArray.bitLength(e),n,i;for(n=0;n>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(t))},toBits:function(e){e=unescape(encodeURIComponent(e));var t=[],r,n=0;for(r=0;r>>i)>>>26),6>i?(s=e[r]<<6-i,i+=26,r++):(s<<=6,i-=6);for(;n.length&3&&!t;)n+="=";return n},toBits:function(e,t){e=e.replace(/\s|=/g,"");var r=[],n,i=0,o=a.codec.base64.S,s=0,c;for(t&&(o=o.substr(0,62)+"-_"),n=0;nc)throw new a.exception.invalid("this isn't base64!");26>>i),s=c<<32-i):(i+=6,s^=c<<32-i)}return i&56&&r.push(a.bitArray.partial(i&56,s,1)),r}};a.codec.base64url={fromBits:function(e){return a.codec.base64.fromBits(e,1,1)},toBits:function(e){return a.codec.base64.toBits(e,1)}};a.hash.sha256=function(e){this.b[0]||this.C(),e?(this.g=e.g.slice(0),this.f=e.f.slice(0),this.c=e.c):this.reset()};a.hash.sha256.hash=function(e){return new a.hash.sha256().update(e).finalize()};a.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(e){typeof e=="string"&&(e=a.codec.utf8String.toBits(e));var t,r=this.f=a.bitArray.concat(this.f,e);if(t=this.c,e=this.c=t+a.bitArray.bitLength(e),9007199254740991t;r++){for(i=!0,n=2;n*n<=r;n++)if(r%n===0){i=!1;break}i&&(8>t&&(this.o[t]=e(Math.pow(r,.5))),this.b[t]=e(Math.pow(r,1/3)),t++)}},l:function(e){var t,r,n,i=this.g,o=this.b,s=i[0],c=i[1],u=i[2],f=i[3],l=i[4],h=i[5],m=i[6],d=i[7];for(t=0;64>t;t++)16>t?r=e[t]:(r=e[t+1&15],n=e[t+14&15],r=e[t&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+e[t&15]+e[t+9&15]|0),r=r+d+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(m^l&(h^m))+o[t],d=m,m=h,h=l,l=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;i[0]=i[0]+s|0,i[1]=i[1]+c|0,i[2]=i[2]+u|0,i[3]=i[3]+f|0,i[4]=i[4]+l|0,i[5]=i[5]+h|0,i[6]=i[6]+m|0,i[7]=i[7]+d|0}};a.hash.sha512=function(e){this.b[0]||this.C(),e?(this.g=e.g.slice(0),this.f=e.f.slice(0),this.c=e.c):this.reset()};a.hash.sha512.hash=function(e){return new a.hash.sha512().update(e).finalize()};a.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(e){typeof e=="string"&&(e=a.codec.utf8String.toBits(e));var t,r=this.f=a.bitArray.concat(this.f,e);if(t=this.c,e=this.c=t+a.bitArray.bitLength(e),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]=e(Math.pow(n,.5)),this.o[2*r+1]=t(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=e(Math.pow(n,1/3)),this.b[2*r+1]=t(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(e){var t,r,n=this.g,i=this.b,o=n[0],s=n[1],c=n[2],u=n[3],f=n[4],l=n[5],h=n[6],m=n[7],d=n[8],O=n[9],N=n[10],J=n[11],Q=n[12],ze=n[13],It=n[14],He=n[15],S;if(typeof Uint32Array<"u"){S=Array(160);for(var _=0;32>_;_++)S[_]=e[_]}else S=e;var _=o,I=s,ye=c,ne=u,ve=f,ie=l,ct=h,Ee=m,z=d,U=O,$e=N,ge=J,qe=Q,we=ze,ut=It,Ae=He;for(e=0;80>e;e++){if(16>e)t=S[2*e],r=S[2*e+1];else{r=S[2*(e-15)];var A=S[2*(e-15)+1];t=(A<<31|r>>>1)^(A<<24|r>>>8)^r>>>7;var H=(r<<31|A>>>1)^(r<<24|A>>>8)^(r<<25|A>>>7);r=S[2*(e-2)];var q=S[2*(e-2)+1],A=(q<<13|r>>>19)^(r<<3|q>>>29)^r>>>6,q=(r<<13|q>>>19)^(q<<3|r>>>29)^(r<<26|q>>>6),ft=S[2*(e-7)],lt=S[2*(e-16)],Le=S[2*(e-16)+1];r=H+S[2*(e-7)+1],t=t+ft+(r>>>0>>0?1:0),r+=q,t+=A+(r>>>0>>0?1:0),r+=Le,t+=lt+(r>>>0>>0?1:0)}S[2*e]=t|=0,S[2*e+1]=r|=0;var ft=z&$e^~z&qe,Ut=U&ge^~U&we,q=_&ye^_&ve^ye&ve,Ur=I&ne^I&ie^ne&ie,lt=(I<<4|_>>>28)^(_<<30|I>>>2)^(_<<25|I>>>7),Le=(_<<4|I>>>28)^(I<<30|_>>>2)^(I<<25|_>>>7),Mr=i[2*e],Mt=i[2*e+1],A=Ae+((z<<18|U>>>14)^(z<<14|U>>>18)^(U<<23|z>>>9)),H=ut+((U<<18|z>>>14)^(U<<14|z>>>18)^(z<<23|U>>>9))+(A>>>0>>0?1:0),A=A+Ut,H=H+(ft+(A>>>0>>0?1:0)),A=A+Mt,H=H+(Mr+(A>>>0>>0?1:0)),A=A+r|0,H=H+(t+(A>>>0>>0?1:0));r=Le+Ur,t=lt+q+(r>>>0>>0?1:0),ut=qe,Ae=we,qe=$e,we=ge,$e=z,ge=U,U=Ee+A|0,z=ct+H+(U>>>0>>0?1:0)|0,ct=ve,Ee=ie,ve=ye,ie=ne,ye=_,ne=I,I=A+r|0,_=H+t+(I>>>0>>0?1:0)|0}s=n[1]=s+I|0,n[0]=o+_+(s>>>0>>0?1:0)|0,u=n[3]=u+ne|0,n[2]=c+ye+(u>>>0>>0?1:0)|0,l=n[5]=l+ie|0,n[4]=f+ve+(l>>>0>>0?1:0)|0,m=n[7]=m+Ee|0,n[6]=h+ct+(m>>>0>>0?1:0)|0,O=n[9]=O+U|0,n[8]=d+z+(O>>>0>>0?1:0)|0,J=n[11]=J+ge|0,n[10]=N+$e+(J>>>0>>0?1:0)|0,ze=n[13]=ze+we|0,n[12]=Q+qe+(ze>>>0>>0?1:0)|0,He=n[15]=He+Ae|0,n[14]=It+ut+(He>>>0>>0?1:0)|0}};a.mode.ccm={name:"ccm",F:[],listenProgress:function(e){a.mode.ccm.F.push(e)},unListenProgress:function(e){e=a.mode.ccm.F.indexOf(e),-1u)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&f>>>8*o;o++);return o<15-u&&(o=15-u),r=c.clamp(r,8*(15-o)),t=a.mode.ccm.U(e,t,r,n,i,o),s=a.mode.ccm.V(e,s,r,t,i,o),c.concat(s.data,s.tag)},decrypt:function(e,t,r,n,i){i=i||64,n=n||[];var o=a.bitArray,s=o.bitLength(r)/8,f=o.bitLength(t),c=o.clamp(t,f-i),u=o.bitSlice(t,f-i),f=(f-i)/8;if(7>s)throw new a.exception.invalid("ccm: iv must be at least 7 bytes");for(t=2;4>t&&f>>>8*t;t++);if(t<15-s&&(t=15-s),r=o.clamp(r,8*(15-t)),c=a.mode.ccm.V(e,c,r,u,i,t),e=a.mode.ccm.U(e,c.data,r,n,i,t),!o.equal(c.tag,e))throw new a.exception.corrupt("ccm: tag doesn't match");return c.data},ma:function(e,t,r,n,i,o){var s=[],c=a.bitArray,u=c.P;if(n=[c.partial(8,(t.length?64:0)|n-2<<2|o-1)],n=c.concat(n,r),n[3]|=i,n=e.encrypt(n),t.length)for(r=c.bitLength(t)/8,65279>=r?s=[c.partial(16,r)]:4294967295>=r&&(s=c.concat([c.partial(16,65534)],[r])),s=c.concat(s,t),t=0;ti||16l&&(a.mode.ccm.da(s/u),l+=h),r[3]++,i=e.encrypt(r),t[s]^=i[0],t[s+1]^=i[1],t[s+2]^=i[2],t[s+3]^=i[3];return{tag:n,data:c.clamp(t,f)}}};a.misc.hmac=function(e,t){this.W=t=t||a.hash.sha256;var r=[[],[]],n,i=t.prototype.blockSize/32;for(this.B=[new t,new t],e.length>i&&(e=t.hash(e)),n=0;nn||0>r)throw new a.exception.invalid("invalid params to pbkdf2");typeof e=="string"&&(e=a.codec.utf8String.toBits(e)),typeof t=="string"&&(t=a.codec.utf8String.toBits(t)),i=i||a.misc.hmac,e=new i(e);var o,s,c,u,f=[],l=a.bitArray;for(u=1;32*f.length<(n||1);u++){for(i=o=e.encrypt(l.concat(t,[u])),s=1;ss;s++)i.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=o),this.N++,this.b=a.hash.sha256.hash(this.b.concat(i)),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,t,o,e.length].concat(e))}break;case"string":t===void 0&&(t=e.length),this.h[s].update([n,this.M++,3,t,o,e.length]),this.h[s].update(e);break;default:u=1}if(u)throw new a.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=t,this.i+=t,c===this.A&&(this.isReady()!==this.A&&ir("seeded",Math.max(this.u,this.i)),ir("progress",this.getProgress()))},isReady:function(e){return e=this.R[e!==void 0?e:this.L],this.u&&this.u>=e?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=e?this.I|this.A:this.A},getProgress:function(e){return e=this.R[e||this.L],this.u>=e||this.i>e?1:this.i/e},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:Ce(this,this.la),mouseCollector:Ce(this,this.na),keyboardCollector:Ce(this,this.ja),accelerometerCollector:Ce(this,this.ca),touchCollector:Ce(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(e,t){this.J[e][this.ea++]=t},removeEventListener:function(e,t){var r,n,i=this.J[e],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===t&&o.push(n);for(r=0;rt&&(e.m[t]=e.m[t]+1|0,!e.m[t]);t++);return e.K.encrypt(e.m)}function Ce(e,t){return function(){t.apply(e,arguments)}}a.random=new a.prng(6);e:try{if(et=typeof ce<"u"&&ce.exports){try{tt=zr("crypto")}catch{tt=null}et=Ye=tt}if(et&&Ye.randomBytes)Re=Ye.randomBytes(128),Re=new Uint32Array(new Uint8Array(Re).buffer),a.random.addEntropy(Re,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(e){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(e))}var Re,Ye,Se,et,tt;a.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(e,t,r,n){r=r||{},n=n||{};var i=a.json,o=i.j({iv:a.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=a.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=a.codec.base64.toBits(o.iv)),!a.mode[o.mode]||!a.cipher[o.cipher]||typeof e=="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=t.iter||t.ts!==64&&t.ts!==96&&t.ts!==128||t.ks!==128&&t.ks!==192&&t.ks!==256||!t.iv||2>t.iv.length||4{"use strict";var Dn=Object.prototype.hasOwnProperty,k="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(k=!1));function xn(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Ar(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new xn(r,n||e,i),s=k?k+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function rt(e,t){--e._eventsCount===0?e._events=new ke:delete e._events[t]}function R(){this._events=new ke,this._eventsCount=0}R.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Dn.call(r,n)&&t.push(k?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};R.prototype.listeners=function(t){var r=k?k+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i{let n=t.isOk()?{type:"Ok",value:t.value}:{type:"Err",value:t.error},i=r.withStackTrace?new Error().stack:void 0;return{data:n,message:e,stack:i}};function oe(e,t,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 c(l){try{f(n.next(l))}catch(h){s(h)}}function u(l){try{f(n.throw(l))}catch(h){s(h)}}function f(l){l.done?o(l.value):i(l.value).then(c,u)}f((n=n.apply(e,t||[])).next())})}function Ft(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function G(e){return this instanceof G?(this.v=e,this):new G(e)}function Bt(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(d){return function(O){return Promise.resolve(O).then(d,h)}}function c(d,O){n[d]&&(i[d]=function(N){return new Promise(function(J,Q){o.push([d,N,J,Q])>1||u(d,N)})},O&&(i[d]=O(i[d])))}function u(d,O){try{f(n[d](O))}catch(N){m(o[0][3],N)}}function f(d){d.value instanceof G?Promise.resolve(d.value.v).then(l,h):m(o[0][2],d)}function l(d){u("next",d)}function h(d){u("throw",d)}function m(d,O){d(O),o.shift(),o.length&&u(o[0][0],o[0][1])}}function qr(e){var t,r;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,o){t[i]=e[i]?function(s){return(r=!r)?{value:G(e[i](s)),done:!1}:o?o(s):s}:o}}function Gr(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof Ft=="function"?Ft(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(s){return new Promise(function(c,u){s=e[o](s),i(c,u,s.done,s.value)})}}function i(o,s,c,u){Promise.resolve(u).then(function(f){o({value:f,done:c})},s)}}var b=class e{constructor(t){this._promise=t}static fromSafePromise(t){let r=t.then(n=>new F(n));return new e(r)}static fromPromise(t,r){let n=t.then(i=>new F(i)).catch(i=>new B(r(i)));return new e(n)}static fromThrowable(t,r){return(...n)=>new e(oe(this,void 0,void 0,function*(){try{return new F(yield t(...n))}catch(i){return new B(r?r(i):i)}}))}static combine(t){return Vr(t)}static combineWithAllErrors(t){return Xr(t)}map(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){return r.isErr()?new B(r.error):new F(yield t(r.value))})))}andThrough(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);let n=yield t(r.value);return n.isErr()?new B(n.error):new F(r.value)})))}andTee(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){if(r.isErr())return new B(r.error);try{yield t(r.value)}catch{}return new F(r.value)})))}mapErr(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){return r.isOk()?new F(r.value):new B(yield t(r.error))})))}andThen(t){return new e(this._promise.then(r=>{if(r.isErr())return new B(r.error);let n=t(r.value);return n instanceof e?n._promise:n}))}orElse(t){return new e(this._promise.then(r=>oe(this,void 0,void 0,function*(){return r.isErr()?t(r.error):new F(r.value)})))}match(t,r){return this._promise.then(n=>n.match(t,r))}unwrapOr(t){return this._promise.then(r=>r.unwrapOr(t))}safeUnwrap(){return Bt(this,arguments,function*(){return yield G(yield G(yield*qr(Gr(yield G(this._promise.then(r=>r.safeUnwrap()))))))})}then(t,r){return this._promise.then(t,r)}[Symbol.asyncIterator](){return Bt(this,arguments,function*(){let r=yield G(this._promise);return r.isErr()&&(yield yield G(L(r.error))),yield G(r.value)})}},C=e=>new b(Promise.resolve(new F(e))),L=e=>new b(Promise.resolve(new B(e))),Rn=b.fromPromise,Sn=b.fromSafePromise,kn=b.fromThrowable,Wt=e=>{let t=re([]);for(let r of e)if(r.isErr()){t=Z(r.error);break}else t.map(n=>n.push(r.value));return t},Vr=e=>b.fromSafePromise(Promise.all(e)).andThen(Wt),Jt=e=>{let t=re([]);for(let r of e)r.isErr()&&t.isErr()?t.error.push(r.error):r.isErr()&&t.isOk()?t=Z([r.error]):r.isOk()&&t.isOk()&&t.value.push(r.value);return t},Xr=e=>b.fromSafePromise(Promise.all(e)).andThen(Jt),mt;(function(e){function t(i,o){return(...s)=>{try{let c=i(...s);return re(c)}catch(c){return Z(o?o(c):c)}}}e.fromThrowable=t;function r(i){return Wt(i)}e.combine=r;function n(i){return Jt(i)}e.combineWithAllErrors=n})(mt||(mt={}));var re=e=>new F(e);function Z(e){return new B(e)}var F=class{constructor(t){this.value=t}isOk(){return!0}isErr(){return!this.isOk()}map(t){return re(t(this.value))}mapErr(t){return re(this.value)}andThen(t){return t(this.value)}andThrough(t){return t(this.value).map(r=>this.value)}andTee(t){try{t(this.value)}catch{}return re(this.value)}orElse(t){return re(this.value)}asyncAndThen(t){return t(this.value)}asyncAndThrough(t){return t(this.value).map(()=>this.value)}asyncMap(t){return b.fromSafePromise(t(this.value))}unwrapOr(t){return this.value}match(t,r){return t(this.value)}safeUnwrap(){let t=this.value;return function*(){return t}()}_unsafeUnwrap(t){return this.value}_unsafeUnwrapErr(t){throw jt("Called `_unsafeUnwrapErr` on an Ok",this,t)}*[Symbol.iterator](){return this.value}},B=class{constructor(t){this.error=t}isOk(){return!1}isErr(){return!this.isOk()}map(t){return Z(this.error)}mapErr(t){return Z(t(this.error))}andThrough(t){return Z(this.error)}andTee(t){return Z(this.error)}andThen(t){return Z(this.error)}orElse(t){return t(this.error)}asyncAndThen(t){return L(this.error)}asyncAndThrough(t){return L(this.error)}asyncMap(t){return L(this.error)}unwrapOr(t){return t}match(t,r){return r(this.error)}safeUnwrap(){let t=this.error;return function*(){throw yield Z(t),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(t){throw jt("Called `_unsafeUnwrap` on an Err",this,t)}_unsafeUnwrapErr(t){return this.error}*[Symbol.iterator](){let t=this;return yield t,t}},Tn=mt.fromThrowable;var T=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});g(this,"context");this.name=this.constructor.name,this.context=o}};var V=class extends T{};var Oe=class extends V{constructor(){super(...arguments);g(this,"message","An error occured while trying to connect to WebSocket")}};var $=e=>{if(e instanceof Error)return e;let t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch{}return new Error(t)};var Kr=()=>typeof Deno<"u";var yt=e=>Kr()?new URL(`./worker/${e}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${e!=="encrypt"?`worker/${e}`:e}.js`));var er=be(Ke());var v=new er.default,Y=(e,t)=>(Object.assign(e,t),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:e}),e),Et=(e,t)=>{Y(e,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:t})},tr=()=>{v.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),v.once("OPERATION_FAILED",e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var ae=class{constructor(t,r){if(!t||t.length!=64)throw Error("Charset must contain 64 characters");this._charset=t,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(t){let r=t.byteLength;if(!r)return"";let n=new Uint8Array(t),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(t){if(t=(t||"").replace(/[\s]/g,""),!t)return new ArrayBuffer(0);if(!this._valid.test(t))throw Error("Invalid base64 input sequence");let r=Math.floor(t.length*.75);t[t.length-2]=="="?r-=2:t[t.length-1]=="="&&r--;let n=new Uint8Array(r),i,o,s,c,u=0,f=0;for(;u>4,n[u++]=(o&15)<<4|s>>2,n[u++]=(s&3)<<6|c;return n.buffer}};var rr=new ae("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function De(e){return rr.Encode(e)}function xe(e){return rr.Decode(e)}var nn=new ae("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function gt(e){return nn.Decode(e)}var Lt=be(sr());var X=class extends T{};var ue=class extends X{constructor(){super(...arguments);g(this,"message","Unable to decrypt the provided data")}};var fe=class extends X{constructor(){super(...arguments);g(this,"message","Unable to encrypt the provided data")}};var ar=(e,t)=>{try{let r=typeof t=="string"?t:t.data;return C(xe(Lt.default.decrypt(e,r)))}catch(r){return L(new ue(void 0,{cause:$(r)}))}},cr=(e,t)=>{try{let r=Lt.default.encrypt(e,De(t));return C({algo:0,data:r,iv:JSON.parse(r).iv})}catch(r){return L(new fe(void 0,{cause:$(r)}))}};var ur=(e,t)=>lr(e).andThen(r=>b.fromPromise(crypto.subtle.decrypt({name:"AES-GCM",iv:t.iv},r,t.data),n=>new ue(void 0,{cause:$(n)}))),fr=(e,t)=>lr(e).andThen(r=>{let n=crypto.getRandomValues(new Uint8Array(12));return b.fromPromise(crypto.subtle.encrypt({name:"AES-GCM",iv:n},r,t),i=>new fe(void 0,{cause:$(i)})).andThen(i=>C({algo:1,data:i,iv:n}))}),lr=e=>b.fromPromise(crypto.subtle.importKey("raw",gt(e),{name:"AES-GCM"},!1,["encrypt","decrypt"]),t=>new X("Unable to import cryptography key",{cause:$(t)}));var hr=(e,t)=>t.algo===void 0||t.algo===0?ar(e,t):ur(e,t),pr=(e,t,r)=>r===0?cr(e,t):fr(e,t);var M={},mr=5,un=e=>(v.emit("UPLOAD_CANCELLED",e.success),C(void 0)),fn=(e,t)=>{let r=e.split("XXMOJOXX"),n=r.shift();if(n!==void 0){let i=JSON.parse(n);if(gn(i)){let o=r.shift();if(o){let s=JSON.parse(o);return s.iv&&(s.iv=new Uint8Array(Object.values(s.iv)),s.data=xe(s.data)),hr(t.keys.client,s).andThen(c=>{let u=typeof c=="string"?new TextEncoder().encode(c).buffer:c;return i.part===0?(Y(t,{chunksReady:t.chunksReady+1,delAtFirstView:i.del_at_first_view,delay:i.delay,name:i.name,size:i.size,totalChunks:i.total,type:i.type,zipped:i.zipped}),v.emit("DOWNLOAD_STARTED")):Y(t,{chunksReady:t.chunksReady+1}),v.emit("CHUNK_DOWNLOADED",u,i.part),t.chunksReady===i.total?dn(t).andThen(()=>(v.emit("DOWNLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED"),C(void 0))):C(void 0)})}else{let s=new V("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",s),L(s)}}else{let o=new V(i.msg);return v.emit("OPERATION_FAILED",o),L(o)}}else{let i=new V("Cannot retrieve metadata from data received by the server");return v.emit("OPERATION_FAILED",i),L(i)}},ln=(e,t)=>{if(e.success)return e.j===0&&(Y(t,{keys:{client:t.keys.client,server:e.short},actionToken:e.token,queueIndex:e.i}),v.emit("UPLOAD_STARTED")),Y(t,{chunksReady:t.chunksReady+1,createdAt:e.created_at}),v.emit("CHUNK_UPLOADED"),t.chunksReady===t.totalChunks&&(Y(t,{uploadStatus:1}),v.emit("UPLOAD_COMPLETE"),v.emit("SOCKET_OPERATION_TERMINATED")),C(void 0);{let r=new V(e.msg);return v.emit("OPERATION_FAILED",r),L(r)}},hn=(e,t)=>{let r=En(e.data),n;if(r)if(!r.action&&r.msg){let i=new V(r.msg);return v.emit("OPERATION_FAILED",i),L(i)}else"delay"in r?n=ln(r,t):n=un(r);else n=fn(e.data,t);return n},pn=e=>M!==void 0&&M[e]!==void 0&&M[e].readyState===WebSocket.CONNECTING,bt=e=>M!==void 0&&M[e]!==void 0&&M[e].readyState===WebSocket.OPEN;var dn=e=>{let t;return e.password?t={ended:!0,file_pwd:e.password}:t={ended:!0},Dt(yn(e),e,JSON.stringify(t))},Ot=(e,t,r)=>(r.data=De(r.data),Dt(vn(e),e,`${JSON.stringify(t)}XXMOJOXX${JSON.stringify(r)}`)),Dt=(e,t,r)=>bt(e)?(M[e].send(r),C(void 0)):yr(e).andThen(()=>(M[e].onmessage=n=>hn(n,t),Dt(e,t,r))),yr=(e,t=0)=>(!bt(e)&&!pn(e)&&(M[e]=new WebSocket(e),v.once("SOCKET_OPERATION_TERMINATED",()=>{M[e].close()}),v.once("OPERATION_FAILED",()=>{v.emit("SOCKET_OPERATION_TERMINATED")}),M[e].onopen=()=>{v.emit("SOCKET_OPENED")},M[e].onclose=()=>{},M[e].onerror=()=>++t<=mr?(console.error(`An error happened while trying to connect to WebSocket ${e}. Trying again. ${t} / ${mr}`),yr(e,t)):(v.emit("SOCKET_ONERROR"),L(new Oe(`Unable to connect to WebSocket ${e}.`)))),mn(e).andThen(()=>C(e)).orElse(r=>L(r))),mn=e=>b.fromPromise(new Promise((t,r)=>{bt(e)?t(void 0):(v.once("SOCKET_OPENED",()=>{t(void 0)}),v.on("SOCKET_ONERROR",()=>{r(new Oe)}))}),t=>$(t));var vr=(e,t)=>{let r=new URL(e);return["ws:","wss:"].includes(r.protocol)||(r.protocol=r.protocol==="http:"?"ws:":"wss:"),r.pathname+=t,new URL(r.origin+r.pathname)},yn=e=>vr(new URL(e.serverUrl),"download"+`/${e.keys.server}`).toString(),vn=e=>vr(new URL(e.serverUrl),"upload").toString(),En=e=>{try{let t=JSON.parse(e);if(t&&typeof t=="object")return t}catch{}return!1},gn=e=>typeof e=="object"&&e!==null&&!("msg"in e);var gr=be(Ke());var Ln=be(Ke());var bn={},ps=new gr.default;var On=()=>Object.values(bn).filter(e=>e.uploadStatus===4),wr=e=>Object.keys(On()).indexOf(e);var _t=be(Lr(),1);var Te=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ct=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},br=e=>globalThis.DOMException===void 0?new Ct(e):new DOMException(e),Or=e=>{let t=e.reason===void 0?br("This operation was aborted."):e.reason;return t instanceof Error?t:br(t)};function Rt(e,t){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=t,s,u=new Promise((f,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:m}=t;m.aborted&&l(Or(m));let d=()=>{l(Or(m))};m.addEventListener("abort",d,{once:!0}),e.finally(()=>{m.removeEventListener("abort",d)})}if(r===Number.POSITIVE_INFINITY){e.then(f,l);return}let h=new Te;s=o.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(m){l(m)}return}typeof e.cancel=="function"&&e.cancel(),i===!1?f():i instanceof Error?l(i):(h.message=i!=null?i:`Promise timed out after ${r} milliseconds`,l(h))},r),(async()=>{try{f(await e)}catch(m){l(m)}})()}).finally(()=>{u.clear()});return u.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},u}function St(e,t,r){let n=0,i=e.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(e[s],t)<=0?(n=++s,i-=o+1):i=o}return n}var K,Pe=class{constructor(){D(this,K,[])}enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&p(this,K)[this.size-1].priority>=r.priority){p(this,K).push(n);return}let i=St(p(this,K),n,(o,s)=>s.priority-o.priority);p(this,K).splice(i,0,n)}dequeue(){let t=p(this,K).shift();return t==null?void 0:t.run}filter(t){return p(this,K).filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return p(this,K).length}};K=new WeakMap;var le,he,te,Ue,pe,Me,j,de,P,Ne,W,me,ee,Fe,y,Dr,xr,_r,Cr,Rr,nt,kt,Tt,it,Sr,ot,Ie=class extends _t.default{constructor(r){var n,i,o,s;super();D(this,y);D(this,le);D(this,he);D(this,te,0);D(this,Ue);D(this,pe);D(this,Me,0);D(this,j);D(this,de);D(this,P);D(this,Ne);D(this,W,0);D(this,me);D(this,ee);D(this,Fe);g(this,"timeout");if(r={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Pe,...r},!(typeof r.intervalCap=="number"&&r.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(n=r.intervalCap)==null?void 0:n.toString())!=null?i:""}\` (${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=(o=r.interval)==null?void 0:o.toString())!=null?s:""}\` (${typeof r.interval})`);w(this,le,r.carryoverConcurrencyCount),w(this,he,r.intervalCap===Number.POSITIVE_INFINITY||r.interval===0),w(this,Ue,r.intervalCap),w(this,pe,r.interval),w(this,P,new r.queueClass),w(this,Ne,r.queueClass),this.concurrency=r.concurrency,this.timeout=r.timeout,w(this,Fe,r.throwOnTimeout===!0),w(this,ee,r.autoStart===!1)}get concurrency(){return p(this,me)}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,me,r),x(this,y,it).call(this)}async add(r,n={}){return n={timeout:this.timeout,throwOnTimeout:p(this,Fe),...n},new Promise((i,o)=>{p(this,P).enqueue(async()=>{var s;Ge(this,W)._++,Ge(this,te)._++;try{(s=n.signal)==null||s.throwIfAborted();let c=r({signal:n.signal});n.timeout&&(c=Rt(Promise.resolve(c),{milliseconds:n.timeout})),n.signal&&(c=Promise.race([c,x(this,y,Sr).call(this,n.signal)]));let u=await c;i(u),this.emit("completed",u)}catch(c){if(c instanceof Te&&!n.throwOnTimeout){i();return}o(c),this.emit("error",c)}finally{x(this,y,_r).call(this)}},n),this.emit("add"),x(this,y,nt).call(this)})}async addAll(r,n){return Promise.all(r.map(async i=>this.add(i,n)))}start(){return p(this,ee)?(w(this,ee,!1),x(this,y,it).call(this),this):this}pause(){w(this,ee,!0)}clear(){w(this,P,new(p(this,Ne)))}async onEmpty(){p(this,P).size!==0&&await x(this,y,ot).call(this,"empty")}async onSizeLessThan(r){p(this,P).sizep(this,P).size{x(this,y,Cr).call(this)},n)),!0}return!1},nt=function(){if(p(this,P).size===0)return p(this,j)&&clearInterval(p(this,j)),w(this,j,void 0),this.emit("empty"),p(this,W)===0&&this.emit("idle"),!1;if(!p(this,ee)){let r=!p(this,y,Rr);if(p(this,y,Dr)&&p(this,y,xr)){let n=p(this,P).dequeue();return n?(this.emit("active"),n(),r&&x(this,y,kt).call(this),!0):!1}}return!1},kt=function(){p(this,he)||p(this,j)!==void 0||(w(this,j,setInterval(()=>{x(this,y,Tt).call(this)},p(this,pe))),w(this,Me,Date.now()+p(this,pe)))},Tt=function(){p(this,te)===0&&p(this,W)===0&&p(this,j)&&(clearInterval(p(this,j)),w(this,j,void 0)),w(this,te,p(this,le)?p(this,W):0),x(this,y,it).call(this)},it=function(){for(;x(this,y,nt).call(this););},Sr=async function(r){return new Promise((n,i)=>{r.addEventListener("abort",()=>{i(r.reason)},{once:!0})})},ot=async function(r,n){return new Promise(i=>{let o=()=>{n&&!n()||(this.off(r,o),i())};this.on(r,o)})};var st=class extends T{};var Be=class extends st{constructor(){super(...arguments);g(this,"message","Parameter must be defined")}};var kr=!1,Pt=navigator.hardwareConcurrency||1,Je=new Ie({concurrency:Pt,autoStart:!1}),We=0,at=!1,je,Tr=new Worker(yt("encrypt"),{type:"module"});self.onmessage=e=>{if(kr||(tr(),kr=!0,je=e.data.args.lufiFile,v.once("UPLOAD_STARTED",()=>{self.postMessage({event:"UPLOAD_STARTED"})}),v.on("CHUNK_UPLOADED",()=>{self.postMessage({event:"CHUNK_UPLOADED"}),We--,Je.isPaused&&!at&&We{self.postMessage({event:"UPLOAD_COMPLETE"})}),v.on("FILE_UPDATED",Y)),e.data.args.chunk)return e.data.args.lufiFile=je,_n(e.data,wr(je.keys.client)).mapErr(t=>{Et(je,t)});e.data.action===0?(at=!0,Ir()):e.data.action===2?(at=!1,Pr()):Et(je,new Be)};var _n=(e,t)=>{let{lufiFile:r,algo:n}=e.args;if(e.args.chunk&&n)e.args.chunk.index===0?pr(r.keys.client,e.args.chunk.buffer,n).map(i=>{Ot(r,{total:r.totalChunks,part:0,size:r.size,name:r.name,type:r.type,delay:r.delay,del_at_first_view:r.delAtFirstView,zipped:r.zipped,id:null,i:t,file_pwd:r.password},i),We++}):Je.add(()=>{if(e.args.chunk){let i=()=>(We++,new Promise(o=>{Tr.onmessage=s=>{o(Ot(r,{total:r.totalChunks,part:s.data.chunkIndex,size:r.size,name:r.name,type:r.type,delay:r.delay,del_at_first_view:r.delAtFirstView,zipped:r.zipped,id:r.keys.server,i:t,file_pwd:r.password},s.data.encryptedData))}}));Tr.postMessage(e,[e.args.chunk.buffer]),!Je.isPaused&&(at||We===Pt)&&Ir(),i()}});else return L(new Be("algo must be defined"));return C(void 0)},Ir=()=>{Je.pause(),self.postMessage({event:"JOB_PAUSED"})},Pr=()=>{Je.start(),self.postMessage({event:"JOB_RESUMED"})};