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

>>0?1:0),r+=ne,e+=Oe+(r>>>0>>0?1:0)}A[2*t]=e|=0,A[2*t+1]=r|=0;var Ae=k&le^~k&de,Re=x&ee^~x&te,P=w&V^w&Q^V&Q,mt=L&z^L&H^z&H,Oe=(L<<4|w>>>28)^(w<<30|L>>>2)^(w<<25|L>>>7),ne=(w<<4|L>>>28)^(L<<30|w>>>2)^(L<<25|w>>>7),yt=o[2*t],Pe=o[2*t+1],v=re+((k<<18|x>>>14)^(k<<14|x>>>18)^(x<<23|k>>>9)),R=Ee+((x<<18|k>>>14)^(x<<14|k>>>18)^(k<<23|x>>>9))+(v>>>0>>0?1:0),v=v+Re,R=R+(Ae+(v>>>0>>0?1:0)),v=v+Pe,R=R+(yt+(v>>>0>>0?1:0)),v=v+r|0,R=R+(e+(v>>>0>>0?1:0));r=ne+mt,e=Oe+P+(r>>>0>>0?1:0),Ee=de,re=te,de=le,te=ee,le=k,ee=x,x=Z+v|0,k=we+R+(x>>>0>>0?1:0)|0,we=Q,Z=H,Q=V,H=z,V=w,z=L,L=v+r|0,w=R+e+(L>>>0>>0?1:0)|0}s=n[1]=s+L|0,n[0]=i+w+(s>>>0>>0?1:0)|0,u=n[3]=u+z|0,n[2]=a+V+(u>>>0>>0?1:0)|0,h=n[5]=h+H|0,n[4]=f+Q+(h>>>0>>0?1:0)|0,y=n[7]=y+Z|0,n[6]=l+we+(y>>>0>>0?1:0)|0,g=n[9]=g+x|0,n[8]=d+k+(g>>>0>>0?1:0)|0,C=n[11]=C+ee|0,n[10]=_+le+(C>>>0>>0?1:0)|0,fe=n[13]=fe+te|0,n[12]=N+de+(fe>>>0>>0?1:0)|0,he=n[15]=he+re|0,n[14]=ke+Ee+(he>>>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(i=2;4>i&&f>>>8*i;i++);return i<15-u&&(i=15-u),r=a.clamp(r,8*(15-i)),e=c.mode.ccm.U(t,e,r,n,o,i),s=c.mode.ccm.V(t,s,r,e,o,i),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,o){o=o||64,n=n||[];var i=c.bitArray,s=i.bitLength(r)/8,f=i.bitLength(e),a=i.clamp(e,f-o),u=i.bitSlice(e,f-o),f=(f-o)/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=i.clamp(r,8*(15-e)),a=c.mode.ccm.V(t,a,r,u,o,e),t=c.mode.ccm.U(t,a.data,r,n,o,e),!i.equal(a.tag,t))throw new c.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,o,i){var s=[],a=c.bitArray,u=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|i-1)],n=a.concat(n,r),n[3]|=o,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;eo||16h&&(c.mode.ccm.da(s/u),h+=l),r[3]++,o=t.encrypt(r),e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3];return{tag:n,data:a.clamp(e,f)}}};c.misc.hmac=function(t,e){this.W=e=e||c.hash.sha256;var r=[[],[]],n,o=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>o&&(t=e.hash(t)),n=0;nn||0>r)throw new 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)),o=o||c.misc.hmac,t=new o(t);var i,s,a,u,f=[],h=c.bitArray;for(u=1;32*f.length<(n||1);u++){for(o=i=t.encrypt(h.concat(e,[u])),s=1;ss;s++)o.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=i),this.N++,this.b=c.hash.sha256.hash(this.b.concat(o)),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,i,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,i,t.length]),this.h[s].update(t);break;default:u=1}if(u)throw new 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&&rt("seeded",Math.max(this.u,this.i)),rt("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,o=this.J[t],i=[];for(n in o)o.hasOwnProperty(n)&&o[n]===e&&i.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function ce(t,e){return function(){e.apply(t,arguments)}}c.random=new c.prng(6);e:try{if(ve=typeof Y<"u"&&Y.exports){try{ge=Lt("crypto")}catch{ge=null}ve=ye=ge}if(ve&&ye.randomBytes)ae=ye.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,ye,ue,ve,ge;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 o=c.json,i=o.j({iv:c.random.randomWords(4,0)},o.defaults),s;if(o.j(i,r),r=i.adata,typeof i.salt=="string"&&(i.salt=c.codec.base64.toBits(i.salt)),typeof i.iv=="string"&&(i.iv=c.codec.base64.toBits(i.iv)),!c.mode[i.mode]||!c.cipher[i.cipher]||typeof t=="string"&&100>=i.iter||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||2>i.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4(Object.assign(t,e),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:t}),t);var $e=()=>{m.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),m.once("OPERATION_FAILED",t=>{self.postMessage({event:"OPERATION_FAILED",error:t})})};var Pt={withStackTrace:!1},Ve=(t,e,r=Pt)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:o}};function G(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function a(h){try{f(n.next(h))}catch(l){s(l)}}function u(h){try{f(n.throw(h))}catch(l){s(l)}}function f(h){h.done?i(h.value):o(h.value).then(a,u)}f((n=n.apply(t,e||[])).next())})}function Ye(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 I(t){return this instanceof I?(this.v=t,this):new I(t)}function qe(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(d){return function(g){return Promise.resolve(g).then(d,l)}}function a(d,g){n[d]&&(o[d]=function(_){return new Promise(function(C,N){i.push([d,_,C,N])>1||u(d,_)})},g&&(o[d]=g(o[d])))}function u(d,g){try{f(n[d](g))}catch(_){y(i[0][3],_)}}function f(d){d.value instanceof I?Promise.resolve(d.value.v).then(h,l):y(i[0][2],d)}function h(d){u("next",d)}function l(d){u("throw",d)}function y(d,g){d(g),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Tt(t){var e,r;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=t[o]?function(s){return(r=!r)?{value:I(t[o](s)),done:!1}:i?i(s):s}:i}}function It(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 Ye=="function"?Ye(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(a,u){s=t[i](s),o(a,u,s.done,s.value)})}}function o(i,s,a,u){Promise.resolve(u).then(function(f){i({value:f,done:a})},s)}}var E=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new D(n));return new t(r)}static fromPromise(e,r){let n=e.then(o=>new D(o)).catch(o=>new S(r(o)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(G(this,void 0,void 0,function*(){try{return new D(yield e(...n))}catch(o){return new S(r?r(o):o)}}))}static combine(e){return Mt(e)}static combineWithAllErrors(e){return Ut(e)}map(e){return new t(this._promise.then(r=>G(this,void 0,void 0,function*(){return r.isErr()?new S(r.error):new D(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>G(this,void 0,void 0,function*(){if(r.isErr())return new S(r.error);let n=yield e(r.value);return n.isErr()?new S(n.error):new D(r.value)})))}andTee(e){return new t(this._promise.then(r=>G(this,void 0,void 0,function*(){if(r.isErr())return new S(r.error);try{yield e(r.value)}catch{}return new D(r.value)})))}mapErr(e){return new t(this._promise.then(r=>G(this,void 0,void 0,function*(){return r.isOk()?new D(r.value):new S(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new S(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>G(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new D(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 qe(this,arguments,function*(){return yield I(yield I(yield*Tt(It(yield I(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return qe(this,arguments,function*(){let r=yield I(this._promise);return r.isErr()&&(yield yield I(O(r.error))),yield I(r.value)})}},M=t=>new E(Promise.resolve(new D(t))),O=t=>new E(Promise.resolve(new S(t))),mr=E.fromPromise,yr=E.fromSafePromise,vr=E.fromThrowable,Qe=t=>{let e=J([]);for(let r of t)if(r.isErr()){e=j(r.error);break}else e.map(n=>n.push(r.value));return e},Mt=t=>E.fromSafePromise(Promise.all(t)).andThen(Qe),Ze=t=>{let e=J([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=j([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},Ut=t=>E.fromSafePromise(Promise.all(t)).andThen(Ze),be;(function(t){function e(o,i){return(...s)=>{try{let a=o(...s);return J(a)}catch(a){return j(i?i(a):a)}}}t.fromThrowable=e;function r(o){return Qe(o)}t.combine=r;function n(o){return Ze(o)}t.combineWithAllErrors=n})(be||(be={}));var J=t=>new D(t);function j(t){return new S(t)}var D=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return J(e(this.value))}mapErr(e){return J(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 J(this.value)}orElse(e){return J(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return E.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 Ve("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},S=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return j(this.error)}mapErr(e){return j(e(this.error))}andThrough(e){return j(this.error)}andTee(e){return j(this.error)}andThen(e){return j(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return O(this.error)}asyncAndThrough(e){return O(this.error)}asyncMap(e){return O(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield j(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw Ve("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},gr=be.fromThrowable;var W=class extends Error{constructor(r,n={}){let{cause:o,context:i}=n;super(r,{cause:o});T(this,"context");this.name=this.constructor.name,this.context=i}};var U=class extends W{};var oe=class extends U{constructor(){super(...arguments);T(this,"message","An error occured while trying to connect to WebSocket")}};var F=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)};var $=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),o="";for(let i=0;i>2]+this._charset[(n[i]&3)<<4|n[i+1]>>4]+this._charset[(n[i+1]&15)<<2|n[i+2]>>6]+this._charset[n[i+2]&63];return r%3==2?(o=o.substring(0,o.length-1),this._noPadding||(o+="=")):r%3==1&&(o=o.substring(0,o.length-2),this._noPadding||(o+="==")),o}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),o,i,s,a,u=0,f=0;for(;u>4,n[u++]=(i&15)<<4|s>>2,n[u++]=(s&3)<<6|a;return n.buffer}};var Nt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function ie(t){return Nt.Decode(t)}var jt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function _e(t){return jt.Decode(t)}var st=Ie(ot());var B=class extends W{};var q=class extends B{constructor(){super(...arguments);T(this,"message","Unable to decrypt the provided data")}};var ct=(t,e)=>{try{let r=typeof e=="string"?e:e.data;return M(ie(st.default.decrypt(t,r)))}catch(r){return O(new q(void 0,{cause:F(r)}))}};var at=(t,e)=>zt(t).andThen(r=>E.fromPromise(crypto.subtle.decrypt({name:"AES-GCM",iv:e.iv},r,ie(e.data)),n=>new q(void 0,{cause:F(n)})));var zt=t=>E.fromPromise(crypto.subtle.importKey("raw",_e(t),{name:"AES-GCM"},!1,["encrypt","decrypt"]),e=>new B("Unable to import cryptography key",{cause:F(e)}));var ut=(t,e)=>e.algo===void 0||e.algo===0?ct(t,e):at(t,e);var b={},ft=5,Xt=t=>(m.emit("UPLOAD_CANCELLED",t.success),M(void 0)),Gt=(t,e)=>{let r=t.split("XXMOJOXX"),n=r.shift();if(n!==void 0){let o=JSON.parse(n);if(rr(o)){let i=r.shift();if(i){let s=JSON.parse(i);return s.iv&&(s.iv=new Uint8Array(Object.values(s.iv))),ut(e.keys.client,s).andThen(a=>{let u=typeof a=="string"?new TextEncoder().encode(a).buffer:a;return o.part===0?(X(e,{chunksReady:e.chunksReady+1,delAtFirstView:o.del_at_first_view,delay:o.delay,name:o.name,size:o.size,totalChunks:o.total,type:o.type,zipped:o.zipped}),m.emit("DOWNLOAD_STARTED")):X(e,{chunksReady:e.chunksReady+1}),m.emit("CHUNK_DOWNLOADED",u,o.part),++o.part===o.total?Vt(e).andThen(()=>(m.emit("DOWNLOAD_COMPLETE"),m.emit("SOCKET_OPERATION_TERMINATED"),M(void 0))):M(void 0)})}else{let s=new U("Cannot retrieve metadata from data received by the server");return m.emit("OPERATION_FAILED",s),O(s)}}else{let i=new U(o.msg);return m.emit("OPERATION_FAILED",i),O(i)}}else{let o=new U("Cannot retrieve metadata from data received by the server");return m.emit("OPERATION_FAILED",o),O(o)}},$t=(t,e)=>{if(t.success)return t.j===0&&(X(e,{keys:{client:e.keys.client,server:t.short},actionToken:t.token,queueIndex:t.i}),m.emit("UPLOAD_STARTED")),X(e,{chunksReady:e.chunksReady+1,createdAt:t.created_at}),m.emit("CHUNK_UPLOADED"),e.chunksReady===e.totalChunks&&(X(e,{uploadStatus:1}),m.emit("UPLOAD_COMPLETE"),m.emit("SOCKET_OPERATION_TERMINATED")),M(void 0);{let r=new U(t.msg);return m.emit("OPERATION_FAILED",r),O(r)}},Yt=(t,e)=>{let r=tr(t.data),n;if(r)if(!r.action&&r.msg){let o=new U(r.msg);return m.emit("OPERATION_FAILED",o),O(o)}else"delay"in r?n=$t(r,e):n=Xt(r);else n=Gt(t.data,e);return n},qt=t=>b!==void 0&&b[t]!==void 0&&b[t].readyState===WebSocket.CONNECTING,Se=t=>b!==void 0&&b[t]!==void 0&&b[t].readyState===WebSocket.OPEN,ht=t=>Ce(er(t),t,`${JSON.stringify({id:t.keys.server,mod_token:t.actionToken,cancel:!0,i:t.queueIndex})}XXMOJOXXuseless`);var Vt=t=>{let e;return t.password?e={ended:!0,file_pwd:t.password}:e={ended:!0},Ce(Zt(t),t,JSON.stringify(e))};var Ce=(t,e,r)=>Se(t)?(b[t].onmessage=n=>Yt(n,e),b[t].send(r),M(void 0)):lt(t).andThen(()=>Ce(t,e,r)),lt=(t,e=0)=>(!Se(t)&&!qt(t)&&(b[t]=new WebSocket(t),m.once("SOCKET_OPERATION_TERMINATED",()=>{b[t].close()}),m.once("OPERATION_FAILED",()=>{m.emit("SOCKET_OPERATION_TERMINATED")}),b[t].onopen=()=>{m.emit("SOCKET_OPENED")},b[t].onclose=()=>{},b[t].onerror=()=>++e<=ft?(console.error(`An error happened while trying to connect to WebSocket ${t}. Trying again. ${e} / ${ft}`),lt(t,e)):(m.emit("SOCKET_ONERROR"),O(new oe(`Unable to connect to WebSocket ${t}.`)))),Qt(t).andThen(()=>M(t)).orElse(r=>O(r))),Qt=t=>E.fromPromise(new Promise((e,r)=>{Se(t)?e(void 0):(m.once("SOCKET_OPENED",()=>{e(void 0)}),m.on("SOCKET_ONERROR",()=>{r(new oe)}))}),e=>F(e));var dt=(t,e)=>{let r=new URL(t);return r.protocol=r.protocol==="http:"?"ws:":"wss:",r.pathname+=e,new URL(r.origin+r.pathname)},Zt=t=>dt(new URL(t.serverUrl),"download"+`/${t.keys.server}`).toString(),er=t=>dt(new URL(t.serverUrl),"upload").toString(),tr=t=>{try{let e=JSON.parse(t);if(e&&typeof e=="object")return e}catch{}return!1},rr=t=>typeof t=="object"&&t!==null&&!("msg"in t);var pt=!1;self.onmessage=t=>{pt||($e(),pt=!0),m.on("UPLOAD_CANCELLED",e=>{self.postMessage({event:"UPLOAD_CANCELLED",success:e})}),or(t.data).mapErr(e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var or=t=>ht(t.args.lufiFile); +var vt=Object.create;var Le=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Ot=(t,e,r)=>e in t?Le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Lt=(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 Te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var xt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!At.call(t,o)&&o!==r&&Le(t,o,{get:()=>e[o],enumerable:!(n=gt(e,o))||n.enumerable});return t};var Ie=(t,e,r)=>(r=t!=null?vt(Et(t)):{},xt(e||!t||!t.__esModule?Le(r,"default",{value:t,enumerable:!0}):r,t));var T=(t,e,r)=>Ot(t,typeof e!="symbol"?e+"":e,r);var Ke=Te((sr,xe)=>{"use strict";var K=typeof Reflect=="object"?Reflect:null,Me=K&&typeof K.apply=="function"?K.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},pe;K&&typeof K.ownKeys=="function"?pe=K.ownKeys:Object.getOwnPropertySymbols?pe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pe=function(e){return Object.getOwnPropertyNames(e)};function bt(t){console&&console.warn&&console.warn(t)}var Ne=Number.isNaN||function(e){return e!==e};function p(){p.init.call(this)}xe.exports=p;xe.exports.once=Ct;p.EventEmitter=p;p.prototype._events=void 0;p.prototype._eventsCount=0;p.prototype._maxListeners=void 0;var Ue=10;function me(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(p,"defaultMaxListeners",{enumerable:!0,get:function(){return Ue},set:function(t){if(typeof t!="number"||t<0||Ne(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ue=t}});p.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};p.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ne(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 je(t){return t._maxListeners===void 0?p.defaultMaxListeners:t._maxListeners}p.prototype.getMaxListeners=function(){return je(this)};p.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=i[e];if(u===void 0)return!1;if(typeof u=="function")Me(u,this,r);else for(var f=u.length,h=ze(u,f),n=0;n0&&s.length>o&&!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,bt(a)}return t}p.prototype.addListener=function(e,r){return Be(this,e,r,!1)};p.prototype.on=p.prototype.addListener;p.prototype.prependListener=function(e,r){return Be(this,e,r,!0)};function _t(){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 We(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=_t.bind(n);return o.listener=r,n.wrapFn=o,o}p.prototype.once=function(e,r){return me(r),this.on(e,We(this,e,r)),this};p.prototype.prependOnceListener=function(e,r){return me(r),this.prependListener(e,We(this,e,r)),this};p.prototype.removeListener=function(e,r){var n,o,i,s,a;if(me(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():Dt(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};p.prototype.off=p.prototype.removeListener;p.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function Je(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?St(o):ze(o,o.length)}p.prototype.listeners=function(e){return Je(this,e,!0)};p.prototype.rawListeners=function(e){return Je(this,e,!1)};p.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Fe.call(t,e)};p.prototype.listenerCount=Fe;function Fe(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}p.prototype.eventNames=function(){return this._eventsCount>0?pe(this._events):[]};function ze(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,o,i=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),o=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[r&255],t%e===0&&(r=r<<8^r>>>24^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],o[e]=4>=t||4>e?r:s[0][i[r>>>24]]^s[1][i[r>>16&255]]^s[2][i[r>>8&255]]^s[3][i[r&255]]};c.cipher.aes.prototype={encrypt:function(t){return tt(this,t,0)},decrypt:function(t){return tt(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],o,i,s,a=[],u=[],f,h,l,y;for(o=0;256>o;o++)u[(a[o]=o<<1^283*(o>>7))^o]=o;for(i=s=0;!r[i];i^=f||1,s=u[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[i]=l,n[l]=i,h=a[o=a[f=a[i]]],y=16843009*h^65537*o^257*f^16843008*i,h=257*a[l]^16843008*l,o=0;4>o;o++)t[o][i]=h=h<<24^h>>>8,e[o][l]=y=y<<24^y>>>8;for(o=0;5>o;o++)t[o]=t[o].slice(0),e[o]=e[o].slice(0)}};function tt(t,e,r){if(e.length!==4)throw new c.exception.invalid("invalid aes block size");var n=t.b[r],o=e[0]^n[0],i=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,u,f,h=n.length/4-2,l,y=4,d=[0,0,0,0];a=t.w[r],t=a[0];var g=a[1],_=a[2],C=a[3],N=a[4];for(l=0;l>>24]^g[i>>16&255]^_[s>>8&255]^C[e&255]^n[y],u=t[i>>>24]^g[s>>16&255]^_[e>>8&255]^C[o&255]^n[y+1],f=t[s>>>24]^g[e>>16&255]^_[o>>8&255]^C[i&255]^n[y+2],e=t[e>>>24]^g[o>>16&255]^_[i>>8&255]^C[s&255]^n[y+3],y+=4,o=a,i=u,s=f;for(l=0;4>l;l++)d[r?3&-l:l]=N[o>>>24]<<24^N[i>>16&255]<<16^N[s>>8&255]<<8^N[e&255]^n[y++],a=o,o=i,i=s,s=e,e=a;return d}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[o]<<32-e;return o=t.length?t[t.length-1]:0,t=c.bitArray.getPartial(o),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,o;for(n=0;n>>8>>>8>>>8),o<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>o)>>>26),6>o?(s=t[r]<<6-o,o+=26,r++):(s<<=6,o-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,o=0,i=c.codec.base64.S,s=0,a;for(e&&(i=i.substr(0,62)+"-_"),n=0;na)throw new c.exception.invalid("this isn't base64!");26>>o),s=a<<32-o):(o+=6,s^=a<<32-o)}return o&56&&r.push(c.bitArray.partial(o&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(o=!0,n=2;n*n<=r;n++)if(r%n===0){o=!1;break}o&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,o=this.g,i=this.b,s=o[0],a=o[1],u=o[2],f=o[3],h=o[4],l=o[5],y=o[6],d=o[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+d+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(y^h&(l^y))+i[e],d=y,y=l,l=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;o[0]=o[0]+s|0,o[1]=o[1]+a|0,o[2]=o[2]+u|0,o[3]=o[3]+f|0,o[4]=o[4]+h|0,o[5]=o[5]+l|0,o[6]=o[6]+y|0,o[7]=o[7]+d|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(i=!0,o=2;o*o<=n;o++)if(n%o===0){i=!1;break}i&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,o=this.b,i=n[0],s=n[1],a=n[2],u=n[3],f=n[4],h=n[5],l=n[6],y=n[7],d=n[8],g=n[9],_=n[10],C=n[11],N=n[12],fe=n[13],ke=n[14],he=n[15],A;if(typeof Uint32Array<"u"){A=Array(160);for(var w=0;32>w;w++)A[w]=t[w]}else A=t;var w=i,L=s,V=a,z=u,Q=f,H=h,we=l,Z=y,k=d,x=g,le=_,ee=C,de=N,te=fe,Ee=ke,re=he;for(t=0;80>t;t++){if(16>t)e=A[2*t],r=A[2*t+1];else{r=A[2*(t-15)];var v=A[2*(t-15)+1];e=(v<<31|r>>>1)^(v<<24|r>>>8)^r>>>7;var R=(r<<31|v>>>1)^(r<<24|v>>>8)^(r<<25|v>>>7);r=A[2*(t-2)];var P=A[2*(t-2)+1],v=(P<<13|r>>>19)^(r<<3|P>>>29)^r>>>6,P=(r<<13|P>>>19)^(P<<3|r>>>29)^(r<<26|P>>>6),Ae=A[2*(t-7)],Oe=A[2*(t-16)],ne=A[2*(t-16)+1];r=R+A[2*(t-7)+1],e=e+Ae+(r>>>0>>0?1:0),r+=P,e+=v+(r>>>0

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

>>0?1:0),r+=V,e+=Ee+(r>>>0>>0?1:0)}w[2*t]=e|=0,w[2*t+1]=r|=0;var we=k&ae^~k&fe,De=x&$^~x&q,P=g&G^g&Y^G&Y,ct=A&U^A&F^U&F,Ee=(A<<4|g>>>28)^(g<<30|A>>>2)^(g<<25|A>>>7),V=(g<<4|A>>>28)^(A<<30|g>>>2)^(A<<25|g>>>7),at=o[2*t],ke=o[2*t+1],y=Q+((k<<18|x>>>14)^(k<<14|x>>>18)^(x<<23|k>>>9)),C=ge+((x<<18|k>>>14)^(x<<14|k>>>18)^(k<<23|x>>>9))+(y>>>0>>0?1:0),y=y+De,C=C+(we+(y>>>0>>0?1:0)),y=y+ke,C=C+(at+(y>>>0>>0?1:0)),y=y+r|0,C=C+(e+(y>>>0>>0?1:0));r=V+ct,e=Ee+P+(r>>>0>>0?1:0),ge=fe,Q=q,fe=ae,q=$,ae=k,$=x,x=X+y|0,k=ve+C+(x>>>0>>0?1:0)|0,ve=Y,X=F,Y=G,F=U,G=g,U=A,A=y+r|0,g=C+e+(A>>>0>>0?1:0)|0}s=n[1]=s+A|0,n[0]=i+g+(s>>>0>>0?1:0)|0,f=n[3]=f+U|0,n[2]=a+G+(f>>>0>>0?1:0)|0,h=n[5]=h+F|0,n[4]=u+Y+(h>>>0>>0?1:0)|0,m=n[7]=m+X|0,n[6]=l+ve+(m>>>0>>0?1:0)|0,v=n[9]=v+x|0,n[8]=p+k+(v>>>0>>0?1:0)|0,D=n[11]=D+$|0,n[10]=L+ae+(D>>>0<$>>>0?1:0)|0,se=n[13]=se+q|0,n[12]=R+fe+(se>>>0>>0?1:0)|0,ce=n[15]=ce+Q|0,n[14]=Oe+ge+(ce>>>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),-1f)throw new c.exception.invalid("ccm: iv must be at least 7 bytes");for(i=2;4>i&&u>>>8*i;i++);return i<15-f&&(i=15-f),r=a.clamp(r,8*(15-i)),e=c.mode.ccm.U(t,e,r,n,o,i),s=c.mode.ccm.V(t,s,r,e,o,i),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,o){o=o||64,n=n||[];var i=c.bitArray,s=i.bitLength(r)/8,u=i.bitLength(e),a=i.clamp(e,u-o),f=i.bitSlice(e,u-o),u=(u-o)/8;if(7>s)throw new c.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&u>>>8*e;e++);if(e<15-s&&(e=15-s),r=i.clamp(r,8*(15-e)),a=c.mode.ccm.V(t,a,r,f,o,e),t=c.mode.ccm.U(t,a.data,r,n,o,e),!i.equal(a.tag,t))throw new c.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,o,i){var s=[],a=c.bitArray,f=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|i-1)],n=a.concat(n,r),n[3]|=o,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;eo||16h&&(c.mode.ccm.da(s/f),h+=l),r[3]++,o=t.encrypt(r),e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3];return{tag:n,data:a.clamp(e,u)}}};c.misc.hmac=function(t,e){this.W=e=e||c.hash.sha256;var r=[[],[]],n,o=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>o&&(t=e.hash(t)),n=0;nn||0>r)throw new 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)),o=o||c.misc.hmac,t=new o(t);var i,s,a,f,u=[],h=c.bitArray;for(f=1;32*u.length<(n||1);f++){for(o=i=t.encrypt(h.concat(e,[f])),s=1;ss;s++)o.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=i),this.N++,this.b=c.hash.sha256.hash(this.b.concat(o)),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,i,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,i,t.length]),this.h[s].update(t);break;default:f=1}if(f)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&&Ue("seeded",Math.max(this.u,this.i)),Ue("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:te(this,this.la),mouseCollector:te(this,this.na),keyboardCollector:te(this,this.ja),accelerometerCollector:te(this,this.ca),touchCollector:te(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,o=this.J[t],i=[];for(n in o)o.hasOwnProperty(n)&&o[n]===e&&i.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function te(t,e){return function(){e.apply(t,arguments)}}c.random=new c.prng(6);e:try{if(le=typeof K<"u"&&K.exports){try{pe=mt("crypto")}catch{pe=null}le=he=pe}if(le&&he.randomBytes)re=he.randomBytes(128),re=new Uint32Array(new Uint8Array(re).buffer),c.random.addEntropy(re,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(ne=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(ne);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(ne);else break e;c.random.addEntropy(ne,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 re,he,ne,le,pe;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 o=c.json,i=o.j({iv:c.random.randomWords(4,0)},o.defaults),s;if(o.j(i,r),r=i.adata,typeof i.salt=="string"&&(i.salt=c.codec.base64.toBits(i.salt)),typeof i.iv=="string"&&(i.iv=c.codec.base64.toBits(i.iv)),!c.mode[i.mode]||!c.cipher[i.cipher]||typeof t=="string"&&100>=i.iter||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||2>i.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4{"use strict";var H=typeof Reflect=="object"?Reflect:null,Ge=H&&typeof H.apply=="function"?H.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},de;H&&typeof H.ownKeys=="function"?de=H.ownKeys:Object.getOwnPropertySymbols?de=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:de=function(e){return Object.getOwnPropertyNames(e)};function St(t){console&&console.warn&&console.warn(t)}var Xe=Number.isNaN||function(e){return e!==e};function d(){d.init.call(this)}_e.exports=d;_e.exports.once=Mt;d.EventEmitter=d;d.prototype._events=void 0;d.prototype._eventsCount=0;d.prototype._maxListeners=void 0;var Ye=10;function me(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return Ye},set:function(t){if(typeof t!="number"||t<0||Xe(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ye=t}});d.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};d.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Xe(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 $e(t){return t._maxListeners===void 0?d.defaultMaxListeners:t._maxListeners}d.prototype.getMaxListeners=function(){return $e(this)};d.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=i[e];if(f===void 0)return!1;if(typeof f=="function")Ge(f,this,r);else for(var u=f.length,h=et(f,u),n=0;n0&&s.length>o&&!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,St(a)}return t}d.prototype.addListener=function(e,r){return qe(this,e,r,!1)};d.prototype.on=d.prototype.addListener;d.prototype.prependListener=function(e,r){return qe(this,e,r,!0)};function Rt(){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 Qe(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=Rt.bind(n);return o.listener=r,n.wrapFn=o,o}d.prototype.once=function(e,r){return me(r),this.on(e,Qe(this,e,r)),this};d.prototype.prependOnceListener=function(e,r){return me(r),this.prependListener(e,Qe(this,e,r)),this};d.prototype.removeListener=function(e,r){var n,o,i,s,a;if(me(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():It(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};d.prototype.off=d.prototype.removeListener;d.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function Ve(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?jt(o):et(o,o.length)}d.prototype.listeners=function(e){return Ve(this,e,!0)};d.prototype.rawListeners=function(e){return Ve(this,e,!1)};d.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Ze.call(t,e)};d.prototype.listenerCount=Ze;function Ze(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}d.prototype.eventNames=function(){return this._eventsCount>0?de(this._events):[]};function et(t,e){for(var r=new Array(e),n=0;n>2]+this._charset[(n[i]&3)<<4|n[i+1]>>4]+this._charset[(n[i+1]&15)<<2|n[i+2]>>6]+this._charset[n[i+2]&63];return r%3==2?(o=o.substring(0,o.length-1),this._noPadding||(o+="=")):r%3==1&&(o=o.substring(0,o.length-2),this._noPadding||(o+="==")),o}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),o,i,s,a,f=0,u=0;for(;f>4,n[f++]=(i&15)<<4|s>>2,n[f++]=(s&3)<<6|a;return n.buffer}};var vt=new W("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function Z(t){return vt.Encode(t)}var gt=new W("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function xe(t){return gt.Decode(t)}var Et={withStackTrace:!1},je=(t,e,r=Et)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:o}};function N(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function a(h){try{u(n.next(h))}catch(l){s(l)}}function f(h){try{u(n.throw(h))}catch(l){s(l)}}function u(h){h.done?i(h.value):o(h.value).then(a,f)}u((n=n.apply(t,e||[])).next())})}function Re(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 S(t){return this instanceof S?(this.v=t,this):new S(t)}function Ie(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(p){return function(v){return Promise.resolve(v).then(p,l)}}function a(p,v){n[p]&&(o[p]=function(L){return new Promise(function(D,R){i.push([p,L,D,R])>1||f(p,L)})},v&&(o[p]=v(o[p])))}function f(p,v){try{u(n[p](v))}catch(L){m(i[0][3],L)}}function u(p){p.value instanceof S?Promise.resolve(p.value.v).then(h,l):m(i[0][2],p)}function h(p){f("next",p)}function l(p){f("throw",p)}function m(p,v){p(v),i.shift(),i.length&&f(i[0][0],i[0][1])}}function At(t){var e,r;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=t[o]?function(s){return(r=!r)?{value:S(t[o](s)),done:!1}:i?i(s):s}:i}}function xt(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 Re=="function"?Re(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(a,f){s=t[i](s),o(a,f,s.done,s.value)})}}function o(i,s,a,f){Promise.resolve(f).then(function(u){i({value:u,done:a})},s)}}var E=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new _(n));return new t(r)}static fromPromise(e,r){let n=e.then(o=>new _(o)).catch(o=>new O(r(o)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(N(this,void 0,void 0,function*(){try{return new _(yield e(...n))}catch(o){return new O(r?r(o):o)}}))}static combine(e){return Lt(e)}static combineWithAllErrors(e){return bt(e)}map(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){return r.isErr()?new O(r.error):new _(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){if(r.isErr())return new O(r.error);let n=yield e(r.value);return n.isErr()?new O(n.error):new _(r.value)})))}andTee(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){if(r.isErr())return new O(r.error);try{yield e(r.value)}catch{}return new _(r.value)})))}mapErr(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){return r.isOk()?new _(r.value):new O(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new O(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new _(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 Ie(this,arguments,function*(){return yield S(yield S(yield*At(xt(yield S(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Ie(this,arguments,function*(){let r=yield S(this._promise);return r.isErr()&&(yield yield S(T(r.error))),yield S(r.value)})}},ue=t=>new E(Promise.resolve(new _(t))),T=t=>new E(Promise.resolve(new O(t))),Xt=E.fromPromise,$t=E.fromSafePromise,qt=E.fromThrowable,Me=t=>{let e=B([]);for(let r of t)if(r.isErr()){e=I(r.error);break}else e.map(n=>n.push(r.value));return e},Lt=t=>E.fromSafePromise(Promise.all(t)).andThen(Me),Be=t=>{let e=B([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=I([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},bt=t=>E.fromSafePromise(Promise.all(t)).andThen(Be),Le;(function(t){function e(o,i){return(...s)=>{try{let a=o(...s);return B(a)}catch(a){return I(i?i(a):a)}}}t.fromThrowable=e;function r(o){return Me(o)}t.combine=r;function n(o){return Be(o)}t.combineWithAllErrors=n})(Le||(Le={}));var B=t=>new _(t);function I(t){return new O(t)}var _=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return B(e(this.value))}mapErr(e){return B(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 B(this.value)}orElse(e){return B(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return E.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 je("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},O=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return I(this.error)}mapErr(e){return I(e(this.error))}andThrough(e){return I(this.error)}andTee(e){return I(this.error)}andThen(e){return I(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return T(this.error)}asyncAndThrough(e){return T(this.error)}asyncMap(e){return T(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield I(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw je("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},Qt=Le.fromThrowable;var Ke=Pe(We());var M=class extends Error{constructor(r,n={}){let{cause:o,context:i}=n;super(r,{cause:o});b(this,"context");this.name=this.constructor.name,this.context=i}};var j=class extends M{};var z=class extends j{constructor(){super(...arguments);b(this,"message","Unable to encrypt the provided data")}};var oe=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)};var ze=(t,e)=>{try{let r=Ke.default.encrypt(t,Z(e));return ue({algo:0,data:r,iv:JSON.parse(r).iv})}catch(r){return T(new z(void 0,{cause:oe(r)}))}};var He=(t,e)=>kt(t).andThen(r=>{let n=crypto.getRandomValues(new Uint8Array(12));return E.fromPromise(crypto.subtle.encrypt({name:"AES-GCM",iv:n},r,e),o=>new z(void 0,{cause:oe(o)})).andThen(o=>ue({algo:1,data:Z(o),iv:n}))}),kt=t=>E.fromPromise(crypto.subtle.importKey("raw",xe(t),{name:"AES-GCM"},!1,["encrypt","decrypt"]),e=>new j("Unable to import cryptography key",{cause:oe(e)}));var Je=(t,e,r)=>{let n;return r===0?n=ze(t,e):(typeof e=="string"&&(e=new TextEncoder().encode(e).buffer),n=He(t,e)),n};var ot=Pe(rt());var nt=new ot.default;var it=()=>{nt.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),nt.once("OPERATION_FAILED",t=>{self.postMessage({event:"OPERATION_FAILED",error:t})})};var J=class extends M{};var ie=class extends J{constructor(){super(...arguments);b(this,"message","Parameter cannot be undefined")}};var ye=class extends J{constructor(){super(...arguments);b(this,"message","File upload already failed")}};var st=!1;self.onmessage=t=>{st||(it(),st=!0);let{lufiFile:e,chunk:r,algo:n}=t.data.args;r&&typeof n<"u"?e.uploadStatus!==2?Je(e.keys.client,r.buffer,n).map(o=>{self.postMessage({encryptedData:o,chunkIndex:r.index})}).mapErr(o=>{self.postMessage({error:o})}):self.postMessage({error:new ye("File upload already failed")}):(r||self.postMessage({error:new ie("chunk buffer cannot be undefined")}),typeof n>"u"&&self.postMessage({error:new ie("algo cannot be undefined")}))}; +var ft=Object.create;var Ae=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var dt=(t,e,r)=>e in t?Ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var mt=(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 Ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var yt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ht(e))!pt.call(t,o)&&o!==r&&Ae(t,o,{get:()=>e[o],enumerable:!(n=ut(e,o))||n.enumerable});return t};var Se=(t,e,r)=>(r=t!=null?ft(lt(t)):{},yt(e||!t||!t.__esModule?Ae(r,"default",{value:t,enumerable:!0}):r,t));var b=(t,e,r)=>dt(t,typeof e!="symbol"?e+"":e,r);var We=Ce((Vt,K)=>{"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,o,i=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),o=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[r&255],t%e===0&&(r=r<<8^r>>>24^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],o[e]=4>=t||4>e?r:s[0][i[r>>>24]]^s[1][i[r>>16&255]]^s[2][i[r>>8&255]]^s[3][i[r&255]]};c.cipher.aes.prototype={encrypt:function(t){return Te(this,t,0)},decrypt:function(t){return Te(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],o,i,s,a=[],f=[],u,h,l,m;for(o=0;256>o;o++)f[(a[o]=o<<1^283*(o>>7))^o]=o;for(i=s=0;!r[i];i^=u||1,s=f[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[i]=l,n[l]=i,h=a[o=a[u=a[i]]],m=16843009*h^65537*o^257*u^16843008*i,h=257*a[l]^16843008*l,o=0;4>o;o++)t[o][i]=h=h<<24^h>>>8,e[o][l]=m=m<<24^m>>>8;for(o=0;5>o;o++)t[o]=t[o].slice(0),e[o]=e[o].slice(0)}};function Te(t,e,r){if(e.length!==4)throw new c.exception.invalid("invalid aes block size");var n=t.b[r],o=e[0]^n[0],i=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,f,u,h=n.length/4-2,l,m=4,p=[0,0,0,0];a=t.w[r],t=a[0];var v=a[1],L=a[2],D=a[3],R=a[4];for(l=0;l>>24]^v[i>>16&255]^L[s>>8&255]^D[e&255]^n[m],f=t[i>>>24]^v[s>>16&255]^L[e>>8&255]^D[o&255]^n[m+1],u=t[s>>>24]^v[e>>16&255]^L[o>>8&255]^D[i&255]^n[m+2],e=t[e>>>24]^v[o>>16&255]^L[i>>8&255]^D[s&255]^n[m+3],m+=4,o=a,i=f,s=u;for(l=0;4>l;l++)p[r?3&-l:l]=R[o>>>24]<<24^R[i>>16&255]<<16^R[s>>8&255]<<8^R[e&255]^n[m++],a=o,o=i,i=s,s=e,e=a;return p}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[o]<<32-e;return o=t.length?t[t.length-1]:0,t=c.bitArray.getPartial(o),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,o;for(n=0;n>>8>>>8>>>8),o<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>o)>>>26),6>o?(s=t[r]<<6-o,o+=26,r++):(s<<=6,o-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,o=0,i=c.codec.base64.S,s=0,a;for(e&&(i=i.substr(0,62)+"-_"),n=0;na)throw new c.exception.invalid("this isn't base64!");26>>o),s=a<<32-o):(o+=6,s^=a<<32-o)}return o&56&&r.push(c.bitArray.partial(o&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(o=!0,n=2;n*n<=r;n++)if(r%n===0){o=!1;break}o&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,o=this.g,i=this.b,s=o[0],a=o[1],f=o[2],u=o[3],h=o[4],l=o[5],m=o[6],p=o[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+p+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(m^h&(l^m))+i[e],p=m,m=l,l=h,h=u+r|0,u=f,f=a,a=s,s=r+(a&f^u&(a^f))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+a|0,o[2]=o[2]+f|0,o[3]=o[3]+u|0,o[4]=o[4]+h|0,o[5]=o[5]+l|0,o[6]=o[6]+m|0,o[7]=o[7]+p|0}};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(i=!0,o=2;o*o<=n;o++)if(n%o===0){i=!1;break}i&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,o=this.b,i=n[0],s=n[1],a=n[2],f=n[3],u=n[4],h=n[5],l=n[6],m=n[7],p=n[8],v=n[9],L=n[10],D=n[11],R=n[12],se=n[13],Oe=n[14],ce=n[15],w;if(typeof Uint32Array<"u"){w=Array(160);for(var g=0;32>g;g++)w[g]=t[g]}else w=t;var g=i,A=s,G=a,U=f,Y=u,F=h,ve=l,X=m,k=p,x=v,ae=L,$=D,fe=R,q=se,ge=Oe,Q=ce;for(t=0;80>t;t++){if(16>t)e=w[2*t],r=w[2*t+1];else{r=w[2*(t-15)];var y=w[2*(t-15)+1];e=(y<<31|r>>>1)^(y<<24|r>>>8)^r>>>7;var C=(r<<31|y>>>1)^(r<<24|y>>>8)^(r<<25|y>>>7);r=w[2*(t-2)];var S=w[2*(t-2)+1],y=(S<<13|r>>>19)^(r<<3|S>>>29)^r>>>6,S=(r<<13|S>>>19)^(S<<3|r>>>29)^(r<<26|S>>>6),we=w[2*(t-7)],Ee=w[2*(t-16)],V=w[2*(t-16)+1];r=C+w[2*(t-7)+1],e=e+we+(r>>>0>>0?1:0),r+=S,e+=y+(r>>>0>>0?1:0),r+=V,e+=Ee+(r>>>0>>0?1:0)}w[2*t]=e|=0,w[2*t+1]=r|=0;var we=k&ae^~k&fe,De=x&$^~x&q,S=g&G^g&Y^G&Y,ct=A&U^A&F^U&F,Ee=(A<<4|g>>>28)^(g<<30|A>>>2)^(g<<25|A>>>7),V=(g<<4|A>>>28)^(A<<30|g>>>2)^(A<<25|g>>>7),at=o[2*t],ke=o[2*t+1],y=Q+((k<<18|x>>>14)^(k<<14|x>>>18)^(x<<23|k>>>9)),C=ge+((x<<18|k>>>14)^(x<<14|k>>>18)^(k<<23|x>>>9))+(y>>>0>>0?1:0),y=y+De,C=C+(we+(y>>>0>>0?1:0)),y=y+ke,C=C+(at+(y>>>0>>0?1:0)),y=y+r|0,C=C+(e+(y>>>0>>0?1:0));r=V+ct,e=Ee+S+(r>>>0>>0?1:0),ge=fe,Q=q,fe=ae,q=$,ae=k,$=x,x=X+y|0,k=ve+C+(x>>>0>>0?1:0)|0,ve=Y,X=F,Y=G,F=U,G=g,U=A,A=y+r|0,g=C+e+(A>>>0>>0?1:0)|0}s=n[1]=s+A|0,n[0]=i+g+(s>>>0>>0?1:0)|0,f=n[3]=f+U|0,n[2]=a+G+(f>>>0>>0?1:0)|0,h=n[5]=h+F|0,n[4]=u+Y+(h>>>0>>0?1:0)|0,m=n[7]=m+X|0,n[6]=l+ve+(m>>>0>>0?1:0)|0,v=n[9]=v+x|0,n[8]=p+k+(v>>>0>>0?1:0)|0,D=n[11]=D+$|0,n[10]=L+ae+(D>>>0<$>>>0?1:0)|0,se=n[13]=se+q|0,n[12]=R+fe+(se>>>0>>0?1:0)|0,ce=n[15]=ce+Q|0,n[14]=Oe+ge+(ce>>>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),-1f)throw new c.exception.invalid("ccm: iv must be at least 7 bytes");for(i=2;4>i&&u>>>8*i;i++);return i<15-f&&(i=15-f),r=a.clamp(r,8*(15-i)),e=c.mode.ccm.U(t,e,r,n,o,i),s=c.mode.ccm.V(t,s,r,e,o,i),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,o){o=o||64,n=n||[];var i=c.bitArray,s=i.bitLength(r)/8,u=i.bitLength(e),a=i.clamp(e,u-o),f=i.bitSlice(e,u-o),u=(u-o)/8;if(7>s)throw new c.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&u>>>8*e;e++);if(e<15-s&&(e=15-s),r=i.clamp(r,8*(15-e)),a=c.mode.ccm.V(t,a,r,f,o,e),t=c.mode.ccm.U(t,a.data,r,n,o,e),!i.equal(a.tag,t))throw new c.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,o,i){var s=[],a=c.bitArray,f=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|i-1)],n=a.concat(n,r),n[3]|=o,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;eo||16h&&(c.mode.ccm.da(s/f),h+=l),r[3]++,o=t.encrypt(r),e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3];return{tag:n,data:a.clamp(e,u)}}};c.misc.hmac=function(t,e){this.W=e=e||c.hash.sha256;var r=[[],[]],n,o=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>o&&(t=e.hash(t)),n=0;nn||0>r)throw new 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)),o=o||c.misc.hmac,t=new o(t);var i,s,a,f,u=[],h=c.bitArray;for(f=1;32*u.length<(n||1);f++){for(o=i=t.encrypt(h.concat(e,[f])),s=1;ss;s++)o.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=i),this.N++,this.b=c.hash.sha256.hash(this.b.concat(o)),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,i,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,i,t.length]),this.h[s].update(t);break;default:f=1}if(f)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&&Ue("seeded",Math.max(this.u,this.i)),Ue("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:te(this,this.la),mouseCollector:te(this,this.na),keyboardCollector:te(this,this.ja),accelerometerCollector:te(this,this.ca),touchCollector:te(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,o=this.J[t],i=[];for(n in o)o.hasOwnProperty(n)&&o[n]===e&&i.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function te(t,e){return function(){e.apply(t,arguments)}}c.random=new c.prng(6);e:try{if(le=typeof K<"u"&&K.exports){try{pe=mt("crypto")}catch{pe=null}le=he=pe}if(le&&he.randomBytes)re=he.randomBytes(128),re=new Uint32Array(new Uint8Array(re).buffer),c.random.addEntropy(re,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(ne=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(ne);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(ne);else break e;c.random.addEntropy(ne,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 re,he,ne,le,pe;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 o=c.json,i=o.j({iv:c.random.randomWords(4,0)},o.defaults),s;if(o.j(i,r),r=i.adata,typeof i.salt=="string"&&(i.salt=c.codec.base64.toBits(i.salt)),typeof i.iv=="string"&&(i.iv=c.codec.base64.toBits(i.iv)),!c.mode[i.mode]||!c.cipher[i.cipher]||typeof t=="string"&&100>=i.iter||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||2>i.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4{"use strict";var H=typeof Reflect=="object"?Reflect:null,Ge=H&&typeof H.apply=="function"?H.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},de;H&&typeof H.ownKeys=="function"?de=H.ownKeys:Object.getOwnPropertySymbols?de=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:de=function(e){return Object.getOwnPropertyNames(e)};function St(t){console&&console.warn&&console.warn(t)}var Xe=Number.isNaN||function(e){return e!==e};function d(){d.init.call(this)}_e.exports=d;_e.exports.once=jt;d.EventEmitter=d;d.prototype._events=void 0;d.prototype._eventsCount=0;d.prototype._maxListeners=void 0;var Ye=10;function me(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return Ye},set:function(t){if(typeof t!="number"||t<0||Xe(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ye=t}});d.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};d.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Xe(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 $e(t){return t._maxListeners===void 0?d.defaultMaxListeners:t._maxListeners}d.prototype.getMaxListeners=function(){return $e(this)};d.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=i[e];if(f===void 0)return!1;if(typeof f=="function")Ge(f,this,r);else for(var u=f.length,h=et(f,u),n=0;n0&&s.length>o&&!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,St(a)}return t}d.prototype.addListener=function(e,r){return qe(this,e,r,!1)};d.prototype.on=d.prototype.addListener;d.prototype.prependListener=function(e,r){return qe(this,e,r,!0)};function Pt(){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 Qe(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=Pt.bind(n);return o.listener=r,n.wrapFn=o,o}d.prototype.once=function(e,r){return me(r),this.on(e,Qe(this,e,r)),this};d.prototype.prependOnceListener=function(e,r){return me(r),this.prependListener(e,Qe(this,e,r)),this};d.prototype.removeListener=function(e,r){var n,o,i,s,a;if(me(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():Rt(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};d.prototype.off=d.prototype.removeListener;d.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function Ve(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?It(o):et(o,o.length)}d.prototype.listeners=function(e){return Ve(this,e,!0)};d.prototype.rawListeners=function(e){return Ve(this,e,!1)};d.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Ze.call(t,e)};d.prototype.listenerCount=Ze;function Ze(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}d.prototype.eventNames=function(){return this._eventsCount>0?de(this._events):[]};function et(t,e){for(var r=new Array(e),n=0;n>2]+this._charset[(n[i]&3)<<4|n[i+1]>>4]+this._charset[(n[i+1]&15)<<2|n[i+2]>>6]+this._charset[n[i+2]&63];return r%3==2?(o=o.substring(0,o.length-1),this._noPadding||(o+="=")):r%3==1&&(o=o.substring(0,o.length-2),this._noPadding||(o+="==")),o}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),o,i,s,a,f=0,u=0;for(;f>4,n[f++]=(i&15)<<4|s>>2,n[f++]=(s&3)<<6|a;return n.buffer}};var vt=new W("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function Z(t){return vt.Encode(t)}var gt=new W("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function xe(t){return gt.Decode(t)}var Et={withStackTrace:!1},je=(t,e,r=Et)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:o}};function N(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function a(h){try{u(n.next(h))}catch(l){s(l)}}function f(h){try{u(n.throw(h))}catch(l){s(l)}}function u(h){h.done?i(h.value):o(h.value).then(a,f)}u((n=n.apply(t,e||[])).next())})}function Re(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 P(t){return this instanceof P?(this.v=t,this):new P(t)}function Ie(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(p){return function(v){return Promise.resolve(v).then(p,l)}}function a(p,v){n[p]&&(o[p]=function(L){return new Promise(function(D,R){i.push([p,L,D,R])>1||f(p,L)})},v&&(o[p]=v(o[p])))}function f(p,v){try{u(n[p](v))}catch(L){m(i[0][3],L)}}function u(p){p.value instanceof P?Promise.resolve(p.value.v).then(h,l):m(i[0][2],p)}function h(p){f("next",p)}function l(p){f("throw",p)}function m(p,v){p(v),i.shift(),i.length&&f(i[0][0],i[0][1])}}function At(t){var e,r;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=t[o]?function(s){return(r=!r)?{value:P(t[o](s)),done:!1}:i?i(s):s}:i}}function xt(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 Re=="function"?Re(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(a,f){s=t[i](s),o(a,f,s.done,s.value)})}}function o(i,s,a,f){Promise.resolve(f).then(function(u){i({value:u,done:a})},s)}}var E=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new _(n));return new t(r)}static fromPromise(e,r){let n=e.then(o=>new _(o)).catch(o=>new O(r(o)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(N(this,void 0,void 0,function*(){try{return new _(yield e(...n))}catch(o){return new O(r?r(o):o)}}))}static combine(e){return Lt(e)}static combineWithAllErrors(e){return bt(e)}map(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){return r.isErr()?new O(r.error):new _(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){if(r.isErr())return new O(r.error);let n=yield e(r.value);return n.isErr()?new O(n.error):new _(r.value)})))}andTee(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){if(r.isErr())return new O(r.error);try{yield e(r.value)}catch{}return new _(r.value)})))}mapErr(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){return r.isOk()?new _(r.value):new O(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new O(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>N(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new _(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 Ie(this,arguments,function*(){return yield P(yield P(yield*At(xt(yield P(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Ie(this,arguments,function*(){let r=yield P(this._promise);return r.isErr()&&(yield yield P(T(r.error))),yield P(r.value)})}},ue=t=>new E(Promise.resolve(new _(t))),T=t=>new E(Promise.resolve(new O(t))),Yt=E.fromPromise,Xt=E.fromSafePromise,$t=E.fromThrowable,Me=t=>{let e=B([]);for(let r of t)if(r.isErr()){e=I(r.error);break}else e.map(n=>n.push(r.value));return e},Lt=t=>E.fromSafePromise(Promise.all(t)).andThen(Me),Be=t=>{let e=B([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=I([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},bt=t=>E.fromSafePromise(Promise.all(t)).andThen(Be),Le;(function(t){function e(o,i){return(...s)=>{try{let a=o(...s);return B(a)}catch(a){return I(i?i(a):a)}}}t.fromThrowable=e;function r(o){return Me(o)}t.combine=r;function n(o){return Be(o)}t.combineWithAllErrors=n})(Le||(Le={}));var B=t=>new _(t);function I(t){return new O(t)}var _=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return B(e(this.value))}mapErr(e){return B(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 B(this.value)}orElse(e){return B(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return E.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 je("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},O=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return I(this.error)}mapErr(e){return I(e(this.error))}andThrough(e){return I(this.error)}andTee(e){return I(this.error)}andThen(e){return I(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return T(this.error)}asyncAndThrough(e){return T(this.error)}asyncMap(e){return T(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield I(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw je("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},qt=Le.fromThrowable;var Ke=Se(We());var M=class extends Error{constructor(r,n={}){let{cause:o,context:i}=n;super(r,{cause:o});b(this,"context");this.name=this.constructor.name,this.context=i}};var j=class extends M{};var z=class extends j{constructor(){super(...arguments);b(this,"message","Unable to encrypt the provided data")}};var oe=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)};var ze=(t,e)=>{try{let r=Ke.default.encrypt(t,Z(e));return ue({algo:0,data:r,iv:JSON.parse(r).iv})}catch(r){return T(new z(void 0,{cause:oe(r)}))}};var He=(t,e)=>kt(t).andThen(r=>{let n=crypto.getRandomValues(new Uint8Array(12));return E.fromPromise(crypto.subtle.encrypt({name:"AES-GCM",iv:n},r,e),o=>new z(void 0,{cause:oe(o)})).andThen(o=>ue({algo:1,data:Z(o),iv:n}))}),kt=t=>E.fromPromise(crypto.subtle.importKey("raw",xe(t),{name:"AES-GCM"},!1,["encrypt","decrypt"]),e=>new j("Unable to import cryptography key",{cause:oe(e)}));var Je=(t,e,r)=>{let n;return r===0?n=ze(t,e):(typeof e=="string"&&(e=new TextEncoder().encode(e).buffer),n=He(t,e)),n};var ot=Se(rt());var nt=new ot.default;var it=()=>{nt.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),nt.once("OPERATION_FAILED",t=>{self.postMessage({event:"OPERATION_FAILED",error:t})})};var J=class extends M{};var ie=class extends J{constructor(){super(...arguments);b(this,"message","Parameter cannot be undefined")}};var ye=class extends J{constructor(){super(...arguments);b(this,"message","File upload already failed")}};var st=!1;self.onmessage=t=>{st||(it(),st=!0);let{lufiFile:e,chunk:r,algo:n}=t.data.args;r&&typeof n<"u"?e.uploadStatus!==2?Je(e.keys.client,r.buffer,n).map(o=>{self.postMessage({encryptedData:o,chunkIndex:r.index})}).mapErr(o=>{self.postMessage({error:o})}):self.postMessage({error:new ye("File upload already failed")}):(r||self.postMessage({error:new ie("chunk buffer cannot be undefined")}),typeof n>"u"&&self.postMessage({error:new ie("algo cannot be undefined")}))}; diff --git a/themes/default/public/js/worker/infos.js b/themes/default/public/js/worker/infos.js index e74daea..b592f17 100644 --- a/themes/default/public/js/worker/infos.js +++ b/themes/default/public/js/worker/infos.js @@ -1 +1 @@ -var vt=Object.create;var xe=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Ot=(t,e,r)=>e in t?xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Lt=(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 Ie=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var xt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!At.call(t,o)&&o!==r&&xe(t,o,{get:()=>e[o],enumerable:!(n=gt(e,o))||n.enumerable});return t};var Me=(t,e,r)=>(r=t!=null?vt(Et(t)):{},xt(e||!t||!t.__esModule?xe(r,"default",{value:t,enumerable:!0}):r,t));var T=(t,e,r)=>Ot(t,typeof e!="symbol"?e+"":e,r);var qe=Ie((Pr,_e)=>{"use strict";var X=typeof Reflect=="object"?Reflect:null,Fe=X&&typeof X.apply=="function"?X.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},pe;X&&typeof X.ownKeys=="function"?pe=X.ownKeys:Object.getOwnPropertySymbols?pe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pe=function(e){return Object.getOwnPropertyNames(e)};function Rt(t){console&&console.warn&&console.warn(t)}var ze=Number.isNaN||function(e){return e!==e};function p(){p.init.call(this)}_e.exports=p;_e.exports.once=It;p.EventEmitter=p;p.prototype._events=void 0;p.prototype._eventsCount=0;p.prototype._maxListeners=void 0;var Je=10;function me(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(p,"defaultMaxListeners",{enumerable:!0,get:function(){return Je},set:function(t){if(typeof t!="number"||t<0||ze(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Je=t}});p.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};p.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ze(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 He(t){return t._maxListeners===void 0?p.defaultMaxListeners:t._maxListeners}p.prototype.getMaxListeners=function(){return He(this)};p.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=i[e];if(u===void 0)return!1;if(typeof u=="function")Fe(u,this,r);else for(var f=u.length,h=Ye(u,f),n=0;n0&&s.length>o&&!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,Rt(a)}return t}p.prototype.addListener=function(e,r){return Ke(this,e,r,!1)};p.prototype.on=p.prototype.addListener;p.prototype.prependListener=function(e,r){return Ke(this,e,r,!0)};function Ct(){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 Xe(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=Ct.bind(n);return o.listener=r,n.wrapFn=o,o}p.prototype.once=function(e,r){return me(r),this.on(e,Xe(this,e,r)),this};p.prototype.prependOnceListener=function(e,r){return me(r),this.prependListener(e,Xe(this,e,r)),this};p.prototype.removeListener=function(e,r){var n,o,i,s,a;if(me(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():Pt(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};p.prototype.off=p.prototype.removeListener;p.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function Ge(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?Tt(o):Ye(o,o.length)}p.prototype.listeners=function(e){return Ge(this,e,!0)};p.prototype.rawListeners=function(e){return Ge(this,e,!1)};p.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):$e.call(t,e)};p.prototype.listenerCount=$e;function $e(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}p.prototype.eventNames=function(){return this._eventsCount>0?pe(this._events):[]};function Ye(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,o,i=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),o=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[r&255],t%e===0&&(r=r<<8^r>>>24^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],o[e]=4>=t||4>e?r:s[0][i[r>>>24]]^s[1][i[r>>16&255]]^s[2][i[r>>8&255]]^s[3][i[r&255]]};c.cipher.aes.prototype={encrypt:function(t){return rt(this,t,0)},decrypt:function(t){return rt(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],o,i,s,a=[],u=[],f,h,l,y;for(o=0;256>o;o++)u[(a[o]=o<<1^283*(o>>7))^o]=o;for(i=s=0;!r[i];i^=f||1,s=u[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[i]=l,n[l]=i,h=a[o=a[f=a[i]]],y=16843009*h^65537*o^257*f^16843008*i,h=257*a[l]^16843008*l,o=0;4>o;o++)t[o][i]=h=h<<24^h>>>8,e[o][l]=y=y<<24^y>>>8;for(o=0;5>o;o++)t[o]=t[o].slice(0),e[o]=e[o].slice(0)}};function rt(t,e,r){if(e.length!==4)throw new c.exception.invalid("invalid aes block size");var n=t.b[r],o=e[0]^n[0],i=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,u,f,h=n.length/4-2,l,y=4,d=[0,0,0,0];a=t.w[r],t=a[0];var g=a[1],_=a[2],k=a[3],N=a[4];for(l=0;l>>24]^g[i>>16&255]^_[s>>8&255]^k[e&255]^n[y],u=t[i>>>24]^g[s>>16&255]^_[e>>8&255]^k[o&255]^n[y+1],f=t[s>>>24]^g[e>>16&255]^_[o>>8&255]^k[i&255]^n[y+2],e=t[e>>>24]^g[o>>16&255]^_[i>>8&255]^k[s&255]^n[y+3],y+=4,o=a,i=u,s=f;for(l=0;4>l;l++)d[r?3&-l:l]=N[o>>>24]<<24^N[i>>16&255]<<16^N[s>>8&255]<<8^N[e&255]^n[y++],a=o,o=i,i=s,s=e,e=a;return d}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[o]<<32-e;return o=t.length?t[t.length-1]:0,t=c.bitArray.getPartial(o),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,o;for(n=0;n>>8>>>8>>>8),o<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>o)>>>26),6>o?(s=t[r]<<6-o,o+=26,r++):(s<<=6,o-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,o=0,i=c.codec.base64.S,s=0,a;for(e&&(i=i.substr(0,62)+"-_"),n=0;na)throw new c.exception.invalid("this isn't base64!");26>>o),s=a<<32-o):(o+=6,s^=a<<32-o)}return o&56&&r.push(c.bitArray.partial(o&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(o=!0,n=2;n*n<=r;n++)if(r%n===0){o=!1;break}o&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,o=this.g,i=this.b,s=o[0],a=o[1],u=o[2],f=o[3],h=o[4],l=o[5],y=o[6],d=o[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+d+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(y^h&(l^y))+i[e],d=y,y=l,l=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;o[0]=o[0]+s|0,o[1]=o[1]+a|0,o[2]=o[2]+u|0,o[3]=o[3]+f|0,o[4]=o[4]+h|0,o[5]=o[5]+l|0,o[6]=o[6]+y|0,o[7]=o[7]+d|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(i=!0,o=2;o*o<=n;o++)if(n%o===0){i=!1;break}i&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,o=this.b,i=n[0],s=n[1],a=n[2],u=n[3],f=n[4],h=n[5],l=n[6],y=n[7],d=n[8],g=n[9],_=n[10],k=n[11],N=n[12],fe=n[13],Ce=n[14],he=n[15],A;if(typeof Uint32Array<"u"){A=Array(160);for(var w=0;32>w;w++)A[w]=t[w]}else A=t;var w=i,x=s,q=a,z=u,Q=f,H=h,Ee=l,Z=y,R=d,b=g,le=_,ee=k,de=N,te=fe,Ae=Ce,re=he;for(t=0;80>t;t++){if(16>t)e=A[2*t],r=A[2*t+1];else{r=A[2*(t-15)];var v=A[2*(t-15)+1];e=(v<<31|r>>>1)^(v<<24|r>>>8)^r>>>7;var C=(r<<31|v>>>1)^(r<<24|v>>>8)^(r<<25|v>>>7);r=A[2*(t-2)];var P=A[2*(t-2)+1],v=(P<<13|r>>>19)^(r<<3|P>>>29)^r>>>6,P=(r<<13|P>>>19)^(P<<3|r>>>29)^(r<<26|P>>>6),Oe=A[2*(t-7)],Le=A[2*(t-16)],ne=A[2*(t-16)+1];r=C+A[2*(t-7)+1],e=e+Oe+(r>>>0>>0?1:0),r+=P,e+=v+(r>>>0

>>0?1:0),r+=ne,e+=Le+(r>>>0>>0?1:0)}A[2*t]=e|=0,A[2*t+1]=r|=0;var Oe=R&le^~R&de,Pe=b&ee^~b&te,P=w&q^w&Q^q&Q,mt=x&z^x&H^z&H,Le=(x<<4|w>>>28)^(w<<30|x>>>2)^(w<<25|x>>>7),ne=(w<<4|x>>>28)^(x<<30|w>>>2)^(x<<25|w>>>7),yt=o[2*t],Te=o[2*t+1],v=re+((R<<18|b>>>14)^(R<<14|b>>>18)^(b<<23|R>>>9)),C=Ae+((b<<18|R>>>14)^(b<<14|R>>>18)^(R<<23|b>>>9))+(v>>>0>>0?1:0),v=v+Pe,C=C+(Oe+(v>>>0>>0?1:0)),v=v+Te,C=C+(yt+(v>>>0>>0?1:0)),v=v+r|0,C=C+(e+(v>>>0>>0?1:0));r=ne+mt,e=Le+P+(r>>>0>>0?1:0),Ae=de,re=te,de=le,te=ee,le=R,ee=b,b=Z+v|0,R=Ee+C+(b>>>0>>0?1:0)|0,Ee=Q,Z=H,Q=q,H=z,q=w,z=x,x=v+r|0,w=C+e+(x>>>0>>0?1:0)|0}s=n[1]=s+x|0,n[0]=i+w+(s>>>0>>0?1:0)|0,u=n[3]=u+z|0,n[2]=a+q+(u>>>0>>0?1:0)|0,h=n[5]=h+H|0,n[4]=f+Q+(h>>>0>>0?1:0)|0,y=n[7]=y+Z|0,n[6]=l+Ee+(y>>>0>>0?1:0)|0,g=n[9]=g+b|0,n[8]=d+R+(g>>>0>>0?1:0)|0,k=n[11]=k+ee|0,n[10]=_+le+(k>>>0>>0?1:0)|0,fe=n[13]=fe+te|0,n[12]=N+de+(fe>>>0>>0?1:0)|0,he=n[15]=he+re|0,n[14]=Ce+Ae+(he>>>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(i=2;4>i&&f>>>8*i;i++);return i<15-u&&(i=15-u),r=a.clamp(r,8*(15-i)),e=c.mode.ccm.U(t,e,r,n,o,i),s=c.mode.ccm.V(t,s,r,e,o,i),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,o){o=o||64,n=n||[];var i=c.bitArray,s=i.bitLength(r)/8,f=i.bitLength(e),a=i.clamp(e,f-o),u=i.bitSlice(e,f-o),f=(f-o)/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=i.clamp(r,8*(15-e)),a=c.mode.ccm.V(t,a,r,u,o,e),t=c.mode.ccm.U(t,a.data,r,n,o,e),!i.equal(a.tag,t))throw new c.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,o,i){var s=[],a=c.bitArray,u=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|i-1)],n=a.concat(n,r),n[3]|=o,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;eo||16h&&(c.mode.ccm.da(s/u),h+=l),r[3]++,o=t.encrypt(r),e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3];return{tag:n,data:a.clamp(e,f)}}};c.misc.hmac=function(t,e){this.W=e=e||c.hash.sha256;var r=[[],[]],n,o=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>o&&(t=e.hash(t)),n=0;nn||0>r)throw new 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)),o=o||c.misc.hmac,t=new o(t);var i,s,a,u,f=[],h=c.bitArray;for(u=1;32*f.length<(n||1);u++){for(o=i=t.encrypt(h.concat(e,[u])),s=1;ss;s++)o.push(4294967296*Math.random()|0);for(s=0;s=1<this.u&&(this.u=i),this.N++,this.b=c.hash.sha256.hash(this.b.concat(o)),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,i,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,i,t.length]),this.h[s].update(t);break;default:u=1}if(u)throw new 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&&nt("seeded",Math.max(this.u,this.i)),nt("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,o=this.J[t],i=[];for(n in o)o.hasOwnProperty(n)&&o[n]===e&&i.push(n);for(r=0;re&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function ce(t,e){return function(){e.apply(t,arguments)}}c.random=new c.prng(6);e:try{if(ve=typeof Y<"u"&&Y.exports){try{ge=Lt("crypto")}catch{ge=null}ve=ye=ge}if(ve&&ye.randomBytes)ae=ye.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,ye,ue,ve,ge;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 o=c.json,i=o.j({iv:c.random.randomWords(4,0)},o.defaults),s;if(o.j(i,r),r=i.adata,typeof i.salt=="string"&&(i.salt=c.codec.base64.toBits(i.salt)),typeof i.iv=="string"&&(i.iv=c.codec.base64.toBits(i.iv)),!c.mode[i.mode]||!c.cipher[i.cipher]||typeof t=="string"&&100>=i.iter||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||2>i.iv.length||4=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:o}};function K(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function a(h){try{f(n.next(h))}catch(l){s(l)}}function u(h){try{f(n.throw(h))}catch(l){s(l)}}function f(h){h.done?i(h.value):o(h.value).then(a,u)}f((n=n.apply(t,e||[])).next())})}function Ue(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 I(t){return this instanceof I?(this.v=t,this):new I(t)}function Ne(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(d){return function(g){return Promise.resolve(g).then(d,l)}}function a(d,g){n[d]&&(o[d]=function(_){return new Promise(function(k,N){i.push([d,_,k,N])>1||u(d,_)})},g&&(o[d]=g(o[d])))}function u(d,g){try{f(n[d](g))}catch(_){y(i[0][3],_)}}function f(d){d.value instanceof I?Promise.resolve(d.value.v).then(h,l):y(i[0][2],d)}function h(d){u("next",d)}function l(d){u("throw",d)}function y(d,g){d(g),i.shift(),i.length&&u(i[0][0],i[0][1])}}function _t(t){var e,r;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=t[o]?function(s){return(r=!r)?{value:I(t[o](s)),done:!1}:i?i(s):s}:i}}function Dt(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 Ue=="function"?Ue(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(a,u){s=t[i](s),o(a,u,s.done,s.value)})}}function o(i,s,a,u){Promise.resolve(u).then(function(f){i({value:f,done:a})},s)}}var E=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new D(n));return new t(r)}static fromPromise(e,r){let n=e.then(o=>new D(o)).catch(o=>new S(r(o)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(K(this,void 0,void 0,function*(){try{return new D(yield e(...n))}catch(o){return new S(r?r(o):o)}}))}static combine(e){return St(e)}static combineWithAllErrors(e){return kt(e)}map(e){return new t(this._promise.then(r=>K(this,void 0,void 0,function*(){return r.isErr()?new S(r.error):new D(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>K(this,void 0,void 0,function*(){if(r.isErr())return new S(r.error);let n=yield e(r.value);return n.isErr()?new S(n.error):new D(r.value)})))}andTee(e){return new t(this._promise.then(r=>K(this,void 0,void 0,function*(){if(r.isErr())return new S(r.error);try{yield e(r.value)}catch{}return new D(r.value)})))}mapErr(e){return new t(this._promise.then(r=>K(this,void 0,void 0,function*(){return r.isOk()?new D(r.value):new S(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new S(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>K(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new D(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 Ne(this,arguments,function*(){return yield I(yield I(yield*_t(Dt(yield I(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return Ne(this,arguments,function*(){let r=yield I(this._promise);return r.isErr()&&(yield yield I(O(r.error))),yield I(r.value)})}},M=t=>new E(Promise.resolve(new D(t))),O=t=>new E(Promise.resolve(new S(t))),ir=E.fromPromise,sr=E.fromSafePromise,cr=E.fromThrowable,Be=t=>{let e=F([]);for(let r of t)if(r.isErr()){e=j(r.error);break}else e.map(n=>n.push(r.value));return e},St=t=>E.fromSafePromise(Promise.all(t)).andThen(Be),We=t=>{let e=F([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=j([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},kt=t=>E.fromSafePromise(Promise.all(t)).andThen(We),be;(function(t){function e(o,i){return(...s)=>{try{let a=o(...s);return F(a)}catch(a){return j(i?i(a):a)}}}t.fromThrowable=e;function r(o){return Be(o)}t.combine=r;function n(o){return We(o)}t.combineWithAllErrors=n})(be||(be={}));var F=t=>new D(t);function j(t){return new S(t)}var D=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return F(e(this.value))}mapErr(e){return F(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 F(this.value)}orElse(e){return F(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return E.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 je("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},S=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return j(this.error)}mapErr(e){return j(e(this.error))}andThrough(e){return j(this.error)}andTee(e){return j(this.error)}andThen(e){return j(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return O(this.error)}asyncAndThrough(e){return O(this.error)}asyncMap(e){return O(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield j(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw je("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},ar=be.fromThrowable;var W=class extends Error{constructor(r,n={}){let{cause:o,context:i}=n;super(r,{cause:o});T(this,"context");this.name=this.constructor.name,this.context=i}};var U=class extends W{};var oe=class extends U{constructor(){super(...arguments);T(this,"message","An error occured while trying to connect to WebSocket")}};var J=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)};var Ze=Me(qe());var m=new Ze.default,G=(t,e)=>(Object.assign(t,e),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:t}),t);var et=()=>{m.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),m.once("OPERATION_FAILED",t=>{self.postMessage({event:"OPERATION_FAILED",error:t})})};var $=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),o="";for(let i=0;i>2]+this._charset[(n[i]&3)<<4|n[i+1]>>4]+this._charset[(n[i+1]&15)<<2|n[i+2]>>6]+this._charset[n[i+2]&63];return r%3==2?(o=o.substring(0,o.length-1),this._noPadding||(o+="=")):r%3==1&&(o=o.substring(0,o.length-2),this._noPadding||(o+="==")),o}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),o,i,s,a,u=0,f=0;for(;u>4,n[u++]=(i&15)<<4|s>>2,n[u++]=(s&3)<<6|a;return n.buffer}};var Nt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function ie(t){return Nt.Decode(t)}var jt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function De(t){return jt.Decode(t)}var ct=Me(it());var B=class extends W{};var V=class extends B{constructor(){super(...arguments);T(this,"message","Unable to decrypt the provided data")}};var at=(t,e)=>{try{let r=typeof e=="string"?e:e.data;return M(ie(ct.default.decrypt(t,r)))}catch(r){return O(new V(void 0,{cause:J(r)}))}};var ut=(t,e)=>zt(t).andThen(r=>E.fromPromise(crypto.subtle.decrypt({name:"AES-GCM",iv:e.iv},r,ie(e.data)),n=>new V(void 0,{cause:J(n)})));var zt=t=>E.fromPromise(crypto.subtle.importKey("raw",De(t),{name:"AES-GCM"},!1,["encrypt","decrypt"]),e=>new B("Unable to import cryptography key",{cause:J(e)}));var ft=(t,e)=>e.algo===void 0||e.algo===0?at(t,e):ut(t,e);var L={},ht=5,Xt=t=>(m.emit("UPLOAD_CANCELLED",t.success),M(void 0)),Gt=(t,e)=>{let r=t.split("XXMOJOXX"),n=r.shift();if(n!==void 0){let o=JSON.parse(n);if(tr(o)){let i=r.shift();if(i){let s=JSON.parse(i);return s.iv&&(s.iv=new Uint8Array(Object.values(s.iv))),ft(e.keys.client,s).andThen(a=>{let u=typeof a=="string"?new TextEncoder().encode(a).buffer:a;return o.part===0?(G(e,{chunksReady:e.chunksReady+1,delAtFirstView:o.del_at_first_view,delay:o.delay,name:o.name,size:o.size,totalChunks:o.total,type:o.type,zipped:o.zipped}),m.emit("DOWNLOAD_STARTED")):G(e,{chunksReady:e.chunksReady+1}),m.emit("CHUNK_DOWNLOADED",u,o.part),++o.part===o.total?qt(e).andThen(()=>(m.emit("DOWNLOAD_COMPLETE"),m.emit("SOCKET_OPERATION_TERMINATED"),M(void 0))):M(void 0)})}else{let s=new U("Cannot retrieve metadata from data received by the server");return m.emit("OPERATION_FAILED",s),O(s)}}else{let i=new U(o.msg);return m.emit("OPERATION_FAILED",i),O(i)}}else{let o=new U("Cannot retrieve metadata from data received by the server");return m.emit("OPERATION_FAILED",o),O(o)}},$t=(t,e)=>{if(t.success)return t.j===0&&(G(e,{keys:{client:e.keys.client,server:t.short},actionToken:t.token,queueIndex:t.i}),m.emit("UPLOAD_STARTED")),G(e,{chunksReady:e.chunksReady+1,createdAt:t.created_at}),m.emit("CHUNK_UPLOADED"),e.chunksReady===e.totalChunks&&(G(e,{uploadStatus:1}),m.emit("UPLOAD_COMPLETE"),m.emit("SOCKET_OPERATION_TERMINATED")),M(void 0);{let r=new U(t.msg);return m.emit("OPERATION_FAILED",r),O(r)}},Yt=(t,e)=>{let r=er(t.data),n;if(r)if(!r.action&&r.msg){let o=new U(r.msg);return m.emit("OPERATION_FAILED",o),O(o)}else"delay"in r?n=$t(r,e):n=Xt(r);else n=Gt(t.data,e);return n},Vt=t=>L!==void 0&&L[t]!==void 0&&L[t].readyState===WebSocket.CONNECTING,ke=t=>L!==void 0&&L[t]!==void 0&&L[t].readyState===WebSocket.OPEN;var lt=(t,e)=>{let r;return t.password?r={part:e,file_pwd:t.password}:r={part:e},Re(we(t),t,JSON.stringify(r))},qt=t=>{let e;return t.password?e={ended:!0,file_pwd:t.password}:e={ended:!0},Re(we(t),t,JSON.stringify(e))};var Re=(t,e,r)=>ke(t)?(L[t].onmessage=n=>Yt(n,e),L[t].send(r),M(void 0)):dt(t).andThen(()=>Re(t,e,r)),dt=(t,e=0)=>(!ke(t)&&!Vt(t)&&(L[t]=new WebSocket(t),m.once("SOCKET_OPERATION_TERMINATED",()=>{L[t].close()}),m.once("OPERATION_FAILED",()=>{m.emit("SOCKET_OPERATION_TERMINATED")}),L[t].onopen=()=>{m.emit("SOCKET_OPENED")},L[t].onclose=()=>{},L[t].onerror=()=>++e<=ht?(console.error(`An error happened while trying to connect to WebSocket ${t}. Trying again. ${e} / ${ht}`),dt(t,e)):(m.emit("SOCKET_ONERROR"),O(new oe(`Unable to connect to WebSocket ${t}.`)))),Qt(t).andThen(()=>M(t)).orElse(r=>O(r))),Qt=t=>E.fromPromise(new Promise((e,r)=>{ke(t)?e(void 0):(m.once("SOCKET_OPENED",()=>{e(void 0)}),m.on("SOCKET_ONERROR",()=>{r(new oe)}))}),e=>J(e));var Zt=(t,e)=>{let r=new URL(t);return r.protocol=r.protocol==="http:"?"ws:":"wss:",r.pathname+=e,new URL(r.origin+r.pathname)},we=t=>Zt(new URL(t.serverUrl),"download"+`/${t.keys.server}`).toString();var er=t=>{try{let e=JSON.parse(t);if(e&&typeof e=="object")return e}catch{}return!1},tr=t=>typeof t=="object"&&t!==null&&!("msg"in t);var pt=!1;self.onmessage=t=>{pt||(et(),pt=!0),m.on("DOWNLOAD_STARTED",()=>{L[we(t.data.args.lufiFile)].close(),self.postMessage({event:"INFOS_RETRIEVED"})}),nr(t.data).mapErr(e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var nr=t=>lt(t.args.lufiFile,0); +var vt=Object.create;var xe=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Ot=(t,e,r)=>e in t?xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Lt=(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 Ie=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var xt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!At.call(t,o)&&o!==r&&xe(t,o,{get:()=>e[o],enumerable:!(n=gt(e,o))||n.enumerable});return t};var Me=(t,e,r)=>(r=t!=null?vt(Et(t)):{},xt(e||!t||!t.__esModule?xe(r,"default",{value:t,enumerable:!0}):r,t));var T=(t,e,r)=>Ot(t,typeof e!="symbol"?e+"":e,r);var qe=Ie((Cr,_e)=>{"use strict";var X=typeof Reflect=="object"?Reflect:null,Fe=X&&typeof X.apply=="function"?X.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},pe;X&&typeof X.ownKeys=="function"?pe=X.ownKeys:Object.getOwnPropertySymbols?pe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pe=function(e){return Object.getOwnPropertyNames(e)};function Rt(t){console&&console.warn&&console.warn(t)}var ze=Number.isNaN||function(e){return e!==e};function p(){p.init.call(this)}_e.exports=p;_e.exports.once=It;p.EventEmitter=p;p.prototype._events=void 0;p.prototype._eventsCount=0;p.prototype._maxListeners=void 0;var Je=10;function me(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(p,"defaultMaxListeners",{enumerable:!0,get:function(){return Je},set:function(t){if(typeof t!="number"||t<0||ze(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Je=t}});p.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};p.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ze(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 He(t){return t._maxListeners===void 0?p.defaultMaxListeners:t._maxListeners}p.prototype.getMaxListeners=function(){return He(this)};p.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=i[e];if(u===void 0)return!1;if(typeof u=="function")Fe(u,this,r);else for(var f=u.length,h=Ye(u,f),n=0;n0&&s.length>o&&!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,Rt(a)}return t}p.prototype.addListener=function(e,r){return Ke(this,e,r,!1)};p.prototype.on=p.prototype.addListener;p.prototype.prependListener=function(e,r){return Ke(this,e,r,!0)};function Ct(){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 Xe(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=Ct.bind(n);return o.listener=r,n.wrapFn=o,o}p.prototype.once=function(e,r){return me(r),this.on(e,Xe(this,e,r)),this};p.prototype.prependOnceListener=function(e,r){return me(r),this.prependListener(e,Xe(this,e,r)),this};p.prototype.removeListener=function(e,r){var n,o,i,s,a;if(me(r),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():Pt(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};p.prototype.off=p.prototype.removeListener;p.prototype.removeAllListeners=function(e){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,r[o]);return this};function Ge(t,e,r){var n=t._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?Tt(o):Ye(o,o.length)}p.prototype.listeners=function(e){return Ge(this,e,!0)};p.prototype.rawListeners=function(e){return Ge(this,e,!1)};p.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):$e.call(t,e)};p.prototype.listenerCount=$e;function $e(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}p.prototype.eventNames=function(){return this._eventsCount>0?pe(this._events):[]};function Ye(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,o,i=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),o=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[r&255],t%e===0&&(r=r<<8^r>>>24^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],o[e]=4>=t||4>e?r:s[0][i[r>>>24]]^s[1][i[r>>16&255]]^s[2][i[r>>8&255]]^s[3][i[r&255]]};c.cipher.aes.prototype={encrypt:function(t){return rt(this,t,0)},decrypt:function(t){return rt(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],o,i,s,a=[],u=[],f,h,l,y;for(o=0;256>o;o++)u[(a[o]=o<<1^283*(o>>7))^o]=o;for(i=s=0;!r[i];i^=f||1,s=u[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[i]=l,n[l]=i,h=a[o=a[f=a[i]]],y=16843009*h^65537*o^257*f^16843008*i,h=257*a[l]^16843008*l,o=0;4>o;o++)t[o][i]=h=h<<24^h>>>8,e[o][l]=y=y<<24^y>>>8;for(o=0;5>o;o++)t[o]=t[o].slice(0),e[o]=e[o].slice(0)}};function rt(t,e,r){if(e.length!==4)throw new c.exception.invalid("invalid aes block size");var n=t.b[r],o=e[0]^n[0],i=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,u,f,h=n.length/4-2,l,y=4,d=[0,0,0,0];a=t.w[r],t=a[0];var g=a[1],_=a[2],k=a[3],N=a[4];for(l=0;l>>24]^g[i>>16&255]^_[s>>8&255]^k[e&255]^n[y],u=t[i>>>24]^g[s>>16&255]^_[e>>8&255]^k[o&255]^n[y+1],f=t[s>>>24]^g[e>>16&255]^_[o>>8&255]^k[i&255]^n[y+2],e=t[e>>>24]^g[o>>16&255]^_[i>>8&255]^k[s&255]^n[y+3],y+=4,o=a,i=u,s=f;for(l=0;4>l;l++)d[r?3&-l:l]=N[o>>>24]<<24^N[i>>16&255]<<16^N[s>>8&255]<<8^N[e&255]^n[y++],a=o,o=i,i=s,s=e,e=a;return d}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[o]<<32-e;return o=t.length?t[t.length-1]:0,t=c.bitArray.getPartial(o),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,o;for(n=0;n>>8>>>8>>>8),o<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r>>o)>>>26),6>o?(s=t[r]<<6-o,o+=26,r++):(s<<=6,o-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,o=0,i=c.codec.base64.S,s=0,a;for(e&&(i=i.substr(0,62)+"-_"),n=0;na)throw new c.exception.invalid("this isn't base64!");26>>o),s=a<<32-o):(o+=6,s^=a<<32-o)}return o&56&&r.push(c.bitArray.partial(o&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(o=!0,n=2;n*n<=r;n++)if(r%n===0){o=!1;break}o&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,o=this.g,i=this.b,s=o[0],a=o[1],u=o[2],f=o[3],h=o[4],l=o[5],y=o[6],d=o[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+d+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(y^h&(l^y))+i[e],d=y,y=l,l=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;o[0]=o[0]+s|0,o[1]=o[1]+a|0,o[2]=o[2]+u|0,o[3]=o[3]+f|0,o[4]=o[4]+h|0,o[5]=o[5]+l|0,o[6]=o[6]+y|0,o[7]=o[7]+d|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(i=!0,o=2;o*o<=n;o++)if(n%o===0){i=!1;break}i&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,o=this.b,i=n[0],s=n[1],a=n[2],u=n[3],f=n[4],h=n[5],l=n[6],y=n[7],d=n[8],g=n[9],_=n[10],k=n[11],N=n[12],fe=n[13],Ce=n[14],he=n[15],A;if(typeof Uint32Array<"u"){A=Array(160);for(var w=0;32>w;w++)A[w]=t[w]}else A=t;var w=i,x=s,q=a,z=u,Q=f,H=h,Ee=l,Z=y,R=d,b=g,le=_,ee=k,de=N,te=fe,Ae=Ce,re=he;for(t=0;80>t;t++){if(16>t)e=A[2*t],r=A[2*t+1];else{r=A[2*(t-15)];var v=A[2*(t-15)+1];e=(v<<31|r>>>1)^(v<<24|r>>>8)^r>>>7;var C=(r<<31|v>>>1)^(r<<24|v>>>8)^(r<<25|v>>>7);r=A[2*(t-2)];var P=A[2*(t-2)+1],v=(P<<13|r>>>19)^(r<<3|P>>>29)^r>>>6,P=(r<<13|P>>>19)^(P<<3|r>>>29)^(r<<26|P>>>6),Oe=A[2*(t-7)],Le=A[2*(t-16)],ne=A[2*(t-16)+1];r=C+A[2*(t-7)+1],e=e+Oe+(r>>>0>>0?1:0),r+=P,e+=v+(r>>>0

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