@libp2p/aes-ctr
Version:
Streaming AES-CTR for node and browsers
5 lines • 62.1 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PAesCtr = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Libp2PAesCtr=(()=>{var Ne=Object.create;var at=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),A=(t,e)=>{for(var r in e)at(t,r,{get:e[r],enumerable:!0})},Gt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Pe(e))!je.call(t,n)&&n!==r&&at(t,n,{get:()=>e[n],enumerable:!(i=Ve(e,n))||i.enumerable});return t};var Kt=(t,e,r)=>(r=t!=null?Ne(Re(t)):{},Gt(e||!t||!t.__esModule?at(r,"default",{value:t,enumerable:!0}):r,t)),qe=t=>Gt(at({},"__esModule",{value:!0}),t);var q=j((ui,Qt)=>{Qt.exports={options:{usePureJavaScript:!1}}});var te=j((li,Yt)=>{var gt={};Yt.exports=gt;var Zt={};gt.encode=function(t,e,r){if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');var i="";if(!(t instanceof Uint8Array))i=$e(t,e);else{var n=0,a=e.length,s=e.charAt(0),h=[0];for(n=0;n<t.length;++n){for(var f=0,c=t[n];f<h.length;++f)c+=h[f]<<8,h[f]=c%a,c=c/a|0;for(;c>0;)h.push(c%a),c=c/a|0}for(n=0;t[n]===0&&n<t.length-1;++n)i+=s;for(n=h.length-1;n>=0;--n)i+=e[h[n]]}if(r){var u=new RegExp(".{1,"+r+"}","g");i=i.match(u).join(`\r
`)}return i};gt.decode=function(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');var r=Zt[e];if(!r){r=Zt[e]=[];for(var i=0;i<e.length;++i)r[e.charCodeAt(i)]=i}t=t.replace(/\s/g,"");for(var n=e.length,a=e.charAt(0),s=[0],i=0;i<t.length;i++){var h=r[t.charCodeAt(i)];if(h===void 0)return;for(var f=0,c=h;f<s.length;++f)c+=s[f]*n,s[f]=c&255,c>>=8;for(;c>0;)s.push(c&255),c>>=8}for(var u=0;t[u]===a&&u<t.length-1;++u)s.push(0);return typeof Buffer<"u"?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};function $e(t,e){var r=0,i=e.length,n=e.charAt(0),a=[0];for(r=0;r<t.length();++r){for(var s=0,h=t.at(r);s<a.length;++s)h+=a[s]<<8,a[s]=h%i,h=h/i|0;for(;h>0;)a.push(h%i),h=h/i|0}var f="";for(r=0;t.at(r)===0&&r<t.length()-1;++r)f+=n;for(r=a.length-1;r>=0;--r)f+=e[a[r]];return f}});var ht=j((pi,ne)=>{var ee=q(),re=te(),o=ne.exports=ee.util=ee.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){o.nextTick=process.nextTick,typeof setImmediate=="function"?o.setImmediate=setImmediate:o.setImmediate=o.nextTick;return}if(typeof setImmediate=="function"){o.setImmediate=function(){return setImmediate.apply(void 0,arguments)},o.nextTick=function(h){return setImmediate(h)};return}if(o.setImmediate=function(h){setTimeout(h,0)},typeof window<"u"&&typeof window.postMessage=="function"){let h=function(f){if(f.source===window&&f.data===t){f.stopPropagation();var c=e.slice();e.length=0,c.forEach(function(u){u()})}};var s=h,t="forge.setImmediate",e=[];o.setImmediate=function(f){e.push(f),e.length===1&&window.postMessage(t,"*")},window.addEventListener("message",h,!0)}if(typeof MutationObserver<"u"){var r=Date.now(),i=!0,n=document.createElement("div"),e=[];new MutationObserver(function(){var f=e.slice();e.length=0,f.forEach(function(c){c()})}).observe(n,{attributes:!0});var a=o.setImmediate;o.setImmediate=function(f){Date.now()-r>15?(r=Date.now(),a(f)):(e.push(f),e.length===1&&n.setAttribute("a",i=!i))}}o.nextTick=o.setImmediate})();o.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;o.globalScope=function(){return o.isNodejs?globalThis:typeof self>"u"?window:self}();o.isArray=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"};o.isArrayBuffer=function(t){return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer};o.isArrayBufferView=function(t){return t&&o.isArrayBuffer(t.buffer)&&t.byteLength!==void 0};function Q(t){if(!(t===8||t===16||t===24||t===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+t)}o.ByteBuffer=yt;function yt(t){if(this.data="",this.read=0,typeof t=="string")this.data=t;else if(o.isArrayBuffer(t)||o.isArrayBufferView(t))if(typeof Buffer<"u"&&t instanceof Buffer)this.data=t.toString("binary");else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch{for(var r=0;r<e.length;++r)this.putByte(e[r])}}else(t instanceof yt||typeof t=="object"&&typeof t.data=="string"&&typeof t.read=="number")&&(this.data=t.data,this.read=t.read);this._constructedStringLength=0}o.ByteStringBuffer=yt;var He=4096;o.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>He&&(this.data.substr(0,1),this._constructedStringLength=0)};o.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};o.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};o.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))};o.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this};o.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this};o.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(o.encodeUtf8(t))};o.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};o.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};o.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};o.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255))};o.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))};o.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))};o.ByteStringBuffer.prototype.putInt=function(t,e){Q(e);var r="";do e-=8,r+=String.fromCharCode(t>>e&255);while(e>0);return this.putBytes(r)};o.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<<e-1),this.putInt(t,e)};o.ByteStringBuffer.prototype.putBuffer=function(t){return this.putBytes(t.getBytes())};o.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};o.ByteStringBuffer.prototype.getInt16=function(){var t=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,t};o.ByteStringBuffer.prototype.getInt24=function(){var t=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,t};o.ByteStringBuffer.prototype.getInt32=function(){var t=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,t};o.ByteStringBuffer.prototype.getInt16Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,t};o.ByteStringBuffer.prototype.getInt24Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,t};o.ByteStringBuffer.prototype.getInt32Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,t};o.ByteStringBuffer.prototype.getInt=function(t){Q(t);var e=0;do e=(e<<8)+this.data.charCodeAt(this.read++),t-=8;while(t>0);return e};o.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};o.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};o.ByteStringBuffer.prototype.bytes=function(t){return typeof t>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};o.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)};o.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this};o.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};o.ByteStringBuffer.prototype.copy=function(){var t=o.createBuffer(this.data);return t.read=this.read,t};o.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};o.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};o.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this};o.ByteStringBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.length;++e){var r=this.data.charCodeAt(e);r<16&&(t+="0"),t+=r.toString(16)}return t};o.ByteStringBuffer.prototype.toString=function(){return o.decodeUtf8(this.bytes())};function Je(t,e){e=e||{},this.read=e.readOffset||0,this.growSize=e.growSize||1024;var r=o.isArrayBuffer(t),i=o.isArrayBufferView(t);if(r||i){r?this.data=new DataView(t):this.data=new DataView(t.buffer,t.byteOffset,t.byteLength),this.write="writeOffset"in e?e.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,t!=null&&this.putBytes(t),"writeOffset"in e&&(this.write=e.writeOffset)}o.DataBuffer=Je;o.DataBuffer.prototype.length=function(){return this.write-this.read};o.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};o.DataBuffer.prototype.accommodate=function(t,e){if(this.length()>=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),i=new Uint8Array(this.length()+e);return i.set(r),this.data=new DataView(i.buffer),this};o.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this};o.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r<e;++r)this.data.setUint8(t);return this};o.DataBuffer.prototype.putBytes=function(t,e){if(o.isArrayBufferView(t)){var r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=r.byteLength-r.byteOffset;this.accommodate(i);var n=new Uint8Array(this.data.buffer,this.write);return n.set(r),this.write+=i,this}if(o.isArrayBuffer(t)){var r=new Uint8Array(t);this.accommodate(r.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(r,this.write),this.write+=r.byteLength,this}if(t instanceof o.DataBuffer||typeof t=="object"&&typeof t.read=="number"&&typeof t.write=="number"&&o.isArrayBufferView(t.data)){var r=new Uint8Array(t.data.byteLength,t.read,t.length());this.accommodate(r.byteLength);var n=new Uint8Array(t.data.byteLength,this.write);return n.set(r),this.write+=r.byteLength,this}if(t instanceof o.ByteStringBuffer&&(t=t.data,e="binary"),e=e||"binary",typeof t=="string"){var a;if(e==="hex")return this.accommodate(Math.ceil(t.length/2)),a=new Uint8Array(this.data.buffer,this.write),this.write+=o.binary.hex.decode(t,a,this.write),this;if(e==="base64")return this.accommodate(Math.ceil(t.length/4)*3),a=new Uint8Array(this.data.buffer,this.write),this.write+=o.binary.base64.decode(t,a,this.write),this;if(e==="utf8"&&(t=o.encodeUtf8(t),e="binary"),e==="binary"||e==="raw")return this.accommodate(t.length),a=new Uint8Array(this.data.buffer,this.write),this.write+=o.binary.raw.decode(a),this;if(e==="utf16")return this.accommodate(t.length*2),a=new Uint16Array(this.data.buffer,this.write),this.write+=o.text.utf16.encode(a),this;throw new Error("Invalid encoding: "+e)}throw Error("Invalid parameter: "+t)};o.DataBuffer.prototype.putBuffer=function(t){return this.putBytes(t),t.clear(),this};o.DataBuffer.prototype.putString=function(t){return this.putBytes(t,"utf16")};o.DataBuffer.prototype.putInt16=function(t){return this.accommodate(2),this.data.setInt16(this.write,t),this.write+=2,this};o.DataBuffer.prototype.putInt24=function(t){return this.accommodate(3),this.data.setInt16(this.write,t>>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this};o.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this};o.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this};o.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this};o.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this};o.DataBuffer.prototype.putInt=function(t,e){Q(e),this.accommodate(e/8);do e-=8,this.data.setInt8(this.write++,t>>e&255);while(e>0);return this};o.DataBuffer.prototype.putSignedInt=function(t,e){return Q(e),this.accommodate(e/8),t<0&&(t+=2<<e-1),this.putInt(t,e)};o.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};o.DataBuffer.prototype.getInt16=function(){var t=this.data.getInt16(this.read);return this.read+=2,t};o.DataBuffer.prototype.getInt24=function(){var t=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,t};o.DataBuffer.prototype.getInt32=function(){var t=this.data.getInt32(this.read);return this.read+=4,t};o.DataBuffer.prototype.getInt16Le=function(){var t=this.data.getInt16(this.read,!0);return this.read+=2,t};o.DataBuffer.prototype.getInt24Le=function(){var t=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,t};o.DataBuffer.prototype.getInt32Le=function(){var t=this.data.getInt32(this.read,!0);return this.read+=4,t};o.DataBuffer.prototype.getInt=function(t){Q(t);var e=0;do e=(e<<8)+this.data.getInt8(this.read++),t-=8;while(t>0);return e};o.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};o.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};o.DataBuffer.prototype.bytes=function(t){return typeof t>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};o.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)};o.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this};o.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};o.DataBuffer.prototype.copy=function(){return new o.DataBuffer(this)};o.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this};o.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};o.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this};o.DataBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.byteLength;++e){var r=this.data.getUint8(e);r<16&&(t+="0"),t+=r.toString(16)}return t};o.DataBuffer.prototype.toString=function(t){var e=new Uint8Array(this.data,this.read,this.length());if(t=t||"utf8",t==="binary"||t==="raw")return o.binary.raw.encode(e);if(t==="hex")return o.binary.hex.encode(e);if(t==="base64")return o.binary.base64.encode(e);if(t==="utf8")return o.text.utf8.decode(e);if(t==="utf16")return o.text.utf16.decode(e);throw new Error("Invalid encoding: "+t)};o.createBuffer=function(t,e){return e=e||"raw",t!==void 0&&e==="utf8"&&(t=o.encodeUtf8(t)),new o.ByteBuffer(t)};o.fillString=function(t,e){for(var r="";e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return r};o.xorBytes=function(t,e,r){for(var i="",n="",a="",s=0,h=0;r>0;--r,++s)n=t.charCodeAt(s)^e.charCodeAt(s),h>=10&&(i+=a,a="",h=0),a+=String.fromCharCode(n),++h;return i+=a,i};o.hexToBytes=function(t){var e="",r=0;for(t.length&!0&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r<t.length;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e};o.bytesToHex=function(t){return o.createBuffer(t).toHex()};o.int32ToBytes=function(t){return String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255)};var T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",M=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],ie="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";o.encode64=function(t,e){for(var r="",i="",n,a,s,h=0;h<t.length;)n=t.charCodeAt(h++),a=t.charCodeAt(h++),s=t.charCodeAt(h++),r+=T.charAt(n>>2),r+=T.charAt((n&3)<<4|a>>4),isNaN(a)?r+="==":(r+=T.charAt((a&15)<<2|s>>6),r+=isNaN(s)?"=":T.charAt(s&63)),e&&r.length>e&&(i+=r.substr(0,e)+`\r
`,r=r.substr(e));return i+=r,i};o.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e="",r,i,n,a,s=0;s<t.length;)r=M[t.charCodeAt(s++)-43],i=M[t.charCodeAt(s++)-43],n=M[t.charCodeAt(s++)-43],a=M[t.charCodeAt(s++)-43],e+=String.fromCharCode(r<<2|i>>4),n!==64&&(e+=String.fromCharCode((i&15)<<4|n>>2),a!==64&&(e+=String.fromCharCode((n&3)<<6|a)));return e};o.encodeUtf8=function(t){return unescape(encodeURIComponent(t))};o.decodeUtf8=function(t){return decodeURIComponent(escape(t))};o.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:re.encode,decode:re.decode}};o.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)};o.binary.raw.decode=function(t,e,r){var i=e;i||(i=new Uint8Array(t.length)),r=r||0;for(var n=r,a=0;a<t.length;++a)i[n++]=t.charCodeAt(a);return e?n-r:i};o.binary.hex.encode=o.bytesToHex;o.binary.hex.decode=function(t,e,r){var i=e;i||(i=new Uint8Array(Math.ceil(t.length/2))),r=r||0;var n=0,a=r;for(t.length&1&&(n=1,i[a++]=parseInt(t[0],16));n<t.length;n+=2)i[a++]=parseInt(t.substr(n,2),16);return e?a-r:i};o.binary.base64.encode=function(t,e){for(var r="",i="",n,a,s,h=0;h<t.byteLength;)n=t[h++],a=t[h++],s=t[h++],r+=T.charAt(n>>2),r+=T.charAt((n&3)<<4|a>>4),isNaN(a)?r+="==":(r+=T.charAt((a&15)<<2|s>>6),r+=isNaN(s)?"=":T.charAt(s&63)),e&&r.length>e&&(i+=r.substr(0,e)+`\r
`,r=r.substr(e));return i+=r,i};o.binary.base64.decode=function(t,e,r){var i=e;i||(i=new Uint8Array(Math.ceil(t.length/4)*3)),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),r=r||0;for(var n,a,s,h,f=0,c=r;f<t.length;)n=M[t.charCodeAt(f++)-43],a=M[t.charCodeAt(f++)-43],s=M[t.charCodeAt(f++)-43],h=M[t.charCodeAt(f++)-43],i[c++]=n<<2|a>>4,s!==64&&(i[c++]=(a&15)<<4|s>>2,h!==64&&(i[c++]=(s&3)<<6|h));return e?c-r:i.subarray(0,c)};o.binary.base58.encode=function(t,e){return o.binary.baseN.encode(t,ie,e)};o.binary.base58.decode=function(t,e){return o.binary.baseN.decode(t,ie,e)};o.text={utf8:{},utf16:{}};o.text.utf8.encode=function(t,e,r){t=o.encodeUtf8(t);var i=e;i||(i=new Uint8Array(t.length)),r=r||0;for(var n=r,a=0;a<t.length;++a)i[n++]=t.charCodeAt(a);return e?n-r:i};o.text.utf8.decode=function(t){return o.decodeUtf8(String.fromCharCode.apply(null,t))};o.text.utf16.encode=function(t,e,r){var i=e;i||(i=new Uint8Array(t.length*2));var n=new Uint16Array(i.buffer);r=r||0;for(var a=r,s=r,h=0;h<t.length;++h)n[s++]=t.charCodeAt(h),a+=2;return e?a-r:i};o.text.utf16.decode=function(t){return String.fromCharCode.apply(null,new Uint16Array(t.buffer))};o.deflate=function(t,e,r){if(e=o.decode64(t.deflate(o.encode64(e)).rval),r){var i=2,n=e.charCodeAt(1);n&32&&(i=6),e=e.substring(i,e.length-4)}return e};o.inflate=function(t,e,r){var i=t.inflate(o.encode64(e)).rval;return i===null?null:o.decode64(i)};var vt=function(t,e,r){if(!t)throw new Error("WebStorage not available.");var i;if(r===null?i=t.removeItem(e):(r=o.encode64(JSON.stringify(r)),i=t.setItem(e,r)),typeof i<"u"&&i.rval!==!0){var n=new Error(i.error.message);throw n.id=i.error.id,n.name=i.error.name,n}},mt=function(t,e){if(!t)throw new Error("WebStorage not available.");var r=t.getItem(e);if(t.init)if(r.rval===null){if(r.error){var i=new Error(r.error.message);throw i.id=r.error.id,i.name=r.error.name,i}r=null}else r=r.rval;return r!==null&&(r=JSON.parse(o.decode64(r))),r},Ge=function(t,e,r,i){var n=mt(t,e);n===null&&(n={}),n[r]=i,vt(t,e,n)},Ke=function(t,e,r){var i=mt(t,e);return i!==null&&(i=r in i?i[r]:null),i},We=function(t,e,r){var i=mt(t,e);if(i!==null&&r in i){delete i[r];var n=!0;for(var a in i){n=!1;break}n&&(i=null),vt(t,e,i)}},Xe=function(t,e){vt(t,e,null)},st=function(t,e,r){var i=null;typeof r>"u"&&(r=["web","flash"]);var n,a=!1,s=null;for(var h in r){n=r[h];try{if(n==="flash"||n==="both"){if(e[0]===null)throw new Error("Flash local storage not available.");i=t.apply(this,e),a=n==="flash"}(n==="web"||n==="both")&&(e[0]=localStorage,i=t.apply(this,e),a=!0)}catch(f){s=f}if(a)break}if(!a)throw s;return i};o.setItem=function(t,e,r,i,n){st(Ge,arguments,n)};o.getItem=function(t,e,r,i){return st(Ke,arguments,i)};o.removeItem=function(t,e,r,i){st(We,arguments,i)};o.clearItems=function(t,e,r){st(Xe,arguments,r)};o.isEmpty=function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0};o.format=function(t){for(var e=/%./g,r,i,n=0,a=[],s=0;r=e.exec(t);){i=t.substring(s,e.lastIndex-2),i.length>0&&a.push(i),s=e.lastIndex;var h=r[0][1];switch(h){case"s":case"o":n<arguments.length?a.push(arguments[n+++1]):a.push("<?>");break;case"%":a.push("%");break;default:a.push("<%"+h+"?>")}}return a.push(t.substring(s)),a.join("")};o.formatNumber=function(t,e,r,i){var n=t,a=isNaN(e=Math.abs(e))?2:e,s=r===void 0?",":r,h=i===void 0?".":i,f=n<0?"-":"",c=parseInt(n=Math.abs(+n||0).toFixed(a),10)+"",u=c.length>3?c.length%3:0;return f+(u?c.substr(0,u)+h:"")+c.substr(u).replace(/(\d{3})(?=\d)/g,"$1"+h)+(a?s+Math.abs(n-c).toFixed(a).slice(2):"")};o.formatSize=function(t){return t>=1073741824?t=o.formatNumber(t/1073741824,2,".","")+" GiB":t>=1048576?t=o.formatNumber(t/1048576,2,".","")+" MiB":t>=1024?t=o.formatNumber(t/1024,0)+" KiB":t=o.formatNumber(t,0)+" bytes",t};o.bytesFromIP=function(t){return t.indexOf(".")!==-1?o.bytesFromIPv4(t):t.indexOf(":")!==-1?o.bytesFromIPv6(t):null};o.bytesFromIPv4=function(t){if(t=t.split("."),t.length!==4)return null;for(var e=o.createBuffer(),r=0;r<t.length;++r){var i=parseInt(t[r],10);if(isNaN(i))return null;e.putByte(i)}return e.getBytes()};o.bytesFromIPv6=function(t){var e=0;t=t.split(":").filter(function(s){return s.length===0&&++e,!0});for(var r=(8-t.length+e)*2,i=o.createBuffer(),n=0;n<8;++n){if(!t[n]||t[n].length===0){i.fillWithByte(0,r),r=0;continue}var a=o.hexToBytes(t[n]);a.length<2&&i.putByte(0),i.putBytes(a)}return i.getBytes()};o.bytesToIP=function(t){return t.length===4?o.bytesToIPv4(t):t.length===16?o.bytesToIPv6(t):null};o.bytesToIPv4=function(t){if(t.length!==4)return null;for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e.join(".")};o.bytesToIPv6=function(t){if(t.length!==16)return null;for(var e=[],r=[],i=0,n=0;n<t.length;n+=2){for(var a=o.bytesToHex(t[n]+t[n+1]);a[0]==="0"&&a!=="0";)a=a.substr(1);if(a==="0"){var s=r[r.length-1],h=e.length;!s||h!==s.end+1?r.push({start:h,end:h}):(s.end=h,s.end-s.start>r[i].end-r[i].start&&(i=r.length-1))}e.push(a)}if(r.length>0){var f=r[i];f.end-f.start>0&&(e.splice(f.start,f.end-f.start+1,""),f.start===0&&e.unshift(""),f.end===7&&e.push(""))}return e.join(":")};o.estimateCores=function(t,e){if(typeof t=="function"&&(e=t,t={}),t=t||{},"cores"in o&&!t.update)return e(null,o.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return o.cores=navigator.hardwareConcurrency,e(null,o.cores);if(typeof Worker>"u")return o.cores=1,e(null,o.cores);if(typeof Blob>"u")return o.cores=2,e(null,o.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(s){for(var h=Date.now(),f=h+4;Date.now()<f;);self.postMessage({st:h,et:f})})}.toString(),")()"],{type:"application/javascript"}));i([],5,16);function i(s,h,f){if(h===0){var c=Math.floor(s.reduce(function(u,d){return u+d},0)/s.length);return o.cores=Math.max(1,c),URL.revokeObjectURL(r),e(null,o.cores)}n(f,function(u,d){s.push(a(f,d)),i(s,h-1,f)})}function n(s,h){for(var f=[],c=[],u=0;u<s;++u){var d=new Worker(r);d.addEventListener("message",function(v){if(c.push(v.data),c.length===s){for(var m=0;m<s;++m)f[m].terminate();h(null,c)}}),f.push(d)}for(var u=0;u<s;++u)f[u].postMessage(u)}function a(s,h){for(var f=[],c=0;c<s;++c)for(var u=h[c],d=f[c]=[],v=0;v<s;++v)if(c!==v){var m=h[v];(u.st>m.st&&u.st<m.et||m.st>u.st&&m.st<u.et)&&d.push(v)}return f.reduce(function(l,g){return Math.max(l,g.length)},0)}}});var oe=j((di,ae)=>{var w=q();ht();ae.exports=w.cipher=w.cipher||{};w.cipher.algorithms=w.cipher.algorithms||{};w.cipher.createCipher=function(t,e){var r=t;if(typeof r=="string"&&(r=w.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new w.cipher.BlockCipher({algorithm:r,key:e,decrypt:!1})};w.cipher.createDecipher=function(t,e){var r=t;if(typeof r=="string"&&(r=w.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new w.cipher.BlockCipher({algorithm:r,key:e,decrypt:!0})};w.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),w.cipher.algorithms[t]=e};w.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in w.cipher.algorithms?w.cipher.algorithms[t]:null};var Bt=w.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};Bt.prototype.start=function(t){t=t||{};var e={};for(var r in t)e[r]=t[r];e.decrypt=this._decrypt,this._finish=!1,this._input=w.util.createBuffer(),this.output=t.output||w.util.createBuffer(),this.mode.start(e)};Bt.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};Bt.prototype.finish=function(t){t&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(r){return t(this.blockSize,r,!1)},this.mode.unpad=function(r){return t(this.blockSize,r,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,e))}});var he=j((gi,se)=>{var _=q();ht();_.cipher=_.cipher||{};var p=se.exports=_.cipher.modes=_.cipher.modes||{};p.ecb=function(t){t=t||{},this.name="ECB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};p.ecb.prototype.start=function(t){};p.ecb.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i])};p.ecb.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i])};p.ecb.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};p.ecb.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),i=t.at(r-1);return i>this.blockSize<<2?!1:(t.truncate(i),!0)};p.cbc=function(t){t=t||{},this.name="CBC",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};p.cbc.prototype.start=function(t){if(t.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in t)this._iv=ft(t.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};p.cbc.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var i=0;i<this._ints;++i)this._inBlock[i]=this._prev[i]^t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]);this._prev=this._outBlock};p.cbc.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._prev[i]^this._outBlock[i]);this._prev=this._inBlock.slice(0)};p.cbc.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};p.cbc.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),i=t.at(r-1);return i>this.blockSize<<2?!1:(t.truncate(i),!0)};p.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=_.util.createBuffer(),this._partialBytes=0};p.cfb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=ft(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};p.cfb.prototype.encrypt=function(t,e,r){var i=t.length();if(i===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&i>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32()^this._outBlock[n],e.putInt32(this._inBlock[n]);return}var a=(this.blockSize-i)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=t.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(a>0)t.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0};p.cfb.prototype.decrypt=function(t,e,r){var i=t.length();if(i===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&i>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32(),e.putInt32(this._inBlock[n]^this._outBlock[n]);return}var a=(this.blockSize-i)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=t.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(a>0)t.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0};p.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=_.util.createBuffer(),this._partialBytes=0};p.ofb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=ft(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};p.ofb.prototype.encrypt=function(t,e,r){var i=t.length();if(t.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&i>=this.blockSize){for(var n=0;n<this._ints;++n)e.putInt32(t.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var a=(this.blockSize-i)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(t.getInt32()^this._outBlock[n]);if(a>0)t.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0};p.ofb.prototype.decrypt=p.ofb.prototype.encrypt;p.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=_.util.createBuffer(),this._partialBytes=0};p.ctr.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=ft(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};p.ctr.prototype.encrypt=function(t,e,r){var i=t.length();if(i===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&i>=this.blockSize)for(var n=0;n<this._ints;++n)e.putInt32(t.getInt32()^this._outBlock[n]);else{var a=(this.blockSize-i)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(t.getInt32()^this._outBlock[n]);if(a>0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}ct(this._inBlock)};p.ctr.prototype.decrypt=p.ctr.prototype.encrypt;p.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=_.util.createBuffer(),this._partialBytes=0,this._R=3774873600};p.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var e=_.util.createBuffer(t.iv);this._cipherLength=0;var r;if("additionalData"in t?r=_.util.createBuffer(t.additionalData):r=_.util.createBuffer(),"tagLength"in t?this._tagLength=t.tagLength:this._tagLength=128,this._tag=null,t.decrypt&&(this._tag=_.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=e.length();if(i===12)this._j0=[e.getInt32(),e.getInt32(),e.getInt32(),1];else{for(this._j0=[0,0,0,0];e.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(bt(i*8)))}this._inBlock=this._j0.slice(0),ct(this._inBlock),this._partialBytes=0,r=_.util.createBuffer(r),this._aDataLength=bt(r.length()*8);var n=r.length()%this.blockSize;for(n&&r.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])};p.gcm.prototype.encrypt=function(t,e,r){var i=t.length();if(i===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&i>=this.blockSize){for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n]^=t.getInt32());this._cipherLength+=this.blockSize}else{var a=(this.blockSize-i)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(t.getInt32()^this._outBlock[n]);if(a<=0||r){if(r){var s=i%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),ct(this._inBlock)};p.gcm.prototype.decrypt=function(t,e,r){var i=t.length();if(i<this.blockSize&&!(r&&i>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),ct(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n]^this._hashBlock[n]);i<this.blockSize?this._cipherLength+=i%this.blockSize:this._cipherLength+=this.blockSize};p.gcm.prototype.afterFinish=function(t,e){var r=!0;e.decrypt&&e.overflow&&t.truncate(this.blockSize-e.overflow),this.tag=_.util.createBuffer();var i=this._aDataLength.concat(bt(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,i);var n=[];this.cipher.encrypt(this._j0,n);for(var a=0;a<this._ints;++a)this.tag.putInt32(this._s[a]^n[a]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),e.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r};p.gcm.prototype.multiply=function(t,e){for(var r=[0,0,0,0],i=e.slice(0),n=0;n<128;++n){var a=t[n/32|0]&1<<31-n%32;a&&(r[0]^=i[0],r[1]^=i[1],r[2]^=i[2],r[3]^=i[3]),this.pow(i,i)}return r};p.gcm.prototype.pow=function(t,e){for(var r=t[3]&1,i=3;i>0;--i)e[i]=t[i]>>>1|(t[i-1]&1)<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)};p.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var i=r/8|0,n=t[i]>>>(7-r%8)*4&15,a=this._m[r][n];e[0]^=a[0],e[1]^=a[1],e[2]^=a[2],e[3]^=a[3]}return e};p.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)};p.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,i=4*r,n=16*r,a=new Array(n),s=0;s<n;++s){var h=[0,0,0,0],f=s/i|0,c=(i-1-s%i)*e;h[f]=1<<e-1<<c,a[s]=this.generateSubHashTable(this.multiply(h,t),e)}return a};p.gcm.prototype.generateSubHashTable=function(t,e){var r=1<<e,i=r>>>1,n=new Array(r);n[i]=t.slice(0);for(var a=i>>>1;a>0;)this.pow(n[2*a],n[a]=[]),a>>=1;for(a=2;a<i;){for(var s=1;s<a;++s){var h=n[a],f=n[s];n[a+s]=[h[0]^f[0],h[1]^f[1],h[2]^f[2],h[3]^f[3]]}a*=2}for(n[0]=[0,0,0,0],a=i+1;a<r;++a){var c=n[a^i];n[a]=[t[0]^c[0],t[1]^c[1],t[2]^c[2],t[3]^c[3]]}return n};function ft(t,e){if(typeof t=="string"&&(t=_.util.createBuffer(t)),_.util.isArray(t)&&t.length>4){var r=t;t=_.util.createBuffer();for(var i=0;i<r.length;++i)t.putByte(r[i])}if(t.length()<e)throw new Error("Invalid IV length; got "+t.length()+" bytes and expected "+e+" bytes.");if(!_.util.isArray(t)){for(var n=[],a=e/4,i=0;i<a;++i)n.push(t.getInt32());t=n}return t}function ct(t){t[t.length-1]=t[t.length-1]+1&4294967295}function bt(t){return[t/4294967296|0,t&4294967295]}});var pe=j((yi,le)=>{var y=q();oe();he();ht();le.exports=y.aes=y.aes||{};y.aes.startEncrypting=function(t,e,r,i){var n=ut({key:t,output:r,decrypt:!1,mode:i});return n.start(e),n};y.aes.createEncryptionCipher=function(t,e){return ut({key:t,output:null,decrypt:!1,mode:e})};y.aes.startDecrypting=function(t,e,r,i){var n=ut({key:t,output:r,decrypt:!0,mode:i});return n.start(e),n};y.aes.createDecryptionCipher=function(t,e){return ut({key:t,output:null,decrypt:!0,mode:e})};y.aes.Algorithm=function(t,e){xt||ce();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(i,n){return _t(r._w,i,n,!1)},decrypt:function(i,n){return _t(r._w,i,n,!0)}}}),r._init=!1};y.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e=t.key,r;if(typeof e=="string"&&(e.length===16||e.length===24||e.length===32))e=y.util.createBuffer(e);else if(y.util.isArray(e)&&(e.length===16||e.length===24||e.length===32)){r=e,e=y.util.createBuffer();for(var i=0;i<r.length;++i)e.putByte(r[i])}if(!y.util.isArray(e)){r=e,e=[];var n=r.length();if(n===16||n===24||n===32){n=n>>>2;for(var i=0;i<n;++i)e.push(r.getInt32())}}if(!y.util.isArray(e)||!(e.length===4||e.length===6||e.length===8))throw new Error("Invalid key parameter.");var a=this.mode.name,s=["CFB","OFB","CTR","GCM"].indexOf(a)!==-1;this._w=ue(e,t.decrypt&&!s),this._init=!0}};y.aes._expandKey=function(t,e){return xt||ce(),ue(t,e)};y.aes._updateBlock=_t;H("AES-ECB",y.cipher.modes.ecb);H("AES-CBC",y.cipher.modes.cbc);H("AES-CFB",y.cipher.modes.cfb);H("AES-OFB",y.cipher.modes.ofb);H("AES-CTR",y.cipher.modes.ctr);H("AES-GCM",y.cipher.modes.gcm);function H(t,e){var r=function(){return new y.aes.Algorithm(t,e)};y.cipher.registerAlgorithm(t,r)}var xt=!1,$=4,S,wt,fe,V,z;function ce(){xt=!0,fe=[0,1,2,4,8,16,32,64,128,27,54];for(var t=new Array(256),e=0;e<128;++e)t[e]=e<<1,t[e+128]=e+128<<1^283;S=new Array(256),wt=new Array(256),V=new Array(4),z=new Array(4);for(var e=0;e<4;++e)V[e]=new Array(256),z[e]=new Array(256);for(var r=0,i=0,n,a,s,h,f,c,u,e=0;e<256;++e){h=i^i<<1^i<<2^i<<3^i<<4,h=h>>8^h&255^99,S[r]=h,wt[h]=r,f=t[h],n=t[r],a=t[n],s=t[a],c=f<<24^h<<16^h<<8^(h^f),u=(n^a^s)<<24^(r^s)<<16^(r^a^s)<<8^(r^n^s);for(var d=0;d<4;++d)V[d][r]=c,z[d][h]=u,c=c<<24|c>>>8,u=u<<24|u>>>8;r===0?r=i=1:(r=n^t[t[t[n^s]]],i^=t[t[i]])}}function ue(t,e){for(var r=t.slice(0),i,n=1,a=r.length,s=a+6+1,h=$*s,f=a;f<h;++f)i=r[f-1],f%a===0?(i=S[i>>>16&255]<<24^S[i>>>8&255]<<16^S[i&255]<<8^S[i>>>24]^fe[n]<<24,n++):a>6&&f%a===4&&(i=S[i>>>24]<<24^S[i>>>16&255]<<16^S[i>>>8&255]<<8^S[i&255]),r[f]=r[f-a]^i;if(e){var c,u=z[0],d=z[1],v=z[2],m=z[3],l=r.slice(0);h=r.length;for(var f=0,g=h-$;f<h;f+=$,g-=$)if(f===0||f===h-$)l[f]=r[g],l[f+1]=r[g+3],l[f+2]=r[g+2],l[f+3]=r[g+1];else for(var x=0;x<$;++x)c=r[g+x],l[f+(3&-x)]=u[S[c>>>24]]^d[S[c>>>16&255]]^v[S[c>>>8&255]]^m[S[c&255]];r=l}return r}function _t(t,e,r,i){var n=t.length/4-1,a,s,h,f,c;i?(a=z[0],s=z[1],h=z[2],f=z[3],c=wt):(a=V[0],s=V[1],h=V[2],f=V[3],c=S);var u,d,v,m,l,g,x;u=e[0]^t[0],d=e[i?3:1]^t[1],v=e[2]^t[2],m=e[i?1:3]^t[3];for(var b=3,C=1;C<n;++C)l=a[u>>>24]^s[d>>>16&255]^h[v>>>8&255]^f[m&255]^t[++b],g=a[d>>>24]^s[v>>>16&255]^h[m>>>8&255]^f[u&255]^t[++b],x=a[v>>>24]^s[m>>>16&255]^h[u>>>8&255]^f[d&255]^t[++b],m=a[m>>>24]^s[u>>>16&255]^h[d>>>8&255]^f[v&255]^t[++b],u=l,d=g,v=x;r[0]=c[u>>>24]<<24^c[d>>>16&255]<<16^c[v>>>8&255]<<8^c[m&255]^t[++b],r[i?3:1]=c[d>>>24]<<24^c[v>>>16&255]<<16^c[m>>>8&255]<<8^c[u&255]^t[++b],r[2]=c[v>>>24]<<24^c[m>>>16&255]<<16^c[u>>>8&255]<<8^c[d&255]^t[++b],r[i?1:3]=c[m>>>24]<<24^c[u>>>16&255]<<16^c[d>>>8&255]<<8^c[v&255]^t[++b]}function ut(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="AES-"+e,i;t.decrypt?i=y.cipher.createDecipher(r,t.key):i=y.cipher.createCipher(r,t.key);var n=i.start;return i.start=function(a,s){var h=null;s instanceof y.util.ByteBuffer&&(h=s,s={}),s=s||{},s.output=h,s.iv=a,n.call(i,s)},i}});var oi={};A(oi,{create:()=>ai});var ot=class extends Error{static name="InvalidKeyLengthError";constructor(e="Invalid key length"){super(e),this.name="InvalidKeyLengthError"}};var Wt={16:"aes-128-ctr",32:"aes-256-ctr"};function Xt(t){if(t.length===16||t.length===32)return Wt[t.length];let e=Object.entries(Wt).map(([r,i])=>`${r} (${i})`).join(" / ");throw new ot(`Invalid key length ${t.length} bytes. Must be ${e}`)}var pn=Kt(pe(),1),it=Kt(q(),1);var kt={};A(kt,{base10:()=>rr});var vi=new Uint8Array(0);function de(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function O(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ge(t){return new TextEncoder().encode(t)}function ye(t){return new TextDecoder().decode(t)}function Qe(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var a=t.charAt(n),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=n}var h=t.length,f=t.charAt(0),c=Math.log(h)/Math.log(256),u=Math.log(256)/Math.log(h);function d(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var g=0,x=0,b=0,C=l.length;b!==C&&l[b]===0;)b++,g++;for(var F=(C-b)*u+1>>>0,I=new Uint8Array(F);b!==C;){for(var E=l[b],L=0,k=F-1;(E!==0||L<x)&&k!==-1;k--,L++)E+=256*I[k]>>>0,I[k]=E%h>>>0,E=E/h>>>0;if(E!==0)throw new Error("Non-zero carry");x=L,b++}for(var U=F-x;U!==F&&I[U]===0;)U++;for(var nt=f.repeat(g);U<F;++U)nt+=t.charAt(I[U]);return nt}function v(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var g=0;if(l[g]!==" "){for(var x=0,b=0;l[g]===f;)x++,g++;for(var C=(l.length-g)*c+1>>>0,F=new Uint8Array(C);l[g];){var I=r[l.charCodeAt(g)];if(I===255)return;for(var E=0,L=C-1;(I!==0||E<b)&&L!==-1;L--,E++)I+=h*F[L]>>>0,F[L]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");b=E,g++}if(l[g]!==" "){for(var k=C-b;k!==C&&F[k]===0;)k++;for(var U=new Uint8Array(x+(C-k)),nt=x;k!==C;)U[nt++]=F[k++];return U}}}function m(l){var g=v(l);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:v,decode:m}}var Ze=Qe,Ye=Ze,me=Ye;var St=class{name;prefix;baseEncode;constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ct=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,i){this.name=e,this.prefix=r;let n=r.codePointAt(0);if(n===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Be(this,e)}},At=class{decoders;constructor(e){this.decoders=e}or(e){return Be(this,e)}decode(e){let r=e[0],i=this.decoders[r];if(i!=null)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Be(t,e){return new At({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var It=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new St(e,r,i),this.decoder=new Ct(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function J({name:t,prefix:e,encode:r,decode:i}){return new It(t,e,r,i)}function N({name:t,prefix:e,alphabet:r}){let{encode:i,decode:n}=me(r,t);return J({prefix:e,name:t,encode:i,decode:a=>O(n(a))})}function tr(t,e,r,i){let n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let a=t.length;for(;t[a-1]==="=";)--a;let s=new Uint8Array(a*r/8|0),h=0,f=0,c=0;for(let u=0;u<a;++u){let d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);f=f<<r|d,h+=r,h>=8&&(h-=8,s[c++]=255&f>>h)}if(h>=r||(255&f<<8-h)!==0)throw new SyntaxError("Unexpected end of data");return s}function er(t,e,r){let i=e[e.length-1]==="=",n=(1<<r)-1,a="",s=0,h=0;for(let f=0;f<t.length;++f)for(h=h<<8|t[f],s+=8;s>r;)s-=r,a+=e[n&h>>s];if(s!==0&&(a+=e[n&h<<r-s]),i)for(;(a.length*r&7)!==0;)a+="=";return a}function B({name:t,prefix:e,bitsPerChar:r,alphabet:i}){return J({prefix:e,name:t,encode(n){return er(n,i,r)},decode(n){return tr(n,i,r,t)}})}var rr=N({prefix:"9",name:"base10",alphabet:"0123456789"});var zt={};A(zt,{base16:()=>ir,base16upper:()=>nr});var ir=B({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),nr=B({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ft={};A(Ft,{base2:()=>ar});var ar=B({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Et={};A(Et,{base256emoji:()=>cr});var be=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C