>>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=R&le^~R&de,ke=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+((R<<18|x>>>14)^(R<<14|x>>>18)^(x<<23|R>>>9)),k=Ee+((x<<18|R>>>14)^(x<<14|R>>>18)^(R<<23|x>>>9))+(v>>>0>>0?1:0),v=v+ke,k=k+(Ae+(v>>>0>>0?1:0)),v=v+Pe,k=k+(yt+(v>>>0>>0?1:0)),v=v+r|0,k=k+(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=R,ee=x,x=Z+v|0,R=we+k+(x>>>0>>0?1:0)|0,we=Q,Z=H,Q=V,H=z,V=w,z=L,L=v+r|0,w=k+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+R+(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]=j+de+(fe>>>0>>0?1:0)|0,he=n[15]=he+re|0,n[14]=Re+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,j){i.push([d,_,C,j])>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=N(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=N([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 N(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 N(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 N(this.error)}mapErr(e){return N(e(this.error))}andThrough(e){return N(this.error)}andTee(e){return N(this.error)}andThen(e){return N(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 N(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 jt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function ie(t){return jt.Decode(t)}var Nt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function _e(t){return Nt.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);
+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 je=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||je(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||je(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 Ne(t){return t._maxListeners===void 0?p.defaultMaxListeners:t._maxListeners}p.prototype.getMaxListeners=function(){return Ne(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],j=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]=j[o>>>24]<<24^j[i>>16&255]<<16^j[s>>8&255]<<8^j[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],j=n[12],fe=n[13],Re=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,R=d,x=g,le=_,ee=C,de=j,te=fe,Ee=Re,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 k=(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=k+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=R&le^~R&de,ke=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+((R<<18|x>>>14)^(R<<14|x>>>18)^(x<<23|R>>>9)),k=Ee+((x<<18|R>>>14)^(x<<14|R>>>18)^(R<<23|x>>>9))+(v>>>0>>0?1:0),v=v+ke,k=k+(Ae+(v>>>0>>0?1:0)),v=v+Pe,k=k+(yt+(v>>>0>>0?1:0)),v=v+r|0,k=k+(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=R,ee=x,x=Z+v|0,R=we+k+(x>>>0>>0?1:0)|0,we=Q,Z=H,Q=V,H=z,V=w,z=L,L=v+r|0,w=k+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+R+(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]=j+de+(fe>>>0>>0?1:0)|0,he=n[15]=he+re|0,n[14]=Re+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,j){i.push([d,_,C,j])>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=N(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=N([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 N(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 N(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 N(this.error)}mapErr(e){return N(e(this.error))}andThrough(e){return N(this.error)}andTee(e){return N(this.error)}andThen(e){return N(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 N(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 jt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");function ie(t){return jt.Decode(t)}var Nt=new $("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function _e(t){return Nt.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),e.chunksReady===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].send(r),M(void 0)):lt(t).andThen(()=>(b[t].onmessage=n=>Yt(n,e),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 7b98273..5d21d42 100644
--- a/themes/default/public/js/worker/download.js
+++ b/themes/default/public/js/worker/download.js
@@ -1 +1 @@
-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=Rr;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 Rt(this,e,r,!1)};g.prototype.on=g.prototype.addListener;g.prototype.prependListener=function(e,r){return Rt(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 kt(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,kt(this,e,r)),this};g.prototype.prependOnceListener=function(e,r){return ze(r),this.prependListener(e,kt(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,k=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