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