lufi/themes/default/public/js/lufi.js

2 lines
62 KiB
JavaScript
Executable File

var Fr=Object.create;var Ze=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var _r=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Nr=Object.prototype.hasOwnProperty;var Jr=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Gr=(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 zt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),qr=(t,e)=>{for(var r in e)Ze(t,r,{get:e[r],enumerable:!0})},Zr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _r(e))!Nr.call(t,i)&&i!==r&&Ze(t,i,{get:()=>e[i],enumerable:!(n=Br(e,i))||n.enumerable});return t};var lt=(t,e,r)=>(r=t!=null?Fr(jr(t)):{},Zr(e||!t||!t.__esModule?Ze(r,"default",{value:t,enumerable:!0}):r,t));var d=(t,e,r)=>Jr(t,typeof e!="symbol"?e+"":e,r);var vt=zt((Jn,pt)=>{"use strict";var xe=typeof Reflect=="object"?Reflect:null,Ft=xe&&typeof xe.apply=="function"?xe.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},He;xe&&typeof xe.ownKeys=="function"?He=xe.ownKeys:Object.getOwnPropertySymbols?He=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:He=function(e){return Object.getOwnPropertyNames(e)};function Hr(t){console&&console.warn&&console.warn(t)}var _t=Number.isNaN||function(e){return e!==e};function C(){C.init.call(this)}pt.exports=C;pt.exports.once=Vr;C.EventEmitter=C;C.prototype._events=void 0;C.prototype._eventsCount=0;C.prototype._maxListeners=void 0;var Bt=10;function We(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(C,"defaultMaxListeners",{enumerable:!0,get:function(){return Bt},set:function(t){if(typeof t!="number"||t<0||_t(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Bt=t}});C.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};C.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||_t(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 jt(t){return t._maxListeners===void 0?C.defaultMaxListeners:t._maxListeners}C.prototype.getMaxListeners=function(){return jt(this)};C.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 c=o[e];if(c===void 0)return!1;if(typeof c=="function")Ft(c,this,r);else for(var u=c.length,h=Zt(c,u),n=0;n<u;++n)Ft(h[n],this,r);return!0};function Nt(t,e,r,n){var i,o,s;if(We(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=jt(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,Hr(a)}return t}C.prototype.addListener=function(e,r){return Nt(this,e,r,!1)};C.prototype.on=C.prototype.addListener;C.prototype.prependListener=function(e,r){return Nt(this,e,r,!0)};function Wr(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Jt(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Wr.bind(n);return i.listener=r,n.wrapFn=i,i}C.prototype.once=function(e,r){return We(r),this.on(e,Jt(this,e,r)),this};C.prototype.prependOnceListener=function(e,r){return We(r),this.prependListener(e,Jt(this,e,r)),this};C.prototype.removeListener=function(e,r){var n,i,o,s,a;if(We(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():$r(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};C.prototype.off=C.prototype.removeListener;C.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 Gt(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?Kr(i):Zt(i,i.length)}C.prototype.listeners=function(e){return Gt(this,e,!0)};C.prototype.rawListeners=function(e){return Gt(this,e,!1)};C.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):qt.call(t,e)};C.prototype.listenerCount=qt;function qt(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}C.prototype.eventNames=function(){return this._eventsCount>0?He(this._events):[]};function Zt(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function $r(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Kr(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Vr(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))}Ht(t,e,o,{once:!0}),e!=="error"&&Yr(t,i,{once:!0})})}function Yr(t,e,r){typeof t.on=="function"&&Ht(t,"error",e,r)}function Ht(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 sr=zt((ki,De)=>{"use strict";var f={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}}};f.cipher.aes=function(t){this.s[0][0][0]||this.O();var e,r,n,i,o=this.s[0][4],s=this.s[1];e=t.length;var a=1;if(e!==4&&e!==6&&e!==8)throw new f.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]]};f.cipher.aes.prototype={encrypt:function(t){return nr(this,t,0)},decrypt:function(t){return nr(this,t,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var t=this.s[0],e=this.s[1],r=t[4],n=e[4],i,o,s,a=[],c=[],u,h,l,p;for(i=0;256>i;i++)c[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!r[o];o^=u||1,s=c[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[u=a[o]]],p=16843009*h^65537*i^257*u^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 nr(t,e,r){if(e.length!==4)throw new f.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,c,u,h=n.length/4-2,l,p=4,v=[0,0,0,0];a=t.s[r],t=a[0];var m=a[1],w=a[2],g=a[3],A=a[4];for(l=0;l<h;l++)a=t[i>>>24]^m[o>>16&255]^w[s>>8&255]^g[e&255]^n[p],c=t[o>>>24]^m[s>>16&255]^w[e>>8&255]^g[i&255]^n[p+1],u=t[s>>>24]^m[e>>16&255]^w[i>>8&255]^g[o&255]^n[p+2],e=t[e>>>24]^m[i>>16&255]^w[o>>8&255]^g[s&255]^n[p+3],p+=4,i=a,o=c,s=u;for(l=0;4>l;l++)v[r?3&-l:l]=A[i>>>24]<<24^A[o>>16&255]<<16^A[s>>8&255]<<8^A[e&255]^n[p++],a=i,i=o,o=s,s=e,e=a;return v}f.bitArray={bitSlice:function(t,e,r){return t=f.bitArray.$(t.slice(e/32),32-(e&31)).slice(1),r===void 0?t:f.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=f.bitArray.getPartial(r);return n===32?t.concat(e):f.bitArray.$(e,n,r|0,t.slice(0,t.length-1))},bitLength:function(t){var e=t.length;return e===0?0:32*(e-1)+f.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]=f.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(f.bitArray.bitLength(t)!==f.bitArray.bitLength(e))return!1;var r=0,n;for(n=0;n<t.length;n++)r|=t[n]^e[n];return r===0},$: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=f.bitArray.getPartial(i),n.push(f.bitArray.partial(e+t&31,32<e+t?r:n.pop(),1)),n},i: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}};f.codec.utf8String={fromBits:function(t){var e="",r=f.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(f.bitArray.partial(8*(r&3),n)),e}};f.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,f.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 f.bitArray.clamp(r,4*n)}};f.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(t,e,r){var n=f.codec.base32.BASE,i=f.codec.base32.REMAINING,o="",s=0,a=f.codec.base32.B,c=0,u=f.bitArray.bitLength(t);for(r&&(a=f.codec.base32.X),r=0;o.length*n<u;)o+=a.charAt((c^t[r]>>>s)>>>i),s<n?(c=t[r]<<n-s,s+=i,r++):(c<<=n,s-=n);for(;o.length&7&&!e;)o+="=";return o},toBits:function(t,e){t=t.replace(/\s|=/g,"").toUpperCase();var r=f.codec.base32.BITS,n=f.codec.base32.BASE,i=f.codec.base32.REMAINING,o=[],s,a=0,c=f.codec.base32.B,u=0,h,l="base32";for(e&&(c=f.codec.base32.X,l="base32hex"),s=0;s<t.length;s++){if(h=c.indexOf(t.charAt(s)),0>h){if(!e)try{return f.codec.base32hex.toBits(t)}catch{}throw new f.exception.invalid("this isn't "+l+"!")}a>i?(a-=i,o.push(u^h>>>a),u=h<<r-a):(a+=n,u^=h<<r-a)}return a&56&&o.push(f.bitArray.partial(a&56,u,1)),o}};f.codec.base32hex={fromBits:function(t,e){return f.codec.base32.fromBits(t,e,1)},toBits:function(t){return f.codec.base32.toBits(t,1)}};f.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,r){var n="",i=0,o=f.codec.base64.B,s=0,a=f.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=f.codec.base64.B,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 f.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(f.bitArray.partial(i&56,s,1)),r}};f.codec.base64url={fromBits:function(t){return f.codec.base64.fromBits(t,1,1)},toBits:function(t){return f.codec.base64.toBits(t,1)}};f.hash.sha256=function(t){this.b[0]||this.O(),t?(this.F=t.F.slice(0),this.A=t.A.slice(0),this.l=t.l):this.reset()};f.hash.sha256.hash=function(t){return new f.hash.sha256().update(t).finalize()};f.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(t){typeof t=="string"&&(t=f.codec.utf8String.toBits(t));var e,r=this.A=f.bitArray.concat(this.A,t);if(e=this.l,t=this.l=e+f.bitArray.bitLength(t),9007199254740991<t)throw new f.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)gt(this,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)gt(this,r.splice(0,16));return this},finalize:function(){var t,r=this.A,e=this.F,r=f.bitArray.concat(r,[f.bitArray.partial(1,1)]);for(t=r.length+2;t&15;t++)r.push(0);for(r.push(Math.floor(this.l/4294967296)),r.push(this.l|0);r.length;)gt(this,r.splice(0,16));return this.reset(),e},Y:[],b:[],O: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.Y[e]=t(Math.pow(r,.5))),this.b[e]=t(Math.pow(r,1/3)),e++)}}};function gt(t,e){var r,n,i,o=t.F,s=t.b,a=o[0],c=o[1],u=o[2],h=o[3],l=o[4],p=o[5],v=o[6],m=o[7];for(r=0;64>r;r++)16>r?n=e[r]:(n=e[r+1&15],i=e[r+14&15],n=e[r&15]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+e[r&15]+e[r+9&15]|0),n=n+m+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(v^l&(p^v))+s[r],m=v,v=p,p=l,l=h+n|0,h=u,u=c,c=a,a=n+(c&u^h&(c^u))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+a|0,o[1]=o[1]+c|0,o[2]=o[2]+u|0,o[3]=o[3]+h|0,o[4]=o[4]+l|0,o[5]=o[5]+p|0,o[6]=o[6]+v|0,o[7]=o[7]+m|0}f.mode.ccm={name:"ccm",G:[],listenProgress:function(t){f.mode.ccm.G.push(t)},unListenProgress:function(t){t=f.mode.ccm.G.indexOf(t),-1<t&&f.mode.ccm.G.splice(t,1)},fa:function(t){var e=f.mode.ccm.G.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=f.bitArray,c=a.bitLength(r)/8,u=a.bitLength(s)/8;if(i=i||64,n=n||[],7>c)throw new f.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&u>>>8*o;o++);return o<15-c&&(o=15-c),r=a.clamp(r,8*(15-o)),e=f.mode.ccm.V(t,e,r,n,i,o),s=f.mode.ccm.C(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=f.bitArray,s=o.bitLength(r)/8,u=o.bitLength(e),a=o.clamp(e,u-i),c=o.bitSlice(e,u-i),u=(u-i)/8;if(7>s)throw new f.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&u>>>8*e;e++);if(e<15-s&&(e=15-s),r=o.clamp(r,8*(15-e)),a=f.mode.ccm.C(t,a,r,c,i,e),t=f.mode.ccm.V(t,a.data,r,n,i,e),!o.equal(a.tag,t))throw new f.exception.corrupt("ccm: tag doesn't match");return a.data},na:function(t,e,r,n,i,o){var s=[],a=f.bitArray,c=a.i;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(c(n,s.slice(e,e+4).concat([0,0,0])));return n},V:function(t,e,r,n,i,o){var s=f.bitArray,a=s.i;if(i/=8,i%2||4>i||16<i)throw new f.exception.invalid("ccm: invalid tag length");if(4294967295<n.length||4294967295<e.length)throw new f.exception.bug("ccm: can't deal with 4GiB or more data");for(r=f.mode.ccm.na(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)},C:function(t,e,r,n,i,o){var s,a=f.bitArray;s=a.i;var c=e.length,u=a.bitLength(e),h=c/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),!c)return{tag:n,data:[]};for(s=0;s<c;s+=4)s>h&&(f.mode.ccm.fa(s/c),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,u)}}};f.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,n,i,o){if(f.bitArray.bitLength(r)!==128)throw new f.exception.invalid("ocb iv must be 128 bits");var s,a=f.mode.ocb2.S,c=f.bitArray,u=c.i,h=[0,0,0,0];r=a(t.encrypt(r));var l,p=[];for(n=n||[],i=i||64,s=0;s+4<e.length;s+=4)l=e.slice(s,s+4),h=u(h,l),p=p.concat(u(r,t.encrypt(u(r,l)))),r=a(r);return l=e.slice(s),e=c.bitLength(l),s=t.encrypt(u(r,[0,0,0,e])),l=c.clamp(u(l.concat([0,0,0]),s),e),h=u(h,u(l.concat([0,0,0]),s)),h=t.encrypt(u(h,u(r,a(r)))),n.length&&(h=u(h,o?n:f.mode.ocb2.pmac(t,n))),p.concat(c.concat(l,c.clamp(h,i)))},decrypt:function(t,e,r,n,i,o){if(f.bitArray.bitLength(r)!==128)throw new f.exception.invalid("ocb iv must be 128 bits");i=i||64;var s=f.mode.ocb2.S,a=f.bitArray,c=a.i,u=[0,0,0,0],h=s(t.encrypt(r)),l,p,v=f.bitArray.bitLength(e)-i,m=[];for(n=n||[],r=0;r+4<v/32;r+=4)l=c(h,t.decrypt(c(h,e.slice(r,r+4)))),u=c(u,l),m=m.concat(l),h=s(h);if(p=v-32*r,l=t.encrypt(c(h,[0,0,0,p])),l=c(l,a.clamp(e.slice(r),p).concat([0,0,0])),u=c(u,l),u=t.encrypt(c(u,c(h,s(h)))),n.length&&(u=c(u,o?n:f.mode.ocb2.pmac(t,n))),!a.equal(a.clamp(u,i),a.bitSlice(e,v)))throw new f.exception.corrupt("ocb: tag doesn't match");return m.concat(a.clamp(l,p))},pmac:function(t,e){var r,n=f.mode.ocb2.S,i=f.bitArray,o=i.i,s=[0,0,0,0],a=t.encrypt([0,0,0,0]),a=o(a,n(n(a)));for(r=0;r+4<e.length;r+=4)a=n(a),s=o(s,t.encrypt(o(a,e.slice(r,r+4))));return r=e.slice(r),128>i.bitLength(r)&&(a=o(a,n(a)),r=i.concat(r,[-2147483648,0,0,0])),s=o(s,r),t.encrypt(o(n(o(a,n(a))),s))},S:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}};f.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=f.bitArray,n=n||[],t=f.mode.gcm.C(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,n,i){var o=e.slice(0),s=f.bitArray,a=s.bitLength(o);if(i=i||128,n=n||[],i<=a?(e=s.bitSlice(o,a-i),o=s.bitSlice(o,0,a-i)):(e=o,o=[]),t=f.mode.gcm.C(!1,t,o,n,r,i),!s.equal(t.tag,e))throw new f.exception.corrupt("gcm: tag doesn't match");return t.data},ka:function(t,e){var r,n,i,o,s,a=f.bitArray.i;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=(t[Math.floor(r/32)]&1<<31-r%32)!==0)&&(i=a(i,o)),s=(o[3]&1)!==0,n=3;0<n;n--)o[n]=o[n]>>>1|(o[n-1]&1)<<31;o[0]>>>=1,s&&(o[0]^=-520093696)}return i},j:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;n<i;n+=4)e[0]^=4294967295&r[n],e[1]^=4294967295&r[n+1],e[2]^=4294967295&r[n+2],e[3]^=4294967295&r[n+3],e=f.mode.gcm.ka(e,t);return e},C:function(t,e,r,n,i,o){var s,a,c,u,h,l,p,v,m=f.bitArray;for(l=r.length,p=m.bitLength(r),v=m.bitLength(n),a=m.bitLength(i),s=e.encrypt([0,0,0,0]),a===96?(i=i.slice(0),i=m.concat(i,[1])):(i=f.mode.gcm.j(s,[0,0,0,0],i),i=f.mode.gcm.j(s,i,[0,0,Math.floor(a/4294967296),a&4294967295])),a=f.mode.gcm.j(s,[0,0,0,0],n),h=i.slice(0),n=a.slice(0),t||(n=f.mode.gcm.j(s,a,r)),u=0;u<l;u+=4)h[3]++,c=e.encrypt(h),r[u]^=c[0],r[u+1]^=c[1],r[u+2]^=c[2],r[u+3]^=c[3];return r=m.clamp(r,p),t&&(n=f.mode.gcm.j(s,a,r)),t=[Math.floor(v/4294967296),v&4294967295,Math.floor(p/4294967296),p&4294967295],n=f.mode.gcm.j(s,n,t),c=e.encrypt(i),n[0]^=c[0],n[1]^=c[1],n[2]^=c[2],n[3]^=c[3],{tag:m.bitSlice(n,0,o),data:r}}};f.misc.hmac=function(t,e){this.W=e=e||f.hash.sha256;var r=[[],[]],n,i=e.prototype.blockSize/32;for(this.w=[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.w[0].update(r[0]),this.w[1].update(r[1]),this.R=new e(this.w[0])};f.misc.hmac.prototype.encrypt=f.misc.hmac.prototype.mac=function(t){if(this.aa)throw new f.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)};f.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]),this.aa=!1};f.misc.hmac.prototype.update=function(t){this.aa=!0,this.R.update(t)};f.misc.hmac.prototype.digest=function(){var t=this.R.finalize(),t=new this.W(this.w[1]).update(t).finalize();return this.reset(),t};f.misc.pbkdf2=function(t,e,r,n,i){if(r=r||1e4,0>n||0>r)throw new f.exception.invalid("invalid params to pbkdf2");typeof t=="string"&&(t=f.codec.utf8String.toBits(t)),typeof e=="string"&&(e=f.codec.utf8String.toBits(e)),i=i||f.misc.hmac,t=new i(t);var o,s,a,c,u=[],h=f.bitArray;for(c=1;32*u.length<(n||1);c++){for(i=o=t.encrypt(h.concat(e,[c])),s=1;s<r;s++)for(o=t.encrypt(o),a=0;a<o.length;a++)i[a]^=o[a];u=u.concat(i)}return n&&(u=h.clamp(u,n)),u};f.prng=function(t){this.c=[new f.hash.sha256],this.m=[0],this.P=0,this.H={},this.N=0,this.U={},this.Z=this.f=this.o=this.ha=0,this.b=[0,0,0,0,0,0,0,0],this.h=[0,0,0,0],this.L=void 0,this.M=t,this.D=!1,this.K={progress:{},seeded:{}},this.u=this.ga=0,this.I=1,this.J=2,this.ca=65536,this.T=[0,48,64,96,128,192,256,384,512,768,1024],this.da=3e4,this.ba=80};f.prng.prototype={randomWords:function(t,e){var r=[],n;n=this.isReady(e);var i;if(n===this.u)throw new f.exception.notReady("generator isn't seeded");if(n&this.J){n=!(n&this.I),i=[];var o=0,s;for(this.Z=i[0]=new Date().valueOf()+this.da,s=0;16>s;s++)i.push(4294967296*Math.random()|0);for(s=0;s<this.c.length&&(i=i.concat(this.c[s].finalize()),o+=this.m[s],this.m[s]=0,n||!(this.P&1<<s));s++);for(this.P>=1<<this.c.length&&(this.c.push(new f.hash.sha256),this.m.push(0)),this.f-=o,o>this.o&&(this.o=o),this.P++,this.b=f.hash.sha256.hash(this.b.concat(i)),this.L=new f.cipher.aes(this.b),n=0;4>n&&(this.h[n]=this.h[n]+1|0,!this.h[n]);n++);}for(n=0;n<t;n+=4)(n+1)%this.ca===0&&or(this),i=wt(this),r.push(i[0],i[1],i[2],i[3]);return or(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 f.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=t},addEntropy:function(t,e,r){r=r||"user";var n,i,o=new Date().valueOf(),s=this.H[r],a=this.isReady(),c=0;switch(n=this.U[r],n===void 0&&(n=this.U[r]=this.ha++),s===void 0&&(s=this.H[r]=0),this.H[r]=(this.H[r]+1)%this.c.length,typeof t){case"number":e===void 0&&(e=1),this.c[s].update([n,this.N++,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]"&&(c=1),r=0;r<t.length&&!c;r++)typeof t[r]!="number"&&(c=1);if(!c){if(e===void 0)for(r=e=0;r<t.length;r++)for(i=t[r];0<i;)e++,i=i>>>1;this.c[s].update([n,this.N++,2,e,o,t.length].concat(t))}break;case"string":e===void 0&&(e=t.length),this.c[s].update([n,this.N++,3,e,o,t.length]),this.c[s].update(t);break;default:c=1}if(c)throw new f.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[s]+=e,this.f+=e,a===this.u&&(this.isReady()!==this.u&&ir("seeded",Math.max(this.o,this.f)),ir("progress",this.getProgress()))},isReady:function(t){return t=this.T[t!==void 0?t:this.M],this.o&&this.o>=t?this.m[0]>this.ba&&new Date().valueOf()>this.Z?this.J|this.I:this.I:this.f>=t?this.J|this.u:this.u},getProgress:function(t){return t=this.T[t||this.M],this.o>=t||this.f>t?1:this.f/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:ze(this,this.ma),mouseCollector:ze(this,this.oa),keyboardCollector:ze(this,this.la),accelerometerCollector:ze(this,this.ea),touchCollector:ze(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 f.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.K[t][this.ga++]=e},removeEventListener:function(t,e){var r,n,i=this.K[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]},la:function(){Ie(this,1)},oa: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"),Ie(this,0)},qa:function(t){t=t.touches[0]||t.changedTouches[0],this.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),Ie(this,0)},ma:function(){Ie(this,2)},ea: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"),Ie(this,0)}};function ir(t,e){var r,n=f.random.K[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;r<i.length;r++)i[r](e)}function Ie(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 or(t){t.b=wt(t).concat(wt(t)),t.L=new f.cipher.aes(t.b)}function wt(t){for(var e=0;4>e&&(t.h[e]=t.h[e]+1|0,!t.h[e]);e++);return t.L.encrypt(t.h)}function ze(t,e){return function(){e.apply(t,arguments)}}f.random=new f.prng(6);e:try{if(Xe=typeof De<"u"&&De.exports){try{Qe=Gr("crypto")}catch{Qe=null}Xe=Ye=Qe}if(Xe&&Ye.randomBytes)Fe=Ye.randomBytes(128),Fe=new Uint32Array(new Uint8Array(Fe).buffer),f.random.addEntropy(Fe,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Be=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Be);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Be);else break e;f.random.addEntropy(Be,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 Fe,Ye,Be,Xe,Qe;f.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(t,e,r,n){r=r||{},n=n||{};var i=f.json,o=i.g({iv:f.random.randomWords(4,0)},i.defaults),s;if(i.g(o,r),r=o.adata,typeof o.salt=="string"&&(o.salt=f.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=f.codec.base64.toBits(o.iv)),!f.mode[o.mode]||!f.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 f.exception.invalid("json encrypt: invalid parameters");return typeof t=="string"?(s=f.misc.cachedPbkdf2(t,o),t=s.key.slice(0,o.ks/32),o.salt=s.salt):f.ecc&&t instanceof f.ecc.elGamal.publicKey&&(s=t.kem(),o.kemtag=s.tag,t=s.key.slice(0,o.ks/32)),typeof e=="string"&&(e=f.codec.utf8String.toBits(e)),typeof r=="string"&&(o.adata=r=f.codec.utf8String.toBits(r)),s=new f.cipher[o.cipher](t),i.g(n,o),n.key=t,o.ct=o.mode==="ccm"&&f.arrayBuffer&&f.arrayBuffer.ccm&&e instanceof ArrayBuffer?f.arrayBuffer.ccm.encrypt(s,e,o.iv,r,o.ts):f.mode[o.mode].encrypt(s,e,o.iv,r,o.ts),o},encrypt:function(t,e,r,n){var i=f.json,o=i.ja.apply(i,arguments);return i.encode(o)},ia:function(t,e,r,n){r=r||{},n=n||{};var i=f.json;e=i.g(i.g(i.g({},i.defaults),e),r,!0);var o,s;if(o=e.adata,typeof e.salt=="string"&&(e.salt=f.codec.base64.toBits(e.salt)),typeof e.iv=="string"&&(e.iv=f.codec.base64.toBits(e.iv)),!f.mode[e.mode]||!f.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 f.exception.invalid("json decrypt: invalid parameters");return typeof t=="string"?(s=f.misc.cachedPbkdf2(t,e),t=s.key.slice(0,e.ks/32),e.salt=s.salt):f.ecc&&t instanceof f.ecc.elGamal.secretKey&&(t=t.unkem(f.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),typeof o=="string"&&(o=f.codec.utf8String.toBits(o)),s=new f.cipher[e.cipher](t),o=e.mode==="ccm"&&f.arrayBuffer&&f.arrayBuffer.ccm&&e.ct instanceof ArrayBuffer?f.arrayBuffer.ccm.decrypt(s,e.ct,e.iv,e.tag,o,e.ts):f.mode[e.mode].decrypt(s,e.ct,e.iv,o,e.ts),i.g(n,e),n.key=t,r.raw===1?o:f.codec.utf8String.fromBits(o)},decrypt:function(t,e,r,n){var i=f.json;return i.ia(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 f.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+='"'+f.codec.base64.fromBits(t[e],0)+'"';break;default:throw new f.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(t=t.replace(/\s/g,""),!t.match(/^\{.*\}$/))throw new f.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 f.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)$/)?f.codec.base64.toBits(n[4]):unescape(n[4]):n[5]!=null&&(e[n[2]]=n[5]==="true")}return e},g: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 f.exception.invalid("required parameter overridden");t[n]=e[n]}return t},sa:function(t,e){var r={},n;for(n in t)t.hasOwnProperty(n)&&t[n]!==e[n]&&(r[n]=t[n]);return r},ra: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}};f.encrypt=f.json.encrypt;f.decrypt=f.json.decrypt;f.misc.pa={};f.misc.cachedPbkdf2=function(t,e){var r=f.misc.pa,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):f.random.randomWords(2,0)},r=e.salt===void 0?n.firstSalt:e.salt,n[r]=n[r]||f.misc.pbkdf2(t,r,e.iter),{key:n[r].slice(0),salt:r.slice(0)}};typeof De<"u"&&De.exports&&(De.exports=f);typeof define=="function"&&define([],function(){return f})});var It={};qr(It,{addFilesToArchive:()=>Tr,cancel:()=>kn,compress:()=>Ir,decompress:()=>Mn,download:()=>Un,events:()=>Tt,getFileIndexInQueue:()=>jn,infos:()=>Rn,pause:()=>Tn,remove:()=>In,resume:()=>zn,upload:()=>Bn});var Rr=lt(vt());var Xr={withStackTrace:!1},$t=(t,e,r=Xr)=>{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 Ae(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{u(n.next(h))}catch(l){s(l)}}function c(h){try{u(n.throw(h))}catch(l){s(l)}}function u(h){h.done?o(h.value):i(h.value).then(a,c)}u((n=n.apply(t,[])).next())})}function Wt(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 me(t){return this instanceof me?(this.v=t,this):new me(t)}function Qr(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),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(v){return new Promise(function(m,w){o.push([p,v,m,w])>1||a(p,v)})})}function a(p,v){try{c(n[p](v))}catch(m){l(o[0][3],m)}}function c(p){p.value instanceof me?Promise.resolve(p.value.v).then(u,h):l(o[0][2],p)}function u(p){a("next",p)}function h(p){a("throw",p)}function l(p,v){p(v),o.shift(),o.length&&a(o[0][0],o[0][1])}}function en(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:me(t[i](s)),done:i==="return"}:o?o(s):s}:o}}function tn(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 Wt=="function"?Wt(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,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}}var b=class t{constructor(e){this._promise=e}static fromSafePromise(e){let r=e.then(n=>new Y(n));return new t(r)}static fromPromise(e,r){let n=e.then(i=>new Y(i)).catch(i=>new X(r(i)));return new t(n)}static fromThrowable(e,r){return(...n)=>new t(Ae(this,void 0,void 0,function*(){try{return new Y(yield e(...n))}catch(i){return new X(r?r(i):i)}}))}static combine(e){return rn(e)}static combineWithAllErrors(e){return nn(e)}map(e){return new t(this._promise.then(r=>Ae(this,void 0,void 0,function*(){return r.isErr()?new X(r.error):new Y(yield e(r.value))})))}andThrough(e){return new t(this._promise.then(r=>Ae(this,void 0,void 0,function*(){if(r.isErr())return new X(r.error);let n=yield e(r.value);return n.isErr()?new X(n.error):new Y(r.value)})))}andTee(e){return new t(this._promise.then(r=>Ae(this,void 0,void 0,function*(){if(r.isErr())return new X(r.error);try{yield e(r.value)}catch{}return new Y(r.value)})))}mapErr(e){return new t(this._promise.then(r=>Ae(this,void 0,void 0,function*(){return r.isOk()?new Y(r.value):new X(yield e(r.error))})))}andThen(e){return new t(this._promise.then(r=>{if(r.isErr())return new X(r.error);let n=e(r.value);return n instanceof t?n._promise:n}))}orElse(e){return new t(this._promise.then(r=>Ae(this,void 0,void 0,function*(){return r.isErr()?e(r.error):new Y(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 Qr(this,arguments,function*(){return yield me(yield me(yield*en(tn(yield me(this._promise.then(r=>r.safeUnwrap()))))))})}then(e,r){return this._promise.then(e,r)}},G=t=>new b(Promise.resolve(new Y(t))),Z=t=>new b(Promise.resolve(new X(t))),Gn=b.fromPromise,qn=b.fromSafePromise,Zn=b.fromThrowable,Kt=t=>{let e=se([]);for(let r of t)if(r.isErr()){e=Q(r.error);break}else e.map(n=>n.push(r.value));return e},rn=t=>b.fromSafePromise(Promise.all(t)).andThen(Kt),Vt=t=>{let e=se([]);for(let r of t)r.isErr()&&e.isErr()?e.error.push(r.error):r.isErr()&&e.isOk()?e=Q([r.error]):r.isOk()&&e.isOk()&&e.value.push(r.value);return e},nn=t=>b.fromSafePromise(Promise.all(t)).andThen(Vt),mt;(function(t){function e(i,o){return(...s)=>{try{let a=i(...s);return se(a)}catch(a){return Q(o?o(a):a)}}}t.fromThrowable=e;function r(i){return Kt(i)}t.combine=r;function n(i){return Vt(i)}t.combineWithAllErrors=n})(mt||(mt={}));var se=t=>new Y(t);function Q(t){return new X(t)}var Y=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return se(e(this.value))}mapErr(e){return se(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 se(this.value)}orElse(e){return se(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return b.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 $t("Called `_unsafeUnwrapErr` on an Ok",this,e)}},X=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return Q(this.error)}mapErr(e){return Q(e(this.error))}andThrough(e){return Q(this.error)}andTee(e){return Q(this.error)}andThen(e){return Q(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return Z(this.error)}asyncAndThrough(e){return Z(this.error)}asyncMap(e){return Z(this.error)}unwrapOr(e){return e}match(e,r){return r(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield Q(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw $t("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}},Hn=mt.fromThrowable;var ne=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 er=lt(vt());var ae=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 $e=class extends ae{constructor(){super(...arguments);d(this,"message","Unable to connect. Is the computer able to access the url?")}};var Ke=class extends ae{constructor(){super(...arguments);d(this,"message","The server returned an error")}};var R=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)},yt=t=>{let e=t.href.match(/(.*?)\/?(?:\/[dr]{1}|login\/?|files\/?)/),r=e&&e[1]?e[1]:t.origin;return b.fromPromise(fetch(r+"/about/config"),n=>new $e(void 0,{cause:R(n)})).andThen(n=>n.ok?b.fromPromise(n.json(),i=>R(i)):Z(new Ke(void 0,{context:n.statusText})))},Xt=()=>typeof Deno<"u",on=()=>Xt()||typeof window<"u"&&(window.isSecureContext||window.location.protocol==="https:"),Qt=t=>Xt()?new URL(`./worker/${t}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${t==="main"?`worker/${t}`:t}.js`)),Ve=async t=>t?Array.from(new Uint8Array(await crypto.subtle.digest("SHA-512",new TextEncoder().encode(t)))).map(e=>e.toString(16).padStart(2,"0")).join(""):"";var ve=class{constructor(e){d(this,"events",new er.default);d(this,"lufiFile");d(this,"status",2);d(this,"tmpFile");d(this,"tmpChunks",[]);d(this,"worker");d(this,"isTerminated",!1);d(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});d(this,"hasFailed",()=>this.status===1);d(this,"onError",e=>(this.worker.onerror=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?G(this):Z(R("Job has failed")):b.fromPromise(new Promise((e,r)=>{this.events.once("OPERATION_FAILED",n=>{r(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>R(e)));d(this,"dispatchEvent",(e,r)=>{this.events.emit(e,r)});this.worker=new Worker(Qt("main"),{type:"module"}),this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",r=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",r)}),this.onError(r=>console.error(r.error))}};var Le=(r=>(r[r.Sjcl=0]="Sjcl",r[r.WebCrypto=1]="WebCrypto",r))(Le||{});var be=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,c=0,u=0;for(;c<e.length*.75;)i=this._charset.indexOf(e.charAt(u++)),o=this._charset.indexOf(e.charAt(u++)),s=this._charset.indexOf(e.charAt(u++)),a=this._charset.indexOf(e.charAt(u++)),n[c++]=i<<2|o>>4,n[c++]=(o&15)<<4|s>>2,n[c++]=(s&3)<<6|a;return n.buffer}};var Li=new be("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var fn=new be("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function dt(t){return fn.Encode(t)}var Et=lt(sr());var he=class extends ae{};var Ce=class extends he{constructor(){super(...arguments);d(this,"message","Unable to decrypt the provided data")}};var ar=()=>{try{return G(Et.default.codec.base64.fromBits(Et.default.random.randomWords(8,10)))}catch(t){return Z(new he("Unable to generate a random key",{cause:R(t)}))}};var fr=()=>b.fromPromise(new Promise(t=>crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]).then(e=>crypto.subtle.exportKey("raw",e).then(r=>t(dt(r))).catch(r=>Z(new Ce(void 0,{cause:R(r)})))).catch(e=>Z(new Ce(void 0,{cause:R(e)})))),t=>new he("Unable to base64 encode the url",{cause:R(t)}));var cr=(t=1)=>t===0?ar():fr();var et=class extends ae{constructor(){super(...arguments);d(this,"message","An error occured while dealing with a file")}};var tt=class extends et{constructor(){super(...arguments);d(this,"message","An error occured while operating on a file")}};var rt=class extends tt{constructor(){super(...arguments);d(this,"message","An error occured while slicing a file")}};var ur={},pn=function(t,e,r,n,i){var o=new Worker(ur[e]||(ur[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,c=a.$e$;if(c){var u=new Error(c[0]);u.code=c[1],u.stack=c[2],i(u,null)}else i(null,a)},o.postMessage(r,n),o},S=Uint8Array,H=Uint16Array,Ne=Int32Array,ke=new S([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]),Me=new S([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]),_e=new S([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mr=function(t,e){for(var r=new H(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];for(var i=new Ne(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}},yr=mr(ke,2),Ot=yr.b,at=yr.r;Ot[28]=258,at[258]=28;var dr=mr(Me,0),gr=dr.b,At=dr.r,je=new H(32768);for(D=0;D<32768;++D)le=(D&43690)>>1|(D&21845)<<1,le=(le&52428)>>2|(le&13107)<<2,le=(le&61680)>>4|(le&3855)<<4,je[D]=((le&65280)>>8|(le&255)<<8)>>1;var le,D,te=function(t,e,r){for(var n=t.length,i=0,o=new H(e);i<n;++i)t[i]&&++o[t[i]-1];var s=new H(e);for(i=1;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(r){a=new H(1<<e);var c=15-e;for(i=0;i<n;++i)if(t[i])for(var u=i<<4|t[i],h=e-t[i],l=s[t[i]-1]++<<h,p=l|(1<<h)-1;l<=p;++l)a[je[l]>>c]=u}else for(a=new H(n),i=0;i<n;++i)t[i]&&(a[i]=je[s[t[i]-1]++]>>15-t[i]);return a},pe=new S(288);for(D=0;D<144;++D)pe[D]=8;var D;for(D=144;D<256;++D)pe[D]=9;var D;for(D=256;D<280;++D)pe[D]=7;var D;for(D=280;D<288;++D)pe[D]=8;var D,Se=new S(32);for(D=0;D<32;++D)Se[D]=5;var D,wr=te(pe,9,0),Er=te(pe,9,1),xr=te(Se,5,0),Ar=te(Se,5,1),it=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},ee=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)},Je=function(t){return(t+7)/8|0},ye=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new S(t.subarray(e,r))};var Lr=["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"],_=function(t,e,r){var n=new Error(e||Lr[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,_),!r)throw n;return n},br=function(t,e,r,n){var i=t.length,o=n?n.length:0;if(!i||e.f&&!e.l)return r||new S(0);var s=!r,a=s||e.i!=2,c=e.i;s&&(r=new S(i*3));var u=function(Re){var Te=r.length;if(Re>Te){var Ee=new S(Math.max(Te*2,Re));Ee.set(r),r=Ee}},h=e.f||0,l=e.p||0,p=e.b||0,v=e.l,m=e.d,w=e.m,g=e.n,A=i*8;do{if(!v){h=ee(t,l,1);var T=ee(t,l+1,3);if(l+=3,T)if(T==1)v=Er,m=Ar,w=9,g=5;else if(T==2){var I=ee(t,l,31)+257,k=ee(t,l+10,15)+4,x=I+ee(t,l+5,31)+1;l+=14;for(var y=new S(x),M=new S(19),O=0;O<k;++O)M[_e[O]]=ee(t,l+O*3,7);l+=k*3;for(var z=it(M),re=(1<<z)-1,j=te(M,z,1),O=0;O<x;){var N=j[ee(t,l,re)];l+=N&15;var L=N>>4;if(L<16)y[O++]=L;else{var B=0,U=0;for(L==16?(U=3+ee(t,l,3),l+=2,B=y[O-1]):L==17?(U=3+ee(t,l,7),l+=3):L==18&&(U=11+ee(t,l,127),l+=7);U--;)y[O++]=B}}var W=y.subarray(0,I),J=y.subarray(I);w=it(W),g=it(J),v=te(W,w,1),m=te(J,g,1)}else _(1);else{var L=Je(l)+4,E=t[L-4]|t[L-3]<<8,P=L+E;if(P>i){c&&_(0);break}a&&u(p+E),r.set(t.subarray(L,P),p),e.b=p+=E,e.p=l=P*8,e.f=h;continue}if(l>A){c&&_(0);break}}a&&u(p+131072);for(var Ue=(1<<w)-1,V=(1<<g)-1,ue=l;;ue=l){var B=v[ot(t,l)&Ue],$=B>>4;if(l+=B&15,l>A){c&&_(0);break}if(B||_(2),$<256)r[p++]=$;else if($==256){ue=l,v=null;break}else{var K=$-254;if($>264){var O=$-257,F=ke[O];K=ee(t,l,(1<<F)-1)+Ot[O],l+=F}var oe=m[ot(t,l)&V],ge=oe>>4;oe||_(3),l+=oe&15;var J=gr[ge];if(ge>3){var F=Me[ge];J+=ot(t,l)&(1<<F)-1,l+=F}if(l>A){c&&_(0);break}a&&u(p+131072);var we=p+K;if(p<J){var Ge=o-J,qe=Math.min(J,we);for(Ge+p<0&&_(3);p<qe;++p)r[p]=n[Ge+p]}for(;p<we;++p)r[p]=r[p-J]}}e.l=v,e.p=ue,e.b=p,e.f=h,v&&(h=1,e.m=w,e.d=m,e.n=g)}while(!h);return p!=r.length&&s?ye(r,0,p):r.subarray(0,p)},fe=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8},Oe=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:St,l:0};if(i==1){var s=new S(r[0].s+1);return s[r[0].s]=1,{t:s,l:1}}r.sort(function(P,I){return P.f-I.f}),r.push({s:-1,f:25001});var a=r[0],c=r[1],u=0,h=1,l=2;for(r[0]={s:-1,f:a.f+c.f,l:a,r:c};h!=i-1;)a=r[r[u].f<r[l].f?u++:l++],c=r[u!=h&&r[u].f<r[l].f?u++:l++],r[h++]={s:-1,f:a.f+c.f,l:a,r:c};for(var p=o[0].s,n=1;n<i;++n)o[n].s>p&&(p=o[n].s);var v=new H(p+1),m=ft(r[h-1],v,0);if(m>e){var n=0,w=0,g=m-e,A=1<<g;for(o.sort(function(I,k){return v[k.s]-v[I.s]||I.f-k.f});n<i;++n){var T=o[n].s;if(v[T]>e)w+=A-(1<<m-v[T]),v[T]=e;else break}for(w>>=g;w>0;){var L=o[n].s;v[L]<e?w-=1<<e-v[L]++-1:++n}for(;n>=0&&w;--n){var E=o[n].s;v[E]==e&&(--v[E],++w)}m=e}return{t:new S(v),l:m}},ft=function(t,e,r){return t.s==-1?Math.max(ft(t.l,e,r+1),ft(t.r,e,r+1)):e[t.s]=r},Lt=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new H(++e),n=0,i=t[0],o=1,s=function(c){r[n++]=c},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}},Pe=function(t,e){for(var r=0,n=0;n<e.length;++n)r+=t[n]*e[n];return r},Pt=function(t,e,r){var n=r.length,i=Je(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},bt=function(t,e,r,n,i,o,s,a,c,u,h){fe(e,h++,r),++i[256];for(var l=st(i,15),p=l.t,v=l.l,m=st(o,15),w=m.t,g=m.l,A=Lt(p),T=A.c,L=A.n,E=Lt(w),P=E.c,I=E.n,k=new H(19),x=0;x<T.length;++x)++k[T[x]&31];for(var x=0;x<P.length;++x)++k[P[x]&31];for(var y=st(k,7),M=y.t,O=y.l,z=19;z>4&&!M[_e[z-1]];--z);var re=u+5<<3,j=Pe(i,pe)+Pe(o,Se)+s,N=Pe(i,p)+Pe(o,w)+s+14+3*z+Pe(k,M)+2*k[16]+3*k[17]+7*k[18];if(c>=0&&re<=j&&re<=N)return Pt(e,h,t.subarray(c,c+u));var B,U,W,J;if(fe(e,h,1+(N<j)),h+=2,N<j){B=te(p,v,0),U=p,W=te(w,g,0),J=w;var Ue=te(M,O,0);fe(e,h,L-257),fe(e,h+5,I-1),fe(e,h+10,z-4),h+=14;for(var x=0;x<z;++x)fe(e,h+3*x,M[_e[x]]);h+=3*z;for(var V=[T,P],ue=0;ue<2;++ue)for(var $=V[ue],x=0;x<$.length;++x){var K=$[x]&31;fe(e,h,Ue[K]),h+=M[K],K>15&&(fe(e,h,$[x]>>5&127),h+=$[x]>>12)}}else B=wr,U=pe,W=xr,J=Se;for(var x=0;x<a;++x){var F=n[x];if(F>255){var K=F>>18&31;Oe(e,h,B[K+257]),h+=U[K+257],K>7&&(fe(e,h,F>>23&31),h+=ke[K]);var oe=F&31;Oe(e,h,W[oe]),h+=J[oe],oe>3&&(Oe(e,h,F>>5&8191),h+=Me[oe])}else Oe(e,h,B[F]),h+=U[F]}return Oe(e,h,B[256]),h+U[256]},Dr=new Ne([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),St=new S(0),Cr=function(t,e,r,n,i,o){var s=o.z||t.length,a=new S(n+s+5*(1+Math.ceil(s/7e3))+i),c=a.subarray(n,a.length-i),u=o.l,h=(o.r||0)&7;if(e){h&&(c[0]=o.r>>3);for(var l=Dr[e-1],p=l>>13,v=l&8191,m=(1<<r)-1,w=o.p||new H(32768),g=o.h||new H(m+1),A=Math.ceil(r/3),T=2*A,L=function(ht){return(t[ht]^t[ht+1]<<A^t[ht+2]<<T)&m},E=new Ne(25e3),P=new H(288),I=new H(32),k=0,x=0,y=o.i||0,M=0,O=o.w||0,z=0;y+2<s;++y){var re=L(y),j=y&32767,N=g[re];if(w[j]=N,g[re]=j,O<=y){var B=s-y;if((k>7e3||M>24576)&&(B>423||!u)){h=bt(t,c,0,E,P,I,x,M,z,y-z,h),M=k=x=0,z=y;for(var U=0;U<286;++U)P[U]=0;for(var U=0;U<30;++U)I[U]=0}var W=2,J=0,Ue=v,V=j-N&32767;if(B>2&&re==L(y-V))for(var ue=Math.min(p,B)-1,$=Math.min(32767,y),K=Math.min(258,B);V<=$&&--Ue&&j!=N;){if(t[y+W]==t[y+W-V]){for(var F=0;F<K&&t[y+F]==t[y+F-V];++F);if(F>W){if(W=F,J=V,F>ue)break;for(var oe=Math.min(V,F-2),ge=0,U=0;U<oe;++U){var we=y-V+U&32767,Ge=w[we],qe=we-Ge&32767;qe>ge&&(ge=qe,N=we)}}}j=N,N=w[j],V+=j-N&32767}if(J){E[M++]=268435456|at[W]<<18|At[J];var Re=at[W]&31,Te=At[J]&31;x+=ke[Re]+Me[Te],++P[257+Re],++I[Te],O=y+W,++k}else E[M++]=t[y],++P[t[y]]}}for(y=Math.max(y,O);y<s;++y)E[M++]=t[y],++P[t[y]];h=bt(t,c,u,E,P,I,x,M,z,y-z,h),u||(o.r=h&7|c[h/8|0]<<3,h-=7,o.h=g,o.p=w,o.i=y,o.w=O)}else{for(var y=o.w||0;y<s+u;y+=65535){var Ee=y+65535;Ee>=s&&(c[h/8|0]=u,Ee=s),h=Pt(c,h+1,t.subarray(y,Ee))}o.i=s}return ye(a,0,n+Je(h)+i)},vn=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}(),mn=function(){var t=-1;return{p:function(e){for(var r=t,n=0;n<e.length;++n)r=vn[r&255^e[n]]^r>>>8;t=r},d:function(){return~t}}};var Or=function(t,e,r,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),s=new S(o.length+t.length);s.set(o),s.set(t,o.length),t=s,i.w=o.length}return Cr(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)},kt=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},hr=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],c=o[s];if(typeof a=="function"){e+=";"+c+"=";var u=a.toString();if(a.prototype)if(u.indexOf("[native code]")!=-1){var h=u.indexOf(" ",8)+1;e+=u.slice(h,u.indexOf("(",h))}else{e+=u;for(var l in a.prototype)e+=";"+c+".prototype."+l+"="+a.prototype[l].toString()}else e+=u}else r[c]=a}return e},nt=[],yn=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},dn=function(t,e,r,n){if(!nt[r]){for(var i="",o={},s=t.length-1,a=0;a<s;++a)i=hr(t[a],i,o);nt[r]={c:hr(t[s],i,o),e:o}}var c=kt({},nt[r].e);return pn(nt[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",r,c,yn(c),n)},gn=function(){return[S,H,Ne,ke,Me,_e,Ot,gr,Er,Ar,je,Lr,te,it,ee,ot,Je,ye,_,br,Ut,ut,Pr]},wn=function(){return[S,H,Ne,ke,Me,_e,at,At,wr,pe,xr,Se,je,Dr,St,te,fe,Oe,st,ft,Lt,Pe,Pt,bt,Je,ye,Cr,Or,Mt,ut]};var ut=function(t){return postMessage(t,[t.buffer])},Pr=function(t){return t&&{out:t.size&&new S(t.size),dictionary:t.dictionary}},Sr=function(t,e,r,n,i,o){var s=dn(r,n,i,function(a,c){s.terminate(),o(a,c)});return s.postMessage([t,e],e.consume?[t.buffer]:[]),function(){s.terminate()}};var ce=function(t,e){return t[e]|t[e+1]<<8},ie=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},xt=function(t,e){return ie(t,e)+ie(t,e+4)*4294967296},q=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8};function En(t,e,r){return r||(r=e,e={}),typeof r!="function"&&_(7),Sr(t,e,[wn],function(n){return ut(Mt(n.data[0],n.data[1]))},0,r)}function Mt(t,e){return Or(t,e||{},0,0)}function xn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&_(7),Sr(t,e,[gn],function(n){return ut(Ut(n.data[0],Pr(n.data[1])))},1,r)}function Ut(t,e){return br(t,{i:2},e&&e.out,e&&e.dictionary)}var kr=function(t,e,r,n){for(var i in t){var o=t[i],s=e+i,a=n;Array.isArray(o)&&(a=kt(n,o[1]),o=o[0]),o instanceof S?r[s]=[o,a]:(r[s+="/"]=[new S(0),a],kr(o,s,r,n))}},lr=typeof TextEncoder<"u"&&new TextEncoder,Dt=typeof TextDecoder<"u"&&new TextDecoder,An=0;try{Dt.decode(St,{stream:!0}),An=1}catch{}var Ln=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:ye(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 pr(t,e){if(e){for(var r=new S(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}if(lr)return lr.encode(t);for(var i=t.length,o=new S(t.length+(t.length>>1)),s=0,a=function(h){o[s++]=h},n=0;n<i;++n){if(s+5>o.length){var c=new S(s+8+(i-n<<1));c.set(o),o=c}var u=t.charCodeAt(n);u<128||e?a(u):u<2048?(a(192|u>>6),a(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|t.charCodeAt(++n)&1023,a(240|u>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|u&63)):(a(224|u>>12),a(128|u>>6&63),a(128|u&63))}return ye(o,0,s)}function bn(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(Dt)return Dt.decode(t);var i=Ln(t),o=i.s,r=i.r;return r.length&&_(8),o}}var Dn=function(t,e){return e+30+ce(t,e+26)+ce(t,e+28)},Cn=function(t,e,r){var n=ce(t,e+28),i=bn(t.subarray(e+46,e+46+n),!(ce(t,e+8)&2048)),o=e+46+n,s=ie(t,e+20),a=r&&s==4294967295?On(t,o):[s,ie(t,e+24),ie(t,e+42)],c=a[0],u=a[1],h=a[2];return[ce(t,e+10),c,u,i,o+ce(t,e+30)+ce(t,e+32),h]},On=function(t,e){for(;ce(t,e)!=1;e+=4+ce(t,e+2));return[xt(t,e+12),xt(t,e+4),xt(t,e+20)]},Ct=function(t){var e=0;if(t)for(var r in t){var n=t[r].length;n>65535&&_(9),e+=n+4}return e},vr=function(t,e,r,n,i,o,s,a){var c=n.length,u=r.extra,h=a&&a.length,l=Ct(u);q(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)&&_(10),q(t,e,v<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,o!=-1&&(q(t,e,r.crc),q(t,e+4,o<0?-o-2:o),q(t,e+8,r.size)),q(t,e+12,c),q(t,e+14,l),e+=16,s!=null&&(q(t,e,h),q(t,e+6,r.attrs),q(t,e+10,s),e+=14),t.set(n,e),e+=c,l)for(var m in u){var w=u[m],g=w.length;q(t,e,+m),q(t,e+2,g),t.set(w,e+4),e+=4+g}return h&&(t.set(a,e),e+=h),e},Pn=function(t,e,r,n,i){q(t,e,101010256),q(t,e+8,r),q(t,e+10,r),q(t,e+12,n),q(t,e+16,i)};function Mr(t,e,r){r||(r=e,e={}),typeof r!="function"&&_(7);var n={};kr(t,"",n,e);var i=Object.keys(n),o=i.length,s=0,a=0,c=o,u=new Array(o),h=[],l=function(){for(var g=0;g<h.length;++g)h[g]()},p=function(g,A){ct(function(){r(g,A)})};ct(function(){p=r});var v=function(){var g=new S(a+22),A=s,T=a-s;a=0;for(var L=0;L<c;++L){var E=u[L];try{var P=E.c.length;vr(g,a,E,E.f,E.u,P);var I=30+E.f.length+Ct(E.extra),k=a+I;g.set(E.c,k),vr(g,s,E,E.f,E.u,P,a,E.m),s+=16+I+(E.m?E.m.length:0),a=k+P}catch(x){return p(x,null)}}Pn(g,s,u.length,T,A),p(null,g)};o||v();for(var m=function(g){var A=i[g],T=n[A],L=T[0],E=T[1],P=mn(),I=L.length;P.p(L);var k=pr(A),x=k.length,y=E.comment,M=y&&pr(y),O=M&&M.length,z=Ct(E.extra),re=E.level==0?0:8,j=function(N,B){if(N)l(),p(N,null);else{var U=B.length;u[g]=kt(E,{size:I,crc:P.d(),c:B,f:k,m:M,u:x!=A.length||M&&y.length!=O,compression:re}),s+=30+x+z+U,a+=76+2*(x+z)+(O||0)+U,--o||v()}};if(x>65535&&j(_(11,0,1),null),!re)j(null,L);else if(I<16e4)try{j(null,Mt(L,E))}catch(N){j(N,null)}else h.push(En(L,E,j))},w=0;w<c;++w)m(w);return l}var ct=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(t){t()};function Ur(t,e,r){r||(r=e,e={}),typeof r!="function"&&_(7);var n=[],i=function(){for(var g=0;g<n.length;++g)n[g]()},o={},s=function(g,A){ct(function(){r(g,A)})};ct(function(){s=r});for(var a=t.length-22;ie(t,a)!=101010256;--a)if(!a||t.length-a>65558)return s(_(13,0,1),null),i;var c=ce(t,a+8);if(c){var u=c,h=ie(t,a+16),l=h==4294967295||u==65535;if(l){var p=ie(t,a-12);l=ie(t,p)==101075792,l&&(u=c=ie(t,p+32),h=ie(t,p+48))}for(var v=e&&e.filter,m=function(g){var A=Cn(t,h,l),T=A[0],L=A[1],E=A[2],P=A[3],I=A[4],k=A[5],x=Dn(t,k);h=I;var y=function(O,z){O?(i(),s(O,null)):(z&&(o[P]=z),--c||s(null,o))};if(!v||v({name:P,size:L,originalSize:E,compression:T}))if(!T)y(null,ye(t,x,x+L));else if(T==8){var M=t.subarray(x,x+L);if(E<524288||L>.8*E)try{y(null,Ut(M,{out:new S(E)}))}catch(O){y(O,null)}else n.push(xn(M,{size:E},y))}else y(_(14,"unknown compression type "+T,1),null);else y(null,null)},w=0;w<u;++w)m(w)}else s(null,{});return i}var Sn=15e5,de={},Tt=new Rr.default,kn=t=>{t.terminate();let e=new ve(t.lufiFile);return b.fromPromise(new Promise((r,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(de[e.lufiFile.keys.client].uploadStatus=0,r(e)),i.data.event==="OPERATION_FAILED"&&n(i.data.error)}).requestMessage({action:2,args:{lufiFile:e.lufiFile}})}),r=>R(r))},Tr=(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(),c=s.split(".").pop(),u=s;if(e[u]!==void 0){let h=1;do u=`${a}_(${h}).${c}`,h++;while(e[u]!==void 0)}Tt.emit("ARCHIVE_ADDED_FILE",{name:u,size:o.size}),e[u]=await o.bytes()}};return b.fromPromise(r(t),n=>R(n)).andThen(()=>G(e))},Ir=(t,e)=>{let r=()=>new Promise((n,i)=>{Mr(t,(o,s)=>{o&&i(o),n(s)})});return b.fromPromise(r(),n=>R(n)).andThen(n=>G(new File([new Blob([n])],e,{type:"application/zip"}))).orElse(n=>Z(n))},Mn=t=>{let e=async()=>{let r=await t.bytes();return new Promise((n,i)=>{Ur(r,(o,s)=>{o&&i(o),n(s)})})};return b.fromPromise(e(),r=>R(r)).andThen(r=>{let n=[];for(let i in r)n.push(new File([new Blob([r[i]])],i));return G(n)})},Un=(t,e)=>{let r;return e?r=yt(t).andThen(n=>n.version.tag>"0.07.0"?b.fromPromise(Ve(e).then(i=>ne.fromDownloadUrl(t,i)),i=>R(i)):G(ne.fromDownloadUrl(t,e))):r=G(ne.fromDownloadUrl(t)),r.andThen(n=>{let i=new ve(n);return b.fromPromise(new Promise((o,s)=>i.onMessage(a=>{zr(o,s,i,a),a.data.event==="CHUNK_DOWNLOADED"&&(i.tmpChunks[a.data.chunk.index]=new Blob([a.data.chunk.buffer])),a.data.event==="DOWNLOAD_COMPLETE"&&(i.tmpFile=new Blob(i.tmpChunks,{type:n.type}),i.tmpChunks=[],i.complete())}).requestMessage({action:3,args:{lufiFile:n}})),o=>R(o))})},Rn=(t,e)=>{let r;return e?r=yt(t).andThen(n=>n.version.tag>"0.07.0"?b.fromPromise(Ve(e).then(i=>ne.fromDownloadUrl(t,i)),i=>R(i)):G(ne.fromDownloadUrl(t,e))):r=G(ne.fromDownloadUrl(t)),r.andThen(n=>G(new ve(n))).andThen(n=>b.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="INFOS_RETRIEVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(s.data.error)}).requestMessage({action:4,args:{lufiFile:n.lufiFile}})}),i=>R(i)))},Tn=t=>(t.status=3,G(t.requestMessage({action:5,args:{lufiFile:t.lufiFile}}))),In=(t,e)=>{let r=ne.fromRemoveUrl(t,e),n=new ve(r);return b.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(s.data.error)}).requestMessage({action:7,args:{lufiFile:r}})}),i=>R(i))},zn=t=>(t.status=2,G(t.requestMessage({action:8,args:{lufiFile:t.lufiFile}}))),Fn=(t,e,r=Sn)=>{let n=Math.ceil(t.size/r);if(de[e].totalChunks=n,n>0){let i=[];for(let o=0;o<n;o++){let s=o*r,a=Math.min(s+r,t.size);i.push(t.slice(s,a,t.type))}return se(i)}else return Q(new rt)},Bn=(t,e,r=0,n=!1,i=!1,o="documents.zip",s="",a=1)=>{let c=[];return i?e.length===1&&e[0].type==="application/zip"?c.push(Rt(t,e[0],r,n,i,s,a)):c.push(Tr(e).andThen(u=>Ir(u,o).andThen(h=>(Tt.emit("ARCHIVE_CREATED",h),Rt(t,h,r,n,i,s,a))))):e.forEach(u=>{c.push(Rt(t,u,r,n,i,s,a))}),b.combine(c)},Rt=(t,e,r,n,i,o,s)=>cr(s).andThen(a=>b.fromPromise(Ve(o).then(c=>(de[a]=new ne(t.toString(),{delay:r,delAtFirstView:n,zipped:i,password:c,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:a,server:""}}),a)),c=>R(c))).andThen(a=>{let c=new ve(de[a]);return Fn(e,a).asyncAndThen(u=>{de[a].uploadStatus=4;let h=new Promise((p,v)=>{c.onMessage(m=>{switch(zr(p,v,c,m),m.data.event){case"UPLOAD_COMPLETE":c.complete(),c.lufiFile.uploadStatus=1;break}})}),l=async p=>{for(let[v,m]of p.entries()){let w=await m.arrayBuffer();c.requestMessage({action:9,args:{chunk:{buffer:w,index:v},lufiFile:de[a],algo:s}},[w])}};return b.fromPromise(l(u),p=>R(p)).andThen(()=>b.fromPromise(h,p=>R(p)))}).orElse(u=>Z(u))}),zr=(t,e,r,n)=>{n.data.event==="SOCKET_OPENED"&&t(r),n.data.event==="OPERATION_FAILED"&&e(n.data.error)},_n=()=>Object.values(de).filter(t=>t.uploadStatus===4),jn=t=>Object.keys(_n()).indexOf(t);export{Le as CryptoAlgorithm,b as ResultAsync,Q as err,Z as errAsync,on as isSecureContext,It as lufi,se as ok,G as okAsync};