2 lines
64 KiB
JavaScript
Executable File
2 lines
64 KiB
JavaScript
Executable File
var Hr=Object.create;var $e=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Zr=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty;var Vr=(t,e,r)=>e in t?$e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Qr=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Jt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xr=(t,e)=>{for(var r in e)$e(t,r,{get:e[r],enumerable:!0})},Yr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Kr(e))!$r.call(t,i)&&i!==r&&$e(t,i,{get:()=>e[i],enumerable:!(n=qr(e,i))||n.enumerable});return t};var Et=(t,e,r)=>(r=t!=null?Hr(Zr(t)):{},Yr(e||!t||!t.__esModule?$e(r,"default",{value:t,enumerable:!0}):r,t));var d=(t,e,r)=>Vr(t,typeof e!="symbol"?e+"":e,r);var xt=Jt((Yn,At)=>{"use strict";var Oe=typeof Reflect=="object"?Reflect:null,Gt=Oe&&typeof Oe.apply=="function"?Oe.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Ve;Oe&&typeof Oe.ownKeys=="function"?Ve=Oe.ownKeys:Object.getOwnPropertySymbols?Ve=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ve=function(e){return Object.getOwnPropertyNames(e)};function en(t){console&&console.warn&&console.warn(t)}var Ht=Number.isNaN||function(e){return e!==e};function M(){M.init.call(this)}At.exports=M;At.exports.once=on;M.EventEmitter=M;M.prototype._events=void 0;M.prototype._eventsCount=0;M.prototype._maxListeners=void 0;var Wt=10;function Qe(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(M,"defaultMaxListeners",{enumerable:!0,get:function(){return Wt},set:function(t){if(typeof t!="number"||t<0||Ht(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Wt=t}});M.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};M.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ht(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function qt(t){return t._maxListeners===void 0?M.defaultMaxListeners:t._maxListeners}M.prototype.getMaxListeners=function(){return qt(this)};M.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")Gt(f,this,r);else for(var c=f.length,h=Qt(f,c),n=0;n<c;++n)Gt(h[n],this,r);return!0};function Kt(t,e,r,n){var i,o,s;if(Qe(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=qt(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,en(a)}return t}M.prototype.addListener=function(e,r){return Kt(this,e,r,!1)};M.prototype.on=M.prototype.addListener;M.prototype.prependListener=function(e,r){return Kt(this,e,r,!0)};function tn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Zt(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=tn.bind(n);return i.listener=r,n.wrapFn=i,i}M.prototype.once=function(e,r){return Qe(r),this.on(e,Zt(this,e,r)),this};M.prototype.prependOnceListener=function(e,r){return Qe(r),this.prependListener(e,Zt(this,e,r)),this};M.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Qe(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():rn(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};M.prototype.off=M.prototype.removeListener;M.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function $t(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?nn(i):Qt(i,i.length)}M.prototype.listeners=function(e){return $t(this,e,!0)};M.prototype.rawListeners=function(e){return $t(this,e,!1)};M.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Vt.call(t,e)};M.prototype.listenerCount=Vt;function Vt(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}M.prototype.eventNames=function(){return this._eventsCount>0?Ve(this._events):[]};function Qt(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function rn(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function nn(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function on(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Xt(t,e,o,{once:!0}),e!=="error"&&sn(t,i,{once:!0})})}function sn(t,e,r){typeof t.on=="function"&&Xt(t,"error",e,r)}function Xt(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var hr=Jt((Gi,Re)=>{"use strict";var u={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};u.cipher.aes=function(t){this.w[0][0][0]||this.C();var e,r,n,i,o=this.w[0][4],s=this.w[1];e=t.length;var a=1;if(e!==4&&e!==6&&e!==8)throw new u.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),i=[]],t=e;t<4*e+28;t++)r=n[t-1],(t%e===0||e===8&&t%e===4)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[r&255],t%e===0&&(r=r<<8^r>>>24^a<<24,a=a<<1^283*(a>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[e&3?t:t-4],i[e]=4>=t||4>e?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[r&255]]};u.cipher.aes.prototype={encrypt:function(t){return ur(this,t,0)},decrypt:function(t){return ur(this,t,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var t=this.w[0],e=this.w[1],r=t[4],n=e[4],i,o,s,a=[],f=[],c,h,l,p;for(i=0;256>i;i++)f[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=c||1,s=f[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,r[o]=l,n[l]=o,h=a[i=a[c=a[o]]],p=16843009*h^65537*i^257*c^16843008*o,h=257*a[l]^16843008*l,i=0;4>i;i++)t[i][o]=h=h<<24^h>>>8,e[i][l]=p=p<<24^p>>>8;for(i=0;5>i;i++)t[i]=t[i].slice(0),e[i]=e[i].slice(0)}};function ur(t,e,r){if(e.length!==4)throw new u.exception.invalid("invalid aes block size");var n=t.b[r],i=e[0]^n[0],o=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,f,c,h=n.length/4-2,l,p=4,v=[0,0,0,0];a=t.w[r],t=a[0];var A=a[1],E=a[2],y=a[3],b=a[4];for(l=0;l<h;l++)a=t[i>>>24]^A[o>>16&255]^E[s>>8&255]^y[e&255]^n[p],f=t[o>>>24]^A[s>>16&255]^E[e>>8&255]^y[i&255]^n[p+1],c=t[s>>>24]^A[e>>16&255]^E[i>>8&255]^y[o&255]^n[p+2],e=t[e>>>24]^A[i>>16&255]^E[o>>8&255]^y[s&255]^n[p+3],p+=4,i=a,o=f,s=c;for(l=0;4>l;l++)v[r?3&-l:l]=b[i>>>24]<<24^b[o>>16&255]<<16^b[s>>8&255]<<8^b[e&255]^n[p++],a=i,i=o,o=s,s=e,e=a;return v}u.bitArray={bitSlice:function(t,e,r){return t=u.bitArray.Y(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:u.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return((e+r-1^e)&-32?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<<r)-1},concat:function(t,e){if(t.length===0||e.length===0)return t.concat(e);var r=t[t.length-1],n=u.bitArray.getPartial(r);return n===32?t.concat(e):u.bitArray.Y(e,n,r|0,t.slice(0,t.length-1))},bitLength:function(t){var e=t.length;return e===0?0:32*(e-1)+u.bitArray.getPartial(t[e-1])},clamp:function(t,e){if(32*t.length<e)return t;t=t.slice(0,Math.ceil(e/32));var r=t.length;return e=e&31,0<r&&e&&(t[r-1]=u.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return t===32?e:(r?e|0:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(u.bitArray.bitLength(t)!==u.bitArray.bitLength(e))return!1;var r=0,n;for(n=0;n<t.length;n++)r|=t[n]^e[n];return r===0},Y:function(t,e,r,n){var i;for(i=0,n===void 0&&(n=[]);32<=e;e-=32)n.push(r),r=0;if(e===0)return n.concat(t);for(i=0;i<t.length;i++)n.push(r|t[i]>>>e),r=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=u.bitArray.getPartial(i),n.push(u.bitArray.partial(e+t&31,32<e+t?r:n.pop(),1)),n},P:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,r;for(e=0;e<t.length;++e)r=t[e],t[e]=r>>>24|r>>>8&65280|(r&65280)<<8|r<<24;return t}};u.codec.utf8String={fromBits:function(t){var e="",r=u.bitArray.bitLength(t),n,i;for(n=0;n<r/8;n++)!(n&3)&&(i=t[n/4]),e+=String.fromCharCode(i>>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(e))},toBits:function(t){t=unescape(encodeURIComponent(t));var e=[],r,n=0;for(r=0;r<t.length;r++)n=n<<8|t.charCodeAt(r),(r&3)===3&&(e.push(n),n=0);return r&3&&e.push(u.bitArray.partial(8*(r&3),n)),e}};u.codec.hex={fromBits:function(t){var e="",r;for(r=0;r<t.length;r++)e+=((t[r]|0)+0xf00000000000).toString(16).substr(4);return e.substr(0,u.bitArray.bitLength(t)/4)},toBits:function(t){var e,r=[],n;for(t=t.replace(/\s|0x/g,""),n=t.length,t=t+"00000000",e=0;e<t.length;e+=8)r.push(parseInt(t.substr(e,8),16)^0);return u.bitArray.clamp(r,4*n)}};u.codec.base64={S:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,r){var n="",i=0,o=u.codec.base64.S,s=0,a=u.bitArray.bitLength(t);for(r&&(o=o.substr(0,62)+"-_"),r=0;6*n.length<a;)n+=o.charAt((s^t[r]>>>i)>>>26),6>i?(s=t[r]<<6-i,i+=26,r++):(s<<=6,i-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r=[],n,i=0,o=u.codec.base64.S,s=0,a;for(e&&(o=o.substr(0,62)+"-_"),n=0;n<t.length;n++){if(a=o.indexOf(t.charAt(n)),0>a)throw new u.exception.invalid("this isn't base64!");26<i?(i-=26,r.push(s^a>>>i),s=a<<32-i):(i+=6,s^=a<<32-i)}return i&56&&r.push(u.bitArray.partial(i&56,s,1)),r}};u.codec.base64url={fromBits:function(t){return u.codec.base64.fromBits(t,1,1)},toBits:function(t){return u.codec.base64.toBits(t,1)}};u.hash.sha256=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};u.hash.sha256.hash=function(t){return new u.hash.sha256().update(t).finalize()};u.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=u.codec.utf8String.toBits(t));var e,r=this.f=u.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+u.bitArray.bitLength(t),9007199254740991<t)throw new u.exception.invalid("Cannot hash more than 2^53 - 1 bits");if(typeof Uint32Array<"u"){var n=new Uint32Array(r),i=0;for(e=512+e-(512+e&511);e<=t;e+=512)this.l(n.subarray(16*i,16*(i+1))),i+=1;r.splice(0,16*i)}else for(e=512+e-(512+e&511);e<=t;e+=512)this.l(r.splice(0,16));return this},finalize:function(){var t,r=this.f,e=this.g,r=u.bitArray.concat(r,[u.bitArray.partial(1,1)]);for(t=r.length+2;t&15;t++)r.push(0);for(r.push(Math.floor(this.c/4294967296)),r.push(this.c|0);r.length;)this.l(r.splice(0,16));return this.reset(),e},o:[],b:[],C:function(){function t(o){return 4294967296*(o-Math.floor(o))|0}for(var e=0,r=2,n,i;64>e;r++){for(i=!0,n=2;n*n<=r;n++)if(r%n===0){i=!1;break}i&&(8>e&&(this.o[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}},l:function(t){var e,r,n,i=this.g,o=this.b,s=i[0],a=i[1],f=i[2],c=i[3],h=i[4],l=i[5],p=i[6],v=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[e&15]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[e&15]+t[e+9&15]|0),r=r+v+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(p^h&(l^p))+o[e],v=p,p=l,l=h,h=c+r|0,c=f,f=a,a=s,s=r+(a&f^c&(a^f))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+f|0,i[3]=i[3]+c|0,i[4]=i[4]+h|0,i[5]=i[5]+l|0,i[6]=i[6]+p|0,i[7]=i[7]+v|0}};u.hash.sha512=function(t){this.b[0]||this.C(),t?(this.g=t.g.slice(0),this.f=t.f.slice(0),this.c=t.c):this.reset()};u.hash.sha512.hash=function(t){return new u.hash.sha512().update(t).finalize()};u.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(t){typeof t=="string"&&(t=u.codec.utf8String.toBits(t));var e,r=this.f=u.bitArray.concat(this.f,t);if(e=this.c,t=this.c=e+u.bitArray.bitLength(t),9007199254740991<t)throw new u.exception.invalid("Cannot hash more than 2^53 - 1 bits");if(typeof Uint32Array<"u"){var n=new Uint32Array(r),i=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.l(n.subarray(32*i,32*(i+1))),i+=1;r.splice(0,32*i)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.l(r.splice(0,32));return this},finalize:function(){var t,r=this.f,e=this.g,r=u.bitArray.concat(r,[u.bitArray.partial(1,1)]);for(t=r.length+4;t&31;t++)r.push(0);for(r.push(0),r.push(0),r.push(Math.floor(this.c/4294967296)),r.push(this.c|0);r.length;)this.l(r.splice(0,32));return this.reset(),e},o:[],ia:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ka:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],C:function(){function t(s){return 4294967296*(s-Math.floor(s))|0}function e(s){return 1099511627776*(s-Math.floor(s))&255}for(var r=0,n=2,i,o;80>r;n++){for(o=!0,i=2;i*i<=n;i++)if(n%i===0){o=!1;break}o&&(8>r&&(this.o[2*r]=t(Math.pow(n,.5)),this.o[2*r+1]=e(Math.pow(n,.5))<<24|this.ia[r]),this.b[2*r]=t(Math.pow(n,1/3)),this.b[2*r+1]=e(Math.pow(n,1/3))<<24|this.ka[r],r++)}},l:function(t){var e,r,n=this.g,i=this.b,o=n[0],s=n[1],a=n[2],f=n[3],c=n[4],h=n[5],l=n[6],p=n[7],v=n[8],A=n[9],E=n[10],y=n[11],b=n[12],I=n[13],O=n[14],w=n[15],x;if(typeof Uint32Array<"u"){x=Array(160);for(var L=0;32>L;L++)x[L]=t[L]}else x=t;var L=o,D=s,g=a,m=f,k=c,C=h,F=l,V=p,P=v,S=A,_=E,R=y,K=b,G=I,me=O,Z=w;for(t=0;80>t;t++){if(16>t)e=x[2*t],r=x[2*t+1];else{r=x[2*(t-15)];var z=x[2*(t-15)+1];e=(z<<31|r>>>1)^(z<<24|r>>>8)^r>>>7;var Q=(r<<31|z>>>1)^(r<<24|z>>>8)^(r<<25|z>>>7);r=x[2*(t-2)];var N=x[2*(t-2)+1],z=(N<<13|r>>>19)^(r<<3|N>>>29)^r>>>6,N=(r<<13|N>>>19)^(N<<3|r>>>29)^(r<<26|N>>>6),re=x[2*(t-7)],te=x[2*(t-16)],ne=x[2*(t-16)+1];r=Q+x[2*(t-7)+1],e=e+re+(r>>>0<Q>>>0?1:0),r+=N,e+=z+(r>>>0<N>>>0?1:0),r+=ne,e+=te+(r>>>0<ne>>>0?1:0)}x[2*t]=e|=0,x[2*t+1]=r|=0;var re=P&_^~P&K,Y=S&R^~S&G,N=L&g^L&k^g&k,j=D&m^D&C^m&C,te=(D<<4|L>>>28)^(L<<30|D>>>2)^(L<<25|D>>>7),ne=(L<<4|D>>>28)^(D<<30|L>>>2)^(D<<25|L>>>7),ge=i[2*t],Le=i[2*t+1],z=Z+((P<<18|S>>>14)^(P<<14|S>>>18)^(S<<23|P>>>9)),Q=me+((S<<18|P>>>14)^(S<<14|P>>>18)^(P<<23|S>>>9))+(z>>>0<Z>>>0?1:0),z=z+Y,Q=Q+(re+(z>>>0<Y>>>0?1:0)),z=z+Le,Q=Q+(ge+(z>>>0<Le>>>0?1:0)),z=z+r|0,Q=Q+(e+(z>>>0<r>>>0?1:0));r=ne+j,e=te+N+(r>>>0<ne>>>0?1:0),me=K,Z=G,K=_,G=R,_=P,R=S,S=V+z|0,P=F+Q+(S>>>0<V>>>0?1:0)|0,F=k,V=C,k=g,C=m,g=L,m=D,D=z+r|0,L=Q+e+(D>>>0<z>>>0?1:0)|0}s=n[1]=s+D|0,n[0]=o+L+(s>>>0<D>>>0?1:0)|0,f=n[3]=f+m|0,n[2]=a+g+(f>>>0<m>>>0?1:0)|0,h=n[5]=h+C|0,n[4]=c+k+(h>>>0<C>>>0?1:0)|0,p=n[7]=p+V|0,n[6]=l+F+(p>>>0<V>>>0?1:0)|0,A=n[9]=A+S|0,n[8]=v+P+(A>>>0<S>>>0?1:0)|0,y=n[11]=y+R|0,n[10]=E+_+(y>>>0<R>>>0?1:0)|0,I=n[13]=I+G|0,n[12]=b+K+(I>>>0<G>>>0?1:0)|0,w=n[15]=w+Z|0,n[14]=O+me+(w>>>0<Z>>>0?1:0)|0}};u.mode.ccm={name:"ccm",F:[],listenProgress:function(t){u.mode.ccm.F.push(t)},unListenProgress:function(t){t=u.mode.ccm.F.indexOf(t),-1<t&&u.mode.ccm.F.splice(t,1)},da:function(t){var e=u.mode.ccm.F.slice(),r;for(r=0;r<e.length;r+=1)e[r](t)},encrypt:function(t,e,r,n,i){var o,s=e.slice(0),a=u.bitArray,f=a.bitLength(r)/8,c=a.bitLength(s)/8;if(i=i||64,n=n||[],7>f)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&c>>>8*o;o++);return o<15-f&&(o=15-f),r=a.clamp(r,8*(15-o)),e=u.mode.ccm.U(t,e,r,n,i,o),s=u.mode.ccm.V(t,s,r,e,i,o),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o=u.bitArray,s=o.bitLength(r)/8,c=o.bitLength(e),a=o.clamp(e,c-i),f=o.bitSlice(e,c-i),c=(c-i)/8;if(7>s)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&c>>>8*e;e++);if(e<15-s&&(e=15-s),r=o.clamp(r,8*(15-e)),a=u.mode.ccm.V(t,a,r,f,i,e),t=u.mode.ccm.U(t,a.data,r,n,i,e),!o.equal(a.tag,t))throw new u.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(t,e,r,n,i,o){var s=[],a=u.bitArray,f=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|o-1)],n=a.concat(n,r),n[3]|=i,n=t.encrypt(n),e.length)for(r=a.bitLength(e)/8,65279>=r?s=[a.partial(16,r)]:4294967295>=r&&(s=a.concat([a.partial(16,65534)],[r])),s=a.concat(s,e),e=0;e<s.length;e+=4)n=t.encrypt(f(n,s.slice(e,e+4).concat([0,0,0])));return n},U:function(t,e,r,n,i,o){var s=u.bitArray,a=s.P;if(i/=8,i%2||4>i||16<i)throw new u.exception.invalid("ccm: invalid tag length");if(4294967295<n.length||4294967295<e.length)throw new u.exception.bug("ccm: can't deal with 4GiB or more data");for(r=u.mode.ccm.ma(t,n,r,i,s.bitLength(e)/8,o),n=0;n<e.length;n+=4)r=t.encrypt(a(r,e.slice(n,n+4).concat([0,0,0])));return s.clamp(r,8*i)},V:function(t,e,r,n,i,o){var s,a=u.bitArray;s=a.P;var f=e.length,c=a.bitLength(e),h=f/50,l=h;if(r=a.concat([a.partial(8,o-1)],r).concat([0,0,0]).slice(0,4),n=a.bitSlice(s(n,t.encrypt(r)),0,i),!f)return{tag:n,data:[]};for(s=0;s<f;s+=4)s>h&&(u.mode.ccm.da(s/f),h+=l),r[3]++,i=t.encrypt(r),e[s]^=i[0],e[s+1]^=i[1],e[s+2]^=i[2],e[s+3]^=i[3];return{tag:n,data:a.clamp(e,c)}}};u.misc.hmac=function(t,e){this.W=e=e||u.hash.sha256;var r=[[],[]],n,i=e.prototype.blockSize/32;for(this.B=[new e,new e],t.length>i&&(t=e.hash(t)),n=0;n<i;n++)r[0][n]=t[n]^909522486,r[1][n]=t[n]^1549556828;this.B[0].update(r[0]),this.B[1].update(r[1]),this.O=new e(this.B[0])};u.misc.hmac.prototype.encrypt=u.misc.hmac.prototype.mac=function(t){if(this.Z)throw new u.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)};u.misc.hmac.prototype.reset=function(){this.O=new this.W(this.B[0]),this.Z=!1};u.misc.hmac.prototype.update=function(t){this.Z=!0,this.O.update(t)};u.misc.hmac.prototype.digest=function(){var t=this.O.finalize(),t=new this.W(this.B[1]).update(t).finalize();return this.reset(),t};u.misc.pbkdf2=function(t,e,r,n,i){if(r=r||1e4,0>n||0>r)throw new u.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=u.codec.utf8String.toBits(t)),typeof e=="string"&&(e=u.codec.utf8String.toBits(e)),i=i||u.misc.hmac,t=new i(t);var o,s,a,f,c=[],h=u.bitArray;for(f=1;32*c.length<(n||1);f++){for(i=o=t.encrypt(h.concat(e,[f])),s=1;s<r;s++)for(o=t.encrypt(o),a=0;a<o.length;a++)i[a]^=o[a];c=c.concat(i)}return n&&(c=h.clamp(c,n)),c};u.prng=function(t){this.h=[new u.hash.sha256],this.s=[0],this.N=0,this.G={},this.M=0,this.T={},this.X=this.i=this.u=this.fa=0,this.b=[0,0,0,0,0,0,0,0],this.m=[0,0,0,0],this.K=void 0,this.L=t,this.D=!1,this.J={progress:{},seeded:{}},this.A=this.ea=0,this.H=1,this.I=2,this.aa=65536,this.R=[0,48,64,96,128,192,256,384,512,768,1024],this.ba=3e4,this.$=80};u.prng.prototype={randomWords:function(t,e){var r=[],n;n=this.isReady(e);var i;if(n===this.A)throw new u.exception.notReady("generator isn't seeded");if(n&this.I){n=!(n&this.H),i=[];var o=0,s;for(this.X=i[0]=new Date().valueOf()+this.ba,s=0;16>s;s++)i.push(4294967296*Math.random()|0);for(s=0;s<this.h.length&&(i=i.concat(this.h[s].finalize()),o+=this.s[s],this.s[s]=0,n||!(this.N&1<<s));s++);for(this.N>=1<<this.h.length&&(this.h.push(new u.hash.sha256),this.s.push(0)),this.i-=o,o>this.u&&(this.u=o),this.N++,this.b=u.hash.sha256.hash(this.b.concat(i)),this.K=new u.cipher.aes(this.b),n=0;4>n&&(this.m[n]=this.m[n]+1|0,!this.m[n]);n++);}for(n=0;n<t;n+=4)(n+1)%this.aa===0&&cr(this),i=Ot(this),r.push(i[0],i[1],i[2],i[3]);return cr(this),r.slice(0,t)},setDefaultParanoia:function(t,e){if(t===0&&e!=="Setting paranoia=0 will ruin your security; use it only for testing")throw new u.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.L=t},addEntropy:function(t,e,r){r=r||"user";var n,i,o=new Date().valueOf(),s=this.G[r],a=this.isReady(),f=0;switch(n=this.T[r],n===void 0&&(n=this.T[r]=this.fa++),s===void 0&&(s=this.G[r]=0),this.G[r]=(this.G[r]+1)%this.h.length,typeof t){case"number":e===void 0&&(e=1),this.h[s].update([n,this.M++,1,e,o,1,t|0]);break;case"object":if(r=Object.prototype.toString.call(t),r==="[object Uint32Array]"){for(i=[],r=0;r<t.length;r++)i.push(t[r]);t=i}else for(r!=="[object Array]"&&(f=1),r=0;r<t.length&&!f;r++)typeof t[r]!="number"&&(f=1);if(!f){if(e===void 0)for(r=e=0;r<t.length;r++)for(i=t[r];0<i;)e++,i=i>>>1;this.h[s].update([n,this.M++,2,e,o,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.h[s].update([n,this.M++,3,e,o,t.length]),this.h[s].update(t);break;default:f=1}if(f)throw new u.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=e,this.i+=e,a===this.A&&(this.isReady()!==this.A&&fr("seeded",Math.max(this.u,this.i)),fr("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:je(this,this.la),mouseCollector:je(this,this.na),keyboardCollector:je(this,this.ja),accelerometerCollector:je(this,this.ca),touchCollector:je(this,this.pa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new u.exception.bug("can't attach event");this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.J[t][this.ea++]=e},removeEventListener:function(t,e){var r,n,i=this.J[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r<o.length;r++)n=o[r],delete i[n]},ja:function(){Ne(this,1)},na:function(t){var e,r;try{e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0}catch{r=e=0}e!=0&&r!=0&&this.addEntropy([e,r],2,"mouse"),Ne(this,0)},pa:function(t){t=t.touches[0]||t.changedTouches[0],this.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),Ne(this,0)},la:function(){Ne(this,2)},ca:function(t){if(t=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;typeof e=="number"&&this.addEntropy(e,1,"accelerometer")}t&&this.addEntropy(t,2,"accelerometer"),Ne(this,0)}};function fr(t,e){var r,n=u.random.J[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;r<i.length;r++)i[r](e)}function Ne(t,e){typeof window<"u"&&window.performance&&typeof window.performance.now=="function"?t.addEntropy(window.performance.now(),e,"loadtime"):t.addEntropy(new Date().valueOf(),e,"loadtime")}function cr(t){t.b=Ot(t).concat(Ot(t)),t.K=new u.cipher.aes(t.b)}function Ot(t){for(var e=0;4>e&&(t.m[e]=t.m[e]+1|0,!t.m[e]);e++);return t.K.encrypt(t.m)}function je(t,e){return function(){e.apply(t,arguments)}}u.random=new u.prng(6);e:try{if(tt=typeof Re<"u"&&Re.exports){try{rt=Qr("crypto")}catch{rt=null}tt=et=rt}if(tt&&et.randomBytes)Je=et.randomBytes(128),Je=new Uint32Array(new Uint8Array(Je).buffer),u.random.addEntropy(Je,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Ge=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Ge);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Ge);else break e;u.random.addEntropy(Ge,1024,"crypto['getRandomValues']")}}catch(t){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}var Je,et,Ge,tt,rt;u.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(t,e,r,n){r=r||{},n=n||{};var i=u.json,o=i.j({iv:u.random.randomWords(4,0)},i.defaults),s;if(i.j(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=u.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=u.codec.base64.toBits(o.iv)),!u.mode[o.mode]||!u.cipher[o.cipher]||typeof t=="string"&&100>=o.iter||o.ts!==64&&o.ts!==96&&o.ts!==128||o.ks!==128&&o.ks!==192&&o.ks!==256||2>o.iv.length||4<o.iv.length)throw new u.exception.invalid("json encrypt: invalid parameters");return typeof t=="string"?(s=u.misc.cachedPbkdf2(t,o),t=s.key.slice(0,o.ks/32),o.salt=s.salt):u.ecc&&t instanceof u.ecc.elGamal.publicKey&&(s=t.kem(),o.kemtag=s.tag,t=s.key.slice(0,o.ks/32)),typeof e=="string"&&(e=u.codec.utf8String.toBits(e)),typeof r=="string"&&(o.adata=r=u.codec.utf8String.toBits(r)),s=new u.cipher[o.cipher](t),i.j(n,o),n.key=t,o.ct=o.mode==="ccm"&&u.arrayBuffer&&u.arrayBuffer.ccm&&e instanceof ArrayBuffer?u.arrayBuffer.ccm.encrypt(s,e,o.iv,r,o.ts):u.mode[o.mode].encrypt(s,e,o.iv,r,o.ts),o},encrypt:function(t,e,r,n){var i=u.json,o=i.ha.apply(i,arguments);return i.encode(o)},ga:function(t,e,r,n){r=r||{},n=n||{};var i=u.json;e=i.j(i.j(i.j({},i.defaults),e),r,!0);var o,s;if(o=e.adata,typeof e.salt=="string"&&(e.salt=u.codec.base64.toBits(e.salt)),typeof e.iv=="string"&&(e.iv=u.codec.base64.toBits(e.iv)),!u.mode[e.mode]||!u.cipher[e.cipher]||typeof t=="string"&&100>=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<e.iv.length)throw new u.exception.invalid("json decrypt: invalid parameters");return typeof t=="string"?(s=u.misc.cachedPbkdf2(t,e),t=s.key.slice(0,e.ks/32),e.salt=s.salt):u.ecc&&t instanceof u.ecc.elGamal.secretKey&&(t=t.unkem(u.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),typeof o=="string"&&(o=u.codec.utf8String.toBits(o)),s=new u.cipher[e.cipher](t),o=e.mode==="ccm"&&u.arrayBuffer&&u.arrayBuffer.ccm&&e.ct instanceof ArrayBuffer?u.arrayBuffer.ccm.decrypt(s,e.ct,e.iv,e.tag,o,e.ts):u.mode[e.mode].decrypt(s,e.ct,e.iv,o,e.ts),i.j(n,e),n.key=t,r.raw===1?o:u.codec.utf8String.fromBits(o)},decrypt:function(t,e,r,n){var i=u.json;return i.ga(t,i.decode(e),r,n)},encode:function(t){var e,r="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new u.exception.invalid("json encode: invalid property name");switch(r+=n+'"'+e+'":',n=",",typeof t[e]){case"number":case"boolean":r+=t[e];break;case"string":r+='"'+escape(t[e])+'"';break;case"object":r+='"'+u.codec.base64.fromBits(t[e],0)+'"';break;default:throw new u.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(t=t.replace(/\s/g,""),!t.match(/^\{.*\}$/))throw new u.exception.invalid("json decode: this isn't json!");t=t.replace(/^\{|\}$/g,"").split(/,/);var e={},r,n;for(r=0;r<t.length;r++){if(!(n=t[r].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new u.exception.invalid("json decode: this isn't json!");n[3]!=null?e[n[2]]=parseInt(n[3],10):n[4]!=null?e[n[2]]=n[2].match(/^(ct|adata|salt|iv)$/)?u.codec.base64.toBits(n[4]):unescape(n[4]):n[5]!=null&&(e[n[2]]=n[5]==="true")}return e},j:function(t,e,r){if(t===void 0&&(t={}),e===void 0)return t;for(var n in e)if(e.hasOwnProperty(n)){if(r&&t[n]!==void 0&&t[n]!==e[n])throw new u.exception.invalid("required parameter overridden");t[n]=e[n]}return t},ra:function(t,e){var r={},n;for(n in t)t.hasOwnProperty(n)&&t[n]!==e[n]&&(r[n]=t[n]);return r},qa:function(t,e){var r={},n;for(n=0;n<e.length;n++)t[e[n]]!==void 0&&(r[e[n]]=t[e[n]]);return r}};u.encrypt=u.json.encrypt;u.decrypt=u.json.decrypt;u.misc.oa={};u.misc.cachedPbkdf2=function(t,e){var r=u.misc.oa,n;return e=e||{},n=e.iter||1e3,r=r[t]=r[t]||{},n=r[n]=r[n]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):u.random.randomWords(2,0)},r=e.salt===void 0?n.firstSalt:e.salt,n[r]=n[r]||u.misc.pbkdf2(t,r,e.iter),{key:n[r].slice(0),salt:r.slice(0)}};typeof Re<"u"&&Re.exports&&(Re.exports=u);typeof define=="function"&&define([],function(){return u})});var jt={};Xr(jt,{addFilesToArchive:()=>jr,cancel:()=>jn,compress:()=>Jr,decompress:()=>Jn,download:()=>Gn,events:()=>gt,getFileIndexInQueue:()=>Qn,infos:()=>Wn,pause:()=>Hn,remove:()=>qn,resume:()=>Kn,upload:()=>$n});var Nr=Et(xt());var an={withStackTrace:!1},tr=(t,e,r=an)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},i=r.withStackTrace?new Error().stack:void 0;return{data:n,message:t,stack:i}};function Ce(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{c(n.next(h))}catch(l){s(l)}}function f(h){try{c(n.throw(h))}catch(l){s(l)}}function c(h){h.done?o(h.value):i(h.value).then(a,f)}c((n=n.apply(t,e||[])).next())})}function Yt(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(t){return this instanceof he?(this.v=t,this):new he(t)}function er(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(v){return function(A){return Promise.resolve(A).then(v,l)}}function a(v,A){n[v]&&(i[v]=function(E){return new Promise(function(y,b){o.push([v,E,y,b])>1||f(v,E)})},A&&(i[v]=A(i[v])))}function f(v,A){try{c(n[v](A))}catch(E){p(o[0][3],E)}}function c(v){v.value instanceof he?Promise.resolve(v.value.v).then(h,l):p(o[0][2],v)}function h(v){f("next",v)}function l(v){f("throw",v)}function p(v,A){v(A),o.shift(),o.length&&f(o[0][0],o[0][1])}}function un(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,o){e[i]=t[i]?function(s){return(r=!r)?{value:he(t[i](s)),done:!1}:o?o(s):s}:o}}function fn(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 Yt=="function"?Yt(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(a,f){s=t[o](s),i(a,f,s.done,s.value)})}}function i(o,s,a,f){Promise.resolve(f).then(function(c){o({value:c,done:a})},s)}}var U=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new ie(n));return new t(r)}static fromPromise(e,r){let n=e.then(i=>new ie(i)).catch(i=>new oe(r(i)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(Ce(this,void 0,void 0,function*(){try{return new ie(yield e(...n))}catch(i){return new oe(r?r(i):i)}}))}static combine(e){return cn(e)}static combineWithAllErrors(e){return hn(e)}map(e){return new t(this._promise.then(r=>Ce(this,void 0,void 0,function*(){return r.isErr()?new oe(r.error):new ie(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>Ce(this,void 0,void 0,function*(){if(r.isErr())return new oe(r.error);let n=yield e(r.value);return n.isErr()?new oe(n.error):new ie(r.value)})))}andTee(e){return new t(this._promise.then(r=>Ce(this,void 0,void 0,function*(){if(r.isErr())return new oe(r.error);try{yield e(r.value)}catch{}return new ie(r.value)})))}mapErr(e){return new t(this._promise.then(r=>Ce(this,void 0,void 0,function*(){return r.isOk()?new ie(r.value):new oe(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new oe(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>Ce(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new ie(r.value)})))}match(e,r){return this._promise.then(n=>n.match(e,r))}unwrapOr(e){return this._promise.then(r=>r.unwrapOr(e))}safeUnwrap(){return er(this,arguments,function*(){return yield he(yield he(yield*un(fn(yield he(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}[Symbol.asyncIterator](){return er(this,arguments,function*(){let r=yield he(this._promise);return r.isErr()&&(yield yield he(W(r.error))),yield he(r.value)})}},H=t=>new U(Promise.resolve(new ie(t))),W=t=>new U(Promise.resolve(new oe(t))),ei=U.fromPromise,ti=U.fromSafePromise,ri=U.fromThrowable,rr=t=>{let e=we([]);for(let r of t)if(r.isErr()){e=le(r.error);break}else e.map(n=>n.push(r.value));return e},cn=t=>U.fromSafePromise(Promise.all(t)).andThen(rr),nr=t=>{let e=we([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=le([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},hn=t=>U.fromSafePromise(Promise.all(t)).andThen(nr),Lt;(function(t){function e(i,o){return(...s)=>{try{let a=i(...s);return we(a)}catch(a){return le(o?o(a):a)}}}t.fromThrowable=e;function r(i){return rr(i)}t.combine=r;function n(i){return nr(i)}t.combineWithAllErrors=n})(Lt||(Lt={}));var we=t=>new ie(t);function le(t){return new oe(t)}var ie=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return we(e(this.value))}mapErr(e){return we(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 we(this.value)}orElse(e){return we(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return U.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 tr("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},oe=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return le(this.error)}mapErr(e){return le(e(this.error))}andThrough(e){return le(this.error)}andTee(e){return le(this.error)}andThen(e){return le(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return W(this.error)}asyncAndThrough(e){return W(this.error)}asyncMap(e){return W(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield le(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw tr("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},ni=Lt.fromThrowable;var Ee=class t{constructor(e,r){d(this,"actionToken","");d(this,"chunksReady",0);d(this,"createdAt",0);d(this,"delay",0);d(this,"delAtFirstView",!1);d(this,"keys",{client:"",server:""});d(this,"name","");d(this,"password","");d(this,"queueIndex",0);d(this,"serverUrl");d(this,"size",0);d(this,"uploadStatus",3);d(this,"totalChunks",0);d(this,"type","");d(this,"zipped",!1);this.serverUrl=e,Object.assign(this,r)}downloadUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}r/${this.keys.server}#${this.keys.client}`)}removeUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}d/${this.keys.server}/${this.actionToken}`)}static fromDownloadUrl(e,r=""){let n=e.pathname.split("r/"),i={client:e.hash.slice(1).split("&")[0],server:n[1]};return new t(e.origin+n[0],{keys:i,password:r})}static fromRemoveUrl(e,r=""){let n=e.pathname.split("d/"),i=n[1].split("/"),o={client:"",server:i[0]};return new t(e.origin+n[0],{keys:o,password:r,actionToken:i[1]})}};var ar=Et(xt());var $=class extends Error{constructor(r,n={}){let{cause:i,context:o}=n;super(r,{cause:i});d(this,"context");this.name=this.constructor.name,this.context=o}};var Xe=class extends ${constructor(){super(...arguments);d(this,"message","Unable to connect. Is the computer able to access the url?")}};var Ye=class extends ${constructor(){super(...arguments);d(this,"message","The server returned an error")}};var J=t=>{if(t instanceof Error)return t;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(t)}catch{}return new Error(e)},or=t=>{let e=t.href.match(/(.*?)\/?(?:\/[dr]{1}\/|login\/?|files\/?)/),r=e&&e[1]?e[1]:t.origin;return U.fromPromise(fetch(r+"/about/config"),n=>new Xe(void 0,{cause:J(n)})).andThen(n=>n.ok?U.fromPromise(n.json(),i=>J(i)):W(new Ye(void 0,{context:n.statusText})))},sr=()=>typeof Deno<"u",Dt=()=>sr()||globalThis.isSecureContext||globalThis.location.protocol==="https:",Se=t=>sr()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t!=="encrypt"?`worker/${t}`:t}.js`));var Ae=class{constructor(e,r){d(this,"events",new ar.default);d(this,"lufiFile");d(this,"status",2);d(this,"downloadedFile");d(this,"worker");d(this,"isTerminated",!1);d(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});d(this,"hasFailed",()=>this.status===1);d(this,"onError",e=>(this.worker.onerror=r=>{e(r)},this));d(this,"onMessage",e=>(this.worker.onmessage=r=>{e&&e(r);let n=r.data.event;n&&(n==="FILE_UPDATED"?Object.assign(this.lufiFile,r.data.lufiFile):this.dispatchEvent(n,r.data.error))},this));d(this,"onMessageError",e=>(this.worker.onmessageerror=r=>{e(r)},this));d(this,"onProgress",e=>(this.events.on("CHUNK_UPLOADED",()=>{e()}),this.events.on("CHUNK_DOWNLOADED",()=>{e()}),this));d(this,"requestMessage",(e,r=[])=>(this.worker.postMessage(e,r),this));d(this,"terminate",()=>(this.worker.terminate(),this));d(this,"waitForCompletion",()=>this.isTerminated?this.status===0?H(this):W(J("Job has failed")):U.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>J(e)));d(this,"waitForStart",()=>U.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("UPLOAD_STARTED",()=>{e(this)}),this.events.once("DOWNLOAD_STARTED",()=>{e(this)})}),e=>J(e)));d(this,"dispatchEvent",(e,r)=>{this.events.emit(e,r)});switch(r){case 0:this.worker=new Worker(Se("cancel"),{type:"module"});break;case 1:this.worker=new Worker(Se("download"),{type:"module"});break;case 2:this.worker=new Worker(Se("infos"),{type:"module"});break;case 3:this.worker=new Worker(Se("remove"),{type:"module"});break;case 4:this.worker=new Worker(Se("upload"),{type:"module"});break}this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",n=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",n)}),this.onError(n=>console.error(n.error))}};var ke=(r=>(r[r.Sjcl=0]="Sjcl",r[r.WebCrypto=1]="WebCrypto",r))(ke||{});var Pe=class{constructor(e,r){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!r,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let r=e.byteLength;if(!r)return"";let n=new Uint8Array(e),i="";for(let o=0;o<r;o+=3)i+=this._charset[n[o]>>2]+this._charset[(n[o]&3)<<4|n[o+1]>>4]+this._charset[(n[o+1]&15)<<2|n[o+2]>>6]+this._charset[n[o+2]&63];return r%3==2?(i=i.substring(0,i.length-1),this._noPadding||(i+="=")):r%3==1&&(i=i.substring(0,i.length-2),this._noPadding||(i+="==")),i}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let r=Math.floor(e.length*.75);e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&r--;let n=new Uint8Array(r),i,o,s,a,f=0,c=0;for(;f<e.length*.75;)i=this._charset.indexOf(e.charAt(c++)),o=this._charset.indexOf(e.charAt(c++)),s=this._charset.indexOf(e.charAt(c++)),a=this._charset.indexOf(e.charAt(c++)),n[f++]=i<<2|o>>4,n[f++]=(o&15)<<4|s>>2,n[f++]=(s&3)<<6|a;return n.buffer}};var Fi=new Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var mn=new Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function bt(t){return mn.Encode(t)}var We=Et(hr());var ue=class extends ${};var Te=class extends ue{constructor(){super(...arguments);d(this,"message","Unable to hash the provided string")}};var lr=()=>{try{return H(We.default.codec.base64.fromBits(We.default.random.randomWords(8,10)))}catch(t){return W(new ue("Unable to generate key",{cause:J(t)}))}},pr=t=>{try{return H(We.default.codec.hex.fromBits(We.default.hash.sha512.hash(t)))}catch(e){return W(new Te(void 0,{cause:J(e)}))}};var vr=()=>U.fromPromise(new Promise((t,e)=>crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]).then(r=>crypto.subtle.exportKey("raw",r).then(n=>t(bt(n))).catch(n=>{e(new ue("Unable to base64 encode the url",{cause:J(n)}))})).catch(r=>e(r))),t=>new ue("Unable to generate key",{cause:J(t)})),mr=t=>{let e=async()=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-512",new TextEncoder().encode(t)))).map(r=>r.toString(16).padStart(2,"0")).join("");return U.fromPromise(e(),r=>new Te(void 0,{cause:J(r)}))};var dr=(t=1)=>t===0?lr():vr(),Ct=(t,e)=>e===0?pr(t):mr(t);var yr={},Dn=function(t,e,r,n,i){var o=new Worker(yr[e]||(yr[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(s){var a=s.data,f=a.$e$;if(f){var c=new Error(f[0]);c.code=f[1],c.stack=f[2],i(c,null)}else i(null,a)},o.postMessage(r,n),o},B=Uint8Array,ee=Uint16Array,Ke=Int32Array,Fe=new B([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ze=new B([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),He=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xr=function(t,e){for(var r=new ee(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];for(var i=new Ke(r[30]),n=1;n<30;++n)for(var o=r[n];o<r[n+1];++o)i[o]=o-r[n]<<5|n;return{b:r,r:i}},Lr=xr(Fe,2),It=Lr.b,at=Lr.r;It[28]=258,at[258]=28;var Dr=xr(ze,0),br=Dr.b,kt=Dr.r,qe=new ee(32768);for(T=0;T<32768;++T)de=(T&43690)>>1|(T&21845)<<1,de=(de&52428)>>2|(de&13107)<<2,de=(de&61680)>>4|(de&3855)<<4,qe[T]=((de&65280)>>8|(de&255)<<8)>>1;var de,T,ae=function(t,e,r){for(var n=t.length,i=0,o=new ee(e);i<n;++i)t[i]&&++o[t[i]-1];var s=new ee(e);for(i=1;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(r){a=new ee(1<<e);var f=15-e;for(i=0;i<n;++i)if(t[i])for(var c=i<<4|t[i],h=e-t[i],l=s[t[i]-1]++<<h,p=l|(1<<h)-1;l<=p;++l)a[qe[l]>>f]=c}else for(a=new ee(n),i=0;i<n;++i)t[i]&&(a[i]=qe[s[t[i]-1]++]>>15-t[i]);return a},ye=new B(288);for(T=0;T<144;++T)ye[T]=8;var T;for(T=144;T<256;++T)ye[T]=9;var T;for(T=256;T<280;++T)ye[T]=7;var T;for(T=280;T<288;++T)ye[T]=8;var T,Me=new B(32);for(T=0;T<32;++T)Me[T]=5;var T,Or=ae(ye,9,0),Cr=ae(ye,9,1),Sr=ae(Me,5,0),kr=ae(Me,5,1),it=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},se=function(t,e,r){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&r},ot=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},Ze=function(t){return(t+7)/8|0},De=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new B(t.subarray(e,r))};var Pr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],q=function(t,e,r){var n=new Error(e||Pr[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,q),!r)throw n;return n},Rr=function(t,e,r,n){var i=t.length,o=n?n.length:0;if(!i||e.f&&!e.l)return r||new B(0);var s=!r,a=s||e.i!=2,f=e.i;s&&(r=new B(i*3));var c=function(Q){var _e=r.length;if(Q>_e){var be=new B(Math.max(_e*2,Q));be.set(r),r=be}},h=e.f||0,l=e.p||0,p=e.b||0,v=e.l,A=e.d,E=e.m,y=e.n,b=i*8;do{if(!v){h=se(t,l,1);var I=se(t,l+1,3);if(l+=3,I)if(I==1)v=Cr,A=kr,E=9,y=5;else if(I==2){var L=se(t,l,31)+257,D=se(t,l+10,15)+4,g=L+se(t,l+5,31)+1;l+=14;for(var m=new B(g),k=new B(19),C=0;C<D;++C)k[He[C]]=se(t,l+C*3,7);l+=D*3;for(var F=it(k),V=(1<<F)-1,P=ae(k,F,1),C=0;C<g;){var S=P[se(t,l,V)];l+=S&15;var O=S>>4;if(O<16)m[C++]=O;else{var _=0,R=0;for(O==16?(R=3+se(t,l,3),l+=2,_=m[C-1]):O==17?(R=3+se(t,l,7),l+=3):O==18&&(R=11+se(t,l,127),l+=7);R--;)m[C++]=_}}var K=m.subarray(0,L),G=m.subarray(L);E=it(K),y=it(G),v=ae(K,E,1),A=ae(G,y,1)}else q(1);else{var O=Ze(l)+4,w=t[O-4]|t[O-3]<<8,x=O+w;if(x>i){f&&q(0);break}a&&c(p+w),r.set(t.subarray(O,x),p),e.b=p+=w,e.p=l=x*8,e.f=h;continue}if(l>b){f&&q(0);break}}a&&c(p+131072);for(var me=(1<<E)-1,Z=(1<<y)-1,re=l;;re=l){var _=v[ot(t,l)&me],Y=_>>4;if(l+=_&15,l>b){f&&q(0);break}if(_||q(2),Y<256)r[p++]=Y;else if(Y==256){re=l,v=null;break}else{var N=Y-254;if(Y>264){var C=Y-257,j=Fe[C];N=se(t,l,(1<<j)-1)+It[C],l+=j}var te=A[ot(t,l)&Z],ne=te>>4;te||q(3),l+=te&15;var G=br[ne];if(ne>3){var j=ze[ne];G+=ot(t,l)&(1<<j)-1,l+=j}if(l>b){f&&q(0);break}a&&c(p+131072);var ge=p+N;if(p<G){var Le=o-G,z=Math.min(G,ge);for(Le+p<0&&q(3);p<z;++p)r[p]=n[Le+p]}for(;p<ge;++p)r[p]=r[p-G]}}e.l=v,e.p=re,e.b=p,e.f=h,v&&(h=1,e.m=E,e.d=A,e.n=y)}while(!h);return p!=r.length&&s?De(r,0,p):r.subarray(0,p)},pe=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8},Ue=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8,t[n+2]|=r>>16},st=function(t,e){for(var r=[],n=0;n<t.length;++n)t[n]&&r.push({s:n,f:t[n]});var i=r.length,o=r.slice();if(!i)return{t:Ft,l:0};if(i==1){var s=new B(r[0].s+1);return s[r[0].s]=1,{t:s,l:1}}r.sort(function(x,L){return x.f-L.f}),r.push({s:-1,f:25001});var a=r[0],f=r[1],c=0,h=1,l=2;for(r[0]={s:-1,f:a.f+f.f,l:a,r:f};h!=i-1;)a=r[r[c].f<r[l].f?c++:l++],f=r[c!=h&&r[c].f<r[l].f?c++:l++],r[h++]={s:-1,f:a.f+f.f,l:a,r:f};for(var p=o[0].s,n=1;n<i;++n)o[n].s>p&&(p=o[n].s);var v=new ee(p+1),A=ut(r[h-1],v,0);if(A>e){var n=0,E=0,y=A-e,b=1<<y;for(o.sort(function(L,D){return v[D.s]-v[L.s]||L.f-D.f});n<i;++n){var I=o[n].s;if(v[I]>e)E+=b-(1<<A-v[I]),v[I]=e;else break}for(E>>=y;E>0;){var O=o[n].s;v[O]<e?E-=1<<e-v[O]++-1:++n}for(;n>=0&&E;--n){var w=o[n].s;v[w]==e&&(--v[w],++E)}A=e}return{t:new B(v),l:A}},ut=function(t,e,r){return t.s==-1?Math.max(ut(t.l,e,r+1),ut(t.r,e,r+1)):e[t.s]=r},Pt=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new ee(++e),n=0,i=t[0],o=1,s=function(f){r[n++]=f},a=1;a<=e;++a)if(t[a]==i&&a!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=t[a]}return{c:r.subarray(0,n),n:e}},Ie=function(t,e){for(var r=0,n=0;n<e.length;++n)r+=t[n]*e[n];return r},Mt=function(t,e,r){var n=r.length,i=Ze(e+2);t[i]=n&255,t[i+1]=n>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var o=0;o<n;++o)t[i+o+4]=r[o];return(i+4+n)*8},Rt=function(t,e,r,n,i,o,s,a,f,c,h){pe(e,h++,r),++i[256];for(var l=st(i,15),p=l.t,v=l.l,A=st(o,15),E=A.t,y=A.l,b=Pt(p),I=b.c,O=b.n,w=Pt(E),x=w.c,L=w.n,D=new ee(19),g=0;g<I.length;++g)++D[I[g]&31];for(var g=0;g<x.length;++g)++D[x[g]&31];for(var m=st(D,7),k=m.t,C=m.l,F=19;F>4&&!k[He[F-1]];--F);var V=c+5<<3,P=Ie(i,ye)+Ie(o,Me)+s,S=Ie(i,p)+Ie(o,E)+s+14+3*F+Ie(D,k)+2*D[16]+3*D[17]+7*D[18];if(f>=0&&V<=P&&V<=S)return Mt(e,h,t.subarray(f,f+c));var _,R,K,G;if(pe(e,h,1+(S<P)),h+=2,S<P){_=ae(p,v,0),R=p,K=ae(E,y,0),G=E;var me=ae(k,C,0);pe(e,h,O-257),pe(e,h+5,L-1),pe(e,h+10,F-4),h+=14;for(var g=0;g<F;++g)pe(e,h+3*g,k[He[g]]);h+=3*F;for(var Z=[I,x],re=0;re<2;++re)for(var Y=Z[re],g=0;g<Y.length;++g){var N=Y[g]&31;pe(e,h,me[N]),h+=k[N],N>15&&(pe(e,h,Y[g]>>5&127),h+=Y[g]>>12)}}else _=Or,R=ye,K=Sr,G=Me;for(var g=0;g<a;++g){var j=n[g];if(j>255){var N=j>>18&31;Ue(e,h,_[N+257]),h+=R[N+257],N>7&&(pe(e,h,j>>23&31),h+=Fe[N]);var te=j&31;Ue(e,h,K[te]),h+=G[te],te>3&&(Ue(e,h,j>>5&8191),h+=ze[te])}else Ue(e,h,_[j]),h+=R[j]}return Ue(e,h,_[256]),h+R[256]},Tr=new Ke([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ft=new B(0),Ur=function(t,e,r,n,i,o){var s=o.z||t.length,a=new B(n+s+5*(1+Math.ceil(s/7e3))+i),f=a.subarray(n,a.length-i),c=o.l,h=(o.r||0)&7;if(e){h&&(f[0]=o.r>>3);for(var l=Tr[e-1],p=l>>13,v=l&8191,A=(1<<r)-1,E=o.p||new ee(32768),y=o.h||new ee(A+1),b=Math.ceil(r/3),I=2*b,O=function(wt){return(t[wt]^t[wt+1]<<b^t[wt+2]<<I)&A},w=new Ke(25e3),x=new ee(288),L=new ee(32),D=0,g=0,m=o.i||0,k=0,C=o.w||0,F=0;m+2<s;++m){var V=O(m),P=m&32767,S=y[V];if(E[P]=S,y[V]=P,C<=m){var _=s-m;if((D>7e3||k>24576)&&(_>423||!c)){h=Rt(t,f,0,w,x,L,g,k,F,m-F,h),k=D=g=0,F=m;for(var R=0;R<286;++R)x[R]=0;for(var R=0;R<30;++R)L[R]=0}var K=2,G=0,me=v,Z=P-S&32767;if(_>2&&V==O(m-Z))for(var re=Math.min(p,_)-1,Y=Math.min(32767,m),N=Math.min(258,_);Z<=Y&&--me&&P!=S;){if(t[m+K]==t[m+K-Z]){for(var j=0;j<N&&t[m+j]==t[m+j-Z];++j);if(j>K){if(K=j,G=Z,j>re)break;for(var te=Math.min(Z,j-2),ne=0,R=0;R<te;++R){var ge=m-Z+R&32767,Le=E[ge],z=ge-Le&32767;z>ne&&(ne=z,S=ge)}}}P=S,S=E[P],Z+=P-S&32767}if(G){w[k++]=268435456|at[K]<<18|kt[G];var Q=at[K]&31,_e=kt[G]&31;g+=Fe[Q]+ze[_e],++x[257+Q],++L[_e],C=m+K,++D}else w[k++]=t[m],++x[t[m]]}}for(m=Math.max(m,C);m<s;++m)w[k++]=t[m],++x[t[m]];h=Rt(t,f,c,w,x,L,g,k,F,m-F,h),c||(o.r=h&7|f[h/8|0]<<3,h-=7,o.h=y,o.p=E,o.i=m,o.w=C)}else{for(var m=o.w||0;m<s+c;m+=65535){var be=m+65535;be>=s&&(f[h/8|0]=c,be=s),h=Mt(f,h+1,t.subarray(m,be))}o.i=s}return De(a,0,n+Ze(h)+i)},bn=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var r=e,n=9;--n;)r=(r&1&&-306674912)^r>>>1;t[e]=r}return t}(),On=function(){var t=-1;return{p:function(e){for(var r=t,n=0;n<e.length;++n)r=bn[r&255^e[n]]^r>>>8;t=r},d:function(){return~t}}};var Ir=function(t,e,r,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),s=new B(o.length+t.length);s.set(o),s.set(t,o.length),t=s,i.w=o.length}return Ur(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,r,n,i)},zt=function(t,e){var r={};for(var n in t)r[n]=t[n];for(var n in e)r[n]=e[n];return r},gr=function(t,e,r){for(var n=t(),i=t.toString(),o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<n.length;++s){var a=n[s],f=o[s];if(typeof a=="function"){e+=";"+f+"=";var c=a.toString();if(a.prototype)if(c.indexOf("[native code]")!=-1){var h=c.indexOf(" ",8)+1;e+=c.slice(h,c.indexOf("(",h))}else{e+=c;for(var l in a.prototype)e+=";"+f+".prototype."+l+"="+a.prototype[l].toString()}else e+=c}else r[f]=a}return e},nt=[],Cn=function(t){var e=[];for(var r in t)t[r].buffer&&e.push((t[r]=new t[r].constructor(t[r])).buffer);return e},Sn=function(t,e,r,n){if(!nt[r]){for(var i="",o={},s=t.length-1,a=0;a<s;++a)i=gr(t[a],i,o);nt[r]={c:gr(t[s],i,o),e:o}}var f=zt({},nt[r].e);return Dn(nt[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",r,f,Cn(f),n)},kn=function(){return[B,ee,Ke,Fe,ze,He,It,br,Cr,kr,qe,Pr,ae,it,se,ot,Ze,De,q,Rr,_t,ct,Mr]},Pn=function(){return[B,ee,Ke,Fe,ze,He,at,kt,Or,ye,Sr,Me,qe,Tr,Ft,ae,pe,Ue,st,ut,Pt,Ie,Mt,Rt,Ze,De,Ur,Ir,Bt,ct]};var ct=function(t){return postMessage(t,[t.buffer])},Mr=function(t){return t&&{out:t.size&&new B(t.size),dictionary:t.dictionary}},Fr=function(t,e,r,n,i,o){var s=Sn(r,n,i,function(a,f){s.terminate(),o(a,f)});return s.postMessage([t,e],e.consume?[t.buffer]:[]),function(){s.terminate()}};var ve=function(t,e){return t[e]|t[e+1]<<8},fe=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},St=function(t,e){return fe(t,e)+fe(t,e+4)*4294967296},X=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8};function Rn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&q(7),Fr(t,e,[Pn],function(n){return ct(Bt(n.data[0],n.data[1]))},0,r)}function Bt(t,e){return Ir(t,e||{},0,0)}function Tn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&q(7),Fr(t,e,[kn],function(n){return ct(_t(n.data[0],Mr(n.data[1])))},1,r)}function _t(t,e){return Rr(t,{i:2},e&&e.out,e&&e.dictionary)}var zr=function(t,e,r,n){for(var i in t){var o=t[i],s=e+i,a=n;Array.isArray(o)&&(a=zt(n,o[1]),o=o[0]),o instanceof B?r[s]=[o,a]:(r[s+="/"]=[new B(0),a],zr(o,s,r,n))}},wr=typeof TextEncoder<"u"&&new TextEncoder,Tt=typeof TextDecoder<"u"&&new TextDecoder,Un=0;try{Tt.decode(Ft,{stream:!0}),Un=1}catch{}var In=function(t){for(var e="",r=0;;){var n=t[r++],i=(n>127)+(n>223)+(n>239);if(r+i>t.length)return{s:e,r:De(t,r-1)};i?i==3?(n=((n&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|t[r++]&63):e+=String.fromCharCode((n&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(n)}};function Er(t,e){if(e){for(var r=new B(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}if(wr)return wr.encode(t);for(var i=t.length,o=new B(t.length+(t.length>>1)),s=0,a=function(h){o[s++]=h},n=0;n<i;++n){if(s+5>o.length){var f=new B(s+8+(i-n<<1));f.set(o),o=f}var c=t.charCodeAt(n);c<128||e?a(c):c<2048?(a(192|c>>6),a(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|t.charCodeAt(++n)&1023,a(240|c>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|c&63)):(a(224|c>>12),a(128|c>>6&63),a(128|c&63))}return De(o,0,s)}function Mn(t,e){if(e){for(var r="",n=0;n<t.length;n+=16384)r+=String.fromCharCode.apply(null,t.subarray(n,n+16384));return r}else{if(Tt)return Tt.decode(t);var i=In(t),o=i.s,r=i.r;return r.length&&q(8),o}}var Fn=function(t,e){return e+30+ve(t,e+26)+ve(t,e+28)},zn=function(t,e,r){var n=ve(t,e+28),i=Mn(t.subarray(e+46,e+46+n),!(ve(t,e+8)&2048)),o=e+46+n,s=fe(t,e+20),a=r&&s==4294967295?Bn(t,o):[s,fe(t,e+24),fe(t,e+42)],f=a[0],c=a[1],h=a[2];return[ve(t,e+10),f,c,i,o+ve(t,e+30)+ve(t,e+32),h]},Bn=function(t,e){for(;ve(t,e)!=1;e+=4+ve(t,e+2));return[St(t,e+12),St(t,e+4),St(t,e+20)]},Ut=function(t){var e=0;if(t)for(var r in t){var n=t[r].length;n>65535&&q(9),e+=n+4}return e},Ar=function(t,e,r,n,i,o,s,a){var f=n.length,c=r.extra,h=a&&a.length,l=Ut(c);X(t,e,s!=null?33639248:67324752),e+=4,s!=null&&(t[e++]=20,t[e++]=r.os),t[e]=20,e+=2,t[e++]=r.flag<<1|(o<0&&8),t[e++]=i&&8,t[e++]=r.compression&255,t[e++]=r.compression>>8;var p=new Date(r.mtime==null?Date.now():r.mtime),v=p.getFullYear()-1980;if((v<0||v>119)&&q(10),X(t,e,v<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,o!=-1&&(X(t,e,r.crc),X(t,e+4,o<0?-o-2:o),X(t,e+8,r.size)),X(t,e+12,f),X(t,e+14,l),e+=16,s!=null&&(X(t,e,h),X(t,e+6,r.attrs),X(t,e+10,s),e+=14),t.set(n,e),e+=f,l)for(var A in c){var E=c[A],y=E.length;X(t,e,+A),X(t,e+2,y),t.set(E,e+4),e+=4+y}return h&&(t.set(a,e),e+=h),e},_n=function(t,e,r,n,i){X(t,e,101010256),X(t,e+8,r),X(t,e+10,r),X(t,e+12,n),X(t,e+16,i)};function Br(t,e,r){r||(r=e,e={}),typeof r!="function"&&q(7);var n={};zr(t,"",n,e);var i=Object.keys(n),o=i.length,s=0,a=0,f=o,c=new Array(o),h=[],l=function(){for(var y=0;y<h.length;++y)h[y]()},p=function(y,b){ft(function(){r(y,b)})};ft(function(){p=r});var v=function(){var y=new B(a+22),b=s,I=a-s;a=0;for(var O=0;O<f;++O){var w=c[O];try{var x=w.c.length;Ar(y,a,w,w.f,w.u,x);var L=30+w.f.length+Ut(w.extra),D=a+L;y.set(w.c,D),Ar(y,s,w,w.f,w.u,x,a,w.m),s+=16+L+(w.m?w.m.length:0),a=D+x}catch(g){return p(g,null)}}_n(y,s,c.length,I,b),p(null,y)};o||v();for(var A=function(y){var b=i[y],I=n[b],O=I[0],w=I[1],x=On(),L=O.length;x.p(O);var D=Er(b),g=D.length,m=w.comment,k=m&&Er(m),C=k&&k.length,F=Ut(w.extra),V=w.level==0?0:8,P=function(S,_){if(S)l(),p(S,null);else{var R=_.length;c[y]=zt(w,{size:L,crc:x.d(),c:_,f:D,m:k,u:g!=b.length||k&&m.length!=C,compression:V}),s+=30+g+F+R,a+=76+2*(g+F)+(C||0)+R,--o||v()}};if(g>65535&&P(q(11,0,1),null),!V)P(null,O);else if(L<16e4)try{P(null,Bt(O,w))}catch(S){P(S,null)}else h.push(Rn(O,w,P))},E=0;E<f;++E)A(E);return l}var ft=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(t){t()};function _r(t,e,r){r||(r=e,e={}),typeof r!="function"&&q(7);var n=[],i=function(){for(var y=0;y<n.length;++y)n[y]()},o={},s=function(y,b){ft(function(){r(y,b)})};ft(function(){s=r});for(var a=t.length-22;fe(t,a)!=101010256;--a)if(!a||t.length-a>65558)return s(q(13,0,1),null),i;var f=ve(t,a+8);if(f){var c=f,h=fe(t,a+16),l=h==4294967295||c==65535;if(l){var p=fe(t,a-12);l=fe(t,p)==101075792,l&&(c=f=fe(t,p+32),h=fe(t,p+48))}for(var v=e&&e.filter,A=function(y){var b=zn(t,h,l),I=b[0],O=b[1],w=b[2],x=b[3],L=b[4],D=b[5],g=Fn(t,D);h=L;var m=function(C,F){C?(i(),s(C,null)):(F&&(o[x]=F),--f||s(null,o))};if(!v||v({name:x,size:O,originalSize:w,compression:I}))if(!I)m(null,De(t,g,g+O));else if(I==8){var k=t.subarray(g,g+O);if(w<524288||O>.8*w)try{m(null,_t(k,{out:new B(w)}))}catch(C){m(C,null)}else n.push(Tn(k,{size:w},m))}else m(q(14,"unknown compression type "+I,1),null);else m(null,null)},E=0;E<c;++E)A(E)}else s(null,{});return i}var Be=class extends ${};var ht=class extends Be{constructor(){super(...arguments);d(this,"message","An error occured while trying to compress the data")}};var lt=class extends Be{constructor(){super(...arguments);d(this,"message","An error occured while trying to decompress the data")}};var pt=class extends ${constructor(){super(...arguments);d(this,"message","An error occured while downloading the data")}};var vt=class extends ${constructor(){super(...arguments);d(this,"message","An error occured while trying to retrieve server informations")}};var ce=class extends ${};var mt=class extends ce{constructor(){super(...arguments);d(this,"message","An error occured while trying to pause the job")}};var dt=class extends ce{constructor(){super(...arguments);d(this,"message","An error occured while trying to resume the job")}};var yt=class extends ${constructor(){super(...arguments);d(this,"message","An error occured while uploading the data")}};var Nn=15e5,xe={},gt=new Nr.default,jn=t=>{t.terminate();let e=new Ae(t.lufiFile,0);return U.fromPromise(new Promise((r,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(xe[e.lufiFile.keys.client].uploadStatus=0,r(e)),i.data.event==="OPERATION_FAILED"&&n(new ce("An error occured while trying to cancel an upload",{cause:i.data.error}))}).requestMessage({args:{lufiFile:e.lufiFile}})}),r=>J(r))},jr=(t,e={})=>{let r=async n=>{var i;for(let o of n){let s=((i=o.name.split("/"))==null?void 0:i.pop())||o.name,a=s.split(".").shift(),f=s.split(".").pop(),c=s;if(e[c]!==void 0){let h=1;do c=`${a}_(${h}).${f}`,h++;while(e[c]!==void 0)}gt.emit("ARCHIVE_ADDED_FILE",{name:c,size:o.size}),e[c]=await o.bytes()}};return U.fromPromise(r(t),n=>J(n)).andThen(()=>H(e))},Jr=(t,e)=>{let r=()=>new Promise((n,i)=>{Br(t,(o,s)=>{o&&i(o),n(s)})});return U.fromPromise(r(),n=>n).andThen(n=>{try{return H(new File([new Blob([n])],e,{type:"application/zip"}))}catch(i){return W(i)}}).orElse(n=>W(new ht(void 0,{cause:J(n)})))},Jn=t=>{let e=async()=>{let r=await t.bytes();return new Promise((n,i)=>{_r(r,(o,s)=>{o&&i(o),n(s)})})};return U.fromPromise(e(),r=>r).andThen(r=>{try{let n=[];for(let i in r)n.push(new File([new Blob([r[i]])],i));return H(n)}catch(n){return W(n)}}).orElse(r=>W(new lt(void 0,{cause:J(r)})))},Gr=(t,e)=>e?or(t).andThen(r=>{if(r.version.tag>"0.07.0"){let n=Dt()?1:0;return Ct(e,n).andThen(i=>H(Ee.fromDownloadUrl(t,i)))}else return H(Ee.fromDownloadUrl(t,e))}):H(Ee.fromDownloadUrl(t)),Gn=(t,e)=>Gr(t,e).andThen(r=>{let n=new Ae(r,1);return U.fromPromise(new Promise((i,o)=>{let s=[];return n.onMessage(a=>{Wr(i,o,n,a),a.data.event==="CHUNK_DOWNLOADED"&&(s.push(a.data.chunk.buffer),s.length>=50&&(n.downloadedFile=new File(n.downloadedFile?[n.downloadedFile.slice()].concat(s):s,r.name,{type:r.type}),s.length=0)),a.data.event==="DOWNLOAD_COMPLETE"&&(n.downloadedFile=new File(n.downloadedFile?[n.downloadedFile.slice()].concat(s):s,r.name,{type:r.type}),s.length=0,n.complete())}).requestMessage({args:{lufiFile:r}})}),i=>new pt(void 0,{cause:J(i)}))}),Wn=(t,e)=>Gr(t,e).andThen(r=>H(new Ae(r,2))).andThen(r=>U.fromPromise(new Promise((n,i)=>{r.onMessage(o=>{o.data.event==="INFOS_RETRIEVED"&&(r.complete(),n(r)),o.data.event==="OPERATION_FAILED"&&i(new ce("An error occured while trying to retrieve informations of the file",{cause:o.data.error}))}).requestMessage({args:{lufiFile:r.lufiFile}})}),n=>new vt(void 0,{cause:J(n)}))),Hn=t=>{try{return t.status=3,H(t.requestMessage({action:0,args:{lufiFile:t.lufiFile}}))}catch(e){return W(new mt(void 0,{cause:J(e)}))}},qn=(t,e)=>{let r=Ee.fromRemoveUrl(t,e),n=new Ae(r,3);return U.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new ce("An error occured while trying to remove a file",{cause:s.data.error()}))}).requestMessage({args:{lufiFile:r}})}),i=>J(i))},Kn=t=>{try{return t.status=2,H(t.requestMessage({action:2,args:{lufiFile:t.lufiFile}}))}catch(e){return W(new dt(void 0,{cause:J(e)}))}},Zn=(t,e,r,n=Nn)=>{gt.emit("SLICE_STARTED",xe[t.lufiFile.keys.client]);let i=Math.ceil(e.size/n)||1,o=navigator.hardwareConcurrency||1;return xe[t.lufiFile.keys.client].totalChunks=i,(async()=>{for(let a=0;a<i;a++){let f=a*n,c=Math.min(f+n,e.size),h=await e.slice(f,c,e.type).arrayBuffer();t.requestMessage({args:{chunk:{buffer:h,index:a},lufiFile:xe[t.lufiFile.keys.client],algo:r}},[h]),a===0?await new Promise(p=>{t.events.once("UPLOAD_STARTED",()=>{p(void 0)})}):a%o===0&&await new Promise(p=>{t.events.once("CHUNK_UPLOADED",()=>{p(void 0)})})}})(),H(void 0)},Nt=(t,e,r,n,i,o,s)=>dr(s).andThen(a=>o?Ct(o,s).andThen(f=>H({password:f,clientKey:a})):H({password:o,clientKey:a})).andThen(({password:a,clientKey:f})=>{xe[f]=new Ee(t.toString(),{delay:r,delAtFirstView:n,zipped:i,password:a,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:f,server:""}});let c=new Ae(xe[f],4);return xe[f].uploadStatus=4,Zn(c,e,s).andThen(()=>U.fromPromise(new Promise((h,l)=>{c.onMessage(p=>{switch(Wr(h,l,c,p),p.data.event){case"UPLOAD_COMPLETE":c.complete(),c.lufiFile.uploadStatus=1;break}})}),h=>J(h)))}),$n=(t,e,r=0,n=!1,i=!1,o="documents.zip",s="",a=1)=>{let f=[];return i?e.length===1&&e[0].type==="application/zip"?f.push(Nt(t,e[0],r,n,i,s,a)):f.push(jr(e).andThen(c=>Jr(c,o).andThen(h=>(gt.emit("ARCHIVE_CREATED",h),Nt(t,h,r,n,i,s,a))))):e.forEach(c=>{f.push(Nt(t,c,r,n,i,s,a))}),U.combine(f).orElse(c=>W(new yt(void 0,{cause:c})))},Wr=(t,e,r,n)=>{n.data.event==="SOCKET_OPENED"&&t(r),n.data.event==="OPERATION_FAILED"&&e(new ce("The job returned an error",{cause:n.data.error}))},Vn=()=>Object.values(xe).filter(t=>t.uploadStatus===4),Qn=t=>Object.keys(Vn()).indexOf(t);export{ke as CryptoAlgorithm,U as ResultAsync,le as err,W as errAsync,Dt as isSecureContext,jt as lufi,we as ok,H as okAsync};
|