@solarpunkltd/swarm-chat-js 0.0.2 → 2.1.0

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.
Files changed (58) hide show
  1. package/README.md +3 -1
  2. package/dist/index.d.ts +2 -4
  3. package/dist/index.esm.js +43205 -23583
  4. package/dist/index.js +23 -26
  5. package/dist/src/index.d.ts +5 -0
  6. package/dist/src/index.d.ts.map +1 -0
  7. package/dist/{libs → src/lib}/constants.d.ts +5 -5
  8. package/dist/src/lib/constants.d.ts.map +1 -0
  9. package/dist/src/lib/core.d.ts +47 -0
  10. package/dist/src/lib/core.d.ts.map +1 -0
  11. package/dist/src/lib/history.d.ts +49 -0
  12. package/dist/src/lib/history.d.ts.map +1 -0
  13. package/dist/src/lib/mine.d.ts +2 -0
  14. package/dist/src/lib/mine.d.ts.map +1 -0
  15. package/dist/src/lib/swarmEventEmitterReader.d.ts +15 -0
  16. package/dist/src/lib/swarmEventEmitterReader.d.ts.map +1 -0
  17. package/dist/src/lib/types/chat.d.ts +59 -0
  18. package/dist/src/lib/types/chat.d.ts.map +1 -0
  19. package/dist/src/lib/types/index.d.ts +4 -0
  20. package/dist/src/lib/types/index.d.ts.map +1 -0
  21. package/dist/src/lib/types/message.d.ts +14 -0
  22. package/dist/src/lib/types/message.d.ts.map +1 -0
  23. package/dist/src/lib/types/user.d.ts +35 -0
  24. package/dist/src/lib/types/user.d.ts.map +1 -0
  25. package/dist/src/lib/utils.d.ts +34 -0
  26. package/dist/src/lib/utils.d.ts.map +1 -0
  27. package/dist/src/utils/bee.d.ts +18 -0
  28. package/dist/src/utils/bee.d.ts.map +1 -0
  29. package/dist/src/utils/common.d.ts +4 -0
  30. package/dist/src/utils/common.d.ts.map +1 -0
  31. package/dist/src/utils/error.d.ts +6 -0
  32. package/dist/src/utils/error.d.ts.map +1 -0
  33. package/dist/src/utils/eventEmitter.d.ts.map +1 -0
  34. package/dist/src/utils/logger.d.ts +12 -0
  35. package/dist/src/utils/logger.d.ts.map +1 -0
  36. package/dist/{utils → src/utils}/queue.d.ts +3 -8
  37. package/dist/src/utils/queue.d.ts.map +1 -0
  38. package/dist/src/utils/validation.d.ts +7 -0
  39. package/dist/src/utils/validation.d.ts.map +1 -0
  40. package/dist/src/utils/waitForBroadcast.d.ts +10 -0
  41. package/dist/src/utils/waitForBroadcast.d.ts.map +1 -0
  42. package/dist/swarm-chat-umd.js +23 -26
  43. package/package.json +11 -5
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/libs/constants.d.ts.map +0 -1
  46. package/dist/libs/core.d.ts +0 -59
  47. package/dist/libs/core.d.ts.map +0 -1
  48. package/dist/libs/mine.d.ts +0 -4
  49. package/dist/libs/mine.d.ts.map +0 -1
  50. package/dist/libs/types.d.ts +0 -85
  51. package/dist/libs/types.d.ts.map +0 -1
  52. package/dist/libs/utils.d.ts +0 -34
  53. package/dist/libs/utils.d.ts.map +0 -1
  54. package/dist/utils/common.d.ts +0 -2
  55. package/dist/utils/common.d.ts.map +0 -1
  56. package/dist/utils/eventEmitter.d.ts.map +0 -1
  57. package/dist/utils/queue.d.ts.map +0 -1
  58. /package/dist/{utils → src/utils}/eventEmitter.d.ts +0 -0
@@ -1,30 +1,27 @@
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
- `,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
- `)+`
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};/*!
1
+ (function(ft,Se){typeof exports=="object"&&typeof module<"u"?Se(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],Se):(ft=typeof globalThis<"u"?globalThis:ft||self,Se(ft.SwarmChatJs={},ft.BeeJs))})(this,function(ft,Se){"use strict";var rae=Object.defineProperty;var c6=ft=>{throw TypeError(ft)};var nae=(ft,Se,ut)=>Se in ft?rae(ft,Se,{enumerable:!0,configurable:!0,writable:!0,value:ut}):ft[Se]=ut;var Q=(ft,Se,ut)=>nae(ft,typeof Se!="symbol"?Se+"":Se,ut),M_=(ft,Se,ut)=>Se.has(ft)||c6("Cannot "+ut);var T=(ft,Se,ut)=>(M_(ft,Se,"read from private field"),ut?ut.call(ft):Se.get(ft)),se=(ft,Se,ut)=>Se.has(ft)?c6("Cannot add the same private member more than once"):Se instanceof WeakSet?Se.add(ft):Se.set(ft,ut),F=(ft,Se,ut,xn)=>(M_(ft,Se,"write to private field"),xn?xn.call(ft,ut):Se.set(ft,ut),ut),Ee=(ft,Se,ut)=>(M_(ft,Se,"access private method"),ut);var bd=(ft,Se,ut,xn)=>({set _(Mc){F(ft,Se,Mc,ut)},get _(){return T(ft,Se,xn)}});var Zu,ic,$o,Qu,Yu,Oi,Ks,Ju,Xu,Hr,qn,Vs,sc,oc,ac,as,Ni,Fo,cc,_d,Nh,Ch,Bh,Zn,el,uc,tl,Ws,lc,nl,yg,Un,Qn,fc,hc,Ho,dc,U_,f6,il,sl,ol,pc,qs,yc,cs,al,cl,ul,ll,fl,hl,dl,pl,gl,yl,ml,mc,zo,Qs,Go,wl,mg,Ph,Js,bl,Zp,h6,Xr,Bi,Mh,D_,_l,wg,jo,Vl,us,ls,fs,cn,hs,bg,_g,Xs,Lh,Ko,Al,Uh,Dh,eC,Vo,bc,Wo,Wl,Jp,d6,Fh,Hh,El,xl,qo,eo,hi,Zo,ds,Il,Ag,_c,Ac,Qo,Sl,to,Xp,kl,ro,Tl,Ol,Yo,di,eg,p6,un,Jo,ln,Nl,Yn,vc,Xo,no,zh,pi,Cl,Bl,ct,Jn,$_,F_,Ad,H_,vd,vg,En,ps,Ec,ea,xc,Pl,ta,z_,G_,Rc,Ic,Ml,io,gs,Pi,gi,Dn,Gh,j_,ra,Ll,ys,jh,na,Sc,ia,Kh,kc,Ul,sa,Tc,Mi;var ut=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Mc(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function g6(){this.__data__=[],this.size=0}var y6=g6;function m6(r,e){return r===e||r!==r&&e!==e}var ql=m6,w6=ql;function b6(r,e){for(var t=r.length;t--;)if(w6(r[t][0],e))return t;return-1}var Ed=b6,_6=Ed,A6=Array.prototype,v6=A6.splice;function E6(r){var e=this.__data__,t=_6(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():v6.call(e,t,1),--this.size,!0}var x6=E6,R6=Ed;function I6(r){var e=this.__data__,t=R6(e,r);return t<0?void 0:e[t][1]}var S6=I6,k6=Ed;function T6(r){return k6(this.__data__,r)>-1}var O6=T6,N6=Ed;function C6(r,e){var t=this.__data__,n=N6(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var B6=C6,P6=y6,M6=x6,L6=S6,U6=O6,D6=B6;function Lc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Lc.prototype.clear=P6,Lc.prototype.delete=M6,Lc.prototype.get=L6,Lc.prototype.has=U6,Lc.prototype.set=D6;var xd=Lc,$6=xd;function F6(){this.__data__=new $6,this.size=0}var H6=F6;function z6(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var G6=z6;function j6(r){return this.__data__.get(r)}var K6=j6;function V6(r){return this.__data__.has(r)}var W6=V6,q6=typeof ut=="object"&&ut&&ut.Object===Object&&ut,K_=q6,Z6=K_,Q6=typeof self=="object"&&self&&self.Object===Object&&self,Y6=Z6||Q6||Function("return this")(),Rn=Y6,J6=Rn,X6=J6.Symbol,Uc=X6,V_=Uc,W_=Object.prototype,e3=W_.hasOwnProperty,t3=W_.toString,Zl=V_?V_.toStringTag:void 0;function r3(r){var e=e3.call(r,Zl),t=r[Zl];try{r[Zl]=void 0;var n=!0}catch{}var i=t3.call(r);return n&&(e?r[Zl]=t:delete r[Zl]),i}var n3=r3,i3=Object.prototype,s3=i3.toString;function o3(r){return s3.call(r)}var a3=o3,q_=Uc,c3=n3,u3=a3,l3="[object Null]",f3="[object Undefined]",Z_=q_?q_.toStringTag:void 0;function h3(r){return r==null?r===void 0?f3:l3:Z_&&Z_ in Object(r)?c3(r):u3(r)}var la=h3;function d3(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var yi=d3,p3=la,g3=yi,y3="[object AsyncFunction]",m3="[object Function]",w3="[object GeneratorFunction]",b3="[object Proxy]";function _3(r){if(!g3(r))return!1;var e=p3(r);return e==m3||e==w3||e==y3||e==b3}var Rd=_3,A3=Rn,v3=A3["__core-js_shared__"],E3=v3,Eg=E3,Q_=function(){var r=/[^.]+$/.exec(Eg&&Eg.keys&&Eg.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function x3(r){return!!Q_&&Q_ in r}var R3=x3,I3=Function.prototype,S3=I3.toString;function k3(r){if(r!=null){try{return S3.call(r)}catch{}try{return r+""}catch{}}return""}var Y_=k3,T3=Rd,O3=R3,N3=yi,C3=Y_,B3=/[\\^$.*+?()[\]{}|]/g,P3=/^\[object .+?Constructor\]$/,M3=Function.prototype,L3=Object.prototype,U3=M3.toString,D3=L3.hasOwnProperty,$3=RegExp("^"+U3.call(D3).replace(B3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function F3(r){if(!N3(r)||O3(r))return!1;var e=T3(r)?$3:P3;return e.test(C3(r))}var H3=F3;function z3(r,e){return r==null?void 0:r[e]}var G3=z3,j3=H3,K3=G3;function V3(r,e){var t=K3(r,e);return j3(t)?t:void 0}var fa=V3,W3=fa,q3=Rn,Z3=W3(q3,"Map"),xg=Z3,Q3=fa,Y3=Q3(Object,"create"),Id=Y3,J_=Id;function J3(){this.__data__=J_?J_(null):{},this.size=0}var X3=J3;function eB(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var tB=eB,rB=Id,nB="__lodash_hash_undefined__",iB=Object.prototype,sB=iB.hasOwnProperty;function oB(r){var e=this.__data__;if(rB){var t=e[r];return t===nB?void 0:t}return sB.call(e,r)?e[r]:void 0}var aB=oB,cB=Id,uB=Object.prototype,lB=uB.hasOwnProperty;function fB(r){var e=this.__data__;return cB?e[r]!==void 0:lB.call(e,r)}var hB=fB,dB=Id,pB="__lodash_hash_undefined__";function gB(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=dB&&e===void 0?pB:e,this}var yB=gB,mB=X3,wB=tB,bB=aB,_B=hB,AB=yB;function Dc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Dc.prototype.clear=mB,Dc.prototype.delete=wB,Dc.prototype.get=bB,Dc.prototype.has=_B,Dc.prototype.set=AB;var vB=Dc,X_=vB,EB=xd,xB=xg;function RB(){this.size=0,this.__data__={hash:new X_,map:new(xB||EB),string:new X_}}var IB=RB;function SB(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var kB=SB,TB=kB;function OB(r,e){var t=r.__data__;return TB(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Sd=OB,NB=Sd;function CB(r){var e=NB(this,r).delete(r);return this.size-=e?1:0,e}var BB=CB,PB=Sd;function MB(r){return PB(this,r).get(r)}var LB=MB,UB=Sd;function DB(r){return UB(this,r).has(r)}var $B=DB,FB=Sd;function HB(r,e){var t=FB(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var zB=HB,GB=IB,jB=BB,KB=LB,VB=$B,WB=zB;function $c(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}$c.prototype.clear=GB,$c.prototype.delete=jB,$c.prototype.get=KB,$c.prototype.has=VB,$c.prototype.set=WB;var Rg=$c,qB=xd,ZB=xg,QB=Rg,YB=200;function JB(r,e){var t=this.__data__;if(t instanceof qB){var n=t.__data__;if(!ZB||n.length<YB-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new QB(n)}return t.set(r,e),this.size=t.size,this}var XB=JB,e8=xd,t8=H6,r8=G6,n8=K6,i8=W6,s8=XB;function Fc(r){var e=this.__data__=new e8(r);this.size=e.size}Fc.prototype.clear=t8,Fc.prototype.delete=r8,Fc.prototype.get=n8,Fc.prototype.has=i8,Fc.prototype.set=s8;var kd=Fc,o8="__lodash_hash_undefined__";function a8(r){return this.__data__.set(r,o8),this}var c8=a8;function u8(r){return this.__data__.has(r)}var l8=u8,f8=Rg,h8=c8,d8=l8;function Td(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new f8;++e<t;)this.add(r[e])}Td.prototype.add=Td.prototype.push=h8,Td.prototype.has=d8;var p8=Td;function g8(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var y8=g8;function m8(r,e){return r.has(e)}var w8=m8,b8=p8,_8=y8,A8=w8,v8=1,E8=2;function x8(r,e,t,n,i,s){var o=t&v8,a=r.length,u=e.length;if(a!=u&&!(o&&u>a))return!1;var l=s.get(r),h=s.get(e);if(l&&h)return l==e&&h==r;var g=-1,b=!0,w=t&E8?new b8:void 0;for(s.set(r,e),s.set(e,r);++g<a;){var I=r[g],S=e[g];if(n)var x=o?n(S,I,g,e,r,s):n(I,S,g,r,e,s);if(x!==void 0){if(x)continue;b=!1;break}if(w){if(!_8(e,function(C,H){if(!A8(w,H)&&(I===C||i(I,C,t,n,s)))return w.push(H)})){b=!1;break}}else if(!(I===S||i(I,S,t,n,s))){b=!1;break}}return s.delete(r),s.delete(e),b}var eA=x8,R8=Rn,I8=R8.Uint8Array,tA=I8;function S8(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var k8=S8;function T8(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var O8=T8,rA=Uc,nA=tA,N8=ql,C8=eA,B8=k8,P8=O8,M8=1,L8=2,U8="[object Boolean]",D8="[object Date]",$8="[object Error]",F8="[object Map]",H8="[object Number]",z8="[object RegExp]",G8="[object Set]",j8="[object String]",K8="[object Symbol]",V8="[object ArrayBuffer]",W8="[object DataView]",iA=rA?rA.prototype:void 0,Ig=iA?iA.valueOf:void 0;function q8(r,e,t,n,i,s,o){switch(t){case W8:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case V8:return!(r.byteLength!=e.byteLength||!s(new nA(r),new nA(e)));case U8:case D8:case H8:return N8(+r,+e);case $8:return r.name==e.name&&r.message==e.message;case z8:case j8:return r==e+"";case F8:var a=B8;case G8:var u=n&M8;if(a||(a=P8),r.size!=e.size&&!u)return!1;var l=o.get(r);if(l)return l==e;n|=L8,o.set(r,e);var h=C8(a(r),a(e),n,i,s,o);return o.delete(r),h;case K8:if(Ig)return Ig.call(r)==Ig.call(e)}return!1}var Z8=q8;function Q8(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Sg=Q8,Y8=Array.isArray,In=Y8,J8=Sg,X8=In;function eP(r,e,t){var n=e(r);return X8(r)?n:J8(n,t(r))}var sA=eP;function tP(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var rP=tP;function nP(){return[]}var oA=nP,iP=rP,sP=oA,oP=Object.prototype,aP=oP.propertyIsEnumerable,aA=Object.getOwnPropertySymbols,cP=aA?function(r){return r==null?[]:(r=Object(r),iP(aA(r),function(e){return aP.call(r,e)}))}:sP,kg=cP;function uP(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var lP=uP;function fP(r){return r!=null&&typeof r=="object"}var Xn=fP,hP=la,dP=Xn,pP="[object Arguments]";function gP(r){return dP(r)&&hP(r)==pP}var yP=gP,cA=yP,mP=Xn,uA=Object.prototype,wP=uA.hasOwnProperty,bP=uA.propertyIsEnumerable,_P=cA(function(){return arguments}())?cA:function(r){return mP(r)&&wP.call(r,"callee")&&!bP.call(r,"callee")},Od=_P,Nd={exports:{}};function AP(){return!1}var vP=AP;Nd.exports,function(r,e){var t=Rn,n=vP,i=e&&!e.nodeType&&e,s=i&&!0&&r&&!r.nodeType&&r,o=s&&s.exports===i,a=o?t.Buffer:void 0,u=a?a.isBuffer:void 0,l=u||n;r.exports=l}(Nd,Nd.exports);var Cd=Nd.exports,EP=9007199254740991,xP=/^(?:0|[1-9]\d*)$/;function RP(r,e){var t=typeof r;return e=e??EP,!!e&&(t=="number"||t!="symbol"&&xP.test(r))&&r>-1&&r%1==0&&r<e}var Bd=RP,IP=9007199254740991;function SP(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=IP}var Tg=SP,kP=la,TP=Tg,OP=Xn,NP="[object Arguments]",CP="[object Array]",BP="[object Boolean]",PP="[object Date]",MP="[object Error]",LP="[object Function]",UP="[object Map]",DP="[object Number]",$P="[object Object]",FP="[object RegExp]",HP="[object Set]",zP="[object String]",GP="[object WeakMap]",jP="[object ArrayBuffer]",KP="[object DataView]",VP="[object Float32Array]",WP="[object Float64Array]",qP="[object Int8Array]",ZP="[object Int16Array]",QP="[object Int32Array]",YP="[object Uint8Array]",JP="[object Uint8ClampedArray]",XP="[object Uint16Array]",e5="[object Uint32Array]",Kt={};Kt[VP]=Kt[WP]=Kt[qP]=Kt[ZP]=Kt[QP]=Kt[YP]=Kt[JP]=Kt[XP]=Kt[e5]=!0,Kt[NP]=Kt[CP]=Kt[jP]=Kt[BP]=Kt[KP]=Kt[PP]=Kt[MP]=Kt[LP]=Kt[UP]=Kt[DP]=Kt[$P]=Kt[FP]=Kt[HP]=Kt[zP]=Kt[GP]=!1;function t5(r){return OP(r)&&TP(r.length)&&!!Kt[kP(r)]}var r5=t5;function n5(r){return function(e){return r(e)}}var Og=n5,Pd={exports:{}};Pd.exports,function(r,e){var t=K_,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,s=i&&i.exports===n,o=s&&t.process,a=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();r.exports=a}(Pd,Pd.exports);var Ng=Pd.exports,i5=r5,s5=Og,lA=Ng,fA=lA&&lA.isTypedArray,o5=fA?s5(fA):i5,Cg=o5,a5=lP,c5=Od,u5=In,l5=Cd,f5=Bd,h5=Cg,d5=Object.prototype,p5=d5.hasOwnProperty;function g5(r,e){var t=u5(r),n=!t&&c5(r),i=!t&&!n&&l5(r),s=!t&&!n&&!i&&h5(r),o=t||n||i||s,a=o?a5(r.length,String):[],u=a.length;for(var l in r)(e||p5.call(r,l))&&!(o&&(l=="length"||i&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||f5(l,u)))&&a.push(l);return a}var hA=g5,y5=Object.prototype;function m5(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||y5;return r===t}var Bg=m5;function w5(r,e){return function(t){return r(e(t))}}var dA=w5,b5=dA,_5=b5(Object.keys,Object),A5=_5,v5=Bg,E5=A5,x5=Object.prototype,R5=x5.hasOwnProperty;function I5(r){if(!v5(r))return E5(r);var e=[];for(var t in Object(r))R5.call(r,t)&&t!="constructor"&&e.push(t);return e}var pA=I5,S5=Rd,k5=Tg;function T5(r){return r!=null&&k5(r.length)&&!S5(r)}var Md=T5,O5=hA,N5=pA,C5=Md;function B5(r){return C5(r)?O5(r):N5(r)}var Ld=B5,P5=sA,M5=kg,L5=Ld;function U5(r){return P5(r,L5,M5)}var gA=U5,yA=gA,D5=1,$5=Object.prototype,F5=$5.hasOwnProperty;function H5(r,e,t,n,i,s){var o=t&D5,a=yA(r),u=a.length,l=yA(e),h=l.length;if(u!=h&&!o)return!1;for(var g=u;g--;){var b=a[g];if(!(o?b in e:F5.call(e,b)))return!1}var w=s.get(r),I=s.get(e);if(w&&I)return w==e&&I==r;var S=!0;s.set(r,e),s.set(e,r);for(var x=o;++g<u;){b=a[g];var C=r[b],H=e[b];if(n)var D=o?n(H,C,b,e,r,s):n(C,H,b,r,e,s);if(!(D===void 0?C===H||i(C,H,t,n,s):D)){S=!1;break}x||(x=b=="constructor")}if(S&&!x){var z=r.constructor,W=e.constructor;z!=W&&"constructor"in r&&"constructor"in e&&!(typeof z=="function"&&z instanceof z&&typeof W=="function"&&W instanceof W)&&(S=!1)}return s.delete(r),s.delete(e),S}var z5=H5,G5=fa,j5=Rn,K5=G5(j5,"DataView"),V5=K5,W5=fa,q5=Rn,Z5=W5(q5,"Promise"),Q5=Z5,Y5=fa,J5=Rn,X5=Y5(J5,"Set"),e4=X5,t4=fa,r4=Rn,n4=t4(r4,"WeakMap"),mA=n4,Pg=V5,Mg=xg,Lg=Q5,Ug=e4,Dg=mA,wA=la,Hc=Y_,bA="[object Map]",i4="[object Object]",_A="[object Promise]",AA="[object Set]",vA="[object WeakMap]",EA="[object DataView]",s4=Hc(Pg),o4=Hc(Mg),a4=Hc(Lg),c4=Hc(Ug),u4=Hc(Dg),ha=wA;(Pg&&ha(new Pg(new ArrayBuffer(1)))!=EA||Mg&&ha(new Mg)!=bA||Lg&&ha(Lg.resolve())!=_A||Ug&&ha(new Ug)!=AA||Dg&&ha(new Dg)!=vA)&&(ha=function(r){var e=wA(r),t=e==i4?r.constructor:void 0,n=t?Hc(t):"";if(n)switch(n){case s4:return EA;case o4:return bA;case a4:return _A;case c4:return AA;case u4:return vA}return e});var Ql=ha,$g=kd,l4=eA,f4=Z8,h4=z5,xA=Ql,RA=In,IA=Cd,d4=Cg,p4=1,SA="[object Arguments]",kA="[object Array]",Ud="[object Object]",g4=Object.prototype,TA=g4.hasOwnProperty;function y4(r,e,t,n,i,s){var o=RA(r),a=RA(e),u=o?kA:xA(r),l=a?kA:xA(e);u=u==SA?Ud:u,l=l==SA?Ud:l;var h=u==Ud,g=l==Ud,b=u==l;if(b&&IA(r)){if(!IA(e))return!1;o=!0,h=!1}if(b&&!h)return s||(s=new $g),o||d4(r)?l4(r,e,t,n,i,s):f4(r,e,u,t,n,i,s);if(!(t&p4)){var w=h&&TA.call(r,"__wrapped__"),I=g&&TA.call(e,"__wrapped__");if(w||I){var S=w?r.value():r,x=I?e.value():e;return s||(s=new $g),i(S,x,t,n,s)}}return b?(s||(s=new $g),h4(r,e,t,n,i,s)):!1}var m4=y4,w4=m4,OA=Xn;function NA(r,e,t,n,i){return r===e?!0:r==null||e==null||!OA(r)&&!OA(e)?r!==r&&e!==e:w4(r,e,t,n,NA,i)}var Fg=NA,b4=Fg;function _4(r,e){return b4(r,e)}var A4=_4;const v4=xn(A4),jr=[];for(let r=0;r<256;++r)jr.push((r+256).toString(16).slice(1));function E4(r,e=0){return(jr[r[e+0]]+jr[r[e+1]]+jr[r[e+2]]+jr[r[e+3]]+"-"+jr[r[e+4]]+jr[r[e+5]]+"-"+jr[r[e+6]]+jr[r[e+7]]+"-"+jr[r[e+8]]+jr[r[e+9]]+"-"+jr[r[e+10]]+jr[r[e+11]]+jr[r[e+12]]+jr[r[e+13]]+jr[r[e+14]]+jr[r[e+15]]).toLowerCase()}let Hg;const x4=new Uint8Array(16);function R4(){if(!Hg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Hg=crypto.getRandomValues.bind(crypto)}return Hg(x4)}const CA={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I4(r,e,t){if(CA.randomUUID&&!e&&!r)return CA.randomUUID();r=r||{};const n=r.random||(r.rng||R4)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,E4(n)}function zg(r){return new Promise(e=>{setTimeout(e,r)})}function BA(r,e,t,n){const i=new Map;return r.forEach(s=>{i.set(t(s),s)}),e.forEach(s=>{i.set(t(s),s)}),Array.from(i.values()).sort(n)}function Gg(r){return(r.startsWith("0x")?r.slice(2):r).toLowerCase()}class Ui{constructor(){}static getInstance(){return Ui.instance||(Ui.instance=new Ui),Ui.instance}formatMessage(e,...t){return`[${new Date().toISOString()}] [${e.toUpperCase()}] - ${t.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...e){console.log(this.formatMessage("log",...e))}info(...e){console.info(this.formatMessage("info",...e))}warn(...e){console.warn(this.formatMessage("warn",...e))}error(...e){console.error(this.formatMessage("error",...e))}debug(...e){console.debug(this.formatMessage("debug",...e))}}class Dd{constructor(){this.logger=Ui.getInstance()}handleError(e,t){const n=e instanceof Error?e.message:"Unknown error occurred",i=e instanceof Error?e.stack:null;this.logger.error(`Error in ${t||"unknown context"}: ${n}`,{stack:i})}}let S4=class{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,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){if(!this.events[e])return;const n=this.events[e].indexOf(t);n>-1&&this.events[e].splice(n,1)}cleanAll(){this.events={}}emit(e,t){this.events[e]&&this.events[e].forEach(n=>n(t))}};class jg{constructor(e={}){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.errorHandler=new Dd,this.clearWaitTime=e.clearWaitTime||500}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const e=this.tasks.shift();if(e)try{const t=e();t instanceof Promise&&await t}catch(t){this.errorHandler.handleError(t,"Queue.processQueue")}}this.isProcessing=!1}}enqueue(e){this.tasks.push(e),this.processQueue()}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await zg(this.clearWaitTime);return this.isWaiting=!1,!1}}var PA={};(function(r){var e;Object.defineProperty(r,"__esModule",{value:!0}),r.Vector=r.Cache=r.Assertions=r.Strings=r.Types=r.Objects=r.Dates=r.Promises=r.Numbers=r.System=r.Arrays=r.Random=r.Elliptic=r.Binary=r.AsyncQueue=r.PubSubChannel=r.FixedPointNumber=r.MerkleTree=r.Chunk=r.Uint8ArrayWriter=r.Uint8ArrayReader=r.AsyncLazy=r.Lazy=r.Optional=void 0;async function t(c){return new Promise((f,d)=>c.then(d,f))}async function n(c){return t(Promise.all(c.map(t)))}async function i(c,f=1){const d=BC(c,f),y=[],R=d.map(async L=>{for(const J of L)y.push(await J())});return await Promise.all(R),y}async function s(c){return new Promise(f=>setTimeout(()=>{f(!0)},c))}function o(c,f=Math.random){for(let d=c.length-1;d>0;d--){const y=Math.floor(f()*(d+1)),R=c[d];c[d]=c[y],c[y]=R}return c}function a(c){if(c.length===1)return c[0];throw Error(`Expected exactly one element, actual: ${c.length}`)}function u(c){return c.length===1?c[0]:null}function l(c){return c.length>0?c[0]:null}function h(c){if(!c.length)throw Error("Received empty array");return c[0]}function g(c,f){const d=[];for(let y=0;y<c;y++)d.push(f(y));return d}function b(c){const f=[];for(let d=0;d<c[0].length;d++){f.push([]);for(let y=0;y<c.length;y++)f[d].push(c[y][d])}return f}function w(c,f,d){const y=[];for(let R=0;R<c;R++){y.push([]);for(let L=0;L<f;L++)y[R].push(d)}return y}function I(c,f,d,y){if(d<0||y<0||y+f[0].length>c[0].length||d+f.length>c.length)return!1;for(let R=0;R<f.length;R++)for(let L=0;L<f[R].length;L++)if(f[R][L]!==void 0&&c[d+R][y+L]!==f[R][L])return!1;return!0}function S(c,f,d=Math.random){return o(tC(0,c.length-1),d).slice(0,f)}function x(c,f){return c.map(d=>d[f])}function C(c){let f=c,d=3405648695,y=3735928559;return function(){return f+=d,d^=f<<7,f*=y,y^=f<<13,f^=d^y,(f>>>0)/4294967296}}function H(c,f,d=Math.random){return Math.floor(d()*(f-c+1))+c}function D(c,f,d=Math.random){return d()*(f-c)+c}function z(){return Math.random()*2-1}function W(c,f,d){return f>=c.x&&f<c.x+c.width&&d>=c.y&&d<c.y+c.height}function Z(c,f,d,y=Math.random){let R,L;do R=H(0,c-1,y),L=H(0,f-1,y);while(d&&W(d,R,L));return[R,L]}function j(c,f=Math.random){const d=Math.floor(c),y=c-d;return V(y,f)?d+1:d}function V(c,f=Math.random){return f()<c}function oe(c,f=Math.random){return c[Math.floor(c.length*f())]}function ce(c,f,d=Math.random){if(f>c.length)throw new Error(`Count (${f}) is greater than array length (${c.length})`);return S(c,f,d).map(y=>c[y])}function ie(c,f,d,y=Math.random){if(f>c.length)throw new Error(`Count (${f}) is greater than array length (${c.length})`);const R=[];for(;R.length<f;){const L=oe(c,y);R.some(J=>d(J,L))||R.push(L)}return R}function ue(c,f,d,y,R,L=Math.random){const J=c.filter(fe=>fe!==f&&fe!==d),de=[];for(f!==null&&de.push(f);J.length&&de.length<y;){const fe=r.Random.intBetween(0,J.length-1,L);R(J[fe],de)&&de.push(J[fe]),J.splice(fe,1)}return o(de,L),{values:de,indexOfGuaranteed:f!==null?de.indexOf(f):-1}}function B(c){if(!c.length)throw Error("Received empty array");return c[c.length-1]}function p(c,f,d){return d(f.reduce((y,R)=>R(y),c))}function m(c,f){return d=>p(d,c,f)}function E(c,f,d){if(d===void 0&&(d=Math.random()),c.length!==f.length)throw new Error("Array length mismatch");let y=f.reduce((L,J)=>L+J,0);const R=d*y;for(let L=0;L<c.length-1;L++)if(y-=f[L],R>=y)return c[L];return B(c)}function k(c,f,d=Math.random){const y=f.map(L=>d()*L),R=[];for(let L=0;L<c.length;L++)R.push([c[L],y[L]]);return R.sort((L,J)=>J[1]-L[1]).map(L=>L[0])}function O(c,f){if(c==null)return null;const d=f.split(".");let y=c;for(const R of d){if(y[R]===null||y[R]===void 0)return null;y=y[R]}return y}function M(c,f,d){const y=f.split(/\.|\[/);let R=c;for(let L=0;L<y.length;L++){const J=y[L],de=L<y.length-1&&y[L+1].includes("]"),fe=J.includes("]")?J.replace(/\[|\]/g,""):J;if(L===y.length-1)return R[fe]=d,d;sr(R[fe])||(de?R[fe]=[]:R[fe]={}),R=R[fe]}return d}function G(c,f,d=1){const y=O(c,f)||0;return M(c,f,y+d),y}function P(c,f,d){return O(c,f)||M(c,f,d)}function A(c,f){const d=_b(f,"."),y=nC(f,".");if(!d||!y)return;const R=O(c,d);delete R[y]}function U(c,f,d){const y=O(c,f);if(!y)throw new Error("Key '"+f+"' does not exist.");return M(c,f,d),y}function le(c,f,d){for(const y of f){const R=O(c,y);if(R)return R}if(d){const y=Object.values(c);if(y.length)return y[0]}return null}async function te(c,f,d){for(;;){try{await c()}catch(y){d&&d("Error in forever",y)}await s(f)}}function re(c,f){c();const d=setInterval(()=>{c()},f);return()=>clearInterval(d)}function he(c){return c/1024/1024}function ye(c){return c>=1024*1024*1024*1024?(c/1024/1024/1024/1024).toFixed(3)+" TB":c>=1024*1024*1024?(c/1024/1024/1024).toFixed(3)+" GB":c>=1024*1024?(c/1024/1024).toFixed(3)+" MB":c>=1024?(c/1024).toFixed(3)+" KB":c+" B"}function be(c){const f=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c.toLowerCase());if(!f)throw new Error("Invalid hex color: "+c);return[parseInt(f[1],16),parseInt(f[2],16),parseInt(f[3],16)]}function Ve(c){return"#"+c.map(f=>f.toString(16).padStart(2,"0")).join("")}function Fe(c,f,d,y){const R=c*Math.PI/180,L=d*Math.PI/180,J=(d-c)*Math.PI/180,de=(y-f)*Math.PI/180,fe=Math.sin(J/2)*Math.sin(J/2)+Math.cos(R)*Math.cos(L)*Math.sin(de/2)*Math.sin(de/2);return 6371e3*(2*Math.atan2(Math.sqrt(fe),Math.sqrt(1-fe)))}function Be(c,f){return Math.round(c/f)*f}function et(c){return c>1e3?(c/1e3).toFixed(0)+" km":c>=500?Be(c,100)+" m":c>=100?Be(c,50)+" m":Be(c,10)+" m"}function Qe(c){return c*(c+1)/2}function ot(c){const f=c.match(/-?\d+(\.\d+)?/);if(!f)throw Error("No float found in "+c);return parseFloat(f[0])}function sr(c,f=!0){return!c||f&&!It(c._readableState)||f&&c.constructor&&(c.constructor.isBuffer||c.constructor.name=="Uint8Array"||c.constructor.name==="ArrayBuffer"||c.constructor.name==="ReadableStream")?!1:typeof c=="object"}function dt(c){return sr(c)&&!Array.isArray(c)}function Ut(c){return Array.isArray(c)&&c.length===0}function oa(c){return dt(c)&&Object.keys(c).length===0}function It(c){return c===void 0}function Ct(c){return Object.prototype.toString.call(c)==="[object Function]"||Object.prototype.toString.call(c)==="[object AsyncFunction]"}function kr(c){return Object.prototype.toString.call(c)==="[object String]"}function pt(c){return typeof c=="number"&&isFinite(c)}function St(c){return c===!0||c===!1}function or(c){return Object.prototype.toString.call(c)==="[object Date]"}function xt(c){return!kr(c)||c.trim().length===0}function Bt(c){return pt(c)&&Number.isInteger(c)&&c>=1}function fn(c){return kr(c)&&c.match(/^-?\d+$/)!==null}function Dt(c){return kr(c)&&c.match(/^(0x)?[0-9a-f]+$/i)!==null}const N="!@#$%^&*()_+-=[]{}|;:<>?,./",_="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),v="abcdefghijklmnopqrstuvwxyz",$="ABCDEFGHIJKLMNOPQRSTUVWXYZ",K="1234567890",Y=v+$+K,ae=Y+N,Ye=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],qe="0123456789abcdef";function We(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=v[Math.floor(f()*v.length)];return d}function $t(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=Y[Math.floor(f()*Y.length)];return d}function Ge(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=ae[Math.floor(f()*ae.length)];return d}function fr(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=Ye[Math.floor(f()*Ye.length)];return d}function tg(c,f){const d=new RegExp(`[0-9a-f]{${f}}`,"i"),y=c.match(d);return y?y[0]:null}function hr(c,f,d=_){const y=iC(c,d);for(const R of y)if(f(R))return R;return null}function dr(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=qe[Math.floor(f()*qe.length)];return d}function rg(c,f){if(!fn(c))throw new TypeError(`Expected integer string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=BigInt(c);if(f&&(f.min&&d<f.min||f.max&&d>f.max))throw RangeError(`Expected integer string${f!=null&&f.name?` for ${f.name}`:""} in range: ${f.min??"-inf"}..${f.max??"inf"}; got: `+d);return c}function ar(c,f){if(xt(c))throw new TypeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);if(f&&(f.min!==void 0&&c.length<f.min||f.max!==void 0&&c.length>f.max))throw RangeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""} length in range: ${f.min??"-inf"}..${f.max??"inf"}; got: ${c.length}`);return c}function pr(c,f){if(!Dt(c))throw new TypeError(`Expected hex string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=c.replace(/^0x/,"");if(f&&f.byteLength&&d.length!==f.byteLength*2)throw RangeError(`Expected hex string${f!=null&&f.name?` for ${f.name}`:""} of byte length ${f.byteLength}; got: `+d);return d}function ng(c,f){if(!ar(c,f).split("").every(d=>d==="_"||od(d)))throw new TypeError(`Expected safe string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function cr(c,f){if(f.min!==void 0&&c<f.min||f.max!==void 0&&c>f.max)throw RangeError(`Expected value${f!=null&&f.name?` for ${f.name}`:""} in range: ${f.min??"-inf"}..${f.max??"inf"}; got: ${c}`)}function gr(c,f){if(!Ct(c))throw new TypeError(`Expected function${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Oc(c,f){if(pt(c))return f&&cr(c,f),c;if(!kr(c)||!c.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=parseFloat(c);return f&&cr(d,f),d}function Jt(c,f){return Oc(c,f)|0}function yr(c,f){if(c==="true")return!0;if(c==="false")return!1;if(!St(c))throw new TypeError(`Expected boolean${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function ig(c,f){if(!or(c))throw new TypeError(`Expected date${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function mr(c){return xt(c)?null:c}function wr(c,f){if(!kr(c))throw new TypeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function sg(c,f){if(Bt(c))return c;const d=parseInt(c,10);if(!Bt(d))throw new TypeError(`Expected id${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function br(c,f){if(!kr(c))throw new TypeError(`Expected time${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=c.split(":");if(d.length!==2)throw new TypeError(`Expected time${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const y=parseInt(d[0],10),R=parseInt(d[1],10);if(!pt(y)||!pt(R)||y<0||y>23||R<0||R>59)throw new TypeError(`Expected time, got${f!=null&&f.name?` for ${f.name}`:""}: `+c);return`${String(y).padStart(2,"0")}:${String(R).padStart(2,"0")}`}function _r(c,f){if(!Array.isArray(c))throw new TypeError(`Expected array${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Nc(c,f){if(!dt(c))throw new TypeError(`Expected object${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Ar(c,f){return c===null?null:Nc(c,f)}function vr(c,f){const d=Nc(c,f);for(const y of Object.keys(d))if(!kr(d[y]))throw new TypeError(`Expected string map${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function Vh(c,f){const d=Nc(c),y=Object.keys(d),R=Object.values(d);if(!y.every(kr)||!R.every(pt))throw new TypeError(`Expected numeric dictionary${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function Dl(c){return kr(c)&&c.match(/^https?:\/\/.+/)!==null}function Wh(c,f){if(!Dl(c))throw new TypeError(`Expected url${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function qh(c,f){return f==null?!0:c(f)}function Zh(c,f){return f==null?null:c(f)}function Qh(c,f){return f==null?void 0:c(f)}function $l(c,f){for(const[d,y]of Object.entries(f))if(!y(c[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(c))if(!f[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function Yh(c,f){return c.every(d=>$l(d,f))}function so(c,f="json",d=0){if(sr(c,!1)){if(d>1)return"[object Object]";if(f==="json"){if(Array.isArray(c)){const R=c.map(L=>so(L,"json",d+1));return d===0?JSON.stringify(R):R}const y={};c.message&&(y.message=so(c.message,"json",d+1));for(const[R,L]of Object.entries(c))y[R]=so(L,"json",d+1);return d===0?JSON.stringify(y):y}else if(f==="key-value"){const y=Object.keys(c);return c.message&&!y.includes("message")&&y.unshift("message"),y.map(R=>`${R}=${JSON.stringify(so(c[R],"json",d+1))}`).join(" ")}}return It(c)&&(c="undefined"),d===0?JSON.stringify(c):c}function Jh(c,f){if(kr(c))return c;const d=Object.keys(c);c.message&&!d.includes("message")&&d.push("message");const y=d.map(R=>`${R}: ${c[R]}`).join("; ");return f&&c.stack?y+`
2
+ `+c.stack:y}function Li(c,f){if(dt(c)&&dt(f))for(const d in f)dt(f[d])?(c[d]||(c[d]={}),Li(c[d],f[d])):Array.isArray(f[d])?c[d]=[...f[d]]:(f[d]!==null&&f[d]!==void 0||c[d]===null||c[d]===void 0)&&(c[d]=f[d]);return c}function Xh(c,f){const d={};return Li(d,c),Li(d,f),d}function ed(c,f,d){const y={};return Li(y,c),Li(y,f),Li(y,d),y}function Fl(c,f){const d={};for(const y of c)for(const R of Object.keys(y))d[R]?d[R]=f(d[R],y[R]):d[R]=y[R];return d}function td(c){return Fl(c,(f,d)=>f+d)}function rd(c,f,d){c[f]||(c[f]=[]),c[f].push(d)}function nd(c,f,d){for(c.unshift(f);c.length>d;)c.pop()}function id(c,f){let d=f%c.length;return d<0&&(d+=c.length),c[d]}function aa(c,f){Array.prototype.push.apply(c,f)}function ene(c,f){Array.prototype.unshift.apply(c,f)}async function tne(c,f){const d=[];for(const y of c)d.push(await f(y));return d}function rne(c,f){const d=[];for(let y=0;y<c.length;y++)d.push(c[y]),y<c.length-1&&(Ct(f)?d.push(f()):d.push(f));return d}function nne(c,f){if(c!==f)throw Error(`Expected [${c}] to equal [${f}]`);return[c,f]}function ine(c){if(c!==!0)throw Error(`Expected [true], got: [${c}]`);return c}function sne(c){if(!c)throw Error(`Expected truthy value, got: [${c}]`);return c}function one(c){if(c!==!1)throw Error(`Expected [false], got: [${c}]`);return c}function ane(c){if(c)throw Error(`Expected falsy value, got: [${c}]`);return c}function cne(c,f){if(!f.includes(c))throw Error(`Expected any of [${f.join(", ")}], got: [${c}]`);return c}function une(c,f){for(let d=0;d<c.length;d++){const y=c[d],R=f[d],L=Math.max(0,R.getTime()-Date.now());setTimeout(y,L)}}function lne(c,f,d){return c+(f-c)*d}function fne(c){return c.reduce((f,d)=>f+d,0)}function hne(c){return c.reduce((f,d)=>f+d,0)/c.length}function dne(c){const f=[...c].sort((y,R)=>y-R),d=Math.floor(f.length/2);return f.length%2===0?(f[d]+f[d-1])/2:f[d]}function pne(c,f){return c-(f-1)/2}function tC(c,f){const d=[];for(let y=c;y<=f;y++)d.push(y);return d}function gne(c,f){return f.some(d=>c.includes(d))}function yne(c){return/^[\u4E00-\u9FA5]+$/.test(c)}function wb(c,f=()=>!1){return c.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(d=>/[a-z0-9]/.test(d)||f(d)?d:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function mne(c){return wb(c).replaceAll("-","")}function wne(c){return ag(c.replace(/([A-Z])/g," $1"))}function bne(c){return c.split("-").map(ag).join(" ")}function _ne(c){return oC(c.split("-").map(ag).join(""))}function Ane(c,f=", ",d=" and "){return!c||!c.length?"":c.length===1?c[0]:c.length===2?`${c[0]}${d}${c[1]}`:`${c.slice(0,c.length-1).join(f)}${d}${c[c.length-1]}`}function vne(c,f){return f+c.split("").join(f)+f}function Ene(c){return wb(c).replace(/-/g,"_").toUpperCase()}function og(c,f){if(f.length===0)return 0;const d=c.toLowerCase(),y=f.toLowerCase();return c===f?1e4:d.startsWith(y)?1e4-c.length:d.includes(y)?5e3-c.length:new RegExp(".*"+y.split("").join(".*")+".*").test(d)?1e3-c.length:0}function xne(c,f){return c.filter(d=>og(d,f)).sort((d,y)=>og(y,f)-og(d,f))}function Rne(c){return c.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Ine={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function Sne(c){let f=c.replace(/&#(\d+);/g,(d,y)=>String.fromCharCode(y)).replace(/&#x(\d+);/g,(d,y)=>String.fromCharCode(parseInt(y,16)));for(const[d,y]of Object.entries(Ine))f=f.replaceAll(d,y);return f}function rC(c,f){const d=c.indexOf(f);return d===-1?null:c.slice(0,d)}function bb(c,f){const d=c.indexOf(f);return d===-1?null:c.slice(d+f.length)}function _b(c,f){const d=c.lastIndexOf(f);return d===-1?null:c.slice(0,d)}function nC(c,f){const d=c.lastIndexOf(f);return d===-1?null:c.slice(d+f.length)}function kne(c,f,d){const y=_b(c,d);return y?bb(y,f):null}function Tne(c,f,d){const y=bb(c,f);return y?rC(y,d):null}function Ab(c,f,d=!1){const y=d?c.lastIndexOf(f):c.indexOf(f);return y===-1?d?[null,c]:[c,null]:[c.slice(0,y),c.slice(y+f.length)]}function iC(c,f){let d=[c];for(const y of f)d=d.flatMap(R=>R.split(y));return d.filter(y=>y)}function vb(c){const f=B(c.split(/\\|\//g)),d=f.lastIndexOf(".",f.length-1);return d<=0?"":f.slice(d+1)}function Eb(c){const f=B(c.split(/\\|\//g)),d=f.lastIndexOf(".",f.length-1);return d<=0?f:f.slice(0,d)}function One(c){let[f,d]=c.split("@");f=sd(f.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[y]=f.split("+");if(!y||!d||d.indexOf(".")===-1||d.indexOf(".")===d.length-1)throw new Error("Invalid email");return d=sd(d.toLowerCase()).replaceAll(" ",""),`${y}@${d}`}function Nne(c){const f=Eb(c),d=vb(c);return d?`${f}.${d}`:f}function Cne(c){const f=Eb(c),d=vb(c);return{basename:f,extension:d,filename:d?`${f}.${d}`:f}}function Bne(c,f=Math.random){return c.replace(/\{(.+?)\}/g,(d,y)=>oe(y.split("|"),f))}function sC(c){const f=/\{(.+?)\}/,d=c.match(f);if(!d||!d.index)return[c];const y=d[1].split(","),R=c.slice(0,d.index),L=c.slice(d.index+d[0].length);let J=[];for(const de of y){const fe=sC(R+de+L);J=J.concat(fe)}return J}function sd(c){return c.split(`
3
+ `).map(f=>f.trim().replace(/\s+/g," ")).filter(f=>f.length>0).join(`
4
+ `)}function ag(c){return c.charAt(0).toUpperCase()+c.slice(1)}function oC(c){return c.charAt(0).toLowerCase()+c.slice(1)}function aC(c){if(!c)return!1;const f=c.charCodeAt(0);return f>=65&&f<=90||f>=97&&f<=122}function cC(c){if(!c)return!1;const f=c.charCodeAt(0);return f>=48&&f<=57}function od(c){return aC(c)||cC(c)}const Pne=`
5
+ \r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function Mne(c){return Pne.includes(c)}function Lne(c){return od(c)||c==="."||c==="["||c==="]"||c==="_"}function Une(c,f,d,y,R){return c.slice(0,f)+y+c.slice(f,f+d)+R+c.slice(f+d)}function uC(c,f,d=0){const y=f.exec(c.slice(d));return y?{index:y.index,match:y[0]}:null}function lC(c,f,d=!0){if(!d)return f.every(R=>R instanceof RegExp?R.test(c):c.indexOf(R,0)!==-1);let y=0;for(const R of f)if(R instanceof RegExp){const L=uC(c,R,y);if(!L)return!1;y=L.index+L.match.length}else{const L=c.indexOf(R,y);if(L===-1)return!1;y=L+R.length}return!0}function Dne(c,f,d=!0){let y=0;for(const R of f){let L=!1;for(;!L&&y<c.length;)lC(c[y],R,d)&&(L=!0),y++;if(!L)return!1}return!0}function $ne(c){return c.match(/"|,/)?`"${c.replace(/"/g,'""')}"`:c}function Hl(c,f,d=0){let y=-1;for(const R of f){const L=c.indexOf(R,d);L!==-1&&(y===-1||L<y)&&(y=L)}return y}function Fne(c,f=0){for(let d=f;d<c.length;d++)if(Mne(c[d]))return d;return-1}function Hne(c,f=0){for(let d=f;d<c.length;d++)if(c[d]==="#"&&od(c[d+1]))return d;return-1}function fC(c,f,d=0){return c.slice(0,d).lastIndexOf(f)}function hC(c,f=0,d="{",y="}"){let R=1;for(let L=f;L<c.length;L++)if(c.slice(L,L+y.length)===y){if(--R===0)return L}else c.slice(L,L+d.length)===d&&R++;return-1}function dC(c,f){const d=f.wordBoundary?Hl(c,[`${f.opening} `,`${f.opening}
6
+ `],f.start||0):c.indexOf(f.opening,f.start||0);if(d===-1)return null;const y=hC(c,d+f.opening.length,f.opening,f.closing);return y===-1?null:f.exclusive?c.slice(d+f.opening.length,y):c.slice(d,y+f.closing.length)}function zne(c,f){const d=[];let y=f.wordBoundary?Hl(c,[`${f.opening} `,`${f.opening}
7
+ `],f.start||0):c.indexOf(f.opening,f.start||0);for(;;){if(y===-1)return d;const R=dC(c,{...f,start:y});if(!R)return d;d.push(R),y=f.wordBoundary?Hl(c,[`${f.opening} `,`${f.opening}
8
+ `],y+R.length):c.indexOf(f.opening,y+R.length)}}function Gne(c,f,d){let y=0;for(;;){const R=r.Strings.extractBlock(c,{...d,start:y});if(!R)return c;const L=f(R);y=c.indexOf(R,y)+L.length,c=c.replace(R,L)}}function jne(c,f){const d=[];let y=0;for(;y<c.length;){const R=c.indexOf(f,y);if(R===-1){d.push({string:c.slice(y),symbol:null});break}const L=c.indexOf(f,R+f.length);if(R>y&&L!==-1&&d.push({string:c.slice(y,R),symbol:null}),L===-1){d.push({string:c.slice(y),symbol:null});break}d.push({string:c.slice(R+f.length,L),symbol:f}),y=L+f.length}return d}function Kne(c){const f=[];let d=0;for(;d<c.length;){const y=Hne(c,d);if(y===-1){f.push({string:c.slice(d),symbol:null});break}const R=Fne(c,y+1);if(R===-1){f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y+1),symbol:"#"});break}y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y+1,R),symbol:"#"}),d=R}return f}function Vne(c){const f=[];let d=0;for(;d<c.length;){const y=Hl(c,["http://","https://"],d);if(y===-1){f.push({string:c.slice(d),symbol:null});break}const R=Hl(c,[" ",`
9
+ `],y);if(R===-1){y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y),symbol:"http"});break}y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y,R),symbol:"http"}),d=R}return f}const pC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gC="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Wne(c){return yC(c,pC)}function qne(c){return mC(c,pC)}function Zne(c){return yC(c,gC)}function Qne(c){return mC(c,gC)}function yC(c,f){const d="=",y=f.length;let R=0,L=0;const J=[];for(let de=0;de<c.length;de++){const fe=c[de];if(fe===d)break;const De=f.indexOf(fe);if(De===-1)throw new Error(`Invalid character: ${fe}`);L=L<<Math.log2(y)|De,R+=Math.log2(y),R>=8&&(R-=8,J.push(L>>R&255))}return new Uint8Array(J)}function mC(c,f){const d=f.length;let y=0,R=0,L="";for(let J=0;J<c.length;J++)for(R=R<<8|c[J],y+=8;y>=Math.log2(d);)y-=Math.log2(d),L+=f[R>>y&d-1];return y>0&&(L+=f[R<<Math.log2(d)-y&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function Yne(c){c.startsWith("0x")&&(c=c.slice(2));const f=c.length/2,d=new Uint8Array(f);for(let y=0;y<f;y++){const R=parseInt(c.slice(y*2,y*2+2),16);d[y]=R}return d}function Jne(c){return Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join("")}function Xne(c,f){const d=c.split("/").filter(L=>L),y=f.split("/").filter(L=>L);if(d.length!==y.length)return null;const R={};for(let L=0;L<d.length;L++){const J=d[L];if(J.startsWith(":"))R[J.slice(1)]=y[L];else if(J!==y[L])return null}return R}function xb(c,f,d){const y=[];for(const R of d)R!==f&&y.push(c.replace(f,R));return y}function eie(c,f,d,y=Math.random){const R=r.Arrays.shuffle(f.map(J=>({variants:r.Arrays.shuffle(J.variants.map(de=>de),y),avoid:J.avoid})),y),L=[];for(const J of R){const de=J.variants.filter(De=>De!==J.avoid),fe=de.find(De=>c.includes(De));if(fe&&(aa(L,xb(c,fe,de)),L.length>=d))break}if(L.length<d)for(const J of R){const de=J.variants.find(fe=>c.includes(fe));if(de&&(aa(L,xb(c,de,J.variants)),L.length>=d))break}return L.slice(0,d)}function tie(c,f,d,y=!1){const R=new RegExp(y?`(?<=\\s|^)${f}(?=\\s|$)`:`\\b${f}\\b`,"g");return c.replace(R,d)}function rie(c,f){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return c.replace(d,y=>y.toUpperCase()===y?y:f(y))}function nie(c){return c.replace(/<[^>]*>/g,"")}function wC(c){const f=c.lastIndexOf(" ");if(f===-1)return{line:c,rest:""};const d=c.slice(0,f),y=c.slice(f+1);return{line:d,rest:y}}function iie(c,f={}){return[...c].reduce((d,y)=>d+(f[y]||1),0)}function sie(c,f,d={}){const y=[];let R="",L=0;for(let J=0;J<c.length;J++){const de=c[J],fe=d[de]||1;if(R+=de,L+=fe,L>f){const{line:De,rest:Lt}=wC(R);y.push(De),R=Lt,L=Lt.split("").map(Gr=>d[Gr]||1).reduce((Gr,Kl)=>Gr+Kl,0)}}return R&&y.push(R),y}function oie(c,f){const d=[];for(let y=0;y<=c.length;y++)d[y]=[y];for(let y=0;y<=f.length;y++)d[0][y]=y;for(let y=1;y<=c.length;y++)for(let R=1;R<=f.length;R++){const L=c[y-1]===f[R-1]?0:1;d[y][R]=Math.min(d[y-1][R]+1,d[y][R-1]+1,d[y-1][R-1]+L)}return d[c.length][f.length]}function Rb(c,f){return new RegExp(`\\b${f}\\b`).test(c)}function aie(c,f,d){return d==="any"?f.some(y=>Rb(c,y)):f.every(y=>Rb(c,y))}function cie(c){const f={},d=c.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const y of d){const[R,L]=Ab(y,"=");f[R]=L.slice(1,L.length-1)}return f}function cg(c,f,d=[]){let y="";for(;f<c.length&&(od(c[f])||d.includes(c[f]));)y+=c[f++];return y}function uie(c,f,d="$",y=":"){for(const R in f)c=bC(c,R,f[R],d,y);return c=_C(c),c}function bC(c,f,d,y="$",R=":"){if(d==="")return c;let L=c.indexOf(`${y}${f}`);for(;L!==-1;){if(c[L+f.length+1]===R)if(c[L+f.length+2]===R)c=c.replace(`${y}${f}${R}${R}`,d);else{const J=cg(c,L+f.length+2,["_"]);c=c.replace(`${y}${f}${R}${J}`,d)}else c=c.replace(`${y}${f}`,d);L=c.indexOf(`${y}${f}`,L+d.length)}return c}function _C(c,f="$",d=":"){let y=c.indexOf(f);for(;y!==-1;){const R=cg(c,y+1);if(c[y+R.length+1]===d)if(c[y+R.length+2]===d)c=c.replace(`${f}${R}${d}${d}`,"");else{const L=cg(c,y+R.length+2);c=c.replace(`${f}${R}${d}${L}`,L)}y=c.indexOf(f,y+1)}return c}function lie(c,f){let d=c.indexOf("](");for(;d!==-1;){const y=fC(c,"[",d),R=c.indexOf(")",d);if(y!==-1&&R!==-1){const[L,J]=c.slice(y+1,R).split("]("),de=f(L,J);c=c.slice(0,y)+de+c.slice(R+1)}d=c.indexOf("](",d+1)}return c}function AC(c,f=!0){const d=Object.entries(c).filter(([y,R])=>R!=null).map(([y,R])=>`${y}=${encodeURIComponent(R)}`).join("&");return d?(f?"?":"")+d:""}function fie(c){const f={},d=c.split("&");for(const y of d){const[R,L]=y.split("=");R&&L&&(f[R]=decodeURIComponent(L))}return f}function hie(c,f){return Object.prototype.hasOwnProperty.call(c,f)}function die(c,f){let d=null,y=-1/0;for(const[R,L]of Object.entries(c)){const J=f(L);J>y&&(y=J,d=R)}return d?[d,c[d]]:null}function pie(c,f,d,y){const R=c.find(J=>J[f]===d),L=c.find(J=>J[f]===d+y);R&&L?(R[f]=d+y,L[f]=d):R&&(R[f]=d+y),c.sort((J,de)=>Oc(J[f])-Oc(de[f])),c.forEach((J,de)=>J[f]=de+1)}function gie(c){const f=Object.keys(c);if(f.length===1)return c[f[0]];throw new Error("Expected object to have a single key")}function yie(c,f=":"){return Object.fromEntries(c.map(d=>Ab(d,f)).map(d=>d[0]&&d[1]?[sd(d[0]),sd(d[1])]:null).filter(d=>d))}function mie(c,f,d){return RC(c,f)+AC(d||{})}function wie(c,f=",",d='"'){const y=[];let R="",L=!1;const J=c.split("");for(const de of J)de===f&&!L?(y.push(R),R=""):de===d&&(!R&&!L||L)?L=!L:R+=de;return y.push(R),y}function bie(c){return`[${Math.floor(c.progress*100)}%] ${ug(c.deltaMs)} out of ${ug(c.totalTimeMs)} (${ug(c.remainingTimeMs)} left) [${Math.round(c.baseTimeMs)} ms each]`}async function _ie(c,f,d){for(let y=0;y<d;y++){try{if(await c())return!0}catch{}y<d-1&&await s(f)}return!1}function Aie(c,f){const d=[];for(let y=c.length-1;y>=0;y--)f(c[y])&&d.push(c.splice(y,1)[0]);return d}function vie(c){return JSON.parse(JSON.stringify(c))}function Eie(c){return Math.ceil((c||Date.now())/1e3)}function xie(c){return(c||new Date).toISOString().slice(0,10)}function Rie(c){return(c||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function Iie(c){const f=new Date(c);return new Date(f.getTime()-f.getTimezoneOffset()*6e4)}function Sie(c){return new Date(c)}function ms(c){return String(Math.floor(c)).padStart(2,"0")}function kie(c){let[f,d]=c.split(":");pt(parseInt(f,10))||(f="0"),pt(parseInt(d,10))||(d="0");let y=Ob(Jt(f),0,23),R=Ob(Jt(d),0,59);return`${ms(y)}:${ms(R)}`}function ug(c){const f=Math.floor(c/36e5);c=c%36e5;const d=Math.floor(c/6e4);c=c%6e4;const y=Math.floor(c/1e3);return f?`${ms(f)}:${ms(d)}:${ms(y)}`:`${ms(d)}:${ms(y)}`}function Cc(c){return Math.floor((or(c)?c.getTime():c)/864e5)}const Tie={today:(c,f)=>ms(c)+":"+ms(f),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:c=>`${c}w`};function Oie(c,f){const d=new Date((f==null?void 0:f.now)||Date.now()),y=(f==null?void 0:f.labels)||Tie,R=or(c)?c:new Date(c);if(Cc(d)===Cc(R))return y.today(R.getUTCHours(),R.getUTCMinutes(),R.getUTCHours()>12);if(Cc(d)-Cc(R)===1)return y.yesterday();const L=Sb(R);return Cc(d)-Cc(R)<7?y[L.day]():y.weeks(Math.round((d.getTime()-R.getTime())/6048e5))}const vC={now:()=>"A few seconds",seconds:c=>`${c} seconds`,minutes:c=>`${c} minutes`,hours:c=>`${c} hours`,days:c=>`${c} days`,weeks:c=>`${c} weeks`};function EC(c,f){const d=(f==null?void 0:f.now)??Date.now(),y=(f==null?void 0:f.labels)||vC,R=r.Types.isDate(c)?c.getTime():c;let L=(d-R)/1e3;return L<10?y.now():L<120?y.seconds(Math.floor(L)):(L/=60,L<120?y.minutes(Math.floor(L)):(L/=60,L<48?y.hours(Math.floor(L)):(L/=24,L<14?y.days(Math.floor(L)):(L/=7,y.weeks(Math.floor(L))))))}function Nie(c,f=vC){return EC(0,{now:c*1e3,labels:f})}function Cie(c,f,d){const y=((d==null?void 0:d.now)??Date.now())-c,R=Math.floor(y/f),L=f/((d==null?void 0:d.precision)??1)-Math.ceil(y%f/((d==null?void 0:d.precision)??1));return{cycles:R,remaining:L}}const Ib={};function Bie(c,f){return!Ib[c]||Date.now()>Ib[c]?(Ib[c]=Date.now()+f,!0):!1}const Pie={s:1e3,m:6e4,h:36e5,d:864e5};function Mie(c,f,d){return f=or(f)?f.getTime():f,d=d?or(d)?d.getTime():d:Date.now(),(d-f)/Pie[c]}function Lie(c,f,d,y){y||(y=Date.now());const R=f/d,L=y-c,J=L/f,de=J*d,fe=de-L;return{deltaMs:L,progress:R,baseTimeMs:J,totalTimeMs:de,remainingTimeMs:fe}}const Uie={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function xC(c){return{zeroBasedIndex:c,day:Uie[c]}}function Sb(c){return xC(c.getDay())}function Die(c){return Sb(new Date(c))}function $ie(c){return c*1e3}function Fie(c){return c*6e4}function Hie(c){return c*36e5}function zie(c){return c*864e5}const Gie={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function jie(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=Gie[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}const Kie={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function Vie(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=Kie[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}function Wie(c){return c.replace(/ +/g," ").replace(/^ /gm,"")}const kb={};async function qie(c,f,d){const y=Date.now(),R=kb[c];if(R&&R.validUntil>y)return R.value;const L=await d(),J=y+f;return kb[c]={value:L,validUntil:J},L}function Zie(c){delete kb[c]}function RC(...c){return c.filter(f=>f).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function Qie(c,f,d,y,R=!0){const L=c.indexOf(f),J=c.indexOf(d,L+f.length);if(L===-1||J===-1)throw Error("Start or end not found");return R?c.substring(0,L+f.length)+y+c.substring(J):c.substring(0,L)+y+c.substring(J+d.length)}function Yie(c){let f="p";c.startsWith("#")?(f="h1",c=c.slice(1).trim()):c.startsWith("-")&&(f="li",c=c.slice(1).trim());const d=c[0]===c[0].toUpperCase(),y=/[.?!]$/.test(c),R=/:$/.test(c);return{type:f,isCapitalized:d,hasPunctuation:y,endsWithColon:R}}function Jie(c,f="(",d=")"){let y=0,R=0;for(;R<c.length;)if(c.startsWith(f,R)?(y++,R+=f.length):c.startsWith(d,R)?(y--,R+=d.length):R++,y<0)return!1;return f===d?y%2===0:y===0}function Xie(c){c=c.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let f=c.length;for(;c=c.replace(/(\w+)[\s,']+\w+/g,"$1"),c.length!==f;)f=c.length;return c=c.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),c=c.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),c=c.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),c}function IC(c){const f=Object.keys(c).sort((y,R)=>y.localeCompare(R)),d={};for(const y of f)d[y]=Bc(c[y]);return d}function SC(c){const f=[];return c.sort((d,y)=>JSON.stringify(Bc(d)).localeCompare(JSON.stringify(Bc(y)))).forEach(d=>f.push(Bc(d))),f}function Bc(c){return Array.isArray(c)?SC(c):sr(c)?IC(c):c}function kC(c,f){return JSON.stringify(Bc(c))===JSON.stringify(Bc(f))}function ese(...c){for(let f=1;f<c.length;f++)if(!kC(c[f-1],c[f]))return!1;return!0}function tse(c){try{return JSON.parse(c)}catch{return null}}function rse(){let c=0;return{next:()=>c++}}function nse(c){let f=0;return{next:()=>c[f++%c.length]}}function ise(c){let f;return d=>{const y=d===c&&f!==c;return f=d,y}}function sse(c,f,d,y,R){const L={};for(const J of Object.keys(f))L[J]=[];L[y]=[],R&&(c=c.sort(R));for(const J of c){const de=J[d],fe=f[de]?de:y;L[fe].length>=f[fe]?L[y].push(J):L[fe].push(J)}return L}function ose(c,f){const d=Object.keys(c),y=Object.keys(f);return{uniqueToA:d.filter(R=>!y.includes(R)),uniqueToB:y.filter(R=>!d.includes(R))}}function TC(c){const f=Object.keys(c);return f[Math.floor(Math.random()*f.length)]}function ase(c,f){const d=TC(c);return c[d]=f(c[d]),d}function cse(c){return c=c.replace(/\r\n/g,`
10
+ `),c=c.replace(/(\w+)\((.+)\)/g,(f,d,y)=>`${d}(${y.replaceAll(",","&comma;")})`),c=c.replace(/(,)(\s+})/g,"$2"),c=c.replace(/\.\.\..+?,/g,""),c=c.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/:(.+)\?(.+):/g,(f,d,y)=>`: (${d.trim()} && ${y.trim()}) ||`),c=c.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),c=c.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(f,d,y,R)=>`"${d}":"${y.trim()}"${R}`),c=c.replace(/("'|'")/g,'"'),c=c.replaceAll("&comma;",","),JSON.parse(c)}const ca=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],use=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],OC=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function lse(c,f,d){let y=c.length-f;if(y<=0)return"0."+"0".repeat(-y)+c+(d?" "+d:"");let R=c.substring(0,y),L=c.substring(y);return R===""&&(R="0"),R+"."+L+(d?" "+d:"")}function fse(c,f){const d=(f==null?void 0:f.longForm)??!1,y=f!=null&&f.unit?` ${f.unit}`:"",R=d?use:OC,L=(f==null?void 0:f.precision)??1;if(c<ca[0])return`${c}${y}`;for(let J=0;J<ca.length-1;J++)if(c<ca[J+1])return`${(c/ca[J]).toFixed(L)}${d?" ":""}${R[J]}${y}`;return`${(c/ca[ca.length-1]).toFixed(L)}${d?" ":""}${R[ca.length-1]}${y}`}function Tb(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeNumber got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim(),y=OC.findIndex(R=>R.toLowerCase()===d.toLowerCase());return y===-1?f:f*ca[y]}function Ob(c,f,d){return c<f?f:c>d?d:c}function hse(c,f,d){const y=c+f;return y>d?d:y}function dse(c,f,d){const y=c-f;return y<d?d:y}function pse(c,f){return f(c),c}function gse(c,f){c&&f(c)}function yse(c,f){const d=Object.keys(f);for(const y of d)Array.isArray(f[y])&&Array.isArray(c[y])&&aa(c[y],f[y])}function mse(c){return c.splice(0,c.length),c}function wse(c){for(const f of Object.keys(c))(Ut(c[f])||Array.isArray(c[f])&&c[f].every(d=>d==null))&&delete c[f];return c}function bse(c){for(const f of Object.entries(c))(f[1]===null||f[1]===void 0||kr(f[1])&&xt(f[1]))&&delete c[f[0]];return c}function _se(c,f){const d={};for(const[y,R]of Object.entries(c))f(y)&&(d[y]=R);return d}function Ase(c,f){const d={};for(const[y,R]of Object.entries(c))f(R)&&(d[y]=R);return d}function vse(c,f){const d={};for(const y of Object.entries(c))d[y[0]]=f(y[1]);return d}function Ese(c,f){const d=[];let y=0;for(const R of c)d.push(f(R,y++));return d}async function xse(c,f){try{return await c()}catch{throw f}}function Rse(c,f,d){d!=null&&(c[f]=d)}function Ise(c,f,d,y){const R=O(d,y);R!=null&&M(c,f,R)}function Sse(c){const f={};for(const[d,y]of Object.entries(c))f[y]=d;return f}function kse(c){const f=Object.keys(c),d=f.map(de=>c[de].length),y=d.reduce((de,fe)=>de*=fe);let R=1;const L=[1];for(let de=0;de<d.length-1;de++)R*=d[de],L.push(R);const J=[];for(let de=0;de<y;de++){const fe={};for(let De=0;De<f.length;De++){const Lt=c[f[De]],Gr=Math.floor(de/L[De])%Lt.length;fe[f[De]]=Lt[Gr]}J.push(fe)}return J}function Tse(c){return Object.values(c).filter(f=>f).length}function Ose(c,f,d){return c+(d?"["+f+"]":(c.length?".":"")+f)}function lg(c,f,d,y,R){if(!sr(f))return f;for(const[L,J]of Object.entries(f)){const de=Ose(d,L,y);Array.isArray(J)?R?lg(c,J,de,!0,R):c[de]=J.map(fe=>lg(Array.isArray(fe)?[]:{},fe,"",!1,R)):sr(J)?lg(c,J,de,!1,R):c[de]=J}return c}function Nse(c,f=!1,d){return lg({},c,d||"",!1,f)}function NC(c){if(!sr(c))return c;const f=Array.isArray(c)?[]:{};for(const[d,y]of Object.entries(c))Array.isArray(y)?M(f,d,y.map(R=>NC(R))):M(f,d,y);return f}function Cse(c,f,d){return f[c]?f[c]:d}function CC(c,f){const d={};for(const y of c){const R=f(y);d[R]=y}return d}function Bse(c,f){const d={};for(const y of c){const R=f(y);d[R]||(d[R]=[]),d[R].push(y)}return d}function Pse(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.slice(y,y+f));return d}function BC(c,f){const d=Math.ceil(c.length/f),y=[];for(let R=0;R<c.length;R+=d)y.push(c.slice(R,R+d));return y}function PC(c,f){const d=[],y=Math.ceil(c.length/f);for(let R=0;R<y;R++)d.push(c.slice(R*f,R*f+f));return d}function Mse(c,f){const d=Math.ceil(c.length/f);return PC(c,d)}function Lse(c,f){return Object.values(CC(c,f))}function Use(c,f,d,y,R){const L=f?c.map(f):c,J={};for(const fe of L)J[fe]=(J[fe]||0)+1;const de=y?MC(J,R?(fe,De)=>fe[1]-De[1]:(fe,De)=>De[1]-fe[1]):J;return d?Object.keys(de):de}function MC(c,f){return Object.fromEntries(Object.entries(c).sort(f))}function Dse(c){const f=[],d=Object.keys(c),y=c[d[0]].length;for(let R=0;R<y;R++){const L={};for(const J of d)L[J]=c[J][R];f.push(L)}return f}function $se(c,f,d=1){for(const y of c)y[f]+=d}function Fse(c,f,d){for(const y of c)y[f]=d}function Nb(c,f){const d=[];let y=[];return c.forEach((R,L)=>{(L===0||!f(R,c[L-1]))&&(y=[],d.push(y)),y.push(R)}),d}function Hse(){return{map:new Map,keys:[]}}function zse(){return{map:new Map,keys:[]}}function LC(c,f,d,y=100){if(c.map.has(f)){const R=c.keys.indexOf(f);c.keys.splice(R,1)}if(c.map.set(f,d),c.keys.push(f),c.keys.length>y){const R=c.keys.shift();R&&c.map.delete(R)}}function Gse(c,f,d,y=100){if(c.map.has(f)){const R=c.keys.indexOf(f);c.keys.splice(R,1)}if(c.map.set(f,d),c.keys.unshift(f),c.keys.length>y){const R=c.keys.shift();R&&c.map.delete(R)}}function jse(c,f,d,y,R=100){LC(c,f,{validUntil:Date.now()+y,data:d},R)}function Kse(c,f){const d=c.map.get(f);return d&&d.validUntil>Date.now()?d.data:null}class ua{constructor(f){this.value=f}static of(f){return new ua(f)}static empty(){return new ua(null)}map(f){return new ua(this.value!==null&&this.value!==void 0?f(this.value):null)}mapAsync(f){return this.value!==null&&this.value!==void 0?f(this.value).then(d=>ua.of(d)):Promise.resolve(ua.empty())}ifPresent(f){return this.value!==null&&this.value!==void 0&&f(this.value),this}ifPresentAsync(f){return this.value!==null&&this.value!==void 0?f(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(f){return(this.value===null||this.value===void 0)&&f(),this}ifAbsentAsync(f){return this.value===null||this.value===void 0?f().then(()=>this):Promise.resolve(this)}getOrFallback(f){return this.value??f()}getOrFallbackAsync(f){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):f()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}r.Optional=ua;class Vse{constructor(f){this.supplier=f,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}r.Lazy=Vse;class Wse{constructor(f){this.supplier=f,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}r.AsyncLazy=Wse;function qse(c){return()=>c.forEach(f=>f())}function Zse(c,f){return c.reduce((d,y)=>f(d)>f(y)?d:y)}function Qse(c,f){const d=c.find(y=>y instanceof f);return ua.of(d)}function Yse(c,f){return c.filter(d=>d instanceof f)}function Jse(c,f){const d=[],y=Math.max(c.length,f.length);for(let R=0;R<y;R++)c[R]&&d.push(c[R]),f[R]&&d.push(f[R]);return d}function Xse(c,f){return c.includes(f)?c.filter(d=>d!==f):[...c,f]}class eoe{constructor(f){this.value=f,this.children=[]}}function toe(c,f,d,y,R=!1){const L=new Map,J=[];c.forEach(fe=>{const De=new eoe(fe);L.set(fe[f],De)}),c.forEach(fe=>{const De=L.get(fe[f]);if(!De)return;const Lt=fe[d];if(Lt){const Gr=L.get(Lt);Gr&&Gr.children.push(De)}else J.push(De)});const de=fe=>{fe.children.sort((De,Lt)=>{const Gr=De.value[y],Kl=Lt.value[y];return R?Kl-Gr:Gr-Kl}),fe.children.forEach(de)};return J.forEach(de),J}function UC(c,f){if(Math.log2(c.length)%1!==0)throw new Error("Array length must be a power of 2");let d=[...c];for(;d.length>1;){const y=[];for(let R=0;R<d.length;R+=2){const L=d[R+1];y.push(f(d[R],L))}d=y}return d[0]}function zl(...c){const f=c.reduce((R,L)=>R+L.length,0),d=new Uint8Array(f);let y=0;return c.forEach(R=>{d.set(R,y),y+=R.length}),d}function DC(c){return c[0]===137&&c[1]===80&&c[2]===78&&c[3]===71}function $C(c){return c[0]===255&&c[1]===216}function FC(c){return c[8]===87&&c[9]===69&&c[10]===66&&c[11]===80}function roe(c){return DC(c)||$C(c)||FC(c)}function noe(c){return new Uint8Array([c])}function ioe(c){return c[0]}function soe(c,f){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,c,f==="LE"),new Uint8Array(d)}function ooe(c,f){return new DataView(c.buffer).getUint16(c.byteOffset,f==="LE")}function aoe(c,f){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,c,f==="LE"),new Uint8Array(d)}function coe(c,f){return new DataView(c.buffer).getUint32(c.byteOffset,f==="LE")}function Cb(c,f){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(c),f==="LE"),new Uint8Array(d)}function uoe(c,f){return new DataView(c.buffer).getBigUint64(c.byteOffset,f==="LE")}function Gl(c,f){const d=new Uint8Array(32);let y=c;if(f==="LE"){for(let R=0;R<32;R++)d[R]=Number(y&0xffn),y>>=8n;return d}for(let R=31;R>=0;R--)d[R]=Number(y&0xffn),y>>=8n;return d}function jl(c,f){let d=0n;if(f==="LE"){for(let y=31;y>=0;y--)d=d<<8n|BigInt(c[y]);return d}for(let y=0;y<32;y++)d=d<<8n|BigInt(c[y]);return d}function loe(c,f){const d=[];let y=0;for(const R of f)d.push(c.subarray(y,y+R)),y+=R;return d}function Bb(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.subarray(y,y+f));return d}const HC=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function foe(c){for(let f=0;f<24;f++){const d=c[0]^c[10]^c[20]^c[30]^c[40],y=c[1]^c[11]^c[21]^c[31]^c[41],R=c[2]^c[12]^c[22]^c[32]^c[42],L=c[3]^c[13]^c[23]^c[33]^c[43],J=c[4]^c[14]^c[24]^c[34]^c[44],de=c[5]^c[15]^c[25]^c[35]^c[45],fe=c[6]^c[16]^c[26]^c[36]^c[46],De=c[7]^c[17]^c[27]^c[37]^c[47],Lt=c[8]^c[18]^c[28]^c[38]^c[48],Gr=c[9]^c[19]^c[29]^c[39]^c[49],Kl=R<<1|L>>>31,Woe=L<<1|R>>>31,ud=Lt^Kl,ld=Gr^Woe,qoe=J<<1|de>>>31,Zoe=de<<1|J>>>31,fd=d^qoe,hd=y^Zoe,Qoe=fe<<1|De>>>31,Yoe=De<<1|fe>>>31,dd=R^Qoe,pd=L^Yoe,Joe=Lt<<1|Gr>>>31,Xoe=Gr<<1|Lt>>>31,gd=J^Joe,yd=de^Xoe,eae=d<<1|y>>>31,tae=y<<1|d>>>31,md=fe^eae,wd=De^tae;c[0]^=ud,c[1]^=ld,c[2]^=fd,c[3]^=hd,c[4]^=dd,c[5]^=pd,c[6]^=gd,c[7]^=yd,c[8]^=md,c[9]^=wd,c[10]^=ud,c[11]^=ld,c[12]^=fd,c[13]^=hd,c[14]^=dd,c[15]^=pd,c[16]^=gd,c[17]^=yd,c[18]^=md,c[19]^=wd,c[20]^=ud,c[21]^=ld,c[22]^=fd,c[23]^=hd,c[24]^=dd,c[25]^=pd,c[26]^=gd,c[27]^=yd,c[28]^=md,c[29]^=wd,c[30]^=ud,c[31]^=ld,c[32]^=fd,c[33]^=hd,c[34]^=dd,c[35]^=pd,c[36]^=gd,c[37]^=yd,c[38]^=md,c[39]^=wd,c[40]^=ud,c[41]^=ld,c[42]^=fd,c[43]^=hd,c[44]^=dd,c[45]^=pd,c[46]^=gd,c[47]^=yd,c[48]^=md,c[49]^=wd;const $b=c[0],Fb=c[1],Hb=c[2]<<1|c[3]>>>31,zb=c[3]<<1|c[2]>>>31,Gb=c[5]<<30|c[4]>>>2,jb=c[4]<<30|c[5]>>>2,Kb=c[6]<<28|c[7]>>>4,Vb=c[7]<<28|c[6]>>>4,Wb=c[8]<<27|c[9]>>>5,qb=c[9]<<27|c[8]>>>5,Zb=c[11]<<4|c[10]>>>28,Qb=c[10]<<4|c[11]>>>28,Yb=c[13]<<12|c[12]>>>20,Jb=c[12]<<12|c[13]>>>20,Xb=c[14]<<6|c[15]>>>26,e_=c[15]<<6|c[14]>>>26,t_=c[17]<<23|c[16]>>>9,r_=c[16]<<23|c[17]>>>9,n_=c[18]<<20|c[19]>>>12,i_=c[19]<<20|c[18]>>>12,s_=c[20]<<3|c[21]>>>29,o_=c[21]<<3|c[20]>>>29,a_=c[22]<<10|c[23]>>>22,c_=c[23]<<10|c[22]>>>22,u_=c[25]<<11|c[24]>>>21,l_=c[24]<<11|c[25]>>>21,f_=c[26]<<25|c[27]>>>7,h_=c[27]<<25|c[26]>>>7,d_=c[29]<<7|c[28]>>>25,p_=c[28]<<7|c[29]>>>25,g_=c[31]<<9|c[30]>>>23,y_=c[30]<<9|c[31]>>>23,m_=c[33]<<13|c[32]>>>19,w_=c[32]<<13|c[33]>>>19,b_=c[34]<<15|c[35]>>>17,__=c[35]<<15|c[34]>>>17,A_=c[36]<<21|c[37]>>>11,v_=c[37]<<21|c[36]>>>11,E_=c[38]<<8|c[39]>>>24,x_=c[39]<<8|c[38]>>>24,R_=c[40]<<18|c[41]>>>14,I_=c[41]<<18|c[40]>>>14,S_=c[42]<<2|c[43]>>>30,k_=c[43]<<2|c[42]>>>30,T_=c[45]<<29|c[44]>>>3,O_=c[44]<<29|c[45]>>>3,N_=c[47]<<24|c[46]>>>8,C_=c[46]<<24|c[47]>>>8,B_=c[48]<<14|c[49]>>>18,P_=c[49]<<14|c[48]>>>18;c[0]=$b^~Yb&u_,c[1]=Fb^~Jb&l_,c[2]=Yb^~u_&A_,c[3]=Jb^~l_&v_,c[4]=u_^~A_&B_,c[5]=l_^~v_&P_,c[6]=A_^~B_&$b,c[7]=v_^~P_&Fb,c[8]=B_^~$b&Yb,c[9]=P_^~Fb&Jb,c[10]=Kb^~n_&s_,c[11]=Vb^~i_&o_,c[12]=n_^~s_&m_,c[13]=i_^~o_&w_,c[14]=s_^~m_&T_,c[15]=o_^~w_&O_,c[16]=m_^~T_&Kb,c[17]=w_^~O_&Vb,c[18]=T_^~Kb&n_,c[19]=O_^~Vb&i_,c[20]=Hb^~Xb&f_,c[21]=zb^~e_&h_,c[22]=Xb^~f_&E_,c[23]=e_^~h_&x_,c[24]=f_^~E_&R_,c[25]=h_^~x_&I_,c[26]=E_^~R_&Hb,c[27]=x_^~I_&zb,c[28]=R_^~Hb&Xb,c[29]=I_^~zb&e_,c[30]=Wb^~Zb&a_,c[31]=qb^~Qb&c_,c[32]=Zb^~a_&b_,c[33]=Qb^~c_&__,c[34]=a_^~b_&N_,c[35]=c_^~__&C_,c[36]=b_^~N_&Wb,c[37]=__^~C_&qb,c[38]=N_^~Wb&Zb,c[39]=C_^~qb&Qb,c[40]=Gb^~t_&d_,c[41]=jb^~r_&p_,c[42]=t_^~d_&g_,c[43]=r_^~p_&y_,c[44]=d_^~g_&S_,c[45]=p_^~y_&k_,c[46]=g_^~S_&Gb,c[47]=y_^~k_&jb,c[48]=S_^~Gb&t_,c[49]=k_^~jb&r_,c[0]^=HC[f*2],c[1]^=HC[f*2+1]}}function zC(c){const f=[];for(let d=0;d<c.length;d+=4)f.push(c[d]|c[d+1]<<8|c[d+2]<<16|c[d+3]<<24);return f}function GC(c,f){if(!c.length){const R=new Uint8Array(136);return R[0]=f,R[135]=128,[zC(R)]}const d=Bb(c,136),y=d[d.length-1];if(y.length<136){const R=new Uint8Array(136);R.set(y),R[y.length]=f,R[135]|=128,d[d.length-1]=R}if(y.length===136){const R=new Uint8Array(136);R[0]=f,R[135]=128,d.push(R)}return d.map(zC)}function jC(c,f){for(const d of f){for(let y=0;y<34;y+=2)c[y]^=d[y+1],c[y+1]^=d[y];foe(c)}return c}function KC(c){return new Uint8Array([c[1],c[1]>>-24,c[1]>>-16,c[1]>>-8,c[0],c[0]>>8,c[0]>>16,c[0]>>24,c[3],c[3]>>-24,c[3]>>-16,c[3]>>-8,c[2],c[2]>>8,c[2]>>16,c[2]>>24,c[5],c[5]>>-24,c[5]>>-16,c[5]>>-8,c[4],c[4]>>8,c[4]>>16,c[4]>>24,c[7],c[7]>>-24,c[7]>>-16,c[7]>>-8,c[6],c[6]>>8,c[6]>>16,c[6]>>24])}function oo(c){return KC(jC(new Array(50).fill(0),GC(c,1)))}function hoe(c){return KC(jC(new Array(50).fill(0),GC(c,6)))}function doe(c,f,d){const y=Math.min(c.length,f.length,d/8+1);for(let R=0;R<y;R++){const L=c[R]^f[R];for(let J=0;J<8;J++)if(L>>7-J&1)return R*8+J}return d}function poe(c,f){const d=Math.min(c.length,f.length);for(let y=0;y<d;y++)if(c[y]!==f[y])return c.subarray(0,y);return c.subarray(0,d)}function goe(c,f,d,y){const R=Math.floor(f/8),L=f%8;d===1?c[R]|=1<<(y==="BE"?7-L:L):c[R]&=~(1<<(y==="BE"?7-L:L))}function yoe(c,f,d){const y=Math.floor(f/8),R=f%8;return c[y]>>(d==="BE"?7-R:R)&1}function moe(c,f,d=0){for(let y=d;y<c.length;y++)for(let R=0;R<f.length&&c[y+R]===f[R];R++)if(R===f.length-1)return y;return-1}function VC(c,f,d=0){if(c.length>=f)return c;const y=new Uint8Array(f);return y.fill(d),y.set(c,f-c.length),y}function woe(c,f,d=0){const y=c.length%f;return y===0?c:VC(c,c.length+f-y,d)}function WC(c,f,d=0){if(c.length>=f)return c;const y=new Uint8Array(f);return y.fill(d),y.set(c,0),y}function boe(c,f,d=0){const y=c.length%f;return y===0?c:WC(c,c.length+f-y,d)}function _oe(c,f){const d=new Uint8Array(c.length);for(let y=0;y<c.length;y++)d[y]=c[y]^f[y%f.length];return d}function Aoe(c,f){if(c.length!==f.length)return!1;for(let d=0;d<c.length;d++)if(c[d]!==f[d])return!1;return!0}function jt(c,f){return(c%f+f)%f}function ad(c,f){c=jt(c,f);let[d,y]=[0n,1n],[R,L]=[f,c];for(;L!==0n;){const J=R/L;[d,y]=[y,d-J*y],[R,L]=[L,R-J*L]}if(R>1n)throw new Error("a is not invertible");return d<0n&&(d+=f),d}function voe(c,f,d){let y=1n;for(c=jt(c,d);f>0;)f%2n===1n&&(y=jt(y*c,d)),c=jt(c*c,d),f=f/2n;return y}function qC(c,f){return jt(c,f)===0n?0n:f%4n===3n?voe(c,(f+1n)/4n,f):null}const hn=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,zr=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,fg=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,hg=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Pb(c,f,d){if(f===0n)return[0n,0n];const y=jt(3n*c*c*ad(2n*f,d),d),R=jt(y*y-2n*c,d),L=jt(y*(c-R)-f,d);return[R,L]}function dg(c,f,d,y,R){if(c===0n&&f===0n)return[d,y];if(d===0n&&y===0n)return[c,f];if(c===d&&f===jt(-y,R))return[0n,0n];if(c===d&&f===y)return Pb(c,f,R);const L=jt((y-f)*ad(d-c,R),R),J=jt(L*L-c-d,R),de=jt(L*(c-J)-f,R);return[J,de]}function Eoe(c){if(c<=0n||c>=zr)throw new Error("Invalid private key");return Pc(fg,hg,c,hn)}function xoe(c){const f=c[1]%2n===0n?2:3;return new Uint8Array([f,...Gl(c[0],"BE")])}function Roe(c){if(c.length!==33||c[0]!==2&&c[0]!==3)throw new Error("Invalid compressed public key");const f=jl(c.slice(1),"BE"),d=qC(jt(f**3n+7n,hn),hn);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const y=jt(-d,hn),R=d%2n===0n;return[f,c[0]===2?R?d:y:R?y:d]}function Ioe(c){const f=new Uint8Array(20),d=oo(zl(Gl(c[0],"BE"),Gl(c[1],"BE")));return f.set(d.subarray(12)),f}function Soe(c){const f=r.Binary.uint8ArrayToHex(c),d=r.Binary.uint8ArrayToHex(r.Binary.keccak256(new Uint8Array([...f].map(R=>R.charCodeAt(0)))));let y="0x";for(let R=0;R<f.length;R++)parseInt(d[R],16)>7?y+=f[R].toUpperCase():y+=f[R];return y}function Pc(c,f,d,y){let R=[0n,0n],L=[c,f];const J=d.toString(2);for(const de of J)de==="0"?(L=dg(R[0],R[1],L[0],L[1],y),R=Pb(R[0],R[1],y)):(R=dg(R[0],R[1],L[0],L[1],y),L=Pb(L[0],L[1],y));return R}function koe(c,f,d){return ZC(jl(oo(c),"BE"),f,d)}function ZC(c,f,d){if(f<=0n||f>=zr)throw new Error("Invalid private key");if(d||(d=jt(jl(oo(zl(oo(Gl(f,"BE")),Gl(c,"BE"))),"BE"),zr)),d<=0n||d>=zr)throw new Error("Invalid nonce");const y=jt(c,zr),R=Pc(fg,hg,d,hn),L=jt(R[0],zr);let J=jt((y+jt(L,zr)*f)*ad(d,zr),zr);if(L===0n||J===0n)throw new Error("Invalid r or s value");let de=R[1]%2n===0n?27n:28n;return J>zr/2n&&(J=zr-J,de=de===27n?28n:27n),[L,J,de]}function Toe(c,f,d,y){const R=qC(jt(f**3n+7n,hn),hn);if(!R)throw new Error("Invalid r: does not correspond to a valid curve point");const L=y===27n?0n:1n,J=R%2n===L?R:hn-R,de=jt(jl(oo(c),"BE"),zr),fe=Pc(f,J,d,hn),De=Pc(fg,hg,de,hn),Lt=dg(fe[0],fe[1],De[0],jt(-De[1],hn),hn);return Pc(Lt[0],Lt[1],ad(f,zr),hn)}function Ooe(c,f,d,y){const R=jt(jl(oo(c),"BE"),zr),L=ad(y,zr),J=jt(R*L,zr),de=jt(d*L,zr),fe=Pc(fg,hg,J,hn),De=Pc(f[0],f[1],de,hn),Lt=dg(fe[0],fe[1],De[0],De[1],hn);return d===jt(Lt[0],zr)}class QC{constructor(f){this.cursor=0,this.buffer=f}read(f){const d=this.buffer.subarray(this.cursor,this.cursor+f);return this.cursor+=f,d}max(){return this.buffer.length-this.cursor}}r.Uint8ArrayReader=QC;class YC{constructor(f){this.buffer=f,this.cursor=0}write(f){const d=Math.min(this.max(),f.max());return this.buffer.set(f.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}r.Uint8ArrayWriter=YC;class pg{constructor(f,d=0n){this.span=d,this.writer=new YC(new Uint8Array(f))}build(){return zl(Cb(this.span,"LE"),this.writer.buffer)}hash(){const f=UC(Bb(this.writer.buffer,32),(d,y)=>oo(zl(d,y)));return oo(zl(Cb(this.span,"LE"),f))}}r.Chunk=pg;class Mb{constructor(f,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new pg(d)],this.onChunk=f}static async root(f,d=4096){const y=new e(e.NOOP,d);return await y.append(f),y.finalize()}async append(f,d=0,y=0n){const R=new QC(f);for(;R.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(R);y?this.chunks[d].span+=y:this.chunks[0].span+=BigInt(L)}}async elevate(f){this.counters[f]=++this.counters[f]%(this.capacity/32),this.chunks[f+1]||(this.chunks.push(new pg(this.capacity)),this.counters.push(1)),await this.append(this.chunks[f].hash(),f+1,this.chunks[f].span),await this.onChunk(this.chunks[f]),this.chunks[f]=new pg(this.capacity)}async finalize(f=0){return this.chunks[f+1]?this.counters[f]===1?(await this.elevate(f+1),this.chunks[f+1]=this.chunks[f],this.finalize(f+1)):(await this.elevate(f),this.finalize(f+1)):(await this.onChunk(this.chunks[f]),this.chunks[f])}}r.MerkleTree=Mb,e=Mb,Mb.NOOP=async c=>{};class ws{constructor(f,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(f),this.scale=d}static fromDecimalString(f,d){let[y,R]=f.split(".");return R=(R||"").padEnd(d,"0").slice(0,d),new ws(BigInt(y+R),d)}add(f){return this.assertSameScale(f),new ws(this.value+f.value,this.scale)}subtract(f){return this.assertSameScale(f),new ws(this.value-f.value,this.scale)}multiply(f){return new ws(this.value*f,this.scale)}divmod(f){if(f===0n)throw new Error("Division by zero is not allowed");const d=this.value/f,y=this.value%f;return[new ws(d,this.scale),new ws(y,this.scale)]}exchange(f,d,y){if(f==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new ws(L,y)}this.assertSameScale(d);const R=this.value*10n**BigInt(y)/d.value;return new ws(R,y)}compare(f){return this.assertSameScale(f),this.value>f.value?1:this.value<f.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const f=this.value.toString(),d=f.slice(0,-this.scale)||"0",y=f.slice(-this.scale).padStart(this.scale,"0");return`${d}.${y}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(f){if(this.scale!==f.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${f.scale}`)}}r.FixedPointNumber=ws;function Noe(c){if(c.length===0)return null;const f=c[0];return f.ttlMax?--f.ttl<=0&&c.shift():f.ttlMax=f.ttl,{progress:(f.ttlMax-f.ttl)/f.ttlMax,data:f.data}}function gg(c,f,d,y){const R=c.findIndex(de=>de===`--${f}`||de.startsWith(`--${f}=`)),L=c[R];if(!L)return(d||{})[y||f||""]||null;if(L.includes("="))return L.split("=")[1];const J=c[R+1];return J&&!J.startsWith("-")?J:(d||{})[y||f||""]||null}function Coe(c,f,d,y){const R=gg(c,f,d,y);if(!R)return null;try{return Tb(R)}catch{throw new Error(`Invalid number argument ${f}: ${R}`)}}function Boe(c,f,d,y){const R=c.some(fe=>fe.endsWith("-"+f)),L=gg(c,f,d,y);if(!L&&R)return!0;if(!L&&!R)return null;const J=["true","1","yes","y","on"],de=["false","0","no","n","off"];if(J.includes(L.toLowerCase()))return!0;if(de.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${f}: ${L}`)}function JC(c,f,d,y){const R=gg(c,f,d,y);if(!R)throw new Error(`Missing argument ${f}`);return R}function Poe(c,f,d,y){const R=JC(c,f,d,y);try{return Tb(R)}catch{throw new Error(`Invalid argument ${f}: ${R}`)}}function XC(c,f){const d=c[f];c.splice(f,1),c.unshift(d)}function Moe(c,f){const d=[...c];return XC(d,f),d}function e6(c,f){return{x:c.x+f.x,y:c.y+f.y}}function Loe(c,f){return{x:c.x-f.x,y:c.y-f.y}}function Lb(c,f){return{x:c.x*f,y:c.y*f}}function Uoe(c){const f=Math.sqrt(c.x*c.x+c.y*c.y);return{x:c.x/f,y:c.y/f}}function t6(c,f,d){return{x:c.x+Math.cos(f)*d,y:c.y+Math.sin(f)*d}}function r6(c,f){return Math.sqrt((c.x-f.x)**2+(c.y-f.y)**2)}function cd(c,f,d="row-first"){const y=[];if(d==="column-first")for(let R=0;R<c.length;R++)for(let L=0;L<c[0].length;L++)f(R,L)&&y.push({x:R,y:L});else for(let R=0;R<c[0].length;R++)for(let L=0;L<c.length;L++)f(L,R)&&y.push({x:L,y:R});return y}function Doe(c,f,d){var y,R;return((y=c[f+1])==null?void 0:y[d])&&((R=c[f-1])==null?void 0:R[d])&&!c[f][d-1]&&!c[f][d+1]}function $oe(c,f,d){var y,R;return c[f][d+1]&&c[f][d-1]&&!((y=c[f-1])!=null&&y[d])&&!((R=c[f+1])!=null&&R[d])}function n6(c,f,d){var y;return!((y=c[f-1])!=null&&y[d])}function i6(c,f,d){var y;return!((y=c[f+1])!=null&&y[d])}function s6(c,f,d){return!c[f][d-1]}function o6(c,f,d){return!c[f][d+1]}function Foe(c,f,d){var R,L,J,de,fe,De,Lt,Gr;const y=[];return c[f][d]?Doe(c,f,d)||$oe(c,f,d)?[]:(!((R=c[f-1])!=null&&R[d-1])&&n6(c,f,d)&&s6(c,f,d)&&y.push({x:f,y:d}),!((L=c[f+1])!=null&&L[d-1])&&i6(c,f,d)&&s6(c,f,d)&&y.push({x:f+1,y:d}),!((J=c[f-1])!=null&&J[d+1])&&n6(c,f,d)&&o6(c,f,d)&&y.push({x:f,y:d+1}),!((de=c[f+1])!=null&&de[d+1])&&i6(c,f,d)&&o6(c,f,d)&&y.push({x:f+1,y:d+1}),y):((fe=c[f-1])!=null&&fe[d]&&c[f][d-1]&&y.push({x:f,y:d}),(De=c[f+1])!=null&&De[d]&&c[f][d-1]&&y.push({x:f+1,y:d}),(Lt=c[f-1])!=null&&Lt[d]&&c[f][d+1]&&y.push({x:f,y:d+1}),(Gr=c[f+1])!=null&&Gr[d]&&c[f][d+1]&&y.push({x:f+1,y:d+1}),y)}function Hoe(c,f,d,y){const R=[{x:0,y:0},{x:d,y:0},{x:0,y},{x:d,y}];for(let L=0;L<c.length;L++)for(let J=0;J<c[0].length;J++){const de=Foe(c,L,J);for(const fe of de)R.some(De=>De.x===fe.x&&De.y===fe.y)||R.push(fe)}return R.map(L=>({x:L.x*f,y:L.y*f}))}function zoe(c,f){const d=cd(c,(fe,De)=>c[fe][De]===0&&c[fe][De+1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),y=cd(c,(fe,De)=>c[fe][De]===0&&c[fe][De-1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),R=cd(c,(fe,De)=>{var Lt;return c[fe][De]===0&&((Lt=c[fe-1])==null?void 0:Lt[De])!==0},"column-first").map(fe=>({...fe,dx:0,dy:1})),L=cd(c,(fe,De)=>{var Lt;return c[fe][De]===0&&((Lt=c[fe+1])==null?void 0:Lt[De])!==0},"column-first").map(fe=>({...fe,dx:0,dy:1}));d.forEach(fe=>fe.y++),L.forEach(fe=>fe.x++);const J=Nb([...R,...L],(fe,De)=>fe.x===De.x&&fe.y-1===De.y),de=Nb([...y,...d],(fe,De)=>fe.y===De.y&&fe.x-1===De.x);return[...J,...de].map(fe=>({start:fe[0],end:B(fe)})).map(fe=>({start:Lb(fe.start,f),end:Lb(e6(fe.end,{x:fe.start.dx,y:fe.start.dy}),f)}))}function Goe(c,f){return Math.atan2(f.y-c.y,f.x-c.x)}function joe(c,f){return f.map(d=>Goe(c,d)).sort((d,y)=>d-y)}function a6(c,f,d,y){const R=(y.y-d.y)*(f.x-c.x)-(y.x-d.x)*(f.y-c.y);if(R===0)return null;let L=c.y-d.y,J=c.x-d.x;const de=(y.x-d.x)*L-(y.y-d.y)*J,fe=(f.x-c.x)*L-(f.y-c.y)*J;return L=de/R,J=fe/R,L>0&&L<1&&J>0&&J<1?{x:c.x+L*(f.x-c.x),y:c.y+L*(f.y-c.y)}:null}function Ub(c,f,d){const y=[],R=t6(c,d,1e4);for(const L of f){const J=a6(c,R,L.start,L.end);J&&y.push(J)}return y.length?y.reduce((L,J)=>{const de=r6(c,J),fe=r6(c,L);return de<fe?J:L}):null}function Koe(c,f,d){const y=joe(c,d),R=[];for(const L of y){const J=Ub(c,f,L-.001),de=Ub(c,f,L+.001);J&&R.push(J),de&&R.push(de)}return R}class Db{constructor(){this.subscribers=[]}subscribe(f){return this.subscribers.push(f),()=>{this.subscribers=this.subscribers.filter(d=>d!==f)}}publish(f){this.subscribers.forEach(d=>d(f))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}r.PubSubChannel=Db;class Voe{constructor(f,d){this.queue=[],this.running=0,this.onProcessed=new Db,this.onDrained=new Db,this.concurrency=f,this.capacity=d}process(){if(this.running>=this.concurrency)return;const f=this.queue.shift();f&&(this.running++,f().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(f){if(this.queue.length<this.capacity)return this.queue.push(f),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(d=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(f),this.process(),this.onProcessed.clear(),d())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(f=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),f()})})}}r.AsyncQueue=Voe,r.Binary={hexToUint8Array:Yne,uint8ArrayToHex:Jne,base64ToUint8Array:Wne,uint8ArrayToBase64:qne,base32ToUint8Array:Zne,uint8ArrayToBase32:Qne,log2Reduce:UC,partition:Bb,concatBytes:zl,numberToUint8:noe,uint8ToNumber:ioe,numberToUint16:soe,uint16ToNumber:ooe,numberToUint32:aoe,uint32ToNumber:coe,numberToUint64:Cb,uint64ToNumber:uoe,numberToUint256:Gl,uint256ToNumber:jl,sliceBytes:loe,keccak256:oo,sha3_256:hoe,proximity:doe,commonPrefix:poe,setBit:goe,getBit:yoe,indexOf:moe,equals:Aoe,padStart:VC,padStartToMultiple:woe,padEnd:WC,padEndToMultiple:boe,xorCypher:_oe},r.Elliptic={privateKeyToPublicKey:Eoe,compressPublicKey:xoe,publicKeyFromCompressed:Roe,publicKeyToAddress:Ioe,signMessage:koe,signHash:ZC,verifySignature:Ooe,recoverPublicKey:Toe,checksumEncode:Soe},r.Random={intBetween:H,floatBetween:D,chance:V,signed:z,makeSeededRng:C,point:Z,procs:j},r.Arrays={countUnique:Use,makeUnique:Lse,splitBySize:Pse,splitByCount:BC,index:CC,indexCollection:Bse,onlyOrThrow:a,onlyOrNull:u,firstOrThrow:h,firstOrNull:l,shuffle:o,initialize:g,initialize2D:w,rotate2D:b,containsShape:I,glue:rne,pluck:x,pick:oe,pickMany:ce,pickManyUnique:ie,pickWeighted:E,pickRandomIndices:S,pickGuaranteed:ue,last:B,pipe:p,makePipe:m,sortWeighted:k,pushAll:aa,unshiftAll:ene,filterAndRemove:Aie,merge:yse,empty:mse,pushToBucket:rd,unshiftAndLimit:nd,atRolling:id,group:Nb,createOscillator:nse,organiseWithLimits:sse,tickPlaybook:Noe,getArgument:gg,getBooleanArgument:Boe,getNumberArgument:Coe,requireStringArgument:JC,requireNumberArgument:Poe,bringToFront:Moe,bringToFrontInPlace:XC,findInstance:Qse,filterInstances:Yse,interleave:Jse,toggle:Xse,createHierarchy:toe,multicall:qse,maxBy:Zse},r.System={sleepMillis:s,forever:te,scheduleMany:une,waitFor:_ie,expandError:Jh,runAndSetInterval:re},r.Numbers={make:Tb,sum:fne,average:hne,median:dne,getDistanceFromMidpoint:pne,clamp:Ob,range:tC,interpolate:lne,createSequence:rse,increment:hse,decrement:dse,format:fse,fromDecimals:lse,makeStorage:Vie,asMegabytes:he,convertBytes:ye,hexToRgb:be,rgbToHex:Ve,haversineDistanceToMeters:Fe,roundToNearest:Be,formatDistance:et,triangularNumber:Qe,searchFloat:ot},r.Promises={raceFulfilled:n,invert:t,runInParallelBatches:i},r.Dates={getTimestamp:Oie,getTimeDelta:EC,secondsToHumanTime:Nie,countCycles:Cie,isoDate:xie,throttle:Bie,timeSince:Mie,dateTimeSlug:Rie,unixTimestamp:Eie,fromUtcString:Iie,fromMillis:Sie,getProgress:Lie,humanizeTime:ug,humanizeProgress:bie,createTimeDigits:ms,mapDayNumber:xC,getDayInfoFromDate:Sb,getDayInfoFromDateTimeString:Die,seconds:$ie,minutes:Fie,hours:Hie,days:zie,make:jie,normalizeTime:kie,absoluteDays:Cc},r.Objects={safeParse:tse,deleteDeep:A,getDeep:O,setDeep:M,incrementDeep:G,ensureDeep:P,replaceDeep:U,getFirstDeep:le,deepMergeInPlace:Li,deepMerge2:Xh,deepMerge3:ed,mapAllAsync:tne,cloneWithJson:vie,sortObject:IC,sortArray:SC,sortAny:Bc,deepEquals:kC,deepEqualsEvery:ese,runOn:pse,ifPresent:gse,zip:Fl,zipSum:td,removeEmptyArrays:wse,removeEmptyValues:bse,flatten:Nse,unflatten:NC,match:Cse,sort:MC,map:vse,mapIterable:Ese,filterKeys:_se,filterValues:Ase,rethrow:xse,setSomeOnObject:Rse,setSomeDeep:Ise,flip:Sse,getAllPermutations:kse,countTruthyValues:Tse,transformToArray:Dse,setMulti:Fse,incrementMulti:$se,createBidirectionalMap:Hse,createTemporalBidirectionalMap:zse,pushToBidirectionalMap:LC,unshiftToBidirectionalMap:Gse,addToTemporalBidirectionalMap:jse,getFromTemporalBidirectionalMap:Kse,createStatefulToggle:ise,diffKeys:ose,pickRandomKey:TC,mapRandomKey:ase,fromObjectString:cse,toQueryString:AC,parseQueryString:fie,hasKey:hie,selectMax:die,reposition:pie,unwrapSingleKey:gie,parseKeyValues:yie},r.Types={isFunction:Ct,isObject:sr,isStrictlyObject:dt,isEmptyArray:Ut,isEmptyObject:oa,isUndefined:It,isString:kr,isNumber:pt,isBoolean:St,isDate:or,isBlank:xt,isId:Bt,isIntegerString:fn,isHexString:Dt,isUrl:Dl,isNullable:qh,asString:ar,asHexString:pr,asSafeString:ng,asIntegerString:rg,asNumber:Oc,asFunction:gr,asInteger:Jt,asBoolean:yr,asDate:ig,asNullableString:mr,asEmptiableString:wr,asId:sg,asTime:br,asArray:_r,asObject:Nc,asNullableObject:Ar,asStringMap:vr,asNumericDictionary:Vh,asUrl:Wh,asNullable:Zh,asOptional:Qh,enforceObjectShape:$l,enforceArrayShape:Yh,isPng:DC,isJpg:$C,isWebp:FC,isImage:roe},r.Strings={tokenizeByCount:Mse,tokenizeByLength:PC,searchHex:tg,searchSubstring:hr,randomHex:dr,randomLetter:We,randomAlphanumeric:$t,randomRichAscii:Ge,randomUnicode:fr,includesAny:gne,slugify:wb,normalForm:mne,enumify:Ene,escapeHtml:Rne,decodeHtmlEntities:Sne,after:bb,afterLast:nC,before:rC,beforeLast:_b,betweenWide:kne,betweenNarrow:Tne,getPreLine:Wie,containsWord:Rb,containsWords:aie,joinUrl:RC,getFuzzyMatchScore:og,sortByFuzzyScore:xne,splitOnce:Ab,splitAll:iC,randomize:Bne,expand:sC,shrinkTrim:sd,capitalize:ag,decapitalize:oC,csvEscape:$ne,parseCsv:wie,surroundInOut:vne,getExtension:vb,getBasename:Eb,normalizeEmail:One,normalizeFilename:Nne,parseFilename:Cne,camelToTitle:wne,slugToTitle:bne,slugToCamel:_ne,joinHumanly:Ane,findWeightedPair:hC,extractBlock:dC,extractAllBlocks:zne,replaceBlocks:Gne,indexOfEarliest:Hl,lastIndexOfBefore:fC,parseHtmlAttributes:cie,readNextWord:cg,resolveVariables:uie,resolveVariableWithDefaultSyntax:bC,resolveRemainingVariablesWithDefaults:_C,isLetter:aC,isDigit:cC,isLetterOrDigit:od,isValidObjectPathCharacter:Lne,insert:Une,indexOfRegex:uC,lineMatches:lC,linesMatchInOrder:Dne,represent:so,resolveMarkdownLinks:lie,buildUrl:mie,isChinese:yne,replaceBetweenStrings:Qie,describeMarkdown:Yie,isBalanced:Jie,textToFormat:Xie,splitFormatting:jne,splitHashtags:Kne,splitUrls:Vne,route:Xne,explodeReplace:xb,generateVariants:eie,replaceWord:tie,replacePascalCaseWords:rie,stripHtml:nie,breakLine:wC,measureTextWidth:iie,toLines:sie,levenshteinDistance:oie},r.Assertions={asEqual:nne,asTrue:ine,asTruthy:sne,asFalse:one,asFalsy:ane,asEither:cne},r.Cache={get:qie,invalidate:Zie},r.Vector={addPoint:e6,subtractPoint:Loe,multiplyPoint:Lb,normalizePoint:Uoe,pushPoint:t6,filterCoordinates:cd,findCorners:Hoe,findLines:zoe,raycast:Ub,raycastCircle:Koe,getLineIntersectionPoint:a6}})(PA);const Vt=xn(PA);Vt.Arrays,Vt.Assertions;const en=Vt.Binary;Vt.Cache,Vt.Dates,Vt.Elliptic,Vt.Numbers,Vt.Objects,Vt.Pagination,Vt.Promises,Vt.Random,Vt.Strings,Vt.System,Vt.Types,Vt.Optional,Vt.Vector,Vt.PubSubChannel,Vt.Chunk;const k4=Vt.MerkleTree;Vt.FixedPointNumber,Vt.Lazy,Vt.AsyncLazy,Vt.AsyncQueue,Vt.Uint8ArrayReader,Vt.Uint8ArrayWriter;var gt;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(gt||(gt={}));var Kg;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Kg||(Kg={}));const Te=gt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bs=r=>{switch(typeof r){case"undefined":return Te.undefined;case"string":return Te.string;case"number":return isNaN(r)?Te.nan:Te.number;case"boolean":return Te.boolean;case"function":return Te.function;case"bigint":return Te.bigint;case"symbol":return Te.symbol;case"object":return Array.isArray(r)?Te.array:r===null?Te.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Te.promise:typeof Map<"u"&&r instanceof Map?Te.map:typeof Set<"u"&&r instanceof Set?Te.set:typeof Date<"u"&&r instanceof Date?Te.date:Te.object;default:return Te.unknown}},we=gt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),T4=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class $n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let a=n,u=0;for(;u<o.path.length;){const l=o.path[u];u===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof $n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,gt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}$n.create=r=>new $n(r);const zc=(r,e)=>{let t;switch(r.code){case we.invalid_type:r.received===Te.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case we.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,gt.jsonStringifyReplacer)}`;break;case we.unrecognized_keys:t=`Unrecognized key(s) in object: ${gt.joinValues(r.keys,", ")}`;break;case we.invalid_union:t="Invalid input";break;case we.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${gt.joinValues(r.options)}`;break;case we.invalid_enum_value:t=`Invalid enum value. Expected ${gt.joinValues(r.options)}, received '${r.received}'`;break;case we.invalid_arguments:t="Invalid function arguments";break;case we.invalid_return_type:t="Invalid function return type";break;case we.invalid_date:t="Invalid date";break;case we.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:gt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case we.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case we.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case we.custom:t="Invalid input";break;case we.invalid_intersection_types:t="Intersection results could not be merged";break;case we.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case we.not_finite:t="Number must be finite";break;default:t=e.defaultError,gt.assertNever(r)}return{message:t}};let MA=zc;function O4(r){MA=r}function $d(){return MA}const Fd=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)a=l(o,{data:e,defaultError:a}).message;return{...i,path:s,message:a}},N4=[];function xe(r,e){const t=$d(),n=Fd({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===zc?void 0:zc].filter(i=>!!i)});r.common.issues.push(n)}class tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Ke;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return tn.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ke;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const Ke=Object.freeze({status:"aborted"}),Gc=r=>({status:"dirty",value:r}),dn=r=>({status:"valid",value:r}),Vg=r=>r.status==="aborted",Wg=r=>r.status==="dirty",da=r=>r.status==="valid",Yl=r=>typeof Promise<"u"&&r instanceof Promise;function Hd(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function LA(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Ue;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ue||(Ue={}));var Jl,Xl;class Di{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const UA=(r,e)=>{if(da(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new $n(r.common.issues);return this._error=t,this._error}}};function Je(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{var u,l;const{message:h}=r;return o.code==="invalid_enum_value"?{message:h??a.defaultError}:typeof a.data>"u"?{message:(u=h??n)!==null&&u!==void 0?u:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l:a.defaultError}},description:i}}class tt{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new tn,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Yl(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},s=this._parseSync({data:e,path:i.path,parent:i});return UA(i,s)}"~validate"(e){var t,n;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:i});return da(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((n=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(s=>da(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Yl(i)?i:Promise.resolve(i));return UA(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),a=()=>s.addIssue({code:we.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new bi({schema:this,typeName:je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Fi.create(this,this._def)}nullable(){return lo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return wi.create(this)}promise(){return Wc.create(this,this._def)}or(e){return nf.create([this,e],this._def)}and(e){return sf.create(this,e,this._def)}transform(e){return new bi({...Je(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lf({...Je(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new Qg({typeName:je.ZodBranded,type:this,...Je(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ff({...Je(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return hf.create(this,e)}readonly(){return df.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C4=/^c[^\s-]{8,}$/i,B4=/^[0-9a-z]+$/,P4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,M4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,L4=/^[a-z0-9_-]{21}$/i,U4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,D4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,$4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qg;const H4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,z4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,G4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,j4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,K4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",W4=new RegExp(`^${DA}$`);function $A(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function q4(r){return new RegExp(`^${$A(r)}$`)}function FA(r){let e=`${DA}T${$A(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Z4(r,e){return!!((e==="v4"||!e)&&H4.test(r)||(e==="v6"||!e)&&G4.test(r))}function Q4(r,e){if(!U4.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function Y4(r,e){return!!((e==="v4"||!e)&&z4.test(r)||(e==="v6"||!e)&&j4.test(r))}class mi extends tt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Te.string){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:Te.string,received:s.parsedType}),Ke}const n=new tn;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?xe(i,{code:we.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&xe(i,{code:we.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")$4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"email",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")qg||(qg=new RegExp(F4,"u")),qg.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"emoji",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")M4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"uuid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")L4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"nanoid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")C4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")B4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid2",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")P4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ulid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),xe(i,{validation:"url",code:we.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"regex",code:we.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?FA(s).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?W4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?q4(s).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?D4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"duration",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Z4(e.data,s.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ip",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Q4(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"jwt",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Y4(e.data,s.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cidr",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?K4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?V4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64url",code:we.invalid_string,message:s.message}),n.dirty()):gt.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:we.invalid_string,...Ue.errToObj(n)})}_addCheck(e){return new mi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ue.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ue.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ue.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ue.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ue.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ue.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ue.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ue.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ue.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ue.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ue.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ue.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ue.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ue.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ue.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ue.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ue.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ue.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ue.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ue.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ue.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ue.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ue.errToObj(t)})}nonempty(e){return this.min(1,Ue.errToObj(e))}trim(){return new mi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}mi.create=r=>{var e;return new mi({checks:[],typeName:je.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Je(r)})};function J4(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class ao extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Te.number){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:Te.number,received:s.parsedType}),Ke}let n;const i=new tn;for(const s of this._def.checks)s.kind==="int"?gt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:we.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?J4(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_finite,message:s.message}),i.dirty()):gt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,i){return new ao({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(i)}]})}_addCheck(e){return new ao({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ue.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ue.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ue.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ue.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&gt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ao.create=r=>new ao({checks:[],typeName:je.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Je(r)});class co extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Te.bigint)return this._getInvalidInput(e);let n;const i=new tn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):gt.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:Te.bigint,received:t.parsedType}),Ke}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,i){return new co({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(i)}]})}_addCheck(e){return new co({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}co.create=r=>{var e;return new co({checks:[],typeName:je.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Je(r)})};class ef extends tt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Te.boolean){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.boolean,received:n.parsedType}),Ke}return dn(e.data)}}ef.create=r=>new ef({typeName:je.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Je(r)});class pa extends tt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Te.date){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:Te.date,received:s.parsedType}),Ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_date}),Ke}const n=new tn;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):gt.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new pa({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ue.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ue.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}pa.create=r=>new pa({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:je.ZodDate,...Je(r)});class zd extends tt{_parse(e){if(this._getType(e)!==Te.symbol){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.symbol,received:n.parsedType}),Ke}return dn(e.data)}}zd.create=r=>new zd({typeName:je.ZodSymbol,...Je(r)});class tf extends tt{_parse(e){if(this._getType(e)!==Te.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.undefined,received:n.parsedType}),Ke}return dn(e.data)}}tf.create=r=>new tf({typeName:je.ZodUndefined,...Je(r)});class rf extends tt{_parse(e){if(this._getType(e)!==Te.null){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.null,received:n.parsedType}),Ke}return dn(e.data)}}rf.create=r=>new rf({typeName:je.ZodNull,...Je(r)});class jc extends tt{constructor(){super(...arguments),this._any=!0}_parse(e){return dn(e.data)}}jc.create=r=>new jc({typeName:je.ZodAny,...Je(r)});class ga extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dn(e.data)}}ga.create=r=>new ga({typeName:je.ZodUnknown,...Je(r)});class _s extends tt{_parse(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:Te.never,received:t.parsedType}),Ke}}_s.create=r=>new _s({typeName:je.ZodNever,...Je(r)});class Gd extends tt{_parse(e){if(this._getType(e)!==Te.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.void,received:n.parsedType}),Ke}return dn(e.data)}}Gd.create=r=>new Gd({typeName:je.ZodVoid,...Je(r)});class wi extends tt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==Te.array)return xe(t,{code:we.invalid_type,expected:Te.array,received:t.parsedType}),Ke;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(o||a)&&(xe(t,{code:o?we.too_big:we.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(xe(t,{code:we.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(xe(t,{code:we.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>i.type._parseAsync(new Di(t,o,t.path,a)))).then(o=>tn.mergeArray(n,o));const s=[...t.data].map((o,a)=>i.type._parseSync(new Di(t,o,t.path,a)));return tn.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new wi({...this._def,minLength:{value:e,message:Ue.toString(t)}})}max(e,t){return new wi({...this._def,maxLength:{value:e,message:Ue.toString(t)}})}length(e,t){return new wi({...this._def,exactLength:{value:e,message:Ue.toString(t)}})}nonempty(e){return this.min(1,e)}}wi.create=(r,e)=>new wi({type:r,minLength:null,maxLength:null,exactLength:null,typeName:je.ZodArray,...Je(e)});function Kc(r){if(r instanceof Xt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Fi.create(Kc(n))}return new Xt({...r._def,shape:()=>e})}else return r instanceof wi?new wi({...r._def,type:Kc(r.element)}):r instanceof Fi?Fi.create(Kc(r.unwrap())):r instanceof lo?lo.create(Kc(r.unwrap())):r instanceof $i?$i.create(r.items.map(e=>Kc(e))):r}class Xt extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=gt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Te.object){const l=this._getOrReturnCtx(e);return xe(l,{code:we.invalid_type,expected:Te.object,received:l.parsedType}),Ke}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof _s&&this._def.unknownKeys==="strip"))for(const l in i.data)o.includes(l)||a.push(l);const u=[];for(const l of o){const h=s[l],g=i.data[l];u.push({key:{status:"valid",value:l},value:h._parse(new Di(i,g,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof _s){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of a)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(l==="strict")a.length>0&&(xe(i,{code:we.unrecognized_keys,keys:a}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of a){const g=i.data[h];u.push({key:{status:"valid",value:h},value:l._parse(new Di(i,g,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of u){const g=await h.key,b=await h.value;l.push({key:g,value:b,alwaysSet:h.alwaysSet})}return l}).then(l=>tn.mergeObjectSync(n,l)):tn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Ue.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,a;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(a=Ue.errToObj(e).message)!==null&&a!==void 0?a:u}:{message:u}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return gt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return Kc(this)}partial(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Fi;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return HA(gt.objectKeys(this.shape))}}Xt.create=(r,e)=>new Xt({shape:()=>r,unknownKeys:"strip",catchall:_s.create(),typeName:je.ZodObject,...Je(e)}),Xt.strictCreate=(r,e)=>new Xt({shape:()=>r,unknownKeys:"strict",catchall:_s.create(),typeName:je.ZodObject,...Je(e)}),Xt.lazycreate=(r,e)=>new Xt({shape:r,unknownKeys:"strip",catchall:_s.create(),typeName:je.ZodObject,...Je(e)});class nf extends tt{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new $n(a.ctx.common.issues));return xe(t,{code:we.invalid_union,unionErrors:o}),Ke}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(u=>new $n(u));return xe(t,{code:we.invalid_union,unionErrors:a}),Ke}}get options(){return this._def.options}}nf.create=(r,e)=>new nf({options:r,typeName:je.ZodUnion,...Je(e)});const As=r=>r instanceof af?As(r.schema):r instanceof bi?As(r.innerType()):r instanceof cf?[r.value]:r instanceof uo?r.options:r instanceof uf?gt.objectValues(r.enum):r instanceof lf?As(r._def.innerType):r instanceof tf?[void 0]:r instanceof rf?[null]:r instanceof Fi?[void 0,...As(r.unwrap())]:r instanceof lo?[null,...As(r.unwrap())]:r instanceof Qg||r instanceof df?As(r.unwrap()):r instanceof ff?As(r._def.innerType):[];class jd extends tt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Te.object)return xe(t,{code:we.invalid_type,expected:Te.object,received:t.parsedType}),Ke;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(xe(t,{code:we.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ke)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=As(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s)}}return new jd({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Je(n)})}}function Zg(r,e){const t=bs(r),n=bs(e);if(r===e)return{valid:!0,data:r};if(t===Te.object&&n===Te.object){const i=gt.objectKeys(e),s=gt.objectKeys(r).filter(a=>i.indexOf(a)!==-1),o={...r,...e};for(const a of s){const u=Zg(r[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(t===Te.array&&n===Te.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],a=e[s],u=Zg(o,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===Te.date&&n===Te.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class sf extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(Vg(s)||Vg(o))return Ke;const a=Zg(s.value,o.value);return a.valid?((Wg(s)||Wg(o))&&t.dirty(),{status:t.value,value:a.data}):(xe(n,{code:we.invalid_intersection_types}),Ke)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}sf.create=(r,e,t)=>new sf({left:r,right:e,typeName:je.ZodIntersection,...Je(t)});class $i extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Te.array)return xe(n,{code:we.invalid_type,expected:Te.array,received:n.parsedType}),Ke;if(n.data.length<this._def.items.length)return xe(n,{code:we.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ke;!this._def.rest&&n.data.length>this._def.items.length&&(xe(n,{code:we.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,a)=>{const u=this._def.items[a]||this._def.rest;return u?u._parse(new Di(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>tn.mergeArray(t,o)):tn.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new $i({...this._def,rest:e})}}$i.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $i({items:r,typeName:je.ZodTuple,rest:null,...Je(e)})};class of extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Te.object)return xe(n,{code:we.invalid_type,expected:Te.object,received:n.parsedType}),Ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in n.data)i.push({key:s._parse(new Di(n,a,n.path,a)),value:o._parse(new Di(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?tn.mergeObjectAsync(t,i):tn.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof tt?new of({keyType:e,valueType:t,typeName:je.ZodRecord,...Je(n)}):new of({keyType:mi.create(),valueType:e,typeName:je.ZodRecord,...Je(t)})}}class Kd extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Te.map)return xe(n,{code:we.invalid_type,expected:Te.map,received:n.parsedType}),Ke;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([a,u],l)=>({key:i._parse(new Di(n,a,n.path,[l,"key"])),value:s._parse(new Di(n,u,n.path,[l,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const u of o){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return Ke;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const u of o){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return Ke;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}}}}Kd.create=(r,e,t)=>new Kd({valueType:e,keyType:r,typeName:je.ZodMap,...Je(t)});class ya extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Te.set)return xe(n,{code:we.invalid_type,expected:Te.set,received:n.parsedType}),Ke;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(xe(n,{code:we.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(xe(n,{code:we.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const l=new Set;for(const h of u){if(h.status==="aborted")return Ke;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const a=[...n.data.values()].map((u,l)=>s._parse(new Di(n,u,n.path,l)));return n.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(e,t){return new ya({...this._def,minSize:{value:e,message:Ue.toString(t)}})}max(e,t){return new ya({...this._def,maxSize:{value:e,message:Ue.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ya.create=(r,e)=>new ya({valueType:r,minSize:null,maxSize:null,typeName:je.ZodSet,...Je(e)});class Vc extends tt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Te.function)return xe(t,{code:we.invalid_type,expected:Te.function,received:t.parsedType}),Ke;function n(a,u){return Fd({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$d(),zc].filter(l=>!!l),issueData:{code:we.invalid_arguments,argumentsError:u}})}function i(a,u){return Fd({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$d(),zc].filter(l=>!!l),issueData:{code:we.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Wc){const a=this;return dn(async function(...u){const l=new $n([]),h=await a._def.args.parseAsync(u,s).catch(w=>{throw l.addIssue(n(u,w)),l}),g=await Reflect.apply(o,this,h);return await a._def.returns._def.type.parseAsync(g,s).catch(w=>{throw l.addIssue(i(g,w)),l})})}else{const a=this;return dn(function(...u){const l=a._def.args.safeParse(u,s);if(!l.success)throw new $n([n(u,l.error)]);const h=Reflect.apply(o,this,l.data),g=a._def.returns.safeParse(h,s);if(!g.success)throw new $n([i(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Vc({...this._def,args:$i.create(e).rest(ga.create())})}returns(e){return new Vc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Vc({args:e||$i.create([]).rest(ga.create()),returns:t||ga.create(),typeName:je.ZodFunction,...Je(n)})}}class af extends tt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}af.create=(r,e)=>new af({getter:r,typeName:je.ZodLazy,...Je(e)});class cf extends tt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return xe(t,{received:t.data,code:we.invalid_literal,expected:this._def.value}),Ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}cf.create=(r,e)=>new cf({value:r,typeName:je.ZodLiteral,...Je(e)});function HA(r,e){return new uo({values:r,typeName:je.ZodEnum,...Je(e)})}class uo extends tt{constructor(){super(...arguments),Jl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return xe(t,{expected:gt.joinValues(n),received:t.parsedType,code:we.invalid_type}),Ke}if(Hd(this,Jl)||LA(this,Jl,new Set(this._def.values)),!Hd(this,Jl).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return xe(t,{received:t.data,code:we.invalid_enum_value,options:n}),Ke}return dn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return uo.create(e,{...this._def,...t})}exclude(e,t=this._def){return uo.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Jl=new WeakMap,uo.create=HA;class uf extends tt{constructor(){super(...arguments),Xl.set(this,void 0)}_parse(e){const t=gt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Te.string&&n.parsedType!==Te.number){const i=gt.objectValues(t);return xe(n,{expected:gt.joinValues(i),received:n.parsedType,code:we.invalid_type}),Ke}if(Hd(this,Xl)||LA(this,Xl,new Set(gt.getValidEnumValues(this._def.values))),!Hd(this,Xl).has(e.data)){const i=gt.objectValues(t);return xe(n,{received:n.data,code:we.invalid_enum_value,options:i}),Ke}return dn(e.data)}get enum(){return this._def.values}}Xl=new WeakMap,uf.create=(r,e)=>new uf({values:r,typeName:je.ZodNativeEnum,...Je(e)});class Wc extends tt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Te.promise&&t.common.async===!1)return xe(t,{code:we.invalid_type,expected:Te.promise,received:t.parsedType}),Ke;const n=t.parsedType===Te.promise?t.data:Promise.resolve(t.data);return dn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Wc.create=(r,e)=>new Wc({type:r,typeName:je.ZodPromise,...Je(e)});class bi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{xe(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return Ke;const u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?Ke:u.status==="dirty"||t.value==="dirty"?Gc(u.value):u});{if(t.value==="aborted")return Ke;const a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?Ke:a.status==="dirty"||t.value==="dirty"?Gc(a.value):a}}if(i.type==="refinement"){const o=a=>{const u=i.refinement(a,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ke:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Ke:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!da(o))return o;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>da(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:t.value,value:a})):o);gt.assertNever(i)}}bi.create=(r,e,t)=>new bi({schema:r,typeName:je.ZodEffects,effect:e,...Je(t)}),bi.createWithPreprocess=(r,e,t)=>new bi({schema:e,effect:{type:"preprocess",transform:r},typeName:je.ZodEffects,...Je(t)});class Fi extends tt{_parse(e){return this._getType(e)===Te.undefined?dn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fi.create=(r,e)=>new Fi({innerType:r,typeName:je.ZodOptional,...Je(e)});class lo extends tt{_parse(e){return this._getType(e)===Te.null?dn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}lo.create=(r,e)=>new lo({innerType:r,typeName:je.ZodNullable,...Je(e)});class lf extends tt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Te.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lf.create=(r,e)=>new lf({innerType:r,typeName:je.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Je(e)});class ff extends tt{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yl(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $n(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $n(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ff.create=(r,e)=>new ff({innerType:r,typeName:je.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Je(e)});class Vd extends tt{_parse(e){if(this._getType(e)!==Te.nan){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.nan,received:n.parsedType}),Ke}return{status:"valid",value:e.data}}}Vd.create=r=>new Vd({typeName:je.ZodNaN,...Je(r)});const X4=Symbol("zod_brand");class Qg extends tt{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class hf extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Ke:s.status==="dirty"?(t.dirty(),Gc(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Ke:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new hf({in:e,out:t,typeName:je.ZodPipeline})}}class df extends tt{_parse(e){const t=this._def.innerType._parse(e),n=i=>(da(i)&&(i.value=Object.freeze(i.value)),i);return Yl(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}df.create=(r,e)=>new df({innerType:r,typeName:je.ZodReadonly,...Je(e)});function zA(r,e={},t){return r?jc.create().superRefine((n,i)=>{var s,o;if(!r(n)){const a=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=a.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,l=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...l,fatal:u})}}):jc.create()}const eM={object:Xt.lazycreate};var je;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(je||(je={}));const tM=(r,e={message:`Input not instance of ${r.name}`})=>zA(t=>t instanceof r,e),GA=mi.create,jA=ao.create,rM=Vd.create,nM=co.create,KA=ef.create,iM=pa.create,sM=zd.create,oM=tf.create,aM=rf.create,cM=jc.create,uM=ga.create,lM=_s.create,fM=Gd.create,hM=wi.create,dM=Xt.create,pM=Xt.strictCreate,gM=nf.create,yM=jd.create,mM=sf.create,wM=$i.create,bM=of.create,_M=Kd.create,AM=ya.create,vM=Vc.create,EM=af.create,xM=cf.create,RM=uo.create,IM=uf.create,SM=Wc.create,VA=bi.create,kM=Fi.create,TM=lo.create,OM=bi.createWithPreprocess,NM=hf.create;var er=Object.freeze({__proto__:null,defaultErrorMap:zc,setErrorMap:O4,getErrorMap:$d,makeIssue:Fd,EMPTY_PATH:N4,addIssueToContext:xe,ParseStatus:tn,INVALID:Ke,DIRTY:Gc,OK:dn,isAborted:Vg,isDirty:Wg,isValid:da,isAsync:Yl,get util(){return gt},get objectUtil(){return Kg},ZodParsedType:Te,getParsedType:bs,ZodType:tt,datetimeRegex:FA,ZodString:mi,ZodNumber:ao,ZodBigInt:co,ZodBoolean:ef,ZodDate:pa,ZodSymbol:zd,ZodUndefined:tf,ZodNull:rf,ZodAny:jc,ZodUnknown:ga,ZodNever:_s,ZodVoid:Gd,ZodArray:wi,ZodObject:Xt,ZodUnion:nf,ZodDiscriminatedUnion:jd,ZodIntersection:sf,ZodTuple:$i,ZodRecord:of,ZodMap:Kd,ZodSet:ya,ZodFunction:Vc,ZodLazy:af,ZodLiteral:cf,ZodEnum:uo,ZodNativeEnum:uf,ZodPromise:Wc,ZodEffects:bi,ZodTransformer:bi,ZodOptional:Fi,ZodNullable:lo,ZodDefault:lf,ZodCatch:ff,ZodNaN:Vd,BRAND:X4,ZodBranded:Qg,ZodPipeline:hf,ZodReadonly:df,custom:zA,Schema:tt,ZodSchema:tt,late:eM,get ZodFirstPartyTypeKind(){return je},coerce:{string:r=>mi.create({...r,coerce:!0}),number:r=>ao.create({...r,coerce:!0}),boolean:r=>ef.create({...r,coerce:!0}),bigint:r=>co.create({...r,coerce:!0}),date:r=>pa.create({...r,coerce:!0})},any:cM,array:hM,bigint:nM,boolean:KA,date:iM,discriminatedUnion:yM,effect:VA,enum:RM,function:vM,instanceof:tM,intersection:mM,lazy:EM,literal:xM,map:_M,nan:rM,nativeEnum:IM,never:lM,null:aM,nullable:TM,number:jA,object:dM,oboolean:()=>KA().optional(),onumber:()=>jA().optional(),optional:kM,ostring:()=>GA().optional(),pipeline:NM,preprocess:OM,promise:SM,record:bM,set:AM,strictObject:pM,string:GA,symbol:sM,transformer:VA,tuple:wM,undefined:oM,union:gM,unknown:uM,void:fM,NEVER:Ke,ZodIssueCode:we,quotelessJson:T4,ZodError:$n});const pf=Ui.getInstance(),WA=er.object({username:er.string(),address:er.string(),timestamp:er.number(),index:er.number(),signature:er.string()}),qA=er.object({id:er.number(),ref:er.string(),updater:er.string(),timestamp:er.number()}),CM=er.object({messageSender:WA.optional(),historyEntry:qA}),BM=er.object({events:er.array(er.object({type:er.string(),timestamp:er.number()})),messageEntries:er.array(er.object({index:er.number(),timestamp:er.number()}))}),PM=er.object({allTimeUsers:er.record(BM)});function ZA(r){const e=CM.safeParse(r);return e.success?r.messageSender&&!UM(r.messageSender)?(console.warn("Invalid messageSender"),!1):MM(r.historyEntry)?!0:(console.warn("Invalid historyEntry"),!1):(pf.warn(e.error.format()),!1)}function MM(r){const e=qA.safeParse(r);return e.success?!0:(pf.warn(e.error.format()),!1)}function LM(r){const e=PM.safeParse(r);return e.success?!0:(pf.warn(e.error.format()),!1)}function UM(r){const e=WA.safeParse(r);return e.success?DM(r):(pf.warn(e.error.format()),!1)}function DM(r){try{const e={username:r.username,address:r.address,timestamp:r.timestamp},t=new TextEncoder,n=en.concatBytes(t.encode(`Ethereum Signed Message:
11
+ 32`),en.keccak256(t.encode(JSON.stringify(e))));if(new Se.Signature(r.signature).isValid(n,r.address))throw new Error("Signature verification failed!");return!0}catch(e){return pf.warn("Error in validateUserSignature",e),!1}}async function QA(r){const{condition:e,broadcast:t,maxRetries:n=2,initialDelayMs:i=2e3,checkIntervalMs:s=1e3,checkCount:o=10}=r;return new Promise((a,u)=>{let l=0;const h=async()=>{await zg(i);for(let g=0;g<o;g++){if(await Promise.resolve(e()))return a();await zg(s)}if(++l>=n)return u(new Error("Broadcast wait timeout"));console.warn(`Retrying broadcast... Attempt ${l} of ${n}`),await t(),h()};console.log("Starting broadcast..."),t().then(()=>h()).catch(u)})}const ei={LOADING_INIT:"loadingInit",LOADING_PREVIOUS_MESSAGES:"loadingPreviousMessages",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_INITIATED:"messageRequestInitiated",MESSAGE_REQUEST_UPLOADED:"messageRequestUploaded",MESSAGE_REQUEST_ERROR:"messageRequestError",CRITICAL_ERROR:"criticalError"},$M=1e3,FM=new Error("request for lock canceled");var HM=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{l(n.next(h))}catch(g){o(g)}}function u(h){try{l(n.throw(h))}catch(g){o(g)}}function l(h){h.done?s(h.value):i(h.value).then(a,u)}l((n=n.apply(r,e||[])).next())})};class zM{constructor(e,t=FM){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const s={resolve:n,reject:i,weight:e,priority:t},o=YA(this._queue,a=>t<=a.priority);o===-1&&e<=this._value?this._dispatchItem(s):this._queue.splice(o+1,0,s)})}runExclusive(e){return HM(this,arguments,void 0,function*(t,n=1,i=0){const[s,o]=yield this.acquire(n,i);try{return yield t(s)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),GM(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const i=n.findIndex(s=>s.priority<=e);(i===-1?n:n.splice(0,i)).forEach(s=>s.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function GM(r,e){const t=YA(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function YA(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var jM=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{l(n.next(h))}catch(g){o(g)}}function u(h){try{l(n.throw(h))}catch(g){o(g)}}function l(h){h.done?s(h.value):i(h.value).then(a,u)}l((n=n.apply(r,e||[])).next())})};class KM{constructor(e){this._semaphore=new zM(1,e)}acquire(){return jM(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var JA={};(function(r){r.aliasToReal={each:"forEach",eachRight:"forEachRight",entries:"toPairs",entriesIn:"toPairsIn",extend:"assignIn",extendAll:"assignInAll",extendAllWith:"assignInAllWith",extendWith:"assignInWith",first:"head",conforms:"conformsTo",matches:"isMatch",property:"get",__:"placeholder",F:"stubFalse",T:"stubTrue",all:"every",allPass:"overEvery",always:"constant",any:"some",anyPass:"overSome",apply:"spread",assoc:"set",assocPath:"set",complement:"negate",compose:"flowRight",contains:"includes",dissoc:"unset",dissocPath:"unset",dropLast:"dropRight",dropLastWhile:"dropRightWhile",equals:"isEqual",identical:"eq",indexBy:"keyBy",init:"initial",invertObj:"invert",juxt:"over",omitAll:"omit",nAry:"ary",path:"get",pathEq:"matchesProperty",pathOr:"getOr",paths:"at",pickAll:"pick",pipe:"flow",pluck:"map",prop:"get",propEq:"matchesProperty",propOr:"getOr",props:"at",symmetricDifference:"xor",symmetricDifferenceBy:"xorBy",symmetricDifferenceWith:"xorWith",takeLast:"takeRight",takeLastWhile:"takeRightWhile",unapply:"rest",unnest:"flatten",useWith:"overArgs",where:"conformsTo",whereEq:"isMatch",zipObj:"zipObject"},r.aryMethod={1:["assignAll","assignInAll","attempt","castArray","ceil","create","curry","curryRight","defaultsAll","defaultsDeepAll","floor","flow","flowRight","fromPairs","invert","iteratee","memoize","method","mergeAll","methodOf","mixin","nthArg","over","overEvery","overSome","rest","reverse","round","runInContext","spread","template","trim","trimEnd","trimStart","uniqueId","words","zipAll"],2:["add","after","ary","assign","assignAllWith","assignIn","assignInAllWith","at","before","bind","bindAll","bindKey","chunk","cloneDeepWith","cloneWith","concat","conformsTo","countBy","curryN","curryRightN","debounce","defaults","defaultsDeep","defaultTo","delay","difference","divide","drop","dropRight","dropRightWhile","dropWhile","endsWith","eq","every","filter","find","findIndex","findKey","findLast","findLastIndex","findLastKey","flatMap","flatMapDeep","flattenDepth","forEach","forEachRight","forIn","forInRight","forOwn","forOwnRight","get","groupBy","gt","gte","has","hasIn","includes","indexOf","intersection","invertBy","invoke","invokeMap","isEqual","isMatch","join","keyBy","lastIndexOf","lt","lte","map","mapKeys","mapValues","matchesProperty","maxBy","meanBy","merge","mergeAllWith","minBy","multiply","nth","omit","omitBy","overArgs","pad","padEnd","padStart","parseInt","partial","partialRight","partition","pick","pickBy","propertyOf","pull","pullAll","pullAt","random","range","rangeRight","rearg","reject","remove","repeat","restFrom","result","sampleSize","some","sortBy","sortedIndex","sortedIndexOf","sortedLastIndex","sortedLastIndexOf","sortedUniqBy","split","spreadFrom","startsWith","subtract","sumBy","take","takeRight","takeRightWhile","takeWhile","tap","throttle","thru","times","trimChars","trimCharsEnd","trimCharsStart","truncate","union","uniqBy","uniqWith","unset","unzipWith","without","wrap","xor","zip","zipObject","zipObjectDeep"],3:["assignInWith","assignWith","clamp","differenceBy","differenceWith","findFrom","findIndexFrom","findLastFrom","findLastIndexFrom","getOr","includesFrom","indexOfFrom","inRange","intersectionBy","intersectionWith","invokeArgs","invokeArgsMap","isEqualWith","isMatchWith","flatMapDepth","lastIndexOfFrom","mergeWith","orderBy","padChars","padCharsEnd","padCharsStart","pullAllBy","pullAllWith","rangeStep","rangeStepRight","reduce","reduceRight","replace","set","slice","sortedIndexBy","sortedLastIndexBy","transform","unionBy","unionWith","update","xorBy","xorWith","zipWith"],4:["fill","setWith","updateWith"]},r.aryRearg={2:[1,0],3:[2,0,1],4:[3,2,0,1]},r.iterateeAry={dropRightWhile:1,dropWhile:1,every:1,filter:1,find:1,findFrom:1,findIndex:1,findIndexFrom:1,findKey:1,findLast:1,findLastFrom:1,findLastIndex:1,findLastIndexFrom:1,findLastKey:1,flatMap:1,flatMapDeep:1,flatMapDepth:1,forEach:1,forEachRight:1,forIn:1,forInRight:1,forOwn:1,forOwnRight:1,map:1,mapKeys:1,mapValues:1,partition:1,reduce:2,reduceRight:2,reject:1,remove:1,some:1,takeRightWhile:1,takeWhile:1,times:1,transform:2},r.iterateeRearg={mapKeys:[1],reduceRight:[1,0]},r.methodRearg={assignInAllWith:[1,0],assignInWith:[1,2,0],assignAllWith:[1,0],assignWith:[1,2,0],differenceBy:[1,2,0],differenceWith:[1,2,0],getOr:[2,1,0],intersectionBy:[1,2,0],intersectionWith:[1,2,0],isEqualWith:[1,2,0],isMatchWith:[2,1,0],mergeAllWith:[1,0],mergeWith:[1,2,0],padChars:[2,1,0],padCharsEnd:[2,1,0],padCharsStart:[2,1,0],pullAllBy:[2,1,0],pullAllWith:[2,1,0],rangeStep:[1,2,0],rangeStepRight:[1,2,0],setWith:[3,1,2,0],sortedIndexBy:[2,1,0],sortedLastIndexBy:[2,1,0],unionBy:[1,2,0],unionWith:[1,2,0],updateWith:[3,1,2,0],xorBy:[1,2,0],xorWith:[1,2,0],zipWith:[1,2,0]},r.methodSpread={assignAll:{start:0},assignAllWith:{start:0},assignInAll:{start:0},assignInAllWith:{start:0},defaultsAll:{start:0},defaultsDeepAll:{start:0},invokeArgs:{start:2},invokeArgsMap:{start:2},mergeAll:{start:0},mergeAllWith:{start:0},partial:{start:1},partialRight:{start:1},without:{start:1},zipAll:{start:0}},r.mutate={array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAllWith:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignAll:!0,assignAllWith:!0,assignIn:!0,assignInAll:!0,assignInAllWith:!0,assignInWith:!0,assignWith:!0,defaults:!0,defaultsAll:!0,defaultsDeep:!0,defaultsDeepAll:!0,merge:!0,mergeAll:!0,mergeAllWith:!0,mergeWith:!0},set:{set:!0,setWith:!0,unset:!0,update:!0,updateWith:!0}},r.realToAlias=function(){var e=Object.prototype.hasOwnProperty,t=r.aliasToReal,n={};for(var i in t){var s=t[i];e.call(n,s)?n[s].push(i):n[s]=[i]}return n}(),r.remap={assignAll:"assign",assignAllWith:"assignWith",assignInAll:"assignIn",assignInAllWith:"assignInWith",curryN:"curry",curryRightN:"curryRight",defaultsAll:"defaults",defaultsDeepAll:"defaultsDeep",findFrom:"find",findIndexFrom:"findIndex",findLastFrom:"findLast",findLastIndexFrom:"findLastIndex",getOr:"get",includesFrom:"includes",indexOfFrom:"indexOf",invokeArgs:"invoke",invokeArgsMap:"invokeMap",lastIndexOfFrom:"lastIndexOf",mergeAll:"merge",mergeAllWith:"mergeWith",padChars:"pad",padCharsEnd:"padEnd",padCharsStart:"padStart",propertyOf:"get",rangeStep:"range",rangeStepRight:"rangeRight",restFrom:"rest",spreadFrom:"spread",trimChars:"trim",trimCharsEnd:"trimEnd",trimCharsStart:"trimStart",zipAll:"zip"},r.skipFixed={castArray:!0,flow:!0,flowRight:!0,iteratee:!0,mixin:!0,rearg:!0,runInContext:!0},r.skipRearg={add:!0,assign:!0,assignIn:!0,bind:!0,bindKey:!0,concat:!0,difference:!0,divide:!0,eq:!0,gt:!0,gte:!0,isEqual:!0,lt:!0,lte:!0,matchesProperty:!0,merge:!0,multiply:!0,overArgs:!0,partial:!0,partialRight:!0,propertyOf:!0,random:!0,range:!0,rangeRight:!0,subtract:!0,zip:!0,zipObject:!0,zipObjectDeep:!0}})(JA);var Yg,XA;function ev(){return XA||(XA=1,Yg={}),Yg}var Cr=JA,VM=ev(),tv=Array.prototype.push;function WM(r,e){return e==2?function(t,n){return r.apply(void 0,arguments)}:function(t){return r.apply(void 0,arguments)}}function Jg(r,e){return e==2?function(t,n){return r(t,n)}:function(t){return r(t)}}function rv(r){for(var e=r?r.length:0,t=Array(e);e--;)t[e]=r[e];return t}function qM(r){return function(e){return r({},e)}}function ZM(r,e){return function(){for(var t=arguments.length,n=t-1,i=Array(t);t--;)i[t]=arguments[t];var s=i[e],o=i.slice(0,e);return s&&tv.apply(o,s),e!=n&&tv.apply(o,i.slice(e+1)),r.apply(this,o)}}function Xg(r,e){return function(){var t=arguments.length;if(t){for(var n=Array(t);t--;)n[t]=arguments[t];var i=n[0]=e.apply(void 0,n);return r.apply(void 0,n),i}}}function ey(r,e,t,n){var i=typeof e=="function",s=e===Object(e);if(s&&(n=t,t=e,e=void 0),t==null)throw new TypeError;n||(n={});var o={cap:"cap"in n?n.cap:!0,curry:"curry"in n?n.curry:!0,fixed:"fixed"in n?n.fixed:!0,immutable:"immutable"in n?n.immutable:!0,rearg:"rearg"in n?n.rearg:!0},a=i?t:VM,u="curry"in n&&n.curry,l="fixed"in n&&n.fixed,h="rearg"in n&&n.rearg,g=i?t.runInContext():void 0,b=i?t:{ary:r.ary,assign:r.assign,clone:r.clone,curry:r.curry,forEach:r.forEach,isArray:r.isArray,isError:r.isError,isFunction:r.isFunction,isWeakMap:r.isWeakMap,iteratee:r.iteratee,keys:r.keys,rearg:r.rearg,toInteger:r.toInteger,toPath:r.toPath},w=b.ary,I=b.assign,S=b.clone,x=b.curry,C=b.forEach,H=b.isArray,D=b.isError,z=b.isFunction,W=b.isWeakMap,Z=b.keys,j=b.rearg,V=b.toInteger,oe=b.toPath,ce=Z(Cr.aryMethod),ie={castArray:function(te){return function(){var re=arguments[0];return H(re)?te(rv(re)):te.apply(void 0,arguments)}},iteratee:function(te){return function(){var re=arguments[0],he=arguments[1],ye=te(re,he),be=ye.length;return o.cap&&typeof he=="number"?(he=he>2?he-2:1,be&&be<=he?ye:Jg(ye,he)):ye}},mixin:function(te){return function(re){var he=this;if(!z(he))return te(he,Object(re));var ye=[];return C(Z(re),function(be){z(re[be])&&ye.push([be,he.prototype[be]])}),te(he,Object(re)),C(ye,function(be){var Ve=be[1];z(Ve)?he.prototype[be[0]]=Ve:delete he.prototype[be[0]]}),he}},nthArg:function(te){return function(re){var he=re<0?1:V(re)+1;return x(te(re),he)}},rearg:function(te){return function(re,he){var ye=he?he.length:0;return x(te(re,he),ye)}},runInContext:function(te){return function(re){return ey(r,te(re),n)}}};function ue(te,re){if(o.cap){var he=Cr.iterateeRearg[te];if(he)return G(re,he);var ye=!i&&Cr.iterateeAry[te];if(ye)return M(re,ye)}return re}function B(te,re,he){return u||o.curry&&he>1?x(re,he):re}function p(te,re,he){if(o.fixed&&(l||!Cr.skipFixed[te])){var ye=Cr.methodSpread[te],be=ye&&ye.start;return be===void 0?w(re,he):ZM(re,be)}return re}function m(te,re,he){return o.rearg&&he>1&&(h||!Cr.skipRearg[te])?j(re,Cr.methodRearg[te]||Cr.aryRearg[he]):re}function E(te,re){re=oe(re);for(var he=-1,ye=re.length,be=ye-1,Ve=S(Object(te)),Fe=Ve;Fe!=null&&++he<ye;){var Be=re[he],et=Fe[Be];et!=null&&!(z(et)||D(et)||W(et))&&(Fe[Be]=S(he==be?et:Object(et))),Fe=Fe[Be]}return Ve}function k(te){return U.runInContext.convert(te)(void 0)}function O(te,re){var he=Cr.aliasToReal[te]||te,ye=Cr.remap[he]||he,be=n;return function(Ve){var Fe=i?g:b,Be=i?g[ye]:re,et=I(I({},be),Ve);return ey(Fe,he,Be,et)}}function M(te,re){return P(te,function(he){return typeof he=="function"?Jg(he,re):he})}function G(te,re){return P(te,function(he){var ye=re.length;return WM(j(Jg(he,ye),re),ye)})}function P(te,re){return function(){var he=arguments.length;if(!he)return te();for(var ye=Array(he);he--;)ye[he]=arguments[he];var be=o.rearg?0:he-1;return ye[be]=re(ye[be]),te.apply(void 0,ye)}}function A(te,re,he){var ye,be=Cr.aliasToReal[te]||te,Ve=re,Fe=ie[be];return Fe?Ve=Fe(re):o.immutable&&(Cr.mutate.array[be]?Ve=Xg(re,rv):Cr.mutate.object[be]?Ve=Xg(re,qM(re)):Cr.mutate.set[be]&&(Ve=Xg(re,E))),C(ce,function(Be){return C(Cr.aryMethod[Be],function(et){if(be==et){var Qe=Cr.methodSpread[be],ot=Qe&&Qe.afterRearg;return ye=ot?p(be,m(be,Ve,Be),Be):m(be,p(be,Ve,Be),Be),ye=ue(be,ye),ye=B(be,ye,Be),!1}}),!ye}),ye||(ye=Ve),ye==re&&(ye=u?x(ye,1):function(){return re.apply(this,arguments)}),ye.convert=O(be,re),ye.placeholder=re.placeholder=he,ye}if(!s)return A(e,t,a);var U=t,le=[];return C(ce,function(te){C(Cr.aryMethod[te],function(re){var he=U[Cr.remap[re]||re];he&&le.push([re,A(re,he,U)])})}),C(Z(U),function(te){var re=U[te];if(typeof re=="function"){for(var he=le.length;he--;)if(le[he][0]==te)return;re.convert=O(te,re),le.push([te,re])}}),C(le,function(te){U[te[0]]=te[1]}),U.convert=k,U.placeholder=U,C(Z(U),function(te){C(Cr.realToAlias[te]||[],function(re){U[re]=U[te]})}),U}var QM=ey,ty,nv;function Wd(){if(nv)return ty;nv=1;function r(e){return e}return ty=r,ty}var iv=mA,YM=iv&&new iv,sv=YM,JM=Wd(),ov=sv,XM=ov?function(r,e){return ov.set(r,e),r}:JM,av=XM,ry,cv;function qd(){if(cv)return ry;cv=1;var r=yi,e=Object.create,t=function(){function n(){}return function(i){if(!r(i))return{};if(e)return e(i);n.prototype=i;var s=new n;return n.prototype=void 0,s}}();return ry=t,ry}var eL=qd(),tL=yi;function rL(r){return function(){var e=arguments;switch(e.length){case 0:return new r;case 1:return new r(e[0]);case 2:return new r(e[0],e[1]);case 3:return new r(e[0],e[1],e[2]);case 4:return new r(e[0],e[1],e[2],e[3]);case 5:return new r(e[0],e[1],e[2],e[3],e[4]);case 6:return new r(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new r(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var t=eL(r.prototype),n=r.apply(t,e);return tL(n)?n:t}}var Zd=rL,nL=Zd,iL=Rn,sL=1;function oL(r,e,t){var n=e&sL,i=nL(r);function s(){var o=this&&this!==iL&&this instanceof s?i:r;return o.apply(n?t:this,arguments)}return s}var aL=oL,ny,uv;function iy(){if(uv)return ny;uv=1;function r(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return ny=r,ny}var cL=Math.max;function uL(r,e,t,n){for(var i=-1,s=r.length,o=t.length,a=-1,u=e.length,l=cL(s-o,0),h=Array(u+l),g=!n;++a<u;)h[a]=e[a];for(;++i<o;)(g||i<s)&&(h[t[i]]=r[i]);for(;l--;)h[a++]=r[i++];return h}var lv=uL,lL=Math.max;function fL(r,e,t,n){for(var i=-1,s=r.length,o=-1,a=t.length,u=-1,l=e.length,h=lL(s-a,0),g=Array(h+l),b=!n;++i<h;)g[i]=r[i];for(var w=i;++u<l;)g[w+u]=e[u];for(;++o<a;)(b||i<s)&&(g[w+t[o]]=r[i++]);return g}var fv=fL;function hL(r,e){for(var t=r.length,n=0;t--;)r[t]===e&&++n;return n}var dL=hL;function pL(){}var sy=pL,gL=qd(),yL=sy,mL=4294967295;function Qd(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=mL,this.__views__=[]}Qd.prototype=gL(yL.prototype),Qd.prototype.constructor=Qd;var oy=Qd;function wL(){}var bL=wL,hv=sv,_L=bL,AL=hv?function(r){return hv.get(r)}:_L,dv=AL,vL={},EL=vL,pv=EL,xL=Object.prototype,RL=xL.hasOwnProperty;function IL(r){for(var e=r.name+"",t=pv[e],n=RL.call(pv,e)?t.length:0;n--;){var i=t[n],s=i.func;if(s==null||s==r)return i.name}return e}var SL=IL,kL=qd(),TL=sy;function Yd(r,e){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}Yd.prototype=kL(TL.prototype),Yd.prototype.constructor=Yd;var gv=Yd;function OL(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var gf=OL,NL=oy,CL=gv,BL=gf;function PL(r){if(r instanceof NL)return r.clone();var e=new CL(r.__wrapped__,r.__chain__);return e.__actions__=BL(r.__actions__),e.__index__=r.__index__,e.__values__=r.__values__,e}var ML=PL,LL=oy,yv=gv,UL=sy,DL=In,$L=Xn,FL=ML,HL=Object.prototype,zL=HL.hasOwnProperty;function Jd(r){if($L(r)&&!DL(r)&&!(r instanceof LL)){if(r instanceof yv)return r;if(zL.call(r,"__wrapped__"))return FL(r)}return new yv(r)}Jd.prototype=UL.prototype,Jd.prototype.constructor=Jd;var GL=Jd,jL=oy,KL=dv,VL=SL,WL=GL;function qL(r){var e=VL(r),t=WL[e];if(typeof t!="function"||!(e in jL.prototype))return!1;if(r===t)return!0;var n=KL(t);return!!n&&r===n[0]}var ZL=qL,ay,mv;function wv(){if(mv)return ay;mv=1;var r=800,e=16,t=Date.now;function n(i){var s=0,o=0;return function(){var a=t(),u=e-(a-o);if(o=a,u>0){if(++s>=r)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return ay=n,ay}var QL=av,YL=wv(),JL=YL(QL),bv=JL,XL=/\{\n\/\* \[wrapped with (.+)\] \*/,eU=/,? & /;function tU(r){var e=r.match(XL);return e?e[1].split(eU):[]}var rU=tU,nU=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function iU(r,e){var t=e.length;if(!t)return r;var n=t-1;return e[n]=(t>1?"& ":"")+e[n],e=e.join(t>2?", ":" "),r.replace(nU,`{
12
+ /* [wrapped with `+e+`] */
13
+ `)}var sU=iU,cy,_v;function oU(){if(_v)return cy;_v=1;function r(e){return function(){return e}}return cy=r,cy}var uy,Av;function vv(){if(Av)return uy;Av=1;var r=fa,e=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}}();return uy=e,uy}var ly,Ev;function aU(){if(Ev)return ly;Ev=1;var r=oU(),e=vv(),t=Wd(),n=e?function(i,s){return e(i,"toString",{configurable:!0,enumerable:!1,value:r(s),writable:!0})}:t;return ly=n,ly}var fy,xv;function hy(){if(xv)return fy;xv=1;var r=aU(),e=wv(),t=e(r);return fy=t,fy}function cU(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var dy=cU;function uU(r,e,t,n){for(var i=r.length,s=t+(n?1:-1);n?s--:++s<i;)if(e(r[s],s,r))return s;return-1}var lU=uU;function fU(r){return r!==r}var hU=fU;function dU(r,e,t){for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}var pU=dU,gU=lU,yU=hU,mU=pU;function wU(r,e,t){return e===e?mU(r,e,t):gU(r,yU,t)}var bU=wU,_U=bU;function AU(r,e){var t=r==null?0:r.length;return!!t&&_U(r,e,0)>-1}var vU=AU,EU=dy,xU=vU,RU=1,IU=2,SU=8,kU=16,TU=32,OU=64,NU=128,CU=256,BU=512,PU=[["ary",NU],["bind",RU],["bindKey",IU],["curry",SU],["curryRight",kU],["flip",BU],["partial",TU],["partialRight",OU],["rearg",CU]];function MU(r,e){return EU(PU,function(t){var n="_."+t[0];e&t[1]&&!xU(r,n)&&r.push(n)}),r.sort()}var LU=MU,UU=rU,DU=sU,$U=hy(),FU=LU;function HU(r,e,t){var n=e+"";return $U(r,DU(n,FU(UU(n),t)))}var Rv=HU,zU=ZL,GU=bv,jU=Rv,KU=1,VU=2,WU=4,qU=8,Iv=32,Sv=64;function ZU(r,e,t,n,i,s,o,a,u,l){var h=e&qU,g=h?o:void 0,b=h?void 0:o,w=h?s:void 0,I=h?void 0:s;e|=h?Iv:Sv,e&=~(h?Sv:Iv),e&WU||(e&=~(KU|VU));var S=[r,e,i,w,g,I,b,a,u,l],x=t.apply(void 0,S);return zU(r)&&GU(x,S),x.placeholder=n,jU(x,r,e)}var kv=ZU;function QU(r){var e=r;return e.placeholder}var Tv=QU,YU=gf,JU=Bd,XU=Math.min;function eD(r,e){for(var t=r.length,n=XU(e.length,t),i=YU(r);n--;){var s=e[n];r[n]=JU(s,t)?i[s]:void 0}return r}var tD=eD,Ov="__lodash_placeholder__";function rD(r,e){for(var t=-1,n=r.length,i=0,s=[];++t<n;){var o=r[t];(o===e||o===Ov)&&(r[t]=Ov,s[i++]=t)}return s}var py=rD,nD=lv,iD=fv,sD=dL,Nv=Zd,oD=kv,aD=Tv,cD=tD,uD=py,lD=Rn,fD=1,hD=2,dD=8,pD=16,gD=128,yD=512;function Cv(r,e,t,n,i,s,o,a,u,l){var h=e&gD,g=e&fD,b=e&hD,w=e&(dD|pD),I=e&yD,S=b?void 0:Nv(r);function x(){for(var C=arguments.length,H=Array(C),D=C;D--;)H[D]=arguments[D];if(w)var z=aD(x),W=sD(H,z);if(n&&(H=nD(H,n,i,w)),s&&(H=iD(H,s,o,w)),C-=W,w&&C<l){var Z=uD(H,z);return oD(r,e,Cv,x.placeholder,t,H,Z,a,u,l-C)}var j=g?t:this,V=b?j[r]:r;return C=H.length,a?H=cD(H,a):I&&C>1&&H.reverse(),h&&u<C&&(H.length=u),this&&this!==lD&&this instanceof x&&(V=S||Nv(V)),V.apply(j,H)}return x}var Bv=Cv,mD=iy(),wD=Zd,bD=Bv,_D=kv,AD=Tv,vD=py,ED=Rn;function xD(r,e,t){var n=wD(r);function i(){for(var s=arguments.length,o=Array(s),a=s,u=AD(i);a--;)o[a]=arguments[a];var l=s<3&&o[0]!==u&&o[s-1]!==u?[]:vD(o,u);if(s-=l.length,s<t)return _D(r,e,bD,i.placeholder,void 0,o,l,void 0,void 0,t-s);var h=this&&this!==ED&&this instanceof i?n:r;return mD(h,this,o)}return i}var RD=xD,ID=iy(),SD=Zd,kD=Rn,TD=1;function OD(r,e,t,n){var i=e&TD,s=SD(r);function o(){for(var a=-1,u=arguments.length,l=-1,h=n.length,g=Array(h+u),b=this&&this!==kD&&this instanceof o?s:r;++l<h;)g[l]=n[l];for(;u--;)g[l++]=arguments[++a];return ID(b,i?t:this,g)}return o}var ND=OD,CD=lv,BD=fv,Pv=py,Mv="__lodash_placeholder__",gy=1,PD=2,MD=4,Lv=8,yf=128,Uv=256,LD=Math.min;function UD(r,e){var t=r[1],n=e[1],i=t|n,s=i<(gy|PD|yf),o=n==yf&&t==Lv||n==yf&&t==Uv&&r[7].length<=e[8]||n==(yf|Uv)&&e[7].length<=e[8]&&t==Lv;if(!(s||o))return r;n&gy&&(r[2]=e[2],i|=t&gy?0:MD);var a=e[3];if(a){var u=r[3];r[3]=u?CD(u,a,e[4]):a,r[4]=u?Pv(r[3],Mv):e[4]}return a=e[5],a&&(u=r[5],r[5]=u?BD(u,a,e[6]):a,r[6]=u?Pv(r[5],Mv):e[6]),a=e[7],a&&(r[7]=a),n&yf&&(r[8]=r[8]==null?e[8]:LD(r[8],e[8])),r[9]==null&&(r[9]=e[9]),r[0]=e[0],r[1]=i,r}var DD=UD,$D=/\s/;function FD(r){for(var e=r.length;e--&&$D.test(r.charAt(e)););return e}var HD=FD,zD=HD,GD=/^\s+/;function jD(r){return r&&r.slice(0,zD(r)+1).replace(GD,"")}var KD=jD,VD=la,WD=Xn,qD="[object Symbol]";function ZD(r){return typeof r=="symbol"||WD(r)&&VD(r)==qD}var mf=ZD,QD=KD,Dv=yi,YD=mf,$v=NaN,JD=/^[-+]0x[0-9a-f]+$/i,XD=/^0b[01]+$/i,e$=/^0o[0-7]+$/i,t$=parseInt;function r$(r){if(typeof r=="number")return r;if(YD(r))return $v;if(Dv(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Dv(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=QD(r);var t=XD.test(r);return t||e$.test(r)?t$(r.slice(2),t?2:8):JD.test(r)?$v:+r}var n$=r$,i$=n$,Fv=1/0,s$=17976931348623157e292;function o$(r){if(!r)return r===0?r:0;if(r=i$(r),r===Fv||r===-Fv){var e=r<0?-1:1;return e*s$}return r===r?r:0}var a$=o$,c$=a$;function u$(r){var e=c$(r),t=e%1;return e===e?t?e-t:e:0}var Hv=u$,l$=av,f$=aL,h$=RD,d$=Bv,p$=ND,g$=dv,y$=DD,m$=bv,w$=Rv,zv=Hv,b$="Expected a function",Gv=1,_$=2,yy=8,my=16,wy=32,jv=64,Kv=Math.max;function A$(r,e,t,n,i,s,o,a){var u=e&_$;if(!u&&typeof r!="function")throw new TypeError(b$);var l=n?n.length:0;if(l||(e&=~(wy|jv),n=i=void 0),o=o===void 0?o:Kv(zv(o),0),a=a===void 0?a:zv(a),l-=i?i.length:0,e&jv){var h=n,g=i;n=i=void 0}var b=u?void 0:g$(r),w=[r,e,t,n,i,h,g,s,o,a];if(b&&y$(w,b),r=w[0],e=w[1],t=w[2],n=w[3],i=w[4],a=w[9]=w[9]===void 0?u?0:r.length:Kv(w[9]-l,0),!a&&e&(yy|my)&&(e&=~(yy|my)),!e||e==Gv)var I=f$(r,e,t);else e==yy||e==my?I=h$(r,e,a):(e==wy||e==(Gv|wy))&&!i.length?I=p$(r,e,t,n):I=d$.apply(void 0,w);var S=b?l$:m$;return w$(S(I,w),r,e)}var by=A$,v$=by,E$=128;function x$(r,e,t){return e=t?void 0:e,e=r&&e==null?r.length:e,v$(r,E$,void 0,void 0,void 0,void 0,e)}var R$=x$,_y,Vv;function Ay(){if(Vv)return _y;Vv=1;var r=vv();function e(t,n,i){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return _y=e,_y}var I$=Ay(),S$=ql,k$=Object.prototype,T$=k$.hasOwnProperty;function O$(r,e,t){var n=r[e];(!(T$.call(r,e)&&S$(n,t))||t===void 0&&!(e in r))&&I$(r,e,t)}var Wv=O$,N$=Wv,C$=Ay();function B$(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],u=n?n(t[a],r[a],a,t,r):void 0;u===void 0&&(u=r[a]),i?C$(t,a,u):N$(t,a,u)}return t}var wf=B$,P$=wf,M$=Ld;function L$(r,e){return r&&P$(e,M$(e),r)}var qv=L$,vy,Zv;function U$(){if(Zv)return vy;Zv=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return vy=r,vy}var Ey,Qv;function D$(){if(Qv)return Ey;Qv=1;var r=yi,e=Bg,t=U$(),n=Object.prototype,i=n.hasOwnProperty;function s(o){if(!r(o))return t(o);var a=e(o),u=[];for(var l in o)l=="constructor"&&(a||!i.call(o,l))||u.push(l);return u}return Ey=s,Ey}var xy,Yv;function bf(){if(Yv)return xy;Yv=1;var r=hA,e=D$(),t=Md;function n(i){return t(i)?r(i,!0):e(i)}return xy=n,xy}var $$=wf,F$=bf();function H$(r,e){return r&&$$(e,F$(e),r)}var z$=H$,_f={exports:{}};_f.exports;var Jv;function Xv(){return Jv||(Jv=1,function(r,e){var t=Rn,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,s=i&&i.exports===n,o=s?t.Buffer:void 0,a=o?o.allocUnsafe:void 0;function u(l,h){if(h)return l.slice();var g=l.length,b=a?a(g):new l.constructor(g);return l.copy(b),b}r.exports=u}(_f,_f.exports)),_f.exports}var G$=wf,j$=kg;function K$(r,e){return G$(r,j$(r),e)}var V$=K$,W$=dA,q$=W$(Object.getPrototypeOf,Object),Ry=q$,Z$=Sg,Q$=Ry,Y$=kg,J$=oA,X$=Object.getOwnPropertySymbols,eF=X$?function(r){for(var e=[];r;)Z$(e,Y$(r)),r=Q$(r);return e}:J$,eE=eF,tF=wf,rF=eE;function nF(r,e){return tF(r,rF(r),e)}var iF=nF,sF=sA,oF=eE,aF=bf();function cF(r){return sF(r,aF,oF)}var uF=cF,lF=Object.prototype,fF=lF.hasOwnProperty;function hF(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&fF.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var dF=hF,Iy,tE;function Sy(){if(tE)return Iy;tE=1;var r=tA;function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return Iy=e,Iy}var pF=Sy();function gF(r,e){var t=e?pF(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var yF=gF,mF=/\w*$/;function wF(r){var e=new r.constructor(r.source,mF.exec(r));return e.lastIndex=r.lastIndex,e}var bF=wF,rE=Uc,nE=rE?rE.prototype:void 0,iE=nE?nE.valueOf:void 0;function _F(r){return iE?Object(iE.call(r)):{}}var AF=_F,ky,sE;function oE(){if(sE)return ky;sE=1;var r=Sy();function e(t,n){var i=n?r(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return ky=e,ky}var vF=Sy(),EF=yF,xF=bF,RF=AF,IF=oE(),SF="[object Boolean]",kF="[object Date]",TF="[object Map]",OF="[object Number]",NF="[object RegExp]",CF="[object Set]",BF="[object String]",PF="[object Symbol]",MF="[object ArrayBuffer]",LF="[object DataView]",UF="[object Float32Array]",DF="[object Float64Array]",$F="[object Int8Array]",FF="[object Int16Array]",HF="[object Int32Array]",zF="[object Uint8Array]",GF="[object Uint8ClampedArray]",jF="[object Uint16Array]",KF="[object Uint32Array]";function VF(r,e,t){var n=r.constructor;switch(e){case MF:return vF(r);case SF:case kF:return new n(+r);case LF:return EF(r,t);case UF:case DF:case $F:case FF:case HF:case zF:case GF:case jF:case KF:return IF(r,t);case TF:return new n;case OF:case BF:return new n(r);case NF:return xF(r);case CF:return new n;case PF:return RF(r)}}var WF=VF,Ty,aE;function cE(){if(aE)return Ty;aE=1;var r=qd(),e=Ry,t=Bg;function n(i){return typeof i.constructor=="function"&&!t(i)?r(e(i)):{}}return Ty=n,Ty}var qF=Ql,ZF=Xn,QF="[object Map]";function YF(r){return ZF(r)&&qF(r)==QF}var JF=YF,XF=JF,e9=Og,uE=Ng,lE=uE&&uE.isMap,t9=lE?e9(lE):XF,r9=t9,n9=Ql,i9=Xn,s9="[object Set]";function o9(r){return i9(r)&&n9(r)==s9}var a9=o9,c9=a9,u9=Og,fE=Ng,hE=fE&&fE.isSet,l9=hE?u9(hE):c9,f9=l9,h9=kd,d9=dy,p9=Wv,g9=qv,y9=z$,m9=Xv(),w9=gf,b9=V$,_9=iF,A9=gA,v9=uF,E9=Ql,x9=dF,R9=WF,I9=cE(),S9=In,k9=Cd,T9=r9,O9=yi,N9=f9,C9=Ld,B9=bf(),P9=1,M9=2,L9=4,dE="[object Arguments]",U9="[object Array]",D9="[object Boolean]",$9="[object Date]",F9="[object Error]",pE="[object Function]",H9="[object GeneratorFunction]",z9="[object Map]",G9="[object Number]",gE="[object Object]",j9="[object RegExp]",K9="[object Set]",V9="[object String]",W9="[object Symbol]",q9="[object WeakMap]",Z9="[object ArrayBuffer]",Q9="[object DataView]",Y9="[object Float32Array]",J9="[object Float64Array]",X9="[object Int8Array]",eH="[object Int16Array]",tH="[object Int32Array]",rH="[object Uint8Array]",nH="[object Uint8ClampedArray]",iH="[object Uint16Array]",sH="[object Uint32Array]",Ft={};Ft[dE]=Ft[U9]=Ft[Z9]=Ft[Q9]=Ft[D9]=Ft[$9]=Ft[Y9]=Ft[J9]=Ft[X9]=Ft[eH]=Ft[tH]=Ft[z9]=Ft[G9]=Ft[gE]=Ft[j9]=Ft[K9]=Ft[V9]=Ft[W9]=Ft[rH]=Ft[nH]=Ft[iH]=Ft[sH]=!0,Ft[F9]=Ft[pE]=Ft[q9]=!1;function Xd(r,e,t,n,i,s){var o,a=e&P9,u=e&M9,l=e&L9;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!O9(r))return r;var h=S9(r);if(h){if(o=x9(r),!a)return w9(r,o)}else{var g=E9(r),b=g==pE||g==H9;if(k9(r))return m9(r,a);if(g==gE||g==dE||b&&!i){if(o=u||b?{}:I9(r),!a)return u?_9(r,y9(o,r)):b9(r,g9(o,r))}else{if(!Ft[g])return i?r:{};o=R9(r,g,a)}}s||(s=new h9);var w=s.get(r);if(w)return w;s.set(r,o),N9(r)?r.forEach(function(x){o.add(Xd(x,e,t,x,r,s))}):T9(r)&&r.forEach(function(x,C){o.set(C,Xd(x,e,t,C,r,s))});var I=l?u?v9:A9:u?B9:C9,S=h?void 0:I(r);return d9(S||r,function(x,C){S&&(C=x,x=r[C]),p9(o,C,Xd(x,e,t,C,r,s))}),o}var yE=Xd,oH=yE,aH=4;function cH(r){return oH(r,aH)}var uH=cH,lH=by,fH=8;function Oy(r,e,t){e=t?void 0:e;var n=lH(r,fH,void 0,void 0,void 0,void 0,void 0,e);return n.placeholder=Oy.placeholder,n}Oy.placeholder={};var hH=Oy,dH=la,pH=Ry,gH=Xn,yH="[object Object]",mH=Function.prototype,wH=Object.prototype,mE=mH.toString,bH=wH.hasOwnProperty,_H=mE.call(Object);function AH(r){if(!gH(r)||dH(r)!=yH)return!1;var e=pH(r);if(e===null)return!0;var t=bH.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&mE.call(t)==_H}var wE=AH,vH=la,EH=Xn,xH=wE,RH="[object DOMException]",IH="[object Error]";function SH(r){if(!EH(r))return!1;var e=vH(r);return e==IH||e==RH||typeof r.message=="string"&&typeof r.name=="string"&&!xH(r)}var kH=SH,TH=Ql,OH=Xn,NH="[object WeakMap]";function CH(r){return OH(r)&&TH(r)==NH}var BH=CH,PH=kd,MH=Fg,LH=1,UH=2;function DH(r,e,t,n){var i=t.length,s=i,o=!n;if(r==null)return!s;for(r=Object(r);i--;){var a=t[i];if(o&&a[2]?a[1]!==r[a[0]]:!(a[0]in r))return!1}for(;++i<s;){a=t[i];var u=a[0],l=r[u],h=a[1];if(o&&a[2]){if(l===void 0&&!(u in r))return!1}else{var g=new PH;if(n)var b=n(l,h,u,r,e,g);if(!(b===void 0?MH(h,l,LH|UH,n,g):b))return!1}}return!0}var $H=DH,FH=yi;function HH(r){return r===r&&!FH(r)}var bE=HH,zH=bE,GH=Ld;function jH(r){for(var e=GH(r),t=e.length;t--;){var n=e[t],i=r[n];e[t]=[n,i,zH(i)]}return e}var KH=jH;function VH(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var _E=VH,WH=$H,qH=KH,ZH=_E;function QH(r){var e=qH(r);return e.length==1&&e[0][2]?ZH(e[0][0],e[0][1]):function(t){return t===r||WH(t,r,e)}}var YH=QH,JH=In,XH=mf,e7=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t7=/^\w*$/;function r7(r,e){if(JH(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||XH(r)?!0:t7.test(r)||!e7.test(r)||e!=null&&r in Object(e)}var Ny=r7,AE=Rg,n7="Expected a function";function Cy(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(n7);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(Cy.Cache||AE),t}Cy.Cache=AE;var i7=Cy,s7=i7,o7=500;function a7(r){var e=s7(r,function(n){return t.size===o7&&t.clear(),n}),t=e.cache;return e}var c7=a7,u7=c7,l7=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,f7=/\\(\\)?/g,h7=u7(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(l7,function(t,n,i,s){e.push(i?s.replace(f7,"$1"):n||t)}),e}),vE=h7;function d7(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var EE=d7,xE=Uc,p7=EE,g7=In,y7=mf,m7=1/0,RE=xE?xE.prototype:void 0,IE=RE?RE.toString:void 0;function SE(r){if(typeof r=="string")return r;if(g7(r))return p7(r,SE)+"";if(y7(r))return IE?IE.call(r):"";var e=r+"";return e=="0"&&1/r==-m7?"-0":e}var w7=SE,b7=w7;function _7(r){return r==null?"":b7(r)}var kE=_7,A7=In,v7=Ny,E7=vE,x7=kE;function R7(r,e){return A7(r)?r:v7(r,e)?[r]:E7(x7(r))}var TE=R7,I7=mf,S7=1/0;function k7(r){if(typeof r=="string"||I7(r))return r;var e=r+"";return e=="0"&&1/r==-S7?"-0":e}var Af=k7,T7=TE,O7=Af;function N7(r,e){e=T7(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[O7(e[t++])];return t&&t==n?r:void 0}var OE=N7,C7=OE;function B7(r,e,t){var n=r==null?void 0:C7(r,e);return n===void 0?t:n}var P7=B7;function M7(r,e){return r!=null&&e in Object(r)}var L7=M7,U7=TE,D7=Od,$7=In,F7=Bd,H7=Tg,z7=Af;function G7(r,e,t){e=U7(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=z7(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&H7(i)&&F7(o,i)&&($7(r)||D7(r)))}var j7=G7,K7=L7,V7=j7;function W7(r,e){return r!=null&&V7(r,e,K7)}var q7=W7,Z7=Fg,Q7=P7,Y7=q7,J7=Ny,X7=bE,ez=_E,tz=Af,rz=1,nz=2;function iz(r,e){return J7(r)&&X7(e)?ez(tz(r),e):function(t){var n=Q7(t,r);return n===void 0&&n===e?Y7(t,r):Z7(e,n,rz|nz)}}var sz=iz;function oz(r){return function(e){return e==null?void 0:e[r]}}var az=oz,cz=OE;function uz(r){return function(e){return cz(e,r)}}var lz=uz,fz=az,hz=lz,dz=Ny,pz=Af;function gz(r){return dz(r)?fz(pz(r)):hz(r)}var yz=gz,mz=YH,wz=sz,bz=Wd(),_z=In,Az=yz;function vz(r){return typeof r=="function"?r:r==null?bz:typeof r=="object"?_z(r)?wz(r[0],r[1]):mz(r):Az(r)}var Ez=vz,xz=yE,Rz=Ez,Iz=1;function Sz(r){return Rz(typeof r=="function"?r:xz(r,Iz))}var kz=Sz,NE=Uc,Tz=Od,Oz=In,CE=NE?NE.isConcatSpreadable:void 0;function Nz(r){return Oz(r)||Tz(r)||!!(CE&&r&&r[CE])}var Cz=Nz,Bz=Sg,Pz=Cz;function BE(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=Pz),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?BE(a,e-1,t,n,i):Bz(i,a):n||(i[i.length]=a)}return i}var Mz=BE,Lz=Mz;function Uz(r){var e=r==null?0:r.length;return e?Lz(r,1):[]}var Dz=Uz,By,PE;function ME(){if(PE)return By;PE=1;var r=iy(),e=Math.max;function t(n,i,s){return i=e(i===void 0?n.length-1:i,0),function(){for(var o=arguments,a=-1,u=e(o.length-i,0),l=Array(u);++a<u;)l[a]=o[i+a];a=-1;for(var h=Array(i+1);++a<i;)h[a]=o[a];return h[i]=s(l),r(n,this,h)}}return By=t,By}var $z=Dz,Fz=ME(),Hz=hy();function zz(r){return Hz(Fz(r,void 0,$z),r+"")}var Gz=zz,jz=by,Kz=Gz,Vz=256,Wz=Kz(function(r,e){return jz(r,Vz,void 0,void 0,void 0,e)}),qz=Wz,Zz=EE,Qz=gf,Yz=In,Jz=mf,Xz=vE,eG=Af,tG=kE;function rG(r){return Yz(r)?Zz(r,eG):Jz(r)?[r]:Qz(Xz(tG(r)))}var nG=rG,iG={ary:R$,assign:qv,clone:uH,curry:hH,forEach:dy,isArray:In,isError:kH,isFunction:Rd,isWeakMap:BH,iteratee:kz,keys:pA,rearg:qz,toInteger:Hv,toPath:nG},sG=QM,oG=iG;function aG(r,e,t){return sG(oG,r,e,t)}var cG=aG,Py,LE;function UE(){if(LE)return Py;LE=1;var r=Ay(),e=ql;function t(n,i,s){(s!==void 0&&!e(n[i],s)||s===void 0&&!(i in n))&&r(n,i,s)}return Py=t,Py}var My,DE;function uG(){if(DE)return My;DE=1;function r(e){return function(t,n,i){for(var s=-1,o=Object(t),a=i(t),u=a.length;u--;){var l=a[e?u:++s];if(n(o[l],l,o)===!1)break}return t}}return My=r,My}var Ly,$E;function lG(){if($E)return Ly;$E=1;var r=uG(),e=r();return Ly=e,Ly}var Uy,FE;function fG(){if(FE)return Uy;FE=1;var r=Md,e=Xn;function t(n){return e(n)&&r(n)}return Uy=t,Uy}var Dy,HE;function zE(){if(HE)return Dy;HE=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return Dy=r,Dy}var $y,GE;function hG(){if(GE)return $y;GE=1;var r=wf,e=bf();function t(n){return r(n,e(n))}return $y=t,$y}var Fy,jE;function dG(){if(jE)return Fy;jE=1;var r=UE(),e=Xv(),t=oE(),n=gf,i=cE(),s=Od,o=In,a=fG(),u=Cd,l=Rd,h=yi,g=wE,b=Cg,w=zE(),I=hG();function S(x,C,H,D,z,W,Z){var j=w(x,H),V=w(C,H),oe=Z.get(V);if(oe){r(x,H,oe);return}var ce=W?W(j,V,H+"",x,C,Z):void 0,ie=ce===void 0;if(ie){var ue=o(V),B=!ue&&u(V),p=!ue&&!B&&b(V);ce=V,ue||B||p?o(j)?ce=j:a(j)?ce=n(j):B?(ie=!1,ce=e(V,!0)):p?(ie=!1,ce=t(V,!0)):ce=[]:g(V)||s(V)?(ce=j,s(j)?ce=I(j):(!h(j)||l(j))&&(ce=i(V))):ie=!1}ie&&(Z.set(V,ce),z(ce,V,D,W,Z),Z.delete(V)),r(x,H,ce)}return Fy=S,Fy}var Hy,KE;function pG(){if(KE)return Hy;KE=1;var r=kd,e=UE(),t=lG(),n=dG(),i=yi,s=bf(),o=zE();function a(u,l,h,g,b){u!==l&&t(l,function(w,I){if(b||(b=new r),i(w))n(u,l,I,h,a,g,b);else{var S=g?g(o(u,I),w,I+"",u,l,b):void 0;S===void 0&&(S=w),e(u,I,S)}},s)}return Hy=a,Hy}var zy,VE;function gG(){if(VE)return zy;VE=1;var r=Wd(),e=ME(),t=hy();function n(i,s){return t(e(i,s,r),i+"")}return zy=n,zy}var Gy,WE;function yG(){if(WE)return Gy;WE=1;var r=ql,e=Md,t=Bd,n=yi;function i(s,o,a){if(!n(a))return!1;var u=typeof o;return(u=="number"?e(a)&&t(o,a.length):u=="string"&&o in a)?r(a[o],s):!1}return Gy=i,Gy}var jy,qE;function mG(){if(qE)return jy;qE=1;var r=gG(),e=yG();function t(n){return r(function(i,s){var o=-1,a=s.length,u=a>1?s[a-1]:void 0,l=a>2?s[2]:void 0;for(u=n.length>3&&typeof u=="function"?(a--,u):void 0,l&&e(s[0],s[1],l)&&(u=a<3?void 0:u,a=1),i=Object(i);++o<a;){var h=s[o];h&&n(i,h,o,u)}return i})}return jy=t,jy}var Ky,ZE;function wG(){if(ZE)return Ky;ZE=1;var r=pG(),e=mG(),t=e(function(n,i,s,o){r(n,i,s,o)});return Ky=t,Ky}var bG=cG,QE=bG("mergeWith",wG());QE.placeholder=ev();var _G=QE;const AG=xn(_G);class vG{constructor(e,t,n){this.userDetails=e,this.utils=t,this.emitter=n,this.mutex=new KM,this.logger=Ui.getInstance(),this.errorHandler=new Dd,this.messagesQueue=new jg({clearWaitTime:200}),this.history={allTimeUsers:{}},this.processedUpdaterRefs=new Set,this.loadedMessagesCache=new Set,this.updaterEntryBuffer=[],this.historyUpdateTimer=null,this.HISTORY_UPDATE_INTERVAL_TIME=5e3,this.MAX_LOADED_MESSAGES_CACHE_SIZE=10}async init(){const e=await this.fetchLatestHistoryEntry();if(!this.historyEntry&&!e){this.initializeDefaultEntry();return}if(e!=null&&e.ref){this.setHistoryEntry(e);const t=await this.fetchHistory(e);this.history=t||this.history,this.trimHistory(),await this.fetchPreviousMessages({preDownloadHistory:!1})}}startHistoryUpdateProcess(){if(this.historyUpdateTimer){this.logger.warn("History update process is already running.");return}this.historyUpdateTimer=setInterval(this.createHistoryEntry.bind(this),this.HISTORY_UPDATE_INTERVAL_TIME)}stopHistoryUpdateProcess(){this.historyUpdateTimer&&(clearInterval(this.historyUpdateTimer),this.historyUpdateTimer=null)}getHistoryEntryWithNewUpdater(e){return{...this.historyEntry,updater:this.chooseNewUpdater(e)}}setHistoryEntry(e){this.historyEntry=e}async processHistoryUpdaterEntry(e,t){const n=await this.mutex.acquire();try{this.updateLocalHistory(e),t.updater===this.userDetails.ownAddress&&this.updaterEntryBuffer.push(t)}catch(i){this.errorHandler.handleError(i,"Chat.processHistoryUpdaterEntry")}finally{n()}}async fetchPreviousMessages(e){const t=await this.mutex.acquire();try{const n=e.preDownloadHistory?await this.fetchHistory(this.historyEntry):null,{allTimeUsers:i}=n?this.mergeChatHistory(n,this.history):this.history,s=this.selectLatestMessages(i);s.length>0&&await this.readAllMessageEntry(s)}finally{t()}}async createHistoryEntry(){const e=await this.mutex.acquire();try{const t=this.selectBestEntryForUpdate([...this.updaterEntryBuffer]);if(!t||this.processedUpdaterRefs.has(t.ref)){this.cleanupUpdaterEntryBuffer(t==null?void 0:t.id);return}const n=t.ref?await this.fetchHistory(this.historyEntry):null,i=n?this.mergeChatHistory(n,this.history):this.history,s=await this.uploadHistory(i),o=this.createNewHistoryEntry(s);await this.waitForHistoryEntryBroadcast(o),this.cleanupUpdaterEntryBuffer(t.id),this.processedUpdaterRefs.add(t.ref)}catch(t){this.errorHandler.handleError(t,"Chat.updateHistory")}finally{e()}}async waitForHistoryEntryBroadcast(e){return QA({condition:()=>this.historyEntry.ref===e.ref,broadcast:()=>this.broadcastHistoryEntry(e)})}async broadcastHistoryEntry(e){try{await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({historyEntry:e}))),this.logger.debug("NEW history entry broadcast CALLED")}catch(t){this.errorHandler.handleError(t,"Chat.broadcastNewAppState")}}async uploadHistory(e){const t=await this.utils.uploadObjectToBee(e);if(!t)throw new Error("History reference is null");return t}async fetchHistory(e){const t=e||await this.fetchLatestHistoryEntry();if(!t)return null;const n=await this.utils.downloadObjectFromBee(t.ref);return LM(n)?n:(this.logger.warn("Could not fetch remote history: invalid history data"),null)}async fetchLatestHistoryEntry(){try{const e=await this.utils.fetchLatestChatMessage();return this.logger.debug("Init GSOC message:",e),ZA(e)?e.historyEntry:(this.logger.warn("Invalid GSOC message during latest history entry fetch"),null)}catch(e){return this.errorHandler.handleError(e,"Chat.fetchLatestHistoryEntry"),null}}async readAllMessageEntry(e){e.forEach(t=>{this.messagesQueue.enqueue(()=>this.readMessage(t))}),await this.messagesQueue.waitForProcessing()}async readMessage(e){try{const t=await this.utils.fetchUserFeedDataByIndex(e.address,e.entry.index);this.emitter.emit(ei.MESSAGE_RECEIVED,t)}catch(t){this.errorHandler.handleError(t,"SwarmHistory.readMessage")}}updateLocalHistory(e){const t={};Object.entries(e).forEach(([n,i])=>{t[n]={events:[],messageEntries:[{index:i.index,timestamp:i.timestamp}]}}),this.history={allTimeUsers:this.mergeUserHistory(t,this.history.allTimeUsers)}}mergeChatHistory(e,t){return{allTimeUsers:this.mergeUserHistory(e.allTimeUsers,t.allTimeUsers)}}mergeUserHistory(e,t){return AG((n,i)=>{if(!n)return i;if(!i)return n;const s=BA(n.events,i.events,a=>`${a.type}-${a.timestamp}`,(a,u)=>a.timestamp-u.timestamp),o=BA(n.messageEntries,i.messageEntries,a=>a.index,(a,u)=>a.timestamp-u.timestamp);return{events:s,messageEntries:o}},e,t)}trimHistory(e=2,t=1e4){try{const n=JSON.stringify(this.history);if(new Blob([n]).size/(1024*1024)<=e)return;const o=[];for(const l in this.history.allTimeUsers)this.history.allTimeUsers[l].messageEntries.forEach(g=>{o.push({address:l,entry:g})});o.sort((l,h)=>l.entry.timestamp-h.entry.timestamp);const a=o.slice(t),u={allTimeUsers:{}};for(const{address:l,entry:h}of a)u.allTimeUsers[l]||(u.allTimeUsers[l]={events:[],messageEntries:[]}),u.allTimeUsers[l].messageEntries.push(h);this.history=u}catch(n){this.errorHandler.handleError(n,"SwarmHistory.trimHistory")}}chooseNewUpdater(e){const t=Object.values(e);if(t.length===0)return this.userDetails.ownAddress;let n;if(window.crypto&&window.crypto.getRandomValues){const i=new Uint32Array(1);window.crypto.getRandomValues(i),n=i[0]%t.length}else n=Math.floor(Math.random()*t.length);return t[n].address}selectLatestMessages(e){const t=[];for(const[i,s]of Object.entries(e))for(const o of s.messageEntries)t.push({address:i,entry:o});t.sort((i,s)=>s.entry.timestamp-i.entry.timestamp);const n=[];for(const{address:i,entry:s}of t){const o=`${i}:${s.index}`;if(!this.loadedMessagesCache.has(o)&&(n.push({address:i,entry:s}),this.loadedMessagesCache.add(o),n.length===this.MAX_LOADED_MESSAGES_CACHE_SIZE))break}return n}selectBestEntryForUpdate(e){return e.filter(t=>t.updater===this.userDetails.ownAddress).reduce((t,n)=>!t||n.id>t.id||n.id===t.id&&n.timestamp>t.timestamp?n:t,null)}cleanupUpdaterEntryBuffer(e){e!==void 0&&(this.updaterEntryBuffer=this.updaterEntryBuffer.filter(t=>t.id!==e))}createNewHistoryEntry(e){return{id:this.historyEntry.id+1,ref:e,updater:this.userDetails.ownAddress,timestamp:Date.now()}}initializeDefaultEntry(){this.historyEntry={id:0,ref:"",updater:this.userDetails.ownAddress,timestamp:Date.now()}}}const qc=globalThis||void 0||self;var Vy={},e0={};e0.byteLength=RG,e0.toByteArray=SG,e0.fromByteArray=OG;for(var Hi=[],ti=[],EG=typeof Uint8Array<"u"?Uint8Array:Array,Wy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zc=0,xG=Wy.length;Zc<xG;++Zc)Hi[Zc]=Wy[Zc],ti[Wy.charCodeAt(Zc)]=Zc;ti[45]=62,ti[95]=63;function YE(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function RG(r){var e=YE(r),t=e[0],n=e[1];return(t+n)*3/4-n}function IG(r,e,t){return(e+t)*3/4-t}function SG(r){var e,t=YE(r),n=t[0],i=t[1],s=new EG(IG(r,n,i)),o=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)e=ti[r.charCodeAt(u)]<<18|ti[r.charCodeAt(u+1)]<<12|ti[r.charCodeAt(u+2)]<<6|ti[r.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=ti[r.charCodeAt(u)]<<2|ti[r.charCodeAt(u+1)]>>4,s[o++]=e&255),i===1&&(e=ti[r.charCodeAt(u)]<<10|ti[r.charCodeAt(u+1)]<<4|ti[r.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function kG(r){return Hi[r>>18&63]+Hi[r>>12&63]+Hi[r>>6&63]+Hi[r&63]}function TG(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(kG(n));return i.join("")}function OG(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,a=t-n;o<a;o+=s)i.push(TG(r,o,o+s>a?a:o+s));return n===1?(e=r[t-1],i.push(Hi[e>>2]+Hi[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(Hi[e>>10]+Hi[e>>4&63]+Hi[e<<2&63]+"=")),i.join("")}var qy={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */qy.read=function(r,e,t,n,i){var s,o,a=i*8-n-1,u=(1<<a)-1,l=u>>1,h=-7,g=t?i-1:0,b=t?-1:1,w=r[e+g];for(g+=b,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+r[e+g],g+=b,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+r[e+g],g+=b,h-=8);if(s===0)s=1-l;else{if(s===u)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)},qy.write=function(r,e,t,n,i,s){var o,a,u,l=s*8-i-1,h=(1<<l)-1,g=h>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,I=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+g>=1?e+=b/u:e+=b*Math.pow(2,1-g),e*u>=2&&(o++,u/=2),o+g>=h?(a=0,o=h):o+g>=1?(a=(e*u-1)*Math.pow(2,i),o=o+g):(a=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;r[t+w]=a&255,w+=I,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;r[t+w]=o&255,w+=I,o/=256,l-=8);r[t+w-I]|=S*128};/*!
5
14
  * The buffer module from node.js, for the browser.
6
15
  *
7
16
  * @author Feross Aboukhadijeh <https://feross.org>
8
17
  * @license MIT
9
- */(function(t){const e=base64Js,n=ieee754,a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=d,t.SlowBuffer=W,t.INSPECT_MAX_BYTES=50;const c=2147483647;t.kMaxLength=c;const{Uint8Array:o,ArrayBuffer:u,SharedArrayBuffer:h}=globalThis;d.TYPED_ARRAY_SUPPORT=l(),!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const V=new o(1),T={foo:function(){return 42}};return Object.setPrototypeOf(T,o.prototype),Object.setPrototypeOf(V,T),V.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function b(V){if(V>c)throw new RangeError('The value "'+V+'" is invalid for option "size"');const T=new o(V);return Object.setPrototypeOf(T,d.prototype),T}function d(V,T,O){if(typeof V=="number"){if(typeof T=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(V)}return p(V,T,O)}d.poolSize=8192;function p(V,T,O){if(typeof V=="string")return g(V,T);if(u.isView(V))return B(V);if(V==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof V);if(Be(V,u)||V&&Be(V.buffer,u)||typeof h<"u"&&(Be(V,h)||V&&Be(V.buffer,h)))return C(V,T,O);if(typeof V=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const X=V.valueOf&&V.valueOf();if(X!=null&&X!==V)return d.from(X,T,O);const ne=F(V);if(ne)return ne;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof V[Symbol.toPrimitive]=="function")return d.from(V[Symbol.toPrimitive]("string"),T,O);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof V)}d.from=function(V,T,O){return p(V,T,O)},Object.setPrototypeOf(d.prototype,o.prototype),Object.setPrototypeOf(d,o);function x(V){if(typeof V!="number")throw new TypeError('"size" argument must be of type number');if(V<0)throw new RangeError('The value "'+V+'" is invalid for option "size"')}function m(V,T,O){return x(V),V<=0?b(V):T!==void 0?typeof O=="string"?b(V).fill(T,O):b(V).fill(T):b(V)}d.alloc=function(V,T,O){return m(V,T,O)};function v(V){return x(V),b(V<0?0:H(V)|0)}d.allocUnsafe=function(V){return v(V)},d.allocUnsafeSlow=function(V){return v(V)};function g(V,T){if((typeof T!="string"||T==="")&&(T="utf8"),!d.isEncoding(T))throw new TypeError("Unknown encoding: "+T);const O=Z(V,T)|0;let X=b(O);const ne=X.write(V,T);return ne!==O&&(X=X.slice(0,ne)),X}function $(V){const T=V.length<0?0:H(V.length)|0,O=b(T);for(let X=0;X<T;X+=1)O[X]=V[X]&255;return O}function B(V){if(Be(V,o)){const T=new o(V);return C(T.buffer,T.byteOffset,T.byteLength)}return $(V)}function C(V,T,O){if(T<0||V.byteLength<T)throw new RangeError('"offset" is outside of buffer bounds');if(V.byteLength<T+(O||0))throw new RangeError('"length" is outside of buffer bounds');let X;return T===void 0&&O===void 0?X=new o(V):O===void 0?X=new o(V,T):X=new o(V,T,O),Object.setPrototypeOf(X,d.prototype),X}function F(V){if(d.isBuffer(V)){const T=H(V.length)|0,O=b(T);return O.length===0||V.copy(O,0,0,T),O}if(V.length!==void 0)return typeof V.length!="number"||De(V.length)?b(0):$(V);if(V.type==="Buffer"&&Array.isArray(V.data))return $(V.data)}function H(V){if(V>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return V|0}function W(V){return+V!=V&&(V=0),d.alloc(+V)}d.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==d.prototype},d.compare=function(T,O){if(Be(T,o)&&(T=d.from(T,T.offset,T.byteLength)),Be(O,o)&&(O=d.from(O,O.offset,O.byteLength)),!d.isBuffer(T)||!d.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===O)return 0;let X=T.length,ne=O.length;for(let ce=0,ue=Math.min(X,ne);ce<ue;++ce)if(T[ce]!==O[ce]){X=T[ce],ne=O[ce];break}return X<ne?-1:ne<X?1:0},d.isEncoding=function(T){switch(String(T).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(T,O){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return d.alloc(0);let X;if(O===void 0)for(O=0,X=0;X<T.length;++X)O+=T[X].length;const ne=d.allocUnsafe(O);let ce=0;for(X=0;X<T.length;++X){let ue=T[X];if(Be(ue,o))ce+ue.length>ne.length?(d.isBuffer(ue)||(ue=d.from(ue)),ue.copy(ne,ce)):o.prototype.set.call(ne,ue,ce);else if(d.isBuffer(ue))ue.copy(ne,ce);else throw new TypeError('"list" argument must be an Array of Buffers');ce+=ue.length}return ne};function Z(V,T){if(d.isBuffer(V))return V.length;if(u.isView(V)||Be(V,u))return V.byteLength;if(typeof V!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof V);const O=V.length,X=arguments.length>2&&arguments[2]===!0;if(!X&&O===0)return 0;let ne=!1;for(;;)switch(T){case"ascii":case"latin1":case"binary":return O;case"utf8":case"utf-8":return ge(V).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O*2;case"hex":return O>>>1;case"base64":return Ne(V).length;default:if(ne)return X?-1:ge(V).length;T=(""+T).toLowerCase(),ne=!0}}d.byteLength=Z;function ie(V,T,O){let X=!1;if((T===void 0||T<0)&&(T=0),T>this.length||((O===void 0||O>this.length)&&(O=this.length),O<=0)||(O>>>=0,T>>>=0,O<=T))return"";for(V||(V="utf8");;)switch(V){case"hex":return E(this,T,O);case"utf8":case"utf-8":return M(this,T,O);case"ascii":return _(this,T,O);case"latin1":case"binary":return q(this,T,O);case"base64":return I(this,T,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,T,O);default:if(X)throw new TypeError("Unknown encoding: "+V);V=(V+"").toLowerCase(),X=!0}}d.prototype._isBuffer=!0;function te(V,T,O){const X=V[T];V[T]=V[O],V[O]=X}d.prototype.swap16=function(){const T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<T;O+=2)te(this,O,O+1);return this},d.prototype.swap32=function(){const T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<T;O+=4)te(this,O,O+3),te(this,O+1,O+2);return this},d.prototype.swap64=function(){const T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<T;O+=8)te(this,O,O+7),te(this,O+1,O+6),te(this,O+2,O+5),te(this,O+3,O+4);return this},d.prototype.toString=function(){const T=this.length;return T===0?"":arguments.length===0?M(this,0,T):ie.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(T){if(!d.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:d.compare(this,T)===0},d.prototype.inspect=function(){let T="";const O=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(T+=" ... "),"<Buffer "+T+">"},a&&(d.prototype[a]=d.prototype.inspect),d.prototype.compare=function(T,O,X,ne,ce){if(Be(T,o)&&(T=d.from(T,T.offset,T.byteLength)),!d.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(O===void 0&&(O=0),X===void 0&&(X=T?T.length:0),ne===void 0&&(ne=0),ce===void 0&&(ce=this.length),O<0||X>T.length||ne<0||ce>this.length)throw new RangeError("out of range index");if(ne>=ce&&O>=X)return 0;if(ne>=ce)return-1;if(O>=X)return 1;if(O>>>=0,X>>>=0,ne>>>=0,ce>>>=0,this===T)return 0;let ue=ce-ne,me=X-O;const Ee=Math.min(ue,me),xe=this.slice(ne,ce),Ae=T.slice(O,X);for(let _e=0;_e<Ee;++_e)if(xe[_e]!==Ae[_e]){ue=xe[_e],me=Ae[_e];break}return ue<me?-1:me<ue?1:0};function ae(V,T,O,X,ne){if(V.length===0)return-1;if(typeof O=="string"?(X=O,O=0):O>2147483647?O=2147483647:O<-2147483648&&(O=-2147483648),O=+O,De(O)&&(O=ne?0:V.length-1),O<0&&(O=V.length+O),O>=V.length){if(ne)return-1;O=V.length-1}else if(O<0)if(ne)O=0;else return-1;if(typeof T=="string"&&(T=d.from(T,X)),d.isBuffer(T))return T.length===0?-1:de(V,T,O,X,ne);if(typeof T=="number")return T=T&255,typeof o.prototype.indexOf=="function"?ne?o.prototype.indexOf.call(V,T,O):o.prototype.lastIndexOf.call(V,T,O):de(V,[T],O,X,ne);throw new TypeError("val must be string, number or Buffer")}function de(V,T,O,X,ne){let ce=1,ue=V.length,me=T.length;if(X!==void 0&&(X=String(X).toLowerCase(),X==="ucs2"||X==="ucs-2"||X==="utf16le"||X==="utf-16le")){if(V.length<2||T.length<2)return-1;ce=2,ue/=2,me/=2,O/=2}function Ee(Ae,_e){return ce===1?Ae[_e]:Ae.readUInt16BE(_e*ce)}let xe;if(ne){let Ae=-1;for(xe=O;xe<ue;xe++)if(Ee(V,xe)===Ee(T,Ae===-1?0:xe-Ae)){if(Ae===-1&&(Ae=xe),xe-Ae+1===me)return Ae*ce}else Ae!==-1&&(xe-=xe-Ae),Ae=-1}else for(O+me>ue&&(O=ue-me),xe=O;xe>=0;xe--){let Ae=!0;for(let _e=0;_e<me;_e++)if(Ee(V,xe+_e)!==Ee(T,_e)){Ae=!1;break}if(Ae)return xe}return-1}d.prototype.includes=function(T,O,X){return this.indexOf(T,O,X)!==-1},d.prototype.indexOf=function(T,O,X){return ae(this,T,O,X,!0)},d.prototype.lastIndexOf=function(T,O,X){return ae(this,T,O,X,!1)};function J(V,T,O,X){O=Number(O)||0;const ne=V.length-O;X?(X=Number(X),X>ne&&(X=ne)):X=ne;const ce=T.length;X>ce/2&&(X=ce/2);let ue;for(ue=0;ue<X;++ue){const me=parseInt(T.substr(ue*2,2),16);if(De(me))return ue;V[O+ue]=me}return ue}function R(V,T,O,X){return ve(ge(T,V.length-O),V,O,X)}function A(V,T,O,X){return ve(ye(T),V,O,X)}function y(V,T,O,X){return ve(Ne(T),V,O,X)}function w(V,T,O,X){return ve($e(T,V.length-O),V,O,X)}d.prototype.write=function(T,O,X,ne){if(O===void 0)ne="utf8",X=this.length,O=0;else if(X===void 0&&typeof O=="string")ne=O,X=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(X)?(X=X>>>0,ne===void 0&&(ne="utf8")):(ne=X,X=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ce=this.length-O;if((X===void 0||X>ce)&&(X=ce),T.length>0&&(X<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");ne||(ne="utf8");let ue=!1;for(;;)switch(ne){case"hex":return J(this,T,O,X);case"utf8":case"utf-8":return R(this,T,O,X);case"ascii":case"latin1":case"binary":return A(this,T,O,X);case"base64":return y(this,T,O,X);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,T,O,X);default:if(ue)throw new TypeError("Unknown encoding: "+ne);ne=(""+ne).toLowerCase(),ue=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(V,T,O){return T===0&&O===V.length?e.fromByteArray(V):e.fromByteArray(V.slice(T,O))}function M(V,T,O){O=Math.min(V.length,O);const X=[];let ne=T;for(;ne<O;){const ce=V[ne];let ue=null,me=ce>239?4:ce>223?3:ce>191?2:1;if(ne+me<=O){let Ee,xe,Ae,_e;switch(me){case 1:ce<128&&(ue=ce);break;case 2:Ee=V[ne+1],(Ee&192)===128&&(_e=(ce&31)<<6|Ee&63,_e>127&&(ue=_e));break;case 3:Ee=V[ne+1],xe=V[ne+2],(Ee&192)===128&&(xe&192)===128&&(_e=(ce&15)<<12|(Ee&63)<<6|xe&63,_e>2047&&(_e<55296||_e>57343)&&(ue=_e));break;case 4:Ee=V[ne+1],xe=V[ne+2],Ae=V[ne+3],(Ee&192)===128&&(xe&192)===128&&(Ae&192)===128&&(_e=(ce&15)<<18|(Ee&63)<<12|(xe&63)<<6|Ae&63,_e>65535&&_e<1114112&&(ue=_e))}}ue===null?(ue=65533,me=1):ue>65535&&(ue-=65536,X.push(ue>>>10&1023|55296),ue=56320|ue&1023),X.push(ue),ne+=me}return P(X)}const k=4096;function P(V){const T=V.length;if(T<=k)return String.fromCharCode.apply(String,V);let O="",X=0;for(;X<T;)O+=String.fromCharCode.apply(String,V.slice(X,X+=k));return O}function _(V,T,O){let X="";O=Math.min(V.length,O);for(let ne=T;ne<O;++ne)X+=String.fromCharCode(V[ne]&127);return X}function q(V,T,O){let X="";O=Math.min(V.length,O);for(let ne=T;ne<O;++ne)X+=String.fromCharCode(V[ne]);return X}function E(V,T,O){const X=V.length;(!T||T<0)&&(T=0),(!O||O<0||O>X)&&(O=X);let ne="";for(let ce=T;ce<O;++ce)ne+=Se[V[ce]];return ne}function j(V,T,O){const X=V.slice(T,O);let ne="";for(let ce=0;ce<X.length-1;ce+=2)ne+=String.fromCharCode(X[ce]+X[ce+1]*256);return ne}d.prototype.slice=function(T,O){const X=this.length;T=~~T,O=O===void 0?X:~~O,T<0?(T+=X,T<0&&(T=0)):T>X&&(T=X),O<0?(O+=X,O<0&&(O=0)):O>X&&(O=X),O<T&&(O=T);const ne=this.subarray(T,O);return Object.setPrototypeOf(ne,d.prototype),ne};function ee(V,T,O){if(V%1!==0||V<0)throw new RangeError("offset is not uint");if(V+T>O)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=this[T],ce=1,ue=0;for(;++ue<O&&(ce*=256);)ne+=this[T+ue]*ce;return ne},d.prototype.readUintBE=d.prototype.readUIntBE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=this[T+--O],ce=1;for(;O>0&&(ce*=256);)ne+=this[T+--O]*ce;return ne},d.prototype.readUint8=d.prototype.readUInt8=function(T,O){return T=T>>>0,O||ee(T,1,this.length),this[T]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(T,O){return T=T>>>0,O||ee(T,2,this.length),this[T]|this[T+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(T,O){return T=T>>>0,O||ee(T,2,this.length),this[T]<<8|this[T+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},d.prototype.readBigUInt64LE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=O+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,ce=this[++T]+this[++T]*2**8+this[++T]*2**16+X*2**24;return BigInt(ne)+(BigInt(ce)<<BigInt(32))}),d.prototype.readBigUInt64BE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=O*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],ce=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+X;return(BigInt(ne)<<BigInt(32))+BigInt(ce)}),d.prototype.readIntLE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=this[T],ce=1,ue=0;for(;++ue<O&&(ce*=256);)ne+=this[T+ue]*ce;return ce*=128,ne>=ce&&(ne-=Math.pow(2,8*O)),ne},d.prototype.readIntBE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=O,ce=1,ue=this[T+--ne];for(;ne>0&&(ce*=256);)ue+=this[T+--ne]*ce;return ce*=128,ue>=ce&&(ue-=Math.pow(2,8*O)),ue},d.prototype.readInt8=function(T,O){return T=T>>>0,O||ee(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},d.prototype.readInt16LE=function(T,O){T=T>>>0,O||ee(T,2,this.length);const X=this[T]|this[T+1]<<8;return X&32768?X|4294901760:X},d.prototype.readInt16BE=function(T,O){T=T>>>0,O||ee(T,2,this.length);const X=this[T+1]|this[T]<<8;return X&32768?X|4294901760:X},d.prototype.readInt32LE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},d.prototype.readInt32BE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},d.prototype.readBigInt64LE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(X<<24);return(BigInt(ne)<<BigInt(32))+BigInt(O+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),d.prototype.readBigInt64BE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=(O<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(ne)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+X)}),d.prototype.readFloatLE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),n.read(this,T,!0,23,4)},d.prototype.readFloatBE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),n.read(this,T,!1,23,4)},d.prototype.readDoubleLE=function(T,O){return T=T>>>0,O||ee(T,8,this.length),n.read(this,T,!0,52,8)},d.prototype.readDoubleBE=function(T,O){return T=T>>>0,O||ee(T,8,this.length),n.read(this,T,!1,52,8)};function oe(V,T,O,X,ne,ce){if(!d.isBuffer(V))throw new TypeError('"buffer" argument must be a Buffer instance');if(T>ne||T<ce)throw new RangeError('"value" argument is out of bounds');if(O+X>V.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(T,O,X,ne){if(T=+T,O=O>>>0,X=X>>>0,!ne){const me=Math.pow(2,8*X)-1;oe(this,T,O,X,me,0)}let ce=1,ue=0;for(this[O]=T&255;++ue<X&&(ce*=256);)this[O+ue]=T/ce&255;return O+X},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(T,O,X,ne){if(T=+T,O=O>>>0,X=X>>>0,!ne){const me=Math.pow(2,8*X)-1;oe(this,T,O,X,me,0)}let ce=X-1,ue=1;for(this[O+ce]=T&255;--ce>=0&&(ue*=256);)this[O+ce]=T/ue&255;return O+X},d.prototype.writeUint8=d.prototype.writeUInt8=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,1,255,0),this[O]=T&255,O+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,65535,0),this[O]=T&255,this[O+1]=T>>>8,O+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,65535,0),this[O]=T>>>8,this[O+1]=T&255,O+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,4294967295,0),this[O+3]=T>>>24,this[O+2]=T>>>16,this[O+1]=T>>>8,this[O]=T&255,O+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,4294967295,0),this[O]=T>>>24,this[O+1]=T>>>16,this[O+2]=T>>>8,this[O+3]=T&255,O+4};function Y(V,T,O,X,ne){he(T,X,ne,V,O,7);let ce=Number(T&BigInt(4294967295));V[O++]=ce,ce=ce>>8,V[O++]=ce,ce=ce>>8,V[O++]=ce,ce=ce>>8,V[O++]=ce;let ue=Number(T>>BigInt(32)&BigInt(4294967295));return V[O++]=ue,ue=ue>>8,V[O++]=ue,ue=ue>>8,V[O++]=ue,ue=ue>>8,V[O++]=ue,O}function L(V,T,O,X,ne){he(T,X,ne,V,O,7);let ce=Number(T&BigInt(4294967295));V[O+7]=ce,ce=ce>>8,V[O+6]=ce,ce=ce>>8,V[O+5]=ce,ce=ce>>8,V[O+4]=ce;let ue=Number(T>>BigInt(32)&BigInt(4294967295));return V[O+3]=ue,ue=ue>>8,V[O+2]=ue,ue=ue>>8,V[O+1]=ue,ue=ue>>8,V[O]=ue,O+8}d.prototype.writeBigUInt64LE=Oe(function(T,O=0){return Y(this,T,O,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Oe(function(T,O=0){return L(this,T,O,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(T,O,X,ne){if(T=+T,O=O>>>0,!ne){const Ee=Math.pow(2,8*X-1);oe(this,T,O,X,Ee-1,-Ee)}let ce=0,ue=1,me=0;for(this[O]=T&255;++ce<X&&(ue*=256);)T<0&&me===0&&this[O+ce-1]!==0&&(me=1),this[O+ce]=(T/ue>>0)-me&255;return O+X},d.prototype.writeIntBE=function(T,O,X,ne){if(T=+T,O=O>>>0,!ne){const Ee=Math.pow(2,8*X-1);oe(this,T,O,X,Ee-1,-Ee)}let ce=X-1,ue=1,me=0;for(this[O+ce]=T&255;--ce>=0&&(ue*=256);)T<0&&me===0&&this[O+ce+1]!==0&&(me=1),this[O+ce]=(T/ue>>0)-me&255;return O+X},d.prototype.writeInt8=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,1,127,-128),T<0&&(T=255+T+1),this[O]=T&255,O+1},d.prototype.writeInt16LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,32767,-32768),this[O]=T&255,this[O+1]=T>>>8,O+2},d.prototype.writeInt16BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,32767,-32768),this[O]=T>>>8,this[O+1]=T&255,O+2},d.prototype.writeInt32LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,2147483647,-2147483648),this[O]=T&255,this[O+1]=T>>>8,this[O+2]=T>>>16,this[O+3]=T>>>24,O+4},d.prototype.writeInt32BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[O]=T>>>24,this[O+1]=T>>>16,this[O+2]=T>>>8,this[O+3]=T&255,O+4},d.prototype.writeBigInt64LE=Oe(function(T,O=0){return Y(this,T,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Oe(function(T,O=0){return L(this,T,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function z(V,T,O,X,ne,ce){if(O+X>V.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("Index out of range")}function re(V,T,O,X,ne){return T=+T,O=O>>>0,ne||z(V,T,O,4),n.write(V,T,O,X,23,4),O+4}d.prototype.writeFloatLE=function(T,O,X){return re(this,T,O,!0,X)},d.prototype.writeFloatBE=function(T,O,X){return re(this,T,O,!1,X)};function D(V,T,O,X,ne){return T=+T,O=O>>>0,ne||z(V,T,O,8),n.write(V,T,O,X,52,8),O+8}d.prototype.writeDoubleLE=function(T,O,X){return D(this,T,O,!0,X)},d.prototype.writeDoubleBE=function(T,O,X){return D(this,T,O,!1,X)},d.prototype.copy=function(T,O,X,ne){if(!d.isBuffer(T))throw new TypeError("argument should be a Buffer");if(X||(X=0),!ne&&ne!==0&&(ne=this.length),O>=T.length&&(O=T.length),O||(O=0),ne>0&&ne<X&&(ne=X),ne===X||T.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(X<0||X>=this.length)throw new RangeError("Index out of range");if(ne<0)throw new RangeError("sourceEnd out of bounds");ne>this.length&&(ne=this.length),T.length-O<ne-X&&(ne=T.length-O+X);const ce=ne-X;return this===T&&typeof o.prototype.copyWithin=="function"?this.copyWithin(O,X,ne):o.prototype.set.call(T,this.subarray(X,ne),O),ce},d.prototype.fill=function(T,O,X,ne){if(typeof T=="string"){if(typeof O=="string"?(ne=O,O=0,X=this.length):typeof X=="string"&&(ne=X,X=this.length),ne!==void 0&&typeof ne!="string")throw new TypeError("encoding must be a string");if(typeof ne=="string"&&!d.isEncoding(ne))throw new TypeError("Unknown encoding: "+ne);if(T.length===1){const ue=T.charCodeAt(0);(ne==="utf8"&&ue<128||ne==="latin1")&&(T=ue)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(O<0||this.length<O||this.length<X)throw new RangeError("Out of range index");if(X<=O)return this;O=O>>>0,X=X===void 0?this.length:X>>>0,T||(T=0);let ce;if(typeof T=="number")for(ce=O;ce<X;++ce)this[ce]=T;else{const ue=d.isBuffer(T)?T:d.from(T,ne),me=ue.length;if(me===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(ce=0;ce<X-O;++ce)this[ce+O]=ue[ce%me]}return this};const G={};function U(V,T,O){G[V]=class extends O{constructor(){super(),Object.defineProperty(this,"message",{value:T.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${V}]`,this.stack,delete this.name}get code(){return V}set code(ne){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ne,writable:!0})}toString(){return`${this.name} [${V}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(V){return V?`${V} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(V,T){return`The "${V}" argument must be of type number. Received type ${typeof T}`},TypeError),U("ERR_OUT_OF_RANGE",function(V,T,O){let X=`The value of "${V}" is out of range.`,ne=O;return Number.isInteger(O)&&Math.abs(O)>2**32?ne=Q(String(O)):typeof O=="bigint"&&(ne=String(O),(O>BigInt(2)**BigInt(32)||O<-(BigInt(2)**BigInt(32)))&&(ne=Q(ne)),ne+="n"),X+=` It must be ${T}. Received ${ne}`,X},RangeError);function Q(V){let T="",O=V.length;const X=V[0]==="-"?1:0;for(;O>=X+4;O-=3)T=`_${V.slice(O-3,O)}${T}`;return`${V.slice(0,O)}${T}`}function fe(V,T,O){le(T,"offset"),(V[T]===void 0||V[T+O]===void 0)&&pe(T,V.length-(O+1))}function he(V,T,O,X,ne,ce){if(V>O||V<T){const ue=typeof T=="bigint"?"n":"";let me;throw T===0||T===BigInt(0)?me=`>= 0${ue} and < 2${ue} ** ${(ce+1)*8}${ue}`:me=`>= -(2${ue} ** ${(ce+1)*8-1}${ue}) and < 2 ** ${(ce+1)*8-1}${ue}`,new G.ERR_OUT_OF_RANGE("value",me,V)}fe(X,ne,ce)}function le(V,T){if(typeof V!="number")throw new G.ERR_INVALID_ARG_TYPE(T,"number",V)}function pe(V,T,O){throw Math.floor(V)!==V?(le(V,O),new G.ERR_OUT_OF_RANGE("offset","an integer",V)):T<0?new G.ERR_BUFFER_OUT_OF_BOUNDS:new G.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${T}`,V)}const be=/[^+/0-9A-Za-z-_]/g;function se(V){if(V=V.split("=")[0],V=V.trim().replace(be,""),V.length<2)return"";for(;V.length%4!==0;)V=V+"=";return V}function ge(V,T){T=T||1/0;let O;const X=V.length;let ne=null;const ce=[];for(let ue=0;ue<X;++ue){if(O=V.charCodeAt(ue),O>55295&&O<57344){if(!ne){if(O>56319){(T-=3)>-1&&ce.push(239,191,189);continue}else if(ue+1===X){(T-=3)>-1&&ce.push(239,191,189);continue}ne=O;continue}if(O<56320){(T-=3)>-1&&ce.push(239,191,189),ne=O;continue}O=(ne-55296<<10|O-56320)+65536}else ne&&(T-=3)>-1&&ce.push(239,191,189);if(ne=null,O<128){if((T-=1)<0)break;ce.push(O)}else if(O<2048){if((T-=2)<0)break;ce.push(O>>6|192,O&63|128)}else if(O<65536){if((T-=3)<0)break;ce.push(O>>12|224,O>>6&63|128,O&63|128)}else if(O<1114112){if((T-=4)<0)break;ce.push(O>>18|240,O>>12&63|128,O>>6&63|128,O&63|128)}else throw new Error("Invalid code point")}return ce}function ye(V){const T=[];for(let O=0;O<V.length;++O)T.push(V.charCodeAt(O)&255);return T}function $e(V,T){let O,X,ne;const ce=[];for(let ue=0;ue<V.length&&!((T-=2)<0);++ue)O=V.charCodeAt(ue),X=O>>8,ne=O%256,ce.push(ne),ce.push(X);return ce}function Ne(V){return e.toByteArray(se(V))}function ve(V,T,O,X){let ne;for(ne=0;ne<X&&!(ne+O>=T.length||ne>=V.length);++ne)T[ne+O]=V[ne];return ne}function Be(V,T){return V instanceof T||V!=null&&V.constructor!=null&&V.constructor.name!=null&&V.constructor.name===T.name}function De(V){return V!==V}const Se=function(){const V="0123456789abcdef",T=new Array(256);for(let O=0;O<16;++O){const X=O*16;for(let ne=0;ne<16;++ne)T[X+ne]=V[O]+V[ne]}return T}();function Oe(V){return typeof BigInt>"u"?je:V}function je(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer=buffer$1.Buffer,Buffer$1=buffer$1.Buffer,dist$1=Object.freeze(Object.defineProperty({__proto__:null,Buffer:Buffer$1,default:Buffer},Symbol.toStringTag,{value:"Module"}));var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs$1(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function getAugmentedNamespace(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function a(){return this instanceof a?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(a){var c=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,c.get?c:{enumerable:!0,get:function(){return t[a]}})}),n}var dist={},file={},chunk={},span={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_SPAN_LENGTH=t.DEFAULT_SPAN_SIZE=void 0,t.makeSpan=e,t.getSpanValue=n,t.DEFAULT_SPAN_SIZE=8,t.MAX_SPAN_LENGTH=Math.pow(2,32)-1;function e(a,c){const o=c||t.DEFAULT_SPAN_SIZE;if(a<0)throw new Error(`invalid length for span: ${a}`);if(a>t.MAX_SPAN_LENGTH)throw new Error(`invalid length (> ${t.MAX_SPAN_LENGTH}) ${a}`);const u=new Uint8Array(o),h=new DataView(u.buffer),l=!0,b=a&4294967295;return h.setUint32(0,b,l),u}function n(a){return new DataView(a.buffer).getUint32(0,!0)}})(span);var utils$p={};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var browser$c={exports:{}},process=browser$c.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(t){if(cachedSetTimeout===setTimeout)return setTimeout(t,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(t,0);try{return cachedSetTimeout(t,0)}catch{try{return cachedSetTimeout.call(null,t,0)}catch{return cachedSetTimeout.call(this,t,0)}}}function runClearTimeout(t){if(cachedClearTimeout===clearTimeout)return clearTimeout(t);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(t);try{return cachedClearTimeout(t)}catch{try{return cachedClearTimeout.call(null,t)}catch{return cachedClearTimeout.call(this,t)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var t=runTimeout(cleanUpNextTick);draining=!0;for(var e=queue.length;e;){for(currentQueue=queue,queue=[];++queueIndex<e;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,e=queue.length}currentQueue=null,draining=!1,runClearTimeout(t)}}process.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];queue.push(new Item(t,e)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(t,e){this.fun=t,this.array=e}Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={};function noop$1(){}process.on=noop$1,process.addListener=noop$1,process.once=noop$1,process.off=noop$1,process.removeListener=noop$1,process.removeAllListeners=noop$1,process.emit=noop$1,process.prependListener=noop$1,process.prependOnceListener=noop$1,process.listeners=function(t){return[]},process.binding=function(t){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(t){throw new Error("process.chdir is not supported")},process.umask=function(){return 0};var browserExports=browser$c.exports;const process$1=getDefaultExportFromCjs(browserExports);var sha3={exports:{}};(function(t){(function(){var e="input is invalid type",n="finalize already called",a=typeof window=="object",c=a?window:{};c.JS_SHA3_NO_WINDOW&&(a=!1);var o=!a&&typeof self=="object",u=!c.JS_SHA3_NO_NODE_JS&&typeof process$1=="object"&&process$1.versions&&process$1.versions.node;u?c=commonjsGlobal:o&&(c=self);for(var h=!c.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,l=!c.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",b="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],p=[4,1024,262144,67108864],x=[1,256,65536,16777216],m=[6,1536,393216,100663296],v=[0,8,16,24],g=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],$=[224,256,384,512],B=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],F={128:168,256:136},H=c.JS_SHA3_NO_NODE_JS||!Array.isArray?function(D){return Object.prototype.toString.call(D)==="[object Array]"}:Array.isArray,W=l&&(c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(D){return typeof D=="object"&&D.buffer&&D.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Z=function(D){var G=typeof D;if(G==="string")return[D,!0];if(G!=="object"||D===null)throw new Error(e);if(l&&D.constructor===ArrayBuffer)return[new Uint8Array(D),!1];if(!H(D)&&!W(D))throw new Error(e);return[D,!1]},ie=function(D){return Z(D)[0].length===0},te=function(D){for(var G=[],U=0;U<D.length;++U)G[U]=D[U];return G},ae=function(D,G,U){return function(Q){return new L(D,G,D).update(Q)[U]()}},de=function(D,G,U){return function(Q,fe){return new L(D,G,fe).update(Q)[U]()}},J=function(D,G,U){return function(Q,fe,he,le){return P["cshake"+D].update(Q,fe,he,le)[U]()}},R=function(D,G,U){return function(Q,fe,he,le){return P["kmac"+D].update(Q,fe,he,le)[U]()}},A=function(D,G,U,Q){for(var fe=0;fe<C.length;++fe){var he=C[fe];D[he]=G(U,Q,he)}return D},y=function(D,G){var U=ae(D,G,"hex");return U.create=function(){return new L(D,G,D)},U.update=function(Q){return U.create().update(Q)},A(U,ae,D,G)},w=function(D,G){var U=de(D,G,"hex");return U.create=function(Q){return new L(D,G,Q)},U.update=function(Q,fe){return U.create(fe).update(Q)},A(U,de,D,G)},I=function(D,G){var U=F[D],Q=J(D,G,"hex");return Q.create=function(fe,he,le){return ie(he)&&ie(le)?P["shake"+D].create(fe):new L(D,G,fe).bytepad([he,le],U)},Q.update=function(fe,he,le,pe){return Q.create(he,le,pe).update(fe)},A(Q,J,D,G)},M=function(D,G){var U=F[D],Q=R(D,G,"hex");return Q.create=function(fe,he,le){return new z(D,G,he).bytepad(["KMAC",le],U).bytepad([fe],U)},Q.update=function(fe,he,le,pe){return Q.create(fe,le,pe).update(he)},A(Q,R,D,G)},k=[{name:"keccak",padding:x,bits:$,createMethod:y},{name:"sha3",padding:m,bits:$,createMethod:y},{name:"shake",padding:d,bits:B,createMethod:w},{name:"cshake",padding:p,bits:B,createMethod:I},{name:"kmac",padding:p,bits:B,createMethod:M}],P={},_=[],q=0;q<k.length;++q)for(var E=k[q],j=E.bits,ee=0;ee<j.length;++ee){var oe=E.name+"_"+j[ee];if(_.push(oe),P[oe]=E.createMethod(j[ee],E.padding),E.name!=="sha3"){var Y=E.name+j[ee];_.push(Y),P[Y]=P[oe]}}function L(D,G,U){this.blocks=[],this.s=[],this.padding=G,this.outputBits=U,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(D<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=U>>5,this.extraBytes=(U&31)>>3;for(var Q=0;Q<50;++Q)this.s[Q]=0}L.prototype.update=function(D){if(this.finalized)throw new Error(n);var G=Z(D);D=G[0];for(var U=G[1],Q=this.blocks,fe=this.byteCount,he=D.length,le=this.blockCount,pe=0,be=this.s,se,ge;pe<he;){if(this.reset)for(this.reset=!1,Q[0]=this.block,se=1;se<le+1;++se)Q[se]=0;if(U)for(se=this.start;pe<he&&se<fe;++pe)ge=D.charCodeAt(pe),ge<128?Q[se>>2]|=ge<<v[se++&3]:ge<2048?(Q[se>>2]|=(192|ge>>6)<<v[se++&3],Q[se>>2]|=(128|ge&63)<<v[se++&3]):ge<55296||ge>=57344?(Q[se>>2]|=(224|ge>>12)<<v[se++&3],Q[se>>2]|=(128|ge>>6&63)<<v[se++&3],Q[se>>2]|=(128|ge&63)<<v[se++&3]):(ge=65536+((ge&1023)<<10|D.charCodeAt(++pe)&1023),Q[se>>2]|=(240|ge>>18)<<v[se++&3],Q[se>>2]|=(128|ge>>12&63)<<v[se++&3],Q[se>>2]|=(128|ge>>6&63)<<v[se++&3],Q[se>>2]|=(128|ge&63)<<v[se++&3]);else for(se=this.start;pe<he&&se<fe;++pe)Q[se>>2]|=D[pe]<<v[se++&3];if(this.lastByteIndex=se,se>=fe){for(this.start=se-fe,this.block=Q[le],se=0;se<le;++se)be[se]^=Q[se];re(be),this.reset=!0}else this.start=se}return this},L.prototype.encode=function(D,G){var U=D&255,Q=1,fe=[U];for(D=D>>8,U=D&255;U>0;)fe.unshift(U),D=D>>8,U=D&255,++Q;return G?fe.push(Q):fe.unshift(Q),this.update(fe),fe.length},L.prototype.encodeString=function(D){var G=Z(D);D=G[0];var U=G[1],Q=0,fe=D.length;if(U)for(var he=0;he<D.length;++he){var le=D.charCodeAt(he);le<128?Q+=1:le<2048?Q+=2:le<55296||le>=57344?Q+=3:(le=65536+((le&1023)<<10|D.charCodeAt(++he)&1023),Q+=4)}else Q=fe;return Q+=this.encode(Q*8),this.update(D),Q},L.prototype.bytepad=function(D,G){for(var U=this.encode(G),Q=0;Q<D.length;++Q)U+=this.encodeString(D[Q]);var fe=(G-U%G)%G,he=[];return he.length=fe,this.update(he),this},L.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var D=this.blocks,G=this.lastByteIndex,U=this.blockCount,Q=this.s;if(D[G>>2]|=this.padding[G&3],this.lastByteIndex===this.byteCount)for(D[0]=D[U],G=1;G<U+1;++G)D[G]=0;for(D[U-1]|=2147483648,G=0;G<U;++G)Q[G]^=D[G];re(Q)}},L.prototype.toString=L.prototype.hex=function(){this.finalize();for(var D=this.blockCount,G=this.s,U=this.outputBlocks,Q=this.extraBytes,fe=0,he=0,le="",pe;he<U;){for(fe=0;fe<D&&he<U;++fe,++he)pe=G[fe],le+=b[pe>>4&15]+b[pe&15]+b[pe>>12&15]+b[pe>>8&15]+b[pe>>20&15]+b[pe>>16&15]+b[pe>>28&15]+b[pe>>24&15];he%D===0&&(G=te(G),re(G),fe=0)}return Q&&(pe=G[fe],le+=b[pe>>4&15]+b[pe&15],Q>1&&(le+=b[pe>>12&15]+b[pe>>8&15]),Q>2&&(le+=b[pe>>20&15]+b[pe>>16&15])),le},L.prototype.arrayBuffer=function(){this.finalize();var D=this.blockCount,G=this.s,U=this.outputBlocks,Q=this.extraBytes,fe=0,he=0,le=this.outputBits>>3,pe;Q?pe=new ArrayBuffer(U+1<<2):pe=new ArrayBuffer(le);for(var be=new Uint32Array(pe);he<U;){for(fe=0;fe<D&&he<U;++fe,++he)be[he]=G[fe];he%D===0&&(G=te(G),re(G))}return Q&&(be[he]=G[fe],pe=pe.slice(0,le)),pe},L.prototype.buffer=L.prototype.arrayBuffer,L.prototype.digest=L.prototype.array=function(){this.finalize();for(var D=this.blockCount,G=this.s,U=this.outputBlocks,Q=this.extraBytes,fe=0,he=0,le=[],pe,be;he<U;){for(fe=0;fe<D&&he<U;++fe,++he)pe=he<<2,be=G[fe],le[pe]=be&255,le[pe+1]=be>>8&255,le[pe+2]=be>>16&255,le[pe+3]=be>>24&255;he%D===0&&(G=te(G),re(G))}return Q&&(pe=he<<2,be=G[fe],le[pe]=be&255,Q>1&&(le[pe+1]=be>>8&255),Q>2&&(le[pe+2]=be>>16&255)),le};function z(D,G,U){L.call(this,D,G,U)}z.prototype=new L,z.prototype.finalize=function(){return this.encode(this.outputBits,!0),L.prototype.finalize.call(this)};var re=function(D){var G,U,Q,fe,he,le,pe,be,se,ge,ye,$e,Ne,ve,Be,De,Se,Oe,je,V,T,O,X,ne,ce,ue,me,Ee,xe,Ae,_e,Me,ze,Ve,Ie,We,Je,Pe,Ze,Xe,Te,Ye,Qe,ke,et,tt,qe,rt,it,Ce,nt,Ge,Ke,ct,dt,ht,lt,pt,bt,xt,yt,mt,vt;for(Q=0;Q<48;Q+=2)fe=D[0]^D[10]^D[20]^D[30]^D[40],he=D[1]^D[11]^D[21]^D[31]^D[41],le=D[2]^D[12]^D[22]^D[32]^D[42],pe=D[3]^D[13]^D[23]^D[33]^D[43],be=D[4]^D[14]^D[24]^D[34]^D[44],se=D[5]^D[15]^D[25]^D[35]^D[45],ge=D[6]^D[16]^D[26]^D[36]^D[46],ye=D[7]^D[17]^D[27]^D[37]^D[47],$e=D[8]^D[18]^D[28]^D[38]^D[48],Ne=D[9]^D[19]^D[29]^D[39]^D[49],G=$e^(le<<1|pe>>>31),U=Ne^(pe<<1|le>>>31),D[0]^=G,D[1]^=U,D[10]^=G,D[11]^=U,D[20]^=G,D[21]^=U,D[30]^=G,D[31]^=U,D[40]^=G,D[41]^=U,G=fe^(be<<1|se>>>31),U=he^(se<<1|be>>>31),D[2]^=G,D[3]^=U,D[12]^=G,D[13]^=U,D[22]^=G,D[23]^=U,D[32]^=G,D[33]^=U,D[42]^=G,D[43]^=U,G=le^(ge<<1|ye>>>31),U=pe^(ye<<1|ge>>>31),D[4]^=G,D[5]^=U,D[14]^=G,D[15]^=U,D[24]^=G,D[25]^=U,D[34]^=G,D[35]^=U,D[44]^=G,D[45]^=U,G=be^($e<<1|Ne>>>31),U=se^(Ne<<1|$e>>>31),D[6]^=G,D[7]^=U,D[16]^=G,D[17]^=U,D[26]^=G,D[27]^=U,D[36]^=G,D[37]^=U,D[46]^=G,D[47]^=U,G=ge^(fe<<1|he>>>31),U=ye^(he<<1|fe>>>31),D[8]^=G,D[9]^=U,D[18]^=G,D[19]^=U,D[28]^=G,D[29]^=U,D[38]^=G,D[39]^=U,D[48]^=G,D[49]^=U,ve=D[0],Be=D[1],tt=D[11]<<4|D[10]>>>28,qe=D[10]<<4|D[11]>>>28,Ee=D[20]<<3|D[21]>>>29,xe=D[21]<<3|D[20]>>>29,xt=D[31]<<9|D[30]>>>23,yt=D[30]<<9|D[31]>>>23,Ye=D[40]<<18|D[41]>>>14,Qe=D[41]<<18|D[40]>>>14,Ve=D[2]<<1|D[3]>>>31,Ie=D[3]<<1|D[2]>>>31,De=D[13]<<12|D[12]>>>20,Se=D[12]<<12|D[13]>>>20,rt=D[22]<<10|D[23]>>>22,it=D[23]<<10|D[22]>>>22,Ae=D[33]<<13|D[32]>>>19,_e=D[32]<<13|D[33]>>>19,mt=D[42]<<2|D[43]>>>30,vt=D[43]<<2|D[42]>>>30,ct=D[5]<<30|D[4]>>>2,dt=D[4]<<30|D[5]>>>2,We=D[14]<<6|D[15]>>>26,Je=D[15]<<6|D[14]>>>26,Oe=D[25]<<11|D[24]>>>21,je=D[24]<<11|D[25]>>>21,Ce=D[34]<<15|D[35]>>>17,nt=D[35]<<15|D[34]>>>17,Me=D[45]<<29|D[44]>>>3,ze=D[44]<<29|D[45]>>>3,ne=D[6]<<28|D[7]>>>4,ce=D[7]<<28|D[6]>>>4,ht=D[17]<<23|D[16]>>>9,lt=D[16]<<23|D[17]>>>9,Pe=D[26]<<25|D[27]>>>7,Ze=D[27]<<25|D[26]>>>7,V=D[36]<<21|D[37]>>>11,T=D[37]<<21|D[36]>>>11,Ge=D[47]<<24|D[46]>>>8,Ke=D[46]<<24|D[47]>>>8,ke=D[8]<<27|D[9]>>>5,et=D[9]<<27|D[8]>>>5,ue=D[18]<<20|D[19]>>>12,me=D[19]<<20|D[18]>>>12,pt=D[29]<<7|D[28]>>>25,bt=D[28]<<7|D[29]>>>25,Xe=D[38]<<8|D[39]>>>24,Te=D[39]<<8|D[38]>>>24,O=D[48]<<14|D[49]>>>18,X=D[49]<<14|D[48]>>>18,D[0]=ve^~De&Oe,D[1]=Be^~Se&je,D[10]=ne^~ue&Ee,D[11]=ce^~me&xe,D[20]=Ve^~We&Pe,D[21]=Ie^~Je&Ze,D[30]=ke^~tt&rt,D[31]=et^~qe&it,D[40]=ct^~ht&pt,D[41]=dt^~lt&bt,D[2]=De^~Oe&V,D[3]=Se^~je&T,D[12]=ue^~Ee&Ae,D[13]=me^~xe&_e,D[22]=We^~Pe&Xe,D[23]=Je^~Ze&Te,D[32]=tt^~rt&Ce,D[33]=qe^~it&nt,D[42]=ht^~pt&xt,D[43]=lt^~bt&yt,D[4]=Oe^~V&O,D[5]=je^~T&X,D[14]=Ee^~Ae&Me,D[15]=xe^~_e&ze,D[24]=Pe^~Xe&Ye,D[25]=Ze^~Te&Qe,D[34]=rt^~Ce&Ge,D[35]=it^~nt&Ke,D[44]=pt^~xt&mt,D[45]=bt^~yt&vt,D[6]=V^~O&ve,D[7]=T^~X&Be,D[16]=Ae^~Me&ne,D[17]=_e^~ze&ce,D[26]=Xe^~Ye&Ve,D[27]=Te^~Qe&Ie,D[36]=Ce^~Ge&ke,D[37]=nt^~Ke&et,D[46]=xt^~mt&ct,D[47]=yt^~vt&dt,D[8]=O^~ve&De,D[9]=X^~Be&Se,D[18]=Me^~ne&ue,D[19]=ze^~ce&me,D[28]=Ye^~Ve&We,D[29]=Qe^~Ie&Je,D[38]=Ge^~ke&tt,D[39]=Ke^~et&qe,D[48]=mt^~ct&ht,D[49]=vt^~dt&lt,D[0]^=g[Q],D[1]^=g[Q+1]};if(h)t.exports=P;else for(q=0;q<_.length;++q)c[_[q]]=P[_[q]]})()})(sha3);var sha3Exports=sha3.exports;Object.defineProperty(utils$p,"__esModule",{value:!0}),utils$p.isFlexBytes=isFlexBytes,utils$p.assertFlexBytes=assertFlexBytes,utils$p.serializeBytes=serializeBytes$1,utils$p.keccak256Hash=keccak256Hash$1,utils$p.bytesToHex=bytesToHex$1,utils$p.equalBytes=equalBytes;const js_sha3_1=sha3Exports;function isFlexBytes(t,e,n){return t instanceof Uint8Array&&t.length>=e&&t.length<=n}function assertFlexBytes(t,e,n){if(!isFlexBytes(t,e,n))throw new TypeError(`Parameter is not valid FlexBytes of min: ${e}, max: ${n}, length: ${t.length}`)}function serializeBytes$1(...t){const e=t.reduce((c,o)=>c+o.length,0),n=new Uint8Array(e);let a=0;return t.forEach(c=>{n.set(c,a),a+=c.length}),n}function keccak256Hash$1(...t){const e=js_sha3_1.keccak256.create();return t.forEach(n=>e.update(n)),Uint8Array.from(e.digest())}function bytesToHex$1(t,e){const n=c=>c.toString(16).padStart(2,"0"),a=Array.from(t,n).join("");if(a.length!==e)throw new TypeError(`Resulting HexString does not have expected length ${e}: ${a}`);return a}function equalBytes(t,e){return t.length!==e.length?!1:t.every((n,a)=>e[a]===n)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_MIN_PAYLOAD_SIZE=t.DEFAULT_MAX_PAYLOAD_SIZE=t.SEGMENT_SIZE=void 0,t.makeChunk=o,t.bmtRootHash=u,t.inclusionProofBottomUp=h,t.rootHashFromInclusionProof=l;const e=span,n=utils$p;t.SEGMENT_SIZE=32;const a=2*t.SEGMENT_SIZE;t.DEFAULT_MAX_PAYLOAD_SIZE=4096;const c=32;t.DEFAULT_MIN_PAYLOAD_SIZE=1;function o(p,x){const m=(x==null?void 0:x.maxPayloadSize)||t.DEFAULT_MAX_PAYLOAD_SIZE,v=(x==null?void 0:x.spanLength)||e.DEFAULT_SPAN_SIZE,g=(x==null?void 0:x.startingSpanValue)||p.length,$=x!=null&&x.hashFn?x.hashFn:n.keccak256Hash;(0,n.assertFlexBytes)(p,0,m);const B=new Uint8Array(m-p.length),C=()=>(0,e.makeSpan)(g,v),F=()=>(0,n.serializeBytes)(p,new Uint8Array(B));return{payload:p,spanLength:v,maxPayloadLength:m,data:F,span:C,address:()=>d(p,v,C(),{hashFn:$}),inclusionProof:ie=>h(F(),ie,{hashFn:$}),bmt:()=>b(F(),{hashFn:$})}}function u(p,x=t.DEFAULT_MAX_PAYLOAD_SIZE,m){if(p.length>x)throw new Error(`invalid data length ${p}`);const v=m!=null&&m.hashFn?m.hashFn:n.keccak256Hash;let g=new Uint8Array([...p,...new Uint8Array(x-p.length)]);for(;g.length!==c;){const $=new Uint8Array(g.length/2);for(let B=0;B<g.length;B+=a){const C=v(g.slice(B,B+a));$.set(C,B/2)}g=$}return g}function h(p,x,m){if(x*t.SEGMENT_SIZE>=p.length)throw new Error(`The given segment index ${x} is greater than ${Math.floor(p.length/t.SEGMENT_SIZE)}`);const v=b(p,m),g=[],$=v.length-1;for(let B=0;B<$;B++){const C=x%2===0?1:-1,F=x+C,H=v[B].slice(F*t.SEGMENT_SIZE,(F+1)*t.SEGMENT_SIZE);g.push(H),x>>>=1}return g}function l(p,x,m,v){const g=v!=null&&v.hashFn?v.hashFn:n.keccak256Hash;let $=x;for(const B of p)$=m%2===0?g($,B):g(B,$),m>>>=1;return $}function b(p,x){if(p.length>t.DEFAULT_MAX_PAYLOAD_SIZE)throw new Error(`invalid data length ${p.length}`);const m=x!=null&&x.hashFn?x.hashFn:n.keccak256Hash;let v=new Uint8Array([...p,...new Uint8Array(t.DEFAULT_MAX_PAYLOAD_SIZE-p.length)]);const g=[];for(;v.length!==c;){g.push(v);const $=new Uint8Array(v.length/2);for(let B=0;B<v.length;B+=a){const C=m(v.slice(B,B+a));$.set(C,B/2)}v=$}return g.push(v),g}function d(p,x,m,v){const g=v!=null&&v.hashFn?v.hashFn:n.keccak256Hash,$=m||(0,e.makeSpan)(p.length,x),B=u(p,t.DEFAULT_MAX_PAYLOAD_SIZE,v),C=new Uint8Array([...$,...B]);return g(C)}})(chunk);var hasRequiredFile;function requireFile(){if(hasRequiredFile)return file;hasRequiredFile=1,Object.defineProperty(file,"__esModule",{value:!0}),file.makeChunkedFile=c,file.fileInclusionProofBottomUp=o,file.fileAddressFromInclusionProof=u,file.getBmtIndexOfSegment=h;const t=requireDist(),e=chunk,n=span,a=utils$p;function c(m,v){const g=(v==null?void 0:v.maxPayloadLength)||e.DEFAULT_MAX_PAYLOAD_SIZE,$=(v==null?void 0:v.spanLength)||n.DEFAULT_SPAN_SIZE,B=()=>{const Z=[];if(m.length===0)Z.push((0,t.makeChunk)(new Uint8Array,v));else for(let ie=0;ie<m.length;ie+=g)Z.push((0,t.makeChunk)(m.slice(ie,ie+g),v));return Z};return{payload:m,span:()=>(0,t.makeSpan)(m.length,$),leafChunks:B,address:()=>b(B()).address(),rootChunk:()=>b(B()),bmt:()=>l(B())}}function o(m,v){if(v*e.SEGMENT_SIZE>=(0,t.getSpanValue)(m.span()))throw new Error(`The given segment index ${v} is greater than ${Math.floor((0,t.getSpanValue)(m.span())/e.SEGMENT_SIZE)}`);let g=m.leafChunks();const B=g[0].maxPayloadLength/e.SEGMENT_SIZE,C=Math.log2(B);let F=x(g);const H=[];for(;g.length!==1||F;){const Z=v%B;let ie=Math.floor(v/B);if(ie===g.length){if(!F)throw new Error("Impossible");v>>>=C;do{const{nextLevelChunks:R,nextLevelCarrierChunk:A}=d(g,F);g=R,F=A,v>>>=C}while(v%B===0);ie=g.length-1}const te=g[ie],ae=te.inclusionProof(Z);H.push({sisterSegments:ae,span:te.span()}),v=ie;const{nextLevelChunks:de,nextLevelCarrierChunk:J}=d(g,F);g=de,F=J}const W=g[0].inclusionProof(v);return H.push({sisterSegments:W,span:g[0].span()}),H}function u(m,v,g,$=4096){const B=Math.floor($/e.SEGMENT_SIZE),C=Math.log2(B),F=(0,t.getSpanValue)(m[m.length-1].span);let H=Math.floor((F-1)/$),W=v;for(const Z of m){const{chunkIndex:ie,level:te}=h(g,H,$);for(const ae of Z.sisterSegments)W=g%2===0?(0,a.keccak256Hash)(W,ae):(0,a.keccak256Hash)(ae,W),g=Math.floor(g/2);W=(0,a.keccak256Hash)(Z.span,W),g=ie,H>>>=C+te*C}return W}function h(m,v,g=4096){const $=Math.floor(g/e.SEGMENT_SIZE),B=Math.log2($);let C=0;if(Math.floor(m/$)===v&&v%$===0&&v!==0)for(m>>>=B;m%e.SEGMENT_SIZE===0;)C++,m>>>=B;else m>>>=B;return{chunkIndex:m,level:C}}function l(m){if(m.length===0)throw new Error("given chunk array is empty");const v=[m];let g=x(m);for(;v[v.length-1].length!==1;){const{nextLevelChunks:$,nextLevelCarrierChunk:B}=d(v[v.length-1],g);g=B,v.push($)}return v}function b(m){if(m.length===0)throw new Error("given chunk array is empty");let v=m,g=x(v);for(;v.length!==1||g;){const{nextLevelChunks:$,nextLevelCarrierChunk:B}=d(v,g);v=$,g=B}return v[0]}function d(m,v){if(m.length===0)throw new Error("The given chunk array is empty");const g=m[0].maxPayloadLength,$=m[0].spanLength,B=g/e.SEGMENT_SIZE,C=[];for(let H=0;H<m.length;H+=B){const W=m.slice(H,H+B);C.push(p(W,$,g))}let F=v;return v?C.length%B!==0&&(C.push(v),F=null):F=x(C),{nextLevelChunks:C,nextLevelCarrierChunk:F}}function p(m,v,g){const $=m.map(F=>F.address()),B=m.map(F=>(0,t.getSpanValue)(F.span())).reduce((F,H)=>F+H),C=(0,a.serializeBytes)(...$);return(0,t.makeChunk)(C,{spanLength:v,startingSpanValue:B,maxPayloadSize:g})}function x(m){if(m.length<=1)return null;const g=m[0].maxPayloadLength/e.SEGMENT_SIZE;return m.length%g===1&&m.pop()||null}return file}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,function(t){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(h,l,b,d){d===void 0&&(d=b);var p=Object.getOwnPropertyDescriptor(l,b);(!p||("get"in p?!l.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return l[b]}}),Object.defineProperty(h,d,p)}:function(h,l,b,d){d===void 0&&(d=b),h[d]=l[b]}),n=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(h,l){Object.defineProperty(h,"default",{enumerable:!0,value:l})}:function(h,l){h.default=l}),a=commonjsGlobal&&commonjsGlobal.__importStar||function(h){if(h&&h.__esModule)return h;var l={};if(h!=null)for(var b in h)b!=="default"&&Object.prototype.hasOwnProperty.call(h,b)&&e(l,h,b);return n(l,h),l};Object.defineProperty(t,"__esModule",{value:!0}),t.Utils=t.getSpanValue=t.makeSpan=t.rootHashFromInclusionProof=t.makeChunk=t.getBmtIndexOfSegment=t.fileAddressFromInclusionProof=t.fileInclusionProofBottomUp=t.makeChunkedFile=void 0;var c=requireFile();Object.defineProperty(t,"makeChunkedFile",{enumerable:!0,get:function(){return c.makeChunkedFile}}),Object.defineProperty(t,"fileInclusionProofBottomUp",{enumerable:!0,get:function(){return c.fileInclusionProofBottomUp}}),Object.defineProperty(t,"fileAddressFromInclusionProof",{enumerable:!0,get:function(){return c.fileAddressFromInclusionProof}}),Object.defineProperty(t,"getBmtIndexOfSegment",{enumerable:!0,get:function(){return c.getBmtIndexOfSegment}});var o=chunk;Object.defineProperty(t,"makeChunk",{enumerable:!0,get:function(){return o.makeChunk}}),Object.defineProperty(t,"rootHashFromInclusionProof",{enumerable:!0,get:function(){return o.rootHashFromInclusionProof}});var u=span;Object.defineProperty(t,"makeSpan",{enumerable:!0,get:function(){return u.makeSpan}}),Object.defineProperty(t,"getSpanValue",{enumerable:!0,get:function(){return u.getSpanValue}}),t.Utils=a(utils$p)}(dist)),dist}var distExports=requireDist(),ws=null;typeof WebSocket<"u"?ws=WebSocket:typeof MozWebSocket<"u"?ws=MozWebSocket:typeof global$1<"u"?ws=global$1.WebSocket||global$1.MozWebSocket:typeof window<"u"?ws=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(ws=self.WebSocket||self.MozWebSocket);const WebSocket$1=ws;var elliptic={};const name="elliptic",version="6.5.7",description="EC cryptography",main="lib/elliptic.js",files=["lib"],scripts={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository={type:"git",url:"git@github.com:indutny/elliptic"},keywords=["EC","Elliptic","curve","Cryptography"],author="Fedor Indutny <fedor@indutny.com>",license="MIT",bugs={url:"https://github.com/indutny/elliptic/issues"},homepage="https://github.com/indutny/elliptic",devDependencies={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},require$$0={name,version,description,main,files,scripts,repository,keywords,author,license,bugs,homepage,devDependencies,dependencies};var utils$o={},bn$1={exports:{}};const require$$1$2=getAugmentedNamespace(dist$1);bn$1.exports,function(t){(function(e,n){function a(J,R){if(!J)throw new Error(R||"Assertion failed")}function c(J,R){J.super_=R;var A=function(){};A.prototype=R.prototype,J.prototype=new A,J.prototype.constructor=J}function o(J,R,A){if(o.isBN(J))return J;this.negative=0,this.words=null,this.length=0,this.red=null,J!==null&&((R==="le"||R==="be")&&(A=R,R=10),this._init(J||0,R||10,A||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var u;try{typeof window<"u"&&typeof window.Buffer<"u"?u=window.Buffer:u=require$$1$2.Buffer}catch{}o.isBN=function(R){return R instanceof o?!0:R!==null&&typeof R=="object"&&R.constructor.wordSize===o.wordSize&&Array.isArray(R.words)},o.max=function(R,A){return R.cmp(A)>0?R:A},o.min=function(R,A){return R.cmp(A)<0?R:A},o.prototype._init=function(R,A,y){if(typeof R=="number")return this._initNumber(R,A,y);if(typeof R=="object")return this._initArray(R,A,y);A==="hex"&&(A=16),a(A===(A|0)&&A>=2&&A<=36),R=R.toString().replace(/\s+/g,"");var w=0;R[0]==="-"&&(w++,this.negative=1),w<R.length&&(A===16?this._parseHex(R,w,y):(this._parseBase(R,A,w),y==="le"&&this._initArray(this.toArray(),A,y)))},o.prototype._initNumber=function(R,A,y){R<0&&(this.negative=1,R=-R),R<67108864?(this.words=[R&67108863],this.length=1):R<4503599627370496?(this.words=[R&67108863,R/67108864&67108863],this.length=2):(a(R<9007199254740992),this.words=[R&67108863,R/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),A,y)},o.prototype._initArray=function(R,A,y){if(a(typeof R.length=="number"),R.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(R.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var I,M,k=0;if(y==="be")for(w=R.length-1,I=0;w>=0;w-=3)M=R[w]|R[w-1]<<8|R[w-2]<<16,this.words[I]|=M<<k&67108863,this.words[I+1]=M>>>26-k&67108863,k+=24,k>=26&&(k-=26,I++);else if(y==="le")for(w=0,I=0;w<R.length;w+=3)M=R[w]|R[w+1]<<8|R[w+2]<<16,this.words[I]|=M<<k&67108863,this.words[I+1]=M>>>26-k&67108863,k+=24,k>=26&&(k-=26,I++);return this.strip()};function h(J,R){var A=J.charCodeAt(R);return A>=65&&A<=70?A-55:A>=97&&A<=102?A-87:A-48&15}function l(J,R,A){var y=h(J,A);return A-1>=R&&(y|=h(J,A-1)<<4),y}o.prototype._parseHex=function(R,A,y){this.length=Math.ceil((R.length-A)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var I=0,M=0,k;if(y==="be")for(w=R.length-1;w>=A;w-=2)k=l(R,A,w)<<I,this.words[M]|=k&67108863,I>=18?(I-=18,M+=1,this.words[M]|=k>>>26):I+=8;else{var P=R.length-A;for(w=P%2===0?A+1:A;w<R.length;w+=2)k=l(R,A,w)<<I,this.words[M]|=k&67108863,I>=18?(I-=18,M+=1,this.words[M]|=k>>>26):I+=8}this.strip()};function b(J,R,A,y){for(var w=0,I=Math.min(J.length,A),M=R;M<I;M++){var k=J.charCodeAt(M)-48;w*=y,k>=49?w+=k-49+10:k>=17?w+=k-17+10:w+=k}return w}o.prototype._parseBase=function(R,A,y){this.words=[0],this.length=1;for(var w=0,I=1;I<=67108863;I*=A)w++;w--,I=I/A|0;for(var M=R.length-y,k=M%w,P=Math.min(M,M-k)+y,_=0,q=y;q<P;q+=w)_=b(R,q,q+w,A),this.imuln(I),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_);if(k!==0){var E=1;for(_=b(R,q,R.length,A),q=0;q<k;q++)E*=A;this.imuln(E),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_)}this.strip()},o.prototype.copy=function(R){R.words=new Array(this.length);for(var A=0;A<this.length;A++)R.words[A]=this.words[A];R.length=this.length,R.negative=this.negative,R.red=this.red},o.prototype.clone=function(){var R=new o(null);return this.copy(R),R},o.prototype._expand=function(R){for(;this.length<R;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],x=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(R,A){R=R||10,A=A|0||1;var y;if(R===16||R==="hex"){y="";for(var w=0,I=0,M=0;M<this.length;M++){var k=this.words[M],P=((k<<w|I)&16777215).toString(16);I=k>>>24-w&16777215,I!==0||M!==this.length-1?y=d[6-P.length]+P+y:y=P+y,w+=2,w>=26&&(w-=26,M--)}for(I!==0&&(y=I.toString(16)+y);y.length%A!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(R===(R|0)&&R>=2&&R<=36){var _=p[R],q=x[R];y="";var E=this.clone();for(E.negative=0;!E.isZero();){var j=E.modn(q).toString(R);E=E.idivn(q),E.isZero()?y=j+y:y=d[_-j.length]+j+y}for(this.isZero()&&(y="0"+y);y.length%A!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}a(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var R=this.words[0];return this.length===2?R+=this.words[1]*67108864:this.length===3&&this.words[2]===1?R+=4503599627370496+this.words[1]*67108864:this.length>2&&a(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-R:R},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(R,A){return a(typeof u<"u"),this.toArrayLike(u,R,A)},o.prototype.toArray=function(R,A){return this.toArrayLike(Array,R,A)},o.prototype.toArrayLike=function(R,A,y){var w=this.byteLength(),I=y||Math.max(1,w);a(w<=I,"byte array longer than desired length"),a(I>0,"Requested array length <= 0"),this.strip();var M=A==="le",k=new R(I),P,_,q=this.clone();if(M){for(_=0;!q.isZero();_++)P=q.andln(255),q.iushrn(8),k[_]=P;for(;_<I;_++)k[_]=0}else{for(_=0;_<I-w;_++)k[_]=0;for(_=0;!q.isZero();_++)P=q.andln(255),q.iushrn(8),k[I-_-1]=P}return k},Math.clz32?o.prototype._countBits=function(R){return 32-Math.clz32(R)}:o.prototype._countBits=function(R){var A=R,y=0;return A>=4096&&(y+=13,A>>>=13),A>=64&&(y+=7,A>>>=7),A>=8&&(y+=4,A>>>=4),A>=2&&(y+=2,A>>>=2),y+A},o.prototype._zeroBits=function(R){if(R===0)return 26;var A=R,y=0;return A&8191||(y+=13,A>>>=13),A&127||(y+=7,A>>>=7),A&15||(y+=4,A>>>=4),A&3||(y+=2,A>>>=2),A&1||y++,y},o.prototype.bitLength=function(){var R=this.words[this.length-1],A=this._countBits(R);return(this.length-1)*26+A};function m(J){for(var R=new Array(J.bitLength()),A=0;A<R.length;A++){var y=A/26|0,w=A%26;R[A]=(J.words[y]&1<<w)>>>w}return R}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var R=0,A=0;A<this.length;A++){var y=this._zeroBits(this.words[A]);if(R+=y,y!==26)break}return R},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(R){return this.negative!==0?this.abs().inotn(R).iaddn(1):this.clone()},o.prototype.fromTwos=function(R){return this.testn(R-1)?this.notn(R).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(R){for(;this.length<R.length;)this.words[this.length++]=0;for(var A=0;A<R.length;A++)this.words[A]=this.words[A]|R.words[A];return this.strip()},o.prototype.ior=function(R){return a((this.negative|R.negative)===0),this.iuor(R)},o.prototype.or=function(R){return this.length>R.length?this.clone().ior(R):R.clone().ior(this)},o.prototype.uor=function(R){return this.length>R.length?this.clone().iuor(R):R.clone().iuor(this)},o.prototype.iuand=function(R){var A;this.length>R.length?A=R:A=this;for(var y=0;y<A.length;y++)this.words[y]=this.words[y]&R.words[y];return this.length=A.length,this.strip()},o.prototype.iand=function(R){return a((this.negative|R.negative)===0),this.iuand(R)},o.prototype.and=function(R){return this.length>R.length?this.clone().iand(R):R.clone().iand(this)},o.prototype.uand=function(R){return this.length>R.length?this.clone().iuand(R):R.clone().iuand(this)},o.prototype.iuxor=function(R){var A,y;this.length>R.length?(A=this,y=R):(A=R,y=this);for(var w=0;w<y.length;w++)this.words[w]=A.words[w]^y.words[w];if(this!==A)for(;w<A.length;w++)this.words[w]=A.words[w];return this.length=A.length,this.strip()},o.prototype.ixor=function(R){return a((this.negative|R.negative)===0),this.iuxor(R)},o.prototype.xor=function(R){return this.length>R.length?this.clone().ixor(R):R.clone().ixor(this)},o.prototype.uxor=function(R){return this.length>R.length?this.clone().iuxor(R):R.clone().iuxor(this)},o.prototype.inotn=function(R){a(typeof R=="number"&&R>=0);var A=Math.ceil(R/26)|0,y=R%26;this._expand(A),y>0&&A--;for(var w=0;w<A;w++)this.words[w]=~this.words[w]&67108863;return y>0&&(this.words[w]=~this.words[w]&67108863>>26-y),this.strip()},o.prototype.notn=function(R){return this.clone().inotn(R)},o.prototype.setn=function(R,A){a(typeof R=="number"&&R>=0);var y=R/26|0,w=R%26;return this._expand(y+1),A?this.words[y]=this.words[y]|1<<w:this.words[y]=this.words[y]&~(1<<w),this.strip()},o.prototype.iadd=function(R){var A;if(this.negative!==0&&R.negative===0)return this.negative=0,A=this.isub(R),this.negative^=1,this._normSign();if(this.negative===0&&R.negative!==0)return R.negative=0,A=this.isub(R),R.negative=1,A._normSign();var y,w;this.length>R.length?(y=this,w=R):(y=R,w=this);for(var I=0,M=0;M<w.length;M++)A=(y.words[M]|0)+(w.words[M]|0)+I,this.words[M]=A&67108863,I=A>>>26;for(;I!==0&&M<y.length;M++)A=(y.words[M]|0)+I,this.words[M]=A&67108863,I=A>>>26;if(this.length=y.length,I!==0)this.words[this.length]=I,this.length++;else if(y!==this)for(;M<y.length;M++)this.words[M]=y.words[M];return this},o.prototype.add=function(R){var A;return R.negative!==0&&this.negative===0?(R.negative=0,A=this.sub(R),R.negative^=1,A):R.negative===0&&this.negative!==0?(this.negative=0,A=R.sub(this),this.negative=1,A):this.length>R.length?this.clone().iadd(R):R.clone().iadd(this)},o.prototype.isub=function(R){if(R.negative!==0){R.negative=0;var A=this.iadd(R);return R.negative=1,A._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(R),this.negative=1,this._normSign();var y=this.cmp(R);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,I;y>0?(w=this,I=R):(w=R,I=this);for(var M=0,k=0;k<I.length;k++)A=(w.words[k]|0)-(I.words[k]|0)+M,M=A>>26,this.words[k]=A&67108863;for(;M!==0&&k<w.length;k++)A=(w.words[k]|0)+M,M=A>>26,this.words[k]=A&67108863;if(M===0&&k<w.length&&w!==this)for(;k<w.length;k++)this.words[k]=w.words[k];return this.length=Math.max(this.length,k),w!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(R){return this.clone().isub(R)};function v(J,R,A){A.negative=R.negative^J.negative;var y=J.length+R.length|0;A.length=y,y=y-1|0;var w=J.words[0]|0,I=R.words[0]|0,M=w*I,k=M&67108863,P=M/67108864|0;A.words[0]=k;for(var _=1;_<y;_++){for(var q=P>>>26,E=P&67108863,j=Math.min(_,R.length-1),ee=Math.max(0,_-J.length+1);ee<=j;ee++){var oe=_-ee|0;w=J.words[oe]|0,I=R.words[ee]|0,M=w*I+E,q+=M/67108864|0,E=M&67108863}A.words[_]=E|0,P=q|0}return P!==0?A.words[_]=P|0:A.length--,A.strip()}var g=function(R,A,y){var w=R.words,I=A.words,M=y.words,k=0,P,_,q,E=w[0]|0,j=E&8191,ee=E>>>13,oe=w[1]|0,Y=oe&8191,L=oe>>>13,z=w[2]|0,re=z&8191,D=z>>>13,G=w[3]|0,U=G&8191,Q=G>>>13,fe=w[4]|0,he=fe&8191,le=fe>>>13,pe=w[5]|0,be=pe&8191,se=pe>>>13,ge=w[6]|0,ye=ge&8191,$e=ge>>>13,Ne=w[7]|0,ve=Ne&8191,Be=Ne>>>13,De=w[8]|0,Se=De&8191,Oe=De>>>13,je=w[9]|0,V=je&8191,T=je>>>13,O=I[0]|0,X=O&8191,ne=O>>>13,ce=I[1]|0,ue=ce&8191,me=ce>>>13,Ee=I[2]|0,xe=Ee&8191,Ae=Ee>>>13,_e=I[3]|0,Me=_e&8191,ze=_e>>>13,Ve=I[4]|0,Ie=Ve&8191,We=Ve>>>13,Je=I[5]|0,Pe=Je&8191,Ze=Je>>>13,Xe=I[6]|0,Te=Xe&8191,Ye=Xe>>>13,Qe=I[7]|0,ke=Qe&8191,et=Qe>>>13,tt=I[8]|0,qe=tt&8191,rt=tt>>>13,it=I[9]|0,Ce=it&8191,nt=it>>>13;y.negative=R.negative^A.negative,y.length=19,P=Math.imul(j,X),_=Math.imul(j,ne),_=_+Math.imul(ee,X)|0,q=Math.imul(ee,ne);var Ge=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,P=Math.imul(Y,X),_=Math.imul(Y,ne),_=_+Math.imul(L,X)|0,q=Math.imul(L,ne),P=P+Math.imul(j,ue)|0,_=_+Math.imul(j,me)|0,_=_+Math.imul(ee,ue)|0,q=q+Math.imul(ee,me)|0;var Ke=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,P=Math.imul(re,X),_=Math.imul(re,ne),_=_+Math.imul(D,X)|0,q=Math.imul(D,ne),P=P+Math.imul(Y,ue)|0,_=_+Math.imul(Y,me)|0,_=_+Math.imul(L,ue)|0,q=q+Math.imul(L,me)|0,P=P+Math.imul(j,xe)|0,_=_+Math.imul(j,Ae)|0,_=_+Math.imul(ee,xe)|0,q=q+Math.imul(ee,Ae)|0;var ct=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(ct>>>26)|0,ct&=67108863,P=Math.imul(U,X),_=Math.imul(U,ne),_=_+Math.imul(Q,X)|0,q=Math.imul(Q,ne),P=P+Math.imul(re,ue)|0,_=_+Math.imul(re,me)|0,_=_+Math.imul(D,ue)|0,q=q+Math.imul(D,me)|0,P=P+Math.imul(Y,xe)|0,_=_+Math.imul(Y,Ae)|0,_=_+Math.imul(L,xe)|0,q=q+Math.imul(L,Ae)|0,P=P+Math.imul(j,Me)|0,_=_+Math.imul(j,ze)|0,_=_+Math.imul(ee,Me)|0,q=q+Math.imul(ee,ze)|0;var dt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(dt>>>26)|0,dt&=67108863,P=Math.imul(he,X),_=Math.imul(he,ne),_=_+Math.imul(le,X)|0,q=Math.imul(le,ne),P=P+Math.imul(U,ue)|0,_=_+Math.imul(U,me)|0,_=_+Math.imul(Q,ue)|0,q=q+Math.imul(Q,me)|0,P=P+Math.imul(re,xe)|0,_=_+Math.imul(re,Ae)|0,_=_+Math.imul(D,xe)|0,q=q+Math.imul(D,Ae)|0,P=P+Math.imul(Y,Me)|0,_=_+Math.imul(Y,ze)|0,_=_+Math.imul(L,Me)|0,q=q+Math.imul(L,ze)|0,P=P+Math.imul(j,Ie)|0,_=_+Math.imul(j,We)|0,_=_+Math.imul(ee,Ie)|0,q=q+Math.imul(ee,We)|0;var ht=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(ht>>>26)|0,ht&=67108863,P=Math.imul(be,X),_=Math.imul(be,ne),_=_+Math.imul(se,X)|0,q=Math.imul(se,ne),P=P+Math.imul(he,ue)|0,_=_+Math.imul(he,me)|0,_=_+Math.imul(le,ue)|0,q=q+Math.imul(le,me)|0,P=P+Math.imul(U,xe)|0,_=_+Math.imul(U,Ae)|0,_=_+Math.imul(Q,xe)|0,q=q+Math.imul(Q,Ae)|0,P=P+Math.imul(re,Me)|0,_=_+Math.imul(re,ze)|0,_=_+Math.imul(D,Me)|0,q=q+Math.imul(D,ze)|0,P=P+Math.imul(Y,Ie)|0,_=_+Math.imul(Y,We)|0,_=_+Math.imul(L,Ie)|0,q=q+Math.imul(L,We)|0,P=P+Math.imul(j,Pe)|0,_=_+Math.imul(j,Ze)|0,_=_+Math.imul(ee,Pe)|0,q=q+Math.imul(ee,Ze)|0;var lt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(lt>>>26)|0,lt&=67108863,P=Math.imul(ye,X),_=Math.imul(ye,ne),_=_+Math.imul($e,X)|0,q=Math.imul($e,ne),P=P+Math.imul(be,ue)|0,_=_+Math.imul(be,me)|0,_=_+Math.imul(se,ue)|0,q=q+Math.imul(se,me)|0,P=P+Math.imul(he,xe)|0,_=_+Math.imul(he,Ae)|0,_=_+Math.imul(le,xe)|0,q=q+Math.imul(le,Ae)|0,P=P+Math.imul(U,Me)|0,_=_+Math.imul(U,ze)|0,_=_+Math.imul(Q,Me)|0,q=q+Math.imul(Q,ze)|0,P=P+Math.imul(re,Ie)|0,_=_+Math.imul(re,We)|0,_=_+Math.imul(D,Ie)|0,q=q+Math.imul(D,We)|0,P=P+Math.imul(Y,Pe)|0,_=_+Math.imul(Y,Ze)|0,_=_+Math.imul(L,Pe)|0,q=q+Math.imul(L,Ze)|0,P=P+Math.imul(j,Te)|0,_=_+Math.imul(j,Ye)|0,_=_+Math.imul(ee,Te)|0,q=q+Math.imul(ee,Ye)|0;var pt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(pt>>>26)|0,pt&=67108863,P=Math.imul(ve,X),_=Math.imul(ve,ne),_=_+Math.imul(Be,X)|0,q=Math.imul(Be,ne),P=P+Math.imul(ye,ue)|0,_=_+Math.imul(ye,me)|0,_=_+Math.imul($e,ue)|0,q=q+Math.imul($e,me)|0,P=P+Math.imul(be,xe)|0,_=_+Math.imul(be,Ae)|0,_=_+Math.imul(se,xe)|0,q=q+Math.imul(se,Ae)|0,P=P+Math.imul(he,Me)|0,_=_+Math.imul(he,ze)|0,_=_+Math.imul(le,Me)|0,q=q+Math.imul(le,ze)|0,P=P+Math.imul(U,Ie)|0,_=_+Math.imul(U,We)|0,_=_+Math.imul(Q,Ie)|0,q=q+Math.imul(Q,We)|0,P=P+Math.imul(re,Pe)|0,_=_+Math.imul(re,Ze)|0,_=_+Math.imul(D,Pe)|0,q=q+Math.imul(D,Ze)|0,P=P+Math.imul(Y,Te)|0,_=_+Math.imul(Y,Ye)|0,_=_+Math.imul(L,Te)|0,q=q+Math.imul(L,Ye)|0,P=P+Math.imul(j,ke)|0,_=_+Math.imul(j,et)|0,_=_+Math.imul(ee,ke)|0,q=q+Math.imul(ee,et)|0;var bt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(bt>>>26)|0,bt&=67108863,P=Math.imul(Se,X),_=Math.imul(Se,ne),_=_+Math.imul(Oe,X)|0,q=Math.imul(Oe,ne),P=P+Math.imul(ve,ue)|0,_=_+Math.imul(ve,me)|0,_=_+Math.imul(Be,ue)|0,q=q+Math.imul(Be,me)|0,P=P+Math.imul(ye,xe)|0,_=_+Math.imul(ye,Ae)|0,_=_+Math.imul($e,xe)|0,q=q+Math.imul($e,Ae)|0,P=P+Math.imul(be,Me)|0,_=_+Math.imul(be,ze)|0,_=_+Math.imul(se,Me)|0,q=q+Math.imul(se,ze)|0,P=P+Math.imul(he,Ie)|0,_=_+Math.imul(he,We)|0,_=_+Math.imul(le,Ie)|0,q=q+Math.imul(le,We)|0,P=P+Math.imul(U,Pe)|0,_=_+Math.imul(U,Ze)|0,_=_+Math.imul(Q,Pe)|0,q=q+Math.imul(Q,Ze)|0,P=P+Math.imul(re,Te)|0,_=_+Math.imul(re,Ye)|0,_=_+Math.imul(D,Te)|0,q=q+Math.imul(D,Ye)|0,P=P+Math.imul(Y,ke)|0,_=_+Math.imul(Y,et)|0,_=_+Math.imul(L,ke)|0,q=q+Math.imul(L,et)|0,P=P+Math.imul(j,qe)|0,_=_+Math.imul(j,rt)|0,_=_+Math.imul(ee,qe)|0,q=q+Math.imul(ee,rt)|0;var xt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(xt>>>26)|0,xt&=67108863,P=Math.imul(V,X),_=Math.imul(V,ne),_=_+Math.imul(T,X)|0,q=Math.imul(T,ne),P=P+Math.imul(Se,ue)|0,_=_+Math.imul(Se,me)|0,_=_+Math.imul(Oe,ue)|0,q=q+Math.imul(Oe,me)|0,P=P+Math.imul(ve,xe)|0,_=_+Math.imul(ve,Ae)|0,_=_+Math.imul(Be,xe)|0,q=q+Math.imul(Be,Ae)|0,P=P+Math.imul(ye,Me)|0,_=_+Math.imul(ye,ze)|0,_=_+Math.imul($e,Me)|0,q=q+Math.imul($e,ze)|0,P=P+Math.imul(be,Ie)|0,_=_+Math.imul(be,We)|0,_=_+Math.imul(se,Ie)|0,q=q+Math.imul(se,We)|0,P=P+Math.imul(he,Pe)|0,_=_+Math.imul(he,Ze)|0,_=_+Math.imul(le,Pe)|0,q=q+Math.imul(le,Ze)|0,P=P+Math.imul(U,Te)|0,_=_+Math.imul(U,Ye)|0,_=_+Math.imul(Q,Te)|0,q=q+Math.imul(Q,Ye)|0,P=P+Math.imul(re,ke)|0,_=_+Math.imul(re,et)|0,_=_+Math.imul(D,ke)|0,q=q+Math.imul(D,et)|0,P=P+Math.imul(Y,qe)|0,_=_+Math.imul(Y,rt)|0,_=_+Math.imul(L,qe)|0,q=q+Math.imul(L,rt)|0,P=P+Math.imul(j,Ce)|0,_=_+Math.imul(j,nt)|0,_=_+Math.imul(ee,Ce)|0,q=q+Math.imul(ee,nt)|0;var yt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(yt>>>26)|0,yt&=67108863,P=Math.imul(V,ue),_=Math.imul(V,me),_=_+Math.imul(T,ue)|0,q=Math.imul(T,me),P=P+Math.imul(Se,xe)|0,_=_+Math.imul(Se,Ae)|0,_=_+Math.imul(Oe,xe)|0,q=q+Math.imul(Oe,Ae)|0,P=P+Math.imul(ve,Me)|0,_=_+Math.imul(ve,ze)|0,_=_+Math.imul(Be,Me)|0,q=q+Math.imul(Be,ze)|0,P=P+Math.imul(ye,Ie)|0,_=_+Math.imul(ye,We)|0,_=_+Math.imul($e,Ie)|0,q=q+Math.imul($e,We)|0,P=P+Math.imul(be,Pe)|0,_=_+Math.imul(be,Ze)|0,_=_+Math.imul(se,Pe)|0,q=q+Math.imul(se,Ze)|0,P=P+Math.imul(he,Te)|0,_=_+Math.imul(he,Ye)|0,_=_+Math.imul(le,Te)|0,q=q+Math.imul(le,Ye)|0,P=P+Math.imul(U,ke)|0,_=_+Math.imul(U,et)|0,_=_+Math.imul(Q,ke)|0,q=q+Math.imul(Q,et)|0,P=P+Math.imul(re,qe)|0,_=_+Math.imul(re,rt)|0,_=_+Math.imul(D,qe)|0,q=q+Math.imul(D,rt)|0,P=P+Math.imul(Y,Ce)|0,_=_+Math.imul(Y,nt)|0,_=_+Math.imul(L,Ce)|0,q=q+Math.imul(L,nt)|0;var mt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(mt>>>26)|0,mt&=67108863,P=Math.imul(V,xe),_=Math.imul(V,Ae),_=_+Math.imul(T,xe)|0,q=Math.imul(T,Ae),P=P+Math.imul(Se,Me)|0,_=_+Math.imul(Se,ze)|0,_=_+Math.imul(Oe,Me)|0,q=q+Math.imul(Oe,ze)|0,P=P+Math.imul(ve,Ie)|0,_=_+Math.imul(ve,We)|0,_=_+Math.imul(Be,Ie)|0,q=q+Math.imul(Be,We)|0,P=P+Math.imul(ye,Pe)|0,_=_+Math.imul(ye,Ze)|0,_=_+Math.imul($e,Pe)|0,q=q+Math.imul($e,Ze)|0,P=P+Math.imul(be,Te)|0,_=_+Math.imul(be,Ye)|0,_=_+Math.imul(se,Te)|0,q=q+Math.imul(se,Ye)|0,P=P+Math.imul(he,ke)|0,_=_+Math.imul(he,et)|0,_=_+Math.imul(le,ke)|0,q=q+Math.imul(le,et)|0,P=P+Math.imul(U,qe)|0,_=_+Math.imul(U,rt)|0,_=_+Math.imul(Q,qe)|0,q=q+Math.imul(Q,rt)|0,P=P+Math.imul(re,Ce)|0,_=_+Math.imul(re,nt)|0,_=_+Math.imul(D,Ce)|0,q=q+Math.imul(D,nt)|0;var vt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(vt>>>26)|0,vt&=67108863,P=Math.imul(V,Me),_=Math.imul(V,ze),_=_+Math.imul(T,Me)|0,q=Math.imul(T,ze),P=P+Math.imul(Se,Ie)|0,_=_+Math.imul(Se,We)|0,_=_+Math.imul(Oe,Ie)|0,q=q+Math.imul(Oe,We)|0,P=P+Math.imul(ve,Pe)|0,_=_+Math.imul(ve,Ze)|0,_=_+Math.imul(Be,Pe)|0,q=q+Math.imul(Be,Ze)|0,P=P+Math.imul(ye,Te)|0,_=_+Math.imul(ye,Ye)|0,_=_+Math.imul($e,Te)|0,q=q+Math.imul($e,Ye)|0,P=P+Math.imul(be,ke)|0,_=_+Math.imul(be,et)|0,_=_+Math.imul(se,ke)|0,q=q+Math.imul(se,et)|0,P=P+Math.imul(he,qe)|0,_=_+Math.imul(he,rt)|0,_=_+Math.imul(le,qe)|0,q=q+Math.imul(le,rt)|0,P=P+Math.imul(U,Ce)|0,_=_+Math.imul(U,nt)|0,_=_+Math.imul(Q,Ce)|0,q=q+Math.imul(Q,nt)|0;var qt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(qt>>>26)|0,qt&=67108863,P=Math.imul(V,Ie),_=Math.imul(V,We),_=_+Math.imul(T,Ie)|0,q=Math.imul(T,We),P=P+Math.imul(Se,Pe)|0,_=_+Math.imul(Se,Ze)|0,_=_+Math.imul(Oe,Pe)|0,q=q+Math.imul(Oe,Ze)|0,P=P+Math.imul(ve,Te)|0,_=_+Math.imul(ve,Ye)|0,_=_+Math.imul(Be,Te)|0,q=q+Math.imul(Be,Ye)|0,P=P+Math.imul(ye,ke)|0,_=_+Math.imul(ye,et)|0,_=_+Math.imul($e,ke)|0,q=q+Math.imul($e,et)|0,P=P+Math.imul(be,qe)|0,_=_+Math.imul(be,rt)|0,_=_+Math.imul(se,qe)|0,q=q+Math.imul(se,rt)|0,P=P+Math.imul(he,Ce)|0,_=_+Math.imul(he,nt)|0,_=_+Math.imul(le,Ce)|0,q=q+Math.imul(le,nt)|0;var Ct=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,P=Math.imul(V,Pe),_=Math.imul(V,Ze),_=_+Math.imul(T,Pe)|0,q=Math.imul(T,Ze),P=P+Math.imul(Se,Te)|0,_=_+Math.imul(Se,Ye)|0,_=_+Math.imul(Oe,Te)|0,q=q+Math.imul(Oe,Ye)|0,P=P+Math.imul(ve,ke)|0,_=_+Math.imul(ve,et)|0,_=_+Math.imul(Be,ke)|0,q=q+Math.imul(Be,et)|0,P=P+Math.imul(ye,qe)|0,_=_+Math.imul(ye,rt)|0,_=_+Math.imul($e,qe)|0,q=q+Math.imul($e,rt)|0,P=P+Math.imul(be,Ce)|0,_=_+Math.imul(be,nt)|0,_=_+Math.imul(se,Ce)|0,q=q+Math.imul(se,nt)|0;var Nt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,P=Math.imul(V,Te),_=Math.imul(V,Ye),_=_+Math.imul(T,Te)|0,q=Math.imul(T,Ye),P=P+Math.imul(Se,ke)|0,_=_+Math.imul(Se,et)|0,_=_+Math.imul(Oe,ke)|0,q=q+Math.imul(Oe,et)|0,P=P+Math.imul(ve,qe)|0,_=_+Math.imul(ve,rt)|0,_=_+Math.imul(Be,qe)|0,q=q+Math.imul(Be,rt)|0,P=P+Math.imul(ye,Ce)|0,_=_+Math.imul(ye,nt)|0,_=_+Math.imul($e,Ce)|0,q=q+Math.imul($e,nt)|0;var Ot=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,P=Math.imul(V,ke),_=Math.imul(V,et),_=_+Math.imul(T,ke)|0,q=Math.imul(T,et),P=P+Math.imul(Se,qe)|0,_=_+Math.imul(Se,rt)|0,_=_+Math.imul(Oe,qe)|0,q=q+Math.imul(Oe,rt)|0,P=P+Math.imul(ve,Ce)|0,_=_+Math.imul(ve,nt)|0,_=_+Math.imul(Be,Ce)|0,q=q+Math.imul(Be,nt)|0;var Dt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,P=Math.imul(V,qe),_=Math.imul(V,rt),_=_+Math.imul(T,qe)|0,q=Math.imul(T,rt),P=P+Math.imul(Se,Ce)|0,_=_+Math.imul(Se,nt)|0,_=_+Math.imul(Oe,Ce)|0,q=q+Math.imul(Oe,nt)|0;var Lt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,P=Math.imul(V,Ce),_=Math.imul(V,nt),_=_+Math.imul(T,Ce)|0,q=Math.imul(T,nt);var Ft=(k+P|0)+((_&8191)<<13)|0;return k=(q+(_>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,M[0]=Ge,M[1]=Ke,M[2]=ct,M[3]=dt,M[4]=ht,M[5]=lt,M[6]=pt,M[7]=bt,M[8]=xt,M[9]=yt,M[10]=mt,M[11]=vt,M[12]=qt,M[13]=Ct,M[14]=Nt,M[15]=Ot,M[16]=Dt,M[17]=Lt,M[18]=Ft,k!==0&&(M[19]=k,y.length++),y};Math.imul||(g=v);function $(J,R,A){A.negative=R.negative^J.negative,A.length=J.length+R.length;for(var y=0,w=0,I=0;I<A.length-1;I++){var M=w;w=0;for(var k=y&67108863,P=Math.min(I,R.length-1),_=Math.max(0,I-J.length+1);_<=P;_++){var q=I-_,E=J.words[q]|0,j=R.words[_]|0,ee=E*j,oe=ee&67108863;M=M+(ee/67108864|0)|0,oe=oe+k|0,k=oe&67108863,M=M+(oe>>>26)|0,w+=M>>>26,M&=67108863}A.words[I]=k,y=M,M=w}return y!==0?A.words[I]=y:A.length--,A.strip()}function B(J,R,A){var y=new C;return y.mulp(J,R,A)}o.prototype.mulTo=function(R,A){var y,w=this.length+R.length;return this.length===10&&R.length===10?y=g(this,R,A):w<63?y=v(this,R,A):w<1024?y=$(this,R,A):y=B(this,R,A),y};function C(J,R){this.x=J,this.y=R}C.prototype.makeRBT=function(R){for(var A=new Array(R),y=o.prototype._countBits(R)-1,w=0;w<R;w++)A[w]=this.revBin(w,y,R);return A},C.prototype.revBin=function(R,A,y){if(R===0||R===y-1)return R;for(var w=0,I=0;I<A;I++)w|=(R&1)<<A-I-1,R>>=1;return w},C.prototype.permute=function(R,A,y,w,I,M){for(var k=0;k<M;k++)w[k]=A[R[k]],I[k]=y[R[k]]},C.prototype.transform=function(R,A,y,w,I,M){this.permute(M,R,A,y,w,I);for(var k=1;k<I;k<<=1)for(var P=k<<1,_=Math.cos(2*Math.PI/P),q=Math.sin(2*Math.PI/P),E=0;E<I;E+=P)for(var j=_,ee=q,oe=0;oe<k;oe++){var Y=y[E+oe],L=w[E+oe],z=y[E+oe+k],re=w[E+oe+k],D=j*z-ee*re;re=j*re+ee*z,z=D,y[E+oe]=Y+z,w[E+oe]=L+re,y[E+oe+k]=Y-z,w[E+oe+k]=L-re,oe!==P&&(D=_*j-q*ee,ee=_*ee+q*j,j=D)}},C.prototype.guessLen13b=function(R,A){var y=Math.max(A,R)|1,w=y&1,I=0;for(y=y/2|0;y;y=y>>>1)I++;return 1<<I+1+w},C.prototype.conjugate=function(R,A,y){if(!(y<=1))for(var w=0;w<y/2;w++){var I=R[w];R[w]=R[y-w-1],R[y-w-1]=I,I=A[w],A[w]=-A[y-w-1],A[y-w-1]=-I}},C.prototype.normalize13b=function(R,A){for(var y=0,w=0;w<A/2;w++){var I=Math.round(R[2*w+1]/A)*8192+Math.round(R[2*w]/A)+y;R[w]=I&67108863,I<67108864?y=0:y=I/67108864|0}return R},C.prototype.convert13b=function(R,A,y,w){for(var I=0,M=0;M<A;M++)I=I+(R[M]|0),y[2*M]=I&8191,I=I>>>13,y[2*M+1]=I&8191,I=I>>>13;for(M=2*A;M<w;++M)y[M]=0;a(I===0),a((I&-8192)===0)},C.prototype.stub=function(R){for(var A=new Array(R),y=0;y<R;y++)A[y]=0;return A},C.prototype.mulp=function(R,A,y){var w=2*this.guessLen13b(R.length,A.length),I=this.makeRBT(w),M=this.stub(w),k=new Array(w),P=new Array(w),_=new Array(w),q=new Array(w),E=new Array(w),j=new Array(w),ee=y.words;ee.length=w,this.convert13b(R.words,R.length,k,w),this.convert13b(A.words,A.length,q,w),this.transform(k,M,P,_,w,I),this.transform(q,M,E,j,w,I);for(var oe=0;oe<w;oe++){var Y=P[oe]*E[oe]-_[oe]*j[oe];_[oe]=P[oe]*j[oe]+_[oe]*E[oe],P[oe]=Y}return this.conjugate(P,_,w),this.transform(P,_,ee,M,w,I),this.conjugate(ee,M,w),this.normalize13b(ee,w),y.negative=R.negative^A.negative,y.length=R.length+A.length,y.strip()},o.prototype.mul=function(R){var A=new o(null);return A.words=new Array(this.length+R.length),this.mulTo(R,A)},o.prototype.mulf=function(R){var A=new o(null);return A.words=new Array(this.length+R.length),B(this,R,A)},o.prototype.imul=function(R){return this.clone().mulTo(R,this)},o.prototype.imuln=function(R){a(typeof R=="number"),a(R<67108864);for(var A=0,y=0;y<this.length;y++){var w=(this.words[y]|0)*R,I=(w&67108863)+(A&67108863);A>>=26,A+=w/67108864|0,A+=I>>>26,this.words[y]=I&67108863}return A!==0&&(this.words[y]=A,this.length++),this},o.prototype.muln=function(R){return this.clone().imuln(R)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(R){var A=m(R);if(A.length===0)return new o(1);for(var y=this,w=0;w<A.length&&A[w]===0;w++,y=y.sqr());if(++w<A.length)for(var I=y.sqr();w<A.length;w++,I=I.sqr())A[w]!==0&&(y=y.mul(I));return y},o.prototype.iushln=function(R){a(typeof R=="number"&&R>=0);var A=R%26,y=(R-A)/26,w=67108863>>>26-A<<26-A,I;if(A!==0){var M=0;for(I=0;I<this.length;I++){var k=this.words[I]&w,P=(this.words[I]|0)-k<<A;this.words[I]=P|M,M=k>>>26-A}M&&(this.words[I]=M,this.length++)}if(y!==0){for(I=this.length-1;I>=0;I--)this.words[I+y]=this.words[I];for(I=0;I<y;I++)this.words[I]=0;this.length+=y}return this.strip()},o.prototype.ishln=function(R){return a(this.negative===0),this.iushln(R)},o.prototype.iushrn=function(R,A,y){a(typeof R=="number"&&R>=0);var w;A?w=(A-A%26)/26:w=0;var I=R%26,M=Math.min((R-I)/26,this.length),k=67108863^67108863>>>I<<I,P=y;if(w-=M,w=Math.max(0,w),P){for(var _=0;_<M;_++)P.words[_]=this.words[_];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,_=0;_<this.length;_++)this.words[_]=this.words[_+M];else this.words[0]=0,this.length=1;var q=0;for(_=this.length-1;_>=0&&(q!==0||_>=w);_--){var E=this.words[_]|0;this.words[_]=q<<26-I|E>>>I,q=E&k}return P&&q!==0&&(P.words[P.length++]=q),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(R,A,y){return a(this.negative===0),this.iushrn(R,A,y)},o.prototype.shln=function(R){return this.clone().ishln(R)},o.prototype.ushln=function(R){return this.clone().iushln(R)},o.prototype.shrn=function(R){return this.clone().ishrn(R)},o.prototype.ushrn=function(R){return this.clone().iushrn(R)},o.prototype.testn=function(R){a(typeof R=="number"&&R>=0);var A=R%26,y=(R-A)/26,w=1<<A;if(this.length<=y)return!1;var I=this.words[y];return!!(I&w)},o.prototype.imaskn=function(R){a(typeof R=="number"&&R>=0);var A=R%26,y=(R-A)/26;if(a(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(A!==0&&y++,this.length=Math.min(y,this.length),A!==0){var w=67108863^67108863>>>A<<A;this.words[this.length-1]&=w}return this.strip()},o.prototype.maskn=function(R){return this.clone().imaskn(R)},o.prototype.iaddn=function(R){return a(typeof R=="number"),a(R<67108864),R<0?this.isubn(-R):this.negative!==0?this.length===1&&(this.words[0]|0)<R?(this.words[0]=R-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(R),this.negative=1,this):this._iaddn(R)},o.prototype._iaddn=function(R){this.words[0]+=R;for(var A=0;A<this.length&&this.words[A]>=67108864;A++)this.words[A]-=67108864,A===this.length-1?this.words[A+1]=1:this.words[A+1]++;return this.length=Math.max(this.length,A+1),this},o.prototype.isubn=function(R){if(a(typeof R=="number"),a(R<67108864),R<0)return this.iaddn(-R);if(this.negative!==0)return this.negative=0,this.iaddn(R),this.negative=1,this;if(this.words[0]-=R,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var A=0;A<this.length&&this.words[A]<0;A++)this.words[A]+=67108864,this.words[A+1]-=1;return this.strip()},o.prototype.addn=function(R){return this.clone().iaddn(R)},o.prototype.subn=function(R){return this.clone().isubn(R)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(R,A,y){var w=R.length+y,I;this._expand(w);var M,k=0;for(I=0;I<R.length;I++){M=(this.words[I+y]|0)+k;var P=(R.words[I]|0)*A;M-=P&67108863,k=(M>>26)-(P/67108864|0),this.words[I+y]=M&67108863}for(;I<this.length-y;I++)M=(this.words[I+y]|0)+k,k=M>>26,this.words[I+y]=M&67108863;if(k===0)return this.strip();for(a(k===-1),k=0,I=0;I<this.length;I++)M=-(this.words[I]|0)+k,k=M>>26,this.words[I]=M&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(R,A){var y=this.length-R.length,w=this.clone(),I=R,M=I.words[I.length-1]|0,k=this._countBits(M);y=26-k,y!==0&&(I=I.ushln(y),w.iushln(y),M=I.words[I.length-1]|0);var P=w.length-I.length,_;if(A!=="mod"){_=new o(null),_.length=P+1,_.words=new Array(_.length);for(var q=0;q<_.length;q++)_.words[q]=0}var E=w.clone()._ishlnsubmul(I,1,P);E.negative===0&&(w=E,_&&(_.words[P]=1));for(var j=P-1;j>=0;j--){var ee=(w.words[I.length+j]|0)*67108864+(w.words[I.length+j-1]|0);for(ee=Math.min(ee/M|0,67108863),w._ishlnsubmul(I,ee,j);w.negative!==0;)ee--,w.negative=0,w._ishlnsubmul(I,1,j),w.isZero()||(w.negative^=1);_&&(_.words[j]=ee)}return _&&_.strip(),w.strip(),A!=="div"&&y!==0&&w.iushrn(y),{div:_||null,mod:w}},o.prototype.divmod=function(R,A,y){if(a(!R.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var w,I,M;return this.negative!==0&&R.negative===0?(M=this.neg().divmod(R,A),A!=="mod"&&(w=M.div.neg()),A!=="div"&&(I=M.mod.neg(),y&&I.negative!==0&&I.iadd(R)),{div:w,mod:I}):this.negative===0&&R.negative!==0?(M=this.divmod(R.neg(),A),A!=="mod"&&(w=M.div.neg()),{div:w,mod:M.mod}):this.negative&R.negative?(M=this.neg().divmod(R.neg(),A),A!=="div"&&(I=M.mod.neg(),y&&I.negative!==0&&I.isub(R)),{div:M.div,mod:I}):R.length>this.length||this.cmp(R)<0?{div:new o(0),mod:this}:R.length===1?A==="div"?{div:this.divn(R.words[0]),mod:null}:A==="mod"?{div:null,mod:new o(this.modn(R.words[0]))}:{div:this.divn(R.words[0]),mod:new o(this.modn(R.words[0]))}:this._wordDiv(R,A)},o.prototype.div=function(R){return this.divmod(R,"div",!1).div},o.prototype.mod=function(R){return this.divmod(R,"mod",!1).mod},o.prototype.umod=function(R){return this.divmod(R,"mod",!0).mod},o.prototype.divRound=function(R){var A=this.divmod(R);if(A.mod.isZero())return A.div;var y=A.div.negative!==0?A.mod.isub(R):A.mod,w=R.ushrn(1),I=R.andln(1),M=y.cmp(w);return M<0||I===1&&M===0?A.div:A.div.negative!==0?A.div.isubn(1):A.div.iaddn(1)},o.prototype.modn=function(R){a(R<=67108863);for(var A=(1<<26)%R,y=0,w=this.length-1;w>=0;w--)y=(A*y+(this.words[w]|0))%R;return y},o.prototype.idivn=function(R){a(R<=67108863);for(var A=0,y=this.length-1;y>=0;y--){var w=(this.words[y]|0)+A*67108864;this.words[y]=w/R|0,A=w%R}return this.strip()},o.prototype.divn=function(R){return this.clone().idivn(R)},o.prototype.egcd=function(R){a(R.negative===0),a(!R.isZero());var A=this,y=R.clone();A.negative!==0?A=A.umod(R):A=A.clone();for(var w=new o(1),I=new o(0),M=new o(0),k=new o(1),P=0;A.isEven()&&y.isEven();)A.iushrn(1),y.iushrn(1),++P;for(var _=y.clone(),q=A.clone();!A.isZero();){for(var E=0,j=1;!(A.words[0]&j)&&E<26;++E,j<<=1);if(E>0)for(A.iushrn(E);E-- >0;)(w.isOdd()||I.isOdd())&&(w.iadd(_),I.isub(q)),w.iushrn(1),I.iushrn(1);for(var ee=0,oe=1;!(y.words[0]&oe)&&ee<26;++ee,oe<<=1);if(ee>0)for(y.iushrn(ee);ee-- >0;)(M.isOdd()||k.isOdd())&&(M.iadd(_),k.isub(q)),M.iushrn(1),k.iushrn(1);A.cmp(y)>=0?(A.isub(y),w.isub(M),I.isub(k)):(y.isub(A),M.isub(w),k.isub(I))}return{a:M,b:k,gcd:y.iushln(P)}},o.prototype._invmp=function(R){a(R.negative===0),a(!R.isZero());var A=this,y=R.clone();A.negative!==0?A=A.umod(R):A=A.clone();for(var w=new o(1),I=new o(0),M=y.clone();A.cmpn(1)>0&&y.cmpn(1)>0;){for(var k=0,P=1;!(A.words[0]&P)&&k<26;++k,P<<=1);if(k>0)for(A.iushrn(k);k-- >0;)w.isOdd()&&w.iadd(M),w.iushrn(1);for(var _=0,q=1;!(y.words[0]&q)&&_<26;++_,q<<=1);if(_>0)for(y.iushrn(_);_-- >0;)I.isOdd()&&I.iadd(M),I.iushrn(1);A.cmp(y)>=0?(A.isub(y),w.isub(I)):(y.isub(A),I.isub(w))}var E;return A.cmpn(1)===0?E=w:E=I,E.cmpn(0)<0&&E.iadd(R),E},o.prototype.gcd=function(R){if(this.isZero())return R.abs();if(R.isZero())return this.abs();var A=this.clone(),y=R.clone();A.negative=0,y.negative=0;for(var w=0;A.isEven()&&y.isEven();w++)A.iushrn(1),y.iushrn(1);do{for(;A.isEven();)A.iushrn(1);for(;y.isEven();)y.iushrn(1);var I=A.cmp(y);if(I<0){var M=A;A=y,y=M}else if(I===0||y.cmpn(1)===0)break;A.isub(y)}while(!0);return y.iushln(w)},o.prototype.invm=function(R){return this.egcd(R).a.umod(R)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(R){return this.words[0]&R},o.prototype.bincn=function(R){a(typeof R=="number");var A=R%26,y=(R-A)/26,w=1<<A;if(this.length<=y)return this._expand(y+1),this.words[y]|=w,this;for(var I=w,M=y;I!==0&&M<this.length;M++){var k=this.words[M]|0;k+=I,I=k>>>26,k&=67108863,this.words[M]=k}return I!==0&&(this.words[M]=I,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(R){var A=R<0;if(this.negative!==0&&!A)return-1;if(this.negative===0&&A)return 1;this.strip();var y;if(this.length>1)y=1;else{A&&(R=-R),a(R<=67108863,"Number is too big");var w=this.words[0]|0;y=w===R?0:w<R?-1:1}return this.negative!==0?-y|0:y},o.prototype.cmp=function(R){if(this.negative!==0&&R.negative===0)return-1;if(this.negative===0&&R.negative!==0)return 1;var A=this.ucmp(R);return this.negative!==0?-A|0:A},o.prototype.ucmp=function(R){if(this.length>R.length)return 1;if(this.length<R.length)return-1;for(var A=0,y=this.length-1;y>=0;y--){var w=this.words[y]|0,I=R.words[y]|0;if(w!==I){w<I?A=-1:w>I&&(A=1);break}}return A},o.prototype.gtn=function(R){return this.cmpn(R)===1},o.prototype.gt=function(R){return this.cmp(R)===1},o.prototype.gten=function(R){return this.cmpn(R)>=0},o.prototype.gte=function(R){return this.cmp(R)>=0},o.prototype.ltn=function(R){return this.cmpn(R)===-1},o.prototype.lt=function(R){return this.cmp(R)===-1},o.prototype.lten=function(R){return this.cmpn(R)<=0},o.prototype.lte=function(R){return this.cmp(R)<=0},o.prototype.eqn=function(R){return this.cmpn(R)===0},o.prototype.eq=function(R){return this.cmp(R)===0},o.red=function(R){return new ae(R)},o.prototype.toRed=function(R){return a(!this.red,"Already a number in reduction context"),a(this.negative===0,"red works only with positives"),R.convertTo(this)._forceRed(R)},o.prototype.fromRed=function(){return a(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(R){return this.red=R,this},o.prototype.forceRed=function(R){return a(!this.red,"Already a number in reduction context"),this._forceRed(R)},o.prototype.redAdd=function(R){return a(this.red,"redAdd works only with red numbers"),this.red.add(this,R)},o.prototype.redIAdd=function(R){return a(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,R)},o.prototype.redSub=function(R){return a(this.red,"redSub works only with red numbers"),this.red.sub(this,R)},o.prototype.redISub=function(R){return a(this.red,"redISub works only with red numbers"),this.red.isub(this,R)},o.prototype.redShl=function(R){return a(this.red,"redShl works only with red numbers"),this.red.shl(this,R)},o.prototype.redMul=function(R){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,R),this.red.mul(this,R)},o.prototype.redIMul=function(R){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,R),this.red.imul(this,R)},o.prototype.redSqr=function(){return a(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return a(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return a(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return a(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return a(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(R){return a(this.red&&!R.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,R)};var F={k256:null,p224:null,p192:null,p25519:null};function H(J,R){this.name=J,this.p=new o(R,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var R=new o(null);return R.words=new Array(Math.ceil(this.n/13)),R},H.prototype.ireduce=function(R){var A=R,y;do this.split(A,this.tmp),A=this.imulK(A),A=A.iadd(this.tmp),y=A.bitLength();while(y>this.n);var w=y<this.n?-1:A.ucmp(this.p);return w===0?(A.words[0]=0,A.length=1):w>0?A.isub(this.p):A.strip!==void 0?A.strip():A._strip(),A},H.prototype.split=function(R,A){R.iushrn(this.n,0,A)},H.prototype.imulK=function(R){return R.imul(this.k)};function W(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}c(W,H),W.prototype.split=function(R,A){for(var y=4194303,w=Math.min(R.length,9),I=0;I<w;I++)A.words[I]=R.words[I];if(A.length=w,R.length<=9){R.words[0]=0,R.length=1;return}var M=R.words[9];for(A.words[A.length++]=M&y,I=10;I<R.length;I++){var k=R.words[I]|0;R.words[I-10]=(k&y)<<4|M>>>22,M=k}M>>>=22,R.words[I-10]=M,M===0&&R.length>10?R.length-=10:R.length-=9},W.prototype.imulK=function(R){R.words[R.length]=0,R.words[R.length+1]=0,R.length+=2;for(var A=0,y=0;y<R.length;y++){var w=R.words[y]|0;A+=w*977,R.words[y]=A&67108863,A=w*64+(A/67108864|0)}return R.words[R.length-1]===0&&(R.length--,R.words[R.length-1]===0&&R.length--),R};function Z(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}c(Z,H);function ie(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}c(ie,H);function te(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}c(te,H),te.prototype.imulK=function(R){for(var A=0,y=0;y<R.length;y++){var w=(R.words[y]|0)*19+A,I=w&67108863;w>>>=26,R.words[y]=I,A=w}return A!==0&&(R.words[R.length++]=A),R},o._prime=function(R){if(F[R])return F[R];var A;if(R==="k256")A=new W;else if(R==="p224")A=new Z;else if(R==="p192")A=new ie;else if(R==="p25519")A=new te;else throw new Error("Unknown prime "+R);return F[R]=A,A};function ae(J){if(typeof J=="string"){var R=o._prime(J);this.m=R.p,this.prime=R}else a(J.gtn(1),"modulus must be greater than 1"),this.m=J,this.prime=null}ae.prototype._verify1=function(R){a(R.negative===0,"red works only with positives"),a(R.red,"red works only with red numbers")},ae.prototype._verify2=function(R,A){a((R.negative|A.negative)===0,"red works only with positives"),a(R.red&&R.red===A.red,"red works only with red numbers")},ae.prototype.imod=function(R){return this.prime?this.prime.ireduce(R)._forceRed(this):R.umod(this.m)._forceRed(this)},ae.prototype.neg=function(R){return R.isZero()?R.clone():this.m.sub(R)._forceRed(this)},ae.prototype.add=function(R,A){this._verify2(R,A);var y=R.add(A);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},ae.prototype.iadd=function(R,A){this._verify2(R,A);var y=R.iadd(A);return y.cmp(this.m)>=0&&y.isub(this.m),y},ae.prototype.sub=function(R,A){this._verify2(R,A);var y=R.sub(A);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},ae.prototype.isub=function(R,A){this._verify2(R,A);var y=R.isub(A);return y.cmpn(0)<0&&y.iadd(this.m),y},ae.prototype.shl=function(R,A){return this._verify1(R),this.imod(R.ushln(A))},ae.prototype.imul=function(R,A){return this._verify2(R,A),this.imod(R.imul(A))},ae.prototype.mul=function(R,A){return this._verify2(R,A),this.imod(R.mul(A))},ae.prototype.isqr=function(R){return this.imul(R,R.clone())},ae.prototype.sqr=function(R){return this.mul(R,R)},ae.prototype.sqrt=function(R){if(R.isZero())return R.clone();var A=this.m.andln(3);if(a(A%2===1),A===3){var y=this.m.add(new o(1)).iushrn(2);return this.pow(R,y)}for(var w=this.m.subn(1),I=0;!w.isZero()&&w.andln(1)===0;)I++,w.iushrn(1);a(!w.isZero());var M=new o(1).toRed(this),k=M.redNeg(),P=this.m.subn(1).iushrn(1),_=this.m.bitLength();for(_=new o(2*_*_).toRed(this);this.pow(_,P).cmp(k)!==0;)_.redIAdd(k);for(var q=this.pow(_,w),E=this.pow(R,w.addn(1).iushrn(1)),j=this.pow(R,w),ee=I;j.cmp(M)!==0;){for(var oe=j,Y=0;oe.cmp(M)!==0;Y++)oe=oe.redSqr();a(Y<ee);var L=this.pow(q,new o(1).iushln(ee-Y-1));E=E.redMul(L),q=L.redSqr(),j=j.redMul(q),ee=Y}return E},ae.prototype.invm=function(R){var A=R._invmp(this.m);return A.negative!==0?(A.negative=0,this.imod(A).redNeg()):this.imod(A)},ae.prototype.pow=function(R,A){if(A.isZero())return new o(1).toRed(this);if(A.cmpn(1)===0)return R.clone();var y=4,w=new Array(1<<y);w[0]=new o(1).toRed(this),w[1]=R;for(var I=2;I<w.length;I++)w[I]=this.mul(w[I-1],R);var M=w[0],k=0,P=0,_=A.bitLength()%26;for(_===0&&(_=26),I=A.length-1;I>=0;I--){for(var q=A.words[I],E=_-1;E>=0;E--){var j=q>>E&1;if(M!==w[0]&&(M=this.sqr(M)),j===0&&k===0){P=0;continue}k<<=1,k|=j,P++,!(P!==y&&(I!==0||E!==0))&&(M=this.mul(M,w[k]),P=0,k=0)}_=26}return M},ae.prototype.convertTo=function(R){var A=R.umod(this.m);return A===R?A.clone():A},ae.prototype.convertFrom=function(R){var A=R.clone();return A.red=null,A},o.mont=function(R){return new de(R)};function de(J){ae.call(this,J),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}c(de,ae),de.prototype.convertTo=function(R){return this.imod(R.ushln(this.shift))},de.prototype.convertFrom=function(R){var A=this.imod(R.mul(this.rinv));return A.red=null,A},de.prototype.imul=function(R,A){if(R.isZero()||A.isZero())return R.words[0]=0,R.length=1,R;var y=R.imul(A),w=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=y.isub(w).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},de.prototype.mul=function(R,A){if(R.isZero()||A.isZero())return new o(0)._forceRed(this);var y=R.mul(A),w=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=y.isub(w).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},de.prototype.invm=function(R){var A=this.imod(R._invmp(this.m).mul(this.r2));return A._forceRed(this)}})(t,commonjsGlobal)}(bn$1);var bnExports=bn$1.exports,minimalisticAssert=assert$e;function assert$e(t,e){if(!t)throw new Error(e||"Assertion failed")}assert$e.equal=function(e,n,a){if(e!=n)throw new Error(a||"Assertion failed: "+e+" != "+n)};var utils$n={};(function(t){var e=t;function n(o,u){if(Array.isArray(o))return o.slice();if(!o)return[];var h=[];if(typeof o!="string"){for(var l=0;l<o.length;l++)h[l]=o[l]|0;return h}if(u==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var l=0;l<o.length;l+=2)h.push(parseInt(o[l]+o[l+1],16))}else for(var l=0;l<o.length;l++){var b=o.charCodeAt(l),d=b>>8,p=b&255;d?h.push(d,p):h.push(p)}return h}e.toArray=n;function a(o){return o.length===1?"0"+o:o}e.zero2=a;function c(o){for(var u="",h=0;h<o.length;h++)u+=a(o[h].toString(16));return u}e.toHex=c,e.encode=function(u,h){return h==="hex"?c(u):u}})(utils$n),function(t){var e=t,n=bnExports,a=minimalisticAssert,c=utils$n;e.assert=a,e.toArray=c.toArray,e.zero2=c.zero2,e.toHex=c.toHex,e.encode=c.encode;function o(d,p,x){var m=new Array(Math.max(d.bitLength(),x)+1),v;for(v=0;v<m.length;v+=1)m[v]=0;var g=1<<p+1,$=d.clone();for(v=0;v<m.length;v++){var B,C=$.andln(g-1);$.isOdd()?(C>(g>>1)-1?B=(g>>1)-C:B=C,$.isubn(B)):B=0,m[v]=B,$.iushrn(1)}return m}e.getNAF=o;function u(d,p){var x=[[],[]];d=d.clone(),p=p.clone();for(var m=0,v=0,g;d.cmpn(-m)>0||p.cmpn(-v)>0;){var $=d.andln(3)+m&3,B=p.andln(3)+v&3;$===3&&($=-1),B===3&&(B=-1);var C;$&1?(g=d.andln(7)+m&7,(g===3||g===5)&&B===2?C=-$:C=$):C=0,x[0].push(C);var F;B&1?(g=p.andln(7)+v&7,(g===3||g===5)&&$===2?F=-B:F=B):F=0,x[1].push(F),2*m===C+1&&(m=1-m),2*v===F+1&&(v=1-v),d.iushrn(1),p.iushrn(1)}return x}e.getJSF=u;function h(d,p,x){var m="_"+p;d.prototype[p]=function(){return this[m]!==void 0?this[m]:this[m]=x.call(this)}}e.cachedProperty=h;function l(d){return typeof d=="string"?e.toArray(d,"hex"):d}e.parseBytes=l;function b(d){return new n(d,"hex","le")}e.intFromLE=b}(utils$o);var brorand={exports:{}},cryptoBrowserify={},browser$b={exports:{}},safeBuffer$1={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var hasRequiredSafeBuffer$1;function requireSafeBuffer$1(){return hasRequiredSafeBuffer$1||(hasRequiredSafeBuffer$1=1,function(t,e){var n=require$$1$2,a=n.Buffer;function c(u,h){for(var l in u)h[l]=u[l]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=n:(c(n,e),e.Buffer=o);function o(u,h,l){return a(u,h,l)}o.prototype=Object.create(a.prototype),c(a,o),o.from=function(u,h,l){if(typeof u=="number")throw new TypeError("Argument must not be a number");return a(u,h,l)},o.alloc=function(u,h,l){if(typeof u!="number")throw new TypeError("Argument must be a number");var b=a(u);return h!==void 0?typeof l=="string"?b.fill(h,l):b.fill(h):b.fill(0),b},o.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a(u)},o.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(u)}}(safeBuffer$1,safeBuffer$1.exports)),safeBuffer$1.exports}var hasRequiredBrowser$b;function requireBrowser$b(){if(hasRequiredBrowser$b)return browser$b.exports;hasRequiredBrowser$b=1;var t=65536,e=4294967295;function n(){throw new Error(`Secure random number generation is not supported by this browser.
10
- Use Chrome, Firefox or Internet Explorer 11`)}var a=requireSafeBuffer$1().Buffer,c=commonjsGlobal.crypto||commonjsGlobal.msCrypto;c&&c.getRandomValues?browser$b.exports=o:browser$b.exports=n;function o(u,h){if(u>e)throw new RangeError("requested too many random bytes");var l=a.allocUnsafe(u);if(u>0)if(u>t)for(var b=0;b<u;b+=t)c.getRandomValues(l.slice(b,b+t));else c.getRandomValues(l);return typeof h=="function"?process$1.nextTick(function(){h(null,l)}):l}return browser$b.exports}var inherits_browser={exports:{}};typeof Object.create=="function"?inherits_browser.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser.exports=function(e,n){if(n){e.super_=n;var a=function(){};a.prototype=n.prototype,e.prototype=new a,e.prototype.constructor=e}};var inherits_browserExports=inherits_browser.exports,readableBrowser$1={exports:{}},events={exports:{}},hasRequiredEvents;function requireEvents(){if(hasRequiredEvents)return events.exports;hasRequiredEvents=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(W,Z,ie){return Function.prototype.apply.call(W,Z,ie)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(W){return Object.getOwnPropertyNames(W).concat(Object.getOwnPropertySymbols(W))}:n=function(W){return Object.getOwnPropertyNames(W)};function a(H){console&&console.warn&&console.warn(H)}var c=Number.isNaN||function(W){return W!==W};function o(){o.init.call(this)}events.exports=o,events.exports.once=B,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var u=10;function h(H){if(typeof H!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof H)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(H){if(typeof H!="number"||H<0||c(H))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+H+".");u=H}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(W){if(typeof W!="number"||W<0||c(W))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+W+".");return this._maxListeners=W,this};function l(H){return H._maxListeners===void 0?o.defaultMaxListeners:H._maxListeners}o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(W){for(var Z=[],ie=1;ie<arguments.length;ie++)Z.push(arguments[ie]);var te=W==="error",ae=this._events;if(ae!==void 0)te=te&&ae.error===void 0;else if(!te)return!1;if(te){var de;if(Z.length>0&&(de=Z[0]),de instanceof Error)throw de;var J=new Error("Unhandled error."+(de?" ("+de.message+")":""));throw J.context=de,J}var R=ae[W];if(R===void 0)return!1;if(typeof R=="function")e(R,this,Z);else for(var A=R.length,y=v(R,A),ie=0;ie<A;++ie)e(y[ie],this,Z);return!0};function b(H,W,Z,ie){var te,ae,de;if(h(Z),ae=H._events,ae===void 0?(ae=H._events=Object.create(null),H._eventsCount=0):(ae.newListener!==void 0&&(H.emit("newListener",W,Z.listener?Z.listener:Z),ae=H._events),de=ae[W]),de===void 0)de=ae[W]=Z,++H._eventsCount;else if(typeof de=="function"?de=ae[W]=ie?[Z,de]:[de,Z]:ie?de.unshift(Z):de.push(Z),te=l(H),te>0&&de.length>te&&!de.warned){de.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+de.length+" "+String(W)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=H,J.type=W,J.count=de.length,a(J)}return H}o.prototype.addListener=function(W,Z){return b(this,W,Z,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(W,Z){return b(this,W,Z,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(H,W,Z){var ie={fired:!1,wrapFn:void 0,target:H,type:W,listener:Z},te=d.bind(ie);return te.listener=Z,ie.wrapFn=te,te}o.prototype.once=function(W,Z){return h(Z),this.on(W,p(this,W,Z)),this},o.prototype.prependOnceListener=function(W,Z){return h(Z),this.prependListener(W,p(this,W,Z)),this},o.prototype.removeListener=function(W,Z){var ie,te,ae,de,J;if(h(Z),te=this._events,te===void 0)return this;if(ie=te[W],ie===void 0)return this;if(ie===Z||ie.listener===Z)--this._eventsCount===0?this._events=Object.create(null):(delete te[W],te.removeListener&&this.emit("removeListener",W,ie.listener||Z));else if(typeof ie!="function"){for(ae=-1,de=ie.length-1;de>=0;de--)if(ie[de]===Z||ie[de].listener===Z){J=ie[de].listener,ae=de;break}if(ae<0)return this;ae===0?ie.shift():g(ie,ae),ie.length===1&&(te[W]=ie[0]),te.removeListener!==void 0&&this.emit("removeListener",W,J||Z)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(W){var Z,ie,te;if(ie=this._events,ie===void 0)return this;if(ie.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):ie[W]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete ie[W]),this;if(arguments.length===0){var ae=Object.keys(ie),de;for(te=0;te<ae.length;++te)de=ae[te],de!=="removeListener"&&this.removeAllListeners(de);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(Z=ie[W],typeof Z=="function")this.removeListener(W,Z);else if(Z!==void 0)for(te=Z.length-1;te>=0;te--)this.removeListener(W,Z[te]);return this};function x(H,W,Z){var ie=H._events;if(ie===void 0)return[];var te=ie[W];return te===void 0?[]:typeof te=="function"?Z?[te.listener||te]:[te]:Z?$(te):v(te,te.length)}o.prototype.listeners=function(W){return x(this,W,!0)},o.prototype.rawListeners=function(W){return x(this,W,!1)},o.listenerCount=function(H,W){return typeof H.listenerCount=="function"?H.listenerCount(W):m.call(H,W)},o.prototype.listenerCount=m;function m(H){var W=this._events;if(W!==void 0){var Z=W[H];if(typeof Z=="function")return 1;if(Z!==void 0)return Z.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function v(H,W){for(var Z=new Array(W),ie=0;ie<W;++ie)Z[ie]=H[ie];return Z}function g(H,W){for(;W+1<H.length;W++)H[W]=H[W+1];H.pop()}function $(H){for(var W=new Array(H.length),Z=0;Z<W.length;++Z)W[Z]=H[Z].listener||H[Z];return W}function B(H,W){return new Promise(function(Z,ie){function te(de){H.removeListener(W,ae),ie(de)}function ae(){typeof H.removeListener=="function"&&H.removeListener("error",te),Z([].slice.call(arguments))}F(H,W,ae,{once:!0}),W!=="error"&&C(H,te,{once:!0})})}function C(H,W,Z){typeof H.on=="function"&&F(H,"error",W,Z)}function F(H,W,Z,ie){if(typeof H.on=="function")ie.once?H.once(W,Z):H.on(W,Z);else if(typeof H.addEventListener=="function")H.addEventListener(W,function te(ae){ie.once&&H.removeEventListener(W,te),Z(ae)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof H)}return events.exports}var streamBrowser$1,hasRequiredStreamBrowser$1;function requireStreamBrowser$1(){return hasRequiredStreamBrowser$1||(hasRequiredStreamBrowser$1=1,streamBrowser$1=requireEvents().EventEmitter),streamBrowser$1}var util$1={},types={},shams$1,hasRequiredShams$1;function requireShams$1(){return hasRequiredShams$1||(hasRequiredShams$1=1,shams$1=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),a=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(a)!=="[object Symbol]")return!1;var c=42;e[n]=c;for(n in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(e,n);if(u.value!==c||u.enumerable!==!0)return!1}return!0}),shams$1}var shams,hasRequiredShams;function requireShams(){if(hasRequiredShams)return shams;hasRequiredShams=1;var t=requireShams$1();return shams=function(){return t()&&!!Symbol.toStringTag},shams}var esErrors,hasRequiredEsErrors;function requireEsErrors(){return hasRequiredEsErrors||(hasRequiredEsErrors=1,esErrors=Error),esErrors}var _eval,hasRequired_eval;function require_eval(){return hasRequired_eval||(hasRequired_eval=1,_eval=EvalError),_eval}var range,hasRequiredRange;function requireRange(){return hasRequiredRange||(hasRequiredRange=1,range=RangeError),range}var ref,hasRequiredRef;function requireRef(){return hasRequiredRef||(hasRequiredRef=1,ref=ReferenceError),ref}var syntax,hasRequiredSyntax;function requireSyntax(){return hasRequiredSyntax||(hasRequiredSyntax=1,syntax=SyntaxError),syntax}var type,hasRequiredType;function requireType(){return hasRequiredType||(hasRequiredType=1,type=TypeError),type}var uri,hasRequiredUri;function requireUri(){return hasRequiredUri||(hasRequiredUri=1,uri=URIError),uri}var hasSymbols,hasRequiredHasSymbols;function requireHasSymbols(){if(hasRequiredHasSymbols)return hasSymbols;hasRequiredHasSymbols=1;var t=typeof Symbol<"u"&&Symbol,e=requireShams$1();return hasSymbols=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},hasSymbols}var hasProto,hasRequiredHasProto;function requireHasProto(){if(hasRequiredHasProto)return hasProto;hasRequiredHasProto=1;var t={__proto__:null,foo:{}},e=Object;return hasProto=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof e)},hasProto}var implementation,hasRequiredImplementation;function requireImplementation(){if(hasRequiredImplementation)return implementation;hasRequiredImplementation=1;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,n=Math.max,a="[object Function]",c=function(l,b){for(var d=[],p=0;p<l.length;p+=1)d[p]=l[p];for(var x=0;x<b.length;x+=1)d[x+l.length]=b[x];return d},o=function(l,b){for(var d=[],p=b,x=0;p<l.length;p+=1,x+=1)d[x]=l[p];return d},u=function(h,l){for(var b="",d=0;d<h.length;d+=1)b+=h[d],d+1<h.length&&(b+=l);return b};return implementation=function(l){var b=this;if(typeof b!="function"||e.apply(b)!==a)throw new TypeError(t+b);for(var d=o(arguments,1),p,x=function(){if(this instanceof p){var B=b.apply(this,c(d,arguments));return Object(B)===B?B:this}return b.apply(l,c(d,arguments))},m=n(0,b.length-d.length),v=[],g=0;g<m;g++)v[g]="$"+g;if(p=Function("binder","return function ("+u(v,",")+"){ return binder.apply(this,arguments); }")(x),b.prototype){var $=function(){};$.prototype=b.prototype,p.prototype=new $,$.prototype=null}return p},implementation}var functionBind,hasRequiredFunctionBind;function requireFunctionBind(){if(hasRequiredFunctionBind)return functionBind;hasRequiredFunctionBind=1;var t=requireImplementation();return functionBind=Function.prototype.bind||t,functionBind}var hasown,hasRequiredHasown;function requireHasown(){if(hasRequiredHasown)return hasown;hasRequiredHasown=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,n=requireFunctionBind();return hasown=n.call(t,e),hasown}var getIntrinsic,hasRequiredGetIntrinsic;function requireGetIntrinsic(){if(hasRequiredGetIntrinsic)return getIntrinsic;hasRequiredGetIntrinsic=1;var t,e=requireEsErrors(),n=require_eval(),a=requireRange(),c=requireRef(),o=requireSyntax(),u=requireType(),h=requireUri(),l=Function,b=function(M){try{return l('"use strict"; return ('+M+").constructor;")()}catch{}},d=Object.getOwnPropertyDescriptor;if(d)try{d({},"")}catch{d=null}var p=function(){throw new u},x=d?function(){try{return arguments.callee,p}catch{try{return d(arguments,"callee").get}catch{return p}}}():p,m=requireHasSymbols()(),v=requireHasProto()(),g=Object.getPrototypeOf||(v?function(M){return M.__proto__}:null),$={},B=typeof Uint8Array>"u"||!g?t:g(Uint8Array),C={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":m&&g?g([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":$,"%AsyncGenerator%":$,"%AsyncGeneratorFunction%":$,"%AsyncIteratorPrototype%":$,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":n,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":$,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":m&&g?g(g([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!m||!g?t:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":a,"%ReferenceError%":c,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!m||!g?t:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":m&&g?g(""[Symbol.iterator]()):t,"%Symbol%":m?Symbol:t,"%SyntaxError%":o,"%ThrowTypeError%":x,"%TypedArray%":B,"%TypeError%":u,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":h,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet};if(g)try{null.error}catch(M){var F=g(g(M));C["%Error.prototype%"]=F}var H=function M(k){var P;if(k==="%AsyncFunction%")P=b("async function () {}");else if(k==="%GeneratorFunction%")P=b("function* () {}");else if(k==="%AsyncGeneratorFunction%")P=b("async function* () {}");else if(k==="%AsyncGenerator%"){var _=M("%AsyncGeneratorFunction%");_&&(P=_.prototype)}else if(k==="%AsyncIteratorPrototype%"){var q=M("%AsyncGenerator%");q&&g&&(P=g(q.prototype))}return C[k]=P,P},W={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Z=requireFunctionBind(),ie=requireHasown(),te=Z.call(Function.call,Array.prototype.concat),ae=Z.call(Function.apply,Array.prototype.splice),de=Z.call(Function.call,String.prototype.replace),J=Z.call(Function.call,String.prototype.slice),R=Z.call(Function.call,RegExp.prototype.exec),A=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,y=/\\(\\)?/g,w=function(k){var P=J(k,0,1),_=J(k,-1);if(P==="%"&&_!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(_==="%"&&P!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var q=[];return de(k,A,function(E,j,ee,oe){q[q.length]=ee?de(oe,y,"$1"):j||E}),q},I=function(k,P){var _=k,q;if(ie(W,_)&&(q=W[_],_="%"+q[0]+"%"),ie(C,_)){var E=C[_];if(E===$&&(E=H(_)),typeof E>"u"&&!P)throw new u("intrinsic "+k+" exists, but is not available. Please file an issue!");return{alias:q,name:_,value:E}}throw new o("intrinsic "+k+" does not exist!")};return getIntrinsic=function(k,P){if(typeof k!="string"||k.length===0)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof P!="boolean")throw new u('"allowMissing" argument must be a boolean');if(R(/^%?[^%]*%?$/,k)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var _=w(k),q=_.length>0?_[0]:"",E=I("%"+q+"%",P),j=E.name,ee=E.value,oe=!1,Y=E.alias;Y&&(q=Y[0],ae(_,te([0,1],Y)));for(var L=1,z=!0;L<_.length;L+=1){var re=_[L],D=J(re,0,1),G=J(re,-1);if((D==='"'||D==="'"||D==="`"||G==='"'||G==="'"||G==="`")&&D!==G)throw new o("property names with quotes must have matching quotes");if((re==="constructor"||!z)&&(oe=!0),q+="."+re,j="%"+q+"%",ie(C,j))ee=C[j];else if(ee!=null){if(!(re in ee)){if(!P)throw new u("base intrinsic for "+k+" exists, but the property is not available.");return}if(d&&L+1>=_.length){var U=d(ee,re);z=!!U,z&&"get"in U&&!("originalValue"in U.get)?ee=U.get:ee=ee[re]}else z=ie(ee,re),ee=ee[re];z&&!oe&&(C[j]=ee)}}return ee},getIntrinsic}var callBind={exports:{}},esDefineProperty,hasRequiredEsDefineProperty;function requireEsDefineProperty(){if(hasRequiredEsDefineProperty)return esDefineProperty;hasRequiredEsDefineProperty=1;var t=requireGetIntrinsic(),e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return esDefineProperty=e,esDefineProperty}var gopd,hasRequiredGopd;function requireGopd(){if(hasRequiredGopd)return gopd;hasRequiredGopd=1;var t=requireGetIntrinsic(),e=t("%Object.getOwnPropertyDescriptor%",!0);if(e)try{e([],"length")}catch{e=null}return gopd=e,gopd}var defineDataProperty,hasRequiredDefineDataProperty;function requireDefineDataProperty(){if(hasRequiredDefineDataProperty)return defineDataProperty;hasRequiredDefineDataProperty=1;var t=requireEsDefineProperty(),e=requireSyntax(),n=requireType(),a=requireGopd();return defineDataProperty=function(o,u,h){if(!o||typeof o!="object"&&typeof o!="function")throw new n("`obj` must be an object or a function`");if(typeof u!="string"&&typeof u!="symbol")throw new n("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new n("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new n("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new n("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new n("`loose`, if provided, must be a boolean");var l=arguments.length>3?arguments[3]:null,b=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,p=arguments.length>6?arguments[6]:!1,x=!!a&&a(o,u);if(t)t(o,u,{configurable:d===null&&x?x.configurable:!d,enumerable:l===null&&x?x.enumerable:!l,value:h,writable:b===null&&x?x.writable:!b});else if(p||!l&&!b&&!d)o[u]=h;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},defineDataProperty}var hasPropertyDescriptors_1,hasRequiredHasPropertyDescriptors;function requireHasPropertyDescriptors(){if(hasRequiredHasPropertyDescriptors)return hasPropertyDescriptors_1;hasRequiredHasPropertyDescriptors=1;var t=requireEsDefineProperty(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},hasPropertyDescriptors_1=e,hasPropertyDescriptors_1}var setFunctionLength,hasRequiredSetFunctionLength;function requireSetFunctionLength(){if(hasRequiredSetFunctionLength)return setFunctionLength;hasRequiredSetFunctionLength=1;var t=requireGetIntrinsic(),e=requireDefineDataProperty(),n=requireHasPropertyDescriptors()(),a=requireGopd(),c=requireType(),o=t("%Math.floor%");return setFunctionLength=function(h,l){if(typeof h!="function")throw new c("`fn` is not a function");if(typeof l!="number"||l<0||l>4294967295||o(l)!==l)throw new c("`length` must be a positive 32-bit integer");var b=arguments.length>2&&!!arguments[2],d=!0,p=!0;if("length"in h&&a){var x=a(h,"length");x&&!x.configurable&&(d=!1),x&&!x.writable&&(p=!1)}return(d||p||!b)&&(n?e(h,"length",l,!0,!0):e(h,"length",l)),h},setFunctionLength}var hasRequiredCallBind;function requireCallBind(){return hasRequiredCallBind||(hasRequiredCallBind=1,function(t){var e=requireFunctionBind(),n=requireGetIntrinsic(),a=requireSetFunctionLength(),c=requireType(),o=n("%Function.prototype.apply%"),u=n("%Function.prototype.call%"),h=n("%Reflect.apply%",!0)||e.call(u,o),l=requireEsDefineProperty(),b=n("%Math.max%");t.exports=function(x){if(typeof x!="function")throw new c("a function is required");var m=h(e,u,arguments);return a(m,1+b(0,x.length-(arguments.length-1)),!0)};var d=function(){return h(e,o,arguments)};l?l(t.exports,"apply",{value:d}):t.exports.apply=d}(callBind)),callBind.exports}var callBound,hasRequiredCallBound;function requireCallBound(){if(hasRequiredCallBound)return callBound;hasRequiredCallBound=1;var t=requireGetIntrinsic(),e=requireCallBind(),n=e(t("String.prototype.indexOf"));return callBound=function(c,o){var u=t(c,!!o);return typeof u=="function"&&n(c,".prototype.")>-1?e(u):u},callBound}var isArguments,hasRequiredIsArguments;function requireIsArguments(){if(hasRequiredIsArguments)return isArguments;hasRequiredIsArguments=1;var t=requireShams()(),e=requireCallBound(),n=e("Object.prototype.toString"),a=function(h){return t&&h&&typeof h=="object"&&Symbol.toStringTag in h?!1:n(h)==="[object Arguments]"},c=function(h){return a(h)?!0:h!==null&&typeof h=="object"&&typeof h.length=="number"&&h.length>=0&&n(h)!=="[object Array]"&&n(h.callee)==="[object Function]"},o=function(){return a(arguments)}();return a.isLegacyArguments=c,isArguments=o?a:c,isArguments}var isGeneratorFunction,hasRequiredIsGeneratorFunction;function requireIsGeneratorFunction(){if(hasRequiredIsGeneratorFunction)return isGeneratorFunction;hasRequiredIsGeneratorFunction=1;var t=Object.prototype.toString,e=Function.prototype.toString,n=/^\s*(?:function)?\*/,a=requireShams()(),c=Object.getPrototypeOf,o=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch{}},u;return isGeneratorFunction=function(l){if(typeof l!="function")return!1;if(n.test(e.call(l)))return!0;if(!a){var b=t.call(l);return b==="[object GeneratorFunction]"}if(!c)return!1;if(typeof u>"u"){var d=o();u=d?c(d):!1}return c(l)===u},isGeneratorFunction}var isCallable,hasRequiredIsCallable;function requireIsCallable(){if(hasRequiredIsCallable)return isCallable;hasRequiredIsCallable=1;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,n,a;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{n=Object.defineProperty({},"length",{get:function(){throw a}}),a={},e(function(){throw 42},null,n)}catch(C){C!==a&&(e=null)}else e=null;var c=/^\s*class\b/,o=function(F){try{var H=t.call(F);return c.test(H)}catch{return!1}},u=function(F){try{return o(F)?!1:(t.call(F),!0)}catch{return!1}},h=Object.prototype.toString,l="[object Object]",b="[object Function]",d="[object GeneratorFunction]",p="[object HTMLAllCollection]",x="[object HTML document.all class]",m="[object HTMLCollection]",v=typeof Symbol=="function"&&!!Symbol.toStringTag,g=!(0 in[,]),$=function(){return!1};if(typeof document=="object"){var B=document.all;h.call(B)===h.call(document.all)&&($=function(F){if((g||!F)&&(typeof F>"u"||typeof F=="object"))try{var H=h.call(F);return(H===p||H===x||H===m||H===l)&&F("")==null}catch{}return!1})}return isCallable=e?function(F){if($(F))return!0;if(!F||typeof F!="function"&&typeof F!="object")return!1;try{e(F,null,n)}catch(H){if(H!==a)return!1}return!o(F)&&u(F)}:function(F){if($(F))return!0;if(!F||typeof F!="function"&&typeof F!="object")return!1;if(v)return u(F);if(o(F))return!1;var H=h.call(F);return H!==b&&H!==d&&!/^\[object HTML/.test(H)?!1:u(F)},isCallable}var forEach_1,hasRequiredForEach;function requireForEach(){if(hasRequiredForEach)return forEach_1;hasRequiredForEach=1;var t=requireIsCallable(),e=Object.prototype.toString,n=Object.prototype.hasOwnProperty,a=function(l,b,d){for(var p=0,x=l.length;p<x;p++)n.call(l,p)&&(d==null?b(l[p],p,l):b.call(d,l[p],p,l))},c=function(l,b,d){for(var p=0,x=l.length;p<x;p++)d==null?b(l.charAt(p),p,l):b.call(d,l.charAt(p),p,l)},o=function(l,b,d){for(var p in l)n.call(l,p)&&(d==null?b(l[p],p,l):b.call(d,l[p],p,l))},u=function(l,b,d){if(!t(b))throw new TypeError("iterator must be a function");var p;arguments.length>=3&&(p=d),e.call(l)==="[object Array]"?a(l,b,p):typeof l=="string"?c(l,b,p):o(l,b,p)};return forEach_1=u,forEach_1}var possibleTypedArrayNames,hasRequiredPossibleTypedArrayNames;function requirePossibleTypedArrayNames(){return hasRequiredPossibleTypedArrayNames||(hasRequiredPossibleTypedArrayNames=1,possibleTypedArrayNames=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),possibleTypedArrayNames}var availableTypedArrays,hasRequiredAvailableTypedArrays;function requireAvailableTypedArrays(){if(hasRequiredAvailableTypedArrays)return availableTypedArrays;hasRequiredAvailableTypedArrays=1;var t=requirePossibleTypedArrayNames(),e=typeof globalThis>"u"?commonjsGlobal:globalThis;return availableTypedArrays=function(){for(var a=[],c=0;c<t.length;c++)typeof e[t[c]]=="function"&&(a[a.length]=t[c]);return a},availableTypedArrays}var whichTypedArray,hasRequiredWhichTypedArray;function requireWhichTypedArray(){if(hasRequiredWhichTypedArray)return whichTypedArray;hasRequiredWhichTypedArray=1;var t=requireForEach(),e=requireAvailableTypedArrays(),n=requireCallBind(),a=requireCallBound(),c=requireGopd(),o=a("Object.prototype.toString"),u=requireShams()(),h=typeof globalThis>"u"?commonjsGlobal:globalThis,l=e(),b=a("String.prototype.slice"),d=Object.getPrototypeOf,p=a("Array.prototype.indexOf",!0)||function($,B){for(var C=0;C<$.length;C+=1)if($[C]===B)return C;return-1},x={__proto__:null};u&&c&&d?t(l,function(g){var $=new h[g];if(Symbol.toStringTag in $){var B=d($),C=c(B,Symbol.toStringTag);if(!C){var F=d(B);C=c(F,Symbol.toStringTag)}x["$"+g]=n(C.get)}}):t(l,function(g){var $=new h[g],B=$.slice||$.set;B&&(x["$"+g]=n(B))});var m=function($){var B=!1;return t(x,function(C,F){if(!B)try{"$"+C($)===F&&(B=b(F,1))}catch{}}),B},v=function($){var B=!1;return t(x,function(C,F){if(!B)try{C($),B=b(F,1)}catch{}}),B};return whichTypedArray=function($){if(!$||typeof $!="object")return!1;if(!u){var B=b(o($),8,-1);return p(l,B)>-1?B:B!=="Object"?!1:v($)}return c?m($):null},whichTypedArray}var isTypedArray$1,hasRequiredIsTypedArray;function requireIsTypedArray(){if(hasRequiredIsTypedArray)return isTypedArray$1;hasRequiredIsTypedArray=1;var t=requireWhichTypedArray();return isTypedArray$1=function(n){return!!t(n)},isTypedArray$1}var hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,function(t){var e=requireIsArguments(),n=requireIsGeneratorFunction(),a=requireWhichTypedArray(),c=requireIsTypedArray();function o(se){return se.call.bind(se)}var u=typeof BigInt<"u",h=typeof Symbol<"u",l=o(Object.prototype.toString),b=o(Number.prototype.valueOf),d=o(String.prototype.valueOf),p=o(Boolean.prototype.valueOf);if(u)var x=o(BigInt.prototype.valueOf);if(h)var m=o(Symbol.prototype.valueOf);function v(se,ge){if(typeof se!="object")return!1;try{return ge(se),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=c;function g(se){return typeof Promise<"u"&&se instanceof Promise||se!==null&&typeof se=="object"&&typeof se.then=="function"&&typeof se.catch=="function"}t.isPromise=g;function $(se){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(se):c(se)||j(se)}t.isArrayBufferView=$;function B(se){return a(se)==="Uint8Array"}t.isUint8Array=B;function C(se){return a(se)==="Uint8ClampedArray"}t.isUint8ClampedArray=C;function F(se){return a(se)==="Uint16Array"}t.isUint16Array=F;function H(se){return a(se)==="Uint32Array"}t.isUint32Array=H;function W(se){return a(se)==="Int8Array"}t.isInt8Array=W;function Z(se){return a(se)==="Int16Array"}t.isInt16Array=Z;function ie(se){return a(se)==="Int32Array"}t.isInt32Array=ie;function te(se){return a(se)==="Float32Array"}t.isFloat32Array=te;function ae(se){return a(se)==="Float64Array"}t.isFloat64Array=ae;function de(se){return a(se)==="BigInt64Array"}t.isBigInt64Array=de;function J(se){return a(se)==="BigUint64Array"}t.isBigUint64Array=J;function R(se){return l(se)==="[object Map]"}R.working=typeof Map<"u"&&R(new Map);function A(se){return typeof Map>"u"?!1:R.working?R(se):se instanceof Map}t.isMap=A;function y(se){return l(se)==="[object Set]"}y.working=typeof Set<"u"&&y(new Set);function w(se){return typeof Set>"u"?!1:y.working?y(se):se instanceof Set}t.isSet=w;function I(se){return l(se)==="[object WeakMap]"}I.working=typeof WeakMap<"u"&&I(new WeakMap);function M(se){return typeof WeakMap>"u"?!1:I.working?I(se):se instanceof WeakMap}t.isWeakMap=M;function k(se){return l(se)==="[object WeakSet]"}k.working=typeof WeakSet<"u"&&k(new WeakSet);function P(se){return k(se)}t.isWeakSet=P;function _(se){return l(se)==="[object ArrayBuffer]"}_.working=typeof ArrayBuffer<"u"&&_(new ArrayBuffer);function q(se){return typeof ArrayBuffer>"u"?!1:_.working?_(se):se instanceof ArrayBuffer}t.isArrayBuffer=q;function E(se){return l(se)==="[object DataView]"}E.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&E(new DataView(new ArrayBuffer(1),0,1));function j(se){return typeof DataView>"u"?!1:E.working?E(se):se instanceof DataView}t.isDataView=j;var ee=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function oe(se){return l(se)==="[object SharedArrayBuffer]"}function Y(se){return typeof ee>"u"?!1:(typeof oe.working>"u"&&(oe.working=oe(new ee)),oe.working?oe(se):se instanceof ee)}t.isSharedArrayBuffer=Y;function L(se){return l(se)==="[object AsyncFunction]"}t.isAsyncFunction=L;function z(se){return l(se)==="[object Map Iterator]"}t.isMapIterator=z;function re(se){return l(se)==="[object Set Iterator]"}t.isSetIterator=re;function D(se){return l(se)==="[object Generator]"}t.isGeneratorObject=D;function G(se){return l(se)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=G;function U(se){return v(se,b)}t.isNumberObject=U;function Q(se){return v(se,d)}t.isStringObject=Q;function fe(se){return v(se,p)}t.isBooleanObject=fe;function he(se){return u&&v(se,x)}t.isBigIntObject=he;function le(se){return h&&v(se,m)}t.isSymbolObject=le;function pe(se){return U(se)||Q(se)||fe(se)||he(se)||le(se)}t.isBoxedPrimitive=pe;function be(se){return typeof Uint8Array<"u"&&(q(se)||Y(se))}t.isAnyArrayBuffer=be,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(se){Object.defineProperty(t,se,{enumerable:!1,value:function(){throw new Error(se+" is not supported in userland")}})})}(types)),types}var isBufferBrowser,hasRequiredIsBufferBrowser;function requireIsBufferBrowser(){return hasRequiredIsBufferBrowser||(hasRequiredIsBufferBrowser=1,isBufferBrowser=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),isBufferBrowser}var hasRequiredUtil$1;function requireUtil$1(){return hasRequiredUtil$1||(hasRequiredUtil$1=1,function(t){var e=Object.getOwnPropertyDescriptors||function(j){for(var ee=Object.keys(j),oe={},Y=0;Y<ee.length;Y++)oe[ee[Y]]=Object.getOwnPropertyDescriptor(j,ee[Y]);return oe},n=/%[sdj%]/g;t.format=function(E){if(!W(E)){for(var j=[],ee=0;ee<arguments.length;ee++)j.push(u(arguments[ee]));return j.join(" ")}for(var ee=1,oe=arguments,Y=oe.length,L=String(E).replace(n,function(re){if(re==="%%")return"%";if(ee>=Y)return re;switch(re){case"%s":return String(oe[ee++]);case"%d":return Number(oe[ee++]);case"%j":try{return JSON.stringify(oe[ee++])}catch{return"[Circular]"}default:return re}}),z=oe[ee];ee<Y;z=oe[++ee])C(z)||!ae(z)?L+=" "+z:L+=" "+u(z);return L},t.deprecate=function(E,j){if(typeof process$1<"u"&&process$1.noDeprecation===!0)return E;if(typeof process$1>"u")return function(){return t.deprecate(E,j).apply(this,arguments)};var ee=!1;function oe(){if(!ee){if(process$1.throwDeprecation)throw new Error(j);process$1.traceDeprecation?console.trace(j):console.error(j),ee=!0}return E.apply(this,arguments)}return oe};var a={},c=/^$/;if(process$1.env.NODE_DEBUG){var o=process$1.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+o+"$","i")}t.debuglog=function(E){if(E=E.toUpperCase(),!a[E])if(c.test(E)){var j=process$1.pid;a[E]=function(){var ee=t.format.apply(t,arguments);console.error("%s %d: %s",E,j,ee)}}else a[E]=function(){};return a[E]};function u(E,j){var ee={seen:[],stylize:l};return arguments.length>=3&&(ee.depth=arguments[2]),arguments.length>=4&&(ee.colors=arguments[3]),B(j)?ee.showHidden=j:j&&t._extend(ee,j),ie(ee.showHidden)&&(ee.showHidden=!1),ie(ee.depth)&&(ee.depth=2),ie(ee.colors)&&(ee.colors=!1),ie(ee.customInspect)&&(ee.customInspect=!0),ee.colors&&(ee.stylize=h),d(ee,E,ee.depth)}t.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function h(E,j){var ee=u.styles[j];return ee?"\x1B["+u.colors[ee][0]+"m"+E+"\x1B["+u.colors[ee][1]+"m":E}function l(E,j){return E}function b(E){var j={};return E.forEach(function(ee,oe){j[ee]=!0}),j}function d(E,j,ee){if(E.customInspect&&j&&R(j.inspect)&&j.inspect!==t.inspect&&!(j.constructor&&j.constructor.prototype===j)){var oe=j.inspect(ee,E);return W(oe)||(oe=d(E,oe,ee)),oe}var Y=p(E,j);if(Y)return Y;var L=Object.keys(j),z=b(L);if(E.showHidden&&(L=Object.getOwnPropertyNames(j)),J(j)&&(L.indexOf("message")>=0||L.indexOf("description")>=0))return x(j);if(L.length===0){if(R(j)){var re=j.name?": "+j.name:"";return E.stylize("[Function"+re+"]","special")}if(te(j))return E.stylize(RegExp.prototype.toString.call(j),"regexp");if(de(j))return E.stylize(Date.prototype.toString.call(j),"date");if(J(j))return x(j)}var D="",G=!1,U=["{","}"];if($(j)&&(G=!0,U=["[","]"]),R(j)){var Q=j.name?": "+j.name:"";D=" [Function"+Q+"]"}if(te(j)&&(D=" "+RegExp.prototype.toString.call(j)),de(j)&&(D=" "+Date.prototype.toUTCString.call(j)),J(j)&&(D=" "+x(j)),L.length===0&&(!G||j.length==0))return U[0]+D+U[1];if(ee<0)return te(j)?E.stylize(RegExp.prototype.toString.call(j),"regexp"):E.stylize("[Object]","special");E.seen.push(j);var fe;return G?fe=m(E,j,ee,z,L):fe=L.map(function(he){return v(E,j,ee,z,he,G)}),E.seen.pop(),g(fe,D,U)}function p(E,j){if(ie(j))return E.stylize("undefined","undefined");if(W(j)){var ee="'"+JSON.stringify(j).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return E.stylize(ee,"string")}if(H(j))return E.stylize(""+j,"number");if(B(j))return E.stylize(""+j,"boolean");if(C(j))return E.stylize("null","null")}function x(E){return"["+Error.prototype.toString.call(E)+"]"}function m(E,j,ee,oe,Y){for(var L=[],z=0,re=j.length;z<re;++z)k(j,String(z))?L.push(v(E,j,ee,oe,String(z),!0)):L.push("");return Y.forEach(function(D){D.match(/^\d+$/)||L.push(v(E,j,ee,oe,D,!0))}),L}function v(E,j,ee,oe,Y,L){var z,re,D;if(D=Object.getOwnPropertyDescriptor(j,Y)||{value:j[Y]},D.get?D.set?re=E.stylize("[Getter/Setter]","special"):re=E.stylize("[Getter]","special"):D.set&&(re=E.stylize("[Setter]","special")),k(oe,Y)||(z="["+Y+"]"),re||(E.seen.indexOf(D.value)<0?(C(ee)?re=d(E,D.value,null):re=d(E,D.value,ee-1),re.indexOf(`
11
- `)>-1&&(L?re=re.split(`
12
- `).map(function(G){return" "+G}).join(`
13
- `).slice(2):re=`
14
- `+re.split(`
15
- `).map(function(G){return" "+G}).join(`
16
- `))):re=E.stylize("[Circular]","special")),ie(z)){if(L&&Y.match(/^\d+$/))return re;z=JSON.stringify(""+Y),z.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(z=z.slice(1,-1),z=E.stylize(z,"name")):(z=z.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),z=E.stylize(z,"string"))}return z+": "+re}function g(E,j,ee){var oe=E.reduce(function(Y,L){return L.indexOf(`
17
- `)>=0,Y+L.replace(/\u001b\[\d\d?m/g,"").length+1},0);return oe>60?ee[0]+(j===""?"":j+`
18
- `)+" "+E.join(`,
19
- `)+" "+ee[1]:ee[0]+j+" "+E.join(", ")+" "+ee[1]}t.types=requireTypes();function $(E){return Array.isArray(E)}t.isArray=$;function B(E){return typeof E=="boolean"}t.isBoolean=B;function C(E){return E===null}t.isNull=C;function F(E){return E==null}t.isNullOrUndefined=F;function H(E){return typeof E=="number"}t.isNumber=H;function W(E){return typeof E=="string"}t.isString=W;function Z(E){return typeof E=="symbol"}t.isSymbol=Z;function ie(E){return E===void 0}t.isUndefined=ie;function te(E){return ae(E)&&y(E)==="[object RegExp]"}t.isRegExp=te,t.types.isRegExp=te;function ae(E){return typeof E=="object"&&E!==null}t.isObject=ae;function de(E){return ae(E)&&y(E)==="[object Date]"}t.isDate=de,t.types.isDate=de;function J(E){return ae(E)&&(y(E)==="[object Error]"||E instanceof Error)}t.isError=J,t.types.isNativeError=J;function R(E){return typeof E=="function"}t.isFunction=R;function A(E){return E===null||typeof E=="boolean"||typeof E=="number"||typeof E=="string"||typeof E=="symbol"||typeof E>"u"}t.isPrimitive=A,t.isBuffer=requireIsBufferBrowser();function y(E){return Object.prototype.toString.call(E)}function w(E){return E<10?"0"+E.toString(10):E.toString(10)}var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(){var E=new Date,j=[w(E.getHours()),w(E.getMinutes()),w(E.getSeconds())].join(":");return[E.getDate(),I[E.getMonth()],j].join(" ")}t.log=function(){console.log("%s - %s",M(),t.format.apply(t,arguments))},t.inherits=inherits_browserExports,t._extend=function(E,j){if(!j||!ae(j))return E;for(var ee=Object.keys(j),oe=ee.length;oe--;)E[ee[oe]]=j[ee[oe]];return E};function k(E,j){return Object.prototype.hasOwnProperty.call(E,j)}var P=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(P&&j[P]){var ee=j[P];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,P,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var oe,Y,L=new Promise(function(D,G){oe=D,Y=G}),z=[],re=0;re<arguments.length;re++)z.push(arguments[re]);z.push(function(D,G){D?Y(D):oe(G)});try{j.apply(this,z)}catch(D){Y(D)}return L}return Object.setPrototypeOf(ee,Object.getPrototypeOf(j)),P&&Object.defineProperty(ee,P,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,e(j))},t.promisify.custom=P;function _(E,j){if(!E){var ee=new Error("Promise was rejected with a falsy value");ee.reason=E,E=ee}return j(E)}function q(E){if(typeof E!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var ee=[],oe=0;oe<arguments.length;oe++)ee.push(arguments[oe]);var Y=ee.pop();if(typeof Y!="function")throw new TypeError("The last argument must be of type Function");var L=this,z=function(){return Y.apply(L,arguments)};E.apply(this,ee).then(function(re){process$1.nextTick(z.bind(null,null,re))},function(re){process$1.nextTick(_.bind(null,re,z))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(E)),Object.defineProperties(j,e(E)),j}t.callbackify=q}(util$1)),util$1}var buffer_list,hasRequiredBuffer_list;function requireBuffer_list(){if(hasRequiredBuffer_list)return buffer_list;hasRequiredBuffer_list=1;function t(v,g){var $=Object.keys(v);if(Object.getOwnPropertySymbols){var B=Object.getOwnPropertySymbols(v);g&&(B=B.filter(function(C){return Object.getOwnPropertyDescriptor(v,C).enumerable})),$.push.apply($,B)}return $}function e(v){for(var g=1;g<arguments.length;g++){var $=arguments[g]!=null?arguments[g]:{};g%2?t(Object($),!0).forEach(function(B){n(v,B,$[B])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors($)):t(Object($)).forEach(function(B){Object.defineProperty(v,B,Object.getOwnPropertyDescriptor($,B))})}return v}function n(v,g,$){return g=u(g),g in v?Object.defineProperty(v,g,{value:$,enumerable:!0,configurable:!0,writable:!0}):v[g]=$,v}function a(v,g){if(!(v instanceof g))throw new TypeError("Cannot call a class as a function")}function c(v,g){for(var $=0;$<g.length;$++){var B=g[$];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(v,u(B.key),B)}}function o(v,g,$){return g&&c(v.prototype,g),Object.defineProperty(v,"prototype",{writable:!1}),v}function u(v){var g=h(v,"string");return typeof g=="symbol"?g:String(g)}function h(v,g){if(typeof v!="object"||v===null)return v;var $=v[Symbol.toPrimitive];if($!==void 0){var B=$.call(v,g||"default");if(typeof B!="object")return B;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(v)}var l=require$$1$2,b=l.Buffer,d=requireUtil$1(),p=d.inspect,x=p&&p.custom||"inspect";function m(v,g,$){b.prototype.copy.call(v,g,$)}return buffer_list=function(){function v(){a(this,v),this.head=null,this.tail=null,this.length=0}return o(v,[{key:"push",value:function($){var B={data:$,next:null};this.length>0?this.tail.next=B:this.head=B,this.tail=B,++this.length}},{key:"unshift",value:function($){var B={data:$,next:this.head};this.length===0&&(this.tail=B),this.head=B,++this.length}},{key:"shift",value:function(){if(this.length!==0){var $=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,$}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function($){if(this.length===0)return"";for(var B=this.head,C=""+B.data;B=B.next;)C+=$+B.data;return C}},{key:"concat",value:function($){if(this.length===0)return b.alloc(0);for(var B=b.allocUnsafe($>>>0),C=this.head,F=0;C;)m(C.data,B,F),F+=C.data.length,C=C.next;return B}},{key:"consume",value:function($,B){var C;return $<this.head.data.length?(C=this.head.data.slice(0,$),this.head.data=this.head.data.slice($)):$===this.head.data.length?C=this.shift():C=B?this._getString($):this._getBuffer($),C}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function($){var B=this.head,C=1,F=B.data;for($-=F.length;B=B.next;){var H=B.data,W=$>H.length?H.length:$;if(W===H.length?F+=H:F+=H.slice(0,$),$-=W,$===0){W===H.length?(++C,B.next?this.head=B.next:this.head=this.tail=null):(this.head=B,B.data=H.slice(W));break}++C}return this.length-=C,F}},{key:"_getBuffer",value:function($){var B=b.allocUnsafe($),C=this.head,F=1;for(C.data.copy(B),$-=C.data.length;C=C.next;){var H=C.data,W=$>H.length?H.length:$;if(H.copy(B,B.length-$,0,W),$-=W,$===0){W===H.length?(++F,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=H.slice(W));break}++F}return this.length-=F,B}},{key:x,value:function($,B){return p(this,e(e({},B),{},{depth:0,customInspect:!1}))}}]),v}(),buffer_list}var destroy_1$1,hasRequiredDestroy$1;function requireDestroy$1(){if(hasRequiredDestroy$1)return destroy_1$1;hasRequiredDestroy$1=1;function t(u,h){var l=this,b=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return b||d?(h?h(u):u&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process$1.nextTick(c,this,u)):process$1.nextTick(c,this,u)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(u||null,function(p){!h&&p?l._writableState?l._writableState.errorEmitted?process$1.nextTick(n,l):(l._writableState.errorEmitted=!0,process$1.nextTick(e,l,p)):process$1.nextTick(e,l,p):h?(process$1.nextTick(n,l),h(p)):process$1.nextTick(n,l)}),this)}function e(u,h){c(u,h),n(u)}function n(u){u._writableState&&!u._writableState.emitClose||u._readableState&&!u._readableState.emitClose||u.emit("close")}function a(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(u,h){u.emit("error",h)}function o(u,h){var l=u._readableState,b=u._writableState;l&&l.autoDestroy||b&&b.autoDestroy?u.destroy(h):u.emit("error",h)}return destroy_1$1={destroy:t,undestroy:a,errorOrDestroy:o},destroy_1$1}var errorsBrowser={},hasRequiredErrorsBrowser;function requireErrorsBrowser(){if(hasRequiredErrorsBrowser)return errorsBrowser;hasRequiredErrorsBrowser=1;function t(h,l){h.prototype=Object.create(l.prototype),h.prototype.constructor=h,h.__proto__=l}var e={};function n(h,l,b){b||(b=Error);function d(x,m,v){return typeof l=="string"?l:l(x,m,v)}var p=function(x){t(m,x);function m(v,g,$){return x.call(this,d(v,g,$))||this}return m}(b);p.prototype.name=b.name,p.prototype.code=h,e[h]=p}function a(h,l){if(Array.isArray(h)){var b=h.length;return h=h.map(function(d){return String(d)}),b>2?"one of ".concat(l," ").concat(h.slice(0,b-1).join(", "),", or ")+h[b-1]:b===2?"one of ".concat(l," ").concat(h[0]," or ").concat(h[1]):"of ".concat(l," ").concat(h[0])}else return"of ".concat(l," ").concat(String(h))}function c(h,l,b){return h.substr(0,l.length)===l}function o(h,l,b){return(b===void 0||b>h.length)&&(b=h.length),h.substring(b-l.length,b)===l}function u(h,l,b){return typeof b!="number"&&(b=0),b+l.length>h.length?!1:h.indexOf(l,b)!==-1}return n("ERR_INVALID_OPT_VALUE",function(h,l){return'The value "'+l+'" is invalid for option "'+h+'"'},TypeError),n("ERR_INVALID_ARG_TYPE",function(h,l,b){var d;typeof l=="string"&&c(l,"not ")?(d="must not be",l=l.replace(/^not /,"")):d="must be";var p;if(o(h," argument"))p="The ".concat(h," ").concat(d," ").concat(a(l,"type"));else{var x=u(h,".")?"property":"argument";p='The "'.concat(h,'" ').concat(x," ").concat(d," ").concat(a(l,"type"))}return p+=". Received type ".concat(typeof b),p},TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",function(h){return"The "+h+" method is not implemented"}),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",function(h){return"Cannot call "+h+" after a stream was destroyed"}),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",function(h){return"Unknown encoding: "+h},TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),errorsBrowser.codes=e,errorsBrowser}var state,hasRequiredState;function requireState(){if(hasRequiredState)return state;hasRequiredState=1;var t=requireErrorsBrowser().codes.ERR_INVALID_OPT_VALUE;function e(a,c,o){return a.highWaterMark!=null?a.highWaterMark:c?a[o]:null}function n(a,c,o,u){var h=e(c,u,o);if(h!=null){if(!(isFinite(h)&&Math.floor(h)===h)||h<0){var l=u?o:"highWaterMark";throw new t(l,h)}return Math.floor(h)}return a.objectMode?16:16*1024}return state={getHighWaterMark:n},state}var browser$a,hasRequiredBrowser$a;function requireBrowser$a(){if(hasRequiredBrowser$a)return browser$a;hasRequiredBrowser$a=1,browser$a=t;function t(n,a){if(e("noDeprecation"))return n;var c=!1;function o(){if(!c){if(e("throwDeprecation"))throw new Error(a);e("traceDeprecation")?console.trace(a):console.warn(a),c=!0}return n.apply(this,arguments)}return o}function e(n){try{if(!commonjsGlobal.localStorage)return!1}catch{return!1}var a=commonjsGlobal.localStorage[n];return a==null?!1:String(a).toLowerCase()==="true"}return browser$a}var _stream_writable$1,hasRequired_stream_writable$1;function require_stream_writable$1(){if(hasRequired_stream_writable$1)return _stream_writable$1;hasRequired_stream_writable$1=1,_stream_writable$1=te;function t(Y){var L=this;this.next=null,this.entry=null,this.finish=function(){oe(L,Y)}}var e;te.WritableState=Z;var n={deprecate:requireBrowser$a()},a=requireStreamBrowser$1(),c=require$$1$2.Buffer,o=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u(Y){return c.from(Y)}function h(Y){return c.isBuffer(Y)||Y instanceof o}var l=requireDestroy$1(),b=requireState(),d=b.getHighWaterMark,p=requireErrorsBrowser().codes,x=p.ERR_INVALID_ARG_TYPE,m=p.ERR_METHOD_NOT_IMPLEMENTED,v=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,$=p.ERR_STREAM_DESTROYED,B=p.ERR_STREAM_NULL_VALUES,C=p.ERR_STREAM_WRITE_AFTER_END,F=p.ERR_UNKNOWN_ENCODING,H=l.errorOrDestroy;inherits_browserExports(te,a);function W(){}function Z(Y,L,z){e=e||require_stream_duplex$1(),Y=Y||{},typeof z!="boolean"&&(z=L instanceof e),this.objectMode=!!Y.objectMode,z&&(this.objectMode=this.objectMode||!!Y.writableObjectMode),this.highWaterMark=d(this,Y,"writableHighWaterMark",z),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var re=Y.decodeStrings===!1;this.decodeStrings=!re,this.defaultEncoding=Y.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(D){I(L,D)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=Y.emitClose!==!1,this.autoDestroy=!!Y.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}Z.prototype.getBuffer=function(){for(var L=this.bufferedRequest,z=[];L;)z.push(L),L=L.next;return z},function(){try{Object.defineProperty(Z.prototype,"buffer",{get:n.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var ie;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(ie=Function.prototype[Symbol.hasInstance],Object.defineProperty(te,Symbol.hasInstance,{value:function(L){return ie.call(this,L)?!0:this!==te?!1:L&&L._writableState instanceof Z}})):ie=function(L){return L instanceof this};function te(Y){e=e||require_stream_duplex$1();var L=this instanceof e;if(!L&&!ie.call(te,this))return new te(Y);this._writableState=new Z(Y,this,L),this.writable=!0,Y&&(typeof Y.write=="function"&&(this._write=Y.write),typeof Y.writev=="function"&&(this._writev=Y.writev),typeof Y.destroy=="function"&&(this._destroy=Y.destroy),typeof Y.final=="function"&&(this._final=Y.final)),a.call(this)}te.prototype.pipe=function(){H(this,new g)};function ae(Y,L){var z=new C;H(Y,z),process$1.nextTick(L,z)}function de(Y,L,z,re){var D;return z===null?D=new B:typeof z!="string"&&!L.objectMode&&(D=new x("chunk",["string","Buffer"],z)),D?(H(Y,D),process$1.nextTick(re,D),!1):!0}te.prototype.write=function(Y,L,z){var re=this._writableState,D=!1,G=!re.objectMode&&h(Y);return G&&!c.isBuffer(Y)&&(Y=u(Y)),typeof L=="function"&&(z=L,L=null),G?L="buffer":L||(L=re.defaultEncoding),typeof z!="function"&&(z=W),re.ending?ae(this,z):(G||de(this,re,Y,z))&&(re.pendingcb++,D=R(this,re,G,Y,L,z)),D},te.prototype.cork=function(){this._writableState.corked++},te.prototype.uncork=function(){var Y=this._writableState;Y.corked&&(Y.corked--,!Y.writing&&!Y.corked&&!Y.bufferProcessing&&Y.bufferedRequest&&P(this,Y))},te.prototype.setDefaultEncoding=function(L){if(typeof L=="string"&&(L=L.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((L+"").toLowerCase())>-1))throw new F(L);return this._writableState.defaultEncoding=L,this},Object.defineProperty(te.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function J(Y,L,z){return!Y.objectMode&&Y.decodeStrings!==!1&&typeof L=="string"&&(L=c.from(L,z)),L}Object.defineProperty(te.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function R(Y,L,z,re,D,G){if(!z){var U=J(L,re,D);re!==U&&(z=!0,D="buffer",re=U)}var Q=L.objectMode?1:re.length;L.length+=Q;var fe=L.length<L.highWaterMark;if(fe||(L.needDrain=!0),L.writing||L.corked){var he=L.lastBufferedRequest;L.lastBufferedRequest={chunk:re,encoding:D,isBuf:z,callback:G,next:null},he?he.next=L.lastBufferedRequest:L.bufferedRequest=L.lastBufferedRequest,L.bufferedRequestCount+=1}else A(Y,L,!1,Q,re,D,G);return fe}function A(Y,L,z,re,D,G,U){L.writelen=re,L.writecb=U,L.writing=!0,L.sync=!0,L.destroyed?L.onwrite(new $("write")):z?Y._writev(D,L.onwrite):Y._write(D,G,L.onwrite),L.sync=!1}function y(Y,L,z,re,D){--L.pendingcb,z?(process$1.nextTick(D,re),process$1.nextTick(j,Y,L),Y._writableState.errorEmitted=!0,H(Y,re)):(D(re),Y._writableState.errorEmitted=!0,H(Y,re),j(Y,L))}function w(Y){Y.writing=!1,Y.writecb=null,Y.length-=Y.writelen,Y.writelen=0}function I(Y,L){var z=Y._writableState,re=z.sync,D=z.writecb;if(typeof D!="function")throw new v;if(w(z),L)y(Y,z,re,L,D);else{var G=_(z)||Y.destroyed;!G&&!z.corked&&!z.bufferProcessing&&z.bufferedRequest&&P(Y,z),re?process$1.nextTick(M,Y,z,G,D):M(Y,z,G,D)}}function M(Y,L,z,re){z||k(Y,L),L.pendingcb--,re(),j(Y,L)}function k(Y,L){L.length===0&&L.needDrain&&(L.needDrain=!1,Y.emit("drain"))}function P(Y,L){L.bufferProcessing=!0;var z=L.bufferedRequest;if(Y._writev&&z&&z.next){var re=L.bufferedRequestCount,D=new Array(re),G=L.corkedRequestsFree;G.entry=z;for(var U=0,Q=!0;z;)D[U]=z,z.isBuf||(Q=!1),z=z.next,U+=1;D.allBuffers=Q,A(Y,L,!0,L.length,D,"",G.finish),L.pendingcb++,L.lastBufferedRequest=null,G.next?(L.corkedRequestsFree=G.next,G.next=null):L.corkedRequestsFree=new t(L),L.bufferedRequestCount=0}else{for(;z;){var fe=z.chunk,he=z.encoding,le=z.callback,pe=L.objectMode?1:fe.length;if(A(Y,L,!1,pe,fe,he,le),z=z.next,L.bufferedRequestCount--,L.writing)break}z===null&&(L.lastBufferedRequest=null)}L.bufferedRequest=z,L.bufferProcessing=!1}te.prototype._write=function(Y,L,z){z(new m("_write()"))},te.prototype._writev=null,te.prototype.end=function(Y,L,z){var re=this._writableState;return typeof Y=="function"?(z=Y,Y=null,L=null):typeof L=="function"&&(z=L,L=null),Y!=null&&this.write(Y,L),re.corked&&(re.corked=1,this.uncork()),re.ending||ee(this,re,z),this},Object.defineProperty(te.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function _(Y){return Y.ending&&Y.length===0&&Y.bufferedRequest===null&&!Y.finished&&!Y.writing}function q(Y,L){Y._final(function(z){L.pendingcb--,z&&H(Y,z),L.prefinished=!0,Y.emit("prefinish"),j(Y,L)})}function E(Y,L){!L.prefinished&&!L.finalCalled&&(typeof Y._final=="function"&&!L.destroyed?(L.pendingcb++,L.finalCalled=!0,process$1.nextTick(q,Y,L)):(L.prefinished=!0,Y.emit("prefinish")))}function j(Y,L){var z=_(L);if(z&&(E(Y,L),L.pendingcb===0&&(L.finished=!0,Y.emit("finish"),L.autoDestroy))){var re=Y._readableState;(!re||re.autoDestroy&&re.endEmitted)&&Y.destroy()}return z}function ee(Y,L,z){L.ending=!0,j(Y,L),z&&(L.finished?process$1.nextTick(z):Y.once("finish",z)),L.ended=!0,Y.writable=!1}function oe(Y,L,z){var re=Y.entry;for(Y.entry=null;re;){var D=re.callback;L.pendingcb--,D(z),re=re.next}L.corkedRequestsFree.next=Y}return Object.defineProperty(te.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(L){this._writableState&&(this._writableState.destroyed=L)}}),te.prototype.destroy=l.destroy,te.prototype._undestroy=l.undestroy,te.prototype._destroy=function(Y,L){L(Y)},_stream_writable$1}var _stream_duplex$1,hasRequired_stream_duplex$1;function require_stream_duplex$1(){if(hasRequired_stream_duplex$1)return _stream_duplex$1;hasRequired_stream_duplex$1=1;var t=Object.keys||function(b){var d=[];for(var p in b)d.push(p);return d};_stream_duplex$1=u;var e=require_stream_readable$1(),n=require_stream_writable$1();inherits_browserExports(u,e);for(var a=t(n.prototype),c=0;c<a.length;c++){var o=a[c];u.prototype[o]||(u.prototype[o]=n.prototype[o])}function u(b){if(!(this instanceof u))return new u(b);e.call(this,b),n.call(this,b),this.allowHalfOpen=!0,b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",h)))}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function h(){this._writableState.ended||process$1.nextTick(l,this)}function l(b){b.end()}return Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),_stream_duplex$1}var string_decoder={},hasRequiredString_decoder;function requireString_decoder(){if(hasRequiredString_decoder)return string_decoder;hasRequiredString_decoder=1;var t=requireSafeBuffer$1().Buffer,e=t.isEncoding||function(B){switch(B=""+B,B&&B.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function n(B){if(!B)return"utf8";for(var C;;)switch(B){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return B;default:if(C)return;B=(""+B).toLowerCase(),C=!0}}function a(B){var C=n(B);if(typeof C!="string"&&(t.isEncoding===e||!e(B)))throw new Error("Unknown encoding: "+B);return C||B}string_decoder.StringDecoder=c;function c(B){this.encoding=a(B);var C;switch(this.encoding){case"utf16le":this.text=p,this.end=x,C=4;break;case"utf8":this.fillLast=l,C=4;break;case"base64":this.text=m,this.end=v,C=3;break;default:this.write=g,this.end=$;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(C)}c.prototype.write=function(B){if(B.length===0)return"";var C,F;if(this.lastNeed){if(C=this.fillLast(B),C===void 0)return"";F=this.lastNeed,this.lastNeed=0}else F=0;return F<B.length?C?C+this.text(B,F):this.text(B,F):C||""},c.prototype.end=d,c.prototype.text=b,c.prototype.fillLast=function(B){if(this.lastNeed<=B.length)return B.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);B.copy(this.lastChar,this.lastTotal-this.lastNeed,0,B.length),this.lastNeed-=B.length};function o(B){return B<=127?0:B>>5===6?2:B>>4===14?3:B>>3===30?4:B>>6===2?-1:-2}function u(B,C,F){var H=C.length-1;if(H<F)return 0;var W=o(C[H]);return W>=0?(W>0&&(B.lastNeed=W-1),W):--H<F||W===-2?0:(W=o(C[H]),W>=0?(W>0&&(B.lastNeed=W-2),W):--H<F||W===-2?0:(W=o(C[H]),W>=0?(W>0&&(W===2?W=0:B.lastNeed=W-3),W):0))}function h(B,C,F){if((C[0]&192)!==128)return B.lastNeed=0,"�";if(B.lastNeed>1&&C.length>1){if((C[1]&192)!==128)return B.lastNeed=1,"�";if(B.lastNeed>2&&C.length>2&&(C[2]&192)!==128)return B.lastNeed=2,"�"}}function l(B){var C=this.lastTotal-this.lastNeed,F=h(this,B);if(F!==void 0)return F;if(this.lastNeed<=B.length)return B.copy(this.lastChar,C,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);B.copy(this.lastChar,C,0,B.length),this.lastNeed-=B.length}function b(B,C){var F=u(this,B,C);if(!this.lastNeed)return B.toString("utf8",C);this.lastTotal=F;var H=B.length-(F-this.lastNeed);return B.copy(this.lastChar,0,H),B.toString("utf8",C,H)}function d(B){var C=B&&B.length?this.write(B):"";return this.lastNeed?C+"�":C}function p(B,C){if((B.length-C)%2===0){var F=B.toString("utf16le",C);if(F){var H=F.charCodeAt(F.length-1);if(H>=55296&&H<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=B[B.length-2],this.lastChar[1]=B[B.length-1],F.slice(0,-1)}return F}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=B[B.length-1],B.toString("utf16le",C,B.length-1)}function x(B){var C=B&&B.length?this.write(B):"";if(this.lastNeed){var F=this.lastTotal-this.lastNeed;return C+this.lastChar.toString("utf16le",0,F)}return C}function m(B,C){var F=(B.length-C)%3;return F===0?B.toString("base64",C):(this.lastNeed=3-F,this.lastTotal=3,F===1?this.lastChar[0]=B[B.length-1]:(this.lastChar[0]=B[B.length-2],this.lastChar[1]=B[B.length-1]),B.toString("base64",C,B.length-F))}function v(B){var C=B&&B.length?this.write(B):"";return this.lastNeed?C+this.lastChar.toString("base64",0,3-this.lastNeed):C}function g(B){return B.toString(this.encoding)}function $(B){return B&&B.length?this.write(B):""}return string_decoder}var endOfStream,hasRequiredEndOfStream;function requireEndOfStream(){if(hasRequiredEndOfStream)return endOfStream;hasRequiredEndOfStream=1;var t=requireErrorsBrowser().codes.ERR_STREAM_PREMATURE_CLOSE;function e(o){var u=!1;return function(){if(!u){u=!0;for(var h=arguments.length,l=new Array(h),b=0;b<h;b++)l[b]=arguments[b];o.apply(this,l)}}}function n(){}function a(o){return o.setHeader&&typeof o.abort=="function"}function c(o,u,h){if(typeof u=="function")return c(o,null,u);u||(u={}),h=e(h||n);var l=u.readable||u.readable!==!1&&o.readable,b=u.writable||u.writable!==!1&&o.writable,d=function(){o.writable||x()},p=o._writableState&&o._writableState.finished,x=function(){b=!1,p=!0,l||h.call(o)},m=o._readableState&&o._readableState.endEmitted,v=function(){l=!1,m=!0,b||h.call(o)},g=function(F){h.call(o,F)},$=function(){var F;if(l&&!m)return(!o._readableState||!o._readableState.ended)&&(F=new t),h.call(o,F);if(b&&!p)return(!o._writableState||!o._writableState.ended)&&(F=new t),h.call(o,F)},B=function(){o.req.on("finish",x)};return a(o)?(o.on("complete",x),o.on("abort",$),o.req?B():o.on("request",B)):b&&!o._writableState&&(o.on("end",d),o.on("close",d)),o.on("end",v),o.on("finish",x),u.error!==!1&&o.on("error",g),o.on("close",$),function(){o.removeListener("complete",x),o.removeListener("abort",$),o.removeListener("request",B),o.req&&o.req.removeListener("finish",x),o.removeListener("end",d),o.removeListener("close",d),o.removeListener("finish",x),o.removeListener("end",v),o.removeListener("error",g),o.removeListener("close",$)}}return endOfStream=c,endOfStream}var async_iterator,hasRequiredAsync_iterator;function requireAsync_iterator(){if(hasRequiredAsync_iterator)return async_iterator;hasRequiredAsync_iterator=1;var t;function e(F,H,W){return H=n(H),H in F?Object.defineProperty(F,H,{value:W,enumerable:!0,configurable:!0,writable:!0}):F[H]=W,F}function n(F){var H=a(F,"string");return typeof H=="symbol"?H:String(H)}function a(F,H){if(typeof F!="object"||F===null)return F;var W=F[Symbol.toPrimitive];if(W!==void 0){var Z=W.call(F,H||"default");if(typeof Z!="object")return Z;throw new TypeError("@@toPrimitive must return a primitive value.")}return(H==="string"?String:Number)(F)}var c=requireEndOfStream(),o=Symbol("lastResolve"),u=Symbol("lastReject"),h=Symbol("error"),l=Symbol("ended"),b=Symbol("lastPromise"),d=Symbol("handlePromise"),p=Symbol("stream");function x(F,H){return{value:F,done:H}}function m(F){var H=F[o];if(H!==null){var W=F[p].read();W!==null&&(F[b]=null,F[o]=null,F[u]=null,H(x(W,!1)))}}function v(F){process$1.nextTick(m,F)}function g(F,H){return function(W,Z){F.then(function(){if(H[l]){W(x(void 0,!0));return}H[d](W,Z)},Z)}}var $=Object.getPrototypeOf(function(){}),B=Object.setPrototypeOf((t={get stream(){return this[p]},next:function(){var H=this,W=this[h];if(W!==null)return Promise.reject(W);if(this[l])return Promise.resolve(x(void 0,!0));if(this[p].destroyed)return new Promise(function(ae,de){process$1.nextTick(function(){H[h]?de(H[h]):ae(x(void 0,!0))})});var Z=this[b],ie;if(Z)ie=new Promise(g(Z,this));else{var te=this[p].read();if(te!==null)return Promise.resolve(x(te,!1));ie=new Promise(this[d])}return this[b]=ie,ie}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var H=this;return new Promise(function(W,Z){H[p].destroy(null,function(ie){if(ie){Z(ie);return}W(x(void 0,!0))})})}),t),$),C=function(H){var W,Z=Object.create(B,(W={},e(W,p,{value:H,writable:!0}),e(W,o,{value:null,writable:!0}),e(W,u,{value:null,writable:!0}),e(W,h,{value:null,writable:!0}),e(W,l,{value:H._readableState.endEmitted,writable:!0}),e(W,d,{value:function(te,ae){var de=Z[p].read();de?(Z[b]=null,Z[o]=null,Z[u]=null,te(x(de,!1))):(Z[o]=te,Z[u]=ae)},writable:!0}),W));return Z[b]=null,c(H,function(ie){if(ie&&ie.code!=="ERR_STREAM_PREMATURE_CLOSE"){var te=Z[u];te!==null&&(Z[b]=null,Z[o]=null,Z[u]=null,te(ie)),Z[h]=ie;return}var ae=Z[o];ae!==null&&(Z[b]=null,Z[o]=null,Z[u]=null,ae(x(void 0,!0))),Z[l]=!0}),H.on("readable",v.bind(null,Z)),Z};return async_iterator=C,async_iterator}var fromBrowser,hasRequiredFromBrowser;function requireFromBrowser(){return hasRequiredFromBrowser||(hasRequiredFromBrowser=1,fromBrowser=function(){throw new Error("Readable.from is not available in the browser")}),fromBrowser}var _stream_readable$1,hasRequired_stream_readable$1;function require_stream_readable$1(){if(hasRequired_stream_readable$1)return _stream_readable$1;hasRequired_stream_readable$1=1,_stream_readable$1=ae;var t;ae.ReadableState=te,requireEvents().EventEmitter;var e=function(U,Q){return U.listeners(Q).length},n=requireStreamBrowser$1(),a=require$$1$2.Buffer,c=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(G){return a.from(G)}function u(G){return a.isBuffer(G)||G instanceof c}var h=requireUtil$1(),l;h&&h.debuglog?l=h.debuglog("stream"):l=function(){};var b=requireBuffer_list(),d=requireDestroy$1(),p=requireState(),x=p.getHighWaterMark,m=requireErrorsBrowser().codes,v=m.ERR_INVALID_ARG_TYPE,g=m.ERR_STREAM_PUSH_AFTER_EOF,$=m.ERR_METHOD_NOT_IMPLEMENTED,B=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,C,F,H;inherits_browserExports(ae,n);var W=d.errorOrDestroy,Z=["error","close","destroy","pause","resume"];function ie(G,U,Q){if(typeof G.prependListener=="function")return G.prependListener(U,Q);!G._events||!G._events[U]?G.on(U,Q):Array.isArray(G._events[U])?G._events[U].unshift(Q):G._events[U]=[Q,G._events[U]]}function te(G,U,Q){t=t||require_stream_duplex$1(),G=G||{},typeof Q!="boolean"&&(Q=U instanceof t),this.objectMode=!!G.objectMode,Q&&(this.objectMode=this.objectMode||!!G.readableObjectMode),this.highWaterMark=x(this,G,"readableHighWaterMark",Q),this.buffer=new b,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=G.emitClose!==!1,this.autoDestroy=!!G.autoDestroy,this.destroyed=!1,this.defaultEncoding=G.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,G.encoding&&(C||(C=requireString_decoder().StringDecoder),this.decoder=new C(G.encoding),this.encoding=G.encoding)}function ae(G){if(t=t||require_stream_duplex$1(),!(this instanceof ae))return new ae(G);var U=this instanceof t;this._readableState=new te(G,this,U),this.readable=!0,G&&(typeof G.read=="function"&&(this._read=G.read),typeof G.destroy=="function"&&(this._destroy=G.destroy)),n.call(this)}Object.defineProperty(ae.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(U){this._readableState&&(this._readableState.destroyed=U)}}),ae.prototype.destroy=d.destroy,ae.prototype._undestroy=d.undestroy,ae.prototype._destroy=function(G,U){U(G)},ae.prototype.push=function(G,U){var Q=this._readableState,fe;return Q.objectMode?fe=!0:typeof G=="string"&&(U=U||Q.defaultEncoding,U!==Q.encoding&&(G=a.from(G,U),U=""),fe=!0),de(this,G,U,!1,fe)},ae.prototype.unshift=function(G){return de(this,G,null,!0,!1)};function de(G,U,Q,fe,he){l("readableAddChunk",U);var le=G._readableState;if(U===null)le.reading=!1,I(G,le);else{var pe;if(he||(pe=R(le,U)),pe)W(G,pe);else if(le.objectMode||U&&U.length>0)if(typeof U!="string"&&!le.objectMode&&Object.getPrototypeOf(U)!==a.prototype&&(U=o(U)),fe)le.endEmitted?W(G,new B):J(G,le,U,!0);else if(le.ended)W(G,new g);else{if(le.destroyed)return!1;le.reading=!1,le.decoder&&!Q?(U=le.decoder.write(U),le.objectMode||U.length!==0?J(G,le,U,!1):P(G,le)):J(G,le,U,!1)}else fe||(le.reading=!1,P(G,le))}return!le.ended&&(le.length<le.highWaterMark||le.length===0)}function J(G,U,Q,fe){U.flowing&&U.length===0&&!U.sync?(U.awaitDrain=0,G.emit("data",Q)):(U.length+=U.objectMode?1:Q.length,fe?U.buffer.unshift(Q):U.buffer.push(Q),U.needReadable&&M(G)),P(G,U)}function R(G,U){var Q;return!u(U)&&typeof U!="string"&&U!==void 0&&!G.objectMode&&(Q=new v("chunk",["string","Buffer","Uint8Array"],U)),Q}ae.prototype.isPaused=function(){return this._readableState.flowing===!1},ae.prototype.setEncoding=function(G){C||(C=requireString_decoder().StringDecoder);var U=new C(G);this._readableState.decoder=U,this._readableState.encoding=this._readableState.decoder.encoding;for(var Q=this._readableState.buffer.head,fe="";Q!==null;)fe+=U.write(Q.data),Q=Q.next;return this._readableState.buffer.clear(),fe!==""&&this._readableState.buffer.push(fe),this._readableState.length=fe.length,this};var A=1073741824;function y(G){return G>=A?G=A:(G--,G|=G>>>1,G|=G>>>2,G|=G>>>4,G|=G>>>8,G|=G>>>16,G++),G}function w(G,U){return G<=0||U.length===0&&U.ended?0:U.objectMode?1:G!==G?U.flowing&&U.length?U.buffer.head.data.length:U.length:(G>U.highWaterMark&&(U.highWaterMark=y(G)),G<=U.length?G:U.ended?U.length:(U.needReadable=!0,0))}ae.prototype.read=function(G){l("read",G),G=parseInt(G,10);var U=this._readableState,Q=G;if(G!==0&&(U.emittedReadable=!1),G===0&&U.needReadable&&((U.highWaterMark!==0?U.length>=U.highWaterMark:U.length>0)||U.ended))return l("read: emitReadable",U.length,U.ended),U.length===0&&U.ended?z(this):M(this),null;if(G=w(G,U),G===0&&U.ended)return U.length===0&&z(this),null;var fe=U.needReadable;l("need readable",fe),(U.length===0||U.length-G<U.highWaterMark)&&(fe=!0,l("length less than watermark",fe)),U.ended||U.reading?(fe=!1,l("reading or ended",fe)):fe&&(l("do read"),U.reading=!0,U.sync=!0,U.length===0&&(U.needReadable=!0),this._read(U.highWaterMark),U.sync=!1,U.reading||(G=w(Q,U)));var he;return G>0?he=L(G,U):he=null,he===null?(U.needReadable=U.length<=U.highWaterMark,G=0):(U.length-=G,U.awaitDrain=0),U.length===0&&(U.ended||(U.needReadable=!0),Q!==G&&U.ended&&z(this)),he!==null&&this.emit("data",he),he};function I(G,U){if(l("onEofChunk"),!U.ended){if(U.decoder){var Q=U.decoder.end();Q&&Q.length&&(U.buffer.push(Q),U.length+=U.objectMode?1:Q.length)}U.ended=!0,U.sync?M(G):(U.needReadable=!1,U.emittedReadable||(U.emittedReadable=!0,k(G)))}}function M(G){var U=G._readableState;l("emitReadable",U.needReadable,U.emittedReadable),U.needReadable=!1,U.emittedReadable||(l("emitReadable",U.flowing),U.emittedReadable=!0,process$1.nextTick(k,G))}function k(G){var U=G._readableState;l("emitReadable_",U.destroyed,U.length,U.ended),!U.destroyed&&(U.length||U.ended)&&(G.emit("readable"),U.emittedReadable=!1),U.needReadable=!U.flowing&&!U.ended&&U.length<=U.highWaterMark,Y(G)}function P(G,U){U.readingMore||(U.readingMore=!0,process$1.nextTick(_,G,U))}function _(G,U){for(;!U.reading&&!U.ended&&(U.length<U.highWaterMark||U.flowing&&U.length===0);){var Q=U.length;if(l("maybeReadMore read 0"),G.read(0),Q===U.length)break}U.readingMore=!1}ae.prototype._read=function(G){W(this,new $("_read()"))},ae.prototype.pipe=function(G,U){var Q=this,fe=this._readableState;switch(fe.pipesCount){case 0:fe.pipes=G;break;case 1:fe.pipes=[fe.pipes,G];break;default:fe.pipes.push(G);break}fe.pipesCount+=1,l("pipe count=%d opts=%j",fe.pipesCount,U);var he=(!U||U.end!==!1)&&G!==process$1.stdout&&G!==process$1.stderr,le=he?be:De;fe.endEmitted?process$1.nextTick(le):Q.once("end",le),G.on("unpipe",pe);function pe(Se,Oe){l("onunpipe"),Se===Q&&Oe&&Oe.hasUnpiped===!1&&(Oe.hasUnpiped=!0,ye())}function be(){l("onend"),G.end()}var se=q(Q);G.on("drain",se);var ge=!1;function ye(){l("cleanup"),G.removeListener("close",ve),G.removeListener("finish",Be),G.removeListener("drain",se),G.removeListener("error",Ne),G.removeListener("unpipe",pe),Q.removeListener("end",be),Q.removeListener("end",De),Q.removeListener("data",$e),ge=!0,fe.awaitDrain&&(!G._writableState||G._writableState.needDrain)&&se()}Q.on("data",$e);function $e(Se){l("ondata");var Oe=G.write(Se);l("dest.write",Oe),Oe===!1&&((fe.pipesCount===1&&fe.pipes===G||fe.pipesCount>1&&D(fe.pipes,G)!==-1)&&!ge&&(l("false write response, pause",fe.awaitDrain),fe.awaitDrain++),Q.pause())}function Ne(Se){l("onerror",Se),De(),G.removeListener("error",Ne),e(G,"error")===0&&W(G,Se)}ie(G,"error",Ne);function ve(){G.removeListener("finish",Be),De()}G.once("close",ve);function Be(){l("onfinish"),G.removeListener("close",ve),De()}G.once("finish",Be);function De(){l("unpipe"),Q.unpipe(G)}return G.emit("pipe",Q),fe.flowing||(l("pipe resume"),Q.resume()),G};function q(G){return function(){var Q=G._readableState;l("pipeOnDrain",Q.awaitDrain),Q.awaitDrain&&Q.awaitDrain--,Q.awaitDrain===0&&e(G,"data")&&(Q.flowing=!0,Y(G))}}ae.prototype.unpipe=function(G){var U=this._readableState,Q={hasUnpiped:!1};if(U.pipesCount===0)return this;if(U.pipesCount===1)return G&&G!==U.pipes?this:(G||(G=U.pipes),U.pipes=null,U.pipesCount=0,U.flowing=!1,G&&G.emit("unpipe",this,Q),this);if(!G){var fe=U.pipes,he=U.pipesCount;U.pipes=null,U.pipesCount=0,U.flowing=!1;for(var le=0;le<he;le++)fe[le].emit("unpipe",this,{hasUnpiped:!1});return this}var pe=D(U.pipes,G);return pe===-1?this:(U.pipes.splice(pe,1),U.pipesCount-=1,U.pipesCount===1&&(U.pipes=U.pipes[0]),G.emit("unpipe",this,Q),this)},ae.prototype.on=function(G,U){var Q=n.prototype.on.call(this,G,U),fe=this._readableState;return G==="data"?(fe.readableListening=this.listenerCount("readable")>0,fe.flowing!==!1&&this.resume()):G==="readable"&&!fe.endEmitted&&!fe.readableListening&&(fe.readableListening=fe.needReadable=!0,fe.flowing=!1,fe.emittedReadable=!1,l("on readable",fe.length,fe.reading),fe.length?M(this):fe.reading||process$1.nextTick(j,this)),Q},ae.prototype.addListener=ae.prototype.on,ae.prototype.removeListener=function(G,U){var Q=n.prototype.removeListener.call(this,G,U);return G==="readable"&&process$1.nextTick(E,this),Q},ae.prototype.removeAllListeners=function(G){var U=n.prototype.removeAllListeners.apply(this,arguments);return(G==="readable"||G===void 0)&&process$1.nextTick(E,this),U};function E(G){var U=G._readableState;U.readableListening=G.listenerCount("readable")>0,U.resumeScheduled&&!U.paused?U.flowing=!0:G.listenerCount("data")>0&&G.resume()}function j(G){l("readable nexttick read 0"),G.read(0)}ae.prototype.resume=function(){var G=this._readableState;return G.flowing||(l("resume"),G.flowing=!G.readableListening,ee(this,G)),G.paused=!1,this};function ee(G,U){U.resumeScheduled||(U.resumeScheduled=!0,process$1.nextTick(oe,G,U))}function oe(G,U){l("resume",U.reading),U.reading||G.read(0),U.resumeScheduled=!1,G.emit("resume"),Y(G),U.flowing&&!U.reading&&G.read(0)}ae.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Y(G){var U=G._readableState;for(l("flow",U.flowing);U.flowing&&G.read()!==null;);}ae.prototype.wrap=function(G){var U=this,Q=this._readableState,fe=!1;G.on("end",function(){if(l("wrapped end"),Q.decoder&&!Q.ended){var pe=Q.decoder.end();pe&&pe.length&&U.push(pe)}U.push(null)}),G.on("data",function(pe){if(l("wrapped data"),Q.decoder&&(pe=Q.decoder.write(pe)),!(Q.objectMode&&pe==null)&&!(!Q.objectMode&&(!pe||!pe.length))){var be=U.push(pe);be||(fe=!0,G.pause())}});for(var he in G)this[he]===void 0&&typeof G[he]=="function"&&(this[he]=function(be){return function(){return G[be].apply(G,arguments)}}(he));for(var le=0;le<Z.length;le++)G.on(Z[le],this.emit.bind(this,Z[le]));return this._read=function(pe){l("wrapped _read",pe),fe&&(fe=!1,G.resume())},this},typeof Symbol=="function"&&(ae.prototype[Symbol.asyncIterator]=function(){return F===void 0&&(F=requireAsync_iterator()),F(this)}),Object.defineProperty(ae.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(ae.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(ae.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(U){this._readableState&&(this._readableState.flowing=U)}}),ae._fromList=L,Object.defineProperty(ae.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function L(G,U){if(U.length===0)return null;var Q;return U.objectMode?Q=U.buffer.shift():!G||G>=U.length?(U.decoder?Q=U.buffer.join(""):U.buffer.length===1?Q=U.buffer.first():Q=U.buffer.concat(U.length),U.buffer.clear()):Q=U.buffer.consume(G,U.decoder),Q}function z(G){var U=G._readableState;l("endReadable",U.endEmitted),U.endEmitted||(U.ended=!0,process$1.nextTick(re,U,G))}function re(G,U){if(l("endReadableNT",G.endEmitted,G.length),!G.endEmitted&&G.length===0&&(G.endEmitted=!0,U.readable=!1,U.emit("end"),G.autoDestroy)){var Q=U._writableState;(!Q||Q.autoDestroy&&Q.finished)&&U.destroy()}}typeof Symbol=="function"&&(ae.from=function(G,U){return H===void 0&&(H=requireFromBrowser()),H(ae,G,U)});function D(G,U){for(var Q=0,fe=G.length;Q<fe;Q++)if(G[Q]===U)return Q;return-1}return _stream_readable$1}var _stream_transform$1,hasRequired_stream_transform$1;function require_stream_transform$1(){if(hasRequired_stream_transform$1)return _stream_transform$1;hasRequired_stream_transform$1=1,_stream_transform$1=h;var t=requireErrorsBrowser().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,n=t.ERR_MULTIPLE_CALLBACK,a=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=t.ERR_TRANSFORM_WITH_LENGTH_0,o=require_stream_duplex$1();inherits_browserExports(h,o);function u(d,p){var x=this._transformState;x.transforming=!1;var m=x.writecb;if(m===null)return this.emit("error",new n);x.writechunk=null,x.writecb=null,p!=null&&this.push(p),m(d);var v=this._readableState;v.reading=!1,(v.needReadable||v.length<v.highWaterMark)&&this._read(v.highWaterMark)}function h(d){if(!(this instanceof h))return new h(d);o.call(this,d),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",l)}function l(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(p,x){b(d,p,x)}):b(this,null,null)}h.prototype.push=function(d,p){return this._transformState.needTransform=!1,o.prototype.push.call(this,d,p)},h.prototype._transform=function(d,p,x){x(new e("_transform()"))},h.prototype._write=function(d,p,x){var m=this._transformState;if(m.writecb=x,m.writechunk=d,m.writeencoding=p,!m.transforming){var v=this._readableState;(m.needTransform||v.needReadable||v.length<v.highWaterMark)&&this._read(v.highWaterMark)}},h.prototype._read=function(d){var p=this._transformState;p.writechunk!==null&&!p.transforming?(p.transforming=!0,this._transform(p.writechunk,p.writeencoding,p.afterTransform)):p.needTransform=!0},h.prototype._destroy=function(d,p){o.prototype._destroy.call(this,d,function(x){p(x)})};function b(d,p,x){if(p)return d.emit("error",p);if(x!=null&&d.push(x),d._writableState.length)throw new c;if(d._transformState.transforming)throw new a;return d.push(null)}return _stream_transform$1}var _stream_passthrough$1,hasRequired_stream_passthrough$1;function require_stream_passthrough$1(){if(hasRequired_stream_passthrough$1)return _stream_passthrough$1;hasRequired_stream_passthrough$1=1,_stream_passthrough$1=e;var t=require_stream_transform$1();inherits_browserExports(e,t);function e(n){if(!(this instanceof e))return new e(n);t.call(this,n)}return e.prototype._transform=function(n,a,c){c(null,n)},_stream_passthrough$1}var pipeline_1,hasRequiredPipeline;function requirePipeline(){if(hasRequiredPipeline)return pipeline_1;hasRequiredPipeline=1;var t;function e(x){var m=!1;return function(){m||(m=!0,x.apply(void 0,arguments))}}var n=requireErrorsBrowser().codes,a=n.ERR_MISSING_ARGS,c=n.ERR_STREAM_DESTROYED;function o(x){if(x)throw x}function u(x){return x.setHeader&&typeof x.abort=="function"}function h(x,m,v,g){g=e(g);var $=!1;x.on("close",function(){$=!0}),t===void 0&&(t=requireEndOfStream()),t(x,{readable:m,writable:v},function(C){if(C)return g(C);$=!0,g()});var B=!1;return function(C){if(!$&&!B){if(B=!0,u(x))return x.abort();if(typeof x.destroy=="function")return x.destroy();g(C||new c("pipe"))}}}function l(x){x()}function b(x,m){return x.pipe(m)}function d(x){return!x.length||typeof x[x.length-1]!="function"?o:x.pop()}function p(){for(var x=arguments.length,m=new Array(x),v=0;v<x;v++)m[v]=arguments[v];var g=d(m);if(Array.isArray(m[0])&&(m=m[0]),m.length<2)throw new a("streams");var $,B=m.map(function(C,F){var H=F<m.length-1,W=F>0;return h(C,H,W,function(Z){$||($=Z),Z&&B.forEach(l),!H&&(B.forEach(l),g($))})});return m.reduce(b)}return pipeline_1=p,pipeline_1}var hasRequiredReadableBrowser$1;function requireReadableBrowser$1(){return hasRequiredReadableBrowser$1||(hasRequiredReadableBrowser$1=1,function(t,e){e=t.exports=require_stream_readable$1(),e.Stream=e,e.Readable=e,e.Writable=require_stream_writable$1(),e.Duplex=require_stream_duplex$1(),e.Transform=require_stream_transform$1(),e.PassThrough=require_stream_passthrough$1(),e.finished=requireEndOfStream(),e.pipeline=requirePipeline()}(readableBrowser$1,readableBrowser$1.exports)),readableBrowser$1.exports}var hashBase,hasRequiredHashBase;function requireHashBase(){if(hasRequiredHashBase)return hashBase;hasRequiredHashBase=1;var t=requireSafeBuffer$1().Buffer,e=requireReadableBrowser$1().Transform,n=inherits_browserExports;function a(o,u){if(!t.isBuffer(o)&&typeof o!="string")throw new TypeError(u+" must be a string or a buffer")}function c(o){e.call(this),this._block=t.allocUnsafe(o),this._blockSize=o,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}return n(c,e),c.prototype._transform=function(o,u,h){var l=null;try{this.update(o,u)}catch(b){l=b}h(l)},c.prototype._flush=function(o){var u=null;try{this.push(this.digest())}catch(h){u=h}o(u)},c.prototype.update=function(o,u){if(a(o,"Data"),this._finalized)throw new Error("Digest already called");t.isBuffer(o)||(o=t.from(o,u));for(var h=this._block,l=0;this._blockOffset+o.length-l>=this._blockSize;){for(var b=this._blockOffset;b<this._blockSize;)h[b++]=o[l++];this._update(),this._blockOffset=0}for(;l<o.length;)h[this._blockOffset++]=o[l++];for(var d=0,p=o.length*8;p>0;++d)this._length[d]+=p,p=this._length[d]/4294967296|0,p>0&&(this._length[d]-=4294967296*p);return this},c.prototype._update=function(){throw new Error("_update is not implemented")},c.prototype.digest=function(o){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var u=this._digest();o!==void 0&&(u=u.toString(o)),this._block.fill(0),this._blockOffset=0;for(var h=0;h<4;++h)this._length[h]=0;return u},c.prototype._digest=function(){throw new Error("_digest is not implemented")},hashBase=c,hashBase}var md5_js,hasRequiredMd5_js;function requireMd5_js(){if(hasRequiredMd5_js)return md5_js;hasRequiredMd5_js=1;var t=inherits_browserExports,e=requireHashBase(),n=requireSafeBuffer$1().Buffer,a=new Array(16);function c(){e.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}t(c,e),c.prototype._update=function(){for(var d=a,p=0;p<16;++p)d[p]=this._block.readInt32LE(p*4);var x=this._a,m=this._b,v=this._c,g=this._d;x=u(x,m,v,g,d[0],3614090360,7),g=u(g,x,m,v,d[1],3905402710,12),v=u(v,g,x,m,d[2],606105819,17),m=u(m,v,g,x,d[3],3250441966,22),x=u(x,m,v,g,d[4],4118548399,7),g=u(g,x,m,v,d[5],1200080426,12),v=u(v,g,x,m,d[6],2821735955,17),m=u(m,v,g,x,d[7],4249261313,22),x=u(x,m,v,g,d[8],1770035416,7),g=u(g,x,m,v,d[9],2336552879,12),v=u(v,g,x,m,d[10],4294925233,17),m=u(m,v,g,x,d[11],2304563134,22),x=u(x,m,v,g,d[12],1804603682,7),g=u(g,x,m,v,d[13],4254626195,12),v=u(v,g,x,m,d[14],2792965006,17),m=u(m,v,g,x,d[15],1236535329,22),x=h(x,m,v,g,d[1],4129170786,5),g=h(g,x,m,v,d[6],3225465664,9),v=h(v,g,x,m,d[11],643717713,14),m=h(m,v,g,x,d[0],3921069994,20),x=h(x,m,v,g,d[5],3593408605,5),g=h(g,x,m,v,d[10],38016083,9),v=h(v,g,x,m,d[15],3634488961,14),m=h(m,v,g,x,d[4],3889429448,20),x=h(x,m,v,g,d[9],568446438,5),g=h(g,x,m,v,d[14],3275163606,9),v=h(v,g,x,m,d[3],4107603335,14),m=h(m,v,g,x,d[8],1163531501,20),x=h(x,m,v,g,d[13],2850285829,5),g=h(g,x,m,v,d[2],4243563512,9),v=h(v,g,x,m,d[7],1735328473,14),m=h(m,v,g,x,d[12],2368359562,20),x=l(x,m,v,g,d[5],4294588738,4),g=l(g,x,m,v,d[8],2272392833,11),v=l(v,g,x,m,d[11],1839030562,16),m=l(m,v,g,x,d[14],4259657740,23),x=l(x,m,v,g,d[1],2763975236,4),g=l(g,x,m,v,d[4],1272893353,11),v=l(v,g,x,m,d[7],4139469664,16),m=l(m,v,g,x,d[10],3200236656,23),x=l(x,m,v,g,d[13],681279174,4),g=l(g,x,m,v,d[0],3936430074,11),v=l(v,g,x,m,d[3],3572445317,16),m=l(m,v,g,x,d[6],76029189,23),x=l(x,m,v,g,d[9],3654602809,4),g=l(g,x,m,v,d[12],3873151461,11),v=l(v,g,x,m,d[15],530742520,16),m=l(m,v,g,x,d[2],3299628645,23),x=b(x,m,v,g,d[0],4096336452,6),g=b(g,x,m,v,d[7],1126891415,10),v=b(v,g,x,m,d[14],2878612391,15),m=b(m,v,g,x,d[5],4237533241,21),x=b(x,m,v,g,d[12],1700485571,6),g=b(g,x,m,v,d[3],2399980690,10),v=b(v,g,x,m,d[10],4293915773,15),m=b(m,v,g,x,d[1],2240044497,21),x=b(x,m,v,g,d[8],1873313359,6),g=b(g,x,m,v,d[15],4264355552,10),v=b(v,g,x,m,d[6],2734768916,15),m=b(m,v,g,x,d[13],1309151649,21),x=b(x,m,v,g,d[4],4149444226,6),g=b(g,x,m,v,d[11],3174756917,10),v=b(v,g,x,m,d[2],718787259,15),m=b(m,v,g,x,d[9],3951481745,21),this._a=this._a+x|0,this._b=this._b+m|0,this._c=this._c+v|0,this._d=this._d+g|0},c.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var d=n.allocUnsafe(16);return d.writeInt32LE(this._a,0),d.writeInt32LE(this._b,4),d.writeInt32LE(this._c,8),d.writeInt32LE(this._d,12),d};function o(d,p){return d<<p|d>>>32-p}function u(d,p,x,m,v,g,$){return o(d+(p&x|~p&m)+v+g|0,$)+p|0}function h(d,p,x,m,v,g,$){return o(d+(p&m|x&~m)+v+g|0,$)+p|0}function l(d,p,x,m,v,g,$){return o(d+(p^x^m)+v+g|0,$)+p|0}function b(d,p,x,m,v,g,$){return o(d+(x^(p|~m))+v+g|0,$)+p|0}return md5_js=c,md5_js}var ripemd160,hasRequiredRipemd160;function requireRipemd160(){if(hasRequiredRipemd160)return ripemd160;hasRequiredRipemd160=1;var t=require$$1$2.Buffer,e=inherits_browserExports,n=requireHashBase(),a=new Array(16),c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],h=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],b=[1352829926,1548603684,1836072691,2053994217,0];function d(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}e(d,n),d.prototype._update=function(){for(var B=a,C=0;C<16;++C)B[C]=this._block.readInt32LE(C*4);for(var F=this._a|0,H=this._b|0,W=this._c|0,Z=this._d|0,ie=this._e|0,te=this._a|0,ae=this._b|0,de=this._c|0,J=this._d|0,R=this._e|0,A=0;A<80;A+=1){var y,w;A<16?(y=x(F,H,W,Z,ie,B[c[A]],l[0],u[A]),w=$(te,ae,de,J,R,B[o[A]],b[0],h[A])):A<32?(y=m(F,H,W,Z,ie,B[c[A]],l[1],u[A]),w=g(te,ae,de,J,R,B[o[A]],b[1],h[A])):A<48?(y=v(F,H,W,Z,ie,B[c[A]],l[2],u[A]),w=v(te,ae,de,J,R,B[o[A]],b[2],h[A])):A<64?(y=g(F,H,W,Z,ie,B[c[A]],l[3],u[A]),w=m(te,ae,de,J,R,B[o[A]],b[3],h[A])):(y=$(F,H,W,Z,ie,B[c[A]],l[4],u[A]),w=x(te,ae,de,J,R,B[o[A]],b[4],h[A])),F=ie,ie=Z,Z=p(W,10),W=H,H=y,te=R,R=J,J=p(de,10),de=ae,ae=w}var I=this._b+W+J|0;this._b=this._c+Z+R|0,this._c=this._d+ie+te|0,this._d=this._e+F+ae|0,this._e=this._a+H+de|0,this._a=I},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var B=t.alloc?t.alloc(20):new t(20);return B.writeInt32LE(this._a,0),B.writeInt32LE(this._b,4),B.writeInt32LE(this._c,8),B.writeInt32LE(this._d,12),B.writeInt32LE(this._e,16),B};function p(B,C){return B<<C|B>>>32-C}function x(B,C,F,H,W,Z,ie,te){return p(B+(C^F^H)+Z+ie|0,te)+W|0}function m(B,C,F,H,W,Z,ie,te){return p(B+(C&F|~C&H)+Z+ie|0,te)+W|0}function v(B,C,F,H,W,Z,ie,te){return p(B+((C|~F)^H)+Z+ie|0,te)+W|0}function g(B,C,F,H,W,Z,ie,te){return p(B+(C&H|F&~H)+Z+ie|0,te)+W|0}function $(B,C,F,H,W,Z,ie,te){return p(B+(C^(F|~H))+Z+ie|0,te)+W|0}return ripemd160=d,ripemd160}var sha_js={exports:{}},hash$3,hasRequiredHash;function requireHash(){if(hasRequiredHash)return hash$3;hasRequiredHash=1;var t=requireSafeBuffer$1().Buffer;function e(n,a){this._block=t.alloc(n),this._finalSize=a,this._blockSize=n,this._len=0}return e.prototype.update=function(n,a){typeof n=="string"&&(a=a||"utf8",n=t.from(n,a));for(var c=this._block,o=this._blockSize,u=n.length,h=this._len,l=0;l<u;){for(var b=h%o,d=Math.min(u-l,o-b),p=0;p<d;p++)c[b+p]=n[l+p];h+=d,l+=d,h%o===0&&this._update(c)}return this._len+=u,this},e.prototype.digest=function(n){var a=this._len%this._blockSize;this._block[a]=128,this._block.fill(0,a+1),a>=this._finalSize&&(this._update(this._block),this._block.fill(0));var c=this._len*8;if(c<=4294967295)this._block.writeUInt32BE(c,this._blockSize-4);else{var o=(c&4294967295)>>>0,u=(c-o)/4294967296;this._block.writeUInt32BE(u,this._blockSize-8),this._block.writeUInt32BE(o,this._blockSize-4)}this._update(this._block);var h=this._hash();return n?h.toString(n):h},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},hash$3=e,hash$3}var sha$1,hasRequiredSha;function requireSha(){if(hasRequiredSha)return sha$1;hasRequiredSha=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],c=new Array(80);function o(){this.init(),this._w=c,e.call(this,64,56)}t(o,e),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function u(b){return b<<5|b>>>27}function h(b){return b<<30|b>>>2}function l(b,d,p,x){return b===0?d&p|~d&x:b===2?d&p|d&x|p&x:d^p^x}return o.prototype._update=function(b){for(var d=this._w,p=this._a|0,x=this._b|0,m=this._c|0,v=this._d|0,g=this._e|0,$=0;$<16;++$)d[$]=b.readInt32BE($*4);for(;$<80;++$)d[$]=d[$-3]^d[$-8]^d[$-14]^d[$-16];for(var B=0;B<80;++B){var C=~~(B/20),F=u(p)+l(C,x,m,v)+g+d[B]+a[C]|0;g=v,v=m,m=h(x),x=p,p=F}this._a=p+this._a|0,this._b=x+this._b|0,this._c=m+this._c|0,this._d=v+this._d|0,this._e=g+this._e|0},o.prototype._hash=function(){var b=n.allocUnsafe(20);return b.writeInt32BE(this._a|0,0),b.writeInt32BE(this._b|0,4),b.writeInt32BE(this._c|0,8),b.writeInt32BE(this._d|0,12),b.writeInt32BE(this._e|0,16),b},sha$1=o,sha$1}var sha1,hasRequiredSha1;function requireSha1(){if(hasRequiredSha1)return sha1;hasRequiredSha1=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],c=new Array(80);function o(){this.init(),this._w=c,e.call(this,64,56)}t(o,e),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function u(d){return d<<1|d>>>31}function h(d){return d<<5|d>>>27}function l(d){return d<<30|d>>>2}function b(d,p,x,m){return d===0?p&x|~p&m:d===2?p&x|p&m|x&m:p^x^m}return o.prototype._update=function(d){for(var p=this._w,x=this._a|0,m=this._b|0,v=this._c|0,g=this._d|0,$=this._e|0,B=0;B<16;++B)p[B]=d.readInt32BE(B*4);for(;B<80;++B)p[B]=u(p[B-3]^p[B-8]^p[B-14]^p[B-16]);for(var C=0;C<80;++C){var F=~~(C/20),H=h(x)+b(F,m,v,g)+$+p[C]+a[F]|0;$=g,g=v,v=l(m),m=x,x=H}this._a=x+this._a|0,this._b=m+this._b|0,this._c=v+this._c|0,this._d=g+this._d|0,this._e=$+this._e|0},o.prototype._hash=function(){var d=n.allocUnsafe(20);return d.writeInt32BE(this._a|0,0),d.writeInt32BE(this._b|0,4),d.writeInt32BE(this._c|0,8),d.writeInt32BE(this._d|0,12),d.writeInt32BE(this._e|0,16),d},sha1=o,sha1}var sha256$1,hasRequiredSha256;function requireSha256(){if(hasRequiredSha256)return sha256$1;hasRequiredSha256=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[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],c=new Array(64);function o(){this.init(),this._w=c,e.call(this,64,56)}t(o,e),o.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function u(x,m,v){return v^x&(m^v)}function h(x,m,v){return x&m|v&(x|m)}function l(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function b(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function d(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function p(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}return o.prototype._update=function(x){for(var m=this._w,v=this._a|0,g=this._b|0,$=this._c|0,B=this._d|0,C=this._e|0,F=this._f|0,H=this._g|0,W=this._h|0,Z=0;Z<16;++Z)m[Z]=x.readInt32BE(Z*4);for(;Z<64;++Z)m[Z]=p(m[Z-2])+m[Z-7]+d(m[Z-15])+m[Z-16]|0;for(var ie=0;ie<64;++ie){var te=W+b(C)+u(C,F,H)+a[ie]+m[ie]|0,ae=l(v)+h(v,g,$)|0;W=H,H=F,F=C,C=B+te|0,B=$,$=g,g=v,v=te+ae|0}this._a=v+this._a|0,this._b=g+this._b|0,this._c=$+this._c|0,this._d=B+this._d|0,this._e=C+this._e|0,this._f=F+this._f|0,this._g=H+this._g|0,this._h=W+this._h|0},o.prototype._hash=function(){var x=n.allocUnsafe(32);return x.writeInt32BE(this._a,0),x.writeInt32BE(this._b,4),x.writeInt32BE(this._c,8),x.writeInt32BE(this._d,12),x.writeInt32BE(this._e,16),x.writeInt32BE(this._f,20),x.writeInt32BE(this._g,24),x.writeInt32BE(this._h,28),x},sha256$1=o,sha256$1}var sha224$1,hasRequiredSha224;function requireSha224(){if(hasRequiredSha224)return sha224$1;hasRequiredSha224=1;var t=inherits_browserExports,e=requireSha256(),n=requireHash(),a=requireSafeBuffer$1().Buffer,c=new Array(64);function o(){this.init(),this._w=c,n.call(this,64,56)}return t(o,e),o.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},o.prototype._hash=function(){var u=a.allocUnsafe(28);return u.writeInt32BE(this._a,0),u.writeInt32BE(this._b,4),u.writeInt32BE(this._c,8),u.writeInt32BE(this._d,12),u.writeInt32BE(this._e,16),u.writeInt32BE(this._f,20),u.writeInt32BE(this._g,24),u},sha224$1=o,sha224$1}var sha512$1,hasRequiredSha512;function requireSha512(){if(hasRequiredSha512)return sha512$1;hasRequiredSha512=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],c=new Array(160);function o(){this.init(),this._w=c,e.call(this,128,112)}t(o,e),o.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function u(g,$,B){return B^g&($^B)}function h(g,$,B){return g&$|B&(g|$)}function l(g,$){return(g>>>28|$<<4)^($>>>2|g<<30)^($>>>7|g<<25)}function b(g,$){return(g>>>14|$<<18)^(g>>>18|$<<14)^($>>>9|g<<23)}function d(g,$){return(g>>>1|$<<31)^(g>>>8|$<<24)^g>>>7}function p(g,$){return(g>>>1|$<<31)^(g>>>8|$<<24)^(g>>>7|$<<25)}function x(g,$){return(g>>>19|$<<13)^($>>>29|g<<3)^g>>>6}function m(g,$){return(g>>>19|$<<13)^($>>>29|g<<3)^(g>>>6|$<<26)}function v(g,$){return g>>>0<$>>>0?1:0}return o.prototype._update=function(g){for(var $=this._w,B=this._ah|0,C=this._bh|0,F=this._ch|0,H=this._dh|0,W=this._eh|0,Z=this._fh|0,ie=this._gh|0,te=this._hh|0,ae=this._al|0,de=this._bl|0,J=this._cl|0,R=this._dl|0,A=this._el|0,y=this._fl|0,w=this._gl|0,I=this._hl|0,M=0;M<32;M+=2)$[M]=g.readInt32BE(M*4),$[M+1]=g.readInt32BE(M*4+4);for(;M<160;M+=2){var k=$[M-30],P=$[M-15*2+1],_=d(k,P),q=p(P,k);k=$[M-2*2],P=$[M-2*2+1];var E=x(k,P),j=m(P,k),ee=$[M-7*2],oe=$[M-7*2+1],Y=$[M-16*2],L=$[M-16*2+1],z=q+oe|0,re=_+ee+v(z,q)|0;z=z+j|0,re=re+E+v(z,j)|0,z=z+L|0,re=re+Y+v(z,L)|0,$[M]=re,$[M+1]=z}for(var D=0;D<160;D+=2){re=$[D],z=$[D+1];var G=h(B,C,F),U=h(ae,de,J),Q=l(B,ae),fe=l(ae,B),he=b(W,A),le=b(A,W),pe=a[D],be=a[D+1],se=u(W,Z,ie),ge=u(A,y,w),ye=I+le|0,$e=te+he+v(ye,I)|0;ye=ye+ge|0,$e=$e+se+v(ye,ge)|0,ye=ye+be|0,$e=$e+pe+v(ye,be)|0,ye=ye+z|0,$e=$e+re+v(ye,z)|0;var Ne=fe+U|0,ve=Q+G+v(Ne,fe)|0;te=ie,I=w,ie=Z,w=y,Z=W,y=A,A=R+ye|0,W=H+$e+v(A,R)|0,H=F,R=J,F=C,J=de,C=B,de=ae,ae=ye+Ne|0,B=$e+ve+v(ae,ye)|0}this._al=this._al+ae|0,this._bl=this._bl+de|0,this._cl=this._cl+J|0,this._dl=this._dl+R|0,this._el=this._el+A|0,this._fl=this._fl+y|0,this._gl=this._gl+w|0,this._hl=this._hl+I|0,this._ah=this._ah+B+v(this._al,ae)|0,this._bh=this._bh+C+v(this._bl,de)|0,this._ch=this._ch+F+v(this._cl,J)|0,this._dh=this._dh+H+v(this._dl,R)|0,this._eh=this._eh+W+v(this._el,A)|0,this._fh=this._fh+Z+v(this._fl,y)|0,this._gh=this._gh+ie+v(this._gl,w)|0,this._hh=this._hh+te+v(this._hl,I)|0},o.prototype._hash=function(){var g=n.allocUnsafe(64);function $(B,C,F){g.writeInt32BE(B,F),g.writeInt32BE(C,F+4)}return $(this._ah,this._al,0),$(this._bh,this._bl,8),$(this._ch,this._cl,16),$(this._dh,this._dl,24),$(this._eh,this._el,32),$(this._fh,this._fl,40),$(this._gh,this._gl,48),$(this._hh,this._hl,56),g},sha512$1=o,sha512$1}var sha384$1,hasRequiredSha384;function requireSha384(){if(hasRequiredSha384)return sha384$1;hasRequiredSha384=1;var t=inherits_browserExports,e=requireSha512(),n=requireHash(),a=requireSafeBuffer$1().Buffer,c=new Array(160);function o(){this.init(),this._w=c,n.call(this,128,112)}return t(o,e),o.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},o.prototype._hash=function(){var u=a.allocUnsafe(48);function h(l,b,d){u.writeInt32BE(l,d),u.writeInt32BE(b,d+4)}return h(this._ah,this._al,0),h(this._bh,this._bl,8),h(this._ch,this._cl,16),h(this._dh,this._dl,24),h(this._eh,this._el,32),h(this._fh,this._fl,40),u},sha384$1=o,sha384$1}var hasRequiredSha_js;function requireSha_js(){if(hasRequiredSha_js)return sha_js.exports;hasRequiredSha_js=1;var t=sha_js.exports=function(n){n=n.toLowerCase();var a=t[n];if(!a)throw new Error(n+" is not supported (we accept pull requests)");return new a};return t.sha=requireSha(),t.sha1=requireSha1(),t.sha224=requireSha224(),t.sha256=requireSha256(),t.sha384=requireSha384(),t.sha512=requireSha512(),sha_js.exports}var streamBrowserify,hasRequiredStreamBrowserify;function requireStreamBrowserify(){if(hasRequiredStreamBrowserify)return streamBrowserify;hasRequiredStreamBrowserify=1,streamBrowserify=n;var t=requireEvents().EventEmitter,e=inherits_browserExports;e(n,t),n.Readable=require_stream_readable$1(),n.Writable=require_stream_writable$1(),n.Duplex=require_stream_duplex$1(),n.Transform=require_stream_transform$1(),n.PassThrough=require_stream_passthrough$1(),n.finished=requireEndOfStream(),n.pipeline=requirePipeline(),n.Stream=n;function n(){t.call(this)}return n.prototype.pipe=function(a,c){var o=this;function u(m){a.writable&&a.write(m)===!1&&o.pause&&o.pause()}o.on("data",u);function h(){o.readable&&o.resume&&o.resume()}a.on("drain",h),!a._isStdio&&(!c||c.end!==!1)&&(o.on("end",b),o.on("close",d));var l=!1;function b(){l||(l=!0,a.end())}function d(){l||(l=!0,typeof a.destroy=="function"&&a.destroy())}function p(m){if(x(),t.listenerCount(this,"error")===0)throw m}o.on("error",p),a.on("error",p);function x(){o.removeListener("data",u),a.removeListener("drain",h),o.removeListener("end",b),o.removeListener("close",d),o.removeListener("error",p),a.removeListener("error",p),o.removeListener("end",x),o.removeListener("close",x),a.removeListener("close",x)}return o.on("end",x),o.on("close",x),a.on("close",x),a.emit("pipe",o),a},streamBrowserify}var cipherBase,hasRequiredCipherBase;function requireCipherBase(){if(hasRequiredCipherBase)return cipherBase;hasRequiredCipherBase=1;var t=requireSafeBuffer$1().Buffer,e=requireStreamBrowserify().Transform,n=requireString_decoder().StringDecoder,a=inherits_browserExports;function c(o){e.call(this),this.hashMode=typeof o=="string",this.hashMode?this[o]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}return a(c,e),c.prototype.update=function(o,u,h){typeof o=="string"&&(o=t.from(o,u));var l=this._update(o);return this.hashMode?this:(h&&(l=this._toString(l,h)),l)},c.prototype.setAutoPadding=function(){},c.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},c.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},c.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},c.prototype._transform=function(o,u,h){var l;try{this.hashMode?this._update(o):this.push(this._update(o))}catch(b){l=b}finally{h(l)}},c.prototype._flush=function(o){var u;try{this.push(this.__final())}catch(h){u=h}o(u)},c.prototype._finalOrDigest=function(o){var u=this.__final()||t.alloc(0);return o&&(u=this._toString(u,o,!0)),u},c.prototype._toString=function(o,u,h){if(this._decoder||(this._decoder=new n(u),this._encoding=u),this._encoding!==u)throw new Error("can't switch encodings");var l=this._decoder.write(o);return h&&(l+=this._decoder.end()),l},cipherBase=c,cipherBase}var browser$9,hasRequiredBrowser$9;function requireBrowser$9(){if(hasRequiredBrowser$9)return browser$9;hasRequiredBrowser$9=1;var t=inherits_browserExports,e=requireMd5_js(),n=requireRipemd160(),a=requireSha_js(),c=requireCipherBase();function o(u){c.call(this,"digest"),this._hash=u}return t(o,c),o.prototype._update=function(u){this._hash.update(u)},o.prototype._final=function(){return this._hash.digest()},browser$9=function(h){return h=h.toLowerCase(),h==="md5"?new e:h==="rmd160"||h==="ripemd160"?new n:new o(a(h))},browser$9}var legacy,hasRequiredLegacy;function requireLegacy(){if(hasRequiredLegacy)return legacy;hasRequiredLegacy=1;var t=inherits_browserExports,e=requireSafeBuffer$1().Buffer,n=requireCipherBase(),a=e.alloc(128),c=64;function o(u,h){n.call(this,"digest"),typeof h=="string"&&(h=e.from(h)),this._alg=u,this._key=h,h.length>c?h=u(h):h.length<c&&(h=e.concat([h,a],c));for(var l=this._ipad=e.allocUnsafe(c),b=this._opad=e.allocUnsafe(c),d=0;d<c;d++)l[d]=h[d]^54,b[d]=h[d]^92;this._hash=[l]}return t(o,n),o.prototype._update=function(u){this._hash.push(u)},o.prototype._final=function(){var u=this._alg(e.concat(this._hash));return this._alg(e.concat([this._opad,u]))},legacy=o,legacy}var md5,hasRequiredMd5;function requireMd5(){if(hasRequiredMd5)return md5;hasRequiredMd5=1;var t=requireMd5_js();return md5=function(e){return new t().update(e).digest()},md5}var browser$8,hasRequiredBrowser$8;function requireBrowser$8(){if(hasRequiredBrowser$8)return browser$8;hasRequiredBrowser$8=1;var t=inherits_browserExports,e=requireLegacy(),n=requireCipherBase(),a=requireSafeBuffer$1().Buffer,c=requireMd5(),o=requireRipemd160(),u=requireSha_js(),h=a.alloc(128);function l(b,d){n.call(this,"digest"),typeof d=="string"&&(d=a.from(d));var p=b==="sha512"||b==="sha384"?128:64;if(this._alg=b,this._key=d,d.length>p){var x=b==="rmd160"?new o:u(b);d=x.update(d).digest()}else d.length<p&&(d=a.concat([d,h],p));for(var m=this._ipad=a.allocUnsafe(p),v=this._opad=a.allocUnsafe(p),g=0;g<p;g++)m[g]=d[g]^54,v[g]=d[g]^92;this._hash=b==="rmd160"?new o:u(b),this._hash.update(m)}return t(l,n),l.prototype._update=function(b){this._hash.update(b)},l.prototype._final=function(){var b=this._hash.digest(),d=this._alg==="rmd160"?new o:u(this._alg);return d.update(this._opad).update(b).digest()},browser$8=function(d,p){return d=d.toLowerCase(),d==="rmd160"||d==="ripemd160"?new l("rmd160",p):d==="md5"?new e(c,p):new l(d,p)},browser$8}const sha224WithRSAEncryption={sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption={sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption={sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption={sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},sha256={sign:"ecdsa",hash:"sha256",id:""},sha224={sign:"ecdsa",hash:"sha224",id:""},sha384={sign:"ecdsa",hash:"sha384",id:""},sha512={sign:"ecdsa",hash:"sha512",id:""},DSA={sign:"dsa",hash:"sha1",id:""},ripemd160WithRSA={sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption={sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},require$$6={sha224WithRSAEncryption,"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption,"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption,"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption,"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256,sha224,sha384,sha512,"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA,"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA,"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption,"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}};var algos,hasRequiredAlgos;function requireAlgos(){return hasRequiredAlgos||(hasRequiredAlgos=1,algos=require$$6),algos}var browser$7={},precondition,hasRequiredPrecondition;function requirePrecondition(){if(hasRequiredPrecondition)return precondition;hasRequiredPrecondition=1;var t=Math.pow(2,30)-1;return precondition=function(e,n){if(typeof e!="number")throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if(typeof n!="number")throw new TypeError("Key length not a number");if(n<0||n>t||n!==n)throw new TypeError("Bad key length")},precondition}var defaultEncoding_1,hasRequiredDefaultEncoding;function requireDefaultEncoding(){if(hasRequiredDefaultEncoding)return defaultEncoding_1;hasRequiredDefaultEncoding=1;var t;if(commonjsGlobal.process&&commonjsGlobal.process.browser)t="utf-8";else if(commonjsGlobal.process&&commonjsGlobal.process.version){var e=parseInt(process$1.version.split(".")[0].slice(1),10);t=e>=6?"utf-8":"binary"}else t="utf-8";return defaultEncoding_1=t,defaultEncoding_1}var toBuffer,hasRequiredToBuffer;function requireToBuffer(){if(hasRequiredToBuffer)return toBuffer;hasRequiredToBuffer=1;var t=requireSafeBuffer$1().Buffer;return toBuffer=function(e,n,a){if(t.isBuffer(e))return e;if(typeof e=="string")return t.from(e,n);if(ArrayBuffer.isView(e))return t.from(e.buffer);throw new TypeError(a+" must be a string, a Buffer, a typed array or a DataView")},toBuffer}var syncBrowser,hasRequiredSyncBrowser;function requireSyncBrowser(){if(hasRequiredSyncBrowser)return syncBrowser;hasRequiredSyncBrowser=1;var t=requireMd5(),e=requireRipemd160(),n=requireSha_js(),a=requireSafeBuffer$1().Buffer,c=requirePrecondition(),o=requireDefaultEncoding(),u=requireToBuffer(),h=a.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function b(x,m,v){var g=d(x),$=x==="sha512"||x==="sha384"?128:64;m.length>$?m=g(m):m.length<$&&(m=a.concat([m,h],$));for(var B=a.allocUnsafe($+l[x]),C=a.allocUnsafe($+l[x]),F=0;F<$;F++)B[F]=m[F]^54,C[F]=m[F]^92;var H=a.allocUnsafe($+v+4);B.copy(H,0,0,$),this.ipad1=H,this.ipad2=B,this.opad=C,this.alg=x,this.blocksize=$,this.hash=g,this.size=l[x]}b.prototype.run=function(x,m){x.copy(m,this.blocksize);var v=this.hash(m);return v.copy(this.opad,this.blocksize),this.hash(this.opad)};function d(x){function m(g){return n(x).update(g).digest()}function v(g){return new e().update(g).digest()}return x==="rmd160"||x==="ripemd160"?v:x==="md5"?t:m}function p(x,m,v,g,$){c(v,g),x=u(x,o,"Password"),m=u(m,o,"Salt"),$=$||"sha1";var B=new b($,x,m.length),C=a.allocUnsafe(g),F=a.allocUnsafe(m.length+4);m.copy(F,0,0,m.length);for(var H=0,W=l[$],Z=Math.ceil(g/W),ie=1;ie<=Z;ie++){F.writeUInt32BE(ie,m.length);for(var te=B.run(F,B.ipad1),ae=te,de=1;de<v;de++){ae=B.run(ae,B.ipad2);for(var J=0;J<W;J++)te[J]^=ae[J]}te.copy(C,H),H+=W}return C}return syncBrowser=p,syncBrowser}var async,hasRequiredAsync;function requireAsync(){if(hasRequiredAsync)return async;hasRequiredAsync=1;var t=requireSafeBuffer$1().Buffer,e=requirePrecondition(),n=requireDefaultEncoding(),a=requireSyncBrowser(),c=requireToBuffer(),o,u=commonjsGlobal.crypto&&commonjsGlobal.crypto.subtle,h={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},l=[];function b(v){if(commonjsGlobal.process&&!commonjsGlobal.process.browser||!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(l[v]!==void 0)return l[v];o=o||t.alloc(8);var g=x(o,o,10,128,v).then(function(){return!0}).catch(function(){return!1});return l[v]=g,g}var d;function p(){return d||(commonjsGlobal.process&&commonjsGlobal.process.nextTick?d=commonjsGlobal.process.nextTick:commonjsGlobal.queueMicrotask?d=commonjsGlobal.queueMicrotask:commonjsGlobal.setImmediate?d=commonjsGlobal.setImmediate:d=commonjsGlobal.setTimeout,d)}function x(v,g,$,B,C){return u.importKey("raw",v,{name:"PBKDF2"},!1,["deriveBits"]).then(function(F){return u.deriveBits({name:"PBKDF2",salt:g,iterations:$,hash:{name:C}},F,B<<3)}).then(function(F){return t.from(F)})}function m(v,g){v.then(function($){p()(function(){g(null,$)})},function($){p()(function(){g($)})})}return async=function(v,g,$,B,C,F){typeof C=="function"&&(F=C,C=void 0),C=C||"sha1";var H=h[C.toLowerCase()];if(!H||typeof commonjsGlobal.Promise!="function"){p()(function(){var W;try{W=a(v,g,$,B,C)}catch(Z){return F(Z)}F(null,W)});return}if(e($,B),v=c(v,n,"Password"),g=c(g,n,"Salt"),typeof F!="function")throw new Error("No callback provided to pbkdf2");m(b(H).then(function(W){return W?x(v,g,$,B,H):a(v,g,$,B,C)}),F)},async}var hasRequiredBrowser$7;function requireBrowser$7(){return hasRequiredBrowser$7||(hasRequiredBrowser$7=1,browser$7.pbkdf2=requireAsync(),browser$7.pbkdf2Sync=requireSyncBrowser()),browser$7}var browser$6={},des$1={},utils$m={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils$m;hasRequiredUtils=1,utils$m.readUInt32BE=function(c,o){var u=c[0+o]<<24|c[1+o]<<16|c[2+o]<<8|c[3+o];return u>>>0},utils$m.writeUInt32BE=function(c,o,u){c[0+u]=o>>>24,c[1+u]=o>>>16&255,c[2+u]=o>>>8&255,c[3+u]=o&255},utils$m.ip=function(c,o,u,h){for(var l=0,b=0,d=6;d>=0;d-=2){for(var p=0;p<=24;p+=8)l<<=1,l|=o>>>p+d&1;for(var p=0;p<=24;p+=8)l<<=1,l|=c>>>p+d&1}for(var d=6;d>=0;d-=2){for(var p=1;p<=25;p+=8)b<<=1,b|=o>>>p+d&1;for(var p=1;p<=25;p+=8)b<<=1,b|=c>>>p+d&1}u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.rip=function(c,o,u,h){for(var l=0,b=0,d=0;d<4;d++)for(var p=24;p>=0;p-=8)l<<=1,l|=o>>>p+d&1,l<<=1,l|=c>>>p+d&1;for(var d=4;d<8;d++)for(var p=24;p>=0;p-=8)b<<=1,b|=o>>>p+d&1,b<<=1,b|=c>>>p+d&1;u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.pc1=function(c,o,u,h){for(var l=0,b=0,d=7;d>=5;d--){for(var p=0;p<=24;p+=8)l<<=1,l|=o>>p+d&1;for(var p=0;p<=24;p+=8)l<<=1,l|=c>>p+d&1}for(var p=0;p<=24;p+=8)l<<=1,l|=o>>p+d&1;for(var d=1;d<=3;d++){for(var p=0;p<=24;p+=8)b<<=1,b|=o>>p+d&1;for(var p=0;p<=24;p+=8)b<<=1,b|=c>>p+d&1}for(var p=0;p<=24;p+=8)b<<=1,b|=c>>p+d&1;u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.r28shl=function(c,o){return c<<o&268435455|c>>>28-o};var t=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];utils$m.pc2=function(c,o,u,h){for(var l=0,b=0,d=t.length>>>1,p=0;p<d;p++)l<<=1,l|=c>>>t[p]&1;for(var p=d;p<t.length;p++)b<<=1,b|=o>>>t[p]&1;u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.expand=function(c,o,u){var h=0,l=0;h=(c&1)<<5|c>>>27;for(var b=23;b>=15;b-=4)h<<=6,h|=c>>>b&63;for(var b=11;b>=3;b-=4)l|=c>>>b&63,l<<=6;l|=(c&31)<<1|c>>>31,o[u+0]=h>>>0,o[u+1]=l>>>0};var e=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];utils$m.substitute=function(c,o){for(var u=0,h=0;h<4;h++){var l=c>>>18-h*6&63,b=e[h*64+l];u<<=4,u|=b}for(var h=0;h<4;h++){var l=o>>>18-h*6&63,b=e[4*64+h*64+l];u<<=4,u|=b}return u>>>0};var n=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];return utils$m.permute=function(c){for(var o=0,u=0;u<n.length;u++)o<<=1,o|=c>>>n[u]&1;return o>>>0},utils$m.padSplit=function(c,o,u){for(var h=c.toString(2);h.length<o;)h="0"+h;for(var l=[],b=0;b<o;b+=u)l.push(h.slice(b,b+u));return l.join(" ")},utils$m}var cipher,hasRequiredCipher;function requireCipher(){if(hasRequiredCipher)return cipher;hasRequiredCipher=1;var t=minimalisticAssert;function e(n){this.options=n,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=n.padding!==!1}return cipher=e,e.prototype._init=function(){},e.prototype.update=function(a){return a.length===0?[]:this.type==="decrypt"?this._updateDecrypt(a):this._updateEncrypt(a)},e.prototype._buffer=function(a,c){for(var o=Math.min(this.buffer.length-this.bufferOff,a.length-c),u=0;u<o;u++)this.buffer[this.bufferOff+u]=a[c+u];return this.bufferOff+=o,o},e.prototype._flushBuffer=function(a,c){return this._update(this.buffer,0,a,c),this.bufferOff=0,this.blockSize},e.prototype._updateEncrypt=function(a){var c=0,o=0,u=(this.bufferOff+a.length)/this.blockSize|0,h=new Array(u*this.blockSize);this.bufferOff!==0&&(c+=this._buffer(a,c),this.bufferOff===this.buffer.length&&(o+=this._flushBuffer(h,o)));for(var l=a.length-(a.length-c)%this.blockSize;c<l;c+=this.blockSize)this._update(a,c,h,o),o+=this.blockSize;for(;c<a.length;c++,this.bufferOff++)this.buffer[this.bufferOff]=a[c];return h},e.prototype._updateDecrypt=function(a){for(var c=0,o=0,u=Math.ceil((this.bufferOff+a.length)/this.blockSize)-1,h=new Array(u*this.blockSize);u>0;u--)c+=this._buffer(a,c),o+=this._flushBuffer(h,o);return c+=this._buffer(a,c),h},e.prototype.final=function(a){var c;a&&(c=this.update(a));var o;return this.type==="encrypt"?o=this._finalEncrypt():o=this._finalDecrypt(),c?c.concat(o):o},e.prototype._pad=function(a,c){if(c===0)return!1;for(;c<a.length;)a[c++]=0;return!0},e.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var a=new Array(this.blockSize);return this._update(this.buffer,0,a,0),a},e.prototype._unpad=function(a){return a},e.prototype._finalDecrypt=function(){t.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var a=new Array(this.blockSize);return this._flushBuffer(a,0),this._unpad(a)},cipher}var des,hasRequiredDes$1;function requireDes$1(){if(hasRequiredDes$1)return des;hasRequiredDes$1=1;var t=minimalisticAssert,e=inherits_browserExports,n=requireUtils(),a=requireCipher();function c(){this.tmp=new Array(2),this.keys=null}function o(h){a.call(this,h);var l=new c;this._desState=l,this.deriveKeys(l,h.key)}e(o,a),des=o,o.create=function(l){return new o(l)};var u=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];return o.prototype.deriveKeys=function(l,b){l.keys=new Array(16*2),t.equal(b.length,this.blockSize,"Invalid key length");var d=n.readUInt32BE(b,0),p=n.readUInt32BE(b,4);n.pc1(d,p,l.tmp,0),d=l.tmp[0],p=l.tmp[1];for(var x=0;x<l.keys.length;x+=2){var m=u[x>>>1];d=n.r28shl(d,m),p=n.r28shl(p,m),n.pc2(d,p,l.keys,x)}},o.prototype._update=function(l,b,d,p){var x=this._desState,m=n.readUInt32BE(l,b),v=n.readUInt32BE(l,b+4);n.ip(m,v,x.tmp,0),m=x.tmp[0],v=x.tmp[1],this.type==="encrypt"?this._encrypt(x,m,v,x.tmp,0):this._decrypt(x,m,v,x.tmp,0),m=x.tmp[0],v=x.tmp[1],n.writeUInt32BE(d,m,p),n.writeUInt32BE(d,v,p+4)},o.prototype._pad=function(l,b){if(this.padding===!1)return!1;for(var d=l.length-b,p=b;p<l.length;p++)l[p]=d;return!0},o.prototype._unpad=function(l){if(this.padding===!1)return l;for(var b=l[l.length-1],d=l.length-b;d<l.length;d++)t.equal(l[d],b);return l.slice(0,l.length-b)},o.prototype._encrypt=function(l,b,d,p,x){for(var m=b,v=d,g=0;g<l.keys.length;g+=2){var $=l.keys[g],B=l.keys[g+1];n.expand(v,l.tmp,0),$^=l.tmp[0],B^=l.tmp[1];var C=n.substitute($,B),F=n.permute(C),H=v;v=(m^F)>>>0,m=H}n.rip(v,m,p,x)},o.prototype._decrypt=function(l,b,d,p,x){for(var m=d,v=b,g=l.keys.length-2;g>=0;g-=2){var $=l.keys[g],B=l.keys[g+1];n.expand(m,l.tmp,0),$^=l.tmp[0],B^=l.tmp[1];var C=n.substitute($,B),F=n.permute(C),H=m;m=(v^F)>>>0,v=H}n.rip(m,v,p,x)},des}var cbc$1={},hasRequiredCbc$1;function requireCbc$1(){if(hasRequiredCbc$1)return cbc$1;hasRequiredCbc$1=1;var t=minimalisticAssert,e=inherits_browserExports,n={};function a(o){t.equal(o.length,8,"Invalid IV length"),this.iv=new Array(8);for(var u=0;u<this.iv.length;u++)this.iv[u]=o[u]}function c(o){function u(d){o.call(this,d),this._cbcInit()}e(u,o);for(var h=Object.keys(n),l=0;l<h.length;l++){var b=h[l];u.prototype[b]=n[b]}return u.create=function(p){return new u(p)},u}return cbc$1.instantiate=c,n._cbcInit=function(){var u=new a(this.options.iv);this._cbcState=u},n._update=function(u,h,l,b){var d=this._cbcState,p=this.constructor.super_.prototype,x=d.iv;if(this.type==="encrypt"){for(var m=0;m<this.blockSize;m++)x[m]^=u[h+m];p._update.call(this,x,0,l,b);for(var m=0;m<this.blockSize;m++)x[m]=l[b+m]}else{p._update.call(this,u,h,l,b);for(var m=0;m<this.blockSize;m++)l[b+m]^=x[m];for(var m=0;m<this.blockSize;m++)x[m]=u[h+m]}},cbc$1}var ede,hasRequiredEde;function requireEde(){if(hasRequiredEde)return ede;hasRequiredEde=1;var t=minimalisticAssert,e=inherits_browserExports,n=requireCipher(),a=requireDes$1();function c(u,h){t.equal(h.length,24,"Invalid key length");var l=h.slice(0,8),b=h.slice(8,16),d=h.slice(16,24);u==="encrypt"?this.ciphers=[a.create({type:"encrypt",key:l}),a.create({type:"decrypt",key:b}),a.create({type:"encrypt",key:d})]:this.ciphers=[a.create({type:"decrypt",key:d}),a.create({type:"encrypt",key:b}),a.create({type:"decrypt",key:l})]}function o(u){n.call(this,u);var h=new c(this.type,this.options.key);this._edeState=h}return e(o,n),ede=o,o.create=function(h){return new o(h)},o.prototype._update=function(h,l,b,d){var p=this._edeState;p.ciphers[0]._update(h,l,b,d),p.ciphers[1]._update(b,d,b,d),p.ciphers[2]._update(b,d,b,d)},o.prototype._pad=a.prototype._pad,o.prototype._unpad=a.prototype._unpad,ede}var hasRequiredDes;function requireDes(){return hasRequiredDes||(hasRequiredDes=1,des$1.utils=requireUtils(),des$1.Cipher=requireCipher(),des$1.DES=requireDes$1(),des$1.CBC=requireCbc$1(),des$1.EDE=requireEde()),des$1}var browserifyDes,hasRequiredBrowserifyDes;function requireBrowserifyDes(){if(hasRequiredBrowserifyDes)return browserifyDes;hasRequiredBrowserifyDes=1;var t=requireCipherBase(),e=requireDes(),n=inherits_browserExports,a=requireSafeBuffer$1().Buffer,c={"des-ede3-cbc":e.CBC.instantiate(e.EDE),"des-ede3":e.EDE,"des-ede-cbc":e.CBC.instantiate(e.EDE),"des-ede":e.EDE,"des-cbc":e.CBC.instantiate(e.DES),"des-ecb":e.DES};c.des=c["des-cbc"],c.des3=c["des-ede3-cbc"],browserifyDes=o,n(o,t);function o(u){t.call(this);var h=u.mode.toLowerCase(),l=c[h],b;u.decrypt?b="decrypt":b="encrypt";var d=u.key;a.isBuffer(d)||(d=a.from(d)),(h==="des-ede"||h==="des-ede-cbc")&&(d=a.concat([d,d.slice(0,8)]));var p=u.iv;a.isBuffer(p)||(p=a.from(p)),this._des=l.create({key:d,iv:p,type:b})}return o.prototype._update=function(u){return a.from(this._des.update(u))},o.prototype._final=function(){return a.from(this._des.final())},browserifyDes}var browser$5={},encrypter={},ecb={},hasRequiredEcb;function requireEcb(){return hasRequiredEcb||(hasRequiredEcb=1,ecb.encrypt=function(t,e){return t._cipher.encryptBlock(e)},ecb.decrypt=function(t,e){return t._cipher.decryptBlock(e)}),ecb}var cbc={},bufferXor,hasRequiredBufferXor;function requireBufferXor(){return hasRequiredBufferXor||(hasRequiredBufferXor=1,bufferXor=function(e,n){for(var a=Math.min(e.length,n.length),c=new Buffer(a),o=0;o<a;++o)c[o]=e[o]^n[o];return c}),bufferXor}var hasRequiredCbc;function requireCbc(){if(hasRequiredCbc)return cbc;hasRequiredCbc=1;var t=requireBufferXor();return cbc.encrypt=function(e,n){var a=t(n,e._prev);return e._prev=e._cipher.encryptBlock(a),e._prev},cbc.decrypt=function(e,n){var a=e._prev;e._prev=n;var c=e._cipher.decryptBlock(n);return t(c,a)},cbc}var cfb={},hasRequiredCfb;function requireCfb(){if(hasRequiredCfb)return cfb;hasRequiredCfb=1;var t=requireSafeBuffer$1().Buffer,e=requireBufferXor();function n(a,c,o){var u=c.length,h=e(c,a._cache);return a._cache=a._cache.slice(u),a._prev=t.concat([a._prev,o?c:h]),h}return cfb.encrypt=function(a,c,o){for(var u=t.allocUnsafe(0),h;c.length;)if(a._cache.length===0&&(a._cache=a._cipher.encryptBlock(a._prev),a._prev=t.allocUnsafe(0)),a._cache.length<=c.length)h=a._cache.length,u=t.concat([u,n(a,c.slice(0,h),o)]),c=c.slice(h);else{u=t.concat([u,n(a,c,o)]);break}return u},cfb}var cfb8={},hasRequiredCfb8;function requireCfb8(){if(hasRequiredCfb8)return cfb8;hasRequiredCfb8=1;var t=requireSafeBuffer$1().Buffer;function e(n,a,c){var o=n._cipher.encryptBlock(n._prev),u=o[0]^a;return n._prev=t.concat([n._prev.slice(1),t.from([c?a:u])]),u}return cfb8.encrypt=function(n,a,c){for(var o=a.length,u=t.allocUnsafe(o),h=-1;++h<o;)u[h]=e(n,a[h],c);return u},cfb8}var cfb1={},hasRequiredCfb1;function requireCfb1(){if(hasRequiredCfb1)return cfb1;hasRequiredCfb1=1;var t=requireSafeBuffer$1().Buffer;function e(a,c,o){for(var u,h=-1,l=8,b=0,d,p;++h<l;)u=a._cipher.encryptBlock(a._prev),d=c&1<<7-h?128:0,p=u[0]^d,b+=(p&128)>>h%8,a._prev=n(a._prev,o?d:p);return b}function n(a,c){var o=a.length,u=-1,h=t.allocUnsafe(a.length);for(a=t.concat([a,t.from([c])]);++u<o;)h[u]=a[u]<<1|a[u+1]>>7;return h}return cfb1.encrypt=function(a,c,o){for(var u=c.length,h=t.allocUnsafe(u),l=-1;++l<u;)h[l]=e(a,c[l],o);return h},cfb1}var ofb={},hasRequiredOfb;function requireOfb(){if(hasRequiredOfb)return ofb;hasRequiredOfb=1;var t=requireBufferXor();function e(n){return n._prev=n._cipher.encryptBlock(n._prev),n._prev}return ofb.encrypt=function(n,a){for(;n._cache.length<a.length;)n._cache=Buffer.concat([n._cache,e(n)]);var c=n._cache.slice(0,a.length);return n._cache=n._cache.slice(a.length),t(a,c)},ofb}var ctr={},incr32_1,hasRequiredIncr32;function requireIncr32(){if(hasRequiredIncr32)return incr32_1;hasRequiredIncr32=1;function t(e){for(var n=e.length,a;n--;)if(a=e.readUInt8(n),a===255)e.writeUInt8(0,n);else{a++,e.writeUInt8(a,n);break}}return incr32_1=t,incr32_1}var hasRequiredCtr;function requireCtr(){if(hasRequiredCtr)return ctr;hasRequiredCtr=1;var t=requireBufferXor(),e=requireSafeBuffer$1().Buffer,n=requireIncr32();function a(o){var u=o._cipher.encryptBlockRaw(o._prev);return n(o._prev),u}var c=16;return ctr.encrypt=function(o,u){var h=Math.ceil(u.length/c),l=o._cache.length;o._cache=e.concat([o._cache,e.allocUnsafe(h*c)]);for(var b=0;b<h;b++){var d=a(o),p=l+b*c;o._cache.writeUInt32BE(d[0],p+0),o._cache.writeUInt32BE(d[1],p+4),o._cache.writeUInt32BE(d[2],p+8),o._cache.writeUInt32BE(d[3],p+12)}var x=o._cache.slice(0,u.length);return o._cache=o._cache.slice(u.length),t(u,x)},ctr}const aes128={cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192={cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256={cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},require$$2={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128,aes192,aes256,"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}};var modes_1,hasRequiredModes$1;function requireModes$1(){if(hasRequiredModes$1)return modes_1;hasRequiredModes$1=1;var t={ECB:requireEcb(),CBC:requireCbc(),CFB:requireCfb(),CFB8:requireCfb8(),CFB1:requireCfb1(),OFB:requireOfb(),CTR:requireCtr(),GCM:requireCtr()},e=require$$2;for(var n in e)e[n].module=t[e[n].mode];return modes_1=e,modes_1}var aes={},hasRequiredAes;function requireAes(){if(hasRequiredAes)return aes;hasRequiredAes=1;var t=requireSafeBuffer$1().Buffer;function e(h){t.isBuffer(h)||(h=t.from(h));for(var l=h.length/4|0,b=new Array(l),d=0;d<l;d++)b[d]=h.readUInt32BE(d*4);return b}function n(h){for(var l=0;l<h.length;h++)h[l]=0}function a(h,l,b,d,p){for(var x=b[0],m=b[1],v=b[2],g=b[3],$=h[0]^l[0],B=h[1]^l[1],C=h[2]^l[2],F=h[3]^l[3],H,W,Z,ie,te=4,ae=1;ae<p;ae++)H=x[$>>>24]^m[B>>>16&255]^v[C>>>8&255]^g[F&255]^l[te++],W=x[B>>>24]^m[C>>>16&255]^v[F>>>8&255]^g[$&255]^l[te++],Z=x[C>>>24]^m[F>>>16&255]^v[$>>>8&255]^g[B&255]^l[te++],ie=x[F>>>24]^m[$>>>16&255]^v[B>>>8&255]^g[C&255]^l[te++],$=H,B=W,C=Z,F=ie;return H=(d[$>>>24]<<24|d[B>>>16&255]<<16|d[C>>>8&255]<<8|d[F&255])^l[te++],W=(d[B>>>24]<<24|d[C>>>16&255]<<16|d[F>>>8&255]<<8|d[$&255])^l[te++],Z=(d[C>>>24]<<24|d[F>>>16&255]<<16|d[$>>>8&255]<<8|d[B&255])^l[te++],ie=(d[F>>>24]<<24|d[$>>>16&255]<<16|d[B>>>8&255]<<8|d[C&255])^l[te++],H=H>>>0,W=W>>>0,Z=Z>>>0,ie=ie>>>0,[H,W,Z,ie]}var c=[0,1,2,4,8,16,32,64,128,27,54],o=function(){for(var h=new Array(256),l=0;l<256;l++)l<128?h[l]=l<<1:h[l]=l<<1^283;for(var b=[],d=[],p=[[],[],[],[]],x=[[],[],[],[]],m=0,v=0,g=0;g<256;++g){var $=v^v<<1^v<<2^v<<3^v<<4;$=$>>>8^$&255^99,b[m]=$,d[$]=m;var B=h[m],C=h[B],F=h[C],H=h[$]*257^$*16843008;p[0][m]=H<<24|H>>>8,p[1][m]=H<<16|H>>>16,p[2][m]=H<<8|H>>>24,p[3][m]=H,H=F*16843009^C*65537^B*257^m*16843008,x[0][$]=H<<24|H>>>8,x[1][$]=H<<16|H>>>16,x[2][$]=H<<8|H>>>24,x[3][$]=H,m===0?m=v=1:(m=B^h[h[h[F^B]]],v^=h[h[v]])}return{SBOX:b,INV_SBOX:d,SUB_MIX:p,INV_SUB_MIX:x}}();function u(h){this._key=e(h),this._reset()}return u.blockSize=4*4,u.keySize=256/8,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var h=this._key,l=h.length,b=l+6,d=(b+1)*4,p=[],x=0;x<l;x++)p[x]=h[x];for(x=l;x<d;x++){var m=p[x-1];x%l===0?(m=m<<8|m>>>24,m=o.SBOX[m>>>24]<<24|o.SBOX[m>>>16&255]<<16|o.SBOX[m>>>8&255]<<8|o.SBOX[m&255],m^=c[x/l|0]<<24):l>6&&x%l===4&&(m=o.SBOX[m>>>24]<<24|o.SBOX[m>>>16&255]<<16|o.SBOX[m>>>8&255]<<8|o.SBOX[m&255]),p[x]=p[x-l]^m}for(var v=[],g=0;g<d;g++){var $=d-g,B=p[$-(g%4?0:4)];g<4||$<=4?v[g]=B:v[g]=o.INV_SUB_MIX[0][o.SBOX[B>>>24]]^o.INV_SUB_MIX[1][o.SBOX[B>>>16&255]]^o.INV_SUB_MIX[2][o.SBOX[B>>>8&255]]^o.INV_SUB_MIX[3][o.SBOX[B&255]]}this._nRounds=b,this._keySchedule=p,this._invKeySchedule=v},u.prototype.encryptBlockRaw=function(h){return h=e(h),a(h,this._keySchedule,o.SUB_MIX,o.SBOX,this._nRounds)},u.prototype.encryptBlock=function(h){var l=this.encryptBlockRaw(h),b=t.allocUnsafe(16);return b.writeUInt32BE(l[0],0),b.writeUInt32BE(l[1],4),b.writeUInt32BE(l[2],8),b.writeUInt32BE(l[3],12),b},u.prototype.decryptBlock=function(h){h=e(h);var l=h[1];h[1]=h[3],h[3]=l;var b=a(h,this._invKeySchedule,o.INV_SUB_MIX,o.INV_SBOX,this._nRounds),d=t.allocUnsafe(16);return d.writeUInt32BE(b[0],0),d.writeUInt32BE(b[3],4),d.writeUInt32BE(b[2],8),d.writeUInt32BE(b[1],12),d},u.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},aes.AES=u,aes}var ghash,hasRequiredGhash;function requireGhash(){if(hasRequiredGhash)return ghash;hasRequiredGhash=1;var t=requireSafeBuffer$1().Buffer,e=t.alloc(16,0);function n(o){return[o.readUInt32BE(0),o.readUInt32BE(4),o.readUInt32BE(8),o.readUInt32BE(12)]}function a(o){var u=t.allocUnsafe(16);return u.writeUInt32BE(o[0]>>>0,0),u.writeUInt32BE(o[1]>>>0,4),u.writeUInt32BE(o[2]>>>0,8),u.writeUInt32BE(o[3]>>>0,12),u}function c(o){this.h=o,this.state=t.alloc(16,0),this.cache=t.allocUnsafe(0)}return c.prototype.ghash=function(o){for(var u=-1;++u<o.length;)this.state[u]^=o[u];this._multiply()},c.prototype._multiply=function(){for(var o=n(this.h),u=[0,0,0,0],h,l,b,d=-1;++d<128;){for(l=(this.state[~~(d/8)]&1<<7-d%8)!==0,l&&(u[0]^=o[0],u[1]^=o[1],u[2]^=o[2],u[3]^=o[3]),b=(o[3]&1)!==0,h=3;h>0;h--)o[h]=o[h]>>>1|(o[h-1]&1)<<31;o[0]=o[0]>>>1,b&&(o[0]=o[0]^225<<24)}this.state=a(u)},c.prototype.update=function(o){this.cache=t.concat([this.cache,o]);for(var u;this.cache.length>=16;)u=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(u)},c.prototype.final=function(o,u){return this.cache.length&&this.ghash(t.concat([this.cache,e],16)),this.ghash(a([0,o,0,u])),this.state},ghash=c,ghash}var authCipher,hasRequiredAuthCipher;function requireAuthCipher(){if(hasRequiredAuthCipher)return authCipher;hasRequiredAuthCipher=1;var t=requireAes(),e=requireSafeBuffer$1().Buffer,n=requireCipherBase(),a=inherits_browserExports,c=requireGhash(),o=requireBufferXor(),u=requireIncr32();function h(d,p){var x=0;d.length!==p.length&&x++;for(var m=Math.min(d.length,p.length),v=0;v<m;++v)x+=d[v]^p[v];return x}function l(d,p,x){if(p.length===12)return d._finID=e.concat([p,e.from([0,0,0,1])]),e.concat([p,e.from([0,0,0,2])]);var m=new c(x),v=p.length,g=v%16;m.update(p),g&&(g=16-g,m.update(e.alloc(g,0))),m.update(e.alloc(8,0));var $=v*8,B=e.alloc(8);B.writeUIntBE($,0,8),m.update(B),d._finID=m.state;var C=e.from(d._finID);return u(C),C}function b(d,p,x,m){n.call(this);var v=e.alloc(4,0);this._cipher=new t.AES(p);var g=this._cipher.encryptBlock(v);this._ghash=new c(g),x=l(this,x,g),this._prev=e.from(x),this._cache=e.allocUnsafe(0),this._secCache=e.allocUnsafe(0),this._decrypt=m,this._alen=0,this._len=0,this._mode=d,this._authTag=null,this._called=!1}return a(b,n),b.prototype._update=function(d){if(!this._called&&this._alen){var p=16-this._alen%16;p<16&&(p=e.alloc(p,0),this._ghash.update(p))}this._called=!0;var x=this._mode.encrypt(this,d);return this._decrypt?this._ghash.update(d):this._ghash.update(x),this._len+=d.length,x},b.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var d=o(this._ghash.final(this._alen*8,this._len*8),this._cipher.encryptBlock(this._finID));if(this._decrypt&&h(d,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=d,this._cipher.scrub()},b.prototype.getAuthTag=function(){if(this._decrypt||!e.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},b.prototype.setAuthTag=function(p){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=p},b.prototype.setAAD=function(p){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(p),this._alen+=p.length},authCipher=b,authCipher}var streamCipher,hasRequiredStreamCipher;function requireStreamCipher(){if(hasRequiredStreamCipher)return streamCipher;hasRequiredStreamCipher=1;var t=requireAes(),e=requireSafeBuffer$1().Buffer,n=requireCipherBase(),a=inherits_browserExports;function c(o,u,h,l){n.call(this),this._cipher=new t.AES(u),this._prev=e.from(h),this._cache=e.allocUnsafe(0),this._secCache=e.allocUnsafe(0),this._decrypt=l,this._mode=o}return a(c,n),c.prototype._update=function(o){return this._mode.encrypt(this,o,this._decrypt)},c.prototype._final=function(){this._cipher.scrub()},streamCipher=c,streamCipher}var evp_bytestokey,hasRequiredEvp_bytestokey;function requireEvp_bytestokey(){if(hasRequiredEvp_bytestokey)return evp_bytestokey;hasRequiredEvp_bytestokey=1;var t=requireSafeBuffer$1().Buffer,e=requireMd5_js();function n(a,c,o,u){if(t.isBuffer(a)||(a=t.from(a,"binary")),c&&(t.isBuffer(c)||(c=t.from(c,"binary")),c.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var h=o/8,l=t.alloc(h),b=t.alloc(u||0),d=t.alloc(0);h>0||u>0;){var p=new e;p.update(d),p.update(a),c&&p.update(c),d=p.digest();var x=0;if(h>0){var m=l.length-h;x=Math.min(h,d.length),d.copy(l,m,0,x),h-=x}if(x<d.length&&u>0){var v=b.length-u,g=Math.min(u,d.length-x);d.copy(b,v,x,x+g),u-=g}}return d.fill(0),{key:l,iv:b}}return evp_bytestokey=n,evp_bytestokey}var hasRequiredEncrypter;function requireEncrypter(){if(hasRequiredEncrypter)return encrypter;hasRequiredEncrypter=1;var t=requireModes$1(),e=requireAuthCipher(),n=requireSafeBuffer$1().Buffer,a=requireStreamCipher(),c=requireCipherBase(),o=requireAes(),u=requireEvp_bytestokey(),h=inherits_browserExports;function l(m,v,g){c.call(this),this._cache=new d,this._cipher=new o.AES(v),this._prev=n.from(g),this._mode=m,this._autopadding=!0}h(l,c),l.prototype._update=function(m){this._cache.add(m);for(var v,g,$=[];v=this._cache.get();)g=this._mode.encrypt(this,v),$.push(g);return n.concat($)};var b=n.alloc(16,16);l.prototype._final=function(){var m=this._cache.flush();if(this._autopadding)return m=this._mode.encrypt(this,m),this._cipher.scrub(),m;if(!m.equals(b))throw this._cipher.scrub(),new Error("data not multiple of block length")},l.prototype.setAutoPadding=function(m){return this._autopadding=!!m,this};function d(){this.cache=n.allocUnsafe(0)}d.prototype.add=function(m){this.cache=n.concat([this.cache,m])},d.prototype.get=function(){if(this.cache.length>15){var m=this.cache.slice(0,16);return this.cache=this.cache.slice(16),m}return null},d.prototype.flush=function(){for(var m=16-this.cache.length,v=n.allocUnsafe(m),g=-1;++g<m;)v.writeUInt8(m,g);return n.concat([this.cache,v])};function p(m,v,g){var $=t[m.toLowerCase()];if(!$)throw new TypeError("invalid suite type");if(typeof v=="string"&&(v=n.from(v)),v.length!==$.key/8)throw new TypeError("invalid key length "+v.length);if(typeof g=="string"&&(g=n.from(g)),$.mode!=="GCM"&&g.length!==$.iv)throw new TypeError("invalid iv length "+g.length);return $.type==="stream"?new a($.module,v,g):$.type==="auth"?new e($.module,v,g):new l($.module,v,g)}function x(m,v){var g=t[m.toLowerCase()];if(!g)throw new TypeError("invalid suite type");var $=u(v,!1,g.key,g.iv);return p(m,$.key,$.iv)}return encrypter.createCipheriv=p,encrypter.createCipher=x,encrypter}var decrypter={},hasRequiredDecrypter;function requireDecrypter(){if(hasRequiredDecrypter)return decrypter;hasRequiredDecrypter=1;var t=requireAuthCipher(),e=requireSafeBuffer$1().Buffer,n=requireModes$1(),a=requireStreamCipher(),c=requireCipherBase(),o=requireAes(),u=requireEvp_bytestokey(),h=inherits_browserExports;function l(m,v,g){c.call(this),this._cache=new b,this._last=void 0,this._cipher=new o.AES(v),this._prev=e.from(g),this._mode=m,this._autopadding=!0}h(l,c),l.prototype._update=function(m){this._cache.add(m);for(var v,g,$=[];v=this._cache.get(this._autopadding);)g=this._mode.decrypt(this,v),$.push(g);return e.concat($)},l.prototype._final=function(){var m=this._cache.flush();if(this._autopadding)return d(this._mode.decrypt(this,m));if(m)throw new Error("data not multiple of block length")},l.prototype.setAutoPadding=function(m){return this._autopadding=!!m,this};function b(){this.cache=e.allocUnsafe(0)}b.prototype.add=function(m){this.cache=e.concat([this.cache,m])},b.prototype.get=function(m){var v;if(m){if(this.cache.length>16)return v=this.cache.slice(0,16),this.cache=this.cache.slice(16),v}else if(this.cache.length>=16)return v=this.cache.slice(0,16),this.cache=this.cache.slice(16),v;return null},b.prototype.flush=function(){if(this.cache.length)return this.cache};function d(m){var v=m[15];if(v<1||v>16)throw new Error("unable to decrypt data");for(var g=-1;++g<v;)if(m[g+(16-v)]!==v)throw new Error("unable to decrypt data");if(v!==16)return m.slice(0,16-v)}function p(m,v,g){var $=n[m.toLowerCase()];if(!$)throw new TypeError("invalid suite type");if(typeof g=="string"&&(g=e.from(g)),$.mode!=="GCM"&&g.length!==$.iv)throw new TypeError("invalid iv length "+g.length);if(typeof v=="string"&&(v=e.from(v)),v.length!==$.key/8)throw new TypeError("invalid key length "+v.length);return $.type==="stream"?new a($.module,v,g,!0):$.type==="auth"?new t($.module,v,g,!0):new l($.module,v,g)}function x(m,v){var g=n[m.toLowerCase()];if(!g)throw new TypeError("invalid suite type");var $=u(v,!1,g.key,g.iv);return p(m,$.key,$.iv)}return decrypter.createDecipher=x,decrypter.createDecipheriv=p,decrypter}var hasRequiredBrowser$6;function requireBrowser$6(){if(hasRequiredBrowser$6)return browser$5;hasRequiredBrowser$6=1;var t=requireEncrypter(),e=requireDecrypter(),n=require$$2;function a(){return Object.keys(n)}return browser$5.createCipher=browser$5.Cipher=t.createCipher,browser$5.createCipheriv=browser$5.Cipheriv=t.createCipheriv,browser$5.createDecipher=browser$5.Decipher=e.createDecipher,browser$5.createDecipheriv=browser$5.Decipheriv=e.createDecipheriv,browser$5.listCiphers=browser$5.getCiphers=a,browser$5}var modes={},hasRequiredModes;function requireModes(){return hasRequiredModes||(hasRequiredModes=1,function(t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}}(modes)),modes}var hasRequiredBrowser$5;function requireBrowser$5(){if(hasRequiredBrowser$5)return browser$6;hasRequiredBrowser$5=1;var t=requireBrowserifyDes(),e=requireBrowser$6(),n=requireModes$1(),a=requireModes(),c=requireEvp_bytestokey();function o(d,p){d=d.toLowerCase();var x,m;if(n[d])x=n[d].key,m=n[d].iv;else if(a[d])x=a[d].key*8,m=a[d].iv;else throw new TypeError("invalid suite type");var v=c(p,!1,x,m);return h(d,v.key,v.iv)}function u(d,p){d=d.toLowerCase();var x,m;if(n[d])x=n[d].key,m=n[d].iv;else if(a[d])x=a[d].key*8,m=a[d].iv;else throw new TypeError("invalid suite type");var v=c(p,!1,x,m);return l(d,v.key,v.iv)}function h(d,p,x){if(d=d.toLowerCase(),n[d])return e.createCipheriv(d,p,x);if(a[d])return new t({key:p,iv:x,mode:d});throw new TypeError("invalid suite type")}function l(d,p,x){if(d=d.toLowerCase(),n[d])return e.createDecipheriv(d,p,x);if(a[d])return new t({key:p,iv:x,mode:d,decrypt:!0});throw new TypeError("invalid suite type")}function b(){return Object.keys(a).concat(e.getCiphers())}return browser$6.createCipher=browser$6.Cipher=o,browser$6.createCipheriv=browser$6.Cipheriv=h,browser$6.createDecipher=browser$6.Decipher=u,browser$6.createDecipheriv=browser$6.Decipheriv=l,browser$6.listCiphers=browser$6.getCiphers=b,browser$6}var browser$4={},mr,hasRequiredMr;function requireMr(){if(hasRequiredMr)return mr;hasRequiredMr=1;var t=bnExports,e=requireBrorand();function n(a){this.rand=a||new e.Rand}return mr=n,n.create=function(c){return new n(c)},n.prototype._randbelow=function(c){var o=c.bitLength(),u=Math.ceil(o/8);do var h=new t(this.rand.generate(u));while(h.cmp(c)>=0);return h},n.prototype._randrange=function(c,o){var u=o.sub(c);return c.add(this._randbelow(u))},n.prototype.test=function(c,o,u){var h=c.bitLength(),l=t.mont(c),b=new t(1).toRed(l);o||(o=Math.max(1,h/48|0));for(var d=c.subn(1),p=0;!d.testn(p);p++);for(var x=c.shrn(p),m=d.toRed(l),v=!0;o>0;o--){var g=this._randrange(new t(2),d);u&&u(g);var $=g.toRed(l).redPow(x);if(!($.cmp(b)===0||$.cmp(m)===0)){for(var B=1;B<p;B++){if($=$.redSqr(),$.cmp(b)===0)return!1;if($.cmp(m)===0)break}if(B===p)return!1}}return v},n.prototype.getDivisor=function(c,o){var u=c.bitLength(),h=t.mont(c),l=new t(1).toRed(h);o||(o=Math.max(1,u/48|0));for(var b=c.subn(1),d=0;!b.testn(d);d++);for(var p=c.shrn(d),x=b.toRed(h);o>0;o--){var m=this._randrange(new t(2),b),v=c.gcd(m);if(v.cmpn(1)!==0)return v;var g=m.toRed(h).redPow(p);if(!(g.cmp(l)===0||g.cmp(x)===0)){for(var $=1;$<d;$++){if(g=g.redSqr(),g.cmp(l)===0)return g.fromRed().subn(1).gcd(c);if(g.cmp(x)===0)break}if($===d)return g=g.redSqr(),g.fromRed().subn(1).gcd(c)}}return!1},mr}var generatePrime,hasRequiredGeneratePrime;function requireGeneratePrime(){if(hasRequiredGeneratePrime)return generatePrime;hasRequiredGeneratePrime=1;var t=requireBrowser$b();generatePrime=$,$.simpleSieve=v,$.fermatTest=g;var e=bnExports,n=new e(24),a=requireMr(),c=new a,o=new e(1),u=new e(2),h=new e(5);new e(16),new e(8);var l=new e(10),b=new e(3);new e(7);var d=new e(11),p=new e(4);new e(12);var x=null;function m(){if(x!==null)return x;var B=1048576,C=[];C[0]=2;for(var F=1,H=3;H<B;H+=2){for(var W=Math.ceil(Math.sqrt(H)),Z=0;Z<F&&C[Z]<=W&&H%C[Z]!==0;Z++);F!==Z&&C[Z]<=W||(C[F++]=H)}return x=C,C}function v(B){for(var C=m(),F=0;F<C.length;F++)if(B.modn(C[F])===0)return B.cmpn(C[F])===0;return!0}function g(B){var C=e.mont(B);return u.toRed(C).redPow(B.subn(1)).fromRed().cmpn(1)===0}function $(B,C){if(B<16)return C===2||C===5?new e([140,123]):new e([140,39]);C=new e(C);for(var F,H;;){for(F=new e(t(Math.ceil(B/8)));F.bitLength()>B;)F.ishrn(1);if(F.isEven()&&F.iadd(o),F.testn(1)||F.iadd(u),C.cmp(u)){if(!C.cmp(h))for(;F.mod(l).cmp(b);)F.iadd(p)}else for(;F.mod(n).cmp(d);)F.iadd(p);if(H=F.shrn(1),v(H)&&v(F)&&g(H)&&g(F)&&c.test(H)&&c.test(F))return F}}return generatePrime}const modp1={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"},require$$1$1={modp1,modp2,modp5,modp14,modp15,modp16,modp17,modp18};var dh,hasRequiredDh;function requireDh(){if(hasRequiredDh)return dh;hasRequiredDh=1;var t=bnExports,e=requireMr(),n=new e,a=new t(24),c=new t(11),o=new t(10),u=new t(3),h=new t(7),l=requireGeneratePrime(),b=requireBrowser$b();dh=v;function d($,B){return B=B||"utf8",Buffer.isBuffer($)||($=new Buffer($,B)),this._pub=new t($),this}function p($,B){return B=B||"utf8",Buffer.isBuffer($)||($=new Buffer($,B)),this._priv=new t($),this}var x={};function m($,B){var C=B.toString("hex"),F=[C,$.toString(16)].join("_");if(F in x)return x[F];var H=0;if($.isEven()||!l.simpleSieve||!l.fermatTest($)||!n.test($))return H+=1,C==="02"||C==="05"?H+=8:H+=4,x[F]=H,H;n.test($.shrn(1))||(H+=2);var W;switch(C){case"02":$.mod(a).cmp(c)&&(H+=8);break;case"05":W=$.mod(o),W.cmp(u)&&W.cmp(h)&&(H+=8);break;default:H+=4}return x[F]=H,H}function v($,B,C){this.setGenerator(B),this.__prime=new t($),this._prime=t.mont(this.__prime),this._primeLen=$.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,C?(this.setPublicKey=d,this.setPrivateKey=p):this._primeCode=8}Object.defineProperty(v.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=m(this.__prime,this.__gen)),this._primeCode}}),v.prototype.generateKeys=function(){return this._priv||(this._priv=new t(b(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},v.prototype.computeSecret=function($){$=new t($),$=$.toRed(this._prime);var B=$.redPow(this._priv).fromRed(),C=new Buffer(B.toArray()),F=this.getPrime();if(C.length<F.length){var H=new Buffer(F.length-C.length);H.fill(0),C=Buffer.concat([H,C])}return C},v.prototype.getPublicKey=function(B){return g(this._pub,B)},v.prototype.getPrivateKey=function(B){return g(this._priv,B)},v.prototype.getPrime=function($){return g(this.__prime,$)},v.prototype.getGenerator=function($){return g(this._gen,$)},v.prototype.setGenerator=function($,B){return B=B||"utf8",Buffer.isBuffer($)||($=new Buffer($,B)),this.__gen=$,this._gen=new t($),this};function g($,B){var C=new Buffer($.toArray());return B?C.toString(B):C}return dh}var hasRequiredBrowser$4;function requireBrowser$4(){if(hasRequiredBrowser$4)return browser$4;hasRequiredBrowser$4=1;var t=requireGeneratePrime(),e=require$$1$1,n=requireDh();function a(u){var h=new Buffer(e[u].prime,"hex"),l=new Buffer(e[u].gen,"hex");return new n(h,l)}var c={binary:!0,hex:!0,base64:!0};function o(u,h,l,b){return Buffer.isBuffer(h)||c[h]===void 0?o(u,"binary",h,l):(h=h||"binary",b=b||"binary",l=l||new Buffer([2]),Buffer.isBuffer(l)||(l=new Buffer(l,b)),typeof u=="number"?new n(t(u,l),l,!0):(Buffer.isBuffer(u)||(u=new Buffer(u,h)),new n(u,l,!0)))}return browser$4.DiffieHellmanGroup=browser$4.createDiffieHellmanGroup=browser$4.getDiffieHellman=a,browser$4.createDiffieHellman=browser$4.DiffieHellman=o,browser$4}var readableBrowser={exports:{}},processNextickArgs={exports:{}},hasRequiredProcessNextickArgs;function requireProcessNextickArgs(){if(hasRequiredProcessNextickArgs)return processNextickArgs.exports;hasRequiredProcessNextickArgs=1,typeof process$1>"u"||!process$1.version||process$1.version.indexOf("v0.")===0||process$1.version.indexOf("v1.")===0&&process$1.version.indexOf("v1.8.")!==0?processNextickArgs.exports={nextTick:t}:processNextickArgs.exports=process$1;function t(e,n,a,c){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var o=arguments.length,u,h;switch(o){case 0:case 1:return process$1.nextTick(e);case 2:return process$1.nextTick(function(){e.call(null,n)});case 3:return process$1.nextTick(function(){e.call(null,n,a)});case 4:return process$1.nextTick(function(){e.call(null,n,a,c)});default:for(u=new Array(o-1),h=0;h<u.length;)u[h++]=arguments[h];return process$1.nextTick(function(){e.apply(null,u)})}}return processNextickArgs.exports}var isarray,hasRequiredIsarray;function requireIsarray(){if(hasRequiredIsarray)return isarray;hasRequiredIsarray=1;var t={}.toString;return isarray=Array.isArray||function(e){return t.call(e)=="[object Array]"},isarray}var streamBrowser,hasRequiredStreamBrowser;function requireStreamBrowser(){return hasRequiredStreamBrowser||(hasRequiredStreamBrowser=1,streamBrowser=requireEvents().EventEmitter),streamBrowser}var safeBuffer={exports:{}},hasRequiredSafeBuffer;function requireSafeBuffer(){return hasRequiredSafeBuffer||(hasRequiredSafeBuffer=1,function(t,e){var n=require$$1$2,a=n.Buffer;function c(u,h){for(var l in u)h[l]=u[l]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=n:(c(n,e),e.Buffer=o);function o(u,h,l){return a(u,h,l)}c(a,o),o.from=function(u,h,l){if(typeof u=="number")throw new TypeError("Argument must not be a number");return a(u,h,l)},o.alloc=function(u,h,l){if(typeof u!="number")throw new TypeError("Argument must be a number");var b=a(u);return h!==void 0?typeof l=="string"?b.fill(h,l):b.fill(h):b.fill(0),b},o.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a(u)},o.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(u)}}(safeBuffer,safeBuffer.exports)),safeBuffer.exports}var util={},hasRequiredUtil;function requireUtil(){if(hasRequiredUtil)return util;hasRequiredUtil=1;function t(g){return Array.isArray?Array.isArray(g):v(g)==="[object Array]"}util.isArray=t;function e(g){return typeof g=="boolean"}util.isBoolean=e;function n(g){return g===null}util.isNull=n;function a(g){return g==null}util.isNullOrUndefined=a;function c(g){return typeof g=="number"}util.isNumber=c;function o(g){return typeof g=="string"}util.isString=o;function u(g){return typeof g=="symbol"}util.isSymbol=u;function h(g){return g===void 0}util.isUndefined=h;function l(g){return v(g)==="[object RegExp]"}util.isRegExp=l;function b(g){return typeof g=="object"&&g!==null}util.isObject=b;function d(g){return v(g)==="[object Date]"}util.isDate=d;function p(g){return v(g)==="[object Error]"||g instanceof Error}util.isError=p;function x(g){return typeof g=="function"}util.isFunction=x;function m(g){return g===null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||typeof g=="symbol"||typeof g>"u"}util.isPrimitive=m,util.isBuffer=require$$1$2.Buffer.isBuffer;function v(g){return Object.prototype.toString.call(g)}return util}var BufferList={exports:{}},hasRequiredBufferList;function requireBufferList(){return hasRequiredBufferList||(hasRequiredBufferList=1,function(t){function e(o,u){if(!(o instanceof u))throw new TypeError("Cannot call a class as a function")}var n=requireSafeBuffer().Buffer,a=requireUtil$1();function c(o,u,h){o.copy(u,h)}t.exports=function(){function o(){e(this,o),this.head=null,this.tail=null,this.length=0}return o.prototype.push=function(h){var l={data:h,next:null};this.length>0?this.tail.next=l:this.head=l,this.tail=l,++this.length},o.prototype.unshift=function(h){var l={data:h,next:this.head};this.length===0&&(this.tail=l),this.head=l,++this.length},o.prototype.shift=function(){if(this.length!==0){var h=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,h}},o.prototype.clear=function(){this.head=this.tail=null,this.length=0},o.prototype.join=function(h){if(this.length===0)return"";for(var l=this.head,b=""+l.data;l=l.next;)b+=h+l.data;return b},o.prototype.concat=function(h){if(this.length===0)return n.alloc(0);for(var l=n.allocUnsafe(h>>>0),b=this.head,d=0;b;)c(b.data,l,d),d+=b.data.length,b=b.next;return l},o}(),a&&a.inspect&&a.inspect.custom&&(t.exports.prototype[a.inspect.custom]=function(){var o=a.inspect({length:this.length});return this.constructor.name+" "+o})}(BufferList)),BufferList.exports}var destroy_1,hasRequiredDestroy;function requireDestroy(){if(hasRequiredDestroy)return destroy_1;hasRequiredDestroy=1;var t=requireProcessNextickArgs();function e(c,o){var u=this,h=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return h||l?(o?o(c):c&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,t.nextTick(a,this,c)):t.nextTick(a,this,c)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(c||null,function(b){!o&&b?u._writableState?u._writableState.errorEmitted||(u._writableState.errorEmitted=!0,t.nextTick(a,u,b)):t.nextTick(a,u,b):o&&o(b)}),this)}function n(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function a(c,o){c.emit("error",o)}return destroy_1={destroy:e,undestroy:n},destroy_1}var _stream_writable,hasRequired_stream_writable;function require_stream_writable(){if(hasRequired_stream_writable)return _stream_writable;hasRequired_stream_writable=1;var t=requireProcessNextickArgs();_stream_writable=g;function e(M){var k=this;this.next=null,this.entry=null,this.finish=function(){I(k,M)}}var n=!process$1.browser&&["v0.10","v0.9."].indexOf(process$1.version.slice(0,5))>-1?setImmediate:t.nextTick,a;g.WritableState=m;var c=Object.create(requireUtil());c.inherits=inherits_browserExports;var o={deprecate:requireBrowser$a()},u=requireStreamBrowser(),h=requireSafeBuffer().Buffer,l=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function b(M){return h.from(M)}function d(M){return h.isBuffer(M)||M instanceof l}var p=requireDestroy();c.inherits(g,u);function x(){}function m(M,k){a=a||require_stream_duplex(),M=M||{};var P=k instanceof a;this.objectMode=!!M.objectMode,P&&(this.objectMode=this.objectMode||!!M.writableObjectMode);var _=M.highWaterMark,q=M.writableHighWaterMark,E=this.objectMode?16:16*1024;_||_===0?this.highWaterMark=_:P&&(q||q===0)?this.highWaterMark=q:this.highWaterMark=E,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var j=M.decodeStrings===!1;this.decodeStrings=!j,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ee){ie(k,ee)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}m.prototype.getBuffer=function(){for(var k=this.bufferedRequest,P=[];k;)P.push(k),k=k.next;return P},function(){try{Object.defineProperty(m.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var v;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(v=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(M){return v.call(this,M)?!0:this!==g?!1:M&&M._writableState instanceof m}})):v=function(M){return M instanceof this};function g(M){if(a=a||require_stream_duplex(),!v.call(g,this)&&!(this instanceof a))return new g(M);this._writableState=new m(M,this),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),u.call(this)}g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function $(M,k){var P=new Error("write after end");M.emit("error",P),t.nextTick(k,P)}function B(M,k,P,_){var q=!0,E=!1;return P===null?E=new TypeError("May not write null values to stream"):typeof P!="string"&&P!==void 0&&!k.objectMode&&(E=new TypeError("Invalid non-string/buffer chunk")),E&&(M.emit("error",E),t.nextTick(_,E),q=!1),q}g.prototype.write=function(M,k,P){var _=this._writableState,q=!1,E=!_.objectMode&&d(M);return E&&!h.isBuffer(M)&&(M=b(M)),typeof k=="function"&&(P=k,k=null),E?k="buffer":k||(k=_.defaultEncoding),typeof P!="function"&&(P=x),_.ended?$(this,P):(E||B(this,_,M,P))&&(_.pendingcb++,q=F(this,_,E,M,k,P)),q},g.prototype.cork=function(){var M=this._writableState;M.corked++},g.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&de(this,M))},g.prototype.setDefaultEncoding=function(k){if(typeof k=="string"&&(k=k.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((k+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+k);return this._writableState.defaultEncoding=k,this};function C(M,k,P){return!M.objectMode&&M.decodeStrings!==!1&&typeof k=="string"&&(k=h.from(k,P)),k}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function F(M,k,P,_,q,E){if(!P){var j=C(k,_,q);_!==j&&(P=!0,q="buffer",_=j)}var ee=k.objectMode?1:_.length;k.length+=ee;var oe=k.length<k.highWaterMark;if(oe||(k.needDrain=!0),k.writing||k.corked){var Y=k.lastBufferedRequest;k.lastBufferedRequest={chunk:_,encoding:q,isBuf:P,callback:E,next:null},Y?Y.next=k.lastBufferedRequest:k.bufferedRequest=k.lastBufferedRequest,k.bufferedRequestCount+=1}else H(M,k,!1,ee,_,q,E);return oe}function H(M,k,P,_,q,E,j){k.writelen=_,k.writecb=j,k.writing=!0,k.sync=!0,P?M._writev(q,k.onwrite):M._write(q,E,k.onwrite),k.sync=!1}function W(M,k,P,_,q){--k.pendingcb,P?(t.nextTick(q,_),t.nextTick(y,M,k),M._writableState.errorEmitted=!0,M.emit("error",_)):(q(_),M._writableState.errorEmitted=!0,M.emit("error",_),y(M,k))}function Z(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function ie(M,k){var P=M._writableState,_=P.sync,q=P.writecb;if(Z(P),k)W(M,P,_,k,q);else{var E=J(P);!E&&!P.corked&&!P.bufferProcessing&&P.bufferedRequest&&de(M,P),_?n(te,M,P,E,q):te(M,P,E,q)}}function te(M,k,P,_){P||ae(M,k),k.pendingcb--,_(),y(M,k)}function ae(M,k){k.length===0&&k.needDrain&&(k.needDrain=!1,M.emit("drain"))}function de(M,k){k.bufferProcessing=!0;var P=k.bufferedRequest;if(M._writev&&P&&P.next){var _=k.bufferedRequestCount,q=new Array(_),E=k.corkedRequestsFree;E.entry=P;for(var j=0,ee=!0;P;)q[j]=P,P.isBuf||(ee=!1),P=P.next,j+=1;q.allBuffers=ee,H(M,k,!0,k.length,q,"",E.finish),k.pendingcb++,k.lastBufferedRequest=null,E.next?(k.corkedRequestsFree=E.next,E.next=null):k.corkedRequestsFree=new e(k),k.bufferedRequestCount=0}else{for(;P;){var oe=P.chunk,Y=P.encoding,L=P.callback,z=k.objectMode?1:oe.length;if(H(M,k,!1,z,oe,Y,L),P=P.next,k.bufferedRequestCount--,k.writing)break}P===null&&(k.lastBufferedRequest=null)}k.bufferedRequest=P,k.bufferProcessing=!1}g.prototype._write=function(M,k,P){P(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(M,k,P){var _=this._writableState;typeof M=="function"?(P=M,M=null,k=null):typeof k=="function"&&(P=k,k=null),M!=null&&this.write(M,k),_.corked&&(_.corked=1,this.uncork()),_.ending||w(this,_,P)};function J(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function R(M,k){M._final(function(P){k.pendingcb--,P&&M.emit("error",P),k.prefinished=!0,M.emit("prefinish"),y(M,k)})}function A(M,k){!k.prefinished&&!k.finalCalled&&(typeof M._final=="function"?(k.pendingcb++,k.finalCalled=!0,t.nextTick(R,M,k)):(k.prefinished=!0,M.emit("prefinish")))}function y(M,k){var P=J(k);return P&&(A(M,k),k.pendingcb===0&&(k.finished=!0,M.emit("finish"))),P}function w(M,k,P){k.ending=!0,y(M,k),P&&(k.finished?t.nextTick(P):M.once("finish",P)),k.ended=!0,M.writable=!1}function I(M,k,P){var _=M.entry;for(M.entry=null;_;){var q=_.callback;k.pendingcb--,q(P),_=_.next}k.corkedRequestsFree.next=M}return Object.defineProperty(g.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(M){this._writableState&&(this._writableState.destroyed=M)}}),g.prototype.destroy=p.destroy,g.prototype._undestroy=p.undestroy,g.prototype._destroy=function(M,k){this.end(),k(M)},_stream_writable}var _stream_duplex,hasRequired_stream_duplex;function require_stream_duplex(){if(hasRequired_stream_duplex)return _stream_duplex;hasRequired_stream_duplex=1;var t=requireProcessNextickArgs(),e=Object.keys||function(p){var x=[];for(var m in p)x.push(m);return x};_stream_duplex=l;var n=Object.create(requireUtil());n.inherits=inherits_browserExports;var a=require_stream_readable(),c=require_stream_writable();n.inherits(l,a);for(var o=e(c.prototype),u=0;u<o.length;u++){var h=o[u];l.prototype[h]||(l.prototype[h]=c.prototype[h])}function l(p){if(!(this instanceof l))return new l(p);a.call(this,p),c.call(this,p),p&&p.readable===!1&&(this.readable=!1),p&&p.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,p&&p.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",b)}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function b(){this.allowHalfOpen||this._writableState.ended||t.nextTick(d,this)}function d(p){p.end()}return Object.defineProperty(l.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(p){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=p,this._writableState.destroyed=p)}}),l.prototype._destroy=function(p,x){this.push(null),this.end(),t.nextTick(x,p)},_stream_duplex}var _stream_readable,hasRequired_stream_readable;function require_stream_readable(){if(hasRequired_stream_readable)return _stream_readable;hasRequired_stream_readable=1;var t=requireProcessNextickArgs();_stream_readable=C;var e=requireIsarray(),n;C.ReadableState=B,requireEvents().EventEmitter;var a=function(L,z){return L.listeners(z).length},c=requireStreamBrowser(),o=requireSafeBuffer().Buffer,u=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function h(L){return o.from(L)}function l(L){return o.isBuffer(L)||L instanceof u}var b=Object.create(requireUtil());b.inherits=inherits_browserExports;var d=requireUtil$1(),p=void 0;d&&d.debuglog?p=d.debuglog("stream"):p=function(){};var x=requireBufferList(),m=requireDestroy(),v;b.inherits(C,c);var g=["error","close","destroy","pause","resume"];function $(L,z,re){if(typeof L.prependListener=="function")return L.prependListener(z,re);!L._events||!L._events[z]?L.on(z,re):e(L._events[z])?L._events[z].unshift(re):L._events[z]=[re,L._events[z]]}function B(L,z){n=n||require_stream_duplex(),L=L||{};var re=z instanceof n;this.objectMode=!!L.objectMode,re&&(this.objectMode=this.objectMode||!!L.readableObjectMode);var D=L.highWaterMark,G=L.readableHighWaterMark,U=this.objectMode?16:16*1024;D||D===0?this.highWaterMark=D:re&&(G||G===0)?this.highWaterMark=G:this.highWaterMark=U,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new x,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=L.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,L.encoding&&(v||(v=requireString_decoder().StringDecoder),this.decoder=new v(L.encoding),this.encoding=L.encoding)}function C(L){if(n=n||require_stream_duplex(),!(this instanceof C))return new C(L);this._readableState=new B(L,this),this.readable=!0,L&&(typeof L.read=="function"&&(this._read=L.read),typeof L.destroy=="function"&&(this._destroy=L.destroy)),c.call(this)}Object.defineProperty(C.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(L){this._readableState&&(this._readableState.destroyed=L)}}),C.prototype.destroy=m.destroy,C.prototype._undestroy=m.undestroy,C.prototype._destroy=function(L,z){this.push(null),z(L)},C.prototype.push=function(L,z){var re=this._readableState,D;return re.objectMode?D=!0:typeof L=="string"&&(z=z||re.defaultEncoding,z!==re.encoding&&(L=o.from(L,z),z=""),D=!0),F(this,L,z,!1,D)},C.prototype.unshift=function(L){return F(this,L,null,!0,!1)};function F(L,z,re,D,G){var U=L._readableState;if(z===null)U.reading=!1,de(L,U);else{var Q;G||(Q=W(U,z)),Q?L.emit("error",Q):U.objectMode||z&&z.length>0?(typeof z!="string"&&!U.objectMode&&Object.getPrototypeOf(z)!==o.prototype&&(z=h(z)),D?U.endEmitted?L.emit("error",new Error("stream.unshift() after end event")):H(L,U,z,!0):U.ended?L.emit("error",new Error("stream.push() after EOF")):(U.reading=!1,U.decoder&&!re?(z=U.decoder.write(z),U.objectMode||z.length!==0?H(L,U,z,!1):A(L,U)):H(L,U,z,!1))):D||(U.reading=!1)}return Z(U)}function H(L,z,re,D){z.flowing&&z.length===0&&!z.sync?(L.emit("data",re),L.read(0)):(z.length+=z.objectMode?1:re.length,D?z.buffer.unshift(re):z.buffer.push(re),z.needReadable&&J(L)),A(L,z)}function W(L,z){var re;return!l(z)&&typeof z!="string"&&z!==void 0&&!L.objectMode&&(re=new TypeError("Invalid non-string/buffer chunk")),re}function Z(L){return!L.ended&&(L.needReadable||L.length<L.highWaterMark||L.length===0)}C.prototype.isPaused=function(){return this._readableState.flowing===!1},C.prototype.setEncoding=function(L){return v||(v=requireString_decoder().StringDecoder),this._readableState.decoder=new v(L),this._readableState.encoding=L,this};var ie=8388608;function te(L){return L>=ie?L=ie:(L--,L|=L>>>1,L|=L>>>2,L|=L>>>4,L|=L>>>8,L|=L>>>16,L++),L}function ae(L,z){return L<=0||z.length===0&&z.ended?0:z.objectMode?1:L!==L?z.flowing&&z.length?z.buffer.head.data.length:z.length:(L>z.highWaterMark&&(z.highWaterMark=te(L)),L<=z.length?L:z.ended?z.length:(z.needReadable=!0,0))}C.prototype.read=function(L){p("read",L),L=parseInt(L,10);var z=this._readableState,re=L;if(L!==0&&(z.emittedReadable=!1),L===0&&z.needReadable&&(z.length>=z.highWaterMark||z.ended))return p("read: emitReadable",z.length,z.ended),z.length===0&&z.ended?ee(this):J(this),null;if(L=ae(L,z),L===0&&z.ended)return z.length===0&&ee(this),null;var D=z.needReadable;p("need readable",D),(z.length===0||z.length-L<z.highWaterMark)&&(D=!0,p("length less than watermark",D)),z.ended||z.reading?(D=!1,p("reading or ended",D)):D&&(p("do read"),z.reading=!0,z.sync=!0,z.length===0&&(z.needReadable=!0),this._read(z.highWaterMark),z.sync=!1,z.reading||(L=ae(re,z)));var G;return L>0?G=_(L,z):G=null,G===null?(z.needReadable=!0,L=0):z.length-=L,z.length===0&&(z.ended||(z.needReadable=!0),re!==L&&z.ended&&ee(this)),G!==null&&this.emit("data",G),G};function de(L,z){if(!z.ended){if(z.decoder){var re=z.decoder.end();re&&re.length&&(z.buffer.push(re),z.length+=z.objectMode?1:re.length)}z.ended=!0,J(L)}}function J(L){var z=L._readableState;z.needReadable=!1,z.emittedReadable||(p("emitReadable",z.flowing),z.emittedReadable=!0,z.sync?t.nextTick(R,L):R(L))}function R(L){p("emit readable"),L.emit("readable"),P(L)}function A(L,z){z.readingMore||(z.readingMore=!0,t.nextTick(y,L,z))}function y(L,z){for(var re=z.length;!z.reading&&!z.flowing&&!z.ended&&z.length<z.highWaterMark&&(p("maybeReadMore read 0"),L.read(0),re!==z.length);)re=z.length;z.readingMore=!1}C.prototype._read=function(L){this.emit("error",new Error("_read() is not implemented"))},C.prototype.pipe=function(L,z){var re=this,D=this._readableState;switch(D.pipesCount){case 0:D.pipes=L;break;case 1:D.pipes=[D.pipes,L];break;default:D.pipes.push(L);break}D.pipesCount+=1,p("pipe count=%d opts=%j",D.pipesCount,z);var G=(!z||z.end!==!1)&&L!==process$1.stdout&&L!==process$1.stderr,U=G?fe:Ne;D.endEmitted?t.nextTick(U):re.once("end",U),L.on("unpipe",Q);function Q(ve,Be){p("onunpipe"),ve===re&&Be&&Be.hasUnpiped===!1&&(Be.hasUnpiped=!0,pe())}function fe(){p("onend"),L.end()}var he=w(re);L.on("drain",he);var le=!1;function pe(){p("cleanup"),L.removeListener("close",ye),L.removeListener("finish",$e),L.removeListener("drain",he),L.removeListener("error",ge),L.removeListener("unpipe",Q),re.removeListener("end",fe),re.removeListener("end",Ne),re.removeListener("data",se),le=!0,D.awaitDrain&&(!L._writableState||L._writableState.needDrain)&&he()}var be=!1;re.on("data",se);function se(ve){p("ondata"),be=!1;var Be=L.write(ve);Be===!1&&!be&&((D.pipesCount===1&&D.pipes===L||D.pipesCount>1&&Y(D.pipes,L)!==-1)&&!le&&(p("false write response, pause",D.awaitDrain),D.awaitDrain++,be=!0),re.pause())}function ge(ve){p("onerror",ve),Ne(),L.removeListener("error",ge),a(L,"error")===0&&L.emit("error",ve)}$(L,"error",ge);function ye(){L.removeListener("finish",$e),Ne()}L.once("close",ye);function $e(){p("onfinish"),L.removeListener("close",ye),Ne()}L.once("finish",$e);function Ne(){p("unpipe"),re.unpipe(L)}return L.emit("pipe",re),D.flowing||(p("pipe resume"),re.resume()),L};function w(L){return function(){var z=L._readableState;p("pipeOnDrain",z.awaitDrain),z.awaitDrain&&z.awaitDrain--,z.awaitDrain===0&&a(L,"data")&&(z.flowing=!0,P(L))}}C.prototype.unpipe=function(L){var z=this._readableState,re={hasUnpiped:!1};if(z.pipesCount===0)return this;if(z.pipesCount===1)return L&&L!==z.pipes?this:(L||(L=z.pipes),z.pipes=null,z.pipesCount=0,z.flowing=!1,L&&L.emit("unpipe",this,re),this);if(!L){var D=z.pipes,G=z.pipesCount;z.pipes=null,z.pipesCount=0,z.flowing=!1;for(var U=0;U<G;U++)D[U].emit("unpipe",this,{hasUnpiped:!1});return this}var Q=Y(z.pipes,L);return Q===-1?this:(z.pipes.splice(Q,1),z.pipesCount-=1,z.pipesCount===1&&(z.pipes=z.pipes[0]),L.emit("unpipe",this,re),this)},C.prototype.on=function(L,z){var re=c.prototype.on.call(this,L,z);if(L==="data")this._readableState.flowing!==!1&&this.resume();else if(L==="readable"){var D=this._readableState;!D.endEmitted&&!D.readableListening&&(D.readableListening=D.needReadable=!0,D.emittedReadable=!1,D.reading?D.length&&J(this):t.nextTick(I,this))}return re},C.prototype.addListener=C.prototype.on;function I(L){p("readable nexttick read 0"),L.read(0)}C.prototype.resume=function(){var L=this._readableState;return L.flowing||(p("resume"),L.flowing=!0,M(this,L)),this};function M(L,z){z.resumeScheduled||(z.resumeScheduled=!0,t.nextTick(k,L,z))}function k(L,z){z.reading||(p("resume read 0"),L.read(0)),z.resumeScheduled=!1,z.awaitDrain=0,L.emit("resume"),P(L),z.flowing&&!z.reading&&L.read(0)}C.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function P(L){var z=L._readableState;for(p("flow",z.flowing);z.flowing&&L.read()!==null;);}C.prototype.wrap=function(L){var z=this,re=this._readableState,D=!1;L.on("end",function(){if(p("wrapped end"),re.decoder&&!re.ended){var Q=re.decoder.end();Q&&Q.length&&z.push(Q)}z.push(null)}),L.on("data",function(Q){if(p("wrapped data"),re.decoder&&(Q=re.decoder.write(Q)),!(re.objectMode&&Q==null)&&!(!re.objectMode&&(!Q||!Q.length))){var fe=z.push(Q);fe||(D=!0,L.pause())}});for(var G in L)this[G]===void 0&&typeof L[G]=="function"&&(this[G]=function(Q){return function(){return L[Q].apply(L,arguments)}}(G));for(var U=0;U<g.length;U++)L.on(g[U],this.emit.bind(this,g[U]));return this._read=function(Q){p("wrapped _read",Q),D&&(D=!1,L.resume())},this},Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),C._fromList=_;function _(L,z){if(z.length===0)return null;var re;return z.objectMode?re=z.buffer.shift():!L||L>=z.length?(z.decoder?re=z.buffer.join(""):z.buffer.length===1?re=z.buffer.head.data:re=z.buffer.concat(z.length),z.buffer.clear()):re=q(L,z.buffer,z.decoder),re}function q(L,z,re){var D;return L<z.head.data.length?(D=z.head.data.slice(0,L),z.head.data=z.head.data.slice(L)):L===z.head.data.length?D=z.shift():D=re?E(L,z):j(L,z),D}function E(L,z){var re=z.head,D=1,G=re.data;for(L-=G.length;re=re.next;){var U=re.data,Q=L>U.length?U.length:L;if(Q===U.length?G+=U:G+=U.slice(0,L),L-=Q,L===0){Q===U.length?(++D,re.next?z.head=re.next:z.head=z.tail=null):(z.head=re,re.data=U.slice(Q));break}++D}return z.length-=D,G}function j(L,z){var re=o.allocUnsafe(L),D=z.head,G=1;for(D.data.copy(re),L-=D.data.length;D=D.next;){var U=D.data,Q=L>U.length?U.length:L;if(U.copy(re,re.length-L,0,Q),L-=Q,L===0){Q===U.length?(++G,D.next?z.head=D.next:z.head=z.tail=null):(z.head=D,D.data=U.slice(Q));break}++G}return z.length-=G,re}function ee(L){var z=L._readableState;if(z.length>0)throw new Error('"endReadable()" called on non-empty stream');z.endEmitted||(z.ended=!0,t.nextTick(oe,z,L))}function oe(L,z){!L.endEmitted&&L.length===0&&(L.endEmitted=!0,z.readable=!1,z.emit("end"))}function Y(L,z){for(var re=0,D=L.length;re<D;re++)if(L[re]===z)return re;return-1}return _stream_readable}var _stream_transform,hasRequired_stream_transform;function require_stream_transform(){if(hasRequired_stream_transform)return _stream_transform;hasRequired_stream_transform=1,_stream_transform=a;var t=require_stream_duplex(),e=Object.create(requireUtil());e.inherits=inherits_browserExports,e.inherits(a,t);function n(u,h){var l=this._transformState;l.transforming=!1;var b=l.writecb;if(!b)return this.emit("error",new Error("write callback called multiple times"));l.writechunk=null,l.writecb=null,h!=null&&this.push(h),b(u);var d=this._readableState;d.reading=!1,(d.needReadable||d.length<d.highWaterMark)&&this._read(d.highWaterMark)}function a(u){if(!(this instanceof a))return new a(u);t.call(this,u),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,u&&(typeof u.transform=="function"&&(this._transform=u.transform),typeof u.flush=="function"&&(this._flush=u.flush)),this.on("prefinish",c)}function c(){var u=this;typeof this._flush=="function"?this._flush(function(h,l){o(u,h,l)}):o(this,null,null)}a.prototype.push=function(u,h){return this._transformState.needTransform=!1,t.prototype.push.call(this,u,h)},a.prototype._transform=function(u,h,l){throw new Error("_transform() is not implemented")},a.prototype._write=function(u,h,l){var b=this._transformState;if(b.writecb=l,b.writechunk=u,b.writeencoding=h,!b.transforming){var d=this._readableState;(b.needTransform||d.needReadable||d.length<d.highWaterMark)&&this._read(d.highWaterMark)}},a.prototype._read=function(u){var h=this._transformState;h.writechunk!==null&&h.writecb&&!h.transforming?(h.transforming=!0,this._transform(h.writechunk,h.writeencoding,h.afterTransform)):h.needTransform=!0},a.prototype._destroy=function(u,h){var l=this;t.prototype._destroy.call(this,u,function(b){h(b),l.emit("close")})};function o(u,h,l){if(h)return u.emit("error",h);if(l!=null&&u.push(l),u._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(u._transformState.transforming)throw new Error("Calling transform done when still transforming");return u.push(null)}return _stream_transform}var _stream_passthrough,hasRequired_stream_passthrough;function require_stream_passthrough(){if(hasRequired_stream_passthrough)return _stream_passthrough;hasRequired_stream_passthrough=1,_stream_passthrough=n;var t=require_stream_transform(),e=Object.create(requireUtil());e.inherits=inherits_browserExports,e.inherits(n,t);function n(a){if(!(this instanceof n))return new n(a);t.call(this,a)}return n.prototype._transform=function(a,c,o){o(null,a)},_stream_passthrough}var hasRequiredReadableBrowser;function requireReadableBrowser(){return hasRequiredReadableBrowser||(hasRequiredReadableBrowser=1,function(t,e){e=t.exports=require_stream_readable(),e.Stream=e,e.Readable=e,e.Writable=require_stream_writable(),e.Duplex=require_stream_duplex(),e.Transform=require_stream_transform(),e.PassThrough=require_stream_passthrough()}(readableBrowser,readableBrowser.exports)),readableBrowser.exports}var sign$1={exports:{}},bn={exports:{}};bn.exports;var hasRequiredBn;function requireBn(){return hasRequiredBn||(hasRequiredBn=1,function(t){(function(e,n){function a(A,y){if(!A)throw new Error(y||"Assertion failed")}function c(A,y){A.super_=y;var w=function(){};w.prototype=y.prototype,A.prototype=new w,A.prototype.constructor=A}function o(A,y,w){if(o.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((y==="le"||y==="be")&&(w=y,y=10),this._init(A||0,y||10,w||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var u;try{typeof window<"u"&&typeof window.Buffer<"u"?u=window.Buffer:u=require$$1$2.Buffer}catch{}o.isBN=function(y){return y instanceof o?!0:y!==null&&typeof y=="object"&&y.constructor.wordSize===o.wordSize&&Array.isArray(y.words)},o.max=function(y,w){return y.cmp(w)>0?y:w},o.min=function(y,w){return y.cmp(w)<0?y:w},o.prototype._init=function(y,w,I){if(typeof y=="number")return this._initNumber(y,w,I);if(typeof y=="object")return this._initArray(y,w,I);w==="hex"&&(w=16),a(w===(w|0)&&w>=2&&w<=36),y=y.toString().replace(/\s+/g,"");var M=0;y[0]==="-"&&(M++,this.negative=1),M<y.length&&(w===16?this._parseHex(y,M,I):(this._parseBase(y,w,M),I==="le"&&this._initArray(this.toArray(),w,I)))},o.prototype._initNumber=function(y,w,I){y<0&&(this.negative=1,y=-y),y<67108864?(this.words=[y&67108863],this.length=1):y<4503599627370496?(this.words=[y&67108863,y/67108864&67108863],this.length=2):(a(y<9007199254740992),this.words=[y&67108863,y/67108864&67108863,1],this.length=3),I==="le"&&this._initArray(this.toArray(),w,I)},o.prototype._initArray=function(y,w,I){if(a(typeof y.length=="number"),y.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(y.length/3),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var k,P,_=0;if(I==="be")for(M=y.length-1,k=0;M>=0;M-=3)P=y[M]|y[M-1]<<8|y[M-2]<<16,this.words[k]|=P<<_&67108863,this.words[k+1]=P>>>26-_&67108863,_+=24,_>=26&&(_-=26,k++);else if(I==="le")for(M=0,k=0;M<y.length;M+=3)P=y[M]|y[M+1]<<8|y[M+2]<<16,this.words[k]|=P<<_&67108863,this.words[k+1]=P>>>26-_&67108863,_+=24,_>=26&&(_-=26,k++);return this._strip()};function h(A,y){var w=A.charCodeAt(y);if(w>=48&&w<=57)return w-48;if(w>=65&&w<=70)return w-55;if(w>=97&&w<=102)return w-87;a(!1,"Invalid character in "+A)}function l(A,y,w){var I=h(A,w);return w-1>=y&&(I|=h(A,w-1)<<4),I}o.prototype._parseHex=function(y,w,I){this.length=Math.ceil((y.length-w)/6),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var k=0,P=0,_;if(I==="be")for(M=y.length-1;M>=w;M-=2)_=l(y,w,M)<<k,this.words[P]|=_&67108863,k>=18?(k-=18,P+=1,this.words[P]|=_>>>26):k+=8;else{var q=y.length-w;for(M=q%2===0?w+1:w;M<y.length;M+=2)_=l(y,w,M)<<k,this.words[P]|=_&67108863,k>=18?(k-=18,P+=1,this.words[P]|=_>>>26):k+=8}this._strip()};function b(A,y,w,I){for(var M=0,k=0,P=Math.min(A.length,w),_=y;_<P;_++){var q=A.charCodeAt(_)-48;M*=I,q>=49?k=q-49+10:q>=17?k=q-17+10:k=q,a(q>=0&&k<I,"Invalid character"),M+=k}return M}o.prototype._parseBase=function(y,w,I){this.words=[0],this.length=1;for(var M=0,k=1;k<=67108863;k*=w)M++;M--,k=k/w|0;for(var P=y.length-I,_=P%M,q=Math.min(P,P-_)+I,E=0,j=I;j<q;j+=M)E=b(y,j,j+M,w),this.imuln(k),this.words[0]+E<67108864?this.words[0]+=E:this._iaddn(E);if(_!==0){var ee=1;for(E=b(y,j,y.length,w),j=0;j<_;j++)ee*=w;this.imuln(ee),this.words[0]+E<67108864?this.words[0]+=E:this._iaddn(E)}this._strip()},o.prototype.copy=function(y){y.words=new Array(this.length);for(var w=0;w<this.length;w++)y.words[w]=this.words[w];y.length=this.length,y.negative=this.negative,y.red=this.red};function d(A,y){A.words=y.words,A.length=y.length,A.negative=y.negative,A.red=y.red}if(o.prototype._move=function(y){d(y,this)},o.prototype.clone=function(){var y=new o(null);return this.copy(y),y},o.prototype._expand=function(y){for(;this.length<y;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=p}catch{o.prototype.inspect=p}else o.prototype.inspect=p;function p(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(y,w){y=y||10,w=w|0||1;var I;if(y===16||y==="hex"){I="";for(var M=0,k=0,P=0;P<this.length;P++){var _=this.words[P],q=((_<<M|k)&16777215).toString(16);k=_>>>24-M&16777215,M+=2,M>=26&&(M-=26,P--),k!==0||P!==this.length-1?I=x[6-q.length]+q+I:I=q+I}for(k!==0&&(I=k.toString(16)+I);I.length%w!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}if(y===(y|0)&&y>=2&&y<=36){var E=m[y],j=v[y];I="";var ee=this.clone();for(ee.negative=0;!ee.isZero();){var oe=ee.modrn(j).toString(y);ee=ee.idivn(j),ee.isZero()?I=oe+I:I=x[E-oe.length]+oe+I}for(this.isZero()&&(I="0"+I);I.length%w!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}a(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var y=this.words[0];return this.length===2?y+=this.words[1]*67108864:this.length===3&&this.words[2]===1?y+=4503599627370496+this.words[1]*67108864:this.length>2&&a(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-y:y},o.prototype.toJSON=function(){return this.toString(16,2)},u&&(o.prototype.toBuffer=function(y,w){return this.toArrayLike(u,y,w)}),o.prototype.toArray=function(y,w){return this.toArrayLike(Array,y,w)};var g=function(y,w){return y.allocUnsafe?y.allocUnsafe(w):new y(w)};o.prototype.toArrayLike=function(y,w,I){this._strip();var M=this.byteLength(),k=I||Math.max(1,M);a(M<=k,"byte array longer than desired length"),a(k>0,"Requested array length <= 0");var P=g(y,k),_=w==="le"?"LE":"BE";return this["_toArrayLike"+_](P,M),P},o.prototype._toArrayLikeLE=function(y,w){for(var I=0,M=0,k=0,P=0;k<this.length;k++){var _=this.words[k]<<P|M;y[I++]=_&255,I<y.length&&(y[I++]=_>>8&255),I<y.length&&(y[I++]=_>>16&255),P===6?(I<y.length&&(y[I++]=_>>24&255),M=0,P=0):(M=_>>>24,P+=2)}if(I<y.length)for(y[I++]=M;I<y.length;)y[I++]=0},o.prototype._toArrayLikeBE=function(y,w){for(var I=y.length-1,M=0,k=0,P=0;k<this.length;k++){var _=this.words[k]<<P|M;y[I--]=_&255,I>=0&&(y[I--]=_>>8&255),I>=0&&(y[I--]=_>>16&255),P===6?(I>=0&&(y[I--]=_>>24&255),M=0,P=0):(M=_>>>24,P+=2)}if(I>=0)for(y[I--]=M;I>=0;)y[I--]=0},Math.clz32?o.prototype._countBits=function(y){return 32-Math.clz32(y)}:o.prototype._countBits=function(y){var w=y,I=0;return w>=4096&&(I+=13,w>>>=13),w>=64&&(I+=7,w>>>=7),w>=8&&(I+=4,w>>>=4),w>=2&&(I+=2,w>>>=2),I+w},o.prototype._zeroBits=function(y){if(y===0)return 26;var w=y,I=0;return w&8191||(I+=13,w>>>=13),w&127||(I+=7,w>>>=7),w&15||(I+=4,w>>>=4),w&3||(I+=2,w>>>=2),w&1||I++,I},o.prototype.bitLength=function(){var y=this.words[this.length-1],w=this._countBits(y);return(this.length-1)*26+w};function $(A){for(var y=new Array(A.bitLength()),w=0;w<y.length;w++){var I=w/26|0,M=w%26;y[w]=A.words[I]>>>M&1}return y}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var y=0,w=0;w<this.length;w++){var I=this._zeroBits(this.words[w]);if(y+=I,I!==26)break}return y},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(y){return this.negative!==0?this.abs().inotn(y).iaddn(1):this.clone()},o.prototype.fromTwos=function(y){return this.testn(y-1)?this.notn(y).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(y){for(;this.length<y.length;)this.words[this.length++]=0;for(var w=0;w<y.length;w++)this.words[w]=this.words[w]|y.words[w];return this._strip()},o.prototype.ior=function(y){return a((this.negative|y.negative)===0),this.iuor(y)},o.prototype.or=function(y){return this.length>y.length?this.clone().ior(y):y.clone().ior(this)},o.prototype.uor=function(y){return this.length>y.length?this.clone().iuor(y):y.clone().iuor(this)},o.prototype.iuand=function(y){var w;this.length>y.length?w=y:w=this;for(var I=0;I<w.length;I++)this.words[I]=this.words[I]&y.words[I];return this.length=w.length,this._strip()},o.prototype.iand=function(y){return a((this.negative|y.negative)===0),this.iuand(y)},o.prototype.and=function(y){return this.length>y.length?this.clone().iand(y):y.clone().iand(this)},o.prototype.uand=function(y){return this.length>y.length?this.clone().iuand(y):y.clone().iuand(this)},o.prototype.iuxor=function(y){var w,I;this.length>y.length?(w=this,I=y):(w=y,I=this);for(var M=0;M<I.length;M++)this.words[M]=w.words[M]^I.words[M];if(this!==w)for(;M<w.length;M++)this.words[M]=w.words[M];return this.length=w.length,this._strip()},o.prototype.ixor=function(y){return a((this.negative|y.negative)===0),this.iuxor(y)},o.prototype.xor=function(y){return this.length>y.length?this.clone().ixor(y):y.clone().ixor(this)},o.prototype.uxor=function(y){return this.length>y.length?this.clone().iuxor(y):y.clone().iuxor(this)},o.prototype.inotn=function(y){a(typeof y=="number"&&y>=0);var w=Math.ceil(y/26)|0,I=y%26;this._expand(w),I>0&&w--;for(var M=0;M<w;M++)this.words[M]=~this.words[M]&67108863;return I>0&&(this.words[M]=~this.words[M]&67108863>>26-I),this._strip()},o.prototype.notn=function(y){return this.clone().inotn(y)},o.prototype.setn=function(y,w){a(typeof y=="number"&&y>=0);var I=y/26|0,M=y%26;return this._expand(I+1),w?this.words[I]=this.words[I]|1<<M:this.words[I]=this.words[I]&~(1<<M),this._strip()},o.prototype.iadd=function(y){var w;if(this.negative!==0&&y.negative===0)return this.negative=0,w=this.isub(y),this.negative^=1,this._normSign();if(this.negative===0&&y.negative!==0)return y.negative=0,w=this.isub(y),y.negative=1,w._normSign();var I,M;this.length>y.length?(I=this,M=y):(I=y,M=this);for(var k=0,P=0;P<M.length;P++)w=(I.words[P]|0)+(M.words[P]|0)+k,this.words[P]=w&67108863,k=w>>>26;for(;k!==0&&P<I.length;P++)w=(I.words[P]|0)+k,this.words[P]=w&67108863,k=w>>>26;if(this.length=I.length,k!==0)this.words[this.length]=k,this.length++;else if(I!==this)for(;P<I.length;P++)this.words[P]=I.words[P];return this},o.prototype.add=function(y){var w;return y.negative!==0&&this.negative===0?(y.negative=0,w=this.sub(y),y.negative^=1,w):y.negative===0&&this.negative!==0?(this.negative=0,w=y.sub(this),this.negative=1,w):this.length>y.length?this.clone().iadd(y):y.clone().iadd(this)},o.prototype.isub=function(y){if(y.negative!==0){y.negative=0;var w=this.iadd(y);return y.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(y),this.negative=1,this._normSign();var I=this.cmp(y);if(I===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,k;I>0?(M=this,k=y):(M=y,k=this);for(var P=0,_=0;_<k.length;_++)w=(M.words[_]|0)-(k.words[_]|0)+P,P=w>>26,this.words[_]=w&67108863;for(;P!==0&&_<M.length;_++)w=(M.words[_]|0)+P,P=w>>26,this.words[_]=w&67108863;if(P===0&&_<M.length&&M!==this)for(;_<M.length;_++)this.words[_]=M.words[_];return this.length=Math.max(this.length,_),M!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(y){return this.clone().isub(y)};function B(A,y,w){w.negative=y.negative^A.negative;var I=A.length+y.length|0;w.length=I,I=I-1|0;var M=A.words[0]|0,k=y.words[0]|0,P=M*k,_=P&67108863,q=P/67108864|0;w.words[0]=_;for(var E=1;E<I;E++){for(var j=q>>>26,ee=q&67108863,oe=Math.min(E,y.length-1),Y=Math.max(0,E-A.length+1);Y<=oe;Y++){var L=E-Y|0;M=A.words[L]|0,k=y.words[Y]|0,P=M*k+ee,j+=P/67108864|0,ee=P&67108863}w.words[E]=ee|0,q=j|0}return q!==0?w.words[E]=q|0:w.length--,w._strip()}var C=function(y,w,I){var M=y.words,k=w.words,P=I.words,_=0,q,E,j,ee=M[0]|0,oe=ee&8191,Y=ee>>>13,L=M[1]|0,z=L&8191,re=L>>>13,D=M[2]|0,G=D&8191,U=D>>>13,Q=M[3]|0,fe=Q&8191,he=Q>>>13,le=M[4]|0,pe=le&8191,be=le>>>13,se=M[5]|0,ge=se&8191,ye=se>>>13,$e=M[6]|0,Ne=$e&8191,ve=$e>>>13,Be=M[7]|0,De=Be&8191,Se=Be>>>13,Oe=M[8]|0,je=Oe&8191,V=Oe>>>13,T=M[9]|0,O=T&8191,X=T>>>13,ne=k[0]|0,ce=ne&8191,ue=ne>>>13,me=k[1]|0,Ee=me&8191,xe=me>>>13,Ae=k[2]|0,_e=Ae&8191,Me=Ae>>>13,ze=k[3]|0,Ve=ze&8191,Ie=ze>>>13,We=k[4]|0,Je=We&8191,Pe=We>>>13,Ze=k[5]|0,Xe=Ze&8191,Te=Ze>>>13,Ye=k[6]|0,Qe=Ye&8191,ke=Ye>>>13,et=k[7]|0,tt=et&8191,qe=et>>>13,rt=k[8]|0,it=rt&8191,Ce=rt>>>13,nt=k[9]|0,Ge=nt&8191,Ke=nt>>>13;I.negative=y.negative^w.negative,I.length=19,q=Math.imul(oe,ce),E=Math.imul(oe,ue),E=E+Math.imul(Y,ce)|0,j=Math.imul(Y,ue);var ct=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(ct>>>26)|0,ct&=67108863,q=Math.imul(z,ce),E=Math.imul(z,ue),E=E+Math.imul(re,ce)|0,j=Math.imul(re,ue),q=q+Math.imul(oe,Ee)|0,E=E+Math.imul(oe,xe)|0,E=E+Math.imul(Y,Ee)|0,j=j+Math.imul(Y,xe)|0;var dt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(dt>>>26)|0,dt&=67108863,q=Math.imul(G,ce),E=Math.imul(G,ue),E=E+Math.imul(U,ce)|0,j=Math.imul(U,ue),q=q+Math.imul(z,Ee)|0,E=E+Math.imul(z,xe)|0,E=E+Math.imul(re,Ee)|0,j=j+Math.imul(re,xe)|0,q=q+Math.imul(oe,_e)|0,E=E+Math.imul(oe,Me)|0,E=E+Math.imul(Y,_e)|0,j=j+Math.imul(Y,Me)|0;var ht=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(ht>>>26)|0,ht&=67108863,q=Math.imul(fe,ce),E=Math.imul(fe,ue),E=E+Math.imul(he,ce)|0,j=Math.imul(he,ue),q=q+Math.imul(G,Ee)|0,E=E+Math.imul(G,xe)|0,E=E+Math.imul(U,Ee)|0,j=j+Math.imul(U,xe)|0,q=q+Math.imul(z,_e)|0,E=E+Math.imul(z,Me)|0,E=E+Math.imul(re,_e)|0,j=j+Math.imul(re,Me)|0,q=q+Math.imul(oe,Ve)|0,E=E+Math.imul(oe,Ie)|0,E=E+Math.imul(Y,Ve)|0,j=j+Math.imul(Y,Ie)|0;var lt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(lt>>>26)|0,lt&=67108863,q=Math.imul(pe,ce),E=Math.imul(pe,ue),E=E+Math.imul(be,ce)|0,j=Math.imul(be,ue),q=q+Math.imul(fe,Ee)|0,E=E+Math.imul(fe,xe)|0,E=E+Math.imul(he,Ee)|0,j=j+Math.imul(he,xe)|0,q=q+Math.imul(G,_e)|0,E=E+Math.imul(G,Me)|0,E=E+Math.imul(U,_e)|0,j=j+Math.imul(U,Me)|0,q=q+Math.imul(z,Ve)|0,E=E+Math.imul(z,Ie)|0,E=E+Math.imul(re,Ve)|0,j=j+Math.imul(re,Ie)|0,q=q+Math.imul(oe,Je)|0,E=E+Math.imul(oe,Pe)|0,E=E+Math.imul(Y,Je)|0,j=j+Math.imul(Y,Pe)|0;var pt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(pt>>>26)|0,pt&=67108863,q=Math.imul(ge,ce),E=Math.imul(ge,ue),E=E+Math.imul(ye,ce)|0,j=Math.imul(ye,ue),q=q+Math.imul(pe,Ee)|0,E=E+Math.imul(pe,xe)|0,E=E+Math.imul(be,Ee)|0,j=j+Math.imul(be,xe)|0,q=q+Math.imul(fe,_e)|0,E=E+Math.imul(fe,Me)|0,E=E+Math.imul(he,_e)|0,j=j+Math.imul(he,Me)|0,q=q+Math.imul(G,Ve)|0,E=E+Math.imul(G,Ie)|0,E=E+Math.imul(U,Ve)|0,j=j+Math.imul(U,Ie)|0,q=q+Math.imul(z,Je)|0,E=E+Math.imul(z,Pe)|0,E=E+Math.imul(re,Je)|0,j=j+Math.imul(re,Pe)|0,q=q+Math.imul(oe,Xe)|0,E=E+Math.imul(oe,Te)|0,E=E+Math.imul(Y,Xe)|0,j=j+Math.imul(Y,Te)|0;var bt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(bt>>>26)|0,bt&=67108863,q=Math.imul(Ne,ce),E=Math.imul(Ne,ue),E=E+Math.imul(ve,ce)|0,j=Math.imul(ve,ue),q=q+Math.imul(ge,Ee)|0,E=E+Math.imul(ge,xe)|0,E=E+Math.imul(ye,Ee)|0,j=j+Math.imul(ye,xe)|0,q=q+Math.imul(pe,_e)|0,E=E+Math.imul(pe,Me)|0,E=E+Math.imul(be,_e)|0,j=j+Math.imul(be,Me)|0,q=q+Math.imul(fe,Ve)|0,E=E+Math.imul(fe,Ie)|0,E=E+Math.imul(he,Ve)|0,j=j+Math.imul(he,Ie)|0,q=q+Math.imul(G,Je)|0,E=E+Math.imul(G,Pe)|0,E=E+Math.imul(U,Je)|0,j=j+Math.imul(U,Pe)|0,q=q+Math.imul(z,Xe)|0,E=E+Math.imul(z,Te)|0,E=E+Math.imul(re,Xe)|0,j=j+Math.imul(re,Te)|0,q=q+Math.imul(oe,Qe)|0,E=E+Math.imul(oe,ke)|0,E=E+Math.imul(Y,Qe)|0,j=j+Math.imul(Y,ke)|0;var xt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(xt>>>26)|0,xt&=67108863,q=Math.imul(De,ce),E=Math.imul(De,ue),E=E+Math.imul(Se,ce)|0,j=Math.imul(Se,ue),q=q+Math.imul(Ne,Ee)|0,E=E+Math.imul(Ne,xe)|0,E=E+Math.imul(ve,Ee)|0,j=j+Math.imul(ve,xe)|0,q=q+Math.imul(ge,_e)|0,E=E+Math.imul(ge,Me)|0,E=E+Math.imul(ye,_e)|0,j=j+Math.imul(ye,Me)|0,q=q+Math.imul(pe,Ve)|0,E=E+Math.imul(pe,Ie)|0,E=E+Math.imul(be,Ve)|0,j=j+Math.imul(be,Ie)|0,q=q+Math.imul(fe,Je)|0,E=E+Math.imul(fe,Pe)|0,E=E+Math.imul(he,Je)|0,j=j+Math.imul(he,Pe)|0,q=q+Math.imul(G,Xe)|0,E=E+Math.imul(G,Te)|0,E=E+Math.imul(U,Xe)|0,j=j+Math.imul(U,Te)|0,q=q+Math.imul(z,Qe)|0,E=E+Math.imul(z,ke)|0,E=E+Math.imul(re,Qe)|0,j=j+Math.imul(re,ke)|0,q=q+Math.imul(oe,tt)|0,E=E+Math.imul(oe,qe)|0,E=E+Math.imul(Y,tt)|0,j=j+Math.imul(Y,qe)|0;var yt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(yt>>>26)|0,yt&=67108863,q=Math.imul(je,ce),E=Math.imul(je,ue),E=E+Math.imul(V,ce)|0,j=Math.imul(V,ue),q=q+Math.imul(De,Ee)|0,E=E+Math.imul(De,xe)|0,E=E+Math.imul(Se,Ee)|0,j=j+Math.imul(Se,xe)|0,q=q+Math.imul(Ne,_e)|0,E=E+Math.imul(Ne,Me)|0,E=E+Math.imul(ve,_e)|0,j=j+Math.imul(ve,Me)|0,q=q+Math.imul(ge,Ve)|0,E=E+Math.imul(ge,Ie)|0,E=E+Math.imul(ye,Ve)|0,j=j+Math.imul(ye,Ie)|0,q=q+Math.imul(pe,Je)|0,E=E+Math.imul(pe,Pe)|0,E=E+Math.imul(be,Je)|0,j=j+Math.imul(be,Pe)|0,q=q+Math.imul(fe,Xe)|0,E=E+Math.imul(fe,Te)|0,E=E+Math.imul(he,Xe)|0,j=j+Math.imul(he,Te)|0,q=q+Math.imul(G,Qe)|0,E=E+Math.imul(G,ke)|0,E=E+Math.imul(U,Qe)|0,j=j+Math.imul(U,ke)|0,q=q+Math.imul(z,tt)|0,E=E+Math.imul(z,qe)|0,E=E+Math.imul(re,tt)|0,j=j+Math.imul(re,qe)|0,q=q+Math.imul(oe,it)|0,E=E+Math.imul(oe,Ce)|0,E=E+Math.imul(Y,it)|0,j=j+Math.imul(Y,Ce)|0;var mt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(mt>>>26)|0,mt&=67108863,q=Math.imul(O,ce),E=Math.imul(O,ue),E=E+Math.imul(X,ce)|0,j=Math.imul(X,ue),q=q+Math.imul(je,Ee)|0,E=E+Math.imul(je,xe)|0,E=E+Math.imul(V,Ee)|0,j=j+Math.imul(V,xe)|0,q=q+Math.imul(De,_e)|0,E=E+Math.imul(De,Me)|0,E=E+Math.imul(Se,_e)|0,j=j+Math.imul(Se,Me)|0,q=q+Math.imul(Ne,Ve)|0,E=E+Math.imul(Ne,Ie)|0,E=E+Math.imul(ve,Ve)|0,j=j+Math.imul(ve,Ie)|0,q=q+Math.imul(ge,Je)|0,E=E+Math.imul(ge,Pe)|0,E=E+Math.imul(ye,Je)|0,j=j+Math.imul(ye,Pe)|0,q=q+Math.imul(pe,Xe)|0,E=E+Math.imul(pe,Te)|0,E=E+Math.imul(be,Xe)|0,j=j+Math.imul(be,Te)|0,q=q+Math.imul(fe,Qe)|0,E=E+Math.imul(fe,ke)|0,E=E+Math.imul(he,Qe)|0,j=j+Math.imul(he,ke)|0,q=q+Math.imul(G,tt)|0,E=E+Math.imul(G,qe)|0,E=E+Math.imul(U,tt)|0,j=j+Math.imul(U,qe)|0,q=q+Math.imul(z,it)|0,E=E+Math.imul(z,Ce)|0,E=E+Math.imul(re,it)|0,j=j+Math.imul(re,Ce)|0,q=q+Math.imul(oe,Ge)|0,E=E+Math.imul(oe,Ke)|0,E=E+Math.imul(Y,Ge)|0,j=j+Math.imul(Y,Ke)|0;var vt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(vt>>>26)|0,vt&=67108863,q=Math.imul(O,Ee),E=Math.imul(O,xe),E=E+Math.imul(X,Ee)|0,j=Math.imul(X,xe),q=q+Math.imul(je,_e)|0,E=E+Math.imul(je,Me)|0,E=E+Math.imul(V,_e)|0,j=j+Math.imul(V,Me)|0,q=q+Math.imul(De,Ve)|0,E=E+Math.imul(De,Ie)|0,E=E+Math.imul(Se,Ve)|0,j=j+Math.imul(Se,Ie)|0,q=q+Math.imul(Ne,Je)|0,E=E+Math.imul(Ne,Pe)|0,E=E+Math.imul(ve,Je)|0,j=j+Math.imul(ve,Pe)|0,q=q+Math.imul(ge,Xe)|0,E=E+Math.imul(ge,Te)|0,E=E+Math.imul(ye,Xe)|0,j=j+Math.imul(ye,Te)|0,q=q+Math.imul(pe,Qe)|0,E=E+Math.imul(pe,ke)|0,E=E+Math.imul(be,Qe)|0,j=j+Math.imul(be,ke)|0,q=q+Math.imul(fe,tt)|0,E=E+Math.imul(fe,qe)|0,E=E+Math.imul(he,tt)|0,j=j+Math.imul(he,qe)|0,q=q+Math.imul(G,it)|0,E=E+Math.imul(G,Ce)|0,E=E+Math.imul(U,it)|0,j=j+Math.imul(U,Ce)|0,q=q+Math.imul(z,Ge)|0,E=E+Math.imul(z,Ke)|0,E=E+Math.imul(re,Ge)|0,j=j+Math.imul(re,Ke)|0;var qt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(qt>>>26)|0,qt&=67108863,q=Math.imul(O,_e),E=Math.imul(O,Me),E=E+Math.imul(X,_e)|0,j=Math.imul(X,Me),q=q+Math.imul(je,Ve)|0,E=E+Math.imul(je,Ie)|0,E=E+Math.imul(V,Ve)|0,j=j+Math.imul(V,Ie)|0,q=q+Math.imul(De,Je)|0,E=E+Math.imul(De,Pe)|0,E=E+Math.imul(Se,Je)|0,j=j+Math.imul(Se,Pe)|0,q=q+Math.imul(Ne,Xe)|0,E=E+Math.imul(Ne,Te)|0,E=E+Math.imul(ve,Xe)|0,j=j+Math.imul(ve,Te)|0,q=q+Math.imul(ge,Qe)|0,E=E+Math.imul(ge,ke)|0,E=E+Math.imul(ye,Qe)|0,j=j+Math.imul(ye,ke)|0,q=q+Math.imul(pe,tt)|0,E=E+Math.imul(pe,qe)|0,E=E+Math.imul(be,tt)|0,j=j+Math.imul(be,qe)|0,q=q+Math.imul(fe,it)|0,E=E+Math.imul(fe,Ce)|0,E=E+Math.imul(he,it)|0,j=j+Math.imul(he,Ce)|0,q=q+Math.imul(G,Ge)|0,E=E+Math.imul(G,Ke)|0,E=E+Math.imul(U,Ge)|0,j=j+Math.imul(U,Ke)|0;var Ct=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,q=Math.imul(O,Ve),E=Math.imul(O,Ie),E=E+Math.imul(X,Ve)|0,j=Math.imul(X,Ie),q=q+Math.imul(je,Je)|0,E=E+Math.imul(je,Pe)|0,E=E+Math.imul(V,Je)|0,j=j+Math.imul(V,Pe)|0,q=q+Math.imul(De,Xe)|0,E=E+Math.imul(De,Te)|0,E=E+Math.imul(Se,Xe)|0,j=j+Math.imul(Se,Te)|0,q=q+Math.imul(Ne,Qe)|0,E=E+Math.imul(Ne,ke)|0,E=E+Math.imul(ve,Qe)|0,j=j+Math.imul(ve,ke)|0,q=q+Math.imul(ge,tt)|0,E=E+Math.imul(ge,qe)|0,E=E+Math.imul(ye,tt)|0,j=j+Math.imul(ye,qe)|0,q=q+Math.imul(pe,it)|0,E=E+Math.imul(pe,Ce)|0,E=E+Math.imul(be,it)|0,j=j+Math.imul(be,Ce)|0,q=q+Math.imul(fe,Ge)|0,E=E+Math.imul(fe,Ke)|0,E=E+Math.imul(he,Ge)|0,j=j+Math.imul(he,Ke)|0;var Nt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,q=Math.imul(O,Je),E=Math.imul(O,Pe),E=E+Math.imul(X,Je)|0,j=Math.imul(X,Pe),q=q+Math.imul(je,Xe)|0,E=E+Math.imul(je,Te)|0,E=E+Math.imul(V,Xe)|0,j=j+Math.imul(V,Te)|0,q=q+Math.imul(De,Qe)|0,E=E+Math.imul(De,ke)|0,E=E+Math.imul(Se,Qe)|0,j=j+Math.imul(Se,ke)|0,q=q+Math.imul(Ne,tt)|0,E=E+Math.imul(Ne,qe)|0,E=E+Math.imul(ve,tt)|0,j=j+Math.imul(ve,qe)|0,q=q+Math.imul(ge,it)|0,E=E+Math.imul(ge,Ce)|0,E=E+Math.imul(ye,it)|0,j=j+Math.imul(ye,Ce)|0,q=q+Math.imul(pe,Ge)|0,E=E+Math.imul(pe,Ke)|0,E=E+Math.imul(be,Ge)|0,j=j+Math.imul(be,Ke)|0;var Ot=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,q=Math.imul(O,Xe),E=Math.imul(O,Te),E=E+Math.imul(X,Xe)|0,j=Math.imul(X,Te),q=q+Math.imul(je,Qe)|0,E=E+Math.imul(je,ke)|0,E=E+Math.imul(V,Qe)|0,j=j+Math.imul(V,ke)|0,q=q+Math.imul(De,tt)|0,E=E+Math.imul(De,qe)|0,E=E+Math.imul(Se,tt)|0,j=j+Math.imul(Se,qe)|0,q=q+Math.imul(Ne,it)|0,E=E+Math.imul(Ne,Ce)|0,E=E+Math.imul(ve,it)|0,j=j+Math.imul(ve,Ce)|0,q=q+Math.imul(ge,Ge)|0,E=E+Math.imul(ge,Ke)|0,E=E+Math.imul(ye,Ge)|0,j=j+Math.imul(ye,Ke)|0;var Dt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,q=Math.imul(O,Qe),E=Math.imul(O,ke),E=E+Math.imul(X,Qe)|0,j=Math.imul(X,ke),q=q+Math.imul(je,tt)|0,E=E+Math.imul(je,qe)|0,E=E+Math.imul(V,tt)|0,j=j+Math.imul(V,qe)|0,q=q+Math.imul(De,it)|0,E=E+Math.imul(De,Ce)|0,E=E+Math.imul(Se,it)|0,j=j+Math.imul(Se,Ce)|0,q=q+Math.imul(Ne,Ge)|0,E=E+Math.imul(Ne,Ke)|0,E=E+Math.imul(ve,Ge)|0,j=j+Math.imul(ve,Ke)|0;var Lt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,q=Math.imul(O,tt),E=Math.imul(O,qe),E=E+Math.imul(X,tt)|0,j=Math.imul(X,qe),q=q+Math.imul(je,it)|0,E=E+Math.imul(je,Ce)|0,E=E+Math.imul(V,it)|0,j=j+Math.imul(V,Ce)|0,q=q+Math.imul(De,Ge)|0,E=E+Math.imul(De,Ke)|0,E=E+Math.imul(Se,Ge)|0,j=j+Math.imul(Se,Ke)|0;var Ft=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,q=Math.imul(O,it),E=Math.imul(O,Ce),E=E+Math.imul(X,it)|0,j=Math.imul(X,Ce),q=q+Math.imul(je,Ge)|0,E=E+Math.imul(je,Ke)|0,E=E+Math.imul(V,Ge)|0,j=j+Math.imul(V,Ke)|0;var pr=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(pr>>>26)|0,pr&=67108863,q=Math.imul(O,Ge),E=Math.imul(O,Ke),E=E+Math.imul(X,Ge)|0,j=Math.imul(X,Ke);var br=(_+q|0)+((E&8191)<<13)|0;return _=(j+(E>>>13)|0)+(br>>>26)|0,br&=67108863,P[0]=ct,P[1]=dt,P[2]=ht,P[3]=lt,P[4]=pt,P[5]=bt,P[6]=xt,P[7]=yt,P[8]=mt,P[9]=vt,P[10]=qt,P[11]=Ct,P[12]=Nt,P[13]=Ot,P[14]=Dt,P[15]=Lt,P[16]=Ft,P[17]=pr,P[18]=br,_!==0&&(P[19]=_,I.length++),I};Math.imul||(C=B);function F(A,y,w){w.negative=y.negative^A.negative,w.length=A.length+y.length;for(var I=0,M=0,k=0;k<w.length-1;k++){var P=M;M=0;for(var _=I&67108863,q=Math.min(k,y.length-1),E=Math.max(0,k-A.length+1);E<=q;E++){var j=k-E,ee=A.words[j]|0,oe=y.words[E]|0,Y=ee*oe,L=Y&67108863;P=P+(Y/67108864|0)|0,L=L+_|0,_=L&67108863,P=P+(L>>>26)|0,M+=P>>>26,P&=67108863}w.words[k]=_,I=P,P=M}return I!==0?w.words[k]=I:w.length--,w._strip()}function H(A,y,w){return F(A,y,w)}o.prototype.mulTo=function(y,w){var I,M=this.length+y.length;return this.length===10&&y.length===10?I=C(this,y,w):M<63?I=B(this,y,w):M<1024?I=F(this,y,w):I=H(this,y,w),I},o.prototype.mul=function(y){var w=new o(null);return w.words=new Array(this.length+y.length),this.mulTo(y,w)},o.prototype.mulf=function(y){var w=new o(null);return w.words=new Array(this.length+y.length),H(this,y,w)},o.prototype.imul=function(y){return this.clone().mulTo(y,this)},o.prototype.imuln=function(y){var w=y<0;w&&(y=-y),a(typeof y=="number"),a(y<67108864);for(var I=0,M=0;M<this.length;M++){var k=(this.words[M]|0)*y,P=(k&67108863)+(I&67108863);I>>=26,I+=k/67108864|0,I+=P>>>26,this.words[M]=P&67108863}return I!==0&&(this.words[M]=I,this.length++),w?this.ineg():this},o.prototype.muln=function(y){return this.clone().imuln(y)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(y){var w=$(y);if(w.length===0)return new o(1);for(var I=this,M=0;M<w.length&&w[M]===0;M++,I=I.sqr());if(++M<w.length)for(var k=I.sqr();M<w.length;M++,k=k.sqr())w[M]!==0&&(I=I.mul(k));return I},o.prototype.iushln=function(y){a(typeof y=="number"&&y>=0);var w=y%26,I=(y-w)/26,M=67108863>>>26-w<<26-w,k;if(w!==0){var P=0;for(k=0;k<this.length;k++){var _=this.words[k]&M,q=(this.words[k]|0)-_<<w;this.words[k]=q|P,P=_>>>26-w}P&&(this.words[k]=P,this.length++)}if(I!==0){for(k=this.length-1;k>=0;k--)this.words[k+I]=this.words[k];for(k=0;k<I;k++)this.words[k]=0;this.length+=I}return this._strip()},o.prototype.ishln=function(y){return a(this.negative===0),this.iushln(y)},o.prototype.iushrn=function(y,w,I){a(typeof y=="number"&&y>=0);var M;w?M=(w-w%26)/26:M=0;var k=y%26,P=Math.min((y-k)/26,this.length),_=67108863^67108863>>>k<<k,q=I;if(M-=P,M=Math.max(0,M),q){for(var E=0;E<P;E++)q.words[E]=this.words[E];q.length=P}if(P!==0)if(this.length>P)for(this.length-=P,E=0;E<this.length;E++)this.words[E]=this.words[E+P];else this.words[0]=0,this.length=1;var j=0;for(E=this.length-1;E>=0&&(j!==0||E>=M);E--){var ee=this.words[E]|0;this.words[E]=j<<26-k|ee>>>k,j=ee&_}return q&&j!==0&&(q.words[q.length++]=j),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(y,w,I){return a(this.negative===0),this.iushrn(y,w,I)},o.prototype.shln=function(y){return this.clone().ishln(y)},o.prototype.ushln=function(y){return this.clone().iushln(y)},o.prototype.shrn=function(y){return this.clone().ishrn(y)},o.prototype.ushrn=function(y){return this.clone().iushrn(y)},o.prototype.testn=function(y){a(typeof y=="number"&&y>=0);var w=y%26,I=(y-w)/26,M=1<<w;if(this.length<=I)return!1;var k=this.words[I];return!!(k&M)},o.prototype.imaskn=function(y){a(typeof y=="number"&&y>=0);var w=y%26,I=(y-w)/26;if(a(this.negative===0,"imaskn works only with positive numbers"),this.length<=I)return this;if(w!==0&&I++,this.length=Math.min(I,this.length),w!==0){var M=67108863^67108863>>>w<<w;this.words[this.length-1]&=M}return this._strip()},o.prototype.maskn=function(y){return this.clone().imaskn(y)},o.prototype.iaddn=function(y){return a(typeof y=="number"),a(y<67108864),y<0?this.isubn(-y):this.negative!==0?this.length===1&&(this.words[0]|0)<=y?(this.words[0]=y-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(y),this.negative=1,this):this._iaddn(y)},o.prototype._iaddn=function(y){this.words[0]+=y;for(var w=0;w<this.length&&this.words[w]>=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},o.prototype.isubn=function(y){if(a(typeof y=="number"),a(y<67108864),y<0)return this.iaddn(-y);if(this.negative!==0)return this.negative=0,this.iaddn(y),this.negative=1,this;if(this.words[0]-=y,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w<this.length&&this.words[w]<0;w++)this.words[w]+=67108864,this.words[w+1]-=1;return this._strip()},o.prototype.addn=function(y){return this.clone().iaddn(y)},o.prototype.subn=function(y){return this.clone().isubn(y)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(y,w,I){var M=y.length+I,k;this._expand(M);var P,_=0;for(k=0;k<y.length;k++){P=(this.words[k+I]|0)+_;var q=(y.words[k]|0)*w;P-=q&67108863,_=(P>>26)-(q/67108864|0),this.words[k+I]=P&67108863}for(;k<this.length-I;k++)P=(this.words[k+I]|0)+_,_=P>>26,this.words[k+I]=P&67108863;if(_===0)return this._strip();for(a(_===-1),_=0,k=0;k<this.length;k++)P=-(this.words[k]|0)+_,_=P>>26,this.words[k]=P&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(y,w){var I=this.length-y.length,M=this.clone(),k=y,P=k.words[k.length-1]|0,_=this._countBits(P);I=26-_,I!==0&&(k=k.ushln(I),M.iushln(I),P=k.words[k.length-1]|0);var q=M.length-k.length,E;if(w!=="mod"){E=new o(null),E.length=q+1,E.words=new Array(E.length);for(var j=0;j<E.length;j++)E.words[j]=0}var ee=M.clone()._ishlnsubmul(k,1,q);ee.negative===0&&(M=ee,E&&(E.words[q]=1));for(var oe=q-1;oe>=0;oe--){var Y=(M.words[k.length+oe]|0)*67108864+(M.words[k.length+oe-1]|0);for(Y=Math.min(Y/P|0,67108863),M._ishlnsubmul(k,Y,oe);M.negative!==0;)Y--,M.negative=0,M._ishlnsubmul(k,1,oe),M.isZero()||(M.negative^=1);E&&(E.words[oe]=Y)}return E&&E._strip(),M._strip(),w!=="div"&&I!==0&&M.iushrn(I),{div:E||null,mod:M}},o.prototype.divmod=function(y,w,I){if(a(!y.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var M,k,P;return this.negative!==0&&y.negative===0?(P=this.neg().divmod(y,w),w!=="mod"&&(M=P.div.neg()),w!=="div"&&(k=P.mod.neg(),I&&k.negative!==0&&k.iadd(y)),{div:M,mod:k}):this.negative===0&&y.negative!==0?(P=this.divmod(y.neg(),w),w!=="mod"&&(M=P.div.neg()),{div:M,mod:P.mod}):this.negative&y.negative?(P=this.neg().divmod(y.neg(),w),w!=="div"&&(k=P.mod.neg(),I&&k.negative!==0&&k.isub(y)),{div:P.div,mod:k}):y.length>this.length||this.cmp(y)<0?{div:new o(0),mod:this}:y.length===1?w==="div"?{div:this.divn(y.words[0]),mod:null}:w==="mod"?{div:null,mod:new o(this.modrn(y.words[0]))}:{div:this.divn(y.words[0]),mod:new o(this.modrn(y.words[0]))}:this._wordDiv(y,w)},o.prototype.div=function(y){return this.divmod(y,"div",!1).div},o.prototype.mod=function(y){return this.divmod(y,"mod",!1).mod},o.prototype.umod=function(y){return this.divmod(y,"mod",!0).mod},o.prototype.divRound=function(y){var w=this.divmod(y);if(w.mod.isZero())return w.div;var I=w.div.negative!==0?w.mod.isub(y):w.mod,M=y.ushrn(1),k=y.andln(1),P=I.cmp(M);return P<0||k===1&&P===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},o.prototype.modrn=function(y){var w=y<0;w&&(y=-y),a(y<=67108863);for(var I=(1<<26)%y,M=0,k=this.length-1;k>=0;k--)M=(I*M+(this.words[k]|0))%y;return w?-M:M},o.prototype.modn=function(y){return this.modrn(y)},o.prototype.idivn=function(y){var w=y<0;w&&(y=-y),a(y<=67108863);for(var I=0,M=this.length-1;M>=0;M--){var k=(this.words[M]|0)+I*67108864;this.words[M]=k/y|0,I=k%y}return this._strip(),w?this.ineg():this},o.prototype.divn=function(y){return this.clone().idivn(y)},o.prototype.egcd=function(y){a(y.negative===0),a(!y.isZero());var w=this,I=y.clone();w.negative!==0?w=w.umod(y):w=w.clone();for(var M=new o(1),k=new o(0),P=new o(0),_=new o(1),q=0;w.isEven()&&I.isEven();)w.iushrn(1),I.iushrn(1),++q;for(var E=I.clone(),j=w.clone();!w.isZero();){for(var ee=0,oe=1;!(w.words[0]&oe)&&ee<26;++ee,oe<<=1);if(ee>0)for(w.iushrn(ee);ee-- >0;)(M.isOdd()||k.isOdd())&&(M.iadd(E),k.isub(j)),M.iushrn(1),k.iushrn(1);for(var Y=0,L=1;!(I.words[0]&L)&&Y<26;++Y,L<<=1);if(Y>0)for(I.iushrn(Y);Y-- >0;)(P.isOdd()||_.isOdd())&&(P.iadd(E),_.isub(j)),P.iushrn(1),_.iushrn(1);w.cmp(I)>=0?(w.isub(I),M.isub(P),k.isub(_)):(I.isub(w),P.isub(M),_.isub(k))}return{a:P,b:_,gcd:I.iushln(q)}},o.prototype._invmp=function(y){a(y.negative===0),a(!y.isZero());var w=this,I=y.clone();w.negative!==0?w=w.umod(y):w=w.clone();for(var M=new o(1),k=new o(0),P=I.clone();w.cmpn(1)>0&&I.cmpn(1)>0;){for(var _=0,q=1;!(w.words[0]&q)&&_<26;++_,q<<=1);if(_>0)for(w.iushrn(_);_-- >0;)M.isOdd()&&M.iadd(P),M.iushrn(1);for(var E=0,j=1;!(I.words[0]&j)&&E<26;++E,j<<=1);if(E>0)for(I.iushrn(E);E-- >0;)k.isOdd()&&k.iadd(P),k.iushrn(1);w.cmp(I)>=0?(w.isub(I),M.isub(k)):(I.isub(w),k.isub(M))}var ee;return w.cmpn(1)===0?ee=M:ee=k,ee.cmpn(0)<0&&ee.iadd(y),ee},o.prototype.gcd=function(y){if(this.isZero())return y.abs();if(y.isZero())return this.abs();var w=this.clone(),I=y.clone();w.negative=0,I.negative=0;for(var M=0;w.isEven()&&I.isEven();M++)w.iushrn(1),I.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;I.isEven();)I.iushrn(1);var k=w.cmp(I);if(k<0){var P=w;w=I,I=P}else if(k===0||I.cmpn(1)===0)break;w.isub(I)}while(!0);return I.iushln(M)},o.prototype.invm=function(y){return this.egcd(y).a.umod(y)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(y){return this.words[0]&y},o.prototype.bincn=function(y){a(typeof y=="number");var w=y%26,I=(y-w)/26,M=1<<w;if(this.length<=I)return this._expand(I+1),this.words[I]|=M,this;for(var k=M,P=I;k!==0&&P<this.length;P++){var _=this.words[P]|0;_+=k,k=_>>>26,_&=67108863,this.words[P]=_}return k!==0&&(this.words[P]=k,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(y){var w=y<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this._strip();var I;if(this.length>1)I=1;else{w&&(y=-y),a(y<=67108863,"Number is too big");var M=this.words[0]|0;I=M===y?0:M<y?-1:1}return this.negative!==0?-I|0:I},o.prototype.cmp=function(y){if(this.negative!==0&&y.negative===0)return-1;if(this.negative===0&&y.negative!==0)return 1;var w=this.ucmp(y);return this.negative!==0?-w|0:w},o.prototype.ucmp=function(y){if(this.length>y.length)return 1;if(this.length<y.length)return-1;for(var w=0,I=this.length-1;I>=0;I--){var M=this.words[I]|0,k=y.words[I]|0;if(M!==k){M<k?w=-1:M>k&&(w=1);break}}return w},o.prototype.gtn=function(y){return this.cmpn(y)===1},o.prototype.gt=function(y){return this.cmp(y)===1},o.prototype.gten=function(y){return this.cmpn(y)>=0},o.prototype.gte=function(y){return this.cmp(y)>=0},o.prototype.ltn=function(y){return this.cmpn(y)===-1},o.prototype.lt=function(y){return this.cmp(y)===-1},o.prototype.lten=function(y){return this.cmpn(y)<=0},o.prototype.lte=function(y){return this.cmp(y)<=0},o.prototype.eqn=function(y){return this.cmpn(y)===0},o.prototype.eq=function(y){return this.cmp(y)===0},o.red=function(y){return new J(y)},o.prototype.toRed=function(y){return a(!this.red,"Already a number in reduction context"),a(this.negative===0,"red works only with positives"),y.convertTo(this)._forceRed(y)},o.prototype.fromRed=function(){return a(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(y){return this.red=y,this},o.prototype.forceRed=function(y){return a(!this.red,"Already a number in reduction context"),this._forceRed(y)},o.prototype.redAdd=function(y){return a(this.red,"redAdd works only with red numbers"),this.red.add(this,y)},o.prototype.redIAdd=function(y){return a(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,y)},o.prototype.redSub=function(y){return a(this.red,"redSub works only with red numbers"),this.red.sub(this,y)},o.prototype.redISub=function(y){return a(this.red,"redISub works only with red numbers"),this.red.isub(this,y)},o.prototype.redShl=function(y){return a(this.red,"redShl works only with red numbers"),this.red.shl(this,y)},o.prototype.redMul=function(y){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,y),this.red.mul(this,y)},o.prototype.redIMul=function(y){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,y),this.red.imul(this,y)},o.prototype.redSqr=function(){return a(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return a(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return a(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return a(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return a(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(y){return a(this.red&&!y.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,y)};var W={k256:null,p224:null,p192:null,p25519:null};function Z(A,y){this.name=A,this.p=new o(y,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Z.prototype._tmp=function(){var y=new o(null);return y.words=new Array(Math.ceil(this.n/13)),y},Z.prototype.ireduce=function(y){var w=y,I;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),I=w.bitLength();while(I>this.n);var M=I<this.n?-1:w.ucmp(this.p);return M===0?(w.words[0]=0,w.length=1):M>0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},Z.prototype.split=function(y,w){y.iushrn(this.n,0,w)},Z.prototype.imulK=function(y){return y.imul(this.k)};function ie(){Z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}c(ie,Z),ie.prototype.split=function(y,w){for(var I=4194303,M=Math.min(y.length,9),k=0;k<M;k++)w.words[k]=y.words[k];if(w.length=M,y.length<=9){y.words[0]=0,y.length=1;return}var P=y.words[9];for(w.words[w.length++]=P&I,k=10;k<y.length;k++){var _=y.words[k]|0;y.words[k-10]=(_&I)<<4|P>>>22,P=_}P>>>=22,y.words[k-10]=P,P===0&&y.length>10?y.length-=10:y.length-=9},ie.prototype.imulK=function(y){y.words[y.length]=0,y.words[y.length+1]=0,y.length+=2;for(var w=0,I=0;I<y.length;I++){var M=y.words[I]|0;w+=M*977,y.words[I]=w&67108863,w=M*64+(w/67108864|0)}return y.words[y.length-1]===0&&(y.length--,y.words[y.length-1]===0&&y.length--),y};function te(){Z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}c(te,Z);function ae(){Z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}c(ae,Z);function de(){Z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}c(de,Z),de.prototype.imulK=function(y){for(var w=0,I=0;I<y.length;I++){var M=(y.words[I]|0)*19+w,k=M&67108863;M>>>=26,y.words[I]=k,w=M}return w!==0&&(y.words[y.length++]=w),y},o._prime=function(y){if(W[y])return W[y];var w;if(y==="k256")w=new ie;else if(y==="p224")w=new te;else if(y==="p192")w=new ae;else if(y==="p25519")w=new de;else throw new Error("Unknown prime "+y);return W[y]=w,w};function J(A){if(typeof A=="string"){var y=o._prime(A);this.m=y.p,this.prime=y}else a(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}J.prototype._verify1=function(y){a(y.negative===0,"red works only with positives"),a(y.red,"red works only with red numbers")},J.prototype._verify2=function(y,w){a((y.negative|w.negative)===0,"red works only with positives"),a(y.red&&y.red===w.red,"red works only with red numbers")},J.prototype.imod=function(y){return this.prime?this.prime.ireduce(y)._forceRed(this):(d(y,y.umod(this.m)._forceRed(this)),y)},J.prototype.neg=function(y){return y.isZero()?y.clone():this.m.sub(y)._forceRed(this)},J.prototype.add=function(y,w){this._verify2(y,w);var I=y.add(w);return I.cmp(this.m)>=0&&I.isub(this.m),I._forceRed(this)},J.prototype.iadd=function(y,w){this._verify2(y,w);var I=y.iadd(w);return I.cmp(this.m)>=0&&I.isub(this.m),I},J.prototype.sub=function(y,w){this._verify2(y,w);var I=y.sub(w);return I.cmpn(0)<0&&I.iadd(this.m),I._forceRed(this)},J.prototype.isub=function(y,w){this._verify2(y,w);var I=y.isub(w);return I.cmpn(0)<0&&I.iadd(this.m),I},J.prototype.shl=function(y,w){return this._verify1(y),this.imod(y.ushln(w))},J.prototype.imul=function(y,w){return this._verify2(y,w),this.imod(y.imul(w))},J.prototype.mul=function(y,w){return this._verify2(y,w),this.imod(y.mul(w))},J.prototype.isqr=function(y){return this.imul(y,y.clone())},J.prototype.sqr=function(y){return this.mul(y,y)},J.prototype.sqrt=function(y){if(y.isZero())return y.clone();var w=this.m.andln(3);if(a(w%2===1),w===3){var I=this.m.add(new o(1)).iushrn(2);return this.pow(y,I)}for(var M=this.m.subn(1),k=0;!M.isZero()&&M.andln(1)===0;)k++,M.iushrn(1);a(!M.isZero());var P=new o(1).toRed(this),_=P.redNeg(),q=this.m.subn(1).iushrn(1),E=this.m.bitLength();for(E=new o(2*E*E).toRed(this);this.pow(E,q).cmp(_)!==0;)E.redIAdd(_);for(var j=this.pow(E,M),ee=this.pow(y,M.addn(1).iushrn(1)),oe=this.pow(y,M),Y=k;oe.cmp(P)!==0;){for(var L=oe,z=0;L.cmp(P)!==0;z++)L=L.redSqr();a(z<Y);var re=this.pow(j,new o(1).iushln(Y-z-1));ee=ee.redMul(re),j=re.redSqr(),oe=oe.redMul(j),Y=z}return ee},J.prototype.invm=function(y){var w=y._invmp(this.m);return w.negative!==0?(w.negative=0,this.imod(w).redNeg()):this.imod(w)},J.prototype.pow=function(y,w){if(w.isZero())return new o(1).toRed(this);if(w.cmpn(1)===0)return y.clone();var I=4,M=new Array(1<<I);M[0]=new o(1).toRed(this),M[1]=y;for(var k=2;k<M.length;k++)M[k]=this.mul(M[k-1],y);var P=M[0],_=0,q=0,E=w.bitLength()%26;for(E===0&&(E=26),k=w.length-1;k>=0;k--){for(var j=w.words[k],ee=E-1;ee>=0;ee--){var oe=j>>ee&1;if(P!==M[0]&&(P=this.sqr(P)),oe===0&&_===0){q=0;continue}_<<=1,_|=oe,q++,!(q!==I&&(k!==0||ee!==0))&&(P=this.mul(P,M[_]),q=0,_=0)}E=26}return P},J.prototype.convertTo=function(y){var w=y.umod(this.m);return w===y?w.clone():w},J.prototype.convertFrom=function(y){var w=y.clone();return w.red=null,w},o.mont=function(y){return new R(y)};function R(A){J.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}c(R,J),R.prototype.convertTo=function(y){return this.imod(y.ushln(this.shift))},R.prototype.convertFrom=function(y){var w=this.imod(y.mul(this.rinv));return w.red=null,w},R.prototype.imul=function(y,w){if(y.isZero()||w.isZero())return y.words[0]=0,y.length=1,y;var I=y.imul(w),M=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=I.isub(M).iushrn(this.shift),P=k;return k.cmp(this.m)>=0?P=k.isub(this.m):k.cmpn(0)<0&&(P=k.iadd(this.m)),P._forceRed(this)},R.prototype.mul=function(y,w){if(y.isZero()||w.isZero())return new o(0)._forceRed(this);var I=y.mul(w),M=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=I.isub(M).iushrn(this.shift),P=k;return k.cmp(this.m)>=0?P=k.isub(this.m):k.cmpn(0)<0&&(P=k.iadd(this.m)),P._forceRed(this)},R.prototype.invm=function(y){var w=this.imod(y._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(t,commonjsGlobal)}(bn)),bn.exports}var browserifyRsa,hasRequiredBrowserifyRsa;function requireBrowserifyRsa(){if(hasRequiredBrowserifyRsa)return browserifyRsa;hasRequiredBrowserifyRsa=1;var t=requireBn(),e=requireBrowser$b(),n=requireSafeBuffer$1().Buffer;function a(u){var h=u.modulus.byteLength(),l;do l=new t(e(h));while(l.cmp(u.modulus)>=0||!l.umod(u.prime1)||!l.umod(u.prime2));return l}function c(u){var h=a(u),l=h.toRed(t.mont(u.modulus)).redPow(new t(u.publicExponent)).fromRed();return{blinder:l,unblinder:h.invm(u.modulus)}}function o(u,h){var l=c(h),b=h.modulus.byteLength(),d=new t(u).mul(l.blinder).umod(h.modulus),p=d.toRed(t.mont(h.prime1)),x=d.toRed(t.mont(h.prime2)),m=h.coefficient,v=h.prime1,g=h.prime2,$=p.redPow(h.exponent1).fromRed(),B=x.redPow(h.exponent2).fromRed(),C=$.isub(B).imul(m).umod(v).imul(g);return B.iadd(C).imul(l.unblinder).umod(h.modulus).toArrayLike(n,"be",b)}return o.getr=a,browserifyRsa=o,browserifyRsa}var asn1$1={},asn1={},api={},vmBrowserify={},hasRequiredVmBrowserify;function requireVmBrowserify(){return hasRequiredVmBrowserify||(hasRequiredVmBrowserify=1,function(exports){var indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1},Object_keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)e.push(n);return e},forEach=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(t,e,n){Object.defineProperty(t,e,{writable:!0,enumerable:!1,configurable:!0,value:n})}}catch{return function(e,n,a){e[n]=a}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function Context(){}Context.prototype={};var Script=exports.Script=function(e){if(!(this instanceof Script))return new Script(e);this.code=e};Script.prototype.runInContext=function(t){if(!(t instanceof Context))throw new TypeError("needs a 'context' argument.");var e=document.createElement("iframe");e.style||(e.style={}),e.style.display="none",document.body.appendChild(e);var n=e.contentWindow,a=n.eval,c=n.execScript;!a&&c&&(c.call(n,"null"),a=n.eval),forEach(Object_keys(t),function(h){n[h]=t[h]}),forEach(globals,function(h){t[h]&&(n[h]=t[h])});var o=Object_keys(n),u=a.call(n,this.code);return forEach(Object_keys(n),function(h){(h in t||indexOf(o,h)===-1)&&(t[h]=n[h])}),forEach(globals,function(h){h in t||defineProp(t,h,n[h])}),document.body.removeChild(e),u},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(t){var e=Script.createContext(t),n=this.runInContext(e);return t&&forEach(Object_keys(e),function(a){t[a]=e[a]}),n},forEach(Object_keys(Script.prototype),function(t){exports[t]=Script[t]=function(e){var n=Script(e);return n[t].apply(n,[].slice.call(arguments,1))}}),exports.isContext=function(t){return t instanceof Context},exports.createScript=function(t){return exports.Script(t)},exports.createContext=Script.createContext=function(t){var e=new Context;return typeof t=="object"&&forEach(Object_keys(t),function(n){e[n]=t[n]}),e}}(vmBrowserify)),vmBrowserify}var hasRequiredApi;function requireApi(){return hasRequiredApi||(hasRequiredApi=1,function(t){var e=requireAsn1$1(),n=inherits_browserExports,a=t;a.define=function(u,h){return new c(u,h)};function c(o,u){this.name=o,this.body=u,this.decoders={},this.encoders={}}c.prototype._createNamed=function(u){var h;try{h=requireVmBrowserify().runInThisContext("(function "+this.name+`(entity) {
20
- this._initNamed(entity);
21
- })`)}catch{h=function(b){this._initNamed(b)}}return n(h,u),h.prototype._initNamed=function(b){u.call(this,b)},new h(this)},c.prototype._getDecoder=function(u){return u=u||"der",this.decoders.hasOwnProperty(u)||(this.decoders[u]=this._createNamed(e.decoders[u])),this.decoders[u]},c.prototype.decode=function(u,h,l){return this._getDecoder(h).decode(u,l)},c.prototype._getEncoder=function(u){return u=u||"der",this.encoders.hasOwnProperty(u)||(this.encoders[u]=this._createNamed(e.encoders[u])),this.encoders[u]},c.prototype.encode=function(u,h,l){return this._getEncoder(h).encode(u,l)}}(api)),api}var base$1={},reporter={},hasRequiredReporter;function requireReporter(){if(hasRequiredReporter)return reporter;hasRequiredReporter=1;var t=inherits_browserExports;function e(a){this._reporterState={obj:null,path:[],options:a||{},errors:[]}}reporter.Reporter=e,e.prototype.isError=function(c){return c instanceof n},e.prototype.save=function(){var c=this._reporterState;return{obj:c.obj,pathLen:c.path.length}},e.prototype.restore=function(c){var o=this._reporterState;o.obj=c.obj,o.path=o.path.slice(0,c.pathLen)},e.prototype.enterKey=function(c){return this._reporterState.path.push(c)},e.prototype.exitKey=function(c){var o=this._reporterState;o.path=o.path.slice(0,c-1)},e.prototype.leaveKey=function(c,o,u){var h=this._reporterState;this.exitKey(c),h.obj!==null&&(h.obj[o]=u)},e.prototype.path=function(){return this._reporterState.path.join("/")},e.prototype.enterObject=function(){var c=this._reporterState,o=c.obj;return c.obj={},o},e.prototype.leaveObject=function(c){var o=this._reporterState,u=o.obj;return o.obj=c,u},e.prototype.error=function(c){var o,u=this._reporterState,h=c instanceof n;if(h?o=c:o=new n(u.path.map(function(l){return"["+JSON.stringify(l)+"]"}).join(""),c.message||c,c.stack),!u.options.partial)throw o;return h||u.errors.push(o),o},e.prototype.wrapResult=function(c){var o=this._reporterState;return o.options.partial?{result:this.isError(c)?null:c,errors:o.errors}:c};function n(a,c){this.path=a,this.rethrow(c)}return t(n,Error),n.prototype.rethrow=function(c){if(this.message=c+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,n),!this.stack)try{throw new Error(this.message)}catch(o){this.stack=o.stack}return this},reporter}var buffer={},hasRequiredBuffer;function requireBuffer(){if(hasRequiredBuffer)return buffer;hasRequiredBuffer=1;var t=inherits_browserExports,e=requireBase().Reporter,n=require$$1$2.Buffer;function a(o,u){if(e.call(this,u),!n.isBuffer(o)){this.error("Input not Buffer");return}this.base=o,this.offset=0,this.length=o.length}t(a,e),buffer.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:e.prototype.save.call(this)}},a.prototype.restore=function(u){var h=new a(this.base);return h.offset=u.offset,h.length=this.offset,this.offset=u.offset,e.prototype.restore.call(this,u.reporter),h},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(u){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(u||"DecoderBuffer overrun")},a.prototype.skip=function(u,h){if(!(this.offset+u<=this.length))return this.error(h||"DecoderBuffer overrun");var l=new a(this.base);return l._reporterState=this._reporterState,l.offset=this.offset,l.length=this.offset+u,this.offset+=u,l},a.prototype.raw=function(u){return this.base.slice(u?u.offset:this.offset,this.length)};function c(o,u){if(Array.isArray(o))this.length=0,this.value=o.map(function(h){return h instanceof c||(h=new c(h,u)),this.length+=h.length,h},this);else if(typeof o=="number"){if(!(0<=o&&o<=255))return u.error("non-byte EncoderBuffer value");this.value=o,this.length=1}else if(typeof o=="string")this.value=o,this.length=n.byteLength(o);else if(n.isBuffer(o))this.value=o,this.length=o.length;else return u.error("Unsupported type: "+typeof o)}return buffer.EncoderBuffer=c,c.prototype.join=function(u,h){return u||(u=new n(this.length)),h||(h=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(l){l.join(u,h),h+=l.length}):(typeof this.value=="number"?u[h]=this.value:typeof this.value=="string"?u.write(this.value,h):n.isBuffer(this.value)&&this.value.copy(u,h),h+=this.length)),u},buffer}var node,hasRequiredNode;function requireNode(){if(hasRequiredNode)return node;hasRequiredNode=1;var t=requireBase().Reporter,e=requireBase().EncoderBuffer,n=requireBase().DecoderBuffer,a=minimalisticAssert,c=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],o=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(c),u=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function h(b,d){var p={};this._baseState=p,p.enc=b,p.parent=d||null,p.children=null,p.tag=null,p.args=null,p.reverseArgs=null,p.choice=null,p.optional=!1,p.any=!1,p.obj=!1,p.use=null,p.useDecoder=null,p.key=null,p.default=null,p.explicit=null,p.implicit=null,p.contains=null,p.parent||(p.children=[],this._wrap())}node=h;var l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return h.prototype.clone=function(){var d=this._baseState,p={};l.forEach(function(m){p[m]=d[m]});var x=new this.constructor(p.parent);return x._baseState=p,x},h.prototype._wrap=function(){var d=this._baseState;o.forEach(function(p){this[p]=function(){var m=new this.constructor(this);return d.children.push(m),m[p].apply(m,arguments)}},this)},h.prototype._init=function(d){var p=this._baseState;a(p.parent===null),d.call(this),p.children=p.children.filter(function(x){return x._baseState.parent===this},this),a.equal(p.children.length,1,"Root node can have only one child")},h.prototype._useArgs=function(d){var p=this._baseState,x=d.filter(function(m){return m instanceof this.constructor},this);d=d.filter(function(m){return!(m instanceof this.constructor)},this),x.length!==0&&(a(p.children===null),p.children=x,x.forEach(function(m){m._baseState.parent=this},this)),d.length!==0&&(a(p.args===null),p.args=d,p.reverseArgs=d.map(function(m){if(typeof m!="object"||m.constructor!==Object)return m;var v={};return Object.keys(m).forEach(function(g){g==(g|0)&&(g|=0);var $=m[g];v[$]=g}),v}))},u.forEach(function(b){h.prototype[b]=function(){var p=this._baseState;throw new Error(b+" not implemented for encoding: "+p.enc)}}),c.forEach(function(b){h.prototype[b]=function(){var p=this._baseState,x=Array.prototype.slice.call(arguments);return a(p.tag===null),p.tag=b,this._useArgs(x),this}}),h.prototype.use=function(d){a(d);var p=this._baseState;return a(p.use===null),p.use=d,this},h.prototype.optional=function(){var d=this._baseState;return d.optional=!0,this},h.prototype.def=function(d){var p=this._baseState;return a(p.default===null),p.default=d,p.optional=!0,this},h.prototype.explicit=function(d){var p=this._baseState;return a(p.explicit===null&&p.implicit===null),p.explicit=d,this},h.prototype.implicit=function(d){var p=this._baseState;return a(p.explicit===null&&p.implicit===null),p.implicit=d,this},h.prototype.obj=function(){var d=this._baseState,p=Array.prototype.slice.call(arguments);return d.obj=!0,p.length!==0&&this._useArgs(p),this},h.prototype.key=function(d){var p=this._baseState;return a(p.key===null),p.key=d,this},h.prototype.any=function(){var d=this._baseState;return d.any=!0,this},h.prototype.choice=function(d){var p=this._baseState;return a(p.choice===null),p.choice=d,this._useArgs(Object.keys(d).map(function(x){return d[x]})),this},h.prototype.contains=function(d){var p=this._baseState;return a(p.use===null),p.contains=d,this},h.prototype._decode=function(d,p){var x=this._baseState;if(x.parent===null)return d.wrapResult(x.children[0]._decode(d,p));var m=x.default,v=!0,g=null;if(x.key!==null&&(g=d.enterKey(x.key)),x.optional){var $=null;if(x.explicit!==null?$=x.explicit:x.implicit!==null?$=x.implicit:x.tag!==null&&($=x.tag),$===null&&!x.any){var B=d.save();try{x.choice===null?this._decodeGeneric(x.tag,d,p):this._decodeChoice(d,p),v=!0}catch{v=!1}d.restore(B)}else if(v=this._peekTag(d,$,x.any),d.isError(v))return v}var C;if(x.obj&&v&&(C=d.enterObject()),v){if(x.explicit!==null){var F=this._decodeTag(d,x.explicit);if(d.isError(F))return F;d=F}var H=d.offset;if(x.use===null&&x.choice===null){if(x.any)var B=d.save();var W=this._decodeTag(d,x.implicit!==null?x.implicit:x.tag,x.any);if(d.isError(W))return W;x.any?m=d.raw(B):d=W}if(p&&p.track&&x.tag!==null&&p.track(d.path(),H,d.length,"tagged"),p&&p.track&&x.tag!==null&&p.track(d.path(),d.offset,d.length,"content"),x.any?m=m:x.choice===null?m=this._decodeGeneric(x.tag,d,p):m=this._decodeChoice(d,p),d.isError(m))return m;if(!x.any&&x.choice===null&&x.children!==null&&x.children.forEach(function(te){te._decode(d,p)}),x.contains&&(x.tag==="octstr"||x.tag==="bitstr")){var Z=new n(m);m=this._getUse(x.contains,d._reporterState.obj)._decode(Z,p)}}return x.obj&&v&&(m=d.leaveObject(C)),x.key!==null&&(m!==null||v===!0)?d.leaveKey(g,x.key,m):g!==null&&d.exitKey(g),m},h.prototype._decodeGeneric=function(d,p,x){var m=this._baseState;return d==="seq"||d==="set"?null:d==="seqof"||d==="setof"?this._decodeList(p,d,m.args[0],x):/str$/.test(d)?this._decodeStr(p,d,x):d==="objid"&&m.args?this._decodeObjid(p,m.args[0],m.args[1],x):d==="objid"?this._decodeObjid(p,null,null,x):d==="gentime"||d==="utctime"?this._decodeTime(p,d,x):d==="null_"?this._decodeNull(p,x):d==="bool"?this._decodeBool(p,x):d==="objDesc"?this._decodeStr(p,d,x):d==="int"||d==="enum"?this._decodeInt(p,m.args&&m.args[0],x):m.use!==null?this._getUse(m.use,p._reporterState.obj)._decode(p,x):p.error("unknown tag: "+d)},h.prototype._getUse=function(d,p){var x=this._baseState;return x.useDecoder=this._use(d,p),a(x.useDecoder._baseState.parent===null),x.useDecoder=x.useDecoder._baseState.children[0],x.implicit!==x.useDecoder._baseState.implicit&&(x.useDecoder=x.useDecoder.clone(),x.useDecoder._baseState.implicit=x.implicit),x.useDecoder},h.prototype._decodeChoice=function(d,p){var x=this._baseState,m=null,v=!1;return Object.keys(x.choice).some(function(g){var $=d.save(),B=x.choice[g];try{var C=B._decode(d,p);if(d.isError(C))return!1;m={type:g,value:C},v=!0}catch{return d.restore($),!1}return!0},this),v?m:d.error("Choice not matched")},h.prototype._createEncoderBuffer=function(d){return new e(d,this.reporter)},h.prototype._encode=function(d,p,x){var m=this._baseState;if(!(m.default!==null&&m.default===d)){var v=this._encodeValue(d,p,x);if(v!==void 0&&!this._skipDefault(v,p,x))return v}},h.prototype._encodeValue=function(d,p,x){var m=this._baseState;if(m.parent===null)return m.children[0]._encode(d,p||new t);var B=null;if(this.reporter=p,m.optional&&d===void 0)if(m.default!==null)d=m.default;else return;var v=null,g=!1;if(m.any)B=this._createEncoderBuffer(d);else if(m.choice)B=this._encodeChoice(d,p);else if(m.contains)v=this._getUse(m.contains,x)._encode(d,p),g=!0;else if(m.children)v=m.children.map(function(H){if(H._baseState.tag==="null_")return H._encode(null,p,d);if(H._baseState.key===null)return p.error("Child should have a key");var W=p.enterKey(H._baseState.key);if(typeof d!="object")return p.error("Child expected, but input is not object");var Z=H._encode(d[H._baseState.key],p,d);return p.leaveKey(W),Z},this).filter(function(H){return H}),v=this._createEncoderBuffer(v);else if(m.tag==="seqof"||m.tag==="setof"){if(!(m.args&&m.args.length===1))return p.error("Too many args for : "+m.tag);if(!Array.isArray(d))return p.error("seqof/setof, but data is not Array");var $=this.clone();$._baseState.implicit=null,v=this._createEncoderBuffer(d.map(function(H){var W=this._baseState;return this._getUse(W.args[0],d)._encode(H,p)},$))}else m.use!==null?B=this._getUse(m.use,x)._encode(d,p):(v=this._encodePrimitive(m.tag,d),g=!0);var B;if(!m.any&&m.choice===null){var C=m.implicit!==null?m.implicit:m.tag,F=m.implicit===null?"universal":"context";C===null?m.use===null&&p.error("Tag could be omitted only for .use()"):m.use===null&&(B=this._encodeComposite(C,g,F,v))}return m.explicit!==null&&(B=this._encodeComposite(m.explicit,!1,"context",B)),B},h.prototype._encodeChoice=function(d,p){var x=this._baseState,m=x.choice[d.type];return m||a(!1,d.type+" not found in "+JSON.stringify(Object.keys(x.choice))),m._encode(d.value,p)},h.prototype._encodePrimitive=function(d,p){var x=this._baseState;if(/str$/.test(d))return this._encodeStr(p,d);if(d==="objid"&&x.args)return this._encodeObjid(p,x.reverseArgs[0],x.args[1]);if(d==="objid")return this._encodeObjid(p,null,null);if(d==="gentime"||d==="utctime")return this._encodeTime(p,d);if(d==="null_")return this._encodeNull();if(d==="int"||d==="enum")return this._encodeInt(p,x.args&&x.reverseArgs[0]);if(d==="bool")return this._encodeBool(p);if(d==="objDesc")return this._encodeStr(p,d);throw new Error("Unsupported tag: "+d)},h.prototype._isNumstr=function(d){return/^[0-9 ]*$/.test(d)},h.prototype._isPrintstr=function(d){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(d)},node}var hasRequiredBase;function requireBase(){return hasRequiredBase||(hasRequiredBase=1,function(t){var e=t;e.Reporter=requireReporter().Reporter,e.DecoderBuffer=requireBuffer().DecoderBuffer,e.EncoderBuffer=requireBuffer().EncoderBuffer,e.Node=requireNode()}(base$1)),base$1}var constants={},der={},hasRequiredDer$2;function requireDer$2(){return hasRequiredDer$2||(hasRequiredDer$2=1,function(t){var e=requireConstants();t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=e._reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=e._reverse(t.tag)}(der)),der}var hasRequiredConstants;function requireConstants(){return hasRequiredConstants||(hasRequiredConstants=1,function(t){var e=t;e._reverse=function(a){var c={};return Object.keys(a).forEach(function(o){(o|0)==o&&(o=o|0);var u=a[o];c[u]=o}),c},e.der=requireDer$2()}(constants)),constants}var decoders={},der_1$1,hasRequiredDer$1;function requireDer$1(){if(hasRequiredDer$1)return der_1$1;hasRequiredDer$1=1;var t=inherits_browserExports,e=requireAsn1$1(),n=e.base,a=e.bignum,c=e.constants.der;function o(b){this.enc="der",this.name=b.name,this.entity=b,this.tree=new u,this.tree._init(b.body)}der_1$1=o,o.prototype.decode=function(d,p){return d instanceof n.DecoderBuffer||(d=new n.DecoderBuffer(d,p)),this.tree._decode(d,p)};function u(b){n.Node.call(this,"der",b)}t(u,n.Node),u.prototype._peekTag=function(d,p,x){if(d.isEmpty())return!1;var m=d.save(),v=h(d,'Failed to peek tag: "'+p+'"');return d.isError(v)?v:(d.restore(m),v.tag===p||v.tagStr===p||v.tagStr+"of"===p||x)},u.prototype._decodeTag=function(d,p,x){var m=h(d,'Failed to decode tag of "'+p+'"');if(d.isError(m))return m;var v=l(d,m.primitive,'Failed to get length of "'+p+'"');if(d.isError(v))return v;if(!x&&m.tag!==p&&m.tagStr!==p&&m.tagStr+"of"!==p)return d.error('Failed to match tag: "'+p+'"');if(m.primitive||v!==null)return d.skip(v,'Failed to match body of: "'+p+'"');var g=d.save(),$=this._skipUntilEnd(d,'Failed to skip indefinite length body: "'+this.tag+'"');return d.isError($)?$:(v=d.offset-g.offset,d.restore(g),d.skip(v,'Failed to match body of: "'+p+'"'))},u.prototype._skipUntilEnd=function(d,p){for(;;){var x=h(d,p);if(d.isError(x))return x;var m=l(d,x.primitive,p);if(d.isError(m))return m;var v;if(x.primitive||m!==null?v=d.skip(m):v=this._skipUntilEnd(d,p),d.isError(v))return v;if(x.tagStr==="end")break}},u.prototype._decodeList=function(d,p,x,m){for(var v=[];!d.isEmpty();){var g=this._peekTag(d,"end");if(d.isError(g))return g;var $=x.decode(d,"der",m);if(d.isError($)&&g)break;v.push($)}return v},u.prototype._decodeStr=function(d,p){if(p==="bitstr"){var x=d.readUInt8();return d.isError(x)?x:{unused:x,data:d.raw()}}else if(p==="bmpstr"){var m=d.raw();if(m.length%2===1)return d.error("Decoding of string type: bmpstr length mismatch");for(var v="",g=0;g<m.length/2;g++)v+=String.fromCharCode(m.readUInt16BE(g*2));return v}else if(p==="numstr"){var $=d.raw().toString("ascii");return this._isNumstr($)?$:d.error("Decoding of string type: numstr unsupported characters")}else{if(p==="octstr")return d.raw();if(p==="objDesc")return d.raw();if(p==="printstr"){var B=d.raw().toString("ascii");return this._isPrintstr(B)?B:d.error("Decoding of string type: printstr unsupported characters")}else return/str$/.test(p)?d.raw().toString():d.error("Decoding of string type: "+p+" unsupported")}},u.prototype._decodeObjid=function(d,p,x){for(var m,v=[],g=0;!d.isEmpty();){var $=d.readUInt8();g<<=7,g|=$&127,$&128||(v.push(g),g=0)}$&128&&v.push(g);var B=v[0]/40|0,C=v[0]%40;if(x?m=v:m=[B,C].concat(v.slice(1)),p){var F=p[m.join(" ")];F===void 0&&(F=p[m.join(".")]),F!==void 0&&(m=F)}return m},u.prototype._decodeTime=function(d,p){var x=d.raw().toString();if(p==="gentime")var m=x.slice(0,4)|0,v=x.slice(4,6)|0,g=x.slice(6,8)|0,$=x.slice(8,10)|0,B=x.slice(10,12)|0,C=x.slice(12,14)|0;else if(p==="utctime"){var m=x.slice(0,2)|0,v=x.slice(2,4)|0,g=x.slice(4,6)|0,$=x.slice(6,8)|0,B=x.slice(8,10)|0,C=x.slice(10,12)|0;m<70?m=2e3+m:m=1900+m}else return d.error("Decoding "+p+" time is not supported yet");return Date.UTC(m,v-1,g,$,B,C,0)},u.prototype._decodeNull=function(d){return null},u.prototype._decodeBool=function(d){var p=d.readUInt8();return d.isError(p)?p:p!==0},u.prototype._decodeInt=function(d,p){var x=d.raw(),m=new a(x);return p&&(m=p[m.toString(10)]||m),m},u.prototype._use=function(d,p){return typeof d=="function"&&(d=d(p)),d._getDecoder("der").tree};function h(b,d){var p=b.readUInt8(d);if(b.isError(p))return p;var x=c.tagClass[p>>6],m=(p&32)===0;if((p&31)===31){var v=p;for(p=0;(v&128)===128;){if(v=b.readUInt8(d),b.isError(v))return v;p<<=7,p|=v&127}}else p&=31;var g=c.tag[p];return{cls:x,primitive:m,tag:p,tagStr:g}}function l(b,d,p){var x=b.readUInt8(p);if(b.isError(x))return x;if(!d&&x===128)return null;if(!(x&128))return x;var m=x&127;if(m>4)return b.error("length octect is too long");x=0;for(var v=0;v<m;v++){x<<=8;var g=b.readUInt8(p);if(b.isError(g))return g;x|=g}return x}return der_1$1}var pem$1,hasRequiredPem$1;function requirePem$1(){if(hasRequiredPem$1)return pem$1;hasRequiredPem$1=1;var t=inherits_browserExports,e=require$$1$2.Buffer,n=requireDer$1();function a(c){n.call(this,c),this.enc="pem"}return t(a,n),pem$1=a,a.prototype.decode=function(o,u){for(var h=o.toString().split(/[\r\n]+/g),l=u.label.toUpperCase(),b=/^-----(BEGIN|END) ([^-]+)-----$/,d=-1,p=-1,x=0;x<h.length;x++){var m=h[x].match(b);if(m!==null&&m[2]===l)if(d===-1){if(m[1]!=="BEGIN")break;d=x}else{if(m[1]!=="END")break;p=x;break}}if(d===-1||p===-1)throw new Error("PEM section not found for: "+l);var v=h.slice(d+1,p).join("");v.replace(/[^a-z0-9\+\/=]+/gi,"");var g=new e(v,"base64");return n.prototype.decode.call(this,g,u)},pem$1}var hasRequiredDecoders;function requireDecoders(){return hasRequiredDecoders||(hasRequiredDecoders=1,function(t){var e=t;e.der=requireDer$1(),e.pem=requirePem$1()}(decoders)),decoders}var encoders={},der_1,hasRequiredDer;function requireDer(){if(hasRequiredDer)return der_1;hasRequiredDer=1;var t=inherits_browserExports,e=require$$1$2.Buffer,n=requireAsn1$1(),a=n.base,c=n.constants.der;function o(b){this.enc="der",this.name=b.name,this.entity=b,this.tree=new u,this.tree._init(b.body)}der_1=o,o.prototype.encode=function(d,p){return this.tree._encode(d,p).join()};function u(b){a.Node.call(this,"der",b)}t(u,a.Node),u.prototype._encodeComposite=function(d,p,x,m){var v=l(d,p,x,this.reporter);if(m.length<128){var B=new e(2);return B[0]=v,B[1]=m.length,this._createEncoderBuffer([B,m])}for(var g=1,$=m.length;$>=256;$>>=8)g++;var B=new e(2+g);B[0]=v,B[1]=128|g;for(var $=1+g,C=m.length;C>0;$--,C>>=8)B[$]=C&255;return this._createEncoderBuffer([B,m])},u.prototype._encodeStr=function(d,p){if(p==="bitstr")return this._createEncoderBuffer([d.unused|0,d.data]);if(p==="bmpstr"){for(var x=new e(d.length*2),m=0;m<d.length;m++)x.writeUInt16BE(d.charCodeAt(m),m*2);return this._createEncoderBuffer(x)}else return p==="numstr"?this._isNumstr(d)?this._createEncoderBuffer(d):this.reporter.error("Encoding of string type: numstr supports only digits and space"):p==="printstr"?this._isPrintstr(d)?this._createEncoderBuffer(d):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(p)?this._createEncoderBuffer(d):p==="objDesc"?this._createEncoderBuffer(d):this.reporter.error("Encoding of string type: "+p+" unsupported")},u.prototype._encodeObjid=function(d,p,x){if(typeof d=="string"){if(!p)return this.reporter.error("string objid given, but no values map found");if(!p.hasOwnProperty(d))return this.reporter.error("objid not found in values map");d=p[d].split(/[\s\.]+/g);for(var m=0;m<d.length;m++)d[m]|=0}else if(Array.isArray(d)){d=d.slice();for(var m=0;m<d.length;m++)d[m]|=0}if(!Array.isArray(d))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(d));if(!x){if(d[1]>=40)return this.reporter.error("Second objid identifier OOB");d.splice(0,2,d[0]*40+d[1])}for(var v=0,m=0;m<d.length;m++){var g=d[m];for(v++;g>=128;g>>=7)v++}for(var $=new e(v),B=$.length-1,m=d.length-1;m>=0;m--){var g=d[m];for($[B--]=g&127;(g>>=7)>0;)$[B--]=128|g&127}return this._createEncoderBuffer($)};function h(b){return b<10?"0"+b:b}u.prototype._encodeTime=function(d,p){var x,m=new Date(d);return p==="gentime"?x=[h(m.getFullYear()),h(m.getUTCMonth()+1),h(m.getUTCDate()),h(m.getUTCHours()),h(m.getUTCMinutes()),h(m.getUTCSeconds()),"Z"].join(""):p==="utctime"?x=[h(m.getFullYear()%100),h(m.getUTCMonth()+1),h(m.getUTCDate()),h(m.getUTCHours()),h(m.getUTCMinutes()),h(m.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+p+" time is not supported yet"),this._encodeStr(x,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(d,p){if(typeof d=="string"){if(!p)return this.reporter.error("String int or enum given, but no values map");if(!p.hasOwnProperty(d))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(d));d=p[d]}if(typeof d!="number"&&!e.isBuffer(d)){var x=d.toArray();!d.sign&&x[0]&128&&x.unshift(0),d=new e(x)}if(e.isBuffer(d)){var m=d.length;d.length===0&&m++;var g=new e(m);return d.copy(g),d.length===0&&(g[0]=0),this._createEncoderBuffer(g)}if(d<128)return this._createEncoderBuffer(d);if(d<256)return this._createEncoderBuffer([0,d]);for(var m=1,v=d;v>=256;v>>=8)m++;for(var g=new Array(m),v=g.length-1;v>=0;v--)g[v]=d&255,d>>=8;return g[0]&128&&g.unshift(0),this._createEncoderBuffer(new e(g))},u.prototype._encodeBool=function(d){return this._createEncoderBuffer(d?255:0)},u.prototype._use=function(d,p){return typeof d=="function"&&(d=d(p)),d._getEncoder("der").tree},u.prototype._skipDefault=function(d,p,x){var m=this._baseState,v;if(m.default===null)return!1;var g=d.join();if(m.defaultBuffer===void 0&&(m.defaultBuffer=this._encodeValue(m.default,p,x).join()),g.length!==m.defaultBuffer.length)return!1;for(v=0;v<g.length;v++)if(g[v]!==m.defaultBuffer[v])return!1;return!0};function l(b,d,p,x){var m;if(b==="seqof"?b="seq":b==="setof"&&(b="set"),c.tagByName.hasOwnProperty(b))m=c.tagByName[b];else if(typeof b=="number"&&(b|0)===b)m=b;else return x.error("Unknown tag: "+b);return m>=31?x.error("Multi-octet tag encoding unsupported"):(d||(m|=32),m|=c.tagClassByName[p||"universal"]<<6,m)}return der_1}var pem,hasRequiredPem;function requirePem(){if(hasRequiredPem)return pem;hasRequiredPem=1;var t=inherits_browserExports,e=requireDer();function n(a){e.call(this,a),this.enc="pem"}return t(n,e),pem=n,n.prototype.encode=function(c,o){for(var u=e.prototype.encode.call(this,c),h=u.toString("base64"),l=["-----BEGIN "+o.label+"-----"],b=0;b<h.length;b+=64)l.push(h.slice(b,b+64));return l.push("-----END "+o.label+"-----"),l.join(`
22
- `)},pem}var hasRequiredEncoders;function requireEncoders(){return hasRequiredEncoders||(hasRequiredEncoders=1,function(t){var e=t;e.der=requireDer(),e.pem=requirePem()}(encoders)),encoders}var hasRequiredAsn1$1;function requireAsn1$1(){return hasRequiredAsn1$1||(hasRequiredAsn1$1=1,function(t){var e=t;e.bignum=bnExports,e.define=requireApi().define,e.base=requireBase(),e.constants=requireConstants(),e.decoders=requireDecoders(),e.encoders=requireEncoders()}(asn1)),asn1}var certificate,hasRequiredCertificate;function requireCertificate(){if(hasRequiredCertificate)return certificate;hasRequiredCertificate=1;var t=requireAsn1$1(),e=t.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),n=t.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=t.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),c=t.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),o=t.define("RelativeDistinguishedName",function(){this.setof(n)}),u=t.define("RDNSequence",function(){this.seqof(o)}),h=t.define("Name",function(){this.choice({rdnSequence:this.use(u)})}),l=t.define("Validity",function(){this.seq().obj(this.key("notBefore").use(e),this.key("notAfter").use(e))}),b=t.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=t.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(h),this.key("validity").use(l),this.key("subject").use(h),this.key("subjectPublicKeyInfo").use(c),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(b).optional())}),p=t.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});return certificate=p,certificate}var hasRequiredAsn1;function requireAsn1(){if(hasRequiredAsn1)return asn1$1;hasRequiredAsn1=1;var t=requireAsn1$1();asn1$1.certificate=requireCertificate();var e=t.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});asn1$1.RSAPrivateKey=e;var n=t.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});asn1$1.RSAPublicKey=n;var a=t.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),c=t.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())});asn1$1.PublicKey=c;var o=t.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(a),this.key("subjectPrivateKey").octstr())});asn1$1.PrivateKey=o;var u=t.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});asn1$1.EncryptedPrivateKey=u;var h=t.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});asn1$1.DSAPrivateKey=h,asn1$1.DSAparam=t.define("DSAparam",function(){this.int()});var l=t.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),b=t.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});return asn1$1.ECPrivateKey=b,asn1$1.signature=t.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())}),asn1$1}const require$$1={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"};var fixProc,hasRequiredFixProc;function requireFixProc(){if(hasRequiredFixProc)return fixProc;hasRequiredFixProc=1;var t=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,e=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,a=requireEvp_bytestokey(),c=requireBrowser$6(),o=requireSafeBuffer$1().Buffer;return fixProc=function(u,h){var l=u.toString(),b=l.match(t),d;if(b){var x="aes"+b[1],m=o.from(b[2],"hex"),v=o.from(b[3].replace(/[\r\n]/g,""),"base64"),g=a(h,m.slice(0,8),parseInt(b[1],10)).key,$=[],B=c.createDecipheriv(x,g,m);$.push(B.update(v)),$.push(B.final()),d=o.concat($)}else{var p=l.match(n);d=o.from(p[2].replace(/[\r\n]/g,""),"base64")}var C=l.match(e)[1];return{tag:C,data:d}},fixProc}var parseAsn1,hasRequiredParseAsn1;function requireParseAsn1(){if(hasRequiredParseAsn1)return parseAsn1;hasRequiredParseAsn1=1;var t=requireAsn1(),e=require$$1,n=requireFixProc(),a=requireBrowser$6(),c=requireBrowser$7(),o=requireSafeBuffer$1().Buffer;function u(l,b){var d=l.algorithm.decrypt.kde.kdeparams.salt,p=parseInt(l.algorithm.decrypt.kde.kdeparams.iters.toString(),10),x=e[l.algorithm.decrypt.cipher.algo.join(".")],m=l.algorithm.decrypt.cipher.iv,v=l.subjectPrivateKey,g=parseInt(x.split("-")[1],10)/8,$=c.pbkdf2Sync(b,d,p,g,"sha1"),B=a.createDecipheriv(x,$,m),C=[];return C.push(B.update(v)),C.push(B.final()),o.concat(C)}function h(l){var b;typeof l=="object"&&!o.isBuffer(l)&&(b=l.passphrase,l=l.key),typeof l=="string"&&(l=o.from(l));var d=n(l,b),p=d.tag,x=d.data,m,v;switch(p){case"CERTIFICATE":v=t.certificate.decode(x,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(v||(v=t.PublicKey.decode(x,"der")),m=v.algorithm.algorithm.join("."),m){case"1.2.840.113549.1.1.1":return t.RSAPublicKey.decode(v.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return v.subjectPrivateKey=v.subjectPublicKey,{type:"ec",data:v};case"1.2.840.10040.4.1":return v.algorithm.params.pub_key=t.DSAparam.decode(v.subjectPublicKey.data,"der"),{type:"dsa",data:v.algorithm.params};default:throw new Error("unknown key id "+m)}case"ENCRYPTED PRIVATE KEY":x=t.EncryptedPrivateKey.decode(x,"der"),x=u(x,b);case"PRIVATE KEY":switch(v=t.PrivateKey.decode(x,"der"),m=v.algorithm.algorithm.join("."),m){case"1.2.840.113549.1.1.1":return t.RSAPrivateKey.decode(v.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:v.algorithm.curve,privateKey:t.ECPrivateKey.decode(v.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return v.algorithm.params.priv_key=t.DSAparam.decode(v.subjectPrivateKey,"der"),{type:"dsa",params:v.algorithm.params};default:throw new Error("unknown key id "+m)}case"RSA PUBLIC KEY":return t.RSAPublicKey.decode(x,"der");case"RSA PRIVATE KEY":return t.RSAPrivateKey.decode(x,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:t.DSAPrivateKey.decode(x,"der")};case"EC PRIVATE KEY":return x=t.ECPrivateKey.decode(x,"der"),{curve:x.parameters.value,privateKey:x.privateKey};default:throw new Error("unknown key type "+p)}}return h.signature=t.signature,parseAsn1=h,parseAsn1}const require$$4={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};var hasRequiredSign;function requireSign(){if(hasRequiredSign)return sign$1.exports;hasRequiredSign=1;var t=requireSafeBuffer$1().Buffer,e=requireBrowser$8(),n=requireBrowserifyRsa(),a=requireElliptic().ec,c=requireBn(),o=requireParseAsn1(),u=require$$4,h=1;function l(B,C,F,H,W){var Z=o(C);if(Z.curve){if(H!=="ecdsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");return b(B,Z)}else if(Z.type==="dsa"){if(H!=="dsa")throw new Error("wrong private key type");return d(B,Z,F)}if(H!=="rsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");if(C.padding!==void 0&&C.padding!==h)throw new Error("illegal or unsupported padding mode");B=t.concat([W,B]);for(var ie=Z.modulus.byteLength(),te=[0,1];B.length+te.length+1<ie;)te.push(255);te.push(0);for(var ae=-1;++ae<B.length;)te.push(B[ae]);var de=n(te,Z);return de}function b(B,C){var F=u[C.curve.join(".")];if(!F)throw new Error("unknown curve "+C.curve.join("."));var H=new a(F),W=H.keyFromPrivate(C.privateKey),Z=W.sign(B);return t.from(Z.toDER())}function d(B,C,F){for(var H=C.params.priv_key,W=C.params.p,Z=C.params.q,ie=C.params.g,te=new c(0),ae,de=m(B,Z).mod(Z),J=!1,R=x(H,Z,B,F);J===!1;)ae=g(Z,R,F),te=$(ie,ae,W,Z),J=ae.invm(Z).imul(de.add(H.mul(te))).mod(Z),J.cmpn(0)===0&&(J=!1,te=new c(0));return p(te,J)}function p(B,C){B=B.toArray(),C=C.toArray(),B[0]&128&&(B=[0].concat(B)),C[0]&128&&(C=[0].concat(C));var F=B.length+C.length+4,H=[48,F,2,B.length];return H=H.concat(B,[2,C.length],C),t.from(H)}function x(B,C,F,H){if(B=t.from(B.toArray()),B.length<C.byteLength()){var W=t.alloc(C.byteLength()-B.length);B=t.concat([W,B])}var Z=F.length,ie=v(F,C),te=t.alloc(Z);te.fill(1);var ae=t.alloc(Z);return ae=e(H,ae).update(te).update(t.from([0])).update(B).update(ie).digest(),te=e(H,ae).update(te).digest(),ae=e(H,ae).update(te).update(t.from([1])).update(B).update(ie).digest(),te=e(H,ae).update(te).digest(),{k:ae,v:te}}function m(B,C){var F=new c(B),H=(B.length<<3)-C.bitLength();return H>0&&F.ishrn(H),F}function v(B,C){B=m(B,C),B=B.mod(C);var F=t.from(B.toArray());if(F.length<C.byteLength()){var H=t.alloc(C.byteLength()-F.length);F=t.concat([H,F])}return F}function g(B,C,F){var H,W;do{for(H=t.alloc(0);H.length*8<B.bitLength();)C.v=e(F,C.k).update(C.v).digest(),H=t.concat([H,C.v]);W=m(H,B),C.k=e(F,C.k).update(C.v).update(t.from([0])).digest(),C.v=e(F,C.k).update(C.v).digest()}while(W.cmp(B)!==-1);return W}function $(B,C,F,H){return B.toRed(c.mont(F)).redPow(C).fromRed().mod(H)}return sign$1.exports=l,sign$1.exports.getKey=x,sign$1.exports.makeKey=g,sign$1.exports}var verify_1,hasRequiredVerify;function requireVerify(){if(hasRequiredVerify)return verify_1;hasRequiredVerify=1;var t=requireSafeBuffer$1().Buffer,e=requireBn(),n=requireElliptic().ec,a=requireParseAsn1(),c=require$$4;function o(b,d,p,x,m){var v=a(p);if(v.type==="ec"){if(x!=="ecdsa"&&x!=="ecdsa/rsa")throw new Error("wrong public key type");return u(b,d,v)}else if(v.type==="dsa"){if(x!=="dsa")throw new Error("wrong public key type");return h(b,d,v)}if(x!=="rsa"&&x!=="ecdsa/rsa")throw new Error("wrong public key type");d=t.concat([m,d]);for(var g=v.modulus.byteLength(),$=[1],B=0;d.length+$.length+2<g;)$.push(255),B+=1;$.push(0);for(var C=-1;++C<d.length;)$.push(d[C]);$=t.from($);var F=e.mont(v.modulus);b=new e(b).toRed(F),b=b.redPow(new e(v.publicExponent)),b=t.from(b.fromRed().toArray());var H=B<8?1:0;for(g=Math.min(b.length,$.length),b.length!==$.length&&(H=1),C=-1;++C<g;)H|=b[C]^$[C];return H===0}function u(b,d,p){var x=c[p.data.algorithm.curve.join(".")];if(!x)throw new Error("unknown curve "+p.data.algorithm.curve.join("."));var m=new n(x),v=p.data.subjectPrivateKey.data;return m.verify(d,b,v)}function h(b,d,p){var x=p.data.p,m=p.data.q,v=p.data.g,g=p.data.pub_key,$=a.signature.decode(b,"der"),B=$.s,C=$.r;l(B,m),l(C,m);var F=e.mont(x),H=B.invm(m),W=v.toRed(F).redPow(new e(d).mul(H).mod(m)).fromRed().mul(g.toRed(F).redPow(C.mul(H).mod(m)).fromRed()).mod(x).mod(m);return W.cmp(C)===0}function l(b,d){if(b.cmpn(0)<=0)throw new Error("invalid sig");if(b.cmp(d)>=0)throw new Error("invalid sig")}return verify_1=o,verify_1}var browser$3,hasRequiredBrowser$3;function requireBrowser$3(){if(hasRequiredBrowser$3)return browser$3;hasRequiredBrowser$3=1;var t=requireSafeBuffer$1().Buffer,e=requireBrowser$9(),n=requireReadableBrowser(),a=inherits_browserExports,c=requireSign(),o=requireVerify(),u=require$$6;Object.keys(u).forEach(function(p){u[p].id=t.from(u[p].id,"hex"),u[p.toLowerCase()]=u[p]});function h(p){n.Writable.call(this);var x=u[p];if(!x)throw new Error("Unknown message digest");this._hashType=x.hash,this._hash=e(x.hash),this._tag=x.id,this._signType=x.sign}a(h,n.Writable),h.prototype._write=function(x,m,v){this._hash.update(x),v()},h.prototype.update=function(x,m){return this._hash.update(typeof x=="string"?t.from(x,m):x),this},h.prototype.sign=function(x,m){this.end();var v=this._hash.digest(),g=c(v,x,this._hashType,this._signType,this._tag);return m?g.toString(m):g};function l(p){n.Writable.call(this);var x=u[p];if(!x)throw new Error("Unknown message digest");this._hash=e(x.hash),this._tag=x.id,this._signType=x.sign}a(l,n.Writable),l.prototype._write=function(x,m,v){this._hash.update(x),v()},l.prototype.update=function(x,m){return this._hash.update(typeof x=="string"?t.from(x,m):x),this},l.prototype.verify=function(x,m,v){var g=typeof m=="string"?t.from(m,v):m;this.end();var $=this._hash.digest();return o(g,$,x,this._signType,this._tag)};function b(p){return new h(p)}function d(p){return new l(p)}return browser$3={Sign:b,Verify:d,createSign:b,createVerify:d},browser$3}var browser$2,hasRequiredBrowser$2;function requireBrowser$2(){if(hasRequiredBrowser$2)return browser$2;hasRequiredBrowser$2=1;var t=requireElliptic(),e=bnExports;browser$2=function(u){return new a(u)};var n={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};n.p224=n.secp224r1,n.p256=n.secp256r1=n.prime256v1,n.p192=n.secp192r1=n.prime192v1,n.p384=n.secp384r1,n.p521=n.secp521r1;function a(o){this.curveType=n[o],this.curveType||(this.curveType={name:o}),this.curve=new t.ec(this.curveType.name),this.keys=void 0}a.prototype.generateKeys=function(o,u){return this.keys=this.curve.genKeyPair(),this.getPublicKey(o,u)},a.prototype.computeSecret=function(o,u,h){u=u||"utf8",Buffer.isBuffer(o)||(o=new Buffer(o,u));var l=this.curve.keyFromPublic(o).getPublic(),b=l.mul(this.keys.getPrivate()).getX();return c(b,h,this.curveType.byteLength)},a.prototype.getPublicKey=function(o,u){var h=this.keys.getPublic(u==="compressed",!0);return u==="hybrid"&&(h[h.length-1]%2?h[0]=7:h[0]=6),c(h,o)},a.prototype.getPrivateKey=function(o){return c(this.keys.getPrivate(),o)},a.prototype.setPublicKey=function(o,u){return u=u||"utf8",Buffer.isBuffer(o)||(o=new Buffer(o,u)),this.keys._importPublic(o),this},a.prototype.setPrivateKey=function(o,u){u=u||"utf8",Buffer.isBuffer(o)||(o=new Buffer(o,u));var h=new e(o);return h=h.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(h),this};function c(o,u,h){Array.isArray(o)||(o=o.toArray());var l=new Buffer(o);if(h&&l.length<h){var b=new Buffer(h-l.length);b.fill(0),l=Buffer.concat([b,l])}return u?l.toString(u):l}return browser$2}var browser$1={},mgf,hasRequiredMgf;function requireMgf(){if(hasRequiredMgf)return mgf;hasRequiredMgf=1;var t=requireBrowser$9(),e=requireSafeBuffer$1().Buffer;mgf=function(a,c){for(var o=e.alloc(0),u=0,h;o.length<c;)h=n(u++),o=e.concat([o,t("sha1").update(a).update(h).digest()]);return o.slice(0,c)};function n(a){var c=e.allocUnsafe(4);return c.writeUInt32BE(a,0),c}return mgf}var xor,hasRequiredXor;function requireXor(){return hasRequiredXor||(hasRequiredXor=1,xor=function(e,n){for(var a=e.length,c=-1;++c<a;)e[c]^=n[c];return e}),xor}var withPublic_1,hasRequiredWithPublic;function requireWithPublic(){if(hasRequiredWithPublic)return withPublic_1;hasRequiredWithPublic=1;var t=bnExports,e=requireSafeBuffer$1().Buffer;function n(a,c){return e.from(a.toRed(t.mont(c.modulus)).redPow(new t(c.publicExponent)).fromRed().toArray())}return withPublic_1=n,withPublic_1}var publicEncrypt,hasRequiredPublicEncrypt;function requirePublicEncrypt(){if(hasRequiredPublicEncrypt)return publicEncrypt;hasRequiredPublicEncrypt=1;var t=requireParseAsn1(),e=requireBrowser$b(),n=requireBrowser$9(),a=requireMgf(),c=requireXor(),o=bnExports,u=requireWithPublic(),h=requireBrowserifyRsa(),l=requireSafeBuffer$1().Buffer;publicEncrypt=function(m,v,g){var $;m.padding?$=m.padding:g?$=1:$=4;var B=t(m),C;if($===4)C=b(B,v);else if($===1)C=d(B,v,g);else if($===3){if(C=new o(v),C.cmp(B.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return g?h(C,B):u(C,B)};function b(x,m){var v=x.modulus.byteLength(),g=m.length,$=n("sha1").update(l.alloc(0)).digest(),B=$.length,C=2*B;if(g>v-C-2)throw new Error("message too long");var F=l.alloc(v-g-C-2),H=v-B-1,W=e(B),Z=c(l.concat([$,F,l.alloc(1,1),m],H),a(W,H)),ie=c(W,a(Z,B));return new o(l.concat([l.alloc(1),ie,Z],v))}function d(x,m,v){var g=m.length,$=x.modulus.byteLength();if(g>$-11)throw new Error("message too long");var B;return v?B=l.alloc($-g-3,255):B=p($-g-3),new o(l.concat([l.from([0,v?1:2]),B,l.alloc(1),m],$))}function p(x){for(var m=l.allocUnsafe(x),v=0,g=e(x*2),$=0,B;v<x;)$===g.length&&(g=e(x*2),$=0),B=g[$++],B&&(m[v++]=B);return m}return publicEncrypt}var privateDecrypt,hasRequiredPrivateDecrypt;function requirePrivateDecrypt(){if(hasRequiredPrivateDecrypt)return privateDecrypt;hasRequiredPrivateDecrypt=1;var t=requireParseAsn1(),e=requireMgf(),n=requireXor(),a=bnExports,c=requireBrowserifyRsa(),o=requireBrowser$9(),u=requireWithPublic(),h=requireSafeBuffer$1().Buffer;privateDecrypt=function(x,m,v){var g;x.padding?g=x.padding:v?g=1:g=4;var $=t(x),B=$.modulus.byteLength();if(m.length>B||new a(m).cmp($.modulus)>=0)throw new Error("decryption error");var C;v?C=u(new a(m),$):C=c(m,$);var F=h.alloc(B-C.length);if(C=h.concat([F,C],B),g===4)return l($,C);if(g===1)return b($,C,v);if(g===3)return C;throw new Error("unknown padding")};function l(p,x){var m=p.modulus.byteLength(),v=o("sha1").update(h.alloc(0)).digest(),g=v.length;if(x[0]!==0)throw new Error("decryption error");var $=x.slice(1,g+1),B=x.slice(g+1),C=n($,e(B,g)),F=n(B,e(C,m-g-1));if(d(v,F.slice(0,g)))throw new Error("decryption error");for(var H=g;F[H]===0;)H++;if(F[H++]!==1)throw new Error("decryption error");return F.slice(H)}function b(p,x,m){for(var v=x.slice(0,2),g=2,$=0;x[g++]!==0;)if(g>=x.length){$++;break}var B=x.slice(2,g-1);if((v.toString("hex")!=="0002"&&!m||v.toString("hex")!=="0001"&&m)&&$++,B.length<8&&$++,$)throw new Error("decryption error");return x.slice(g)}function d(p,x){p=h.from(p),x=h.from(x);var m=0,v=p.length;p.length!==x.length&&(m++,v=Math.min(p.length,x.length));for(var g=-1;++g<v;)m+=p[g]^x[g];return m}return privateDecrypt}var hasRequiredBrowser$1;function requireBrowser$1(){return hasRequiredBrowser$1||(hasRequiredBrowser$1=1,function(t){t.publicEncrypt=requirePublicEncrypt(),t.privateDecrypt=requirePrivateDecrypt(),t.privateEncrypt=function(n,a){return t.publicEncrypt(n,a,!0)},t.publicDecrypt=function(n,a){return t.privateDecrypt(n,a,!0)}}(browser$1)),browser$1}var browser={},hasRequiredBrowser;function requireBrowser(){if(hasRequiredBrowser)return browser;hasRequiredBrowser=1;function t(){throw new Error(`secure random number generation not supported by this browser
23
- use chrome, FireFox or Internet Explorer 11`)}var e=requireSafeBuffer$1(),n=requireBrowser$b(),a=e.Buffer,c=e.kMaxLength,o=commonjsGlobal.crypto||commonjsGlobal.msCrypto,u=Math.pow(2,32)-1;function h(x,m){if(typeof x!="number"||x!==x)throw new TypeError("offset must be a number");if(x>u||x<0)throw new TypeError("offset must be a uint32");if(x>c||x>m)throw new RangeError("offset out of range")}function l(x,m,v){if(typeof x!="number"||x!==x)throw new TypeError("size must be a number");if(x>u||x<0)throw new TypeError("size must be a uint32");if(x+m>v||x>c)throw new RangeError("buffer too small")}o&&o.getRandomValues||!process$1.browser?(browser.randomFill=b,browser.randomFillSync=p):(browser.randomFill=t,browser.randomFillSync=t);function b(x,m,v,g){if(!a.isBuffer(x)&&!(x instanceof commonjsGlobal.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof m=="function")g=m,m=0,v=x.length;else if(typeof v=="function")g=v,v=x.length-m;else if(typeof g!="function")throw new TypeError('"cb" argument must be a function');return h(m,x.length),l(v,m,x.length),d(x,m,v,g)}function d(x,m,v,g){if(process$1.browser){var $=x.buffer,B=new Uint8Array($,m,v);if(o.getRandomValues(B),g){process$1.nextTick(function(){g(null,x)});return}return x}if(g){n(v,function(F,H){if(F)return g(F);H.copy(x,m),g(null,x)});return}var C=n(v);return C.copy(x,m),x}function p(x,m,v){if(typeof m>"u"&&(m=0),!a.isBuffer(x)&&!(x instanceof commonjsGlobal.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return h(m,x.length),v===void 0&&(v=x.length-m),l(v,m,x.length),d(x,m,v)}return browser}var hasRequiredCryptoBrowserify;function requireCryptoBrowserify(){if(hasRequiredCryptoBrowserify)return cryptoBrowserify;hasRequiredCryptoBrowserify=1,cryptoBrowserify.randomBytes=cryptoBrowserify.rng=cryptoBrowserify.pseudoRandomBytes=cryptoBrowserify.prng=requireBrowser$b(),cryptoBrowserify.createHash=cryptoBrowserify.Hash=requireBrowser$9(),cryptoBrowserify.createHmac=cryptoBrowserify.Hmac=requireBrowser$8();var t=requireAlgos(),e=Object.keys(t),n=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(e);cryptoBrowserify.getHashes=function(){return n};var a=requireBrowser$7();cryptoBrowserify.pbkdf2=a.pbkdf2,cryptoBrowserify.pbkdf2Sync=a.pbkdf2Sync;var c=requireBrowser$5();cryptoBrowserify.Cipher=c.Cipher,cryptoBrowserify.createCipher=c.createCipher,cryptoBrowserify.Cipheriv=c.Cipheriv,cryptoBrowserify.createCipheriv=c.createCipheriv,cryptoBrowserify.Decipher=c.Decipher,cryptoBrowserify.createDecipher=c.createDecipher,cryptoBrowserify.Decipheriv=c.Decipheriv,cryptoBrowserify.createDecipheriv=c.createDecipheriv,cryptoBrowserify.getCiphers=c.getCiphers,cryptoBrowserify.listCiphers=c.listCiphers;var o=requireBrowser$4();cryptoBrowserify.DiffieHellmanGroup=o.DiffieHellmanGroup,cryptoBrowserify.createDiffieHellmanGroup=o.createDiffieHellmanGroup,cryptoBrowserify.getDiffieHellman=o.getDiffieHellman,cryptoBrowserify.createDiffieHellman=o.createDiffieHellman,cryptoBrowserify.DiffieHellman=o.DiffieHellman;var u=requireBrowser$3();cryptoBrowserify.createSign=u.createSign,cryptoBrowserify.Sign=u.Sign,cryptoBrowserify.createVerify=u.createVerify,cryptoBrowserify.Verify=u.Verify,cryptoBrowserify.createECDH=requireBrowser$2();var h=requireBrowser$1();cryptoBrowserify.publicEncrypt=h.publicEncrypt,cryptoBrowserify.privateEncrypt=h.privateEncrypt,cryptoBrowserify.publicDecrypt=h.publicDecrypt,cryptoBrowserify.privateDecrypt=h.privateDecrypt;var l=requireBrowser();return cryptoBrowserify.randomFill=l.randomFill,cryptoBrowserify.randomFillSync=l.randomFillSync,cryptoBrowserify.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(`
24
- `))},cryptoBrowserify.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6},cryptoBrowserify}var hasRequiredBrorand;function requireBrorand(){if(hasRequiredBrorand)return brorand.exports;hasRequiredBrorand=1;var t;brorand.exports=function(c){return t||(t=new e(null)),t.generate(c)};function e(a){this.rand=a}if(brorand.exports.Rand=e,e.prototype.generate=function(c){return this._rand(c)},e.prototype._rand=function(c){if(this.rand.getBytes)return this.rand.getBytes(c);for(var o=new Uint8Array(c),u=0;u<o.length;u++)o[u]=this.rand.getByte();return o},typeof self=="object")self.crypto&&self.crypto.getRandomValues?e.prototype._rand=function(c){var o=new Uint8Array(c);return self.crypto.getRandomValues(o),o}:self.msCrypto&&self.msCrypto.getRandomValues?e.prototype._rand=function(c){var o=new Uint8Array(c);return self.msCrypto.getRandomValues(o),o}:typeof window=="object"&&(e.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var n=requireCryptoBrowserify();if(typeof n.randomBytes!="function")throw new Error("Not supported");e.prototype._rand=function(c){return n.randomBytes(c)}}catch{}return brorand.exports}var curve={},BN$6=bnExports,utils$l=utils$o,getNAF=utils$l.getNAF,getJSF=utils$l.getJSF,assert$d=utils$l.assert;function BaseCurve(t,e){this.type=t,this.p=new BN$6(e.p,16),this.red=e.prime?BN$6.red(e.prime):BN$6.mont(this.p),this.zero=new BN$6(0).toRed(this.red),this.one=new BN$6(1).toRed(this.red),this.two=new BN$6(2).toRed(this.red),this.n=e.n&&new BN$6(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var base=BaseCurve;BaseCurve.prototype.point=function t(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function t(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function t(e,n){assert$d(e.precomputed);var a=e._getDoubles(),c=getNAF(n,1,this._bitLength),o=(1<<a.step+1)-(a.step%2===0?2:1);o/=3;var u=[],h,l;for(h=0;h<c.length;h+=a.step){l=0;for(var b=h+a.step-1;b>=h;b--)l=(l<<1)+c[b];u.push(l)}for(var d=this.jpoint(null,null,null),p=this.jpoint(null,null,null),x=o;x>0;x--){for(h=0;h<u.length;h++)l=u[h],l===x?p=p.mixedAdd(a.points[h]):l===-x&&(p=p.mixedAdd(a.points[h].neg()));d=d.add(p)}return d.toP()},BaseCurve.prototype._wnafMul=function t(e,n){var a=4,c=e._getNAFPoints(a);a=c.wnd;for(var o=c.points,u=getNAF(n,a,this._bitLength),h=this.jpoint(null,null,null),l=u.length-1;l>=0;l--){for(var b=0;l>=0&&u[l]===0;l--)b++;if(l>=0&&b++,h=h.dblp(b),l<0)break;var d=u[l];assert$d(d!==0),e.type==="affine"?d>0?h=h.mixedAdd(o[d-1>>1]):h=h.mixedAdd(o[-d-1>>1].neg()):d>0?h=h.add(o[d-1>>1]):h=h.add(o[-d-1>>1].neg())}return e.type==="affine"?h.toP():h},BaseCurve.prototype._wnafMulAdd=function t(e,n,a,c,o){var u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,b=0,d,p,x;for(d=0;d<c;d++){x=n[d];var m=x._getNAFPoints(e);u[d]=m.wnd,h[d]=m.points}for(d=c-1;d>=1;d-=2){var v=d-1,g=d;if(u[v]!==1||u[g]!==1){l[v]=getNAF(a[v],u[v],this._bitLength),l[g]=getNAF(a[g],u[g],this._bitLength),b=Math.max(l[v].length,b),b=Math.max(l[g].length,b);continue}var $=[n[v],null,null,n[g]];n[v].y.cmp(n[g].y)===0?($[1]=n[v].add(n[g]),$[2]=n[v].toJ().mixedAdd(n[g].neg())):n[v].y.cmp(n[g].y.redNeg())===0?($[1]=n[v].toJ().mixedAdd(n[g]),$[2]=n[v].add(n[g].neg())):($[1]=n[v].toJ().mixedAdd(n[g]),$[2]=n[v].toJ().mixedAdd(n[g].neg()));var B=[-3,-1,-5,-7,0,7,5,1,3],C=getJSF(a[v],a[g]);for(b=Math.max(C[0].length,b),l[v]=new Array(b),l[g]=new Array(b),p=0;p<b;p++){var F=C[0][p]|0,H=C[1][p]|0;l[v][p]=B[(F+1)*3+(H+1)],l[g][p]=0,h[v]=$}}var W=this.jpoint(null,null,null),Z=this._wnafT4;for(d=b;d>=0;d--){for(var ie=0;d>=0;){var te=!0;for(p=0;p<c;p++)Z[p]=l[p][d]|0,Z[p]!==0&&(te=!1);if(!te)break;ie++,d--}if(d>=0&&ie++,W=W.dblp(ie),d<0)break;for(p=0;p<c;p++){var ae=Z[p];ae!==0&&(ae>0?x=h[p][ae-1>>1]:ae<0&&(x=h[p][-ae-1>>1].neg()),x.type==="affine"?W=W.mixedAdd(x):W=W.add(x))}}for(d=0;d<c;d++)h[d]=null;return o?W:W.toP()};function BasePoint(t,e){this.curve=t,this.type=e,this.precomputed=null}BaseCurve.BasePoint=BasePoint,BasePoint.prototype.eq=function t(){throw new Error("Not implemented")},BasePoint.prototype.validate=function t(){return this.curve.validate(this)},BaseCurve.prototype.decodePoint=function t(e,n){e=utils$l.toArray(e,n);var a=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*a){e[0]===6?assert$d(e[e.length-1]%2===0):e[0]===7&&assert$d(e[e.length-1]%2===1);var c=this.point(e.slice(1,1+a),e.slice(1+a,1+2*a));return c}else if((e[0]===2||e[0]===3)&&e.length-1===a)return this.pointFromX(e.slice(1,1+a),e[0]===3);throw new Error("Unknown point format")},BasePoint.prototype.encodeCompressed=function t(e){return this.encode(e,!0)},BasePoint.prototype._encode=function t(e){var n=this.curve.p.byteLength(),a=this.getX().toArray("be",n);return e?[this.getY().isEven()?2:3].concat(a):[4].concat(a,this.getY().toArray("be",n))},BasePoint.prototype.encode=function t(e,n){return utils$l.encode(this._encode(n),e)},BasePoint.prototype.precompute=function t(e){if(this.precomputed)return this;var n={doubles:null,naf:null,beta:null};return n.naf=this._getNAFPoints(8),n.doubles=this._getDoubles(4,e),n.beta=this._getBeta(),this.precomputed=n,this},BasePoint.prototype._hasDoubles=function t(e){if(!this.precomputed)return!1;var n=this.precomputed.doubles;return n?n.points.length>=Math.ceil((e.bitLength()+1)/n.step):!1},BasePoint.prototype._getDoubles=function t(e,n){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],c=this,o=0;o<n;o+=e){for(var u=0;u<e;u++)c=c.dbl();a.push(c)}return{step:e,points:a}},BasePoint.prototype._getNAFPoints=function t(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var n=[this],a=(1<<e)-1,c=a===1?null:this.dbl(),o=1;o<a;o++)n[o]=n[o-1].add(c);return{wnd:e,points:n}},BasePoint.prototype._getBeta=function t(){return null},BasePoint.prototype.dblp=function t(e){for(var n=this,a=0;a<e;a++)n=n.dbl();return n};var utils$k=utils$o,BN$5=bnExports,inherits$4=inherits_browserExports,Base$2=base,assert$c=utils$k.assert;function ShortCurve(t){Base$2.call(this,"short",t),this.a=new BN$5(t.a,16).toRed(this.red),this.b=new BN$5(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits$4(ShortCurve,Base$2);var short=ShortCurve;ShortCurve.prototype._getEndomorphism=function t(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var n,a;if(e.beta)n=new BN$5(e.beta,16).toRed(this.red);else{var c=this._getEndoRoots(this.p);n=c[0].cmp(c[1])<0?c[0]:c[1],n=n.toRed(this.red)}if(e.lambda)a=new BN$5(e.lambda,16);else{var o=this._getEndoRoots(this.n);this.g.mul(o[0]).x.cmp(this.g.x.redMul(n))===0?a=o[0]:(a=o[1],assert$c(this.g.mul(a).x.cmp(this.g.x.redMul(n))===0))}var u;return e.basis?u=e.basis.map(function(h){return{a:new BN$5(h.a,16),b:new BN$5(h.b,16)}}):u=this._getEndoBasis(a),{beta:n,lambda:a,basis:u}}},ShortCurve.prototype._getEndoRoots=function t(e){var n=e===this.p?this.red:BN$5.mont(e),a=new BN$5(2).toRed(n).redInvm(),c=a.redNeg(),o=new BN$5(3).toRed(n).redNeg().redSqrt().redMul(a),u=c.redAdd(o).fromRed(),h=c.redSub(o).fromRed();return[u,h]},ShortCurve.prototype._getEndoBasis=function t(e){for(var n=this.n.ushrn(Math.floor(this.n.bitLength()/2)),a=e,c=this.n.clone(),o=new BN$5(1),u=new BN$5(0),h=new BN$5(0),l=new BN$5(1),b,d,p,x,m,v,g,$=0,B,C;a.cmpn(0)!==0;){var F=c.div(a);B=c.sub(F.mul(a)),C=h.sub(F.mul(o));var H=l.sub(F.mul(u));if(!p&&B.cmp(n)<0)b=g.neg(),d=o,p=B.neg(),x=C;else if(p&&++$===2)break;g=B,c=a,a=B,h=o,o=C,l=u,u=H}m=B.neg(),v=C;var W=p.sqr().add(x.sqr()),Z=m.sqr().add(v.sqr());return Z.cmp(W)>=0&&(m=b,v=d),p.negative&&(p=p.neg(),x=x.neg()),m.negative&&(m=m.neg(),v=v.neg()),[{a:p,b:x},{a:m,b:v}]},ShortCurve.prototype._endoSplit=function t(e){var n=this.endo.basis,a=n[0],c=n[1],o=c.b.mul(e).divRound(this.n),u=a.b.neg().mul(e).divRound(this.n),h=o.mul(a.a),l=u.mul(c.a),b=o.mul(a.b),d=u.mul(c.b),p=e.sub(h).sub(l),x=b.add(d).neg();return{k1:p,k2:x}},ShortCurve.prototype.pointFromX=function t(e,n){e=new BN$5(e,16),e.red||(e=e.toRed(this.red));var a=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),c=a.redSqrt();if(c.redSqr().redSub(a).cmp(this.zero)!==0)throw new Error("invalid point");var o=c.fromRed().isOdd();return(n&&!o||!n&&o)&&(c=c.redNeg()),this.point(e,c)},ShortCurve.prototype.validate=function t(e){if(e.inf)return!0;var n=e.x,a=e.y,c=this.a.redMul(n),o=n.redSqr().redMul(n).redIAdd(c).redIAdd(this.b);return a.redSqr().redISub(o).cmpn(0)===0},ShortCurve.prototype._endoWnafMulAdd=function t(e,n,a){for(var c=this._endoWnafT1,o=this._endoWnafT2,u=0;u<e.length;u++){var h=this._endoSplit(n[u]),l=e[u],b=l._getBeta();h.k1.negative&&(h.k1.ineg(),l=l.neg(!0)),h.k2.negative&&(h.k2.ineg(),b=b.neg(!0)),c[u*2]=l,c[u*2+1]=b,o[u*2]=h.k1,o[u*2+1]=h.k2}for(var d=this._wnafMulAdd(1,c,o,u*2,a),p=0;p<u*2;p++)c[p]=null,o[p]=null;return d};function Point$2(t,e,n,a){Base$2.BasePoint.call(this,t,"affine"),e===null&&n===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN$5(e,16),this.y=new BN$5(n,16),a&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}inherits$4(Point$2,Base$2.BasePoint),ShortCurve.prototype.point=function t(e,n,a){return new Point$2(this,e,n,a)},ShortCurve.prototype.pointFromJSON=function t(e,n){return Point$2.fromJSON(this,e,n)},Point$2.prototype._getBeta=function t(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var n=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var a=this.curve,c=function(o){return a.point(o.x.redMul(a.endo.beta),o.y)};e.beta=n,n.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(c)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(c)}}}return n}},Point$2.prototype.toJSON=function t(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Point$2.fromJSON=function t(e,n,a){typeof n=="string"&&(n=JSON.parse(n));var c=e.point(n[0],n[1],a);if(!n[2])return c;function o(h){return e.point(h[0],h[1],a)}var u=n[2];return c.precomputed={beta:null,doubles:u.doubles&&{step:u.doubles.step,points:[c].concat(u.doubles.points.map(o))},naf:u.naf&&{wnd:u.naf.wnd,points:[c].concat(u.naf.points.map(o))}},c},Point$2.prototype.inspect=function t(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Point$2.prototype.isInfinity=function t(){return this.inf},Point$2.prototype.add=function t(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var n=this.y.redSub(e.y);n.cmpn(0)!==0&&(n=n.redMul(this.x.redSub(e.x).redInvm()));var a=n.redSqr().redISub(this.x).redISub(e.x),c=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,c)},Point$2.prototype.dbl=function t(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var n=this.curve.a,a=this.x.redSqr(),c=e.redInvm(),o=a.redAdd(a).redIAdd(a).redIAdd(n).redMul(c),u=o.redSqr().redISub(this.x.redAdd(this.x)),h=o.redMul(this.x.redSub(u)).redISub(this.y);return this.curve.point(u,h)},Point$2.prototype.getX=function t(){return this.x.fromRed()},Point$2.prototype.getY=function t(){return this.y.fromRed()},Point$2.prototype.mul=function t(e){return e=new BN$5(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Point$2.prototype.mulAdd=function t(e,n,a){var c=[this,n],o=[e,a];return this.curve.endo?this.curve._endoWnafMulAdd(c,o):this.curve._wnafMulAdd(1,c,o,2)},Point$2.prototype.jmulAdd=function t(e,n,a){var c=[this,n],o=[e,a];return this.curve.endo?this.curve._endoWnafMulAdd(c,o,!0):this.curve._wnafMulAdd(1,c,o,2,!0)},Point$2.prototype.eq=function t(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Point$2.prototype.neg=function t(e){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var a=this.precomputed,c=function(o){return o.neg()};n.precomputed={naf:a.naf&&{wnd:a.naf.wnd,points:a.naf.points.map(c)},doubles:a.doubles&&{step:a.doubles.step,points:a.doubles.points.map(c)}}}return n},Point$2.prototype.toJ=function t(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function JPoint(t,e,n,a){Base$2.BasePoint.call(this,t,"jacobian"),e===null&&n===null&&a===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN$5(0)):(this.x=new BN$5(e,16),this.y=new BN$5(n,16),this.z=new BN$5(a,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits$4(JPoint,Base$2.BasePoint),ShortCurve.prototype.jpoint=function t(e,n,a){return new JPoint(this,e,n,a)},JPoint.prototype.toP=function t(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),n=e.redSqr(),a=this.x.redMul(n),c=this.y.redMul(n).redMul(e);return this.curve.point(a,c)},JPoint.prototype.neg=function t(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function t(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var n=e.z.redSqr(),a=this.z.redSqr(),c=this.x.redMul(n),o=e.x.redMul(a),u=this.y.redMul(n.redMul(e.z)),h=e.y.redMul(a.redMul(this.z)),l=c.redSub(o),b=u.redSub(h);if(l.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=l.redSqr(),p=d.redMul(l),x=c.redMul(d),m=b.redSqr().redIAdd(p).redISub(x).redISub(x),v=b.redMul(x.redISub(m)).redISub(u.redMul(p)),g=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(m,v,g)},JPoint.prototype.mixedAdd=function t(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var n=this.z.redSqr(),a=this.x,c=e.x.redMul(n),o=this.y,u=e.y.redMul(n).redMul(this.z),h=a.redSub(c),l=o.redSub(u);if(h.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=h.redSqr(),d=b.redMul(h),p=a.redMul(b),x=l.redSqr().redIAdd(d).redISub(p).redISub(p),m=l.redMul(p.redISub(x)).redISub(o.redMul(d)),v=this.z.redMul(h);return this.curve.jpoint(x,m,v)},JPoint.prototype.dblp=function t(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var n;if(this.curve.zeroA||this.curve.threeA){var a=this;for(n=0;n<e;n++)a=a.dbl();return a}var c=this.curve.a,o=this.curve.tinv,u=this.x,h=this.y,l=this.z,b=l.redSqr().redSqr(),d=h.redAdd(h);for(n=0;n<e;n++){var p=u.redSqr(),x=d.redSqr(),m=x.redSqr(),v=p.redAdd(p).redIAdd(p).redIAdd(c.redMul(b)),g=u.redMul(x),$=v.redSqr().redISub(g.redAdd(g)),B=g.redISub($),C=v.redMul(B);C=C.redIAdd(C).redISub(m);var F=d.redMul(l);n+1<e&&(b=b.redMul(m)),u=$,l=F,d=C}return this.curve.jpoint(u,d.redMul(o),l)},JPoint.prototype.dbl=function t(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},JPoint.prototype._zeroDbl=function t(){var e,n,a;if(this.zOne){var c=this.x.redSqr(),o=this.y.redSqr(),u=o.redSqr(),h=this.x.redAdd(o).redSqr().redISub(c).redISub(u);h=h.redIAdd(h);var l=c.redAdd(c).redIAdd(c),b=l.redSqr().redISub(h).redISub(h),d=u.redIAdd(u);d=d.redIAdd(d),d=d.redIAdd(d),e=b,n=l.redMul(h.redISub(b)).redISub(d),a=this.y.redAdd(this.y)}else{var p=this.x.redSqr(),x=this.y.redSqr(),m=x.redSqr(),v=this.x.redAdd(x).redSqr().redISub(p).redISub(m);v=v.redIAdd(v);var g=p.redAdd(p).redIAdd(p),$=g.redSqr(),B=m.redIAdd(m);B=B.redIAdd(B),B=B.redIAdd(B),e=$.redISub(v).redISub(v),n=g.redMul(v.redISub(e)).redISub(B),a=this.y.redMul(this.z),a=a.redIAdd(a)}return this.curve.jpoint(e,n,a)},JPoint.prototype._threeDbl=function t(){var e,n,a;if(this.zOne){var c=this.x.redSqr(),o=this.y.redSqr(),u=o.redSqr(),h=this.x.redAdd(o).redSqr().redISub(c).redISub(u);h=h.redIAdd(h);var l=c.redAdd(c).redIAdd(c).redIAdd(this.curve.a),b=l.redSqr().redISub(h).redISub(h);e=b;var d=u.redIAdd(u);d=d.redIAdd(d),d=d.redIAdd(d),n=l.redMul(h.redISub(b)).redISub(d),a=this.y.redAdd(this.y)}else{var p=this.z.redSqr(),x=this.y.redSqr(),m=this.x.redMul(x),v=this.x.redSub(p).redMul(this.x.redAdd(p));v=v.redAdd(v).redIAdd(v);var g=m.redIAdd(m);g=g.redIAdd(g);var $=g.redAdd(g);e=v.redSqr().redISub($),a=this.y.redAdd(this.z).redSqr().redISub(x).redISub(p);var B=x.redSqr();B=B.redIAdd(B),B=B.redIAdd(B),B=B.redIAdd(B),n=v.redMul(g.redISub(e)).redISub(B)}return this.curve.jpoint(e,n,a)},JPoint.prototype._dbl=function t(){var e=this.curve.a,n=this.x,a=this.y,c=this.z,o=c.redSqr().redSqr(),u=n.redSqr(),h=a.redSqr(),l=u.redAdd(u).redIAdd(u).redIAdd(e.redMul(o)),b=n.redAdd(n);b=b.redIAdd(b);var d=b.redMul(h),p=l.redSqr().redISub(d.redAdd(d)),x=d.redISub(p),m=h.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var v=l.redMul(x).redISub(m),g=a.redAdd(a).redMul(c);return this.curve.jpoint(p,v,g)},JPoint.prototype.trpl=function t(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),n=this.y.redSqr(),a=this.z.redSqr(),c=n.redSqr(),o=e.redAdd(e).redIAdd(e),u=o.redSqr(),h=this.x.redAdd(n).redSqr().redISub(e).redISub(c);h=h.redIAdd(h),h=h.redAdd(h).redIAdd(h),h=h.redISub(u);var l=h.redSqr(),b=c.redIAdd(c);b=b.redIAdd(b),b=b.redIAdd(b),b=b.redIAdd(b);var d=o.redIAdd(h).redSqr().redISub(u).redISub(l).redISub(b),p=n.redMul(d);p=p.redIAdd(p),p=p.redIAdd(p);var x=this.x.redMul(l).redISub(p);x=x.redIAdd(x),x=x.redIAdd(x);var m=this.y.redMul(d.redMul(b.redISub(d)).redISub(h.redMul(l)));m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var v=this.z.redAdd(h).redSqr().redISub(a).redISub(l);return this.curve.jpoint(x,m,v)},JPoint.prototype.mul=function t(e,n){return e=new BN$5(e,n),this.curve._wnafMul(this,e)},JPoint.prototype.eq=function t(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var n=this.z.redSqr(),a=e.z.redSqr();if(this.x.redMul(a).redISub(e.x.redMul(n)).cmpn(0)!==0)return!1;var c=n.redMul(this.z),o=a.redMul(e.z);return this.y.redMul(o).redISub(e.y.redMul(c)).cmpn(0)===0},JPoint.prototype.eqXToP=function t(e){var n=this.z.redSqr(),a=e.toRed(this.curve.red).redMul(n);if(this.x.cmp(a)===0)return!0;for(var c=e.clone(),o=this.curve.redN.redMul(n);;){if(c.iadd(this.curve.n),c.cmp(this.curve.p)>=0)return!1;if(a.redIAdd(o),this.x.cmp(a)===0)return!0}},JPoint.prototype.inspect=function t(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},JPoint.prototype.isInfinity=function t(){return this.z.cmpn(0)===0};var BN$4=bnExports,inherits$3=inherits_browserExports,Base$1=base,utils$j=utils$o;function MontCurve(t){Base$1.call(this,"mont",t),this.a=new BN$4(t.a,16).toRed(this.red),this.b=new BN$4(t.b,16).toRed(this.red),this.i4=new BN$4(4).toRed(this.red).redInvm(),this.two=new BN$4(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits$3(MontCurve,Base$1);var mont=MontCurve;MontCurve.prototype.validate=function t(e){var n=e.normalize().x,a=n.redSqr(),c=a.redMul(n).redAdd(a.redMul(this.a)).redAdd(n),o=c.redSqrt();return o.redSqr().cmp(c)===0};function Point$1(t,e,n){Base$1.BasePoint.call(this,t,"projective"),e===null&&n===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN$4(e,16),this.z=new BN$4(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits$3(Point$1,Base$1.BasePoint),MontCurve.prototype.decodePoint=function t(e,n){return this.point(utils$j.toArray(e,n),1)},MontCurve.prototype.point=function t(e,n){return new Point$1(this,e,n)},MontCurve.prototype.pointFromJSON=function t(e){return Point$1.fromJSON(this,e)},Point$1.prototype.precompute=function t(){},Point$1.prototype._encode=function t(){return this.getX().toArray("be",this.curve.p.byteLength())},Point$1.fromJSON=function t(e,n){return new Point$1(e,n[0],n[1]||e.one)},Point$1.prototype.inspect=function t(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Point$1.prototype.isInfinity=function t(){return this.z.cmpn(0)===0},Point$1.prototype.dbl=function t(){var e=this.x.redAdd(this.z),n=e.redSqr(),a=this.x.redSub(this.z),c=a.redSqr(),o=n.redSub(c),u=n.redMul(c),h=o.redMul(c.redAdd(this.curve.a24.redMul(o)));return this.curve.point(u,h)},Point$1.prototype.add=function t(){throw new Error("Not supported on Montgomery curve")},Point$1.prototype.diffAdd=function t(e,n){var a=this.x.redAdd(this.z),c=this.x.redSub(this.z),o=e.x.redAdd(e.z),u=e.x.redSub(e.z),h=u.redMul(a),l=o.redMul(c),b=n.z.redMul(h.redAdd(l).redSqr()),d=n.x.redMul(h.redISub(l).redSqr());return this.curve.point(b,d)},Point$1.prototype.mul=function t(e){for(var n=e.clone(),a=this,c=this.curve.point(null,null),o=this,u=[];n.cmpn(0)!==0;n.iushrn(1))u.push(n.andln(1));for(var h=u.length-1;h>=0;h--)u[h]===0?(a=a.diffAdd(c,o),c=c.dbl()):(c=a.diffAdd(c,o),a=a.dbl());return c},Point$1.prototype.mulAdd=function t(){throw new Error("Not supported on Montgomery curve")},Point$1.prototype.jumlAdd=function t(){throw new Error("Not supported on Montgomery curve")},Point$1.prototype.eq=function t(e){return this.getX().cmp(e.getX())===0},Point$1.prototype.normalize=function t(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point$1.prototype.getX=function t(){return this.normalize(),this.x.fromRed()};var utils$i=utils$o,BN$3=bnExports,inherits$2=inherits_browserExports,Base=base,assert$b=utils$i.assert;function EdwardsCurve(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Base.call(this,"edwards",t),this.a=new BN$3(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN$3(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN$3(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert$b(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}inherits$2(EdwardsCurve,Base);var edwards=EdwardsCurve;EdwardsCurve.prototype._mulA=function t(e){return this.mOneA?e.redNeg():this.a.redMul(e)},EdwardsCurve.prototype._mulC=function t(e){return this.oneC?e:this.c.redMul(e)},EdwardsCurve.prototype.jpoint=function t(e,n,a,c){return this.point(e,n,a,c)},EdwardsCurve.prototype.pointFromX=function t(e,n){e=new BN$3(e,16),e.red||(e=e.toRed(this.red));var a=e.redSqr(),c=this.c2.redSub(this.a.redMul(a)),o=this.one.redSub(this.c2.redMul(this.d).redMul(a)),u=c.redMul(o.redInvm()),h=u.redSqrt();if(h.redSqr().redSub(u).cmp(this.zero)!==0)throw new Error("invalid point");var l=h.fromRed().isOdd();return(n&&!l||!n&&l)&&(h=h.redNeg()),this.point(e,h)},EdwardsCurve.prototype.pointFromY=function t(e,n){e=new BN$3(e,16),e.red||(e=e.toRed(this.red));var a=e.redSqr(),c=a.redSub(this.c2),o=a.redMul(this.d).redMul(this.c2).redSub(this.a),u=c.redMul(o.redInvm());if(u.cmp(this.zero)===0){if(n)throw new Error("invalid point");return this.point(this.zero,e)}var h=u.redSqrt();if(h.redSqr().redSub(u).cmp(this.zero)!==0)throw new Error("invalid point");return h.fromRed().isOdd()!==n&&(h=h.redNeg()),this.point(h,e)},EdwardsCurve.prototype.validate=function t(e){if(e.isInfinity())return!0;e.normalize();var n=e.x.redSqr(),a=e.y.redSqr(),c=n.redMul(this.a).redAdd(a),o=this.c2.redMul(this.one.redAdd(this.d.redMul(n).redMul(a)));return c.cmp(o)===0};function Point(t,e,n,a,c){Base.BasePoint.call(this,t,"projective"),e===null&&n===null&&a===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN$3(e,16),this.y=new BN$3(n,16),this.z=a?new BN$3(a,16):this.curve.one,this.t=c&&new BN$3(c,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits$2(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function t(e){return Point.fromJSON(this,e)},EdwardsCurve.prototype.point=function t(e,n,a,c){return new Point(this,e,n,a,c)},Point.fromJSON=function t(e,n){return new Point(e,n[0],n[1],n[2])},Point.prototype.inspect=function t(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Point.prototype.isInfinity=function t(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},Point.prototype._extDbl=function t(){var e=this.x.redSqr(),n=this.y.redSqr(),a=this.z.redSqr();a=a.redIAdd(a);var c=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(n),u=c.redAdd(n),h=u.redSub(a),l=c.redSub(n),b=o.redMul(h),d=u.redMul(l),p=o.redMul(l),x=h.redMul(u);return this.curve.point(b,d,x,p)},Point.prototype._projDbl=function t(){var e=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),a=this.y.redSqr(),c,o,u,h,l,b;if(this.curve.twisted){h=this.curve._mulA(n);var d=h.redAdd(a);this.zOne?(c=e.redSub(n).redSub(a).redMul(d.redSub(this.curve.two)),o=d.redMul(h.redSub(a)),u=d.redSqr().redSub(d).redSub(d)):(l=this.z.redSqr(),b=d.redSub(l).redISub(l),c=e.redSub(n).redISub(a).redMul(b),o=d.redMul(h.redSub(a)),u=d.redMul(b))}else h=n.redAdd(a),l=this.curve._mulC(this.z).redSqr(),b=h.redSub(l).redSub(l),c=this.curve._mulC(e.redISub(h)).redMul(b),o=this.curve._mulC(h).redMul(n.redISub(a)),u=h.redMul(b);return this.curve.point(c,o,u)},Point.prototype.dbl=function t(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function t(e){var n=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),a=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),c=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),u=a.redSub(n),h=o.redSub(c),l=o.redAdd(c),b=a.redAdd(n),d=u.redMul(h),p=l.redMul(b),x=u.redMul(b),m=h.redMul(l);return this.curve.point(d,p,m,x)},Point.prototype._projAdd=function t(e){var n=this.z.redMul(e.z),a=n.redSqr(),c=this.x.redMul(e.x),o=this.y.redMul(e.y),u=this.curve.d.redMul(c).redMul(o),h=a.redSub(u),l=a.redAdd(u),b=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(c).redISub(o),d=n.redMul(h).redMul(b),p,x;return this.curve.twisted?(p=n.redMul(l).redMul(o.redSub(this.curve._mulA(c))),x=h.redMul(l)):(p=n.redMul(l).redMul(o.redSub(c)),x=this.curve._mulC(h).redMul(l)),this.curve.point(d,p,x)},Point.prototype.add=function t(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point.prototype.mul=function t(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function t(e,n,a){return this.curve._wnafMulAdd(1,[this,n],[e,a],2,!1)},Point.prototype.jmulAdd=function t(e,n,a){return this.curve._wnafMulAdd(1,[this,n],[e,a],2,!0)},Point.prototype.normalize=function t(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function t(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function t(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function t(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function t(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},Point.prototype.eqXToP=function t(e){var n=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(n)===0)return!0;for(var a=e.clone(),c=this.curve.redN.redMul(this.z);;){if(a.iadd(this.curve.n),a.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(c),this.x.cmp(n)===0)return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add,function(t){var e=t;e.base=base,e.short=short,e.mont=mont,e.edwards=edwards}(curve);var curves$1={},hash$2={},utils$h={},assert$a=minimalisticAssert,inherits$1=inherits_browserExports;utils$h.inherits=inherits$1;function isSurrogatePair(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function toArray$1(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),c=0;c<t.length;c+=2)n.push(parseInt(t[c]+t[c+1],16))}else for(var a=0,c=0;c<t.length;c++){var o=t.charCodeAt(c);o<128?n[a++]=o:o<2048?(n[a++]=o>>6|192,n[a++]=o&63|128):isSurrogatePair(t,c)?(o=65536+((o&1023)<<10)+(t.charCodeAt(++c)&1023),n[a++]=o>>18|240,n[a++]=o>>12&63|128,n[a++]=o>>6&63|128,n[a++]=o&63|128):(n[a++]=o>>12|224,n[a++]=o>>6&63|128,n[a++]=o&63|128)}else for(c=0;c<t.length;c++)n[c]=t[c]|0;return n}utils$h.toArray=toArray$1;function toHex(t){for(var e="",n=0;n<t.length;n++)e+=zero2(t[n].toString(16));return e}utils$h.toHex=toHex;function htonl(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}utils$h.htonl=htonl;function toHex32(t,e){for(var n="",a=0;a<t.length;a++){var c=t[a];e==="little"&&(c=htonl(c)),n+=zero8(c.toString(16))}return n}utils$h.toHex32=toHex32;function zero2(t){return t.length===1?"0"+t:t}utils$h.zero2=zero2;function zero8(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}utils$h.zero8=zero8;function join32(t,e,n,a){var c=n-e;assert$a(c%4===0);for(var o=new Array(c/4),u=0,h=e;u<o.length;u++,h+=4){var l;a==="big"?l=t[h]<<24|t[h+1]<<16|t[h+2]<<8|t[h+3]:l=t[h+3]<<24|t[h+2]<<16|t[h+1]<<8|t[h],o[u]=l>>>0}return o}utils$h.join32=join32;function split32(t,e){for(var n=new Array(t.length*4),a=0,c=0;a<t.length;a++,c+=4){var o=t[a];e==="big"?(n[c]=o>>>24,n[c+1]=o>>>16&255,n[c+2]=o>>>8&255,n[c+3]=o&255):(n[c+3]=o>>>24,n[c+2]=o>>>16&255,n[c+1]=o>>>8&255,n[c]=o&255)}return n}utils$h.split32=split32;function rotr32$1(t,e){return t>>>e|t<<32-e}utils$h.rotr32=rotr32$1;function rotl32$2(t,e){return t<<e|t>>>32-e}utils$h.rotl32=rotl32$2;function sum32$3(t,e){return t+e>>>0}utils$h.sum32=sum32$3;function sum32_3$1(t,e,n){return t+e+n>>>0}utils$h.sum32_3=sum32_3$1;function sum32_4$2(t,e,n,a){return t+e+n+a>>>0}utils$h.sum32_4=sum32_4$2;function sum32_5$2(t,e,n,a,c){return t+e+n+a+c>>>0}utils$h.sum32_5=sum32_5$2;function sum64$1(t,e,n,a){var c=t[e],o=t[e+1],u=a+o>>>0,h=(u<a?1:0)+n+c;t[e]=h>>>0,t[e+1]=u}utils$h.sum64=sum64$1;function sum64_hi$1(t,e,n,a){var c=e+a>>>0,o=(c<e?1:0)+t+n;return o>>>0}utils$h.sum64_hi=sum64_hi$1;function sum64_lo$1(t,e,n,a){var c=e+a;return c>>>0}utils$h.sum64_lo=sum64_lo$1;function sum64_4_hi$1(t,e,n,a,c,o,u,h){var l=0,b=e;b=b+a>>>0,l+=b<e?1:0,b=b+o>>>0,l+=b<o?1:0,b=b+h>>>0,l+=b<h?1:0;var d=t+n+c+u+l;return d>>>0}utils$h.sum64_4_hi=sum64_4_hi$1;function sum64_4_lo$1(t,e,n,a,c,o,u,h){var l=e+a+o+h;return l>>>0}utils$h.sum64_4_lo=sum64_4_lo$1;function sum64_5_hi$1(t,e,n,a,c,o,u,h,l,b){var d=0,p=e;p=p+a>>>0,d+=p<e?1:0,p=p+o>>>0,d+=p<o?1:0,p=p+h>>>0,d+=p<h?1:0,p=p+b>>>0,d+=p<b?1:0;var x=t+n+c+u+l+d;return x>>>0}utils$h.sum64_5_hi=sum64_5_hi$1;function sum64_5_lo$1(t,e,n,a,c,o,u,h,l,b){var d=e+a+o+h+b;return d>>>0}utils$h.sum64_5_lo=sum64_5_lo$1;function rotr64_hi$1(t,e,n){var a=e<<32-n|t>>>n;return a>>>0}utils$h.rotr64_hi=rotr64_hi$1;function rotr64_lo$1(t,e,n){var a=t<<32-n|e>>>n;return a>>>0}utils$h.rotr64_lo=rotr64_lo$1;function shr64_hi$1(t,e,n){return t>>>n}utils$h.shr64_hi=shr64_hi$1;function shr64_lo$1(t,e,n){var a=t<<32-n|e>>>n;return a>>>0}utils$h.shr64_lo=shr64_lo$1;var common$5={},utils$g=utils$h,assert$9=minimalisticAssert;function BlockHash$4(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}common$5.BlockHash=BlockHash$4,BlockHash$4.prototype.update=function t(e,n){if(e=utils$g.toArray(e,n),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var a=e.length%this._delta8;this.pending=e.slice(e.length-a,e.length),this.pending.length===0&&(this.pending=null),e=utils$g.join32(e,0,e.length-a,this.endian);for(var c=0;c<e.length;c+=this._delta32)this._update(e,c,c+this._delta32)}return this},BlockHash$4.prototype.digest=function t(e){return this.update(this._pad()),assert$9(this.pending===null),this._digest(e)},BlockHash$4.prototype._pad=function t(){var e=this.pendingTotal,n=this._delta8,a=n-(e+this.padLength)%n,c=new Array(a+this.padLength);c[0]=128;for(var o=1;o<a;o++)c[o]=0;if(e<<=3,this.endian==="big"){for(var u=8;u<this.padLength;u++)c[o++]=0;c[o++]=0,c[o++]=0,c[o++]=0,c[o++]=0,c[o++]=e>>>24&255,c[o++]=e>>>16&255,c[o++]=e>>>8&255,c[o++]=e&255}else for(c[o++]=e&255,c[o++]=e>>>8&255,c[o++]=e>>>16&255,c[o++]=e>>>24&255,c[o++]=0,c[o++]=0,c[o++]=0,c[o++]=0,u=8;u<this.padLength;u++)c[o++]=0;return c};var sha={},common$4={},utils$f=utils$h,rotr32=utils$f.rotr32;function ft_1$1(t,e,n,a){if(t===0)return ch32$1(e,n,a);if(t===1||t===3)return p32(e,n,a);if(t===2)return maj32$1(e,n,a)}common$4.ft_1=ft_1$1;function ch32$1(t,e,n){return t&e^~t&n}common$4.ch32=ch32$1;function maj32$1(t,e,n){return t&e^t&n^e&n}common$4.maj32=maj32$1;function p32(t,e,n){return t^e^n}common$4.p32=p32;function s0_256$1(t){return rotr32(t,2)^rotr32(t,13)^rotr32(t,22)}common$4.s0_256=s0_256$1;function s1_256$1(t){return rotr32(t,6)^rotr32(t,11)^rotr32(t,25)}common$4.s1_256=s1_256$1;function g0_256$1(t){return rotr32(t,7)^rotr32(t,18)^t>>>3}common$4.g0_256=g0_256$1;function g1_256$1(t){return rotr32(t,17)^rotr32(t,19)^t>>>10}common$4.g1_256=g1_256$1;var utils$e=utils$h,common$3=common$5,shaCommon$1=common$4,rotl32$1=utils$e.rotl32,sum32$2=utils$e.sum32,sum32_5$1=utils$e.sum32_5,ft_1=shaCommon$1.ft_1,BlockHash$3=common$3.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash$3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils$e.inherits(SHA1,BlockHash$3);var _1=SHA1;SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.prototype._update=function t(e,n){for(var a=this.W,c=0;c<16;c++)a[c]=e[n+c];for(;c<a.length;c++)a[c]=rotl32$1(a[c-3]^a[c-8]^a[c-14]^a[c-16],1);var o=this.h[0],u=this.h[1],h=this.h[2],l=this.h[3],b=this.h[4];for(c=0;c<a.length;c++){var d=~~(c/20),p=sum32_5$1(rotl32$1(o,5),ft_1(d,u,h,l),b,a[c],sha1_K[d]);b=l,l=h,h=rotl32$1(u,30),u=o,o=p}this.h[0]=sum32$2(this.h[0],o),this.h[1]=sum32$2(this.h[1],u),this.h[2]=sum32$2(this.h[2],h),this.h[3]=sum32$2(this.h[3],l),this.h[4]=sum32$2(this.h[4],b)},SHA1.prototype._digest=function t(e){return e==="hex"?utils$e.toHex32(this.h,"big"):utils$e.split32(this.h,"big")};var utils$d=utils$h,common$2=common$5,shaCommon=common$4,assert$8=minimalisticAssert,sum32$1=utils$d.sum32,sum32_4$1=utils$d.sum32_4,sum32_5=utils$d.sum32_5,ch32=shaCommon.ch32,maj32=shaCommon.maj32,s0_256=shaCommon.s0_256,s1_256=shaCommon.s1_256,g0_256=shaCommon.g0_256,g1_256=shaCommon.g1_256,BlockHash$2=common$2.BlockHash,sha256_K=[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];function SHA256$1(){if(!(this instanceof SHA256$1))return new SHA256$1;BlockHash$2.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,this.W=new Array(64)}utils$d.inherits(SHA256$1,BlockHash$2);var _256=SHA256$1;SHA256$1.blockSize=512,SHA256$1.outSize=256,SHA256$1.hmacStrength=192,SHA256$1.padLength=64,SHA256$1.prototype._update=function t(e,n){for(var a=this.W,c=0;c<16;c++)a[c]=e[n+c];for(;c<a.length;c++)a[c]=sum32_4$1(g1_256(a[c-2]),a[c-7],g0_256(a[c-15]),a[c-16]);var o=this.h[0],u=this.h[1],h=this.h[2],l=this.h[3],b=this.h[4],d=this.h[5],p=this.h[6],x=this.h[7];for(assert$8(this.k.length===a.length),c=0;c<a.length;c++){var m=sum32_5(x,s1_256(b),ch32(b,d,p),this.k[c],a[c]),v=sum32$1(s0_256(o),maj32(o,u,h));x=p,p=d,d=b,b=sum32$1(l,m),l=h,h=u,u=o,o=sum32$1(m,v)}this.h[0]=sum32$1(this.h[0],o),this.h[1]=sum32$1(this.h[1],u),this.h[2]=sum32$1(this.h[2],h),this.h[3]=sum32$1(this.h[3],l),this.h[4]=sum32$1(this.h[4],b),this.h[5]=sum32$1(this.h[5],d),this.h[6]=sum32$1(this.h[6],p),this.h[7]=sum32$1(this.h[7],x)},SHA256$1.prototype._digest=function t(e){return e==="hex"?utils$d.toHex32(this.h,"big"):utils$d.split32(this.h,"big")};var utils$c=utils$h,SHA256=_256;function SHA224(){if(!(this instanceof SHA224))return new SHA224;SHA256.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}utils$c.inherits(SHA224,SHA256);var _224=SHA224;SHA224.blockSize=512,SHA224.outSize=224,SHA224.hmacStrength=192,SHA224.padLength=64,SHA224.prototype._digest=function t(e){return e==="hex"?utils$c.toHex32(this.h.slice(0,7),"big"):utils$c.split32(this.h.slice(0,7),"big")};var utils$b=utils$h,common$1=common$5,assert$7=minimalisticAssert,rotr64_hi=utils$b.rotr64_hi,rotr64_lo=utils$b.rotr64_lo,shr64_hi=utils$b.shr64_hi,shr64_lo=utils$b.shr64_lo,sum64=utils$b.sum64,sum64_hi=utils$b.sum64_hi,sum64_lo=utils$b.sum64_lo,sum64_4_hi=utils$b.sum64_4_hi,sum64_4_lo=utils$b.sum64_4_lo,sum64_5_hi=utils$b.sum64_5_hi,sum64_5_lo=utils$b.sum64_5_lo,BlockHash$1=common$1.BlockHash,sha512_K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function SHA512$1(){if(!(this instanceof SHA512$1))return new SHA512$1;BlockHash$1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,this.W=new Array(160)}utils$b.inherits(SHA512$1,BlockHash$1);var _512=SHA512$1;SHA512$1.blockSize=1024,SHA512$1.outSize=512,SHA512$1.hmacStrength=192,SHA512$1.padLength=128,SHA512$1.prototype._prepareBlock=function t(e,n){for(var a=this.W,c=0;c<32;c++)a[c]=e[n+c];for(;c<a.length;c+=2){var o=g1_512_hi(a[c-4],a[c-3]),u=g1_512_lo(a[c-4],a[c-3]),h=a[c-14],l=a[c-13],b=g0_512_hi(a[c-30],a[c-29]),d=g0_512_lo(a[c-30],a[c-29]),p=a[c-32],x=a[c-31];a[c]=sum64_4_hi(o,u,h,l,b,d,p,x),a[c+1]=sum64_4_lo(o,u,h,l,b,d,p,x)}},SHA512$1.prototype._update=function t(e,n){this._prepareBlock(e,n);var a=this.W,c=this.h[0],o=this.h[1],u=this.h[2],h=this.h[3],l=this.h[4],b=this.h[5],d=this.h[6],p=this.h[7],x=this.h[8],m=this.h[9],v=this.h[10],g=this.h[11],$=this.h[12],B=this.h[13],C=this.h[14],F=this.h[15];assert$7(this.k.length===a.length);for(var H=0;H<a.length;H+=2){var W=C,Z=F,ie=s1_512_hi(x,m),te=s1_512_lo(x,m),ae=ch64_hi(x,m,v,g,$),de=ch64_lo(x,m,v,g,$,B),J=this.k[H],R=this.k[H+1],A=a[H],y=a[H+1],w=sum64_5_hi(W,Z,ie,te,ae,de,J,R,A,y),I=sum64_5_lo(W,Z,ie,te,ae,de,J,R,A,y);W=s0_512_hi(c,o),Z=s0_512_lo(c,o),ie=maj64_hi(c,o,u,h,l),te=maj64_lo(c,o,u,h,l,b);var M=sum64_hi(W,Z,ie,te),k=sum64_lo(W,Z,ie,te);C=$,F=B,$=v,B=g,v=x,g=m,x=sum64_hi(d,p,w,I),m=sum64_lo(p,p,w,I),d=l,p=b,l=u,b=h,u=c,h=o,c=sum64_hi(w,I,M,k),o=sum64_lo(w,I,M,k)}sum64(this.h,0,c,o),sum64(this.h,2,u,h),sum64(this.h,4,l,b),sum64(this.h,6,d,p),sum64(this.h,8,x,m),sum64(this.h,10,v,g),sum64(this.h,12,$,B),sum64(this.h,14,C,F)},SHA512$1.prototype._digest=function t(e){return e==="hex"?utils$b.toHex32(this.h,"big"):utils$b.split32(this.h,"big")};function ch64_hi(t,e,n,a,c){var o=t&n^~t&c;return o<0&&(o+=4294967296),o}function ch64_lo(t,e,n,a,c,o){var u=e&a^~e&o;return u<0&&(u+=4294967296),u}function maj64_hi(t,e,n,a,c){var o=t&n^t&c^n&c;return o<0&&(o+=4294967296),o}function maj64_lo(t,e,n,a,c,o){var u=e&a^e&o^a&o;return u<0&&(u+=4294967296),u}function s0_512_hi(t,e){var n=rotr64_hi(t,e,28),a=rotr64_hi(e,t,2),c=rotr64_hi(e,t,7),o=n^a^c;return o<0&&(o+=4294967296),o}function s0_512_lo(t,e){var n=rotr64_lo(t,e,28),a=rotr64_lo(e,t,2),c=rotr64_lo(e,t,7),o=n^a^c;return o<0&&(o+=4294967296),o}function s1_512_hi(t,e){var n=rotr64_hi(t,e,14),a=rotr64_hi(t,e,18),c=rotr64_hi(e,t,9),o=n^a^c;return o<0&&(o+=4294967296),o}function s1_512_lo(t,e){var n=rotr64_lo(t,e,14),a=rotr64_lo(t,e,18),c=rotr64_lo(e,t,9),o=n^a^c;return o<0&&(o+=4294967296),o}function g0_512_hi(t,e){var n=rotr64_hi(t,e,1),a=rotr64_hi(t,e,8),c=shr64_hi(t,e,7),o=n^a^c;return o<0&&(o+=4294967296),o}function g0_512_lo(t,e){var n=rotr64_lo(t,e,1),a=rotr64_lo(t,e,8),c=shr64_lo(t,e,7),o=n^a^c;return o<0&&(o+=4294967296),o}function g1_512_hi(t,e){var n=rotr64_hi(t,e,19),a=rotr64_hi(e,t,29),c=shr64_hi(t,e,6),o=n^a^c;return o<0&&(o+=4294967296),o}function g1_512_lo(t,e){var n=rotr64_lo(t,e,19),a=rotr64_lo(e,t,29),c=shr64_lo(t,e,6),o=n^a^c;return o<0&&(o+=4294967296),o}var utils$a=utils$h,SHA512=_512;function SHA384(){if(!(this instanceof SHA384))return new SHA384;SHA512.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}utils$a.inherits(SHA384,SHA512);var _384=SHA384;SHA384.blockSize=1024,SHA384.outSize=384,SHA384.hmacStrength=192,SHA384.padLength=128,SHA384.prototype._digest=function t(e){return e==="hex"?utils$a.toHex32(this.h.slice(0,12),"big"):utils$a.split32(this.h.slice(0,12),"big")},sha.sha1=_1,sha.sha224=_224,sha.sha256=_256,sha.sha384=_384,sha.sha512=_512;var ripemd={},utils$9=utils$h,common=common$5,rotl32=utils$9.rotl32,sum32=utils$9.sum32,sum32_3=utils$9.sum32_3,sum32_4=utils$9.sum32_4,BlockHash=common.BlockHash;function RIPEMD160(){if(!(this instanceof RIPEMD160))return new RIPEMD160;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}utils$9.inherits(RIPEMD160,BlockHash),ripemd.ripemd160=RIPEMD160,RIPEMD160.blockSize=512,RIPEMD160.outSize=160,RIPEMD160.hmacStrength=192,RIPEMD160.padLength=64,RIPEMD160.prototype._update=function t(e,n){for(var a=this.h[0],c=this.h[1],o=this.h[2],u=this.h[3],h=this.h[4],l=a,b=c,d=o,p=u,x=h,m=0;m<80;m++){var v=sum32(rotl32(sum32_4(a,f(m,c,o,u),e[r[m]+n],K(m)),s[m]),h);a=h,h=u,u=rotl32(o,10),o=c,c=v,v=sum32(rotl32(sum32_4(l,f(79-m,b,d,p),e[rh[m]+n],Kh(m)),sh[m]),x),l=x,x=p,p=rotl32(d,10),d=b,b=v}v=sum32_3(this.h[1],o,p),this.h[1]=sum32_3(this.h[2],u,x),this.h[2]=sum32_3(this.h[3],h,l),this.h[3]=sum32_3(this.h[4],a,b),this.h[4]=sum32_3(this.h[0],c,d),this.h[0]=v},RIPEMD160.prototype._digest=function t(e){return e==="hex"?utils$9.toHex32(this.h,"little"):utils$9.split32(this.h,"little")};function f(t,e,n,a){return t<=15?e^n^a:t<=31?e&n|~e&a:t<=47?(e|~n)^a:t<=63?e&a|n&~a:e^(n|~a)}function K(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function Kh(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var r=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],rh=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],s=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sh=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],utils$8=utils$h,assert$6=minimalisticAssert;function Hmac(t,e,n){if(!(this instanceof Hmac))return new Hmac(t,e,n);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(utils$8.toArray(e,n))}var hmac=Hmac;Hmac.prototype._init=function t(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),assert$6(e.length<=this.blockSize);for(var n=e.length;n<this.blockSize;n++)e.push(0);for(n=0;n<e.length;n++)e[n]^=54;for(this.inner=new this.Hash().update(e),n=0;n<e.length;n++)e[n]^=106;this.outer=new this.Hash().update(e)},Hmac.prototype.update=function t(e,n){return this.inner.update(e,n),this},Hmac.prototype.digest=function t(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=utils$h,e.common=common$5,e.sha=sha,e.ripemd=ripemd,e.hmac=hmac,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(hash$2);var secp256k1,hasRequiredSecp256k1;function requireSecp256k1(){return hasRequiredSecp256k1||(hasRequiredSecp256k1=1,secp256k1={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),secp256k1}(function(t){var e=t,n=hash$2,a=curve,c=utils$o,o=c.assert;function u(b){b.type==="short"?this.curve=new a.short(b):b.type==="edwards"?this.curve=new a.edwards(b):this.curve=new a.mont(b),this.g=this.curve.g,this.n=this.curve.n,this.hash=b.hash,o(this.g.validate(),"Invalid curve"),o(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=u;function h(b,d){Object.defineProperty(e,b,{configurable:!0,enumerable:!0,get:function(){var p=new u(d);return Object.defineProperty(e,b,{configurable:!0,enumerable:!0,value:p}),p}})}h("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:n.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),h("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:n.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),h("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:n.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),h("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:n.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),h("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:n.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),h("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:n.sha256,gRed:!1,g:["9"]}),h("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:n.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var l;try{l=requireSecp256k1()}catch{l=void 0}h("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:n.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",l]})})(curves$1);var hash$1=hash$2,utils$7=utils$n,assert$5=minimalisticAssert;function HmacDRBG(t){if(!(this instanceof HmacDRBG))return new HmacDRBG(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=utils$7.toArray(t.entropy,t.entropyEnc||"hex"),n=utils$7.toArray(t.nonce,t.nonceEnc||"hex"),a=utils$7.toArray(t.pers,t.persEnc||"hex");assert$5(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,n,a)}var hmacDrbg=HmacDRBG;HmacDRBG.prototype._init=function t(e,n,a){var c=e.concat(n).concat(a);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(c),this._reseed=1,this.reseedInterval=281474976710656},HmacDRBG.prototype._hmac=function t(){return new hash$1.hmac(this.hash,this.K)},HmacDRBG.prototype._update=function t(e){var n=this._hmac().update(this.V).update([0]);e&&(n=n.update(e)),this.K=n.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},HmacDRBG.prototype.reseed=function t(e,n,a,c){typeof n!="string"&&(c=a,a=n,n=null),e=utils$7.toArray(e,n),a=utils$7.toArray(a,c),assert$5(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(a||[])),this._reseed=1},HmacDRBG.prototype.generate=function t(e,n,a,c){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof n!="string"&&(c=a,a=n,n=null),a&&(a=utils$7.toArray(a,c||"hex"),this._update(a));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var u=o.slice(0,e);return this._update(a),this._reseed++,utils$7.encode(u,n)};var BN$2=bnExports,utils$6=utils$o,assert$4=utils$6.assert;function KeyPair$2(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var key$1=KeyPair$2;KeyPair$2.fromPublic=function t(e,n,a){return n instanceof KeyPair$2?n:new KeyPair$2(e,{pub:n,pubEnc:a})},KeyPair$2.fromPrivate=function t(e,n,a){return n instanceof KeyPair$2?n:new KeyPair$2(e,{priv:n,privEnc:a})},KeyPair$2.prototype.validate=function t(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},KeyPair$2.prototype.getPublic=function t(e,n){return typeof e=="string"&&(n=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),n?this.pub.encode(n,e):this.pub},KeyPair$2.prototype.getPrivate=function t(e){return e==="hex"?this.priv.toString(16,2):this.priv},KeyPair$2.prototype._importPrivate=function t(e,n){this.priv=new BN$2(e,n||16),this.priv=this.priv.umod(this.ec.curve.n)},KeyPair$2.prototype._importPublic=function t(e,n){if(e.x||e.y){this.ec.curve.type==="mont"?assert$4(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&assert$4(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,n)},KeyPair$2.prototype.derive=function t(e){return e.validate()||assert$4(e.validate(),"public point not validated"),e.mul(this.priv).getX()},KeyPair$2.prototype.sign=function t(e,n,a){return this.ec.sign(e,this,n,a)},KeyPair$2.prototype.verify=function t(e,n){return this.ec.verify(e,n,this)},KeyPair$2.prototype.inspect=function t(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var BN$1=bnExports,utils$5=utils$o,assert$3=utils$5.assert;function Signature$2(t,e){if(t instanceof Signature$2)return t;this._importDER(t,e)||(assert$3(t.r&&t.s,"Signature without r or s"),this.r=new BN$1(t.r,16),this.s=new BN$1(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var signature$1=Signature$2;function Position(){this.place=0}function getLength(t,e){var n=t[e.place++];if(!(n&128))return n;var a=n&15;if(a===0||a>4||t[e.place]===0)return!1;for(var c=0,o=0,u=e.place;o<a;o++,u++)c<<=8,c|=t[u],c>>>=0;return c<=127?!1:(e.place=u,c)}function rmPadding(t){for(var e=0,n=t.length-1;!t[e]&&!(t[e+1]&128)&&e<n;)e++;return e===0?t:t.slice(e)}Signature$2.prototype._importDER=function t(e,n){e=utils$5.toArray(e,n);var a=new Position;if(e[a.place++]!==48)return!1;var c=getLength(e,a);if(c===!1||c+a.place!==e.length||e[a.place++]!==2)return!1;var o=getLength(e,a);if(o===!1||e[a.place]&128)return!1;var u=e.slice(a.place,o+a.place);if(a.place+=o,e[a.place++]!==2)return!1;var h=getLength(e,a);if(h===!1||e.length!==h+a.place||e[a.place]&128)return!1;var l=e.slice(a.place,h+a.place);if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new BN$1(u),this.s=new BN$1(l),this.recoveryParam=null,!0};function constructLength(t,e){if(e<128){t.push(e);return}var n=1+(Math.log(e)/Math.LN2>>>3);for(t.push(n|128);--n;)t.push(e>>>(n<<3)&255);t.push(e)}Signature$2.prototype.toDER=function t(e){var n=this.r.toArray(),a=this.s.toArray();for(n[0]&128&&(n=[0].concat(n)),a[0]&128&&(a=[0].concat(a)),n=rmPadding(n),a=rmPadding(a);!a[0]&&!(a[1]&128);)a=a.slice(1);var c=[2];constructLength(c,n.length),c=c.concat(n),c.push(2),constructLength(c,a.length);var o=c.concat(a),u=[48];return constructLength(u,o.length),u=u.concat(o),utils$5.encode(u,e)};var ec$1,hasRequiredEc;function requireEc(){if(hasRequiredEc)return ec$1;hasRequiredEc=1;var t=bnExports,e=hmacDrbg,n=utils$o,a=curves$1,c=requireBrorand(),o=n.assert,u=key$1,h=signature$1;function l(b){if(!(this instanceof l))return new l(b);typeof b=="string"&&(o(Object.prototype.hasOwnProperty.call(a,b),"Unknown curve "+b),b=a[b]),b instanceof a.PresetCurve&&(b={curve:b}),this.curve=b.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=b.curve.g,this.g.precompute(b.curve.n.bitLength()+1),this.hash=b.hash||b.curve.hash}return ec$1=l,l.prototype.keyPair=function(d){return new u(this,d)},l.prototype.keyFromPrivate=function(d,p){return u.fromPrivate(this,d,p)},l.prototype.keyFromPublic=function(d,p){return u.fromPublic(this,d,p)},l.prototype.genKeyPair=function(d){d||(d={});for(var p=new e({hash:this.hash,pers:d.pers,persEnc:d.persEnc||"utf8",entropy:d.entropy||c(this.hash.hmacStrength),entropyEnc:d.entropy&&d.entropyEnc||"utf8",nonce:this.n.toArray()}),x=this.n.byteLength(),m=this.n.sub(new t(2));;){var v=new t(p.generate(x));if(!(v.cmp(m)>0))return v.iaddn(1),this.keyFromPrivate(v)}},l.prototype._truncateToN=function(d,p){var x=d.byteLength()*8-this.n.bitLength();return x>0&&(d=d.ushrn(x)),!p&&d.cmp(this.n)>=0?d.sub(this.n):d},l.prototype.sign=function(d,p,x,m){typeof x=="object"&&(m=x,x=null),m||(m={}),p=this.keyFromPrivate(p,x),d=this._truncateToN(new t(d,16));for(var v=this.n.byteLength(),g=p.getPrivate().toArray("be",v),$=d.toArray("be",v),B=new e({hash:this.hash,entropy:g,nonce:$,pers:m.pers,persEnc:m.persEnc||"utf8"}),C=this.n.sub(new t(1)),F=0;;F++){var H=m.k?m.k(F):new t(B.generate(this.n.byteLength()));if(H=this._truncateToN(H,!0),!(H.cmpn(1)<=0||H.cmp(C)>=0)){var W=this.g.mul(H);if(!W.isInfinity()){var Z=W.getX(),ie=Z.umod(this.n);if(ie.cmpn(0)!==0){var te=H.invm(this.n).mul(ie.mul(p.getPrivate()).iadd(d));if(te=te.umod(this.n),te.cmpn(0)!==0){var ae=(W.getY().isOdd()?1:0)|(Z.cmp(ie)!==0?2:0);return m.canonical&&te.cmp(this.nh)>0&&(te=this.n.sub(te),ae^=1),new h({r:ie,s:te,recoveryParam:ae})}}}}}},l.prototype.verify=function(d,p,x,m){d=this._truncateToN(new t(d,16)),x=this.keyFromPublic(x,m),p=new h(p,"hex");var v=p.r,g=p.s;if(v.cmpn(1)<0||v.cmp(this.n)>=0||g.cmpn(1)<0||g.cmp(this.n)>=0)return!1;var $=g.invm(this.n),B=$.mul(d).umod(this.n),C=$.mul(v).umod(this.n),F;return this.curve._maxwellTrick?(F=this.g.jmulAdd(B,x.getPublic(),C),F.isInfinity()?!1:F.eqXToP(v)):(F=this.g.mulAdd(B,x.getPublic(),C),F.isInfinity()?!1:F.getX().umod(this.n).cmp(v)===0)},l.prototype.recoverPubKey=function(b,d,p,x){o((3&p)===p,"The recovery param is more than two bits"),d=new h(d,x);var m=this.n,v=new t(b),g=d.r,$=d.s,B=p&1,C=p>>1;if(g.cmp(this.curve.p.umod(this.curve.n))>=0&&C)throw new Error("Unable to find sencond key candinate");C?g=this.curve.pointFromX(g.add(this.curve.n),B):g=this.curve.pointFromX(g,B);var F=d.r.invm(m),H=m.sub(v).mul(F).umod(m),W=$.mul(F).umod(m);return this.g.mulAdd(H,g,W)},l.prototype.getKeyRecoveryParam=function(b,d,p,x){if(d=new h(d,x),d.recoveryParam!==null)return d.recoveryParam;for(var m=0;m<4;m++){var v;try{v=this.recoverPubKey(b,d,m)}catch{continue}if(v.eq(p))return m}throw new Error("Unable to find valid recovery factor")},ec$1}var utils$4=utils$o,assert$2=utils$4.assert,parseBytes$2=utils$4.parseBytes,cachedProperty$1=utils$4.cachedProperty;function KeyPair$1(t,e){this.eddsa=t,this._secret=parseBytes$2(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=parseBytes$2(e.pub)}KeyPair$1.fromPublic=function t(e,n){return n instanceof KeyPair$1?n:new KeyPair$1(e,{pub:n})},KeyPair$1.fromSecret=function t(e,n){return n instanceof KeyPair$1?n:new KeyPair$1(e,{secret:n})},KeyPair$1.prototype.secret=function t(){return this._secret},cachedProperty$1(KeyPair$1,"pubBytes",function t(){return this.eddsa.encodePoint(this.pub())}),cachedProperty$1(KeyPair$1,"pub",function t(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),cachedProperty$1(KeyPair$1,"privBytes",function t(){var e=this.eddsa,n=this.hash(),a=e.encodingLength-1,c=n.slice(0,e.encodingLength);return c[0]&=248,c[a]&=127,c[a]|=64,c}),cachedProperty$1(KeyPair$1,"priv",function t(){return this.eddsa.decodeInt(this.privBytes())}),cachedProperty$1(KeyPair$1,"hash",function t(){return this.eddsa.hash().update(this.secret()).digest()}),cachedProperty$1(KeyPair$1,"messagePrefix",function t(){return this.hash().slice(this.eddsa.encodingLength)}),KeyPair$1.prototype.sign=function t(e){return assert$2(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},KeyPair$1.prototype.verify=function t(e,n){return this.eddsa.verify(e,n,this)},KeyPair$1.prototype.getSecret=function t(e){return assert$2(this._secret,"KeyPair is public only"),utils$4.encode(this.secret(),e)},KeyPair$1.prototype.getPublic=function t(e){return utils$4.encode(this.pubBytes(),e)};var key=KeyPair$1,BN=bnExports,utils$3=utils$o,assert$1=utils$3.assert,cachedProperty=utils$3.cachedProperty,parseBytes$1=utils$3.parseBytes;function Signature$1(t,e){this.eddsa=t,typeof e!="object"&&(e=parseBytes$1(e)),Array.isArray(e)&&(assert$1(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),assert$1(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof BN&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}cachedProperty(Signature$1,"S",function t(){return this.eddsa.decodeInt(this.Sencoded())}),cachedProperty(Signature$1,"R",function t(){return this.eddsa.decodePoint(this.Rencoded())}),cachedProperty(Signature$1,"Rencoded",function t(){return this.eddsa.encodePoint(this.R())}),cachedProperty(Signature$1,"Sencoded",function t(){return this.eddsa.encodeInt(this.S())}),Signature$1.prototype.toBytes=function t(){return this.Rencoded().concat(this.Sencoded())},Signature$1.prototype.toHex=function t(){return utils$3.encode(this.toBytes(),"hex").toUpperCase()};var signature=Signature$1,hash=hash$2,curves=curves$1,utils$2=utils$o,assert=utils$2.assert,parseBytes=utils$2.parseBytes,KeyPair=key,Signature=signature;function EDDSA(t){if(assert(t==="ed25519","only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(t);t=curves[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hash.sha512}var eddsa=EDDSA;EDDSA.prototype.sign=function t(e,n){e=parseBytes(e);var a=this.keyFromSecret(n),c=this.hashInt(a.messagePrefix(),e),o=this.g.mul(c),u=this.encodePoint(o),h=this.hashInt(u,a.pubBytes(),e).mul(a.priv()),l=c.add(h).umod(this.curve.n);return this.makeSignature({R:o,S:l,Rencoded:u})},EDDSA.prototype.verify=function t(e,n,a){if(e=parseBytes(e),n=this.makeSignature(n),n.S().gte(n.eddsa.curve.n)||n.S().isNeg())return!1;var c=this.keyFromPublic(a),o=this.hashInt(n.Rencoded(),c.pubBytes(),e),u=this.g.mul(n.S()),h=n.R().add(c.pub().mul(o));return h.eq(u)},EDDSA.prototype.hashInt=function t(){for(var e=this.hash(),n=0;n<arguments.length;n++)e.update(arguments[n]);return utils$2.intFromLE(e.digest()).umod(this.curve.n)},EDDSA.prototype.keyFromPublic=function t(e){return KeyPair.fromPublic(this,e)},EDDSA.prototype.keyFromSecret=function t(e){return KeyPair.fromSecret(this,e)},EDDSA.prototype.makeSignature=function t(e){return e instanceof Signature?e:new Signature(this,e)},EDDSA.prototype.encodePoint=function t(e){var n=e.getY().toArray("le",this.encodingLength);return n[this.encodingLength-1]|=e.getX().isOdd()?128:0,n},EDDSA.prototype.decodePoint=function t(e){e=utils$2.parseBytes(e);var n=e.length-1,a=e.slice(0,n).concat(e[n]&-129),c=(e[n]&128)!==0,o=utils$2.intFromLE(a);return this.curve.pointFromY(o,c)},EDDSA.prototype.encodeInt=function t(e){return e.toArray("le",this.encodingLength)},EDDSA.prototype.decodeInt=function t(e){return utils$2.intFromLE(e)},EDDSA.prototype.isPoint=function t(e){return e instanceof this.pointClass};var hasRequiredElliptic;function requireElliptic(){return hasRequiredElliptic||(hasRequiredElliptic=1,function(t){var e=t;e.version=require$$0.version,e.utils=utils$o,e.rand=requireBrorand(),e.curve=curve,e.curves=curves$1,e.ec=requireEc(),e.eddsa=eddsa}(elliptic)),elliptic}var ellipticExports=requireElliptic();const pkg=getDefaultExportFromCjs$1(ellipticExports),{ec}=pkg,UNCOMPRESSED_RECOVERY_ID=27,keccak256Hash=distExports.Utils.keccak256Hash;function getConsensualPrivateKey(t){return isBytes(t,32)?t:isHexString(t)&&t.length===64?hexToBytes(t):keccak256Hash(t)}function isPostageBatchId(t){return isHexString(t)&&t.length===64}function isPostageStamp(t){return isHexString(t)&&t.length===226}function publicKeyToAddress(t){return keccak256Hash(t.slice(1)).slice(12)}function hashWithEthereumPrefix(t){const e=`Ethereum Signed Message:
25
- ${t.length}`,n=new TextEncoder().encode(e);return keccak256Hash(n,t)}function defaultSign(t,e){const n=new ec("secp256k1"),a=n.keyFromPrivate(e),c=hashWithEthereumPrefix(t),o=n.sign(c,a,{canonical:!0,pers:void 0});if(o.recoveryParam===null)throw new Error("signDigest recovery param was null");return new Uint8Array([...o.r.toArray("be",32),...o.s.toArray("be",32),o.recoveryParam+UNCOMPRESSED_RECOVERY_ID])}function makePrivateKeySigner(t){const n=new ec("secp256k1").keyFromPrivate(t),a=publicKeyToAddress(n.getPublic().encode("array",!1));return{sign:c=>defaultSign(c,t),address:a}}function isObject$1(t){return t!==null&&typeof t=="object"}function isStrictlyObject(t){return isObject$1(t)&&!Array.isArray(t)}function assertSignerFn(t){if(!isStrictlyObject(t))throw new TypeError("Signer must be an object!");const e=t;if(!isBytes(e.address,20))throw new TypeError("Signer's address must be Uint8Array with 20 bytes!");if(typeof e.sign!="function")throw new TypeError("Signer sign property needs to be function!")}function makeSigner(t){if(typeof t=="string"){const e=makeHexString(t,64),n=hexToBytes(e);return makePrivateKeySigner(n)}else if(t instanceof Uint8Array)return assertBytes(t,32),makePrivateKeySigner(t);return assertSignerFn(t),t}function inProximity(t,e,n){if(t.length!==e.length||t.length!==32)throw new Error("Lengths are incorrect at proximity check");let a=0,c=n;for(;c>0;)if(c>=8){if(t[a]!==e[a])return!1;a++,c-=8}else{const o=t[a]>>>8-c,u=e[a]>>>8-c;return o===u}return!0}function isBytes(t,e){return t instanceof Uint8Array&&t.length===e}function assertBytes(t,e){if(!isBytes(t,e))throw new TypeError(`Parameter is not valid Bytes of length: ${e} !== ${t.length}`)}function serializeBytes(...t){const e=t.reduce((c,o)=>c+o.length,0),n=new Uint8Array(e);let a=0;return t.forEach(c=>{n.set(c,a),a+=c.length}),n}function bytesToHex(t,e){const n=c=>c.toString(16).padStart(2,"0"),a=Array.from(t,n).join("");if(e&&a.length!==e)throw new TypeError(`Resulting HexString does not have expected length ${e}: ${a}`);return a}function intToHex(t,e){if(!Number.isInteger(t))throw new TypeError("the value provided is not integer");if(t>Number.MAX_SAFE_INTEGER)throw new TypeError("the value provided exceeds safe integer");if(t<0)throw new TypeError("the value provided is a negative integer");const n=t.toString(16);if(e&&n.length!==e)throw new TypeError(`Resulting HexString does not have expected length ${e}: ${n}`);return n}function hexToBytes(t){assertHexString(t);const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const a=t.substr(n*2,2);e[n]=parseInt(a,16)}return e}function isHexString(t,e){return typeof t=="string"&&/^[0-9a-f]+$/i.test(t)&&(!e||t.length===e)}function isPrefixedHexString(t){return typeof t=="string"&&/^0x[0-9a-f]+$/i.test(t)}function serializePayload(t){return new TextEncoder().encode(JSON.stringify(t))}function assertHexString(t,e,n="value"){if(!isHexString(t,e)){if(isPrefixedHexString(t))throw new TypeError(`${n} not valid non prefixed hex string (has 0x prefix): ${t}`);const a=e?` of length ${e}`:"";throw new TypeError(`${n} not valid hex string${a}: ${t}`)}}function makeHexString(t,e){if(typeof t=="number")return intToHex(t,e);if(t instanceof Uint8Array)return bytesToHex(t,e);if(typeof t=="string")if(isPrefixedHexString(t)){const n=t.slice(2);if(e&&n.length!==e)throw new TypeError(`Length mismatch for valid hex string. Expecting length ${e}: ${n}`);return n}else return assertHexString(t,e),t;throw new TypeError("Not HexString compatible type!")}function wrapBytesWithHelpers(t){return Object.assign(t,{text:()=>new TextDecoder("utf-8").decode(t),json:()=>JSON.parse(new TextDecoder("utf-8").decode(t)),hex:()=>bytesToHex(t)})}async function makeSingleOwnerChunk(t,e,n){const a=t.address(),c=distExports.Utils.keccak256Hash(e,a),o=await sign(n,c),u=serializeBytes(e,o,t.span(),t.payload),h=makeSOCAddress(e,n.address);return{...t,data:()=>u,identifier:()=>e,signature:()=>o,address:()=>h,owner:()=>n.address}}function makeSOCAddress(t,e){return distExports.Utils.keccak256Hash(t,e)}async function sign(t,e){const n=await t.sign(e);if(typeof n=="string"){const a=makeHexString(n);return hexToBytes(a)}if(n instanceof Uint8Array)return n;throw new TypeError("Invalid output of sign function!")}function bind(t,e){return function(){return t.apply(e,arguments)}}const{toString}=Object.prototype,{getPrototypeOf}=Object,kindOf=(t=>e=>{const n=toString.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),kindOfTest=t=>(t=t.toLowerCase(),e=>kindOf(e)===t),typeOfTest=t=>e=>typeof e===t,{isArray}=Array,isUndefined=typeOfTest("undefined");function isBuffer(t){return t!==null&&!isUndefined(t)&&t.constructor!==null&&!isUndefined(t.constructor)&&isFunction(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const isArrayBuffer=kindOfTest("ArrayBuffer");function isArrayBufferView(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&isArrayBuffer(t.buffer),e}const isString=typeOfTest("string"),isFunction=typeOfTest("function"),isNumber=typeOfTest("number"),isObject=t=>t!==null&&typeof t=="object",isBoolean=t=>t===!0||t===!1,isPlainObject=t=>{if(kindOf(t)!=="object")return!1;const e=getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},isDate=kindOfTest("Date"),isFile=kindOfTest("File"),isBlob=kindOfTest("Blob"),isFileList=kindOfTest("FileList"),isStream=t=>isObject(t)&&isFunction(t.pipe),isFormData=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||isFunction(t.append)&&((e=kindOf(t))==="formdata"||e==="object"&&isFunction(t.toString)&&t.toString()==="[object FormData]"))},isURLSearchParams=kindOfTest("URLSearchParams"),[isReadableStream,isRequest,isResponse,isHeaders]=["ReadableStream","Request","Response","Headers"].map(kindOfTest),trim=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function forEach(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let a,c;if(typeof t!="object"&&(t=[t]),isArray(t))for(a=0,c=t.length;a<c;a++)e.call(null,t[a],a,t);else{const o=n?Object.getOwnPropertyNames(t):Object.keys(t),u=o.length;let h;for(a=0;a<u;a++)h=o[a],e.call(null,t[h],h,t)}}function findKey(t,e){e=e.toLowerCase();const n=Object.keys(t);let a=n.length,c;for(;a-- >0;)if(c=n[a],e===c.toLowerCase())return c;return null}const _global=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global$1,isContextDefined=t=>!isUndefined(t)&&t!==_global;function merge(){const{caseless:t}=isContextDefined(this)&&this||{},e={},n=(a,c)=>{const o=t&&findKey(e,c)||c;isPlainObject(e[o])&&isPlainObject(a)?e[o]=merge(e[o],a):isPlainObject(a)?e[o]=merge({},a):isArray(a)?e[o]=a.slice():e[o]=a};for(let a=0,c=arguments.length;a<c;a++)arguments[a]&&forEach(arguments[a],n);return e}const extend=(t,e,n,{allOwnKeys:a}={})=>(forEach(e,(c,o)=>{n&&isFunction(c)?t[o]=bind(c,n):t[o]=c},{allOwnKeys:a}),t),stripBOM=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),inherits=(t,e,n,a)=>{t.prototype=Object.create(e.prototype,a),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},toFlatObject=(t,e,n,a)=>{let c,o,u;const h={};if(e=e||{},t==null)return e;do{for(c=Object.getOwnPropertyNames(t),o=c.length;o-- >0;)u=c[o],(!a||a(u,t,e))&&!h[u]&&(e[u]=t[u],h[u]=!0);t=n!==!1&&getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},endsWith=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const a=t.indexOf(e,n);return a!==-1&&a===n},toArray=t=>{if(!t)return null;if(isArray(t))return t;let e=t.length;if(!isNumber(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},isTypedArray=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&getPrototypeOf(Uint8Array)),forEachEntry=(t,e)=>{const a=(t&&t[Symbol.iterator]).call(t);let c;for(;(c=a.next())&&!c.done;){const o=c.value;e.call(t,o[0],o[1])}},matchAll=(t,e)=>{let n;const a=[];for(;(n=t.exec(e))!==null;)a.push(n);return a},isHTMLForm=kindOfTest("HTMLFormElement"),toCamelCase=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,a,c){return a.toUpperCase()+c}),hasOwnProperty=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),isRegExp=kindOfTest("RegExp"),reduceDescriptors=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),a={};forEach(n,(c,o)=>{let u;(u=e(c,o,t))!==!1&&(a[o]=u||c)}),Object.defineProperties(t,a)},freezeMethods=t=>{reduceDescriptors(t,(e,n)=>{if(isFunction(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const a=t[n];if(isFunction(a)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet=(t,e)=>{const n={},a=c=>{c.forEach(o=>{n[o]=!0})};return isArray(t)?a(t):a(String(t).split(e)),n},noop=()=>{},toFiniteNumber=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,ALPHA="abcdefghijklmnopqrstuvwxyz",DIGIT="0123456789",ALPHABET={DIGIT,ALPHA,ALPHA_DIGIT:ALPHA+ALPHA.toUpperCase()+DIGIT},generateString=(t=16,e=ALPHABET.ALPHA_DIGIT)=>{let n="";const{length:a}=e;for(;t--;)n+=e[Math.random()*a|0];return n};function isSpecCompliantForm(t){return!!(t&&isFunction(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const toJSONObject=t=>{const e=new Array(10),n=(a,c)=>{if(isObject(a)){if(e.indexOf(a)>=0)return;if(!("toJSON"in a)){e[c]=a;const o=isArray(a)?[]:{};return forEach(a,(u,h)=>{const l=n(u,c+1);!isUndefined(l)&&(o[h]=l)}),e[c]=void 0,o}}return a};return n(t,0)},isAsyncFn=kindOfTest("AsyncFunction"),isThenable=t=>t&&(isObject(t)||isFunction(t))&&isFunction(t.then)&&isFunction(t.catch),_setImmediate=((t,e)=>t?setImmediate:e?((n,a)=>(_global.addEventListener("message",({source:c,data:o})=>{c===_global&&o===n&&a.length&&a.shift()()},!1),c=>{a.push(c),_global.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",isFunction(_global.postMessage)),asap=typeof queueMicrotask<"u"?queueMicrotask.bind(_global):typeof process$1<"u"&&process$1.nextTick||_setImmediate,utils$1={isArray,isArrayBuffer,isBuffer,isFormData,isArrayBufferView,isString,isNumber,isBoolean,isObject,isPlainObject,isReadableStream,isRequest,isResponse,isHeaders,isUndefined,isDate,isFile,isBlob,isRegExp,isFunction,isStream,isURLSearchParams,isTypedArray,isFileList,forEach,merge,extend,trim,stripBOM,inherits,toFlatObject,kindOf,kindOfTest,endsWith,toArray,forEachEntry,matchAll,isHTMLForm,hasOwnProperty,hasOwnProp:hasOwnProperty,reduceDescriptors,freezeMethods,toObjectSet,toCamelCase,noop,toFiniteNumber,findKey,global:_global,isContextDefined,ALPHABET,generateString,isSpecCompliantForm,toJSONObject,isAsyncFn,isThenable,setImmediate:_setImmediate,asap};function AxiosError$1(t,e,n,a,c){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),a&&(this.request=a),c&&(this.response=c,this.status=c.status?c.status:null)}utils$1.inherits(AxiosError$1,Error,{toJSON:function t(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:utils$1.toJSONObject(this.config),code:this.code,status:this.status}}});const prototype$1=AxiosError$1.prototype,descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{descriptors[t]={value:t}}),Object.defineProperties(AxiosError$1,descriptors),Object.defineProperty(prototype$1,"isAxiosError",{value:!0}),AxiosError$1.from=(t,e,n,a,c,o)=>{const u=Object.create(prototype$1);return utils$1.toFlatObject(t,u,function(l){return l!==Error.prototype},h=>h!=="isAxiosError"),AxiosError$1.call(u,t.message,e,n,a,c),u.cause=t,u.name=t.name,o&&Object.assign(u,o),u};const httpAdapter=null;function isVisitable(t){return utils$1.isPlainObject(t)||utils$1.isArray(t)}function removeBrackets(t){return utils$1.endsWith(t,"[]")?t.slice(0,-2):t}function renderKey(t,e,n){return t?t.concat(e).map(function(c,o){return c=removeBrackets(c),!n&&o?"["+c+"]":c}).join(n?".":""):e}function isFlatArray(t){return utils$1.isArray(t)&&!t.some(isVisitable)}const predicates=utils$1.toFlatObject(utils$1,{},null,function t(e){return/^is[A-Z]/.test(e)});function toFormData$1(t,e,n){if(!utils$1.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=utils$1.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,$){return!utils$1.isUndefined($[g])});const a=n.metaTokens,c=n.visitor||d,o=n.dots,u=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&utils$1.isSpecCompliantForm(e);if(!utils$1.isFunction(c))throw new TypeError("visitor must be a function");function b(v){if(v===null)return"";if(utils$1.isDate(v))return v.toISOString();if(!l&&utils$1.isBlob(v))throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");return utils$1.isArrayBuffer(v)||utils$1.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,$){let B=v;if(v&&!$&&typeof v=="object"){if(utils$1.endsWith(g,"{}"))g=a?g:g.slice(0,-2),v=JSON.stringify(v);else if(utils$1.isArray(v)&&isFlatArray(v)||(utils$1.isFileList(v)||utils$1.endsWith(g,"[]"))&&(B=utils$1.toArray(v)))return g=removeBrackets(g),B.forEach(function(F,H){!(utils$1.isUndefined(F)||F===null)&&e.append(u===!0?renderKey([g],H,o):u===null?g:g+"[]",b(F))}),!1}return isVisitable(v)?!0:(e.append(renderKey($,g,o),b(v)),!1)}const p=[],x=Object.assign(predicates,{defaultVisitor:d,convertValue:b,isVisitable});function m(v,g){if(!utils$1.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),utils$1.forEach(v,function(B,C){(!(utils$1.isUndefined(B)||B===null)&&c.call(e,B,utils$1.isString(C)?C.trim():C,g,x))===!0&&m(B,g?g.concat(C):[C])}),p.pop()}}if(!utils$1.isObject(t))throw new TypeError("data must be an object");return m(t),e}function encode$1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(a){return e[a]})}function AxiosURLSearchParams(t,e){this._pairs=[],t&&toFormData$1(t,this,e)}const prototype=AxiosURLSearchParams.prototype;prototype.append=function t(e,n){this._pairs.push([e,n])},prototype.toString=function t(e){const n=e?function(a){return e.call(this,a,encode$1)}:encode$1;return this._pairs.map(function(c){return n(c[0])+"="+n(c[1])},"").join("&")};function encode(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function buildURL(t,e,n){if(!e)return t;const a=n&&n.encode||encode;utils$1.isFunction(n)&&(n={serialize:n});const c=n&&n.serialize;let o;if(c?o=c(e,n):o=utils$1.isURLSearchParams(e)?e.toString():new AxiosURLSearchParams(e,n).toString(a),o){const u=t.indexOf("#");u!==-1&&(t=t.slice(0,u)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class InterceptorManager{constructor(){this.handlers=[]}use(e,n,a){return this.handlers.push({fulfilled:e,rejected:n,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){utils$1.forEach(this.handlers,function(a){a!==null&&e(a)})}}const transitionalDefaults={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},URLSearchParams$1=typeof URLSearchParams<"u"?URLSearchParams:AxiosURLSearchParams,FormData$1=typeof FormData<"u"?FormData:null,Blob$1=typeof Blob<"u"?Blob:null,platform$1={isBrowser:!0,classes:{URLSearchParams:URLSearchParams$1,FormData:FormData$1,Blob:Blob$1},protocols:["http","https","file","blob","url","data"]},hasBrowserEnv=typeof window<"u"&&typeof document<"u",_navigator=typeof navigator=="object"&&navigator||void 0,hasStandardBrowserEnv=hasBrowserEnv&&(!_navigator||["ReactNative","NativeScript","NS"].indexOf(_navigator.product)<0),hasStandardBrowserWebWorkerEnv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",origin=hasBrowserEnv&&window.location.href||"http://localhost",utils=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv,hasStandardBrowserEnv,hasStandardBrowserWebWorkerEnv,navigator:_navigator,origin},Symbol.toStringTag,{value:"Module"})),platform={...utils,...platform$1};function toURLEncodedForm(t,e){return toFormData$1(t,new platform.classes.URLSearchParams,Object.assign({visitor:function(n,a,c,o){return platform.isNode&&utils$1.isBuffer(n)?(this.append(a,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function parsePropPath(t){return utils$1.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function arrayToObject(t){const e={},n=Object.keys(t);let a;const c=n.length;let o;for(a=0;a<c;a++)o=n[a],e[o]=t[o];return e}function formDataToJSON(t){function e(n,a,c,o){let u=n[o++];if(u==="__proto__")return!0;const h=Number.isFinite(+u),l=o>=n.length;return u=!u&&utils$1.isArray(c)?c.length:u,l?(utils$1.hasOwnProp(c,u)?c[u]=[c[u],a]:c[u]=a,!h):((!c[u]||!utils$1.isObject(c[u]))&&(c[u]=[]),e(n,a,c[u],o)&&utils$1.isArray(c[u])&&(c[u]=arrayToObject(c[u])),!h)}if(utils$1.isFormData(t)&&utils$1.isFunction(t.entries)){const n={};return utils$1.forEachEntry(t,(a,c)=>{e(parsePropPath(a),c,n,0)}),n}return null}function stringifySafely(t,e,n){if(utils$1.isString(t))try{return(e||JSON.parse)(t),utils$1.trim(t)}catch(a){if(a.name!=="SyntaxError")throw a}return(0,JSON.stringify)(t)}const defaults={transitional:transitionalDefaults,adapter:["xhr","http","fetch"],transformRequest:[function t(e,n){const a=n.getContentType()||"",c=a.indexOf("application/json")>-1,o=utils$1.isObject(e);if(o&&utils$1.isHTMLForm(e)&&(e=new FormData(e)),utils$1.isFormData(e))return c?JSON.stringify(formDataToJSON(e)):e;if(utils$1.isArrayBuffer(e)||utils$1.isBuffer(e)||utils$1.isStream(e)||utils$1.isFile(e)||utils$1.isBlob(e)||utils$1.isReadableStream(e))return e;if(utils$1.isArrayBufferView(e))return e.buffer;if(utils$1.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let h;if(o){if(a.indexOf("application/x-www-form-urlencoded")>-1)return toURLEncodedForm(e,this.formSerializer).toString();if((h=utils$1.isFileList(e))||a.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return toFormData$1(h?{"files[]":e}:e,l&&new l,this.formSerializer)}}return o||c?(n.setContentType("application/json",!1),stringifySafely(e)):e}],transformResponse:[function t(e){const n=this.transitional||defaults.transitional,a=n&&n.forcedJSONParsing,c=this.responseType==="json";if(utils$1.isResponse(e)||utils$1.isReadableStream(e))return e;if(e&&utils$1.isString(e)&&(a&&!this.responseType||c)){const u=!(n&&n.silentJSONParsing)&&c;try{return JSON.parse(e)}catch(h){if(u)throw h.name==="SyntaxError"?AxiosError$1.from(h,AxiosError$1.ERR_BAD_RESPONSE,this,null,this.response):h}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:platform.classes.FormData,Blob:platform.classes.Blob},validateStatus:function t(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};utils$1.forEach(["delete","get","head","post","put","patch"],t=>{defaults.headers[t]={}});const ignoreDuplicateOf=utils$1.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),parseHeaders=t=>{const e={};let n,a,c;return t&&t.split(`
26
- `).forEach(function(u){c=u.indexOf(":"),n=u.substring(0,c).trim().toLowerCase(),a=u.substring(c+1).trim(),!(!n||e[n]&&ignoreDuplicateOf[n])&&(n==="set-cookie"?e[n]?e[n].push(a):e[n]=[a]:e[n]=e[n]?e[n]+", "+a:a)}),e},$internals=Symbol("internals");function normalizeHeader(t){return t&&String(t).trim().toLowerCase()}function normalizeValue(t){return t===!1||t==null?t:utils$1.isArray(t)?t.map(normalizeValue):String(t)}function parseTokens(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=n.exec(t);)e[a[1]]=a[2];return e}const isValidHeaderName=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function matchHeaderValue(t,e,n,a,c){if(utils$1.isFunction(a))return a.call(this,e,n);if(c&&(e=n),!!utils$1.isString(e)){if(utils$1.isString(a))return e.indexOf(a)!==-1;if(utils$1.isRegExp(a))return a.test(e)}}function formatHeader(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,a)=>n.toUpperCase()+a)}function buildAccessors(t,e){const n=utils$1.toCamelCase(" "+e);["get","set","has"].forEach(a=>{Object.defineProperty(t,a+n,{value:function(c,o,u){return this[a].call(this,e,c,o,u)},configurable:!0})})}let AxiosHeaders$1=class{constructor(e){e&&this.set(e)}set(e,n,a){const c=this;function o(h,l,b){const d=normalizeHeader(l);if(!d)throw new Error("header name must be a non-empty string");const p=utils$1.findKey(c,d);(!p||c[p]===void 0||b===!0||b===void 0&&c[p]!==!1)&&(c[p||l]=normalizeValue(h))}const u=(h,l)=>utils$1.forEach(h,(b,d)=>o(b,d,l));if(utils$1.isPlainObject(e)||e instanceof this.constructor)u(e,n);else if(utils$1.isString(e)&&(e=e.trim())&&!isValidHeaderName(e))u(parseHeaders(e),n);else if(utils$1.isHeaders(e))for(const[h,l]of e.entries())o(l,h,a);else e!=null&&o(n,e,a);return this}get(e,n){if(e=normalizeHeader(e),e){const a=utils$1.findKey(this,e);if(a){const c=this[a];if(!n)return c;if(n===!0)return parseTokens(c);if(utils$1.isFunction(n))return n.call(this,c,a);if(utils$1.isRegExp(n))return n.exec(c);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=normalizeHeader(e),e){const a=utils$1.findKey(this,e);return!!(a&&this[a]!==void 0&&(!n||matchHeaderValue(this,this[a],a,n)))}return!1}delete(e,n){const a=this;let c=!1;function o(u){if(u=normalizeHeader(u),u){const h=utils$1.findKey(a,u);h&&(!n||matchHeaderValue(a,a[h],h,n))&&(delete a[h],c=!0)}}return utils$1.isArray(e)?e.forEach(o):o(e),c}clear(e){const n=Object.keys(this);let a=n.length,c=!1;for(;a--;){const o=n[a];(!e||matchHeaderValue(this,this[o],o,e,!0))&&(delete this[o],c=!0)}return c}normalize(e){const n=this,a={};return utils$1.forEach(this,(c,o)=>{const u=utils$1.findKey(a,o);if(u){n[u]=normalizeValue(c),delete n[o];return}const h=e?formatHeader(o):String(o).trim();h!==o&&delete n[o],n[h]=normalizeValue(c),a[h]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return utils$1.forEach(this,(a,c)=>{a!=null&&a!==!1&&(n[c]=e&&utils$1.isArray(a)?a.join(", "):a)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
27
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const a=new this(e);return n.forEach(c=>a.set(c)),a}static accessor(e){const a=(this[$internals]=this[$internals]={accessors:{}}).accessors,c=this.prototype;function o(u){const h=normalizeHeader(u);a[h]||(buildAccessors(c,u),a[h]=!0)}return utils$1.isArray(e)?e.forEach(o):o(e),this}};AxiosHeaders$1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),utils$1.reduceDescriptors(AxiosHeaders$1.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(a){this[n]=a}}}),utils$1.freezeMethods(AxiosHeaders$1);function transformData(t,e){const n=this||defaults,a=e||n,c=AxiosHeaders$1.from(a.headers);let o=a.data;return utils$1.forEach(t,function(h){o=h.call(n,o,c.normalize(),e?e.status:void 0)}),c.normalize(),o}function isCancel$1(t){return!!(t&&t.__CANCEL__)}function CanceledError$1(t,e,n){AxiosError$1.call(this,t??"canceled",AxiosError$1.ERR_CANCELED,e,n),this.name="CanceledError"}utils$1.inherits(CanceledError$1,AxiosError$1,{__CANCEL__:!0});function settle(t,e,n){const a=n.config.validateStatus;!n.status||!a||a(n.status)?t(n):e(new AxiosError$1("Request failed with status code "+n.status,[AxiosError$1.ERR_BAD_REQUEST,AxiosError$1.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function parseProtocol(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function speedometer(t,e){t=t||10;const n=new Array(t),a=new Array(t);let c=0,o=0,u;return e=e!==void 0?e:1e3,function(l){const b=Date.now(),d=a[o];u||(u=b),n[c]=l,a[c]=b;let p=o,x=0;for(;p!==c;)x+=n[p++],p=p%t;if(c=(c+1)%t,c===o&&(o=(o+1)%t),b-u<e)return;const m=d&&b-d;return m?Math.round(x*1e3/m):void 0}}function throttle(t,e){let n=0,a=1e3/e,c,o;const u=(b,d=Date.now())=>{n=d,c=null,o&&(clearTimeout(o),o=null),t.apply(null,b)};return[(...b)=>{const d=Date.now(),p=d-n;p>=a?u(b,d):(c=b,o||(o=setTimeout(()=>{o=null,u(c)},a-p)))},()=>c&&u(c)]}const progressEventReducer=(t,e,n=3)=>{let a=0;const c=speedometer(50,250);return throttle(o=>{const u=o.loaded,h=o.lengthComputable?o.total:void 0,l=u-a,b=c(l),d=u<=h;a=u;const p={loaded:u,total:h,progress:h?u/h:void 0,bytes:l,rate:b||void 0,estimated:b&&h&&d?(h-u)/b:void 0,event:o,lengthComputable:h!=null,[e?"download":"upload"]:!0};t(p)},n)},progressEventDecorator=(t,e)=>{const n=t!=null;return[a=>e[0]({lengthComputable:n,total:t,loaded:a}),e[1]]},asyncDecorator=t=>(...e)=>utils$1.asap(()=>t(...e)),isURLSameOrigin=platform.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,platform.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(platform.origin),platform.navigator&&/(msie|trident)/i.test(platform.navigator.userAgent)):()=>!0,cookies=platform.hasStandardBrowserEnv?{write(t,e,n,a,c,o){const u=[t+"="+encodeURIComponent(e)];utils$1.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),utils$1.isString(a)&&u.push("path="+a),utils$1.isString(c)&&u.push("domain="+c),o===!0&&u.push("secure"),document.cookie=u.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function isAbsoluteURL(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function combineURLs(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function buildFullPath(t,e){return t&&!isAbsoluteURL(e)?combineURLs(t,e):e}const headersToObject=t=>t instanceof AxiosHeaders$1?{...t}:t;function mergeConfig$1(t,e){e=e||{};const n={};function a(b,d,p,x){return utils$1.isPlainObject(b)&&utils$1.isPlainObject(d)?utils$1.merge.call({caseless:x},b,d):utils$1.isPlainObject(d)?utils$1.merge({},d):utils$1.isArray(d)?d.slice():d}function c(b,d,p,x){if(utils$1.isUndefined(d)){if(!utils$1.isUndefined(b))return a(void 0,b,p,x)}else return a(b,d,p,x)}function o(b,d){if(!utils$1.isUndefined(d))return a(void 0,d)}function u(b,d){if(utils$1.isUndefined(d)){if(!utils$1.isUndefined(b))return a(void 0,b)}else return a(void 0,d)}function h(b,d,p){if(p in e)return a(b,d);if(p in t)return a(void 0,b)}const l={url:o,method:o,data:o,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:h,headers:(b,d,p)=>c(headersToObject(b),headersToObject(d),p,!0)};return utils$1.forEach(Object.keys(Object.assign({},t,e)),function(d){const p=l[d]||c,x=p(t[d],e[d],d);utils$1.isUndefined(x)&&p!==h||(n[d]=x)}),n}const resolveConfig=t=>{const e=mergeConfig$1({},t);let{data:n,withXSRFToken:a,xsrfHeaderName:c,xsrfCookieName:o,headers:u,auth:h}=e;e.headers=u=AxiosHeaders$1.from(u),e.url=buildURL(buildFullPath(e.baseURL,e.url),t.params,t.paramsSerializer),h&&u.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):"")));let l;if(utils$1.isFormData(n)){if(platform.hasStandardBrowserEnv||platform.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((l=u.getContentType())!==!1){const[b,...d]=l?l.split(";").map(p=>p.trim()).filter(Boolean):[];u.setContentType([b||"multipart/form-data",...d].join("; "))}}if(platform.hasStandardBrowserEnv&&(a&&utils$1.isFunction(a)&&(a=a(e)),a||a!==!1&&isURLSameOrigin(e.url))){const b=c&&o&&cookies.read(o);b&&u.set(c,b)}return e},isXHRAdapterSupported=typeof XMLHttpRequest<"u",xhrAdapter=isXHRAdapterSupported&&function(t){return new Promise(function(n,a){const c=resolveConfig(t);let o=c.data;const u=AxiosHeaders$1.from(c.headers).normalize();let{responseType:h,onUploadProgress:l,onDownloadProgress:b}=c,d,p,x,m,v;function g(){m&&m(),v&&v(),c.cancelToken&&c.cancelToken.unsubscribe(d),c.signal&&c.signal.removeEventListener("abort",d)}let $=new XMLHttpRequest;$.open(c.method.toUpperCase(),c.url,!0),$.timeout=c.timeout;function B(){if(!$)return;const F=AxiosHeaders$1.from("getAllResponseHeaders"in $&&$.getAllResponseHeaders()),W={data:!h||h==="text"||h==="json"?$.responseText:$.response,status:$.status,statusText:$.statusText,headers:F,config:t,request:$};settle(function(ie){n(ie),g()},function(ie){a(ie),g()},W),$=null}"onloadend"in $?$.onloadend=B:$.onreadystatechange=function(){!$||$.readyState!==4||$.status===0&&!($.responseURL&&$.responseURL.indexOf("file:")===0)||setTimeout(B)},$.onabort=function(){$&&(a(new AxiosError$1("Request aborted",AxiosError$1.ECONNABORTED,t,$)),$=null)},$.onerror=function(){a(new AxiosError$1("Network Error",AxiosError$1.ERR_NETWORK,t,$)),$=null},$.ontimeout=function(){let H=c.timeout?"timeout of "+c.timeout+"ms exceeded":"timeout exceeded";const W=c.transitional||transitionalDefaults;c.timeoutErrorMessage&&(H=c.timeoutErrorMessage),a(new AxiosError$1(H,W.clarifyTimeoutError?AxiosError$1.ETIMEDOUT:AxiosError$1.ECONNABORTED,t,$)),$=null},o===void 0&&u.setContentType(null),"setRequestHeader"in $&&utils$1.forEach(u.toJSON(),function(H,W){$.setRequestHeader(W,H)}),utils$1.isUndefined(c.withCredentials)||($.withCredentials=!!c.withCredentials),h&&h!=="json"&&($.responseType=c.responseType),b&&([x,v]=progressEventReducer(b,!0),$.addEventListener("progress",x)),l&&$.upload&&([p,m]=progressEventReducer(l),$.upload.addEventListener("progress",p),$.upload.addEventListener("loadend",m)),(c.cancelToken||c.signal)&&(d=F=>{$&&(a(!F||F.type?new CanceledError$1(null,t,$):F),$.abort(),$=null)},c.cancelToken&&c.cancelToken.subscribe(d),c.signal&&(c.signal.aborted?d():c.signal.addEventListener("abort",d)));const C=parseProtocol(c.url);if(C&&platform.protocols.indexOf(C)===-1){a(new AxiosError$1("Unsupported protocol "+C+":",AxiosError$1.ERR_BAD_REQUEST,t));return}$.send(o||null)})},composeSignals=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let a=new AbortController,c;const o=function(b){if(!c){c=!0,h();const d=b instanceof Error?b:this.reason;a.abort(d instanceof AxiosError$1?d:new CanceledError$1(d instanceof Error?d.message:d))}};let u=e&&setTimeout(()=>{u=null,o(new AxiosError$1(`timeout ${e} of ms exceeded`,AxiosError$1.ETIMEDOUT))},e);const h=()=>{t&&(u&&clearTimeout(u),u=null,t.forEach(b=>{b.unsubscribe?b.unsubscribe(o):b.removeEventListener("abort",o)}),t=null)};t.forEach(b=>b.addEventListener("abort",o));const{signal:l}=a;return l.unsubscribe=()=>utils$1.asap(h),l}},streamChunk=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let a=0,c;for(;a<n;)c=a+e,yield t.slice(a,c),a=c},readBytes=async function*(t,e){for await(const n of readStream(t))yield*streamChunk(n,e)},readStream=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:a}=await e.read();if(n)break;yield a}}finally{await e.cancel()}},trackStream=(t,e,n,a)=>{const c=readBytes(t,e);let o=0,u,h=l=>{u||(u=!0,a&&a(l))};return new ReadableStream({async pull(l){try{const{done:b,value:d}=await c.next();if(b){h(),l.close();return}let p=d.byteLength;if(n){let x=o+=p;n(x)}l.enqueue(new Uint8Array(d))}catch(b){throw h(b),b}},cancel(l){return h(l),c.return()}},{highWaterMark:2})},isFetchSupported=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",isReadableStreamSupported=isFetchSupported&&typeof ReadableStream=="function",encodeText=isFetchSupported&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),test=(t,...e)=>{try{return!!t(...e)}catch{return!1}},supportsRequestStream=isReadableStreamSupported&&test(()=>{let t=!1;const e=new Request(platform.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),DEFAULT_CHUNK_SIZE=64*1024,supportsResponseStream=isReadableStreamSupported&&test(()=>utils$1.isReadableStream(new Response("").body)),resolvers={stream:supportsResponseStream&&(t=>t.body)};isFetchSupported&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!resolvers[e]&&(resolvers[e]=utils$1.isFunction(t[e])?n=>n[e]():(n,a)=>{throw new AxiosError$1(`Response type '${e}' is not supported`,AxiosError$1.ERR_NOT_SUPPORT,a)})})})(new Response);const getBodyLength=async t=>{if(t==null)return 0;if(utils$1.isBlob(t))return t.size;if(utils$1.isSpecCompliantForm(t))return(await new Request(platform.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(utils$1.isArrayBufferView(t)||utils$1.isArrayBuffer(t))return t.byteLength;if(utils$1.isURLSearchParams(t)&&(t=t+""),utils$1.isString(t))return(await encodeText(t)).byteLength},resolveBodyLength=async(t,e)=>{const n=utils$1.toFiniteNumber(t.getContentLength());return n??getBodyLength(e)},fetchAdapter=isFetchSupported&&(async t=>{let{url:e,method:n,data:a,signal:c,cancelToken:o,timeout:u,onDownloadProgress:h,onUploadProgress:l,responseType:b,headers:d,withCredentials:p="same-origin",fetchOptions:x}=resolveConfig(t);b=b?(b+"").toLowerCase():"text";let m=composeSignals([c,o&&o.toAbortSignal()],u),v;const g=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let $;try{if(l&&supportsRequestStream&&n!=="get"&&n!=="head"&&($=await resolveBodyLength(d,a))!==0){let W=new Request(e,{method:"POST",body:a,duplex:"half"}),Z;if(utils$1.isFormData(a)&&(Z=W.headers.get("content-type"))&&d.setContentType(Z),W.body){const[ie,te]=progressEventDecorator($,progressEventReducer(asyncDecorator(l)));a=trackStream(W.body,DEFAULT_CHUNK_SIZE,ie,te)}}utils$1.isString(p)||(p=p?"include":"omit");const B="credentials"in Request.prototype;v=new Request(e,{...x,signal:m,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:a,duplex:"half",credentials:B?p:void 0});let C=await fetch(v);const F=supportsResponseStream&&(b==="stream"||b==="response");if(supportsResponseStream&&(h||F&&g)){const W={};["status","statusText","headers"].forEach(ae=>{W[ae]=C[ae]});const Z=utils$1.toFiniteNumber(C.headers.get("content-length")),[ie,te]=h&&progressEventDecorator(Z,progressEventReducer(asyncDecorator(h),!0))||[];C=new Response(trackStream(C.body,DEFAULT_CHUNK_SIZE,ie,()=>{te&&te(),g&&g()}),W)}b=b||"text";let H=await resolvers[utils$1.findKey(resolvers,b)||"text"](C,t);return!F&&g&&g(),await new Promise((W,Z)=>{settle(W,Z,{data:H,headers:AxiosHeaders$1.from(C.headers),status:C.status,statusText:C.statusText,config:t,request:v})})}catch(B){throw g&&g(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new AxiosError$1("Network Error",AxiosError$1.ERR_NETWORK,t,v),{cause:B.cause||B}):AxiosError$1.from(B,B&&B.code,t,v)}}),knownAdapters={http:httpAdapter,xhr:xhrAdapter,fetch:fetchAdapter};utils$1.forEach(knownAdapters,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const renderReason=t=>`- ${t}`,isResolvedHandle=t=>utils$1.isFunction(t)||t===null||t===!1,adapters={getAdapter:t=>{t=utils$1.isArray(t)?t:[t];const{length:e}=t;let n,a;const c={};for(let o=0;o<e;o++){n=t[o];let u;if(a=n,!isResolvedHandle(n)&&(a=knownAdapters[(u=String(n)).toLowerCase()],a===void 0))throw new AxiosError$1(`Unknown adapter '${u}'`);if(a)break;c[u||"#"+o]=a}if(!a){const o=Object.entries(c).map(([h,l])=>`adapter ${h} `+(l===!1?"is not supported by the environment":"is not available in the build"));let u=e?o.length>1?`since :
28
- `+o.map(renderReason).join(`
29
- `):" "+renderReason(o[0]):"as no adapter specified";throw new AxiosError$1("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return a},adapters:knownAdapters};function throwIfCancellationRequested(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new CanceledError$1(null,t)}function dispatchRequest(t){return throwIfCancellationRequested(t),t.headers=AxiosHeaders$1.from(t.headers),t.data=transformData.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),adapters.getAdapter(t.adapter||defaults.adapter)(t).then(function(a){return throwIfCancellationRequested(t),a.data=transformData.call(t,t.transformResponse,a),a.headers=AxiosHeaders$1.from(a.headers),a},function(a){return isCancel$1(a)||(throwIfCancellationRequested(t),a&&a.response&&(a.response.data=transformData.call(t,t.transformResponse,a.response),a.response.headers=AxiosHeaders$1.from(a.response.headers))),Promise.reject(a)})}const VERSION$1="1.7.9",validators$1={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{validators$1[t]=function(a){return typeof a===t||"a"+(e<1?"n ":" ")+t}});const deprecatedWarnings={};validators$1.transitional=function t(e,n,a){function c(o,u){return"[Axios v"+VERSION$1+"] Transitional option '"+o+"'"+u+(a?". "+a:"")}return(o,u,h)=>{if(e===!1)throw new AxiosError$1(c(u," has been removed"+(n?" in "+n:"")),AxiosError$1.ERR_DEPRECATED);return n&&!deprecatedWarnings[u]&&(deprecatedWarnings[u]=!0,console.warn(c(u," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,u,h):!0}},validators$1.spelling=function t(e){return(n,a)=>(console.warn(`${a} is likely a misspelling of ${e}`),!0)};function assertOptions(t,e,n){if(typeof t!="object")throw new AxiosError$1("options must be an object",AxiosError$1.ERR_BAD_OPTION_VALUE);const a=Object.keys(t);let c=a.length;for(;c-- >0;){const o=a[c],u=e[o];if(u){const h=t[o],l=h===void 0||u(h,o,t);if(l!==!0)throw new AxiosError$1("option "+o+" must be "+l,AxiosError$1.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new AxiosError$1("Unknown option "+o,AxiosError$1.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$1},validators=validator.validators;let Axios$1=class{constructor(e){this.defaults=e,this.interceptors={request:new InterceptorManager,response:new InterceptorManager}}async request(e,n){try{return await this._request(e,n)}catch(a){if(a instanceof Error){let c={};Error.captureStackTrace?Error.captureStackTrace(c):c=new Error;const o=c.stack?c.stack.replace(/^.+\n/,""):"";try{a.stack?o&&!String(a.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(a.stack+=`
30
- `+o):a.stack=o}catch{}}throw a}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=mergeConfig$1(this.defaults,n);const{transitional:a,paramsSerializer:c,headers:o}=n;a!==void 0&&validator.assertOptions(a,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},!1),c!=null&&(utils$1.isFunction(c)?n.paramsSerializer={serialize:c}:validator.assertOptions(c,{encode:validators.function,serialize:validators.function},!0)),validator.assertOptions(n,{baseUrl:validators.spelling("baseURL"),withXsrfToken:validators.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=o&&utils$1.merge(o.common,o[n.method]);o&&utils$1.forEach(["delete","get","head","post","put","patch","common"],v=>{delete o[v]}),n.headers=AxiosHeaders$1.concat(u,o);const h=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,h.unshift(g.fulfilled,g.rejected))});const b=[];this.interceptors.response.forEach(function(g){b.push(g.fulfilled,g.rejected)});let d,p=0,x;if(!l){const v=[dispatchRequest.bind(this),void 0];for(v.unshift.apply(v,h),v.push.apply(v,b),x=v.length,d=Promise.resolve(n);p<x;)d=d.then(v[p++],v[p++]);return d}x=h.length;let m=n;for(p=0;p<x;){const v=h[p++],g=h[p++];try{m=v(m)}catch($){g.call(this,$);break}}try{d=dispatchRequest.call(this,m)}catch(v){return Promise.reject(v)}for(p=0,x=b.length;p<x;)d=d.then(b[p++],b[p++]);return d}getUri(e){e=mergeConfig$1(this.defaults,e);const n=buildFullPath(e.baseURL,e.url);return buildURL(n,e.params,e.paramsSerializer)}};utils$1.forEach(["delete","get","head","options"],function t(e){Axios$1.prototype[e]=function(n,a){return this.request(mergeConfig$1(a||{},{method:e,url:n,data:(a||{}).data}))}}),utils$1.forEach(["post","put","patch"],function t(e){function n(a){return function(o,u,h){return this.request(mergeConfig$1(h||{},{method:e,headers:a?{"Content-Type":"multipart/form-data"}:{},url:o,data:u}))}}Axios$1.prototype[e]=n(),Axios$1.prototype[e+"Form"]=n(!0)});let CancelToken$1=class Sr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const a=this;this.promise.then(c=>{if(!a._listeners)return;let o=a._listeners.length;for(;o-- >0;)a._listeners[o](c);a._listeners=null}),this.promise.then=c=>{let o;const u=new Promise(h=>{a.subscribe(h),o=h}).then(c);return u.cancel=function(){a.unsubscribe(o)},u},e(function(o,u,h){a.reason||(a.reason=new CanceledError$1(o,u,h),n(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=a=>{e.abort(a)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new Sr(function(c){e=c}),cancel:e}}};function spread$1(t){return function(n){return t.apply(null,n)}}function isAxiosError$1(t){return utils$1.isObject(t)&&t.isAxiosError===!0}const HttpStatusCode$1={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(HttpStatusCode$1).forEach(([t,e])=>{HttpStatusCode$1[e]=t});function createInstance(t){const e=new Axios$1(t),n=bind(Axios$1.prototype.request,e);return utils$1.extend(n,Axios$1.prototype,e,{allOwnKeys:!0}),utils$1.extend(n,e,null,{allOwnKeys:!0}),n.create=function(c){return createInstance(mergeConfig$1(t,c))},n}const axios=createInstance(defaults);axios.Axios=Axios$1,axios.CanceledError=CanceledError$1,axios.CancelToken=CancelToken$1,axios.isCancel=isCancel$1,axios.VERSION=VERSION$1,axios.toFormData=toFormData$1,axios.AxiosError=AxiosError$1,axios.Cancel=axios.CanceledError,axios.all=function t(e){return Promise.all(e)},axios.spread=spread$1,axios.isAxiosError=isAxiosError$1,axios.mergeConfig=mergeConfig$1,axios.AxiosHeaders=AxiosHeaders$1,axios.formToJSON=t=>formDataToJSON(utils$1.isHTMLForm(t)?new FormData(t):t),axios.getAdapter=adapters.getAdapter,axios.HttpStatusCode=HttpStatusCode$1,axios.default=axios;const{Axios,AxiosError,CanceledError,isCancel,CancelToken,VERSION,all,Cancel,isAxiosError,spread,toFormData,AxiosHeaders,HttpStatusCode,formToJSON,getAdapter,mergeConfig}=axios;async function uploadSingleOwnerChunkData(t,e,n,a,c,o){const u=distExports.makeChunk(c),h=await makeSingleOwnerChunk(u,a,n),l=bytesToHex(h.owner()),b=bytesToHex(a),d=bytesToHex(h.signature()),p=serializeBytes(h.span(),h.payload);return await uploadSoc(t,l,b,d,p,e),h}function gsocSubscribe(t,e,n){if(assertSubscriptionHandler(n),typeof e!="string"||e.length!==64)throw new TypeError("soc address has to be an string and 32 bytes!");const a=webSocket(t,`gsoc/subscribe/${e}`);let c=!1;const o=()=>{c===!1&&(c=!0,a.terminate?a.terminate():a.close())};return a.onmessage=async u=>{const h=await prepareWebsocketData(u.data);h.length>0&&n.onMessage(wrapBytesWithHelpers(h))},a.onerror=u=>{c||n.onError(new BeeError(u.message))},o}async function uploadSoc(t,e,n,a,c,o,u){return(await http({...t,method:"post",url:`soc/${e}/${n}`,data:c,headers:{"content-type":"application/octet-stream",...extractUploadHeaders(o)},responseType:"json",params:{sig:a}})).data.reference}function assertSubscriptionHandler(t){if(!isStrictlyObject(t))throw new TypeError("SubscriptionHandler has to be object!");const e=t;if(typeof e.onMessage!="function")throw new TypeError("onMessage property of SubscriptionHandler has to be function!");if(typeof e.onError!="function")throw new TypeError("onError property of SubscriptionHandler has to be function!")}async function prepareWebsocketData(t){if(typeof t=="string")return new TextEncoder().encode(t);if(t instanceof Buffer)return new Uint8Array(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Blob)return new Uint8Array(await t.arrayBuffer());throw new TypeError("unknown websocket data type")}function webSocket(t,e){const n=t.replace(/^http/i,"ws");return new WebSocket$1(`${n}/${e}`)}function extractUploadHeaders(t,e){const n={};if(isPostageBatchId(t))n["swarm-postage-batch-id"]=t;else if(isPostageStamp(t))n["swarm-postage-stamp"]=t;else throw Error("Postage is invalid. Define either a postage batch id or a postage stamp (coming from envelope)");return n}async function http(t){var e;try{return t.headers||(t.headers={}),t.headers={...DEFAULT_HTTP_CONFIG.headers,...t.headers},await axios(t)}catch(n){throw n instanceof AxiosError?new BeeResponseError(n.message,n.code,n.status,(e=n.response)==null?void 0:e.status,n.config,n.response):n}}const DEFAULT_HTTP_CONFIG={headers:{accept:"application/json, text/plain, */*"},maxBodyLength:1/0,maxContentLength:1/0};class BeeError extends Error{constructor(e){super(e)}}class BeeResponseError extends BeeError{constructor(n,a,c,o,u,h){super(n);Ue(this,"code");Ue(this,"axiosStatus");Ue(this,"status");Ue(this,"config");Ue(this,"response");this.code=a,this.axiosStatus=c,this.status=o,this.config=u,this.response=h}}const DEFAULT_RESOURCE_ID="any",DEFAULT_POSTAGE_BATCH_ID="0000000000000000000000000000000000000000000000000000000000000000",DEFAULT_CONSENSUS_ID="SimpleGraffiti:v1";class InformationSignal{constructor(e,n){Ue(this,"postage");Ue(this,"beeApiUrl");Ue(this,"consensusHash");Ue(this,"assertGraffitiRecord");var a,c;if(assertBeeUrl(e),this.beeApiUrl=e,this.postage=(n==null?void 0:n.postage)??DEFAULT_POSTAGE_BATCH_ID,this.assertGraffitiRecord=((a=n==null?void 0:n.consensus)==null?void 0:a.assertRecord)??assertInformationSignalRecord,this.consensusHash=keccak256Hash(((c=n==null?void 0:n.consensus)==null?void 0:c.id)??DEFAULT_CONSENSUS_ID),!isHexString(this.postage))throw new Error("Postage batch id or postage stamp has to be a hex string!")}subscribe(e,n=DEFAULT_RESOURCE_ID){const a=getConsensualPrivateKey(n),c=makeSigner(a),o=makeSOCAddress(this.consensusHash,c.address),u={onMessage:l=>{try{const b=l.json();this.assertGraffitiRecord(b),e.onMessage(b)}catch(b){e.onError(b)}},onError:e.onError};return{close:gsocSubscribe(this.beeApiUrl,bytesToHex(o),u),gsocAddress:o}}listen(e,n=DEFAULT_RESOURCE_ID){return this.subscribe(e,n)}async write(e,n=DEFAULT_RESOURCE_ID,a){this.assertGraffitiRecord(e);const c=getConsensualPrivateKey(n),o=makeSigner(c);return uploadSingleOwnerChunkData({baseURL:this.beeApiUrl,...a},this.postage,o,this.consensusHash,serializePayload(e))}async send(e,n=DEFAULT_RESOURCE_ID){return this.write(e,n)}mineResourceId(e,n){if(isHexString(e)&&(e=hexToBytes(e)),typeof n!="number")throw new Error("storageDepth argument must be a number");if(n>32)throw new Error("Storage depth cannot be greater than 32!");if(e.length!==32)throw new Error("Bee address has to be 32 bytes!");const a=new Uint8Array(32);let c,o;do{for(let u=0;u<a.length;u++)if(a[u]===255)a[u]=0;else{a[u]++;break}c=makeSigner(a),o=makeSOCAddress(this.consensusHash,c.address)}while(!inProximity(e,o,n));return{resourceId:a,gsocAddress:o}}mine(e,n){return this.mineResourceId(e,n)}}function assertBeeUrl(t){if(!isValidBeeUrl(t))throw new Error("URL is not valid!")}function isValidBeeUrl(t){try{if(typeof t!="string")return!1;const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch(e){if(e instanceof TypeError||e.code!==null&&e.code==="ERR_INVALID_URL")return!1;throw e}}function isInformationSignalRecord(t){return t!==null&&typeof t=="string"}function assertInformationSignalRecord(t){if(!isInformationSignalRecord(t))throw new Error("Value is not a valid Graffiti Feed Record")}class SwarmChatUtils{constructor(e){this.UPLOAD_GSOC_TIMEOUT=2e3,this.handleError=e}generateUsersFeedId(e){return`${e}_EthercastChat_Users`}generateUserOwnedFeedId(e,n){return`${e}_EthercastChat_${n}`}initBees(e){var u;if(!e.singleBee&&!e.multiBees)throw new Error("No bees provided");const n={},a=h=>({bee:new beeJs.Bee(h.url),stamp:h.stamp,main:h.main}),c=h=>{if(!h)throw new Error("No bee configurations provided");return h.map(l=>({bee:new beeJs.Bee(l.url),stamp:l.stamp,main:l.main}))};if(e.singleBee){if(!e.singleBee.stamp)throw new Error("No postage stamp provided for the single bee");return{single:a(e.singleBee)}}const o=["gsoc","reader","writer"];for(const h of o){const l=(u=e.multiBees)==null?void 0:u[h];l&&(l.singleBee?n[h]=a(l.singleBee):l.multiBees&&(n[h]=c(l.multiBees)))}return n}selectBee(e,n,a){const c=e[n];if(!c)throw new Error(`No ${n} bees available`);if(Array.isArray(c)){if(a){const u=c.find(h=>h.main);if(u)return u}const o=c.filter(u=>!u.main);if(o.length>0){const u=Math.floor(Math.random()*o.length);return o[u]}throw new Error(`No non-main ${n} bees available`)}if(c.bee)return c;throw new Error(`No ${n} bees available`)}validateUserObject(e){try{if(typeof e.username!="string")throw"username should be a string";if(typeof e.address!="string")throw"address should be a string";if(typeof e.timestamp!="number")throw"timestamp should be number";if(typeof e.signature!="string")throw"signature should be a string";const n=["username","address","timestamp","signature","index"],a=Object.keys(e).filter(u=>!n.includes(u));if(a.length>0)throw`Unexpected properties found: ${a.join(", ")}`;const c={username:e.username,address:e.address,timestamp:e.timestamp};if(verifyMessage(JSON.stringify(c),e.signature)!==e.address)throw"Signature verification failed!";return!0}catch(n){return this.handleError({error:n,context:"This User object is not correct",throw:!1}),!1}}orderMessages(e){return e.sort((n,a)=>n.timestamp-a.timestamp)}async retryAwaitableAsync(e,n=3,a=250){return new Promise((c,o)=>{e().then(c).catch(u=>{n>0?(console.info(`Retrying... Attempts left: ${n}. Error: ${u.message}`),setTimeout(()=>{this.retryAwaitableAsync(e,n-1,a).then(c).catch(o)},a)):(this.handleError({error:u,context:`Failed after ${n} initial attempts. Last error: ${u.message}`,throw:!1}),o(u))})})}async uploadObjectToBee(e,n,a){try{return await e.uploadData(a,this.serializeGraffitiRecord(n),{redundancyLevel:4})}catch(c){return this.handleError({error:c,context:"uploadObjectToBee",throw:!1}),null}}graffitiFeedWriterFromTopic(e,n,a){const{consensusHash:c,graffitiSigner:o}=this.generateGraffitiFeedMetadata(n);return e.makeFeedWriter("sequence",c,o,a)}graffitiFeedReaderFromTopic(e,n,a){const{consensusHash:c,graffitiSigner:o}=this.generateGraffitiFeedMetadata(n);return e.makeFeedReader("sequence",c,o.address,a)}async getLatestFeedIndex(e,n,a){try{const o=await e.makeFeedReader("sequence",n,a).download(),u=parseInt(o.feedIndex.toString(),HEX_RADIX),h=parseInt(o.feedIndexNext,HEX_RADIX);return{latestIndex:u,nextIndex:h}}catch(c){if(this.isNotFoundError(c))return{latestIndex:-1,nextIndex:0};throw c}}subscribeToGsoc(e,n,a,c){try{if(!a)throw"ResourceID was not provided!";return new InformationSignal(e,{consensus:{id:`SwarmDecentralizedChat::${n}`,assertRecord:h=>{const l=JSON.parse(h);return this.validateUserObject(l)}}}).subscribe({onMessage:c,onError:console.log},a)}catch(o){return this.handleError({error:o,context:"subscribeToGSOC",throw:!0}),null}}async sendMessageToGsoc(e,n,a,c,o){try{if(!c)throw"ResourceID was not provided!";return await new InformationSignal(e,{consensus:{id:`SwarmDecentralizedChat::${a}`,assertRecord:l=>!0},postage:n}).write(o,c,{timeout:this.UPLOAD_GSOC_TIMEOUT})}catch(u){this.handleError({error:u,context:"sendMessageToGSOC",throw:!1})}}getConsensualPrivateKey(e){return beeJs.Utils.isHexString(e)&&e.length===64?beeJs.Utils.hexToBytes(e):beeJs.Utils.keccak256Hash(e)}getGraffitiWallet(e){const n=hexlify(e);return new Wallet(n)}serializeGraffitiRecord(e){return new TextEncoder().encode(JSON.stringify(e))}generateGraffitiFeedMetadata(e){const n=this.generateUsersFeedId(e),a=this.getConsensualPrivateKey(n),c=this.getGraffitiWallet(a),o={address:beeJs.Utils.hexToBytes(c.address.slice(2)),sign:async h=>await c.signMessage(h)};return{consensusHash:beeJs.Utils.keccak256Hash(CONSENSUS_ID),graffitiSigner:o}}isNotFoundError(e){return e.stack.includes("404")||e.message.includes("Not Found")||e.message.includes("404")}}class SwarmChat{constructor(e){this.emitter=new EventEmitter,this.utils=new SwarmChatUtils(this.handleError.bind(this)),this.messagesQueue=new Queue({clearWaitTime:200},this.handleError.bind(this)),this.gsocListenerQueue=new Queue({clearWaitTime:200},this.handleError.bind(this)),this.fetchMessageTimer=null,this.keepUserAliveTimer=null,this.idleUserCleanupInterval=null,this.KEEP_ALIVE_INTERVAL_TIME=2500,this.FETCH_MESSAGE_INTERVAL_TIME=1e3,this.IDLE_USER_CLEANUP_INTERVAL_TIME=5e3,this.READ_MESSAGE_TIMEOUT=1500,this.users={},this.userIndexCache={},this.userPunishmentCache={},this.tempUser=null,this.gsocResourceId=null,this.gsocSubscribtion=null,this.ownIndex=null,this.ownAddress=e.ownAddress,this.privateKey=e.privateKey,this.topic=e.topic,this.nickname=e.nickname,this.gsocResourceId=e.gsocResourceId,this.bees=this.utils.initBees(e.bees),this.KEEP_ALIVE_INTERVAL_TIME=e.keepAliveIntervalTime||this.KEEP_ALIVE_INTERVAL_TIME,this.FETCH_MESSAGE_INTERVAL_TIME=e.fetchMessageIntervalTime||this.FETCH_MESSAGE_INTERVAL_TIME,this.IDLE_USER_CLEANUP_INTERVAL_TIME=e.idleUserCleanupIntervalTime||this.IDLE_USER_CLEANUP_INTERVAL_TIME,this.READ_MESSAGE_TIMEOUT=e.readMessageTimeout||this.READ_MESSAGE_TIMEOUT}start(){this.initSelfIndex(),this.listenToNewSubscribers(),this.startKeepMeAliveProcess(),this.startMessagesFetchProcess(),this.startIdleUserCleanup()}stop(){this.stopListenToNewSubscribers(),this.stopKeepMeAliveProcess(),this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.emitter.cleanAll()}isUserRegistered(e){return!!this.users[e]}getEmitter(){return this.emitter}async initSelfIndex(){try{const e=this.utils.generateUserOwnedFeedId(this.topic,this.ownAddress),n=this.getReaderBee(),a=n.makeFeedTopic(e),{latestIndex:c}=await this.utils.retryAwaitableAsync(()=>this.utils.getLatestFeedIndex(n,a,this.ownAddress));this.ownIndex=c}catch(e){this.handleError({error:e,context:"initSelfIndex",throw:!1})}}listenToNewSubscribers(){try{if(!this.gsocResourceId)throw new Error("GSOC Resource ID is not defined");this.emitter.emit(EVENTS.LOADING_INIT_USERS,!0);const e=this.getMainGsocBee();this.gsocSubscribtion=this.utils.subscribeToGsoc(e.url,this.topic,this.gsocResourceId,n=>this.gsocListenerQueue.enqueue(()=>this.userRegistrationOnGsoc(n)))}catch(e){this.handleError({error:e,context:"Could not listen to new subscribers",throw:!0})}}async sendMessage(e){const n={id:v4(),username:this.nickname,address:this.ownAddress,timestamp:Date.now(),message:e};try{if(this.ownIndex===null)throw new Error("Cannot send message with null index");this.emitter.emit(EVENTS.MESSAGE_REQUEST_SENT,n);const{bee:a,stamp:c}=this.getWriterBee(),o=await this.utils.retryAwaitableAsync(()=>this.utils.uploadObjectToBee(a,n,c));if(!o)throw"Could not upload message data to bee";const u=this.utils.generateUserOwnedFeedId(this.topic,this.ownAddress),h=a.makeFeedTopic(u),l=a.makeFeedWriter("sequence",h,this.privateKey),b=this.ownIndex===-1?0:this.ownIndex+1;for(await l.upload(c,o.reference,{index:b}),this.ownIndex=b;!this.isUserIndexRead(this.ownAddress,this.ownIndex);)await sleep(200)}catch(a){this.emitter.emit(EVENTS.MESSAGE_REQUEST_ERROR,n),this.handleError({error:a,context:"sendMessage",throw:!1})}}async keepUserAlive(){try{if(!this.gsocResourceId)throw new Error("GSOC Resource ID is not defined");const e=this.getOwnIndex();if(e===null)return;const n=new Wallet(this.privateKey),a=n.address;if(a.toLowerCase()!==this.ownAddress.toLowerCase())throw new Error("The provided address does not match the address derived from the private key");if(this.checkUserPunishment(a))return;const c=Date.now(),o=await n.signMessage(JSON.stringify({username:this.nickname,address:a,timestamp:c})),u={address:a,timestamp:c,signature:o,index:e,username:this.nickname};if(!this.utils.validateUserObject(u))throw new Error("User object validation failed");const{bee:h,stamp:l}=this.getGsocBee(),b=await this.utils.sendMessageToGsoc(h.url,l,this.topic,this.gsocResourceId,JSON.stringify(u));if(!(b!=null&&b.payload.length))throw"Error writing User object to GSOC!"}catch(e){this.handleError({error:e,context:"registerUser",throw:!1})}}orderMessages(e){return this.utils.orderMessages(e)}isUserIndexRead(e,n){return this.userIndexCache[e]===n}setUserIndexCache(e){this.userIndexCache[e.address]=e.index}getOwnIndex(){return this.ownIndex}removeIdleUsers(){const e=Date.now();for(const n of Object.values(this.users))e-n.timestamp>30*SECOND&&delete this.users[n.address]}setUser(e){this.users[e.address]=e}checkUserPunishment(e){return this.userPunishmentCache[e]>0?(this.userPunishmentCache[e]--,!0):!1}userRegistrationOnGsoc(e){var n;try{let a;try{a=JSON.parse(e)}catch{console.error("Invalid GSOC message format:",e);return}if(((n=this.tempUser)==null?void 0:n.address)===a.address&&this.userPunishmentCache[a.address]===0&&Object.keys(this.users).length>1){this.userPunishmentCache[a.address]=Object.keys(this.users).length;return}this.setUser(a),this.tempUser=a}catch(a){this.handleError({error:a,context:"userRegisteredThroughGsoc",throw:!1})}}async readMessagesForAll(){if(!await this.messagesQueue.waitForProcessing())for(const n of Object.values(this.users))this.messagesQueue.enqueue(()=>this.readMessage(n,this.topic))}async readMessage(e,n){try{if(e.index===-1||this.isUserIndexRead(e.address,e.index))return;const c=this.getReaderBee(),o=this.utils.generateUserOwnedFeedId(n,e.address),u=c.makeFeedTopic(o),l=await c.makeFeedReader("sequence",u,e.address,{timeout:this.READ_MESSAGE_TIMEOUT}).download({index:e.index}),b=await c.downloadData(l.reference,{headers:{"Swarm-Redundancy-Level":"0"}}),d=JSON.parse(new TextDecoder().decode(b));this.emitter.emit(EVENTS.MESSAGE_RECEIVED,d),this.setUserIndexCache(e)}catch(a){a instanceof Error&&this.handleError({error:a,context:"readMessage",throw:!1})}finally{this.ownAddress===e.address&&this.emitter.emit(EVENTS.LOADING_INIT_USERS,!1)}}stopListenToNewSubscribers(){this.gsocSubscribtion&&(this.gsocSubscribtion.close(),this.gsocSubscribtion=null)}startKeepMeAliveProcess(){if(this.keepUserAliveTimer){console.warn("Keep me alive process is already running.");return}this.keepUserAliveTimer=setInterval(this.keepUserAlive.bind(this),this.KEEP_ALIVE_INTERVAL_TIME)}stopKeepMeAliveProcess(){this.keepUserAliveTimer&&(clearInterval(this.keepUserAliveTimer),this.keepUserAliveTimer=null)}startMessagesFetchProcess(){if(this.fetchMessageTimer){console.warn("Messages fetch process is already running.");return}this.fetchMessageTimer=setInterval(this.readMessagesForAll.bind(this),this.FETCH_MESSAGE_INTERVAL_TIME)}stopMessagesFetchProcess(){this.fetchMessageTimer&&(clearInterval(this.fetchMessageTimer),this.fetchMessageTimer=null)}startIdleUserCleanup(){if(this.idleUserCleanupInterval){console.warn("Idle user cleanup is already running.");return}this.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),this.IDLE_USER_CLEANUP_INTERVAL_TIME)}stopIdleUserCleanup(){this.idleUserCleanupInterval&&(clearInterval(this.idleUserCleanupInterval),this.idleUserCleanupInterval=null)}getMainGsocBee(){const{bee:e}=this.utils.selectBee(this.bees,BeeType.GSOC,!0);if(!e)throw new Error("Could not get main GSOC bee");return e}getGsocBee(){const{bee:e,stamp:n}=this.utils.selectBee(this.bees,BeeType.GSOC);if(!e)throw new Error("Could not get GSOC bee");if(!n)throw new Error("Could not get valid gsoc stamp");return{bee:e,stamp:n}}getReaderBee(){const{bee:e}=this.utils.selectBee(this.bees,BeeType.READER);if(!e)throw new Error("Could not get reader bee");return e}getWriterBee(){const{bee:e,stamp:n}=this.utils.selectBee(this.bees,BeeType.WRITER);if(!e)throw new Error("Could not get writer bee");if(!n)throw new Error("Could not get valid writer stamp");return{bee:e,stamp:n}}handleError(e){if(console.error(`Error in ${e.context}: ${e.error.message}`),this.emitter.emit(EVENTS.ERROR,e),e.throw)throw new Error(`Error in ${e.context}`)}}exports.EVENTS=EVENTS,exports.SwarmChat=SwarmChat,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
18
+ */(function(r){const e=e0,t=qy,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=h,r.SlowBuffer=W,r.INSPECT_MAX_BYTES=50;const i=2147483647;r.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:a}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const N=new s(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,s.prototype),Object.setPrototypeOf(N,_),N.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function l(N){if(N>i)throw new RangeError('The value "'+N+'" is invalid for option "size"');const _=new s(N);return Object.setPrototypeOf(_,h.prototype),_}function h(N,_,v){if(typeof N=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(N)}return g(N,_,v)}h.poolSize=8192;function g(N,_,v){if(typeof N=="string")return S(N,_);if(o.isView(N))return C(N);if(N==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof N);if(or(N,o)||N&&or(N.buffer,o)||typeof a<"u"&&(or(N,a)||N&&or(N.buffer,a)))return H(N,_,v);if(typeof N=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const $=N.valueOf&&N.valueOf();if($!=null&&$!==N)return h.from($,_,v);const K=D(N);if(K)return K;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof N[Symbol.toPrimitive]=="function")return h.from(N[Symbol.toPrimitive]("string"),_,v);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof N)}h.from=function(N,_,v){return g(N,_,v)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function b(N){if(typeof N!="number")throw new TypeError('"size" argument must be of type number');if(N<0)throw new RangeError('The value "'+N+'" is invalid for option "size"')}function w(N,_,v){return b(N),N<=0?l(N):_!==void 0?typeof v=="string"?l(N).fill(_,v):l(N).fill(_):l(N)}h.alloc=function(N,_,v){return w(N,_,v)};function I(N){return b(N),l(N<0?0:z(N)|0)}h.allocUnsafe=function(N){return I(N)},h.allocUnsafeSlow=function(N){return I(N)};function S(N,_){if((typeof _!="string"||_==="")&&(_="utf8"),!h.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const v=Z(N,_)|0;let $=l(v);const K=$.write(N,_);return K!==v&&($=$.slice(0,K)),$}function x(N){const _=N.length<0?0:z(N.length)|0,v=l(_);for(let $=0;$<_;$+=1)v[$]=N[$]&255;return v}function C(N){if(or(N,s)){const _=new s(N);return H(_.buffer,_.byteOffset,_.byteLength)}return x(N)}function H(N,_,v){if(_<0||N.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(N.byteLength<_+(v||0))throw new RangeError('"length" is outside of buffer bounds');let $;return _===void 0&&v===void 0?$=new s(N):v===void 0?$=new s(N,_):$=new s(N,_,v),Object.setPrototypeOf($,h.prototype),$}function D(N){if(h.isBuffer(N)){const _=z(N.length)|0,v=l(_);return v.length===0||N.copy(v,0,0,_),v}if(N.length!==void 0)return typeof N.length!="number"||xt(N.length)?l(0):x(N);if(N.type==="Buffer"&&Array.isArray(N.data))return x(N.data)}function z(N){if(N>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return N|0}function W(N){return+N!=N&&(N=0),h.alloc(+N)}h.isBuffer=function(_){return _!=null&&_._isBuffer===!0&&_!==h.prototype},h.compare=function(_,v){if(or(_,s)&&(_=h.from(_,_.offset,_.byteLength)),or(v,s)&&(v=h.from(v,v.offset,v.byteLength)),!h.isBuffer(_)||!h.isBuffer(v))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(_===v)return 0;let $=_.length,K=v.length;for(let Y=0,ae=Math.min($,K);Y<ae;++Y)if(_[Y]!==v[Y]){$=_[Y],K=v[Y];break}return $<K?-1:K<$?1:0},h.isEncoding=function(_){switch(String(_).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(_,v){if(!Array.isArray(_))throw new TypeError('"list" argument must be an Array of Buffers');if(_.length===0)return h.alloc(0);let $;if(v===void 0)for(v=0,$=0;$<_.length;++$)v+=_[$].length;const K=h.allocUnsafe(v);let Y=0;for($=0;$<_.length;++$){let ae=_[$];if(or(ae,s))Y+ae.length>K.length?(h.isBuffer(ae)||(ae=h.from(ae)),ae.copy(K,Y)):s.prototype.set.call(K,ae,Y);else if(h.isBuffer(ae))ae.copy(K,Y);else throw new TypeError('"list" argument must be an Array of Buffers');Y+=ae.length}return K};function Z(N,_){if(h.isBuffer(N))return N.length;if(o.isView(N)||or(N,o))return N.byteLength;if(typeof N!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof N);const v=N.length,$=arguments.length>2&&arguments[2]===!0;if(!$&&v===0)return 0;let K=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return v;case"utf8":case"utf-8":return It(N).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v*2;case"hex":return v>>>1;case"base64":return pt(N).length;default:if(K)return $?-1:It(N).length;_=(""+_).toLowerCase(),K=!0}}h.byteLength=Z;function j(N,_,v){let $=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((v===void 0||v>this.length)&&(v=this.length),v<=0)||(v>>>=0,_>>>=0,v<=_))return"";for(N||(N="utf8");;)switch(N){case"hex":return A(this,_,v);case"utf8":case"utf-8":return k(this,_,v);case"ascii":return G(this,_,v);case"latin1":case"binary":return P(this,_,v);case"base64":return E(this,_,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,_,v);default:if($)throw new TypeError("Unknown encoding: "+N);N=(N+"").toLowerCase(),$=!0}}h.prototype._isBuffer=!0;function V(N,_,v){const $=N[_];N[_]=N[v],N[v]=$}h.prototype.swap16=function(){const _=this.length;if(_%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let v=0;v<_;v+=2)V(this,v,v+1);return this},h.prototype.swap32=function(){const _=this.length;if(_%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let v=0;v<_;v+=4)V(this,v,v+3),V(this,v+1,v+2);return this},h.prototype.swap64=function(){const _=this.length;if(_%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let v=0;v<_;v+=8)V(this,v,v+7),V(this,v+1,v+6),V(this,v+2,v+5),V(this,v+3,v+4);return this},h.prototype.toString=function(){const _=this.length;return _===0?"":arguments.length===0?k(this,0,_):j.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(_){if(!h.isBuffer(_))throw new TypeError("Argument must be a Buffer");return this===_?!0:h.compare(this,_)===0},h.prototype.inspect=function(){let _="";const v=r.INSPECT_MAX_BYTES;return _=this.toString("hex",0,v).replace(/(.{2})/g,"$1 ").trim(),this.length>v&&(_+=" ... "),"<Buffer "+_+">"},n&&(h.prototype[n]=h.prototype.inspect),h.prototype.compare=function(_,v,$,K,Y){if(or(_,s)&&(_=h.from(_,_.offset,_.byteLength)),!h.isBuffer(_))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof _);if(v===void 0&&(v=0),$===void 0&&($=_?_.length:0),K===void 0&&(K=0),Y===void 0&&(Y=this.length),v<0||$>_.length||K<0||Y>this.length)throw new RangeError("out of range index");if(K>=Y&&v>=$)return 0;if(K>=Y)return-1;if(v>=$)return 1;if(v>>>=0,$>>>=0,K>>>=0,Y>>>=0,this===_)return 0;let ae=Y-K,Ye=$-v;const qe=Math.min(ae,Ye),We=this.slice(K,Y),$t=_.slice(v,$);for(let Ge=0;Ge<qe;++Ge)if(We[Ge]!==$t[Ge]){ae=We[Ge],Ye=$t[Ge];break}return ae<Ye?-1:Ye<ae?1:0};function oe(N,_,v,$,K){if(N.length===0)return-1;if(typeof v=="string"?($=v,v=0):v>2147483647?v=2147483647:v<-2147483648&&(v=-2147483648),v=+v,xt(v)&&(v=K?0:N.length-1),v<0&&(v=N.length+v),v>=N.length){if(K)return-1;v=N.length-1}else if(v<0)if(K)v=0;else return-1;if(typeof _=="string"&&(_=h.from(_,$)),h.isBuffer(_))return _.length===0?-1:ce(N,_,v,$,K);if(typeof _=="number")return _=_&255,typeof s.prototype.indexOf=="function"?K?s.prototype.indexOf.call(N,_,v):s.prototype.lastIndexOf.call(N,_,v):ce(N,[_],v,$,K);throw new TypeError("val must be string, number or Buffer")}function ce(N,_,v,$,K){let Y=1,ae=N.length,Ye=_.length;if($!==void 0&&($=String($).toLowerCase(),$==="ucs2"||$==="ucs-2"||$==="utf16le"||$==="utf-16le")){if(N.length<2||_.length<2)return-1;Y=2,ae/=2,Ye/=2,v/=2}function qe($t,Ge){return Y===1?$t[Ge]:$t.readUInt16BE(Ge*Y)}let We;if(K){let $t=-1;for(We=v;We<ae;We++)if(qe(N,We)===qe(_,$t===-1?0:We-$t)){if($t===-1&&($t=We),We-$t+1===Ye)return $t*Y}else $t!==-1&&(We-=We-$t),$t=-1}else for(v+Ye>ae&&(v=ae-Ye),We=v;We>=0;We--){let $t=!0;for(let Ge=0;Ge<Ye;Ge++)if(qe(N,We+Ge)!==qe(_,Ge)){$t=!1;break}if($t)return We}return-1}h.prototype.includes=function(_,v,$){return this.indexOf(_,v,$)!==-1},h.prototype.indexOf=function(_,v,$){return oe(this,_,v,$,!0)},h.prototype.lastIndexOf=function(_,v,$){return oe(this,_,v,$,!1)};function ie(N,_,v,$){v=Number(v)||0;const K=N.length-v;$?($=Number($),$>K&&($=K)):$=K;const Y=_.length;$>Y/2&&($=Y/2);let ae;for(ae=0;ae<$;++ae){const Ye=parseInt(_.substr(ae*2,2),16);if(xt(Ye))return ae;N[v+ae]=Ye}return ae}function ue(N,_,v,$){return St(It(_,N.length-v),N,v,$)}function B(N,_,v,$){return St(Ct(_),N,v,$)}function p(N,_,v,$){return St(pt(_),N,v,$)}function m(N,_,v,$){return St(kr(_,N.length-v),N,v,$)}h.prototype.write=function(_,v,$,K){if(v===void 0)K="utf8",$=this.length,v=0;else if($===void 0&&typeof v=="string")K=v,$=this.length,v=0;else if(isFinite(v))v=v>>>0,isFinite($)?($=$>>>0,K===void 0&&(K="utf8")):(K=$,$=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Y=this.length-v;if(($===void 0||$>Y)&&($=Y),_.length>0&&($<0||v<0)||v>this.length)throw new RangeError("Attempt to write outside buffer bounds");K||(K="utf8");let ae=!1;for(;;)switch(K){case"hex":return ie(this,_,v,$);case"utf8":case"utf-8":return ue(this,_,v,$);case"ascii":case"latin1":case"binary":return B(this,_,v,$);case"base64":return p(this,_,v,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,_,v,$);default:if(ae)throw new TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),ae=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(N,_,v){return _===0&&v===N.length?e.fromByteArray(N):e.fromByteArray(N.slice(_,v))}function k(N,_,v){v=Math.min(N.length,v);const $=[];let K=_;for(;K<v;){const Y=N[K];let ae=null,Ye=Y>239?4:Y>223?3:Y>191?2:1;if(K+Ye<=v){let qe,We,$t,Ge;switch(Ye){case 1:Y<128&&(ae=Y);break;case 2:qe=N[K+1],(qe&192)===128&&(Ge=(Y&31)<<6|qe&63,Ge>127&&(ae=Ge));break;case 3:qe=N[K+1],We=N[K+2],(qe&192)===128&&(We&192)===128&&(Ge=(Y&15)<<12|(qe&63)<<6|We&63,Ge>2047&&(Ge<55296||Ge>57343)&&(ae=Ge));break;case 4:qe=N[K+1],We=N[K+2],$t=N[K+3],(qe&192)===128&&(We&192)===128&&($t&192)===128&&(Ge=(Y&15)<<18|(qe&63)<<12|(We&63)<<6|$t&63,Ge>65535&&Ge<1114112&&(ae=Ge))}}ae===null?(ae=65533,Ye=1):ae>65535&&(ae-=65536,$.push(ae>>>10&1023|55296),ae=56320|ae&1023),$.push(ae),K+=Ye}return M($)}const O=4096;function M(N){const _=N.length;if(_<=O)return String.fromCharCode.apply(String,N);let v="",$=0;for(;$<_;)v+=String.fromCharCode.apply(String,N.slice($,$+=O));return v}function G(N,_,v){let $="";v=Math.min(N.length,v);for(let K=_;K<v;++K)$+=String.fromCharCode(N[K]&127);return $}function P(N,_,v){let $="";v=Math.min(N.length,v);for(let K=_;K<v;++K)$+=String.fromCharCode(N[K]);return $}function A(N,_,v){const $=N.length;(!_||_<0)&&(_=0),(!v||v<0||v>$)&&(v=$);let K="";for(let Y=_;Y<v;++Y)K+=Bt[N[Y]];return K}function U(N,_,v){const $=N.slice(_,v);let K="";for(let Y=0;Y<$.length-1;Y+=2)K+=String.fromCharCode($[Y]+$[Y+1]*256);return K}h.prototype.slice=function(_,v){const $=this.length;_=~~_,v=v===void 0?$:~~v,_<0?(_+=$,_<0&&(_=0)):_>$&&(_=$),v<0?(v+=$,v<0&&(v=0)):v>$&&(v=$),v<_&&(v=_);const K=this.subarray(_,v);return Object.setPrototypeOf(K,h.prototype),K};function le(N,_,v){if(N%1!==0||N<0)throw new RangeError("offset is not uint");if(N+_>v)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=this[_],Y=1,ae=0;for(;++ae<v&&(Y*=256);)K+=this[_+ae]*Y;return K},h.prototype.readUintBE=h.prototype.readUIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=this[_+--v],Y=1;for(;v>0&&(Y*=256);)K+=this[_+--v]*Y;return K},h.prototype.readUint8=h.prototype.readUInt8=function(_,v){return _=_>>>0,v||le(_,1,this.length),this[_]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(_,v){return _=_>>>0,v||le(_,2,this.length),this[_]|this[_+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(_,v){return _=_>>>0,v||le(_,2,this.length),this[_]<<8|this[_+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(_,v){return _=_>>>0,v||le(_,4,this.length),(this[_]|this[_+1]<<8|this[_+2]<<16)+this[_+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]*16777216+(this[_+1]<<16|this[_+2]<<8|this[_+3])},h.prototype.readBigUInt64LE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const K=v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24,Y=this[++_]+this[++_]*2**8+this[++_]*2**16+$*2**24;return BigInt(K)+(BigInt(Y)<<BigInt(32))}),h.prototype.readBigUInt64BE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const K=v*2**24+this[++_]*2**16+this[++_]*2**8+this[++_],Y=this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$;return(BigInt(K)<<BigInt(32))+BigInt(Y)}),h.prototype.readIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=this[_],Y=1,ae=0;for(;++ae<v&&(Y*=256);)K+=this[_+ae]*Y;return Y*=128,K>=Y&&(K-=Math.pow(2,8*v)),K},h.prototype.readIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=v,Y=1,ae=this[_+--K];for(;K>0&&(Y*=256);)ae+=this[_+--K]*Y;return Y*=128,ae>=Y&&(ae-=Math.pow(2,8*v)),ae},h.prototype.readInt8=function(_,v){return _=_>>>0,v||le(_,1,this.length),this[_]&128?(255-this[_]+1)*-1:this[_]},h.prototype.readInt16LE=function(_,v){_=_>>>0,v||le(_,2,this.length);const $=this[_]|this[_+1]<<8;return $&32768?$|4294901760:$},h.prototype.readInt16BE=function(_,v){_=_>>>0,v||le(_,2,this.length);const $=this[_+1]|this[_]<<8;return $&32768?$|4294901760:$},h.prototype.readInt32LE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]|this[_+1]<<8|this[_+2]<<16|this[_+3]<<24},h.prototype.readInt32BE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]<<24|this[_+1]<<16|this[_+2]<<8|this[_+3]},h.prototype.readBigInt64LE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const K=this[_+4]+this[_+5]*2**8+this[_+6]*2**16+($<<24);return(BigInt(K)<<BigInt(32))+BigInt(v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24)}),h.prototype.readBigInt64BE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const K=(v<<24)+this[++_]*2**16+this[++_]*2**8+this[++_];return(BigInt(K)<<BigInt(32))+BigInt(this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$)}),h.prototype.readFloatLE=function(_,v){return _=_>>>0,v||le(_,4,this.length),t.read(this,_,!0,23,4)},h.prototype.readFloatBE=function(_,v){return _=_>>>0,v||le(_,4,this.length),t.read(this,_,!1,23,4)},h.prototype.readDoubleLE=function(_,v){return _=_>>>0,v||le(_,8,this.length),t.read(this,_,!0,52,8)},h.prototype.readDoubleBE=function(_,v){return _=_>>>0,v||le(_,8,this.length),t.read(this,_,!1,52,8)};function te(N,_,v,$,K,Y){if(!h.isBuffer(N))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>K||_<Y)throw new RangeError('"value" argument is out of bounds');if(v+$>N.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(_,v,$,K){if(_=+_,v=v>>>0,$=$>>>0,!K){const Ye=Math.pow(2,8*$)-1;te(this,_,v,$,Ye,0)}let Y=1,ae=0;for(this[v]=_&255;++ae<$&&(Y*=256);)this[v+ae]=_/Y&255;return v+$},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(_,v,$,K){if(_=+_,v=v>>>0,$=$>>>0,!K){const Ye=Math.pow(2,8*$)-1;te(this,_,v,$,Ye,0)}let Y=$-1,ae=1;for(this[v+Y]=_&255;--Y>=0&&(ae*=256);)this[v+Y]=_/ae&255;return v+$},h.prototype.writeUint8=h.prototype.writeUInt8=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,1,255,0),this[v]=_&255,v+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,65535,0),this[v]=_&255,this[v+1]=_>>>8,v+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,65535,0),this[v]=_>>>8,this[v+1]=_&255,v+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,4294967295,0),this[v+3]=_>>>24,this[v+2]=_>>>16,this[v+1]=_>>>8,this[v]=_&255,v+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,4294967295,0),this[v]=_>>>24,this[v+1]=_>>>16,this[v+2]=_>>>8,this[v+3]=_&255,v+4};function re(N,_,v,$,K){ot(_,$,K,N,v,7);let Y=Number(_&BigInt(4294967295));N[v++]=Y,Y=Y>>8,N[v++]=Y,Y=Y>>8,N[v++]=Y,Y=Y>>8,N[v++]=Y;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return N[v++]=ae,ae=ae>>8,N[v++]=ae,ae=ae>>8,N[v++]=ae,ae=ae>>8,N[v++]=ae,v}function he(N,_,v,$,K){ot(_,$,K,N,v,7);let Y=Number(_&BigInt(4294967295));N[v+7]=Y,Y=Y>>8,N[v+6]=Y,Y=Y>>8,N[v+5]=Y,Y=Y>>8,N[v+4]=Y;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return N[v+3]=ae,ae=ae>>8,N[v+2]=ae,ae=ae>>8,N[v+1]=ae,ae=ae>>8,N[v]=ae,v+8}h.prototype.writeBigUInt64LE=fn(function(_,v=0){return re(this,_,v,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=fn(function(_,v=0){return he(this,_,v,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(_,v,$,K){if(_=+_,v=v>>>0,!K){const qe=Math.pow(2,8*$-1);te(this,_,v,$,qe-1,-qe)}let Y=0,ae=1,Ye=0;for(this[v]=_&255;++Y<$&&(ae*=256);)_<0&&Ye===0&&this[v+Y-1]!==0&&(Ye=1),this[v+Y]=(_/ae>>0)-Ye&255;return v+$},h.prototype.writeIntBE=function(_,v,$,K){if(_=+_,v=v>>>0,!K){const qe=Math.pow(2,8*$-1);te(this,_,v,$,qe-1,-qe)}let Y=$-1,ae=1,Ye=0;for(this[v+Y]=_&255;--Y>=0&&(ae*=256);)_<0&&Ye===0&&this[v+Y+1]!==0&&(Ye=1),this[v+Y]=(_/ae>>0)-Ye&255;return v+$},h.prototype.writeInt8=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,1,127,-128),_<0&&(_=255+_+1),this[v]=_&255,v+1},h.prototype.writeInt16LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,32767,-32768),this[v]=_&255,this[v+1]=_>>>8,v+2},h.prototype.writeInt16BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,32767,-32768),this[v]=_>>>8,this[v+1]=_&255,v+2},h.prototype.writeInt32LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,2147483647,-2147483648),this[v]=_&255,this[v+1]=_>>>8,this[v+2]=_>>>16,this[v+3]=_>>>24,v+4},h.prototype.writeInt32BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,2147483647,-2147483648),_<0&&(_=4294967295+_+1),this[v]=_>>>24,this[v+1]=_>>>16,this[v+2]=_>>>8,this[v+3]=_&255,v+4},h.prototype.writeBigInt64LE=fn(function(_,v=0){return re(this,_,v,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=fn(function(_,v=0){return he(this,_,v,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ye(N,_,v,$,K,Y){if(v+$>N.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("Index out of range")}function be(N,_,v,$,K){return _=+_,v=v>>>0,K||ye(N,_,v,4),t.write(N,_,v,$,23,4),v+4}h.prototype.writeFloatLE=function(_,v,$){return be(this,_,v,!0,$)},h.prototype.writeFloatBE=function(_,v,$){return be(this,_,v,!1,$)};function Ve(N,_,v,$,K){return _=+_,v=v>>>0,K||ye(N,_,v,8),t.write(N,_,v,$,52,8),v+8}h.prototype.writeDoubleLE=function(_,v,$){return Ve(this,_,v,!0,$)},h.prototype.writeDoubleBE=function(_,v,$){return Ve(this,_,v,!1,$)},h.prototype.copy=function(_,v,$,K){if(!h.isBuffer(_))throw new TypeError("argument should be a Buffer");if($||($=0),!K&&K!==0&&(K=this.length),v>=_.length&&(v=_.length),v||(v=0),K>0&&K<$&&(K=$),K===$||_.length===0||this.length===0)return 0;if(v<0)throw new RangeError("targetStart out of bounds");if($<0||$>=this.length)throw new RangeError("Index out of range");if(K<0)throw new RangeError("sourceEnd out of bounds");K>this.length&&(K=this.length),_.length-v<K-$&&(K=_.length-v+$);const Y=K-$;return this===_&&typeof s.prototype.copyWithin=="function"?this.copyWithin(v,$,K):s.prototype.set.call(_,this.subarray($,K),v),Y},h.prototype.fill=function(_,v,$,K){if(typeof _=="string"){if(typeof v=="string"?(K=v,v=0,$=this.length):typeof $=="string"&&(K=$,$=this.length),K!==void 0&&typeof K!="string")throw new TypeError("encoding must be a string");if(typeof K=="string"&&!h.isEncoding(K))throw new TypeError("Unknown encoding: "+K);if(_.length===1){const ae=_.charCodeAt(0);(K==="utf8"&&ae<128||K==="latin1")&&(_=ae)}}else typeof _=="number"?_=_&255:typeof _=="boolean"&&(_=Number(_));if(v<0||this.length<v||this.length<$)throw new RangeError("Out of range index");if($<=v)return this;v=v>>>0,$=$===void 0?this.length:$>>>0,_||(_=0);let Y;if(typeof _=="number")for(Y=v;Y<$;++Y)this[Y]=_;else{const ae=h.isBuffer(_)?_:h.from(_,K),Ye=ae.length;if(Ye===0)throw new TypeError('The value "'+_+'" is invalid for argument "value"');for(Y=0;Y<$-v;++Y)this[Y+v]=ae[Y%Ye]}return this};const Fe={};function Be(N,_,v){Fe[N]=class extends v{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${N}]`,this.stack,delete this.name}get code(){return N}set code(K){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:K,writable:!0})}toString(){return`${this.name} [${N}]: ${this.message}`}}}Be("ERR_BUFFER_OUT_OF_BOUNDS",function(N){return N?`${N} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Be("ERR_INVALID_ARG_TYPE",function(N,_){return`The "${N}" argument must be of type number. Received type ${typeof _}`},TypeError),Be("ERR_OUT_OF_RANGE",function(N,_,v){let $=`The value of "${N}" is out of range.`,K=v;return Number.isInteger(v)&&Math.abs(v)>2**32?K=et(String(v)):typeof v=="bigint"&&(K=String(v),(v>BigInt(2)**BigInt(32)||v<-(BigInt(2)**BigInt(32)))&&(K=et(K)),K+="n"),$+=` It must be ${_}. Received ${K}`,$},RangeError);function et(N){let _="",v=N.length;const $=N[0]==="-"?1:0;for(;v>=$+4;v-=3)_=`_${N.slice(v-3,v)}${_}`;return`${N.slice(0,v)}${_}`}function Qe(N,_,v){sr(_,"offset"),(N[_]===void 0||N[_+v]===void 0)&&dt(_,N.length-(v+1))}function ot(N,_,v,$,K,Y){if(N>v||N<_){const ae=typeof _=="bigint"?"n":"";let Ye;throw _===0||_===BigInt(0)?Ye=`>= 0${ae} and < 2${ae} ** ${(Y+1)*8}${ae}`:Ye=`>= -(2${ae} ** ${(Y+1)*8-1}${ae}) and < 2 ** ${(Y+1)*8-1}${ae}`,new Fe.ERR_OUT_OF_RANGE("value",Ye,N)}Qe($,K,Y)}function sr(N,_){if(typeof N!="number")throw new Fe.ERR_INVALID_ARG_TYPE(_,"number",N)}function dt(N,_,v){throw Math.floor(N)!==N?(sr(N,v),new Fe.ERR_OUT_OF_RANGE("offset","an integer",N)):_<0?new Fe.ERR_BUFFER_OUT_OF_BOUNDS:new Fe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,N)}const Ut=/[^+/0-9A-Za-z-_]/g;function oa(N){if(N=N.split("=")[0],N=N.trim().replace(Ut,""),N.length<2)return"";for(;N.length%4!==0;)N=N+"=";return N}function It(N,_){_=_||1/0;let v;const $=N.length;let K=null;const Y=[];for(let ae=0;ae<$;++ae){if(v=N.charCodeAt(ae),v>55295&&v<57344){if(!K){if(v>56319){(_-=3)>-1&&Y.push(239,191,189);continue}else if(ae+1===$){(_-=3)>-1&&Y.push(239,191,189);continue}K=v;continue}if(v<56320){(_-=3)>-1&&Y.push(239,191,189),K=v;continue}v=(K-55296<<10|v-56320)+65536}else K&&(_-=3)>-1&&Y.push(239,191,189);if(K=null,v<128){if((_-=1)<0)break;Y.push(v)}else if(v<2048){if((_-=2)<0)break;Y.push(v>>6|192,v&63|128)}else if(v<65536){if((_-=3)<0)break;Y.push(v>>12|224,v>>6&63|128,v&63|128)}else if(v<1114112){if((_-=4)<0)break;Y.push(v>>18|240,v>>12&63|128,v>>6&63|128,v&63|128)}else throw new Error("Invalid code point")}return Y}function Ct(N){const _=[];for(let v=0;v<N.length;++v)_.push(N.charCodeAt(v)&255);return _}function kr(N,_){let v,$,K;const Y=[];for(let ae=0;ae<N.length&&!((_-=2)<0);++ae)v=N.charCodeAt(ae),$=v>>8,K=v%256,Y.push(K),Y.push($);return Y}function pt(N){return e.toByteArray(oa(N))}function St(N,_,v,$){let K;for(K=0;K<$&&!(K+v>=_.length||K>=N.length);++K)_[K+v]=N[K];return K}function or(N,_){return N instanceof _||N!=null&&N.constructor!=null&&N.constructor.name!=null&&N.constructor.name===_.name}function xt(N){return N!==N}const Bt=function(){const N="0123456789abcdef",_=new Array(256);for(let v=0;v<16;++v){const $=v*16;for(let K=0;K<16;++K)_[$+K]=N[v]+N[K]}return _}();function fn(N){return typeof BigInt>"u"?Dt:N}function Dt(){throw new Error("BigInt not supported")}})(Vy);const Ze=Vy.Buffer,Ne=Vy.Buffer,NG=Object.freeze(Object.defineProperty({__proto__:null,Buffer:Ne,default:Ze},Symbol.toStringTag,{value:"Module"}));var Zy={exports:{}};const Qy=Mc(NG);Zy.exports,function(r){(function(e,t){function n(B,p){if(!B)throw new Error(p||"Assertion failed")}function i(B,p){B.super_=p;var m=function(){};m.prototype=p.prototype,B.prototype=new m,B.prototype.constructor=B}function s(B,p,m){if(s.isBN(B))return B;this.negative=0,this.words=null,this.length=0,this.red=null,B!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(B||0,p||10,m||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qy.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,m){return p.cmp(m)>0?p:m},s.min=function(p,m){return p.cmp(m)<0?p:m},s.prototype._init=function(p,m,E){if(typeof p=="number")return this._initNumber(p,m,E);if(typeof p=="object")return this._initArray(p,m,E);m==="hex"&&(m=16),n(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var k=0;p[0]==="-"&&(k++,this.negative=1),k<p.length&&(m===16?this._parseHex(p,k,E):(this._parseBase(p,m,k),E==="le"&&this._initArray(this.toArray(),m,E)))},s.prototype._initNumber=function(p,m,E){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(n(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),m,E)},s.prototype._initArray=function(p,m,E){if(n(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var O,M,G=0;if(E==="be")for(k=p.length-1,O=0;k>=0;k-=3)M=p[k]|p[k-1]<<8|p[k-2]<<16,this.words[O]|=M<<G&67108863,this.words[O+1]=M>>>26-G&67108863,G+=24,G>=26&&(G-=26,O++);else if(E==="le")for(k=0,O=0;k<p.length;k+=3)M=p[k]|p[k+1]<<8|p[k+2]<<16,this.words[O]|=M<<G&67108863,this.words[O+1]=M>>>26-G&67108863,G+=24,G>=26&&(G-=26,O++);return this._strip()};function a(B,p){var m=B.charCodeAt(p);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;n(!1,"Invalid character in "+B)}function u(B,p,m){var E=a(B,m);return m-1>=p&&(E|=a(B,m-1)<<4),E}s.prototype._parseHex=function(p,m,E){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var O=0,M=0,G;if(E==="be")for(k=p.length-1;k>=m;k-=2)G=u(p,m,k)<<O,this.words[M]|=G&67108863,O>=18?(O-=18,M+=1,this.words[M]|=G>>>26):O+=8;else{var P=p.length-m;for(k=P%2===0?m+1:m;k<p.length;k+=2)G=u(p,m,k)<<O,this.words[M]|=G&67108863,O>=18?(O-=18,M+=1,this.words[M]|=G>>>26):O+=8}this._strip()};function l(B,p,m,E){for(var k=0,O=0,M=Math.min(B.length,m),G=p;G<M;G++){var P=B.charCodeAt(G)-48;k*=E,P>=49?O=P-49+10:P>=17?O=P-17+10:O=P,n(P>=0&&O<E,"Invalid character"),k+=O}return k}s.prototype._parseBase=function(p,m,E){this.words=[0],this.length=1;for(var k=0,O=1;O<=67108863;O*=m)k++;k--,O=O/m|0;for(var M=p.length-E,G=M%k,P=Math.min(M,M-G)+E,A=0,U=E;U<P;U+=k)A=l(p,U,U+k,m),this.imuln(O),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A);if(G!==0){var le=1;for(A=l(p,U,p.length,m),U=0;U<G;U++)le*=m;this.imuln(le),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A)}this._strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var m=0;m<this.length;m++)p.words[m]=this.words[m];p.length=this.length,p.negative=this.negative,p.red=this.red};function h(B,p){B.words=p.words,B.length=p.length,B.negative=p.negative,B.red=p.red}if(s.prototype._move=function(p){h(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{s.prototype.inspect=g}else s.prototype.inspect=g;function g(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var b=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],w=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(p,m){p=p||10,m=m|0||1;var E;if(p===16||p==="hex"){E="";for(var k=0,O=0,M=0;M<this.length;M++){var G=this.words[M],P=((G<<k|O)&16777215).toString(16);O=G>>>24-k&16777215,k+=2,k>=26&&(k-=26,M--),O!==0||M!==this.length-1?E=b[6-P.length]+P+E:E=P+E}for(O!==0&&(E=O.toString(16)+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(p===(p|0)&&p>=2&&p<=36){var A=w[p],U=I[p];E="";var le=this.clone();for(le.negative=0;!le.isZero();){var te=le.modrn(U).toString(p);le=le.idivn(U),le.isZero()?E=te+E:E=b[A-te.length]+te+E}for(this.isZero()&&(E="0"+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,m){return this.toArrayLike(o,p,m)}),s.prototype.toArray=function(p,m){return this.toArrayLike(Array,p,m)};var S=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,E){this._strip();var k=this.byteLength(),O=E||Math.max(1,k);n(k<=O,"byte array longer than desired length"),n(O>0,"Requested array length <= 0");var M=S(p,O),G=m==="le"?"LE":"BE";return this["_toArrayLike"+G](M,k),M},s.prototype._toArrayLikeLE=function(p,m){for(var E=0,k=0,O=0,M=0;O<this.length;O++){var G=this.words[O]<<M|k;p[E++]=G&255,E<p.length&&(p[E++]=G>>8&255),E<p.length&&(p[E++]=G>>16&255),M===6?(E<p.length&&(p[E++]=G>>24&255),k=0,M=0):(k=G>>>24,M+=2)}if(E<p.length)for(p[E++]=k;E<p.length;)p[E++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var E=p.length-1,k=0,O=0,M=0;O<this.length;O++){var G=this.words[O]<<M|k;p[E--]=G&255,E>=0&&(p[E--]=G>>8&255),E>=0&&(p[E--]=G>>16&255),M===6?(E>=0&&(p[E--]=G>>24&255),k=0,M=0):(k=G>>>24,M+=2)}if(E>=0)for(p[E--]=k;E>=0;)p[E--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,E=0;return m>=4096&&(E+=13,m>>>=13),m>=64&&(E+=7,m>>>=7),m>=8&&(E+=4,m>>>=4),m>=2&&(E+=2,m>>>=2),E+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,E=0;return m&8191||(E+=13,m>>>=13),m&127||(E+=7,m>>>=7),m&15||(E+=4,m>>>=4),m&3||(E+=2,m>>>=2),m&1||E++,E},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function x(B){for(var p=new Array(B.bitLength()),m=0;m<p.length;m++){var E=m/26|0,k=m%26;p[m]=B.words[E]>>>k&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var E=this._zeroBits(this.words[m]);if(p+=E,E!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]|p.words[m];return this._strip()},s.prototype.ior=function(p){return n((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var m;this.length>p.length?m=p:m=this;for(var E=0;E<m.length;E++)this.words[E]=this.words[E]&p.words[E];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return n((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var m,E;this.length>p.length?(m=this,E=p):(m=p,E=this);for(var k=0;k<E.length;k++)this.words[k]=m.words[k]^E.words[k];if(this!==m)for(;k<m.length;k++)this.words[k]=m.words[k];return this.length=m.length,this._strip()},s.prototype.ixor=function(p){return n((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){n(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,E=p%26;this._expand(m),E>0&&m--;for(var k=0;k<m;k++)this.words[k]=~this.words[k]&67108863;return E>0&&(this.words[k]=~this.words[k]&67108863>>26-E),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){n(typeof p=="number"&&p>=0);var E=p/26|0,k=p%26;return this._expand(E+1),m?this.words[E]=this.words[E]|1<<k:this.words[E]=this.words[E]&~(1<<k),this._strip()},s.prototype.iadd=function(p){var m;if(this.negative!==0&&p.negative===0)return this.negative=0,m=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,m=this.isub(p),p.negative=1,m._normSign();var E,k;this.length>p.length?(E=this,k=p):(E=p,k=this);for(var O=0,M=0;M<k.length;M++)m=(E.words[M]|0)+(k.words[M]|0)+O,this.words[M]=m&67108863,O=m>>>26;for(;O!==0&&M<E.length;M++)m=(E.words[M]|0)+O,this.words[M]=m&67108863,O=m>>>26;if(this.length=E.length,O!==0)this.words[this.length]=O,this.length++;else if(E!==this)for(;M<E.length;M++)this.words[M]=E.words[M];return this},s.prototype.add=function(p){var m;return p.negative!==0&&this.negative===0?(p.negative=0,m=this.sub(p),p.negative^=1,m):p.negative===0&&this.negative!==0?(this.negative=0,m=p.sub(this),this.negative=1,m):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var m=this.iadd(p);return p.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var E=this.cmp(p);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,O;E>0?(k=this,O=p):(k=p,O=this);for(var M=0,G=0;G<O.length;G++)m=(k.words[G]|0)-(O.words[G]|0)+M,M=m>>26,this.words[G]=m&67108863;for(;M!==0&&G<k.length;G++)m=(k.words[G]|0)+M,M=m>>26,this.words[G]=m&67108863;if(M===0&&G<k.length&&k!==this)for(;G<k.length;G++)this.words[G]=k.words[G];return this.length=Math.max(this.length,G),k!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function C(B,p,m){m.negative=p.negative^B.negative;var E=B.length+p.length|0;m.length=E,E=E-1|0;var k=B.words[0]|0,O=p.words[0]|0,M=k*O,G=M&67108863,P=M/67108864|0;m.words[0]=G;for(var A=1;A<E;A++){for(var U=P>>>26,le=P&67108863,te=Math.min(A,p.length-1),re=Math.max(0,A-B.length+1);re<=te;re++){var he=A-re|0;k=B.words[he]|0,O=p.words[re]|0,M=k*O+le,U+=M/67108864|0,le=M&67108863}m.words[A]=le|0,P=U|0}return P!==0?m.words[A]=P|0:m.length--,m._strip()}var H=function(p,m,E){var k=p.words,O=m.words,M=E.words,G=0,P,A,U,le=k[0]|0,te=le&8191,re=le>>>13,he=k[1]|0,ye=he&8191,be=he>>>13,Ve=k[2]|0,Fe=Ve&8191,Be=Ve>>>13,et=k[3]|0,Qe=et&8191,ot=et>>>13,sr=k[4]|0,dt=sr&8191,Ut=sr>>>13,oa=k[5]|0,It=oa&8191,Ct=oa>>>13,kr=k[6]|0,pt=kr&8191,St=kr>>>13,or=k[7]|0,xt=or&8191,Bt=or>>>13,fn=k[8]|0,Dt=fn&8191,N=fn>>>13,_=k[9]|0,v=_&8191,$=_>>>13,K=O[0]|0,Y=K&8191,ae=K>>>13,Ye=O[1]|0,qe=Ye&8191,We=Ye>>>13,$t=O[2]|0,Ge=$t&8191,fr=$t>>>13,tg=O[3]|0,hr=tg&8191,dr=tg>>>13,rg=O[4]|0,ar=rg&8191,pr=rg>>>13,ng=O[5]|0,cr=ng&8191,gr=ng>>>13,Oc=O[6]|0,Jt=Oc&8191,yr=Oc>>>13,ig=O[7]|0,mr=ig&8191,wr=ig>>>13,sg=O[8]|0,br=sg&8191,_r=sg>>>13,Nc=O[9]|0,Ar=Nc&8191,vr=Nc>>>13;E.negative=p.negative^m.negative,E.length=19,P=Math.imul(te,Y),A=Math.imul(te,ae),A=A+Math.imul(re,Y)|0,U=Math.imul(re,ae);var Vh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Vh>>>26)|0,Vh&=67108863,P=Math.imul(ye,Y),A=Math.imul(ye,ae),A=A+Math.imul(be,Y)|0,U=Math.imul(be,ae),P=P+Math.imul(te,qe)|0,A=A+Math.imul(te,We)|0,A=A+Math.imul(re,qe)|0,U=U+Math.imul(re,We)|0;var Dl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Dl>>>26)|0,Dl&=67108863,P=Math.imul(Fe,Y),A=Math.imul(Fe,ae),A=A+Math.imul(Be,Y)|0,U=Math.imul(Be,ae),P=P+Math.imul(ye,qe)|0,A=A+Math.imul(ye,We)|0,A=A+Math.imul(be,qe)|0,U=U+Math.imul(be,We)|0,P=P+Math.imul(te,Ge)|0,A=A+Math.imul(te,fr)|0,A=A+Math.imul(re,Ge)|0,U=U+Math.imul(re,fr)|0;var Wh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Wh>>>26)|0,Wh&=67108863,P=Math.imul(Qe,Y),A=Math.imul(Qe,ae),A=A+Math.imul(ot,Y)|0,U=Math.imul(ot,ae),P=P+Math.imul(Fe,qe)|0,A=A+Math.imul(Fe,We)|0,A=A+Math.imul(Be,qe)|0,U=U+Math.imul(Be,We)|0,P=P+Math.imul(ye,Ge)|0,A=A+Math.imul(ye,fr)|0,A=A+Math.imul(be,Ge)|0,U=U+Math.imul(be,fr)|0,P=P+Math.imul(te,hr)|0,A=A+Math.imul(te,dr)|0,A=A+Math.imul(re,hr)|0,U=U+Math.imul(re,dr)|0;var qh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(qh>>>26)|0,qh&=67108863,P=Math.imul(dt,Y),A=Math.imul(dt,ae),A=A+Math.imul(Ut,Y)|0,U=Math.imul(Ut,ae),P=P+Math.imul(Qe,qe)|0,A=A+Math.imul(Qe,We)|0,A=A+Math.imul(ot,qe)|0,U=U+Math.imul(ot,We)|0,P=P+Math.imul(Fe,Ge)|0,A=A+Math.imul(Fe,fr)|0,A=A+Math.imul(Be,Ge)|0,U=U+Math.imul(Be,fr)|0,P=P+Math.imul(ye,hr)|0,A=A+Math.imul(ye,dr)|0,A=A+Math.imul(be,hr)|0,U=U+Math.imul(be,dr)|0,P=P+Math.imul(te,ar)|0,A=A+Math.imul(te,pr)|0,A=A+Math.imul(re,ar)|0,U=U+Math.imul(re,pr)|0;var Zh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Zh>>>26)|0,Zh&=67108863,P=Math.imul(It,Y),A=Math.imul(It,ae),A=A+Math.imul(Ct,Y)|0,U=Math.imul(Ct,ae),P=P+Math.imul(dt,qe)|0,A=A+Math.imul(dt,We)|0,A=A+Math.imul(Ut,qe)|0,U=U+Math.imul(Ut,We)|0,P=P+Math.imul(Qe,Ge)|0,A=A+Math.imul(Qe,fr)|0,A=A+Math.imul(ot,Ge)|0,U=U+Math.imul(ot,fr)|0,P=P+Math.imul(Fe,hr)|0,A=A+Math.imul(Fe,dr)|0,A=A+Math.imul(Be,hr)|0,U=U+Math.imul(Be,dr)|0,P=P+Math.imul(ye,ar)|0,A=A+Math.imul(ye,pr)|0,A=A+Math.imul(be,ar)|0,U=U+Math.imul(be,pr)|0,P=P+Math.imul(te,cr)|0,A=A+Math.imul(te,gr)|0,A=A+Math.imul(re,cr)|0,U=U+Math.imul(re,gr)|0;var Qh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Qh>>>26)|0,Qh&=67108863,P=Math.imul(pt,Y),A=Math.imul(pt,ae),A=A+Math.imul(St,Y)|0,U=Math.imul(St,ae),P=P+Math.imul(It,qe)|0,A=A+Math.imul(It,We)|0,A=A+Math.imul(Ct,qe)|0,U=U+Math.imul(Ct,We)|0,P=P+Math.imul(dt,Ge)|0,A=A+Math.imul(dt,fr)|0,A=A+Math.imul(Ut,Ge)|0,U=U+Math.imul(Ut,fr)|0,P=P+Math.imul(Qe,hr)|0,A=A+Math.imul(Qe,dr)|0,A=A+Math.imul(ot,hr)|0,U=U+Math.imul(ot,dr)|0,P=P+Math.imul(Fe,ar)|0,A=A+Math.imul(Fe,pr)|0,A=A+Math.imul(Be,ar)|0,U=U+Math.imul(Be,pr)|0,P=P+Math.imul(ye,cr)|0,A=A+Math.imul(ye,gr)|0,A=A+Math.imul(be,cr)|0,U=U+Math.imul(be,gr)|0,P=P+Math.imul(te,Jt)|0,A=A+Math.imul(te,yr)|0,A=A+Math.imul(re,Jt)|0,U=U+Math.imul(re,yr)|0;var $l=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+($l>>>26)|0,$l&=67108863,P=Math.imul(xt,Y),A=Math.imul(xt,ae),A=A+Math.imul(Bt,Y)|0,U=Math.imul(Bt,ae),P=P+Math.imul(pt,qe)|0,A=A+Math.imul(pt,We)|0,A=A+Math.imul(St,qe)|0,U=U+Math.imul(St,We)|0,P=P+Math.imul(It,Ge)|0,A=A+Math.imul(It,fr)|0,A=A+Math.imul(Ct,Ge)|0,U=U+Math.imul(Ct,fr)|0,P=P+Math.imul(dt,hr)|0,A=A+Math.imul(dt,dr)|0,A=A+Math.imul(Ut,hr)|0,U=U+Math.imul(Ut,dr)|0,P=P+Math.imul(Qe,ar)|0,A=A+Math.imul(Qe,pr)|0,A=A+Math.imul(ot,ar)|0,U=U+Math.imul(ot,pr)|0,P=P+Math.imul(Fe,cr)|0,A=A+Math.imul(Fe,gr)|0,A=A+Math.imul(Be,cr)|0,U=U+Math.imul(Be,gr)|0,P=P+Math.imul(ye,Jt)|0,A=A+Math.imul(ye,yr)|0,A=A+Math.imul(be,Jt)|0,U=U+Math.imul(be,yr)|0,P=P+Math.imul(te,mr)|0,A=A+Math.imul(te,wr)|0,A=A+Math.imul(re,mr)|0,U=U+Math.imul(re,wr)|0;var Yh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Yh>>>26)|0,Yh&=67108863,P=Math.imul(Dt,Y),A=Math.imul(Dt,ae),A=A+Math.imul(N,Y)|0,U=Math.imul(N,ae),P=P+Math.imul(xt,qe)|0,A=A+Math.imul(xt,We)|0,A=A+Math.imul(Bt,qe)|0,U=U+Math.imul(Bt,We)|0,P=P+Math.imul(pt,Ge)|0,A=A+Math.imul(pt,fr)|0,A=A+Math.imul(St,Ge)|0,U=U+Math.imul(St,fr)|0,P=P+Math.imul(It,hr)|0,A=A+Math.imul(It,dr)|0,A=A+Math.imul(Ct,hr)|0,U=U+Math.imul(Ct,dr)|0,P=P+Math.imul(dt,ar)|0,A=A+Math.imul(dt,pr)|0,A=A+Math.imul(Ut,ar)|0,U=U+Math.imul(Ut,pr)|0,P=P+Math.imul(Qe,cr)|0,A=A+Math.imul(Qe,gr)|0,A=A+Math.imul(ot,cr)|0,U=U+Math.imul(ot,gr)|0,P=P+Math.imul(Fe,Jt)|0,A=A+Math.imul(Fe,yr)|0,A=A+Math.imul(Be,Jt)|0,U=U+Math.imul(Be,yr)|0,P=P+Math.imul(ye,mr)|0,A=A+Math.imul(ye,wr)|0,A=A+Math.imul(be,mr)|0,U=U+Math.imul(be,wr)|0,P=P+Math.imul(te,br)|0,A=A+Math.imul(te,_r)|0,A=A+Math.imul(re,br)|0,U=U+Math.imul(re,_r)|0;var so=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(so>>>26)|0,so&=67108863,P=Math.imul(v,Y),A=Math.imul(v,ae),A=A+Math.imul($,Y)|0,U=Math.imul($,ae),P=P+Math.imul(Dt,qe)|0,A=A+Math.imul(Dt,We)|0,A=A+Math.imul(N,qe)|0,U=U+Math.imul(N,We)|0,P=P+Math.imul(xt,Ge)|0,A=A+Math.imul(xt,fr)|0,A=A+Math.imul(Bt,Ge)|0,U=U+Math.imul(Bt,fr)|0,P=P+Math.imul(pt,hr)|0,A=A+Math.imul(pt,dr)|0,A=A+Math.imul(St,hr)|0,U=U+Math.imul(St,dr)|0,P=P+Math.imul(It,ar)|0,A=A+Math.imul(It,pr)|0,A=A+Math.imul(Ct,ar)|0,U=U+Math.imul(Ct,pr)|0,P=P+Math.imul(dt,cr)|0,A=A+Math.imul(dt,gr)|0,A=A+Math.imul(Ut,cr)|0,U=U+Math.imul(Ut,gr)|0,P=P+Math.imul(Qe,Jt)|0,A=A+Math.imul(Qe,yr)|0,A=A+Math.imul(ot,Jt)|0,U=U+Math.imul(ot,yr)|0,P=P+Math.imul(Fe,mr)|0,A=A+Math.imul(Fe,wr)|0,A=A+Math.imul(Be,mr)|0,U=U+Math.imul(Be,wr)|0,P=P+Math.imul(ye,br)|0,A=A+Math.imul(ye,_r)|0,A=A+Math.imul(be,br)|0,U=U+Math.imul(be,_r)|0,P=P+Math.imul(te,Ar)|0,A=A+Math.imul(te,vr)|0,A=A+Math.imul(re,Ar)|0,U=U+Math.imul(re,vr)|0;var Jh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Jh>>>26)|0,Jh&=67108863,P=Math.imul(v,qe),A=Math.imul(v,We),A=A+Math.imul($,qe)|0,U=Math.imul($,We),P=P+Math.imul(Dt,Ge)|0,A=A+Math.imul(Dt,fr)|0,A=A+Math.imul(N,Ge)|0,U=U+Math.imul(N,fr)|0,P=P+Math.imul(xt,hr)|0,A=A+Math.imul(xt,dr)|0,A=A+Math.imul(Bt,hr)|0,U=U+Math.imul(Bt,dr)|0,P=P+Math.imul(pt,ar)|0,A=A+Math.imul(pt,pr)|0,A=A+Math.imul(St,ar)|0,U=U+Math.imul(St,pr)|0,P=P+Math.imul(It,cr)|0,A=A+Math.imul(It,gr)|0,A=A+Math.imul(Ct,cr)|0,U=U+Math.imul(Ct,gr)|0,P=P+Math.imul(dt,Jt)|0,A=A+Math.imul(dt,yr)|0,A=A+Math.imul(Ut,Jt)|0,U=U+Math.imul(Ut,yr)|0,P=P+Math.imul(Qe,mr)|0,A=A+Math.imul(Qe,wr)|0,A=A+Math.imul(ot,mr)|0,U=U+Math.imul(ot,wr)|0,P=P+Math.imul(Fe,br)|0,A=A+Math.imul(Fe,_r)|0,A=A+Math.imul(Be,br)|0,U=U+Math.imul(Be,_r)|0,P=P+Math.imul(ye,Ar)|0,A=A+Math.imul(ye,vr)|0,A=A+Math.imul(be,Ar)|0,U=U+Math.imul(be,vr)|0;var Li=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Li>>>26)|0,Li&=67108863,P=Math.imul(v,Ge),A=Math.imul(v,fr),A=A+Math.imul($,Ge)|0,U=Math.imul($,fr),P=P+Math.imul(Dt,hr)|0,A=A+Math.imul(Dt,dr)|0,A=A+Math.imul(N,hr)|0,U=U+Math.imul(N,dr)|0,P=P+Math.imul(xt,ar)|0,A=A+Math.imul(xt,pr)|0,A=A+Math.imul(Bt,ar)|0,U=U+Math.imul(Bt,pr)|0,P=P+Math.imul(pt,cr)|0,A=A+Math.imul(pt,gr)|0,A=A+Math.imul(St,cr)|0,U=U+Math.imul(St,gr)|0,P=P+Math.imul(It,Jt)|0,A=A+Math.imul(It,yr)|0,A=A+Math.imul(Ct,Jt)|0,U=U+Math.imul(Ct,yr)|0,P=P+Math.imul(dt,mr)|0,A=A+Math.imul(dt,wr)|0,A=A+Math.imul(Ut,mr)|0,U=U+Math.imul(Ut,wr)|0,P=P+Math.imul(Qe,br)|0,A=A+Math.imul(Qe,_r)|0,A=A+Math.imul(ot,br)|0,U=U+Math.imul(ot,_r)|0,P=P+Math.imul(Fe,Ar)|0,A=A+Math.imul(Fe,vr)|0,A=A+Math.imul(Be,Ar)|0,U=U+Math.imul(Be,vr)|0;var Xh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Xh>>>26)|0,Xh&=67108863,P=Math.imul(v,hr),A=Math.imul(v,dr),A=A+Math.imul($,hr)|0,U=Math.imul($,dr),P=P+Math.imul(Dt,ar)|0,A=A+Math.imul(Dt,pr)|0,A=A+Math.imul(N,ar)|0,U=U+Math.imul(N,pr)|0,P=P+Math.imul(xt,cr)|0,A=A+Math.imul(xt,gr)|0,A=A+Math.imul(Bt,cr)|0,U=U+Math.imul(Bt,gr)|0,P=P+Math.imul(pt,Jt)|0,A=A+Math.imul(pt,yr)|0,A=A+Math.imul(St,Jt)|0,U=U+Math.imul(St,yr)|0,P=P+Math.imul(It,mr)|0,A=A+Math.imul(It,wr)|0,A=A+Math.imul(Ct,mr)|0,U=U+Math.imul(Ct,wr)|0,P=P+Math.imul(dt,br)|0,A=A+Math.imul(dt,_r)|0,A=A+Math.imul(Ut,br)|0,U=U+Math.imul(Ut,_r)|0,P=P+Math.imul(Qe,Ar)|0,A=A+Math.imul(Qe,vr)|0,A=A+Math.imul(ot,Ar)|0,U=U+Math.imul(ot,vr)|0;var ed=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(ed>>>26)|0,ed&=67108863,P=Math.imul(v,ar),A=Math.imul(v,pr),A=A+Math.imul($,ar)|0,U=Math.imul($,pr),P=P+Math.imul(Dt,cr)|0,A=A+Math.imul(Dt,gr)|0,A=A+Math.imul(N,cr)|0,U=U+Math.imul(N,gr)|0,P=P+Math.imul(xt,Jt)|0,A=A+Math.imul(xt,yr)|0,A=A+Math.imul(Bt,Jt)|0,U=U+Math.imul(Bt,yr)|0,P=P+Math.imul(pt,mr)|0,A=A+Math.imul(pt,wr)|0,A=A+Math.imul(St,mr)|0,U=U+Math.imul(St,wr)|0,P=P+Math.imul(It,br)|0,A=A+Math.imul(It,_r)|0,A=A+Math.imul(Ct,br)|0,U=U+Math.imul(Ct,_r)|0,P=P+Math.imul(dt,Ar)|0,A=A+Math.imul(dt,vr)|0,A=A+Math.imul(Ut,Ar)|0,U=U+Math.imul(Ut,vr)|0;var Fl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,P=Math.imul(v,cr),A=Math.imul(v,gr),A=A+Math.imul($,cr)|0,U=Math.imul($,gr),P=P+Math.imul(Dt,Jt)|0,A=A+Math.imul(Dt,yr)|0,A=A+Math.imul(N,Jt)|0,U=U+Math.imul(N,yr)|0,P=P+Math.imul(xt,mr)|0,A=A+Math.imul(xt,wr)|0,A=A+Math.imul(Bt,mr)|0,U=U+Math.imul(Bt,wr)|0,P=P+Math.imul(pt,br)|0,A=A+Math.imul(pt,_r)|0,A=A+Math.imul(St,br)|0,U=U+Math.imul(St,_r)|0,P=P+Math.imul(It,Ar)|0,A=A+Math.imul(It,vr)|0,A=A+Math.imul(Ct,Ar)|0,U=U+Math.imul(Ct,vr)|0;var td=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(td>>>26)|0,td&=67108863,P=Math.imul(v,Jt),A=Math.imul(v,yr),A=A+Math.imul($,Jt)|0,U=Math.imul($,yr),P=P+Math.imul(Dt,mr)|0,A=A+Math.imul(Dt,wr)|0,A=A+Math.imul(N,mr)|0,U=U+Math.imul(N,wr)|0,P=P+Math.imul(xt,br)|0,A=A+Math.imul(xt,_r)|0,A=A+Math.imul(Bt,br)|0,U=U+Math.imul(Bt,_r)|0,P=P+Math.imul(pt,Ar)|0,A=A+Math.imul(pt,vr)|0,A=A+Math.imul(St,Ar)|0,U=U+Math.imul(St,vr)|0;var rd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(rd>>>26)|0,rd&=67108863,P=Math.imul(v,mr),A=Math.imul(v,wr),A=A+Math.imul($,mr)|0,U=Math.imul($,wr),P=P+Math.imul(Dt,br)|0,A=A+Math.imul(Dt,_r)|0,A=A+Math.imul(N,br)|0,U=U+Math.imul(N,_r)|0,P=P+Math.imul(xt,Ar)|0,A=A+Math.imul(xt,vr)|0,A=A+Math.imul(Bt,Ar)|0,U=U+Math.imul(Bt,vr)|0;var nd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(nd>>>26)|0,nd&=67108863,P=Math.imul(v,br),A=Math.imul(v,_r),A=A+Math.imul($,br)|0,U=Math.imul($,_r),P=P+Math.imul(Dt,Ar)|0,A=A+Math.imul(Dt,vr)|0,A=A+Math.imul(N,Ar)|0,U=U+Math.imul(N,vr)|0;var id=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(id>>>26)|0,id&=67108863,P=Math.imul(v,Ar),A=Math.imul(v,vr),A=A+Math.imul($,Ar)|0,U=Math.imul($,vr);var aa=(G+P|0)+((A&8191)<<13)|0;return G=(U+(A>>>13)|0)+(aa>>>26)|0,aa&=67108863,M[0]=Vh,M[1]=Dl,M[2]=Wh,M[3]=qh,M[4]=Zh,M[5]=Qh,M[6]=$l,M[7]=Yh,M[8]=so,M[9]=Jh,M[10]=Li,M[11]=Xh,M[12]=ed,M[13]=Fl,M[14]=td,M[15]=rd,M[16]=nd,M[17]=id,M[18]=aa,G!==0&&(M[19]=G,E.length++),E};Math.imul||(H=C);function D(B,p,m){m.negative=p.negative^B.negative,m.length=B.length+p.length;for(var E=0,k=0,O=0;O<m.length-1;O++){var M=k;k=0;for(var G=E&67108863,P=Math.min(O,p.length-1),A=Math.max(0,O-B.length+1);A<=P;A++){var U=O-A,le=B.words[U]|0,te=p.words[A]|0,re=le*te,he=re&67108863;M=M+(re/67108864|0)|0,he=he+G|0,G=he&67108863,M=M+(he>>>26)|0,k+=M>>>26,M&=67108863}m.words[O]=G,E=M,M=k}return E!==0?m.words[O]=E:m.length--,m._strip()}function z(B,p,m){return D(B,p,m)}s.prototype.mulTo=function(p,m){var E,k=this.length+p.length;return this.length===10&&p.length===10?E=H(this,p,m):k<63?E=C(this,p,m):k<1024?E=D(this,p,m):E=z(this,p,m),E},s.prototype.mul=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),this.mulTo(p,m)},s.prototype.mulf=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),z(this,p,m)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var m=p<0;m&&(p=-p),n(typeof p=="number"),n(p<67108864);for(var E=0,k=0;k<this.length;k++){var O=(this.words[k]|0)*p,M=(O&67108863)+(E&67108863);E>>=26,E+=O/67108864|0,E+=M>>>26,this.words[k]=M&67108863}return E!==0&&(this.words[k]=E,this.length++),m?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var m=x(p);if(m.length===0)return new s(1);for(var E=this,k=0;k<m.length&&m[k]===0;k++,E=E.sqr());if(++k<m.length)for(var O=E.sqr();k<m.length;k++,O=O.sqr())m[k]!==0&&(E=E.mul(O));return E},s.prototype.iushln=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26,k=67108863>>>26-m<<26-m,O;if(m!==0){var M=0;for(O=0;O<this.length;O++){var G=this.words[O]&k,P=(this.words[O]|0)-G<<m;this.words[O]=P|M,M=G>>>26-m}M&&(this.words[O]=M,this.length++)}if(E!==0){for(O=this.length-1;O>=0;O--)this.words[O+E]=this.words[O];for(O=0;O<E;O++)this.words[O]=0;this.length+=E}return this._strip()},s.prototype.ishln=function(p){return n(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,E){n(typeof p=="number"&&p>=0);var k;m?k=(m-m%26)/26:k=0;var O=p%26,M=Math.min((p-O)/26,this.length),G=67108863^67108863>>>O<<O,P=E;if(k-=M,k=Math.max(0,k),P){for(var A=0;A<M;A++)P.words[A]=this.words[A];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,A=0;A<this.length;A++)this.words[A]=this.words[A+M];else this.words[0]=0,this.length=1;var U=0;for(A=this.length-1;A>=0&&(U!==0||A>=k);A--){var le=this.words[A]|0;this.words[A]=U<<26-O|le>>>O,U=le&G}return P&&U!==0&&(P.words[P.length++]=U),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,E){return n(this.negative===0),this.iushrn(p,m,E)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26,k=1<<m;if(this.length<=E)return!1;var O=this.words[E];return!!(O&k)},s.prototype.imaskn=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(m!==0&&E++,this.length=Math.min(E,this.length),m!==0){var k=67108863^67108863>>>m<<m;this.words[this.length-1]&=k}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return n(typeof p=="number"),n(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(p){if(n(typeof p=="number"),n(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,m,E){var k=p.length+E,O;this._expand(k);var M,G=0;for(O=0;O<p.length;O++){M=(this.words[O+E]|0)+G;var P=(p.words[O]|0)*m;M-=P&67108863,G=(M>>26)-(P/67108864|0),this.words[O+E]=M&67108863}for(;O<this.length-E;O++)M=(this.words[O+E]|0)+G,G=M>>26,this.words[O+E]=M&67108863;if(G===0)return this._strip();for(n(G===-1),G=0,O=0;O<this.length;O++)M=-(this.words[O]|0)+G,G=M>>26,this.words[O]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var E=this.length-p.length,k=this.clone(),O=p,M=O.words[O.length-1]|0,G=this._countBits(M);E=26-G,E!==0&&(O=O.ushln(E),k.iushln(E),M=O.words[O.length-1]|0);var P=k.length-O.length,A;if(m!=="mod"){A=new s(null),A.length=P+1,A.words=new Array(A.length);for(var U=0;U<A.length;U++)A.words[U]=0}var le=k.clone()._ishlnsubmul(O,1,P);le.negative===0&&(k=le,A&&(A.words[P]=1));for(var te=P-1;te>=0;te--){var re=(k.words[O.length+te]|0)*67108864+(k.words[O.length+te-1]|0);for(re=Math.min(re/M|0,67108863),k._ishlnsubmul(O,re,te);k.negative!==0;)re--,k.negative=0,k._ishlnsubmul(O,1,te),k.isZero()||(k.negative^=1);A&&(A.words[te]=re)}return A&&A._strip(),k._strip(),m!=="div"&&E!==0&&k.iushrn(E),{div:A||null,mod:k}},s.prototype.divmod=function(p,m,E){if(n(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,O,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(k=M.div.neg()),m!=="div"&&(O=M.mod.neg(),E&&O.negative!==0&&O.iadd(p)),{div:k,mod:O}):this.negative===0&&p.negative!==0?(M=this.divmod(p.neg(),m),m!=="mod"&&(k=M.div.neg()),{div:k,mod:M.mod}):this.negative&p.negative?(M=this.neg().divmod(p.neg(),m),m!=="div"&&(O=M.mod.neg(),E&&O.negative!==0&&O.isub(p)),{div:M.div,mod:O}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?m==="div"?{div:this.divn(p.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,m)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var m=this.divmod(p);if(m.mod.isZero())return m.div;var E=m.div.negative!==0?m.mod.isub(p):m.mod,k=p.ushrn(1),O=p.andln(1),M=E.cmp(k);return M<0||O===1&&M===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(p){var m=p<0;m&&(p=-p),n(p<=67108863);for(var E=(1<<26)%p,k=0,O=this.length-1;O>=0;O--)k=(E*k+(this.words[O]|0))%p;return m?-k:k},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var m=p<0;m&&(p=-p),n(p<=67108863);for(var E=0,k=this.length-1;k>=0;k--){var O=(this.words[k]|0)+E*67108864;this.words[k]=O/p|0,E=O%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){n(p.negative===0),n(!p.isZero());var m=this,E=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),O=new s(0),M=new s(0),G=new s(1),P=0;m.isEven()&&E.isEven();)m.iushrn(1),E.iushrn(1),++P;for(var A=E.clone(),U=m.clone();!m.isZero();){for(var le=0,te=1;!(m.words[0]&te)&&le<26;++le,te<<=1);if(le>0)for(m.iushrn(le);le-- >0;)(k.isOdd()||O.isOdd())&&(k.iadd(A),O.isub(U)),k.iushrn(1),O.iushrn(1);for(var re=0,he=1;!(E.words[0]&he)&&re<26;++re,he<<=1);if(re>0)for(E.iushrn(re);re-- >0;)(M.isOdd()||G.isOdd())&&(M.iadd(A),G.isub(U)),M.iushrn(1),G.iushrn(1);m.cmp(E)>=0?(m.isub(E),k.isub(M),O.isub(G)):(E.isub(m),M.isub(k),G.isub(O))}return{a:M,b:G,gcd:E.iushln(P)}},s.prototype._invmp=function(p){n(p.negative===0),n(!p.isZero());var m=this,E=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),O=new s(0),M=E.clone();m.cmpn(1)>0&&E.cmpn(1)>0;){for(var G=0,P=1;!(m.words[0]&P)&&G<26;++G,P<<=1);if(G>0)for(m.iushrn(G);G-- >0;)k.isOdd()&&k.iadd(M),k.iushrn(1);for(var A=0,U=1;!(E.words[0]&U)&&A<26;++A,U<<=1);if(A>0)for(E.iushrn(A);A-- >0;)O.isOdd()&&O.iadd(M),O.iushrn(1);m.cmp(E)>=0?(m.isub(E),k.isub(O)):(E.isub(m),O.isub(k))}var le;return m.cmpn(1)===0?le=k:le=O,le.cmpn(0)<0&&le.iadd(p),le},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),E=p.clone();m.negative=0,E.negative=0;for(var k=0;m.isEven()&&E.isEven();k++)m.iushrn(1),E.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;E.isEven();)E.iushrn(1);var O=m.cmp(E);if(O<0){var M=m;m=E,E=M}else if(O===0||E.cmpn(1)===0)break;m.isub(E)}while(!0);return E.iushln(k)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){n(typeof p=="number");var m=p%26,E=(p-m)/26,k=1<<m;if(this.length<=E)return this._expand(E+1),this.words[E]|=k,this;for(var O=k,M=E;O!==0&&M<this.length;M++){var G=this.words[M]|0;G+=O,O=G>>>26,G&=67108863,this.words[M]=G}return O!==0&&(this.words[M]=O,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var m=p<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var E;if(this.length>1)E=1;else{m&&(p=-p),n(p<=67108863,"Number is too big");var k=this.words[0]|0;E=k===p?0:k<p?-1:1}return this.negative!==0?-E|0:E},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var m=this.ucmp(p);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var m=0,E=this.length-1;E>=0;E--){var k=this.words[E]|0,O=p.words[E]|0;if(k!==O){k<O?m=-1:k>O&&(m=1);break}}return m},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new ie(p)},s.prototype.toRed=function(p){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return n(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return n(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var W={k256:null,p224:null,p192:null,p25519:null};function Z(B,p){this.name=B,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Z.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},Z.prototype.ireduce=function(p){var m=p,E;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),E=m.bitLength();while(E>this.n);var k=E<this.n?-1:m.ucmp(this.p);return k===0?(m.words[0]=0,m.length=1):k>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},Z.prototype.split=function(p,m){p.iushrn(this.n,0,m)},Z.prototype.imulK=function(p){return p.imul(this.k)};function j(){Z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(j,Z),j.prototype.split=function(p,m){for(var E=4194303,k=Math.min(p.length,9),O=0;O<k;O++)m.words[O]=p.words[O];if(m.length=k,p.length<=9){p.words[0]=0,p.length=1;return}var M=p.words[9];for(m.words[m.length++]=M&E,O=10;O<p.length;O++){var G=p.words[O]|0;p.words[O-10]=(G&E)<<4|M>>>22,M=G}M>>>=22,p.words[O-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},j.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,E=0;E<p.length;E++){var k=p.words[E]|0;m+=k*977,p.words[E]=m&67108863,m=k*64+(m/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function V(){Z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(V,Z);function oe(){Z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(oe,Z);function ce(){Z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ce,Z),ce.prototype.imulK=function(p){for(var m=0,E=0;E<p.length;E++){var k=(p.words[E]|0)*19+m,O=k&67108863;k>>>=26,p.words[E]=O,m=k}return m!==0&&(p.words[p.length++]=m),p},s._prime=function(p){if(W[p])return W[p];var m;if(p==="k256")m=new j;else if(p==="p224")m=new V;else if(p==="p192")m=new oe;else if(p==="p25519")m=new ce;else throw new Error("Unknown prime "+p);return W[p]=m,m};function ie(B){if(typeof B=="string"){var p=s._prime(B);this.m=p.p,this.prime=p}else n(B.gtn(1),"modulus must be greater than 1"),this.m=B,this.prime=null}ie.prototype._verify1=function(p){n(p.negative===0,"red works only with positives"),n(p.red,"red works only with red numbers")},ie.prototype._verify2=function(p,m){n((p.negative|m.negative)===0,"red works only with positives"),n(p.red&&p.red===m.red,"red works only with red numbers")},ie.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},ie.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},ie.prototype.add=function(p,m){this._verify2(p,m);var E=p.add(m);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},ie.prototype.iadd=function(p,m){this._verify2(p,m);var E=p.iadd(m);return E.cmp(this.m)>=0&&E.isub(this.m),E},ie.prototype.sub=function(p,m){this._verify2(p,m);var E=p.sub(m);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},ie.prototype.isub=function(p,m){this._verify2(p,m);var E=p.isub(m);return E.cmpn(0)<0&&E.iadd(this.m),E},ie.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},ie.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},ie.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},ie.prototype.isqr=function(p){return this.imul(p,p.clone())},ie.prototype.sqr=function(p){return this.mul(p,p)},ie.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(n(m%2===1),m===3){var E=this.m.add(new s(1)).iushrn(2);return this.pow(p,E)}for(var k=this.m.subn(1),O=0;!k.isZero()&&k.andln(1)===0;)O++,k.iushrn(1);n(!k.isZero());var M=new s(1).toRed(this),G=M.redNeg(),P=this.m.subn(1).iushrn(1),A=this.m.bitLength();for(A=new s(2*A*A).toRed(this);this.pow(A,P).cmp(G)!==0;)A.redIAdd(G);for(var U=this.pow(A,k),le=this.pow(p,k.addn(1).iushrn(1)),te=this.pow(p,k),re=O;te.cmp(M)!==0;){for(var he=te,ye=0;he.cmp(M)!==0;ye++)he=he.redSqr();n(ye<re);var be=this.pow(U,new s(1).iushln(re-ye-1));le=le.redMul(be),U=be.redSqr(),te=te.redMul(U),re=ye}return le},ie.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},ie.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var E=4,k=new Array(1<<E);k[0]=new s(1).toRed(this),k[1]=p;for(var O=2;O<k.length;O++)k[O]=this.mul(k[O-1],p);var M=k[0],G=0,P=0,A=m.bitLength()%26;for(A===0&&(A=26),O=m.length-1;O>=0;O--){for(var U=m.words[O],le=A-1;le>=0;le--){var te=U>>le&1;if(M!==k[0]&&(M=this.sqr(M)),te===0&&G===0){P=0;continue}G<<=1,G|=te,P++,!(P!==E&&(O!==0||le!==0))&&(M=this.mul(M,k[G]),P=0,G=0)}A=26}return M},ie.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},ie.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ue(p)};function ue(B){ie.call(this,B),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ue,ie),ue.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ue.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ue.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var E=p.imul(m),k=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=E.isub(k).iushrn(this.shift),M=O;return O.cmp(this.m)>=0?M=O.isub(this.m):O.cmpn(0)<0&&(M=O.iadd(this.m)),M._forceRed(this)},ue.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var E=p.mul(m),k=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=E.isub(k).iushrn(this.shift),M=O;return O.cmp(this.m)>=0?M=O.isub(this.m):O.cmpn(0)<0&&(M=O.iadd(this.m)),M._forceRed(this)},ue.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(r,ut)}(Zy);var Yy=Zy.exports;const vs=xn(Yy);function t0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function CG(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function vf(r,...e){if(!CG(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function BG(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");t0(r.outputLen),t0(r.blockLen)}function Qc(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function JE(r,e){vf(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Yc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function PG(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Jy(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function zi(r,e){return r<<32-e|r>>>e}const XE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function MG(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function e2(r){for(let e=0;e<r.length;e++)r[e]=MG(r[e])}function LG(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function r0(r){return typeof r=="string"&&(r=LG(r)),vf(r),r}function UG(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];vf(i),e+=i.length}const t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){const s=r[n];t.set(s,i),i+=s.length}return t}let Xy=class{clone(){return this._cloneInto()}};function em(r){const e=n=>r().update(r0(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function t2(r=32){if(Yc&&typeof Yc.getRandomValues=="function")return Yc.getRandomValues(new Uint8Array(r));if(Yc&&typeof Yc.randomBytes=="function")return Yc.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function DG(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),u=n?4:0,l=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+l,a,n)}function $G(r,e,t){return r&e^~r&t}function FG(r,e,t){return r&e^r&t^e&t}class r2 extends Xy{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Jy(this.buffer)}update(e){Qc(this);const{view:t,buffer:n,blockLen:i}=this;e=r0(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=Jy(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Qc(this),JE(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;DG(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=Jy(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,h[g],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}}const n0=BigInt(2**32-1),tm=BigInt(32);function n2(r,e=!1){return e?{h:Number(r&n0),l:Number(r>>tm&n0)}:{h:Number(r>>tm&n0)|0,l:Number(r&n0)|0}}function i2(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){const{h:s,l:o}=n2(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const HG=(r,e)=>BigInt(r>>>0)<<tm|BigInt(e>>>0),zG=(r,e,t)=>r>>>t,GG=(r,e,t)=>r<<32-t|e>>>t,jG=(r,e,t)=>r>>>t|e<<32-t,KG=(r,e,t)=>r<<32-t|e>>>t,VG=(r,e,t)=>r<<64-t|e>>>t-32,WG=(r,e,t)=>r>>>t-32|e<<64-t,qG=(r,e)=>e,ZG=(r,e)=>r,s2=(r,e,t)=>r<<t|e>>>32-t,o2=(r,e,t)=>e<<t|r>>>32-t,a2=(r,e,t)=>e<<t-32|r>>>64-t,c2=(r,e,t)=>r<<t-32|e>>>64-t;function QG(r,e,t,n){const i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}const rt={fromBig:n2,split:i2,toBig:HG,shrSH:zG,shrSL:GG,rotrSH:jG,rotrSL:KG,rotrBH:VG,rotrBL:WG,rotr32H:qG,rotr32L:ZG,rotlSH:s2,rotlSL:o2,rotlBH:a2,rotlBL:c2,add:QG,add3L:(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),add3H:(r,e,t,n)=>e+t+n+(r/2**32|0)|0,add4L:(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,add5H:(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,add5L:(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0)},[YG,JG]=rt.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(r=>BigInt(r))),fo=new Uint32Array(80),ho=new Uint32Array(80);let XG=class extends r2{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:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:l,El:h,Fh:g,Fl:b,Gh:w,Gl:I,Hh:S,Hl:x}=this;return[e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x]}set(e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=h|0,this.Fh=g|0,this.Fl=b|0,this.Gh=w|0,this.Gl=I|0,this.Hh=S|0,this.Hl=x|0}process(e,t){for(let D=0;D<16;D++,t+=4)fo[D]=e.getUint32(t),ho[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const z=fo[D-15]|0,W=ho[D-15]|0,Z=rt.rotrSH(z,W,1)^rt.rotrSH(z,W,8)^rt.shrSH(z,W,7),j=rt.rotrSL(z,W,1)^rt.rotrSL(z,W,8)^rt.shrSL(z,W,7),V=fo[D-2]|0,oe=ho[D-2]|0,ce=rt.rotrSH(V,oe,19)^rt.rotrBH(V,oe,61)^rt.shrSH(V,oe,6),ie=rt.rotrSL(V,oe,19)^rt.rotrBL(V,oe,61)^rt.shrSL(V,oe,6),ue=rt.add4L(j,ie,ho[D-7],ho[D-16]),B=rt.add4H(ue,Z,ce,fo[D-7],fo[D-16]);fo[D]=B|0,ho[D]=ue|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:l,Dl:h,Eh:g,El:b,Fh:w,Fl:I,Gh:S,Gl:x,Hh:C,Hl:H}=this;for(let D=0;D<80;D++){const z=rt.rotrSH(g,b,14)^rt.rotrSH(g,b,18)^rt.rotrBH(g,b,41),W=rt.rotrSL(g,b,14)^rt.rotrSL(g,b,18)^rt.rotrBL(g,b,41),Z=g&w^~g&S,j=b&I^~b&x,V=rt.add5L(H,W,j,JG[D],ho[D]),oe=rt.add5H(V,C,z,Z,YG[D],fo[D]),ce=V|0,ie=rt.rotrSH(n,i,28)^rt.rotrBH(n,i,34)^rt.rotrBH(n,i,39),ue=rt.rotrSL(n,i,28)^rt.rotrBL(n,i,34)^rt.rotrBL(n,i,39),B=n&s^n&a^s&a,p=i&o^i&u^o&u;C=S|0,H=x|0,S=w|0,x=I|0,w=g|0,I=b|0,{h:g,l:b}=rt.add(l|0,h|0,oe|0,ce|0),l=a|0,h=u|0,a=s|0,u=o|0,s=n|0,o=i|0;const m=rt.add3L(ce,ue,p);n=rt.add3H(m,oe,ie,B),i=m|0}({h:n,l:i}=rt.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=rt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=rt.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:h}=rt.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:g,l:b}=rt.add(this.Eh|0,this.El|0,g|0,b|0),{h:w,l:I}=rt.add(this.Fh|0,this.Fl|0,w|0,I|0),{h:S,l:x}=rt.add(this.Gh|0,this.Gl|0,S|0,x|0),{h:C,l:H}=rt.add(this.Hh|0,this.Hl|0,C|0,H|0),this.set(n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H)}roundClean(){fo.fill(0),ho.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 ej=em(()=>new XG);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const i0=BigInt(0),s0=BigInt(1),tj=BigInt(2);function ma(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ef(r){if(!ma(r))throw new Error("Uint8Array expected")}function Es(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}const rj=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function wa(r){Ef(r);let e="";for(let t=0;t<r.length;t++)e+=rj[r[t]];return e}function Jc(r){const e=r.toString(16);return e.length&1?"0"+e:e}function rm(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?i0:BigInt("0x"+r)}const xs={_0:48,_9:57,A:65,F:70,a:97,f:102};function u2(r){if(r>=xs._0&&r<=xs._9)return r-xs._0;if(r>=xs.A&&r<=xs.F)return r-(xs.A-10);if(r>=xs.a&&r<=xs.f)return r-(xs.a-10)}function Xc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const o=u2(r.charCodeAt(s)),a=u2(r.charCodeAt(s+1));if(o===void 0||a===void 0){const u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+a}return n}function ba(r){return rm(wa(r))}function eu(r){return Ef(r),rm(wa(Uint8Array.from(r).reverse()))}function tu(r,e){return Xc(r.toString(16).padStart(e*2,"0"))}function xf(r,e){return tu(r,e).reverse()}function nj(r){return Xc(Jc(r))}function Tr(r,e,t){let n;if(typeof e=="string")try{n=Xc(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ma(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");const i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function _a(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];Ef(i),e+=i.length}const t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){const s=r[n];t.set(s,i),i+=s.length}return t}function ij(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function sj(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}const nm=r=>typeof r=="bigint"&&i0<=r;function o0(r,e,t){return nm(r)&&nm(e)&&nm(t)&&e<=r&&r<t}function ri(r,e,t,n){if(!o0(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function l2(r){let e;for(e=0;r>i0;r>>=s0,e+=1);return e}function oj(r,e){return r>>BigInt(e)&s0}function aj(r,e,t){return r|(t?s0:i0)<<BigInt(e)}const im=r=>(tj<<BigInt(r-1))-s0,sm=r=>new Uint8Array(r),f2=r=>Uint8Array.from(r);function h2(r,e,t){if(typeof r!="number"||r<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 t!="function")throw new Error("hmacFn must be a function");let n=sm(r),i=sm(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=sm())=>{i=a(f2([0]),g),n=a(),g.length!==0&&(i=a(f2([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){n=a();const w=n.slice();b.push(w),g+=n.length}return _a(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const cj={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ma(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ru(r,e,t={}){const n=(i,s,o)=>{const a=cj[s];if(typeof a!="function")throw new Error("invalid validator function");const u=r[i];if(!(o&&u===void 0)&&!a(u,r))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(t))n(i,s,!0);return r}const uj=()=>{throw new Error("not implemented")};function Rf(r){const e=new WeakMap;return(t,...n)=>{const i=e.get(t);if(i!==void 0)return i;const s=r(t,...n);return e.set(t,s),s}}const lj=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ri,abool:Es,abytes:Ef,bitGet:oj,bitLen:l2,bitMask:im,bitSet:aj,bytesToHex:wa,bytesToNumberBE:ba,bytesToNumberLE:eu,concatBytes:_a,createHmacDrbg:h2,ensureBytes:Tr,equalBytes:ij,hexToBytes:Xc,hexToNumber:rm,inRange:o0,isBytes:ma,memoized:Rf,notImplemented:uj,numberToBytesBE:tu,numberToBytesLE:xf,numberToHexUnpadded:Jc,numberToVarBytesBE:nj,utf8ToBytes:sj,validateObject:ru},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mr=BigInt(0),tr=BigInt(1),Aa=BigInt(2),fj=BigInt(3),om=BigInt(4),d2=BigInt(5),p2=BigInt(8);function Zt(r,e){const t=r%e;return t>=Mr?t:e+t}function hj(r,e,t){if(e<Mr)throw new Error("invalid exponent, negatives unsupported");if(t<=Mr)throw new Error("invalid modulus");if(t===tr)return Mr;let n=tr;for(;e>Mr;)e&tr&&(n=n*r%t),r=r*r%t,e>>=tr;return n}function ur(r,e,t){let n=r;for(;e-- >Mr;)n*=n,n%=t;return n}function am(r,e){if(r===Mr)throw new Error("invert: expected non-zero number");if(e<=Mr)throw new Error("invert: expected positive modulus, got "+e);let t=Zt(r,e),n=e,i=Mr,s=tr;for(;t!==Mr;){const a=n/t,u=n%t,l=i-s*a;n=t,t=u,i=s,s=l}if(n!==tr)throw new Error("invert: does not exist");return Zt(i,e)}function dj(r){const e=(r-tr)/Aa;let t,n,i;for(t=r-tr,n=0;t%Aa===Mr;t/=Aa,n++);for(i=Aa;i<r&&hj(i,e,r)!==r-tr;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(r+tr)/om;return function(u,l){const h=u.pow(l,o);if(!u.eql(u.sqr(h),l))throw new Error("Cannot find square root");return h}}const s=(t+tr)/Aa;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),t),g=a.pow(u,s),b=a.pow(u,t);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let w=1;for(let S=a.sqr(b);w<l&&!a.eql(S,a.ONE);w++)S=a.sqr(S);const I=a.pow(h,tr<<BigInt(l-w-1));h=a.sqr(I),g=a.mul(g,I),b=a.mul(b,h),l=w}return g}}function pj(r){if(r%om===fj){const e=(r+tr)/om;return function(n,i){const s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%p2===d2){const e=(r-d2)/p2;return function(n,i){const s=n.mul(i,Aa),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,Aa),o),l=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return dj(r)}const gj=(r,e)=>(Zt(r,e)&tr)===tr,yj=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function mj(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=yj.reduce((n,i)=>(n[i]="function",n),e);return ru(r,t)}function wj(r,e,t){if(t<Mr)throw new Error("invalid exponent, negatives unsupported");if(t===Mr)return r.ONE;if(t===tr)return e;let n=r.ONE,i=e;for(;t>Mr;)t&tr&&(n=r.mul(n,i)),i=r.sqr(i),t>>=tr;return n}function bj(r,e){const t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function g2(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function a0(r,e,t=!1,n={}){if(r<=Mr)throw new Error("invalid field: expected ORDER > 0, got "+r);const{nBitLength:i,nByteLength:s}=g2(r,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:s,MASK:im(i),ZERO:Mr,ONE:tr,create:u=>Zt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Mr<=u&&u<r},is0:u=>u===Mr,isOdd:u=>(u&tr)===tr,neg:u=>Zt(-u,r),eql:(u,l)=>u===l,sqr:u=>Zt(u*u,r),add:(u,l)=>Zt(u+l,r),sub:(u,l)=>Zt(u-l,r),mul:(u,l)=>Zt(u*l,r),pow:(u,l)=>wj(a,u,l),div:(u,l)=>Zt(u*am(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>am(u,r),sqrt:n.sqrt||(u=>(o||(o=pj(r)),o(a,u))),invertBatch:u=>bj(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?xf(u,s):tu(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return t?eu(u):ba(u)}});return Object.freeze(a)}function y2(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function m2(r){const e=y2(r);return e+Math.ceil(e/2)}function _j(r,e,t=!1){const n=r.length,i=y2(e),s=m2(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const o=t?eu(r):ba(r),a=Zt(o,e-tr)+tr;return t?xf(a,i):tu(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const w2=BigInt(0),c0=BigInt(1);function cm(r,e){const t=e.negate();return r?t:e}function b2(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function um(r,e){b2(r,e);const t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Aj(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function vj(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}const lm=new WeakMap,_2=new WeakMap;function fm(r){return _2.get(r)||1}function A2(r,e){return{constTimeNegate:cm,hasPrecomputes(t){return fm(t)!==1},unsafeLadder(t,n,i=r.ZERO){let s=t;for(;n>w2;)n&c0&&(i=i.add(s)),s=s.double(),n>>=c0;return i},precomputeWindow(t,n){const{windows:i,windowSize:s}=um(n,e),o=[];let a=t,u=a;for(let l=0;l<i;l++){u=a,o.push(u);for(let h=1;h<s;h++)u=u.add(a),o.push(u);a=u.double()}return o},wNAF(t,n,i){const{windows:s,windowSize:o}=um(t,e);let a=r.ZERO,u=r.BASE;const l=BigInt(2**t-1),h=2**t,g=BigInt(t);for(let b=0;b<s;b++){const w=b*o;let I=Number(i&l);i>>=g,I>o&&(I-=h,i+=c0);const S=w,x=w+Math.abs(I)-1,C=b%2!==0,H=I<0;I===0?u=u.add(cm(C,n[S])):a=a.add(cm(H,n[x]))}return{p:a,f:u}},wNAFUnsafe(t,n,i,s=r.ZERO){const{windows:o,windowSize:a}=um(t,e),u=BigInt(2**t-1),l=2**t,h=BigInt(t);for(let g=0;g<o;g++){const b=g*a;if(i===w2)break;let w=Number(i&u);if(i>>=h,w>a&&(w-=l,i+=c0),w===0)continue;let I=n[b+Math.abs(w)-1];w<0&&(I=I.negate()),s=s.add(I)}return s},getPrecomputes(t,n,i){let s=lm.get(n);return s||(s=this.precomputeWindow(n,t),t!==1&&lm.set(n,i(s))),s},wNAFCached(t,n,i){const s=fm(t);return this.wNAF(s,this.getPrecomputes(s,t,i),n)},wNAFCachedUnsafe(t,n,i,s){const o=fm(t);return o===1?this.unsafeLadder(t,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),n,s)},setWindowSize(t,n){b2(n,e),_2.set(t,n),lm.delete(t)}}}function v2(r,e,t,n){if(Aj(t,r),vj(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=r.ZERO,s=l2(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,u=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let h=i;for(let g=l;g>=0;g-=o){u.fill(i);for(let w=0;w<n.length;w++){const I=n[w],S=Number(I>>BigInt(g)&BigInt(a));u[S]=u[S].add(t[w])}let b=i;for(let w=u.length-1,I=i;w>0;w--)I=I.add(u[w]),b=b.add(I);if(h=h.add(b),g!==0)for(let w=0;w<o;w++)h=h.double()}return h}function hm(r){return mj(r.Fp),ru(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...g2(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _i=BigInt(0),Sn=BigInt(1),u0=BigInt(2),Ej=BigInt(8),xj={zip215:!0};function Rj(r){const e=hm(r);return ru(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ij(r){const e=Rj(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:u}=e,l=u0<<BigInt(a*8)-Sn,h=t.create,g=a0(e.n,e.nBitLength),b=e.uvRatio||((E,k)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(k))}}catch{return{isValid:!1,value:_i}}}),w=e.adjustScalarBytes||(E=>E),I=e.domain||((E,k,O)=>{if(Es("phflag",O),k.length||O)throw new Error("Contexts/pre-hash are not supported");return E});function S(E,k){ri("coordinate "+E,k,_i,l)}function x(E){if(!(E instanceof D))throw new Error("ExtendedPoint expected")}const C=Rf((E,k)=>{const{ex:O,ey:M,ez:G}=E,P=E.is0();k==null&&(k=P?Ej:t.inv(G));const A=h(O*k),U=h(M*k),le=h(G*k);if(P)return{x:_i,y:Sn};if(le!==Sn)throw new Error("invZ was invalid");return{x:A,y:U}}),H=Rf(E=>{const{a:k,d:O}=e;if(E.is0())throw new Error("bad point: ZERO");const{ex:M,ey:G,ez:P,et:A}=E,U=h(M*M),le=h(G*G),te=h(P*P),re=h(te*te),he=h(U*k),ye=h(te*h(he+le)),be=h(re+h(O*h(U*le)));if(ye!==be)throw new Error("bad point: equation left != right (1)");const Ve=h(M*G),Fe=h(P*A);if(Ve!==Fe)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(k,O,M,G){this.ex=k,this.ey=O,this.ez=M,this.et=G,S("x",k),S("y",O),S("z",M),S("t",G),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(k){if(k instanceof D)throw new Error("extended point not allowed");const{x:O,y:M}=k||{};return S("x",O),S("y",M),new D(O,M,Sn,h(O*M))}static normalizeZ(k){const O=t.invertBatch(k.map(M=>M.ez));return k.map((M,G)=>M.toAffine(O[G])).map(D.fromAffine)}static msm(k,O){return v2(D,g,k,O)}_setWindowSize(k){Z.setWindowSize(this,k)}assertValidity(){H(this)}equals(k){x(k);const{ex:O,ey:M,ez:G}=this,{ex:P,ey:A,ez:U}=k,le=h(O*U),te=h(P*G),re=h(M*U),he=h(A*G);return le===te&&re===he}is0(){return this.equals(D.ZERO)}negate(){return new D(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:k}=e,{ex:O,ey:M,ez:G}=this,P=h(O*O),A=h(M*M),U=h(u0*h(G*G)),le=h(k*P),te=O+M,re=h(h(te*te)-P-A),he=le+A,ye=he-U,be=le-A,Ve=h(re*ye),Fe=h(he*be),Be=h(re*be),et=h(ye*he);return new D(Ve,Fe,et,Be)}add(k){x(k);const{a:O,d:M}=e,{ex:G,ey:P,ez:A,et:U}=this,{ex:le,ey:te,ez:re,et:he}=k;if(O===BigInt(-1)){const It=h((P-G)*(te+le)),Ct=h((P+G)*(te-le)),kr=h(Ct-It);if(kr===_i)return this.double();const pt=h(A*u0*he),St=h(U*u0*re),or=St+pt,xt=Ct+It,Bt=St-pt,fn=h(or*kr),Dt=h(xt*Bt),N=h(or*Bt),_=h(kr*xt);return new D(fn,Dt,_,N)}const ye=h(G*le),be=h(P*te),Ve=h(U*M*he),Fe=h(A*re),Be=h((G+P)*(le+te)-ye-be),et=Fe-Ve,Qe=Fe+Ve,ot=h(be-O*ye),sr=h(Be*et),dt=h(Qe*ot),Ut=h(Be*ot),oa=h(et*Qe);return new D(sr,dt,oa,Ut)}subtract(k){return this.add(k.negate())}wNAF(k){return Z.wNAFCached(this,k,D.normalizeZ)}multiply(k){const O=k;ri("scalar",O,Sn,n);const{p:M,f:G}=this.wNAF(O);return D.normalizeZ([M,G])[0]}multiplyUnsafe(k,O=D.ZERO){const M=k;return ri("scalar",M,_i,n),M===_i?W:this.is0()||M===Sn?this:Z.wNAFCachedUnsafe(this,M,D.normalizeZ,O)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return Z.unsafeLadder(this,n).is0()}toAffine(k){return C(this,k)}clearCofactor(){const{h:k}=e;return k===Sn?this:this.multiplyUnsafe(k)}static fromHex(k,O=!1){const{d:M,a:G}=e,P=t.BYTES;k=Tr("pointHex",k,P),Es("zip215",O);const A=k.slice(),U=k[P-1];A[P-1]=U&-129;const le=eu(A),te=O?l:t.ORDER;ri("pointHex.y",le,_i,te);const re=h(le*le),he=h(re-Sn),ye=h(M*re-G);let{isValid:be,value:Ve}=b(he,ye);if(!be)throw new Error("Point.fromHex: invalid y coordinate");const Fe=(Ve&Sn)===Sn,Be=(U&128)!==0;if(!O&&Ve===_i&&Be)throw new Error("Point.fromHex: x=0 and x_0=1");return Be!==Fe&&(Ve=h(-Ve)),D.fromAffine({x:Ve,y:le})}static fromPrivateKey(k){return oe(k).point}toRawBytes(){const{x:k,y:O}=this.toAffine(),M=xf(O,t.BYTES);return M[M.length-1]|=k&Sn?128:0,M}toHex(){return wa(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,Sn,h(e.Gx*e.Gy)),D.ZERO=new D(_i,Sn,Sn,_i);const{BASE:z,ZERO:W}=D,Z=A2(D,a*8);function j(E){return Zt(E,n)}function V(E){return j(eu(E))}function oe(E){const k=t.BYTES;E=Tr("private key",E,k);const O=Tr("hashed private key",s(E),2*k),M=w(O.slice(0,k)),G=O.slice(k,2*k),P=V(M),A=z.multiply(P),U=A.toRawBytes();return{head:M,prefix:G,scalar:P,point:A,pointBytes:U}}function ce(E){return oe(E).pointBytes}function ie(E=new Uint8Array,...k){const O=_a(...k);return V(s(I(O,Tr("context",E),!!i)))}function ue(E,k,O={}){E=Tr("message",E),i&&(E=i(E));const{prefix:M,scalar:G,pointBytes:P}=oe(k),A=ie(O.context,M,E),U=z.multiply(A).toRawBytes(),le=ie(O.context,U,P,E),te=j(A+le*G);ri("signature.s",te,_i,n);const re=_a(U,xf(te,t.BYTES));return Tr("result",re,t.BYTES*2)}const B=xj;function p(E,k,O,M=B){const{context:G,zip215:P}=M,A=t.BYTES;E=Tr("signature",E,2*A),k=Tr("message",k),O=Tr("publicKey",O,A),P!==void 0&&Es("zip215",P),i&&(k=i(k));const U=eu(E.slice(A,2*A));let le,te,re;try{le=D.fromHex(O,P),te=D.fromHex(E.slice(0,A),P),re=z.multiplyUnsafe(U)}catch{return!1}if(!P&&le.isSmallOrder())return!1;const he=ie(G,te.toRawBytes(),le.toRawBytes(),k);return te.add(le.multiplyUnsafe(he)).subtract(re).clearCofactor().equals(D.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:ue,verify:p,ExtendedPoint:D,utils:{getExtendedPublicKey:oe,randomPrivateKey:()=>o(t.BYTES),precompute(E=8,k=D.BASE){return k._setWindowSize(E),k.multiply(BigInt(3)),k}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dm=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),E2=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Sj=BigInt(1),x2=BigInt(2);BigInt(3);const kj=BigInt(5),Tj=BigInt(8);function Oj(r){const e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=dm,a=r*r%s*r%s,u=ur(a,x2,s)*a%s,l=ur(u,Sj,s)*r%s,h=ur(l,kj,s)*l%s,g=ur(h,e,s)*h%s,b=ur(g,t,s)*g%s,w=ur(b,n,s)*b%s,I=ur(w,i,s)*w%s,S=ur(I,i,s)*w%s,x=ur(S,e,s)*h%s;return{pow_p_5_8:ur(x,x2,s)*r%s,b2:a}}function Nj(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Cj(r,e){const t=dm,n=Zt(e*e*e,t),i=Zt(n*n*e,t),s=Oj(r*i).pow_p_5_8;let o=Zt(r*n*s,t);const a=Zt(e*o*o,t),u=o,l=Zt(o*E2,t),h=a===r,g=a===Zt(-r,t),b=a===Zt(-r*E2,t);return h&&(o=u),(g||b)&&(o=l),gj(o,t)&&(o=Zt(-o,t)),{isValid:h||g,value:o}}const Bj=a0(dm,void 0,!0),Pj={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bj,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Tj,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ej,randomBytes:t2,adjustScalarBytes:Nj,uvRatio:Cj},nu=Ij(Pj);var pm={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,e){var t=Qy,n=t.Buffer;function i(o,a){for(var u in o)a[u]=o[u]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?r.exports=t:(i(t,e),e.Buffer=s);function s(o,a,u){return n(o,a,u)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(o,a,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,u)},s.alloc=function(o,a,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=n(o);return a!==void 0?typeof u=="string"?l.fill(a,u):l.fill(a):l.fill(0),l},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}})(pm,pm.exports);var Mj=pm.exports,l0=Mj.Buffer;function Lj(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var i=r.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var o=r.length,a=r.charAt(0),u=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function h(w){if((Array.isArray(w)||w instanceof Uint8Array)&&(w=l0.from(w)),!l0.isBuffer(w))throw new TypeError("Expected Buffer");if(w.length===0)return"";for(var I=0,S=0,x=0,C=w.length;x!==C&&w[x]===0;)x++,I++;for(var H=(C-x)*l+1>>>0,D=new Uint8Array(H);x!==C;){for(var z=w[x],W=0,Z=H-1;(z!==0||W<S)&&Z!==-1;Z--,W++)z+=256*D[Z]>>>0,D[Z]=z%o>>>0,z=z/o>>>0;if(z!==0)throw new Error("Non-zero carry");S=W,x++}for(var j=H-S;j!==H&&D[j]===0;)j++;for(var V=a.repeat(I);j<H;++j)V+=r.charAt(D[j]);return V}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return l0.alloc(0);for(var I=0,S=0,x=0;w[I]===a;)S++,I++;for(var C=(w.length-I)*u+1>>>0,H=new Uint8Array(C);I<w.length;){var D=w.charCodeAt(I);if(D>255)return;var z=e[D];if(z===255)return;for(var W=0,Z=C-1;(z!==0||W<x)&&Z!==-1;Z--,W++)z+=o*H[Z]>>>0,H[Z]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");x=W,I++}for(var j=C-x;j!==C&&H[j]===0;)j++;var V=l0.allocUnsafe(S+(C-j));V.fill(0,0,S);for(var oe=S;j!==C;)V[oe++]=H[j++];return V}function b(w){var I=g(w);if(I)return I;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:g,decode:b}}var Uj=Lj,Dj=Uj,$j="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",R2=Dj($j);const Or=xn(R2),Fj=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]),po=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),go=new Uint32Array(64);let Hj=class extends r2{constructor(){super(64,32,8,!1),this.A=po[0]|0,this.B=po[1]|0,this.C=po[2]|0,this.D=po[3]|0,this.E=po[4]|0,this.F=po[5]|0,this.G=po[6]|0,this.H=po[7]|0}get(){const{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:u}=this;return[e,t,n,i,s,o,a,u]}set(e,t,n,i,s,o,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,t){for(let g=0;g<16;g++,t+=4)go[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){const b=go[g-15],w=go[g-2],I=zi(b,7)^zi(b,18)^b>>>3,S=zi(w,17)^zi(w,19)^w>>>10;go[g]=S+go[g-7]+I+go[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:h}=this;for(let g=0;g<64;g++){const b=zi(a,6)^zi(a,11)^zi(a,25),w=h+b+$G(a,u,l)+Fj[g]+go[g]|0,S=(zi(n,2)^zi(n,13)^zi(n,22))+FG(n,i,s)|0;h=l,l=u,u=a,a=o+w|0,o=s,s=i,i=n,n=w+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,u,l,h)}roundClean(){go.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const gm=em(()=>new Hj);var Kr={};function Rs(r,e,t){return e<=r&&r<=t}function f0(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function zj(r){for(var e=String(r),t=e.length,n=0,i=[];n<t;){var s=e.charCodeAt(n);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(n===t-1)i.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var a=s&1023,u=o&1023;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}function Gj(r){for(var e="",t=0;t<r.length;++t){var n=r[t];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return e}var h0=-1;function ym(r){this.tokens=[].slice.call(r)}ym.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():h0},prepend:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.push(e.shift());else this.tokens.push(r)}};var iu=-1;function mm(r,e){if(r)throw TypeError("Decoder error");return e||65533}var d0="utf-8";function p0(r,e){if(!(this instanceof p0))return new p0(r,e);if(r=r!==void 0?String(r).toLowerCase():d0,r!==d0)throw new Error("Encoding not supported. Only utf-8 is supported");e=f0(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}p0.prototype={decode:function(e,t){var n;typeof e=="object"&&e instanceof ArrayBuffer?n=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):n=new Uint8Array(0),t=f0(t),this._streaming||(this._decoder=new jj({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var i=new ym(n),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==iu);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===iu)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),Gj(s)}};function g0(r,e){if(!(this instanceof g0))return new g0(r,e);if(r=r!==void 0?String(r).toLowerCase():d0,r!==d0)throw new Error("Encoding not supported. Only utf-8 is supported");e=f0(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}g0.prototype={encode:function(e,t){e=e?String(e):"",t=f0(t),this._streaming||(this._encoder=new Kj(this._options)),this._streaming=!!t.stream;for(var n=[],i=new ym(zj(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==iu);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==iu;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function jj(r){var e=r.fatal,t=0,n=0,i=0,s=128,o=191;this.handler=function(a,u){if(u===h0&&i!==0)return i=0,mm(e);if(u===h0)return iu;if(i===0){if(Rs(u,0,127))return u;if(Rs(u,194,223))i=1,t=u-192;else if(Rs(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,t=u-224;else if(Rs(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,t=u-240;else return mm(e);return t=t<<6*i,null}if(!Rs(u,s,o))return t=i=n=0,s=128,o=191,a.prepend(u),mm(e);if(s=128,o=191,n+=1,t+=u-128<<6*(i-n),n!==i)return null;var l=t;return t=i=n=0,l}}function Kj(r){r.fatal,this.handler=function(e,t){if(t===h0)return iu;if(Rs(t,0,127))return t;var n,i;Rs(t,128,2047)?(n=1,i=192):Rs(t,2048,65535)?(n=2,i=224):Rs(t,65536,1114111)&&(n=3,i=240);for(var s=[(t>>6*n)+i];n>0;){var o=t>>6*(n-1);s.push(128|o&63),n-=1}return s}}const Vj=Mc(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:p0,TextEncoder:g0},Symbol.toStringTag,{value:"Module"})));var Wj=ut&&ut.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t),Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[t]}})}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),qj=ut&&ut.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Gi=ut&&ut.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Zj=ut&&ut.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.hasOwnProperty.call(r,t)&&Wj(e,r,t);return qj(e,r),e},I2=ut&&ut.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Kr,"__esModule",{value:!0});var S2=Kr.deserializeUnchecked=B2=Kr.deserialize=C2=Kr.serialize=Kr.BinaryReader=Kr.BinaryWriter=Kr.BorshError=Kr.baseDecode=Kr.baseEncode=void 0;const yo=I2(Yy),k2=I2(R2),Qj=Zj(Vj),Yj=typeof TextDecoder!="function"?Qj.TextDecoder:TextDecoder,Jj=new Yj("utf-8",{fatal:!0});function Xj(r){return typeof r=="string"&&(r=Ze.from(r,"utf8")),k2.default.encode(Ze.from(r))}Kr.baseEncode=Xj;function eK(r){return Ze.from(k2.default.decode(r))}Kr.baseDecode=eK;const wm=1024;class pn extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Kr.BorshError=pn;class T2{constructor(){this.buf=Ze.alloc(wm),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Ze.concat([this.buf,Ze.alloc(wm)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Ze.concat([Ze.from(this.buf.subarray(0,this.length)),e,Ze.alloc(wm)]),this.length+=e.length}writeString(e){this.maybeResize();const t=Ze.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Ze.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(const n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}}Kr.BinaryWriter=T2;function ji(r,e,t){const n=t.value;t.value=function(...i){try{return n.apply(this,i)}catch(s){if(s instanceof RangeError){const o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new pn("Reached the end of buffer when deserializing")}throw s}}}class Fn{constructor(e){this.buf=e,this.offset=0}readU8(){const e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){const e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){const e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){const e=this.readBuffer(8);return new yo.default(e,"le")}readU128(){const e=this.readBuffer(16);return new yo.default(e,"le")}readU256(){const e=this.readBuffer(32);return new yo.default(e,"le")}readU512(){const e=this.readBuffer(64);return new yo.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new pn(`Expected buffer length ${e} isn't within bounds`);const t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){const e=this.readU32(),t=this.readBuffer(e);try{return Jj.decode(t)}catch(n){throw new pn(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){const t=this.readU32(),n=Array();for(let i=0;i<t;++i)n.push(e());return n}}Gi([ji],Fn.prototype,"readU8",null),Gi([ji],Fn.prototype,"readU16",null),Gi([ji],Fn.prototype,"readU32",null),Gi([ji],Fn.prototype,"readU64",null),Gi([ji],Fn.prototype,"readU128",null),Gi([ji],Fn.prototype,"readU256",null),Gi([ji],Fn.prototype,"readU512",null),Gi([ji],Fn.prototype,"readString",null),Gi([ji],Fn.prototype,"readFixedArray",null),Gi([ji],Fn.prototype,"readArray",null),Kr.BinaryReader=Fn;function O2(r){return r.charAt(0).toUpperCase()+r.slice(1)}function va(r,e,t,n,i){try{if(typeof n=="string")i[`write${O2(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new pn(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);i.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new pn(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let s=0;s<n[1];s++)va(r,null,t[s],n[0],i)}else i.writeArray(t,s=>{va(r,e,s,n[0],i)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?i.writeU8(0):(i.writeU8(1),va(r,e,t,n.type,i));break}case"map":{i.writeU32(t.size),t.forEach((s,o)=>{va(r,e,o,n.key,i),va(r,e,s,n.value,i)});break}default:throw new pn(`FieldType ${n} unrecognized`)}else N2(r,t,i)}catch(s){throw s instanceof pn&&s.addToFieldPath(e),s}}function N2(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}const n=r.get(e.constructor);if(!n)throw new pn(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([i,s])=>{va(r,i,e[i],s,t)});else if(n.kind==="enum"){const i=e[n.field];for(let s=0;s<n.values.length;++s){const[o,a]=n.values[s];if(o===i){t.writeU8(s),va(r,o,e[o],a,t);break}}}else throw new pn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function tK(r,e,t=T2){const n=new t;return N2(r,e,n),n.toArray()}var C2=Kr.serialize=tK;function Ea(r,e,t,n){try{if(typeof t=="string")return n[`read${O2(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){const i=[];for(let s=0;s<t[1];s++)i.push(Ea(r,null,t[0],n));return i}else return n.readArray(()=>Ea(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?Ea(r,e,t.type,n):void 0;if(t.kind==="map"){let i=new Map;const s=n.readU32();for(let o=0;o<s;o++){const a=Ea(r,e,t.key,n),u=Ea(r,e,t.value,n);i.set(a,u)}return i}return bm(r,t,n)}catch(i){throw i instanceof pn&&i.addToFieldPath(e),i}}function bm(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);const n=r.get(e);if(!n)throw new pn(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){const i={};for(const[s,o]of r.get(e).fields)i[s]=Ea(r,s,o,t);return new e(i)}if(n.kind==="enum"){const i=t.readU8();if(i>=n.values.length)throw new pn(`Enum index: ${i} is out of range`);const[s,o]=n.values[i],a=Ea(r,s,o,t);return new e({[s]:a})}throw new pn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function rK(r,e,t,n=Fn){const i=new n(t),s=bm(r,e,i);if(i.offset<t.length)throw new pn(`Unexpected ${t.length-i.offset} bytes after deserialized data`);return s}var B2=Kr.deserialize=rK;function nK(r,e,t,n=Fn){const i=new n(t);return bm(r,e,i)}S2=Kr.deserializeUnchecked=nK;var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.s16=ne.s8=ne.nu64be=ne.u48be=ne.u40be=ne.u32be=ne.u24be=ne.u16be=Vr=ne.nu64=ne.u48=ne.u40=Pe=ne.u32=ne.u24=ii=ne.u16=bt=ne.u8=mo=ne.offset=ne.greedy=ne.Constant=ne.UTF8=ne.CString=ne.Blob=ne.Boolean=ne.BitField=ne.BitStructure=ne.VariantLayout=ne.Union=ne.UnionLayoutDiscriminator=ne.UnionDiscriminator=ne.Structure=ne.Sequence=ne.DoubleBE=ne.Double=ne.FloatBE=ne.Float=ne.NearInt64BE=ne.NearInt64=ne.NearUInt64BE=ne.NearUInt64=ne.IntBE=ne.Int=ne.UIntBE=ne.UInt=ne.OffsetLayout=ne.GreedyCount=ne.ExternalLayout=ne.bindConstructorLayout=ne.nameWithProperty=ne.Layout=ne.uint8ArrayToBuffer=ne.checkUint8Array=void 0,ne.constant=ne.utf8=ne.cstr=Wt=ne.blob=ne.unionLayoutDiscriminator=ne.union=Wr=ne.seq=ne.bits=Me=ne.struct=ne.f64be=ne.f64=ne.f32be=ne.f32=ne.ns64be=ne.s48be=ne.s40be=ne.s32be=ne.s24be=ne.s16be=Hn=ne.ns64=ne.s48=ne.s40=ne.s32=ne.s24=void 0;const _m=Qy;function su(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ne.checkUint8Array=su;function At(r){return su(r),_m.Buffer.from(r.buffer,r.byteOffset,r.length)}ne.uint8ArrayToBuffer=At;let Tt=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};ne.Layout=Tt;function Am(r,e){return e.property?r+"["+e.property+"]":r}ne.nameWithProperty=Am;function iK(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Tt))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value(t,n){return e.decode(t,n)},writable:!0})}ne.bindConstructorLayout=iK;let kn=class extends Tt{isCount(){throw new Error("ExternalLayout is abstract")}};ne.ExternalLayout=kn;let P2=class extends kn{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){su(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};ne.GreedyCount=P2;let vm=class extends kn{constructor(e,t=0,n){if(!(e instanceof Tt))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof ni||this.layout instanceof Ai}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};ne.OffsetLayout=vm;let ni=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readUIntLE(t,this.span)}encode(e,t,n=0){return At(t).writeUIntLE(e,n,this.span),this.span}};ne.UInt=ni;let Ai=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readUIntBE(t,this.span)}encode(e,t,n=0){return At(t).writeUIntBE(e,n,this.span),this.span}};ne.UIntBE=Ai;let xa=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readIntLE(t,this.span)}encode(e,t,n=0){return At(t).writeIntLE(e,n,this.span),this.span}};ne.Int=xa;let ou=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readIntBE(t,this.span)}encode(e,t,n=0){return At(t).writeIntBE(e,n,this.span),this.span}};ne.IntBE=ou;const Em=Math.pow(2,32);function y0(r){const e=Math.floor(r/Em),t=r-e*Em;return{hi32:e,lo32:t}}function m0(r,e){return r*Em+e}let M2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readUInt32LE(t),s=n.readUInt32LE(t+4);return m0(s,i)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeUInt32LE(i.lo32,n),s.writeUInt32LE(i.hi32,n+4),8}};ne.NearUInt64=M2;let L2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readUInt32BE(t),s=n.readUInt32BE(t+4);return m0(i,s)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeUInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ne.NearUInt64BE=L2;let U2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readUInt32LE(t),s=n.readInt32LE(t+4);return m0(s,i)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeUInt32LE(i.lo32,n),s.writeInt32LE(i.hi32,n+4),8}};ne.NearInt64=U2;let D2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readInt32BE(t),s=n.readUInt32BE(t+4);return m0(i,s)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ne.NearInt64BE=D2;let $2=class extends Tt{constructor(e){super(4,e)}decode(e,t=0){return At(e).readFloatLE(t)}encode(e,t,n=0){return At(t).writeFloatLE(e,n),4}};ne.Float=$2;let F2=class extends Tt{constructor(e){super(4,e)}decode(e,t=0){return At(e).readFloatBE(t)}encode(e,t,n=0){return At(t).writeFloatBE(e,n),4}};ne.FloatBE=F2;let H2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){return At(e).readDoubleLE(t)}encode(e,t,n=0){return At(t).writeDoubleLE(e,n),8}};ne.Double=H2;let z2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){return At(e).readDoubleBE(t)}encode(e,t,n=0){return At(t).writeDoubleBE(e,n),8}};ne.DoubleBE=z2;let G2=class extends Tt{constructor(e,t,n){if(!(e instanceof Tt))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof kn&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof kn)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,i=this.count;if(i instanceof kn&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t=0){const n=[];let i=0,s=this.count;for(s instanceof kn&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n=0){const i=this.elementLayout,s=e.reduce((o,a)=>o+i.encode(a,t,n+o),0);return this.count instanceof kn&&this.count.encode(e.length,t,n),s}};ne.Sequence=G2;let j2=class extends Tt{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Tt,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){su(e);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};ne.Structure=j2;let xm=class{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}};ne.UnionDiscriminator=xm;let w0=class extends xm{constructor(e,t){if(!(e instanceof kn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};ne.UnionLayoutDiscriminator=w0;let Rm=class extends Tt{constructor(e,t,n){let i;if(e instanceof ni||e instanceof Ai)i=new w0(new vm(e));else if(e instanceof kn&&e.isCount())i=new w0(e);else if(e instanceof xm)i=e;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Tt))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&(e instanceof ni||e instanceof Ai)&&(s+=i.layout.span)),super(s,n),this.discriminator=i,this.usesPrefixDiscriminator=e instanceof ni||e instanceof Ai,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n;const i=this.discriminator,s=i.decode(e,t),o=this.registry[s];if(o===void 0){const a=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[a.property]=a.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new K2(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};ne.Union=Rm;let K2=class extends Tt{constructor(e,t,n,i){if(!(e instanceof Rm))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Tt))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(e,t+n)),n+i}decode(e,t=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};ne.VariantLayout=K2;function au(r){return 0>r&&(r+=4294967296),r}let Im=class extends Tt{constructor(e,t,n){if(!(e instanceof ni||e instanceof Ai))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=au(s),this},this._packedGetValue=function(){return i}}decode(e,t=0){const n=this.makeDestinationObject(),i=this.word.decode(e,t);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(e));return n}encode(e,t,n=0){const i=this.word.decode(t,n);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new Sm(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new V2(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}};ne.BitStructure=Im;let Sm=class{constructor(e,t,n){if(!(e instanceof Im))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((o,a)=>o+a.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=au(this.valueMask<<this.start),this.property=n}decode(e,t){const n=this.container._packedGetValue();return au(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==au(e&this.valueMask))throw new TypeError(Am("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=au(e<<this.start);this.container._packedSetValue(au(t&~this.wordMask)|n)}};ne.BitField=Sm;let V2=class extends Sm{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e=="boolean"&&(e=+e),super.encode(e)}};ne.Boolean=V2;let W2=class extends Tt{constructor(e,t){if(!(e instanceof kn&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof kn||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),At(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof kn&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw new TypeError(Am("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(n+i>t.length)throw new RangeError("encoding overruns Uint8Array");const s=At(e);return At(t).write(s.toString("hex"),n,i,"hex"),this.length instanceof kn&&this.length.encode(i,t,n),i}};ne.Blob=W2;let q2=class extends Tt{constructor(e){super(-1,e)}getSpan(e,t=0){su(e);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t=0){const n=this.getSpan(e,t);return At(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));const i=_m.Buffer.from(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");const o=At(t);return i.copy(o,n),o[n+s]=0,s+1}};ne.CString=q2;let Z2=class extends Tt{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return su(e),e.length-t}decode(e,t=0){const n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return At(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));const i=_m.Buffer.from(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(At(t),n),s}};ne.UTF8=Z2;let Q2=class extends Tt{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};ne.Constant=Q2,ne.greedy=(r,e)=>new P2(r,e);var mo=ne.offset=(r,e,t)=>new vm(r,e,t),bt=ne.u8=r=>new ni(1,r),ii=ne.u16=r=>new ni(2,r);ne.u24=r=>new ni(3,r);var Pe=ne.u32=r=>new ni(4,r);ne.u40=r=>new ni(5,r),ne.u48=r=>new ni(6,r);var Vr=ne.nu64=r=>new M2(r);ne.u16be=r=>new Ai(2,r),ne.u24be=r=>new Ai(3,r),ne.u32be=r=>new Ai(4,r),ne.u40be=r=>new Ai(5,r),ne.u48be=r=>new Ai(6,r),ne.nu64be=r=>new L2(r),ne.s8=r=>new xa(1,r),ne.s16=r=>new xa(2,r),ne.s24=r=>new xa(3,r),ne.s32=r=>new xa(4,r),ne.s40=r=>new xa(5,r),ne.s48=r=>new xa(6,r);var Hn=ne.ns64=r=>new U2(r);ne.s16be=r=>new ou(2,r),ne.s24be=r=>new ou(3,r),ne.s32be=r=>new ou(4,r),ne.s40be=r=>new ou(5,r),ne.s48be=r=>new ou(6,r),ne.ns64be=r=>new D2(r),ne.f32=r=>new $2(r),ne.f32be=r=>new F2(r),ne.f64=r=>new H2(r),ne.f64be=r=>new z2(r);var Me=ne.struct=(r,e,t)=>new j2(r,e,t);ne.bits=(r,e,t)=>new Im(r,e,t);var Wr=ne.seq=(r,e,t)=>new G2(r,e,t);ne.union=(r,e,t)=>new Rm(r,e,t),ne.unionLayoutDiscriminator=(r,e)=>new w0(r,e);var Wt=ne.blob=(r,e)=>new W2(r,e);ne.cstr=r=>new q2(r),ne.utf8=(r,e)=>new Z2(r,e),ne.constant=(r,e)=>new Q2(r,e);var If={};Object.defineProperty(If,"__esModule",{value:!0});function sK(r){{const e=Ze.from(r);e.reverse();const t=e.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}var oK=If.toBigIntLE=sK;function aK(r){{const e=r.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}If.toBigIntBE=aK;function cK(r,e){{const t=r.toString(16),n=Ze.from(t.padStart(e*2,"0").slice(0,e*2),"hex");return n.reverse(),n}}var Y2=If.toBufferLE=cK;function uK(r,e){{const t=r.toString(16);return Ze.from(t.padStart(e*2,"0").slice(0,e*2),"hex")}}If.toBufferBE=uK;let lK=class extends TypeError{constructor(e,t){let n;const{message:i,explanation:s,...o}=e,{path:a}=e,u=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function fK(r){return Sf(r)&&typeof r[Symbol.iterator]=="function"}function Sf(r){return typeof r=="object"&&r!=null}function b0(r){return Sf(r)&&!Array.isArray(r)}function vi(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function hK(r){const{done:e,value:t}=r.next();return e?void 0:t}function dK(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:s}=e,{type:o}=t,{refinement:a,message:u=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${vi(n)}\``}=r;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*J2(r,e,t,n){fK(r)||(r=[r]);for(const i of r){const s=dK(i,e,t,n);s&&(yield s)}}function*km(r,e,t={}){const{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,a={path:n,branch:i,mask:o};s&&(r=e.coercer(r,a));let u="valid";for(const l of e.validator(r,a))l.explanation=t.message,u="not_valid",yield[l,void 0];for(let[l,h,g]of e.entries(r,a)){const b=km(h,g,{path:l===void 0?n:[...n,l],branch:l===void 0?i:[...i,h],coerce:s,mask:o,message:t.message});for(const w of b)w[0]?(u=w[0].refinement!=null?"not_refined":"not_valid",yield[w[0],void 0]):s&&(h=w[1],l===void 0?r=h:r instanceof Map?r.set(l,h):r instanceof Set?r.add(h):Sf(r)&&(h!==void 0||l in r)&&(r[l]=h))}if(u!=="not_valid")for(const l of e.refiner(r,a))l.explanation=t.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,r])}let Ki=class{constructor(e){const{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,l)=>{const h=i(u,l);return J2(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return J2(h,l,this,u)}:this.refiner=()=>[]}assert(e,t){return X2(e,this,t)}create(e,t){return Ae(e,this,t)}is(e){return ex(e,this)}mask(e,t){return pK(e,this,t)}validate(e,t={}){return kf(e,this,t)}};function X2(r,e,t){const n=kf(r,e,{message:t});if(n[0])throw n[0]}function Ae(r,e,t){const n=kf(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function pK(r,e,t){const n=kf(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function ex(r,e){return!kf(r,e)[0]}function kf(r,e,t={}){const n=km(r,e,t),i=hK(n);return i[0]?[new lK(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Ra(r,e){return new Ki({type:r,schema:null,validator:e})}function gK(){return Ra("any",()=>!0)}function Re(r){return new Ki({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${vi(e)}`}})}function Vi(){return Ra("boolean",r=>typeof r=="boolean")}function Tm(r){return Ra("instance",e=>e instanceof r||`Expected a \`${r.name}\` instance, but received: ${vi(e)}`)}function rr(r){const e=vi(r),t=typeof r;return new Ki({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${e}\`, but received: ${vi(n)}`}})}function yK(){return Ra("never",()=>!1)}function Ie(r){return new Ki({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function X(){return Ra("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${vi(r)}`)}function He(r){return new Ki({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function tx(r,e){return new Ki({type:"record",schema:null,*entries(t){if(Sf(t))for(const n in t){const i=t[n];yield[n,n,r],yield[n,i,e]}},validator(t){return b0(t)||`Expected an object, but received: ${vi(t)}`},coercer(t){return b0(t)?{...t}:t}})}function _e(){return Ra("string",r=>typeof r=="string"||`Expected a string, but received: ${vi(r)}`)}function Om(r){const e=yK();return new Ki({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const n=Math.max(r.length,t.length);for(let i=0;i<n;i++)yield[i,t[i],r[i]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${vi(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function pe(r){const e=Object.keys(r);return new Ki({type:"type",schema:r,*entries(t){if(Sf(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return b0(t)||`Expected an object, but received: ${vi(t)}`},coercer(t){return b0(t)?{...t}:t}})}function gn(r){const e=r.map(t=>t.type).join(" | ");return new Ki({type:"union",schema:null,coercer(t,n){for(const i of r){const[s,o]=i.validate(t,{coerce:!0,mask:n.mask});if(!s)return o}return t},validator(t,n){const i=[];for(const s of r){const[...o]=km(t,s,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${vi(t)}`,...i]}})}function cu(){return Ra("unknown",()=>!0)}function Tf(r,e,t){return new Ki({...r,coercer:(n,i)=>ex(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}var _0,mK=new Uint8Array(16);function rx(){if(!_0&&(_0=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!_0))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _0(mK)}const wK=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function A0(r){return typeof r=="string"&&wK.test(r)}for(var qr=[],Nm=0;Nm<256;++Nm)qr.push((Nm+256).toString(16).substr(1));function v0(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(qr[r[e+0]]+qr[r[e+1]]+qr[r[e+2]]+qr[r[e+3]]+"-"+qr[r[e+4]]+qr[r[e+5]]+"-"+qr[r[e+6]]+qr[r[e+7]]+"-"+qr[r[e+8]]+qr[r[e+9]]+"-"+qr[r[e+10]]+qr[r[e+11]]+qr[r[e+12]]+qr[r[e+13]]+qr[r[e+14]]+qr[r[e+15]]).toLowerCase();if(!A0(t))throw TypeError("Stringified UUID is invalid");return t}var nx,Cm,Bm=0,Pm=0;function bK(r,e,t){var n=e&&t||0,i=e||new Array(16);r=r||{};var s=r.node||nx,o=r.clockseq!==void 0?r.clockseq:Cm;if(s==null||o==null){var a=r.random||(r.rng||rx)();s==null&&(s=nx=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Cm=(a[6]<<8|a[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),l=r.nsecs!==void 0?r.nsecs:Pm+1,h=u-Bm+(l-Pm)/1e4;if(h<0&&r.clockseq===void 0&&(o=o+1&16383),(h<0||u>Bm)&&r.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Bm=u,Pm=l,Cm=o,u+=122192928e5;var g=((u&268435455)*1e4+l)%4294967296;i[n++]=g>>>24&255,i[n++]=g>>>16&255,i[n++]=g>>>8&255,i[n++]=g&255;var b=u/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=b&255,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var w=0;w<6;++w)i[n+w]=s[w];return e||v0(i)}function ix(r){if(!A0(r))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function _K(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var AK="6ba7b810-9dad-11d1-80b4-00c04fd430c8",vK="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function sx(r,e,t){function n(i,s,o,a){if(typeof i=="string"&&(i=_K(i)),typeof s=="string"&&(s=ix(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(var l=0;l<16;++l)o[a+l]=u[l];return o}return v0(u)}try{n.name=r}catch{}return n.DNS=AK,n.URL=vK,n}function EK(r){if(typeof r=="string"){var e=unescape(encodeURIComponent(r));r=new Uint8Array(e.length);for(var t=0;t<e.length;++t)r[t]=e.charCodeAt(t)}return xK(RK(IK(r),r.length*8))}function xK(r){for(var e=[],t=r.length*32,n="0123456789abcdef",i=0;i<t;i+=8){var s=r[i>>5]>>>i%32&255,o=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);e.push(o)}return e}function ox(r){return(r+64>>>9<<4)+14+1}function RK(r,e){r[e>>5]|=128<<e%32,r[ox(e)-1]=e;for(var t=1732584193,n=-271733879,i=-1732584194,s=271733878,o=0;o<r.length;o+=16){var a=t,u=n,l=i,h=s;t=rn(t,n,i,s,r[o],7,-680876936),s=rn(s,t,n,i,r[o+1],12,-389564586),i=rn(i,s,t,n,r[o+2],17,606105819),n=rn(n,i,s,t,r[o+3],22,-1044525330),t=rn(t,n,i,s,r[o+4],7,-176418897),s=rn(s,t,n,i,r[o+5],12,1200080426),i=rn(i,s,t,n,r[o+6],17,-1473231341),n=rn(n,i,s,t,r[o+7],22,-45705983),t=rn(t,n,i,s,r[o+8],7,1770035416),s=rn(s,t,n,i,r[o+9],12,-1958414417),i=rn(i,s,t,n,r[o+10],17,-42063),n=rn(n,i,s,t,r[o+11],22,-1990404162),t=rn(t,n,i,s,r[o+12],7,1804603682),s=rn(s,t,n,i,r[o+13],12,-40341101),i=rn(i,s,t,n,r[o+14],17,-1502002290),n=rn(n,i,s,t,r[o+15],22,1236535329),t=nn(t,n,i,s,r[o+1],5,-165796510),s=nn(s,t,n,i,r[o+6],9,-1069501632),i=nn(i,s,t,n,r[o+11],14,643717713),n=nn(n,i,s,t,r[o],20,-373897302),t=nn(t,n,i,s,r[o+5],5,-701558691),s=nn(s,t,n,i,r[o+10],9,38016083),i=nn(i,s,t,n,r[o+15],14,-660478335),n=nn(n,i,s,t,r[o+4],20,-405537848),t=nn(t,n,i,s,r[o+9],5,568446438),s=nn(s,t,n,i,r[o+14],9,-1019803690),i=nn(i,s,t,n,r[o+3],14,-187363961),n=nn(n,i,s,t,r[o+8],20,1163531501),t=nn(t,n,i,s,r[o+13],5,-1444681467),s=nn(s,t,n,i,r[o+2],9,-51403784),i=nn(i,s,t,n,r[o+7],14,1735328473),n=nn(n,i,s,t,r[o+12],20,-1926607734),t=sn(t,n,i,s,r[o+5],4,-378558),s=sn(s,t,n,i,r[o+8],11,-2022574463),i=sn(i,s,t,n,r[o+11],16,1839030562),n=sn(n,i,s,t,r[o+14],23,-35309556),t=sn(t,n,i,s,r[o+1],4,-1530992060),s=sn(s,t,n,i,r[o+4],11,1272893353),i=sn(i,s,t,n,r[o+7],16,-155497632),n=sn(n,i,s,t,r[o+10],23,-1094730640),t=sn(t,n,i,s,r[o+13],4,681279174),s=sn(s,t,n,i,r[o],11,-358537222),i=sn(i,s,t,n,r[o+3],16,-722521979),n=sn(n,i,s,t,r[o+6],23,76029189),t=sn(t,n,i,s,r[o+9],4,-640364487),s=sn(s,t,n,i,r[o+12],11,-421815835),i=sn(i,s,t,n,r[o+15],16,530742520),n=sn(n,i,s,t,r[o+2],23,-995338651),t=on(t,n,i,s,r[o],6,-198630844),s=on(s,t,n,i,r[o+7],10,1126891415),i=on(i,s,t,n,r[o+14],15,-1416354905),n=on(n,i,s,t,r[o+5],21,-57434055),t=on(t,n,i,s,r[o+12],6,1700485571),s=on(s,t,n,i,r[o+3],10,-1894986606),i=on(i,s,t,n,r[o+10],15,-1051523),n=on(n,i,s,t,r[o+1],21,-2054922799),t=on(t,n,i,s,r[o+8],6,1873313359),s=on(s,t,n,i,r[o+15],10,-30611744),i=on(i,s,t,n,r[o+6],15,-1560198380),n=on(n,i,s,t,r[o+13],21,1309151649),t=on(t,n,i,s,r[o+4],6,-145523070),s=on(s,t,n,i,r[o+11],10,-1120210379),i=on(i,s,t,n,r[o+2],15,718787259),n=on(n,i,s,t,r[o+9],21,-343485551),t=wo(t,a),n=wo(n,u),i=wo(i,l),s=wo(s,h)}return[t,n,i,s]}function IK(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(ox(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function wo(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function SK(r,e){return r<<e|r>>>32-e}function E0(r,e,t,n,i,s){return wo(SK(wo(wo(e,r),wo(n,s)),i),t)}function rn(r,e,t,n,i,s,o){return E0(e&t|~e&n,r,e,i,s,o)}function nn(r,e,t,n,i,s,o){return E0(e&n|t&~n,r,e,i,s,o)}function sn(r,e,t,n,i,s,o){return E0(e^t^n,r,e,i,s,o)}function on(r,e,t,n,i,s,o){return E0(t^(e|~n),r,e,i,s,o)}var kK=sx("v3",48,EK);function TK(r,e,t){r=r||{};var n=r.random||(r.rng||rx)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=n[i];return e}return v0(n)}function OK(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function Mm(r,e){return r<<e|r>>>32-e}function NK(r){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var i=0;i<n.length;++i)r.push(n.charCodeAt(i))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var s=r.length/4+2,o=Math.ceil(s/16),a=new Array(o),u=0;u<o;++u){for(var l=new Uint32Array(16),h=0;h<16;++h)l[h]=r[u*64+h*4]<<24|r[u*64+h*4+1]<<16|r[u*64+h*4+2]<<8|r[u*64+h*4+3];a[u]=l}a[o-1][14]=(r.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(r.length-1)*8&4294967295;for(var g=0;g<o;++g){for(var b=new Uint32Array(80),w=0;w<16;++w)b[w]=a[g][w];for(var I=16;I<80;++I)b[I]=Mm(b[I-3]^b[I-8]^b[I-14]^b[I-16],1);for(var S=t[0],x=t[1],C=t[2],H=t[3],D=t[4],z=0;z<80;++z){var W=Math.floor(z/20),Z=Mm(S,5)+OK(W,x,C,H)+D+e[W]+b[z]>>>0;D=H,H=C,C=Mm(x,30)>>>0,x=S,S=Z}t[0]=t[0]+S>>>0,t[1]=t[1]+x>>>0,t[2]=t[2]+C>>>0,t[3]=t[3]+H>>>0,t[4]=t[4]+D>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var CK=sx("v5",80,NK);const BK="00000000-0000-0000-0000-000000000000";function PK(r){if(!A0(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const ax=Mc(Object.freeze(Object.defineProperty({__proto__:null,NIL:BK,parse:ix,stringify:v0,v1:bK,v3:kK,v4:TK,v5:CK,validate:A0,version:PK},Symbol.toStringTag,{value:"Module"}))),MK=ax.v4;var LK=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};const i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:r};if(i===2&&(s.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");s.params=e}if(typeof t>"u"){const o=typeof n.generator=="function"?n.generator:function(){return MK()};s.id=o(s,n)}else i===2&&t===null?n.notificationIdNull&&(s.id=null):s.id=t;return s};const UK=ax.v4,DK=LK,Of=function(r,e){if(!(this instanceof Of))return new Of(r,e);e||(e={}),this.options={reviver:typeof e.reviver<"u"?e.reviver:null,replacer:typeof e.replacer<"u"?e.replacer:null,generator:typeof e.generator<"u"?e.generator:function(){return UK()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};var $K=Of;Of.prototype.request=function(r,e,t,n){const i=this;let s=null;const o=Array.isArray(r)&&typeof e=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&r&&typeof r=="object"&&typeof e=="function")n=e,s=r;else{typeof t=="function"&&(n=t,t=void 0);const l=typeof n=="function";try{s=DK(r,e,t,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(l)return n(h);throw h}if(!l)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(l){return n(l)}return this.callServer(u,function(l,h){i._parseResponse(l,h,n)}),s},Of.prototype._parseResponse=function(r,e,t){if(r){t(r);return}if(!e)return t();let n;try{n=JSON.parse(e,this.options.reviver)}catch(i){return t(i)}if(t.length===3)if(Array.isArray(n)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return t(null,n.filter(i),n.filter(s))}else return t(null,n.error,n.result);t(null,n)};const FK=xn($K);var cx={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function s(u,l,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||u,b),I=t?t+l:l;return u._events[I]?u._events[I].fn?u._events[I]=[u._events[I],w]:u._events[I].push(w):(u._events[I]=w,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,g;if(this._eventsCount===0)return l;for(g in h=this._events)e.call(h,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,I=new Array(w);b<w;b++)I[b]=g[b].fn;return I},a.prototype.listenerCount=function(l){var h=t?t+l:l,g=this._events[h];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,h,g,b,w,I){var S=t?t+l:l;if(!this._events[S])return!1;var x=this._events[S],C=arguments.length,H,D;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),C){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,g),!0;case 4:return x.fn.call(x.context,h,g,b),!0;case 5:return x.fn.call(x.context,h,g,b,w),!0;case 6:return x.fn.call(x.context,h,g,b,w,I),!0}for(D=1,H=new Array(C-1);D<C;D++)H[D-1]=arguments[D];x.fn.apply(x.context,H)}else{var z=x.length,W;for(D=0;D<z;D++)switch(x[D].once&&this.removeListener(l,x[D].fn,void 0,!0),C){case 1:x[D].fn.call(x[D].context);break;case 2:x[D].fn.call(x[D].context,h);break;case 3:x[D].fn.call(x[D].context,h,g);break;case 4:x[D].fn.call(x[D].context,h,g,b);break;default:if(!H)for(W=1,H=new Array(C-1);W<C;W++)H[W-1]=arguments[W];x[D].fn.apply(x[D].context,H)}}return!0},a.prototype.on=function(l,h,g){return s(this,l,h,g,!1)},a.prototype.once=function(l,h,g){return s(this,l,h,g,!0)},a.prototype.removeListener=function(l,h,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!h)return o(this,w),this;var I=this._events[w];if(I.fn)I.fn===h&&(!b||I.once)&&(!g||I.context===g)&&o(this,w);else{for(var S=0,x=[],C=I.length;S<C;S++)(I[S].fn!==h||b&&!I[S].once||g&&I[S].context!==g)&&x.push(I[S]);x.length?this._events[w]=x.length===1?x[0]:x:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(cx);var HK=cx.exports;const ux=xn(HK);var zK=class extends ux{constructor(e,t,n){super();Q(this,"socket");this.socket=new window.WebSocket(e,n),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=i=>this.emit("message",i.data),this.socket.onerror=i=>this.emit("error",i),this.socket.onclose=i=>{this.emit("close",i.code,i.reason)}}send(e,t,n){const i=n||t;try{this.socket.send(e),i()}catch(s){i(s)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function GK(r,e){return new zK(r,e)}var jK=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},KK=class extends ux{constructor(e,t="ws://localhost:8080",{autoconnect:n=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...a}={},u,l){super();Q(this,"address");Q(this,"rpc_id");Q(this,"queue");Q(this,"options");Q(this,"autoconnect");Q(this,"ready");Q(this,"reconnect");Q(this,"reconnect_timer_id");Q(this,"reconnect_interval");Q(this,"max_reconnects");Q(this,"rest_options");Q(this,"current_reconnects");Q(this,"generate_request_id");Q(this,"socket");Q(this,"webSocketFactory");Q(this,"dataPack");this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),l?this.dataPack=l:this.dataPack=new jK,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,i){return!i&&typeof n=="object"&&(i=n,n=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(e,t),u={jsonrpc:"2.0",method:e,params:t||void 0,id:a};this.socket.send(this.dataPack.encode(u),i,l=>{if(l)return o(l);this.queue[a]={promise:[s,o]},n&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},n))})})}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise((n,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);n()})})}async subscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.on",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.off",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Ne.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const i=[n.notification];if(n.params.constructor===Object)i.push(n.params);else for(let s=0;s<n.params.length;s++)i.push(n.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",n,i),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval)))})}};const lx=[],fx=[],hx=[],VK=BigInt(0),Nf=BigInt(1),WK=BigInt(2),qK=BigInt(7),ZK=BigInt(256),QK=BigInt(113);for(let r=0,e=Nf,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],lx.push(2*(5*n+t)),fx.push((r+1)*(r+2)/2%64);let i=VK;for(let s=0;s<7;s++)e=(e<<Nf^(e>>qK)*QK)%ZK,e&WK&&(i^=Nf<<(Nf<<BigInt(s))-Nf);hx.push(i)}const[YK,JK]=i2(hx,!0),dx=(r,e,t)=>t>32?a2(r,e,t):s2(r,e,t),px=(r,e,t)=>t>32?c2(r,e,t):o2(r,e,t);function XK(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=t[u],h=t[u+1],g=dx(l,h,1)^t[a],b=px(l,h,1)^t[a+1];for(let w=0;w<50;w+=10)r[o+w]^=g,r[o+w+1]^=b}let i=r[2],s=r[3];for(let o=0;o<24;o++){const a=fx[o],u=dx(i,s,a),l=px(i,s,a),h=lx[o];i=r[h],s=r[h+1],r[h]=u,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=YK[n],r[1]^=JK[n]}t.fill(0)}let eV=class u6 extends Xy{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,t0(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=PG(this.state)}keccak(){XE||e2(this.state32),XK(this.state32,this.rounds),XE||e2(this.state32),this.posOut=0,this.pos=0}update(e){Qc(this);const{blockLen:t,state:n}=this;e=r0(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,t&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Qc(this,!1),vf(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return t0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(JE(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:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new u6(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const gx=((r,e,t)=>em(()=>new eV(e,r,t)))(1,136,256/8);let yx=class extends Xy{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,BG(e);const n=r0(t);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 i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Qc(this),this.iHash.update(e),this}digestInto(e){Qc(this),vf(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:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const mx=(r,e,t)=>new yx(r,e).update(t).digest();mx.create=(r,e)=>new yx(r,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wx(r){r.lowS!==void 0&&Es("lowS",r.lowS),r.prehash!==void 0&&Es("prehash",r.prehash)}function tV(r){const e=hm(r);ru(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:rV,hexToBytes:nV}=lj;class iV extends Error{constructor(e=""){super(e)}}const Is={Err:iV,_tlv:{encode:(r,e)=>{const{Err:t}=Is;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const n=e.length/2,i=Jc(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=n>127?Jc(i.length/2|128):"";return Jc(r)+s+i+e},decode(r,e){const{Err:t}=Is;let n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");const i=e[n++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new t("tlv.decode(long): indefinite length not supported");if(u>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+u);if(l.length!==u)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(n+=u,o<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(r){const{Err:e}=Is;if(r<Ss)throw new e("integer: negative integers are not allowed");let t=Jc(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){const{Err:e}=Is;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return rV(r)}},toSig(r){const{Err:e,_int:t,_tlv:n}=Is,i=typeof r=="string"?nV(r):r;Ef(i);const{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:u}=n.decode(2,s),{v:l,l:h}=n.decode(2,u);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(r){const{_tlv:e,_int:t}=Is,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),s=n+i;return e.encode(48,s)}},Ss=BigInt(0),Lr=BigInt(1);BigInt(2);const bx=BigInt(3);BigInt(4);function sV(r){const e=tV(r),{Fp:t}=e,n=a0(e.n,e.nBitLength),i=e.toBytes||((S,x,C)=>{const H=x.toAffine();return _a(Uint8Array.from([4]),t.toBytes(H.x),t.toBytes(H.y))}),s=e.fromBytes||(S=>{const x=S.subarray(1),C=t.fromBytes(x.subarray(0,t.BYTES)),H=t.fromBytes(x.subarray(t.BYTES,2*t.BYTES));return{x:C,y:H}});function o(S){const{a:x,b:C}=e,H=t.sqr(S),D=t.mul(H,S);return t.add(t.add(D,t.mul(S,x)),C)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return o0(S,Lr,e.n)}function u(S){const{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:H,n:D}=e;if(x&&typeof S!="bigint"){if(ma(S)&&(S=wa(S)),typeof S!="string"||!x.includes(S.length))throw new Error("invalid private key");S=S.padStart(C*2,"0")}let z;try{z=typeof S=="bigint"?S:ba(Tr("private key",S,C))}catch{throw new Error("invalid private key, expected hex or "+C+" bytes, got "+typeof S)}return H&&(z=Zt(z,D)),ri("private key",z,Lr,D),z}function l(S){if(!(S instanceof b))throw new Error("ProjectivePoint expected")}const h=Rf((S,x)=>{const{px:C,py:H,pz:D}=S;if(t.eql(D,t.ONE))return{x:C,y:H};const z=S.is0();x==null&&(x=z?t.ONE:t.inv(D));const W=t.mul(C,x),Z=t.mul(H,x),j=t.mul(D,x);if(z)return{x:t.ZERO,y:t.ZERO};if(!t.eql(j,t.ONE))throw new Error("invZ was invalid");return{x:W,y:Z}}),g=Rf(S=>{if(S.is0()){if(e.allowInfinityPoint&&!t.is0(S.py))return;throw new Error("bad point: ZERO")}const{x,y:C}=S.toAffine();if(!t.isValid(x)||!t.isValid(C))throw new Error("bad point: x or y not FE");const H=t.sqr(C),D=o(x);if(!t.eql(H,D))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class b{constructor(x,C,H){if(this.px=x,this.py=C,this.pz=H,x==null||!t.isValid(x))throw new Error("x required");if(C==null||!t.isValid(C))throw new Error("y required");if(H==null||!t.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(x){const{x:C,y:H}=x||{};if(!x||!t.isValid(C)||!t.isValid(H))throw new Error("invalid affine point");if(x instanceof b)throw new Error("projective point not allowed");const D=z=>t.eql(z,t.ZERO);return D(C)&&D(H)?b.ZERO:new b(C,H,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){const C=t.invertBatch(x.map(H=>H.pz));return x.map((H,D)=>H.toAffine(C[D])).map(b.fromAffine)}static fromHex(x){const C=b.fromAffine(s(Tr("pointHex",x)));return C.assertValidity(),C}static fromPrivateKey(x){return b.BASE.multiply(u(x))}static msm(x,C){return v2(b,n,x,C)}_setWindowSize(x){I.setWindowSize(this,x)}assertValidity(){g(this)}hasEvenY(){const{y:x}=this.toAffine();if(t.isOdd)return!t.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:W,pz:Z}=x,j=t.eql(t.mul(C,Z),t.mul(z,D)),V=t.eql(t.mul(H,Z),t.mul(W,D));return j&&V}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:x,b:C}=e,H=t.mul(C,bx),{px:D,py:z,pz:W}=this;let Z=t.ZERO,j=t.ZERO,V=t.ZERO,oe=t.mul(D,D),ce=t.mul(z,z),ie=t.mul(W,W),ue=t.mul(D,z);return ue=t.add(ue,ue),V=t.mul(D,W),V=t.add(V,V),Z=t.mul(x,V),j=t.mul(H,ie),j=t.add(Z,j),Z=t.sub(ce,j),j=t.add(ce,j),j=t.mul(Z,j),Z=t.mul(ue,Z),V=t.mul(H,V),ie=t.mul(x,ie),ue=t.sub(oe,ie),ue=t.mul(x,ue),ue=t.add(ue,V),V=t.add(oe,oe),oe=t.add(V,oe),oe=t.add(oe,ie),oe=t.mul(oe,ue),j=t.add(j,oe),ie=t.mul(z,W),ie=t.add(ie,ie),oe=t.mul(ie,ue),Z=t.sub(Z,oe),V=t.mul(ie,ce),V=t.add(V,V),V=t.add(V,V),new b(Z,j,V)}add(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:W,pz:Z}=x;let j=t.ZERO,V=t.ZERO,oe=t.ZERO;const ce=e.a,ie=t.mul(e.b,bx);let ue=t.mul(C,z),B=t.mul(H,W),p=t.mul(D,Z),m=t.add(C,H),E=t.add(z,W);m=t.mul(m,E),E=t.add(ue,B),m=t.sub(m,E),E=t.add(C,D);let k=t.add(z,Z);return E=t.mul(E,k),k=t.add(ue,p),E=t.sub(E,k),k=t.add(H,D),j=t.add(W,Z),k=t.mul(k,j),j=t.add(B,p),k=t.sub(k,j),oe=t.mul(ce,E),j=t.mul(ie,p),oe=t.add(j,oe),j=t.sub(B,oe),oe=t.add(B,oe),V=t.mul(j,oe),B=t.add(ue,ue),B=t.add(B,ue),p=t.mul(ce,p),E=t.mul(ie,E),B=t.add(B,p),p=t.sub(ue,p),p=t.mul(ce,p),E=t.add(E,p),ue=t.mul(B,E),V=t.add(V,ue),ue=t.mul(k,E),j=t.mul(m,j),j=t.sub(j,ue),ue=t.mul(m,B),oe=t.mul(k,oe),oe=t.add(oe,ue),new b(j,V,oe)}subtract(x){return this.add(x.negate())}is0(){return this.equals(b.ZERO)}wNAF(x){return I.wNAFCached(this,x,b.normalizeZ)}multiplyUnsafe(x){const{endo:C,n:H}=e;ri("scalar",x,Ss,H);const D=b.ZERO;if(x===Ss)return D;if(this.is0()||x===Lr)return this;if(!C||I.hasPrecomputes(this))return I.wNAFCachedUnsafe(this,x,b.normalizeZ);let{k1neg:z,k1:W,k2neg:Z,k2:j}=C.splitScalar(x),V=D,oe=D,ce=this;for(;W>Ss||j>Ss;)W&Lr&&(V=V.add(ce)),j&Lr&&(oe=oe.add(ce)),ce=ce.double(),W>>=Lr,j>>=Lr;return z&&(V=V.negate()),Z&&(oe=oe.negate()),oe=new b(t.mul(oe.px,C.beta),oe.py,oe.pz),V.add(oe)}multiply(x){const{endo:C,n:H}=e;ri("scalar",x,Lr,H);let D,z;if(C){const{k1neg:W,k1:Z,k2neg:j,k2:V}=C.splitScalar(x);let{p:oe,f:ce}=this.wNAF(Z),{p:ie,f:ue}=this.wNAF(V);oe=I.constTimeNegate(W,oe),ie=I.constTimeNegate(j,ie),ie=new b(t.mul(ie.px,C.beta),ie.py,ie.pz),D=oe.add(ie),z=ce.add(ue)}else{const{p:W,f:Z}=this.wNAF(x);D=W,z=Z}return b.normalizeZ([D,z])[0]}multiplyAndAddUnsafe(x,C,H){const D=b.BASE,z=(Z,j)=>j===Ss||j===Lr||!Z.equals(D)?Z.multiplyUnsafe(j):Z.multiply(j),W=z(this,C).add(z(x,H));return W.is0()?void 0:W}toAffine(x){return h(this,x)}isTorsionFree(){const{h:x,isTorsionFree:C}=e;if(x===Lr)return!0;if(C)return C(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:x,clearCofactor:C}=e;return x===Lr?this:C?C(b,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return Es("isCompressed",x),this.assertValidity(),i(b,this,x)}toHex(x=!0){return Es("isCompressed",x),wa(this.toRawBytes(x))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const w=e.nBitLength,I=A2(b,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function oV(r){const e=hm(r);return ru(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function aV(r){const e=oV(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(p){return Zt(p,n)}function a(p){return am(p,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:g}=sV({...e,toBytes(p,m,E){const k=m.toAffine(),O=t.toBytes(k.x),M=_a;return Es("isCompressed",E),E?M(Uint8Array.from([m.hasEvenY()?2:3]),O):M(Uint8Array.from([4]),O,t.toBytes(k.y))},fromBytes(p){const m=p.length,E=p[0],k=p.subarray(1);if(m===i&&(E===2||E===3)){const O=ba(k);if(!o0(O,Lr,t.ORDER))throw new Error("Point is not on curve");const M=h(O);let G;try{G=t.sqrt(M)}catch(U){const le=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+le)}const P=(G&Lr)===Lr;return(E&1)===1!==P&&(G=t.neg(G)),{x:O,y:G}}else if(m===s&&E===4){const O=t.fromBytes(k.subarray(0,t.BYTES)),M=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:O,y:M}}else{const O=i,M=s;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+M+", got "+m)}}}),b=p=>wa(tu(p,e.nByteLength));function w(p){const m=n>>Lr;return p>m}function I(p){return w(p)?o(-p):p}const S=(p,m,E)=>ba(p.slice(m,E));class x{constructor(m,E,k){this.r=m,this.s=E,this.recovery=k,this.assertValidity()}static fromCompact(m){const E=e.nByteLength;return m=Tr("compactSignature",m,E*2),new x(S(m,0,E),S(m,E,2*E))}static fromDER(m){const{r:E,s:k}=Is.toSig(Tr("DER",m));return new x(E,k)}assertValidity(){ri("r",this.r,Lr,n),ri("s",this.s,Lr,n)}addRecoveryBit(m){return new x(this.r,this.s,m)}recoverPublicKey(m){const{r:E,s:k,recovery:O}=this,M=Z(Tr("msgHash",m));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const G=O===2||O===3?E+e.n:E;if(G>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=O&1?"03":"02",A=u.fromHex(P+b(G)),U=a(G),le=o(-M*U),te=o(k*U),re=u.BASE.multiplyAndAddUnsafe(A,le,te);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Xc(this.toDERHex())}toDERHex(){return Is.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xc(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const C={isValidPrivateKey(p){try{return l(p),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const p=m2(e.n);return _j(e.randomBytes(p),e.n)},precompute(p=8,m=u.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function H(p,m=!0){return u.fromPrivateKey(p).toRawBytes(m)}function D(p){const m=ma(p),E=typeof p=="string",k=(m||E)&&p.length;return m?k===i||k===s:E?k===2*i||k===2*s:p instanceof u}function z(p,m,E=!0){if(D(p))throw new Error("first arg must be private key");if(!D(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(l(p)).toRawBytes(E)}const W=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=ba(p),E=p.length*8-e.nBitLength;return E>0?m>>BigInt(E):m},Z=e.bits2int_modN||function(p){return o(W(p))},j=im(e.nBitLength);function V(p){return ri("num < 2^"+e.nBitLength,p,Ss,j),tu(p,e.nByteLength)}function oe(p,m,E=ce){if(["recovered","canonical"].some(ye=>ye in E))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:O}=e;let{lowS:M,prehash:G,extraEntropy:P}=E;M==null&&(M=!0),p=Tr("msgHash",p),wx(E),G&&(p=Tr("prehashed msgHash",k(p)));const A=Z(p),U=l(m),le=[V(U),V(A)];if(P!=null&&P!==!1){const ye=P===!0?O(t.BYTES):P;le.push(Tr("extraEntropy",ye))}const te=_a(...le),re=A;function he(ye){const be=W(ye);if(!g(be))return;const Ve=a(be),Fe=u.BASE.multiply(be).toAffine(),Be=o(Fe.x);if(Be===Ss)return;const et=o(Ve*o(re+Be*U));if(et===Ss)return;let Qe=(Fe.x===Be?0:2)|Number(Fe.y&Lr),ot=et;return M&&w(et)&&(ot=I(et),Qe^=1),new x(Be,ot,Qe)}return{seed:te,k2sig:he}}const ce={lowS:e.lowS,prehash:!1},ie={lowS:e.lowS,prehash:!1};function ue(p,m,E=ce){const{seed:k,k2sig:O}=oe(p,m,E),M=e;return h2(M.hash.outputLen,M.nByteLength,M.hmac)(k,O)}u.BASE._setWindowSize(8);function B(p,m,E,k=ie){var Qe;const O=p;m=Tr("msgHash",m),E=Tr("publicKey",E);const{lowS:M,prehash:G,format:P}=k;if(wx(k),"strict"in k)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");const A=typeof O=="string"||ma(O),U=!A&&!P&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!A&&!U)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let le,te;try{if(U&&(le=new x(O.r,O.s)),A){try{P!=="compact"&&(le=x.fromDER(O))}catch(ot){if(!(ot instanceof Is.Err))throw ot}!le&&P!=="der"&&(le=x.fromCompact(O))}te=u.fromHex(E)}catch{return!1}if(!le||M&&le.hasHighS())return!1;G&&(m=e.hash(m));const{r:re,s:he}=le,ye=Z(m),be=a(he),Ve=o(ye*be),Fe=o(re*be),Be=(Qe=u.BASE.multiplyAndAddUnsafe(te,Ve,Fe))==null?void 0:Qe.toAffine();return Be?o(Be.x)===re:!1}return{CURVE:e,getPublicKey:H,getSharedSecret:z,sign:ue,verify:B,ProjectivePoint:u,Signature:x,utils:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function cV(r){return{hash:r,hmac:(e,...t)=>mx(r,e,UG(...t)),randomBytes:t2}}function uV(r,e){const t=n=>aV({...r,...cV(n)});return{...t(e),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _x=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ax=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lV=BigInt(1),Lm=BigInt(2),vx=(r,e)=>(r+e/Lm)/e;function fV(r){const e=_x,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=r*r*r%e,h=l*l*r%e,g=ur(h,t,e)*h%e,b=ur(g,t,e)*h%e,w=ur(b,Lm,e)*l%e,I=ur(w,i,e)*w%e,S=ur(I,s,e)*I%e,x=ur(S,a,e)*S%e,C=ur(x,u,e)*x%e,H=ur(C,a,e)*S%e,D=ur(H,t,e)*h%e,z=ur(D,o,e)*I%e,W=ur(z,n,e)*l%e,Z=ur(W,Lm,e);if(!Um.eql(Um.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Um=a0(_x,void 0,void 0,{sqrt:fV}),x0=uV({a:BigInt(0),b:BigInt(7),Fp:Um,n:Ax,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=Ax,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-lV*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=vx(s*r,e),u=vx(-n*r,e);let l=Zt(r-a*t-u*i,e),h=Zt(-a*n-u*s,e);const g=l>o,b=h>o;if(g&&(l=e-l),b&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:l,k2neg:b,k2:h}}}},gm);BigInt(0),x0.ProjectivePoint;const hV=nu.utils.randomPrivateKey,Ex=()=>{const r=nu.utils.randomPrivateKey(),e=R0(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},R0=nu.getPublicKey;function xx(r){try{return nu.ExtendedPoint.fromHex(r),!0}catch{return!1}}const Dm=(r,e)=>nu.sign(r,e.slice(0,32)),dV=nu.verify,nt=r=>Ne.isBuffer(r)?r:r instanceof Uint8Array?Ne.from(r.buffer,r.byteOffset,r.byteLength):Ne.from(r);let $m=class{constructor(e){Object.assign(this,e)}encode(){return Ne.from(C2(Cf,this))}static decode(e){return B2(Cf,this,e)}static decodeUnchecked(e){return S2(Cf,this,e)}};class pV extends $m{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const Cf=new Map;var Rx;const Ix=32,Wi=32;function gV(r){return r._bn!==void 0}let Sx=1;class me extends $m{constructor(e){if(super({}),this._bn=void 0,gV(e))this._bn=e._bn;else{if(typeof e=="string"){const t=Or.decode(e);if(t.length!=Wi)throw new Error("Invalid public key input");this._bn=new vs(t)}else this._bn=new vs(e);if(this._bn.byteLength()>Wi)throw new Error("Invalid public key input")}}static unique(){const e=new me(Sx);return Sx+=1,new me(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Or.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Ne);if(e.length===Wi)return e;const t=Ne.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){const i=Ne.concat([e.toBuffer(),Ne.from(t),n.toBuffer()]),s=gm(i);return new me(s)}static createProgramAddressSync(e,t){let n=Ne.alloc(0);e.forEach(function(s){if(s.length>Ix)throw new TypeError("Max seed length exceeded");n=Ne.concat([n,nt(s)])}),n=Ne.concat([n,t.toBuffer(),Ne.from("ProgramDerivedAddress")]);const i=gm(n);if(xx(i))throw new Error("Invalid seeds, address must fall off the curve");return new me(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,i;for(;n!=0;){try{const s=e.concat(Ne.from([n]));i=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new me(e);return xx(t.toBytes())}}Rx=me,me.default=new Rx("11111111111111111111111111111111"),Cf.set(me,{kind:"struct",fields:[["_bn","u256"]]});class yV{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=nt(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=nt(hV()),this._publicKey=nt(R0(this._secretKey))}get publicKey(){return new me(this._publicKey)}get secretKey(){return Ne.concat([this._secretKey,this._publicKey],64)}}const mV=new me("BPFLoader1111111111111111111111111111111111"),bo=1232,I0=127,Bf=64;class Fm extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Fm.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Hm extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Hm.prototype,"name",{value:"TransactionExpiredTimeoutError"});class uu extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(uu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Pf{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((s,o)=>{n.set(s.toBase58(),o)});const i=s=>{const o=n.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const lt=(r="publicKey")=>Wt(32,r),wV=(r="signature")=>Wt(64,r),Ia=(r="string")=>{const e=Me([Pe("length"),Pe("lengthPadding"),Wt(mo(Pe(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(s,o)=>t(s,o).chars.toString(),i.encode=(s,o,a)=>{const u={chars:Ne.from(s,"utf8")};return n(u,o,a)},i.alloc=s=>Pe().span+Pe().span+Ne.from(s,"utf8").length,i},bV=(r="authorized")=>Me([lt("staker"),lt("withdrawer")],r),_V=(r="lockup")=>Me([Hn("unixTimestamp"),Hn("epoch"),lt("custodian")],r),AV=(r="voteInit")=>Me([lt("nodePubkey"),lt("authorizedVoter"),lt("authorizedWithdrawer"),bt("commission")],r),vV=(r="voteAuthorizeWithSeedArgs")=>Me([Pe("voteAuthorizationType"),lt("currentAuthorityDerivedKeyOwnerPubkey"),Ia("currentAuthorityDerivedKeySeed"),lt("newAuthorized")],r);function kx(r,e){const t=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(e[i.property]);if("count"in i&&"elementLayout"in i){const s=e[i.property];if(Array.isArray(s))return s.length*t(i.elementLayout)}else if("fields"in i)return kx({layout:i},e[i.property]);return 0};let n=0;return r.layout.fields.forEach(i=>{n+=t(i)}),n}function Tn(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,!(n&128))break}return e}function zn(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function vt(r,e){if(!r)throw new Error(e||"Assertion failed")}class S0{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const n=new Map,i=o=>{const a=o.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},s=i(t);s.isSigner=!0,s.isWritable=!0;for(const o of e){i(o.programId).isInvoked=!0;for(const a of o.keys){const u=i(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new S0(t,n)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];vt(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),i=e.filter(([,u])=>!u.isSigner&&u.isWritable),s=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{vt(t.length>0,"Expected at least one writable signer key");const[u]=t[0];vt(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([u])=>new me(u)),...n.map(([u])=>new me(u)),...i.map(([u])=>new me(u)),...s.map(([u])=>new me(u))];return[o,a]}extractTableLookup(e){const[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(e,t){const n=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(t(o)){const a=new me(s),u=e.findIndex(l=>l.equals(a));u>=0&&(vt(u<256,"Max lookup table index exceeded"),n.push(u),i.push(a),this.keyMetaMap.delete(s))}return[n,i]}}const Tx="Reached end of buffer unexpectedly";function qi(r){if(r.length===0)throw new Error(Tx);return r.shift()}function On(r,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>r.length:t>=r.length)throw new Error(Tx);return r.splice(...e)}class Ei{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new me(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Or.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Pf(this.staticAccountKeys)}static compile(e){const t=S0.compile(e.instructions,e.payerKey),[n,i]=t.getMessageComponents(),o=new Pf(i).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Or.encode(a.data)}));return new Ei({header:n,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const n=e-t,s=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<s}else{const n=t-this.header.numReadonlySignedAccounts;return e<n}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];zn(t,e);const n=this.instructions.map(g=>{const{accounts:b,programIdIndex:w}=g,I=Array.from(Or.decode(g.data));let S=[];zn(S,b.length);let x=[];return zn(x,I.length),{programIdIndex:w,keyIndicesCount:Ne.from(S),keyIndices:b,dataLength:Ne.from(x),data:I}});let i=[];zn(i,n.length);let s=Ne.alloc(bo);Ne.from(i).copy(s);let o=i.length;n.forEach(g=>{const w=Me([bt("programIdIndex"),Wt(g.keyIndicesCount.length,"keyIndicesCount"),Wr(bt("keyIndex"),g.keyIndices.length,"keyIndices"),Wt(g.dataLength.length,"dataLength"),Wr(bt("userdatum"),g.data.length,"data")]).encode(g,s,o);o+=w}),s=s.slice(0,o);const a=Me([Wt(1,"numRequiredSignatures"),Wt(1,"numReadonlySignedAccounts"),Wt(1,"numReadonlyUnsignedAccounts"),Wt(t.length,"keyCount"),Wr(lt("key"),e,"keys"),lt("recentBlockhash")]),u={numRequiredSignatures:Ne.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Ne.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Ne.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Ne.from(t),keys:this.accountKeys.map(g=>nt(g.toBytes())),recentBlockhash:Or.decode(this.recentBlockhash)};let l=Ne.alloc(2048);const h=a.encode(u,l);return s.copy(l,h),l.slice(0,h+s.length)}static from(e){let t=[...e];const n=qi(t);if(n!==(n&I0))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=qi(t),s=qi(t),o=Tn(t);let a=[];for(let b=0;b<o;b++){const w=On(t,0,Wi);a.push(new me(Ne.from(w)))}const u=On(t,0,Wi),l=Tn(t);let h=[];for(let b=0;b<l;b++){const w=qi(t),I=Tn(t),S=On(t,0,I),x=Tn(t),C=On(t,0,x),H=Or.encode(Ne.from(C));h.push({programIdIndex:w,accounts:S,data:H})}const g={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:Or.encode(Ne.from(u)),accountKeys:a,instructions:h};return new Ei(g)}}class Sa{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Pf(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(e>=n){const i=e-n,s=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<s}else if(e>=this.header.numRequiredSignatures){const i=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=t-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const n of this.addressTableLookups){const i=e.find(s=>s.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const s of n.writableIndexes)if(s<i.state.addresses.length)t.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(const s of n.readonlyIndexes)if(s<i.state.addresses.length)t.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){const t=S0.compile(e.instructions,e.payerKey),n=new Array,i={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(const h of s){const g=t.extractTableLookup(h);if(g!==void 0){const[b,{writable:w,readonly:I}]=g;n.push(b),i.writable.push(...w),i.readonly.push(...I)}}const[o,a]=t.getMessageComponents(),l=new Pf(a,i).compileInstructions(e.instructions);return new Sa({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:l,addressTableLookups:n})}serialize(){const e=Array();zn(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();zn(n,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();zn(s,this.addressTableLookups.length);const o=Me([bt("prefix"),Me([bt("numRequiredSignatures"),bt("numReadonlySignedAccounts"),bt("numReadonlyUnsignedAccounts")],"header"),Wt(e.length,"staticAccountKeysLength"),Wr(lt(),this.staticAccountKeys.length,"staticAccountKeys"),lt("recentBlockhash"),Wt(n.length,"instructionsLength"),Wt(t.length,"serializedInstructions"),Wt(s.length,"addressTableLookupsLength"),Wt(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(bo),l=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:Or.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},a);return a.slice(0,l)}serializeInstructions(){let e=0;const t=new Uint8Array(bo);for(const n of this.compiledInstructions){const i=Array();zn(i,n.accountKeyIndexes.length);const s=Array();zn(s,n.data.length);const o=Me([bt("programIdIndex"),Wt(i.length,"encodedAccountKeyIndexesLength"),Wr(bt(),n.accountKeyIndexes.length,"accountKeyIndexes"),Wt(s.length,"encodedDataLength"),Wt(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(bo);for(const n of this.addressTableLookups){const i=Array();zn(i,n.writableIndexes.length);const s=Array();zn(s,n.readonlyIndexes.length);const o=Me([lt("accountKey"),Wt(i.length,"encodedWritableIndexesLength"),Wr(bt(),n.writableIndexes.length,"writableIndexes"),Wt(s.length,"encodedReadonlyIndexesLength"),Wr(bt(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const n=qi(t),i=n&I0;vt(n!==i,"Expected versioned message but received legacy message");const s=i;vt(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:qi(t),numReadonlySignedAccounts:qi(t),numReadonlyUnsignedAccounts:qi(t)},a=[],u=Tn(t);for(let I=0;I<u;I++)a.push(new me(On(t,0,Wi)));const l=Or.encode(On(t,0,Wi)),h=Tn(t),g=[];for(let I=0;I<h;I++){const S=qi(t),x=Tn(t),C=On(t,0,x),H=Tn(t),D=new Uint8Array(On(t,0,H));g.push({programIdIndex:S,accountKeyIndexes:C,data:D})}const b=Tn(t),w=[];for(let I=0;I<b;I++){const S=new me(On(t,0,Wi)),x=Tn(t),C=On(t,0,x),H=Tn(t),D=On(t,0,H);w.push({accountKey:S,writableIndexes:C,readonlyIndexes:D})}return new Sa({header:o,staticAccountKeys:a,recentBlockhash:l,compiledInstructions:g,addressTableLookups:w})}}const zm={deserializeMessageVersion(r){const e=r[0],t=e&I0;return t===e?"legacy":t},deserialize:r=>{const e=zm.deserializeMessageVersion(r);if(e==="legacy")return Ei.from(r);if(e===0)return Sa.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let ks=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({});const EV=Ne.alloc(Bf).fill(0);class Pt{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Ne.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}let Ot=class L_{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{const{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Pt(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let S=0;S<t.length;S++)if(t[S].programId===void 0)throw new Error(`Transaction instruction index ${S} has undefined program id`);const i=[],s=[];t.forEach(S=>{S.keys.forEach(C=>{s.push({...C})});const x=S.programId.toString();i.includes(x)||i.push(x)}),i.forEach(S=>{s.push({pubkey:new me(S),isSigner:!1,isWritable:!1})});const o=[];s.forEach(S=>{const x=S.pubkey.toString(),C=o.findIndex(H=>H.pubkey.toString()===x);C>-1?(o[C].isWritable=o[C].isWritable||S.isWritable,o[C].isSigner=o[C].isSigner||S.isSigner):o.push(S)}),o.sort(function(S,x){if(S.isSigner!==x.isSigner)return S.isSigner?-1:1;if(S.isWritable!==x.isWritable)return S.isWritable?-1:1;const C={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return S.pubkey.toBase58().localeCompare(x.pubkey.toBase58(),"en",C)});const a=o.findIndex(S=>S.pubkey.equals(n));if(a>-1){const[S]=o.splice(a,1);S.isSigner=!0,S.isWritable=!0,o.unshift(S)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const S of this.signatures){const x=o.findIndex(C=>C.pubkey.equals(S.publicKey));if(x>-1)o[x].isSigner||(o[x].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${S.publicKey.toString()}`)}let u=0,l=0,h=0;const g=[],b=[];o.forEach(({pubkey:S,isSigner:x,isWritable:C})=>{x?(g.push(S.toString()),u+=1,C||(l+=1)):(b.push(S.toString()),C||(h+=1))});const w=g.concat(b),I=t.map(S=>{const{data:x,programId:C}=S;return{programIdIndex:w.indexOf(C.toString()),accounts:S.keys.map(H=>w.indexOf(H.pubkey.toString())),data:Or.encode(x)}});return I.forEach(S=>{vt(S.programIdIndex>=0),S.accounts.forEach(x=>vt(x>=0))}),new Ei({header:{numRequiredSignatures:u,numReadonlySignedAccounts:l,numReadonlyUnsignedAccounts:h},accountKeys:w,recentBlockhash:e,instructions:I})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((i,s)=>t[s].equals(i.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(n=>{const i=n.toString();return t.has(i)?!1:(t.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const s of e){const o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const s of e){const o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}const i=this._compile();this._partialSign(i,...n)}_partialSign(e,...t){const n=e.serialize();t.forEach(i=>{const s=Dm(n,i.secretKey);this._addSignature(i.publicKey,nt(s))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){vt(t.length===64);const n=this.signatures.findIndex(i=>e.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=Ne.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const n={};for(const{signature:i,publicKey:s}of this.signatures)i===null?t&&(n.missing||(n.missing=[])).push(s):dV(i,e,s.toBytes())||(n.invalid||(n.invalid=[])).push(s);return n.invalid||n.missing?n:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(n){const s=this._getMessageSignednessErrors(i,t);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
19
+ Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
20
+ Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(e){const{signatures:t}=this,n=[];zn(n,t.length);const i=n.length+t.length*64+e.length,s=Ne.alloc(i);return vt(t.length<256),Ne.from(n).copy(s,0),t.forEach(({signature:o},a)=>{o!==null&&(vt(o.length===64,"signature has invalid length"),Ne.from(o).copy(s,n.length+a*64))}),e.copy(s,n.length+t.length*64),vt(s.length<=bo,`Transaction too large: ${s.length} > ${bo}`),s}get keys(){return vt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return vt(this.instructions.length===1),this.instructions[0].programId}get data(){return vt(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const n=Tn(t);let i=[];for(let s=0;s<n;s++){const o=On(t,0,Bf);i.push(Or.encode(Ne.from(o)))}return L_.populate(Ei.from(t),i)}static populate(e,t=[]){const n=new L_;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((i,s)=>{const o={signature:i==Or.encode(EV)?null:Or.decode(i),publicKey:e.accountKeys[s]};n.signatures.push(o)}),e.instructions.forEach(i=>{const s=i.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});n.instructions.push(new Pt({keys:s,programId:e.accountKeys[i.programIdIndex],data:Or.decode(i.data)}))}),n._message=e,n._json=n.toJSON(),n}};class Gm{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:n,compiledInstructions:i,recentBlockhash:s}=e,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=n,l=o-a;vt(l>0,"Message header is invalid");const h=e.staticAccountKeys.length-o-u;vt(h>=0,"Message header is invalid");const g=e.getAccountKeys(t),b=g.get(0);if(b===void 0)throw new Error("Failed to decompile message because no account keys were found");const w=[];for(const I of i){const S=[];for(const C of I.accountKeyIndexes){const H=g.get(C);if(H===void 0)throw new Error(`Failed to find key for account key index ${C}`);const D=C<o;let z;D?z=C<l:C<g.staticAccountKeys.length?z=C-o<h:z=C-g.staticAccountKeys.length<g.accountKeysFromLookups.writable.length,S.push({pubkey:H,isSigner:C<n.numRequiredSignatures,isWritable:z})}const x=g.get(I.programIdIndex);if(x===void 0)throw new Error(`Failed to find program id for program id index ${I.programIdIndex}`);w.push(new Pt({programId:x,data:nt(I.data),keys:S}))}return new Gm({payerKey:b,instructions:w,recentBlockhash:s})}compileToLegacyMessage(){return Ei.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Sa.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class jm{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)vt(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const n=[];for(let i=0;i<e.header.numRequiredSignatures;i++)n.push(new Uint8Array(Bf));this.signatures=n}this.message=e}serialize(){const e=this.message.serialize(),t=Array();zn(t,this.signatures.length);const n=Me([Wt(t.length,"encodedSignaturesLength"),Wr(wV(),this.signatures.length,"signatures"),Wt(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e];const n=[],i=Tn(t);for(let o=0;o<i;o++)n.push(new Uint8Array(On(t,0,Bf)));const s=zm.deserialize(new Uint8Array(t));return new jm(s,n)}sign(e){const t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of e){const s=n.findIndex(o=>o.equals(i.publicKey));vt(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=Dm(t,i.secretKey)}}addSignature(e,t){vt(t.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));vt(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=t}}const Ox=1e3/(160/64),Zi=new me("SysvarC1ock11111111111111111111111111111111"),xV=new me("SysvarEpochSchedu1e111111111111111111111111"),RV=new me("Sysvar1nstructions1111111111111111111111111"),k0=new me("SysvarRecentB1ockHashes11111111111111111111"),lu=new me("SysvarRent111111111111111111111111111111111"),IV=new me("SysvarRewards111111111111111111111111111111"),SV=new me("SysvarS1otHashes111111111111111111111111111"),kV=new me("SysvarS1otHistory11111111111111111111111111"),T0=new me("SysvarStakeHistory1111111111111111111111111");class _o extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:i}){const s=i?`Logs:
21
+ ${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(e){case"send":a=`Transaction ${t} resulted in an error.
22
+ ${n}. `+s+o;break;case"simulate":a=`Simulation failed.
23
+ Message: ${n}.
24
+ `+s+o;break;default:a=`Unknown action '${(u=>u)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,t(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const TV={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class $e extends Error{constructor({code:e,message:t,data:n},i){super(i!=null?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}}async function Km(r,e,t,n){const i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await r.sendTransaction(e,t,i);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:s,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,u=a.keys[0].pubkey;o=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await r.confirmTransaction(s,n&&n.commitment)).value;if(o.err)throw s!=null?new _o({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function ka(r){return new Promise(e=>setTimeout(e,r))}function yt(r,e){const t=r.layout.span>=0?r.layout.span:kx(r,e),n=Ne.alloc(t),i=Object.assign({instruction:r.index},e);return r.layout.encode(i,n),n}function kt(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.instruction!==r.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${r.index}`);return t}const Nx=Vr("lamportsPerSignature"),Cx=Me([Pe("version"),Pe("state"),lt("authorizedPubkey"),lt("nonce"),Me([Nx],"feeCalculator")]),Vm=Cx.span;class O0{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Cx.decode(nt(e),0);return new O0({authorizedPubkey:new me(t.authorizedPubkey),nonce:new me(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const OV=r=>{const e=r.decode.bind(r),t=r.encode.bind(r);return{decode:e,encode:t}},fu=(r=>e=>{const t=Wt(r,e),{encode:n,decode:i}=OV(t),s=t;return s.decode=(o,a)=>{const u=i(o,a);return oK(Ne.from(u))},s.encode=(o,a,u)=>{const l=Y2(o,r);return n(l,a,u)},s})(8);class NV{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ht))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:n,programId:i}=kt(Ht.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new me(i)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=kt(Ht.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:n,programId:i}=kt(Ht.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new me(i)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=kt(Ht.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,space:i,programId:s}=kt(Ht.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new me(t),seed:n,space:i,programId:new me(s)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=kt(Ht.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new me(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,programId:i}=kt(Ht.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new me(t),seed:n,programId:new me(i)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:n,lamports:i,space:s,programId:o}=kt(Ht.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new me(t),seed:n,lamports:i,space:s,programId:new me(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=kt(Ht.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new me(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(Ht.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=kt(Ht.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=kt(Ht.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new me(t)}}static checkProgramId(e){if(!e.equals(Br.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Ht=Object.freeze({Create:{index:0,layout:Me([Pe("instruction"),Hn("lamports"),Hn("space"),lt("programId")])},Assign:{index:1,layout:Me([Pe("instruction"),lt("programId")])},Transfer:{index:2,layout:Me([Pe("instruction"),fu("lamports")])},CreateWithSeed:{index:3,layout:Me([Pe("instruction"),lt("base"),Ia("seed"),Hn("lamports"),Hn("space"),lt("programId")])},AdvanceNonceAccount:{index:4,layout:Me([Pe("instruction")])},WithdrawNonceAccount:{index:5,layout:Me([Pe("instruction"),Hn("lamports")])},InitializeNonceAccount:{index:6,layout:Me([Pe("instruction"),lt("authorized")])},AuthorizeNonceAccount:{index:7,layout:Me([Pe("instruction"),lt("authorized")])},Allocate:{index:8,layout:Me([Pe("instruction"),Hn("space")])},AllocateWithSeed:{index:9,layout:Me([Pe("instruction"),lt("base"),Ia("seed"),Hn("space"),lt("programId")])},AssignWithSeed:{index:10,layout:Me([Pe("instruction"),lt("base"),Ia("seed"),lt("programId")])},TransferWithSeed:{index:11,layout:Me([Pe("instruction"),fu("lamports"),Ia("seed"),lt("programId")])},UpgradeNonceAccount:{index:12,layout:Me([Pe("instruction")])}});class Br{constructor(){}static createAccount(e){const t=Ht.Create,n=yt(t,{lamports:e.lamports,space:e.space,programId:nt(e.programId.toBuffer())});return new Pt({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if("basePubkey"in e){const i=Ht.TransferWithSeed;t=yt(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=Ht.Transfer;t=yt(i,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Pt({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const i=Ht.AssignWithSeed;t=yt(i,{base:nt(e.basePubkey.toBuffer()),seed:e.seed,programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=Ht.Assign;t=yt(i,{programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pt({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Ht.CreateWithSeed,n=yt(t,{base:nt(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:nt(e.programId.toBuffer())});let i=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||i.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Pt({keys:i,programId:this.programId,data:n})}static createNonceAccount(e){const t=new Ot;"basePubkey"in e&&"seed"in e?t.add(Br.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Vm,programId:this.programId})):t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Vm,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=Ht.InitializeNonceAccount,n=yt(t,{authorized:nt(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:k0,isSigner:!1,isWritable:!1},{pubkey:lu,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Pt(i)}static nonceAdvance(e){const t=Ht.AdvanceNonceAccount,n=yt(t),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:k0,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Pt(i)}static nonceWithdraw(e){const t=Ht.WithdrawNonceAccount,n=yt(t,{lamports:e.lamports});return new Pt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:k0,isSigner:!1,isWritable:!1},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=Ht.AuthorizeNonceAccount,n=yt(t,{authorized:nt(e.newAuthorizedPubkey.toBuffer())});return new Pt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if("basePubkey"in e){const i=Ht.AllocateWithSeed;t=yt(i,{base:nt(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=Ht.Allocate;t=yt(i,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pt({keys:n,programId:this.programId,data:t})}}Br.programId=new me("11111111111111111111111111111111");const CV=bo-300;class Ta{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Ta.chunkSize)+1+1)}static async load(e,t,n,i,s){{const g=await e.getMinimumBalanceForRentExemption(s.length),b=await e.getAccountInfo(n.publicKey,"confirmed");let w=null;if(b!==null){if(b.executable)return console.error("Program load failed, account is already executable"),!1;b.data.length!==s.length&&(w=w||new Ot,w.add(Br.allocate({accountPubkey:n.publicKey,space:s.length}))),b.owner.equals(i)||(w=w||new Ot,w.add(Br.assign({accountPubkey:n.publicKey,programId:i}))),b.lamports<g&&(w=w||new Ot,w.add(Br.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:g-b.lamports})))}else w=new Ot().add(Br.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:g>0?g:1,space:s.length,programId:i}));w!==null&&await Km(e,w,[t,n],{commitment:"confirmed"})}const o=Me([Pe("instruction"),Pe("offset"),Pe("bytesLength"),Pe("bytesLengthPadding"),Wr(bt("byte"),mo(Pe(),-8),"bytes")]),a=Ta.chunkSize;let u=0,l=s,h=[];for(;l.length>0;){const g=l.slice(0,a),b=Ne.alloc(a+16);o.encode({instruction:0,offset:u,bytes:g,bytesLength:0,bytesLengthPadding:0},b);const w=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:b});h.push(Km(e,w,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await ka(1e3/4),u+=a,l=l.slice(a)}await Promise.all(h);{const g=Me([Pe("instruction")]),b=Ne.alloc(g.span);g.encode({instruction:1},b);const w=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1}],programId:i,data:b}),I="processed",S=await e.sendTransaction(w,[t,n],{preflightCommitment:I}),{context:x,value:C}=await e.confirmTransaction({signature:S,lastValidBlockHeight:w.lastValidBlockHeight,blockhash:w.recentBlockhash},I);if(C.err)throw new Error(`Transaction ${S} failed (${JSON.stringify(C)})`);for(;;){try{if(await e.getSlot({commitment:I})>x.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(Ox/2)))}}return!0}}Ta.chunkSize=CV;const BV=new me("BPFLoader2111111111111111111111111111111111");class PV{static getMinNumSignatures(e){return Ta.getMinNumSignatures(e)}static load(e,t,n,i,s){return Ta.load(e,t,n,s,i)}}function MV(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wm,Bx;function LV(){if(Bx)return Wm;Bx=1;var r=Object.prototype.toString,e=Object.keys||function(n){var i=[];for(var s in n)i.push(s);return i};function t(n,i){var s,o,a,u,l,h,g;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return t(n.toJSON(),i);if(g=r.call(n),g==="[object Array]"){for(a="[",o=n.length-1,s=0;s<o;s++)a+=t(n[s],!0)+",";return o>-1&&(a+=t(n[s],!0)),a+"]"}else if(g==="[object Object]"){for(u=e(n).sort(),o=u.length,a="",s=0;s<o;)l=u[s],h=t(n[l],!1),h!==void 0&&(a&&(a+=","),a+=JSON.stringify(l)+":"+h),s++;return"{"+a+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return Wm=function(n){var i=t(n,!1);if(i!==void 0)return""+i},Wm}var UV=LV(),Px=MV(UV);const Mf=32;function qm(r){let e=0;for(;r>1;)r/=2,e++;return e}function DV(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class Mx{constructor(e,t,n,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=qm(DV(e+Mf+1))-qm(Mf)-1,n=this.getSlotsInEpoch(t),i=e-(n-Mf);return[t,i]}else{const t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),i=this.firstNormalEpoch+n,s=t%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Mf:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+qm(Mf)):this.slotsPerEpoch}}var $V=globalThis.fetch;class FV extends KK{constructor(e,t,n){const i=s=>{const o=GK(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,e,t,n),this.underlyingSocket=void 0}call(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function HV(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}const Lx=56;class Zm{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=HV(zV,e),n=e.length-Lx;vt(n>=0,"lookup table is invalid"),vt(n%32===0,"lookup table is invalid");const i=n/32,{addresses:s}=Me([Wr(lt(),i,"addresses")]).decode(e.slice(Lx));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new me(t.authority[0]):void 0,addresses:s.map(o=>new me(o))}}}const zV={index:1,layout:Me([Pe("typeIndex"),fu("deactivationSlot"),Vr("lastExtendedSlot"),bt("lastExtendedStartIndex"),bt(),Wr(lt(),mo(bt(),-1),"authority")])},GV=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function jV(r){const e=r.match(GV);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[t,n,i,s]=e,o=r.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${n}${u}${s}`}const nr=Tf(Tm(me),_e(),r=>new me(r)),Ux=Om([_e(),rr("base64")]),Qm=Tf(Tm(Ne),Ux,r=>Ne.from(r[0],"base64")),Dx=30*1e3;function KV(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function zt(r){let e,t;if(typeof r=="string")e=r;else if(r){const{commitment:n,...i}=r;e=n,t=i}return{commitment:e,config:t}}function $x(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function Fx(r){return gn([pe({jsonrpc:rr("2.0"),id:_e(),result:r}),pe({jsonrpc:rr("2.0"),id:_e(),error:pe({code:cu(),message:_e(),data:He(gK())})})])}const VV=Fx(cu());function it(r){return Tf(Fx(r),VV,e=>"error"in e?e:{...e,result:Ae(e.result,r)})}function Er(r){return it(pe({context:pe({slot:X()}),value:r}))}function N0(r){return pe({context:pe({slot:X()}),value:r})}function Ym(r,e){return r===0?new Sa({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new me(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Or.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Ei(e)}const WV=pe({foundation:X(),foundationTerm:X(),initial:X(),taper:X(),terminal:X()}),qV=it(Re(Ie(pe({epoch:X(),effectiveSlot:X(),amount:X(),postBalance:X(),commission:He(Ie(X()))})))),ZV=Re(pe({slot:X(),prioritizationFee:X()})),QV=pe({total:X(),validator:X(),foundation:X(),epoch:X()}),YV=pe({epoch:X(),slotIndex:X(),slotsInEpoch:X(),absoluteSlot:X(),blockHeight:He(X()),transactionCount:He(X())}),JV=pe({slotsPerEpoch:X(),leaderScheduleSlotOffset:X(),warmup:Vi(),firstNormalEpoch:X(),firstNormalSlot:X()}),XV=tx(_e(),Re(X())),Oa=Ie(gn([pe({}),_e()])),eW=pe({err:Oa}),tW=rr("receivedSignature"),rW=pe({"solana-core":_e(),"feature-set":He(X())}),nW=pe({program:_e(),programId:nr,parsed:cu()}),iW=pe({programId:nr,accounts:Re(nr),data:_e()}),Hx=Er(pe({err:Ie(gn([pe({}),_e()])),logs:Ie(Re(_e())),accounts:He(Ie(Re(Ie(pe({executable:Vi(),owner:_e(),lamports:X(),data:Re(_e()),rentEpoch:He(X())}))))),unitsConsumed:He(X()),returnData:He(Ie(pe({programId:_e(),data:Om([_e(),rr("base64")])}))),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(gn([nW,iW]))}))))})),sW=Er(pe({byIdentity:tx(_e(),Re(X())),range:pe({firstSlot:X(),lastSlot:X()})}));function oW(r,e,t,n,i,s){const o=t||$V;let a;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(h,g)=>{const b=await new Promise((w,I)=>{try{n(h,g,(S,x)=>w([S,x]))}catch(S){I(S)}});return await o(...b)}),new FK(async(h,g)=>{const b={method:"POST",body:h,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},oq)};try{let w=5,I,S=500;for(;u?I=await u(r,b):I=await o(r,b),!(I.status!==429||i===!0||(w-=1,w===0));)console.error(`Server responded with ${I.status} ${I.statusText}. Retrying after ${S}ms delay...`),await ka(S),S*=2;const x=await I.text();I.ok?g(null,x):g(new Error(`${I.status} ${I.statusText}: ${x}`))}catch(w){w instanceof Error&&g(w)}},{})}function aW(r){return(e,t)=>new Promise((n,i)=>{r.request(e,t,(s,o)=>{if(s){i(s);return}n(o)})})}function cW(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);const i=e.map(s=>r.request(s.methodName,s.args));r.request(i,(s,o)=>{if(s){n(s);return}t(o)})})}const uW=it(WV),lW=it(QV),fW=it(ZV),hW=it(YV),dW=it(JV),pW=it(XV),gW=it(X()),yW=Er(pe({total:X(),circulating:X(),nonCirculating:X(),nonCirculatingAccounts:Re(nr)})),Jm=pe({amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:He(_e())}),mW=Er(Re(pe({address:nr,amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:He(_e())}))),wW=Er(Re(pe({pubkey:nr,account:pe({executable:Vi(),owner:nr,lamports:X(),data:Qm,rentEpoch:X()})}))),Xm=pe({program:_e(),parsed:cu(),space:X()}),bW=Er(Re(pe({pubkey:nr,account:pe({executable:Vi(),owner:nr,lamports:X(),data:Xm,rentEpoch:X()})}))),_W=Er(Re(pe({lamports:X(),address:nr}))),Lf=pe({executable:Vi(),owner:nr,lamports:X(),data:Qm,rentEpoch:X()}),AW=pe({pubkey:nr,account:Lf}),vW=Tf(gn([Tm(Ne),Xm]),gn([Ux,Xm]),r=>Array.isArray(r)?Ae(r,Qm):r),e1=pe({executable:Vi(),owner:nr,lamports:X(),data:vW,rentEpoch:X()}),EW=pe({pubkey:nr,account:e1}),xW=pe({state:gn([rr("active"),rr("inactive"),rr("activating"),rr("deactivating")]),active:X(),inactive:X()}),RW=it(Re(pe({signature:_e(),slot:X(),err:Oa,memo:Ie(_e()),blockTime:He(Ie(X()))}))),IW=it(Re(pe({signature:_e(),slot:X(),err:Oa,memo:Ie(_e()),blockTime:He(Ie(X()))}))),SW=pe({subscription:X(),result:N0(Lf)}),kW=pe({pubkey:nr,account:Lf}),TW=pe({subscription:X(),result:N0(kW)}),OW=pe({parent:X(),slot:X(),root:X()}),NW=pe({subscription:X(),result:OW}),CW=gn([pe({type:gn([rr("firstShredReceived"),rr("completed"),rr("optimisticConfirmation"),rr("root")]),slot:X(),timestamp:X()}),pe({type:rr("createdBank"),parent:X(),slot:X(),timestamp:X()}),pe({type:rr("frozen"),slot:X(),timestamp:X(),stats:pe({numTransactionEntries:X(),numSuccessfulTransactions:X(),numFailedTransactions:X(),maxTransactionsPerEntry:X()})}),pe({type:rr("dead"),slot:X(),timestamp:X(),err:_e()})]),BW=pe({subscription:X(),result:CW}),PW=pe({subscription:X(),result:N0(gn([eW,tW]))}),MW=pe({subscription:X(),result:X()}),LW=pe({pubkey:_e(),gossip:Ie(_e()),tpu:Ie(_e()),rpc:Ie(_e()),version:Ie(_e())}),zx=pe({votePubkey:_e(),nodePubkey:_e(),activatedStake:X(),epochVoteAccount:Vi(),epochCredits:Re(Om([X(),X(),X()])),commission:X(),lastVote:X(),rootSlot:Ie(X())}),UW=it(pe({current:Re(zx),delinquent:Re(zx)})),DW=gn([rr("processed"),rr("confirmed"),rr("finalized")]),$W=pe({slot:X(),confirmations:Ie(X()),err:Oa,confirmationStatus:He(DW)}),FW=Er(Re(Ie($W))),HW=it(X()),Gx=pe({accountKey:nr,writableIndexes:Re(X()),readonlyIndexes:Re(X())}),t1=pe({signatures:Re(_e()),message:pe({accountKeys:Re(_e()),header:pe({numRequiredSignatures:X(),numReadonlySignedAccounts:X(),numReadonlyUnsignedAccounts:X()}),instructions:Re(pe({accounts:Re(X()),data:_e(),programIdIndex:X()})),recentBlockhash:_e(),addressTableLookups:He(Re(Gx))})}),jx=pe({pubkey:nr,signer:Vi(),writable:Vi(),source:He(gn([rr("transaction"),rr("lookupTable")]))}),Kx=pe({accountKeys:Re(jx),signatures:Re(_e())}),Vx=pe({parsed:cu(),program:_e(),programId:nr}),Wx=pe({accounts:Re(nr),data:_e(),programId:nr}),zW=gn([Wx,Vx]),GW=gn([pe({parsed:cu(),program:_e(),programId:_e()}),pe({accounts:Re(_e()),data:_e(),programId:_e()})]),qx=Tf(zW,GW,r=>"accounts"in r?Ae(r,Wx):Ae(r,Vx)),Zx=pe({signatures:Re(_e()),message:pe({accountKeys:Re(jx),instructions:Re(qx),recentBlockhash:_e(),addressTableLookups:He(Ie(Re(Gx)))})}),C0=pe({accountIndex:X(),mint:_e(),owner:He(_e()),programId:He(_e()),uiTokenAmount:Jm}),Qx=pe({writable:Re(nr),readonly:Re(nr)}),B0=pe({err:Oa,fee:X(),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(pe({accounts:Re(X()),data:_e(),programIdIndex:X()}))})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:He(Ie(Re(_e()))),preTokenBalances:He(Ie(Re(C0))),postTokenBalances:He(Ie(Re(C0))),loadedAddresses:He(Qx),computeUnitsConsumed:He(X())}),r1=pe({err:Oa,fee:X(),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(qx)})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:He(Ie(Re(_e()))),preTokenBalances:He(Ie(Re(C0))),postTokenBalances:He(Ie(Re(C0))),loadedAddresses:He(Qx),computeUnitsConsumed:He(X())}),hu=gn([rr(0),rr("legacy")]),Na=pe({pubkey:_e(),lamports:X(),postBalance:Ie(X()),rewardType:Ie(_e()),commission:He(Ie(X()))}),jW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:t1,meta:Ie(B0),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),KW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),VW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Kx,meta:Ie(B0),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),WW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Zx,meta:Ie(r1),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),qW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Kx,meta:Ie(r1),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),ZW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),QW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:t1,meta:Ie(B0)})),rewards:He(Re(Na)),blockTime:Ie(X())}))),Yx=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),signatures:Re(_e()),blockTime:Ie(X())}))),n1=it(Ie(pe({slot:X(),meta:Ie(B0),blockTime:He(Ie(X())),transaction:t1,version:He(hu)}))),P0=it(Ie(pe({slot:X(),transaction:Zx,meta:Ie(r1),blockTime:He(Ie(X())),version:He(hu)}))),YW=Er(pe({blockhash:_e(),lastValidBlockHeight:X()})),JW=Er(Vi()),XW=pe({slot:X(),numTransactions:X(),numSlots:X(),samplePeriodSecs:X()}),eq=it(Re(XW)),tq=Er(Ie(pe({feeCalculator:pe({lamportsPerSignature:X()})}))),rq=it(_e()),nq=it(_e()),iq=pe({err:Oa,logs:Re(_e()),signature:_e()}),sq=pe({result:N0(iq),subscription:X()}),oq={"solana-client":"js/1.0.0-maintenance"};class Jx{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const l={};return async h=>{const{commitment:g,config:b}=zt(h),w=this._buildArgs([],g,void 0,b),I=Px(w);return l[I]=l[I]??(async()=>{try{const S=await this._rpcRequest("getBlockHeight",w),x=Ae(S,it(X()));if("error"in x)throw new $e(x.error,"failed to get block height information");return x.result}finally{delete l[I]}})(),await l[I]}})();let n,i,s,o,a,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,i=t.httpHeaders,s=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=KV(e),this._rpcWsEndpoint=n||jV(e),this._rpcClient=oW(e,i,s,o,a,u),this._rpcRequest=aW(this._rpcClient),this._rpcBatchRequest=cW(this._rpcClient),this._rpcWebSocket=new FV(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",s),a=Ae(o,Er(X()));if("error"in a)throw new $e(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),n=Ae(t,it(Ie(X())));if("error"in n)throw new $e(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=Ae(e,it(X()));if("error"in t)throw new $e(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=Ae(e,gW);if("error"in t)throw new $e(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[t]),i=Ae(n,yW);if("error"in i)throw new $e(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",n),s=Ae(i,Er(Jm));if("error"in s)throw new $e(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",n),s=Ae(i,Er(Jm));if("error"in s)throw new $e(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,n){const{commitment:i,config:s}=zt(n);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",a),l=Ae(u,wW);if("error"in l)throw new $e(l.error,`failed to get token accounts owned by account ${e.toBase58()}`);return l.result}async getParsedTokenAccountsByOwner(e,t,n){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});const s=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),a=Ae(o,bW);if("error"in a)throw new $e(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",n),s=Ae(i,_W);if("error"in s)throw new $e(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",n),s=Ae(i,mW);if("error"in s)throw new $e(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",s),a=Ae(o,Er(Ie(Lf)));if("error"in a)throw new $e(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),a=Ae(o,Er(Ie(e1)));if("error"in a)throw new $e(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){const{commitment:n,config:i}=zt(t),s=e.map(l=>l.toBase58()),o=this._buildArgs([s],n,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=Ae(a,Er(Re(Ie(e1))));if("error"in u)throw new $e(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:i}=zt(t),s=e.map(l=>l.toBase58()),o=this._buildArgs([s],n,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=Ae(a,Er(Re(Ie(Lf))));if("error"in u)throw new $e(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){const{commitment:i,config:s}=zt(t),o=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:n??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=Ae(a,it(xW));if("error"in u)throw new $e(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){const{commitment:n,config:i}=zt(t),{encoding:s,...o}=i||{},a=this._buildArgs([e.toBase58()],n,s||"base64",{...o,...o.filters?{filters:$x(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),l=Re(AW),h=o.withContext===!0?Ae(u,Er(l)):Ae(u,it(l));if("error"in h)throw new $e(h.error,`failed to get accounts owned by program ${e.toBase58()}`);return h.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),a=Ae(o,it(Re(EW)));if("error"in a)throw new $e(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var s;let n;if(typeof e=="string")n=e;else{const o=e;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let i;try{i=Or.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return vt(i.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,i,s=!1;const o=new Promise((u,l)=>{try{n=this.onSignature(t,(g,b)=>{n=void 0;const w={context:b,value:g};u({__type:ks.PROCESSED,response:w})},e);const h=new Promise(g=>{n==null?g():i=this._onSubscriptionStateChange(n,b=>{b==="subscribed"&&g()})});(async()=>{if(await h,s)return;const g=await this.getSignatureStatus(t);if(s||g==null)return;const{context:b,value:w}=g;if(w!=null)if(w!=null&&w.err)l(w.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(w.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(w.confirmationStatus==="processed"||w.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:ks.PROCESSED,response:{context:b,value:w}})}})()}catch(h){l(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:i}}){let s=!1;const o=new Promise(g=>{const b=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let w=await b();if(!s){for(;w<=n;)if(await ka(1e3),s||(w=await b(),s))return;g({__type:ks.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),l=this.getCancellationPromise(t);let h;try{const g=await Promise.race([l,u,o]);if(g.__type===ks.PROCESSED)h=g.response;else throw new Fm(i)}finally{s=!0,a()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let a=!1;const u=new Promise(w=>{let I=s,S=null;const x=async()=>{try{const{context:C,value:H}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:n});return S=C.slot,H==null?void 0:H.nonce}catch{return I}};(async()=>{if(I=await x(),!a)for(;;){if(s!==I){w({__type:ks.NONCE_INVALID,slotInWhichNonceDidAdvance:S});return}if(await ka(2e3),a||(I=await x(),a))return}})()}),{abortConfirmation:l,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),g=this.getCancellationPromise(t);let b;try{const w=await Promise.race([g,h,u]);if(w.__type===ks.PROCESSED)b=w.response;else{let I;for(;;){const S=await this.getSignatureStatus(o);if(S==null)break;if(S.context.slot<(w.slotInWhichNonceDidAdvance??n)){await ka(400);continue}I=S;break}if(I!=null&&I.value){const S=e||"finalized",{confirmationStatus:x}=I.value;switch(S){case"processed":case"recent":if(x!=="processed"&&x!=="confirmed"&&x!=="finalized")throw new uu(o);break;case"confirmed":case"single":case"singleGossip":if(x!=="confirmed"&&x!=="finalized")throw new uu(o);break;case"finalized":case"max":case"root":if(x!=="finalized")throw new uu(o);break;default:}b={context:I.context,value:{err:I.value.err}}}else throw new uu(o)}}finally{a=!0,l()}return b}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n;const i=new Promise(u=>{let l=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{l=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:ks.TIMED_OUT,timeoutMs:l}),l)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const u=await Promise.race([o,i]);if(u.__type===ks.PROCESSED)a=u.response;else throw new Hm(t,u.timeoutMs/1e3)}finally{clearTimeout(n),s()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=Ae(e,it(Re(LW)));if("error"in t)throw new $e(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),i=Ae(n,UW);if("error"in i)throw new $e(i.error,"failed to get vote accounts");return i.result}async getSlot(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlot",i),o=Ae(s,it(X()));if("error"in o)throw new $e(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlotLeader",i),o=Ae(s,it(_e()));if("error"in o)throw new $e(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const n=[e,t],i=await this._rpcRequest("getSlotLeaders",n),s=Ae(i,it(Re(nr)));if("error"in s)throw new $e(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(e,t){const{context:n,value:i}=await this.getSignatureStatuses([e],t);vt(i.length===1);const s=i[0];return{context:n,value:s}}async getSignatureStatuses(e,t){const n=[e];t&&n.push(t);const i=await this._rpcRequest("getSignatureStatuses",n),s=Ae(i,FW);if("error"in s)throw new $e(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getTransactionCount",i),o=Ae(s,it(X()));if("error"in o)throw new $e(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),i=Ae(n,uW);if("error"in i)throw new $e(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,n){const{commitment:i,config:s}=zt(n),o=this._buildArgs([e.map(l=>l.toBase58())],i,void 0,{...s,epoch:t??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=Ae(a,qV);if("error"in u)throw new $e(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=Ae(e,lW);if("error"in t)throw new $e(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getEpochInfo",i),o=Ae(s,hW);if("error"in o)throw new $e(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=Ae(e,dW);if("error"in t)throw new $e(t.error,"failed to get epoch schedule");const n=t.result;return new Mx(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=Ae(e,pW);if("error"in t)throw new $e(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const n=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=Ae(i,HW);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=Ae(t,eq);if("error"in n)throw new $e(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){const n=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=Ae(i,tq);if("error"in s)throw new $e(s.error,"failed to get fee calculator");const{context:o,value:a}=s.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const n=nt(e.serialize()).toString("base64"),i=this._buildArgs([n],t),s=await this._rpcRequest("getFeeForMessage",i),o=Ae(s,Er(Ie(X())));if("error"in o)throw new $e(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){var o;const t=(o=e==null?void 0:e.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),n=t!=null&&t.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),s=Ae(i,fW);if("error"in s)throw new $e(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getLatestBlockhash",i),o=Ae(s,YW);if("error"in o)throw new $e(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),a=Ae(o,JW);if("error"in a)throw new $e(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=Ae(e,it(rW));if("error"in t)throw new $e(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=Ae(e,it(_e()));if("error"in t)throw new $e(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=Ae(o,VW);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,KW);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,jW);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:l,meta:h,version:g})=>({meta:h,transaction:{...l,message:Ym(g,l.message)},version:g}))}:null}}}catch(a){throw new $e(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=Ae(o,qW);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,ZW);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,WW);if("error"in a)throw a.error;return a.result}}}catch(a){throw new $e(a,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){const{commitment:a,...u}=e;n=a,t=u}const i=this._buildArgs([],n,"base64",t),s=await this._rpcRequest("getBlockProduction",i),o=Ae(s,sW);if("error"in o)throw new $e(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getTransaction",s),a=Ae(o,n1);if("error"in a)throw new $e(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:Ym(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),a=Ae(o,P0);if("error"in a)throw new $e(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:n,config:i}=zt(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const l=Ae(u,P0);if("error"in l)throw new $e(l.error,"failed to get transactions");return l.result})}async getTransactions(e,t){const{commitment:n,config:i}=zt(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const l=Ae(u,n1);if("error"in l)throw new $e(l.error,"failed to get transactions");const h=l.result;return h&&{...h,transaction:{...h.transaction,message:Ym(h.version,h.transaction.message)}}})}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",n),s=Ae(i,QW);if("error"in s)throw new $e(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:l})=>{const h=new Ei(u.message);return{meta:l,transaction:{...u,message:h}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:l})=>({meta:l,transaction:Ot.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){const i=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),s=await this._rpcRequest("getBlocks",i),o=Ae(s,it(Re(X())));if("error"in o)throw new $e(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=Ae(i,Yx);if("error"in s)throw new $e(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=Ae(i,Yx);if("error"in s)throw new $e(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",n),s=Ae(i,n1);if("error"in s)throw new $e(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const a=new Ei(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Ot.populate(a,u)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),s=Ae(i,P0);if("error"in s)throw new $e(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){const n=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{const a=Ae(o,P0);if("error"in a)throw new $e(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,n){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(t--,!(t<=0||t<s));)try{const u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(n++,!(n>o));)try{const u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=Ae(s,RW);if("error"in o)throw new $e(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,n){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),o=Ae(s,IW);if("error"in o)throw new $e(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:n,value:i}=await this.getAccountInfoAndContext(e,t);let s=null;return i!==null&&(s=new Zm({key:e,state:Zm.deserialize(i.data)})),{context:n,value:s}}async getNonceAndContext(e,t){const{context:n,value:i}=await this.getAccountInfoAndContext(e,t);let s=null;return i!==null&&(s=O0.fromAccountData(i.data)),{context:n,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){const n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=Ae(n,rq);if("error"in i)throw new $e(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await ka(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Dx;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await ka(Ox/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=Ae(s,Er(X()));if("error"in o)throw new $e(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,n){if("message"in e){const S=e.serialize(),x=Ne.from(S).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");const C=t||{};C.encoding="base64","commitment"in C||(C.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(C.innerInstructions=t.innerInstructions);const H=[x,C],D=await this._rpcRequest("simulateTransaction",H),z=Ae(D,Hx);if("error"in z)throw new Error("failed to simulate transaction: "+z.error.message);return z.result}let i;if(e instanceof Ot){let I=e;i=new Ot,i.feePayer=I.feePayer,i.instructions=e.instructions,i.nonceInfo=I.nonceInfo,i.signatures=I.signatures}else i=Ot.populate(e),i._message=i._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(i.nonceInfo&&s)i.sign(...s);else{let I=this._disableBlockhashCaching;for(;;){const S=await this._blockhashWithExpiryBlockHeight(I);if(i.lastValidBlockHeight=S.lastValidBlockHeight,i.recentBlockhash=S.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const x=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(x)&&!this._blockhashInfo.transactionSignatures.includes(x)){this._blockhashInfo.simulatedSignatures.push(x);break}else I=!0}}const o=i._compile(),a=o.serialize(),l=i._serialize(a).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(n){const I=(Array.isArray(n)?n:o.nonProgramIds()).map(S=>S.toBase58());h.accounts={encoding:"base64",addresses:I}}s&&(h.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(h.innerInstructions=t.innerInstructions);const g=[l,h],b=await this._rpcRequest("simulateTransaction",g),w=Ae(b,Hx);if("error"in w){let I;if("data"in w.error&&(I=w.error.data.logs,I&&Array.isArray(I))){const S=`
25
+ `,x=S+I.join(S);console.error(w.error.message,x)}throw new _o({action:"simulate",signature:"",transactionMessage:w.error.message,logs:I})}return w.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(e.nonceInfo)e.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");const u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=e.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(e,t){const n=nt(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){const n={encoding:"base64"},i=t&&t.skipPreflight,s=i===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),i&&(n.skipPreflight=i),s&&(n.preflightCommitment=s);const o=[e,n],a=await this._rpcRequest("sendTransaction",o),u=Ae(a,nq);if("error"in u){let l;throw"data"in u.error&&(l=u.error.data.logs),new _o({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:l})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){var i;const n=(i=this._subscriptionsByHash[e])==null?void 0:i.state;if(this._subscriptionsByHash[e]=t,n!==t.state){const s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(o=>{try{o(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var s;const n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[n]||(s[n]=new Set);return i.add(t),()=>{i.delete(t),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,s);this._setSubscription(n,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:a}),!t())return;this._setSubscription(n,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(i=>{try{i(...t)}catch(s){console.error(s)}})}_wsOnAccountNotification(e){const{result:t,subscription:n}=Ae(e,SW);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,i=Px([e.method,t]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[i];vt(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){const{commitment:i,config:s}=zt(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:n}=Ae(e,TW);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,i){const{commitment:s,config:o}=zt(n),a=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:$x(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,n){const i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:n}=Ae(e,sq);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=Ae(e,NW);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:n}=Ae(e,BW);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,i){const s=t||this._commitment;if(s||n||i){let o={};n&&(o.encoding=n),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,i){const s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,i)}_wsOnSignatureNotification(e){const{result:t,subscription:n}=Ae(e,PW);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){const i=this._buildArgs([e],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(e,t,n){const{commitment:i,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],i,void 0,s),a=this._makeSubscription({callback:(u,l)=>{t(u,l);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:n}=Ae(e,MW);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class Ca{constructor(e){this._keypair=void 0,this._keypair=e??Ex()}static generate(){return new Ca(Ex())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const n=e.slice(32,64);if(!t||!t.skipValidation){const i=e.slice(0,32),s=R0(i);for(let o=0;o<32;o++)if(n[o]!==s[o])throw new Error("provided secretKey is invalid")}return new Ca({publicKey:n,secretKey:e})}static fromSeed(e){const t=R0(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new Ca({publicKey:t,secretKey:n})}get publicKey(){return new me(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Ts=Object.freeze({CreateLookupTable:{index:0,layout:Me([Pe("instruction"),fu("recentSlot"),bt("bumpSeed")])},FreezeLookupTable:{index:1,layout:Me([Pe("instruction")])},ExtendLookupTable:{index:2,layout:Me([Pe("instruction"),fu(),Wr(lt(),mo(Pe(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Me([Pe("instruction")])},CloseLookupTable:{index:4,layout:Me([Pe("instruction")])}});class aq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ts))if(o.index==n){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=kt(Ts.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=kt(Ts.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(n=>new me(n))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(i1.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class i1{constructor(){}static createLookupTable(e){const[t,n]=me.findProgramAddressSync([e.authority.toBuffer(),Y2(BigInt(e.recentSlot),8)],this.programId),i=Ts.CreateLookupTable,s=yt(i,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Br.programId,isSigner:!1,isWritable:!1}];return[new Pt({programId:this.programId,keys:o,data:s}),t]}static freezeLookupTable(e){const t=Ts.FreezeLookupTable,n=yt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Pt({programId:this.programId,keys:i,data:n})}static extendLookupTable(e){const t=Ts.ExtendLookupTable,n=yt(t,{addresses:e.addresses.map(s=>s.toBytes())}),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&i.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Br.programId,isSigner:!1,isWritable:!1}),new Pt({programId:this.programId,keys:i,data:n})}static deactivateLookupTable(e){const t=Ts.DeactivateLookupTable,n=yt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Pt({programId:this.programId,keys:i,data:n})}static closeLookupTable(e){const t=Ts.CloseLookupTable,n=yt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Pt({programId:this.programId,keys:i,data:n})}}i1.programId=new me("AddressLookupTab1e1111111111111111111111111");class cq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=bt("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Qi))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:n}=kt(Qi.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=kt(Qi.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=kt(Qi.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=kt(Qi.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(s1.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qi=Object.freeze({RequestUnits:{index:0,layout:Me([bt("instruction"),Pe("units"),Pe("additionalFee")])},RequestHeapFrame:{index:1,layout:Me([bt("instruction"),Pe("bytes")])},SetComputeUnitLimit:{index:2,layout:Me([bt("instruction"),Pe("units")])},SetComputeUnitPrice:{index:3,layout:Me([bt("instruction"),fu("microLamports")])}});class s1{constructor(){}static requestUnits(e){const t=Qi.RequestUnits,n=yt(t,e);return new Pt({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=Qi.RequestHeapFrame,n=yt(t,e);return new Pt({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=Qi.SetComputeUnitLimit,n=yt(t,e);return new Pt({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=Qi.SetComputeUnitPrice,n=yt(t,{microLamports:BigInt(e.microLamports)});return new Pt({keys:[],programId:this.programId,data:n})}}s1.programId=new me("ComputeBudget111111111111111111111111111111");const Xx=64,eR=32,tR=64,rR=Me([bt("numSignatures"),bt("padding"),ii("signatureOffset"),ii("signatureInstructionIndex"),ii("publicKeyOffset"),ii("publicKeyInstructionIndex"),ii("messageDataOffset"),ii("messageDataSize"),ii("messageInstructionIndex")]);class M0{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,instructionIndex:s}=e;vt(t.length===eR,`Public Key must be ${eR} bytes but received ${t.length} bytes`),vt(i.length===tR,`Signature must be ${tR} bytes but received ${i.length} bytes`);const o=rR.span,a=o+t.length,u=a+i.length,l=1,h=Ne.alloc(u+n.length),g=s??65535;return rR.encode({numSignatures:l,padding:0,signatureOffset:a,signatureInstructionIndex:g,publicKeyOffset:o,publicKeyInstructionIndex:g,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:g},h),h.fill(t,o),h.fill(i,a),h.fill(n,u),new Pt({keys:[],programId:M0.programId,data:h})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;vt(t.length===Xx,`Private key must be ${Xx} bytes but received ${t.length} bytes`);try{const s=Ca.fromSecretKey(t),o=s.publicKey.toBytes(),a=Dm(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:a,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}M0.programId=new me("Ed25519SigVerify111111111111111111111111111");const uq=(r,e)=>{const t=x0.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};x0.utils.isValidPrivateKey;const lq=x0.getPublicKey,nR=32,o1=20,iR=64,fq=11,a1=Me([bt("numSignatures"),ii("signatureOffset"),bt("signatureInstructionIndex"),ii("ethAddressOffset"),bt("ethAddressInstructionIndex"),ii("messageDataOffset"),ii("messageDataSize"),bt("messageInstructionIndex"),Wt(20,"ethAddress"),Wt(64,"signature"),bt("recoveryId")]);class du{constructor(){}static publicKeyToEthAddress(e){vt(e.length===iR,`Public key must be ${iR} bytes but received ${e.length} bytes`);try{return Ne.from(gx(nt(e))).slice(-o1)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,recoveryId:s,instructionIndex:o}=e;return du.createInstructionWithEthAddress({ethAddress:du.publicKeyToEthAddress(t),message:n,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:n,signature:i,recoveryId:s,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=Ne.from(t.substr(2),"hex"):a=Ne.from(t,"hex"):a=t,vt(a.length===o1,`Address must be ${o1} bytes but received ${a.length} bytes`);const u=1+fq,l=u,h=u+a.length,g=h+i.length+1,b=1,w=Ne.alloc(a1.span+n.length);return a1.encode({numSignatures:b,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:l,ethAddressInstructionIndex:o,messageDataOffset:g,messageDataSize:n.length,messageInstructionIndex:o,signature:nt(i),ethAddress:nt(a),recoveryId:s},w),w.fill(nt(n),a1.span),new Pt({keys:[],programId:du.programId,data:w})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;vt(t.length===nR,`Private key must be ${nR} bytes but received ${t.length} bytes`);try{const s=nt(t),o=lq(s,!1).slice(1),a=Ne.from(gx(nt(n))),[u,l]=uq(a,s);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:l,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}du.programId=new me("KeccakSecp256k11111111111111111111111111111");var sR;const oR=new me("StakeConfig11111111111111111111111111111111");class aR{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class Uf{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}}sR=Uf,Uf.default=new sR(0,0,me.default);class hq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ur))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:n}=kt(Ur.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new aR(new me(t.staker),new me(t.withdrawer)),lockup:new Uf(n.unixTimestamp,n.epoch,new me(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),kt(Ur.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:n}=kt(Ur.Authorize,e.data),i={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new me(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:i,authorityOwner:s}=kt(Ur.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:i,authorityOwner:new me(s),newAuthorizedPubkey:new me(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=kt(Ur.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(Ur.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=kt(Ur.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(Ur.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(L0.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Ur=Object.freeze({Initialize:{index:0,layout:Me([Pe("instruction"),bV(),_V()])},Authorize:{index:1,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("stakeAuthorizationType")])},Delegate:{index:2,layout:Me([Pe("instruction")])},Split:{index:3,layout:Me([Pe("instruction"),Hn("lamports")])},Withdraw:{index:4,layout:Me([Pe("instruction"),Hn("lamports")])},Deactivate:{index:5,layout:Me([Pe("instruction")])},Merge:{index:7,layout:Me([Pe("instruction")])},AuthorizeWithSeed:{index:8,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("stakeAuthorizationType"),Ia("authoritySeed"),lt("authorityOwner")])}}),dq=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class L0{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:i}=e,s=i||Uf.default,o=Ur.Initialize,a=yt(o,{authorized:{staker:nt(n.staker.toBuffer()),withdrawer:nt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:nt(s.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Pt(u)}static createAccountWithSeed(e){const t=new Ot;t.add(Br.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static createAccount(e){const t=new Ot;t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:n,votePubkey:i}=e,s=Ur.Delegate,o=yt(s);return new Ot().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:T0,isSigner:!1,isWritable:!1},{pubkey:oR,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=e,a=Ur.Authorize,u=yt(a,{newAuthorized:nt(i.toBuffer()),stakeAuthorizationType:s.index}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Ot().add({keys:l,programId:this.programId,data:u})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:n,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:u}=e,l=Ur.AuthorizeWithSeed,h=yt(l,{newAuthorized:nt(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:i,authorityOwner:nt(s.toBuffer())}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1}];return u&&g.push({pubkey:u,isSigner:!0,isWritable:!1}),new Ot().add({keys:g,programId:this.programId,data:h})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:i,lamports:s}=e,o=Ur.Split,a=yt(o,{lamports:s});return new Pt({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const n=new Ot;return n.add(Br.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:a,lamports:u}=e,l=new Ot;return l.add(Br.allocate({accountPubkey:s,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&l.add(Br.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),l.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:i}=e,s=Ur.Merge,o=yt(s);return new Ot().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:T0,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:n,toPubkey:i,lamports:s,custodianPubkey:o}=e,a=Ur.Withdraw,u=yt(a,{lamports:s}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:T0,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Ot().add({keys:l,programId:this.programId,data:u})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,i=Ur.Deactivate,s=yt(i);return new Ot().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}L0.programId=new me("Stake11111111111111111111111111111111111111"),L0.space=200;class cR{constructor(e,t,n,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=i}}class pq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Yi))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=kt(Yi.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new cR(new me(t.nodePubkey),new me(t.authorizedVoter),new me(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:n}=kt(Yi.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new me(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:i,voteAuthorizationType:s}}=kt(Yi.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new me(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new me(i),voteAuthorizationType:{index:s},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=kt(Yi.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(pu.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Yi=Object.freeze({InitializeAccount:{index:0,layout:Me([Pe("instruction"),AV()])},Authorize:{index:1,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("voteAuthorizationType")])},Withdraw:{index:3,layout:Me([Pe("instruction"),Hn("lamports")])},UpdateValidatorIdentity:{index:4,layout:Me([Pe("instruction")])},AuthorizeWithSeed:{index:10,layout:Me([Pe("instruction"),vV()])}}),gq=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class pu{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:i}=e,s=Yi.InitializeAccount,o=yt(s,{voteInit:{nodePubkey:nt(i.nodePubkey.toBuffer()),authorizedVoter:nt(i.authorizedVoter.toBuffer()),authorizedWithdrawer:nt(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Pt(a)}static createAccount(e){const t=new Ot;return t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,voteAuthorizationType:s}=e,o=Yi.Authorize,a=yt(o,{newAuthorized:nt(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:a}=e,u=Yi.AuthorizeWithSeed,l=yt(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:nt(n.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:nt(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Ot().add({keys:h,programId:this.programId,data:l})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:i,toPubkey:s}=e,o=Yi.Withdraw,a=yt(o,{lamports:i}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return pu.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:i}=e,s=Yi.UpdateValidatorIdentity,o=yt(s),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:a,programId:this.programId,data:o})}}pu.programId=new me("Vote111111111111111111111111111111111111111"),pu.space=3762;const uR=new me("Va1idator1nfo111111111111111111111111111111"),yq=pe({name:_e(),website:He(_e()),details:He(_e()),iconUrl:He(_e()),keybaseUsername:He(_e())});class c1{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(Tn(t)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new me(On(t,0,Wi)),a=qi(t)===1;i.push({publicKey:o,isSigner:a})}if(i[0].publicKey.equals(uR)&&i[1].isSigner){const s=Ia().decode(Ne.from(t)),o=JSON.parse(s);return X2(o,yq),new c1(i[1].publicKey,o)}return null}}const mq=new me("Vote111111111111111111111111111111111111111"),wq=Me([lt("nodePubkey"),lt("authorizedWithdrawer"),bt("commission"),Vr(),Wr(Me([Vr("slot"),Pe("confirmationCount")]),mo(Pe(),-8),"votes"),bt("rootSlotValid"),Vr("rootSlot"),Vr(),Wr(Me([Vr("epoch"),lt("authorizedVoter")]),mo(Pe(),-8),"authorizedVoters"),Me([Wr(Me([lt("authorizedPubkey"),Vr("epochOfLastAuthorizedSwitch"),Vr("targetEpoch")]),32,"buf"),Vr("idx"),bt("isEmpty")],"priorVoters"),Vr(),Wr(Me([Vr("epoch"),Vr("credits"),Vr("prevCredits")]),mo(Pe(),-8),"epochCredits"),Me([Vr("slot"),Vr("timestamp")],"lastTimestamp")]);class u1{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const n=wq.decode(nt(e),4);let i=n.rootSlot;return n.rootSlotValid||(i=null),new u1({nodePubkey:new me(n.nodePubkey),authorizedWithdrawer:new me(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:i,authorizedVoters:n.authorizedVoters.map(bq),priorVoters:_q(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function bq({authorizedVoter:r,epoch:e}){return{epoch:e,authorizedVoter:new me(r)}}function lR({authorizedPubkey:r,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new me(r),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function _q({buf:r,idx:e,isEmpty:t}){return t?[]:[...r.slice(e+1).map(lR),...r.slice(0,e).map(lR)]}const fR={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function Aq(r,e){const t=e===!1?"http":"https";if(!r)return fR[t].devnet;const n=fR[t][r];if(!n)throw new Error(`Unknown ${t} cluster: ${r}`);return n}async function vq(r,e,t,n){let i,s;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(i=t,s=n):s=t;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},a=await r.sendRawTransaction(e,o),u=s&&s.commitment,h=(await(i?r.confirmTransaction(i,u):r.confirmTransaction(a,u))).value;if(h.err)throw a!=null?new _o({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(h)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(h)})`);return a}const Eq=Object.freeze(Object.defineProperty({__proto__:null,Account:yV,AddressLookupTableAccount:Zm,AddressLookupTableInstruction:aq,AddressLookupTableProgram:i1,Authorized:aR,BLOCKHASH_CACHE_TIMEOUT_MS:Dx,BPF_LOADER_DEPRECATED_PROGRAM_ID:mV,BPF_LOADER_PROGRAM_ID:BV,BpfLoader:PV,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qi,ComputeBudgetInstruction:cq,ComputeBudgetProgram:s1,Connection:Jx,Ed25519Program:M0,Enum:pV,EpochSchedule:Mx,FeeCalculatorLayout:Nx,Keypair:Ca,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ts,Loader:Ta,Lockup:Uf,MAX_SEED_LENGTH:Ix,Message:Ei,MessageAccountKeys:Pf,MessageV0:Sa,NONCE_ACCOUNT_LENGTH:Vm,NonceAccount:O0,PACKET_DATA_SIZE:bo,PUBLIC_KEY_LENGTH:Wi,PublicKey:me,SIGNATURE_LENGTH_IN_BYTES:Bf,SOLANA_SCHEMA:Cf,STAKE_CONFIG_ID:oR,STAKE_INSTRUCTION_LAYOUTS:Ur,SYSTEM_INSTRUCTION_LAYOUTS:Ht,SYSVAR_CLOCK_PUBKEY:Zi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:xV,SYSVAR_INSTRUCTIONS_PUBKEY:RV,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:k0,SYSVAR_RENT_PUBKEY:lu,SYSVAR_REWARDS_PUBKEY:IV,SYSVAR_SLOT_HASHES_PUBKEY:SV,SYSVAR_SLOT_HISTORY_PUBKEY:kV,SYSVAR_STAKE_HISTORY_PUBKEY:T0,Secp256k1Program:du,SendTransactionError:_o,SolanaJSONRPCError:$e,SolanaJSONRPCErrorCode:TV,StakeAuthorizationLayout:dq,StakeInstruction:hq,StakeProgram:L0,Struct:$m,SystemInstruction:NV,SystemProgram:Br,Transaction:Ot,TransactionExpiredBlockheightExceededError:Fm,TransactionExpiredNonceInvalidError:uu,TransactionExpiredTimeoutError:Hm,TransactionInstruction:Pt,TransactionMessage:Gm,TransactionStatus:ks,VALIDATOR_INFO_KEY:uR,VERSION_PREFIX_MASK:I0,VOTE_PROGRAM_ID:mq,ValidatorInfo:c1,VersionedMessage:zm,VersionedTransaction:jm,VoteAccount:u1,VoteAuthorizationLayout:gq,VoteInit:cR,VoteInstruction:pq,VoteProgram:pu,clusterApiUrl:Aq,sendAndConfirmRawTransaction:vq,sendAndConfirmTransaction:Km},Symbol.toStringTag,{value:"Module"}));var l1={exports:{}};const xq=/[\p{Lu}]/u,Rq=/[\p{Ll}]/u,hR=/^[\p{Lu}](?![\p{Lu}])/gu,dR=/([\p{Alpha}\p{N}_]|$)/u,pR=/[_.\- ]+/,Iq=new RegExp("^"+pR.source),gR=new RegExp(pR.source+dR.source,"gu"),yR=new RegExp("\\d+"+dR.source,"gu"),Sq=(r,e,t)=>{let n=!1,i=!1,s=!1;for(let o=0;o<r.length;o++){const a=r[o];n&&xq.test(a)?(r=r.slice(0,o)+"-"+r.slice(o),n=!1,s=i,i=!0,o++):i&&s&&Rq.test(a)?(r=r.slice(0,o-1)+"-"+r.slice(o-1),s=i,i=!1,n=!0):(n=e(a)===a&&t(a)!==a,s=i,i=t(a)===a&&e(a)!==a)}return r},kq=(r,e)=>(hR.lastIndex=0,r.replace(hR,t=>e(t))),Tq=(r,e)=>(gR.lastIndex=0,yR.lastIndex=0,r.replace(gR,(t,n)=>e(n)).replace(yR,t=>e(t))),mR=(r,e)=>{if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(r)?r=r.map(s=>s.trim()).filter(s=>s.length).join("-"):r=r.trim(),r.length===0)return"";const t=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),n=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return r.length===1?e.pascalCase?n(r):t(r):(r!==t(r)&&(r=Sq(r,t,n)),r=r.replace(Iq,""),e.preserveConsecutiveUppercase?r=kq(r,t):r=t(r),e.pascalCase&&(r=n(r.charAt(0))+r.slice(1)),Tq(r,n))};l1.exports=mR,l1.exports.default=mR;var Oq=l1.exports;const Nq=xn(Oq);var Xe={},ke={};let Nt=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,n){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};ke.Layout=Nt;function f1(r,e){return e.property?r+"["+e.property+"]":r}ke.nameWithProperty=f1;function Cq(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(r.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Nt))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value:function(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value:function(t,n){return e.decode(t,n)},writable:!0})}ke.bindConstructorLayout=Cq;let Nn=class extends Nt{isCount(){throw new Error("ExternalLayout is abstract")}};class wR extends Nn{constructor(e,t){if(e===void 0&&(e=1),!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t){t===void 0&&(t=0);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}}let h1=class extends Nn{constructor(e,t,n){if(!(e instanceof Nt))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof Ji||this.layout instanceof Os}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,n){return n===void 0&&(n=0),this.layout.encode(e,t,n+this.offset)}},Ji=class extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntLE(e,n,this.span),this.span}},Os=class extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntBE(e,n,this.span),this.span}};class Ba extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeIntLE(e,n,this.span),this.span}}class gu extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeIntBE(e,n,this.span),this.span}}const d1=Math.pow(2,32);function U0(r){const e=Math.floor(r/d1),t=r-e*d1;return{hi32:e,lo32:t}}function D0(r,e){return r*d1+e}let Bq=class extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readUInt32LE(t+4);return D0(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}};class Pq extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32BE(t),i=e.readUInt32BE(t+4);return D0(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeUInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}let Mq=class extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readInt32LE(t+4);return D0(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}};class Lq extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readInt32BE(t),i=e.readUInt32BE(t+4);return D0(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}class bR extends Nt{constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatLE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeFloatLE(e,n),4}}class _R extends Nt{constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatBE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeFloatBE(e,n),4}}class AR extends Nt{constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleLE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeDoubleLE(e,n),8}}class vR extends Nt{constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleBE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeDoubleBE(e,n),8}}class ER extends Nt{constructor(e,t,n){if(!(e instanceof Nt))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Nn&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof Nn)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0,i=this.count;if(i instanceof Nn&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t){t===void 0&&(t=0);const n=[];let i=0,s=this.count;for(s instanceof Nn&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n){n===void 0&&(n=0);const i=this.elementLayout,s=e.reduce((o,a)=>o+i.encode(a,t,n+o),0);return this.count instanceof Nn&&this.count.encode(e.length,t,n),s}}let xR=class extends Nt{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Nt,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t){t===void 0&&(t=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n){n===void 0&&(n=0);const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}},p1=class{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},$0=class extends p1{constructor(e,t){if(!(e instanceof Nn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}},g1=class extends Nt{constructor(e,t,n){const i=e instanceof Ji||e instanceof Os;if(i)e=new $0(new h1(e));else if(e instanceof Nn&&e.isCount())e=new $0(e);else if(!(e instanceof p1))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Nt))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&i&&(s+=e.layout.span)),super(s,n),this.discriminator=e,this.usesPrefixDiscriminator=i,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(e.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let n;const i=this.discriminator,s=i.decode(e,t);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[o.property]=this.defaultLayout.decode(e,t+a)}else n=o.decode(e,t);return n}encode(e,t,n){n===void 0&&(n=0);const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new RR(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t){let n=e;return Ze.isBuffer(e)&&(t===void 0&&(t=0),n=this.discriminator.decode(e,t)),this.registry[n]}},RR=class extends Nt{constructor(e,t,n,i){if(!(e instanceof g1))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Nt))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(e,t+n)}decode(e,t){const n=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};function yu(r){return 0>r&&(r+=4294967296),r}class y1 extends Nt{constructor(e,t,n){if(!(e instanceof Ji||e instanceof Os))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=void 0),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=yu(s),this},this._packedGetValue=function(){return i}}decode(e,t){const n=this.makeDestinationObject();t===void 0&&(t=0);const i=this.word.decode(e,t);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(i));return n}encode(e,t,n){n===void 0&&(n=0);const i=this.word.decode(t,n);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new Df(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new IR(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}}class Df{constructor(e,t,n){if(!(e instanceof y1))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((o,a)=>o+a.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=yu(this.valueMask<<this.start),this.property=n}decode(){const e=this.container._packedGetValue();return yu(e&this.wordMask)>>>this.start}encode(e){if(!Number.isInteger(e)||e!==yu(e&this.valueMask))throw new TypeError(f1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=yu(e<<this.start);this.container._packedSetValue(yu(t&~this.wordMask)|n)}}let IR=class extends Df{constructor(e,t){super(e,1,t)}decode(e,t){return!!Df.prototype.decode.call(this,e,t)}encode(e){return typeof e=="boolean"&&(e=+e),Df.prototype.encode.call(this,e)}},SR=class extends Nt{constructor(e,t){if(!(e instanceof Nn&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof Nn||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t){t===void 0&&(t=0);let n=this.span;return 0>n&&(n=this.length.decode(e,t)),e.slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof Nn&&(i=e.length),!(Ze.isBuffer(e)&&i===e.length))throw new TypeError(f1("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),n,i,"hex"),this.length instanceof Nn&&this.length.encode(i,t,n),i}};class kR extends Nt{constructor(e){super(-1,e)}getSpan(e,t){if(!Ze.isBuffer(e))throw new TypeError("b must be a Buffer");t===void 0&&(t=0);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t,n){t===void 0&&(t=0);let i=this.getSpan(e,t);return e.slice(t,t+i-1).toString("utf-8")}encode(e,t,n){n===void 0&&(n=0),typeof e!="string"&&(e=e.toString());const i=new Ze(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(t,n),t[n+s]=0,s+1}}class TR extends Nt{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t){if(!Ze.isBuffer(e))throw new TypeError("b must be a Buffer");return t===void 0&&(t=0),e.length-t}decode(e,t,n){t===void 0&&(t=0);let i=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return e.slice(t,t+i).toString("utf-8")}encode(e,t,n){n===void 0&&(n=0),typeof e!="string"&&(e=e.toString());const i=new Ze(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(t,n),s}}class OR extends Nt{constructor(e,t){super(0,t),this.value=e}decode(e,t,n){return this.value}encode(e,t,n){return 0}}ke.ExternalLayout=Nn,ke.GreedyCount=wR,ke.OffsetLayout=h1,ke.UInt=Ji,ke.UIntBE=Os,ke.Int=Ba,ke.IntBE=gu,ke.Float=bR,ke.FloatBE=_R,ke.Double=AR,ke.DoubleBE=vR,ke.Sequence=ER,ke.Structure=xR,ke.UnionDiscriminator=p1,ke.UnionLayoutDiscriminator=$0,ke.Union=g1,ke.VariantLayout=RR,ke.BitStructure=y1,ke.BitField=Df,ke.Boolean=IR,ke.Blob=SR,ke.CString=kR,ke.UTF8=TR,ke.Constant=OR,ke.greedy=(r,e)=>new wR(r,e),ke.offset=(r,e,t)=>new h1(r,e,t),ke.u8=r=>new Ji(1,r),ke.u16=r=>new Ji(2,r),ke.u24=r=>new Ji(3,r),ke.u32=r=>new Ji(4,r),ke.u40=r=>new Ji(5,r),ke.u48=r=>new Ji(6,r),ke.nu64=r=>new Bq(r),ke.u16be=r=>new Os(2,r),ke.u24be=r=>new Os(3,r),ke.u32be=r=>new Os(4,r),ke.u40be=r=>new Os(5,r),ke.u48be=r=>new Os(6,r),ke.nu64be=r=>new Pq(r),ke.s8=r=>new Ba(1,r),ke.s16=r=>new Ba(2,r),ke.s24=r=>new Ba(3,r),ke.s32=r=>new Ba(4,r),ke.s40=r=>new Ba(5,r),ke.s48=r=>new Ba(6,r),ke.ns64=r=>new Mq(r),ke.s16be=r=>new gu(2,r),ke.s24be=r=>new gu(3,r),ke.s32be=r=>new gu(4,r),ke.s40be=r=>new gu(5,r),ke.s48be=r=>new gu(6,r),ke.ns64be=r=>new Lq(r),ke.f32=r=>new bR(r),ke.f32be=r=>new _R(r),ke.f64=r=>new AR(r),ke.f64be=r=>new vR(r),ke.struct=(r,e,t)=>new xR(r,e,t),ke.bits=(r,e,t)=>new y1(r,e,t),ke.seq=(r,e,t)=>new ER(r,e,t),ke.union=(r,e,t)=>new g1(r,e,t),ke.unionLayoutDiscriminator=(r,e)=>new $0(r,e),ke.blob=(r,e)=>new SR(r,e),ke.cstr=r=>new kR(r),ke.utf8=(r,e)=>new TR(r,e),ke.const=(r,e)=>new OR(r,e);const Uq=Mc(Eq);(function(r){var e=ut&&ut.__importDefault||function(ue){return ue&&ue.__esModule?ue:{default:ue}};Object.defineProperty(r,"__esModule",{value:!0}),r.struct=r.f64=r.f32=r.i32=r.u32=r.i16=r.u16=r.i8=r.u8=void 0,r.u64=a,r.i64=u,r.u128=l,r.i128=h,r.u256=g,r.i256=b,r.publicKey=I,r.option=x,r.bool=C,r.vec=z,r.tagged=W,r.vecU8=Z,r.str=j,r.rustEnum=V,r.array=oe,r.map=ie;const t=ke,n=Uq,i=e(Yy);var s=ke;Object.defineProperty(r,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(r,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(r,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(r,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(r,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(r,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(r,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(r,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(r,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends t.Layout{constructor(B,p,m){super(B,m),this.blob=(0,t.blob)(B),this.signed=p}decode(B,p=0){const m=new i.default(this.blob.decode(B,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(B,p,m=0){return this.signed&&(B=B.toTwos(this.span*8)),this.blob.encode(B.toArrayLike(Ze,"le",this.span),p,m)}}function a(ue){return new o(8,!1,ue)}function u(ue){return new o(8,!0,ue)}function l(ue){return new o(16,!1,ue)}function h(ue){return new o(16,!0,ue)}function g(ue){return new o(32,!1,ue)}function b(ue){return new o(32,!0,ue)}class w extends t.Layout{constructor(B,p,m,E){super(B.span,E),this.layout=B,this.decoder=p,this.encoder=m}decode(B,p){return this.decoder(this.layout.decode(B,p))}encode(B,p,m){return this.layout.encode(this.encoder(B),p,m)}getSpan(B,p){return this.layout.getSpan(B,p)}}function I(ue){return new w((0,t.blob)(32),B=>new n.PublicKey(B),B=>B.toBuffer(),ue)}class S extends t.Layout{constructor(B,p){super(-1,p),this.layout=B,this.discriminator=(0,t.u8)()}encode(B,p,m=0){return B==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(B,p,m+1)+1)}decode(B,p=0){const m=this.discriminator.decode(B,p);if(m===0)return null;if(m===1)return this.layout.decode(B,p+1);throw new Error("Invalid option "+this.property)}getSpan(B,p=0){const m=this.discriminator.decode(B,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(B,p+1)+1;throw new Error("Invalid option "+this.property)}}function x(ue,B){return new S(ue,B)}function C(ue){return new w((0,t.u8)(),H,D,ue)}function H(ue){if(ue===0)return!1;if(ue===1)return!0;throw new Error("Invalid bool: "+ue)}function D(ue){return ue?1:0}function z(ue,B){const p=(0,t.u32)("length"),m=(0,t.struct)([p,(0,t.seq)(ue,(0,t.offset)(p,-p.span),"values")]);return new w(m,({values:E})=>E,E=>({values:E}),B)}function W(ue,B,p){const m=(0,t.struct)([a("tag"),B.replicate("data")]);function E({tag:k,data:O}){if(!k.eq(ue))throw new Error("Invalid tag, expected: "+ue.toString("hex")+", got: "+k.toString("hex"));return O}return new w(m,E,k=>({tag:ue,data:k}),p)}function Z(ue){const B=(0,t.u32)("length"),p=(0,t.struct)([B,(0,t.blob)((0,t.offset)(B,-B.span),"data")]);return new w(p,({data:m})=>m,m=>({data:m}),ue)}function j(ue){return new w(Z(),B=>B.toString("utf-8"),B=>Ze.from(B,"utf-8"),ue)}function V(ue,B,p){const m=(0,t.union)(p??(0,t.u8)(),B);return ue.forEach((E,k)=>m.addVariant(k,E,E.property)),m}function oe(ue,B,p){const m=(0,t.struct)([(0,t.seq)(ue,B,"values")]);return new w(m,({values:E})=>E,E=>({values:E}),p)}class ce extends t.Layout{constructor(B,p,m){super(B.span+p.span,m),this.keyLayout=B,this.valueLayout=p}decode(B,p){p=p||0;const m=this.keyLayout.decode(B,p),E=this.valueLayout.decode(B,p+this.keyLayout.getSpan(B,p));return[m,E]}encode(B,p,m){m=m||0;const E=this.keyLayout.encode(B[0],p,m),k=this.valueLayout.encode(B[1],p,m+E);return E+k}getSpan(B,p){return this.keyLayout.getSpan(B,p)+this.valueLayout.getSpan(B,p)}}function ie(ue,B,p){const m=(0,t.u32)("length"),E=(0,t.struct)([m,(0,t.seq)(new ce(ue,B),(0,t.offset)(m,-m.span),"values")]);return new w(E,({values:k})=>new Map(k),k=>({values:Array.from(k.entries())}),p)}})(Xe);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const Dq=4,NR=0,CR=1,$q=2;function mu(r){let e=r.length;for(;--e>=0;)r[e]=0}const Fq=0,BR=1,Hq=2,zq=3,Gq=258,m1=29,$f=256,Ff=$f+1+m1,wu=30,w1=19,PR=2*Ff+1,Pa=15,b1=16,jq=7,_1=256,MR=16,LR=17,UR=18,A1=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),F0=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Kq=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),DR=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vq=512,Ns=new Array((Ff+2)*2);mu(Ns);const Hf=new Array(wu*2);mu(Hf);const zf=new Array(Vq);mu(zf);const Gf=new Array(Gq-zq+1);mu(Gf);const v1=new Array(m1);mu(v1);const H0=new Array(wu);mu(H0);function E1(r,e,t,n,i){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=n,this.max_length=i,this.has_stree=r&&r.length}let $R,FR,HR;function x1(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}const zR=r=>r<256?zf[r]:zf[256+(r>>>7)],jf=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},Cn=(r,e,t)=>{r.bi_valid>b1-t?(r.bi_buf|=e<<r.bi_valid&65535,jf(r,r.bi_buf),r.bi_buf=e>>b1-r.bi_valid,r.bi_valid+=t-b1):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},Xi=(r,e,t)=>{Cn(r,t[e*2],t[e*2+1])},GR=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},Wq=r=>{r.bi_valid===16?(jf(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},qq=(r,e)=>{const t=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,u=e.stat_desc.max_length;let l,h,g,b,w,I,S=0;for(b=0;b<=Pa;b++)r.bl_count[b]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<PR;l++)h=r.heap[l],b=t[t[h*2+1]*2+1]+1,b>u&&(b=u,S++),t[h*2+1]=b,!(h>n)&&(r.bl_count[b]++,w=0,h>=a&&(w=o[h-a]),I=t[h*2],r.opt_len+=I*(b+w),s&&(r.static_len+=I*(i[h*2+1]+w)));if(S!==0){do{for(b=u-1;r.bl_count[b]===0;)b--;r.bl_count[b]--,r.bl_count[b+1]+=2,r.bl_count[u]--,S-=2}while(S>0);for(b=u;b!==0;b--)for(h=r.bl_count[b];h!==0;)g=r.heap[--l],!(g>n)&&(t[g*2+1]!==b&&(r.opt_len+=(b-t[g*2+1])*t[g*2],t[g*2+1]=b),h--)}},jR=(r,e,t)=>{const n=new Array(Pa+1);let i=0,s,o;for(s=1;s<=Pa;s++)i=i+t[s-1]<<1,n[s]=i;for(o=0;o<=e;o++){let a=r[o*2+1];a!==0&&(r[o*2]=GR(n[a]++,a))}},Zq=()=>{let r,e,t,n,i;const s=new Array(Pa+1);for(t=0,n=0;n<m1-1;n++)for(v1[n]=t,r=0;r<1<<A1[n];r++)Gf[t++]=n;for(Gf[t-1]=n,i=0,n=0;n<16;n++)for(H0[n]=i,r=0;r<1<<F0[n];r++)zf[i++]=n;for(i>>=7;n<wu;n++)for(H0[n]=i<<7,r=0;r<1<<F0[n]-7;r++)zf[256+i++]=n;for(e=0;e<=Pa;e++)s[e]=0;for(r=0;r<=143;)Ns[r*2+1]=8,r++,s[8]++;for(;r<=255;)Ns[r*2+1]=9,r++,s[9]++;for(;r<=279;)Ns[r*2+1]=7,r++,s[7]++;for(;r<=287;)Ns[r*2+1]=8,r++,s[8]++;for(jR(Ns,Ff+1,s),r=0;r<wu;r++)Hf[r*2+1]=5,Hf[r*2]=GR(r,5);$R=new E1(Ns,A1,$f+1,Ff,Pa),FR=new E1(Hf,F0,0,wu,Pa),HR=new E1(new Array(0),Kq,0,w1,jq)},KR=r=>{let e;for(e=0;e<Ff;e++)r.dyn_ltree[e*2]=0;for(e=0;e<wu;e++)r.dyn_dtree[e*2]=0;for(e=0;e<w1;e++)r.bl_tree[e*2]=0;r.dyn_ltree[_1*2]=1,r.opt_len=r.static_len=0,r.sym_next=r.matches=0},VR=r=>{r.bi_valid>8?jf(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},WR=(r,e,t,n)=>{const i=e*2,s=t*2;return r[i]<r[s]||r[i]===r[s]&&n[e]<=n[t]},R1=(r,e,t)=>{const n=r.heap[t];let i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&WR(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!WR(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},qR=(r,e,t)=>{let n,i,s=0,o,a;if(r.sym_next!==0)do n=r.pending_buf[r.sym_buf+s++]&255,n+=(r.pending_buf[r.sym_buf+s++]&255)<<8,i=r.pending_buf[r.sym_buf+s++],n===0?Xi(r,i,e):(o=Gf[i],Xi(r,o+$f+1,e),a=A1[o],a!==0&&(i-=v1[o],Cn(r,i,a)),n--,o=zR(n),Xi(r,o,t),a=F0[o],a!==0&&(n-=H0[o],Cn(r,n,a)));while(s<r.sym_next);Xi(r,_1,e)},I1=(r,e)=>{const t=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,u=-1,l;for(r.heap_len=0,r.heap_max=PR,o=0;o<s;o++)t[o*2]!==0?(r.heap[++r.heap_len]=u=o,r.depth[o]=0):t[o*2+1]=0;for(;r.heap_len<2;)l=r.heap[++r.heap_len]=u<2?++u:0,t[l*2]=1,r.depth[l]=0,r.opt_len--,i&&(r.static_len-=n[l*2+1]);for(e.max_code=u,o=r.heap_len>>1;o>=1;o--)R1(r,t,o);l=s;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],R1(r,t,1),a=r.heap[1],r.heap[--r.heap_max]=o,r.heap[--r.heap_max]=a,t[l*2]=t[o*2]+t[a*2],r.depth[l]=(r.depth[o]>=r.depth[a]?r.depth[o]:r.depth[a])+1,t[o*2+1]=t[a*2+1]=l,r.heap[1]=l++,R1(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],qq(r,e),jR(t,u,r.bl_count)},ZR=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,u=7,l=4;for(o===0&&(u=138,l=3),e[(t+1)*2+1]=65535,n=0;n<=t;n++)s=o,o=e[(n+1)*2+1],!(++a<u&&s===o)&&(a<l?r.bl_tree[s*2]+=a:s!==0?(s!==i&&r.bl_tree[s*2]++,r.bl_tree[MR*2]++):a<=10?r.bl_tree[LR*2]++:r.bl_tree[UR*2]++,a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4))},QR=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,u=7,l=4;for(o===0&&(u=138,l=3),n=0;n<=t;n++)if(s=o,o=e[(n+1)*2+1],!(++a<u&&s===o)){if(a<l)do Xi(r,s,r.bl_tree);while(--a!==0);else s!==0?(s!==i&&(Xi(r,s,r.bl_tree),a--),Xi(r,MR,r.bl_tree),Cn(r,a-3,2)):a<=10?(Xi(r,LR,r.bl_tree),Cn(r,a-3,3)):(Xi(r,UR,r.bl_tree),Cn(r,a-11,7));a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4)}},Qq=r=>{let e;for(ZR(r,r.dyn_ltree,r.l_desc.max_code),ZR(r,r.dyn_dtree,r.d_desc.max_code),I1(r,r.bl_desc),e=w1-1;e>=3&&r.bl_tree[DR[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},Yq=(r,e,t,n)=>{let i;for(Cn(r,e-257,5),Cn(r,t-1,5),Cn(r,n-4,4),i=0;i<n;i++)Cn(r,r.bl_tree[DR[i]*2+1],3);QR(r,r.dyn_ltree,e-1),QR(r,r.dyn_dtree,t-1)},Jq=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return NR;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return CR;for(t=32;t<$f;t++)if(r.dyn_ltree[t*2]!==0)return CR;return NR};let YR=!1;const Xq=r=>{YR||(Zq(),YR=!0),r.l_desc=new x1(r.dyn_ltree,$R),r.d_desc=new x1(r.dyn_dtree,FR),r.bl_desc=new x1(r.bl_tree,HR),r.bi_buf=0,r.bi_valid=0,KR(r)},JR=(r,e,t,n)=>{Cn(r,(Fq<<1)+(n?1:0),3),VR(r),jf(r,t),jf(r,~t),t&&r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},eZ=r=>{Cn(r,BR<<1,3),Xi(r,_1,Ns),Wq(r)},tZ=(r,e,t,n)=>{let i,s,o=0;r.level>0?(r.strm.data_type===$q&&(r.strm.data_type=Jq(r)),I1(r,r.l_desc),I1(r,r.d_desc),o=Qq(r),i=r.opt_len+3+7>>>3,s=r.static_len+3+7>>>3,s<=i&&(i=s)):i=s=t+5,t+4<=i&&e!==-1?JR(r,e,t,n):r.strategy===Dq||s===i?(Cn(r,(BR<<1)+(n?1:0),3),qR(r,Ns,Hf)):(Cn(r,(Hq<<1)+(n?1:0),3),Yq(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),qR(r,r.dyn_ltree,r.dyn_dtree)),KR(r),n&&VR(r)},rZ=(r,e,t)=>(r.pending_buf[r.sym_buf+r.sym_next++]=e,r.pending_buf[r.sym_buf+r.sym_next++]=e>>8,r.pending_buf[r.sym_buf+r.sym_next++]=t,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(Gf[t]+$f+1)*2]++,r.dyn_dtree[zR(e)*2]++),r.sym_next===r.sym_end);var nZ=Xq,iZ=JR,sZ=tZ,oZ=rZ,aZ=eZ,cZ={_tr_init:nZ,_tr_stored_block:iZ,_tr_flush_block:sZ,_tr_tally:oZ,_tr_align:aZ},Kf=(r,e,t,n)=>{let i=r&65535|0,s=r>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do i=i+e[n++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};const uZ=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},lZ=new Uint32Array(uZ());var Dr=(r,e,t,n)=>{const i=lZ,s=n+t;r^=-1;for(let o=n;o<s;o++)r=r>>>8^i[(r^e[o])&255];return r^-1},bu={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Vf={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:fZ,_tr_stored_block:S1,_tr_flush_block:hZ,_tr_tally:Ao,_tr_align:dZ}=cZ,{Z_NO_FLUSH:vo,Z_PARTIAL_FLUSH:pZ,Z_FULL_FLUSH:gZ,Z_FINISH:si,Z_BLOCK:XR,Z_OK:Zr,Z_STREAM_END:eI,Z_STREAM_ERROR:es,Z_DATA_ERROR:yZ,Z_BUF_ERROR:k1,Z_DEFAULT_COMPRESSION:mZ,Z_FILTERED:wZ,Z_HUFFMAN_ONLY:z0,Z_RLE:bZ,Z_FIXED:_Z,Z_DEFAULT_STRATEGY:AZ,Z_UNKNOWN:vZ,Z_DEFLATED:G0}=Vf,EZ=9,xZ=15,RZ=8,T1=256+1+29,IZ=30,SZ=19,kZ=2*T1+1,TZ=15,ht=3,Eo=258,ts=Eo+ht+1,OZ=32,_u=42,O1=57,N1=69,C1=73,B1=91,P1=103,Ma=113,Wf=666,yn=1,Au=2,La=3,vu=4,NZ=3,Ua=(r,e)=>(r.msg=bu[e],e),tI=r=>r*2-(r>4?9:0),xo=r=>{let e=r.length;for(;--e>=0;)r[e]=0},CZ=r=>{let e,t,n,i=r.w_size;e=r.hash_size,n=e;do t=r.head[--n],r.head[n]=t>=i?t-i:0;while(--e);e=i,n=e;do t=r.prev[--n],r.prev[n]=t>=i?t-i:0;while(--e)};let Ro=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask;const Gn=r=>{const e=r.state;let t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(r.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},jn=(r,e)=>{hZ(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,Gn(r.strm)},Rt=(r,e)=>{r.pending_buf[r.pending++]=e},qf=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},M1=(r,e,t,n)=>{let i=r.avail_in;return i>n&&(i=n),i===0?0:(r.avail_in-=i,e.set(r.input.subarray(r.next_in,r.next_in+i),t),r.state.wrap===1?r.adler=Kf(r.adler,e,i,t):r.state.wrap===2&&(r.adler=Dr(r.adler,e,i,t)),r.next_in+=i,r.total_in+=i,i)},rI=(r,e)=>{let t=r.max_chain_length,n=r.strstart,i,s,o=r.prev_length,a=r.nice_match;const u=r.strstart>r.w_size-ts?r.strstart-(r.w_size-ts):0,l=r.window,h=r.w_mask,g=r.prev,b=r.strstart+Eo;let w=l[n+o-1],I=l[n+o];r.prev_length>=r.good_match&&(t>>=2),a>r.lookahead&&(a=r.lookahead);do if(i=e,!(l[i+o]!==I||l[i+o-1]!==w||l[i]!==l[n]||l[++i]!==l[n+1])){n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<b);if(s=Eo-(b-n),n=b-Eo,s>o){if(r.match_start=e,o=s,s>=a)break;w=l[n+o-1],I=l[n+o]}}while((e=g[e&h])>u&&--t!==0);return o<=r.lookahead?o:r.lookahead},Eu=r=>{const e=r.w_size;let t,n,i;do{if(n=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-ts)&&(r.window.set(r.window.subarray(e,e+e-n),0),r.match_start-=e,r.strstart-=e,r.block_start-=e,r.insert>r.strstart&&(r.insert=r.strstart),CZ(r),n+=e),r.strm.avail_in===0)break;if(t=M1(r.strm,r.window,r.strstart+r.lookahead,n),r.lookahead+=t,r.lookahead+r.insert>=ht)for(i=r.strstart-r.insert,r.ins_h=r.window[i],r.ins_h=Ro(r,r.ins_h,r.window[i+1]);r.insert&&(r.ins_h=Ro(r,r.ins_h,r.window[i+ht-1]),r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++,r.insert--,!(r.lookahead+r.insert<ht)););}while(r.lookahead<ts&&r.strm.avail_in!==0)},nI=(r,e)=>{let t=r.pending_buf_size-5>r.w_size?r.w_size:r.pending_buf_size-5,n,i,s,o=0,a=r.strm.avail_in;do{if(n=65535,s=r.bi_valid+42>>3,r.strm.avail_out<s||(s=r.strm.avail_out-s,i=r.strstart-r.block_start,n>i+r.strm.avail_in&&(n=i+r.strm.avail_in),n>s&&(n=s),n<t&&(n===0&&e!==si||e===vo||n!==i+r.strm.avail_in)))break;o=e===si&&n===i+r.strm.avail_in?1:0,S1(r,0,0,o),r.pending_buf[r.pending-4]=n,r.pending_buf[r.pending-3]=n>>8,r.pending_buf[r.pending-2]=~n,r.pending_buf[r.pending-1]=~n>>8,Gn(r.strm),i&&(i>n&&(i=n),r.strm.output.set(r.window.subarray(r.block_start,r.block_start+i),r.strm.next_out),r.strm.next_out+=i,r.strm.avail_out-=i,r.strm.total_out+=i,r.block_start+=i,n-=i),n&&(M1(r.strm,r.strm.output,r.strm.next_out,n),r.strm.next_out+=n,r.strm.avail_out-=n,r.strm.total_out+=n)}while(o===0);return a-=r.strm.avail_in,a&&(a>=r.w_size?(r.matches=2,r.window.set(r.strm.input.subarray(r.strm.next_in-r.w_size,r.strm.next_in),0),r.strstart=r.w_size,r.insert=r.strstart):(r.window_size-r.strstart<=a&&(r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,r.insert>r.strstart&&(r.insert=r.strstart)),r.window.set(r.strm.input.subarray(r.strm.next_in-a,r.strm.next_in),r.strstart),r.strstart+=a,r.insert+=a>r.w_size-r.insert?r.w_size-r.insert:a),r.block_start=r.strstart),r.high_water<r.strstart&&(r.high_water=r.strstart),o?vu:e!==vo&&e!==si&&r.strm.avail_in===0&&r.strstart===r.block_start?Au:(s=r.window_size-r.strstart,r.strm.avail_in>s&&r.block_start>=r.w_size&&(r.block_start-=r.w_size,r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,s+=r.w_size,r.insert>r.strstart&&(r.insert=r.strstart)),s>r.strm.avail_in&&(s=r.strm.avail_in),s&&(M1(r.strm,r.window,r.strstart,s),r.strstart+=s,r.insert+=s>r.w_size-r.insert?r.w_size-r.insert:s),r.high_water<r.strstart&&(r.high_water=r.strstart),s=r.bi_valid+42>>3,s=r.pending_buf_size-s>65535?65535:r.pending_buf_size-s,t=s>r.w_size?r.w_size:s,i=r.strstart-r.block_start,(i>=t||(i||e===si)&&e!==vo&&r.strm.avail_in===0&&i<=s)&&(n=i>s?s:i,o=e===si&&r.strm.avail_in===0&&n===i?1:0,S1(r,r.block_start,n,o),r.block_start+=n,Gn(r.strm)),o?La:yn)},L1=(r,e)=>{let t,n;for(;;){if(r.lookahead<ts){if(Eu(r),r.lookahead<ts&&e===vo)return yn;if(r.lookahead===0)break}if(t=0,r.lookahead>=ht&&(r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-ts&&(r.match_length=rI(r,t)),r.match_length>=ht)if(n=Ao(r,r.strstart-r.match_start,r.match_length-ht),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=ht){r.match_length--;do r.strstart++,r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+1]);else n=Ao(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(n&&(jn(r,!1),r.strm.avail_out===0))return yn}return r.insert=r.strstart<ht-1?r.strstart:ht-1,e===si?(jn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(jn(r,!1),r.strm.avail_out===0)?yn:Au},xu=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<ts){if(Eu(r),r.lookahead<ts&&e===vo)return yn;if(r.lookahead===0)break}if(t=0,r.lookahead>=ht&&(r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=ht-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-ts&&(r.match_length=rI(r,t),r.match_length<=5&&(r.strategy===wZ||r.match_length===ht&&r.strstart-r.match_start>4096)&&(r.match_length=ht-1)),r.prev_length>=ht&&r.match_length<=r.prev_length){i=r.strstart+r.lookahead-ht,n=Ao(r,r.strstart-1-r.prev_match,r.prev_length-ht),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=i&&(r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=ht-1,r.strstart++,n&&(jn(r,!1),r.strm.avail_out===0))return yn}else if(r.match_available){if(n=Ao(r,0,r.window[r.strstart-1]),n&&jn(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return yn}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(n=Ao(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<ht-1?r.strstart:ht-1,e===si?(jn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(jn(r,!1),r.strm.avail_out===0)?yn:Au},BZ=(r,e)=>{let t,n,i,s;const o=r.window;for(;;){if(r.lookahead<=Eo){if(Eu(r),r.lookahead<=Eo&&e===vo)return yn;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=ht&&r.strstart>0&&(i=r.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=r.strstart+Eo;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);r.match_length=Eo-(s-i),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=ht?(t=Ao(r,1,r.match_length-ht),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=Ao(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(jn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===si?(jn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(jn(r,!1),r.strm.avail_out===0)?yn:Au},PZ=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(Eu(r),r.lookahead===0)){if(e===vo)return yn;break}if(r.match_length=0,t=Ao(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(jn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===si?(jn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(jn(r,!1),r.strm.avail_out===0)?yn:Au};function rs(r,e,t,n,i){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=n,this.func=i}const Zf=[new rs(0,0,0,0,nI),new rs(4,4,8,4,L1),new rs(4,5,16,8,L1),new rs(4,6,32,32,L1),new rs(4,4,16,16,xu),new rs(8,16,32,32,xu),new rs(8,16,128,128,xu),new rs(8,32,128,256,xu),new rs(32,128,258,1024,xu),new rs(32,258,258,4096,xu)],MZ=r=>{r.window_size=2*r.w_size,xo(r.head),r.max_lazy_match=Zf[r.level].max_lazy,r.good_match=Zf[r.level].good_length,r.nice_match=Zf[r.level].nice_length,r.max_chain_length=Zf[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=ht-1,r.match_available=0,r.ins_h=0};function LZ(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=G0,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(kZ*2),this.dyn_dtree=new Uint16Array((2*IZ+1)*2),this.bl_tree=new Uint16Array((2*SZ+1)*2),xo(this.dyn_ltree),xo(this.dyn_dtree),xo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(TZ+1),this.heap=new Uint16Array(2*T1+1),xo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*T1+1),xo(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Qf=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.status!==_u&&e.status!==O1&&e.status!==N1&&e.status!==C1&&e.status!==B1&&e.status!==P1&&e.status!==Ma&&e.status!==Wf?1:0},iI=r=>{if(Qf(r))return Ua(r,es);r.total_in=r.total_out=0,r.data_type=vZ;const e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?O1:e.wrap?_u:Ma,r.adler=e.wrap===2?0:1,e.last_flush=-2,fZ(e),Zr},sI=r=>{const e=iI(r);return e===Zr&&MZ(r.state),e},UZ=(r,e)=>Qf(r)||r.state.wrap!==2?es:(r.state.gzhead=e,Zr),oI=(r,e,t,n,i,s)=>{if(!r)return es;let o=1;if(e===mZ&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>EZ||t!==G0||n<8||n>15||e<0||e>9||s<0||s>_Z||n===8&&o!==1)return Ua(r,es);n===8&&(n=9);const a=new LZ;return r.state=a,a.strm=r,a.status=_u,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+ht-1)/ht),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=e,a.strategy=s,a.method=t,sI(r)},DZ=(r,e)=>oI(r,e,G0,xZ,RZ,AZ),$Z=(r,e)=>{if(Qf(r)||e>XR||e<0)return r?Ua(r,es):es;const t=r.state;if(!r.output||r.avail_in!==0&&!r.input||t.status===Wf&&e!==si)return Ua(r,r.avail_out===0?k1:es);const n=t.last_flush;if(t.last_flush=e,t.pending!==0){if(Gn(r),r.avail_out===0)return t.last_flush=-1,Zr}else if(r.avail_in===0&&tI(e)<=tI(n)&&e!==si)return Ua(r,k1);if(t.status===Wf&&r.avail_in!==0)return Ua(r,k1);if(t.status===_u&&t.wrap===0&&(t.status=Ma),t.status===_u){let i=G0+(t.w_bits-8<<4)<<8,s=-1;if(t.strategy>=z0||t.level<2?s=0:t.level<6?s=1:t.level===6?s=2:s=3,i|=s<<6,t.strstart!==0&&(i|=OZ),i+=31-i%31,qf(t,i),t.strstart!==0&&(qf(t,r.adler>>>16),qf(t,r.adler&65535)),r.adler=1,t.status=Ma,Gn(r),t.pending!==0)return t.last_flush=-1,Zr}if(t.status===O1){if(r.adler=0,Rt(t,31),Rt(t,139),Rt(t,8),t.gzhead)Rt(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),Rt(t,t.gzhead.time&255),Rt(t,t.gzhead.time>>8&255),Rt(t,t.gzhead.time>>16&255),Rt(t,t.gzhead.time>>24&255),Rt(t,t.level===9?2:t.strategy>=z0||t.level<2?4:0),Rt(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(Rt(t,t.gzhead.extra.length&255),Rt(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(r.adler=Dr(r.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=N1;else if(Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,t.level===9?2:t.strategy>=z0||t.level<2?4:0),Rt(t,NZ),t.status=Ma,Gn(r),t.pending!==0)return t.last_flush=-1,Zr}if(t.status===N1){if(t.gzhead.extra){let i=t.pending,s=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+s>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex+=a,Gn(r),t.pending!==0)return t.last_flush=-1,Zr;i=0,s-=a}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+s),t.pending),t.pending+=s,t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=C1}if(t.status===C1){if(t.gzhead.name){let i=t.pending,s;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),Gn(r),t.pending!==0)return t.last_flush=-1,Zr;i=0}t.gzindex<t.gzhead.name.length?s=t.gzhead.name.charCodeAt(t.gzindex++)&255:s=0,Rt(t,s)}while(s!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=B1}if(t.status===B1){if(t.gzhead.comment){let i=t.pending,s;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),Gn(r),t.pending!==0)return t.last_flush=-1,Zr;i=0}t.gzindex<t.gzhead.comment.length?s=t.gzhead.comment.charCodeAt(t.gzindex++)&255:s=0,Rt(t,s)}while(s!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i))}t.status=P1}if(t.status===P1){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(Gn(r),t.pending!==0))return t.last_flush=-1,Zr;Rt(t,r.adler&255),Rt(t,r.adler>>8&255),r.adler=0}if(t.status=Ma,Gn(r),t.pending!==0)return t.last_flush=-1,Zr}if(r.avail_in!==0||t.lookahead!==0||e!==vo&&t.status!==Wf){let i=t.level===0?nI(t,e):t.strategy===z0?PZ(t,e):t.strategy===bZ?BZ(t,e):Zf[t.level].func(t,e);if((i===La||i===vu)&&(t.status=Wf),i===yn||i===La)return r.avail_out===0&&(t.last_flush=-1),Zr;if(i===Au&&(e===pZ?dZ(t):e!==XR&&(S1(t,0,0,!1),e===gZ&&(xo(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),Gn(r),r.avail_out===0))return t.last_flush=-1,Zr}return e!==si?Zr:t.wrap<=0?eI:(t.wrap===2?(Rt(t,r.adler&255),Rt(t,r.adler>>8&255),Rt(t,r.adler>>16&255),Rt(t,r.adler>>24&255),Rt(t,r.total_in&255),Rt(t,r.total_in>>8&255),Rt(t,r.total_in>>16&255),Rt(t,r.total_in>>24&255)):(qf(t,r.adler>>>16),qf(t,r.adler&65535)),Gn(r),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Zr:eI)},FZ=r=>{if(Qf(r))return es;const e=r.state.status;return r.state=null,e===Ma?Ua(r,yZ):Zr},HZ=(r,e)=>{let t=e.length;if(Qf(r))return es;const n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==_u||n.lookahead)return es;if(i===1&&(r.adler=Kf(r.adler,e,t,0)),n.wrap=0,t>=n.w_size){i===0&&(xo(n.head),n.strstart=0,n.block_start=0,n.insert=0);let u=new Uint8Array(n.w_size);u.set(e.subarray(t-n.w_size,t),0),e=u,t=n.w_size}const s=r.avail_in,o=r.next_in,a=r.input;for(r.avail_in=t,r.next_in=0,r.input=e,Eu(n);n.lookahead>=ht;){let u=n.strstart,l=n.lookahead-(ht-1);do n.ins_h=Ro(n,n.ins_h,n.window[u+ht-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++;while(--l);n.strstart=u,n.lookahead=ht-1,Eu(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=ht-1,n.match_available=0,r.next_in=o,r.input=a,r.avail_in=s,n.wrap=i,Zr};var zZ=DZ,GZ=oI,jZ=sI,KZ=iI,VZ=UZ,WZ=$Z,qZ=FZ,ZZ=HZ,QZ="pako deflate (from Nodeca project)",Yf={deflateInit:zZ,deflateInit2:GZ,deflateReset:jZ,deflateResetKeep:KZ,deflateSetHeader:VZ,deflate:WZ,deflateEnd:qZ,deflateSetDictionary:ZZ,deflateInfo:QZ};const YZ=(r,e)=>Object.prototype.hasOwnProperty.call(r,e);var JZ=function(r){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const n in t)YZ(t,n)&&(r[n]=t[n])}}return r},XZ=r=>{let e=0;for(let n=0,i=r.length;n<i;n++)e+=r[n].length;const t=new Uint8Array(e);for(let n=0,i=0,s=r.length;n<s;n++){let o=r[n];t.set(o,i),i+=o.length}return t},j0={assign:JZ,flattenChunks:XZ};let aI=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{aI=!1}const Jf=new Uint8Array(256);for(let r=0;r<256;r++)Jf[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Jf[254]=Jf[254]=1;var eQ=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,n,i,s,o=r.length,a=0;for(i=0;i<o;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),t<128?e[s++]=t:t<2048?(e[s++]=192|t>>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e};const tQ=(r,e)=>{if(e<65534&&r.subarray&&aI)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(r[n]);return t};var rQ=(r,e)=>{const t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let n,i;const s=new Array(t*2);for(i=0,n=0;n<t;){let o=r[n++];if(o<128){s[i++]=o;continue}let a=Jf[o];if(a>4){s[i++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n<t;)o=o<<6|r[n++]&63,a--;if(a>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return tQ(s,i)},nQ=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+Jf[r[t]]>e?t:e},Xf={string2buf:eQ,buf2string:rQ,utf8border:nQ};function iQ(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var cI=iQ;const uI=Object.prototype.toString,{Z_NO_FLUSH:sQ,Z_SYNC_FLUSH:oQ,Z_FULL_FLUSH:aQ,Z_FINISH:cQ,Z_OK:K0,Z_STREAM_END:uQ,Z_DEFAULT_COMPRESSION:lQ,Z_DEFAULT_STRATEGY:fQ,Z_DEFLATED:hQ}=Vf;function U1(r){this.options=j0.assign({level:lQ,method:hQ,chunkSize:16384,windowBits:15,memLevel:8,strategy:fQ},r||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cI,this.strm.avail_out=0;let t=Yf.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==K0)throw new Error(bu[t]);if(e.header&&Yf.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=Xf.string2buf(e.dictionary):uI.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=Yf.deflateSetDictionary(this.strm,n),t!==K0)throw new Error(bu[t]);this._dict_set=!0}}U1.prototype.push=function(r,e){const t=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?cQ:sQ,typeof r=="string"?t.input=Xf.string2buf(r):uI.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),(s===oQ||s===aQ)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=Yf.deflate(t,s),i===uQ)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=Yf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===K0;if(t.avail_out===0){this.onData(t.output);continue}if(s>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0},U1.prototype.onData=function(r){this.chunks.push(r)},U1.prototype.onEnd=function(r){r===K0&&(this.result=j0.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};const V0=16209,dQ=16191;var pQ=function(e,t){let n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H,D,z,W,Z,j,V,oe,ce;const ie=e.state;n=e.next_in,oe=e.input,i=n+(e.avail_in-5),s=e.next_out,ce=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),u=ie.dmax,l=ie.wsize,h=ie.whave,g=ie.wnext,b=ie.window,w=ie.hold,I=ie.bits,S=ie.lencode,x=ie.distcode,C=(1<<ie.lenbits)-1,H=(1<<ie.distbits)-1;e:do{I<15&&(w+=oe[n++]<<I,I+=8,w+=oe[n++]<<I,I+=8),D=S[w&C];t:for(;;){if(z=D>>>24,w>>>=z,I-=z,z=D>>>16&255,z===0)ce[s++]=D&65535;else if(z&16){W=D&65535,z&=15,z&&(I<z&&(w+=oe[n++]<<I,I+=8),W+=w&(1<<z)-1,w>>>=z,I-=z),I<15&&(w+=oe[n++]<<I,I+=8,w+=oe[n++]<<I,I+=8),D=x[w&H];r:for(;;){if(z=D>>>24,w>>>=z,I-=z,z=D>>>16&255,z&16){if(Z=D&65535,z&=15,I<z&&(w+=oe[n++]<<I,I+=8,I<z&&(w+=oe[n++]<<I,I+=8)),Z+=w&(1<<z)-1,Z>u){e.msg="invalid distance too far back",ie.mode=V0;break e}if(w>>>=z,I-=z,z=s-o,Z>z){if(z=Z-z,z>h&&ie.sane){e.msg="invalid distance too far back",ie.mode=V0;break e}if(j=0,V=b,g===0){if(j+=l-z,z<W){W-=z;do ce[s++]=b[j++];while(--z);j=s-Z,V=ce}}else if(g<z){if(j+=l+g-z,z-=g,z<W){W-=z;do ce[s++]=b[j++];while(--z);if(j=0,g<W){z=g,W-=z;do ce[s++]=b[j++];while(--z);j=s-Z,V=ce}}}else if(j+=g-z,z<W){W-=z;do ce[s++]=b[j++];while(--z);j=s-Z,V=ce}for(;W>2;)ce[s++]=V[j++],ce[s++]=V[j++],ce[s++]=V[j++],W-=3;W&&(ce[s++]=V[j++],W>1&&(ce[s++]=V[j++]))}else{j=s-Z;do ce[s++]=ce[j++],ce[s++]=ce[j++],ce[s++]=ce[j++],W-=3;while(W>2);W&&(ce[s++]=ce[j++],W>1&&(ce[s++]=ce[j++]))}}else if(z&64){e.msg="invalid distance code",ie.mode=V0;break e}else{D=x[(D&65535)+(w&(1<<z)-1)];continue r}break}}else if(z&64)if(z&32){ie.mode=dQ;break e}else{e.msg="invalid literal/length code",ie.mode=V0;break e}else{D=S[(D&65535)+(w&(1<<z)-1)];continue t}break}}while(n<i&&s<a);W=I>>3,n-=W,I-=W<<3,w&=(1<<I)-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=s<a?257+(a-s):257-(s-a),ie.hold=w,ie.bits=I};const Ru=15,lI=852,fI=592,hI=0,D1=1,dI=2,gQ=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),yQ=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),mQ=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),wQ=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var eh=(r,e,t,n,i,s,o,a)=>{const u=a.bits;let l=0,h=0,g=0,b=0,w=0,I=0,S=0,x=0,C=0,H=0,D,z,W,Z,j,V=null,oe;const ce=new Uint16Array(Ru+1),ie=new Uint16Array(Ru+1);let ue=null,B,p,m;for(l=0;l<=Ru;l++)ce[l]=0;for(h=0;h<n;h++)ce[e[t+h]]++;for(w=u,b=Ru;b>=1&&ce[b]===0;b--);if(w>b&&(w=b),b===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,a.bits=1,0;for(g=1;g<b&&ce[g]===0;g++);for(w<g&&(w=g),x=1,l=1;l<=Ru;l++)if(x<<=1,x-=ce[l],x<0)return-1;if(x>0&&(r===hI||b!==1))return-1;for(ie[1]=0,l=1;l<Ru;l++)ie[l+1]=ie[l]+ce[l];for(h=0;h<n;h++)e[t+h]!==0&&(o[ie[e[t+h]]++]=h);if(r===hI?(V=ue=o,oe=20):r===D1?(V=gQ,ue=yQ,oe=257):(V=mQ,ue=wQ,oe=0),H=0,h=0,l=g,j=s,I=w,S=0,W=-1,C=1<<w,Z=C-1,r===D1&&C>lI||r===dI&&C>fI)return 1;for(;;){B=l-S,o[h]+1<oe?(p=0,m=o[h]):o[h]>=oe?(p=ue[o[h]-oe],m=V[o[h]-oe]):(p=96,m=0),D=1<<l-S,z=1<<I,g=z;do z-=D,i[j+(H>>S)+z]=B<<24|p<<16|m|0;while(z!==0);for(D=1<<l-1;H&D;)D>>=1;if(D!==0?(H&=D-1,H+=D):H=0,h++,--ce[l]===0){if(l===b)break;l=e[t+o[h]]}if(l>w&&(H&Z)!==W){for(S===0&&(S=w),j+=g,I=l-S,x=1<<I;I+S<b&&(x-=ce[I+S],!(x<=0));)I++,x<<=1;if(C+=1<<I,r===D1&&C>lI||r===dI&&C>fI)return 1;W=H&Z,i[W]=w<<24|I<<16|j-s|0}}return H!==0&&(i[j+H]=l-S<<24|64<<16|0),a.bits=w,0};const bQ=0,pI=1,gI=2,{Z_FINISH:yI,Z_BLOCK:_Q,Z_TREES:W0,Z_OK:Da,Z_STREAM_END:AQ,Z_NEED_DICT:vQ,Z_STREAM_ERROR:oi,Z_DATA_ERROR:mI,Z_MEM_ERROR:wI,Z_BUF_ERROR:EQ,Z_DEFLATED:bI}=Vf,q0=16180,_I=16181,AI=16182,vI=16183,EI=16184,xI=16185,RI=16186,II=16187,SI=16188,kI=16189,Z0=16190,Cs=16191,$1=16192,TI=16193,F1=16194,OI=16195,NI=16196,CI=16197,BI=16198,Q0=16199,Y0=16200,PI=16201,MI=16202,LI=16203,UI=16204,DI=16205,H1=16206,$I=16207,FI=16208,Qt=16209,HI=16210,zI=16211,xQ=852,RQ=592,IQ=15,GI=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function SQ(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const $a=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.mode<q0||e.mode>zI?1:0},jI=r=>{if($a(r))return oi;const e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=q0,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(xQ),e.distcode=e.distdyn=new Int32Array(RQ),e.sane=1,e.back=-1,Da},KI=r=>{if($a(r))return oi;const e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,jI(r)},VI=(r,e)=>{let t;if($a(r))return oi;const n=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?oi:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,KI(r))},WI=(r,e)=>{if(!r)return oi;const t=new SQ;r.state=t,t.strm=r,t.window=null,t.mode=q0;const n=VI(r,e);return n!==Da&&(r.state=null),n},kQ=r=>WI(r,IQ);let qI=!0,z1,G1;const TQ=r=>{if(qI){z1=new Int32Array(512),G1=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(eh(pI,r.lens,0,288,z1,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;eh(gI,r.lens,0,32,G1,0,r.work,{bits:5}),qI=!1}r.lencode=z1,r.lenbits=9,r.distcode=G1,r.distbits=5},ZI=(r,e,t,n)=>{let i;const s=r.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(t-n,t-n+i),s.wnext),n-=i,n?(s.window.set(e.subarray(t-n,t),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},OQ=(r,e)=>{let t,n,i,s,o,a,u,l,h,g,b,w,I,S,x=0,C,H,D,z,W,Z,j,V;const oe=new Uint8Array(4);let ce,ie;const ue=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($a(r)||!r.output||!r.input&&r.avail_in!==0)return oi;t=r.state,t.mode===Cs&&(t.mode=$1),o=r.next_out,i=r.output,u=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,h=t.bits,g=a,b=u,V=Da;e:for(;;)switch(t.mode){case q0:if(t.wrap===0){t.mode=$1;break}for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&2&&l===35615){t.wbits===0&&(t.wbits=15),t.check=0,oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0),l=0,h=0,t.mode=_I;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){r.msg="incorrect header check",t.mode=Qt;break}if((l&15)!==bI){r.msg="unknown compression method",t.mode=Qt;break}if(l>>>=4,h-=4,j=(l&15)+8,t.wbits===0&&(t.wbits=j),j>15||j>t.wbits){r.msg="invalid window size",t.mode=Qt;break}t.dmax=1<<t.wbits,t.flags=0,r.adler=t.check=1,t.mode=l&512?kI:Cs,l=0,h=0;break;case _I:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.flags=l,(t.flags&255)!==bI){r.msg="unknown compression method",t.mode=Qt;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=Qt;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0)),l=0,h=0,t.mode=AI;case AI:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.head&&(t.head.time=l),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,oe[2]=l>>>16&255,oe[3]=l>>>24&255,t.check=Dr(t.check,oe,4,0)),l=0,h=0,t.mode=vI;case vI:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0)),l=0,h=0,t.mode=EI;case EI:if(t.flags&1024){for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0)),l=0,h=0}else t.head&&(t.head.extra=null);t.mode=xI;case xI:if(t.flags&1024&&(w=t.length,w>a&&(w=a),w&&(t.head&&(j=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(s,s+w),j)),t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,t.length-=w),t.length))break e;t.length=0,t.mode=RI;case RI:if(t.flags&2048){if(a===0)break e;w=0;do j=n[s+w++],t.head&&j&&t.length<65536&&(t.head.name+=String.fromCharCode(j));while(j&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,j)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=II;case II:if(t.flags&4096){if(a===0)break e;w=0;do j=n[s+w++],t.head&&j&&t.length<65536&&(t.head.comment+=String.fromCharCode(j));while(j&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,j)break e}else t.head&&(t.head.comment=null);t.mode=SI;case SI:if(t.flags&512){for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&4&&l!==(t.check&65535)){r.msg="header crc mismatch",t.mode=Qt;break}l=0,h=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=Cs;break;case kI:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}r.adler=t.check=GI(l),l=0,h=0,t.mode=Z0;case Z0:if(t.havedict===0)return r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,vQ;r.adler=t.check=1,t.mode=Cs;case Cs:if(e===_Q||e===W0)break e;case $1:if(t.last){l>>>=h&7,h-=h&7,t.mode=H1;break}for(;h<3;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}switch(t.last=l&1,l>>>=1,h-=1,l&3){case 0:t.mode=TI;break;case 1:if(TQ(t),t.mode=Q0,e===W0){l>>>=2,h-=2;break e}break;case 2:t.mode=NI;break;case 3:r.msg="invalid block type",t.mode=Qt}l>>>=2,h-=2;break;case TI:for(l>>>=h&7,h-=h&7;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if((l&65535)!==(l>>>16^65535)){r.msg="invalid stored block lengths",t.mode=Qt;break}if(t.length=l&65535,l=0,h=0,t.mode=F1,e===W0)break e;case F1:t.mode=OI;case OI:if(w=t.length,w){if(w>a&&(w=a),w>u&&(w=u),w===0)break e;i.set(n.subarray(s,s+w),o),a-=w,s+=w,u-=w,o+=w,t.length-=w;break}t.mode=Cs;break;case NI:for(;h<14;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.nlen=(l&31)+257,l>>>=5,h-=5,t.ndist=(l&31)+1,l>>>=5,h-=5,t.ncode=(l&15)+4,l>>>=4,h-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=Qt;break}t.have=0,t.mode=CI;case CI:for(;t.have<t.ncode;){for(;h<3;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.lens[ue[t.have++]]=l&7,l>>>=3,h-=3}for(;t.have<19;)t.lens[ue[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,ce={bits:t.lenbits},V=eh(bQ,t.lens,0,19,t.lencode,0,t.work,ce),t.lenbits=ce.bits,V){r.msg="invalid code lengths set",t.mode=Qt;break}t.have=0,t.mode=BI;case BI:for(;t.have<t.nlen+t.ndist;){for(;x=t.lencode[l&(1<<t.lenbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(D<16)l>>>=C,h-=C,t.lens[t.have++]=D;else{if(D===16){for(ie=C+2;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(l>>>=C,h-=C,t.have===0){r.msg="invalid bit length repeat",t.mode=Qt;break}j=t.lens[t.have-1],w=3+(l&3),l>>>=2,h-=2}else if(D===17){for(ie=C+3;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=C,h-=C,j=0,w=3+(l&7),l>>>=3,h-=3}else{for(ie=C+7;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=C,h-=C,j=0,w=11+(l&127),l>>>=7,h-=7}if(t.have+w>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=Qt;break}for(;w--;)t.lens[t.have++]=j}}if(t.mode===Qt)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=Qt;break}if(t.lenbits=9,ce={bits:t.lenbits},V=eh(pI,t.lens,0,t.nlen,t.lencode,0,t.work,ce),t.lenbits=ce.bits,V){r.msg="invalid literal/lengths set",t.mode=Qt;break}if(t.distbits=6,t.distcode=t.distdyn,ce={bits:t.distbits},V=eh(gI,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,ce),t.distbits=ce.bits,V){r.msg="invalid distances set",t.mode=Qt;break}if(t.mode=Q0,e===W0)break e;case Q0:t.mode=Y0;case Y0:if(a>=6&&u>=258){r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,pQ(r,b),o=r.next_out,i=r.output,u=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,h=t.bits,t.mode===Cs&&(t.back=-1);break}for(t.back=0;x=t.lencode[l&(1<<t.lenbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(H&&!(H&240)){for(z=C,W=H,Z=D;x=t.lencode[Z+((l&(1<<z+W)-1)>>z)],C=x>>>24,H=x>>>16&255,D=x&65535,!(z+C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=z,h-=z,t.back+=z}if(l>>>=C,h-=C,t.back+=C,t.length=D,H===0){t.mode=DI;break}if(H&32){t.back=-1,t.mode=Cs;break}if(H&64){r.msg="invalid literal/length code",t.mode=Qt;break}t.extra=H&15,t.mode=PI;case PI:if(t.extra){for(ie=t.extra;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=MI;case MI:for(;x=t.distcode[l&(1<<t.distbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(!(H&240)){for(z=C,W=H,Z=D;x=t.distcode[Z+((l&(1<<z+W)-1)>>z)],C=x>>>24,H=x>>>16&255,D=x&65535,!(z+C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=z,h-=z,t.back+=z}if(l>>>=C,h-=C,t.back+=C,H&64){r.msg="invalid distance code",t.mode=Qt;break}t.offset=D,t.extra=H&15,t.mode=LI;case LI:if(t.extra){for(ie=t.extra;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=Qt;break}t.mode=UI;case UI:if(u===0)break e;if(w=b-u,t.offset>w){if(w=t.offset-w,w>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=Qt;break}w>t.wnext?(w-=t.wnext,I=t.wsize-w):I=t.wnext-w,w>t.length&&(w=t.length),S=t.window}else S=i,I=o-t.offset,w=t.length;w>u&&(w=u),u-=w,t.length-=w;do i[o++]=S[I++];while(--w);t.length===0&&(t.mode=Y0);break;case DI:if(u===0)break e;i[o++]=t.length,u--,t.mode=Y0;break;case H1:if(t.wrap){for(;h<32;){if(a===0)break e;a--,l|=n[s++]<<h,h+=8}if(b-=u,r.total_out+=b,t.total+=b,t.wrap&4&&b&&(r.adler=t.check=t.flags?Dr(t.check,i,b,o-b):Kf(t.check,i,b,o-b)),b=u,t.wrap&4&&(t.flags?l:GI(l))!==t.check){r.msg="incorrect data check",t.mode=Qt;break}l=0,h=0}t.mode=$I;case $I:if(t.wrap&&t.flags){for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&4&&l!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=Qt;break}l=0,h=0}t.mode=FI;case FI:V=AQ;break e;case Qt:V=mI;break e;case HI:return wI;case zI:default:return oi}return r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,(t.wsize||b!==r.avail_out&&t.mode<Qt&&(t.mode<H1||e!==yI))&&ZI(r,r.output,r.next_out,b-r.avail_out),g-=r.avail_in,b-=r.avail_out,r.total_in+=g,r.total_out+=b,t.total+=b,t.wrap&4&&b&&(r.adler=t.check=t.flags?Dr(t.check,i,b,r.next_out-b):Kf(t.check,i,b,r.next_out-b)),r.data_type=t.bits+(t.last?64:0)+(t.mode===Cs?128:0)+(t.mode===Q0||t.mode===F1?256:0),(g===0&&b===0||e===yI)&&V===Da&&(V=EQ),V},NQ=r=>{if($a(r))return oi;let e=r.state;return e.window&&(e.window=null),r.state=null,Da},CQ=(r,e)=>{if($a(r))return oi;const t=r.state;return t.wrap&2?(t.head=e,e.done=!1,Da):oi},BQ=(r,e)=>{const t=e.length;let n,i,s;return $a(r)||(n=r.state,n.wrap!==0&&n.mode!==Z0)?oi:n.mode===Z0&&(i=1,i=Kf(i,e,t,0),i!==n.check)?mI:(s=ZI(r,e,t,t),s?(n.mode=HI,wI):(n.havedict=1,Da))};var PQ=KI,MQ=VI,LQ=jI,UQ=kQ,DQ=WI,$Q=OQ,FQ=NQ,HQ=CQ,zQ=BQ,GQ="pako inflate (from Nodeca project)",Bs={inflateReset:PQ,inflateReset2:MQ,inflateResetKeep:LQ,inflateInit:UQ,inflateInit2:DQ,inflate:$Q,inflateEnd:FQ,inflateGetHeader:HQ,inflateSetDictionary:zQ,inflateInfo:GQ};function jQ(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var KQ=jQ;const QI=Object.prototype.toString,{Z_NO_FLUSH:VQ,Z_FINISH:WQ,Z_OK:th,Z_STREAM_END:j1,Z_NEED_DICT:K1,Z_STREAM_ERROR:qQ,Z_DATA_ERROR:YI,Z_MEM_ERROR:ZQ}=Vf;function rh(r){this.options=j0.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cI,this.strm.avail_out=0;let t=Bs.inflateInit2(this.strm,e.windowBits);if(t!==th)throw new Error(bu[t]);if(this.header=new KQ,Bs.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Xf.string2buf(e.dictionary):QI.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Bs.inflateSetDictionary(this.strm,e.dictionary),t!==th)))throw new Error(bu[t])}rh.prototype.push=function(r,e){const t=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?WQ:VQ,QI.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),s=Bs.inflate(t,o),s===K1&&i&&(s=Bs.inflateSetDictionary(t,i),s===th?s=Bs.inflate(t,o):s===YI&&(s=K1));t.avail_in>0&&s===j1&&t.state.wrap>0&&r[t.next_in]!==0;)Bs.inflateReset(t),s=Bs.inflate(t,o);switch(s){case qQ:case YI:case K1:case ZQ:return this.onEnd(s),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||s===j1))if(this.options.to==="string"){let u=Xf.utf8border(t.output,t.next_out),l=t.next_out-u,h=Xf.buf2string(t.output,u);t.next_out=l,t.avail_out=n-l,l&&t.output.set(t.output.subarray(u,u+l),0),this.onData(h)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===th&&a===0)){if(s===j1)return s=Bs.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0},rh.prototype.onData=function(r){this.chunks.push(r)},rh.prototype.onEnd=function(r){r===th&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=j0.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function V1(r,e){const t=new rh(e);if(t.push(r),t.err)throw t.msg||bu[t.err];return t.result}function QQ(r,e){return e=e||{},e.raw=!0,V1(r,e)}var YQ=rh,JQ=V1,XQ=QQ,eY=V1,tY=Vf,rY={Inflate:YQ,inflate:JQ,inflateRaw:XQ,ungzip:eY,constants:tY};const{Inflate:Cae,inflate:nY,inflateRaw:Bae,ungzip:Pae}=rY;var iY=nY,JI={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function s(u,l,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||u,b),I=t?t+l:l;return u._events[I]?u._events[I].fn?u._events[I]=[u._events[I],w]:u._events[I].push(w):(u._events[I]=w,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,g;if(this._eventsCount===0)return l;for(g in h=this._events)e.call(h,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,I=new Array(w);b<w;b++)I[b]=g[b].fn;return I},a.prototype.listenerCount=function(l){var h=t?t+l:l,g=this._events[h];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,h,g,b,w,I){var S=t?t+l:l;if(!this._events[S])return!1;var x=this._events[S],C=arguments.length,H,D;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),C){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,g),!0;case 4:return x.fn.call(x.context,h,g,b),!0;case 5:return x.fn.call(x.context,h,g,b,w),!0;case 6:return x.fn.call(x.context,h,g,b,w,I),!0}for(D=1,H=new Array(C-1);D<C;D++)H[D-1]=arguments[D];x.fn.apply(x.context,H)}else{var z=x.length,W;for(D=0;D<z;D++)switch(x[D].once&&this.removeListener(l,x[D].fn,void 0,!0),C){case 1:x[D].fn.call(x[D].context);break;case 2:x[D].fn.call(x[D].context,h);break;case 3:x[D].fn.call(x[D].context,h,g);break;case 4:x[D].fn.call(x[D].context,h,g,b);break;default:if(!H)for(W=1,H=new Array(C-1);W<C;W++)H[W-1]=arguments[W];x[D].fn.apply(x[D].context,H)}}return!0},a.prototype.on=function(l,h,g){return s(this,l,h,g,!1)},a.prototype.once=function(l,h,g){return s(this,l,h,g,!0)},a.prototype.removeListener=function(l,h,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!h)return o(this,w),this;var I=this._events[w];if(I.fn)I.fn===h&&(!b||I.once)&&(!g||I.context===g)&&o(this,w);else{for(var S=0,x=[],C=I.length;S<C;S++)(I[S].fn!==h||b&&!I[S].once||g&&I[S].context!==g)&&x.push(I[S]);x.length?this._events[w]=x.length===1?x[0]:x:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(JI);var sY=JI.exports;const oY=xn(sY);function aY(r,e){return Array.apply(0,new Array(Math.ceil(r.length/e))).map((t,n)=>r.slice(n*e,(n+1)*e))}const Fa=r=>"version"in r;function cY(r){return new TextDecoder("utf-8").decode(r)}function XI(r){return Or.encode(r)}function eS(r){return Ne.from(r,"base64")}function Io(r){return"accounts"in r}async function uY(r){const e=(await me.findProgramAddress([],r))[0];return await me.createWithSeed(e,lY(),r)}function lY(){return"anchor:idl"}const fY=Xe.struct([Xe.publicKey("authority"),Xe.vecU8("data")]);function hY(r){return fY.decode(r)}function dY(r){const e=["name","path","account","relations","generic"],t=s=>s.split(".").map(Nq).join("."),n=s=>{for(const o in s){const a=s[o];e.includes(o)?s[o]=Array.isArray(a)?a.map(t):t(a):typeof a=="object"&&n(a)}},i=structuredClone(r);return n(i),i}function Iu(r,e,t,n){return r!=null&&r.length?r[0].name?t(r):n(r):e()}function pY(r){const e=new Map;return r.errors&&r.errors.forEach(t=>{var n;let i=(n=t.msg)!==null&&n!==void 0?n:t.name;e.set(t.code,i)}),e}function gY(r,...e){if(r.args.length!=e.length)throw new Error("Invalid argument length");const t={};let n=0;return r.args.forEach(i=>{t[i.name]=e[n],n+=1}),t}function tS(r,e={}){r.forEach(t=>{if(Io(t))tS(t.accounts,e[t.name]);else if(!e[t.name])throw new Error(`Account \`${t.name}\` not provided.`)})}function xi(r){return r instanceof me?r:new me(r)}class yY extends TypeError{constructor(e,t){let n;const{message:i,...s}=e,{path:o}=e,a=o.length===0?i:"At path: "+o.join(".")+" -- "+i;super(a),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>{var u;return(u=n)!=null?u:n=[e,...t()]}}}function mY(r){return Su(r)&&typeof r[Symbol.iterator]=="function"}function Su(r){return typeof r=="object"&&r!=null}function So(r){return typeof r=="string"?JSON.stringify(r):""+r}function wY(r){const{done:e,value:t}=r.next();return e?void 0:t}function bY(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:s}=e,{type:o}=t,{refinement:a,message:u="Expected a value of type `"+o+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+So(n)+"`"}=r;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*rS(r,e,t,n){mY(r)||(r=[r]);for(const i of r){const s=bY(i,e,t,n);s&&(yield s)}}function*W1(r,e,t){t===void 0&&(t={});const{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,a={path:n,branch:i};if(s&&(r=e.coercer(r,a),o&&e.type!=="type"&&Su(e.schema)&&Su(r)&&!Array.isArray(r)))for(const l in r)e.schema[l]===void 0&&delete r[l];let u=!0;for(const l of e.validator(r,a))u=!1,yield[l,void 0];for(let[l,h,g]of e.entries(r,a)){const b=W1(h,g,{path:l===void 0?n:[...n,l],branch:l===void 0?i:[...i,h],coerce:s,mask:o});for(const w of b)w[0]?(u=!1,yield[w[0],void 0]):s&&(h=w[1],l===void 0?r=h:r instanceof Map?r.set(l,h):r instanceof Set?r.add(h):Su(r)&&(r[l]=h))}if(u)for(const l of e.refiner(r,a))u=!1,yield[l,void 0];u&&(yield[void 0,r])}class ko{constructor(e){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,l)=>{const h=i(u,l);return rS(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return rS(h,l,this,u)}:this.refiner=()=>[]}assert(e){return _Y(e,this)}create(e){return q1(e,this)}is(e){return nS(e,this)}mask(e){return AY(e,this)}validate(e,t){return t===void 0&&(t={}),nh(e,this,t)}}function _Y(r,e){const t=nh(r,e);if(t[0])throw t[0]}function q1(r,e){const t=nh(r,e,{coerce:!0});if(t[0])throw t[0];return t[1]}function AY(r,e){const t=nh(r,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}function nS(r,e){return!nh(r,e)[0]}function nh(r,e,t){t===void 0&&(t={});const n=W1(r,e,t),i=wY(n);return i[0]?[new yY(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function ih(r,e){return new ko({type:r,schema:null,validator:e})}function vY(){return ih("any",()=>!0)}function Z1(r){return new ko({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||"Expected an array value, but received: "+So(e)}})}function EY(){return ih("boolean",r=>typeof r=="boolean")}function iS(r){const e=So(r);return new ko({type:"literal",schema:r,validator(t){return t===r||"Expected the literal `"+e+"`, but received: "+So(t)}})}function J0(r){return new ko({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function X0(){return ih("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+So(r))}function ep(r){return new ko({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function Ha(){return ih("string",r=>typeof r=="string"||"Expected a string, but received: "+So(r))}function To(r){const e=Object.keys(r);return new ko({type:"type",schema:r,*entries(t){if(Su(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return Su(t)||"Expected an object, but received: "+So(t)}})}function sS(r){const e=r.map(t=>t.type).join(" | ");return new ko({type:"union",schema:null,coercer(t,n){return(r.find(s=>{const[o]=s.validate(t,{coerce:!0});return!o})||Q1()).coercer(t,n)},validator(t,n){const i=[];for(const s of r){const[...o]=W1(t,s,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return["Expected the value to satisfy a union of `"+e+"`, but received: "+So(t),...i]}})}function Q1(){return ih("unknown",()=>!0)}function xY(r,e,t){return new ko({...r,coercer:(n,i)=>nS(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}const oS=99;async function RY(r,e,t){if(e.length<=oS)return await aS(r,e,t);{const n=aY(e,oS);return(await Promise.all(n.map(s=>aS(r,s,t)))).flat()}}async function aS(r,e,t){const n=t??r.commitment,{value:i,context:s}=await r.getMultipleAccountsInfoAndContext(e,n);return i.map((a,u)=>a===null?null:{publicKey:e[u],account:a,context:s})}async function IY(r,e,t,n,i){var s;t&&t.length>0&&e.sign(...t);const o=e._compile(),a=o.serialize(),l=e._serialize(a).toString("base64"),h={encoding:"base64",commitment:n??r.commitment};if(i){const I=(Array.isArray(i)?i:o.nonProgramIds()).map(S=>S.toBase58());h.accounts={encoding:"base64",addresses:I}}t&&t.length>0&&(h.sigVerify=!0);const g=[l,h],b=await r._rpcRequest("simulateTransaction",g),w=q1(b,OY);if("error"in w){let I;if("data"in w.error&&(I=(s=w.error.data)===null||s===void 0?void 0:s.logs,I&&Array.isArray(I))){const S=`
26
+ `,x=S+I.join(S);console.error(w.error.message,x)}throw new _o("failed to simulate transaction: "+w.error.message,I)}return w.result}function SY(r){return xY(cS(r),kY,e=>"error"in e?e:{...e,result:q1(e.result,r)})}const kY=cS(Q1());function cS(r){return sS([To({jsonrpc:iS("2.0"),id:Ha(),result:r}),To({jsonrpc:iS("2.0"),id:Ha(),error:To({code:Q1(),message:Ha(),data:ep(vY())})})])}function TY(r){return SY(To({context:To({slot:X0()}),value:r}))}const OY=TY(To({err:J0(sS([To({}),Ha()])),logs:J0(Z1(Ha())),accounts:ep(J0(Z1(J0(To({executable:EY(),owner:Ha(),lamports:X0(),data:Z1(Ha()),rentEpoch:ep(X0())}))))),unitsConsumed:ep(X0())}));class sh{constructor(e,t,n=sh.defaultOptions()){this.connection=e,this.wallet=t,this.opts=n,this.publicKey=t==null?void 0:t.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(e,t=sh.defaultOptions()){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(e,t,n){var i,s,o,a;if(n===void 0&&(n=this.opts),Fa(e))t&&e.sign(t);else if(e.feePayer=(i=e.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,e.recentBlockhash=(await this.connection.getLatestBlockhash(n.preflightCommitment)).blockhash,t)for(const l of t)e.partialSign(l);e=await this.wallet.signTransaction(e);const u=e.serialize();try{return await uS(this.connection,u,n)}catch(l){if(l instanceof Y1){const h=XI(Fa(e)?((s=e.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=e.signature)!==null&&o!==void 0?o:new Uint8Array),g=Fa(e)?0:void 0,b=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:g});if(b){const w=(a=b.meta)===null||a===void 0?void 0:a.logMessages;throw w?new _o(l.message,w):l}else throw l}else throw l}}async sendAll(e,t){var n,i,s;t===void 0&&(t=this.opts);const o=(await this.connection.getLatestBlockhash(t.preflightCommitment)).blockhash;let a=e.map(h=>{var g,b;if(Fa(h.tx)){let w=h.tx;return h.signers&&w.sign(h.signers),w}else{let w=h.tx,I=(g=h.signers)!==null&&g!==void 0?g:[];return w.feePayer=(b=w.feePayer)!==null&&b!==void 0?b:this.wallet.publicKey,w.recentBlockhash=o,I.forEach(S=>{w.partialSign(S)}),w}});const u=await this.wallet.signAllTransactions(a),l=[];for(let h=0;h<a.length;h+=1){const g=u[h],b=g.serialize();try{l.push(await uS(this.connection,b,t))}catch(w){if(w instanceof Y1){const I=XI(Fa(g)?((n=g.signatures)===null||n===void 0?void 0:n[0])||new Uint8Array:(i=g.signature)!==null&&i!==void 0?i:new Uint8Array),S=Fa(g)?0:void 0,x=await this.connection.getTransaction(I,{commitment:"confirmed",maxSupportedTransactionVersion:S});if(x){const C=(s=x.meta)===null||s===void 0?void 0:s.logMessages;throw C?new _o(w.message,C):w}else throw w}else throw w}}return l}async simulate(e,t,n,i){let s=(await this.connection.getLatestBlockhash(n??this.connection.commitment)).blockhash,o;if(Fa(e)?(t&&t.length>0&&(e.sign(t),e=await this.wallet.signTransaction(e)),o=await this.connection.simulateTransaction(e,{commitment:n})):(e.feePayer=e.feePayer||this.wallet.publicKey,e.recentBlockhash=s,t&&t.length>0&&(e=await this.wallet.signTransaction(e)),o=await IY(this.connection,e,t,n,i)),o.value.err)throw new NY(o.value);return o.value}}class NY extends Error{constructor(e,t){super(t),this.simulationResponse=e}}async function uS(r,e,t){const n=t?{skipPreflight:t.skipPreflight,preflightCommitment:t.preflightCommitment||t.commitment,maxRetries:t.maxRetries,minContextSlot:t.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await r.sendRawTransaction(e,n);if(t!=null&&t.blockhash)if(n.maxRetries===0){const a=AbortSignal.timeout(15e3);i=(await r.confirmTransaction({abortSignal:a,signature:o,...t.blockhash},t&&t.commitment)).value}else i=(await r.confirmTransaction({signature:o,...t.blockhash},t&&t.commitment)).value;else i=(await r.confirmTransaction(o,t&&t.commitment)).value;if(i.err)throw new Y1(`Raw transaction ${o} failed (${JSON.stringify(i)})`);return o}catch(o){if(o.name==="TimeoutError")continue;throw o}throw Error("Transaction failed to confirm in 60s")}class Y1 extends Error{constructor(e){super(e)}}function J1(){return sh.local()}var CY=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof qc<"u"?qc:typeof self<"u"?self:{},ee={};Object.defineProperty(ee,"__esModule",{value:!0});var lS=ee.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=ok=ee.ANCHOR_ERROR__REQUIRE_VIOLATED=sk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=ik=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=nk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=rk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=tk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=ek=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=XS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=JS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=YS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=QS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=ZS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=qS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=WS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=VS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=KS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=jS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=GS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=zS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=HS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=FS=ee.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=$S=ee.ANCHOR_ERROR__CONSTRAINT_SPACE=DS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=US=ee.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=LS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=MS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=PS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=BS=ee.ANCHOR_ERROR__CONSTRAINT_ZERO=CS=ee.ANCHOR_ERROR__CONSTRAINT_ADDRESS=NS=ee.ANCHOR_ERROR__CONSTRAINT_CLOSE=OS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=TS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=kS=ee.ANCHOR_ERROR__CONSTRAINT_STATE=SS=ee.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=IS=ee.ANCHOR_ERROR__CONSTRAINT_SEEDS=RS=ee.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=xS=ee.ANCHOR_ERROR__CONSTRAINT_OWNER=ES=ee.ANCHOR_ERROR__CONSTRAINT_RAW=vS=ee.ANCHOR_ERROR__CONSTRAINT_SIGNER=AS=ee.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=_S=ee.ANCHOR_ERROR__CONSTRAINT_MUT=bS=ee.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=wS=ee.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=mS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=yS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=gS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=pS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=dS=ee.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=hS=ee.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,fS=ee.ANCHOR_ERROR__DEPRECATED=Ck=ee.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=Nk=ee.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=Ok=ee.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=Tk=ee.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=kk=ee.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=Sk=ee.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=Ik=ee.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=Rk=ee.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=xk=ee.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=Ek=ee.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=vk=ee.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=Ak=ee.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=_k=ee.ANCHOR_ERROR__INVALID_PROGRAM_ID=bk=ee.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=wk=ee.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=mk=ee.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=yk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=gk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=pk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=dk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=hk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=fk=ee.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=lk=ee.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=uk=ee.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=ck=ee.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=ak=ee.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,hS=ee.ANCHOR_ERROR__INSTRUCTION_MISSING=100,dS=ee.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,pS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,gS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,yS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,mS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,wS=ee.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,bS=ee.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,_S=ee.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,AS=ee.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,vS=ee.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,ES=ee.ANCHOR_ERROR__CONSTRAINT_RAW=2003,xS=ee.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,RS=ee.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,IS=ee.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,SS=ee.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,kS=ee.ANCHOR_ERROR__CONSTRAINT_STATE=2008,TS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,OS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,NS=ee.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,CS=ee.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,BS=ee.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,PS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,MS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,LS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,US=ee.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,DS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,$S=ee.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,FS=ee.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,HS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,zS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,GS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,jS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,KS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,VS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,WS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,qS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,ZS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,QS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,YS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,JS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,XS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,ek=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,tk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,rk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,nk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,ik=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,sk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,ok=ee.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;lS=ee.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var ak=ee.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,ck=ee.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,uk=ee.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,lk=ee.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,fk=ee.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,hk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,dk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,pk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,gk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,yk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,mk=ee.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,wk=ee.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,bk=ee.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,_k=ee.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,Ak=ee.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,vk=ee.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,Ek=ee.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,xk=ee.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,Rk=ee.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,Ik=ee.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,Sk=ee.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,kk=ee.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,Tk=ee.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,Ok=ee.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,Nk=ee.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,Ck=ee.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;fS=ee.ANCHOR_ERROR__DEPRECATED=5e3;const BY=new Map;function Bk(r){return BY.get(r)!==void 0}class Oo extends Error{constructor(e){super(e),this.name="IdlError"}}class oh{constructor(e){this.stack=e}static parse(e){var t;const n=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<e.length;o++){if(i.exec(e[o])){s.pop();continue}const a=(t=n.exec(e[o]))===null||t===void 0?void 0:t[1];a&&s.push(new me(a))}return new oh(s)}}class ah extends Error{constructor(e,t,n,i,s,o){super(n.join(`
27
+ `).replace("Program log: ","")),this.errorLogs=n,this.logs=i,this.error={errorCode:e,errorMessage:t,comparedValues:o,origin:s},this._programErrorStack=oh.parse(i)}static parse(e){if(!e)return null;const t=e.findIndex(b=>b.startsWith("Program log: AnchorError"));if(t===-1)return null;const n=e[t],i=[n];let s;if(t+1<e.length){if(e[t+1]==="Program log: Left:"){const b=/^Program log: (.*)$/,w=b.exec(e[t+2])[1],I=b.exec(e[t+4])[1];s=[new me(w),new me(I)],i.push(...e.slice(t+1,t+5))}else if(e[t+1].startsWith("Program log: Left:")){const b=/^Program log: (Left|Right): (.*)$/,w=b.exec(e[t+1])[2],I=b.exec(e[t+2])[2];i.push(...e.slice(t+1,t+3)),s=[w,I]}}const a=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),l=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),g=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n);if(a){const[b,w,I]=a.slice(1,4),S={code:b,number:parseInt(w)};return new ah(S,I,i,e,void 0,s)}else if(l){const[b,w,I,S,x]=l.slice(1,6),C={code:I,number:parseInt(S)},H={file:b,line:parseInt(w)};return new ah(C,x,i,e,H,s)}else if(g){const[b,w,I,S]=g.slice(1,5),x=b,C={code:w,number:parseInt(I)};return new ah(C,S,i,e,x,s)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class tp extends Error{constructor(e,t,n){super(),this.code=e,this.msg=t,this.logs=n,n&&(this._programErrorStack=oh.parse(n))}static parse(e,t){const n=e.toString();let i;if(n.includes("custom program error:")){let a=n.split("custom program error: ");if(a.length!==2)return null;i=a[1]}else{const a=n.match(/"Custom":([0-9]+)}/g);if(!a||a.length>1)return null;i=a[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(i)}catch{return null}let o=t.get(s);return o!==void 0?new tp(s,o,e.logs):(o=PY.get(s),o!==void 0?new tp(s,o,e.logs):null)}get program(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack}toString(){return this.msg}}function Pk(r,e){Bk("debug-logs")&&console.log("Translating error:",r);const t=ah.parse(r.logs);if(t)return t;const n=tp.parse(r,e);if(n)return n;if(r.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[r.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return r.programErrorStack=oh.parse(r.logs),new Proxy(r,i)}return r}const ve={InstructionMissing:hS,InstructionFallbackNotFound:dS,InstructionDidNotDeserialize:pS,InstructionDidNotSerialize:gS,IdlInstructionStub:yS,IdlInstructionInvalidProgram:mS,IdlAccountNotEmpty:wS,EventInstructionStub:bS,ConstraintMut:_S,ConstraintHasOne:AS,ConstraintSigner:vS,ConstraintRaw:ES,ConstraintOwner:xS,ConstraintRentExempt:RS,ConstraintSeeds:IS,ConstraintExecutable:SS,ConstraintState:kS,ConstraintAssociated:TS,ConstraintAssociatedInit:OS,ConstraintClose:NS,ConstraintAddress:CS,ConstraintZero:BS,ConstraintTokenMint:PS,ConstraintTokenOwner:MS,ConstraintMintMintAuthority:LS,ConstraintMintFreezeAuthority:US,ConstraintMintDecimals:DS,ConstraintSpace:$S,ConstraintAccountIsNone:FS,ConstraintTokenTokenProgram:HS,ConstraintMintTokenProgram:zS,ConstraintAssociatedTokenTokenProgram:GS,ConstraintMintGroupPointerExtension:jS,ConstraintMintGroupPointerExtensionAuthority:KS,ConstraintMintGroupPointerExtensionGroupAddress:VS,ConstraintMintGroupMemberPointerExtension:WS,ConstraintMintGroupMemberPointerExtensionAuthority:qS,ConstraintMintGroupMemberPointerExtensionMemberAddress:ZS,ConstraintMintMetadataPointerExtension:QS,ConstraintMintMetadataPointerExtensionAuthority:YS,ConstraintMintMetadataPointerExtensionMetadataAddress:JS,ConstraintMintCloseAuthorityExtension:XS,ConstraintMintCloseAuthorityExtensionAuthority:ek,ConstraintMintPermanentDelegateExtension:tk,ConstraintMintPermanentDelegateExtensionDelegate:rk,ConstraintMintTransferHookExtension:nk,ConstraintMintTransferHookExtensionAuthority:ik,ConstraintMintTransferHookExtensionProgramId:sk,RequireViolated:ok,RequireEqViolated:lS,RequireKeysEqViolated:ak,RequireNeqViolated:ck,RequireKeysNeqViolated:uk,RequireGtViolated:lk,RequireGteViolated:fk,AccountDiscriminatorAlreadySet:hk,AccountDiscriminatorNotFound:dk,AccountDiscriminatorMismatch:pk,AccountDidNotDeserialize:gk,AccountDidNotSerialize:yk,AccountNotEnoughKeys:mk,AccountNotMutable:wk,AccountOwnedByWrongProgram:bk,InvalidProgramId:_k,InvalidProgramExecutable:Ak,AccountNotSigner:vk,AccountNotSystemOwned:Ek,AccountNotInitialized:xk,AccountNotProgramData:Rk,AccountNotAssociatedTokenAccount:Ik,AccountSysvarMismatch:Sk,AccountReallocExceedsLimit:kk,AccountDuplicateReallocs:Tk,DeclaredProgramIdMismatch:Ok,TryingToInitPayerAsProgramAccount:Nk,InvalidNumericConversion:Ck,Deprecated:fS},PY=new Map([[ve.InstructionMissing,"Instruction discriminator not provided"],[ve.InstructionFallbackNotFound,"Fallback functions are not supported"],[ve.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[ve.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[ve.IdlInstructionStub,"The program was compiled without idl instructions"],[ve.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[ve.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[ve.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[ve.ConstraintMut,"A mut constraint was violated"],[ve.ConstraintHasOne,"A has one constraint was violated"],[ve.ConstraintSigner,"A signer constraint was violated"],[ve.ConstraintRaw,"A raw constraint was violated"],[ve.ConstraintOwner,"An owner constraint was violated"],[ve.ConstraintRentExempt,"A rent exemption constraint was violated"],[ve.ConstraintSeeds,"A seeds constraint was violated"],[ve.ConstraintExecutable,"An executable constraint was violated"],[ve.ConstraintState,"Deprecated Error, feel free to replace with something else"],[ve.ConstraintAssociated,"An associated constraint was violated"],[ve.ConstraintAssociatedInit,"An associated init constraint was violated"],[ve.ConstraintClose,"A close constraint was violated"],[ve.ConstraintAddress,"An address constraint was violated"],[ve.ConstraintZero,"Expected zero account discriminant"],[ve.ConstraintTokenMint,"A token mint constraint was violated"],[ve.ConstraintTokenOwner,"A token owner constraint was violated"],[ve.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[ve.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[ve.ConstraintMintDecimals,"A mint decimals constraint was violated"],[ve.ConstraintSpace,"A space constraint was violated"],[ve.ConstraintAccountIsNone,"A required account for the constraint is None"],[ve.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[ve.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[ve.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[ve.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[ve.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[ve.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[ve.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[ve.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[ve.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[ve.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[ve.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[ve.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[ve.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[ve.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[ve.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[ve.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[ve.RequireViolated,"A require expression was violated"],[ve.RequireEqViolated,"A require_eq expression was violated"],[ve.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[ve.RequireNeqViolated,"A require_neq expression was violated"],[ve.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[ve.RequireGtViolated,"A require_gt expression was violated"],[ve.RequireGteViolated,"A require_gte expression was violated"],[ve.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[ve.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[ve.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[ve.AccountDidNotDeserialize,"Failed to deserialize the account"],[ve.AccountDidNotSerialize,"Failed to serialize the account"],[ve.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[ve.AccountNotMutable,"The given account is not mutable"],[ve.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[ve.InvalidProgramId,"Program ID was not as expected"],[ve.InvalidProgramExecutable,"Program account is not executable"],[ve.AccountNotSigner,"The given account did not sign"],[ve.AccountNotSystemOwned,"The given account is not owned by the system program"],[ve.AccountNotInitialized,"The program expected this account to be already initialized"],[ve.AccountNotProgramData,"The given account is not a program data account"],[ve.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[ve.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[ve.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[ve.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[ve.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[ve.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[ve.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[ve.Deprecated,"The API being used is deprecated and should no longer be used"]]);class mt{static fieldLayout(e,t=[],n){const i=e.name;switch(e.type){case"bool":return Xe.bool(i);case"u8":return Xe.u8(i);case"i8":return Xe.i8(i);case"u16":return Xe.u16(i);case"i16":return Xe.i16(i);case"u32":return Xe.u32(i);case"i32":return Xe.i32(i);case"f32":return Xe.f32(i);case"u64":return Xe.u64(i);case"i64":return Xe.i64(i);case"f64":return Xe.f64(i);case"u128":return Xe.u128(i);case"i128":return Xe.i128(i);case"u256":return Xe.u256(i);case"i256":return Xe.i256(i);case"bytes":return Xe.vecU8(i);case"string":return Xe.str(i);case"pubkey":return Xe.publicKey(i);default:{if("option"in e.type)return Xe.option(mt.fieldLayout({type:e.type.option},t,n),i);if("vec"in e.type)return Xe.vec(mt.fieldLayout({type:e.type.vec},t,n),i);if("array"in e.type){let[s,o]=e.type.array;return o=mt.resolveArrayLen(o,n),Xe.array(mt.fieldLayout({type:s},t,n),o,i)}if("defined"in e.type){if(!t)throw new Oo("User defined types not provided");const s=e.type.defined.name,o=t.find(a=>a.name===s);if(!o)throw new Oo(`Type not found: ${e.name}`);return mt.typeDefLayout({typeDef:o,types:t,genericArgs:n??e.type.defined.generics,name:i})}if("generic"in e.type){const s=n==null?void 0:n.at(0);if((s==null?void 0:s.kind)!=="type")throw new Oo(`Invalid generic field: ${e.name}`);return mt.fieldLayout({...e,type:s.type},t)}throw new Oo(`Not yet implemented: ${JSON.stringify(e.type)}`)}}}static typeDefLayout({typeDef:e,types:t,name:n,genericArgs:i}){switch(e.type.kind){case"struct":{const s=Iu(e.type.fields,()=>[],o=>o.map(a=>{const u=i&&mt.resolveGenericArgs({type:a.type,typeDef:e,genericArgs:i});return mt.fieldLayout(a,t,u)}),o=>o.map((a,u)=>{const l=i&&mt.resolveGenericArgs({type:a,typeDef:e,genericArgs:i});return mt.fieldLayout({name:u.toString(),type:a},t,l)}));return Xe.struct(s,n)}case"enum":{const s=e.type.variants.map(o=>{const a=Iu(o.fields,()=>[],u=>u.map(l=>{const h=i&&mt.resolveGenericArgs({type:l.type,typeDef:e,genericArgs:i});return mt.fieldLayout(l,t,h)}),u=>u.map((l,h)=>{const g=i&&mt.resolveGenericArgs({type:l,typeDef:e,genericArgs:i});return mt.fieldLayout({name:h.toString(),type:l},t,g)}));return Xe.struct(a,o.name)});return n!==void 0?Xe.rustEnum(s).replicate(n):Xe.rustEnum(s,n)}case"type":return mt.fieldLayout({type:e.type.alias,name:n},t)}}static typeSize(e,t,n){var i;switch(e){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in e)return 1+mt.typeSize(e.option,t,n);if("coption"in e)return 4+mt.typeSize(e.coption,t,n);if("vec"in e)return 1;if("array"in e){let[s,o]=e.array;return o=mt.resolveArrayLen(o,n),mt.typeSize(s,t,n)*o}if("defined"in e){const s=(i=t.types)===null||i===void 0?void 0:i.find(a=>a.name===e.defined.name);if(!s)throw new Oo(`Type not found: ${JSON.stringify(e)}`);const o=a=>{const u=n??e.defined.generics,l=u&&mt.resolveGenericArgs({type:a,typeDef:s,genericArgs:u});return mt.typeSize(a,t,l)};switch(s.type.kind){case"struct":return Iu(s.type.fields,()=>[0],a=>a.map(u=>o(u.type)),a=>a.map(u=>o(u))).reduce((a,u)=>a+u,0);case"enum":{const a=s.type.variants.map(u=>Iu(u.fields,()=>[0],l=>l.map(h=>o(h.type)),l=>l.map(h=>o(h))).reduce((l,h)=>l+h,0));return Math.max(...a)+1}case"type":return mt.typeSize(s.type.alias,t,n)}}if("generic"in e){const s=n==null?void 0:n.at(0);if((s==null?void 0:s.kind)!=="type")throw new Oo(`Invalid generic: ${e.generic}`);return mt.typeSize(s.type,t,n)}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}static resolveArrayLen(e,t){if(typeof e=="number")return e;if(t){const n=t.find(i=>i.kind==="const");(n==null?void 0:n.kind)==="const"&&(e=+n.value)}if(typeof e!="number")throw new Oo("Generic array length did not resolve");return e}static resolveGenericArgs({type:e,typeDef:t,genericArgs:n,isDefined:i}){if(typeof e!="object")return null;for(const s in t.generics){const o=t.generics[s];if("generic"in e&&o.name===e.generic)return[n[s]];if("option"in e){const a=mt.resolveGenericArgs({type:e.option,typeDef:t,genericArgs:n,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{option:a[0].type}}]}if("vec"in e){const a=mt.resolveGenericArgs({type:e.vec,typeDef:t,genericArgs:n,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{vec:a[0].type}}]}if("array"in e){const[a,u]=e.array,l=typeof u=="object",h=mt.resolveGenericArgs({type:a,typeDef:t,genericArgs:n,isDefined:i});if(h){for(const g in t.generics.slice(+s)){const b=+s+ +g;l&&t.generics[b].name===u.generic&&h.push(n[b])}if(!i)return h;if(h[0].kind==="type"&&h[1].kind==="const")return[{kind:"type",type:{array:[h[0].type,+h[1].value]}}]}if(l&&o.name===u.generic){const g=n[s];return i?[{kind:"type",type:{array:[a,+g.value]}}]:[g]}return null}if("defined"in e)return e.defined.generics?e.defined.generics.flatMap(a=>{switch(a.kind){case"type":return mt.resolveGenericArgs({type:a.type,typeDef:t,genericArgs:n,isDefined:!0});case"const":return[a]}}).filter(a=>a!==null):null}return null}}class MY{constructor(e){this.idl=e;const t=e.instructions.map(n=>{const i=n.name,s=n.args.map(a=>mt.fieldLayout(a,e.types)),o=Xe.struct(s,i);return[i,{discriminator:n.discriminator,layout:o}]});this.ixLayouts=new Map(t)}encode(e,t){const n=Ne.alloc(1e3),i=this.ixLayouts.get(e);if(!i)throw new Error(`Unknown method: ${e}`);const s=i.layout.encode(t,n),o=n.slice(0,s);return Ne.concat([Ne.from(i.discriminator),o])}decode(e,t="hex"){typeof e=="string"&&(e=t==="hex"?Ne.from(e,"hex"):Or.decode(e));for(const[n,i]of this.ixLayouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(Ne.from(i.discriminator)))return{name:n,data:i.layout.decode(e.subarray(s.length))}}return null}format(e,t){return Kn.format(e,t,this.idl)}}class Kn{static format(e,t,n){const i=n.instructions.find(u=>e.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:Kn.formatIdlType(u.type),data:Kn.formatIdlData(u,e.data[u.name],n.types)})),o=Kn.flattenIdlAccounts(i.accounts),a=t.map((u,l)=>l<o.length?{name:o[l].name,...u}:{name:void 0,...u});return{args:s,accounts:a}}static formatIdlType(e){if(typeof e=="string")return e;if("option"in e)return`Option<${this.formatIdlType(e.option)}>`;if("coption"in e)return`COption<${this.formatIdlType(e.coption)}>`;if("vec"in e)return`Vec<${this.formatIdlType(e.vec)}>`;if("array"in e)return`Array<${e.array[0]}; ${e.array[1]}>`;if("defined"in e){const t=e.defined.name;if(e.defined.generics){const n=e.defined.generics.map(i=>{switch(i.kind){case"type":return Kn.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${t}<${n}>`}return t}throw new Error(`Unknown IDL type: ${e}`)}static formatIdlData(e,t,n){if(typeof e.type=="string")return t.toString();if("vec"in e.type)return"["+t.map(i=>this.formatIdlData({name:"",type:e.type.vec},i,n)).join(", ")+"]";if("option"in e.type)return t===null?"null":this.formatIdlData({name:"",type:e.type.option},t,n);if("defined"in e.type){if(!n)throw new Error("User defined types not provided");const i=e.type.defined.name,s=n.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return Kn.formatIdlDataDefined(s,t,n)}return"unknown"}static formatIdlDataDefined(e,t,n){switch(e.type.kind){case"struct":return"{ "+Iu(e.type.fields,()=>"",i=>Object.entries(t).map(([s,o])=>{const a=i.find(u=>u.name===s);if(!a)throw new Error(`Field not found: ${s}`);return s+": "+Kn.formatIdlData(a,o,n)}).join(", "),i=>Object.entries(t).map(([s,o])=>s+": "+Kn.formatIdlData({name:"",type:i[s]},o,n)).join(", "))+" }";case"enum":{const i=Object.keys(t)[0],s=e.type.variants.find(a=>a.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=t[i];return Iu(s.fields,()=>i,a=>{const u=Object.keys(o).map(l=>{const h=o[l],g=a.find(b=>b.name===l);if(!g)throw new Error(`Field not found: ${l}`);return l+": "+Kn.formatIdlData(g,h,n)}).join(", ");return`${i} { ${u} }`},a=>{const u=Object.entries(o).map(([l,h])=>l+": "+Kn.formatIdlData({name:"",type:a[l]},h,n)).join(", ");return`${i} { ${u} }`})}case"type":return Kn.formatIdlType(e.type.alias)}}static flattenIdlAccounts(e,t){return e.map(n=>{const i=LY(n.name);if(n.hasOwnProperty("accounts")){const s=t?`${t} > ${i}`:i;return Kn.flattenIdlAccounts(n.accounts,s)}else return{...n,name:t?`${t} > ${i}`:i}}).flat()}}function LY(r){const e=r.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}class UY{constructor(e){if(this.idl=e,!e.accounts){this.accountLayouts=new Map;return}const t=e.types;if(!t)throw new Error("Accounts require `idl.types`");const n=e.accounts.map(i=>{const s=t.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:mt.typeDefLayout({typeDef:s,types:t})}]});this.accountLayouts=new Map(n)}async encode(e,t){const n=Ne.alloc(1e3),i=this.accountLayouts.get(e);if(!i)throw new Error(`Unknown account: ${e}`);const s=i.layout.encode(t,n),o=n.slice(0,s),a=this.accountDiscriminator(e);return Ne.concat([a,o])}decode(e,t){const n=this.accountDiscriminator(e);if(n.compare(t.slice(0,n.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(e,t)}decodeAny(e){for(const[t,n]of this.accountLayouts)if(e.subarray(0,n.discriminator.length).equals(Ne.from(n.discriminator)))return this.decodeUnchecked(t,e);throw new Error("Account not found")}decodeUnchecked(e,t){const n=this.accountDiscriminator(e),i=t.subarray(n.length),s=this.accountLayouts.get(e);if(!s)throw new Error(`Unknown account: ${e}`);return s.layout.decode(i)}memcmp(e,t){const n=this.accountDiscriminator(e);return{offset:0,bytes:Or.encode(t?Ne.concat([n,t]):n)}}size(e){return this.accountDiscriminator(e).length+mt.typeSize({defined:{name:e}},this.idl)}accountDiscriminator(e){var t;const n=(t=this.idl.accounts)===null||t===void 0?void 0:t.find(i=>i.name===e);if(!n)throw new Error(`Account not found: ${e}`);return Ne.from(n.discriminator)}}class DY{constructor(e){if(!e.events){this.layouts=new Map;return}const t=e.types;if(!t)throw new Error("Events require `idl.types`");const n=e.events.map(i=>{const s=t.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:mt.typeDefLayout({typeDef:s,types:t})}]});this.layouts=new Map(n)}decode(e){let t;try{t=eS(e)}catch{return null}for(const[n,i]of this.layouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(Ne.from(i.discriminator)))return{name:n,data:i.layout.decode(t.subarray(s.length))}}return null}}class $Y{constructor(e){const t=e.types;if(!t){this.typeLayouts=new Map;return}const n=t.filter(i=>!i.generics).map(i=>[i.name,mt.typeDefLayout({typeDef:i,types:t})]);this.typeLayouts=new Map(n)}encode(e,t){const n=Ne.alloc(1e3),i=this.typeLayouts.get(e);if(!i)throw new Error(`Unknown type: ${e}`);const s=i.encode(t,n);return n.slice(0,s)}decode(e,t){const n=this.typeLayouts.get(e);if(!n)throw new Error(`Unknown type: ${e}`);return n.decode(t)}}class Mk{constructor(e){this.instruction=new MY(e),this.accounts=new UY(e),this.events=new DY(e),this.types=new $Y(e)}}class Bn{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,n){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}var rp=Bn;function FY(r,e){return e.property?r+"["+e.property+"]":r}class za extends Bn{isCount(){throw new Error("ExternalLayout is abstract")}}class Lk extends za{constructor(e,t,n){if(!(e instanceof Bn))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof np||this.layout instanceof Uk}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,n){return n===void 0&&(n=0),this.layout.encode(e,t,n+this.offset)}}class np extends Bn{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntLE(e,n,this.span),this.span}}class Uk extends Bn{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntBE(e,n,this.span),this.span}}const X1=Math.pow(2,32);function Dk(r){const e=Math.floor(r/X1),t=r-e*X1;return{hi32:e,lo32:t}}function $k(r,e){return r*X1+e}class HY extends Bn{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readUInt32LE(t+4);return $k(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=Dk(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}}class zY extends Bn{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readInt32LE(t+4);return $k(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=Dk(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}}class GY extends Bn{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Bn,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t){t===void 0&&(t=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n){n===void 0&&(n=0);const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}}class Fk{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class Hk extends Fk{constructor(e,t){if(!(e instanceof za&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}}class zk extends Bn{constructor(e,t,n){const i=e instanceof np||e instanceof Uk;if(i)e=new Hk(new Lk(e));else if(e instanceof za&&e.isCount())e=new Hk(e);else if(!(e instanceof Fk))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Bn))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&i&&(s+=e.layout.span)),super(s,n),this.discriminator=e,this.usesPrefixDiscriminator=i,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(e.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let n;const i=this.discriminator,s=i.decode(e,t);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[o.property]=this.defaultLayout.decode(e,t+a)}else n=o.decode(e,t);return n}encode(e,t,n){n===void 0&&(n=0);const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new jY(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t){let n=e;return Ze.isBuffer(e)&&(t===void 0&&(t=0),n=this.discriminator.decode(e,t)),this.registry[n]}}class jY extends Bn{constructor(e,t,n,i){if(!(e instanceof zk))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Bn))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(e,t+n)}decode(e,t){const n=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}class KY extends Bn{constructor(e,t){if(!(e instanceof za&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof za||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t){t===void 0&&(t=0);let n=this.span;return 0>n&&(n=this.length.decode(e,t)),e.slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof za&&(i=e.length),!(Ze.isBuffer(e)&&i===e.length))throw new TypeError(FY("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),n,i,"hex"),this.length instanceof za&&this.length.encode(i,t,n),i}}var VY=(r,e,t)=>new Lk(r,e,t),WY=r=>new np(1,r),Ps=r=>new np(4,r),qY=r=>new HY(r),Ms=r=>new zY(r),Pr=(r,e,t)=>new GY(r,e,t),Gk=(r,e,t)=>new zk(r,e,t),ch=(r,e)=>new KY(r,e);class ZY extends rp{constructor(e){super(-1,e),this.property=e,this.layout=Pr([Ps("length"),Ps("lengthPadding"),ch(VY(Ps(),-8),"chars")],this.property)}encode(e,t,n=0){if(e==null)return this.layout.span;const i={chars:Ze.from(e,"utf8")};return this.layout.encode(i,t,n)}decode(e,t=0){return this.layout.decode(e,t).chars.toString()}getSpan(e,t=0){return Ps().span+Ps().span+new vs(new Uint8Array(e).slice(t,t+4),10,"le").toNumber()}}function ip(r){return new ZY(r)}function ai(r){return ch(32,r)}const Vn=Gk(Ps("instruction"));Vn.addVariant(0,Pr([Ms("lamports"),Ms("space"),ai("owner")]),"createAccount"),Vn.addVariant(1,Pr([ai("owner")]),"assign"),Vn.addVariant(2,Pr([Ms("lamports")]),"transfer"),Vn.addVariant(3,Pr([ai("base"),ip("seed"),Ms("lamports"),Ms("space"),ai("owner")]),"createAccountWithSeed"),Vn.addVariant(4,Pr([ai("authorized")]),"advanceNonceAccount"),Vn.addVariant(5,Pr([Ms("lamports")]),"withdrawNonceAccount"),Vn.addVariant(6,Pr([ai("authorized")]),"initializeNonceAccount"),Vn.addVariant(7,Pr([ai("authorized")]),"authorizeNonceAccount"),Vn.addVariant(8,Pr([Ms("space")]),"allocate"),Vn.addVariant(9,Pr([ai("base"),ip("seed"),Ms("space"),ai("owner")]),"allocateWithSeed"),Vn.addVariant(10,Pr([ai("base"),ip("seed"),ai("owner")]),"assignWithSeed"),Vn.addVariant(11,Pr([Ms("lamports"),ip("seed"),ai("owner")]),"transferWithSeed"),Math.max(...Object.values(Vn.registry).map(r=>r.span));class QY extends rp{constructor(e,t,n,i){super(e.span,i),this.layout=e,this.decoder=t,this.encoder=n}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,n){return this.layout.encode(this.encoder(e),t,n)}getSpan(e,t){return this.layout.getSpan(e,t)}}function jk(r){return new QY(ch(32),e=>new me(e),e=>e.toBuffer(),r)}Pr([Ps("version"),Ps("state"),jk("authorizedPubkey"),jk("nonce"),Pr([qY("lamportsPerSignature")],"feeCalculator")]),new me("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),new me("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var Kk={exports:{}};(function(r,e){var t=typeof self<"u"?self:CY,n=function(){function s(){this.fetch=!1,this.DOMException=t.DOMException}return s.prototype=t,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(p){return p&&DataView.prototype.isPrototypeOf(p)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(p){return p&&l.indexOf(Object.prototype.toString.call(p))>-1};function g(p){if(typeof p!="string"&&(p=String(p)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(p))throw new TypeError("Invalid character in header field name");return p.toLowerCase()}function b(p){return typeof p!="string"&&(p=String(p)),p}function w(p){var m={next:function(){var E=p.shift();return{done:E===void 0,value:E}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function I(p){this.map={},p instanceof I?p.forEach(function(m,E){this.append(E,m)},this):Array.isArray(p)?p.forEach(function(m){this.append(m[0],m[1])},this):p&&Object.getOwnPropertyNames(p).forEach(function(m){this.append(m,p[m])},this)}I.prototype.append=function(p,m){p=g(p),m=b(m);var E=this.map[p];this.map[p]=E?E+", "+m:m},I.prototype.delete=function(p){delete this.map[g(p)]},I.prototype.get=function(p){return p=g(p),this.has(p)?this.map[p]:null},I.prototype.has=function(p){return this.map.hasOwnProperty(g(p))},I.prototype.set=function(p,m){this.map[g(p)]=b(m)},I.prototype.forEach=function(p,m){for(var E in this.map)this.map.hasOwnProperty(E)&&p.call(m,this.map[E],E,this)},I.prototype.keys=function(){var p=[];return this.forEach(function(m,E){p.push(E)}),w(p)},I.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),w(p)},I.prototype.entries=function(){var p=[];return this.forEach(function(m,E){p.push([E,m])}),w(p)},a.iterable&&(I.prototype[Symbol.iterator]=I.prototype.entries);function S(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function x(p){return new Promise(function(m,E){p.onload=function(){m(p.result)},p.onerror=function(){E(p.error)}})}function C(p){var m=new FileReader,E=x(m);return m.readAsArrayBuffer(p),E}function H(p){var m=new FileReader,E=x(m);return m.readAsText(p),E}function D(p){for(var m=new Uint8Array(p),E=new Array(m.length),k=0;k<m.length;k++)E[k]=String.fromCharCode(m[k]);return E.join("")}function z(p){if(p.slice)return p.slice(0);var m=new Uint8Array(p.byteLength);return m.set(new Uint8Array(p)),m.buffer}function W(){return this.bodyUsed=!1,this._initBody=function(p){this._bodyInit=p,p?typeof p=="string"?this._bodyText=p:a.blob&&Blob.prototype.isPrototypeOf(p)?this._bodyBlob=p:a.formData&&FormData.prototype.isPrototypeOf(p)?this._bodyFormData=p:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)?this._bodyText=p.toString():a.arrayBuffer&&a.blob&&u(p)?(this._bodyArrayBuffer=z(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=z(p):this._bodyText=p=Object.prototype.toString.call(p):this._bodyText="",this.headers.get("content-type")||(typeof p=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var p=S(this);if(p)return p;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?S(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(C)}),this.text=function(){var p=S(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(oe)}),this.json=function(){return this.text().then(JSON.parse)},this}var Z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(p){var m=p.toUpperCase();return Z.indexOf(m)>-1?m:p}function V(p,m){m=m||{};var E=m.body;if(p instanceof V){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new I(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!E&&p._bodyInit!=null&&(E=p._bodyInit,p.bodyUsed=!0)}else this.url=String(p);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new I(m.headers)),this.method=j(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&E)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(E)}V.prototype.clone=function(){return new V(this,{body:this._bodyInit})};function oe(p){var m=new FormData;return p.trim().split("&").forEach(function(E){if(E){var k=E.split("="),O=k.shift().replace(/\+/g," "),M=k.join("=").replace(/\+/g," ");m.append(decodeURIComponent(O),decodeURIComponent(M))}}),m}function ce(p){var m=new I,E=p.replace(/\r?\n[\t ]+/g," ");return E.split(/\r?\n/).forEach(function(k){var O=k.split(":"),M=O.shift().trim();if(M){var G=O.join(":").trim();m.append(M,G)}}),m}W.call(V.prototype);function ie(p,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new I(m.headers),this.url=m.url||"",this._initBody(p)}W.call(ie.prototype),ie.prototype.clone=function(){return new ie(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new I(this.headers),url:this.url})},ie.error=function(){var p=new ie(null,{status:0,statusText:""});return p.type="error",p};var ue=[301,302,303,307,308];ie.redirect=function(p,m){if(ue.indexOf(m)===-1)throw new RangeError("Invalid status code");return new ie(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,E){this.message=m,this.name=E;var k=Error(m);this.stack=k.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function B(p,m){return new Promise(function(E,k){var O=new V(p,m);if(O.signal&&O.signal.aborted)return k(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function G(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ce(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var A="response"in M?M.response:M.responseText;E(new ie(A,P))},M.onerror=function(){k(new TypeError("Network request failed"))},M.ontimeout=function(){k(new TypeError("Network request failed"))},M.onabort=function(){k(new o.DOMException("Aborted","AbortError"))},M.open(O.method,O.url,!0),O.credentials==="include"?M.withCredentials=!0:O.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&a.blob&&(M.responseType="blob"),O.headers.forEach(function(P,A){M.setRequestHeader(A,P)}),O.signal&&(O.signal.addEventListener("abort",G),M.onreadystatechange=function(){M.readyState===4&&O.signal.removeEventListener("abort",G)}),M.send(typeof O._bodyInit>"u"?null:O._bodyInit)})}return B.polyfill=!0,s.fetch||(s.fetch=B,s.Headers=I,s.Request=V,s.Response=ie),o.Headers=I,o.Request=V,o.Response=ie,o.fetch=B,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,r.exports=e})(Kk,Kk.exports),Xe.rustEnum([Xe.struct([],"uninitialized"),Xe.struct([Xe.option(Xe.publicKey(),"authorityAddress")],"buffer"),Xe.struct([Xe.publicKey("programdataAddress")],"program"),Xe.struct([Xe.u64("slot"),Xe.option(Xe.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,Xe.u32());const ew="Program log: ",Vk="Program data: ",YY=ew.length,JY=Vk.length;class XY{constructor(e,t,n){this._programId=e,this._provider=t,this._eventParser=new Wk(e,n),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(e,t,n){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.set(e,((i=this._eventListeners.get(e))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[e,t]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,a)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const l=this._eventListeners.get(u.name);l&&l.forEach(h=>{const g=this._eventCallbacks.get(h);if(g){const[,b]=g;b(u.data,a.slot,o.signature)}})}},n)),s}async removeEventListener(e){const t=this._eventCallbacks.get(e);if(!t)throw new Error(`Event listener ${e} doesn't exist!`);const[n]=t;let i=this._eventListeners.get(n);if(!i)throw new Error(`Event listeners don't exist for ${n}!`);if(this._eventCallbacks.delete(e),i=i.filter(s=>s!==e),this._eventListeners.set(n,i),i.length===0&&this._eventListeners.delete(n),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class Wk{constructor(e,t){this.coder=t,this.programId=e}*parseLogs(e,t=!1){const n=new tJ(e),i=new eJ;let s=n.next();for(;s!==null;){let[o,a,u]=this.handleLog(i,s,t);o&&(yield o),a&&i.push(a),u&&i.pop(),s=n.next()}}handleLog(e,t,n){return e.stack.length>0&&e.program()===this.programId.toString()?this.handleProgramLog(t,n):[null,...this.handleSystemLog(t)]}handleProgramLog(e,t){if(e.startsWith(ew)||e.startsWith(Vk)){const n=e.startsWith(ew)?e.slice(YY):e.slice(JY),i=this.coder.events.decode(n);if(t&&i===null)throw new Error(`Unable to decode event ${n}`);return[i,null,!1]}else return[null,...this.handleSystemLog(e)]}handleSystemLog(e){const t=e.split(":")[0];return t.match(/^Program (.*) success/g)!==null?[null,!0]:t.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:t.includes("invoke")?["cpi",!1]:[null,!1]}}class eJ{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(e){this.stack.push(e)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class tJ{constructor(e){this.logs=e}next(){if(this.logs.length===0)return null;let e=this.logs[0];return this.logs=this.logs.slice(1),e}}function sp(r,e){var t,n;let i={};const s=r.args?r.args.length:0;if(e.length>s){if(e.length!==s+1)throw new Error(`provided too many arguments ${e} to instruction ${r==null?void 0:r.name} expecting: ${(n=(t=r.args)===null||t===void 0?void 0:t.map(o=>o.name))!==null&&n!==void 0?n:[]}`);i=e.pop()}return[e,i]}class op{static build(e,t,n){if(e.name==="_inner")throw new Oo("the _inner name is reserved");const i=(...s)=>{const[o,a]=sp(e,[...s]);tS(e.accounts,a.accounts),rJ(e,...s);const u=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&u.push(...a.remainingAccounts),Bk("debug-logs")&&console.log("Outgoing account metas:",u),new Pt({keys:u,programId:n,data:t(e.name,gY(e,...o))})};return i.accounts=s=>op.accountsArray(s,e.accounts,n,e.name),i}static accountsArray(e,t,n,i){return e?t.map(s=>{if(Io(s)){const h=e[s.name];return op.accountsArray(h,s.accounts,n,i).flat()}let o;try{o=xi(e[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const a=s.optional&&o.equals(n),u=!!(s.writable&&!a),l=!!(s.signer&&!a);return{pubkey:o,isWritable:u,isSigner:l}}).flat():[]}}function rJ(r,...e){}class nJ{static build(e,t){return(...i)=>{var s,o,a;const[,u]=sp(e,[...i]),l=new Ot;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>l.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>l.add(h)),l.add(t(...i)),(a=u.postInstructions)===null||a===void 0||a.forEach(h=>l.add(h)),l}}}class iJ{static build(e,t,n,i){return async(...o)=>{var a;const u=t(...o),[,l]=sp(e,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(a=l.signers)!==null&&a!==void 0?a:[],l.options)}catch(h){throw Pk(h,n)}}}}class sJ{static build(e,t,n,i){var s;return((s=e.accounts)!==null&&s!==void 0?s:[]).reduce((o,a)=>(o[a.name]=new oJ(e,a,n,i,t),o),{})}}class oJ{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(e,t,n,i,s){this._idlAccount=t,this._programId=n,this._provider=i??J1(),this._coder=s??new Mk(e),this._size=this._coder.accounts.size(t.name)}async fetchNullable(e,t){const{data:n}=await this.fetchNullableAndContext(e,t);return n}async fetchNullableAndContext(e,t){const n=await this.getAccountInfoAndContext(e,t),{value:i,context:s}=n;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(e,t){const{data:n}=await this.fetchNullableAndContext(e,t);if(n===null)throw new Error(`Account does not exist or has no data ${e.toString()}`);return n}async fetchAndContext(e,t){const{data:n,context:i}=await this.fetchNullableAndContext(e,t);if(n===null)throw new Error(`Account does not exist ${e.toString()}`);return{data:n,context:i}}async fetchMultiple(e,t){return(await this.fetchMultipleAndContext(e,t)).map(i=>i?i.data:null)}async fetchMultipleAndContext(e,t){return(await RY(this._provider.connection,e.map(i=>xi(i)),t)).map(i=>{if(i==null)return null;const{account:s,context:o}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:o}})}async all(e){const t=this.coder.accounts.memcmp(this._idlAccount.name,e instanceof Ze?e:void 0),n=[];return(t==null?void 0:t.offset)!=null&&(t==null?void 0:t.bytes)!=null&&n.push({memcmp:{offset:t.offset,bytes:t.bytes}}),(t==null?void 0:t.dataSize)!=null&&n.push({dataSize:t.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...n,...Array.isArray(e)?e:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(e,t){const n=uh.get(e.toString());if(n)return n.ee;const i=new oY;e=xi(e);const s=this._provider.connection.onAccountChange(e,o=>{const a=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",a)},t);return uh.set(e.toString(),{ee:i,listener:s}),i}async unsubscribe(e){let t=uh.get(e.toString());if(!t){console.warn("Address is not subscribed");return}uh&&await this._provider.connection.removeAccountChangeListener(t.listener).then(()=>{uh.delete(e.toString())}).catch(console.error)}async createInstruction(e,t){const n=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Br.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:e.publicKey,space:t??n,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(t??n),programId:this._programId})}async getAccountInfo(e,t){return await this._provider.connection.getAccountInfo(xi(e),t)}async getAccountInfoAndContext(e,t){return await this._provider.connection.getAccountInfoAndContext(xi(e),t)}}const uh=new Map;class aJ{static build(e,t,n,i,s,o,a){return async(...l)=>{var h;const g=t(...l),[,b]=sp(e,[...l]);let w;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{w=await i.simulate(g,b.signers,(h=b.options)===null||h===void 0?void 0:h.commitment)}catch(x){throw Pk(x,n)}if(w===void 0)throw new Error("Unable to simulate transaction");const I=w.logs;if(!I)throw new Error("Simulated logs not found");const S=[];if(a.events){let x=new Wk(o,s);for(const C of x.parseLogs(I))S.push(C)}return{events:S,raw:I}}}}function tw(r){return new qk(ch(8),e=>uJ.fromBuffer(e),e=>e.toBuffer(),r)}function ap(r){return new qk(ch(32),e=>new me(e),e=>e.toBuffer(),r)}function rw(r,e){return new cJ(r,e)}class qk extends rp{constructor(e,t,n,i){super(e.span,i),this.layout=e,this.decoder=t,this.encoder=n}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,n){return this.layout.encode(this.encoder(e),t,n)}getSpan(e,t){return this.layout.getSpan(e,t)}}class cJ extends rp{constructor(e,t){super(-1,t),this.layout=e,this.discriminator=Ps()}encode(e,t,n=0){return e==null?this.layout.span+this.discriminator.encode(0,t,n):(this.discriminator.encode(1,t,n),this.layout.encode(e,t,n+4)+4)}decode(e,t=0){const n=this.discriminator.decode(e,t);if(n===0)return null;if(n===1)return this.layout.decode(e,t+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(e,t=0){return this.layout.getSpan(e,t+4)+4}}let uJ=class l6 extends vs{toBuffer(){const e=super.toArray().reverse(),t=Ze.from(e);if(t.length===8)return t;if(t.length>=8)throw new Error("u64 too large");const n=Ze.alloc(8);return t.copy(n),n}static fromBuffer(e){if(e.length!==8)throw new Error(`Invalid buffer length: ${e.length}`);return new l6([...e].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}};const lJ=Pr([ap("mint"),ap("owner"),tw("amount"),rw(ap(),"delegate"),(r=>{const e=Gk(WY("discriminator"),null,r);return e.addVariant(0,Pr([]),"uninitialized"),e.addVariant(1,Pr([]),"initialized"),e.addVariant(2,Pr([]),"frozen"),e})("state"),rw(tw(),"isNative"),tw("delegatedAmount"),rw(ap(),"closeAuthority")]);function fJ(r){return lJ.decode(r)}class hJ{constructor(e,t,n,i,s,o,a,u){this._args=e,this._accounts=t,this._provider=n,this._programId=i,this._idlIx=s,this._idlTypes=a,this._customResolver=u,this._accountStore=new dJ(n,o,i)}args(e){this._args=e}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let e=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(e++,e===16){const t=o=>Io(o)?o.accounts.some(t):!!(o.address||o.pda||o.relations),n=(o,a=[],u=[])=>{for(const l of o)Io(l)?u.push(...n(l.accounts,[...a,l.name])):u.push([...a,l.name]);return u},i=this._idlIx.accounts.filter(t),s=n(i).filter(o=>!this.get(o)).map(o=>o.reduce((a,u)=>a+"."+u)).map(o=>`\`${o}\``).join(", ");throw new Error(["Reached maximum depth for account resolution.",`Unresolved accounts: ${s}`].join(" "))}}resolveOptionals(e){Object.assign(this._accounts,this.resolveOptionalsHelper(e,this._idlIx.accounts))}get(e){const t=e.reduce((n,i)=>n&&n[i],this._accounts);if(t&&t.toBase58)return t}set(e,t){let n=this._accounts;e.forEach((i,s)=>{var o;s===e.length-1&&(n[i]=t),n[i]=(o=n[i])!==null&&o!==void 0?o:{},n=n[i]})}resolveOptionalsHelper(e,t){const n={};for(const i of t){const s=i.name,o=e[s];o!==void 0&&(Zk(o)?Io(i)?n[s]=this.resolveOptionalsHelper(o,i.accounts):n[s]=Qk(o):o!==null?n[s]=xi(o):i.optional&&(n[s]=this._programId))}return n}async resolveCustom(){if(this._customResolver){const{accounts:e,resolved:t}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=e,t}return 0}resolveEventCpi(e,t=[]){for(const n in e){const i=e[n];Io(i)&&this.resolveEventCpi(i.accounts,[...t,i.name]);const s=+n+1;if(s===e.length)return;const o=e[n].name,a=e[s].name;if(o==="eventAuthority"&&a==="program"){const u=[...t,o],l=[...t,a];this.get(u)||this.set(u,me.findProgramAddressSync([Ze.from("__event_authority")],this._programId)[0]),this.get(l)||this.set(l,this._programId);return}}}resolveConst(e,t=[]){for(const n of e){const i=n.name;if(Io(n))this.resolveConst(n.accounts,[...t,i]);else{const s=n;if((s.signer||s.address)&&!this.get([...t,i])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...t,i],this._provider.wallet.publicKey)}s.address&&this.set([...t,i],xi(s.address))}}}}async resolvePdasAndRelations(e,t=[]){let n=0;for(const i of e){const s=i.name;if(Io(i))n+=await this.resolvePdasAndRelations(i.accounts,[...t,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...t,s])){n++;try{if(o.pda){const a=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,t)));if(a.some(h=>!h))continue;const u=await this.parseProgramId(o,t),[l]=me.findProgramAddressSync(a,u);this.set([...t,s],l)}}catch{}try{if(o.relations){const a=this.get([...t,o.relations[0]]);if(a){const u=await this._accountStore.fetchAccount({publicKey:a});this.set([...t,s],u[s])}}}catch{}}}}return n}async parseProgramId(e,t=[]){var n;if(!(!((n=e.pda)===null||n===void 0)&&n.program))return this._programId;const i=await this.toBuffer(e.pda.program,t);if(!i)throw new Error(`Program seed not resolved: ${e.name}`);return new me(i)}async toBuffer(e,t=[]){switch(e.kind){case"const":return this.toBufferConst(e);case"arg":return await this.toBufferArg(e);case"account":return await this.toBufferAccount(e,t);default:throw new Error(`Unexpected seed: ${e}`)}}toBufferConst(e){return this.toBufferValue("bytes",e.value)}async toBufferArg(e){const[t,...n]=e.path.split("."),i=this._idlIx.args.findIndex(a=>a.name===t);if(i===-1)throw new Error(`Unable to find argument for seed: ${t}`);const s=n.reduce((a,u)=>(a??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,n);return this.toBufferValue(o,s)}async toBufferAccount(e,t=[]){const[n,...i]=e.path.split("."),s=this.get([...t,n]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!e.account)throw new Error(`Seed account is required in order to resolve type: ${e.path}`);let a=await this._accountStore.fetchAccount({publicKey:s,name:e.account}),u=i;for(;u.length>0;)a=a[u[0]],u=u.slice(1);if(a===void 0)return;const l=this.getType({defined:{name:e.account}},i);return this.toBufferValue(l,a)}toBufferValue(e,t){switch(e){case"u8":case"i8":return Ze.from([t]);case"u16":case"i16":return new vs(t).toArrayLike(Ze,"le",2);case"u32":case"i32":return new vs(t).toArrayLike(Ze,"le",4);case"u64":case"i64":return new vs(t).toArrayLike(Ze,"le",8);case"u128":case"i128":return new vs(t).toArrayLike(Ze,"le",16);case"u256":case"i256":return new vs(t).toArrayLike(Ze,"le",32);case"string":return Ze.from(t);case"pubkey":return t.toBuffer();case"bytes":return Ze.from(t);default:if(e!=null&&e.array)return Ze.from(t);throw new Error(`Unexpected seed type: ${e}`)}}getType(e,t=[]){var n;const i=(n=e==null?void 0:e.defined)===null||n===void 0?void 0:n.name;if(i){if(i==="tokenAccount")switch(t.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${t}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...a]=t,l=s.type.fields.find(h=>h.name===o);if(!l)throw new Error(`Field not found: ${o}`);return this.getType(l.type,a)}return e}}class dJ{constructor(e,t,n){this._provider=e,this._cache=new Map,this._idls={},this._idls[n.toBase58()]=t}async fetchAccount({publicKey:e,name:t}){const n=e.toBase58();if(!this._cache.has(n)){const i=await this._provider.connection.getAccountInfo(e);if(i===null)throw new Error(`Account not found: ${n}`);if(t==="tokenAccount"){const s=fJ(i.data);this._cache.set(n,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const a=o.coder.accounts.decodeAny(i.data);this._cache.set(n,a)}}}}return this._cache.get(n)}async getAccountsNs(e){const t=e.toBase58();if(!this._idls[t]){const n=await ku.fetchIdl(e,this._provider);if(n){const i=new ku(n,this._provider);this._idls[t]=i.account}}return this._idls[t]}}class pJ{static build(e,t,n,i,s,o,a,u,l,h,g){return(...b)=>new gJ(b,i,s,o,a,u,e,t,n,l,h,g)}}function Zk(r){return typeof r=="object"&&r!==null&&!("_bn"in r)}function Qk(r,e){const t={};for(const n in r){const i=r[n];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");t[n]=Zk(i)?Qk(i):xi(i)}return t}class gJ{constructor(e,t,n,i,s,o,a,u,l,h,g,b){this._args=e,this._ixFn=t,this._txFn=n,this._rpcFn=i,this._simulateFn=s,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new hJ(e,this._accounts,a,u,l,h,g,b)}args(e){this._args=e,this._accountsResolver.args(e)}accounts(e){return this.accountsPartial(e)}accountsPartial(e){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(e),this}accountsStrict(e){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(e),this}signers(e){return this._signers=this._signers.concat(e),this}remainingAccounts(e){return this._remainingAccounts=this._remainingAccounts.concat(e),this}preInstructions(e,t=!1){return t?this._preInstructions=e.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(e),this}postInstructions(e){return this._postInstructions=this._postInstructions.concat(e),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(e){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async view(e){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error(["Method does not support views.","The instruction should return a value, and its accounts must be read-only"].join(" "));return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async rpc(e){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async rpcAndKeys(e){return{signature:await this.rpc(e),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class yJ{static build(e,t,n,i){const s=t.accounts.find(u=>u.writable),o=!!t.returns;return s||!o?void 0:async(...u)=>{let l=await n(...u);const h=`Program return: ${e} `;let g=l.raw.find(S=>S.startsWith(h));if(!g)throw new Error("View expected return log");let b=eS(g.slice(h.length)),w=t.returns;if(!w)throw new Error("View expected return type");return mt.fieldLayout({type:w},i.types).decode(b)}}}class mJ{static build(e,t,n,i,s){const o={},a={},u={},l={},h={},g={},b=pY(e),w=e.accounts?sJ.build(e,t,n,i):{};return e.instructions.forEach(I=>{const S=op.build(I,(Z,j)=>t.instruction.encode(Z,j),n),x=nJ.build(I,S),C=iJ.build(I,x,b,i),H=aJ.build(I,x,b,i,t,n,e),D=yJ.build(n,I,H,e),z=pJ.build(i,n,I,S,x,C,H,D,w,e.types||[],s==null?void 0:s(I)),W=I.name;a[W]=S,u[W]=x,o[W]=C,l[W]=H,h[W]=z,D&&(g[W]=D)}),[o,a,u,w,l,h,g]}}class ku{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(e,t=J1(),n,i){this._idl=dY(e),this._rawIdl=e,this._provider=t,this._programId=xi(e.address),this._coder=n??new Mk(this._idl),this._events=new XY(this._programId,t,this._coder);const[s,o,a,u,l,h,g]=mJ.build(this._idl,this._coder,this._programId,t,i);this.rpc=s,this.instruction=o,this.transaction=a,this.account=u,this.simulate=l,this.methods=h,this.views=g}static async at(e,t){const n=xi(e),i=await ku.fetchIdl(n,t);if(!i)throw new Error(`IDL not found for program: ${e.toString()}`);return new ku(i,t)}static async fetchIdl(e,t){t=t??J1();const n=xi(e),i=await uY(n),s=await t.connection.getAccountInfo(i);if(!s)return null;let o=hY(s.data.slice(8));const a=iY(o.data);return JSON.parse(cY(a))}addEventListener(e,t,n){return this._events.addEventListener(e,t,n)}async removeEventListener(e){return await this._events.removeEventListener(e)}}new me("11111111111111111111111111111111");const wJ="6.13.5";function bJ(r,e,t){const n=e.split("|").map(s=>s.trim());for(let s=0;s<n.length;s++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${t}`,i.value=r,i}async function mn(r){const e=Object.keys(r);return(await Promise.all(e.map(n=>Promise.resolve(r[n])))).reduce((n,i,s)=>(n[e[s]]=i,n),{})}function ze(r,e,t){for(let n in e){let i=e[n];const s=t?t[n]:null;s&&bJ(i,s,n),Object.defineProperty(r,n,{enumerable:!0,value:i,writable:!1})}}function Tu(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(Tu).join(", ")+" ]";if(r instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let n=0;n<r.length;n++)t+=e[r[n]>>4],t+=e[r[n]&15];return t}if(typeof r=="object"&&typeof r.toJSON=="function")return Tu(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const e=Object.keys(r);return e.sort(),"{ "+e.map(t=>`${Tu(t)}: ${Tu(r[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Qr(r,e){return r&&r.code===e}function nw(r){return Qr(r,"CALL_EXCEPTION")}function Yt(r,e,t){let n=r;{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Tu(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];s.push(o+"="+Tu(a))}}s.push(`code=${e}`),s.push(`version=${wJ}`),s.length&&(r+=" ("+s.join(", ")+")")}let i;switch(e){case"INVALID_ARGUMENT":i=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(r);break;default:i=new Error(r)}return ze(i,{code:e}),t&&Object.assign(i,t),i.shortMessage==null&&ze(i,{shortMessage:n}),i}function ge(r,e,t,n){if(!r)throw Yt(e,t,n)}function q(r,e,t,n){ge(r,e,"INVALID_ARGUMENT",{argument:t,value:n})}function Yk(r,e,t){t==null&&(t=""),t&&(t=": "+t),ge(r>=e,"missing argument"+t,"MISSING_ARGUMENT",{count:r,expectedCount:e}),ge(r<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((r,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(e)}catch{}return r},[]);function cp(r,e,t){if(t==null&&(t=""),r!==e){let n=t,i="new";t&&(n+=".",i+=" "+t),ge(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function Jk(r,e,t){if(r instanceof Uint8Array)return t?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let i=2;for(let s=0;s<n.length;s++)n[s]=parseInt(r.substring(i,i+2),16),i+=2;return n}q(!1,"invalid BytesLike value",e||"value",r)}function _t(r,e){return Jk(r,e,!1)}function wn(r,e){return Jk(r,e,!0)}function Gt(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&r.length!==2+2*e||e===!0&&r.length%2!==0)}function iw(r){return Gt(r,!0)||r instanceof Uint8Array}const Xk="0123456789abcdef";function Ce(r){const e=_t(r);let t="0x";for(let n=0;n<e.length;n++){const i=e[n];t+=Xk[(i&240)>>4]+Xk[i&15]}return t}function xr(r){return"0x"+r.map(e=>Ce(e).substring(2)).join("")}function Ou(r){return Gt(r,!0)?(r.length-2)/2:_t(r).length}function lr(r,e,t){const n=_t(r);return t!=null&&t>n.length&&ge(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),Ce(n.slice(e??0,t??n.length))}function eT(r,e,t){const n=_t(r);ge(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),t?i.set(n,e-n.length):i.set(n,0),Ce(i)}function Ga(r,e){return eT(r,e,!0)}function _J(r,e){return eT(r,e,!1)}const up=BigInt(0),Ri=BigInt(1),Nu=9007199254740991;function AJ(r,e){const t=lp(r,"value"),n=BigInt(at(e,"width"));if(ge(t>>n===up,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),t>>n-Ri){const i=(Ri<<n)-Ri;return-((~t&i)+Ri)}return t}function tT(r,e){let t=Le(r,"value");const n=BigInt(at(e,"width")),i=Ri<<n-Ri;if(t<up){t=-t,ge(t<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const s=(Ri<<n)-Ri;return(~t&s)+Ri}else ge(t<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return t}function lh(r,e){const t=lp(r,"value"),n=BigInt(at(e,"bits"));return t&(Ri<<n)-Ri}function Le(r,e){switch(typeof r){case"bigint":return r;case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-Nu&&r<=Nu,"overflow",e||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(t){q(!1,`invalid BigNumberish string: ${t.message}`,e||"value",r)}}q(!1,"invalid BigNumberish value",e||"value",r)}function lp(r,e){const t=Le(r,e);return ge(t>=up,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),t}const rT="0123456789abcdef";function sw(r){if(r instanceof Uint8Array){let e="0x0";for(const t of r)e+=rT[t>>4],e+=rT[t&15];return BigInt(e)}return Le(r)}function at(r,e){switch(typeof r){case"bigint":return q(r>=-Nu&&r<=Nu,"overflow",e||"value",r),Number(r);case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-Nu&&r<=Nu,"overflow",e||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return at(BigInt(r),e)}catch(t){q(!1,`invalid numeric string: ${t.message}`,e||"value",r)}}q(!1,"invalid numeric value",e||"value",r)}function vJ(r){return at(sw(r))}function No(r,e){let n=lp(r,"value").toString(16);if(e==null)n.length%2&&(n="0"+n);else{const i=at(e,"width");for(ge(i*2>=n.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<i*2;)n="0"+n}return"0x"+n}function bn(r){const e=lp(r,"value");if(e===up)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const n=new Uint8Array(t.length/2);for(let i=0;i<n.length;i++){const s=i*2;n[i]=parseInt(t.substring(s,s+2),16)}return n}function Cu(r){let e=Ce(iw(r)?r:bn(r)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const nT="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const iT=BigInt(58);function EJ(r){const e=_t(r);let t=sw(e),n="";for(;t;)n=nT[Number(t%iT)]+n,t/=iT;for(let i=0;i<e.length&&!e[i];i++)n=nT[0]+n;return n}function xJ(r){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return _t(e)}function RJ(r){const e=_t(r);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}class sT{constructor(e,t,n){Q(this,"filter");Q(this,"emitter");se(this,Zu);F(this,Zu,t),ze(this,{emitter:e,filter:n})}async removeListener(){T(this,Zu)!=null&&await this.emitter.off(this.filter,T(this,Zu))}}Zu=new WeakMap;function IJ(r,e,t,n,i){q(!1,`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function oT(r,e,t,n,i){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let s=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)s++;return s}return r==="OVERRUN"?t.length-e-1:0}function SJ(r,e,t,n,i){return r==="OVERLONG"?(q(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),oT(r,e,t))}const kJ=Object.freeze({error:IJ,ignore:oT,replace:SJ});function TJ(r,e){e==null&&(e=kJ.error);const t=_t(r,"bytes"),n=[];let i=0;for(;i<t.length;){const s=t[i++];if(!(s>>7)){n.push(s);continue}let o=null,a=null;if((s&224)===192)o=1,a=127;else if((s&240)===224)o=2,a=2047;else if((s&248)===240)o=3,a=65535;else{(s&192)===128?i+=e("UNEXPECTED_CONTINUE",i-1,t,n):i+=e("BAD_PREFIX",i-1,t,n);continue}if(i-1+o>=t.length){i+=e("OVERRUN",i-1,t,n);continue}let u=s&(1<<8-o-1)-1;for(let l=0;l<o;l++){let h=t[i];if((h&192)!=128){i+=e("MISSING_CONTINUE",i,t,n),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=e("OUT_OF_RANGE",i-1-o,t,n,u);continue}if(u>=55296&&u<=57343){i+=e("UTF16_SURROGATE",i-1-o,t,n,u);continue}if(u<=a){i+=e("OVERLONG",i-1-o,t,n,u);continue}n.push(u)}}return n}function Ls(r,e){q(typeof r=="string","invalid string value","str",r);let t=[];for(let n=0;n<r.length;n++){const i=r.charCodeAt(n);if(i<128)t.push(i);else if(i<2048)t.push(i>>6|192),t.push(i&63|128);else if((i&64512)==55296){n++;const s=r.charCodeAt(n);q(n<r.length&&(s&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((i&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return new Uint8Array(t)}function OJ(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function fp(r,e){return OJ(TJ(r,e))}function aT(r){async function e(t,n){ge(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const i=t.url.split(":")[0].toLowerCase();ge(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),ge(i==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,a=setTimeout(()=>{s=Yt("request timeout","TIMEOUT"),o.abort()},t.timeout);n&&n.addListener(()=>{s=Yt("request cancelled","CANCELLED"),o.abort()});const u={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let l;try{l=await fetch(t.url,u)}catch(w){throw clearTimeout(a),s||w}clearTimeout(a);const h={};l.headers.forEach((w,I)=>{h[I.toLowerCase()]=w});const g=await l.arrayBuffer(),b=g==null?null:new Uint8Array(g);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:b}}return e}const NJ=12,CJ=250;let cT=aT();const BJ=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),PJ=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let ow=!1;async function uT(r,e){try{const t=r.match(BJ);if(!t)throw new Error("invalid data");return new Co(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?xJ(t[3]):LJ(t[3]))}catch{return new Co(599,"BAD REQUEST (invalid data: URI)",{},null,new Us(r))}}function lT(r){async function e(t,n){try{const i=t.match(PJ);if(!i)throw new Error("invalid link");return new Us(`${r}${i[2]}`)}catch{return new Co(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Us(t))}}return e}const hp={data:uT,ipfs:lT("https://gateway.ipfs.io/ipfs/")},fT=new WeakMap;class MJ{constructor(e){se(this,ic);se(this,$o);F(this,ic,[]),F(this,$o,!1),fT.set(e,()=>{if(!T(this,$o)){F(this,$o,!0);for(const t of T(this,ic))setTimeout(()=>{t()},0);F(this,ic,[])}})}addListener(e){ge(!T(this,$o),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,ic).push(e)}get cancelled(){return T(this,$o)}checkSignal(){ge(!this.cancelled,"cancelled","CANCELLED",{})}}ic=new WeakMap,$o=new WeakMap;function dp(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}const qp=class qp{constructor(e){se(this,cc);se(this,Qu);se(this,Yu);se(this,Oi);se(this,Ks);se(this,Ju);se(this,Xu);se(this,Hr);se(this,qn);se(this,Vs);se(this,sc);se(this,oc);se(this,ac);se(this,as);se(this,Ni);se(this,Fo);F(this,Xu,String(e)),F(this,Qu,!1),F(this,Yu,!0),F(this,Oi,{}),F(this,Ks,""),F(this,Ju,3e5),F(this,Ni,{slotInterval:CJ,maxAttempts:NJ}),F(this,Fo,null)}get url(){return T(this,Xu)}set url(e){F(this,Xu,String(e))}get body(){return T(this,Hr)==null?null:new Uint8Array(T(this,Hr))}set body(e){if(e==null)F(this,Hr,void 0),F(this,qn,void 0);else if(typeof e=="string")F(this,Hr,Ls(e)),F(this,qn,"text/plain");else if(e instanceof Uint8Array)F(this,Hr,e),F(this,qn,"application/octet-stream");else if(typeof e=="object")F(this,Hr,Ls(JSON.stringify(e))),F(this,qn,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,Hr)!=null}get method(){return T(this,Ks)?T(this,Ks):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),F(this,Ks,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,Oi));return T(this,Vs)&&(e.authorization=`Basic ${RJ(Ls(T(this,Vs)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,qn)&&(e["content-type"]=T(this,qn)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,Oi)[String(e).toLowerCase()]=String(t)}clearHeaders(){F(this,Oi,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const i=t[n++];return{value:[i,e[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Vs)||null}setCredentials(e,t){q(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),F(this,Vs,`${e}:${t}`)}get allowGzip(){return T(this,Yu)}set allowGzip(e){F(this,Yu,!!e)}get allowInsecureAuthentication(){return!!T(this,Qu)}set allowInsecureAuthentication(e){F(this,Qu,!!e)}get timeout(){return T(this,Ju)}set timeout(e){q(e>=0,"timeout must be non-zero","timeout",e),F(this,Ju,e)}get preflightFunc(){return T(this,sc)||null}set preflightFunc(e){F(this,sc,e)}get processFunc(){return T(this,oc)||null}set processFunc(e){F(this,oc,e)}get retryFunc(){return T(this,ac)||null}set retryFunc(e){F(this,ac,e)}get getUrlFunc(){return T(this,Fo)||cT}set getUrlFunc(e){F(this,Fo,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,Hr)?Ce(T(this,Hr)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,Ni).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,Ni).maxAttempts=e.maxAttempts)}send(){return ge(T(this,as)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),F(this,as,new MJ(this)),Ee(this,cc,_d).call(this,0,hT()+this.timeout,0,this,new Co(0,"",{},null,this))}cancel(){ge(T(this,as)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=fT.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();ge(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const i=new qp(e);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,F(i,Oi,Object.assign({},T(this,Oi))),T(this,Hr)&&F(i,Hr,new Uint8Array(T(this,Hr))),F(i,qn,T(this,qn)),i}clone(){const e=new qp(this.url);return F(e,Ks,T(this,Ks)),T(this,Hr)&&F(e,Hr,T(this,Hr)),F(e,qn,T(this,qn)),F(e,Oi,Object.assign({},T(this,Oi))),F(e,Vs,T(this,Vs)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),F(e,sc,T(this,sc)),F(e,oc,T(this,oc)),F(e,ac,T(this,ac)),F(e,Ni,Object.assign({},T(this,Ni))),F(e,Fo,T(this,Fo)),e}static lockConfig(){ow=!0}static getGateway(e){return hp[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(ow)throw new Error("gateways locked");hp[e]=t}static registerGetUrl(e){if(ow)throw new Error("gateways locked");cT=e}static createGetUrlFunc(e){return aT()}static createDataGateway(){return uT}static createIpfsGatewayFunc(e){return lT(e)}};Qu=new WeakMap,Yu=new WeakMap,Oi=new WeakMap,Ks=new WeakMap,Ju=new WeakMap,Xu=new WeakMap,Hr=new WeakMap,qn=new WeakMap,Vs=new WeakMap,sc=new WeakMap,oc=new WeakMap,ac=new WeakMap,as=new WeakMap,Ni=new WeakMap,Fo=new WeakMap,cc=new WeakSet,_d=async function(e,t,n,i,s){var h,g,b;if(e>=T(this,Ni).maxAttempts)return s.makeServerError("exceeded maximum retry limit");ge(hT()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),n>0&&await UJ(n);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in hp){const w=await hp[a](o.url,dp(T(i,as)));if(w instanceof Co){let I=w;if(this.processFunc){dp(T(i,as));try{I=await this.processFunc(o,I)}catch(S){(S.throttle==null||typeof S.stall!="number")&&I.makeServerError("error in post-processing function",S).assertOk()}}return I}o=w}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,dp(T(i,as)));let l=new Co(u.statusCode,u.statusMessage,u.headers,u.body,i);if(l.statusCode===301||l.statusCode===302){try{const w=l.headers.location||"";return Ee(h=o.redirect(w),cc,_d).call(h,e+1,t,0,i,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,l,e))){const w=l.headers["retry-after"];let I=T(this,Ni).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof w=="string"&&w.match(/^[1-9][0-9]*$/)&&(I=parseInt(w)),Ee(g=o.clone(),cc,_d).call(g,e+1,t,I,i,l)}if(this.processFunc){dp(T(i,as));try{l=await this.processFunc(o,l)}catch(w){(w.throttle==null||typeof w.stall!="number")&&l.makeServerError("error in post-processing function",w).assertOk();let I=T(this,Ni).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return w.stall>=0&&(I=w.stall),Ee(b=o.clone(),cc,_d).call(b,e+1,t,I,i,l)}}return l};let Us=qp;const gb=class gb{constructor(e,t,n,i,s){se(this,Nh);se(this,Ch);se(this,Bh);se(this,Zn);se(this,el);se(this,uc);F(this,Nh,e),F(this,Ch,t),F(this,Bh,Object.keys(n).reduce((o,a)=>(o[a.toLowerCase()]=String(n[a]),o),{})),F(this,Zn,i==null?null:new Uint8Array(i)),F(this,el,s||null),F(this,uc,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,Zn)?Ce(T(this,Zn)):"null"}>`}get statusCode(){return T(this,Nh)}get statusMessage(){return T(this,Ch)}get headers(){return Object.assign({},T(this,Bh))}get body(){return T(this,Zn)==null?null:new Uint8Array(T(this,Zn))}get bodyText(){try{return T(this,Zn)==null?"":fp(T(this,Zn))}catch{ge(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ge(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const i=t[n++];return{value:[i,e[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const i=new gb(599,n,this.headers,this.body,T(this,el)||void 0);return F(i,uc,{message:e,error:t}),i}throwThrottleError(e,t){t==null?t=-1:q(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw ze(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,Zn)!=null}get request(){return T(this,el)}ok(){return T(this,uc).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,uc);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let i=null;try{T(this,Zn)&&(i=fp(T(this,Zn)))}catch{}ge(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Nh=new WeakMap,Ch=new WeakMap,Bh=new WeakMap,Zn=new WeakMap,el=new WeakMap,uc=new WeakMap;let Co=gb;function hT(){return new Date().getTime()}function LJ(r){return Ls(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function UJ(r){return new Promise(e=>setTimeout(e,r))}function DJ(r){let e=r.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function dT(r,e,t){let n=0;for(let i=0;i<t;i++)n=n*256+r[e+i];return n}function pT(r,e,t,n){const i=[];for(;t<e+1+n;){const s=gT(r,t);i.push(s.result),t+=s.consumed,ge(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:r,length:n,offset:e})}return{consumed:1+n,result:i}}function gT(r,e){ge(r.length!==0,"data too short","BUFFER_OVERRUN",{buffer:r,length:0,offset:1});const t=n=>{ge(n<=r.length,"data short segment too short","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n})};if(r[e]>=248){const n=r[e]-247;t(e+1+n);const i=dT(r,e+1,n);return t(e+1+n+i),pT(r,e,e+1+n,n+i)}else if(r[e]>=192){const n=r[e]-192;return t(e+1+n),pT(r,e,e+1,n)}else if(r[e]>=184){const n=r[e]-183;t(e+1+n);const i=dT(r,e+1,n);t(e+1+n+i);const s=Ce(r.slice(e+1+n,e+1+n+i));return{consumed:1+n+i,result:s}}else if(r[e]>=128){const n=r[e]-128;t(e+1+n);const i=Ce(r.slice(e+1,e+1+n));return{consumed:1+n,result:i}}return{consumed:1,result:DJ(r[e])}}function pp(r){const e=_t(r,"data"),t=gT(e,0);return q(t.consumed===e.length,"unexpected junk after rlp payload","data",r),t.result}function yT(r){const e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function mT(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(s){n=n.concat(mT(s))}),n.length<=55)return n.unshift(192+n.length),n;const i=yT(n.length);return i.unshift(247+i.length),i.concat(n)}const e=Array.prototype.slice.call(_t(r,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=yT(e.length);return t.unshift(183+t.length),t.concat(e)}const wT="0123456789abcdef";function ja(r){let e="0x";for(const t of mT(r))e+=wT[t>>4],e+=wT[t&15];return e}const _n=32,aw=new Uint8Array(_n),$J=["then"],gp={},bT=new WeakMap;function Ka(r){return bT.get(r)}function _T(r,e){bT.set(r,e)}function fh(r,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw t.error=e,t}function cw(r,e,t){return r.indexOf(null)>=0?e.map((n,i)=>n instanceof Bu?cw(Ka(n),n,t):n):r.reduce((n,i,s)=>{let o=e.getValue(i);return i in n||(t&&o instanceof Bu&&(o=cw(Ka(o),o,t)),n[i]=o),n},{})}const rl=class rl extends Array{constructor(...t){const n=t[0];let i=t[1],s=(t[2]||[]).slice(),o=!0;n!==gp&&(i=t,s=[],o=!1);super(i.length);se(this,tl);i.forEach((l,h)=>{this[h]=l});const a=s.reduce((l,h)=>(typeof h=="string"&&l.set(h,(l.get(h)||0)+1),l),new Map);if(_T(this,Object.freeze(i.map((l,h)=>{const g=s[h];return g!=null&&a.get(g)===1?g:null}))),F(this,tl,[]),T(this,tl)==null&&T(this,tl),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(l,h,g)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const w=at(h,"%index");if(w<0||w>=this.length)throw new RangeError("out of result range");const I=l[w];return I instanceof Error&&fh(`index ${w}`,I),I}if($J.indexOf(h)>=0)return Reflect.get(l,h,g);const b=l[h];if(b instanceof Function)return function(...w){return b.apply(this===g?l:this,w)};if(!(h in l))return l.getValue.apply(this===g?l:this,[h])}return Reflect.get(l,h,g)}});return _T(u,Ka(this)),u}toArray(t){const n=[];return this.forEach((i,s)=>{i instanceof Error&&fh(`index ${s}`,i),t&&i instanceof rl&&(i=i.toArray(t)),n.push(i)}),n}toObject(t){const n=Ka(this);return n.reduce((i,s,o)=>(ge(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),cw(n,this,t)),{})}slice(t,n){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const i=Ka(this),s=[],o=[];for(let a=t;a<n;a++)s.push(this[a]),o.push(i[a]);return new rl(gp,s,o)}filter(t,n){const i=Ka(this),s=[],o=[];for(let a=0;a<this.length;a++){const u=this[a];u instanceof Error&&fh(`index ${a}`,u),t.call(n,u,a,this)&&(s.push(u),o.push(i[a]))}return new rl(gp,s,o)}map(t,n){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&fh(`index ${s}`,o),i.push(t.call(n,o,s,this))}return i}getValue(t){const n=Ka(this).indexOf(t);if(n===-1)return;const i=this[n];return i instanceof Error&&fh(`property ${JSON.stringify(t)}`,i.error),i}static fromItems(t,n){return new rl(gp,t,n)}};tl=new WeakMap;let Bu=rl;function AT(r){let e=bn(r);return ge(e.length<=_n,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_n,offset:e.length}),e.length!==_n&&(e=wn(xr([aw.slice(e.length%_n),e]))),e}class Ds{constructor(e,t,n,i){Q(this,"name");Q(this,"type");Q(this,"localName");Q(this,"dynamic");ze(this,{name:e,type:t,localName:n,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){q(!1,e,this.localName,t)}}class uw{constructor(){se(this,nl);se(this,Ws);se(this,lc);F(this,Ws,[]),F(this,lc,0)}get data(){return xr(T(this,Ws))}get length(){return T(this,lc)}appendWriter(e){return Ee(this,nl,yg).call(this,wn(e.data))}writeBytes(e){let t=wn(e);const n=t.length%_n;return n&&(t=wn(xr([t,aw.slice(n)]))),Ee(this,nl,yg).call(this,t)}writeValue(e){return Ee(this,nl,yg).call(this,AT(e))}writeUpdatableValue(){const e=T(this,Ws).length;return T(this,Ws).push(aw),F(this,lc,T(this,lc)+_n),t=>{T(this,Ws)[e]=AT(t)}}}Ws=new WeakMap,lc=new WeakMap,nl=new WeakSet,yg=function(e){return T(this,Ws).push(e),F(this,lc,T(this,lc)+e.length),e.length};const yb=class yb{constructor(e,t,n){se(this,dc);Q(this,"allowLoose");se(this,Un);se(this,Qn);se(this,fc);se(this,hc);se(this,Ho);ze(this,{allowLoose:!!t}),F(this,Un,wn(e)),F(this,fc,0),F(this,hc,null),F(this,Ho,n??1024),F(this,Qn,0)}get data(){return Ce(T(this,Un))}get dataLength(){return T(this,Un).length}get consumed(){return T(this,Qn)}get bytes(){return new Uint8Array(T(this,Un))}subReader(e){const t=new yb(T(this,Un).slice(T(this,Qn)+e),this.allowLoose,T(this,Ho));return F(t,hc,this),t}readBytes(e,t){let n=Ee(this,dc,f6).call(this,0,e,!!t);return Ee(this,dc,U_).call(this,e),F(this,Qn,T(this,Qn)+n.length),n.slice(0,e)}readValue(){return sw(this.readBytes(_n))}readIndex(){return vJ(this.readBytes(_n))}};Un=new WeakMap,Qn=new WeakMap,fc=new WeakMap,hc=new WeakMap,Ho=new WeakMap,dc=new WeakSet,U_=function(e){var t;if(T(this,hc))return Ee(t=T(this,hc),dc,U_).call(t,e);F(this,fc,T(this,fc)+e),ge(T(this,Ho)<1||T(this,fc)<=T(this,Ho)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Ho)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:wn(T(this,Un)),offset:T(this,Qn),length:e,info:{bytesRead:T(this,fc),dataLength:this.dataLength}})},f6=function(e,t,n){let i=Math.ceil(t/_n)*_n;return T(this,Qn)+i>T(this,Un).length&&(this.allowLoose&&n&&T(this,Qn)+t<=T(this,Un).length?i=t:ge(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:wn(T(this,Un)),length:T(this,Un).length,offset:T(this,Qn)+i})),T(this,Un).slice(T(this,Qn),T(this,Qn)+i)};let lw=yb;function yp(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function fw(r,...e){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function FJ(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");yp(r.outputLen),yp(r.blockLen)}function Pu(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function vT(r,e){fw(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const hw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ET=r=>r instanceof Uint8Array,HJ=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),dw=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ns=(r,e)=>r<<32-e|r>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function zJ(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function mp(r){if(typeof r=="string"&&(r=zJ(r)),!ET(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function GJ(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!ET(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class pw{clone(){return this._cloneInto()}}function gw(r){const e=n=>r().update(mp(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function jJ(r=32){if(hw&&typeof hw.getRandomValues=="function")return hw.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}class xT extends pw{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,FJ(e);const n=mp(t);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 i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Pu(this),this.iHash.update(e),this}digestInto(e){Pu(this),fw(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:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const RT=(r,e,t)=>new xT(r,e).update(t).digest();RT.create=(r,e)=>new xT(r,e);function KJ(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),u=n?4:0,l=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+l,a,n)}class IT extends pw{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=dw(this.buffer)}update(e){Pu(this);const{view:t,buffer:n,blockLen:i}=this;e=mp(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=dw(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pu(this),vT(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;KJ(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=dw(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,h[g],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}}const VJ=(r,e,t)=>r&e^~r&t,WJ=(r,e,t)=>r&e^r&t^e&t,qJ=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]),Bo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Po=new Uint32Array(64);class ZJ extends IT{constructor(){super(64,32,8,!1),this.A=Bo[0]|0,this.B=Bo[1]|0,this.C=Bo[2]|0,this.D=Bo[3]|0,this.E=Bo[4]|0,this.F=Bo[5]|0,this.G=Bo[6]|0,this.H=Bo[7]|0}get(){const{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:u}=this;return[e,t,n,i,s,o,a,u]}set(e,t,n,i,s,o,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,t){for(let g=0;g<16;g++,t+=4)Po[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){const b=Po[g-15],w=Po[g-2],I=ns(b,7)^ns(b,18)^b>>>3,S=ns(w,17)^ns(w,19)^w>>>10;Po[g]=S+Po[g-7]+I+Po[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:h}=this;for(let g=0;g<64;g++){const b=ns(a,6)^ns(a,11)^ns(a,25),w=h+b+VJ(a,u,l)+qJ[g]+Po[g]|0,S=(ns(n,2)^ns(n,13)^ns(n,22))+WJ(n,i,s)|0;h=l,l=u,u=a,a=o+w|0,o=s,s=i,i=n,n=w+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,u,l,h)}roundClean(){Po.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ST=gw(()=>new ZJ),wp=BigInt(2**32-1),yw=BigInt(32);function kT(r,e=!1){return e?{h:Number(r&wp),l:Number(r>>yw&wp)}:{h:Number(r>>yw&wp)|0,l:Number(r&wp)|0}}function TT(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){const{h:s,l:o}=kT(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const QJ=(r,e)=>BigInt(r>>>0)<<yw|BigInt(e>>>0),YJ=(r,e,t)=>r>>>t,JJ=(r,e,t)=>r<<32-t|e>>>t,XJ=(r,e,t)=>r>>>t|e<<32-t,eX=(r,e,t)=>r<<32-t|e>>>t,tX=(r,e,t)=>r<<64-t|e>>>t-32,rX=(r,e,t)=>r>>>t-32|e<<64-t,nX=(r,e)=>e,iX=(r,e)=>r,OT=(r,e,t)=>r<<t|e>>>32-t,NT=(r,e,t)=>e<<t|r>>>32-t,CT=(r,e,t)=>e<<t-32|r>>>64-t,BT=(r,e,t)=>r<<t-32|e>>>64-t;function sX(r,e,t,n){const i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}const st={fromBig:kT,split:TT,toBig:QJ,shrSH:YJ,shrSL:JJ,rotrSH:XJ,rotrSL:eX,rotrBH:tX,rotrBL:rX,rotr32H:nX,rotr32L:iX,rotlSH:OT,rotlSL:NT,rotlBH:CT,rotlBL:BT,add:sX,add3L:(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),add3H:(r,e,t,n)=>e+t+n+(r/2**32|0)|0,add4L:(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,add5H:(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,add5L:(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0)},[oX,aX]=st.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(r=>BigInt(r))),Mo=new Uint32Array(80),Lo=new Uint32Array(80);class cX extends IT{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:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:l,El:h,Fh:g,Fl:b,Gh:w,Gl:I,Hh:S,Hl:x}=this;return[e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x]}set(e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=h|0,this.Fh=g|0,this.Fl=b|0,this.Gh=w|0,this.Gl=I|0,this.Hh=S|0,this.Hl=x|0}process(e,t){for(let D=0;D<16;D++,t+=4)Mo[D]=e.getUint32(t),Lo[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const z=Mo[D-15]|0,W=Lo[D-15]|0,Z=st.rotrSH(z,W,1)^st.rotrSH(z,W,8)^st.shrSH(z,W,7),j=st.rotrSL(z,W,1)^st.rotrSL(z,W,8)^st.shrSL(z,W,7),V=Mo[D-2]|0,oe=Lo[D-2]|0,ce=st.rotrSH(V,oe,19)^st.rotrBH(V,oe,61)^st.shrSH(V,oe,6),ie=st.rotrSL(V,oe,19)^st.rotrBL(V,oe,61)^st.shrSL(V,oe,6),ue=st.add4L(j,ie,Lo[D-7],Lo[D-16]),B=st.add4H(ue,Z,ce,Mo[D-7],Mo[D-16]);Mo[D]=B|0,Lo[D]=ue|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:l,Dl:h,Eh:g,El:b,Fh:w,Fl:I,Gh:S,Gl:x,Hh:C,Hl:H}=this;for(let D=0;D<80;D++){const z=st.rotrSH(g,b,14)^st.rotrSH(g,b,18)^st.rotrBH(g,b,41),W=st.rotrSL(g,b,14)^st.rotrSL(g,b,18)^st.rotrBL(g,b,41),Z=g&w^~g&S,j=b&I^~b&x,V=st.add5L(H,W,j,aX[D],Lo[D]),oe=st.add5H(V,C,z,Z,oX[D],Mo[D]),ce=V|0,ie=st.rotrSH(n,i,28)^st.rotrBH(n,i,34)^st.rotrBH(n,i,39),ue=st.rotrSL(n,i,28)^st.rotrBL(n,i,34)^st.rotrBL(n,i,39),B=n&s^n&a^s&a,p=i&o^i&u^o&u;C=S|0,H=x|0,S=w|0,x=I|0,w=g|0,I=b|0,{h:g,l:b}=st.add(l|0,h|0,oe|0,ce|0),l=a|0,h=u|0,a=s|0,u=o|0,s=n|0,o=i|0;const m=st.add3L(ce,ue,p);n=st.add3H(m,oe,ie,B),i=m|0}({h:n,l:i}=st.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=st.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=st.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:h}=st.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:g,l:b}=st.add(this.Eh|0,this.El|0,g|0,b|0),{h:w,l:I}=st.add(this.Fh|0,this.Fl|0,w|0,I|0),{h:S,l:x}=st.add(this.Gh|0,this.Gl|0,S|0,x|0),{h:C,l:H}=st.add(this.Hh|0,this.Hl|0,C|0,H|0),this.set(n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H)}roundClean(){Mo.fill(0),Lo.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 uX=gw(()=>new cX);function lX(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof qc<"u")return qc;throw new Error("unable to locate global object")}const PT=lX();PT.crypto||PT.msCrypto;function fX(r){switch(r){case"sha256":return ST.create();case"sha512":return uX.create()}q(!1,"invalid hashing algorithm name","algorithm",r)}const[MT,LT,UT]=[[],[],[]],hX=BigInt(0),hh=BigInt(1),dX=BigInt(2),pX=BigInt(7),gX=BigInt(256),yX=BigInt(113);for(let r=0,e=hh,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],MT.push(2*(5*n+t)),LT.push((r+1)*(r+2)/2%64);let i=hX;for(let s=0;s<7;s++)e=(e<<hh^(e>>pX)*yX)%gX,e&dX&&(i^=hh<<(hh<<BigInt(s))-hh);UT.push(i)}const[mX,wX]=TT(UT,!0),DT=(r,e,t)=>t>32?CT(r,e,t):OT(r,e,t),$T=(r,e,t)=>t>32?BT(r,e,t):NT(r,e,t);function bX(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=t[u],h=t[u+1],g=DT(l,h,1)^t[a],b=$T(l,h,1)^t[a+1];for(let w=0;w<50;w+=10)r[o+w]^=g,r[o+w+1]^=b}let i=r[2],s=r[3];for(let o=0;o<24;o++){const a=LT[o],u=DT(i,s,a),l=$T(i,s,a),h=MT[o];i=r[h],s=r[h+1],r[h]=u,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=mX[n],r[1]^=wX[n]}t.fill(0)}class mw extends pw{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,yp(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=HJ(this.state)}keccak(){bX(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Pu(this);const{blockLen:t,state:n}=this;e=mp(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,t&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Pu(this,!1),fw(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return yp(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vT(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:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new mw(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const _X=((r,e,t)=>gw(()=>new mw(e,r,t)))(1,136,256/8);let FT=!1;const HT=function(r){return _X(r)};let zT=HT;function Nr(r){const e=_t(r,"data");return Ce(zT(e))}Nr._=HT,Nr.lock=function(){FT=!0},Nr.register=function(r){if(FT)throw new TypeError("keccak256 is locked");zT=r},Object.freeze(Nr);const GT=function(r){return fX("sha256").update(r).digest()};let jT=GT,KT=!1;function Mu(r){const e=_t(r,"data");return Ce(jT(e))}Mu._=GT,Mu.lock=function(){KT=!0},Mu.register=function(r){if(KT)throw new Error("sha256 is locked");jT=r},Object.freeze(Mu),Object.freeze(Mu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const VT=BigInt(0),bp=BigInt(1),AX=BigInt(2),_p=r=>r instanceof Uint8Array,vX=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Lu(r){if(!_p(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=vX[r[t]];return e}function WT(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function ww(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Uu(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const i=n*2,s=r.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[n]=o}return t}function Va(r){return ww(Lu(r))}function bw(r){if(!_p(r))throw new Error("Uint8Array expected");return ww(Lu(Uint8Array.from(r).reverse()))}function Du(r,e){return Uu(r.toString(16).padStart(e*2,"0"))}function _w(r,e){return Du(r,e).reverse()}function EX(r){return Uu(WT(r))}function Ii(r,e,t){let n;if(typeof e=="string")try{n=Uu(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(_p(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function dh(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!_p(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function xX(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function RX(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function IX(r){let e;for(e=0;r>VT;r>>=bp,e+=1);return e}function SX(r,e){return r>>BigInt(e)&bp}const kX=(r,e,t)=>r|(t?bp:VT)<<BigInt(e),Aw=r=>(AX<<BigInt(r-1))-bp,vw=r=>new Uint8Array(r),qT=r=>Uint8Array.from(r);function ZT(r,e,t){if(typeof r!="number"||r<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 t!="function")throw new Error("hmacFn must be a function");let n=vw(r),i=vw(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=vw())=>{i=a(qT([0]),g),n=a(),g.length!==0&&(i=a(qT([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){n=a();const w=n.slice();b.push(w),g+=n.length}return dh(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const TX={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ph(r,e,t={}){const n=(i,s,o)=>{const a=TX[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=r[i];if(!(o&&u===void 0)&&!a(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(t))n(i,s,!0);return r}const OX=Object.freeze(Object.defineProperty({__proto__:null,bitGet:SX,bitLen:IX,bitMask:Aw,bitSet:kX,bytesToHex:Lu,bytesToNumberBE:Va,bytesToNumberLE:bw,concatBytes:dh,createHmacDrbg:ZT,ensureBytes:Ii,equalBytes:xX,hexToBytes:Uu,hexToNumber:ww,numberToBytesBE:Du,numberToBytesLE:_w,numberToHexUnpadded:WT,numberToVarBytesBE:EX,utf8ToBytes:RX,validateObject:ph},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $r=BigInt(0),Rr=BigInt(1),Wa=BigInt(2),NX=BigInt(3),Ew=BigInt(4),QT=BigInt(5),YT=BigInt(8);BigInt(9),BigInt(16);function Pn(r,e){const t=r%e;return t>=$r?t:e+t}function CX(r,e,t){if(t<=$r||e<$r)throw new Error("Expected power/modulo > 0");if(t===Rr)return $r;let n=Rr;for(;e>$r;)e&Rr&&(n=n*r%t),r=r*r%t,e>>=Rr;return n}function ci(r,e,t){let n=r;for(;e-- >$r;)n*=n,n%=t;return n}function xw(r,e){if(r===$r||e<=$r)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Pn(r,e),n=e,i=$r,s=Rr;for(;t!==$r;){const a=n/t,u=n%t,l=i-s*a;n=t,t=u,i=s,s=l}if(n!==Rr)throw new Error("invert: does not exist");return Pn(i,e)}function BX(r){const e=(r-Rr)/Wa;let t,n,i;for(t=r-Rr,n=0;t%Wa===$r;t/=Wa,n++);for(i=Wa;i<r&&CX(i,e,r)!==r-Rr;i++);if(n===1){const o=(r+Rr)/Ew;return function(u,l){const h=u.pow(l,o);if(!u.eql(u.sqr(h),l))throw new Error("Cannot find square root");return h}}const s=(t+Rr)/Wa;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),t),g=a.pow(u,s),b=a.pow(u,t);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let w=1;for(let S=a.sqr(b);w<l&&!a.eql(S,a.ONE);w++)S=a.sqr(S);const I=a.pow(h,Rr<<BigInt(l-w-1));h=a.sqr(I),g=a.mul(g,I),b=a.mul(b,h),l=w}return g}}function PX(r){if(r%Ew===NX){const e=(r+Rr)/Ew;return function(n,i){const s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%YT===QT){const e=(r-QT)/YT;return function(n,i){const s=n.mul(i,Wa),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,Wa),o),l=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return BX(r)}const MX=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function LX(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=MX.reduce((n,i)=>(n[i]="function",n),e);return ph(r,t)}function UX(r,e,t){if(t<$r)throw new Error("Expected power > 0");if(t===$r)return r.ONE;if(t===Rr)return e;let n=r.ONE,i=e;for(;t>$r;)t&Rr&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Rr;return n}function DX(r,e){const t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function JT(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function $X(r,e,t=!1,n={}){if(r<=$r)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:i,nByteLength:s}=JT(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=PX(r),a=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Aw(i),ZERO:$r,ONE:Rr,create:u=>Pn(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return $r<=u&&u<r},is0:u=>u===$r,isOdd:u=>(u&Rr)===Rr,neg:u=>Pn(-u,r),eql:(u,l)=>u===l,sqr:u=>Pn(u*u,r),add:(u,l)=>Pn(u+l,r),sub:(u,l)=>Pn(u-l,r),mul:(u,l)=>Pn(u*l,r),pow:(u,l)=>UX(a,u,l),div:(u,l)=>Pn(u*xw(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>xw(u,r),sqrt:n.sqrt||(u=>o(a,u)),invertBatch:u=>DX(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?_w(u,s):Du(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return t?bw(u):Va(u)}});return Object.freeze(a)}function XT(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function eO(r){const e=XT(r);return e+Math.ceil(e/2)}function FX(r,e,t=!1){const n=r.length,i=XT(e),s=eO(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=t?Va(r):bw(r),a=Pn(o,e-Rr)+Rr;return t?_w(a,i):Du(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const HX=BigInt(0),Rw=BigInt(1);function zX(r,e){const t=(i,s)=>{const o=s.negate();return i?o:s},n=i=>{const s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:t,unsafeLadder(i,s){let o=r.ZERO,a=i;for(;s>HX;)s&Rw&&(o=o.add(a)),a=a.double(),s>>=Rw;return o},precomputeWindow(i,s){const{windows:o,windowSize:a}=n(s),u=[];let l=i,h=l;for(let g=0;g<o;g++){h=l,u.push(h);for(let b=1;b<a;b++)h=h.add(l),u.push(h);l=h.double()}return u},wNAF(i,s,o){const{windows:a,windowSize:u}=n(i);let l=r.ZERO,h=r.BASE;const g=BigInt(2**i-1),b=2**i,w=BigInt(i);for(let I=0;I<a;I++){const S=I*u;let x=Number(o&g);o>>=w,x>u&&(x-=b,o+=Rw);const C=S,H=S+Math.abs(x)-1,D=I%2!==0,z=x<0;x===0?h=h.add(t(D,s[C])):l=l.add(t(z,s[H]))}return{p:l,f:h}},wNAFCached(i,s,o,a){const u=i._WINDOW_SIZE||1;let l=s.get(i);return l||(l=this.precomputeWindow(i,u),u!==1&&s.set(i,a(l))),this.wNAF(u,l,o)}}}function tO(r){return LX(r.Fp),ph(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...JT(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function GX(r){const e=tO(r);ph(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:jX,hexToBytes:KX}=OX,qa={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=qa;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:jX(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=qa,t=typeof r=="string"?KX(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=qa._parseInt(t.subarray(2)),{d:o,l:a}=qa._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(r){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(r.s)),i=e(t(r.r)),s=n.length/2,o=i.length/2,a=t(s),u=t(o);return`30${t(o+s+4)}02${u}${i}02${a}${n}`}},$s=BigInt(0),ui=BigInt(1);BigInt(2);const rO=BigInt(3);BigInt(4);function VX(r){const e=GX(r),{Fp:t}=e,n=e.toBytes||((I,S,x)=>{const C=S.toAffine();return dh(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(I=>{const S=I.subarray(1),x=t.fromBytes(S.subarray(0,t.BYTES)),C=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x,y:C}});function s(I){const{a:S,b:x}=e,C=t.sqr(I),H=t.mul(C,I);return t.add(t.add(H,t.mul(I,S)),x)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(I){return typeof I=="bigint"&&$s<I&&I<e.n}function a(I){if(!o(I))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(I){const{allowedPrivateKeyLengths:S,nByteLength:x,wrapPrivateKey:C,n:H}=e;if(S&&typeof I!="bigint"){if(I instanceof Uint8Array&&(I=Lu(I)),typeof I!="string"||!S.includes(I.length))throw new Error("Invalid key");I=I.padStart(x*2,"0")}let D;try{D=typeof I=="bigint"?I:Va(Ii("private key",I,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof I}`)}return C&&(D=Pn(D,H)),a(D),D}const l=new Map;function h(I){if(!(I instanceof g))throw new Error("ProjectivePoint expected")}class g{constructor(S,x,C){if(this.px=S,this.py=x,this.pz=C,S==null||!t.isValid(S))throw new Error("x required");if(x==null||!t.isValid(x))throw new Error("y required");if(C==null||!t.isValid(C))throw new Error("z required")}static fromAffine(S){const{x,y:C}=S||{};if(!S||!t.isValid(x)||!t.isValid(C))throw new Error("invalid affine point");if(S instanceof g)throw new Error("projective point not allowed");const H=D=>t.eql(D,t.ZERO);return H(x)&&H(C)?g.ZERO:new g(x,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(S){const x=t.invertBatch(S.map(C=>C.pz));return S.map((C,H)=>C.toAffine(x[H])).map(g.fromAffine)}static fromHex(S){const x=g.fromAffine(i(Ii("pointHex",S)));return x.assertValidity(),x}static fromPrivateKey(S){return g.BASE.multiply(u(S))}_setWindowSize(S){this._WINDOW_SIZE=S,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:S,y:x}=this.toAffine();if(!t.isValid(S)||!t.isValid(x))throw new Error("bad point: x or y not FE");const C=t.sqr(x),H=s(S);if(!t.eql(C,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:S}=this.toAffine();if(t.isOdd)return!t.isOdd(S);throw new Error("Field doesn't support isOdd")}equals(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:W}=S,Z=t.eql(t.mul(x,W),t.mul(D,H)),j=t.eql(t.mul(C,W),t.mul(z,H));return Z&&j}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:S,b:x}=e,C=t.mul(x,rO),{px:H,py:D,pz:z}=this;let W=t.ZERO,Z=t.ZERO,j=t.ZERO,V=t.mul(H,H),oe=t.mul(D,D),ce=t.mul(z,z),ie=t.mul(H,D);return ie=t.add(ie,ie),j=t.mul(H,z),j=t.add(j,j),W=t.mul(S,j),Z=t.mul(C,ce),Z=t.add(W,Z),W=t.sub(oe,Z),Z=t.add(oe,Z),Z=t.mul(W,Z),W=t.mul(ie,W),j=t.mul(C,j),ce=t.mul(S,ce),ie=t.sub(V,ce),ie=t.mul(S,ie),ie=t.add(ie,j),j=t.add(V,V),V=t.add(j,V),V=t.add(V,ce),V=t.mul(V,ie),Z=t.add(Z,V),ce=t.mul(D,z),ce=t.add(ce,ce),V=t.mul(ce,ie),W=t.sub(W,V),j=t.mul(ce,oe),j=t.add(j,j),j=t.add(j,j),new g(W,Z,j)}add(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:W}=S;let Z=t.ZERO,j=t.ZERO,V=t.ZERO;const oe=e.a,ce=t.mul(e.b,rO);let ie=t.mul(x,D),ue=t.mul(C,z),B=t.mul(H,W),p=t.add(x,C),m=t.add(D,z);p=t.mul(p,m),m=t.add(ie,ue),p=t.sub(p,m),m=t.add(x,H);let E=t.add(D,W);return m=t.mul(m,E),E=t.add(ie,B),m=t.sub(m,E),E=t.add(C,H),Z=t.add(z,W),E=t.mul(E,Z),Z=t.add(ue,B),E=t.sub(E,Z),V=t.mul(oe,m),Z=t.mul(ce,B),V=t.add(Z,V),Z=t.sub(ue,V),V=t.add(ue,V),j=t.mul(Z,V),ue=t.add(ie,ie),ue=t.add(ue,ie),B=t.mul(oe,B),m=t.mul(ce,m),ue=t.add(ue,B),B=t.sub(ie,B),B=t.mul(oe,B),m=t.add(m,B),ie=t.mul(ue,m),j=t.add(j,ie),ie=t.mul(E,m),Z=t.mul(p,Z),Z=t.sub(Z,ie),ie=t.mul(p,ue),V=t.mul(E,V),V=t.add(V,ie),new g(Z,j,V)}subtract(S){return this.add(S.negate())}is0(){return this.equals(g.ZERO)}wNAF(S){return w.wNAFCached(this,l,S,x=>{const C=t.invertBatch(x.map(H=>H.pz));return x.map((H,D)=>H.toAffine(C[D])).map(g.fromAffine)})}multiplyUnsafe(S){const x=g.ZERO;if(S===$s)return x;if(a(S),S===ui)return this;const{endo:C}=e;if(!C)return w.unsafeLadder(this,S);let{k1neg:H,k1:D,k2neg:z,k2:W}=C.splitScalar(S),Z=x,j=x,V=this;for(;D>$s||W>$s;)D&ui&&(Z=Z.add(V)),W&ui&&(j=j.add(V)),V=V.double(),D>>=ui,W>>=ui;return H&&(Z=Z.negate()),z&&(j=j.negate()),j=new g(t.mul(j.px,C.beta),j.py,j.pz),Z.add(j)}multiply(S){a(S);let x=S,C,H;const{endo:D}=e;if(D){const{k1neg:z,k1:W,k2neg:Z,k2:j}=D.splitScalar(x);let{p:V,f:oe}=this.wNAF(W),{p:ce,f:ie}=this.wNAF(j);V=w.constTimeNegate(z,V),ce=w.constTimeNegate(Z,ce),ce=new g(t.mul(ce.px,D.beta),ce.py,ce.pz),C=V.add(ce),H=oe.add(ie)}else{const{p:z,f:W}=this.wNAF(x);C=z,H=W}return g.normalizeZ([C,H])[0]}multiplyAndAddUnsafe(S,x,C){const H=g.BASE,D=(W,Z)=>Z===$s||Z===ui||!W.equals(H)?W.multiplyUnsafe(Z):W.multiply(Z),z=D(this,x).add(D(S,C));return z.is0()?void 0:z}toAffine(S){const{px:x,py:C,pz:H}=this,D=this.is0();S==null&&(S=D?t.ONE:t.inv(H));const z=t.mul(x,S),W=t.mul(C,S),Z=t.mul(H,S);if(D)return{x:t.ZERO,y:t.ZERO};if(!t.eql(Z,t.ONE))throw new Error("invZ was invalid");return{x:z,y:W}}isTorsionFree(){const{h:S,isTorsionFree:x}=e;if(S===ui)return!0;if(x)return x(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:S,clearCofactor:x}=e;return S===ui?this:x?x(g,this):this.multiplyUnsafe(e.h)}toRawBytes(S=!0){return this.assertValidity(),n(g,this,S)}toHex(S=!0){return Lu(this.toRawBytes(S))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const b=e.nBitLength,w=zX(g,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function WX(r){const e=tO(r);return ph(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function qX(r){const e=WX(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(m){return $s<m&&m<t.ORDER}function a(m){return Pn(m,n)}function u(m){return xw(m,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:g,isWithinCurveOrder:b}=VX({...e,toBytes(m,E,k){const O=E.toAffine(),M=t.toBytes(O.x),G=dh;return k?G(Uint8Array.from([E.hasEvenY()?2:3]),M):G(Uint8Array.from([4]),M,t.toBytes(O.y))},fromBytes(m){const E=m.length,k=m[0],O=m.subarray(1);if(E===i&&(k===2||k===3)){const M=Va(O);if(!o(M))throw new Error("Point is not on curve");const G=g(M);let P=t.sqrt(G);const A=(P&ui)===ui;return(k&1)===1!==A&&(P=t.neg(P)),{x:M,y:P}}else if(E===s&&k===4){const M=t.fromBytes(O.subarray(0,t.BYTES)),G=t.fromBytes(O.subarray(t.BYTES,2*t.BYTES));return{x:M,y:G}}else throw new Error(`Point of length ${E} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),w=m=>Lu(Du(m,e.nByteLength));function I(m){const E=n>>ui;return m>E}function S(m){return I(m)?a(-m):m}const x=(m,E,k)=>Va(m.slice(E,k));class C{constructor(E,k,O){this.r=E,this.s=k,this.recovery=O,this.assertValidity()}static fromCompact(E){const k=e.nByteLength;return E=Ii("compactSignature",E,k*2),new C(x(E,0,k),x(E,k,2*k))}static fromDER(E){const{r:k,s:O}=qa.toSig(Ii("DER",E));return new C(k,O)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new C(this.r,this.s,E)}recoverPublicKey(E){const{r:k,s:O,recovery:M}=this,G=j(Ii("msgHash",E));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?k+e.n:k;if(P>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const A=M&1?"03":"02",U=l.fromHex(A+w(P)),le=u(P),te=a(-G*le),re=a(O*le),he=l.BASE.multiplyAndAddUnsafe(U,te,re);if(!he)throw new Error("point at infinify");return he.assertValidity(),he}hasHighS(){return I(this.s)}normalizeS(){return this.hasHighS()?new C(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Uu(this.toDERHex())}toDERHex(){return qa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Uu(this.toCompactHex())}toCompactHex(){return w(this.r)+w(this.s)}}const H={isValidPrivateKey(m){try{return h(m),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const m=eO(e.n);return FX(e.randomBytes(m),e.n)},precompute(m=8,E=l.BASE){return E._setWindowSize(m),E.multiply(BigInt(3)),E}};function D(m,E=!0){return l.fromPrivateKey(m).toRawBytes(E)}function z(m){const E=m instanceof Uint8Array,k=typeof m=="string",O=(E||k)&&m.length;return E?O===i||O===s:k?O===2*i||O===2*s:m instanceof l}function W(m,E,k=!0){if(z(m))throw new Error("first arg must be private key");if(!z(E))throw new Error("second arg must be public key");return l.fromHex(E).multiply(h(m)).toRawBytes(k)}const Z=e.bits2int||function(m){const E=Va(m),k=m.length*8-e.nBitLength;return k>0?E>>BigInt(k):E},j=e.bits2int_modN||function(m){return a(Z(m))},V=Aw(e.nBitLength);function oe(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!($s<=m&&m<V))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Du(m,e.nByteLength)}function ce(m,E,k=ie){if(["recovered","canonical"].some(be=>be in k))throw new Error("sign() legacy options not supported");const{hash:O,randomBytes:M}=e;let{lowS:G,prehash:P,extraEntropy:A}=k;G==null&&(G=!0),m=Ii("msgHash",m),P&&(m=Ii("prehashed msgHash",O(m)));const U=j(m),le=h(E),te=[oe(le),oe(U)];if(A!=null){const be=A===!0?M(t.BYTES):A;te.push(Ii("extraEntropy",be))}const re=dh(...te),he=U;function ye(be){const Ve=Z(be);if(!b(Ve))return;const Fe=u(Ve),Be=l.BASE.multiply(Ve).toAffine(),et=a(Be.x);if(et===$s)return;const Qe=a(Fe*a(he+et*le));if(Qe===$s)return;let ot=(Be.x===et?0:2)|Number(Be.y&ui),sr=Qe;return G&&I(Qe)&&(sr=S(Qe),ot^=1),new C(et,sr,ot)}return{seed:re,k2sig:ye}}const ie={lowS:e.lowS,prehash:!1},ue={lowS:e.lowS,prehash:!1};function B(m,E,k=ie){const{seed:O,k2sig:M}=ce(m,E,k),G=e;return ZT(G.hash.outputLen,G.nByteLength,G.hmac)(O,M)}l.BASE._setWindowSize(8);function p(m,E,k,O=ue){var Be;const M=m;if(E=Ii("msgHash",E),k=Ii("publicKey",k),"strict"in O)throw new Error("options.strict was renamed to lowS");const{lowS:G,prehash:P}=O;let A,U;try{if(typeof M=="string"||M instanceof Uint8Array)try{A=C.fromDER(M)}catch(et){if(!(et instanceof qa.Err))throw et;A=C.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:et,s:Qe}=M;A=new C(et,Qe)}else throw new Error("PARSE");U=l.fromHex(k)}catch(et){if(et.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(G&&A.hasHighS())return!1;P&&(E=e.hash(E));const{r:le,s:te}=A,re=j(E),he=u(te),ye=a(re*he),be=a(le*he),Ve=(Be=l.BASE.multiplyAndAddUnsafe(U,ye,be))==null?void 0:Be.toAffine();return Ve?a(Ve.x)===le:!1}return{CURVE:e,getPublicKey:D,getSharedSecret:W,sign:B,verify:p,ProjectivePoint:l,Signature:C,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ZX(r){return{hash:r,hmac:(e,...t)=>RT(r,e,GJ(...t)),randomBytes:jJ}}function QX(r,e){const t=n=>qX({...r,...ZX(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nO=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),iO=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),YX=BigInt(1),Iw=BigInt(2),sO=(r,e)=>(r+e/Iw)/e;function JX(r){const e=nO,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=r*r*r%e,h=l*l*r%e,g=ci(h,t,e)*h%e,b=ci(g,t,e)*h%e,w=ci(b,Iw,e)*l%e,I=ci(w,i,e)*w%e,S=ci(I,s,e)*I%e,x=ci(S,a,e)*S%e,C=ci(x,u,e)*x%e,H=ci(C,a,e)*S%e,D=ci(H,t,e)*h%e,z=ci(D,o,e)*I%e,W=ci(z,n,e)*l%e,Z=ci(W,Iw,e);if(!Sw.eql(Sw.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Sw=$X(nO,void 0,void 0,{sqrt:JX}),Uo=QX({a:BigInt(0),b:BigInt(7),Fp:Sw,n:iO,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=iO,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-YX*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=sO(s*r,e),u=sO(-n*r,e);let l=Pn(r-a*t-u*i,e),h=Pn(-a*n-u*s,e);const g=l>o,b=h>o;if(g&&(l=e-l),b&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:l,k2neg:b,k2:h}}}},ST);BigInt(0),Uo.ProjectivePoint;const gh="0x0000000000000000000000000000000000000000",oO="0x0000000000000000000000000000000000000000000000000000000000000000",aO=BigInt(0),cO=BigInt(1),uO=BigInt(2),lO=BigInt(27),fO=BigInt(28),Ap=BigInt(35),$u={};function hO(r){return Ga(bn(r),32)}const Ci=class Ci{constructor(e,t,n,i){se(this,il);se(this,sl);se(this,ol);se(this,pc);cp(e,$u,"Signature"),F(this,il,t),F(this,sl,n),F(this,ol,i),F(this,pc,null)}get r(){return T(this,il)}set r(e){q(Ou(e)===32,"invalid r","value",e),F(this,il,Ce(e))}get s(){return T(this,sl)}set s(e){q(Ou(e)===32,"invalid s","value",e);const t=Ce(e);q(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),F(this,sl,t)}get v(){return T(this,ol)}set v(e){const t=at(e,"value");q(t===27||t===28,"invalid v","v",e),F(this,ol,t)}get networkV(){return T(this,pc)}get legacyChainId(){const e=this.networkV;return e==null?null:Ci.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=_t(this.s);return this.yParity&&(e[0]|=128),Ce(e)}get compactSerialized(){return xr([this.r,this.yParityAndS])}get serialized(){return xr([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 Ci($u,this.r,this.s,this.v);return this.networkV&&F(e,pc,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 t=Le(e,"v");return t==lO||t==fO?aO:(q(t>=Ap,"invalid EIP-155 v","v",e),(t-Ap)/uO)}static getChainIdV(e,t){return Le(e)*uO+BigInt(35+t-27)}static getNormalizedV(e){const t=Le(e);return t===aO||t===lO?27:t===cO||t===fO?28:(q(t>=Ap,"invalid v","v",e),t&cO?27:28)}static from(e){function t(l,h){q(l,h,"signature",e)}if(e==null)return new Ci($u,oO,oO,27);if(typeof e=="string"){const l=_t(e,"signature");if(l.length===64){const h=Ce(l.slice(0,32)),g=l.slice(32,64),b=g[0]&128?28:27;return g[0]&=127,new Ci($u,h,Ce(g),b)}if(l.length===65){const h=Ce(l.slice(0,32)),g=l.slice(32,64);t((g[0]&128)===0,"non-canonical s");const b=Ci.getNormalizedV(l[64]);return new Ci($u,h,Ce(g),b)}t(!1,"invalid raw signature length")}if(e instanceof Ci)return e.clone();const n=e.r;t(n!=null,"missing r");const i=hO(n),s=function(l,h){if(l!=null)return hO(l);if(h!=null){t(Gt(h,32),"invalid yParityAndS");const g=_t(h);return g[0]&=127,Ce(g)}t(!1,"missing s")}(e.s,e.yParityAndS);t((_t(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(l,h,g){if(l!=null){const b=Le(l);return{networkV:b>=Ap?b:void 0,v:Ci.getNormalizedV(b)}}if(h!=null)return t(Gt(h,32),"invalid yParityAndS"),{v:_t(h)[0]&128?28:27};if(g!=null){switch(at(g,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),u=new Ci($u,i,s,a);return o&&F(u,pc,o),t(e.yParity==null||at(e.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};il=new WeakMap,sl=new WeakMap,ol=new WeakMap,pc=new WeakMap;let Si=Ci;const gc=class gc{constructor(e){se(this,qs);q(Ou(e)===32,"invalid private key","privateKey","[REDACTED]"),F(this,qs,Ce(e))}get privateKey(){return T(this,qs)}get publicKey(){return gc.computePublicKey(T(this,qs))}get compressedPublicKey(){return gc.computePublicKey(T(this,qs),!0)}sign(e){q(Ou(e)===32,"invalid digest length","digest",e);const t=Uo.sign(wn(e),wn(T(this,qs)),{lowS:!0});return Si.from({r:No(t.r,32),s:No(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=gc.computePublicKey(e);return Ce(Uo.getSharedSecret(wn(T(this,qs)),_t(t),!1))}static computePublicKey(e,t){let n=_t(e,"key");if(n.length===32){const s=Uo.getPublicKey(n,!!t);return Ce(s)}if(n.length===64){const s=new Uint8Array(65);s[0]=4,s.set(n,1),n=s}const i=Uo.ProjectivePoint.fromHex(n);return Ce(i.toRawBytes(t))}static recoverPublicKey(e,t){q(Ou(e)===32,"invalid digest length","digest",e);const n=Si.from(t);let i=Uo.Signature.fromCompact(wn(xr([n.r,n.s])));i=i.addRecoveryBit(n.yParity);const s=i.recoverPublicKey(wn(e));return q(s!=null,"invalid signautre for digest","signature",t),"0x"+s.toHex(!1)}static addPoints(e,t,n){const i=Uo.ProjectivePoint.fromHex(gc.computePublicKey(e).substring(2)),s=Uo.ProjectivePoint.fromHex(gc.computePublicKey(t).substring(2));return"0x"+i.add(s).toHex(!!n)}};qs=new WeakMap;let yh=gc;const XX=BigInt(0),eee=BigInt(36);function dO(r){r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const n=_t(Nr(t));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const kw={};for(let r=0;r<10;r++)kw[String(r)]=String(r);for(let r=0;r<26;r++)kw[String.fromCharCode(65+r)]=String(10+r);const pO=15;function tee(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>kw[n]).join("");for(;e.length>=pO;){let n=e.substring(0,pO);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const ree=function(){const r={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];r[t]=BigInt(e)}return r}();function nee(r){r=r.toLowerCase();let e=XX;for(let t=0;t<r.length;t++)e=e*eee+ree[r[t]];return e}function Mt(r){if(q(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const e=dO(r);return q(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===r,"bad address checksum","address",r),e}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){q(r.substring(2,4)===tee(r),"bad icap checksum","address",r);let e=nee(r.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return dO("0x"+e)}q(!1,"invalid address","address",r)}function iee(r){const e=Mt(r.from);let n=Le(r.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,Mt(lr(Nr(ja([e,n])),12))}function gO(r){return r&&typeof r.getAddress=="function"}async function Tw(r,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(ge(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),q(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),Mt(t)}function An(r,e){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?Mt(r):(ge(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Tw(r,e.resolveName(r)));if(gO(r))return Tw(r,r.getAddress());if(r&&typeof r.then=="function")return Tw(r,r);q(!1,"unsupported addressable value","target",r)}const Fs={};function Oe(r,e){let t=!1;return e<0&&(t=!0,e*=-1),new an(Fs,`${t?"":"u"}int${e}`,r,{signed:t,width:e})}function Et(r,e){return new an(Fs,`bytes${e||""}`,r,{size:e})}const yO=Symbol.for("_ethers_typed"),Zs=class Zs{constructor(e,t,n,i){Q(this,"type");Q(this,"value");se(this,yc);Q(this,"_typedSymbol");i==null&&(i=null),cp(Fs,e,"Typed"),ze(this,{_typedSymbol:yO,type:t,value:n}),F(this,yc,i),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,yc)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,yc)===!0?-1:T(this,yc)===!1?this.value.length:null}static from(e,t){return new Zs(Fs,e,t)}static uint8(e){return Oe(e,8)}static uint16(e){return Oe(e,16)}static uint24(e){return Oe(e,24)}static uint32(e){return Oe(e,32)}static uint40(e){return Oe(e,40)}static uint48(e){return Oe(e,48)}static uint56(e){return Oe(e,56)}static uint64(e){return Oe(e,64)}static uint72(e){return Oe(e,72)}static uint80(e){return Oe(e,80)}static uint88(e){return Oe(e,88)}static uint96(e){return Oe(e,96)}static uint104(e){return Oe(e,104)}static uint112(e){return Oe(e,112)}static uint120(e){return Oe(e,120)}static uint128(e){return Oe(e,128)}static uint136(e){return Oe(e,136)}static uint144(e){return Oe(e,144)}static uint152(e){return Oe(e,152)}static uint160(e){return Oe(e,160)}static uint168(e){return Oe(e,168)}static uint176(e){return Oe(e,176)}static uint184(e){return Oe(e,184)}static uint192(e){return Oe(e,192)}static uint200(e){return Oe(e,200)}static uint208(e){return Oe(e,208)}static uint216(e){return Oe(e,216)}static uint224(e){return Oe(e,224)}static uint232(e){return Oe(e,232)}static uint240(e){return Oe(e,240)}static uint248(e){return Oe(e,248)}static uint256(e){return Oe(e,256)}static uint(e){return Oe(e,256)}static int8(e){return Oe(e,-8)}static int16(e){return Oe(e,-16)}static int24(e){return Oe(e,-24)}static int32(e){return Oe(e,-32)}static int40(e){return Oe(e,-40)}static int48(e){return Oe(e,-48)}static int56(e){return Oe(e,-56)}static int64(e){return Oe(e,-64)}static int72(e){return Oe(e,-72)}static int80(e){return Oe(e,-80)}static int88(e){return Oe(e,-88)}static int96(e){return Oe(e,-96)}static int104(e){return Oe(e,-104)}static int112(e){return Oe(e,-112)}static int120(e){return Oe(e,-120)}static int128(e){return Oe(e,-128)}static int136(e){return Oe(e,-136)}static int144(e){return Oe(e,-144)}static int152(e){return Oe(e,-152)}static int160(e){return Oe(e,-160)}static int168(e){return Oe(e,-168)}static int176(e){return Oe(e,-176)}static int184(e){return Oe(e,-184)}static int192(e){return Oe(e,-192)}static int200(e){return Oe(e,-200)}static int208(e){return Oe(e,-208)}static int216(e){return Oe(e,-216)}static int224(e){return Oe(e,-224)}static int232(e){return Oe(e,-232)}static int240(e){return Oe(e,-240)}static int248(e){return Oe(e,-248)}static int256(e){return Oe(e,-256)}static int(e){return Oe(e,-256)}static bytes1(e){return Et(e,1)}static bytes2(e){return Et(e,2)}static bytes3(e){return Et(e,3)}static bytes4(e){return Et(e,4)}static bytes5(e){return Et(e,5)}static bytes6(e){return Et(e,6)}static bytes7(e){return Et(e,7)}static bytes8(e){return Et(e,8)}static bytes9(e){return Et(e,9)}static bytes10(e){return Et(e,10)}static bytes11(e){return Et(e,11)}static bytes12(e){return Et(e,12)}static bytes13(e){return Et(e,13)}static bytes14(e){return Et(e,14)}static bytes15(e){return Et(e,15)}static bytes16(e){return Et(e,16)}static bytes17(e){return Et(e,17)}static bytes18(e){return Et(e,18)}static bytes19(e){return Et(e,19)}static bytes20(e){return Et(e,20)}static bytes21(e){return Et(e,21)}static bytes22(e){return Et(e,22)}static bytes23(e){return Et(e,23)}static bytes24(e){return Et(e,24)}static bytes25(e){return Et(e,25)}static bytes26(e){return Et(e,26)}static bytes27(e){return Et(e,27)}static bytes28(e){return Et(e,28)}static bytes29(e){return Et(e,29)}static bytes30(e){return Et(e,30)}static bytes31(e){return Et(e,31)}static bytes32(e){return Et(e,32)}static address(e){return new Zs(Fs,"address",e)}static bool(e){return new Zs(Fs,"bool",!!e)}static bytes(e){return new Zs(Fs,"bytes",e)}static string(e){return new Zs(Fs,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Zs(Fs,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===yO}static dereference(e,t){if(Zs.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};yc=new WeakMap;let an=Zs;class see extends Ds{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=an.dereference(t,"string");try{n=Mt(n)}catch(i){return this._throwError(i.message,t)}return e.writeValue(n)}decode(e){return Mt(No(e.readValue(),20))}}class oee extends Ds{constructor(t){super(t.name,t.type,"_",t.dynamic);Q(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,n){return this.coder.encode(t,n)}decode(t){return this.coder.decode(t)}}function mO(r,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let u={};n=e.map(l=>{const h=l.localName;return ge(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),ge(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),u[h]=!0,t[h]})}else q(!1,"invalid tuple value","tuple",t);q(e.length===n.length,"types/value length mismatch","tuple",t);let i=new uw,s=new uw,o=[];e.forEach((u,l)=>{let h=n[l];if(u.dynamic){let g=s.length;u.encode(s,h);let b=i.writeUpdatableValue();o.push(w=>{b(w+g)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let a=r.appendWriter(i);return a+=r.appendWriter(s),a}function wO(r,e){let t=[],n=[],i=r.subReader(0);return e.forEach(s=>{let o=null;if(s.dynamic){let a=r.readIndex(),u=i.subReader(a);try{o=s.decode(u)}catch(l){if(Qr(l,"BUFFER_OVERRUN"))throw l;o=l,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(r)}catch(a){if(Qr(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=s.name,o.name=s.localName,o.type=s.type}if(o==null)throw new Error("investigate");t.push(o),n.push(s.localName||null)}),Bu.fromItems(t,n)}class aee extends Ds{constructor(t,n,i){const s=t.type+"["+(n>=0?n:"")+"]",o=n===-1||t.dynamic;super("array",s,i,o);Q(this,"coder");Q(this,"length");ze(this,{coder:t,length:n})}defaultValue(){const t=this.coder.defaultValue(),n=[];for(let i=0;i<this.length;i++)n.push(t);return n}encode(t,n){const i=an.dereference(n,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,t.writeValue(i.length)),Yk(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<i.length;a++)o.push(this.coder);return mO(t,o,i)}decode(t){let n=this.length;n===-1&&(n=t.readIndex(),ge(n*_n<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:n*_n,length:t.dataLength}));let i=[];for(let s=0;s<n;s++)i.push(new oee(this.coder));return wO(t,i)}}class cee extends Ds{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=an.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class bO extends Ds{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=wn(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class uee extends bO{constructor(e){super("bytes",e)}decode(e){return Ce(super.decode(e))}}class lee extends Ds{constructor(t,n){let i="bytes"+String(t);super(i,i,n,!1);Q(this,"size");ze(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,n){let i=wn(an.dereference(n,this.type));return i.length!==this.size&&this._throwError("incorrect data length",n),t.writeBytes(i)}decode(t){return Ce(t.readBytes(this.size))}}const fee=new Uint8Array([]);class hee extends Ds{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(fee)}decode(e){return e.readBytes(0),null}}const dee=BigInt(0),pee=BigInt(1),gee=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class yee extends Ds{constructor(t,n,i){const s=(n?"int":"uint")+t*8;super(s,s,i,!1);Q(this,"size");Q(this,"signed");ze(this,{size:t,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,n){let i=Le(an.dereference(n,this.type)),s=lh(gee,_n*8);if(this.signed){let o=lh(s,this.size*8-1);(i>o||i<-(o+pee))&&this._throwError("value out-of-bounds",n),i=tT(i,8*_n)}else(i<dee||i>lh(s,this.size*8))&&this._throwError("value out-of-bounds",n);return t.writeValue(i)}decode(t){let n=lh(t.readValue(),this.size*8);return this.signed&&(n=AJ(n,this.size*8)),n}}class mee extends bO{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Ls(an.dereference(t,"string")))}decode(e){return fp(super.decode(e))}}class vp extends Ds{constructor(t,n){let i=!1;const s=[];t.forEach(a=>{a.dynamic&&(i=!0),s.push(a.type)});const o="tuple("+s.join(",")+")";super("tuple",o,n,i);Q(this,"coders");ze(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(i=>{t.push(i.defaultValue())});const n=this.coders.reduce((i,s)=>{const o=s.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,s)=>{let o=i.localName;!o||n[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[s]))}),Object.freeze(t)}encode(t,n){const i=an.dereference(n,"tuple");return mO(t,this.coders,i)}decode(t){return wO(t,this.coders)}}function Za(r){return Nr(Ls(r))}var wee="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const _O=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),AO=4;function bee(r){let e=0;function t(){return r[e++]<<8|r[e++]}let n=t(),i=1,s=[0,1];for(let W=1;W<n;W++)s.push(i+=t());let o=t(),a=e;e+=o;let u=0,l=0;function h(){return u==0&&(l=l<<8|r[e++],u=8),l>>--u&1}const g=31,b=2**g,w=b>>>1,I=w>>1,S=b-1;let x=0;for(let W=0;W<g;W++)x=x<<1|h();let C=[],H=0,D=b;for(;;){let W=Math.floor(((x-H+1)*i-1)/D),Z=0,j=n;for(;j-Z>1;){let ce=Z+j>>>1;W<s[ce]?j=ce:Z=ce}if(Z==0)break;C.push(Z);let V=H+Math.floor(D*s[Z]/i),oe=H+Math.floor(D*s[Z+1]/i)-1;for(;!((V^oe)&w);)x=x<<1&S|h(),V=V<<1&S,oe=oe<<1&S|1;for(;V&~oe&I;)x=x&w|x<<1&S>>>1|h(),V=V<<1^w,oe=(oe^w)<<1|w|1;H=V,D=1+oe-V}let z=n-4;return C.map(W=>{switch(W-z){case 3:return z+65792+(r[a++]<<16|r[a++]<<8|r[a++]);case 2:return z+256+(r[a++]<<8|r[a++]);case 1:return z+r[a++];default:return W-1}})}function _ee(r){let e=0;return()=>r[e++]}function vO(r){return _ee(bee(Aee(r)))}function Aee(r){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>e[i.charCodeAt(0)]=s);let t=r.length,n=new Uint8Array(6*t>>3);for(let i=0,s=0,o=0,a=0;i<t;i++)a=a<<6|e[r.charCodeAt(i)],o+=6,o>=8&&(n[s++]=a>>(o-=8));return n}function vee(r){return r&1?~r>>1:r>>1}function Eee(r,e){let t=Array(r);for(let n=0,i=0;n<r;n++)t[n]=i+=vee(e());return t}function mh(r,e=0){let t=[];for(;;){let n=r(),i=r();if(!i)break;e+=n;for(let s=0;s<i;s++)t.push(e+s);e+=i+1}return t}function EO(r){return wh(()=>{let e=mh(r);if(e.length)return e})}function xO(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(xee(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(Ree(t,r))}return e.flat()}function wh(r){let e=[];for(;;){let t=r(e.length);if(!t)break;e.push(t)}return e}function RO(r,e,t){let n=Array(r).fill().map(()=>[]);for(let i=0;i<e;i++)Eee(r,t).forEach((s,o)=>n[o].push(s));return n}function xee(r,e){let t=1+e(),n=e(),i=wh(e);return RO(i.length,1+r,e).flatMap((o,a)=>{let[u,...l]=o;return Array(i[a]).fill().map((h,g)=>{let b=g*n;return[u+g*t,l.map(w=>w+b)]})})}function Ree(r,e){let t=1+e();return RO(t,1+r,e).map(i=>[i[0],i.slice(1)])}function Iee(r){let e=[],t=mh(r);return i(n([]),[]),e;function n(s){let o=r(),a=wh(()=>{let u=mh(r).map(l=>t[l]);if(u.length)return n(u)});return{S:o,B:a,Q:s}}function i({S:s,B:o},a,u){if(!(s&4&&u===a[a.length-1])){s&2&&(u=a[a.length-1]),s&1&&e.push(a);for(let l of o)for(let h of l.Q)i(l,[...a,h],u)}}}function See(r){return r.toString(16).toUpperCase().padStart(2,"0")}function IO(r){return`{${See(r)}}`}function kee(r){let e=[];for(let t=0,n=r.length;t<n;){let i=r.codePointAt(t);t+=i<65536?1:2,e.push(i)}return e}function Fu(r){let t=r.length;if(t<4096)return String.fromCodePoint(...r);let n=[];for(let i=0;i<t;)n.push(String.fromCodePoint(...r.slice(i,i+=4096)));return n.join("")}function Tee(r,e){let t=r.length,n=t-e.length;for(let i=0;n==0&&i<t;i++)n=r[i]-e[i];return n}var Oee="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const bh=44032,Ep=4352,xp=4449,Rp=4519,SO=19,kO=21,Hu=28,Ip=kO*Hu,Nee=SO*Ip,Cee=bh+Nee,Bee=Ep+SO,Pee=xp+kO,Mee=Rp+Hu;function _h(r){return r>>24&255}function TO(r){return r&16777215}let Ow,OO,Nw,Sp;function Lee(){let r=vO(Oee);Ow=new Map(EO(r).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),OO=new Set(mh(r)),Nw=new Map,Sp=new Map;for(let[e,t]of xO(r)){if(!OO.has(e)&&t.length==2){let[n,i]=t,s=Sp.get(n);s||(s=new Map,Sp.set(n,s)),s.set(i,e)}Nw.set(e,t.reverse())}}function NO(r){return r>=bh&&r<Cee}function Uee(r,e){if(r>=Ep&&r<Bee&&e>=xp&&e<Pee)return bh+(r-Ep)*Ip+(e-xp)*Hu;if(NO(r)&&e>Rp&&e<Mee&&(r-bh)%Hu==0)return r+(e-Rp);{let t=Sp.get(r);return t&&(t=t.get(e),t)?t:-1}}function CO(r){Ow||Lee();let e=[],t=[],n=!1;function i(s){let o=Ow.get(s);o&&(n=!0,s|=o),e.push(s)}for(let s of r)for(;;){if(s<128)e.push(s);else if(NO(s)){let o=s-bh,a=o/Ip|0,u=o%Ip/Hu|0,l=o%Hu;i(Ep+a),i(xp+u),l>0&&i(Rp+l)}else{let o=Nw.get(s);o?t.push(...o):i(s)}if(!t.length)break;s=t.pop()}if(n&&e.length>1){let s=_h(e[0]);for(let o=1;o<e.length;o++){let a=_h(e[o]);if(a==0||s<=a){s=a;continue}let u=o-1;for(;;){let l=e[u+1];if(e[u+1]=e[u],e[u]=l,!u||(s=_h(e[--u]),s<=a))break}s=_h(e[o])}}return e}function Dee(r){let e=[],t=[],n=-1,i=0;for(let s of r){let o=_h(s),a=TO(s);if(n==-1)o==0?n=a:e.push(a);else if(i>0&&i>=o)o==0?(e.push(n,...t),t.length=0,n=a):t.push(a),i=o;else{let u=Uee(n,a);u>=0?n=u:i==0&&o==0?(e.push(n),n=a):(t.push(a),i=o)}}return n>=0&&e.push(n,...t),e}function BO(r){return CO(r).map(TO)}function $ee(r){return Dee(CO(r))}const PO=45,MO=".",LO=65039,UO=1,kp=r=>Array.from(r);function Ah(r,e){return r.P.has(e)||r.Q.has(e)}class Fee extends Array{get is_emoji(){return!0}}let Cw,DO,Qa,Bw,$O,zu,Pw,Gu,Ya,FO,Mw;function Lw(){if(Cw)return;let r=vO(wee);const e=()=>mh(r),t=()=>new Set(e()),n=(h,g)=>g.forEach(b=>h.add(b));Cw=new Map(xO(r)),DO=t(),Qa=e(),Bw=new Set(e().map(h=>Qa[h])),Qa=new Set(Qa),$O=t(),t();let i=EO(r),s=r();const o=()=>{let h=new Set;return e().forEach(g=>n(h,i[g])),n(h,e()),h};zu=wh(h=>{let g=wh(r).map(b=>b+96);if(g.length){let b=h>=s;g[0]-=32,g=Fu(g),b&&(g=`Restricted[${g}]`);let w=o(),I=o(),S=!r();return{N:g,P:w,Q:I,M:S,R:b}}}),Pw=t(),Gu=new Map;let a=e().concat(kp(Pw)).sort((h,g)=>h-g);a.forEach((h,g)=>{let b=r(),w=a[g]=b?a[g-b]:{V:[],M:new Map};w.V.push(h),Pw.has(h)||Gu.set(h,w)});for(let{V:h,M:g}of new Set(Gu.values())){let b=[];for(let I of h){let S=zu.filter(C=>Ah(C,I)),x=b.find(({G:C})=>S.some(H=>C.has(H)));x||(x={G:new Set,V:[]},b.push(x)),x.V.push(I),n(x.G,S)}let w=b.flatMap(I=>kp(I.G));for(let{G:I,V:S}of b){let x=new Set(w.filter(C=>!I.has(C)));for(let C of S)g.set(C,x)}}Ya=new Set;let u=new Set;const l=h=>Ya.has(h)?u.add(h):Ya.add(h);for(let h of zu){for(let g of h.P)l(g);for(let g of h.Q)l(g)}for(let h of Ya)!Gu.has(h)&&!u.has(h)&&Gu.set(h,UO);n(Ya,BO(Ya)),FO=Iee(r).map(h=>Fee.from(h)).sort(Tee),Mw=new Map;for(let h of FO){let g=[Mw];for(let b of h){let w=g.map(I=>{let S=I.get(b);return S||(S=new Map,I.set(b,S)),S});b===LO?g.push(...w):g=w}for(let b of g)b.V=h}}function Uw(r){return(HO(r)?"":`${Dw(Tp([r]))} `)+IO(r)}function Dw(r){return`"${r}"‎`}function Hee(r){if(r.length>=4&&r[2]==PO&&r[3]==PO)throw new Error(`invalid label extension: "${Fu(r.slice(0,4))}"`)}function zee(r){for(let t=r.lastIndexOf(95);t>0;)if(r[--t]!==95)throw new Error("underscore allowed only at start")}function Gee(r){let e=r[0],t=_O.get(e);if(t)throw vh(`leading ${t}`);let n=r.length,i=-1;for(let s=1;s<n;s++){e=r[s];let o=_O.get(e);if(o){if(i==s)throw vh(`${t} + ${o}`);i=s+1,t=o}}if(i==n)throw vh(`trailing ${t}`)}function Tp(r,e=1/0,t=IO){let n=[];jee(r[0])&&n.push("◌"),r.length>e&&(e>>=1,r=[...r.slice(0,e),8230,...r.slice(-e)]);let i=0,s=r.length;for(let o=0;o<s;o++){let a=r[o];HO(a)&&(n.push(Fu(r.slice(i,o))),n.push(t(a)),i=o+1)}return n.push(Fu(r.slice(i,s))),n.join("")}function jee(r){return Lw(),Qa.has(r)}function HO(r){return Lw(),$O.has(r)}function Kee(r){return Zee(Vee(r,$ee,Jee))}function Vee(r,e,t){if(!r)return[];Lw();let n=0;return r.split(MO).map(i=>{let s=kee(i),o={input:s,offset:n};n+=s.length+1;try{let a=o.tokens=Yee(s,e,t),u=a.length,l;if(!u)throw new Error("empty label");let h=o.output=a.flat();if(zee(h),!(o.emoji=u>1||a[0].is_emoji)&&h.every(b=>b<128))Hee(h),l="ASCII";else{let b=a.flatMap(w=>w.is_emoji?[]:w);if(!b.length)l="Emoji";else{if(Qa.has(h[0]))throw vh("leading combining mark");for(let S=1;S<u;S++){let x=a[S];if(!x.is_emoji&&Qa.has(x[0]))throw vh(`emoji + combining mark: "${Fu(a[S-1])} + ${Tp([x[0]])}"`)}Gee(h);let w=kp(new Set(b)),[I]=qee(w);Qee(I,b),Wee(I,w),l=I.N}}o.type=l}catch(a){o.error=a}return o})}function Wee(r,e){let t,n=[];for(let i of e){let s=Gu.get(i);if(s===UO)return;if(s){let o=s.M.get(i);if(t=t?t.filter(a=>o.has(a)):kp(o),!t.length)return}else n.push(i)}if(t){for(let i of t)if(n.every(s=>Ah(i,s)))throw new Error(`whole-script confusable: ${r.N}/${i.N}`)}}function qee(r){let e=zu;for(let t of r){let n=e.filter(i=>Ah(i,t));if(!n.length)throw zu.some(i=>Ah(i,t))?GO(e[0],t):zO(t);if(e=n,n.length==1)break}return e}function Zee(r){return r.map(({input:e,error:t,output:n})=>{if(t){let i=t.message;throw new Error(r.length==1?i:`Invalid label ${Dw(Tp(e,63))}: ${i}`)}return Fu(n)}).join(MO)}function zO(r){return new Error(`disallowed character: ${Uw(r)}`)}function GO(r,e){let t=Uw(e),n=zu.find(i=>i.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${r.N} + ${t}`)}function vh(r){return new Error(`illegal placement: ${r}`)}function Qee(r,e){for(let t of e)if(!Ah(r,t))throw GO(r,t);if(r.M){let t=BO(e);for(let n=1,i=t.length;n<i;n++)if(Bw.has(t[n])){let s=n+1;for(let o;s<i&&Bw.has(o=t[s]);s++)for(let a=n;a<s;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${Uw(o)}`);if(s-n>AO)throw new Error(`excessive non-spacing marks: ${Dw(Tp(t.slice(n-1,s)))} (${s-n}/${AO})`);n=s}}}function Yee(r,e,t){let n=[],i=[];for(r=r.slice().reverse();r.length;){let s=Xee(r);if(s)i.length&&(n.push(e(i)),i=[]),n.push(t(s));else{let o=r.pop();if(Ya.has(o))i.push(o);else{let a=Cw.get(o);if(a)i.push(...a);else if(!DO.has(o))throw zO(o)}}}return i.length&&n.push(e(i)),n}function Jee(r){return r.filter(e=>e!=LO)}function Xee(r,e){let t=Mw,n,i=r.length;for(;i&&(t=t.get(r[--i]),!!t);){let{V:s}=t;s&&(n=s,r.length=i)}return n}const jO=new Uint8Array(32);jO.fill(0);function KO(r){return q(r.length!==0,"invalid ENS name; empty component","comp",r),r}function VO(r){const e=Ls(ete(r)),t=[];if(r.length===0)return t;let n=0;for(let i=0;i<e.length;i++)e[i]===46&&(t.push(KO(e.slice(n,i))),n=i+1);return q(n<e.length,"invalid ENS name; empty component","name",r),t.push(KO(e.slice(n))),t}function ete(r){try{if(r.length===0)throw new Error("empty label");return Kee(r)}catch(e){q(!1,`invalid ENS name (${e.message})`,"name",r)}}function $w(r){q(typeof r=="string","invalid ENS name; not a string","name",r),q(r.length,"invalid ENS name (empty label)","name",r);let e=jO;const t=VO(r);for(;t.length;)e=Nr(xr([e,Nr(t.pop())]));return Ce(e)}function tte(r,e){const t=e;return q(t<=255,"DNS encoded label cannot exceed 255","length",t),Ce(xr(VO(r).map(n=>{q(n.length<=t,`label ${JSON.stringify(r)} exceeds ${t} bytes`,"name",r);const i=new Uint8Array(n.length+1);return i.set(n,1),i[0]=i.length-1,i})))+"00"}function Fw(r,e){return{address:Mt(r),storageKeys:e.map((t,n)=>(q(Gt(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function Ja(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(q(t.length===2,"invalid slot set",`value[${n}]`,t),Fw(t[0],t[1])):(q(t!=null&&typeof t=="object","invalid address-slot set","value",r),Fw(t.address,t.storageKeys)));q(r!=null&&typeof r=="object","invalid access list","value",r);const e=Object.keys(r).map(t=>{const n=r[t].reduce((i,s)=>(i[s]=!0,i),{});return Fw(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function rte(r){let e;return typeof r=="string"?e=yh.computePublicKey(r,!1):e=r.publicKey,Mt(Nr("0x"+e.substring(4)).substring(26))}function nte(r,e){return rte(yh.recoverPublicKey(r,e))}const Fr=BigInt(0),ite=BigInt(2),ste=BigInt(27),ote=BigInt(28),ate=BigInt(35),cte=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Hw=4096*32;function WO(r,e){let t=r.toString(16);for(;t.length<2;)t="0"+t;return t+=Mu(e).substring(4),"0x"+t}function Op(r){return r==="0x"?null:Mt(r)}function zw(r,e){try{return Ja(r)}catch(t){q(!1,t.message,e,r)}}function Eh(r,e){return r==="0x"?0:at(r,e)}function Ir(r,e){if(r==="0x")return Fr;const t=Le(r,e);return q(t<=cte,"value exceeds uint size",e,t),t}function qt(r,e){const t=Le(r,"value"),n=bn(t);return q(n.length<=32,"value too large",`tx.${e}`,t),n}function Gw(r){return Ja(r).map(e=>[e.address,e.storageKeys])}function ute(r,e){q(Array.isArray(r),`invalid ${e}`,"value",r);for(let t=0;t<r.length;t++)q(Gt(r[t],32),"invalid ${ param } hash",`value[${t}]`,r[t]);return r}function lte(r){const e=pp(r);q(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",r);const t={type:0,nonce:Eh(e[0],"nonce"),gasPrice:Ir(e[1],"gasPrice"),gasLimit:Ir(e[2],"gasLimit"),to:Op(e[3]),value:Ir(e[4],"value"),data:Ce(e[5]),chainId:Fr};if(e.length===6)return t;const n=Ir(e[6],"v"),i=Ir(e[7],"r"),s=Ir(e[8],"s");if(i===Fr&&s===Fr)t.chainId=n;else{let o=(n-ate)/ite;o<Fr&&(o=Fr),t.chainId=o,q(o!==Fr||n===ste||n===ote,"non-canonical legacy v","v",e[6]),t.signature=Si.from({r:Ga(e[7],32),s:Ga(e[8],32),v:n})}return t}function fte(r,e){const t=[qt(r.nonce,"nonce"),qt(r.gasPrice||0,"gasPrice"),qt(r.gasLimit,"gasLimit"),r.to||"0x",qt(r.value,"value"),r.data];let n=Fr;if(r.chainId!=Fr)n=Le(r.chainId,"tx.chainId"),q(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(r.signature){const s=r.signature.legacyChainId;s!=null&&(n=s)}if(!e)return n!==Fr&&(t.push(bn(n)),t.push("0x"),t.push("0x")),ja(t);let i=BigInt(27+e.yParity);return n!==Fr?i=Si.getChainIdV(n,e.v):BigInt(e.v)!==i&&q(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(bn(i)),t.push(bn(e.r)),t.push(bn(e.s)),ja(t)}function jw(r,e){let t;try{if(t=Eh(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{q(!1,"invalid yParity","yParity",e[0])}const n=Ga(e[1],32),i=Ga(e[2],32),s=Si.from({r:n,s:i,yParity:t});r.signature=s}function hte(r){const e=pp(_t(r).slice(1));q(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",Ce(r));const t={type:2,chainId:Ir(e[0],"chainId"),nonce:Eh(e[1],"nonce"),maxPriorityFeePerGas:Ir(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ir(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ir(e[4],"gasLimit"),to:Op(e[5]),value:Ir(e[6],"value"),data:Ce(e[7]),accessList:zw(e[8],"accessList")};return e.length===9||jw(t,e.slice(9)),t}function dte(r,e){const t=[qt(r.chainId,"chainId"),qt(r.nonce,"nonce"),qt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),qt(r.maxFeePerGas||0,"maxFeePerGas"),qt(r.gasLimit,"gasLimit"),r.to||"0x",qt(r.value,"value"),r.data,Gw(r.accessList||[])];return e&&(t.push(qt(e.yParity,"yParity")),t.push(bn(e.r)),t.push(bn(e.s))),xr(["0x02",ja(t)])}function pte(r){const e=pp(_t(r).slice(1));q(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",Ce(r));const t={type:1,chainId:Ir(e[0],"chainId"),nonce:Eh(e[1],"nonce"),gasPrice:Ir(e[2],"gasPrice"),gasLimit:Ir(e[3],"gasLimit"),to:Op(e[4]),value:Ir(e[5],"value"),data:Ce(e[6]),accessList:zw(e[7],"accessList")};return e.length===8||jw(t,e.slice(8)),t}function gte(r,e){const t=[qt(r.chainId,"chainId"),qt(r.nonce,"nonce"),qt(r.gasPrice||0,"gasPrice"),qt(r.gasLimit,"gasLimit"),r.to||"0x",qt(r.value,"value"),r.data,Gw(r.accessList||[])];return e&&(t.push(qt(e.yParity,"recoveryParam")),t.push(bn(e.r)),t.push(bn(e.s))),xr(["0x01",ja(t)])}function yte(r){let e=pp(_t(r).slice(1)),t="3",n=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const s=e[1],o=e[2],a=e[3];q(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),q(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),q(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),q(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),q(s.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let u=0;u<e[1].length;u++)n.push({data:s[u],commitment:o[u],proof:a[u]});e=e[0]}q(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",Ce(r));const i={type:3,chainId:Ir(e[0],"chainId"),nonce:Eh(e[1],"nonce"),maxPriorityFeePerGas:Ir(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ir(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ir(e[4],"gasLimit"),to:Op(e[5]),value:Ir(e[6],"value"),data:Ce(e[7]),accessList:zw(e[8],"accessList"),maxFeePerBlobGas:Ir(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),q(i.to!=null,`invalid address for transaction type: ${t}`,"data",r),q(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",r);for(let s=0;s<i.blobVersionedHashes.length;s++)q(Gt(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",r);return e.length===11||jw(i,e.slice(11)),i}function mte(r,e,t){const n=[qt(r.chainId,"chainId"),qt(r.nonce,"nonce"),qt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),qt(r.maxFeePerGas||0,"maxFeePerGas"),qt(r.gasLimit,"gasLimit"),r.to||gh,qt(r.value,"value"),r.data,Gw(r.accessList||[]),qt(r.maxFeePerBlobGas||0,"maxFeePerBlobGas"),ute(r.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(qt(e.yParity,"yParity")),n.push(bn(e.r)),n.push(bn(e.s)),t)?xr(["0x03",ja([n,t.map(i=>i.data),t.map(i=>i.commitment),t.map(i=>i.proof)])]):xr(["0x03",ja(n)])}const Ys=class Ys{constructor(){se(this,wl);se(this,cs);se(this,al);se(this,cl);se(this,ul);se(this,ll);se(this,fl);se(this,hl);se(this,dl);se(this,pl);se(this,gl);se(this,yl);se(this,ml);se(this,mc);se(this,zo);se(this,Qs);se(this,Go);F(this,cs,null),F(this,al,null),F(this,ul,0),F(this,ll,Fr),F(this,fl,null),F(this,hl,null),F(this,dl,null),F(this,cl,"0x"),F(this,pl,Fr),F(this,gl,Fr),F(this,yl,null),F(this,ml,null),F(this,mc,null),F(this,zo,null),F(this,Go,null),F(this,Qs,null)}get type(){return T(this,cs)}set type(e){switch(e){case null:F(this,cs,null);break;case 0:case"legacy":F(this,cs,0);break;case 1:case"berlin":case"eip-2930":F(this,cs,1);break;case 2:case"london":case"eip-1559":F(this,cs,2);break;case 3:case"cancun":case"eip-4844":F(this,cs,3);break;default:q(!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=T(this,al);return e==null&&this.type===3?gh:e}set to(e){F(this,al,e==null?null:Mt(e))}get nonce(){return T(this,ul)}set nonce(e){F(this,ul,at(e,"value"))}get gasLimit(){return T(this,ll)}set gasLimit(e){F(this,ll,Le(e))}get gasPrice(){const e=T(this,fl);return e==null&&(this.type===0||this.type===1)?Fr:e}set gasPrice(e){F(this,fl,e==null?null:Le(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,hl);return e??(this.type===2||this.type===3?Fr:null)}set maxPriorityFeePerGas(e){F(this,hl,e==null?null:Le(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,dl);return e??(this.type===2||this.type===3?Fr:null)}set maxFeePerGas(e){F(this,dl,e==null?null:Le(e,"maxFeePerGas"))}get data(){return T(this,cl)}set data(e){F(this,cl,Ce(e))}get value(){return T(this,pl)}set value(e){F(this,pl,Le(e,"value"))}get chainId(){return T(this,gl)}set chainId(e){F(this,gl,Le(e))}get signature(){return T(this,yl)||null}set signature(e){F(this,yl,e==null?null:Si.from(e))}get accessList(){const e=T(this,ml)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){F(this,ml,e==null?null:Ja(e))}get maxFeePerBlobGas(){const e=T(this,mc);return e==null&&this.type===3?Fr:e}set maxFeePerBlobGas(e){F(this,mc,e==null?null:Le(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,zo);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){q(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)q(Gt(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}F(this,zo,e)}get blobs(){return T(this,Go)==null?null:T(this,Go).map(e=>Object.assign({},e))}set blobs(e){if(e==null){F(this,Go,null);return}const t=[],n=[];for(let i=0;i<e.length;i++){const s=e[i];if(iw(s)){ge(T(this,Qs),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=_t(s);if(q(o.length<=Hw,"blob is too large",`blobs[${i}]`,s),o.length!==Hw){const l=new Uint8Array(Hw);l.set(o),o=l}const a=T(this,Qs).blobToKzgCommitment(o),u=Ce(T(this,Qs).computeBlobKzgProof(o,a));t.push({data:Ce(o),commitment:Ce(a),proof:u}),n.push(WO(1,a))}else{const o=Ce(s.commitment);t.push({data:Ce(s.data),commitment:o,proof:Ce(s.proof)}),n.push(WO(1,o))}}F(this,Go,t),F(this,zo,n)}get kzg(){return T(this,Qs)}set kzg(e){F(this,Qs,e)}get hash(){return this.signature==null?null:Nr(Ee(this,wl,mg).call(this,!0,!1))}get unsignedHash(){return Nr(this.unsignedSerialized)}get from(){return this.signature==null?null:nte(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:yh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return Ee(this,wl,mg).call(this,!0,!0)}get unsignedSerialized(){return Ee(this,wl,mg).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,i=T(this,mc)!=null||T(this,zo);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ge(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ge(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ge(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):t?s.push(2):e?(s.push(1),n||s.push(0)):n?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Ys.from(this)}toJSON(){const e=t=>t==null?null:t.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 Ys;if(typeof e=="string"){const n=_t(e);if(n[0]>=127)return Ys.from(lte(n));switch(n[0]){case 1:return Ys.from(pte(n));case 2:return Ys.from(hte(n));case 3:return Ys.from(yte(n))}ge(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Ys;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Si.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(q(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),q(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(q(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),q(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};cs=new WeakMap,al=new WeakMap,cl=new WeakMap,ul=new WeakMap,ll=new WeakMap,fl=new WeakMap,hl=new WeakMap,dl=new WeakMap,pl=new WeakMap,gl=new WeakMap,yl=new WeakMap,ml=new WeakMap,mc=new WeakMap,zo=new WeakMap,Qs=new WeakMap,Go=new WeakMap,wl=new WeakSet,mg=function(e,t){ge(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return fte(this,n);case 1:return gte(this,n);case 2:return dte(this,n);case 3:return mte(this,n,t?this.blobs:null)}ge(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Np=Ys;const qO=new Uint8Array(32);qO.fill(0);const wte=BigInt(-1),ZO=BigInt(0),QO=BigInt(1),bte=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function _te(r){const e=_t(r),t=e.length%32;return t?xr([e,qO.slice(t)]):Ce(e)}const Ate=No(QO,32),vte=No(ZO,32),YO={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Kw=["name","version","chainId","verifyingContract","salt"];function JO(r){return function(e){return q(typeof e=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}const Ete={name:JO("name"),version:JO("version"),chainId:function(r){const e=Le(r,"domain.chainId");return q(e>=0,"invalid chain ID","domain.chainId",r),Number.isSafeInteger(e)?Number(e):Cu(e)},verifyingContract:function(r){try{return Mt(r).toLowerCase()}catch{}q(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){const e=_t(r,"domain.salt");return q(e.length===32,'invalid domain value "salt"',"domain.salt",r),Ce(e)}};function Vw(r){{const e=r.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);q(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",r);const i=lh(bte,t?n-1:n),s=t?(i+QO)*wte:ZO;return function(o){const a=Le(o,"value");return q(a>=s&&a<=i,`value out-of-bounds for ${r}`,"value",a),No(t?tT(a,256):a,32)}}}{const e=r.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return q(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",r),function(n){const i=_t(n);return q(i.length===t,`invalid length for ${r}`,"value",n),_te(n)}}}switch(r){case"address":return function(e){return Ga(Mt(e),32)};case"bool":return function(e){return e?Ate:vte};case"bytes":return function(e){return Nr(e)};case"string":return function(e){return Za(e)}}return null}function XO(r,e){return`${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function Cp(r){const e=r.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:r}}const li=class li{constructor(e){se(this,Zp);Q(this,"primaryType");se(this,Ph);se(this,Js);se(this,bl);F(this,Js,new Map),F(this,bl,new Map);const t=new Map,n=new Map,i=new Map,s={};Object.keys(e).forEach(u=>{s[u]=e[u].map(({name:l,type:h})=>{let{base:g,index:b}=Cp(h);return g==="int"&&!e.int&&(g="int256"),g==="uint"&&!e.uint&&(g="uint256"),{name:l,type:g+(b||"")}}),t.set(u,new Set),n.set(u,[]),i.set(u,new Set)}),F(this,Ph,JSON.stringify(s));for(const u in s){const l=new Set;for(const h of s[u]){q(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",e),l.add(h.name);const g=Cp(h.type).base;q(g!==u,`circular type reference to ${JSON.stringify(g)}`,"types",e),!Vw(g)&&(q(n.has(g),`unknown type ${JSON.stringify(g)}`,"types",e),n.get(g).push(u),t.get(u).add(g))}}const o=Array.from(n.keys()).filter(u=>n.get(u).length===0);q(o.length!==0,"missing primary type","types",e),q(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",e),ze(this,{primaryType:o[0]});function a(u,l){q(!l.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",e),l.add(u);for(const h of t.get(u))if(n.has(h)){a(h,l);for(const g of l)i.get(g).add(h)}l.delete(u)}a(this.primaryType,new Set);for(const[u,l]of i){const h=Array.from(l);h.sort(),T(this,Js).set(u,XO(u,s[u])+h.map(g=>XO(g,s[g])).join(""))}}get types(){return JSON.parse(T(this,Ph))}getEncoder(e){let t=T(this,bl).get(e);return t||(t=Ee(this,Zp,h6).call(this,e),T(this,bl).set(e,t)),t}encodeType(e){const t=T(this,Js).get(e);return q(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Nr(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Vw(e))return n(e,t);const i=Cp(e).array;if(i)return q(i.count===-1||i.count===t.length,`array length mismatch; expected length ${i.count}`,"value",t),t.map(o=>this._visit(i.prefix,o,n));const s=this.types[e];if(s)return s.reduce((o,{name:a,type:u})=>(o[a]=this._visit(u,t[a],n),o),{});q(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new li(e)}static getPrimaryType(e){return li.from(e).primaryType}static hashStruct(e,t,n){return li.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const i=YO[n];q(i,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:i})}return t.sort((n,i)=>Kw.indexOf(n.name)-Kw.indexOf(i.name)),li.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return xr(["0x1901",li.hashDomain(e),li.from(t).hash(n)])}static hash(e,t,n){return Nr(li.encode(e,t,n))}static async resolveNames(e,t,n,i){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const s={};e.verifyingContract&&!Gt(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=li.from(t);o.visit(n,(a,u)=>(a==="address"&&!Gt(u,20)&&(s[u]="0x"),u));for(const a in s)s[a]=await i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=o.visit(n,(a,u)=>a==="address"&&s[u]?s[u]:u),{domain:e,value:n}}static getPayload(e,t,n){li.hashDomain(e);const i={},s=[];Kw.forEach(u=>{const l=e[u];l!=null&&(i[u]=Ete[u](l),s.push({name:u,type:YO[u]}))});const o=li.from(t);t=o.types;const a=Object.assign({},t);return q(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=s,o.encode(n),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(n,(u,l)=>{if(u.match(/^bytes(\d*)/))return Ce(_t(l));if(u.match(/^u?int/))return Le(l).toString();switch(u){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return q(typeof l=="string","invalid string","value",l),l}q(!1,"unsupported type","type",u)})}}};Ph=new WeakMap,Js=new WeakMap,bl=new WeakMap,Zp=new WeakSet,h6=function(e){{const i=Vw(e);if(i)return i}const t=Cp(e).array;if(t){const i=t.prefix,s=this.getEncoder(i);return o=>{q(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(s);return T(this,Js).has(i)&&(a=a.map(Nr)),Nr(xr(a))}}const n=this.types[e];if(n){const i=Za(T(this,Js).get(e));return s=>{const o=n.map(({name:a,type:u})=>{const l=this.getEncoder(u)(s[a]);return T(this,Js).has(u)?Nr(l):l});return o.unshift(i),xr(o)}}q(!1,`unknown type: ${e}`,"type",e)};let Bp=li;function vn(r){const e=new Set;return r.forEach(t=>e.add(t)),Object.freeze(e)}const xte=vn("external public payable override".split(" ")),eN="constant external internal payable private public pure view override",Rte=vn(eN.split(" ")),tN="constructor error event fallback function receive struct",rN=vn(tN.split(" ")),nN="calldata memory storage payable indexed",Ite=vn(nN.split(" ")),Ste=[tN,nN,"tuple returns",eN].join(" "),kte=vn(Ste.split(" ")),Tte={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Ote=new RegExp("^(\\s*)"),Nte=new RegExp("^([0-9]+)"),Cte=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),iN=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),sN=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Qp=class Qp{constructor(e){se(this,Mh);se(this,Xr);se(this,Bi);F(this,Xr,0),F(this,Bi,e.slice())}get offset(){return T(this,Xr)}get length(){return T(this,Bi).length-T(this,Xr)}clone(){return new Qp(T(this,Bi))}reset(){F(this,Xr,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=Ee(this,Mh,D_).call(this,T(this,Xr)+1,e.match+1);return F(this,Xr,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,Xr)<e.match-1;){const n=this.peek().linkNext;t.push(Ee(this,Mh,D_).call(this,T(this,Xr)+1,n)),F(this,Xr,n)}return F(this,Xr,e.match+1),t}peek(){if(T(this,Xr)>=T(this,Bi).length)throw new Error("out-of-bounds");return T(this,Bi)[T(this,Xr)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return bd(this,Xr)._++,e}toString(){const e=[];for(let t=T(this,Xr);t<T(this,Bi).length;t++){const n=T(this,Bi)[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}};Xr=new WeakMap,Bi=new WeakMap,Mh=new WeakSet,D_=function(e=0,t=0){return new Qp(T(this,Bi).slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))};let ki=Qp;function Do(r){const e=[],t=o=>{const a=s<r.length?JSON.stringify(r[s]):"$EOI";throw new Error(`invalid token ${a} at ${s}: ${o}`)};let n=[],i=[],s=0;for(;s<r.length;){let o=r.substring(s),a=o.match(Ote);a&&(s+=a[1].length,o=r.substring(s));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(u);let l=Tte[o[0]]||"";if(l){if(u.type=l,u.text=o[0],s++,l==="OPEN_PAREN")n.push(e.length-1),i.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),u.match=n.pop(),e[u.match].match=e.length-1,u.depth--,u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1;else if(l==="COMMA")u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1,i.push(e.length-1);else if(l==="OPEN_BRACKET")u.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const g=e.pop().text;h=g+h,e[e.length-1].value=at(g)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(a=o.match(Cte),a){if(u.text=a[1],s+=u.text.length,kte.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(sN)){u.type="TYPE";continue}u.type="ID";continue}if(a=o.match(Nte),a){u.text=a[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`)}return new ki(e.map(o=>Object.freeze(o)))}function oN(r,e){let t=[];for(const n in e.keys())r.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Pp(r,e){if(e.peekKeyword(rN)){const t=e.pop().text;if(t!==r)throw new Error(`expected ${r}, got ${t}`)}return e.popType("ID")}function Hs(r,e){const t=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(r.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function aN(r){let e=Hs(r,Rte);return oN(e,vn("constant payable nonpayable".split(" "))),oN(e,vn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function zs(r,e){return r.popParams().map(t=>Yr.from(t,e))}function cN(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return Le(r.pop().text);throw new Error("invalid gas")}return null}function Xa(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const Bte=new RegExp(/^(.*)\[([0-9]*)\]$/);function uN(r){const e=r.match(sN);if(q(e,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(e[2]){const t=parseInt(e[2]);q(t!==0&&t<=32,"invalid bytes length","type",r)}else if(e[3]){const t=parseInt(e[3]);q(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",r)}return r}const ir={},Mn=Symbol.for("_ethers_internal"),lN="_ParamTypeInternal",fN="_ErrorInternal",hN="_EventInternal",dN="_ConstructorInternal",pN="_FallbackInternal",gN="_FunctionInternal",yN="_StructInternal",fi=class fi{constructor(e,t,n,i,s,o,a,u){se(this,_l);Q(this,"name");Q(this,"type");Q(this,"baseType");Q(this,"indexed");Q(this,"components");Q(this,"arrayLength");Q(this,"arrayChildren");if(cp(e,ir,"ParamType"),Object.defineProperty(this,Mn,{value:lN}),o&&(o=Object.freeze(o.slice())),i==="array"){if(a==null||u==null)throw new Error("")}else if(a!=null||u!=null)throw new Error("");if(i==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");ze(this,{name:t,type:n,baseType:i,indexed:s,components:o,arrayLength:a,arrayChildren:u})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=n,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(i)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(i=>n.arrayChildren.walk(i,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((i,s)=>n.components[s].walk(i,t))}return t(this.type,e)}async walkAsync(e,t){const n=[],i=[e];return Ee(this,_l,wg).call(this,n,e,t,s=>{i[0]=s}),n.length&&await Promise.all(n),i[0]}static from(e,t){if(fi.isParamType(e))return e;if(typeof e=="string")try{return fi.from(Do(e),t)}catch{q(!1,"invalid param type","obj",e)}else if(e instanceof ki){let a="",u="",l=null;Hs(e,vn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(u="tuple",l=e.popParams().map(S=>fi.from(S)),a=`tuple(${l.map(S=>S.format()).join(",")})`):(a=uN(e.popType("TYPE")),u=a);let h=null,g=null;for(;e.length&&e.peekType("BRACKET");){const S=e.pop();h=new fi(ir,"",a,u,null,l,g,h),g=S.value,a+=S.text,u="array",l=null}let b=null;if(Hs(e,Ite).has("indexed")){if(!t)throw new Error("");b=!0}const I=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new fi(ir,I,a,u,b,l,g,h)}const n=e.name;q(!n||typeof n=="string"&&n.match(iN),"invalid name","obj.name",n);let i=e.indexed;i!=null&&(q(t,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,o=s.match(Bte);if(o){const a=parseInt(o[2]||"-1"),u=fi.from({type:o[1],components:e.components});return new fi(ir,n||"",s,"array",i,null,a,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const a=e.components!=null?e.components.map(l=>fi.from(l)):null;return new fi(ir,n||"",s,"tuple",i,a,null,null)}return s=uN(e.type),new fi(ir,n||"",s,s,i,null,null,null)}static isParamType(e){return e&&e[Mn]===lN}};_l=new WeakSet,wg=function(e,t,n,i){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((u,l)=>{var h;Ee(h=o,_l,wg).call(h,e,u,n,g=>{a[l]=g})}),i(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in t))throw new Error(`missing value for component ${u.name}`);return t[u.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((u,l)=>{var h;Ee(h=o[l],_l,wg).call(h,e,u,n,g=>{a[l]=g})}),i(a);return}const s=n(this.type,t);s.then?e.push(async function(){i(await s)}()):i(s)};let Yr=fi;class ec{constructor(e,t,n){Q(this,"type");Q(this,"inputs");cp(e,ir,"Fragment"),n=Object.freeze(n.slice()),ze(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{ec.from(JSON.parse(e))}catch{}return ec.from(Do(e))}if(e instanceof ki)switch(e.peekKeyword(rN)){case"constructor":return Gs.from(e);case"error":return Ln.from(e);case"event":return is.from(e);case"fallback":case"receive":return js.from(e);case"function":return ss.from(e);case"struct":return tc.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Gs.from(e);case"error":return Ln.from(e);case"event":return is.from(e);case"fallback":case"receive":return js.from(e);case"function":return ss.from(e);case"struct":return tc.from(e)}ge(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}q(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Gs.isFragment(e)}static isError(e){return Ln.isFragment(e)}static isEvent(e){return is.isFragment(e)}static isFunction(e){return ss.isFragment(e)}static isStruct(e){return tc.isFragment(e)}}class Mp extends ec{constructor(t,n,i,s){super(t,n,s);Q(this,"name");q(typeof i=="string"&&i.match(iN),"invalid identifier","name",i),s=Object.freeze(s.slice()),ze(this,{name:i})}}function xh(r,e){return"("+e.map(t=>t.format(r)).join(r==="full"?", ":",")+")"}class Ln extends Mp{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,Mn,{value:fN})}get selector(){return Za(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+xh(e,this.inputs)),t.join(" ")}static from(e){if(Ln.isFragment(e))return e;if(typeof e=="string")return Ln.from(Do(e));if(e instanceof ki){const t=Pp("error",e),n=zs(e);return Xa(e),new Ln(ir,t,n)}return new Ln(ir,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Mn]===fN}}class is extends Mp{constructor(t,n,i,s){super(t,"event",n,i);Q(this,"anonymous");Object.defineProperty(this,Mn,{value:hN}),ze(this,{anonymous:s})}get topicHash(){return Za(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("event"),n.push(this.name+xh(t,this.inputs)),t!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(t,n){return n=(n||[]).map(s=>Yr.from(s)),new is(ir,t,n,!1).topicHash}static from(t){if(is.isFragment(t))return t;if(typeof t=="string")try{return is.from(Do(t))}catch{q(!1,"invalid event fragment","obj",t)}else if(t instanceof ki){const n=Pp("event",t),i=zs(t,!0),s=!!Hs(t,vn(["anonymous"])).has("anonymous");return Xa(t),new is(ir,n,i,s)}return new is(ir,t.name,t.inputs?t.inputs.map(n=>Yr.from(n,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Mn]===hN}}class Gs extends ec{constructor(t,n,i,s,o){super(t,n,i);Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Mn,{value:dN}),ze(this,{payable:s,gas:o})}format(t){if(ge(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[`constructor${xh(t,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(t){if(Gs.isFragment(t))return t;if(typeof t=="string")try{return Gs.from(Do(t))}catch{q(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof ki){Hs(t,vn(["constructor"]));const n=zs(t),i=!!Hs(t,xte).has("payable"),s=cN(t);return Xa(t),new Gs(ir,"constructor",n,i,s)}return new Gs(ir,"constructor",t.inputs?t.inputs.map(Yr.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Mn]===dN}}class js extends ec{constructor(t,n,i){super(t,"fallback",n);Q(this,"payable");Object.defineProperty(this,Mn,{value:pN}),ze(this,{payable:i})}format(t){const n=this.inputs.length===0?"receive":"fallback";if(t==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:i})}return`${n}()${this.payable?" payable":""}`}static from(t){if(js.isFragment(t))return t;if(typeof t=="string")try{return js.from(Do(t))}catch{q(!1,"invalid fallback fragment","obj",t)}else if(t instanceof ki){const n=t.toString(),i=t.peekKeyword(vn(["fallback","receive"]));if(q(i,"type must be fallback or receive","obj",n),t.popKeyword(vn(["fallback","receive"]))==="receive"){const u=zs(t);return q(u.length===0,"receive cannot have arguments","obj.inputs",u),Hs(t,vn(["payable"])),Xa(t),new js(ir,[],!0)}let o=zs(t);o.length?q(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[Yr.from("bytes")];const a=aN(t);if(q(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Hs(t,vn(["returns"])).has("returns")){const u=zs(t);q(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(l=>l.format("minimal")).join(", "))}return Xa(t),new js(ir,o,a==="payable")}if(t.type==="receive")return new js(ir,[],!0);if(t.type==="fallback"){const n=[Yr.from("bytes")],i=t.stateMutability==="payable";return new js(ir,n,i)}q(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Mn]===pN}}class ss extends Mp{constructor(t,n,i,s,o,a){super(t,"function",n,s);Q(this,"constant");Q(this,"outputs");Q(this,"stateMutability");Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Mn,{value:gN}),o=Object.freeze(o.slice()),ze(this,{constant:i==="view"||i==="pure",gas:a,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return Za(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(t))),outputs:this.outputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("function"),n.push(this.name+xh(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(xh(t,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(t,n){return n=(n||[]).map(s=>Yr.from(s)),new ss(ir,t,"view",n,[],null).selector}static from(t){if(ss.isFragment(t))return t;if(typeof t=="string")try{return ss.from(Do(t))}catch{q(!1,"invalid function fragment","obj",t)}else if(t instanceof ki){const i=Pp("function",t),s=zs(t),o=aN(t);let a=[];Hs(t,vn(["returns"])).has("returns")&&(a=zs(t));const u=cN(t);return Xa(t),new ss(ir,i,o,s,a,u)}let n=t.stateMutability;return n==null&&(n="payable",typeof t.constant=="boolean"?(n="view",t.constant||(n="payable",typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable")),new ss(ir,t.name,n,t.inputs?t.inputs.map(Yr.from):[],t.outputs?t.outputs.map(Yr.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Mn]===gN}}class tc extends Mp{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,Mn,{value:yN})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return tc.from(Do(e))}catch{q(!1,"invalid struct fragment","obj",e)}else if(e instanceof ki){const t=Pp("struct",e),n=zs(e);return Xa(e),new tc(ir,t,n)}return new tc(ir,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Mn]===yN}}const Ti=new Map;Ti.set(0,"GENERIC_PANIC"),Ti.set(1,"ASSERT_FALSE"),Ti.set(17,"OVERFLOW"),Ti.set(18,"DIVIDE_BY_ZERO"),Ti.set(33,"ENUM_RANGE_ERROR"),Ti.set(34,"BAD_STORAGE_DATA"),Ti.set(49,"STACK_UNDERFLOW"),Ti.set(50,"ARRAY_RANGE_ERROR"),Ti.set(65,"OUT_OF_MEMORY"),Ti.set(81,"UNINITIALIZED_FUNCTION_CALL");const Pte=new RegExp(/^bytes([0-9]*)$/),Mte=new RegExp(/^(u?int)([0-9]*)$/);let Ww=null,mN=1024;function Lte(r,e,t,n){let i="missing revert data",s=null;const o=null;let a=null;if(t){i="execution reverted";const l=_t(t);if(t=Ce(t),l.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(l.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(Ce(l.slice(0,4))==="0x08c379a0")try{s=n.decode(["string"],l.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(Ce(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Ti.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:e.to?Mt(e.to):null,data:e.data||"0x"};return e.from&&(u.from=Mt(e.from)),Yt(i,"CALL_EXCEPTION",{action:r,data:t,reason:s,transaction:u,invocation:o,revert:a})}const Yp=class Yp{constructor(){se(this,jo)}getDefaultValue(e){const t=e.map(i=>Ee(this,jo,Vl).call(this,Yr.from(i)));return new vp(t,"_").defaultValue()}encode(e,t){Yk(t.length,e.length,"types/values length mismatch");const n=e.map(o=>Ee(this,jo,Vl).call(this,Yr.from(o))),i=new vp(n,"_"),s=new uw;return i.encode(s,t),s.data}decode(e,t,n){const i=e.map(o=>Ee(this,jo,Vl).call(this,Yr.from(o)));return new vp(i,"_").decode(new lw(t,n,mN))}static _setDefaultMaxInflation(e){q(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),mN=e}static defaultAbiCoder(){return Ww==null&&(Ww=new Yp),Ww}static getBuiltinCallException(e,t,n){return Lte(e,t,n,Yp.defaultAbiCoder())}};jo=new WeakSet,Vl=function(e){if(e.isArray())return new aee(Ee(this,jo,Vl).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new vp(e.components.map(n=>Ee(this,jo,Vl).call(this,n)),e.name);switch(e.baseType){case"address":return new see(e.name);case"bool":return new cee(e.name);case"string":return new mee(e.name);case"bytes":return new uee(e.name);case"":return new hee(e.name)}let t=e.type.match(Mte);if(t){let n=parseInt(t[2]||"256");return q(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new yee(n/8,t[1]==="int",e.name)}if(t=e.type.match(Pte),t){let n=parseInt(t[1]);return q(n!==0&&n<=32,"invalid bytes length","param",e),new lee(n,e.name)}q(!1,"invalid type","type",e.type)};let Rh=Yp;class Ute{constructor(e,t,n){Q(this,"fragment");Q(this,"name");Q(this,"signature");Q(this,"topic");Q(this,"args");const i=e.name,s=e.format();ze(this,{fragment:e,name:i,signature:s,topic:t,args:n})}}class Dte{constructor(e,t,n,i){Q(this,"fragment");Q(this,"name");Q(this,"args");Q(this,"signature");Q(this,"selector");Q(this,"value");const s=e.name,o=e.format();ze(this,{fragment:e,name:s,args:n,signature:o,selector:t,value:i})}}class $te{constructor(e,t,n){Q(this,"fragment");Q(this,"name");Q(this,"args");Q(this,"signature");Q(this,"selector");const i=e.name,s=e.format();ze(this,{fragment:e,name:i,args:n,signature:s,selector:t})}}class wN{constructor(e){Q(this,"hash");Q(this,"_isIndexed");ze(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const bN={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},_N={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let e="unknown panic code";return r>=0&&r<=255&&bN[r.toString()]&&(e=bN[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${e})`}}},wc=class wc{constructor(e){se(this,hs);Q(this,"fragments");Q(this,"deploy");Q(this,"fallback");Q(this,"receive");se(this,us);se(this,ls);se(this,fs);se(this,cn);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,F(this,fs,new Map),F(this,us,new Map),F(this,ls,new Map);const n=[];for(const o of t)try{n.push(ec.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}ze(this,{fragments:Object.freeze(n)});let i=null,s=!1;F(this,cn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}ze(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(q(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${a}]`,o),i=o,s=i.payable);return;case"function":u=T(this,fs);break;case"event":u=T(this,ls);break;case"error":u=T(this,us);break;default:return}const l=o.format();u.has(l)||u.set(l,o)}),this.deploy||ze(this,{deploy:Gs.from("constructor()")}),ze(this,{fallback:i,receive:s})}format(e){const t=e?"minimal":"full";return this.fragments.map(i=>i.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Rh.defaultAbiCoder()}getFunctionName(e){const t=Ee(this,hs,bg).call(this,e,null,!1);return q(t,"no matching function","key",e),t.name}hasFunction(e){return!!Ee(this,hs,bg).call(this,e,null,!1)}getFunction(e,t){return Ee(this,hs,bg).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,fs).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,fs).get(i),n)}}getEventName(e){const t=Ee(this,hs,_g).call(this,e,null,!1);return q(t,"no matching event","key",e),t.name}hasEvent(e){return!!Ee(this,hs,_g).call(this,e,null,!1)}getEvent(e,t){return Ee(this,hs,_g).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,ls).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,ls).get(i),n)}}getError(e,t){if(Gt(e)){const i=e.toLowerCase();if(_N[i])return Ln.from(_N[i].signature);for(const s of T(this,us).values())if(i===s.selector)return s;return null}if(e.indexOf("(")===-1){const i=[];for(const[s,o]of T(this,us))s.split("(")[0]===e&&i.push(o);if(i.length===0)return e==="Error"?Ln.from("error Error(string)"):e==="Panic"?Ln.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");q(!1,`ambiguous error description (i.e. ${s})`,"name",e)}return i[0]}if(e=Ln.from(e).format(),e==="Error(string)")return Ln.from("error Error(string)");if(e==="Panic(uint256)")return Ln.from("error Panic(uint256)");const n=T(this,us).get(e);return n||null}forEachError(e){const t=Array.from(T(this,us).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,us).get(i),n)}}_decodeParams(e,t){return T(this,cn).decode(e,t)}_encodeParams(e,t){return T(this,cn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);q(n,"unknown error","fragment",e),e=n}return q(lr(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,lr(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);q(n,"unknown error","fragment",e),e=n}return xr([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return q(lr(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,lr(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return xr([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const s=this.getFunction(e);q(s,"unknown function","fragment",e),e=s}let n="invalid length for result data";const i=wn(t);if(i.length%32===0)try{return T(this,cn).decode(e.outputs,i)}catch{n="could not decode result data"}ge(!1,n,"BAD_DATA",{value:Ce(i),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=_t(e,"data"),i=Rh.getBuiltinCallException("call",t,n);if(i.message.startsWith("execution reverted (unknown custom error)")){const a=Ce(n.slice(0,4)),u=this.getError(a);if(u)try{const l=T(this,cn).decode(u.inputs,n.slice(4));i.revert={name:u.name,signature:u.format(),args:l},i.reason=i.revert.signature,i.message=`execution reverted: ${i.reason}`}catch{i.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return Ce(T(this,cn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const s=this.getEvent(e);q(s,"unknown event","eventFragment",e),e=s}ge(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const i=(s,o)=>s.type==="string"?Za(o):s.type==="bytes"?Nr(Ce(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=No(o):s.type.match(/^bytes/)?o=_J(o,32):s.type==="address"&&T(this,cn).encode(["address"],[o]),Ga(Ce(o),32));for(t.forEach((s,o)=>{const a=e.inputs[o];if(!a.indexed){q(s==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?q(!1,"filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?n.push(s.map(u=>i(a,u))):n.push(i(a,s))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);q(o,"unknown event","eventFragment",e),e=o}const n=[],i=[],s=[];return e.anonymous||n.push(e.topicHash),q(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const u=t[a];if(o.indexed)if(o.type==="string")n.push(Za(u));else if(o.type==="bytes")n.push(Nr(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(T(this,cn).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:T(this,cn).encode(i,s),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const w=this.getEvent(e);q(w,"unknown event","eventFragment",e),e=w}if(n!=null&&!e.anonymous){const w=e.topicHash;q(Gt(n[0],32)&&n[0].toLowerCase()===w,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const i=[],s=[],o=[];e.inputs.forEach((w,I)=>{w.indexed?w.type==="string"||w.type==="bytes"||w.baseType==="tuple"||w.baseType==="array"?(i.push(Yr.from({type:"bytes32",name:w.name})),o.push(!0)):(i.push(w),o.push(!1)):(s.push(w),o.push(!1))});const a=n!=null?T(this,cn).decode(i,xr(n)):null,u=T(this,cn).decode(s,t,!0),l=[],h=[];let g=0,b=0;return e.inputs.forEach((w,I)=>{let S=null;if(w.indexed)if(a==null)S=new wN(null);else if(o[I])S=new wN(a[b++]);else try{S=a[b++]}catch(x){S=x}else try{S=u[g++]}catch(x){S=x}l.push(S),h.push(w.name||null)}),Bu.fromItems(l,h)}parseTransaction(e){const t=_t(e.data,"tx.data"),n=Le(e.value!=null?e.value:0,"tx.value"),i=this.getFunction(Ce(t.slice(0,4)));if(!i)return null;const s=T(this,cn).decode(i.inputs,t.slice(4));return new Dte(i,i.selector,s,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new Ute(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=Ce(e),n=this.getError(lr(t,0,4));if(!n)return null;const i=T(this,cn).decode(n.inputs,lr(t,4));return new $te(n,n.selector,i)}static from(e){return e instanceof wc?e:typeof e=="string"?new wc(JSON.parse(e)):typeof e.formatJson=="function"?new wc(e.formatJson()):typeof e.format=="function"?new wc(e.format("json")):new wc(e)}};us=new WeakMap,ls=new WeakMap,fs=new WeakMap,cn=new WeakMap,hs=new WeakSet,bg=function(e,t,n){if(Gt(e)){const s=e.toLowerCase();for(const o of T(this,fs).values())if(s===o.selector)return o;return null}if(e.indexOf("(")===-1){const s=[];for(const[o,a]of T(this,fs))o.split("(")[0]===e&&s.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,u=!0;an.isTyped(o)&&o.type==="overrides"&&(u=!1,a--);for(let l=s.length-1;l>=0;l--){const h=s[l].inputs.length;h!==a&&(!u||h!==a-1)&&s.splice(l,1)}for(let l=s.length-1;l>=0;l--){const h=s[l].inputs;for(let g=0;g<t.length;g++)if(an.isTyped(t[g])){if(g>=h.length){if(t[g].type==="overrides")continue;s.splice(l,1);break}if(t[g].type!==h[g].baseType){s.splice(l,1);break}}}}if(s.length===1&&t&&t.length!==s[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&n){const o=s.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return s[0]}const i=T(this,fs).get(ss.from(e).format());return i||null},_g=function(e,t,n){if(Gt(e)){const s=e.toLowerCase();for(const o of T(this,ls).values())if(s===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const s=[];for(const[o,a]of T(this,ls))o.split("(")[0]===e&&s.push(a);if(t){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<t.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const a=s[o].inputs;for(let u=0;u<t.length;u++)if(an.isTyped(t[u])&&t[u].type!==a[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&n){const o=s.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return s[0]}const i=T(this,ls).get(is.from(e).format());return i||null};let qw=wc;const AN=BigInt(0);function ju(r){return r??null}function Sr(r){return r==null?null:r.toString()}class vN{constructor(e,t,n){Q(this,"gasPrice");Q(this,"maxFeePerGas");Q(this,"maxPriorityFeePerGas");ze(this,{gasPrice:ju(e),maxFeePerGas:ju(t),maxPriorityFeePerGas:ju(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Sr(e),maxFeePerGas:Sr(t),maxPriorityFeePerGas:Sr(n)}}}function Lp(r){const e={};r.to&&(e.to=r.to),r.from&&(e.from=r.from),r.data&&(e.data=Ce(r.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of t)!(i in r)||r[i]==null||(e[i]=Le(r[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)!(i in r)||r[i]==null||(e[i]=at(r[i],`request.${i}`));return r.accessList&&(e.accessList=Ja(r.accessList)),"blockTag"in r&&(e.blockTag=r.blockTag),"enableCcipRead"in r&&(e.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(e.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(e.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(e.kzg=r.kzg),"blobs"in r&&r.blobs&&(e.blobs=r.blobs.map(i=>iw(i)?Ce(i):Object.assign({},i))),e}class Fte{constructor(e,t){Q(this,"provider");Q(this,"number");Q(this,"hash");Q(this,"timestamp");Q(this,"parentHash");Q(this,"parentBeaconBlockRoot");Q(this,"nonce");Q(this,"difficulty");Q(this,"gasLimit");Q(this,"gasUsed");Q(this,"stateRoot");Q(this,"receiptsRoot");Q(this,"blobGasUsed");Q(this,"excessBlobGas");Q(this,"miner");Q(this,"prevRandao");Q(this,"extraData");Q(this,"baseFeePerGas");se(this,Xs);F(this,Xs,e.transactions.map(n=>typeof n!="string"?new Sh(n,t):n)),ze(this,{provider:t,hash:ju(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:ju(e.prevRandao),extraData:e.extraData,baseFeePerGas:ju(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Xs).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Xs).slice();return e.length===0?[]:(ge(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:i,gasUsed:s,hash:o,miner:a,prevRandao:u,nonce:l,number:h,parentHash:g,parentBeaconBlockRoot:b,stateRoot:w,receiptsRoot:I,timestamp:S,transactions:x}=this;return{_type:"Block",baseFeePerGas:Sr(e),difficulty:Sr(t),extraData:n,gasLimit:Sr(i),gasUsed:Sr(s),blobGasUsed:Sr(this.blobGasUsed),excessBlobGas:Sr(this.excessBlobGas),hash:o,miner:a,prevRandao:u,nonce:l,number:h,parentHash:g,timestamp:S,parentBeaconBlockRoot:b,stateRoot:w,receiptsRoot:I,transactions:x}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Xs).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Xs)[e];else{const n=e.toLowerCase();for(const i of T(this,Xs))if(typeof i=="string"){if(i!==n)continue;t=i;break}else{if(i.hash!==n)continue;t=i;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;q(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return Hte(this)}}Xs=new WeakMap;class Ih{constructor(e,t){Q(this,"provider");Q(this,"transactionHash");Q(this,"blockHash");Q(this,"blockNumber");Q(this,"removed");Q(this,"address");Q(this,"data");Q(this,"topics");Q(this,"index");Q(this,"transactionIndex");this.provider=t;const n=Object.freeze(e.topics.slice());ze(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return ge(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return ge(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return ge(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return zte(this)}}class EN{constructor(e,t){Q(this,"provider");Q(this,"to");Q(this,"from");Q(this,"contractAddress");Q(this,"hash");Q(this,"index");Q(this,"blockHash");Q(this,"blockNumber");Q(this,"logsBloom");Q(this,"gasUsed");Q(this,"blobGasUsed");Q(this,"cumulativeGasUsed");Q(this,"gasPrice");Q(this,"blobGasPrice");Q(this,"type");Q(this,"status");Q(this,"root");se(this,Lh);F(this,Lh,Object.freeze(e.logs.map(i=>new Ih(i,t))));let n=AN;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),ze(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Lh)}toJSON(){const{to:e,from:t,contractAddress:n,hash:i,index:s,blockHash:o,blockNumber:a,logsBloom:u,logs:l,status:h,root:g}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:Sr(this.cumulativeGasUsed),from:t,gasPrice:Sr(this.gasPrice),blobGasUsed:Sr(this.blobGasUsed),blobGasPrice:Sr(this.blobGasPrice),gasUsed:Sr(this.gasUsed),hash:i,index:s,logs:l,logsBloom:u,root:g,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return RN(this)}reorderedEvent(e){return ge(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),xN(this,e)}}Lh=new WeakMap;const mb=class mb{constructor(e,t){Q(this,"provider");Q(this,"blockNumber");Q(this,"blockHash");Q(this,"index");Q(this,"hash");Q(this,"type");Q(this,"to");Q(this,"from");Q(this,"nonce");Q(this,"gasLimit");Q(this,"gasPrice");Q(this,"maxPriorityFeePerGas");Q(this,"maxFeePerGas");Q(this,"maxFeePerBlobGas");Q(this,"data");Q(this,"value");Q(this,"chainId");Q(this,"signature");Q(this,"accessList");Q(this,"blobVersionedHashes");se(this,Ko);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,F(this,Ko,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:i,type:s,to:o,from:a,nonce:u,data:l,signature:h,accessList:g,blobVersionedHashes:b}=this;return{_type:"TransactionResponse",accessList:g,blockNumber:e,blockHash:t,blobVersionedHashes:b,chainId:Sr(this.chainId),data:l,from:a,gasLimit:Sr(this.gasLimit),gasPrice:Sr(this.gasPrice),hash:i,maxFeePerGas:Sr(this.maxFeePerGas),maxPriorityFeePerGas:Sr(this.maxPriorityFeePerGas),maxFeePerBlobGas:Sr(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:n,type:s,value:Sr(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await mn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,i=t??0;let s=T(this,Ko),o=-1,a=s===-1;const u=async()=>{if(a)return null;const{blockNumber:b,nonce:w}=await mn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(w<this.nonce){s=b;return}if(a)return null;const I=await this.getTransaction();if(!(I&&I.blockNumber!=null))for(o===-1&&(o=s-3,o<T(this,Ko)&&(o=T(this,Ko)));o<=b;){if(a)return null;const S=await this.provider.getBlock(o,!0);if(S==null)return;for(const x of S)if(x===this.hash)return;for(let x=0;x<S.length;x++){const C=await S.getTransaction(x);if(C.from===this.from&&C.nonce===this.nonce){if(a)return null;const H=await this.provider.getTransactionReceipt(C.hash);if(H==null||b-H.blockNumber+1<n)return;let D="replaced";C.data===this.data&&C.to===this.to&&C.value===this.value?D="repriced":C.data==="0x"&&C.from===C.to&&C.value===AN&&(D="cancelled"),ge(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:D==="replaced"||D==="cancelled",reason:D,replacement:C.replaceableTransaction(s),hash:C.hash,receipt:H})}}o++}},l=b=>{if(b==null||b.status!==0)return b;ge(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:b.to,from:b.from,data:""},receipt:b})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(await h.confirmations()>=n)return l(h)}else if(await u(),n===0)return null;return await new Promise((b,w)=>{const I=[],S=()=>{I.forEach(C=>C())};if(I.push(()=>{a=!0}),i>0){const C=setTimeout(()=>{S(),w(Yt("wait for transaction timeout","TIMEOUT"))},i);I.push(()=>{clearTimeout(C)})}const x=async C=>{if(await C.confirmations()>=n){S();try{b(l(C))}catch(H){w(H)}}};if(I.push(()=>{this.provider.off(this.hash,x)}),this.provider.on(this.hash,x),s>=0){const C=async()=>{try{await u()}catch(H){if(Qr(H,"TRANSACTION_REPLACED")){S(),w(H);return}}a||this.provider.once("block",C)};I.push(()=>{this.provider.off("block",C)}),this.provider.once("block",C)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ge(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),RN(this)}reorderedEvent(e){return ge(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ge(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),xN(this,e)}replaceableTransaction(e){q(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new mb(this,this.provider);return F(t,Ko,e),t}};Ko=new WeakMap;let Sh=mb;function Hte(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function xN(r,e){return{orphan:"reorder-transaction",tx:r,other:e}}function RN(r){return{orphan:"drop-transaction",tx:r}}function zte(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class Zw extends Ih{constructor(t,n,i){super(t,t.provider);Q(this,"interface");Q(this,"fragment");Q(this,"args");const s=n.decodeEventLog(i,t.data,t.topics);ze(this,{args:s,fragment:i,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class IN extends Ih{constructor(t,n){super(t,t.provider);Q(this,"error");ze(this,{error:n})}}class Gte extends EN{constructor(t,n,i){super(i,n);se(this,Al);F(this,Al,t)}get logs(){return super.logs.map(t=>{const n=t.topics.length?T(this,Al).getEvent(t.topics[0]):null;if(n)try{return new Zw(t,T(this,Al),n)}catch(i){return new IN(t,i)}return t})}}Al=new WeakMap;class Qw extends Sh{constructor(t,n,i){super(i,n);se(this,Uh);F(this,Uh,t)}async wait(t,n){const i=await super.wait(t,n);return i==null?null:new Gte(T(this,Uh),this.provider,i)}}Uh=new WeakMap;class SN extends sT{constructor(t,n,i,s){super(t,n,i);Q(this,"log");ze(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class jte extends SN{constructor(e,t,n,i,s){super(e,t,n,new Zw(s,e.interface,i));const o=e.interface.decodeEventLog(i,this.log.data,this.log.topics);ze(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const kN=BigInt(0);function TN(r){return r&&typeof r.call=="function"}function ON(r){return r&&typeof r.estimateGas=="function"}function Up(r){return r&&typeof r.resolveName=="function"}function NN(r){return r&&typeof r.sendTransaction=="function"}function CN(r){if(r!=null){if(Up(r))return r;if(r.provider)return r.provider}}class Kte{constructor(e,t,n){se(this,Dh);Q(this,"fragment");if(ze(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const i=rc(e.runner,"resolveName"),s=Up(i)?i:null;F(this,Dh,async function(){const o=await Promise.all(t.inputs.map((a,u)=>n[u]==null?null:a.walkAsync(n[u],(h,g)=>h==="address"?Array.isArray(g)?Promise.all(g.map(b=>An(b,s))):An(g,s):g)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,Dh)}}Dh=new WeakMap;function rc(r,e){return r==null?null:typeof r[e]=="function"?r:r.provider&&typeof r.provider[e]=="function"?r.provider:null}function nc(r){return r==null?null:r.provider||null}async function BN(r,e){const t=an.dereference(r,"overrides");q(typeof t=="object","invalid overrides parameter","overrides",r);const n=Lp(t);return q(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),q(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function Vte(r,e,t){const n=rc(r,"resolveName"),i=Up(n)?n:null;return await Promise.all(e.map((s,o)=>s.walkAsync(t[o],(a,u)=>(u=an.dereference(u,a),a==="address"?An(u,i):u))))}function Wte(r){const e=async function(o){const a=await BN(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await An(a.from,CN(r.runner)));const u=r.interface,l=Le(a.value||kN,"overrides.value")===kN,h=(a.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!l&&q(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),q(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const g=u.receive||u.fallback&&u.fallback.payable;return q(g||l,"cannot send value to non-payable fallback","overrides.value",a.value),q(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=rc(r.runner,"call");ge(TN(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await e(o);try{return await a.call(u)}catch(l){throw nw(l)&&l.data?r.interface.makeError(l.data,u):l}},n=async function(o){const a=r.runner;ge(NN(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await a.sendTransaction(await e(o)),l=nc(r.runner);return new Qw(r.interface,l,u)},i=async function(o){const a=rc(r.runner,"estimateGas");return ge(ON(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},s=async o=>await n(o);return ze(s,{_contract:r,estimateGas:i,populateTransaction:e,send:n,staticCall:t}),s}function qte(r,e){const t=function(...l){const h=r.interface.getFunction(e,l);return ge(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let g={};if(h.inputs.length+1===l.length&&(g=await BN(l.pop()),g.from&&(g.from=await An(g.from,CN(r.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const b=await Vte(r.runner,h.inputs,l);return Object.assign({},g,await mn({to:r.getAddress(),data:r.interface.encodeFunctionData(h,b)}))},i=async function(...l){const h=await a(...l);return h.length===1?h[0]:h},s=async function(...l){const h=r.runner;ge(NN(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const g=await h.sendTransaction(await n(...l)),b=nc(r.runner);return new Qw(r.interface,b,g)},o=async function(...l){const h=rc(r.runner,"estimateGas");return ge(ON(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},a=async function(...l){const h=rc(r.runner,"call");ge(TN(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const g=await n(...l);let b="0x";try{b=await h.call(g)}catch(I){throw nw(I)&&I.data?r.interface.makeError(I.data,g):I}const w=t(...l);return r.interface.decodeFunctionResult(w,b)},u=async(...l)=>t(...l).constant?await i(...l):await s(...l);return ze(u,{name:r.interface.getFunctionName(e),_contract:r,_key:e,getFragment:t,estimateGas:o,populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=r.interface.getFunction(e);return ge(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),u}function Zte(r,e){const t=function(...i){const s=r.interface.getEvent(e,i);return ge(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:i}}),s},n=function(...i){return new Kte(r,t(...i),i)};return ze(n,{name:r.interface.getEventName(e),_contract:r,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=r.interface.getEvent(e);return ge(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),i}}),n}const Dp=Symbol.for("_ethersInternal_contract"),PN=new WeakMap;function Qte(r,e){PN.set(r[Dp],e)}function Wn(r){return PN.get(r[Dp])}function Yte(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function Yw(r,e){let t,n=null;if(Array.isArray(e)){const s=function(o){if(Gt(o,32))return o;const a=r.interface.getEvent(o);return q(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else e==="*"?t=[null]:typeof e=="string"?Gt(e,32)?t=[e]:(n=r.interface.getEvent(e),q(n,"unknown fragment","event",e),t=[n.topicHash]):Yte(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):q(!1,"unknown event name","event",e);t=t.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=t.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:n,tag:i,topics:t}}async function kh(r,e){const{subs:t}=Wn(r);return t.get((await Yw(r,e)).tag)||null}async function MN(r,e,t){const n=nc(r.runner);ge(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=await Yw(r,t),{addr:a,subs:u}=Wn(r);let l=u.get(s);if(!l){const g={address:a||r,topics:o},b=x=>{let C=i;if(C==null)try{C=r.interface.getEvent(x.topics[0])}catch{}if(C){const H=C,D=i?r.interface.decodeEventLog(i,x.data,x.topics):[];Xw(r,t,D,z=>new jte(r,z,t,H,x))}else Xw(r,t,[],H=>new SN(r,H,t,x))};let w=[];l={tag:s,listeners:[],start:()=>{w.length||w.push(n.on(g,b))},stop:async()=>{if(w.length==0)return;let x=w;w=[],await Promise.all(x),n.off(g,b)}},u.set(s,l)}return l}let Jw=Promise.resolve();async function Jte(r,e,t,n){await Jw;const i=await kh(r,e);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:a})=>{const u=Array.from(t);n&&u.push(n(a?null:o));try{o.call(r,...u)}catch{}return!a}),i.listeners.length===0&&(i.stop(),Wn(r).subs.delete(i.tag)),s>0}async function Xw(r,e,t,n){try{await Jw}catch{}const i=Jte(r,e,t,n);return Jw=i,await i}const $p=["then"];eC=Dp;const $h=class $h{constructor(e,t,n,i){Q(this,"target");Q(this,"interface");Q(this,"runner");Q(this,"filters");Q(this,eC);Q(this,"fallback");q(typeof e=="string"||gO(e),"invalid value for Contract target","target",e),n==null&&(n=null);const s=qw.from(t);ze(this,{target:e,runner:n,interface:s}),Object.defineProperty(this,Dp,{value:{}});let o,a=null,u=null;if(i){const g=nc(n);u=new Qw(this.interface,g,i)}let l=new Map;if(typeof e=="string")if(Gt(e))a=e,o=Promise.resolve(e);else{const g=rc(n,"resolveName");if(!Up(g))throw Yt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=g.resolveName(e).then(b=>{if(b==null)throw Yt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Wn(this).addr=b,b})}else o=e.getAddress().then(g=>{if(g==null)throw new Error("TODO");return Wn(this).addr=g,g});Qte(this,{addrPromise:o,addr:a,deployTx:u,subs:l});const h=new Proxy({},{get:(g,b,w)=>{if(typeof b=="symbol"||$p.indexOf(b)>=0)return Reflect.get(g,b,w);try{return this.getEvent(b)}catch(I){if(!Qr(I,"INVALID_ARGUMENT")||I.argument!=="key")throw I}},has:(g,b)=>$p.indexOf(b)>=0?Reflect.has(g,b):Reflect.has(g,b)||this.interface.hasEvent(String(b))});return ze(this,{filters:h}),ze(this,{fallback:s.receive||s.fallback?Wte(this):null}),new Proxy(this,{get:(g,b,w)=>{if(typeof b=="symbol"||b in g||$p.indexOf(b)>=0)return Reflect.get(g,b,w);try{return g.getFunction(b)}catch(I){if(!Qr(I,"INVALID_ARGUMENT")||I.argument!=="key")throw I}},has:(g,b)=>typeof b=="symbol"||b in g||$p.indexOf(b)>=0?Reflect.has(g,b):g.interface.hasFunction(b)})}connect(e){return new $h(this.target,this.interface,e)}attach(e){return new $h(e,this.interface,this.runner)}async getAddress(){return await Wn(this).addrPromise}async getDeployedCode(){const e=nc(this.runner);ge(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=nc(this.runner);return ge(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);n.once("block",o)}catch(a){s(a)}};o()})}deploymentTransaction(){return Wn(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),qte(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),Zte(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:i,addrPromise:s}=Wn(this),o=i||await s,{fragment:a,topics:u}=await Yw(this,e),l={address:o,topics:u,fromBlock:t,toBlock:n},h=nc(this.runner);return ge(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(g=>{let b=a;if(b==null)try{b=this.interface.getEvent(g.topics[0])}catch{}if(b)try{return new Zw(g,this.interface,b)}catch(w){return new IN(g,w)}return new Ih(g,h)})}async on(e,t){const n=await MN(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await MN(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await Xw(this,e,t,null)}async listenerCount(e){if(e){const i=await kh(this,e);return i?i.listeners.length:0}const{subs:t}=Wn(this);let n=0;for(const{listeners:i}of t.values())n+=i.length;return n}async listeners(e){if(e){const i=await kh(this,e);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:t}=Wn(this);let n=[];for(const{listeners:i}of t.values())n=n.concat(i.map(({listener:s})=>s));return n}async off(e,t){const n=await kh(this,e);if(!n)return this;if(t){const i=n.listeners.map(({listener:s})=>s).indexOf(t);i>=0&&n.listeners.splice(i,1)}return(t==null||n.listeners.length===0)&&(n.stop(),Wn(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await kh(this,e);if(!t)return this;t.stop(),Wn(this).subs.delete(t.tag)}else{const{subs:t}=Wn(this);for(const{tag:n,stop:i}of t.values())i(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends $h{constructor(i,s=null){super(i,e,s)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}};let eb=$h;function Xte(){return eb}class Ku extends Xte(){}function tb(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):q(!1,"unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}class ere{constructor(e){Q(this,"name");ze(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const LN=new RegExp("^(ipfs)://(.*)$","i"),UN=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),LN,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],vl=class vl{constructor(e,t,n){se(this,Wo);Q(this,"provider");Q(this,"address");Q(this,"name");se(this,Vo);se(this,bc);ze(this,{provider:e,address:t,name:n}),F(this,Vo,null),F(this,bc,new Ku(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Vo)==null&&F(this,Vo,(async()=>{try{return await T(this,bc).supportsInterface("0x9061b923")}catch(e){if(Qr(e,"CALL_EXCEPTION"))return!1;throw F(this,Vo,null),e}})()),await T(this,Vo)}async getAddress(e){if(e==null&&(e=60),e===60)try{const s=await Ee(this,Wo,Wl).call(this,"addr(bytes32)");return s==null||s===gh?null:s}catch(s){if(Qr(s,"CALL_EXCEPTION"))return null;throw s}if(e>=0&&e<2147483648){let s=e+2147483648;const o=await Ee(this,Wo,Wl).call(this,"addr(bytes32,uint)",[s]);if(Gt(o,20))return Mt(o)}let t=null;for(const s of this.provider.plugins)if(s instanceof ere&&s.supportsCoinType(e)){t=s;break}if(t==null)return null;const n=await Ee(this,Wo,Wl).call(this,"addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const i=await t.decodeAddress(e,n);if(i!=null)return i;ge(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await Ee(this,Wo,Wl).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await Ee(this,Wo,Wl).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const i=t[1]==="e3010170"?"ipfs":"ipns",s=parseInt(t[4],16);if(t[5].length===s*2)return`${i}://${EJ("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;ge(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<UN.length;n++){const i=t.match(UN[n]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=tb(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:s,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const u=(i[2]||"").split("/");if(u.length!==2)return e.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:e};const l=u[1],h=new Ku(u[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(s==="erc721"){const S=await h.ownerOf(l);if(a!==S)return e.push({type:"!owner",value:S}),{url:null,linkage:e};e.push({type:"owner",value:S})}else if(s==="erc1155"){const S=await h.balanceOf(a,l);if(!S)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:S.toString()})}let g=await h[o](l);if(g==null||g==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:g}),s==="erc1155"&&(g=g.replace("{id}",No(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:g})),g.match(/^ipfs:/i)&&(g=tb(g)),e.push({type:"metadata-url",value:g});let b={};const w=await new Us(g).send();w.assertOk();try{b=w.bodyJson}catch{try{e.push({type:"!metadata",value:w.bodyText})}catch{const C=w.body;return C&&e.push({type:"!metadata",value:Ce(C)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!b)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(b)});let I=b.image;if(typeof I!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!I.match(/^(https:\/\/|data:)/i)){if(I.match(LN)==null)return e.push({type:"!imageUrl-ipfs",value:I}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:I}),I=tb(I)}return e.push({type:"url",value:I}),{linkage:e,url:I}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return ge(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async fromName(e,t){var i;let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const s=await Ee(i=vl,Jp,d6).call(i,e,n);if(s!=null){const o=new vl(e,s,t);return n!==t&&!await o.supportsWildcard()?null:o}n=n.split(".").slice(1).join(".")}}};Vo=new WeakMap,bc=new WeakMap,Wo=new WeakSet,Wl=async function(e,t){t=(t||[]).slice();const n=T(this,bc).interface;t.unshift($w(this.name));let i=null;await this.supportsWildcard()&&(i=n.getFunction(e),ge(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[tte(this.name,255),n.encodeFunctionData(i,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const s=await T(this,bc)[e](...t);return i?n.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Qr(s,"CALL_EXCEPTION"))throw s}return null},Jp=new WeakSet,d6=async function(e,t){const n=await vl.getEnsAddress(e);try{const s=await new Ku(n,["function resolver(bytes32) view returns (address)"],e).resolver($w(t),{enableCcipRead:!0});return s===gh?null:s}catch(i){throw i}return null},se(vl,Jp);let Fp=vl;const DN=BigInt(0);function wt(r,e){return function(t){return t==null?e:r(t)}}function Hp(r,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>r(n))}}function Th(r,e){return t=>{const n={};for(const i in r){let s=i;if(e&&i in e&&!(s in t)){for(const o of e[i])if(o in t){s=o;break}}try{const o=r[i](t[s]);o!==void 0&&(n[i]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ge(!1,`invalid value for value.${i} (${a})`,"BAD_DATA",{value:t})}}return n}}function tre(r){switch(r){case!0:case"true":return!0;case!1:case"false":return!1}q(!1,`invalid boolean; ${JSON.stringify(r)}`,"value",r)}function Vu(r){return q(Gt(r,!0),"invalid data","value",r),r}function Jr(r){return q(Gt(r,32),"invalid hash","value",r),r}const rre=Th({address:Mt,blockHash:Jr,blockNumber:at,data:Vu,index:at,removed:wt(tre,!1),topics:Hp(Jr),transactionHash:Jr,transactionIndex:at},{index:["logIndex"]});function nre(r){return rre(r)}const ire=Th({hash:wt(Jr),parentHash:Jr,parentBeaconBlockRoot:wt(Jr,null),number:at,timestamp:at,nonce:wt(Vu),difficulty:Le,gasLimit:Le,gasUsed:Le,stateRoot:wt(Jr,null),receiptsRoot:wt(Jr,null),blobGasUsed:wt(Le,null),excessBlobGas:wt(Le,null),miner:wt(Mt),prevRandao:wt(Jr,null),extraData:Vu,baseFeePerGas:wt(Le)},{prevRandao:["mixHash"]});function sre(r){const e=ire(r);return e.transactions=r.transactions.map(t=>typeof t=="string"?t:$N(t)),e}const ore=Th({transactionIndex:at,blockNumber:at,transactionHash:Jr,address:Mt,topics:Hp(Jr),data:Vu,index:at,blockHash:Jr},{index:["logIndex"]});function are(r){return ore(r)}const cre=Th({to:wt(Mt,null),from:wt(Mt,null),contractAddress:wt(Mt,null),index:at,root:wt(Ce),gasUsed:Le,blobGasUsed:wt(Le,null),logsBloom:wt(Vu),blockHash:Jr,hash:Jr,logs:Hp(are),blockNumber:at,cumulativeGasUsed:Le,effectiveGasPrice:wt(Le),blobGasPrice:wt(Le,null),status:wt(at),type:wt(at,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function ure(r){return cre(r)}function $N(r){r.to&&Le(r.to)===DN&&(r.to="0x0000000000000000000000000000000000000000");const e=Th({hash:Jr,index:wt(at,void 0),type:t=>t==="0x"||t==null?0:at(t),accessList:wt(Ja,null),blobVersionedHashes:wt(Hp(Jr,!0),null),blockHash:wt(Jr,null),blockNumber:wt(at,null),transactionIndex:wt(at,null),from:Mt,gasPrice:wt(Le),maxPriorityFeePerGas:wt(Le),maxFeePerGas:wt(Le),maxFeePerBlobGas:wt(Le,null),gasLimit:Le,to:wt(Mt,null),value:Le,nonce:at,data:Vu,creates:wt(Mt,null),chainId:wt(Le,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(r);if(e.to==null&&e.creates==null&&(e.creates=iee(e)),(r.type===1||r.type===2)&&r.accessList==null&&(e.accessList=[]),r.signature?e.signature=Si.from(r.signature):e.signature=Si.from(r),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Le(e.blockHash)===DN&&(e.blockHash=null),e}const lre="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Oh{constructor(e){Q(this,"name");ze(this,{name:e})}clone(){return new Oh(this.name)}}class zp extends Oh{constructor(t,n){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);Q(this,"effectiveBlock");Q(this,"txBase");Q(this,"txCreate");Q(this,"txDataZero");Q(this,"txDataNonzero");Q(this,"txAccessListStorageKey");Q(this,"txAccessListAddress");const i={effectiveBlock:t};function s(o,a){let u=(n||{})[o];u==null&&(u=a),q(typeof u=="number",`invalud value for ${o}`,"costs",n),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),ze(this,i)}clone(){return new zp(this.effectiveBlock,this)}}class Gp extends Oh{constructor(t,n){super("org.ethers.plugins.network.Ens");Q(this,"address");Q(this,"targetNetwork");ze(this,{address:t||lre,targetNetwork:n??1})}clone(){return new Gp(this.address,this.targetNetwork)}}class fre extends Oh{constructor(t,n){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");se(this,Fh);se(this,Hh);F(this,Fh,t),F(this,Hh,n)}get url(){return T(this,Fh)}get processFunc(){return T(this,Hh)}clone(){return this}}Fh=new WeakMap,Hh=new WeakMap;const rb=new Map,Rl=class Rl{constructor(e,t){se(this,El);se(this,xl);se(this,qo);F(this,El,e),F(this,xl,Le(t)),F(this,qo,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,El)}set name(e){F(this,El,e)}get chainId(){return T(this,xl)}set chainId(e){F(this,xl,Le(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Le(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Le(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Le(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,qo).values())}attachPlugin(e){if(T(this,qo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,qo).set(e.name,e.clone()),this}getPlugin(e){return T(this,qo).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new Rl(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new zp;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let i=2;i<e.data.length;i+=2)e.data.substring(i,i+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const i=Ja(e.accessList);for(const s in i)n+=t.txAccessListAddress+t.txAccessListStorageKey*i[s].storageKeys.length}return n}static from(e){if(hre(),e==null)return Rl.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=rb.get(e);if(t)return t();if(typeof e=="bigint")return new Rl("unknown",e);q(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){q(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new Rl(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Gp(e.ensAddress,e.ensNetwork)),t}q(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=rb.get(e);n&&q(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),rb.set(e,t)}};El=new WeakMap,xl=new WeakMap,qo=new WeakMap;let os=Rl;function FN(r,e){const t=String(r);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${r}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${r}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let i=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||i++,n[1]=i.toString()}return BigInt(n[0]+n[1])}function HN(r){return new fre(r,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([n.send(),e()]);i=s;const a=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:FN(a.maxFee,9),maxPriorityFeePerGas:FN(a.maxPriorityFee,9)}}catch(s){ge(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:i,error:s})}})}let zN=!1;function hre(){if(zN)return;zN=!0;function r(e,t,n){const i=function(){const s=new os(e,t);return n.ensNetwork!=null&&s.attachPlugin(new Gp(null,n.ensNetwork)),s.attachPlugin(new zp),(n.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};os.register(e,i),os.register(t,i),n.altNames&&n.altNames.forEach(s=>{os.register(s,i)})}r("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),r("ropsten",3,{ensNetwork:3}),r("rinkeby",4,{ensNetwork:4}),r("goerli",5,{ensNetwork:5}),r("kovan",42,{ensNetwork:42}),r("sepolia",11155111,{ensNetwork:11155111}),r("holesky",17e3,{ensNetwork:17e3}),r("classic",61,{}),r("classicKotti",6,{}),r("arbitrum",42161,{ensNetwork:1}),r("arbitrum-goerli",421613,{}),r("arbitrum-sepolia",421614,{}),r("base",8453,{ensNetwork:1}),r("base-goerli",84531,{}),r("base-sepolia",84532,{}),r("bnb",56,{ensNetwork:1}),r("bnbt",97,{}),r("linea",59144,{ensNetwork:1}),r("linea-goerli",59140,{}),r("linea-sepolia",59141,{}),r("matic",137,{ensNetwork:1,plugins:[HN("https://gasstation.polygon.technology/v2")]}),r("matic-amoy",80002,{}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[HN("https://gasstation-testnet.polygon.technology/v2")]}),r("optimism",10,{ensNetwork:1,plugins:[]}),r("optimism-goerli",420,{}),r("optimism-sepolia",11155420,{}),r("xdai",100,{ensNetwork:1})}function nb(r){return JSON.parse(JSON.stringify(r))}class dre{constructor(e){se(this,Il);se(this,eo);se(this,hi);se(this,Zo);se(this,ds);F(this,eo,e),F(this,hi,null),F(this,Zo,4e3),F(this,ds,-2)}get pollingInterval(){return T(this,Zo)}set pollingInterval(e){F(this,Zo,e)}start(){T(this,hi)||(F(this,hi,T(this,eo)._setTimeout(Ee(this,Il,Ag).bind(this),T(this,Zo))),Ee(this,Il,Ag).call(this))}stop(){T(this,hi)&&(T(this,eo)._clearTimeout(T(this,hi)),F(this,hi,null))}pause(e){this.stop(),e&&F(this,ds,-2)}resume(){this.start()}}eo=new WeakMap,hi=new WeakMap,Zo=new WeakMap,ds=new WeakMap,Il=new WeakSet,Ag=async function(){try{const e=await T(this,eo).getBlockNumber();if(T(this,ds)===-2){F(this,ds,e);return}if(e!==T(this,ds)){for(let t=T(this,ds)+1;t<=e;t++){if(T(this,hi)==null)return;await T(this,eo).emit("block",t)}F(this,ds,e)}}catch{}T(this,hi)!=null&&F(this,hi,T(this,eo)._setTimeout(Ee(this,Il,Ag).bind(this),T(this,Zo)))};class ib{constructor(e){se(this,_c);se(this,Ac);se(this,Qo);F(this,_c,e),F(this,Qo,!1),F(this,Ac,t=>{this._poll(t,T(this,_c))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Qo)||(F(this,Qo,!0),T(this,Ac).call(this,-2),T(this,_c).on("block",T(this,Ac)))}stop(){T(this,Qo)&&(F(this,Qo,!1),T(this,_c).off("block",T(this,Ac)))}pause(e){this.stop()}resume(){this.start()}}_c=new WeakMap,Ac=new WeakMap,Qo=new WeakMap;class pre extends ib{constructor(t,n){super(t);se(this,Sl);se(this,to);F(this,Sl,n),F(this,to,-2)}pause(t){t&&F(this,to,-2),super.pause(t)}async _poll(t,n){const i=await n.getBlock(T(this,Sl));i!=null&&(T(this,to)===-2?F(this,to,i.number):i.number>T(this,to)&&(n.emit(T(this,Sl),i.number),F(this,to,i.number)))}}Sl=new WeakMap,to=new WeakMap;class gre extends ib{constructor(t,n){super(t);se(this,Xp);F(this,Xp,nb(n))}async _poll(t,n){throw new Error("@TODO")}}Xp=new WeakMap;class yre extends ib{constructor(t,n){super(t);se(this,kl);F(this,kl,n)}async _poll(t,n){const i=await n.getTransactionReceipt(T(this,kl));i&&n.emit(T(this,kl),i)}}kl=new WeakMap;class sb{constructor(e,t){se(this,eg);se(this,ro);se(this,Tl);se(this,Ol);se(this,Yo);se(this,di);F(this,ro,e),F(this,Tl,nb(t)),F(this,Ol,Ee(this,eg,p6).bind(this)),F(this,Yo,!1),F(this,di,-2)}start(){T(this,Yo)||(F(this,Yo,!0),T(this,di)===-2&&T(this,ro).getBlockNumber().then(e=>{F(this,di,e)}),T(this,ro).on("block",T(this,Ol)))}stop(){T(this,Yo)&&(F(this,Yo,!1),T(this,ro).off("block",T(this,Ol)))}pause(e){this.stop(),e&&F(this,di,-2)}resume(){this.start()}}ro=new WeakMap,Tl=new WeakMap,Ol=new WeakMap,Yo=new WeakMap,di=new WeakMap,eg=new WeakSet,p6=async function(e){if(T(this,di)===-2)return;const t=nb(T(this,Tl));t.fromBlock=T(this,di)+1,t.toBlock=e;const n=await T(this,ro).getLogs(t);if(n.length===0){T(this,di)<e-60&&F(this,di,e-60);return}for(const i of n)T(this,ro).emit(T(this,Tl),i),F(this,di,i.blockNumber)};const mre=BigInt(2),wre=10;function jp(r){return r&&typeof r.then=="function"}function Kp(r,e){return r+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const i=Object.keys(n);return i.sort(),i.reduce((s,o)=>(s[o]=n[o],s),{})}return n})}class Vp{constructor(e){Q(this,"name");ze(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function bre(r){return JSON.parse(JSON.stringify(r))}function ob(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function ab(r,e){if(r==null)throw new Error("invalid event");if(Array.isArray(r)&&(r={topics:r}),typeof r=="string")switch(r){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:r,tag:r}}if(Gt(r,32)){const t=r.toLowerCase();return{type:"transaction",tag:Kp("tx",{hash:t}),hash:t}}if(r.orphan){const t=r;return{type:"orphan",tag:Kp("orphan",t),filter:bre(t)}}if(r.address||r.topics){const t=r,n={topics:(t.topics||[]).map(i=>i==null?null:Array.isArray(i)?ob(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(t.address){const i=[],s=[],o=a=>{Gt(a)?i.push(a):s.push((async()=>{i.push(await An(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),s.length&&await Promise.all(s),n.address=ob(i.map(a=>a.toLowerCase()))}return{filter:n,tag:Kp("event",n),type:"event"}}q(!1,"unknown ProviderEvent","event",r)}function cb(){return new Date().getTime()}const _re={cacheTimeout:250,pollingInterval:4e3};class Are{constructor(e,t){se(this,ct);se(this,un);se(this,Jo);se(this,ln);se(this,Nl);se(this,Yn);se(this,vc);se(this,Xo);se(this,no);se(this,zh);se(this,pi);se(this,Cl);se(this,Bl);if(F(this,Bl,Object.assign({},_re,t||{})),e==="any")F(this,vc,!0),F(this,Yn,null);else if(e){const n=os.from(e);F(this,vc,!1),F(this,Yn,Promise.resolve(n)),setTimeout(()=>{this.emit("network",n,null)},0)}else F(this,vc,!1),F(this,Yn,null);F(this,no,-1),F(this,Xo,new Map),F(this,un,new Map),F(this,Jo,new Map),F(this,ln,null),F(this,Nl,!1),F(this,zh,1),F(this,pi,new Map),F(this,Cl,!1)}get pollingInterval(){return T(this,Bl).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Jo).values())}attachPlugin(e){if(T(this,Jo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Jo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Jo).get(e)||null}get disableCcipRead(){return T(this,Cl)}set disableCcipRead(e){F(this,Cl,!!e)}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const i=e.to.toLowerCase(),s=t.toLowerCase(),o=[];for(let a=0;a<n.length;a++){const u=n[a],l=u.replace("{sender}",i).replace("{data}",s),h=new Us(l);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:n});let g="unknown error",b;try{b=await h.send()}catch(w){o.push(w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:w}});continue}try{const w=b.bodyJson;if(w.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:w}),w.data;w.message&&(g=w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:w})}catch{}ge(b.statusCode<400||b.statusCode>=500,`response not found during CCIP fetch: ${g}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:u,errorMessage:g}}),o.push(g)}ge(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:o}})}_wrapBlock(e,t){return new Fte(sre(e),this)}_wrapLog(e,t){return new Ih(nre(e),this)}_wrapTransactionReceipt(e,t){return new EN(ure(e),this)}_wrapTransactionResponse(e,t){return new Sh($N(e),this)}_detectNetwork(){ge(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){ge(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=at(await Ee(this,ct,Jn).call(this,{method:"getBlockNumber"}),"%response");return T(this,no)>=0&&F(this,no,e),e}_getAddress(e){return An(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(Gt(e))return Gt(e,32)?e:Cu(e);if(typeof e=="bigint"&&(e=at(e,"blockTag")),typeof e=="number")return e>=0?Cu(e):T(this,no)>=0?Cu(T(this,no)+e):this.getBlockNumber().then(t=>Cu(t+e));q(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(u=>u==null?null:Array.isArray(u)?ob(u.map(l=>l.toLowerCase())):u.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,i=(u,l,h)=>{let g;switch(u.length){case 0:break;case 1:g=u[0];break;default:u.sort(),g=u}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const b={};return g&&(b.address=g),t.length&&(b.topics=t),l&&(b.fromBlock=l),h&&(b.toBlock=h),n&&(b.blockHash=n),b};let s=[];if(e.address)if(Array.isArray(e.address))for(const u of e.address)s.push(this._getAddress(u));else s.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),s.filter(u=>typeof u!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(s),o,a]).then(u=>i(u[0],u[1],u[2])):i(s,o,a)}_getTransactionRequest(e){const t=Lp(e),n=[];if(["to","from"].forEach(i=>{if(t[i]==null)return;const s=An(t[i],this);jp(s)?n.push(async function(){t[i]=await s}()):t[i]=s}),t.blockTag!=null){const i=this._getBlockTag(t.blockTag);jp(i)?n.push(async function(){t.blockTag=await i}()):t.blockTag=i}return n.length?async function(){return await Promise.all(n),t}():t}async getNetwork(){if(T(this,Yn)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw T(this,Yn)===i&&F(this,Yn,null),s}})();return F(this,Yn,i),(await i).clone()}const e=T(this,Yn),[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(T(this,vc)?(this.emit("network",n,t),T(this,Yn)===e&&F(this,Yn,Promise.resolve(n))):ge(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await mn({_block:Ee(this,ct,H_).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await Ee(this,ct,Jn).call(this,{method:"getGasPrice"});return Le(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await Ee(this,ct,Jn).call(this,{method:"getPriorityFee"});return Le(h,"%response")}catch{}return null})()});let a=null,u=null;const l=this._wrapBlock(i,e);return l&&l.baseFeePerGas&&(u=o??BigInt("1000000000"),a=l.baseFeePerGas*mre+u),new vN(s,a,u)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const i=new Us(n.url),s=await n.processFunc(t,this,i);return new vN(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return jp(t)&&(t=await t),Le(await Ee(this,ct,Jn).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:n}=await mn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await Ee(this,ct,F_).call(this,Ee(this,ct,$_).call(this,t,n,e.enableCcipRead?0:-1))}async getBalance(e,t){return Le(await Ee(this,ct,Ad).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return at(await Ee(this,ct,Ad).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return Ce(await Ee(this,ct,Ad).call(this,{method:"getCode"},e,t))}async getStorage(e,t,n){const i=Le(t,"position");return Ce(await Ee(this,ct,Ad).call(this,{method:"getStorage",position:i},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:i}=await mn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),s=Np.from(e);if(s.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(t)}async getBlock(e,t){const{network:n,params:i}=await mn({network:this.getNetwork(),params:Ee(this,ct,H_).call(this,e,!!t)});return i==null?null:this._wrapBlock(i,n)}async getTransaction(e){const{network:t,params:n}=await mn({network:this.getNetwork(),params:Ee(this,ct,Jn).call(this,{method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await mn({network:this.getNetwork(),params:Ee(this,ct,Jn).call(this,{method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const i=await Ee(this,ct,Jn).call(this,{method:"getTransaction",hash:e});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await mn({network:this.getNetwork(),result:Ee(this,ct,Jn).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:Ce(t)}async getLogs(e){let t=this._getFilter(e);jp(t)&&(t=await t);const{network:n,params:i}=await mn({network:this.getNetwork(),params:Ee(this,ct,Jn).call(this,{method:"getLogs",filter:t})});return i.map(s=>this._wrapLog(s,n))}_getProvider(e){ge(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Fp.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=Mt(e);const t=$w(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await Fp.getEnsAddress(this),s=await new Ku(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(s==null||s===gh)return null;const a=await new Ku(s,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(n){if(Qr(n,"BAD_DATA")&&n.value==="0x"||Qr(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const i=t??1;return i===0?this.getTransactionReceipt(e):new Promise(async(s,o)=>{let a=null;const u=async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=i){s(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",u),o(Yt("timeout","TIMEOUT",{reason:"timeout"})))},n)),u(await this.getBlockNumber())})}async waitForBlock(e){ge(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,pi).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,pi).delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=bd(this,zh)._++,i=()=>{T(this,pi).delete(n),e()};if(this.paused)T(this,pi).set(n,{timer:null,func:i,time:t});else{const s=setTimeout(i,t);T(this,pi).set(n,{timer:s,func:i,time:cb()})}return n}_forEachSubscriber(e){for(const t of T(this,un).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Vp(e.type);case"block":{const t=new dre(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new pre(this,e.type);case"event":return new sb(this,e.filter);case"transaction":return new yre(this,e.hash);case"orphan":return new gre(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of T(this,un).values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),T(this,ln)!=null&&t.pause(T(this,ln));break}}async on(e,t){const n=await Ee(this,ct,vg).call(this,e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,T(this,ln)!=null&&n.subscriber.pause(T(this,ln))),this}async once(e,t){const n=await Ee(this,ct,vg).call(this,e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,T(this,ln)!=null&&n.subscriber.pause(T(this,ln))),this}async emit(e,...t){const n=await Ee(this,ct,vd).call(this,e,t);if(!n||n.listeners.length===0)return!1;const i=n.listeners.length;return n.listeners=n.listeners.filter(({listener:s,once:o})=>{const a=new sT(this,o?null:s,e);try{s.call(this,...t,a)}catch{}return!o}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),T(this,un).delete(n.tag)),i>0}async listenerCount(e){if(e){const n=await Ee(this,ct,vd).call(this,e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of T(this,un).values())t+=n.length;return t}async listeners(e){if(e){const n=await Ee(this,ct,vd).call(this,e);return n?n.listeners.map(({listener:i})=>i):[]}let t=[];for(const{listeners:n}of T(this,un).values())t=t.concat(n.map(({listener:i})=>i));return t}async off(e,t){const n=await Ee(this,ct,vd).call(this,e);if(!n)return this;if(t){const i=n.listeners.map(({listener:s})=>s).indexOf(t);i>=0&&n.listeners.splice(i,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),T(this,un).delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:i}=await Ee(this,ct,vg).call(this,e);n&&i.stop(),T(this,un).delete(t)}else for(const[t,{started:n,subscriber:i}]of T(this,un))n&&i.stop(),T(this,un).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Nl)}destroy(){this.removeAllListeners();for(const e of T(this,pi).keys())this._clearTimeout(e);F(this,Nl,!0)}get paused(){return T(this,ln)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(F(this,no,-1),T(this,ln)!=null){if(T(this,ln)==!!e)return;ge(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),F(this,ln,!!e);for(const t of T(this,pi).values())t.timer&&clearTimeout(t.timer),t.time=cb()-t.time}resume(){if(T(this,ln)!=null){this._forEachSubscriber(e=>e.resume()),F(this,ln,null);for(const e of T(this,pi).values()){let t=e.time;t<0&&(t=0),e.time=cb(),setTimeout(e.func,t)}}}}un=new WeakMap,Jo=new WeakMap,ln=new WeakMap,Nl=new WeakMap,Yn=new WeakMap,vc=new WeakMap,Xo=new WeakMap,no=new WeakMap,zh=new WeakMap,pi=new WeakMap,Cl=new WeakMap,Bl=new WeakMap,ct=new WeakSet,Jn=async function(e){const t=T(this,Bl).cacheTimeout;if(t<0)return await this._perform(e);const n=Kp(e.method,e);let i=T(this,Xo).get(n);return i||(i=this._perform(e),T(this,Xo).set(n,i),setTimeout(()=>{T(this,Xo).get(n)===i&&T(this,Xo).delete(n)},t)),await i},$_=async function(e,t,n){ge(n<wre,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const i=Lp(e);try{return Ce(await this._perform({method:"call",transaction:i,blockTag:t}))}catch(s){if(!this.disableCcipRead&&nw(s)&&s.data&&n>=0&&t==="latest"&&i.to!=null&&lr(s.data,0,4)==="0x556f1830"){const o=s.data,a=await An(i.to,this);let u;try{u=Ire(lr(s.data,4))}catch(g){ge(!1,g.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}ge(u.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:i,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:u.errorArgs}});const l=await this.ccipReadFetch(i,u.calldata,u.urls);ge(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:a,data:xr([u.selector,Rre([l,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const g=await Ee(this,ct,$_).call(this,h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:g}),g}catch(g){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:g}),g}}throw s}},F_=async function(e){const{value:t}=await mn({network:this.getNetwork(),value:e});return t},Ad=async function(e,t,n){let i=this._getAddress(t),s=this._getBlockTag(n);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await Ee(this,ct,F_).call(this,Ee(this,ct,Jn).call(this,Object.assign(e,{address:i,blockTag:s})))},H_=async function(e,t){if(Gt(e,32))return await Ee(this,ct,Jn).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await Ee(this,ct,Jn).call(this,{method:"getBlock",blockTag:n,includeTransactions:t})},vd=async function(e,t){let n=await ab(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await ab({orphan:"drop-log",log:t[0]},this)),T(this,un).get(n.tag)||null},vg=async function(e){const t=await ab(e,this),n=t.tag;let i=T(this,un).get(n);return i||(i={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,un).set(n,i)),i};function vre(r,e){try{const t=ub(r,e);if(t)return fp(t)}catch{}return null}function ub(r,e){if(r==="0x")return null;try{const t=at(lr(r,e,e+32)),n=at(lr(r,t,t+32));return lr(r,t+32,t+32+n)}catch{}return null}function GN(r){const e=bn(r);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function Ere(r){if(r.length%32===0)return r;const e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}const xre=new Uint8Array([]);function Rre(r){const e=[];let t=0;for(let n=0;n<r.length;n++)e.push(xre),t+=32;for(let n=0;n<r.length;n++){const i=_t(r[n]);e[n]=GN(t),e.push(GN(i.length)),e.push(Ere(i)),t+=32+Math.ceil(i.length/32)*32}return xr(e)}const jN="0x0000000000000000000000000000000000000000000000000000000000000000";function Ire(r){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ge(Ou(r)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=lr(r,0,32);ge(lr(t,0,12)===lr(jN,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=lr(t,12);try{const n=[],i=at(lr(r,32,64)),s=at(lr(r,i,i+32)),o=lr(r,i+32);for(let a=0;a<s;a++){const u=vre(o,a*32);if(u==null)throw new Error("abort");n.push(u)}e.urls=n}catch{ge(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=ub(r,64);if(n==null)throw new Error("abort");e.calldata=n}catch{ge(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ge(lr(r,100,128)===lr(jN,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=lr(r,96,100);try{const n=ub(r,128);if(n==null)throw new Error("abort");e.extraData=n}catch{ge(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function Wu(r,e){if(r.provider)return r.provider;ge(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function KN(r,e){let t=Lp(e);if(t.to!=null&&(t.to=An(t.to,r)),t.from!=null){const n=t.from;t.from=Promise.all([r.getAddress(),An(n,r)]).then(([i,s])=>(q(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else t.from=r.getAddress();return await mn(t)}class Sre{constructor(e){Q(this,"provider");ze(this,{provider:e||null})}async getNonce(e){return Wu(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await KN(this,e)}async populateTransaction(e){const t=Wu(this,"populateTransaction"),n=await KN(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const i=await this.provider.getNetwork();if(n.chainId!=null){const o=Le(n.chainId);q(o===i.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=i.chainId;const s=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||s)?q(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&s&&q(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const o=await t.getFeeData();ge(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(n.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const a=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=a,n.maxPriorityFeePerGas=a}else n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ge(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice),n.type=0):ge(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await mn(n)}async estimateGas(e){return Wu(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Wu(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Wu(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Wu(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const i=Np.from(n);return await t.broadcastTransaction(await this.signTransaction(i))}}function kre(r){return JSON.parse(JSON.stringify(r))}class VN{constructor(e){se(this,ta);se(this,En);se(this,ps);se(this,Ec);se(this,ea);se(this,xc);se(this,Pl);F(this,En,e),F(this,ps,null),F(this,Ec,Ee(this,ta,z_).bind(this)),F(this,ea,!1),F(this,xc,null),F(this,Pl,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,ea)||(F(this,ea,!0),Ee(this,ta,z_).call(this,-2))}stop(){T(this,ea)&&(F(this,ea,!1),F(this,Pl,!0),Ee(this,ta,G_).call(this),T(this,En).off("block",T(this,Ec)))}pause(e){e&&Ee(this,ta,G_).call(this),T(this,En).off("block",T(this,Ec))}resume(){this.start()}}En=new WeakMap,ps=new WeakMap,Ec=new WeakMap,ea=new WeakMap,xc=new WeakMap,Pl=new WeakMap,ta=new WeakSet,z_=async function(e){try{T(this,ps)==null&&F(this,ps,this._subscribe(T(this,En)));let t=null;try{t=await T(this,ps)}catch(s){if(!Qr(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(t==null){F(this,ps,null),T(this,En)._recoverSubscriber(this,this._recover(T(this,En)));return}const n=await T(this,En).getNetwork();if(T(this,xc)||F(this,xc,n),T(this,xc).chainId!==n.chainId)throw new Error("chaid changed");if(T(this,Pl))return;const i=await T(this,En).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,En),i)}catch(t){console.log("@TODO",t)}T(this,En).once("block",T(this,Ec))},G_=function(){const e=T(this,ps);e&&(F(this,ps,null),e.then(t=>{T(this,En).destroyed||T(this,En).send("eth_uninstallFilter",[t])}))};class Tre extends VN{constructor(t,n){super(t);se(this,Rc);F(this,Rc,kre(n))}_recover(t){return new sb(t,T(this,Rc))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,Rc)])}async _emitResults(t,n){for(const i of n)t.emit(T(this,Rc),t._wrapLog(i,t._network))}}Rc=new WeakMap;class Ore extends VN{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const Nre="bigint,boolean,function,number,string,symbol".split(/,/g);function Wp(r){if(r==null||Nre.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(Wp);if(typeof r=="object")return Object.keys(r).reduce((e,t)=>(e[t]=r[t],e),{});throw new Error(`should not happen: ${r} (${typeof r})`)}function Cre(r){return new Promise(e=>{setTimeout(e,r)})}function qu(r){return r&&r.toLowerCase()}function WN(r){return r&&typeof r.pollingInterval=="number"}const qN={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class lb extends Sre{constructor(t,n){super(t);Q(this,"address");n=Mt(n),ze(this,{address:n})}connect(t){ge(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const n=Wp(t),i=[];if(n.from){const o=n.from;i.push((async()=>{const a=await An(o,this.provider);q(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=a})())}else n.from=this.address;if(n.gasLimit==null&&i.push((async()=>{n.gasLimit=await this.provider.estimateGas({...n,from:this.address})})()),n.to!=null){const o=n.to;i.push((async()=>{n.to=await An(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(n);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(t){const n=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(t);return await new Promise((s,o)=>{const a=[1e3,100];let u=0;const l=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(n));return}}catch(h){if(Qr(h,"CANCELLED")||Qr(h,"BAD_DATA")||Qr(h,"NETWORK_ERROR")||Qr(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(Qr(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",Yt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{l()},a.pop()||4e3)};l()})}async signTransaction(t){const n=Wp(t);if(n.from){const s=await An(n.from,this.provider);q(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=s}else n.from=this.address;const i=this.provider.getRpcTransaction(n);return await this.provider.send("eth_signTransaction",[i])}async signMessage(t){const n=typeof t=="string"?Ls(t):t;return await this.provider.send("personal_sign",[Ce(n),this.address.toLowerCase()])}async signTypedData(t,n,i){const s=Wp(i),o=await Bp.resolveNames(t,n,s,async a=>{const u=await An(a);return q(u!=null,"TypedData does not support null address","value",a),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Bp.getPayload(o.domain,n,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const n=typeof t=="string"?Ls(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),Ce(n)])}}class ZN extends Are{constructor(t,n){super(t,n);se(this,Gh);se(this,Ic);se(this,Ml);se(this,io);se(this,gs);se(this,Pi);se(this,gi);se(this,Dn);F(this,Ml,1),F(this,Ic,Object.assign({},qN,n||{})),F(this,io,[]),F(this,gs,null),F(this,gi,null),F(this,Dn,null);{let s=null;const o=new Promise(a=>{s=a});F(this,Pi,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(q(!i||t!=="any","staticNetwork cannot be used on special network 'any'","options",n),i&&t!=null&&F(this,gi,os.from(t))):i&&(q(t==null||i.matches(t),"staticNetwork MUST match network object","options",n),F(this,gi,i))}_getOption(t){return T(this,Ic)[t]}get _network(){return ge(T(this,gi),"network is not available yet","NETWORK_ERROR"),T(this,gi)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let i=t.transaction;if(i&&i.type!=null&&Le(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},i,{type:void 0})}))}}const n=this.getRpcRequest(t);return n!=null?await this.send(n.method,n.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,gi))return T(this,gi)}else return t;return T(this,Dn)?await T(this,Dn):this.ready?(F(this,Dn,(async()=>{try{const n=os.from(Le(await this.send("eth_chainId",[])));return F(this,Dn,null),n}catch(n){throw F(this,Dn,null),n}})()),await T(this,Dn)):(F(this,Dn,(async()=>{const n={id:bd(this,Ml)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:n});let i;try{i=(await this._send(n))[0],F(this,Dn,null)}catch(s){throw F(this,Dn,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return os.from(Le(i.result));throw this.getRpcError(n,i)})()),await T(this,Dn))}_start(){T(this,Pi)==null||T(this,Pi).resolve==null||(T(this,Pi).resolve(),F(this,Pi,null),(async()=>{for(;T(this,gi)==null&&!this.destroyed;)try{F(this,gi,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Yt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await Cre(1e3)}Ee(this,Gh,j_).call(this)})())}async _waitUntilReady(){if(T(this,Pi)!=null)return await T(this,Pi).promise}_getSubscriber(t){return t.type==="pending"?new Ore(this):t.type==="event"?this._getOption("polling")?new sb(this,t.filter):new Tre(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Vp("orphan"):super._getSubscriber(t)}get ready(){return T(this,Pi)==null}getRpcTransaction(t){const n={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(t[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),n[s]=Cu(Le(t[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{t[i]!=null&&(n[i]=Ce(t[i]))}),t.accessList&&(n.accessList=Ja(t.accessList)),t.blobVersionedHashes&&(n.blobVersionedHashes=t.blobVersionedHashes.map(i=>i.toLowerCase())),n}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[qu(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[qu(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[qu(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[qu(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(qu):t.filter.address=qu(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,n){const{method:i}=t,{error:s}=n;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return Yt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=fb(s),l=Rh.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",t.params[0],u?u.data:null);return l.info={error:s,payload:t},l}const o=JSON.stringify(Mre(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Yt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[i]||"unknown",reason:"rejected",info:{payload:t,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Yt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Yt("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Yt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Yt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:i,info:{transaction:u,info:{error:s}}})}let a=!!o.match(/the method .* does not exist/i);return a||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(a=!0),a?Yt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:s,payload:t}}):Yt("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:t})}send(t,n){if(this.destroyed)return Promise.reject(Yt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const i=bd(this,Ml)._++,s=new Promise((o,a)=>{T(this,io).push({resolve:o,reject:a,payload:{method:t,params:n,id:i,jsonrpc:"2.0"}})});return Ee(this,Gh,j_).call(this),s}async getSigner(t){t==null&&(t=0);const n=this.send("eth_accounts",[]);if(typeof t=="number"){const s=await n;if(t>=s.length)throw new Error("no such account");return new lb(this,s[t])}const{accounts:i}=await mn({network:this.getNetwork(),accounts:n});t=Mt(t);for(const s of i)if(Mt(s)===t)return new lb(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(n=>new lb(this,n))}destroy(){T(this,gs)&&(clearTimeout(T(this,gs)),F(this,gs,null));for(const{payload:t,reject:n}of T(this,io))n(Yt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));F(this,io,[]),super.destroy()}}Ic=new WeakMap,Ml=new WeakMap,io=new WeakMap,gs=new WeakMap,Pi=new WeakMap,gi=new WeakMap,Dn=new WeakMap,Gh=new WeakSet,j_=function(){if(T(this,gs))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");F(this,gs,setTimeout(()=>{F(this,gs,null);const n=T(this,io);for(F(this,io,[]);n.length;){const i=[n.shift()];for(;n.length&&i.length!==T(this,Ic).batchMaxCount;)if(i.push(n.shift()),JSON.stringify(i.map(o=>o.payload)).length>T(this,Ic).batchMaxSize){n.unshift(i.pop());break}(async()=>{const s=i.length===1?i[0].payload:i.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const o=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:u,payload:l}of i){if(this.destroyed){u(Yt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:l.method}));continue}const h=o.filter(g=>g.id===l.id)[0];if(h==null){const g=Yt("missing response for request","BAD_DATA",{value:o,info:{payload:l}});this.emit("error",g),u(g);continue}if("error"in h){u(this.getRpcError(l,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of i)a(o)}})()}},t))};class Bre extends ZN{constructor(t,n){super(t,n);se(this,ra);let i=this._getOption("pollingInterval");i==null&&(i=qN.pollingInterval),F(this,ra,i)}_getSubscriber(t){const n=super._getSubscriber(t);return WN(n)&&(n.pollingInterval=T(this,ra)),n}get pollingInterval(){return T(this,ra)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");F(this,ra,t),this._forEachSubscriber(n=>{WN(n)&&(n.pollingInterval=T(this,ra))})}}ra=new WeakMap;class Pre extends Bre{constructor(t,n,i){t==null&&(t="http://localhost:8545");super(n,i);se(this,Ll);typeof t=="string"?F(this,Ll,new Us(t)):F(this,Ll,t.clone())}_getConnection(){return T(this,Ll).clone()}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){const n=this._getConnection();n.body=JSON.stringify(t),n.setHeader("content-type","application/json");const i=await n.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}Ll=new WeakMap;function fb(r){if(r==null)return null;if(typeof r.message=="string"&&r.message.match(/revert/i)&&Gt(r.data))return{message:r.message,data:r.data};if(typeof r=="object"){for(const e in r){const t=fb(r[e]);if(t)return t}return null}if(typeof r=="string")try{return fb(JSON.parse(r))}catch{}return null}function hb(r,e){if(r!=null){if(typeof r.message=="string"&&e.push(r.message),typeof r=="object")for(const t in r)hb(r[t],e);if(typeof r=="string")try{return hb(JSON.parse(r),e)}catch{}}}function Mre(r){const e=[];return hb(r,e),e}function Lre(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof qc<"u")return qc;throw new Error("unable to locate global object")}const Ure=Lre().WebSocket;class db{constructor(e,t){se(this,ys);se(this,jh);se(this,na);se(this,Sc);se(this,ia);F(this,ys,e),F(this,jh,JSON.stringify(t)),F(this,na,null),F(this,Sc,null),F(this,ia,null)}get filter(){return JSON.parse(T(this,jh))}start(){F(this,na,T(this,ys).send("eth_subscribe",this.filter).then(e=>(T(this,ys)._register(e,this),e)))}stop(){T(this,na).then(e=>{T(this,ys).destroyed||T(this,ys).send("eth_unsubscribe",[e])}),F(this,na,null)}pause(e){ge(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),F(this,Sc,!!e)}resume(){F(this,Sc,null)}_handleMessage(e){if(T(this,na)!=null&&T(this,Sc)===null){let t=T(this,ia);t==null?t=this._emit(T(this,ys),e):t=t.then(async()=>{await this._emit(T(this,ys),e)}),F(this,ia,t.then(()=>{T(this,ia)===t&&F(this,ia,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}ys=new WeakMap,jh=new WeakMap,na=new WeakMap,Sc=new WeakMap,ia=new WeakMap;class Dre extends db{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class $re extends db{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class Fre extends db{constructor(t,n){super(t,["logs",n]);se(this,Kh);F(this,Kh,JSON.stringify(n))}get logFilter(){return JSON.parse(T(this,Kh))}async _emit(t,n){t.emit(this.logFilter,t._wrapLog(n,t._network))}}Kh=new WeakMap;class Hre extends ZN{constructor(t,n){const i=Object.assign({},n??{});q(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",n),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(t,i);se(this,kc);se(this,Ul);se(this,sa);F(this,kc,new Map),F(this,Ul,new Map),F(this,sa,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Vp("close");case"block":return new Dre(this);case"pending":return new $re(this);case"event":return new Fre(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Vp("drop-log")}return super._getSubscriber(t)}_register(t,n){T(this,Ul).set(t,n);const i=T(this,sa).get(t);if(i){for(const s of i)n._handleMessage(s);T(this,sa).delete(t)}}async _send(t){q(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const n=new Promise((i,s)=>{T(this,kc).set(t.id,{payload:t,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await n]}async _processMessage(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&"id"in n){const i=T(this,kc).get(n.id);if(i==null){this.emit("error",Yt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:n}));return}T(this,kc).delete(n.id),i.resolve(n)}else if(n&&n.method==="eth_subscription"){const i=n.params.subscription,s=T(this,Ul).get(i);if(s)s._handleMessage(n.params.result);else{let o=T(this,sa).get(i);o==null&&(o=[],T(this,sa).set(i,o)),o.push(n.params.result)}}else{this.emit("error",Yt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:n}));return}}async _write(t){throw new Error("sub-classes must override this")}}kc=new WeakMap,Ul=new WeakMap,sa=new WeakMap;class zre extends Hre{constructor(t,n,i){super(n,i);se(this,Tc);se(this,Mi);typeof t=="string"?(F(this,Tc,()=>new Ure(t)),F(this,Mi,T(this,Tc).call(this))):typeof t=="function"?(F(this,Tc,t),F(this,Mi,t())):(F(this,Tc,null),F(this,Mi,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(s){console.log("failed to start WebsocketProvider",s)}},this.websocket.onmessage=s=>{this._processMessage(s.data)}}get websocket(){if(T(this,Mi)==null)throw new Error("websocket closed");return T(this,Mi)}async _write(t){this.websocket.send(t)}async destroy(){T(this,Mi)!=null&&(T(this,Mi).close(),F(this,Mi,null)),super.destroy()}}Tc=new WeakMap,Mi=new WeakMap;const Gre={_format:"hh-sol-artifact-1",contractName:"SwarmEventEmitter",sourceName:"contracts/SwarmEventEmitter.sol",abi:[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"string",name:"message",type:"string"}],name:"MessageLogged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"RemovedFromWhitelist",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"Whitelisted",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"addToWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"string",name:"message",type:"string"}],name:"emitMessage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"removeFromWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"whitelisted",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}],bytecode:"0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a26107b08061013b6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",deployedBytecode:"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",linkReferences:{},deployedLinkReferences:{}},jre={address:"Eai8D93JKad51sYmft1r74fzLkBSwRGPQVAmwZoLoWDf",metadata:{name:"swarm_event_emitter",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},instructions:[{name:"add_to_whitelist",discriminator:[157,211,52,54,144,81,5,55],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]},{name:"emit_message",discriminator:[118,99,20,87,25,132,207,62],accounts:[{name:"state",writable:!0},{name:"user",signer:!0}],args:[{name:"message",type:"string"}]},{name:"initialize",discriminator:[175,175,109,31,13,152,155,237],accounts:[{name:"state",writable:!0,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"admin",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"remove_from_whitelist",discriminator:[7,144,216,239,243,236,193,235],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]}],accounts:[{name:"State",discriminator:[216,146,107,94,104,75,182,177]}],events:[{name:"MessageLogged",discriminator:[24,236,247,207,227,70,101,210]},{name:"RemovedFromWhitelist",discriminator:[107,247,94,185,182,200,82,172]},{name:"Whitelisted",discriminator:[235,202,86,232,226,75,139,182]}],errors:[{code:6e3,name:"NotAdmin",msg:"Only the admin can perform this action."},{code:6001,name:"NotWhitelisted",msg:"You are not whitelisted."}],types:[{name:"MessageLogged",type:{kind:"struct",fields:[{name:"sender",type:"pubkey"},{name:"message",type:"string"}]}},{name:"RemovedFromWhitelist",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}},{name:"State",type:{kind:"struct",fields:[{name:"admin",type:"pubkey"},{name:"whitelisted",type:{vec:"pubkey"}}]}},{name:"Whitelisted",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}}]};class Kre{constructor(e){this.settings=e,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:e,contractAddress:t}=this.settings;if(!t)throw new Error("Contract address is required for EVM chain type");const n=e.startsWith("ws")?new zre(e):new Pre(e),i=new Ku(t,Gre.abi,n);this.evm={provider:n,contract:i}}initSvm(){const e=new Jx(this.settings.rpcUrl,"confirmed"),t=Ca.generate(),n={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:t.publicKey},i=new sh(e,n,{}),s=new ku(jre,i);this.svm={provider:e,program:s}}async onMessageFrom(e){this.settings.chainType==="EVM"?this.listenToEvm(e):this.settings.chainType==="SVM"&&await this.listenToSvm(e)}listenToEvm(e){var t;(t=this.evm)==null||t.contract.on("MessageLogged",(n,i)=>{n.toLowerCase()===this.settings.swarmEmitterAddress.toLowerCase()&&e(n,i)})}async listenToSvm(e){var n;const t=(n=this.svm)==null?void 0:n.program.addEventListener("messageLogged",i=>{const{sender:s,message:o}=i;s.toBase58()===this.settings.swarmEmitterAddress&&e(s.toBase58(),o)});this.svm&&t!==void 0&&(this.svm.listenerId=t)}async removeAllListeners(){var e,t;this.settings.chainType==="EVM"&&((e=this.evm)==null||e.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((t=this.svm)==null?void 0:t.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const Vre=new TextEncoder,QN=1,YN=4096,pb=4096,Wre=32;function qre(r,e){return e=typeof e=="number"?Se.FeedIndex.fromBigInt(BigInt(e)):e,new Se.Identifier(en.keccak256(en.concatBytes(r.toUint8Array(),e.toUint8Array())))}function Zre(r){const e=r.slice(0,Se.Span.LENGTH),t=r.slice(Se.Span.LENGTH),n=Qre(t),i=en.keccak256(en.concatBytes(e,n));return new Se.Reference(i)}function Qre(r){if(r.length>pb)throw new Se.BeeArgumentError(`payload size ${r.length} exceeds maximum chunk payload size ${pb}`,r);const e=new Uint8Array(pb);return e.set(r),en.log2Reduce(en.partition(e,Wre),(t,n)=>en.keccak256(en.concatBytes(t,n)))}function JN(r){if(r instanceof Uint8Array||(r=Vre.encode(r)),r.length<QN||r.length>YN)throw new RangeError(`payload size ${r.length} exceeds limits [${QN}, ${YN}]`);const e=Se.Span.fromBigInt(BigInt(r.length)),t=en.concatBytes(e.toUint8Array(),r);return{data:t,span:e,payload:Se.Bytes.fromSlice(t,Se.Span.LENGTH),address:Zre(t)}}function Yre(r,e){return new Se.Reference(en.keccak256(en.concatBytes(r.toUint8Array(),e.toUint8Array())))}function XN(r,e,t){e=new Se.Identifier(e),t=new Se.PrivateKey(t);const n=Yre(e,t.publicKey().address()),i=t.sign(en.concatBytes(e.toUint8Array(),r.address.toUint8Array())),s=en.concatBytes(e.toUint8Array(),i.toUint8Array(),r.data),o=Se.Span.fromSlice(r.data,0),a=Se.Bytes.fromSlice(r.data,Se.Span.LENGTH);return{data:s,identifier:e,signature:i,span:o,payload:a,address:n,owner:t.publicKey().address()}}class Jre{constructor(e,t){this.userDetails=e,this.swarmSettings=t,this.depth=24,this.logger=Ui.getInstance(),this.errorHandler=new Dd,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(e,t){const{enveloped:n,stamp:i}=this.swarmSettings;if(!n)await this.writeOwnFeedDataByIndexOwned(e,t);else if(i)await this.writeOwnFeedDataByIndexEnvelope(e,t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=this.generateUserOwnedFeedId(s,a),l=Se.Topic.fromString(u);console.log("DEBUG: feedID write",l.toString(),a,e,u),await n.makeFeedWriter(l,new Se.PrivateKey(o)).uploadPayload(i,JSON.stringify(t),{index:e})}async writeOwnFeedDataByIndexEnvelope(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=new Se.PrivateKey(o),l=Se.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,a),g=Se.Topic.fromString(h),b=qre(g,e),w=JN(t),I=XN(w,b,u),S={hash:()=>I.address.toUint8Array()},x=l.stamp(S),{upload:C}=n.makeSOCWriter(u),H=Se.Bytes.fromUtf8(t);return(await C(x,b,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(e,t,n){const{bee:i,chatTopic:s}=this.swarmSettings,o=(n==null?void 0:n.timeout)??1500,a=this.generateUserOwnedFeedId(s,e),u=Se.Topic.fromString(a);console.log("DEBUG: feedID read",u.toString(),e,t,a);const h=await i.makeFeedReader(u,e,{timeout:o}).downloadPayload({index:t});return console.log(h.payload.toHex()),console.log(h.payload.toUtf8()),h.payload.toJSON()}orderMessages(e){return e.sort((t,n)=>t.timestamp-n.timestamp)}async retryAwaitableAsync(e,t=3,n=250){return new Promise((i,s)=>{e().then(i).catch(o=>{t>0?(this.logger.info(`Retrying... Attempts left: ${t}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(e,t-1,n).then(i).catch(s)},n)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(e){const{enveloped:t,stamp:n}=this.swarmSettings;if(t){if(n)return this.uploadObjectToBeeEnvelope(e);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(e)}async uploadObjectToBeeOwn(e){try{const{bee:t,stamp:n}=this.swarmSettings,i=await t.uploadData(n,JSON.stringify(e),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i.reference.toString()}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(e){try{const{bee:t,stamp:n}=this.swarmSettings,{privateKey:i}=this.userDetails,s=Se.Stamper.fromBlank(i,n,this.depth),o=Se.Bytes.fromUtf8(JSON.stringify(e)),a=new k4(async l=>{await t.uploadChunk(s.stamp(l),l.build())});await a.append(o.toUint8Array());const u=await a.finalize();return en.uint8ArrayToHex(u.hash())}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(e){try{const{bee:t}=this.swarmSettings;return(await t.downloadData(e)).toJSON()}catch(t){return this.errorHandler.handleError(t,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:e,chatTopic:t}=this.swarmSettings,{ownAddress:n}=this.userDetails,i=this.generateUserOwnedFeedId(t,n),s=Se.Topic.fromString(i),a=await e.makeFeedReader(s,n).downloadPayload(),u=Number(a.feedIndex.toBigInt()),l=u+1;return console.log("DEBUG: getLatestFeedIndex",u,l),{latestIndex:u,nextIndex:l}}catch(e){if(this.isNotFoundError(e))return{latestIndex:-1,nextIndex:0};throw e}}async fetchLatestChatMessage(){const{bee:e,chatTopic:t,chatAddress:n}=this.swarmSettings;return(await e.makeFeedReader(Se.Topic.fromString(t),Gg(n)).downloadPayload()).payload.toJSON()}async fetchChatMessage(e){const{bee:t,chatTopic:n,chatAddress:i}=this.swarmSettings;return(await t.makeFeedReader(Se.Topic.fromString(n),Gg(i)).downloadPayload({index:Se.FeedIndex.fromBigInt(BigInt(`0x${e}`))})).payload.toJSON()}async sendMessageToGsoc(e){const{enveloped:t,stamp:n}=this.swarmSettings;if(!t)await this.sendMessageToGsocOwn(e);else if(n)await this.sendMessageToGsocEnvelope(e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new Se.PrivateKey(s),a=Se.Identifier.fromString(i),u=Se.Bytes.fromUtf8(e),{upload:l}=t.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await l(n,a,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,a=Se.Stamper.fromBlank(o,n,this.depth),u=new Se.PrivateKey(s),l=Se.Identifier.fromString(i),h=Se.Bytes.fromUtf8(e),g=JN(h.toUint8Array()),b=XN(g,l,u),w={hash:()=>b.address.toUint8Array()},I=a.stamp(w),{upload:S}=t.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await S(I,l,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(e,t){return`${e}_EthercastChat_${t}`}isNotFoundError(e){return e.stack.includes("404")||e.message.includes("Not Found")||e.message.includes("404")}}class Xre{constructor(e){var n,i,s;this.logger=Ui.getInstance(),this.errorHandler=new Dd,this.messagesQueue=new jg({clearWaitTime:200}),this.gsocListenerQueue=new jg({clearWaitTime:200}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const t=new Se.PrivateKey(Gg(e.user.privateKey));this.userDetails={privateKey:e.user.privateKey,ownAddress:t.publicKey().address().toString(),nickname:e.user.nickname,ownIndex:-1},this.swarmSettings={bee:new Se.Bee(e.infra.swarm.beeUrl),stamp:e.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:e.infra.swarm.enveloped,gsocTopic:e.infra.swarm.gsocTopic,gsocResourceId:e.infra.swarm.gsocResourceId,chatTopic:e.infra.swarm.chatTopic,chatAddress:e.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((n=e.options)==null?void 0:n.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=e.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=e.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new S4,this.utils=new Jre(this.userDetails,this.swarmSettings),this.history=new vG(this.userDetails,this.utils,this.emitter),this.swarmEventEmitterReader=new Kre(e.infra.chain)}start(){this.init(),this.subscribeToGSOCEvent(),this.startMessagesFetchProcess(),this.startIdleUserCleanup(),this.history.startHistoryUpdateProcess()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.unsubFromGSOCEvent(),this.history.stopHistoryUpdateProcess(),this.emitter.cleanAll()}getEmitter(){return this.emitter}orderMessages(e){return this.utils.orderMessages(e)}async sendMessage(e,t){const n=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:t||I4(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:n,message:e};try{this.emitter.emit(ei.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(n,JSON.stringify(i)),this.userDetails.ownIndex=n,this.emitter.emit(ei.MESSAGE_REQUEST_UPLOADED,i),await this.waitForMessageBroadcast(n)}catch(s){this.emitter.emit(ei.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(ei.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages({preDownloadHistory:!0})}finally{this.emitter.emit(ei.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(e){this.sendMessage(e.message,e.id)}async retryBroadcastUserMessage(e){this.waitForMessageBroadcast(e.index)}async init(){try{this.emitter.emit(ei.LOADING_INIT,!0);const[e,t]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(e.status==="rejected")throw e.reason;t.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${t.reason}`),this.emitter.emit(ei.LOADING_INIT,!1)}catch(e){this.errorHandler.handleError(e,"Chat.initSelfState"),this.emitter.emit(ei.CRITICAL_ERROR,e)}}async initOwnIndex(){const{latestIndex:n}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=n}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom((e,t)=>this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(t)))}catch(e){this.errorHandler.handleError(e,"Chat.listenToNewSubscribers"),this.emitter.emit(ei.CRITICAL_ERROR,e)}}async processGsocEvent(e){try{console.log("processGsocMessage CALLED",e);const[t,n]=e.split("_"),i=await this.utils.fetchChatMessage(n);if(console.log("DEBUG processGsocMessage",i),!ZA(i)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",i),v4(this.latestMessage,i))return;i.messageSender?(this.updateActiveUsers(i.messageSender),this.history.processHistoryUpdaterEntry(this.activeUsers,i.historyEntry)):this.history.setHistoryEntry(i.historyEntry),this.latestMessage=i}catch(t){this.errorHandler.handleError(t,"Chat.processGsocMessage")}}async waitForMessageBroadcast(e){return QA({condition:()=>Object.values(this.activeUsers).some(t=>t.index===e),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const e=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",e),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({messageSender:e,historyEntry:this.history.getHistoryEntryWithNewUpdater(this.activeUsers)})))}catch(e){this.errorHandler.handleError(e,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:e,privateKey:t,nickname:n}=this.userDetails,i=new Se.EthAddress(e).toString(),s=new Se.PrivateKey(t);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const a=Date.now(),u=s.sign(JSON.stringify({username:n,address:i,timestamp:a}));return{address:i,timestamp:a,signature:u.toHex(),index:this.getOwnIndex(),username:n}}async readAllActiveUserMessage(){if(!await this.messagesQueue.waitForProcessing())for(const t of Object.values(this.activeUsers))this.messagesQueue.enqueue(()=>this.readMessage(t))}async readMessage(e){try{let t;const n=this.isUserIndexRead(e.address,e.index);if(n.isIndexRead)return;t=n.cachedIndex?n.cachedIndex+1:e.index;const i=await this.utils.fetchUserFeedDataByIndex(e.address,t);this.setUserIndexCache(e.address,t),this.emitter.emit(ei.MESSAGE_RECEIVED,i)}catch(t){this.errorHandler.handleError(t,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:e,FETCH_MESSAGE_INTERVAL_TIME:t}=this.options;if(e){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),t)}stopMessagesFetchProcess(){const{fetchMessageTimer:e}=this.options;e&&(clearInterval(e),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:e,IDLE_USER_CLEANUP_INTERVAL_TIME:t}=this.options;if(e){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),t)}stopIdleUserCleanup(){const{idleUserCleanupInterval:e}=this.options;e&&(clearInterval(e),this.options.idleUserCleanupInterval=null)}isUserIndexRead(e,t){const n=this.userIndexCache[e];return{cachedIndex:n,isIndexRead:n===t}}setUserIndexCache(e,t){this.userIndexCache[e]=t}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const e=Date.now();for(const t of Object.values(this.activeUsers))e-t.timestamp>300*$M&&delete this.activeUsers[t.address]}updateActiveUsers(e){this.activeUsers[e.address]=e}}ft.EVENTS=ei,ft.SwarmChat=Xre,Object.defineProperty(ft,Symbol.toStringTag,{value:"Module"})});