@solarpunkltd/swarm-chat-js 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(Fe,He){typeof exports=="object"&&typeof module<"u"?He(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],He):(Fe=typeof globalThis<"u"?globalThis:Fe||self,He(Fe.SwarmStreamJs={},Fe.BeeJs))})(this,function(exports,beeJs){"use strict";var Er=Object.defineProperty;var wr=Fe=>{throw TypeError(Fe)};var Ar=(Fe,He,at)=>He in Fe?Er(Fe,He,{enumerable:!0,configurable:!0,writable:!0,value:at}):Fe[He]=at;var Ue=(Fe,He,at)=>Ar(Fe,typeof He!="symbol"?He+"":He,at),xr=(Fe,He,at)=>He.has(Fe)||wr("Cannot "+at);var Re=(Fe,He,at)=>(xr(Fe,He,"read from private field"),at?at.call(Fe):He.get(Fe)),Le=(Fe,He,at)=>He.has(Fe)?wr("Cannot add the same private member more than once"):He instanceof WeakSet?He.add(Fe):He.set(Fe,at),we=(Fe,He,at,wt)=>(xr(Fe,He,"write to private field"),wt?wt.call(Fe,at):He.set(Fe,at),at),st=(Fe,He,at)=>(xr(Fe,He,"access private method"),at);var Fe,He,at,wt,ot,St,_t,Ut,Ht,jt,Gt,Kt,zt,Vt,Wt,Jt,Zt,Xt,It,Rt,Et,$t,Yt,ur,ir,Bt,Qt,cr,_r,er,dr,tr,rr,nr,Pt,ar,yr,sr,vr,Tt,fr,or,gr;const version$1="6.13.4";async function resolveProperties(t){const e=Object.keys(t);return(await Promise.all(e.map(a=>Promise.resolve(t[a])))).reduce((a,c,o)=>(a[e[o]]=c,a),{})}function defineProperties(t,e,n){for(let a in e){let c=e[a];Object.defineProperty(t,a,{enumerable:!0,value:c,writable:!1})}}function stringify(t){if(t==null)return"null";if(Array.isArray(t))return"[ "+t.map(stringify).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let a=0;a<t.length;a++)n+=e[t[a]>>4],n+=e[t[a]&15];return n}if(typeof t=="object"&&typeof t.toJSON=="function")return stringify(t.toJSON());switch(typeof t){case"boolean":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"number":return t.toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map(n=>`${stringify(n)}: ${stringify(t[n])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function makeError(t,e,n){let a=t;{const o=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${stringify(n)}`);for(const u in n){if(u==="shortMessage")continue;const h=n[u];o.push(u+"="+stringify(h))}}o.push(`code=${e}`),o.push(`version=${version$1}`),o.length&&(t+=" ("+o.join(", ")+")")}let c;switch(e){case"INVALID_ARGUMENT":c=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":c=new RangeError(t);break;default:c=new Error(t)}return defineProperties(c,{code:e}),n&&Object.assign(c,n),c.shortMessage==null&&defineProperties(c,{shortMessage:a}),c}function assert$f(t,e,n,a){if(!t)throw makeError(e,n,a)}function assertArgument(t,e,n,a){assert$f(t,e,"INVALID_ARGUMENT",{argument:n,value:a})}const _normalizeForms=["NFD","NFC","NFKD","NFKC"].reduce((t,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");t.push(e)}catch{}return t},[]);function assertNormalize(t){assert$f(_normalizeForms.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}function assertPrivate(t,e,n){if(n==null&&(n=""),t!==e){let a=n,c="new";n&&(a+=".",c+=" "+n),assert$f(!1,`private constructor; use ${a}from* methods`,"UNSUPPORTED_OPERATION",{operation:c})}}function _getBytes(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if(typeof t=="string"&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const a=new Uint8Array((t.length-2)/2);let c=2;for(let o=0;o<a.length;o++)a[o]=parseInt(t.substring(c,c+2),16),c+=2;return a}assertArgument(!1,"invalid BytesLike value",e||"value",t)}function getBytes(t,e){return _getBytes(t,e,!1)}function getBytesCopy(t,e){return _getBytes(t,e,!0)}function isHexString$1(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&t.length!==2+2*e||e===!0&&t.length%2!==0)}function isBytesLike(t){return isHexString$1(t,!0)||t instanceof Uint8Array}const HexCharacters="0123456789abcdef";function hexlify(t){const e=getBytes(t);let n="0x";for(let a=0;a<e.length;a++){const c=e[a];n+=HexCharacters[(c&240)>>4]+HexCharacters[c&15]}return n}function concat(t){return"0x"+t.map(e=>hexlify(e).substring(2)).join("")}function dataLength(t){return isHexString$1(t,!0)?(t.length-2)/2:getBytes(t).length}function dataSlice(t,e,n){const a=getBytes(t);return n>a.length&&assert$f(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:a,length:a.length,offset:n}),hexlify(a.slice(e,n))}function zeroPad(t,e,n){const a=getBytes(t);assert$f(e>=a.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(a),length:e,offset:e+1});const c=new Uint8Array(e);return c.fill(0),c.set(a,e-a.length),hexlify(c)}function zeroPadValue(t,e){return zeroPad(t,e)}const BN_0$5=BigInt(0),BN_1$2=BigInt(1),maxValue=9007199254740991;function toTwos(t,e){let n=getBigInt(t,"value");const a=BigInt(getNumber(e,"width")),c=BN_1$2<<a-BN_1$2;if(n<BN_0$5){n=-n,assert$f(n<=c,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});const o=(BN_1$2<<a)-BN_1$2;return(~n&o)+BN_1$2}else assert$f(n<c,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return n}function mask(t,e){const n=getUint(t,"value"),a=BigInt(getNumber(e,"bits"));return n&(BN_1$2<<a)-BN_1$2}function getBigInt(t,e){switch(typeof t){case"bigint":return t;case"number":return assertArgument(Number.isInteger(t),"underflow",e||"value",t),assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),BigInt(t);case"string":try{if(t==="")throw new Error("empty string");return t[0]==="-"&&t[1]!=="-"?-BigInt(t.substring(1)):BigInt(t)}catch(n){assertArgument(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}assertArgument(!1,"invalid BigNumberish value",e||"value",t)}function getUint(t,e){const n=getBigInt(t,e);return assert$f(n>=BN_0$5,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const Nibbles$1="0123456789abcdef";function toBigInt(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=Nibbles$1[n>>4],e+=Nibbles$1[n&15];return BigInt(e)}return getBigInt(t)}function getNumber(t,e){switch(typeof t){case"bigint":return assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),Number(t);case"number":return assertArgument(Number.isInteger(t),"underflow",e||"value",t),assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),t;case"string":try{if(t==="")throw new Error("empty string");return getNumber(BigInt(t),e)}catch(n){assertArgument(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}assertArgument(!1,"invalid numeric value",e||"value",t)}function toBeHex(t,e){let a=getUint(t,"value").toString(16);{const c=getNumber(e,"width");for(assert$f(c*2>=a.length,`value exceeds width (${c} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});a.length<c*2;)a="0"+a}return"0x"+a}function toBeArray(t){const e=getUint(t,"value");if(e===BN_0$5)return new Uint8Array([]);let n=e.toString(16);n.length%2&&(n="0"+n);const a=new Uint8Array(n.length/2);for(let c=0;c<a.length;c++){const o=c*2;a[c]=parseInt(n.substring(o,o+2),16)}return a}function toQuantity(t){let e=hexlify(isBytesLike(t)?t:toBeArray(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const Alphabet="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";let Lookup=null;function getAlpha(t){if(Lookup==null){Lookup={};for(let n=0;n<Alphabet.length;n++)Lookup[Alphabet[n]]=BigInt(n)}const e=Lookup[t];return assertArgument(e!=null,"invalid base58 value","letter",t),e}const BN_0$4=BigInt(0),BN_58=BigInt(58);function encodeBase58(t){const e=getBytes(t);let n=toBigInt(e),a="";for(;n;)a=Alphabet[Number(n%BN_58)]+a,n/=BN_58;for(let c=0;c<e.length&&!e[c];c++)a=Alphabet[0]+a;return a}function decodeBase58(t){let e=BN_0$4;for(let n=0;n<t.length;n++)e*=BN_58,e+=getAlpha(t[n]);return e}function toUtf8Bytes(t,e){assertArgument(typeof t=="string","invalid string value","str",t),e!=null&&(assertNormalize(e),t=t.normalize(e));let n=[];for(let a=0;a<t.length;a++){const c=t.charCodeAt(a);if(c<128)n.push(c);else if(c<2048)n.push(c>>6|192),n.push(c&63|128);else if((c&64512)==55296){a++;const o=t.charCodeAt(a);assertArgument(a<t.length&&(o&64512)===56320,"invalid surrogate pair","str",t);const u=65536+((c&1023)<<10)+(o&1023);n.push(u>>18|240),n.push(u>>12&63|128),n.push(u>>6&63|128),n.push(u&63|128)}else n.push(c>>12|224),n.push(c>>6&63|128),n.push(c&63|128)}return new Uint8Array(n)}function hexlifyByte(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function unarrayifyInteger(t,e,n){let a=0;for(let c=0;c<n;c++)a=a*256+t[e+c];return a}function _decodeChildren(t,e,n,a){const c=[];for(;n<e+1+a;){const o=_decode(t,n);c.push(o.result),n+=o.consumed,assert$f(n<=e+1+a,"child data too short","BUFFER_OVERRUN",{buffer:t,length:a,offset:e})}return{consumed:1+a,result:c}}function _decode(t,e){assert$f(t.length!==0,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=a=>{assert$f(a<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:a})};if(t[e]>=248){const a=t[e]-247;n(e+1+a);const c=unarrayifyInteger(t,e+1,a);return n(e+1+a+c),_decodeChildren(t,e,e+1+a,a+c)}else if(t[e]>=192){const a=t[e]-192;return n(e+1+a),_decodeChildren(t,e,e+1,a)}else if(t[e]>=184){const a=t[e]-183;n(e+1+a);const c=unarrayifyInteger(t,e+1,a);n(e+1+a+c);const o=hexlify(t.slice(e+1+a,e+1+a+c));return{consumed:1+a+c,result:o}}else if(t[e]>=128){const a=t[e]-128;n(e+1+a);const c=hexlify(t.slice(e+1,e+1+a));return{consumed:1+a,result:c}}return{consumed:1,result:hexlifyByte(t[e])}}function decodeRlp(t){const e=getBytes(t,"data"),n=_decode(e,0);return assertArgument(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function arrayifyInteger(t){const e=[];for(;t;)e.unshift(t&255),t>>=8;return e}function _encode(t){if(Array.isArray(t)){let a=[];if(t.forEach(function(o){a=a.concat(_encode(o))}),a.length<=55)return a.unshift(192+a.length),a;const c=arrayifyInteger(a.length);return c.unshift(247+c.length),c.concat(a)}const e=Array.prototype.slice.call(getBytes(t,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=arrayifyInteger(e.length);return n.unshift(183+n.length),n.concat(e)}const nibbles="0123456789abcdef";function encodeRlp(t){let e="0x";for(const n of _encode(t))e+=nibbles[n>>4],e+=nibbles[n&15];return e}function uuidV4(t){const e=getBytes(t,"randomBytes");e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=hexlify(e);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join("-")}const global$1=globalThis||void 0||self;function number(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function bytes(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function hash$4(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number(t.outputLen),number(t.blockLen)}function exists(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function output(t,e){bytes(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const crypto$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const u8a$1=t=>t instanceof Uint8Array,u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),rotr=(t,e)=>t<<32-e|t>>>e,isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE)throw new Error("Non little-endian hardware is not supported");const nextTick=async()=>{};async function asyncLoop(t,e,n){let a=Date.now();for(let c=0;c<t;c++){n(c);const o=Date.now()-a;o>=0&&o<e||(await nextTick(),a+=o)}}function utf8ToBytes$1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function toBytes(t){if(typeof t=="string"&&(t=utf8ToBytes$1(t)),!u8a$1(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function concatBytes$1(...t){const e=new Uint8Array(t.reduce((a,c)=>a+c.length,0));let n=0;return t.forEach(a=>{if(!u8a$1(a))throw new Error("Uint8Array expected");e.set(a,n),n+=a.length}),e}class Hash{clone(){return this._cloneInto()}}const toStr={}.toString;function checkOpts(t,e){if(e!==void 0&&toStr.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function wrapConstructor(t){const e=a=>t().update(toBytes(a)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function randomBytes$2(t=32){if(crypto$2&&typeof crypto$2.getRandomValues=="function")return crypto$2.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class HMAC extends Hash{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,hash$4(e);const a=toBytes(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const c=this.blockLen,o=new Uint8Array(c);o.set(a.length>c?e.create().update(a).digest():a);for(let u=0;u<o.length;u++)o[u]^=54;this.iHash.update(o),this.oHash=e.create();for(let u=0;u<o.length;u++)o[u]^=106;this.oHash.update(o),o.fill(0)}update(e){return exists(this),this.iHash.update(e),this}digestInto(e){exists(this),bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:a,finished:c,destroyed:o,blockLen:u,outputLen:h}=this;return e=e,e.finished=c,e.destroyed=o,e.blockLen=u,e.outputLen=h,e.oHash=n._cloneInto(e.oHash),e.iHash=a._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac$1=(t,e,n)=>new HMAC(t,e).update(n).digest();hmac$1.create=(t,e)=>new HMAC(t,e);function pbkdf2Init(t,e,n,a){hash$4(t);const c=checkOpts({dkLen:32,asyncTick:10},a),{c:o,dkLen:u,asyncTick:h}=c;if(number(o),number(u),number(h),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=toBytes(e),b=toBytes(n),d=new Uint8Array(u),p=hmac$1.create(t,l),x=p._cloneInto().update(b);return{c:o,dkLen:u,asyncTick:h,DK:d,PRF:p,PRFSalt:x}}function pbkdf2Output(t,e,n,a,c){return t.destroy(),e.destroy(),a&&a.destroy(),c.fill(0),n}function pbkdf2$1(t,e,n,a){const{c,dkLen:o,DK:u,PRF:h,PRFSalt:l}=pbkdf2Init(t,e,n,a);let b;const d=new Uint8Array(4),p=createView(d),x=new Uint8Array(h.outputLen);for(let m=1,v=0;v<o;m++,v+=h.outputLen){const g=u.subarray(v,v+h.outputLen);p.setInt32(0,m,!1),(b=l._cloneInto(b)).update(d).digestInto(x),g.set(x.subarray(0,g.length));for(let $=1;$<c;$++){h._cloneInto(b).update(x).digestInto(x);for(let B=0;B<g.length;B++)g[B]^=x[B]}}return pbkdf2Output(h,l,u,b,x)}function setBigUint64(t,e,n,a){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,a);const c=BigInt(32),o=BigInt(4294967295),u=Number(n>>c&o),h=Number(n&o),l=a?4:0,b=a?0:4;t.setUint32(e+l,u,a),t.setUint32(e+b,h,a)}class SHA2 extends Hash{constructor(e,n,a,c){super(),this.blockLen=e,this.outputLen=n,this.padOffset=a,this.isLE=c,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){exists(this);const{view:n,buffer:a,blockLen:c}=this;e=toBytes(e);const o=e.length;for(let u=0;u<o;){const h=Math.min(c-this.pos,o-u);if(h===c){const l=createView(e);for(;c<=o-u;u+=c)this.process(l,u);continue}a.set(e.subarray(u,u+h),this.pos),this.pos+=h,u+=h,this.pos===c&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists(this),output(e,this),this.finished=!0;const{buffer:n,view:a,blockLen:c,isLE:o}=this;let{pos:u}=this;n[u++]=128,this.buffer.subarray(u).fill(0),this.padOffset>c-u&&(this.process(a,0),u=0);for(let p=u;p<c;p++)n[p]=0;setBigUint64(a,c-8,BigInt(this.length*8),o),this.process(a,0);const h=createView(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const b=l/4,d=this.get();if(b>d.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<b;p++)h.setUint32(4*p,d[p],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const a=e.slice(0,n);return this.destroy(),a}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:a,length:c,finished:o,destroyed:u,pos:h}=this;return e.length=c,e.pos=h,e.finished=o,e.destroyed=u,c%n&&e.buffer.set(a),e}}const Chi=(t,e,n)=>t&e^~t&n,Maj=(t,e,n)=>t&e^t&n^e&n,SHA256_K=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);let SHA256$2=class extends SHA2{constructor(){super(64,32,8,!1),this.A=IV[0]|0,this.B=IV[1]|0,this.C=IV[2]|0,this.D=IV[3]|0,this.E=IV[4]|0,this.F=IV[5]|0,this.G=IV[6]|0,this.H=IV[7]|0}get(){const{A:e,B:n,C:a,D:c,E:o,F:u,G:h,H:l}=this;return[e,n,a,c,o,u,h,l]}set(e,n,a,c,o,u,h,l){this.A=e|0,this.B=n|0,this.C=a|0,this.D=c|0,this.E=o|0,this.F=u|0,this.G=h|0,this.H=l|0}process(e,n){for(let p=0;p<16;p++,n+=4)SHA256_W[p]=e.getUint32(n,!1);for(let p=16;p<64;p++){const x=SHA256_W[p-15],m=SHA256_W[p-2],v=rotr(x,7)^rotr(x,18)^x>>>3,g=rotr(m,17)^rotr(m,19)^m>>>10;SHA256_W[p]=g+SHA256_W[p-7]+v+SHA256_W[p-16]|0}let{A:a,B:c,C:o,D:u,E:h,F:l,G:b,H:d}=this;for(let p=0;p<64;p++){const x=rotr(h,6)^rotr(h,11)^rotr(h,25),m=d+x+Chi(h,l,b)+SHA256_K[p]+SHA256_W[p]|0,g=(rotr(a,2)^rotr(a,13)^rotr(a,22))+Maj(a,c,o)|0;d=b,b=l,l=h,h=u+m|0,u=o,o=c,c=a,a=m+g|0}a=a+this.A|0,c=c+this.B|0,o=o+this.C|0,u=u+this.D|0,h=h+this.E|0,l=l+this.F|0,b=b+this.G|0,d=d+this.H|0,this.set(a,c,o,u,h,l,b,d)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$3=wrapConstructor(()=>new SHA256$2),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(t,e=!1){return e?{h:Number(t&U32_MASK64),l:Number(t>>_32n&U32_MASK64)}:{h:Number(t>>_32n&U32_MASK64)|0,l:Number(t&U32_MASK64)|0}}function split(t,e=!1){let n=new Uint32Array(t.length),a=new Uint32Array(t.length);for(let c=0;c<t.length;c++){const{h:o,l:u}=fromBig(t[c],e);[n[c],a[c]]=[o,u]}return[n,a]}const toBig=(t,e)=>BigInt(t>>>0)<<_32n|BigInt(e>>>0),shrSH=(t,e,n)=>t>>>n,shrSL=(t,e,n)=>t<<32-n|e>>>n,rotrSH=(t,e,n)=>t>>>n|e<<32-n,rotrSL=(t,e,n)=>t<<32-n|e>>>n,rotrBH=(t,e,n)=>t<<64-n|e>>>n-32,rotrBL=(t,e,n)=>t>>>n-32|e<<64-n,rotr32H=(t,e)=>e,rotr32L=(t,e)=>t,rotlSH=(t,e,n)=>t<<n|e>>>32-n,rotlSL=(t,e,n)=>e<<n|t>>>32-n,rotlBH=(t,e,n)=>e<<n-32|t>>>64-n,rotlBL=(t,e,n)=>t<<n-32|e>>>64-n;function add(t,e,n,a){const c=(e>>>0)+(a>>>0);return{h:t+n+(c/2**32|0)|0,l:c|0}}const add3L=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H=(t,e,n,a)=>e+n+a+(t/2**32|0)|0,add4L=(t,e,n,a)=>(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0),add4H=(t,e,n,a,c)=>e+n+a+c+(t/2**32|0)|0,add5L=(t,e,n,a,c)=>(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0)+(c>>>0),add5H=(t,e,n,a,c,o)=>e+n+a+c+o+(t/2**32|0)|0,u64={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},[SHA512_Kh,SHA512_Kl]=u64.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);let SHA512$2=class extends SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:n,Bh:a,Bl:c,Ch:o,Cl:u,Dh:h,Dl:l,Eh:b,El:d,Fh:p,Fl:x,Gh:m,Gl:v,Hh:g,Hl:$}=this;return[e,n,a,c,o,u,h,l,b,d,p,x,m,v,g,$]}set(e,n,a,c,o,u,h,l,b,d,p,x,m,v,g,$){this.Ah=e|0,this.Al=n|0,this.Bh=a|0,this.Bl=c|0,this.Ch=o|0,this.Cl=u|0,this.Dh=h|0,this.Dl=l|0,this.Eh=b|0,this.El=d|0,this.Fh=p|0,this.Fl=x|0,this.Gh=m|0,this.Gl=v|0,this.Hh=g|0,this.Hl=$|0}process(e,n){for(let F=0;F<16;F++,n+=4)SHA512_W_H[F]=e.getUint32(n),SHA512_W_L[F]=e.getUint32(n+=4);for(let F=16;F<80;F++){const H=SHA512_W_H[F-15]|0,W=SHA512_W_L[F-15]|0,Z=u64.rotrSH(H,W,1)^u64.rotrSH(H,W,8)^u64.shrSH(H,W,7),ie=u64.rotrSL(H,W,1)^u64.rotrSL(H,W,8)^u64.shrSL(H,W,7),te=SHA512_W_H[F-2]|0,ae=SHA512_W_L[F-2]|0,de=u64.rotrSH(te,ae,19)^u64.rotrBH(te,ae,61)^u64.shrSH(te,ae,6),J=u64.rotrSL(te,ae,19)^u64.rotrBL(te,ae,61)^u64.shrSL(te,ae,6),R=u64.add4L(ie,J,SHA512_W_L[F-7],SHA512_W_L[F-16]),A=u64.add4H(R,Z,de,SHA512_W_H[F-7],SHA512_W_H[F-16]);SHA512_W_H[F]=A|0,SHA512_W_L[F]=R|0}let{Ah:a,Al:c,Bh:o,Bl:u,Ch:h,Cl:l,Dh:b,Dl:d,Eh:p,El:x,Fh:m,Fl:v,Gh:g,Gl:$,Hh:B,Hl:C}=this;for(let F=0;F<80;F++){const H=u64.rotrSH(p,x,14)^u64.rotrSH(p,x,18)^u64.rotrBH(p,x,41),W=u64.rotrSL(p,x,14)^u64.rotrSL(p,x,18)^u64.rotrBL(p,x,41),Z=p&m^~p&g,ie=x&v^~x&$,te=u64.add5L(C,W,ie,SHA512_Kl[F],SHA512_W_L[F]),ae=u64.add5H(te,B,H,Z,SHA512_Kh[F],SHA512_W_H[F]),de=te|0,J=u64.rotrSH(a,c,28)^u64.rotrBH(a,c,34)^u64.rotrBH(a,c,39),R=u64.rotrSL(a,c,28)^u64.rotrBL(a,c,34)^u64.rotrBL(a,c,39),A=a&o^a&h^o&h,y=c&u^c&l^u&l;B=g|0,C=$|0,g=m|0,$=v|0,m=p|0,v=x|0,{h:p,l:x}=u64.add(b|0,d|0,ae|0,de|0),b=h|0,d=l|0,h=o|0,l=u|0,o=a|0,u=c|0;const w=u64.add3L(de,R,y);a=u64.add3H(w,ae,J,A),c=w|0}({h:a,l:c}=u64.add(this.Ah|0,this.Al|0,a|0,c|0)),{h:o,l:u}=u64.add(this.Bh|0,this.Bl|0,o|0,u|0),{h,l}=u64.add(this.Ch|0,this.Cl|0,h|0,l|0),{h:b,l:d}=u64.add(this.Dh|0,this.Dl|0,b|0,d|0),{h:p,l:x}=u64.add(this.Eh|0,this.El|0,p|0,x|0),{h:m,l:v}=u64.add(this.Fh|0,this.Fl|0,m|0,v|0),{h:g,l:$}=u64.add(this.Gh|0,this.Gl|0,g|0,$|0),{h:B,l:C}=u64.add(this.Hh|0,this.Hl|0,B|0,C|0),this.set(a,c,o,u,h,l,b,d,p,x,m,v,g,$,B,C)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sha512$2=wrapConstructor(()=>new SHA512$2);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global$1<"u")return global$1;throw new Error("unable to locate global object")}const anyGlobal=getGlobal(),crypto$1=anyGlobal.crypto||anyGlobal.msCrypto;function createHash(t){switch(t){case"sha256":return sha256$3.create();case"sha512":return sha512$2.create()}assertArgument(!1,"invalid hashing algorithm name","algorithm",t)}function createHmac(t,e){const n={sha256:sha256$3,sha512:sha512$2}[t];return assertArgument(n!=null,"invalid hmac algorithm","algorithm",t),hmac$1.create(n,e)}function pbkdf2Sync(t,e,n,a,c){const o={sha256:sha256$3,sha512:sha512$2}[c];return assertArgument(o!=null,"invalid pbkdf2 algorithm","algorithm",c),pbkdf2$1(o,t,e,{c:n,dkLen:a})}function randomBytes$1(t){assert$f(crypto$1!=null,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),assertArgument(Number.isInteger(t)&&t>0&&t<=1024,"invalid length","length",t);const e=new Uint8Array(t);return crypto$1.getRandomValues(e),e}let locked$4=!1;const _computeHmac=function(t,e,n){return createHmac(t,e).update(n).digest()};let __computeHmac=_computeHmac;function computeHmac(t,e,n){const a=getBytes(e,"key"),c=getBytes(n,"data");return hexlify(__computeHmac(t,a,c))}computeHmac._=_computeHmac,computeHmac.lock=function(){locked$4=!0},computeHmac.register=function(t){if(locked$4)throw new Error("computeHmac is locked");__computeHmac=t},Object.freeze(computeHmac);const[SHA3_PI,SHA3_ROTL,_SHA3_IOTA]=[[],[],[]],_0n$4=BigInt(0),_1n$5=BigInt(1),_2n$3=BigInt(2),_7n=BigInt(7),_256n=BigInt(256),_0x71n=BigInt(113);for(let t=0,e=_1n$5,n=1,a=0;t<24;t++){[n,a]=[a,(2*n+3*a)%5],SHA3_PI.push(2*(5*a+n)),SHA3_ROTL.push((t+1)*(t+2)/2%64);let c=_0n$4;for(let o=0;o<7;o++)e=(e<<_1n$5^(e>>_7n)*_0x71n)%_256n,e&_2n$3&&(c^=_1n$5<<(_1n$5<<BigInt(o))-_1n$5);_SHA3_IOTA.push(c)}const[SHA3_IOTA_H,SHA3_IOTA_L]=split(_SHA3_IOTA,!0),rotlH=(t,e,n)=>n>32?rotlBH(t,e,n):rotlSH(t,e,n),rotlL=(t,e,n)=>n>32?rotlBL(t,e,n):rotlSL(t,e,n);function keccakP(t,e=24){const n=new Uint32Array(10);for(let a=24-e;a<24;a++){for(let u=0;u<10;u++)n[u]=t[u]^t[u+10]^t[u+20]^t[u+30]^t[u+40];for(let u=0;u<10;u+=2){const h=(u+8)%10,l=(u+2)%10,b=n[l],d=n[l+1],p=rotlH(b,d,1)^n[h],x=rotlL(b,d,1)^n[h+1];for(let m=0;m<50;m+=10)t[u+m]^=p,t[u+m+1]^=x}let c=t[2],o=t[3];for(let u=0;u<24;u++){const h=SHA3_ROTL[u],l=rotlH(c,o,h),b=rotlL(c,o,h),d=SHA3_PI[u];c=t[d],o=t[d+1],t[d]=l,t[d+1]=b}for(let u=0;u<50;u+=10){for(let h=0;h<10;h++)n[h]=t[u+h];for(let h=0;h<10;h++)t[u+h]^=~n[(h+2)%10]&n[(h+4)%10]}t[0]^=SHA3_IOTA_H[a],t[1]^=SHA3_IOTA_L[a]}n.fill(0)}class Keccak extends Hash{constructor(e,n,a,c=!1,o=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=a,this.enableXOF=c,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,number(a),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=u32(this.state)}keccak(){keccakP(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){exists(this);const{blockLen:n,state:a}=this;e=toBytes(e);const c=e.length;for(let o=0;o<c;){const u=Math.min(n-this.pos,c-o);for(let h=0;h<u;h++)a[this.pos++]^=e[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:a,blockLen:c}=this;e[a]^=n,n&128&&a===c-1&&this.keccak(),e[c-1]^=128,this.keccak()}writeInto(e){exists(this,!1),bytes(e),this.finish();const n=this.state,{blockLen:a}=this;for(let c=0,o=e.length;c<o;){this.posOut>=a&&this.keccak();const u=Math.min(a-this.posOut,o-c);e.set(n.subarray(this.posOut,this.posOut+u),c),this.posOut+=u,c+=u}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:n,suffix:a,outputLen:c,rounds:o,enableXOF:u}=this;return e||(e=new Keccak(n,a,c,u,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=a,e.outputLen=c,e.enableXOF=u,e.destroyed=this.destroyed,e}}const gen=(t,e,n)=>wrapConstructor(()=>new Keccak(e,t,n)),keccak_256=gen(1,136,256/8);let locked$3=!1;const _keccak256=function(t){return keccak_256(t)};let __keccak256=_keccak256;function keccak256(t){const e=getBytes(t,"data");return hexlify(__keccak256(e))}keccak256._=_keccak256,keccak256.lock=function(){locked$3=!0},keccak256.register=function(t){if(locked$3)throw new TypeError("keccak256 is locked");__keccak256=t},Object.freeze(keccak256);const Rho=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id=Uint8Array.from({length:16},(t,e)=>e),Pi=Id.map(t=>(9*t+5)%16);let idxL=[Id],idxR=[Pi];for(let t=0;t<4;t++)for(let e of[idxL,idxR])e.push(e[t].map(n=>Rho[n]));const shifts=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),shiftsL=idxL.map((t,e)=>t.map(n=>shifts[e][n])),shiftsR=idxR.map((t,e)=>t.map(n=>shifts[e][n])),Kl=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),rotl$1=(t,e)=>t<<e|t>>>32-e;function f$1(t,e,n,a){return t===0?e^n^a:t===1?e&n|~e&a:t===2?(e|~n)^a:t===3?e&a|n&~a:e^(n|~a)}const BUF=new Uint32Array(16);let RIPEMD160$1=class extends SHA2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:a,h3:c,h4:o}=this;return[e,n,a,c,o]}set(e,n,a,c,o){this.h0=e|0,this.h1=n|0,this.h2=a|0,this.h3=c|0,this.h4=o|0}process(e,n){for(let m=0;m<16;m++,n+=4)BUF[m]=e.getUint32(n,!0);let a=this.h0|0,c=a,o=this.h1|0,u=o,h=this.h2|0,l=h,b=this.h3|0,d=b,p=this.h4|0,x=p;for(let m=0;m<5;m++){const v=4-m,g=Kl[m],$=Kr[m],B=idxL[m],C=idxR[m],F=shiftsL[m],H=shiftsR[m];for(let W=0;W<16;W++){const Z=rotl$1(a+f$1(m,o,h,b)+BUF[B[W]]+g,F[W])+p|0;a=p,p=b,b=rotl$1(h,10)|0,h=o,o=Z}for(let W=0;W<16;W++){const Z=rotl$1(c+f$1(v,u,l,d)+BUF[C[W]]+$,H[W])+x|0;c=x,x=d,d=rotl$1(l,10)|0,l=u,u=Z}}this.set(this.h1+h+d|0,this.h2+b+x|0,this.h3+p+c|0,this.h4+a+u|0,this.h0+o+l|0)}roundClean(){BUF.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const ripemd160$2=wrapConstructor(()=>new RIPEMD160$1);let locked$2=!1;const _ripemd160=function(t){return ripemd160$2(t)};let __ripemd160=_ripemd160;function ripemd160$1(t){const e=getBytes(t,"data");return hexlify(__ripemd160(e))}ripemd160$1._=_ripemd160,ripemd160$1.lock=function(){locked$2=!0},ripemd160$1.register=function(t){if(locked$2)throw new TypeError("ripemd160 is locked");__ripemd160=t},Object.freeze(ripemd160$1);let locked$1=!1;const _pbkdf2=function(t,e,n,a,c){return pbkdf2Sync(t,e,n,a,c)};let __pbkdf2=_pbkdf2;function pbkdf2(t,e,n,a,c){const o=getBytes(t,"password"),u=getBytes(e,"salt");return hexlify(__pbkdf2(o,u,n,a,c))}pbkdf2._=_pbkdf2,pbkdf2.lock=function(){locked$1=!0},pbkdf2.register=function(t){if(locked$1)throw new Error("pbkdf2 is locked");__pbkdf2=t},Object.freeze(pbkdf2);let locked=!1;const _randomBytes=function(t){return new Uint8Array(randomBytes$1(t))};let __randomBytes=_randomBytes;function randomBytes(t){return __randomBytes(t)}randomBytes._=_randomBytes,randomBytes.lock=function(){locked=!0},randomBytes.register=function(t){if(locked)throw new Error("randomBytes is locked");__randomBytes=t},Object.freeze(randomBytes);const rotl=(t,e)=>t<<e|t>>>32-e;function XorAndSalsa(t,e,n,a,c,o){let u=t[e++]^n[a++],h=t[e++]^n[a++],l=t[e++]^n[a++],b=t[e++]^n[a++],d=t[e++]^n[a++],p=t[e++]^n[a++],x=t[e++]^n[a++],m=t[e++]^n[a++],v=t[e++]^n[a++],g=t[e++]^n[a++],$=t[e++]^n[a++],B=t[e++]^n[a++],C=t[e++]^n[a++],F=t[e++]^n[a++],H=t[e++]^n[a++],W=t[e++]^n[a++],Z=u,ie=h,te=l,ae=b,de=d,J=p,R=x,A=m,y=v,w=g,I=$,M=B,k=C,P=F,_=H,q=W;for(let E=0;E<8;E+=2)de^=rotl(Z+k|0,7),y^=rotl(de+Z|0,9),k^=rotl(y+de|0,13),Z^=rotl(k+y|0,18),w^=rotl(J+ie|0,7),P^=rotl(w+J|0,9),ie^=rotl(P+w|0,13),J^=rotl(ie+P|0,18),_^=rotl(I+R|0,7),te^=rotl(_+I|0,9),R^=rotl(te+_|0,13),I^=rotl(R+te|0,18),ae^=rotl(q+M|0,7),A^=rotl(ae+q|0,9),M^=rotl(A+ae|0,13),q^=rotl(M+A|0,18),ie^=rotl(Z+ae|0,7),te^=rotl(ie+Z|0,9),ae^=rotl(te+ie|0,13),Z^=rotl(ae+te|0,18),R^=rotl(J+de|0,7),A^=rotl(R+J|0,9),de^=rotl(A+R|0,13),J^=rotl(de+A|0,18),M^=rotl(I+w|0,7),y^=rotl(M+I|0,9),w^=rotl(y+M|0,13),I^=rotl(w+y|0,18),k^=rotl(q+_|0,7),P^=rotl(k+q|0,9),_^=rotl(P+k|0,13),q^=rotl(_+P|0,18);c[o++]=u+Z|0,c[o++]=h+ie|0,c[o++]=l+te|0,c[o++]=b+ae|0,c[o++]=d+de|0,c[o++]=p+J|0,c[o++]=x+R|0,c[o++]=m+A|0,c[o++]=v+y|0,c[o++]=g+w|0,c[o++]=$+I|0,c[o++]=B+M|0,c[o++]=C+k|0,c[o++]=F+P|0,c[o++]=H+_|0,c[o++]=W+q|0}function BlockMix(t,e,n,a,c){let o=a+0,u=a+16*c;for(let h=0;h<16;h++)n[u+h]=t[e+(2*c-1)*16+h];for(let h=0;h<c;h++,o+=16,e+=16)XorAndSalsa(n,u,t,e,n,o),h>0&&(u+=16),XorAndSalsa(n,o,t,e+=16,n,u)}function scryptInit(t,e,n){const a=checkOpts({dkLen:32,asyncTick:10,maxmem:1073742848},n),{N:c,r:o,p:u,dkLen:h,asyncTick:l,maxmem:b,onProgress:d}=a;if(number(c),number(o),number(u),number(h),number(l),number(b),d!==void 0&&typeof d!="function")throw new Error("progressCb should be function");const p=128*o,x=p/4;if(c<=1||c&c-1||c>=2**(p/8)||c>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(u<0||u>(2**32-1)*32/p)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(h<0||h>(2**32-1)*32)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const m=p*(c+u);if(m>b)throw new Error(`Scrypt: parameters too large, ${m} (128 * r * (N + p)) > ${b} (maxmem)`);const v=pbkdf2$1(sha256$3,t,e,{c:1,dkLen:p*u}),g=u32(v),$=u32(new Uint8Array(p*c)),B=u32(new Uint8Array(p));let C=()=>{};if(d){const F=2*c*u,H=Math.max(Math.floor(F/1e4),1);let W=0;C=()=>{W++,d&&(!(W%H)||W===F)&&d(W/F)}}return{N:c,r:o,p:u,dkLen:h,blockSize32:x,V:$,B32:g,B:v,tmp:B,blockMixCb:C,asyncTick:l}}function scryptOutput(t,e,n,a,c){const o=pbkdf2$1(sha256$3,t,n,{c:1,dkLen:e});return n.fill(0),a.fill(0),c.fill(0),o}function scrypt$1(t,e,n){const{N:a,r:c,p:o,dkLen:u,blockSize32:h,V:l,B32:b,B:d,tmp:p,blockMixCb:x}=scryptInit(t,e,n);for(let m=0;m<o;m++){const v=h*m;for(let g=0;g<h;g++)l[g]=b[v+g];for(let g=0,$=0;g<a-1;g++)BlockMix(l,$,l,$+=h,c),x();BlockMix(l,(a-1)*h,b,v,c),x();for(let g=0;g<a;g++){const $=b[v+h-16]%a;for(let B=0;B<h;B++)p[B]=b[v+B]^l[$*h+B];BlockMix(p,0,b,v,c),x()}}return scryptOutput(t,u,d,l,p)}async function scryptAsync(t,e,n){const{N:a,r:c,p:o,dkLen:u,blockSize32:h,V:l,B32:b,B:d,tmp:p,blockMixCb:x,asyncTick:m}=scryptInit(t,e,n);for(let v=0;v<o;v++){const g=h*v;for(let B=0;B<h;B++)l[B]=b[g+B];let $=0;await asyncLoop(a-1,m,()=>{BlockMix(l,$,l,$+=h,c),x()}),BlockMix(l,(a-1)*h,b,g,c),x(),await asyncLoop(a,m,()=>{const B=b[g+h-16]%a;for(let C=0;C<h;C++)p[C]=b[g+C]^l[B*h+C];BlockMix(p,0,b,g,c),x()})}return scryptOutput(t,u,d,l,p)}let lockedSync=!1,lockedAsync=!1;const _scryptAsync=async function(t,e,n,a,c,o,u){return await scryptAsync(t,e,{N:n,r:a,p:c,dkLen:o,onProgress:u})},_scryptSync=function(t,e,n,a,c,o){return scrypt$1(t,e,{N:n,r:a,p:c,dkLen:o})};let __scryptAsync=_scryptAsync,__scryptSync=_scryptSync;async function scrypt(t,e,n,a,c,o,u){const h=getBytes(t,"passwd"),l=getBytes(e,"salt");return hexlify(await __scryptAsync(h,l,n,a,c,o,u))}scrypt._=_scryptAsync,scrypt.lock=function(){lockedAsync=!0},scrypt.register=function(t){if(lockedAsync)throw new Error("scrypt is locked");__scryptAsync=t},Object.freeze(scrypt);function scryptSync(t,e,n,a,c,o){const u=getBytes(t,"passwd"),h=getBytes(e,"salt");return hexlify(__scryptSync(u,h,n,a,c,o))}scryptSync._=_scryptSync,scryptSync.lock=function(){lockedSync=!0},scryptSync.register=function(t){if(lockedSync)throw new Error("scryptSync is locked");__scryptSync=t},Object.freeze(scryptSync);const _sha256=function(t){return createHash("sha256").update(t).digest()};let __sha256=_sha256,locked256=!1;function sha256$2(t){const e=getBytes(t,"data");return hexlify(__sha256(e))}sha256$2._=_sha256,sha256$2.lock=function(){locked256=!0},sha256$2.register=function(t){if(locked256)throw new Error("sha256 is locked");__sha256=t},Object.freeze(sha256$2),Object.freeze(sha256$2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$4=BigInt(1),_2n$2=BigInt(2),u8a=t=>t instanceof Uint8Array,hexes=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function bytesToHex$2(t){if(!u8a(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=hexes[t[n]];return e}function numberToHexUnpadded(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function hexToNumber(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function hexToBytes$1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let a=0;a<n.length;a++){const c=a*2,o=t.slice(c,c+2),u=Number.parseInt(o,16);if(Number.isNaN(u)||u<0)throw new Error("Invalid byte sequence");n[a]=u}return n}function bytesToNumberBE(t){return hexToNumber(bytesToHex$2(t))}function bytesToNumberLE(t){if(!u8a(t))throw new Error("Uint8Array expected");return hexToNumber(bytesToHex$2(Uint8Array.from(t).reverse()))}function numberToBytesBE(t,e){return hexToBytes$1(t.toString(16).padStart(e*2,"0"))}function numberToBytesLE(t,e){return numberToBytesBE(t,e).reverse()}function numberToVarBytesBE(t){return hexToBytes$1(numberToHexUnpadded(t))}function ensureBytes(t,e,n){let a;if(typeof e=="string")try{a=hexToBytes$1(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(u8a(e))a=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const c=a.length;if(typeof n=="number"&&c!==n)throw new Error(`${t} expected ${n} bytes, got ${c}`);return a}function concatBytes(...t){const e=new Uint8Array(t.reduce((a,c)=>a+c.length,0));let n=0;return t.forEach(a=>{if(!u8a(a))throw new Error("Uint8Array expected");e.set(a,n),n+=a.length}),e}function equalBytes$1(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function utf8ToBytes(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function bitLen(t){let e;for(e=0;t>_0n$3;t>>=_1n$4,e+=1);return e}function bitGet(t,e){return t>>BigInt(e)&_1n$4}const bitSet=(t,e,n)=>t|(n?_1n$4:_0n$3)<<BigInt(e),bitMask=t=>(_2n$2<<BigInt(t-1))-_1n$4,u8n=t=>new Uint8Array(t),u8fr=t=>Uint8Array.from(t);function createHmacDrbg(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let a=u8n(t),c=u8n(t),o=0;const u=()=>{a.fill(1),c.fill(0),o=0},h=(...p)=>n(c,a,...p),l=(p=u8n())=>{c=h(u8fr([0]),p),a=h(),p.length!==0&&(c=h(u8fr([1]),p),a=h())},b=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let p=0;const x=[];for(;p<e;){a=h();const m=a.slice();x.push(m),p+=a.length}return concatBytes(...x)};return(p,x)=>{u(),l(p);let m;for(;!(m=x(b()));)l();return u(),m}}const validatorFns={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function validateObject(t,e,n={}){const a=(c,o,u)=>{const h=validatorFns[o];if(typeof h!="function")throw new Error(`Invalid validator "${o}", expected function`);const l=t[c];if(!(u&&l===void 0)&&!h(l,t))throw new Error(`Invalid param ${String(c)}=${l} (${typeof l}), expected ${o}`)};for(const[c,o]of Object.entries(e))a(c,o,!1);for(const[c,o]of Object.entries(n))a(c,o,!0);return t}const ut=Object.freeze(Object.defineProperty({__proto__:null,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes,createHmacDrbg,ensureBytes,equalBytes:equalBytes$1,hexToBytes:hexToBytes$1,hexToNumber,numberToBytesBE,numberToBytesLE,numberToHexUnpadded,numberToVarBytesBE,utf8ToBytes,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_4n=BigInt(4),_5n=BigInt(5),_8n=BigInt(8);BigInt(9),BigInt(16);function mod(t,e){const n=t%e;return n>=_0n$2?n:e+n}function pow(t,e,n){if(n<=_0n$2||e<_0n$2)throw new Error("Expected power/modulo > 0");if(n===_1n$3)return _0n$2;let a=_1n$3;for(;e>_0n$2;)e&_1n$3&&(a=a*t%n),t=t*t%n,e>>=_1n$3;return a}function pow2(t,e,n){let a=t;for(;e-- >_0n$2;)a*=a,a%=n;return a}function invert(t,e){if(t===_0n$2||e<=_0n$2)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=mod(t,e),a=e,c=_0n$2,o=_1n$3;for(;n!==_0n$2;){const h=a/n,l=a%n,b=c-o*h;a=n,n=l,c=o,o=b}if(a!==_1n$3)throw new Error("invert: does not exist");return mod(c,e)}function tonelliShanks(t){const e=(t-_1n$3)/_2n$1;let n,a,c;for(n=t-_1n$3,a=0;n%_2n$1===_0n$2;n/=_2n$1,a++);for(c=_2n$1;c<t&&pow(c,e,t)!==t-_1n$3;c++);if(a===1){const u=(t+_1n$3)/_4n;return function(l,b){const d=l.pow(b,u);if(!l.eql(l.sqr(d),b))throw new Error("Cannot find square root");return d}}const o=(n+_1n$3)/_2n$1;return function(h,l){if(h.pow(l,e)===h.neg(h.ONE))throw new Error("Cannot find square root");let b=a,d=h.pow(h.mul(h.ONE,c),n),p=h.pow(l,o),x=h.pow(l,n);for(;!h.eql(x,h.ONE);){if(h.eql(x,h.ZERO))return h.ZERO;let m=1;for(let g=h.sqr(x);m<b&&!h.eql(g,h.ONE);m++)g=h.sqr(g);const v=h.pow(d,_1n$3<<BigInt(b-m-1));d=h.sqr(v),p=h.mul(p,v),x=h.mul(x,d),b=m}return p}}function FpSqrt(t){if(t%_4n===_3n$1){const e=(t+_1n$3)/_4n;return function(a,c){const o=a.pow(c,e);if(!a.eql(a.sqr(o),c))throw new Error("Cannot find square root");return o}}if(t%_8n===_5n){const e=(t-_5n)/_8n;return function(a,c){const o=a.mul(c,_2n$1),u=a.pow(o,e),h=a.mul(c,u),l=a.mul(a.mul(h,_2n$1),u),b=a.mul(h,a.sub(l,a.ONE));if(!a.eql(a.sqr(b),c))throw new Error("Cannot find square root");return b}}return tonelliShanks(t)}const FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=FIELD_FIELDS.reduce((a,c)=>(a[c]="function",a),e);return validateObject(t,n)}function FpPow(t,e,n){if(n<_0n$2)throw new Error("Expected power > 0");if(n===_0n$2)return t.ONE;if(n===_1n$3)return e;let a=t.ONE,c=e;for(;n>_0n$2;)n&_1n$3&&(a=t.mul(a,c)),c=t.sqr(c),n>>=_1n$3;return a}function FpInvertBatch(t,e){const n=new Array(e.length),a=e.reduce((o,u,h)=>t.is0(u)?o:(n[h]=o,t.mul(o,u)),t.ONE),c=t.inv(a);return e.reduceRight((o,u,h)=>t.is0(u)?o:(n[h]=t.mul(o,n[h]),t.mul(o,u)),c),n}function nLength(t,e){const n=e!==void 0?e:t.toString(2).length,a=Math.ceil(n/8);return{nBitLength:n,nByteLength:a}}function Field(t,e,n=!1,a={}){if(t<=_0n$2)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:c,nByteLength:o}=nLength(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const u=FpSqrt(t),h=Object.freeze({ORDER:t,BITS:c,BYTES:o,MASK:bitMask(c),ZERO:_0n$2,ONE:_1n$3,create:l=>mod(l,t),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return _0n$2<=l&&l<t},is0:l=>l===_0n$2,isOdd:l=>(l&_1n$3)===_1n$3,neg:l=>mod(-l,t),eql:(l,b)=>l===b,sqr:l=>mod(l*l,t),add:(l,b)=>mod(l+b,t),sub:(l,b)=>mod(l-b,t),mul:(l,b)=>mod(l*b,t),pow:(l,b)=>FpPow(h,l,b),div:(l,b)=>mod(l*invert(b,t),t),sqrN:l=>l*l,addN:(l,b)=>l+b,subN:(l,b)=>l-b,mulN:(l,b)=>l*b,inv:l=>invert(l,t),sqrt:a.sqrt||(l=>u(h,l)),invertBatch:l=>FpInvertBatch(h,l),cmov:(l,b,d)=>d?b:l,toBytes:l=>n?numberToBytesLE(l,o):numberToBytesBE(l,o),fromBytes:l=>{if(l.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${l.length}`);return n?bytesToNumberLE(l):bytesToNumberBE(l)}});return Object.freeze(h)}function getFieldBytesLength(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function getMinHashLength(t){const e=getFieldBytesLength(t);return e+Math.ceil(e/2)}function mapHashToField(t,e,n=!1){const a=t.length,c=getFieldBytesLength(e),o=getMinHashLength(e);if(a<16||a<o||a>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${a}`);const u=n?bytesToNumberBE(t):bytesToNumberLE(t),h=mod(u,e-_1n$3)+_1n$3;return n?numberToBytesLE(h,c):numberToBytesBE(h,c)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function wNAF(t,e){const n=(c,o)=>{const u=o.negate();return c?u:o},a=c=>{const o=Math.ceil(e/c)+1,u=2**(c-1);return{windows:o,windowSize:u}};return{constTimeNegate:n,unsafeLadder(c,o){let u=t.ZERO,h=c;for(;o>_0n$1;)o&_1n$2&&(u=u.add(h)),h=h.double(),o>>=_1n$2;return u},precomputeWindow(c,o){const{windows:u,windowSize:h}=a(o),l=[];let b=c,d=b;for(let p=0;p<u;p++){d=b,l.push(d);for(let x=1;x<h;x++)d=d.add(b),l.push(d);b=d.double()}return l},wNAF(c,o,u){const{windows:h,windowSize:l}=a(c);let b=t.ZERO,d=t.BASE;const p=BigInt(2**c-1),x=2**c,m=BigInt(c);for(let v=0;v<h;v++){const g=v*l;let $=Number(u&p);u>>=m,$>l&&($-=x,u+=_1n$2);const B=g,C=g+Math.abs($)-1,F=v%2!==0,H=$<0;$===0?d=d.add(n(F,o[B])):b=b.add(n(H,o[C]))}return{p:b,f:d}},wNAFCached(c,o,u,h){const l=c._WINDOW_SIZE||1;let b=o.get(c);return b||(b=this.precomputeWindow(c,l),l!==1&&o.set(c,h(b))),this.wNAF(l,b,u)}}}function validateBasic(t){return validateField(t.Fp),validateObject(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(t){const e=validateBasic(t);validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:a,a:c}=e;if(n){if(!a.eql(c,a.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],a=t.subarray(2,n+2);if(!n||a.length!==n)throw new e("Invalid signature integer: wrong length");if(a[0]&128)throw new e("Invalid signature integer: negative");if(a[0]===0&&!(a[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:b2n(a),l:t.subarray(n+2)}},toSig(t){const{Err:e}=DER,n=typeof t=="string"?h2b(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let a=n.length;if(a<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==a-2)throw new e("Invalid signature: incorrect length");const{d:c,l:o}=DER._parseInt(n.subarray(2)),{d:u,l:h}=DER._parseInt(o);if(h.length)throw new e("Invalid signature: left bytes after parsing");return{r:c,s:u}},hexFromSig(t){const e=b=>Number.parseInt(b[0],16)&8?"00"+b:b,n=b=>{const d=b.toString(16);return d.length&1?`0${d}`:d},a=e(n(t.s)),c=e(n(t.r)),o=a.length/2,u=c.length/2,h=n(o),l=n(u);return`30${n(u+o+4)}02${l}${c}02${h}${a}`}},_0n=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);BigInt(4);function weierstrassPoints(t){const e=validatePointOpts(t),{Fp:n}=e,a=e.toBytes||((v,g,$)=>{const B=g.toAffine();return concatBytes(Uint8Array.from([4]),n.toBytes(B.x),n.toBytes(B.y))}),c=e.fromBytes||(v=>{const g=v.subarray(1),$=n.fromBytes(g.subarray(0,n.BYTES)),B=n.fromBytes(g.subarray(n.BYTES,2*n.BYTES));return{x:$,y:B}});function o(v){const{a:g,b:$}=e,B=n.sqr(v),C=n.mul(B,v);return n.add(n.add(C,n.mul(v,g)),$)}if(!n.eql(n.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function u(v){return typeof v=="bigint"&&_0n<v&&v<e.n}function h(v){if(!u(v))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(v){const{allowedPrivateKeyLengths:g,nByteLength:$,wrapPrivateKey:B,n:C}=e;if(g&&typeof v!="bigint"){if(v instanceof Uint8Array&&(v=bytesToHex$2(v)),typeof v!="string"||!g.includes(v.length))throw new Error("Invalid key");v=v.padStart($*2,"0")}let F;try{F=typeof v=="bigint"?v:bytesToNumberBE(ensureBytes("private key",v,$))}catch{throw new Error(`private key must be ${$} bytes, hex or bigint, not ${typeof v}`)}return B&&(F=mod(F,C)),h(F),F}const b=new Map;function d(v){if(!(v instanceof p))throw new Error("ProjectivePoint expected")}class p{constructor(g,$,B){if(this.px=g,this.py=$,this.pz=B,g==null||!n.isValid(g))throw new Error("x required");if($==null||!n.isValid($))throw new Error("y required");if(B==null||!n.isValid(B))throw new Error("z required")}static fromAffine(g){const{x:$,y:B}=g||{};if(!g||!n.isValid($)||!n.isValid(B))throw new Error("invalid affine point");if(g instanceof p)throw new Error("projective point not allowed");const C=F=>n.eql(F,n.ZERO);return C($)&&C(B)?p.ZERO:new p($,B,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const $=n.invertBatch(g.map(B=>B.pz));return g.map((B,C)=>B.toAffine($[C])).map(p.fromAffine)}static fromHex(g){const $=p.fromAffine(c(ensureBytes("pointHex",g)));return $.assertValidity(),$}static fromPrivateKey(g){return p.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,b.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y:$}=this.toAffine();if(!n.isValid(g)||!n.isValid($))throw new Error("bad point: x or y not FE");const B=n.sqr($),C=o(g);if(!n.eql(B,C))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(n.isOdd)return!n.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){d(g);const{px:$,py:B,pz:C}=this,{px:F,py:H,pz:W}=g,Z=n.eql(n.mul($,W),n.mul(F,C)),ie=n.eql(n.mul(B,W),n.mul(H,C));return Z&&ie}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:g,b:$}=e,B=n.mul($,_3n),{px:C,py:F,pz:H}=this;let W=n.ZERO,Z=n.ZERO,ie=n.ZERO,te=n.mul(C,C),ae=n.mul(F,F),de=n.mul(H,H),J=n.mul(C,F);return J=n.add(J,J),ie=n.mul(C,H),ie=n.add(ie,ie),W=n.mul(g,ie),Z=n.mul(B,de),Z=n.add(W,Z),W=n.sub(ae,Z),Z=n.add(ae,Z),Z=n.mul(W,Z),W=n.mul(J,W),ie=n.mul(B,ie),de=n.mul(g,de),J=n.sub(te,de),J=n.mul(g,J),J=n.add(J,ie),ie=n.add(te,te),te=n.add(ie,te),te=n.add(te,de),te=n.mul(te,J),Z=n.add(Z,te),de=n.mul(F,H),de=n.add(de,de),te=n.mul(de,J),W=n.sub(W,te),ie=n.mul(de,ae),ie=n.add(ie,ie),ie=n.add(ie,ie),new p(W,Z,ie)}add(g){d(g);const{px:$,py:B,pz:C}=this,{px:F,py:H,pz:W}=g;let Z=n.ZERO,ie=n.ZERO,te=n.ZERO;const ae=e.a,de=n.mul(e.b,_3n);let J=n.mul($,F),R=n.mul(B,H),A=n.mul(C,W),y=n.add($,B),w=n.add(F,H);y=n.mul(y,w),w=n.add(J,R),y=n.sub(y,w),w=n.add($,C);let I=n.add(F,W);return w=n.mul(w,I),I=n.add(J,A),w=n.sub(w,I),I=n.add(B,C),Z=n.add(H,W),I=n.mul(I,Z),Z=n.add(R,A),I=n.sub(I,Z),te=n.mul(ae,w),Z=n.mul(de,A),te=n.add(Z,te),Z=n.sub(R,te),te=n.add(R,te),ie=n.mul(Z,te),R=n.add(J,J),R=n.add(R,J),A=n.mul(ae,A),w=n.mul(de,w),R=n.add(R,A),A=n.sub(J,A),A=n.mul(ae,A),w=n.add(w,A),J=n.mul(R,w),ie=n.add(ie,J),J=n.mul(I,w),Z=n.mul(y,Z),Z=n.sub(Z,J),J=n.mul(y,R),te=n.mul(I,te),te=n.add(te,J),new p(Z,ie,te)}subtract(g){return this.add(g.negate())}is0(){return this.equals(p.ZERO)}wNAF(g){return m.wNAFCached(this,b,g,$=>{const B=n.invertBatch($.map(C=>C.pz));return $.map((C,F)=>C.toAffine(B[F])).map(p.fromAffine)})}multiplyUnsafe(g){const $=p.ZERO;if(g===_0n)return $;if(h(g),g===_1n$1)return this;const{endo:B}=e;if(!B)return m.unsafeLadder(this,g);let{k1neg:C,k1:F,k2neg:H,k2:W}=B.splitScalar(g),Z=$,ie=$,te=this;for(;F>_0n||W>_0n;)F&_1n$1&&(Z=Z.add(te)),W&_1n$1&&(ie=ie.add(te)),te=te.double(),F>>=_1n$1,W>>=_1n$1;return C&&(Z=Z.negate()),H&&(ie=ie.negate()),ie=new p(n.mul(ie.px,B.beta),ie.py,ie.pz),Z.add(ie)}multiply(g){h(g);let $=g,B,C;const{endo:F}=e;if(F){const{k1neg:H,k1:W,k2neg:Z,k2:ie}=F.splitScalar($);let{p:te,f:ae}=this.wNAF(W),{p:de,f:J}=this.wNAF(ie);te=m.constTimeNegate(H,te),de=m.constTimeNegate(Z,de),de=new p(n.mul(de.px,F.beta),de.py,de.pz),B=te.add(de),C=ae.add(J)}else{const{p:H,f:W}=this.wNAF($);B=H,C=W}return p.normalizeZ([B,C])[0]}multiplyAndAddUnsafe(g,$,B){const C=p.BASE,F=(W,Z)=>Z===_0n||Z===_1n$1||!W.equals(C)?W.multiplyUnsafe(Z):W.multiply(Z),H=F(this,$).add(F(g,B));return H.is0()?void 0:H}toAffine(g){const{px:$,py:B,pz:C}=this,F=this.is0();g==null&&(g=F?n.ONE:n.inv(C));const H=n.mul($,g),W=n.mul(B,g),Z=n.mul(C,g);if(F)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:H,y:W}}isTorsionFree(){const{h:g,isTorsionFree:$}=e;if(g===_1n$1)return!0;if($)return $(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:$}=e;return g===_1n$1?this:$?$(p,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),a(p,this,g)}toHex(g=!0){return bytesToHex$2(this.toRawBytes(g))}}p.BASE=new p(e.Gx,e.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const x=e.nBitLength,m=wNAF(p,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:u}}function validateOpts(t){const e=validateBasic(t);return validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function weierstrass(t){const e=validateOpts(t),{Fp:n,n:a}=e,c=n.BYTES+1,o=2*n.BYTES+1;function u(w){return _0n<w&&w<n.ORDER}function h(w){return mod(w,a)}function l(w){return invert(w,a)}const{ProjectivePoint:b,normPrivateKeyToScalar:d,weierstrassEquation:p,isWithinCurveOrder:x}=weierstrassPoints({...e,toBytes(w,I,M){const k=I.toAffine(),P=n.toBytes(k.x),_=concatBytes;return M?_(Uint8Array.from([I.hasEvenY()?2:3]),P):_(Uint8Array.from([4]),P,n.toBytes(k.y))},fromBytes(w){const I=w.length,M=w[0],k=w.subarray(1);if(I===c&&(M===2||M===3)){const P=bytesToNumberBE(k);if(!u(P))throw new Error("Point is not on curve");const _=p(P);let q=n.sqrt(_);const E=(q&_1n$1)===_1n$1;return(M&1)===1!==E&&(q=n.neg(q)),{x:P,y:q}}else if(I===o&&M===4){const P=n.fromBytes(k.subarray(0,n.BYTES)),_=n.fromBytes(k.subarray(n.BYTES,2*n.BYTES));return{x:P,y:_}}else throw new Error(`Point of length ${I} was invalid. Expected ${c} compressed bytes or ${o} uncompressed bytes`)}}),m=w=>bytesToHex$2(numberToBytesBE(w,e.nByteLength));function v(w){const I=a>>_1n$1;return w>I}function g(w){return v(w)?h(-w):w}const $=(w,I,M)=>bytesToNumberBE(w.slice(I,M));class B{constructor(I,M,k){this.r=I,this.s=M,this.recovery=k,this.assertValidity()}static fromCompact(I){const M=e.nByteLength;return I=ensureBytes("compactSignature",I,M*2),new B($(I,0,M),$(I,M,2*M))}static fromDER(I){const{r:M,s:k}=DER.toSig(ensureBytes("DER",I));return new B(M,k)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new B(this.r,this.s,I)}recoverPublicKey(I){const{r:M,s:k,recovery:P}=this,_=ie(ensureBytes("msgHash",I));if(P==null||![0,1,2,3].includes(P))throw new Error("recovery id invalid");const q=P===2||P===3?M+e.n:M;if(q>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const E=P&1?"03":"02",j=b.fromHex(E+m(q)),ee=l(q),oe=h(-_*ee),Y=h(k*ee),L=b.BASE.multiplyAndAddUnsafe(j,oe,Y);if(!L)throw new Error("point at infinify");return L.assertValidity(),L}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,h(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$1(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$1(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}const C={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const w=getMinHashLength(e.n);return mapHashToField(e.randomBytes(w),e.n)},precompute(w=8,I=b.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function F(w,I=!0){return b.fromPrivateKey(w).toRawBytes(I)}function H(w){const I=w instanceof Uint8Array,M=typeof w=="string",k=(I||M)&&w.length;return I?k===c||k===o:M?k===2*c||k===2*o:w instanceof b}function W(w,I,M=!0){if(H(w))throw new Error("first arg must be private key");if(!H(I))throw new Error("second arg must be public key");return b.fromHex(I).multiply(d(w)).toRawBytes(M)}const Z=e.bits2int||function(w){const I=bytesToNumberBE(w),M=w.length*8-e.nBitLength;return M>0?I>>BigInt(M):I},ie=e.bits2int_modN||function(w){return h(Z(w))},te=bitMask(e.nBitLength);function ae(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(_0n<=w&&w<te))throw new Error(`bigint expected < 2^${e.nBitLength}`);return numberToBytesBE(w,e.nByteLength)}function de(w,I,M=J){if(["recovered","canonical"].some(re=>re in M))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:P}=e;let{lowS:_,prehash:q,extraEntropy:E}=M;_==null&&(_=!0),w=ensureBytes("msgHash",w),q&&(w=ensureBytes("prehashed msgHash",k(w)));const j=ie(w),ee=d(I),oe=[ae(ee),ae(j)];if(E!=null){const re=E===!0?P(n.BYTES):E;oe.push(ensureBytes("extraEntropy",re))}const Y=concatBytes(...oe),L=j;function z(re){const D=Z(re);if(!x(D))return;const G=l(D),U=b.BASE.multiply(D).toAffine(),Q=h(U.x);if(Q===_0n)return;const fe=h(G*h(L+Q*ee));if(fe===_0n)return;let he=(U.x===Q?0:2)|Number(U.y&_1n$1),le=fe;return _&&v(fe)&&(le=g(fe),he^=1),new B(Q,le,he)}return{seed:Y,k2sig:z}}const J={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function A(w,I,M=J){const{seed:k,k2sig:P}=de(w,I,M),_=e;return createHmacDrbg(_.hash.outputLen,_.nByteLength,_.hmac)(k,P)}b.BASE._setWindowSize(8);function y(w,I,M,k=R){var U;const P=w;if(I=ensureBytes("msgHash",I),M=ensureBytes("publicKey",M),"strict"in k)throw new Error("options.strict was renamed to lowS");const{lowS:_,prehash:q}=k;let E,j;try{if(typeof P=="string"||P instanceof Uint8Array)try{E=B.fromDER(P)}catch(Q){if(!(Q instanceof DER.Err))throw Q;E=B.fromCompact(P)}else if(typeof P=="object"&&typeof P.r=="bigint"&&typeof P.s=="bigint"){const{r:Q,s:fe}=P;E=new B(Q,fe)}else throw new Error("PARSE");j=b.fromHex(M)}catch(Q){if(Q.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(_&&E.hasHighS())return!1;q&&(I=e.hash(I));const{r:ee,s:oe}=E,Y=ie(I),L=l(oe),z=h(Y*L),re=h(ee*L),D=(U=b.BASE.multiplyAndAddUnsafe(j,z,re))==null?void 0:U.toAffine();return D?h(D.x)===ee:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:W,sign:A,verify:y,ProjectivePoint:b,Signature:B,utils:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(t){return{hash:t,hmac:(e,...n)=>hmac$1(t,e,concatBytes$1(...n)),randomBytes:randomBytes$2}}function createCurve(t,e){const n=a=>weierstrass({...t,...getHash(a)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(t,e)=>(t+e/_2n)/e;function sqrtMod(t){const e=secp256k1P,n=BigInt(3),a=BigInt(6),c=BigInt(11),o=BigInt(22),u=BigInt(23),h=BigInt(44),l=BigInt(88),b=t*t*t%e,d=b*b*t%e,p=pow2(d,n,e)*d%e,x=pow2(p,n,e)*d%e,m=pow2(x,_2n,e)*b%e,v=pow2(m,c,e)*m%e,g=pow2(v,o,e)*v%e,$=pow2(g,h,e)*g%e,B=pow2($,l,e)*$%e,C=pow2(B,h,e)*g%e,F=pow2(C,n,e)*d%e,H=pow2(F,u,e)*v%e,W=pow2(H,a,e)*b%e,Z=pow2(W,_2n,e);if(!Fp.eql(Fp.sqr(Z),t))throw new Error("Cannot find square root");return Z}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1$1=createCurve({a:BigInt(0),b:BigInt(7),Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=secp256k1N,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),a=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),c=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,u=BigInt("0x100000000000000000000000000000000"),h=divNearest(o*t,e),l=divNearest(-a*t,e);let b=mod(t-h*n-l*c,e),d=mod(-h*a-l*o,e);const p=b>u,x=d>u;if(p&&(b=e-b),x&&(d=e-d),b>u||d>u)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:p,k1:b,k2neg:x,k2:d}}}},sha256$3);BigInt(0),secp256k1$1.ProjectivePoint;const ZeroAddress="0x0000000000000000000000000000000000000000",ZeroHash="0x0000000000000000000000000000000000000000000000000000000000000000",MessagePrefix=`Ethereum Signed Message:
1
+ (function(Fe,He){typeof exports=="object"&&typeof module<"u"?He(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],He):(Fe=typeof globalThis<"u"?globalThis:Fe||self,He(Fe.SwarmChatJs={},Fe.BeeJs))})(this,function(exports,beeJs){"use strict";var Er=Object.defineProperty;var wr=Fe=>{throw TypeError(Fe)};var Ar=(Fe,He,at)=>He in Fe?Er(Fe,He,{enumerable:!0,configurable:!0,writable:!0,value:at}):Fe[He]=at;var Ue=(Fe,He,at)=>Ar(Fe,typeof He!="symbol"?He+"":He,at),xr=(Fe,He,at)=>He.has(Fe)||wr("Cannot "+at);var Re=(Fe,He,at)=>(xr(Fe,He,"read from private field"),at?at.call(Fe):He.get(Fe)),Le=(Fe,He,at)=>He.has(Fe)?wr("Cannot add the same private member more than once"):He instanceof WeakSet?He.add(Fe):He.set(Fe,at),we=(Fe,He,at,wt)=>(xr(Fe,He,"write to private field"),wt?wt.call(Fe,at):He.set(Fe,at),at),st=(Fe,He,at)=>(xr(Fe,He,"access private method"),at);var Fe,He,at,wt,ot,St,_t,Ut,Ht,jt,Gt,Kt,zt,Vt,Wt,Jt,Zt,Xt,It,Rt,Et,$t,Yt,ur,ir,Bt,Qt,cr,_r,er,dr,tr,rr,nr,Pt,ar,yr,sr,vr,Tt,fr,or,gr;const version$1="6.13.4";async function resolveProperties(t){const e=Object.keys(t);return(await Promise.all(e.map(a=>Promise.resolve(t[a])))).reduce((a,c,o)=>(a[e[o]]=c,a),{})}function defineProperties(t,e,n){for(let a in e){let c=e[a];Object.defineProperty(t,a,{enumerable:!0,value:c,writable:!1})}}function stringify(t){if(t==null)return"null";if(Array.isArray(t))return"[ "+t.map(stringify).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let a=0;a<t.length;a++)n+=e[t[a]>>4],n+=e[t[a]&15];return n}if(typeof t=="object"&&typeof t.toJSON=="function")return stringify(t.toJSON());switch(typeof t){case"boolean":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"number":return t.toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map(n=>`${stringify(n)}: ${stringify(t[n])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function makeError(t,e,n){let a=t;{const o=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${stringify(n)}`);for(const u in n){if(u==="shortMessage")continue;const h=n[u];o.push(u+"="+stringify(h))}}o.push(`code=${e}`),o.push(`version=${version$1}`),o.length&&(t+=" ("+o.join(", ")+")")}let c;switch(e){case"INVALID_ARGUMENT":c=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":c=new RangeError(t);break;default:c=new Error(t)}return defineProperties(c,{code:e}),n&&Object.assign(c,n),c.shortMessage==null&&defineProperties(c,{shortMessage:a}),c}function assert$f(t,e,n,a){if(!t)throw makeError(e,n,a)}function assertArgument(t,e,n,a){assert$f(t,e,"INVALID_ARGUMENT",{argument:n,value:a})}const _normalizeForms=["NFD","NFC","NFKD","NFKC"].reduce((t,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");t.push(e)}catch{}return t},[]);function assertNormalize(t){assert$f(_normalizeForms.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}function assertPrivate(t,e,n){if(n==null&&(n=""),t!==e){let a=n,c="new";n&&(a+=".",c+=" "+n),assert$f(!1,`private constructor; use ${a}from* methods`,"UNSUPPORTED_OPERATION",{operation:c})}}function _getBytes(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if(typeof t=="string"&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const a=new Uint8Array((t.length-2)/2);let c=2;for(let o=0;o<a.length;o++)a[o]=parseInt(t.substring(c,c+2),16),c+=2;return a}assertArgument(!1,"invalid BytesLike value",e||"value",t)}function getBytes(t,e){return _getBytes(t,e,!1)}function getBytesCopy(t,e){return _getBytes(t,e,!0)}function isHexString$1(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&t.length!==2+2*e||e===!0&&t.length%2!==0)}function isBytesLike(t){return isHexString$1(t,!0)||t instanceof Uint8Array}const HexCharacters="0123456789abcdef";function hexlify(t){const e=getBytes(t);let n="0x";for(let a=0;a<e.length;a++){const c=e[a];n+=HexCharacters[(c&240)>>4]+HexCharacters[c&15]}return n}function concat(t){return"0x"+t.map(e=>hexlify(e).substring(2)).join("")}function dataLength(t){return isHexString$1(t,!0)?(t.length-2)/2:getBytes(t).length}function dataSlice(t,e,n){const a=getBytes(t);return n>a.length&&assert$f(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:a,length:a.length,offset:n}),hexlify(a.slice(e,n))}function zeroPad(t,e,n){const a=getBytes(t);assert$f(e>=a.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(a),length:e,offset:e+1});const c=new Uint8Array(e);return c.fill(0),c.set(a,e-a.length),hexlify(c)}function zeroPadValue(t,e){return zeroPad(t,e)}const BN_0$5=BigInt(0),BN_1$2=BigInt(1),maxValue=9007199254740991;function toTwos(t,e){let n=getBigInt(t,"value");const a=BigInt(getNumber(e,"width")),c=BN_1$2<<a-BN_1$2;if(n<BN_0$5){n=-n,assert$f(n<=c,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});const o=(BN_1$2<<a)-BN_1$2;return(~n&o)+BN_1$2}else assert$f(n<c,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return n}function mask(t,e){const n=getUint(t,"value"),a=BigInt(getNumber(e,"bits"));return n&(BN_1$2<<a)-BN_1$2}function getBigInt(t,e){switch(typeof t){case"bigint":return t;case"number":return assertArgument(Number.isInteger(t),"underflow",e||"value",t),assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),BigInt(t);case"string":try{if(t==="")throw new Error("empty string");return t[0]==="-"&&t[1]!=="-"?-BigInt(t.substring(1)):BigInt(t)}catch(n){assertArgument(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}assertArgument(!1,"invalid BigNumberish value",e||"value",t)}function getUint(t,e){const n=getBigInt(t,e);return assert$f(n>=BN_0$5,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const Nibbles$1="0123456789abcdef";function toBigInt(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=Nibbles$1[n>>4],e+=Nibbles$1[n&15];return BigInt(e)}return getBigInt(t)}function getNumber(t,e){switch(typeof t){case"bigint":return assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),Number(t);case"number":return assertArgument(Number.isInteger(t),"underflow",e||"value",t),assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),t;case"string":try{if(t==="")throw new Error("empty string");return getNumber(BigInt(t),e)}catch(n){assertArgument(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}assertArgument(!1,"invalid numeric value",e||"value",t)}function toBeHex(t,e){let a=getUint(t,"value").toString(16);{const c=getNumber(e,"width");for(assert$f(c*2>=a.length,`value exceeds width (${c} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});a.length<c*2;)a="0"+a}return"0x"+a}function toBeArray(t){const e=getUint(t,"value");if(e===BN_0$5)return new Uint8Array([]);let n=e.toString(16);n.length%2&&(n="0"+n);const a=new Uint8Array(n.length/2);for(let c=0;c<a.length;c++){const o=c*2;a[c]=parseInt(n.substring(o,o+2),16)}return a}function toQuantity(t){let e=hexlify(isBytesLike(t)?t:toBeArray(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const Alphabet="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";let Lookup=null;function getAlpha(t){if(Lookup==null){Lookup={};for(let n=0;n<Alphabet.length;n++)Lookup[Alphabet[n]]=BigInt(n)}const e=Lookup[t];return assertArgument(e!=null,"invalid base58 value","letter",t),e}const BN_0$4=BigInt(0),BN_58=BigInt(58);function encodeBase58(t){const e=getBytes(t);let n=toBigInt(e),a="";for(;n;)a=Alphabet[Number(n%BN_58)]+a,n/=BN_58;for(let c=0;c<e.length&&!e[c];c++)a=Alphabet[0]+a;return a}function decodeBase58(t){let e=BN_0$4;for(let n=0;n<t.length;n++)e*=BN_58,e+=getAlpha(t[n]);return e}function toUtf8Bytes(t,e){assertArgument(typeof t=="string","invalid string value","str",t),e!=null&&(assertNormalize(e),t=t.normalize(e));let n=[];for(let a=0;a<t.length;a++){const c=t.charCodeAt(a);if(c<128)n.push(c);else if(c<2048)n.push(c>>6|192),n.push(c&63|128);else if((c&64512)==55296){a++;const o=t.charCodeAt(a);assertArgument(a<t.length&&(o&64512)===56320,"invalid surrogate pair","str",t);const u=65536+((c&1023)<<10)+(o&1023);n.push(u>>18|240),n.push(u>>12&63|128),n.push(u>>6&63|128),n.push(u&63|128)}else n.push(c>>12|224),n.push(c>>6&63|128),n.push(c&63|128)}return new Uint8Array(n)}function hexlifyByte(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function unarrayifyInteger(t,e,n){let a=0;for(let c=0;c<n;c++)a=a*256+t[e+c];return a}function _decodeChildren(t,e,n,a){const c=[];for(;n<e+1+a;){const o=_decode(t,n);c.push(o.result),n+=o.consumed,assert$f(n<=e+1+a,"child data too short","BUFFER_OVERRUN",{buffer:t,length:a,offset:e})}return{consumed:1+a,result:c}}function _decode(t,e){assert$f(t.length!==0,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=a=>{assert$f(a<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:a})};if(t[e]>=248){const a=t[e]-247;n(e+1+a);const c=unarrayifyInteger(t,e+1,a);return n(e+1+a+c),_decodeChildren(t,e,e+1+a,a+c)}else if(t[e]>=192){const a=t[e]-192;return n(e+1+a),_decodeChildren(t,e,e+1,a)}else if(t[e]>=184){const a=t[e]-183;n(e+1+a);const c=unarrayifyInteger(t,e+1,a);n(e+1+a+c);const o=hexlify(t.slice(e+1+a,e+1+a+c));return{consumed:1+a+c,result:o}}else if(t[e]>=128){const a=t[e]-128;n(e+1+a);const c=hexlify(t.slice(e+1,e+1+a));return{consumed:1+a,result:c}}return{consumed:1,result:hexlifyByte(t[e])}}function decodeRlp(t){const e=getBytes(t,"data"),n=_decode(e,0);return assertArgument(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function arrayifyInteger(t){const e=[];for(;t;)e.unshift(t&255),t>>=8;return e}function _encode(t){if(Array.isArray(t)){let a=[];if(t.forEach(function(o){a=a.concat(_encode(o))}),a.length<=55)return a.unshift(192+a.length),a;const c=arrayifyInteger(a.length);return c.unshift(247+c.length),c.concat(a)}const e=Array.prototype.slice.call(getBytes(t,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=arrayifyInteger(e.length);return n.unshift(183+n.length),n.concat(e)}const nibbles="0123456789abcdef";function encodeRlp(t){let e="0x";for(const n of _encode(t))e+=nibbles[n>>4],e+=nibbles[n&15];return e}function uuidV4(t){const e=getBytes(t,"randomBytes");e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=hexlify(e);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join("-")}const global$1=globalThis||void 0||self;function number(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function bytes(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function hash$4(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number(t.outputLen),number(t.blockLen)}function exists(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function output(t,e){bytes(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const crypto$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const u8a$1=t=>t instanceof Uint8Array,u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),rotr=(t,e)=>t<<32-e|t>>>e,isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE)throw new Error("Non little-endian hardware is not supported");const nextTick=async()=>{};async function asyncLoop(t,e,n){let a=Date.now();for(let c=0;c<t;c++){n(c);const o=Date.now()-a;o>=0&&o<e||(await nextTick(),a+=o)}}function utf8ToBytes$1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function toBytes(t){if(typeof t=="string"&&(t=utf8ToBytes$1(t)),!u8a$1(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function concatBytes$1(...t){const e=new Uint8Array(t.reduce((a,c)=>a+c.length,0));let n=0;return t.forEach(a=>{if(!u8a$1(a))throw new Error("Uint8Array expected");e.set(a,n),n+=a.length}),e}class Hash{clone(){return this._cloneInto()}}const toStr={}.toString;function checkOpts(t,e){if(e!==void 0&&toStr.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function wrapConstructor(t){const e=a=>t().update(toBytes(a)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function randomBytes$2(t=32){if(crypto$2&&typeof crypto$2.getRandomValues=="function")return crypto$2.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class HMAC extends Hash{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,hash$4(e);const a=toBytes(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const c=this.blockLen,o=new Uint8Array(c);o.set(a.length>c?e.create().update(a).digest():a);for(let u=0;u<o.length;u++)o[u]^=54;this.iHash.update(o),this.oHash=e.create();for(let u=0;u<o.length;u++)o[u]^=106;this.oHash.update(o),o.fill(0)}update(e){return exists(this),this.iHash.update(e),this}digestInto(e){exists(this),bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:a,finished:c,destroyed:o,blockLen:u,outputLen:h}=this;return e=e,e.finished=c,e.destroyed=o,e.blockLen=u,e.outputLen=h,e.oHash=n._cloneInto(e.oHash),e.iHash=a._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac$1=(t,e,n)=>new HMAC(t,e).update(n).digest();hmac$1.create=(t,e)=>new HMAC(t,e);function pbkdf2Init(t,e,n,a){hash$4(t);const c=checkOpts({dkLen:32,asyncTick:10},a),{c:o,dkLen:u,asyncTick:h}=c;if(number(o),number(u),number(h),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=toBytes(e),b=toBytes(n),d=new Uint8Array(u),p=hmac$1.create(t,l),x=p._cloneInto().update(b);return{c:o,dkLen:u,asyncTick:h,DK:d,PRF:p,PRFSalt:x}}function pbkdf2Output(t,e,n,a,c){return t.destroy(),e.destroy(),a&&a.destroy(),c.fill(0),n}function pbkdf2$1(t,e,n,a){const{c,dkLen:o,DK:u,PRF:h,PRFSalt:l}=pbkdf2Init(t,e,n,a);let b;const d=new Uint8Array(4),p=createView(d),x=new Uint8Array(h.outputLen);for(let m=1,v=0;v<o;m++,v+=h.outputLen){const g=u.subarray(v,v+h.outputLen);p.setInt32(0,m,!1),(b=l._cloneInto(b)).update(d).digestInto(x),g.set(x.subarray(0,g.length));for(let $=1;$<c;$++){h._cloneInto(b).update(x).digestInto(x);for(let B=0;B<g.length;B++)g[B]^=x[B]}}return pbkdf2Output(h,l,u,b,x)}function setBigUint64(t,e,n,a){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,a);const c=BigInt(32),o=BigInt(4294967295),u=Number(n>>c&o),h=Number(n&o),l=a?4:0,b=a?0:4;t.setUint32(e+l,u,a),t.setUint32(e+b,h,a)}class SHA2 extends Hash{constructor(e,n,a,c){super(),this.blockLen=e,this.outputLen=n,this.padOffset=a,this.isLE=c,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){exists(this);const{view:n,buffer:a,blockLen:c}=this;e=toBytes(e);const o=e.length;for(let u=0;u<o;){const h=Math.min(c-this.pos,o-u);if(h===c){const l=createView(e);for(;c<=o-u;u+=c)this.process(l,u);continue}a.set(e.subarray(u,u+h),this.pos),this.pos+=h,u+=h,this.pos===c&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists(this),output(e,this),this.finished=!0;const{buffer:n,view:a,blockLen:c,isLE:o}=this;let{pos:u}=this;n[u++]=128,this.buffer.subarray(u).fill(0),this.padOffset>c-u&&(this.process(a,0),u=0);for(let p=u;p<c;p++)n[p]=0;setBigUint64(a,c-8,BigInt(this.length*8),o),this.process(a,0);const h=createView(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const b=l/4,d=this.get();if(b>d.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<b;p++)h.setUint32(4*p,d[p],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const a=e.slice(0,n);return this.destroy(),a}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:a,length:c,finished:o,destroyed:u,pos:h}=this;return e.length=c,e.pos=h,e.finished=o,e.destroyed=u,c%n&&e.buffer.set(a),e}}const Chi=(t,e,n)=>t&e^~t&n,Maj=(t,e,n)=>t&e^t&n^e&n,SHA256_K=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);let SHA256$2=class extends SHA2{constructor(){super(64,32,8,!1),this.A=IV[0]|0,this.B=IV[1]|0,this.C=IV[2]|0,this.D=IV[3]|0,this.E=IV[4]|0,this.F=IV[5]|0,this.G=IV[6]|0,this.H=IV[7]|0}get(){const{A:e,B:n,C:a,D:c,E:o,F:u,G:h,H:l}=this;return[e,n,a,c,o,u,h,l]}set(e,n,a,c,o,u,h,l){this.A=e|0,this.B=n|0,this.C=a|0,this.D=c|0,this.E=o|0,this.F=u|0,this.G=h|0,this.H=l|0}process(e,n){for(let p=0;p<16;p++,n+=4)SHA256_W[p]=e.getUint32(n,!1);for(let p=16;p<64;p++){const x=SHA256_W[p-15],m=SHA256_W[p-2],v=rotr(x,7)^rotr(x,18)^x>>>3,g=rotr(m,17)^rotr(m,19)^m>>>10;SHA256_W[p]=g+SHA256_W[p-7]+v+SHA256_W[p-16]|0}let{A:a,B:c,C:o,D:u,E:h,F:l,G:b,H:d}=this;for(let p=0;p<64;p++){const x=rotr(h,6)^rotr(h,11)^rotr(h,25),m=d+x+Chi(h,l,b)+SHA256_K[p]+SHA256_W[p]|0,g=(rotr(a,2)^rotr(a,13)^rotr(a,22))+Maj(a,c,o)|0;d=b,b=l,l=h,h=u+m|0,u=o,o=c,c=a,a=m+g|0}a=a+this.A|0,c=c+this.B|0,o=o+this.C|0,u=u+this.D|0,h=h+this.E|0,l=l+this.F|0,b=b+this.G|0,d=d+this.H|0,this.set(a,c,o,u,h,l,b,d)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$3=wrapConstructor(()=>new SHA256$2),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(t,e=!1){return e?{h:Number(t&U32_MASK64),l:Number(t>>_32n&U32_MASK64)}:{h:Number(t>>_32n&U32_MASK64)|0,l:Number(t&U32_MASK64)|0}}function split(t,e=!1){let n=new Uint32Array(t.length),a=new Uint32Array(t.length);for(let c=0;c<t.length;c++){const{h:o,l:u}=fromBig(t[c],e);[n[c],a[c]]=[o,u]}return[n,a]}const toBig=(t,e)=>BigInt(t>>>0)<<_32n|BigInt(e>>>0),shrSH=(t,e,n)=>t>>>n,shrSL=(t,e,n)=>t<<32-n|e>>>n,rotrSH=(t,e,n)=>t>>>n|e<<32-n,rotrSL=(t,e,n)=>t<<32-n|e>>>n,rotrBH=(t,e,n)=>t<<64-n|e>>>n-32,rotrBL=(t,e,n)=>t>>>n-32|e<<64-n,rotr32H=(t,e)=>e,rotr32L=(t,e)=>t,rotlSH=(t,e,n)=>t<<n|e>>>32-n,rotlSL=(t,e,n)=>e<<n|t>>>32-n,rotlBH=(t,e,n)=>e<<n-32|t>>>64-n,rotlBL=(t,e,n)=>t<<n-32|e>>>64-n;function add(t,e,n,a){const c=(e>>>0)+(a>>>0);return{h:t+n+(c/2**32|0)|0,l:c|0}}const add3L=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H=(t,e,n,a)=>e+n+a+(t/2**32|0)|0,add4L=(t,e,n,a)=>(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0),add4H=(t,e,n,a,c)=>e+n+a+c+(t/2**32|0)|0,add5L=(t,e,n,a,c)=>(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0)+(c>>>0),add5H=(t,e,n,a,c,o)=>e+n+a+c+o+(t/2**32|0)|0,u64={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},[SHA512_Kh,SHA512_Kl]=u64.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);let SHA512$2=class extends SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:n,Bh:a,Bl:c,Ch:o,Cl:u,Dh:h,Dl:l,Eh:b,El:d,Fh:p,Fl:x,Gh:m,Gl:v,Hh:g,Hl:$}=this;return[e,n,a,c,o,u,h,l,b,d,p,x,m,v,g,$]}set(e,n,a,c,o,u,h,l,b,d,p,x,m,v,g,$){this.Ah=e|0,this.Al=n|0,this.Bh=a|0,this.Bl=c|0,this.Ch=o|0,this.Cl=u|0,this.Dh=h|0,this.Dl=l|0,this.Eh=b|0,this.El=d|0,this.Fh=p|0,this.Fl=x|0,this.Gh=m|0,this.Gl=v|0,this.Hh=g|0,this.Hl=$|0}process(e,n){for(let F=0;F<16;F++,n+=4)SHA512_W_H[F]=e.getUint32(n),SHA512_W_L[F]=e.getUint32(n+=4);for(let F=16;F<80;F++){const H=SHA512_W_H[F-15]|0,W=SHA512_W_L[F-15]|0,Z=u64.rotrSH(H,W,1)^u64.rotrSH(H,W,8)^u64.shrSH(H,W,7),ie=u64.rotrSL(H,W,1)^u64.rotrSL(H,W,8)^u64.shrSL(H,W,7),te=SHA512_W_H[F-2]|0,ae=SHA512_W_L[F-2]|0,de=u64.rotrSH(te,ae,19)^u64.rotrBH(te,ae,61)^u64.shrSH(te,ae,6),J=u64.rotrSL(te,ae,19)^u64.rotrBL(te,ae,61)^u64.shrSL(te,ae,6),R=u64.add4L(ie,J,SHA512_W_L[F-7],SHA512_W_L[F-16]),A=u64.add4H(R,Z,de,SHA512_W_H[F-7],SHA512_W_H[F-16]);SHA512_W_H[F]=A|0,SHA512_W_L[F]=R|0}let{Ah:a,Al:c,Bh:o,Bl:u,Ch:h,Cl:l,Dh:b,Dl:d,Eh:p,El:x,Fh:m,Fl:v,Gh:g,Gl:$,Hh:B,Hl:C}=this;for(let F=0;F<80;F++){const H=u64.rotrSH(p,x,14)^u64.rotrSH(p,x,18)^u64.rotrBH(p,x,41),W=u64.rotrSL(p,x,14)^u64.rotrSL(p,x,18)^u64.rotrBL(p,x,41),Z=p&m^~p&g,ie=x&v^~x&$,te=u64.add5L(C,W,ie,SHA512_Kl[F],SHA512_W_L[F]),ae=u64.add5H(te,B,H,Z,SHA512_Kh[F],SHA512_W_H[F]),de=te|0,J=u64.rotrSH(a,c,28)^u64.rotrBH(a,c,34)^u64.rotrBH(a,c,39),R=u64.rotrSL(a,c,28)^u64.rotrBL(a,c,34)^u64.rotrBL(a,c,39),A=a&o^a&h^o&h,y=c&u^c&l^u&l;B=g|0,C=$|0,g=m|0,$=v|0,m=p|0,v=x|0,{h:p,l:x}=u64.add(b|0,d|0,ae|0,de|0),b=h|0,d=l|0,h=o|0,l=u|0,o=a|0,u=c|0;const w=u64.add3L(de,R,y);a=u64.add3H(w,ae,J,A),c=w|0}({h:a,l:c}=u64.add(this.Ah|0,this.Al|0,a|0,c|0)),{h:o,l:u}=u64.add(this.Bh|0,this.Bl|0,o|0,u|0),{h,l}=u64.add(this.Ch|0,this.Cl|0,h|0,l|0),{h:b,l:d}=u64.add(this.Dh|0,this.Dl|0,b|0,d|0),{h:p,l:x}=u64.add(this.Eh|0,this.El|0,p|0,x|0),{h:m,l:v}=u64.add(this.Fh|0,this.Fl|0,m|0,v|0),{h:g,l:$}=u64.add(this.Gh|0,this.Gl|0,g|0,$|0),{h:B,l:C}=u64.add(this.Hh|0,this.Hl|0,B|0,C|0),this.set(a,c,o,u,h,l,b,d,p,x,m,v,g,$,B,C)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sha512$2=wrapConstructor(()=>new SHA512$2);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global$1<"u")return global$1;throw new Error("unable to locate global object")}const anyGlobal=getGlobal(),crypto$1=anyGlobal.crypto||anyGlobal.msCrypto;function createHash(t){switch(t){case"sha256":return sha256$3.create();case"sha512":return sha512$2.create()}assertArgument(!1,"invalid hashing algorithm name","algorithm",t)}function createHmac(t,e){const n={sha256:sha256$3,sha512:sha512$2}[t];return assertArgument(n!=null,"invalid hmac algorithm","algorithm",t),hmac$1.create(n,e)}function pbkdf2Sync(t,e,n,a,c){const o={sha256:sha256$3,sha512:sha512$2}[c];return assertArgument(o!=null,"invalid pbkdf2 algorithm","algorithm",c),pbkdf2$1(o,t,e,{c:n,dkLen:a})}function randomBytes$1(t){assert$f(crypto$1!=null,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),assertArgument(Number.isInteger(t)&&t>0&&t<=1024,"invalid length","length",t);const e=new Uint8Array(t);return crypto$1.getRandomValues(e),e}let locked$4=!1;const _computeHmac=function(t,e,n){return createHmac(t,e).update(n).digest()};let __computeHmac=_computeHmac;function computeHmac(t,e,n){const a=getBytes(e,"key"),c=getBytes(n,"data");return hexlify(__computeHmac(t,a,c))}computeHmac._=_computeHmac,computeHmac.lock=function(){locked$4=!0},computeHmac.register=function(t){if(locked$4)throw new Error("computeHmac is locked");__computeHmac=t},Object.freeze(computeHmac);const[SHA3_PI,SHA3_ROTL,_SHA3_IOTA]=[[],[],[]],_0n$4=BigInt(0),_1n$5=BigInt(1),_2n$3=BigInt(2),_7n=BigInt(7),_256n=BigInt(256),_0x71n=BigInt(113);for(let t=0,e=_1n$5,n=1,a=0;t<24;t++){[n,a]=[a,(2*n+3*a)%5],SHA3_PI.push(2*(5*a+n)),SHA3_ROTL.push((t+1)*(t+2)/2%64);let c=_0n$4;for(let o=0;o<7;o++)e=(e<<_1n$5^(e>>_7n)*_0x71n)%_256n,e&_2n$3&&(c^=_1n$5<<(_1n$5<<BigInt(o))-_1n$5);_SHA3_IOTA.push(c)}const[SHA3_IOTA_H,SHA3_IOTA_L]=split(_SHA3_IOTA,!0),rotlH=(t,e,n)=>n>32?rotlBH(t,e,n):rotlSH(t,e,n),rotlL=(t,e,n)=>n>32?rotlBL(t,e,n):rotlSL(t,e,n);function keccakP(t,e=24){const n=new Uint32Array(10);for(let a=24-e;a<24;a++){for(let u=0;u<10;u++)n[u]=t[u]^t[u+10]^t[u+20]^t[u+30]^t[u+40];for(let u=0;u<10;u+=2){const h=(u+8)%10,l=(u+2)%10,b=n[l],d=n[l+1],p=rotlH(b,d,1)^n[h],x=rotlL(b,d,1)^n[h+1];for(let m=0;m<50;m+=10)t[u+m]^=p,t[u+m+1]^=x}let c=t[2],o=t[3];for(let u=0;u<24;u++){const h=SHA3_ROTL[u],l=rotlH(c,o,h),b=rotlL(c,o,h),d=SHA3_PI[u];c=t[d],o=t[d+1],t[d]=l,t[d+1]=b}for(let u=0;u<50;u+=10){for(let h=0;h<10;h++)n[h]=t[u+h];for(let h=0;h<10;h++)t[u+h]^=~n[(h+2)%10]&n[(h+4)%10]}t[0]^=SHA3_IOTA_H[a],t[1]^=SHA3_IOTA_L[a]}n.fill(0)}class Keccak extends Hash{constructor(e,n,a,c=!1,o=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=a,this.enableXOF=c,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,number(a),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=u32(this.state)}keccak(){keccakP(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){exists(this);const{blockLen:n,state:a}=this;e=toBytes(e);const c=e.length;for(let o=0;o<c;){const u=Math.min(n-this.pos,c-o);for(let h=0;h<u;h++)a[this.pos++]^=e[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:a,blockLen:c}=this;e[a]^=n,n&128&&a===c-1&&this.keccak(),e[c-1]^=128,this.keccak()}writeInto(e){exists(this,!1),bytes(e),this.finish();const n=this.state,{blockLen:a}=this;for(let c=0,o=e.length;c<o;){this.posOut>=a&&this.keccak();const u=Math.min(a-this.posOut,o-c);e.set(n.subarray(this.posOut,this.posOut+u),c),this.posOut+=u,c+=u}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:n,suffix:a,outputLen:c,rounds:o,enableXOF:u}=this;return e||(e=new Keccak(n,a,c,u,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=a,e.outputLen=c,e.enableXOF=u,e.destroyed=this.destroyed,e}}const gen=(t,e,n)=>wrapConstructor(()=>new Keccak(e,t,n)),keccak_256=gen(1,136,256/8);let locked$3=!1;const _keccak256=function(t){return keccak_256(t)};let __keccak256=_keccak256;function keccak256(t){const e=getBytes(t,"data");return hexlify(__keccak256(e))}keccak256._=_keccak256,keccak256.lock=function(){locked$3=!0},keccak256.register=function(t){if(locked$3)throw new TypeError("keccak256 is locked");__keccak256=t},Object.freeze(keccak256);const Rho=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id=Uint8Array.from({length:16},(t,e)=>e),Pi=Id.map(t=>(9*t+5)%16);let idxL=[Id],idxR=[Pi];for(let t=0;t<4;t++)for(let e of[idxL,idxR])e.push(e[t].map(n=>Rho[n]));const shifts=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),shiftsL=idxL.map((t,e)=>t.map(n=>shifts[e][n])),shiftsR=idxR.map((t,e)=>t.map(n=>shifts[e][n])),Kl=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),rotl$1=(t,e)=>t<<e|t>>>32-e;function f$1(t,e,n,a){return t===0?e^n^a:t===1?e&n|~e&a:t===2?(e|~n)^a:t===3?e&a|n&~a:e^(n|~a)}const BUF=new Uint32Array(16);let RIPEMD160$1=class extends SHA2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:a,h3:c,h4:o}=this;return[e,n,a,c,o]}set(e,n,a,c,o){this.h0=e|0,this.h1=n|0,this.h2=a|0,this.h3=c|0,this.h4=o|0}process(e,n){for(let m=0;m<16;m++,n+=4)BUF[m]=e.getUint32(n,!0);let a=this.h0|0,c=a,o=this.h1|0,u=o,h=this.h2|0,l=h,b=this.h3|0,d=b,p=this.h4|0,x=p;for(let m=0;m<5;m++){const v=4-m,g=Kl[m],$=Kr[m],B=idxL[m],C=idxR[m],F=shiftsL[m],H=shiftsR[m];for(let W=0;W<16;W++){const Z=rotl$1(a+f$1(m,o,h,b)+BUF[B[W]]+g,F[W])+p|0;a=p,p=b,b=rotl$1(h,10)|0,h=o,o=Z}for(let W=0;W<16;W++){const Z=rotl$1(c+f$1(v,u,l,d)+BUF[C[W]]+$,H[W])+x|0;c=x,x=d,d=rotl$1(l,10)|0,l=u,u=Z}}this.set(this.h1+h+d|0,this.h2+b+x|0,this.h3+p+c|0,this.h4+a+u|0,this.h0+o+l|0)}roundClean(){BUF.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const ripemd160$2=wrapConstructor(()=>new RIPEMD160$1);let locked$2=!1;const _ripemd160=function(t){return ripemd160$2(t)};let __ripemd160=_ripemd160;function ripemd160$1(t){const e=getBytes(t,"data");return hexlify(__ripemd160(e))}ripemd160$1._=_ripemd160,ripemd160$1.lock=function(){locked$2=!0},ripemd160$1.register=function(t){if(locked$2)throw new TypeError("ripemd160 is locked");__ripemd160=t},Object.freeze(ripemd160$1);let locked$1=!1;const _pbkdf2=function(t,e,n,a,c){return pbkdf2Sync(t,e,n,a,c)};let __pbkdf2=_pbkdf2;function pbkdf2(t,e,n,a,c){const o=getBytes(t,"password"),u=getBytes(e,"salt");return hexlify(__pbkdf2(o,u,n,a,c))}pbkdf2._=_pbkdf2,pbkdf2.lock=function(){locked$1=!0},pbkdf2.register=function(t){if(locked$1)throw new Error("pbkdf2 is locked");__pbkdf2=t},Object.freeze(pbkdf2);let locked=!1;const _randomBytes=function(t){return new Uint8Array(randomBytes$1(t))};let __randomBytes=_randomBytes;function randomBytes(t){return __randomBytes(t)}randomBytes._=_randomBytes,randomBytes.lock=function(){locked=!0},randomBytes.register=function(t){if(locked)throw new Error("randomBytes is locked");__randomBytes=t},Object.freeze(randomBytes);const rotl=(t,e)=>t<<e|t>>>32-e;function XorAndSalsa(t,e,n,a,c,o){let u=t[e++]^n[a++],h=t[e++]^n[a++],l=t[e++]^n[a++],b=t[e++]^n[a++],d=t[e++]^n[a++],p=t[e++]^n[a++],x=t[e++]^n[a++],m=t[e++]^n[a++],v=t[e++]^n[a++],g=t[e++]^n[a++],$=t[e++]^n[a++],B=t[e++]^n[a++],C=t[e++]^n[a++],F=t[e++]^n[a++],H=t[e++]^n[a++],W=t[e++]^n[a++],Z=u,ie=h,te=l,ae=b,de=d,J=p,R=x,A=m,y=v,w=g,I=$,M=B,k=C,P=F,_=H,q=W;for(let E=0;E<8;E+=2)de^=rotl(Z+k|0,7),y^=rotl(de+Z|0,9),k^=rotl(y+de|0,13),Z^=rotl(k+y|0,18),w^=rotl(J+ie|0,7),P^=rotl(w+J|0,9),ie^=rotl(P+w|0,13),J^=rotl(ie+P|0,18),_^=rotl(I+R|0,7),te^=rotl(_+I|0,9),R^=rotl(te+_|0,13),I^=rotl(R+te|0,18),ae^=rotl(q+M|0,7),A^=rotl(ae+q|0,9),M^=rotl(A+ae|0,13),q^=rotl(M+A|0,18),ie^=rotl(Z+ae|0,7),te^=rotl(ie+Z|0,9),ae^=rotl(te+ie|0,13),Z^=rotl(ae+te|0,18),R^=rotl(J+de|0,7),A^=rotl(R+J|0,9),de^=rotl(A+R|0,13),J^=rotl(de+A|0,18),M^=rotl(I+w|0,7),y^=rotl(M+I|0,9),w^=rotl(y+M|0,13),I^=rotl(w+y|0,18),k^=rotl(q+_|0,7),P^=rotl(k+q|0,9),_^=rotl(P+k|0,13),q^=rotl(_+P|0,18);c[o++]=u+Z|0,c[o++]=h+ie|0,c[o++]=l+te|0,c[o++]=b+ae|0,c[o++]=d+de|0,c[o++]=p+J|0,c[o++]=x+R|0,c[o++]=m+A|0,c[o++]=v+y|0,c[o++]=g+w|0,c[o++]=$+I|0,c[o++]=B+M|0,c[o++]=C+k|0,c[o++]=F+P|0,c[o++]=H+_|0,c[o++]=W+q|0}function BlockMix(t,e,n,a,c){let o=a+0,u=a+16*c;for(let h=0;h<16;h++)n[u+h]=t[e+(2*c-1)*16+h];for(let h=0;h<c;h++,o+=16,e+=16)XorAndSalsa(n,u,t,e,n,o),h>0&&(u+=16),XorAndSalsa(n,o,t,e+=16,n,u)}function scryptInit(t,e,n){const a=checkOpts({dkLen:32,asyncTick:10,maxmem:1073742848},n),{N:c,r:o,p:u,dkLen:h,asyncTick:l,maxmem:b,onProgress:d}=a;if(number(c),number(o),number(u),number(h),number(l),number(b),d!==void 0&&typeof d!="function")throw new Error("progressCb should be function");const p=128*o,x=p/4;if(c<=1||c&c-1||c>=2**(p/8)||c>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(u<0||u>(2**32-1)*32/p)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(h<0||h>(2**32-1)*32)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const m=p*(c+u);if(m>b)throw new Error(`Scrypt: parameters too large, ${m} (128 * r * (N + p)) > ${b} (maxmem)`);const v=pbkdf2$1(sha256$3,t,e,{c:1,dkLen:p*u}),g=u32(v),$=u32(new Uint8Array(p*c)),B=u32(new Uint8Array(p));let C=()=>{};if(d){const F=2*c*u,H=Math.max(Math.floor(F/1e4),1);let W=0;C=()=>{W++,d&&(!(W%H)||W===F)&&d(W/F)}}return{N:c,r:o,p:u,dkLen:h,blockSize32:x,V:$,B32:g,B:v,tmp:B,blockMixCb:C,asyncTick:l}}function scryptOutput(t,e,n,a,c){const o=pbkdf2$1(sha256$3,t,n,{c:1,dkLen:e});return n.fill(0),a.fill(0),c.fill(0),o}function scrypt$1(t,e,n){const{N:a,r:c,p:o,dkLen:u,blockSize32:h,V:l,B32:b,B:d,tmp:p,blockMixCb:x}=scryptInit(t,e,n);for(let m=0;m<o;m++){const v=h*m;for(let g=0;g<h;g++)l[g]=b[v+g];for(let g=0,$=0;g<a-1;g++)BlockMix(l,$,l,$+=h,c),x();BlockMix(l,(a-1)*h,b,v,c),x();for(let g=0;g<a;g++){const $=b[v+h-16]%a;for(let B=0;B<h;B++)p[B]=b[v+B]^l[$*h+B];BlockMix(p,0,b,v,c),x()}}return scryptOutput(t,u,d,l,p)}async function scryptAsync(t,e,n){const{N:a,r:c,p:o,dkLen:u,blockSize32:h,V:l,B32:b,B:d,tmp:p,blockMixCb:x,asyncTick:m}=scryptInit(t,e,n);for(let v=0;v<o;v++){const g=h*v;for(let B=0;B<h;B++)l[B]=b[g+B];let $=0;await asyncLoop(a-1,m,()=>{BlockMix(l,$,l,$+=h,c),x()}),BlockMix(l,(a-1)*h,b,g,c),x(),await asyncLoop(a,m,()=>{const B=b[g+h-16]%a;for(let C=0;C<h;C++)p[C]=b[g+C]^l[B*h+C];BlockMix(p,0,b,g,c),x()})}return scryptOutput(t,u,d,l,p)}let lockedSync=!1,lockedAsync=!1;const _scryptAsync=async function(t,e,n,a,c,o,u){return await scryptAsync(t,e,{N:n,r:a,p:c,dkLen:o,onProgress:u})},_scryptSync=function(t,e,n,a,c,o){return scrypt$1(t,e,{N:n,r:a,p:c,dkLen:o})};let __scryptAsync=_scryptAsync,__scryptSync=_scryptSync;async function scrypt(t,e,n,a,c,o,u){const h=getBytes(t,"passwd"),l=getBytes(e,"salt");return hexlify(await __scryptAsync(h,l,n,a,c,o,u))}scrypt._=_scryptAsync,scrypt.lock=function(){lockedAsync=!0},scrypt.register=function(t){if(lockedAsync)throw new Error("scrypt is locked");__scryptAsync=t},Object.freeze(scrypt);function scryptSync(t,e,n,a,c,o){const u=getBytes(t,"passwd"),h=getBytes(e,"salt");return hexlify(__scryptSync(u,h,n,a,c,o))}scryptSync._=_scryptSync,scryptSync.lock=function(){lockedSync=!0},scryptSync.register=function(t){if(lockedSync)throw new Error("scryptSync is locked");__scryptSync=t},Object.freeze(scryptSync);const _sha256=function(t){return createHash("sha256").update(t).digest()};let __sha256=_sha256,locked256=!1;function sha256$2(t){const e=getBytes(t,"data");return hexlify(__sha256(e))}sha256$2._=_sha256,sha256$2.lock=function(){locked256=!0},sha256$2.register=function(t){if(locked256)throw new Error("sha256 is locked");__sha256=t},Object.freeze(sha256$2),Object.freeze(sha256$2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$4=BigInt(1),_2n$2=BigInt(2),u8a=t=>t instanceof Uint8Array,hexes=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function bytesToHex$2(t){if(!u8a(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=hexes[t[n]];return e}function numberToHexUnpadded(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function hexToNumber(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function hexToBytes$1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let a=0;a<n.length;a++){const c=a*2,o=t.slice(c,c+2),u=Number.parseInt(o,16);if(Number.isNaN(u)||u<0)throw new Error("Invalid byte sequence");n[a]=u}return n}function bytesToNumberBE(t){return hexToNumber(bytesToHex$2(t))}function bytesToNumberLE(t){if(!u8a(t))throw new Error("Uint8Array expected");return hexToNumber(bytesToHex$2(Uint8Array.from(t).reverse()))}function numberToBytesBE(t,e){return hexToBytes$1(t.toString(16).padStart(e*2,"0"))}function numberToBytesLE(t,e){return numberToBytesBE(t,e).reverse()}function numberToVarBytesBE(t){return hexToBytes$1(numberToHexUnpadded(t))}function ensureBytes(t,e,n){let a;if(typeof e=="string")try{a=hexToBytes$1(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(u8a(e))a=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const c=a.length;if(typeof n=="number"&&c!==n)throw new Error(`${t} expected ${n} bytes, got ${c}`);return a}function concatBytes(...t){const e=new Uint8Array(t.reduce((a,c)=>a+c.length,0));let n=0;return t.forEach(a=>{if(!u8a(a))throw new Error("Uint8Array expected");e.set(a,n),n+=a.length}),e}function equalBytes$1(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function utf8ToBytes(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function bitLen(t){let e;for(e=0;t>_0n$3;t>>=_1n$4,e+=1);return e}function bitGet(t,e){return t>>BigInt(e)&_1n$4}const bitSet=(t,e,n)=>t|(n?_1n$4:_0n$3)<<BigInt(e),bitMask=t=>(_2n$2<<BigInt(t-1))-_1n$4,u8n=t=>new Uint8Array(t),u8fr=t=>Uint8Array.from(t);function createHmacDrbg(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let a=u8n(t),c=u8n(t),o=0;const u=()=>{a.fill(1),c.fill(0),o=0},h=(...p)=>n(c,a,...p),l=(p=u8n())=>{c=h(u8fr([0]),p),a=h(),p.length!==0&&(c=h(u8fr([1]),p),a=h())},b=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let p=0;const x=[];for(;p<e;){a=h();const m=a.slice();x.push(m),p+=a.length}return concatBytes(...x)};return(p,x)=>{u(),l(p);let m;for(;!(m=x(b()));)l();return u(),m}}const validatorFns={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function validateObject(t,e,n={}){const a=(c,o,u)=>{const h=validatorFns[o];if(typeof h!="function")throw new Error(`Invalid validator "${o}", expected function`);const l=t[c];if(!(u&&l===void 0)&&!h(l,t))throw new Error(`Invalid param ${String(c)}=${l} (${typeof l}), expected ${o}`)};for(const[c,o]of Object.entries(e))a(c,o,!1);for(const[c,o]of Object.entries(n))a(c,o,!0);return t}const ut=Object.freeze(Object.defineProperty({__proto__:null,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes,createHmacDrbg,ensureBytes,equalBytes:equalBytes$1,hexToBytes:hexToBytes$1,hexToNumber,numberToBytesBE,numberToBytesLE,numberToHexUnpadded,numberToVarBytesBE,utf8ToBytes,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_4n=BigInt(4),_5n=BigInt(5),_8n=BigInt(8);BigInt(9),BigInt(16);function mod(t,e){const n=t%e;return n>=_0n$2?n:e+n}function pow(t,e,n){if(n<=_0n$2||e<_0n$2)throw new Error("Expected power/modulo > 0");if(n===_1n$3)return _0n$2;let a=_1n$3;for(;e>_0n$2;)e&_1n$3&&(a=a*t%n),t=t*t%n,e>>=_1n$3;return a}function pow2(t,e,n){let a=t;for(;e-- >_0n$2;)a*=a,a%=n;return a}function invert(t,e){if(t===_0n$2||e<=_0n$2)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=mod(t,e),a=e,c=_0n$2,o=_1n$3;for(;n!==_0n$2;){const h=a/n,l=a%n,b=c-o*h;a=n,n=l,c=o,o=b}if(a!==_1n$3)throw new Error("invert: does not exist");return mod(c,e)}function tonelliShanks(t){const e=(t-_1n$3)/_2n$1;let n,a,c;for(n=t-_1n$3,a=0;n%_2n$1===_0n$2;n/=_2n$1,a++);for(c=_2n$1;c<t&&pow(c,e,t)!==t-_1n$3;c++);if(a===1){const u=(t+_1n$3)/_4n;return function(l,b){const d=l.pow(b,u);if(!l.eql(l.sqr(d),b))throw new Error("Cannot find square root");return d}}const o=(n+_1n$3)/_2n$1;return function(h,l){if(h.pow(l,e)===h.neg(h.ONE))throw new Error("Cannot find square root");let b=a,d=h.pow(h.mul(h.ONE,c),n),p=h.pow(l,o),x=h.pow(l,n);for(;!h.eql(x,h.ONE);){if(h.eql(x,h.ZERO))return h.ZERO;let m=1;for(let g=h.sqr(x);m<b&&!h.eql(g,h.ONE);m++)g=h.sqr(g);const v=h.pow(d,_1n$3<<BigInt(b-m-1));d=h.sqr(v),p=h.mul(p,v),x=h.mul(x,d),b=m}return p}}function FpSqrt(t){if(t%_4n===_3n$1){const e=(t+_1n$3)/_4n;return function(a,c){const o=a.pow(c,e);if(!a.eql(a.sqr(o),c))throw new Error("Cannot find square root");return o}}if(t%_8n===_5n){const e=(t-_5n)/_8n;return function(a,c){const o=a.mul(c,_2n$1),u=a.pow(o,e),h=a.mul(c,u),l=a.mul(a.mul(h,_2n$1),u),b=a.mul(h,a.sub(l,a.ONE));if(!a.eql(a.sqr(b),c))throw new Error("Cannot find square root");return b}}return tonelliShanks(t)}const FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=FIELD_FIELDS.reduce((a,c)=>(a[c]="function",a),e);return validateObject(t,n)}function FpPow(t,e,n){if(n<_0n$2)throw new Error("Expected power > 0");if(n===_0n$2)return t.ONE;if(n===_1n$3)return e;let a=t.ONE,c=e;for(;n>_0n$2;)n&_1n$3&&(a=t.mul(a,c)),c=t.sqr(c),n>>=_1n$3;return a}function FpInvertBatch(t,e){const n=new Array(e.length),a=e.reduce((o,u,h)=>t.is0(u)?o:(n[h]=o,t.mul(o,u)),t.ONE),c=t.inv(a);return e.reduceRight((o,u,h)=>t.is0(u)?o:(n[h]=t.mul(o,n[h]),t.mul(o,u)),c),n}function nLength(t,e){const n=e!==void 0?e:t.toString(2).length,a=Math.ceil(n/8);return{nBitLength:n,nByteLength:a}}function Field(t,e,n=!1,a={}){if(t<=_0n$2)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:c,nByteLength:o}=nLength(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const u=FpSqrt(t),h=Object.freeze({ORDER:t,BITS:c,BYTES:o,MASK:bitMask(c),ZERO:_0n$2,ONE:_1n$3,create:l=>mod(l,t),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return _0n$2<=l&&l<t},is0:l=>l===_0n$2,isOdd:l=>(l&_1n$3)===_1n$3,neg:l=>mod(-l,t),eql:(l,b)=>l===b,sqr:l=>mod(l*l,t),add:(l,b)=>mod(l+b,t),sub:(l,b)=>mod(l-b,t),mul:(l,b)=>mod(l*b,t),pow:(l,b)=>FpPow(h,l,b),div:(l,b)=>mod(l*invert(b,t),t),sqrN:l=>l*l,addN:(l,b)=>l+b,subN:(l,b)=>l-b,mulN:(l,b)=>l*b,inv:l=>invert(l,t),sqrt:a.sqrt||(l=>u(h,l)),invertBatch:l=>FpInvertBatch(h,l),cmov:(l,b,d)=>d?b:l,toBytes:l=>n?numberToBytesLE(l,o):numberToBytesBE(l,o),fromBytes:l=>{if(l.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${l.length}`);return n?bytesToNumberLE(l):bytesToNumberBE(l)}});return Object.freeze(h)}function getFieldBytesLength(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function getMinHashLength(t){const e=getFieldBytesLength(t);return e+Math.ceil(e/2)}function mapHashToField(t,e,n=!1){const a=t.length,c=getFieldBytesLength(e),o=getMinHashLength(e);if(a<16||a<o||a>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${a}`);const u=n?bytesToNumberBE(t):bytesToNumberLE(t),h=mod(u,e-_1n$3)+_1n$3;return n?numberToBytesLE(h,c):numberToBytesBE(h,c)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function wNAF(t,e){const n=(c,o)=>{const u=o.negate();return c?u:o},a=c=>{const o=Math.ceil(e/c)+1,u=2**(c-1);return{windows:o,windowSize:u}};return{constTimeNegate:n,unsafeLadder(c,o){let u=t.ZERO,h=c;for(;o>_0n$1;)o&_1n$2&&(u=u.add(h)),h=h.double(),o>>=_1n$2;return u},precomputeWindow(c,o){const{windows:u,windowSize:h}=a(o),l=[];let b=c,d=b;for(let p=0;p<u;p++){d=b,l.push(d);for(let x=1;x<h;x++)d=d.add(b),l.push(d);b=d.double()}return l},wNAF(c,o,u){const{windows:h,windowSize:l}=a(c);let b=t.ZERO,d=t.BASE;const p=BigInt(2**c-1),x=2**c,m=BigInt(c);for(let v=0;v<h;v++){const g=v*l;let $=Number(u&p);u>>=m,$>l&&($-=x,u+=_1n$2);const B=g,C=g+Math.abs($)-1,F=v%2!==0,H=$<0;$===0?d=d.add(n(F,o[B])):b=b.add(n(H,o[C]))}return{p:b,f:d}},wNAFCached(c,o,u,h){const l=c._WINDOW_SIZE||1;let b=o.get(c);return b||(b=this.precomputeWindow(c,l),l!==1&&o.set(c,h(b))),this.wNAF(l,b,u)}}}function validateBasic(t){return validateField(t.Fp),validateObject(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(t){const e=validateBasic(t);validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:a,a:c}=e;if(n){if(!a.eql(c,a.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],a=t.subarray(2,n+2);if(!n||a.length!==n)throw new e("Invalid signature integer: wrong length");if(a[0]&128)throw new e("Invalid signature integer: negative");if(a[0]===0&&!(a[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:b2n(a),l:t.subarray(n+2)}},toSig(t){const{Err:e}=DER,n=typeof t=="string"?h2b(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let a=n.length;if(a<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==a-2)throw new e("Invalid signature: incorrect length");const{d:c,l:o}=DER._parseInt(n.subarray(2)),{d:u,l:h}=DER._parseInt(o);if(h.length)throw new e("Invalid signature: left bytes after parsing");return{r:c,s:u}},hexFromSig(t){const e=b=>Number.parseInt(b[0],16)&8?"00"+b:b,n=b=>{const d=b.toString(16);return d.length&1?`0${d}`:d},a=e(n(t.s)),c=e(n(t.r)),o=a.length/2,u=c.length/2,h=n(o),l=n(u);return`30${n(u+o+4)}02${l}${c}02${h}${a}`}},_0n=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);BigInt(4);function weierstrassPoints(t){const e=validatePointOpts(t),{Fp:n}=e,a=e.toBytes||((v,g,$)=>{const B=g.toAffine();return concatBytes(Uint8Array.from([4]),n.toBytes(B.x),n.toBytes(B.y))}),c=e.fromBytes||(v=>{const g=v.subarray(1),$=n.fromBytes(g.subarray(0,n.BYTES)),B=n.fromBytes(g.subarray(n.BYTES,2*n.BYTES));return{x:$,y:B}});function o(v){const{a:g,b:$}=e,B=n.sqr(v),C=n.mul(B,v);return n.add(n.add(C,n.mul(v,g)),$)}if(!n.eql(n.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function u(v){return typeof v=="bigint"&&_0n<v&&v<e.n}function h(v){if(!u(v))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(v){const{allowedPrivateKeyLengths:g,nByteLength:$,wrapPrivateKey:B,n:C}=e;if(g&&typeof v!="bigint"){if(v instanceof Uint8Array&&(v=bytesToHex$2(v)),typeof v!="string"||!g.includes(v.length))throw new Error("Invalid key");v=v.padStart($*2,"0")}let F;try{F=typeof v=="bigint"?v:bytesToNumberBE(ensureBytes("private key",v,$))}catch{throw new Error(`private key must be ${$} bytes, hex or bigint, not ${typeof v}`)}return B&&(F=mod(F,C)),h(F),F}const b=new Map;function d(v){if(!(v instanceof p))throw new Error("ProjectivePoint expected")}class p{constructor(g,$,B){if(this.px=g,this.py=$,this.pz=B,g==null||!n.isValid(g))throw new Error("x required");if($==null||!n.isValid($))throw new Error("y required");if(B==null||!n.isValid(B))throw new Error("z required")}static fromAffine(g){const{x:$,y:B}=g||{};if(!g||!n.isValid($)||!n.isValid(B))throw new Error("invalid affine point");if(g instanceof p)throw new Error("projective point not allowed");const C=F=>n.eql(F,n.ZERO);return C($)&&C(B)?p.ZERO:new p($,B,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const $=n.invertBatch(g.map(B=>B.pz));return g.map((B,C)=>B.toAffine($[C])).map(p.fromAffine)}static fromHex(g){const $=p.fromAffine(c(ensureBytes("pointHex",g)));return $.assertValidity(),$}static fromPrivateKey(g){return p.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,b.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y:$}=this.toAffine();if(!n.isValid(g)||!n.isValid($))throw new Error("bad point: x or y not FE");const B=n.sqr($),C=o(g);if(!n.eql(B,C))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(n.isOdd)return!n.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){d(g);const{px:$,py:B,pz:C}=this,{px:F,py:H,pz:W}=g,Z=n.eql(n.mul($,W),n.mul(F,C)),ie=n.eql(n.mul(B,W),n.mul(H,C));return Z&&ie}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:g,b:$}=e,B=n.mul($,_3n),{px:C,py:F,pz:H}=this;let W=n.ZERO,Z=n.ZERO,ie=n.ZERO,te=n.mul(C,C),ae=n.mul(F,F),de=n.mul(H,H),J=n.mul(C,F);return J=n.add(J,J),ie=n.mul(C,H),ie=n.add(ie,ie),W=n.mul(g,ie),Z=n.mul(B,de),Z=n.add(W,Z),W=n.sub(ae,Z),Z=n.add(ae,Z),Z=n.mul(W,Z),W=n.mul(J,W),ie=n.mul(B,ie),de=n.mul(g,de),J=n.sub(te,de),J=n.mul(g,J),J=n.add(J,ie),ie=n.add(te,te),te=n.add(ie,te),te=n.add(te,de),te=n.mul(te,J),Z=n.add(Z,te),de=n.mul(F,H),de=n.add(de,de),te=n.mul(de,J),W=n.sub(W,te),ie=n.mul(de,ae),ie=n.add(ie,ie),ie=n.add(ie,ie),new p(W,Z,ie)}add(g){d(g);const{px:$,py:B,pz:C}=this,{px:F,py:H,pz:W}=g;let Z=n.ZERO,ie=n.ZERO,te=n.ZERO;const ae=e.a,de=n.mul(e.b,_3n);let J=n.mul($,F),R=n.mul(B,H),A=n.mul(C,W),y=n.add($,B),w=n.add(F,H);y=n.mul(y,w),w=n.add(J,R),y=n.sub(y,w),w=n.add($,C);let I=n.add(F,W);return w=n.mul(w,I),I=n.add(J,A),w=n.sub(w,I),I=n.add(B,C),Z=n.add(H,W),I=n.mul(I,Z),Z=n.add(R,A),I=n.sub(I,Z),te=n.mul(ae,w),Z=n.mul(de,A),te=n.add(Z,te),Z=n.sub(R,te),te=n.add(R,te),ie=n.mul(Z,te),R=n.add(J,J),R=n.add(R,J),A=n.mul(ae,A),w=n.mul(de,w),R=n.add(R,A),A=n.sub(J,A),A=n.mul(ae,A),w=n.add(w,A),J=n.mul(R,w),ie=n.add(ie,J),J=n.mul(I,w),Z=n.mul(y,Z),Z=n.sub(Z,J),J=n.mul(y,R),te=n.mul(I,te),te=n.add(te,J),new p(Z,ie,te)}subtract(g){return this.add(g.negate())}is0(){return this.equals(p.ZERO)}wNAF(g){return m.wNAFCached(this,b,g,$=>{const B=n.invertBatch($.map(C=>C.pz));return $.map((C,F)=>C.toAffine(B[F])).map(p.fromAffine)})}multiplyUnsafe(g){const $=p.ZERO;if(g===_0n)return $;if(h(g),g===_1n$1)return this;const{endo:B}=e;if(!B)return m.unsafeLadder(this,g);let{k1neg:C,k1:F,k2neg:H,k2:W}=B.splitScalar(g),Z=$,ie=$,te=this;for(;F>_0n||W>_0n;)F&_1n$1&&(Z=Z.add(te)),W&_1n$1&&(ie=ie.add(te)),te=te.double(),F>>=_1n$1,W>>=_1n$1;return C&&(Z=Z.negate()),H&&(ie=ie.negate()),ie=new p(n.mul(ie.px,B.beta),ie.py,ie.pz),Z.add(ie)}multiply(g){h(g);let $=g,B,C;const{endo:F}=e;if(F){const{k1neg:H,k1:W,k2neg:Z,k2:ie}=F.splitScalar($);let{p:te,f:ae}=this.wNAF(W),{p:de,f:J}=this.wNAF(ie);te=m.constTimeNegate(H,te),de=m.constTimeNegate(Z,de),de=new p(n.mul(de.px,F.beta),de.py,de.pz),B=te.add(de),C=ae.add(J)}else{const{p:H,f:W}=this.wNAF($);B=H,C=W}return p.normalizeZ([B,C])[0]}multiplyAndAddUnsafe(g,$,B){const C=p.BASE,F=(W,Z)=>Z===_0n||Z===_1n$1||!W.equals(C)?W.multiplyUnsafe(Z):W.multiply(Z),H=F(this,$).add(F(g,B));return H.is0()?void 0:H}toAffine(g){const{px:$,py:B,pz:C}=this,F=this.is0();g==null&&(g=F?n.ONE:n.inv(C));const H=n.mul($,g),W=n.mul(B,g),Z=n.mul(C,g);if(F)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:H,y:W}}isTorsionFree(){const{h:g,isTorsionFree:$}=e;if(g===_1n$1)return!0;if($)return $(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:$}=e;return g===_1n$1?this:$?$(p,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),a(p,this,g)}toHex(g=!0){return bytesToHex$2(this.toRawBytes(g))}}p.BASE=new p(e.Gx,e.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const x=e.nBitLength,m=wNAF(p,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:u}}function validateOpts(t){const e=validateBasic(t);return validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function weierstrass(t){const e=validateOpts(t),{Fp:n,n:a}=e,c=n.BYTES+1,o=2*n.BYTES+1;function u(w){return _0n<w&&w<n.ORDER}function h(w){return mod(w,a)}function l(w){return invert(w,a)}const{ProjectivePoint:b,normPrivateKeyToScalar:d,weierstrassEquation:p,isWithinCurveOrder:x}=weierstrassPoints({...e,toBytes(w,I,M){const k=I.toAffine(),P=n.toBytes(k.x),_=concatBytes;return M?_(Uint8Array.from([I.hasEvenY()?2:3]),P):_(Uint8Array.from([4]),P,n.toBytes(k.y))},fromBytes(w){const I=w.length,M=w[0],k=w.subarray(1);if(I===c&&(M===2||M===3)){const P=bytesToNumberBE(k);if(!u(P))throw new Error("Point is not on curve");const _=p(P);let q=n.sqrt(_);const E=(q&_1n$1)===_1n$1;return(M&1)===1!==E&&(q=n.neg(q)),{x:P,y:q}}else if(I===o&&M===4){const P=n.fromBytes(k.subarray(0,n.BYTES)),_=n.fromBytes(k.subarray(n.BYTES,2*n.BYTES));return{x:P,y:_}}else throw new Error(`Point of length ${I} was invalid. Expected ${c} compressed bytes or ${o} uncompressed bytes`)}}),m=w=>bytesToHex$2(numberToBytesBE(w,e.nByteLength));function v(w){const I=a>>_1n$1;return w>I}function g(w){return v(w)?h(-w):w}const $=(w,I,M)=>bytesToNumberBE(w.slice(I,M));class B{constructor(I,M,k){this.r=I,this.s=M,this.recovery=k,this.assertValidity()}static fromCompact(I){const M=e.nByteLength;return I=ensureBytes("compactSignature",I,M*2),new B($(I,0,M),$(I,M,2*M))}static fromDER(I){const{r:M,s:k}=DER.toSig(ensureBytes("DER",I));return new B(M,k)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new B(this.r,this.s,I)}recoverPublicKey(I){const{r:M,s:k,recovery:P}=this,_=ie(ensureBytes("msgHash",I));if(P==null||![0,1,2,3].includes(P))throw new Error("recovery id invalid");const q=P===2||P===3?M+e.n:M;if(q>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const E=P&1?"03":"02",j=b.fromHex(E+m(q)),ee=l(q),oe=h(-_*ee),Y=h(k*ee),L=b.BASE.multiplyAndAddUnsafe(j,oe,Y);if(!L)throw new Error("point at infinify");return L.assertValidity(),L}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,h(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$1(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$1(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}const C={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const w=getMinHashLength(e.n);return mapHashToField(e.randomBytes(w),e.n)},precompute(w=8,I=b.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function F(w,I=!0){return b.fromPrivateKey(w).toRawBytes(I)}function H(w){const I=w instanceof Uint8Array,M=typeof w=="string",k=(I||M)&&w.length;return I?k===c||k===o:M?k===2*c||k===2*o:w instanceof b}function W(w,I,M=!0){if(H(w))throw new Error("first arg must be private key");if(!H(I))throw new Error("second arg must be public key");return b.fromHex(I).multiply(d(w)).toRawBytes(M)}const Z=e.bits2int||function(w){const I=bytesToNumberBE(w),M=w.length*8-e.nBitLength;return M>0?I>>BigInt(M):I},ie=e.bits2int_modN||function(w){return h(Z(w))},te=bitMask(e.nBitLength);function ae(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(_0n<=w&&w<te))throw new Error(`bigint expected < 2^${e.nBitLength}`);return numberToBytesBE(w,e.nByteLength)}function de(w,I,M=J){if(["recovered","canonical"].some(re=>re in M))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:P}=e;let{lowS:_,prehash:q,extraEntropy:E}=M;_==null&&(_=!0),w=ensureBytes("msgHash",w),q&&(w=ensureBytes("prehashed msgHash",k(w)));const j=ie(w),ee=d(I),oe=[ae(ee),ae(j)];if(E!=null){const re=E===!0?P(n.BYTES):E;oe.push(ensureBytes("extraEntropy",re))}const Y=concatBytes(...oe),L=j;function z(re){const D=Z(re);if(!x(D))return;const G=l(D),U=b.BASE.multiply(D).toAffine(),Q=h(U.x);if(Q===_0n)return;const fe=h(G*h(L+Q*ee));if(fe===_0n)return;let he=(U.x===Q?0:2)|Number(U.y&_1n$1),le=fe;return _&&v(fe)&&(le=g(fe),he^=1),new B(Q,le,he)}return{seed:Y,k2sig:z}}const J={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function A(w,I,M=J){const{seed:k,k2sig:P}=de(w,I,M),_=e;return createHmacDrbg(_.hash.outputLen,_.nByteLength,_.hmac)(k,P)}b.BASE._setWindowSize(8);function y(w,I,M,k=R){var U;const P=w;if(I=ensureBytes("msgHash",I),M=ensureBytes("publicKey",M),"strict"in k)throw new Error("options.strict was renamed to lowS");const{lowS:_,prehash:q}=k;let E,j;try{if(typeof P=="string"||P instanceof Uint8Array)try{E=B.fromDER(P)}catch(Q){if(!(Q instanceof DER.Err))throw Q;E=B.fromCompact(P)}else if(typeof P=="object"&&typeof P.r=="bigint"&&typeof P.s=="bigint"){const{r:Q,s:fe}=P;E=new B(Q,fe)}else throw new Error("PARSE");j=b.fromHex(M)}catch(Q){if(Q.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(_&&E.hasHighS())return!1;q&&(I=e.hash(I));const{r:ee,s:oe}=E,Y=ie(I),L=l(oe),z=h(Y*L),re=h(ee*L),D=(U=b.BASE.multiplyAndAddUnsafe(j,z,re))==null?void 0:U.toAffine();return D?h(D.x)===ee:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:W,sign:A,verify:y,ProjectivePoint:b,Signature:B,utils:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(t){return{hash:t,hmac:(e,...n)=>hmac$1(t,e,concatBytes$1(...n)),randomBytes:randomBytes$2}}function createCurve(t,e){const n=a=>weierstrass({...t,...getHash(a)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(t,e)=>(t+e/_2n)/e;function sqrtMod(t){const e=secp256k1P,n=BigInt(3),a=BigInt(6),c=BigInt(11),o=BigInt(22),u=BigInt(23),h=BigInt(44),l=BigInt(88),b=t*t*t%e,d=b*b*t%e,p=pow2(d,n,e)*d%e,x=pow2(p,n,e)*d%e,m=pow2(x,_2n,e)*b%e,v=pow2(m,c,e)*m%e,g=pow2(v,o,e)*v%e,$=pow2(g,h,e)*g%e,B=pow2($,l,e)*$%e,C=pow2(B,h,e)*g%e,F=pow2(C,n,e)*d%e,H=pow2(F,u,e)*v%e,W=pow2(H,a,e)*b%e,Z=pow2(W,_2n,e);if(!Fp.eql(Fp.sqr(Z),t))throw new Error("Cannot find square root");return Z}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1$1=createCurve({a:BigInt(0),b:BigInt(7),Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=secp256k1N,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),a=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),c=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,u=BigInt("0x100000000000000000000000000000000"),h=divNearest(o*t,e),l=divNearest(-a*t,e);let b=mod(t-h*n-l*c,e),d=mod(-h*a-l*o,e);const p=b>u,x=d>u;if(p&&(b=e-b),x&&(d=e-d),b>u||d>u)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:p,k1:b,k2neg:x,k2:d}}}},sha256$3);BigInt(0),secp256k1$1.ProjectivePoint;const ZeroAddress="0x0000000000000000000000000000000000000000",ZeroHash="0x0000000000000000000000000000000000000000000000000000000000000000",MessagePrefix=`Ethereum Signed Message:
2
2
  `,BN_0$3=BigInt(0),BN_1$1=BigInt(1),BN_2$1=BigInt(2),BN_27$1=BigInt(27),BN_28$1=BigInt(28),BN_35$1=BigInt(35),_guard$2={};function toUint256(t){return zeroPadValue(toBeArray(t),32)}let Signature$3=(ot=class{constructor(e,n,a,c){Le(this,Fe);Le(this,He);Le(this,at);Le(this,wt);assertPrivate(e,_guard$2,"Signature"),we(this,Fe,n),we(this,He,a),we(this,at,c),we(this,wt,null)}get r(){return Re(this,Fe)}set r(e){assertArgument(dataLength(e)===32,"invalid r","value",e),we(this,Fe,hexlify(e))}get s(){return Re(this,He)}set s(e){assertArgument(dataLength(e)===32,"invalid s","value",e);const n=hexlify(e);assertArgument(parseInt(n.substring(0,3))<8,"non-canonical s","value",n),we(this,He,n)}get v(){return Re(this,at)}set v(e){const n=getNumber(e,"value");assertArgument(n===27||n===28,"invalid v","v",e),we(this,at,n)}get networkV(){return Re(this,wt)}get legacyChainId(){const e=this.networkV;return e==null?null:ot.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=getBytes(this.s);return this.yParity&&(e[0]|=128),hexlify(e)}get compactSerialized(){return concat([this.r,this.yParityAndS])}get serialized(){return concat([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ot(_guard$2,this.r,this.s,this.v);return this.networkV&&we(e,wt,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const n=getBigInt(e,"v");return n==BN_27$1||n==BN_28$1?BN_0$3:(assertArgument(n>=BN_35$1,"invalid EIP-155 v","v",e),(n-BN_35$1)/BN_2$1)}static getChainIdV(e,n){return getBigInt(e)*BN_2$1+BigInt(35+n-27)}static getNormalizedV(e){const n=getBigInt(e);return n===BN_0$3||n===BN_27$1?27:n===BN_1$1||n===BN_28$1?28:(assertArgument(n>=BN_35$1,"invalid v","v",e),n&BN_1$1?27:28)}static from(e){function n(b,d){assertArgument(b,d,"signature",e)}if(e==null)return new ot(_guard$2,ZeroHash,ZeroHash,27);if(typeof e=="string"){const b=getBytes(e,"signature");if(b.length===64){const d=hexlify(b.slice(0,32)),p=b.slice(32,64),x=p[0]&128?28:27;return p[0]&=127,new ot(_guard$2,d,hexlify(p),x)}if(b.length===65){const d=hexlify(b.slice(0,32)),p=b.slice(32,64);n((p[0]&128)===0,"non-canonical s");const x=ot.getNormalizedV(b[64]);return new ot(_guard$2,d,hexlify(p),x)}n(!1,"invalid raw signature length")}if(e instanceof ot)return e.clone();const a=e.r;n(a!=null,"missing r");const c=toUint256(a),o=function(b,d){if(b!=null)return toUint256(b);if(d!=null){n(isHexString$1(d,32),"invalid yParityAndS");const p=getBytes(d);return p[0]&=127,hexlify(p)}n(!1,"missing s")}(e.s,e.yParityAndS);n((getBytes(o)[0]&128)==0,"non-canonical s");const{networkV:u,v:h}=function(b,d,p){if(b!=null){const x=getBigInt(b);return{networkV:x>=BN_35$1?x:void 0,v:ot.getNormalizedV(x)}}if(d!=null)return n(isHexString$1(d,32),"invalid yParityAndS"),{v:getBytes(d)[0]&128?28:27};if(p!=null){switch(getNumber(p,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}n(!1,"invalid yParity")}n(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new ot(_guard$2,c,o,h);return u&&we(l,wt,u),n(e.yParity==null||getNumber(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),n(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}},Fe=new WeakMap,He=new WeakMap,at=new WeakMap,wt=new WeakMap,ot);const Mt=class Mt{constructor(e){Le(this,St);assertArgument(dataLength(e)===32,"invalid private key","privateKey","[REDACTED]"),we(this,St,hexlify(e))}get privateKey(){return Re(this,St)}get publicKey(){return Mt.computePublicKey(Re(this,St))}get compressedPublicKey(){return Mt.computePublicKey(Re(this,St),!0)}sign(e){assertArgument(dataLength(e)===32,"invalid digest length","digest",e);const n=secp256k1$1.sign(getBytesCopy(e),getBytesCopy(Re(this,St)),{lowS:!0});return Signature$3.from({r:toBeHex(n.r,32),s:toBeHex(n.s,32),v:n.recovery?28:27})}computeSharedSecret(e){const n=Mt.computePublicKey(e);return hexlify(secp256k1$1.getSharedSecret(getBytesCopy(Re(this,St)),getBytes(n),!1))}static computePublicKey(e,n){let a=getBytes(e,"key");if(a.length===32){const o=secp256k1$1.getPublicKey(a,!!n);return hexlify(o)}if(a.length===64){const o=new Uint8Array(65);o[0]=4,o.set(a,1),a=o}const c=secp256k1$1.ProjectivePoint.fromHex(a);return hexlify(c.toRawBytes(n))}static recoverPublicKey(e,n){assertArgument(dataLength(e)===32,"invalid digest length","digest",e);const a=Signature$3.from(n);let c=secp256k1$1.Signature.fromCompact(getBytesCopy(concat([a.r,a.s])));c=c.addRecoveryBit(a.yParity);const o=c.recoverPublicKey(getBytesCopy(e));return assertArgument(o!=null,"invalid signautre for digest","signature",n),"0x"+o.toHex(!1)}static addPoints(e,n,a){const c=secp256k1$1.ProjectivePoint.fromHex(Mt.computePublicKey(e).substring(2)),o=secp256k1$1.ProjectivePoint.fromHex(Mt.computePublicKey(n).substring(2));return"0x"+c.add(o).toHex(!!a)}};St=new WeakMap;let SigningKey=Mt;const BN_0$2=BigInt(0),BN_36=BigInt(36);function getChecksumAddress(t){t=t.toLowerCase();const e=t.substring(2).split(""),n=new Uint8Array(40);for(let c=0;c<40;c++)n[c]=e[c].charCodeAt(0);const a=getBytes(keccak256(n));for(let c=0;c<40;c+=2)a[c>>1]>>4>=8&&(e[c]=e[c].toUpperCase()),(a[c>>1]&15)>=8&&(e[c+1]=e[c+1].toUpperCase());return"0x"+e.join("")}const ibanLookup={};for(let t=0;t<10;t++)ibanLookup[String(t)]=String(t);for(let t=0;t<26;t++)ibanLookup[String.fromCharCode(65+t)]=String(10+t);const safeDigits=15;function ibanChecksum(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(a=>ibanLookup[a]).join("");for(;e.length>=safeDigits;){let a=e.substring(0,safeDigits);e=parseInt(a,10)%97+e.substring(a.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}const Base36=function(){const t={};for(let e=0;e<36;e++){const n="0123456789abcdefghijklmnopqrstuvwxyz"[e];t[n]=BigInt(e)}return t}();function fromBase36(t){t=t.toLowerCase();let e=BN_0$2;for(let n=0;n<t.length;n++)e=e*BN_36+Base36[t[n]];return e}function getAddress(t){if(assertArgument(typeof t=="string","invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=getChecksumAddress(t);return assertArgument(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){assertArgument(t.substring(2,4)===ibanChecksum(t),"bad icap checksum","address",t);let e=fromBase36(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return getChecksumAddress("0x"+e)}assertArgument(!1,"invalid address","address",t)}function isAddressable(t){return t&&typeof t.getAddress=="function"}async function checkAddress(t,e){const n=await e;return(n==null||n==="0x0000000000000000000000000000000000000000")&&(assert$f(typeof t!="string","unconfigured name","UNCONFIGURED_NAME",{value:t}),assertArgument(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),getAddress(n)}function resolveAddress(t,e){if(typeof t=="string")return t.match(/^0x[0-9a-f]{40}$/i)?getAddress(t):(assert$f(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),checkAddress(t,e.resolveName(t)));if(isAddressable(t))return checkAddress(t,t.getAddress());if(t&&typeof t.then=="function")return checkAddress(t,t);assertArgument(!1,"unsupported addressable value","target",t)}function id(t){return keccak256(toUtf8Bytes(t))}function accessSetify(t,e){return{address:getAddress(t),storageKeys:e.map((n,a)=>(assertArgument(isHexString$1(n,32),"invalid slot",`storageKeys[${a}]`,n),n.toLowerCase()))}}function accessListify(t){if(Array.isArray(t))return t.map((n,a)=>Array.isArray(n)?(assertArgument(n.length===2,"invalid slot set",`value[${a}]`,n),accessSetify(n[0],n[1])):(assertArgument(n!=null&&typeof n=="object","invalid address-slot set","value",t),accessSetify(n.address,n.storageKeys)));assertArgument(t!=null&&typeof t=="object","invalid access list","value",t);const e=Object.keys(t).map(n=>{const a=t[n].reduce((c,o)=>(c[o]=!0,c),{});return accessSetify(n,Object.keys(a).sort())});return e.sort((n,a)=>n.address.localeCompare(a.address)),e}function computeAddress(t){let e;return typeof t=="string"?e=SigningKey.computePublicKey(t,!1):e=t.publicKey,getAddress(keccak256("0x"+e.substring(4)).substring(26))}function recoverAddress(t,e){return computeAddress(SigningKey.recoverPublicKey(t,e))}const BN_0$1=BigInt(0),BN_2=BigInt(2),BN_27=BigInt(27),BN_28=BigInt(28),BN_35=BigInt(35),BN_MAX_UINT=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),BLOB_SIZE=4096*32;function getVersionedHash(t,e){let n=t.toString(16);for(;n.length<2;)n="0"+n;return n+=sha256$2(e).substring(4),"0x"+n}function handleAddress(t){return t==="0x"?null:getAddress(t)}function handleAccessList(t,e){try{return accessListify(t)}catch(n){assertArgument(!1,n.message,e,t)}}function handleNumber(t,e){return t==="0x"?0:getNumber(t,e)}function handleUint(t,e){if(t==="0x")return BN_0$1;const n=getBigInt(t,e);return assertArgument(n<=BN_MAX_UINT,"value exceeds uint size",e,n),n}function formatNumber(t,e){const n=getBigInt(t,"value"),a=toBeArray(n);return assertArgument(a.length<=32,"value too large",`tx.${e}`,n),a}function formatAccessList(t){return accessListify(t).map(e=>[e.address,e.storageKeys])}function formatHashes(t,e){assertArgument(Array.isArray(t),`invalid ${e}`,"value",t);for(let n=0;n<t.length;n++)assertArgument(isHexString$1(t[n],32),"invalid ${ param } hash",`value[${n}]`,t[n]);return t}function _parseLegacy(t){const e=decodeRlp(t);assertArgument(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",t);const n={type:0,nonce:handleNumber(e[0],"nonce"),gasPrice:handleUint(e[1],"gasPrice"),gasLimit:handleUint(e[2],"gasLimit"),to:handleAddress(e[3]),value:handleUint(e[4],"value"),data:hexlify(e[5]),chainId:BN_0$1};if(e.length===6)return n;const a=handleUint(e[6],"v"),c=handleUint(e[7],"r"),o=handleUint(e[8],"s");if(c===BN_0$1&&o===BN_0$1)n.chainId=a;else{let u=(a-BN_35)/BN_2;u<BN_0$1&&(u=BN_0$1),n.chainId=u,assertArgument(u!==BN_0$1||a===BN_27||a===BN_28,"non-canonical legacy v","v",e[6]),n.signature=Signature$3.from({r:zeroPadValue(e[7],32),s:zeroPadValue(e[8],32),v:a})}return n}function _serializeLegacy(t,e){const n=[formatNumber(t.nonce,"nonce"),formatNumber(t.gasPrice||0,"gasPrice"),formatNumber(t.gasLimit,"gasLimit"),t.to||"0x",formatNumber(t.value,"value"),t.data];let a=BN_0$1;if(t.chainId!=BN_0$1)a=getBigInt(t.chainId,"tx.chainId"),assertArgument(!e||e.networkV==null||e.legacyChainId===a,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const o=t.signature.legacyChainId;o!=null&&(a=o)}if(!e)return a!==BN_0$1&&(n.push(toBeArray(a)),n.push("0x"),n.push("0x")),encodeRlp(n);let c=BigInt(27+e.yParity);return a!==BN_0$1?c=Signature$3.getChainIdV(a,e.v):BigInt(e.v)!==c&&assertArgument(!1,"tx.chainId/sig.v mismatch","sig",e),n.push(toBeArray(c)),n.push(toBeArray(e.r)),n.push(toBeArray(e.s)),encodeRlp(n)}function _parseEipSignature(t,e){let n;try{if(n=handleNumber(e[0],"yParity"),n!==0&&n!==1)throw new Error("bad yParity")}catch{assertArgument(!1,"invalid yParity","yParity",e[0])}const a=zeroPadValue(e[1],32),c=zeroPadValue(e[2],32),o=Signature$3.from({r:a,s:c,yParity:n});t.signature=o}function _parseEip1559(t){const e=decodeRlp(getBytes(t).slice(1));assertArgument(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",hexlify(t));const n={type:2,chainId:handleUint(e[0],"chainId"),nonce:handleNumber(e[1],"nonce"),maxPriorityFeePerGas:handleUint(e[2],"maxPriorityFeePerGas"),maxFeePerGas:handleUint(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:handleUint(e[4],"gasLimit"),to:handleAddress(e[5]),value:handleUint(e[6],"value"),data:hexlify(e[7]),accessList:handleAccessList(e[8],"accessList")};return e.length===9||_parseEipSignature(n,e.slice(9)),n}function _serializeEip1559(t,e){const n=[formatNumber(t.chainId,"chainId"),formatNumber(t.nonce,"nonce"),formatNumber(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(t.maxFeePerGas||0,"maxFeePerGas"),formatNumber(t.gasLimit,"gasLimit"),t.to||"0x",formatNumber(t.value,"value"),t.data,formatAccessList(t.accessList||[])];return e&&(n.push(formatNumber(e.yParity,"yParity")),n.push(toBeArray(e.r)),n.push(toBeArray(e.s))),concat(["0x02",encodeRlp(n)])}function _parseEip2930(t){const e=decodeRlp(getBytes(t).slice(1));assertArgument(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",hexlify(t));const n={type:1,chainId:handleUint(e[0],"chainId"),nonce:handleNumber(e[1],"nonce"),gasPrice:handleUint(e[2],"gasPrice"),gasLimit:handleUint(e[3],"gasLimit"),to:handleAddress(e[4]),value:handleUint(e[5],"value"),data:hexlify(e[6]),accessList:handleAccessList(e[7],"accessList")};return e.length===8||_parseEipSignature(n,e.slice(8)),n}function _serializeEip2930(t,e){const n=[formatNumber(t.chainId,"chainId"),formatNumber(t.nonce,"nonce"),formatNumber(t.gasPrice||0,"gasPrice"),formatNumber(t.gasLimit,"gasLimit"),t.to||"0x",formatNumber(t.value,"value"),t.data,formatAccessList(t.accessList||[])];return e&&(n.push(formatNumber(e.yParity,"recoveryParam")),n.push(toBeArray(e.r)),n.push(toBeArray(e.s))),concat(["0x01",encodeRlp(n)])}function _parseEip4844(t){let e=decodeRlp(getBytes(t).slice(1)),n="3",a=null;if(e.length===4&&Array.isArray(e[0])){n="3 (network format)";const o=e[1],u=e[2],h=e[3];assertArgument(Array.isArray(o),"invalid network format: blobs not an array","fields[1]",o),assertArgument(Array.isArray(u),"invalid network format: commitments not an array","fields[2]",u),assertArgument(Array.isArray(h),"invalid network format: proofs not an array","fields[3]",h),assertArgument(o.length===u.length,"invalid network format: blobs/commitments length mismatch","fields",e),assertArgument(o.length===h.length,"invalid network format: blobs/proofs length mismatch","fields",e),a=[];for(let l=0;l<e[1].length;l++)a.push({data:o[l],commitment:u[l],proof:h[l]});e=e[0]}assertArgument(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${n}`,"data",hexlify(t));const c={type:3,chainId:handleUint(e[0],"chainId"),nonce:handleNumber(e[1],"nonce"),maxPriorityFeePerGas:handleUint(e[2],"maxPriorityFeePerGas"),maxFeePerGas:handleUint(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:handleUint(e[4],"gasLimit"),to:handleAddress(e[5]),value:handleUint(e[6],"value"),data:hexlify(e[7]),accessList:handleAccessList(e[8],"accessList"),maxFeePerBlobGas:handleUint(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};a&&(c.blobs=a),assertArgument(c.to!=null,`invalid address for transaction type: ${n}`,"data",t),assertArgument(Array.isArray(c.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let o=0;o<c.blobVersionedHashes.length;o++)assertArgument(isHexString$1(c.blobVersionedHashes[o],32),`invalid blobVersionedHash at index ${o}: must be length 32`,"data",t);return e.length===11||_parseEipSignature(c,e.slice(11)),c}function _serializeEip4844(t,e,n){const a=[formatNumber(t.chainId,"chainId"),formatNumber(t.nonce,"nonce"),formatNumber(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(t.maxFeePerGas||0,"maxFeePerGas"),formatNumber(t.gasLimit,"gasLimit"),t.to||ZeroAddress,formatNumber(t.value,"value"),t.data,formatAccessList(t.accessList||[]),formatNumber(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),formatHashes(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(a.push(formatNumber(e.yParity,"yParity")),a.push(toBeArray(e.r)),a.push(toBeArray(e.s)),n)?concat(["0x03",encodeRlp([a,n.map(c=>c.data),n.map(c=>c.commitment),n.map(c=>c.proof)])]):concat(["0x03",encodeRlp(a)])}const At=class At{constructor(){Le(this,Yt);Le(this,_t);Le(this,Ut);Le(this,Ht);Le(this,jt);Le(this,Gt);Le(this,Kt);Le(this,zt);Le(this,Vt);Le(this,Wt);Le(this,Jt);Le(this,Zt);Le(this,Xt);Le(this,It);Le(this,Rt);Le(this,Et);Le(this,$t);we(this,_t,null),we(this,Ut,null),we(this,jt,0),we(this,Gt,BN_0$1),we(this,Kt,null),we(this,zt,null),we(this,Vt,null),we(this,Ht,"0x"),we(this,Wt,BN_0$1),we(this,Jt,BN_0$1),we(this,Zt,null),we(this,Xt,null),we(this,It,null),we(this,Rt,null),we(this,$t,null),we(this,Et,null)}get type(){return Re(this,_t)}set type(e){switch(e){case null:we(this,_t,null);break;case 0:case"legacy":we(this,_t,0);break;case 1:case"berlin":case"eip-2930":we(this,_t,1);break;case 2:case"london":case"eip-1559":we(this,_t,2);break;case 3:case"cancun":case"eip-4844":we(this,_t,3);break;default:assertArgument(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=Re(this,Ut);return e==null&&this.type===3?ZeroAddress:e}set to(e){we(this,Ut,e==null?null:getAddress(e))}get nonce(){return Re(this,jt)}set nonce(e){we(this,jt,getNumber(e,"value"))}get gasLimit(){return Re(this,Gt)}set gasLimit(e){we(this,Gt,getBigInt(e))}get gasPrice(){const e=Re(this,Kt);return e==null&&(this.type===0||this.type===1)?BN_0$1:e}set gasPrice(e){we(this,Kt,e==null?null:getBigInt(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=Re(this,zt);return e??(this.type===2||this.type===3?BN_0$1:null)}set maxPriorityFeePerGas(e){we(this,zt,e==null?null:getBigInt(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=Re(this,Vt);return e??(this.type===2||this.type===3?BN_0$1:null)}set maxFeePerGas(e){we(this,Vt,e==null?null:getBigInt(e,"maxFeePerGas"))}get data(){return Re(this,Ht)}set data(e){we(this,Ht,hexlify(e))}get value(){return Re(this,Wt)}set value(e){we(this,Wt,getBigInt(e,"value"))}get chainId(){return Re(this,Jt)}set chainId(e){we(this,Jt,getBigInt(e))}get signature(){return Re(this,Zt)||null}set signature(e){we(this,Zt,e==null?null:Signature$3.from(e))}get accessList(){const e=Re(this,Xt)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){we(this,Xt,e==null?null:accessListify(e))}get maxFeePerBlobGas(){const e=Re(this,It);return e==null&&this.type===3?BN_0$1:e}set maxFeePerBlobGas(e){we(this,It,e==null?null:getBigInt(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=Re(this,Rt);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){assertArgument(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let n=0;n<e.length;n++)assertArgument(isHexString$1(e[n],32),"invalid blobVersionedHash",`value[${n}]`,e[n])}we(this,Rt,e)}get blobs(){return Re(this,$t)==null?null:Re(this,$t).map(e=>Object.assign({},e))}set blobs(e){if(e==null){we(this,$t,null);return}const n=[],a=[];for(let c=0;c<e.length;c++){const o=e[c];if(isBytesLike(o)){assert$f(Re(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let u=getBytes(o);if(assertArgument(u.length<=BLOB_SIZE,"blob is too large",`blobs[${c}]`,o),u.length!==BLOB_SIZE){const b=new Uint8Array(BLOB_SIZE);b.set(u),u=b}const h=Re(this,Et).blobToKzgCommitment(u),l=hexlify(Re(this,Et).computeBlobKzgProof(u,h));n.push({data:hexlify(u),commitment:hexlify(h),proof:l}),a.push(getVersionedHash(1,h))}else{const u=hexlify(o.commitment);n.push({data:hexlify(o.data),commitment:u,proof:hexlify(o.proof)}),a.push(getVersionedHash(1,u))}}we(this,$t,n),we(this,Rt,a)}get kzg(){return Re(this,Et)}set kzg(e){we(this,Et,e)}get hash(){return this.signature==null?null:keccak256(st(this,Yt,ur).call(this,!0,!1))}get unsignedHash(){return keccak256(this.unsignedSerialized)}get from(){return this.signature==null?null:recoverAddress(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:SigningKey.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return st(this,Yt,ur).call(this,!0,!0)}get unsignedSerialized(){return st(this,Yt,ur).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,n=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,a=this.accessList!=null,c=Re(this,It)!=null||Re(this,Rt);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&assert$f(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),assert$f(!n||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),assert$f(this.type!==0||!a,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const o=[];return this.type!=null?o.push(this.type):n?o.push(2):e?(o.push(1),a||o.push(0)):a?(o.push(1),o.push(2)):(c&&this.to||(o.push(0),o.push(1),o.push(2)),o.push(3)),o.sort(),o}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return At.from(this)}toJSON(){const e=n=>n==null?null:n.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new At;if(typeof e=="string"){const a=getBytes(e);if(a[0]>=127)return At.from(_parseLegacy(a));switch(a[0]){case 1:return At.from(_parseEip2930(a));case 2:return At.from(_parseEip1559(a));case 3:return At.from(_parseEip4844(a))}assert$f(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const n=new At;return e.type!=null&&(n.type=e.type),e.to!=null&&(n.to=e.to),e.nonce!=null&&(n.nonce=e.nonce),e.gasLimit!=null&&(n.gasLimit=e.gasLimit),e.gasPrice!=null&&(n.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(n.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(n.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(n.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(n.data=e.data),e.value!=null&&(n.value=e.value),e.chainId!=null&&(n.chainId=e.chainId),e.signature!=null&&(n.signature=Signature$3.from(e.signature)),e.accessList!=null&&(n.accessList=e.accessList),e.blobVersionedHashes!=null&&(n.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(n.kzg=e.kzg),e.blobs!=null&&(n.blobs=e.blobs),e.hash!=null&&(assertArgument(n.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),assertArgument(n.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(assertArgument(n.isSigned(),"unsigned transaction cannot define '.from'","tx",e),assertArgument(n.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),n}};_t=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,zt=new WeakMap,Vt=new WeakMap,Wt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,It=new WeakMap,Rt=new WeakMap,Et=new WeakMap,$t=new WeakMap,Yt=new WeakSet,ur=function(e,n){assert$f(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const a=e?this.signature:null;switch(this.inferType()){case 0:return _serializeLegacy(this,a);case 1:return _serializeEip2930(this,a);case 2:return _serializeEip1559(this,a);case 3:return _serializeEip4844(this,a,n?this.blobs:null)}assert$f(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Transaction=At;function hashMessage(t){return typeof t=="string"&&(t=toUtf8Bytes(t)),keccak256(concat([toUtf8Bytes(MessagePrefix),toUtf8Bytes(String(t.length)),t]))}function verifyMessage(t,e){const n=hashMessage(t);return recoverAddress(n,e)}const padding=new Uint8Array(32);padding.fill(0);const BN__1=BigInt(-1),BN_0=BigInt(0),BN_1=BigInt(1),BN_MAX_UINT256=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function hexPadRight(t){const e=getBytes(t),n=e.length%32;return n?concat([e,padding.slice(n)]):hexlify(e)}const hexTrue=toBeHex(BN_1,32),hexFalse=toBeHex(BN_0,32),domainFieldTypes={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},domainFieldNames=["name","version","chainId","verifyingContract","salt"];function checkString(t){return function(e){return assertArgument(typeof e=="string",`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const domainChecks={name:checkString("name"),version:checkString("version"),chainId:function(t){const e=getBigInt(t,"domain.chainId");return assertArgument(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):toQuantity(e)},verifyingContract:function(t){try{return getAddress(t).toLowerCase()}catch{}assertArgument(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=getBytes(t,"domain.salt");return assertArgument(e.length===32,'invalid domain value "salt"',"domain.salt",t),hexlify(e)}};function getBaseEncoder(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const n=e[1]==="",a=parseInt(e[2]);assertArgument(a%8===0&&a!==0&&a<=256&&e[2]===String(a),"invalid numeric width","type",t);const c=mask(BN_MAX_UINT256,n?a-1:a),o=n?(c+BN_1)*BN__1:BN_0;return function(u){const h=getBigInt(u,"value");return assertArgument(h>=o&&h<=c,`value out-of-bounds for ${t}`,"value",h),toBeHex(n?toTwos(h,256):h,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const n=parseInt(e[1]);return assertArgument(n!==0&&n<=32&&e[1]===String(n),"invalid bytes width","type",t),function(a){const c=getBytes(a);return assertArgument(c.length===n,`invalid length for ${t}`,"value",a),hexPadRight(a)}}}switch(t){case"address":return function(e){return zeroPadValue(getAddress(e),32)};case"bool":return function(e){return e?hexTrue:hexFalse};case"bytes":return function(e){return keccak256(e)};case"string":return function(e){return id(e)}}return null}function encodeType(t,e){return`${t}(${e.map(({name:n,type:a})=>a+" "+n).join(",")})`}function splitArray(t){const e=t.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:t}}const ft=class ft{constructor(e){Le(this,cr);Ue(this,"primaryType");Le(this,ir);Le(this,Bt);Le(this,Qt);we(this,Bt,new Map),we(this,Qt,new Map);const n=new Map,a=new Map,c=new Map,o={};Object.keys(e).forEach(l=>{o[l]=e[l].map(({name:b,type:d})=>{let{base:p,index:x}=splitArray(d);return p==="int"&&!e.int&&(p="int256"),p==="uint"&&!e.uint&&(p="uint256"),{name:b,type:p+(x||"")}}),n.set(l,new Set),a.set(l,[]),c.set(l,new Set)}),we(this,ir,JSON.stringify(o));for(const l in o){const b=new Set;for(const d of o[l]){assertArgument(!b.has(d.name),`duplicate variable name ${JSON.stringify(d.name)} in ${JSON.stringify(l)}`,"types",e),b.add(d.name);const p=splitArray(d.type).base;assertArgument(p!==l,`circular type reference to ${JSON.stringify(p)}`,"types",e),!getBaseEncoder(p)&&(assertArgument(a.has(p),`unknown type ${JSON.stringify(p)}`,"types",e),a.get(p).push(l),n.get(l).add(p))}}const u=Array.from(a.keys()).filter(l=>a.get(l).length===0);assertArgument(u.length!==0,"missing primary type","types",e),assertArgument(u.length===1,`ambiguous primary types or unused types: ${u.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),defineProperties(this,{primaryType:u[0]});function h(l,b){assertArgument(!b.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),b.add(l);for(const d of n.get(l))if(a.has(d)){h(d,b);for(const p of b)c.get(p).add(d)}b.delete(l)}h(this.primaryType,new Set);for(const[l,b]of c){const d=Array.from(b);d.sort(),Re(this,Bt).set(l,encodeType(l,o[l])+d.map(p=>encodeType(p,o[p])).join(""))}}get types(){return JSON.parse(Re(this,ir))}getEncoder(e){let n=Re(this,Qt).get(e);return n||(n=st(this,cr,_r).call(this,e),Re(this,Qt).set(e,n)),n}encodeType(e){const n=Re(this,Bt).get(e);return assertArgument(n,`unknown type: ${JSON.stringify(e)}`,"name",e),n}encodeData(e,n){return this.getEncoder(e)(n)}hashStruct(e,n){return keccak256(this.encodeData(e,n))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,n,a){if(getBaseEncoder(e))return a(e,n);const c=splitArray(e).array;if(c)return assertArgument(c.count===-1||c.count===n.length,`array length mismatch; expected length ${c.count}`,"value",n),n.map(u=>this._visit(c.prefix,u,a));const o=this.types[e];if(o)return o.reduce((u,{name:h,type:l})=>(u[h]=this._visit(l,n[h],a),u),{});assertArgument(!1,`unknown type: ${e}`,"type",e)}visit(e,n){return this._visit(this.primaryType,e,n)}static from(e){return new ft(e)}static getPrimaryType(e){return ft.from(e).primaryType}static hashStruct(e,n,a){return ft.from(n).hashStruct(e,a)}static hashDomain(e){const n=[];for(const a in e){if(e[a]==null)continue;const c=domainFieldTypes[a];assertArgument(c,`invalid typed-data domain key: ${JSON.stringify(a)}`,"domain",e),n.push({name:a,type:c})}return n.sort((a,c)=>domainFieldNames.indexOf(a.name)-domainFieldNames.indexOf(c.name)),ft.hashStruct("EIP712Domain",{EIP712Domain:n},e)}static encode(e,n,a){return concat(["0x1901",ft.hashDomain(e),ft.from(n).hash(a)])}static hash(e,n,a){return keccak256(ft.encode(e,n,a))}static async resolveNames(e,n,a,c){e=Object.assign({},e);for(const h in e)e[h]==null&&delete e[h];const o={};e.verifyingContract&&!isHexString$1(e.verifyingContract,20)&&(o[e.verifyingContract]="0x");const u=ft.from(n);u.visit(a,(h,l)=>(h==="address"&&!isHexString$1(l,20)&&(o[l]="0x"),l));for(const h in o)o[h]=await c(h);return e.verifyingContract&&o[e.verifyingContract]&&(e.verifyingContract=o[e.verifyingContract]),a=u.visit(a,(h,l)=>h==="address"&&o[l]?o[l]:l),{domain:e,value:a}}static getPayload(e,n,a){ft.hashDomain(e);const c={},o=[];domainFieldNames.forEach(l=>{const b=e[l];b!=null&&(c[l]=domainChecks[l](b),o.push({name:l,type:domainFieldTypes[l]}))});const u=ft.from(n);n=u.types;const h=Object.assign({},n);return assertArgument(h.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",n),h.EIP712Domain=o,u.encode(a),{types:h,domain:c,primaryType:u.primaryType,message:u.visit(a,(l,b)=>{if(l.match(/^bytes(\d*)/))return hexlify(getBytes(b));if(l.match(/^u?int/))return getBigInt(b).toString();switch(l){case"address":return b.toLowerCase();case"bool":return!!b;case"string":return assertArgument(typeof b=="string","invalid string","value",b),b}assertArgument(!1,"unsupported type","type",l)})}}};ir=new WeakMap,Bt=new WeakMap,Qt=new WeakMap,cr=new WeakSet,_r=function(e){{const c=getBaseEncoder(e);if(c)return c}const n=splitArray(e).array;if(n){const c=n.prefix,o=this.getEncoder(c);return u=>{assertArgument(n.count===-1||n.count===u.length,`array length mismatch; expected length ${n.count}`,"value",u);let h=u.map(o);return Re(this,Bt).has(c)&&(h=h.map(keccak256)),keccak256(concat(h))}}const a=this.types[e];if(a){const c=id(Re(this,Bt).get(e));return o=>{const u=a.map(({name:h,type:l})=>{const b=this.getEncoder(l)(o[h]);return Re(this,Bt).has(l)?keccak256(b):b});return u.unshift(c),concat(u)}}assertArgument(!1,`unknown type: ${e}`,"type",e)};let TypedDataEncoder=ft;BigInt(0);function copyRequest(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=hexlify(t.data));const n="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const c of n)!(c in t)||t[c]==null||(e[c]=getBigInt(t[c],`request.${c}`));const a="type,nonce".split(/,/);for(const c of a)!(c in t)||t[c]==null||(e[c]=getNumber(t[c],`request.${c}`));return t.accessList&&(e.accessList=accessListify(t.accessList)),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map(c=>isBytesLike(c)?hexlify(c):Object.assign({},c))),e}function checkProvider(t,e){if(t.provider)return t.provider;assert$f(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function populate(t,e){let n=copyRequest(e);if(n.to!=null&&(n.to=resolveAddress(n.to,t)),n.from!=null){const a=n.from;n.from=Promise.all([t.getAddress(),resolveAddress(a,t)]).then(([c,o])=>(assertArgument(c.toLowerCase()===o.toLowerCase(),"transaction from mismatch","tx.from",o),c))}else n.from=t.getAddress();return await resolveProperties(n)}class AbstractSigner{constructor(e){Ue(this,"provider");defineProperties(this,{provider:e||null})}async getNonce(e){return checkProvider(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await populate(this,e)}async populateTransaction(e){const n=checkProvider(this,"populateTransaction"),a=await populate(this,e);a.nonce==null&&(a.nonce=await this.getNonce("pending")),a.gasLimit==null&&(a.gasLimit=await this.estimateGas(a));const c=await this.provider.getNetwork();if(a.chainId!=null){const u=getBigInt(a.chainId);assertArgument(u===c.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else a.chainId=c.chainId;const o=a.maxFeePerGas!=null||a.maxPriorityFeePerGas!=null;if(a.gasPrice!=null&&(a.type===2||o)?assertArgument(!1,"eip-1559 transaction do not support gasPrice","tx",e):(a.type===0||a.type===1)&&o&&assertArgument(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(a.type===2||a.type==null)&&a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)a.type=2;else if(a.type===0||a.type===1){const u=await n.getFeeData();assert$f(u.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),a.gasPrice==null&&(a.gasPrice=u.gasPrice)}else{const u=await n.getFeeData();if(a.type==null)if(u.maxFeePerGas!=null&&u.maxPriorityFeePerGas!=null)if(a.type=2,a.gasPrice!=null){const h=a.gasPrice;delete a.gasPrice,a.maxFeePerGas=h,a.maxPriorityFeePerGas=h}else a.maxFeePerGas==null&&(a.maxFeePerGas=u.maxFeePerGas),a.maxPriorityFeePerGas==null&&(a.maxPriorityFeePerGas=u.maxPriorityFeePerGas);else u.gasPrice!=null?(assert$f(!o,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),a.gasPrice==null&&(a.gasPrice=u.gasPrice),a.type=0):assert$f(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(a.type===2||a.type===3)&&(a.maxFeePerGas==null&&(a.maxFeePerGas=u.maxFeePerGas),a.maxPriorityFeePerGas==null&&(a.maxPriorityFeePerGas=u.maxPriorityFeePerGas))}return await resolveProperties(a)}async estimateGas(e){return checkProvider(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return checkProvider(this,"call").call(await this.populateCall(e))}async resolveName(e){return await checkProvider(this,"resolveName").resolveName(e)}async sendTransaction(e){const n=checkProvider(this,"sendTransaction"),a=await this.populateTransaction(e);delete a.from;const c=Transaction.from(a);return await n.broadcastTransaction(await this.signTransaction(c))}}const hr=class hr extends AbstractSigner{constructor(n,a){super(a);Le(this,er);Ue(this,"address");defineProperties(this,{address:n})}async getAddress(){return this.address}connect(n){return new hr(this.address,n)}async signTransaction(n){st(this,er,dr).call(this,"transactions","signTransaction")}async signMessage(n){st(this,er,dr).call(this,"messages","signMessage")}async signTypedData(n,a,c){st(this,er,dr).call(this,"typed-data","signTypedData")}};er=new WeakSet,dr=function(n,a){assert$f(!1,`VoidSigner cannot sign ${n}`,"UNSUPPORTED_OPERATION",{operation:a})};let VoidSigner=hr;const lr=class lr extends AbstractSigner{constructor(n,a){super(a);Ue(this,"address");Le(this,tr);assertArgument(n&&typeof n.sign=="function","invalid private key","privateKey","[ REDACTED ]"),we(this,tr,n);const c=computeAddress(this.signingKey.publicKey);defineProperties(this,{address:c})}get signingKey(){return Re(this,tr)}get privateKey(){return this.signingKey.privateKey}async getAddress(){return this.address}connect(n){return new lr(Re(this,tr),n)}async signTransaction(n){n=copyRequest(n);const{to:a,from:c}=await resolveProperties({to:n.to?resolveAddress(n.to,this.provider):void 0,from:n.from?resolveAddress(n.from,this.provider):void 0});a!=null&&(n.to=a),c!=null&&(n.from=c),n.from!=null&&(assertArgument(getAddress(n.from)===this.address,"transaction from address mismatch","tx.from",n.from),delete n.from);const o=Transaction.from(n);return o.signature=this.signingKey.sign(o.unsignedHash),o.serialized}async signMessage(n){return this.signMessageSync(n)}signMessageSync(n){return this.signingKey.sign(hashMessage(n)).serialized}async signTypedData(n,a,c){const o=await TypedDataEncoder.resolveNames(n,a,c,async u=>{assert$f(this.provider!=null,"cannot resolve ENS names without a provider","UNSUPPORTED_OPERATION",{operation:"resolveName",info:{name:u}});const h=await this.provider.resolveName(u);return assert$f(h!=null,"unconfigured ENS name","UNCONFIGURED_NAME",{value:u}),h});return this.signingKey.sign(TypedDataEncoder.hash(o.domain,a,o.value)).serialized}};tr=new WeakMap;let BaseWallet=lr;const subsChrs=" !#$%&'()*+,-./<=>?@[]^_`{|}~",Word=/^[a-z]*$/i;function unfold(t,e){let n=97;return t.reduce((a,c)=>(c===e?n++:c.match(Word)?a.push(String.fromCharCode(n)+c):(n=97,a.push(c)),a),[])}function decode(t,e){for(let c=subsChrs.length-1;c>=0;c--)t=t.split(subsChrs[c]).join(e.substring(2*c,2*c+2));const n=[],a=t.replace(/(:|([0-9])|([A-Z][a-z]*))/g,(c,o,u,h)=>{if(u)for(let l=parseInt(u);l>=0;l--)n.push(";");else n.push(o.toLowerCase());return""});if(a)throw new Error(`leftovers: ${JSON.stringify(a)}`);return unfold(unfold(n,";"),":")}function decodeOwl(t){return assertArgument(t[0]==="0","unsupported auwl data","data",t),decode(t.substring(1+2*subsChrs.length),t.substring(1,1+2*subsChrs.length))}class Wordlist{constructor(e){Ue(this,"locale");defineProperties(this,{locale:e})}split(e){return e.toLowerCase().split(/\s+/g)}join(e){return e.join(" ")}}class WordlistOwl extends Wordlist{constructor(n,a,c){super(n);Le(this,ar);Le(this,rr);Le(this,nr);Le(this,Pt);we(this,rr,a),we(this,nr,c),we(this,Pt,null)}get _data(){return Re(this,rr)}_decodeWords(){return decodeOwl(Re(this,rr))}getWord(n){const a=st(this,ar,yr).call(this);return assertArgument(n>=0&&n<a.length,`invalid word index: ${n}`,"index",n),a[n]}getWordIndex(n){return st(this,ar,yr).call(this).indexOf(n)}}rr=new WeakMap,nr=new WeakMap,Pt=new WeakMap,ar=new WeakSet,yr=function(){if(Re(this,Pt)==null){const n=this._decodeWords();if(id(n.join(`
3
3
  `)+`
4
4
  `)!==Re(this,nr))throw new Error(`BIP39 Wordlist for ${this.locale} FAILED`);we(this,Pt,n)}return Re(this,Pt)};const words="0erleonalorenseinceregesticitStanvetearctssi#ch2Athck&tneLl0And#Il.yLeOutO=S|S%b/ra@SurdU'0Ce[Cid|CountCu'Hie=IdOu,-Qui*Ro[TT]T%T*[Tu$0AptDD-tD*[Ju,M.UltV<)Vi)0Rob-0FairF%dRaid0A(EEntRee0Ead0MRRp%tS!_rmBumCoholErtI&LLeyLowMo,O}PhaReadySoT Ways0A>urAz(gOngOuntU'd0Aly,Ch%Ci|G G!GryIm$K!Noun)Nu$O` Sw T&naTiqueXietyY1ArtOlogyPe?P!Pro=Ril1ChCt-EaEnaGueMMedM%MyOundR<+Re,Ri=RowTTefa@Ti,Tw%k0KPe@SaultSetSi,SumeThma0H!>OmTa{T&dT.udeTra@0Ct]D.Gu,NtTh%ToTumn0Era+OcadoOid0AkeA*AyEsomeFulKw?d0Is:ByChel%C#D+GL<)Lc#y~MbooN<aNn RRelyRga(R*lSeS-SketTt!3A^AnAutyCau'ComeEfF%eG(Ha=H(dLie=LowLtN^Nef./TrayTt Twe&Y#d3Cyc!DKeNdOlogyRdR`Tt _{AdeAmeAnketA,EakE[IndOodO[omOu'UeUrUsh_rdAtDyIlMbNeNusOkO,Rd R(gRrowSsTtomUn)XY_{etA(AndA[A=EadEezeI{Id+IefIghtIngIskOccoliOk&OnzeOomO` OwnUsh2Bb!DdyD+tFf$oIldLbLkL!tNd!Nk Rd&Rg R,SS(e[SyTt Y Zz:Bba+B(B!CtusGeKe~LmM aMpNN$N)lNdyNn#NoeNvasNy#Pab!P.$Pta(RRb#RdRgoRpetRryRtSeShS(o/!Su$TT$ogT^Teg%yTt!UghtU'Ut]Ve3Il(gL yM|NsusNturyRe$Rta(_irAlkAmp]An+AosApt Ar+A'AtEapE{Ee'EfErryE,I{&IefIldIm}yOi)Oo'R#-U{!UnkUrn0G?Nnam#Rc!Tiz&TyVil_imApArifyAwAyE<ErkEv I{I|IffImbIn-IpO{OgO'O`OudOwnUbUmpU, Ut^_^A,C#utDeFfeeIlInL!@L%LumnMb(eMeMf%tM-Mm#Mp<yNc tNdu@NfirmNg*[N}@Nsid NtrolNv()OkOlPp PyR$ReRnR*@/Tt#U^UntryUp!Ur'Us(V Yo>_{Ad!AftAmA}AshAt AwlAzyEamEd.EekEwI{etImeIspIt-OpO[Ou^OwdUci$UelUi'Umb!Un^UshYY,$2BeLtu*PPbo?dRiousRr|Rta(R=Sh]/omTe3C!:DMa+MpN)Ng R(gShUght WnY3AlBa>BrisCadeCemb CideCl(eC%a>C*a'ErF&'F(eFyG*eLayLiv M<dMi'Ni$Nti,NyP?tP&dPos.P`PutyRi=ScribeS tSignSkSpair/royTailTe@VelopVi)Vo>3AgramAlAm#dAryCeE'lEtFf G.$Gn.yLemmaNn NosaurRe@RtSag*eScov Sea'ShSmi[S%d Splay/<)V tVideV%)Zzy5Ct%Cum|G~Lph(Ma(Na>NkeyN%OrSeUb!Ve_ftAg#AmaA,-AwEamE[IftIllInkIpI=OpUmY2CkMbNeR(g/T^Ty1Arf1Nam-:G G!RlyRnR`Sily/Sy1HoOlogyOnomy0GeItUca>1F%t0G1GhtTh 2BowD E@r-Eg<tEm|Eph<tEvat%I>Se0B?kBodyBra)Er+Ot]PloyPow Pty0Ab!A@DD![D%'EmyErgyF%)Ga+G(eH<)JoyLi,OughR-hRollSu*T Ti*TryVelope1Isode0U$Uip0AA'OdeOs]R%Upt0CapeSayS&)Ta>0Ern$H-s1Id&)IlOkeOl=1A@Amp!Ce[Ch<+C.eCludeCu'Ecu>Erci'Hau,Hib.I!I,ItOt-P<dPe@Pi*Pla(Po'P*[T&dTra0EEbrow:Br-CeCultyDeIntI`~L'MeMilyMousNNcyNtasyRmSh]TT$Th TigueUltV%.e3Atu*Bru?yD $EEdElMa!N)/iv$T^V W3B Ct]EldGu*LeLmLt N$NdNeNg NishReRmR,Sc$ShTT}[X_gAmeAshAtAv%EeIghtIpOatO{O%Ow UidUshY_mCusGIlLd~owOdOtR)Re,R+tRkRtu}RumRw?dSsil/ UndX_gi!AmeEqu|EshI&dIn+OgOntO,OwnOz&U.2ElNNnyRna)RyTu*:D+tInLaxy~ yMePRa+Rba+Rd&Rl-Rm|SSpTeTh U+Ze3N $NiusN*Nt!Nu(e/u*2O,0AntFtGg!Ng RaffeRlVe_dAn)A*A[IdeImp'ObeOomOryO=OwUe_tDde[LdOdO'RillaSpelSsipV nWn_bA)A(AntApeA[Av.yEatE&IdIefItOc yOupOwUnt_rdE[IdeIltIt?N3M:B.IrLfMm M, NdPpyRb%RdRshR=,TVeWkZ?d3AdAl`ArtAvyD+hogIght~oLmetLpNRo3Dd&Gh~NtPRe/%y5BbyCkeyLdLeLiday~owMeNeyOdPeRnRr%R'Sp.$/TelUrV 5BGeM<Mb!M%Nd*dNgryNtRd!RryRtSb<d3Brid:1EOn0EaEntifyLe2N%e4LLeg$L}[0A+Ita>M&'Mu}Pa@Po'Pro=Pul'0ChCludeComeC*a'DexD-a>Do%Du,ryF<tFl-tF%mHa!H .Iti$Je@JuryMa>N Noc|PutQuiryS<eSe@SideSpi*/$lTa@T e,ToVe,V.eVol=3On0L<dOla>Sue0Em1Ory:CketGu?RZz3AlousAns~yWel9BInKeUr}yY5D+I)MpNg!Ni%Nk/:Ng?oo3EnEpT^upY3CkDD}yNdNgdomSsTT^&TeTt&Wi4EeIfeO{Ow:BBelB%Dd DyKeMpNgua+PtopR+T T(UghUndryVaWWnWsu.Y Zy3Ad AfArnA=Ctu*FtGG$G&dIsu*M#NdNg`NsOp?dSs#Tt Vel3ArB tyBr?yC&'FeFtGhtKeMbM.NkOnQuid/Tt!VeZ?d5AdAnB, C$CkG-NelyNgOpTt yUdUn+VeY$5CkyGga+Mb N?N^Xury3R-s:Ch(eDG-G}tIdIlInJ%KeMm$NNa+Nda>NgoNs]Nu$P!Rb!R^Rg(R(eRketRria+SkSs/ T^T i$ThTrixTt XimumZe3AdowAnAsu*AtCh<-D$DiaLodyLtMb M%yNt]NuRcyR+R.RryShSsa+T$Thod3Dd!DnightLk~]M-NdNimumN%Nu>Rac!Rr%S ySs/akeXXedXtu*5Bi!DelDifyMM|N.%NkeyN, N`OnR$ReRn(gSqu.oTh T]T%Unta(U'VeVie5ChFf(LeLtiplySc!SeumShroomS-/Tu$3Self/ yTh:I=MePk(Rrow/yT]Tu*3ArCkEdGati=G!@I` PhewR=/TTw%kUtr$V WsXt3CeGht5B!I'M(eeOd!Rm$R`SeTab!TeTh(gTi)VelW5C!?Mb R'T:K0EyJe@Li+Scu*S =Ta(Vious0CurE<Tob 0Or1FF Fi)T&2L1Ay0DI=Ymp-0It0CeEI#L(eLy1EnEraIn]Po'T]1An+B.Ch?dD D(?yG<I|Ig($Ph<0Tr-h0H 0Tdo%T TputTside0AlEnEr0NN 0Yg&0/ 0O}:CtDd!GeIrLa)LmNdaNelN-N` P RadeR|RkRrotRtySsT^ThTi|TrolTt nU'VeYm|3A)AnutArAs<tL-<NN$tyNcilOp!Pp Rfe@Rm.Rs#T2O}OtoRa'Ys-$0AnoCn-Ctu*E)GGe#~LotNkO} Pe/olT^Zza_)A}tA,-A>AyEa'Ed+U{UgUn+2EmEtIntL?LeLi)NdNyOlPul?Rt]S.]Ssib!/TatoTt yV tyWd W _@i)Ai'Ed-tEf Epa*Es|EttyEv|I)IdeIm?yIntI%.yIs#Iva>IzeOb!mO)[Odu)Of.OgramOje@Omo>OofOp tyOsp O>@OudOvide2Bl-Dd(g~LpL'Mpk(N^PilPpyR^a'R.yRpo'R'ShTZz!3Ramid:99Al.yAntumArt E,]I{ItIzO>:Bb.Cco#CeCkD?DioIlInI'~yMpN^NdomN+PidReTeTh V&WZ%3AdyAlAs#BelBuildC$lCei=CipeC%dCyc!Du)F!@F%mFu'G]G*tGul?Je@LaxLea'LiefLyMa(Memb M(dMo=Nd NewNtOp&PairPeatPla)P%tQui*ScueSemb!Si,Sour)Sp#'SultTi*T*atTurnUn]Ve$ViewW?d2Y`m0BBb#CeChDeD+F!GhtGidNgOtPp!SkTu$V$V 5AdA,BotBu,CketM<)OfOkieOmSeTa>UghUndU>Y$5Bb DeGLeNNwayR$:DDd!D}[FeIlLadLm#L#LtLu>MeMp!NdTisfyToshiU)Usa+VeY1A!AnA*Att E}HemeHoolI&)I[%sOrp]OutRapRe&RiptRub1AAr^As#AtC#dC*tCt]Cur.yEdEkGm|Le@~M(?Ni%N'Nt&)RiesRvi)Ss]Tt!TupV&_dowAftAllowA*EdEllEriffIeldIftI}IpIv O{OeOotOpOrtOuld O=RimpRugUff!Y0Bl(gCkDeE+GhtGnL|Lk~yLv Mil?Mp!N)NgR&/ Tua>XZe1A>Et^IIllInIrtUll0AbAmEepEnd I)IdeIghtImOg<OtOwUsh0AllArtI!OkeOo`0A{AkeApIffOw0ApCc Ci$CkDaFtL?Ldi LidLut]L=Me#eNgOnRryRtUlUndUpUr)U`0A)A*Ati$AwnEakEci$EedEllEndH eI)Id IkeInIr.L.OilOns%O#OrtOtRayReadR(gY0Ua*UeezeUir*l_b!AdiumAffA+AirsAmpAndArtA>AyEakEelEmEpE*oI{IllIngO{Oma^O}OolOryO=Ra>gyReetRikeR#gRugg!Ud|UffUmb!Y!0Bje@Bm.BwayC)[ChDd&Ff G?G+,ItMm NNnyN'tP PplyP*meReRfa)R+Rpri'RroundR=ySpe@/a(1AllowAmpApArmE?EetIftImIngIt^Ord1MbolMptomRup/em:B!Ck!GIlL|LkNkPeR+tSk/eTtooXi3A^Am~NN<tNnisNtRm/Xt_nkAtEmeEnE%yE*EyIngIsOughtReeRi=RowUmbUnd 0CketDeG LtMb MeNyPRedSsueT!5A,BaccoDayDdl EGe` I!tK&MatoM%rowNeNgueNightOlO`PP-Pp!R^RnadoRtoi'SsT$Uri,W?dW WnY_{AdeAff-Ag-A(Ansf ApAshA=lAyEatEeEndI$IbeI{Igg ImIpOphyOub!U{UeUlyUmpetU,U`Y2BeIt]Mb!NaN}lRkeyRnRt!1El=EntyI)InI,O1PeP-$:5Ly5B*lla0Ab!Awa*C!Cov D DoFairFoldHappyIf%mIqueItIv 'KnownLo{TilUsu$Veil1Da>GradeHoldOnP Set1B<Ge0A+EEdEfulE![U$0Il.y:C<tCuumGueLidL!yL=NNishP%Rious/Ult3H-!L=tNd%Ntu*NueRbRifyRs]RyS'lT <3Ab!Br<tCiousCt%yDeoEw~a+Nta+Ol(Rtu$RusSaS.Su$T$Vid5C$I)IdLc<oLumeTeYa+:GeG#ItLk~LnutNtRfa*RmRri%ShSp/eT VeY3Al`Ap#ArA'lA` BDd(gEk&dIrdLcome/T_!AtEatEelEnE*IpIsp 0DeD`FeLd~NNdowNeNgNkNn Nt ReSdomSeShT}[5LfM<Nd OdOlRdRkRldRryR`_pE{E,!I,I>Ong::Rd3Ar~ow9UUngU`:3BraRo9NeO",checksum="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60";let wordlist=null;class LangEn extends WordlistOwl{constructor(){super("en",words,checksum)}static wordlist(){return wordlist==null&&(wordlist=new LangEn),wordlist}}function getUpperMask(t){return(1<<t)-1<<8-t&255}function getLowerMask(t){return(1<<t)-1&255}function mnemonicToEntropy(t,e){assertNormalize("NFKD"),e==null&&(e=LangEn.wordlist());const n=e.split(t);assertArgument(n.length%3===0&&n.length>=12&&n.length<=24,"invalid mnemonic length","mnemonic","[ REDACTED ]");const a=new Uint8Array(Math.ceil(11*n.length/8));let c=0;for(let b=0;b<n.length;b++){let d=e.getWordIndex(n[b].normalize("NFKD"));assertArgument(d>=0,`invalid mnemonic word at index ${b}`,"mnemonic","[ REDACTED ]");for(let p=0;p<11;p++)d&1<<10-p&&(a[c>>3]|=1<<7-c%8),c++}const o=32*n.length/3,u=n.length/3,h=getUpperMask(u),l=getBytes(sha256$2(a.slice(0,o/8)))[0]&h;return assertArgument(l===(a[a.length-1]&h),"invalid mnemonic checksum","mnemonic","[ REDACTED ]"),hexlify(a.slice(0,o/8))}function entropyToMnemonic(t,e){assertArgument(t.length%4===0&&t.length>=16&&t.length<=32,"invalid entropy size","entropy","[ REDACTED ]"),e==null&&(e=LangEn.wordlist());const n=[0];let a=11;for(let u=0;u<t.length;u++)a>8?(n[n.length-1]<<=8,n[n.length-1]|=t[u],a-=8):(n[n.length-1]<<=a,n[n.length-1]|=t[u]>>8-a,n.push(t[u]&getLowerMask(8-a)),a+=3);const c=t.length/4,o=parseInt(sha256$2(t).substring(2,4),16)&getUpperMask(c);return n[n.length-1]<<=c,n[n.length-1]|=o>>8-c,e.join(n.map(u=>e.getWord(u)))}const _guard$1={};class Mnemonic{constructor(e,n,a,c,o){Ue(this,"phrase");Ue(this,"password");Ue(this,"wordlist");Ue(this,"entropy");c==null&&(c=""),o==null&&(o=LangEn.wordlist()),assertPrivate(e,_guard$1,"Mnemonic"),defineProperties(this,{phrase:a,password:c,wordlist:o,entropy:n})}computeSeed(){const e=toUtf8Bytes("mnemonic"+this.password,"NFKD");return pbkdf2(toUtf8Bytes(this.phrase,"NFKD"),e,2048,64,"sha512")}static fromPhrase(e,n,a){const c=mnemonicToEntropy(e,a);return e=entropyToMnemonic(getBytes(c),a),new Mnemonic(_guard$1,c,e,n,a)}static fromEntropy(e,n,a){const c=getBytes(e,"entropy"),o=entropyToMnemonic(c,a);return new Mnemonic(_guard$1,hexlify(c),o,n,a)}static entropyToPhrase(e,n){const a=getBytes(e,"entropy");return entropyToMnemonic(a,n)}static phraseToEntropy(e,n){return mnemonicToEntropy(e,n)}static isValidMnemonic(e,n){try{return mnemonicToEntropy(e,n),!0}catch{}return!1}}/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */var __classPrivateFieldGet$2=function(t,e,n,a){if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(t):a?a.value:e.get(t)},__classPrivateFieldSet$2=function(t,e,n,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!c:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(t,n):c?c.value=n:e.set(t,n),n},_AES_key,_AES_Kd,_AES_Ke;const numberOfRounds={16:10,24:12,32:14},rcon=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],S=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Si=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],T1=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],T2=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],T3=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],T4=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],T5=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],T6=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],T7=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],T8=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],U1=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],U2=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],U3=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],U4=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function convertToInt32(t){const e=[];for(let n=0;n<t.length;n+=4)e.push(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3]);return e}class AES{get key(){return __classPrivateFieldGet$2(this,_AES_key,"f").slice()}constructor(e){if(_AES_key.set(this,void 0),_AES_Kd.set(this,void 0),_AES_Ke.set(this,void 0),!(this instanceof AES))throw Error("AES must be instanitated with `new`");__classPrivateFieldSet$2(this,_AES_key,new Uint8Array(e),"f");const n=numberOfRounds[this.key.length];if(n==null)throw new TypeError("invalid key size (must be 16, 24 or 32 bytes)");__classPrivateFieldSet$2(this,_AES_Ke,[],"f"),__classPrivateFieldSet$2(this,_AES_Kd,[],"f");for(let d=0;d<=n;d++)__classPrivateFieldGet$2(this,_AES_Ke,"f").push([0,0,0,0]),__classPrivateFieldGet$2(this,_AES_Kd,"f").push([0,0,0,0]);const a=(n+1)*4,c=this.key.length/4,o=convertToInt32(this.key);let u;for(let d=0;d<c;d++)u=d>>2,__classPrivateFieldGet$2(this,_AES_Ke,"f")[u][d%4]=o[d],__classPrivateFieldGet$2(this,_AES_Kd,"f")[n-u][d%4]=o[d];let h=0,l=c,b;for(;l<a;){if(b=o[c-1],o[0]^=S[b>>16&255]<<24^S[b>>8&255]<<16^S[b&255]<<8^S[b>>24&255]^rcon[h]<<24,h+=1,c!=8)for(let m=1;m<c;m++)o[m]^=o[m-1];else{for(let m=1;m<c/2;m++)o[m]^=o[m-1];b=o[c/2-1],o[c/2]^=S[b&255]^S[b>>8&255]<<8^S[b>>16&255]<<16^S[b>>24&255]<<24;for(let m=c/2+1;m<c;m++)o[m]^=o[m-1]}let d=0,p,x;for(;d<c&&l<a;)p=l>>2,x=l%4,__classPrivateFieldGet$2(this,_AES_Ke,"f")[p][x]=o[d],__classPrivateFieldGet$2(this,_AES_Kd,"f")[n-p][x]=o[d++],l++}for(let d=1;d<n;d++)for(let p=0;p<4;p++)b=__classPrivateFieldGet$2(this,_AES_Kd,"f")[d][p],__classPrivateFieldGet$2(this,_AES_Kd,"f")[d][p]=U1[b>>24&255]^U2[b>>16&255]^U3[b>>8&255]^U4[b&255]}encrypt(e){if(e.length!=16)throw new TypeError("invalid plaintext size (must be 16 bytes)");const n=__classPrivateFieldGet$2(this,_AES_Ke,"f").length-1,a=[0,0,0,0];let c=convertToInt32(e);for(let h=0;h<4;h++)c[h]^=__classPrivateFieldGet$2(this,_AES_Ke,"f")[0][h];for(let h=1;h<n;h++){for(let l=0;l<4;l++)a[l]=T1[c[l]>>24&255]^T2[c[(l+1)%4]>>16&255]^T3[c[(l+2)%4]>>8&255]^T4[c[(l+3)%4]&255]^__classPrivateFieldGet$2(this,_AES_Ke,"f")[h][l];c=a.slice()}const o=new Uint8Array(16);let u=0;for(let h=0;h<4;h++)u=__classPrivateFieldGet$2(this,_AES_Ke,"f")[n][h],o[4*h]=(S[c[h]>>24&255]^u>>24)&255,o[4*h+1]=(S[c[(h+1)%4]>>16&255]^u>>16)&255,o[4*h+2]=(S[c[(h+2)%4]>>8&255]^u>>8)&255,o[4*h+3]=(S[c[(h+3)%4]&255]^u)&255;return o}decrypt(e){if(e.length!=16)throw new TypeError("invalid ciphertext size (must be 16 bytes)");const n=__classPrivateFieldGet$2(this,_AES_Kd,"f").length-1,a=[0,0,0,0];let c=convertToInt32(e);for(let h=0;h<4;h++)c[h]^=__classPrivateFieldGet$2(this,_AES_Kd,"f")[0][h];for(let h=1;h<n;h++){for(let l=0;l<4;l++)a[l]=T5[c[l]>>24&255]^T6[c[(l+3)%4]>>16&255]^T7[c[(l+2)%4]>>8&255]^T8[c[(l+1)%4]&255]^__classPrivateFieldGet$2(this,_AES_Kd,"f")[h][l];c=a.slice()}const o=new Uint8Array(16);let u=0;for(let h=0;h<4;h++)u=__classPrivateFieldGet$2(this,_AES_Kd,"f")[n][h],o[4*h]=(Si[c[h]>>24&255]^u>>24)&255,o[4*h+1]=(Si[c[(h+3)%4]>>16&255]^u>>16)&255,o[4*h+2]=(Si[c[(h+2)%4]>>8&255]^u>>8)&255,o[4*h+3]=(Si[c[(h+1)%4]&255]^u)&255;return o}}_AES_key=new WeakMap,_AES_Kd=new WeakMap,_AES_Ke=new WeakMap;class ModeOfOperation{constructor(e,n,a){if(a&&!(this instanceof a))throw new Error(`${e} must be instantiated with "new"`);Object.defineProperties(this,{aes:{enumerable:!0,value:new AES(n)},name:{enumerable:!0,value:e}})}}var __classPrivateFieldSet$1=function(t,e,n,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!c:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(t,n):c?c.value=n:e.set(t,n),n},__classPrivateFieldGet$1=function(t,e,n,a){if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(t):a?a.value:e.get(t)},_CBC_iv,_CBC_lastBlock;class CBC extends ModeOfOperation{constructor(e,n){if(super("ECC",e,CBC),_CBC_iv.set(this,void 0),_CBC_lastBlock.set(this,void 0),n){if(n.length%16)throw new TypeError("invalid iv size (must be 16 bytes)");__classPrivateFieldSet$1(this,_CBC_iv,new Uint8Array(n),"f")}else __classPrivateFieldSet$1(this,_CBC_iv,new Uint8Array(16),"f");__classPrivateFieldSet$1(this,_CBC_lastBlock,this.iv,"f")}get iv(){return new Uint8Array(__classPrivateFieldGet$1(this,_CBC_iv,"f"))}encrypt(e){if(e.length%16)throw new TypeError("invalid plaintext size (must be multiple of 16 bytes)");const n=new Uint8Array(e.length);for(let a=0;a<e.length;a+=16){for(let c=0;c<16;c++)__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")[c]^=e[a+c];__classPrivateFieldSet$1(this,_CBC_lastBlock,this.aes.encrypt(__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")),"f"),n.set(__classPrivateFieldGet$1(this,_CBC_lastBlock,"f"),a)}return n}decrypt(e){if(e.length%16)throw new TypeError("invalid ciphertext size (must be multiple of 16 bytes)");const n=new Uint8Array(e.length);for(let a=0;a<e.length;a+=16){const c=this.aes.decrypt(e.subarray(a,a+16));for(let o=0;o<16;o++)n[a+o]=c[o]^__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")[o],__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")[o]=e[a+o]}return n}}_CBC_iv=new WeakMap,_CBC_lastBlock=new WeakMap;var __classPrivateFieldSet=function(t,e,n,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!c:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(t,n):c?c.value=n:e.set(t,n),n},__classPrivateFieldGet=function(t,e,n,a){if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(t):a?a.value:e.get(t)},_CTR_remaining,_CTR_remainingIndex,_CTR_counter;class CTR extends ModeOfOperation{constructor(e,n){super("CTR",e,CTR),_CTR_remaining.set(this,void 0),_CTR_remainingIndex.set(this,void 0),_CTR_counter.set(this,void 0),__classPrivateFieldSet(this,_CTR_counter,new Uint8Array(16),"f"),__classPrivateFieldGet(this,_CTR_counter,"f").fill(0),__classPrivateFieldSet(this,_CTR_remaining,__classPrivateFieldGet(this,_CTR_counter,"f"),"f"),__classPrivateFieldSet(this,_CTR_remainingIndex,16,"f"),n==null&&(n=1),typeof n=="number"?this.setCounterValue(n):this.setCounterBytes(n)}get counter(){return new Uint8Array(__classPrivateFieldGet(this,_CTR_counter,"f"))}setCounterValue(e){if(!Number.isInteger(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new TypeError("invalid counter initial integer value");for(let n=15;n>=0;--n)__classPrivateFieldGet(this,_CTR_counter,"f")[n]=e%256,e=Math.floor(e/256)}setCounterBytes(e){if(e.length!==16)throw new TypeError("invalid counter initial Uint8Array value length");__classPrivateFieldGet(this,_CTR_counter,"f").set(e)}increment(){for(let e=15;e>=0;e--)if(__classPrivateFieldGet(this,_CTR_counter,"f")[e]===255)__classPrivateFieldGet(this,_CTR_counter,"f")[e]=0;else{__classPrivateFieldGet(this,_CTR_counter,"f")[e]++;break}}encrypt(e){var n,a;const c=new Uint8Array(e);for(let o=0;o<c.length;o++)__classPrivateFieldGet(this,_CTR_remainingIndex,"f")===16&&(__classPrivateFieldSet(this,_CTR_remaining,this.aes.encrypt(__classPrivateFieldGet(this,_CTR_counter,"f")),"f"),__classPrivateFieldSet(this,_CTR_remainingIndex,0,"f"),this.increment()),c[o]^=__classPrivateFieldGet(this,_CTR_remaining,"f")[__classPrivateFieldSet(this,_CTR_remainingIndex,(a=__classPrivateFieldGet(this,_CTR_remainingIndex,"f"),n=a++,a),"f"),n];return c}decrypt(e){return this.encrypt(e)}}_CTR_remaining=new WeakMap,_CTR_remainingIndex=new WeakMap,_CTR_counter=new WeakMap;function pkcs7Strip(t){if(t.length<16)throw new TypeError("PKCS#7 invalid length");const e=t[t.length-1];if(e>16)throw new TypeError("PKCS#7 padding byte out of range");const n=t.length-e;for(let a=0;a<e;a++)if(t[n+a]!==e)throw new TypeError("PKCS#7 invalid padding byte");return new Uint8Array(t.subarray(0,n))}function looseArrayify(t){return typeof t=="string"&&!t.startsWith("0x")&&(t="0x"+t),getBytesCopy(t)}function zpad$1(t,e){for(t=String(t);t.length<e;)t="0"+t;return t}function getPassword(t){return typeof t=="string"?toUtf8Bytes(t,"NFKC"):getBytesCopy(t)}function spelunk(t,e){const n=e.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);assertArgument(n!=null,"invalid path","path",e);const a=n[1],c=n[3],o=n[4]==="!";let u=t;for(const h of a.toLowerCase().split(".")){if(Array.isArray(u)){if(!h.match(/^[0-9]+$/))break;u=u[parseInt(h)]}else if(typeof u=="object"){let l=null;for(const b in u)if(b.toLowerCase()===h){l=u[b];break}u=l}else u=null;if(u==null)break}if(assertArgument(!o||u!=null,"missing required value","path",a),c&&u!=null){if(c==="int"){if(typeof u=="string"&&u.match(/^-?[0-9]+$/))return parseInt(u);if(Number.isSafeInteger(u))return u}if(c==="number"&&typeof u=="string"&&u.match(/^-?[0-9.]*$/))return parseFloat(u);if(c==="data"&&typeof u=="string")return looseArrayify(u);if(c==="array"&&Array.isArray(u)||c===typeof u)return u;assertArgument(!1,`wrong type found for ${c} `,"path",a)}return u}const defaultPath$1="m/44'/60'/0'/0/0";function isKeystoreJson(t){try{const e=JSON.parse(t);if((e.version!=null?parseInt(e.version):0)===3)return!0}catch{}return!1}function decrypt(t,e,n){if(spelunk(t,"crypto.cipher:string")==="aes-128-ctr"){const c=spelunk(t,"crypto.cipherparams.iv:data!"),o=new CTR(e,c);return hexlify(o.decrypt(n))}assert$f(!1,"unsupported cipher","UNSUPPORTED_OPERATION",{operation:"decrypt"})}function getAccount(t,e){const n=getBytes(e),a=spelunk(t,"crypto.ciphertext:data!"),c=hexlify(keccak256(concat([n.slice(16,32),a]))).substring(2);assertArgument(c===spelunk(t,"crypto.mac:string!").toLowerCase(),"incorrect password","password","[ REDACTED ]");const o=decrypt(t,n.slice(0,16),a),u=computeAddress(o);if(t.address){let b=t.address.toLowerCase();b.startsWith("0x")||(b="0x"+b),assertArgument(getAddress(b)===u,"keystore address/privateKey mismatch","address",t.address)}const h={address:u,privateKey:o};if(spelunk(t,"x-ethers.version:string")==="0.1"){const b=n.slice(32,64),d=spelunk(t,"x-ethers.mnemonicCiphertext:data!"),p=spelunk(t,"x-ethers.mnemonicCounter:data!"),x=new CTR(b,p);h.mnemonic={path:spelunk(t,"x-ethers.path:string")||defaultPath$1,locale:spelunk(t,"x-ethers.locale:string")||"en",entropy:hexlify(getBytes(x.decrypt(d)))}}return h}function getDecryptKdfParams(t){const e=spelunk(t,"crypto.kdf:string");if(e&&typeof e=="string"){if(e.toLowerCase()==="scrypt"){const n=spelunk(t,"crypto.kdfparams.salt:data!"),a=spelunk(t,"crypto.kdfparams.n:int!"),c=spelunk(t,"crypto.kdfparams.r:int!"),o=spelunk(t,"crypto.kdfparams.p:int!");assertArgument(a>0&&(a&a-1)===0,"invalid kdf.N","kdf.N",a),assertArgument(c>0&&o>0,"invalid kdf","kdf",e);const u=spelunk(t,"crypto.kdfparams.dklen:int!");return assertArgument(u===32,"invalid kdf.dklen","kdf.dflen",u),{name:"scrypt",salt:n,N:a,r:c,p:o,dkLen:64}}else if(e.toLowerCase()==="pbkdf2"){const n=spelunk(t,"crypto.kdfparams.salt:data!"),a=spelunk(t,"crypto.kdfparams.prf:string!"),c=a.split("-").pop();assertArgument(c==="sha256"||c==="sha512","invalid kdf.pdf","kdf.pdf",a);const o=spelunk(t,"crypto.kdfparams.c:int!"),u=spelunk(t,"crypto.kdfparams.dklen:int!");return assertArgument(u===32,"invalid kdf.dklen","kdf.dklen",u),{name:"pbkdf2",salt:n,count:o,dkLen:u,algorithm:c}}}assertArgument(!1,"unsupported key-derivation function","kdf",e)}function decryptKeystoreJsonSync(t,e){const n=JSON.parse(t),a=getPassword(e),c=getDecryptKdfParams(n);if(c.name==="pbkdf2"){const{salt:p,count:x,dkLen:m,algorithm:v}=c,g=pbkdf2(a,p,x,m,v);return getAccount(n,g)}assert$f(c.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:c});const{salt:o,N:u,r:h,p:l,dkLen:b}=c,d=scryptSync(a,o,u,h,l,b);return getAccount(n,d)}function stall$1(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}async function decryptKeystoreJson(t,e,n){const a=JSON.parse(t),c=getPassword(e),o=getDecryptKdfParams(a);if(o.name==="pbkdf2"){n&&(n(0),await stall$1(0));const{salt:x,count:m,dkLen:v,algorithm:g}=o,$=pbkdf2(c,x,m,v,g);return n&&(n(1),await stall$1(0)),getAccount(a,$)}assert$f(o.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:o});const{salt:u,N:h,r:l,p:b,dkLen:d}=o,p=await scrypt(c,u,h,l,b,d,n);return getAccount(a,p)}function getEncryptKdfParams(t){const e=t.salt!=null?getBytes(t.salt,"options.salt"):randomBytes(32);let n=1<<17,a=8,c=1;return t.scrypt&&(t.scrypt.N&&(n=t.scrypt.N),t.scrypt.r&&(a=t.scrypt.r),t.scrypt.p&&(c=t.scrypt.p)),assertArgument(typeof n=="number"&&n>0&&Number.isSafeInteger(n)&&(BigInt(n)&BigInt(n-1))===BigInt(0),"invalid scrypt N parameter","options.N",n),assertArgument(typeof a=="number"&&a>0&&Number.isSafeInteger(a),"invalid scrypt r parameter","options.r",a),assertArgument(typeof c=="number"&&c>0&&Number.isSafeInteger(c),"invalid scrypt p parameter","options.p",c),{name:"scrypt",dkLen:32,salt:e,N:n,r:a,p:c}}function _encryptKeystore(t,e,n,a){const c=getBytes(n.privateKey,"privateKey"),o=a.iv!=null?getBytes(a.iv,"options.iv"):randomBytes(16);assertArgument(o.length===16,"invalid options.iv length","options.iv",a.iv);const u=a.uuid!=null?getBytes(a.uuid,"options.uuid"):randomBytes(16);assertArgument(u.length===16,"invalid options.uuid length","options.uuid",a.iv);const h=t.slice(0,16),l=t.slice(16,32),b=new CTR(h,o),d=getBytes(b.encrypt(c)),p=keccak256(concat([l,d])),x={address:n.address.substring(2).toLowerCase(),id:uuidV4(u),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(o).substring(2)},ciphertext:hexlify(d).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(e.salt).substring(2),n:e.N,dklen:32,p:e.p,r:e.r},mac:p.substring(2)}};if(n.mnemonic){const m=a.client!=null?a.client:`ethers/${version$1}`,v=n.mnemonic.path||defaultPath$1,g=n.mnemonic.locale||"en",$=t.slice(32,64),B=getBytes(n.mnemonic.entropy,"account.mnemonic.entropy"),C=randomBytes(16),F=new CTR($,C),H=getBytes(F.encrypt(B)),W=new Date,ie="UTC--"+(W.getUTCFullYear()+"-"+zpad$1(W.getUTCMonth()+1,2)+"-"+zpad$1(W.getUTCDate(),2)+"T"+zpad$1(W.getUTCHours(),2)+"-"+zpad$1(W.getUTCMinutes(),2)+"-"+zpad$1(W.getUTCSeconds(),2)+".0Z")+"--"+x.address;x["x-ethers"]={client:m,gethFilename:ie,path:v,locale:g,mnemonicCounter:hexlify(C).substring(2),mnemonicCiphertext:hexlify(H).substring(2),version:"0.1"}}return JSON.stringify(x)}function encryptKeystoreJsonSync(t,e,n){n==null&&(n={});const a=getPassword(e),c=getEncryptKdfParams(n),o=scryptSync(a,c.salt,c.N,c.r,c.p,64);return _encryptKeystore(getBytes(o),c,t,n)}async function encryptKeystoreJson(t,e,n){n==null&&(n={});const a=getPassword(e),c=getEncryptKdfParams(n),o=await scrypt(a,c.salt,c.N,c.r,c.p,64,n.progressCallback);return _encryptKeystore(getBytes(o),c,t,n)}const defaultPath="m/44'/60'/0'/0/0",MasterSecret=new Uint8Array([66,105,116,99,111,105,110,32,115,101,101,100]),HardenedBit=2147483648,N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Nibbles="0123456789abcdef";function zpad(t,e){let n="";for(;t;)n=Nibbles[t%16]+n,t=Math.trunc(t/16);for(;n.length<e*2;)n="0"+n;return"0x"+n}function encodeBase58Check(t){const e=getBytes(t),n=dataSlice(sha256$2(sha256$2(e)),0,4),a=concat([e,n]);return encodeBase58(a)}const _guard={};function ser_I(t,e,n,a){const c=new Uint8Array(37);t&HardenedBit?(assert$f(a!=null,"cannot derive child of neutered node","UNSUPPORTED_OPERATION",{operation:"deriveChild"}),c.set(getBytes(a),1)):c.set(getBytes(n));for(let u=24;u>=0;u-=8)c[33+(u>>3)]=t>>24-u&255;const o=getBytes(computeHmac("sha512",e,c));return{IL:o.slice(0,32),IR:o.slice(32)}}function derivePath(t,e){const n=e.split("/");assertArgument(n.length>0,"invalid path","path",e),n[0]==="m"&&(assertArgument(t.depth===0,`cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${t.depth}`,"path",e),n.shift());let a=t;for(let c=0;c<n.length;c++){const o=n[c];if(o.match(/^[0-9]+'$/)){const u=parseInt(o.substring(0,o.length-1));assertArgument(u<HardenedBit,"invalid path index",`path[${c}]`,o),a=a.deriveChild(HardenedBit+u)}else if(o.match(/^[0-9]+$/)){const u=parseInt(o);assertArgument(u<HardenedBit,"invalid path index",`path[${c}]`,o),a=a.deriveChild(u)}else assertArgument(!1,"invalid path component",`path[${c}]`,o)}return a}const gt=class gt extends BaseWallet{constructor(n,a,c,o,u,h,l,b,d){super(a,d);Le(this,sr);Ue(this,"publicKey");Ue(this,"fingerprint");Ue(this,"parentFingerprint");Ue(this,"mnemonic");Ue(this,"chainCode");Ue(this,"path");Ue(this,"index");Ue(this,"depth");assertPrivate(n,_guard,"HDNodeWallet"),defineProperties(this,{publicKey:a.compressedPublicKey});const p=dataSlice(ripemd160$1(sha256$2(this.publicKey)),0,4);defineProperties(this,{parentFingerprint:c,fingerprint:p,chainCode:o,path:u,index:h,depth:l}),defineProperties(this,{mnemonic:b})}connect(n){return new gt(_guard,this.signingKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.mnemonic,n)}async encrypt(n,a){return await encryptKeystoreJson(st(this,sr,vr).call(this),n,{progressCallback:a})}encryptSync(n){return encryptKeystoreJsonSync(st(this,sr,vr).call(this),n)}get extendedKey(){return assert$f(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),encodeBase58Check(concat(["0x0488ADE4",zpad(this.depth,1),this.parentFingerprint,zpad(this.index,4),this.chainCode,concat(["0x00",this.privateKey])]))}hasPath(){return this.path!=null}neuter(){return new HDNodeVoidWallet(_guard,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.provider)}deriveChild(n){const a=getNumber(n,"index");assertArgument(a<=4294967295,"invalid index","index",a);let c=this.path;c&&(c+="/"+(a&~HardenedBit),a&HardenedBit&&(c+="'"));const{IR:o,IL:u}=ser_I(a,this.chainCode,this.publicKey,this.privateKey),h=new SigningKey(toBeHex((toBigInt(u)+BigInt(this.privateKey))%N,32));return new gt(_guard,h,this.fingerprint,hexlify(o),c,a,this.depth+1,this.mnemonic,this.provider)}derivePath(n){return derivePath(this,n)}static fromExtendedKey(n){const a=toBeArray(decodeBase58(n));assertArgument(a.length===82||encodeBase58Check(a.slice(0,78))===n,"invalid extended key","extendedKey","[ REDACTED ]");const c=a[4],o=hexlify(a.slice(5,9)),u=parseInt(hexlify(a.slice(9,13)).substring(2),16),h=hexlify(a.slice(13,45)),l=a.slice(45,78);switch(hexlify(a.slice(0,4))){case"0x0488b21e":case"0x043587cf":{const b=hexlify(l);return new HDNodeVoidWallet(_guard,computeAddress(b),b,o,h,null,u,c,null)}case"0x0488ade4":case"0x04358394 ":if(l[0]!==0)break;return new gt(_guard,new SigningKey(l.slice(1)),o,h,null,u,c,null,null)}assertArgument(!1,"invalid extended key prefix","extendedKey","[ REDACTED ]")}static createRandom(n,a,c){var u;n==null&&(n=""),a==null&&(a=defaultPath),c==null&&(c=LangEn.wordlist());const o=Mnemonic.fromEntropy(randomBytes(16),n,c);return st(u=gt,Tt,fr).call(u,o.computeSeed(),o).derivePath(a)}static fromMnemonic(n,a){var c;return a||(a=defaultPath),st(c=gt,Tt,fr).call(c,n.computeSeed(),n).derivePath(a)}static fromPhrase(n,a,c,o){var h;a==null&&(a=""),c==null&&(c=defaultPath),o==null&&(o=LangEn.wordlist());const u=Mnemonic.fromPhrase(n,a,o);return st(h=gt,Tt,fr).call(h,u.computeSeed(),u).derivePath(c)}static fromSeed(n){var a;return st(a=gt,Tt,fr).call(a,n,null)}};sr=new WeakSet,vr=function(){const n={address:this.address,privateKey:this.privateKey},a=this.mnemonic;return this.path&&a&&a.wordlist.locale==="en"&&a.password===""&&(n.mnemonic={path:this.path,locale:"en",entropy:a.entropy}),n},Tt=new WeakSet,fr=function(n,a){assertArgument(isBytesLike(n),"invalid seed","seed","[REDACTED]");const c=getBytes(n,"seed");assertArgument(c.length>=16&&c.length<=64,"invalid seed","seed","[REDACTED]");const o=getBytes(computeHmac("sha512",MasterSecret,c)),u=new SigningKey(hexlify(o.slice(0,32)));return new gt(_guard,u,"0x00000000",hexlify(o.slice(32)),"m",0,0,a,null)},Le(gt,Tt);let HDNodeWallet=gt;class HDNodeVoidWallet extends VoidSigner{constructor(n,a,c,o,u,h,l,b,d){super(a,d);Ue(this,"publicKey");Ue(this,"fingerprint");Ue(this,"parentFingerprint");Ue(this,"chainCode");Ue(this,"path");Ue(this,"index");Ue(this,"depth");assertPrivate(n,_guard,"HDNodeVoidWallet"),defineProperties(this,{publicKey:c});const p=dataSlice(ripemd160$1(sha256$2(c)),0,4);defineProperties(this,{publicKey:c,fingerprint:p,parentFingerprint:o,chainCode:u,path:h,index:l,depth:b})}connect(n){return new HDNodeVoidWallet(_guard,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,n)}get extendedKey(){return assert$f(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),encodeBase58Check(concat(["0x0488B21E",zpad(this.depth,1),this.parentFingerprint,zpad(this.index,4),this.chainCode,this.publicKey]))}hasPath(){return this.path!=null}deriveChild(n){const a=getNumber(n,"index");assertArgument(a<=4294967295,"invalid index","index",a);let c=this.path;c&&(c+="/"+(a&~HardenedBit),a&HardenedBit&&(c+="'"));const{IR:o,IL:u}=ser_I(a,this.chainCode,this.publicKey,null),h=SigningKey.addPoints(u,this.publicKey,!0),l=computeAddress(h);return new HDNodeVoidWallet(_guard,l,h,this.fingerprint,hexlify(o),c,a,this.depth+1,this.provider)}derivePath(n){return derivePath(this,n)}}function isCrowdsaleJson(t){try{if(JSON.parse(t).encseed)return!0}catch{}return!1}function decryptCrowdsaleJson(t,e){const n=JSON.parse(t),a=getPassword(e),c=getAddress(spelunk(n,"ethaddr:string!")),o=looseArrayify(spelunk(n,"encseed:string!"));assertArgument(o&&o.length%16===0,"invalid encseed","json",t);const u=getBytes(pbkdf2(a,a,2e3,32,"sha256")).slice(0,16),h=o.slice(0,16),l=o.slice(16),b=new CBC(u,h),d=pkcs7Strip(getBytes(b.decrypt(l)));let p="";for(let x=0;x<d.length;x++)p+=String.fromCharCode(d[x]);return{address:c,privateKey:id(p)}}function stall(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}const kt=class kt extends BaseWallet{constructor(e,n){typeof e=="string"&&!e.startsWith("0x")&&(e="0x"+e);let a=typeof e=="string"?new SigningKey(e):e;super(a,n)}connect(e){return new kt(this.signingKey,e)}async encrypt(e,n){const a={address:this.address,privateKey:this.privateKey};return await encryptKeystoreJson(a,e,{progressCallback:n})}encryptSync(e){const n={address:this.address,privateKey:this.privateKey};return encryptKeystoreJsonSync(n,e)}static async fromEncryptedJson(e,n,a){var o;let c=null;return isKeystoreJson(e)?c=await decryptKeystoreJson(e,n,a):isCrowdsaleJson(e)&&(a&&(a(0),await stall(0)),c=decryptCrowdsaleJson(e,n),a&&(a(1),await stall(0))),st(o=kt,or,gr).call(o,c)}static fromEncryptedJsonSync(e,n){var c;let a=null;return isKeystoreJson(e)?a=decryptKeystoreJsonSync(e,n):isCrowdsaleJson(e)?a=decryptCrowdsaleJson(e,n):assertArgument(!1,"invalid JSON wallet","json","[ REDACTED ]"),st(c=kt,or,gr).call(c,a)}static createRandom(e){const n=HDNodeWallet.createRandom();return e?n.connect(e):n}static fromPhrase(e,n){const a=HDNodeWallet.fromPhrase(e);return n?a.connect(n):a}};or=new WeakSet,gr=function(e){if(assertArgument(e,"invalid JSON wallet","json","[ REDACTED ]"),"mnemonic"in e&&e.mnemonic&&e.mnemonic.locale==="en"){const a=Mnemonic.fromEntropy(e.mnemonic.entropy),c=HDNodeWallet.fromMnemonic(a,e.mnemonic.path);if(c.address===e.address&&c.privateKey===e.privateKey)return c;console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key")}const n=new kt(e.privateKey);return assertArgument(n.address===e.address,"address/privateKey mismatch","json","[ REDACTED ]"),n},Le(kt,or);let Wallet=kt;const byteToHex=[];for(let t=0;t<256;++t)byteToHex.push((t+256).toString(16).slice(1));function unsafeStringify(t,e=0){return(byteToHex[t[e+0]]+byteToHex[t[e+1]]+byteToHex[t[e+2]]+byteToHex[t[e+3]]+"-"+byteToHex[t[e+4]]+byteToHex[t[e+5]]+"-"+byteToHex[t[e+6]]+byteToHex[t[e+7]]+"-"+byteToHex[t[e+8]]+byteToHex[t[e+9]]+"-"+byteToHex[t[e+10]]+byteToHex[t[e+11]]+byteToHex[t[e+12]]+byteToHex[t[e+13]]+byteToHex[t[e+14]]+byteToHex[t[e+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(t,e,n){if(native.randomUUID&&!e&&!t)return native.randomUUID();t=t||{};const a=t.random||(t.rng||rng)();return a[6]=a[6]&15|64,a[8]=a[8]&63|128,unsafeStringify(a)}function sleep(t){return new Promise(e=>{setTimeout(e,t)})}class EventEmitter{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(e,n){this.events[e]||(this.events[e]=[]),this.events[e].push(n)}off(e,n){if(!this.events[e])return;const a=this.events[e].indexOf(n);a>-1&&this.events[e].splice(a,1)}cleanAll(){this.events={}}emit(e,n){this.events[e]&&this.events[e].forEach(a=>a(n))}}class Queue{constructor(e={},n){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.clearWaitTime=e.clearWaitTime||500,this.handleError=n}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const e=this.tasks.shift();if(e)try{const n=e();n instanceof Promise&&await n}catch(n){this.handleError({error:n,context:"Error processing task",throw:!1})}}this.isProcessing=!1}}enqueue(e){this.tasks.push(e),this.processQueue()}async clearQueue(){for(this.tasks=[];this.isProcessing;)await sleep(this.clearWaitTime)}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await sleep(this.clearWaitTime);return this.isWaiting=!1,!1}}const CONSENSUS_ID="SwarmStream",EVENTS={LOADING_INIT_USERS:"loadingInitUsers",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_SENT:"messageRequestSent",MESSAGE_REQUEST_ERROR:"messageRequestError",ERROR:"errorEvent"},SECOND=1e3,HEX_RADIX=16;var BeeType=(t=>(t.READER="reader",t.WRITER="writer",t.GSOC="gsoc",t))(BeeType||{}),buffer$1={},base64Js={};base64Js.byteLength=byteLength,base64Js.toByteArray=toByteArray,base64Js.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;revLookup[45]=62,revLookup[95]=63;function getLens(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var a=n===e?0:4-n%4;return[n,a]}function byteLength(t){var e=getLens(t),n=e[0],a=e[1];return(n+a)*3/4-a}function _byteLength(t,e,n){return(e+n)*3/4-n}function toByteArray(t){var e,n=getLens(t),a=n[0],c=n[1],o=new Arr(_byteLength(t,a,c)),u=0,h=c>0?a-4:a,l;for(l=0;l<h;l+=4)e=revLookup[t.charCodeAt(l)]<<18|revLookup[t.charCodeAt(l+1)]<<12|revLookup[t.charCodeAt(l+2)]<<6|revLookup[t.charCodeAt(l+3)],o[u++]=e>>16&255,o[u++]=e>>8&255,o[u++]=e&255;return c===2&&(e=revLookup[t.charCodeAt(l)]<<2|revLookup[t.charCodeAt(l+1)]>>4,o[u++]=e&255),c===1&&(e=revLookup[t.charCodeAt(l)]<<10|revLookup[t.charCodeAt(l+1)]<<4|revLookup[t.charCodeAt(l+2)]>>2,o[u++]=e>>8&255,o[u++]=e&255),o}function tripletToBase64(t){return lookup[t>>18&63]+lookup[t>>12&63]+lookup[t>>6&63]+lookup[t&63]}function encodeChunk(t,e,n){for(var a,c=[],o=e;o<n;o+=3)a=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),c.push(tripletToBase64(a));return c.join("")}function fromByteArray(t){for(var e,n=t.length,a=n%3,c=[],o=16383,u=0,h=n-a;u<h;u+=o)c.push(encodeChunk(t,u,u+o>h?h:u+o));return a===1?(e=t[n-1],c.push(lookup[e>>2]+lookup[e<<4&63]+"==")):a===2&&(e=(t[n-2]<<8)+t[n-1],c.push(lookup[e>>10]+lookup[e>>4&63]+lookup[e<<2&63]+"=")),c.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ieee754.read=function(t,e,n,a,c){var o,u,h=c*8-a-1,l=(1<<h)-1,b=l>>1,d=-7,p=n?c-1:0,x=n?-1:1,m=t[e+p];for(p+=x,o=m&(1<<-d)-1,m>>=-d,d+=h;d>0;o=o*256+t[e+p],p+=x,d-=8);for(u=o&(1<<-d)-1,o>>=-d,d+=a;d>0;u=u*256+t[e+p],p+=x,d-=8);if(o===0)o=1-b;else{if(o===l)return u?NaN:(m?-1:1)*(1/0);u=u+Math.pow(2,a),o=o-b}return(m?-1:1)*u*Math.pow(2,o-a)},ieee754.write=function(t,e,n,a,c,o){var u,h,l,b=o*8-c-1,d=(1<<b)-1,p=d>>1,x=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=a?0:o-1,v=a?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,u=d):(u=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-u))<1&&(u--,l*=2),u+p>=1?e+=x/l:e+=x*Math.pow(2,1-p),e*l>=2&&(u++,l/=2),u+p>=d?(h=0,u=d):u+p>=1?(h=(e*l-1)*Math.pow(2,c),u=u+p):(h=e*Math.pow(2,p-1)*Math.pow(2,c),u=0));c>=8;t[n+m]=h&255,m+=v,h/=256,c-=8);for(u=u<<c|h,b+=c;b>0;t[n+m]=u&255,m+=v,u/=256,b-=8);t[n+m-v]|=g*128};/*!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solarpunkltd/swarm-chat-js",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "JS library for chatting on Swarm",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -9,7 +9,7 @@
9
9
  "keywords": [
10
10
  "swarm",
11
11
  "js",
12
- "streaming"
12
+ "chat"
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",