@notabene/verify-proof 1.8.0 → 1.9.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.
@@ -0,0 +1,2 @@
1
+ import { SignatureProof } from "@notabene/javascript-sdk";
2
+ export declare function verifyCosmosSignature(proof: SignatureProof): Promise<SignatureProof>;
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("@notabene/javascript-sdk"),t=require("varuint-bitcoin"),r=require("@scure/base"),n=require("ox"),o=require("@noble/curves/secp256k1"),s=require("bip322-js"),i=require("tweetnacl"),a=require("@cardano-foundation/cardano-verify-datasignature"),c=require("xrpl"),u=require("@noble/curves/abstract/utils"),f=require("@noble/curves/ed25519"),d=require("@stellar/stellar-sdk");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l,y=/*#__PURE__*/h(r),p=/*#__PURE__*/h(o),b=/*#__PURE__*/h(i),v=/*#__PURE__*/h(a),g=/*#__PURE__*/h(u),A=/*#__PURE__*/h(f);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function P(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return m(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},S.apply(null,arguments)}!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(l||(l={}));var x,_={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},litecoin:{messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc",isTestnet:!1},dogecoin:{messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22,isTestnet:!1},dash:{messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16,isTestnet:!1},zcash:{messagePrefix:"Zcash Signed Message:\n",pubKeyHashVersion:Uint8Array.from([28,184]),scriptHashVersion:Uint8Array.from([28,189]),isTestnet:!1},testnet:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:111,scriptHashVersion:196,bech32Prefix:"tb",isTestnet:!0}};function H(t,r){return S({},r,{status:s.Verifier.verifySignature(t,r.attestation,r.proof)?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})}function E(s,i,a){var c=Boolean(a.bech32Prefix&&[x.SEGWIT,x.NATIVE].includes(function(e){if(e.match("^(bc1|tb1|ltc1).*"))return x.NATIVE;if(e.match("^[32M].*"))return x.SEGWIT;if(e.match("^[1nmL].*"))return x.LEGACY;if(e.match("^(D).*"))return x.DOGECOIN;if(e.match("^(q).*"))return x.BCH;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(s))),u=function(e,s,i,a,c){var u=function(e){var t=r.base64.decode(e);if(65!==t.length)throw new Error("Invalid signature length");var n=t[0]-27;if(n>15||n<0)throw new Error("Invalid signature parameter");var s=!!(12&n),i=3&n,a=o.secp256k1.Signature.fromCompact(t.slice(1));return{compressed:s,segwitType:8&n?4&n?l.P2WPKH:l.P2SH_P2WPKH:void 0,signature:a.addRecoveryBit(i)}}(i),f=u.compressed,d=u.segwitType,h=u.signature;if(a&&!f)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");var y,p=function(e,r){var o=(new TextEncoder).encode(r),s=(new TextEncoder).encode(e),i=t.encode(s.length).buffer,a=new Uint8Array(o.length+i.byteLength+s.length);return a.set(o),a.set(new Uint8Array(i),o.length),a.set(s,o.length+i.byteLength),function(e){return n.Hash.sha256(n.Hash.sha256(e))}(a)}(e,c.messagePrefix),b=(y=h.recoverPublicKey(p).toRawBytes(f),n.Hash.ripemd160(n.Hash.sha256(y))),v="";if(s.startsWith("q"))return(v=I(c.pubKeyHashVersion,b)).startsWith("1");if(d)v=d===l.P2SH_P2WPKH?I(c.scriptHashVersion,b):c.bech32Prefix?D(b,c.bech32Prefix):I(c.scriptHashVersion,b);else if(a&&c.bech32Prefix)try{v=D(b,c.bech32Prefix)}catch(e){v=I(c.scriptHashVersion,b)}else v=I(c.pubKeyHashVersion,b);return v===s}(i.attestation,s,i.proof,c,a);return S({},i,{status:u?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})}!function(e){e.LEGACY="Legacy",e.NATIVE="Native SegWit",e.SEGWIT="SegWit",e.P2SH_SEGWIT="p2sh",e.BCH="Bitcoin Cash",e.ETHEREUM="Ethereum",e.DOGECOIN="Dogecoin",e.UNKNOWN="Unknown"}(x||(x={}));var w=r.createBase58check(n.Hash.sha256);function I(e,t){var r="number"==typeof e?Uint8Array.of(e):e,n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),w.encode(n)}function D(e,t){void 0===t&&(t="bc");var n=r.bech32.toWords(e);return n.unshift(0),r.bech32.encode(t,n)}function B(e,t){for(var r=[],n=t;n<e.length&&null!=(o=e[n])&&o.startsWith("- ");){var o;r.push(e[n].substring(2)),n++}return r}var L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function V(e){var t={exports:{}};return e(t,t.exports),t.exports}var U=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0}),T=V(function(e,t){function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function o(e,...t){if(!r(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function s(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function i(e){for(let t=0;t<e.length;t++)e[t]=s(e[t]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=r,t.anumber=n,t.abytes=o,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");n(e.outputLen),n(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){o(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=s,t.byteSwap32=i,t.bytesToHex=function(e){if(o(e),a)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=c[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(a)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=f(e.charCodeAt(o)),s=f(e.charCodeAt(o+1));if(void 0===r||void 0===s)throw new Error('hex string expected, got non-hex character "'+(e[o]+e[o+1])+'" at index '+o);n[t]=16*r+s}return n},t.asyncLoop=async function(e,r,n){let o=Date.now();for(let s=0;s<e;s++){n(s);const e=Date.now()-o;e>=0&&e<r||(await(0,t.nextTick)(),o+=e)}},t.utf8ToBytes=d,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=h,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=d(e)),o(e),e},t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];o(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=l,t.createOptHasher=y,t.createXOFer=p,t.randomBytes=function(e=32){if(U.crypto&&"function"==typeof U.crypto.getRandomValues)return U.crypto.getRandomValues(new Uint8Array(e));if(U.crypto&&"function"==typeof U.crypto.randomBytes)return Uint8Array.from(U.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>s(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:i;const a=/* @__PURE__ */(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),c=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),u={_0:48,_9:57,A:65,F:70,a:97,f:102};function f(e){return e>=u._0&&e<=u._9?e-u._0:e>=u.A&&e<=u.F?e-(u.A-10):e>=u.a&&e<=u.f?e-(u.a-10):void 0}function d(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function h(e){return"string"==typeof e&&(e=d(e)),o(e),e}function l(e){const t=t=>e().update(h(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function y(e){const t=(t,r)=>e(r).update(h(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}function p(e){const t=(t,r)=>e(r).update(h(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=l,t.wrapConstructorWithOpts=y,t.wrapXOFConstructorWithOpts=p}),k=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equal=t.concat=t.HEX_REGEX=void 0,t.HEX_REGEX=/^[A-F0-9]*$/iu,t.concat=function(e){return(0,T.concatBytes)(...e)},t.equal=function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Int8Array(e),n=new Int8Array(t);for(let t=0;t!==e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}}),C=V(function(e,t){var r=L&&L.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=L&&L.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.stringToHex=t.hexToString=t.hexToBytes=t.bytesToHex=void 0,t.bytesToHex=e=>(0,T.bytesToHex)(e instanceof Uint8Array?e:Uint8Array.from(e)).toUpperCase(),t.hexToBytes=e=>{const t=new Uint8Array(e.length/2);if(!k.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,o=e.slice(n,n+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}return t},t.hexToString=(e,r="utf8")=>new TextDecoder(r).decode((0,t.hexToBytes)(e)),t.stringToHex=e=>(0,t.bytesToHex)((new TextEncoder).encode(e)),t.randomBytes=T.randomBytes,n(k,t)}),F=V(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),c=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+c,a,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=r,t.Chi=function(e,t,r){return e&t^~e&r},t.Maj=function(e,t,r){return e&t^e&r^t&r},t.HashMD=class extends T.Hash{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,T.createView)(this.buffer)}update(e){(0,T.aexists)(this),e=(0,T.toBytes)(e),(0,T.abytes)(e);const{view:t,buffer:r,blockLen:n}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);if(i===n){const t=(0,T.createView)(e);for(;n<=o-s;s+=n)this.process(t,s);continue}r.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,T.aexists)(this),(0,T.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:s}=this;let{pos:i}=this;t[i++]=128,(0,T.clean)(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let e=i;e<o;e++)t[e]=0;r(n,o-8,BigInt(8*this.length),s),this.process(n,0);const a=(0,T.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)a.setUint32(4*e,f[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}},t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),j=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=A,t.fromBig=o,t.split=s;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function o(e,t=!1){return t?{h:Number(e&r),l:Number(e>>n&r)}:{h:0|Number(e>>n&r),l:0|Number(e&r)}}function s(e,t=!1){const r=e.length;let n=new Uint32Array(r),s=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:a}=o(e[i],t);[n[i],s[i]]=[r,a]}return[n,s]}const i=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>0);t.toBig=i;const a=(e,t,r)=>e>>>r;t.shrSH=a;const c=(e,t,r)=>e<<32-r|t>>>r;t.shrSL=c;const u=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=u;const f=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=f;const d=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=d;const h=(e,t,r)=>e>>>r-32|t<<64-r;t.rotrBL=h;const l=(e,t)=>t;t.rotr32H=l;const y=(e,t)=>e;t.rotr32L=y;const p=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=p;const b=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=b;const v=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=v;const g=(e,t,r)=>e<<r-32|t>>>64-r;function A(e,t,r,n){const o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:0|o}}t.rotlBL=g;const m=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=m;const P=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=P;const S=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=S;const x=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;t.add4H=x;const _=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);t.add5L=_;const H=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;t.add5H=H,t.default={fromBig:o,split:s,toBig:i,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:d,rotrBL:h,rotr32H:l,rotr32L:y,rotlSH:p,rotlSL:b,rotlBH:v,rotlBL:g,add:A,add3L:m,add3H:P,add4L:S,add4H:x,add5H:H,add5L:_}}),O=F,K=j,M=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=/* @__PURE__ */Uint32Array.from([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]),n=/* @__PURE__ */new Uint32Array(64);class o extends O.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|O.SHA256_IV[0],this.B=0|O.SHA256_IV[1],this.C=0|O.SHA256_IV[2],this.D=0|O.SHA256_IV[3],this.E=0|O.SHA256_IV[4],this.F=0|O.SHA256_IV[5],this.G=0|O.SHA256_IV[6],this.H=0|O.SHA256_IV[7]}get(){const{A:e,B:t,C:r,D:n,E:o,F:s,G:i,H:a}=this;return[e,t,r,n,o,s,i,a]}set(e,t,r,n,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=n[e-15],r=n[e-2],o=(0,T.rotr)(t,7)^(0,T.rotr)(t,18)^t>>>3,s=(0,T.rotr)(r,17)^(0,T.rotr)(r,19)^r>>>10;n[e]=s+n[e-7]+o+n[e-16]|0}let{A:o,B:s,C:i,D:a,E:c,F:u,G:f,H:d}=this;for(let e=0;e<64;e++){const t=d+((0,T.rotr)(c,6)^(0,T.rotr)(c,11)^(0,T.rotr)(c,25))+(0,O.Chi)(c,u,f)+r[e]+n[e]|0,h=((0,T.rotr)(o,2)^(0,T.rotr)(o,13)^(0,T.rotr)(o,22))+(0,O.Maj)(o,s,i)|0;d=f,f=u,u=c,c=a+t|0,a=i,i=s,s=o,o=t+h|0}o=o+this.A|0,s=s+this.B|0,i=i+this.C|0,a=a+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(o,s,i,a,c,u,f,d)}roundClean(){(0,T.clean)(n)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,T.clean)(this.buffer)}}t.SHA256=o;class s extends o{constructor(){super(28),this.A=0|O.SHA224_IV[0],this.B=0|O.SHA224_IV[1],this.C=0|O.SHA224_IV[2],this.D=0|O.SHA224_IV[3],this.E=0|O.SHA224_IV[4],this.F=0|O.SHA224_IV[5],this.G=0|O.SHA224_IV[6],this.H=0|O.SHA224_IV[7]}}t.SHA224=s;const i=/* @__PURE__ */(()=>K.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(e=>BigInt(e))))(),a=/* @__PURE__ */(()=>i[0])(),c=/* @__PURE__ */(()=>i[1])(),u=/* @__PURE__ */new Uint32Array(80),f=/* @__PURE__ */new Uint32Array(80);class d extends O.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|O.SHA512_IV[0],this.Al=0|O.SHA512_IV[1],this.Bh=0|O.SHA512_IV[2],this.Bl=0|O.SHA512_IV[3],this.Ch=0|O.SHA512_IV[4],this.Cl=0|O.SHA512_IV[5],this.Dh=0|O.SHA512_IV[6],this.Dl=0|O.SHA512_IV[7],this.Eh=0|O.SHA512_IV[8],this.El=0|O.SHA512_IV[9],this.Fh=0|O.SHA512_IV[10],this.Fl=0|O.SHA512_IV[11],this.Gh=0|O.SHA512_IV[12],this.Gl=0|O.SHA512_IV[13],this.Hh=0|O.SHA512_IV[14],this.Hl=0|O.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:o,Cl:s,Dh:i,Dl:a,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:l,Hh:y,Hl:p}=this;return[e,t,r,n,o,s,i,a,c,u,f,d,h,l,y,p]}set(e,t,r,n,o,s,i,a,c,u,f,d,h,l,y,p){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|d,this.Gh=0|h,this.Gl=0|l,this.Hh=0|y,this.Hl=0|p}process(e,t){for(let r=0;r<16;r++,t+=4)u[r]=e.getUint32(t),f[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|u[e-15],r=0|f[e-15],n=K.rotrSH(t,r,1)^K.rotrSH(t,r,8)^K.shrSH(t,r,7),o=K.rotrSL(t,r,1)^K.rotrSL(t,r,8)^K.shrSL(t,r,7),s=0|u[e-2],i=0|f[e-2],a=K.rotrSH(s,i,19)^K.rotrBH(s,i,61)^K.shrSH(s,i,6),c=K.rotrSL(s,i,19)^K.rotrBL(s,i,61)^K.shrSL(s,i,6),d=K.add4L(o,c,f[e-7],f[e-16]),h=K.add4H(d,n,a,u[e-7],u[e-16]);u[e]=0|h,f[e]=0|d}let{Ah:r,Al:n,Bh:o,Bl:s,Ch:i,Cl:d,Dh:h,Dl:l,Eh:y,El:p,Fh:b,Fl:v,Gh:g,Gl:A,Hh:m,Hl:P}=this;for(let e=0;e<80;e++){const t=K.rotrSH(y,p,14)^K.rotrSH(y,p,18)^K.rotrBH(y,p,41),S=K.rotrSL(y,p,14)^K.rotrSL(y,p,18)^K.rotrBL(y,p,41),x=y&b^~y&g,_=K.add5L(P,S,p&v^~p&A,c[e],f[e]),H=K.add5H(_,m,t,x,a[e],u[e]),E=0|_,w=K.rotrSH(r,n,28)^K.rotrBH(r,n,34)^K.rotrBH(r,n,39),I=K.rotrSL(r,n,28)^K.rotrBL(r,n,34)^K.rotrBL(r,n,39),D=r&o^r&i^o&i,B=n&s^n&d^s&d;m=0|g,P=0|A,g=0|b,A=0|v,b=0|y,v=0|p,({h:y,l:p}=K.add(0|h,0|l,0|H,0|E)),h=0|i,l=0|d,i=0|o,d=0|s,o=0|r,s=0|n;const L=K.add3L(E,I,B);r=K.add3H(L,H,w,D),n=0|L}({h:r,l:n}=K.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:s}=K.add(0|this.Bh,0|this.Bl,0|o,0|s)),({h:i,l:d}=K.add(0|this.Ch,0|this.Cl,0|i,0|d)),({h:h,l:l}=K.add(0|this.Dh,0|this.Dl,0|h,0|l)),({h:y,l:p}=K.add(0|this.Eh,0|this.El,0|y,0|p)),({h:b,l:v}=K.add(0|this.Fh,0|this.Fl,0|b,0|v)),({h:g,l:A}=K.add(0|this.Gh,0|this.Gl,0|g,0|A)),({h:m,l:P}=K.add(0|this.Hh,0|this.Hl,0|m,0|P)),this.set(r,n,o,s,i,d,h,l,y,p,b,v,g,A,m,P)}roundClean(){(0,T.clean)(u,f)}destroy(){(0,T.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=d;class h extends d{constructor(){super(48),this.Ah=0|O.SHA384_IV[0],this.Al=0|O.SHA384_IV[1],this.Bh=0|O.SHA384_IV[2],this.Bl=0|O.SHA384_IV[3],this.Ch=0|O.SHA384_IV[4],this.Cl=0|O.SHA384_IV[5],this.Dh=0|O.SHA384_IV[6],this.Dl=0|O.SHA384_IV[7],this.Eh=0|O.SHA384_IV[8],this.El=0|O.SHA384_IV[9],this.Fh=0|O.SHA384_IV[10],this.Fl=0|O.SHA384_IV[11],this.Gh=0|O.SHA384_IV[12],this.Gl=0|O.SHA384_IV[13],this.Hh=0|O.SHA384_IV[14],this.Hl=0|O.SHA384_IV[15]}}t.SHA384=h;const l=/* @__PURE__ */Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),y=/* @__PURE__ */Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class p extends d{constructor(){super(28),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}}t.SHA512_224=p;class b extends d{constructor(){super(32),this.Ah=0|y[0],this.Al=0|y[1],this.Bh=0|y[2],this.Bl=0|y[3],this.Ch=0|y[4],this.Cl=0|y[5],this.Dh=0|y[6],this.Dl=0|y[7],this.Eh=0|y[8],this.El=0|y[9],this.Fh=0|y[10],this.Fl=0|y[11],this.Gh=0|y[12],this.Gl=0|y[13],this.Hh=0|y[14],this.Hl=0|y[15]}}t.SHA512_256=b,t.sha256=(0,T.createHasher)(()=>new o),t.sha224=(0,T.createHasher)(()=>new s),t.sha512=(0,T.createHasher)(()=>new d),t.sha384=(0,T.createHasher)(()=>new h),t.sha512_256=(0,T.createHasher)(()=>new b),t.sha512_224=(0,T.createHasher)(()=>new p)}),N=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.SHA224=t.sha256=t.SHA256=void 0,t.SHA256=M.SHA256,t.sha256=M.sha256,t.SHA224=M.SHA224,t.sha224=M.sha224});const R=(L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:function(e){return Array.isArray(e)?new Uint8Array(e):e}},"__esModule",{value:!0}));var W=/*#__PURE__*/Object.defineProperty({default:function(e){function t(t){return e((0,R.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,R.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),G=N,q=V(function(e,t){var r=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha256=void 0;const n=r(W);t.sha256=(0,n.default)(G.sha256)}),X=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.concatArgs=t.arrayEqual=void 0,t.arrayEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])},t.concatArgs=function(...e){return e.flatMap(e=>"number"==typeof e?[e]:Array.from(e))}}),$=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.encodeNodePublic=t.decodeNodePublic=t.decodeAddress=t.decodeAccountID=t.encodeAddress=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0;const r=[1,225,75],n={sha256:q.sha256},o=new class{constructor(e){this._sha256=e.sha256,this._codec=y.default.base58xrp}encode(e,t){return this._encodeVersioned(e,t.versions,t.expectedLength)}decode(e,t){var r;const n=t.versions,o=t.versionTypes,s=this.decodeChecked(e);if(n.length>1&&!t.expectedLength)throw new Error("expectedLength is required because there are >= 2 possible versions");const i=null!==(r=t.expectedLength)&&void 0!==r?r:s.length-("number"==typeof n[0]?1:n[0].length),a=s.slice(0,-i),c=s.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,X.arrayEqual)(a,t))return{version:t,bytes:c,type:o?o[e]:null}}throw new Error("version_invalid: version bytes do not match any of the provided version(s)")}encodeChecked(e){const t=this._sha256(this._sha256(e)).slice(0,4);return this._encodeRaw(Uint8Array.from((0,X.concatArgs)(e,t)))}decodeChecked(e){const t=this._decodeRaw(e);if(t.byteLength<5)throw new Error("invalid_input_size: decoded data must have length >= 5");if(!this._verifyCheckSum(t))throw new Error("checksum_invalid");return t.slice(0,-4)}_encodeVersioned(e,t,r){if(!a(e,r))throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Uint8Array.");return this.encodeChecked((0,X.concatArgs)(t,e))}_encodeRaw(e){return this._codec.encode(Uint8Array.from(e))}_decodeRaw(e){return this._codec.decode(e)}_verifyCheckSum(e){const t=this._sha256(this._sha256(e.slice(0,-4))).slice(0,4),r=e.slice(-4);return(0,X.arrayEqual)(t,r)}}(n);function s(e){return o.encode(e,{versions:[0],expectedLength:20})}function i(e){return o.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=o,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return o.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return o.decode(e,t)},t.encodeAccountID=s,t.encodeAddress=s,t.decodeAccountID=i,t.decodeAddress=i,t.decodeNodePublic=function(e){return o.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return o.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return o.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return o.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{i(e)}catch(e){return!1}return!0}}),z=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidXAddress=t.decodeXAddress=t.xAddressToClassicAddress=t.encodeXAddress=t.classicAddressToXAddress=t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.decodeNodePublic=t.encodeNodePublic=t.decodeAccountID=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0,Object.defineProperty(t,"codec",{enumerable:!0,get:function(){return $.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return $.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return $.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return $.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return $.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return $.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return $.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return $.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return $.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return $.isValidClassicAddress}});const r={main:Uint8Array.from([5,68]),test:Uint8Array.from([4,147])};function n(e,t,n){if(20!==e.length)throw new Error("Account ID must be 20 bytes");if(!1!==t&&t>4294967295)throw new Error("Invalid tag");const o=t||0,s=(0,C.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0])]);return $.codec.encodeChecked(s)}function o(e){const t=$.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,C.equal)(r.main,t))return!1;if((0,C.equal)(r.test,t))return!0;throw new Error("Invalid X-address: bad prefix")}(t);return{accountId:t.slice(2,22),tag:function(e){const t=e[22];if(t>=2)throw new Error("Unsupported X-address");if(1===t)return e[23]+256*e[24]+65536*e[25]+16777216*e[26];if(0!==t)throw new Error("flag must be zero to indicate no tag");if(!(0,C.equal)((0,C.hexToBytes)("0000000000000000"),e.slice(23,31)))throw new Error("remaining bytes must be zero");return!1}(t),test:n}}t.classicAddressToXAddress=function(e,t,r){return n((0,$.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=o(e);return{classicAddress:(0,$.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=o,t.isValidXAddress=function(e){try{o(e)}catch(e){return!1}return!0}}),Y=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=t.md5=t.MD5=t.sha1=t.SHA1=void 0;const r=/* @__PURE__ */Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),n=/* @__PURE__ */new Uint32Array(80);class o extends O.HashMD{constructor(){super(64,20,8,!1),this.A=0|r[0],this.B=0|r[1],this.C=0|r[2],this.D=0|r[3],this.E=0|r[4]}get(){const{A:e,B:t,C:r,D:n,E:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)n[e]=(0,T.rotl)(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let{A:r,B:o,C:s,D:i,E:a}=this;for(let e=0;e<80;e++){let t,c;e<20?(t=(0,O.Chi)(o,s,i),c=1518500249):e<40?(t=o^s^i,c=1859775393):e<60?(t=(0,O.Maj)(o,s,i),c=2400959708):(t=o^s^i,c=3395469782);const u=(0,T.rotl)(r,5)+t+a+c+n[e]|0;a=i,i=s,s=(0,T.rotl)(o,30),o=r,r=u}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,this.set(r,o,s,i,a)}roundClean(){(0,T.clean)(n)}destroy(){this.set(0,0,0,0,0),(0,T.clean)(this.buffer)}}t.SHA1=o,t.sha1=(0,T.createHasher)(()=>new o);const s=/* @__PURE__ */Math.pow(2,32),i=/* @__PURE__ */Array.from({length:64},(e,t)=>Math.floor(s*Math.abs(Math.sin(t+1)))),a=/* @__PURE__ */r.slice(0,4),c=/* @__PURE__ */new Uint32Array(16);class u extends O.HashMD{constructor(){super(64,16,8,!0),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3]}get(){const{A:e,B:t,C:r,D:n}=this;return[e,t,r,n]}set(e,t,r,n){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n}process(e,t){for(let r=0;r<16;r++,t+=4)c[r]=e.getUint32(t,!0);let{A:r,B:n,C:o,D:s}=this;for(let e=0;e<64;e++){let t,a,u;e<16?(t=(0,O.Chi)(n,o,s),a=e,u=[7,12,17,22]):e<32?(t=(0,O.Chi)(s,n,o),a=(5*e+1)%16,u=[5,9,14,20]):e<48?(t=n^o^s,a=(3*e+5)%16,u=[4,11,16,23]):(t=o^(n|~s),a=7*e%16,u=[6,10,15,21]),t=t+r+i[e]+c[a],r=s,s=o,o=n,n+=(0,T.rotl)(t,u[e%4])}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,s=s+this.D|0,this.set(r,n,o,s)}roundClean(){(0,T.clean)(c)}destroy(){this.set(0,0,0,0),(0,T.clean)(this.buffer)}}t.MD5=u,t.md5=(0,T.createHasher)(()=>new u);const f=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),d=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),h=/* @__PURE__ */(()=>d.map(e=>(9*e+5)%16))(),l=/* @__PURE__ */(()=>{const e=[[d],[h]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>f[e]));return e})(),y=/* @__PURE__ */(()=>l[0])(),p=/* @__PURE__ */(()=>l[1])(),b=/* @__PURE__ */[[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(e=>Uint8Array.from(e)),v=/* @__PURE__ */y.map((e,t)=>e.map(e=>b[t][e])),g=/* @__PURE__ */p.map((e,t)=>e.map(e=>b[t][e])),A=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),m=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function P(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const S=/* @__PURE__ */new Uint32Array(16);class x extends O.HashMD{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:t,h2:r,h3:n,h4:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)S[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,i=0|this.h2,a=i,c=0|this.h3,u=c,f=0|this.h4,d=f;for(let e=0;e<5;e++){const t=4-e,h=A[e],l=m[e],b=y[e],x=p[e],_=v[e],H=g[e];for(let t=0;t<16;t++){const n=(0,T.rotl)(r+P(e,o,i,c)+S[b[t]]+h,_[t])+f|0;r=f,f=c,c=0|(0,T.rotl)(i,10),i=o,o=n}for(let e=0;e<16;e++){const r=(0,T.rotl)(n+P(t,s,a,u)+S[x[e]]+l,H[e])+d|0;n=d,d=u,u=0|(0,T.rotl)(a,10),a=s,s=r}}this.set(this.h1+i+u|0,this.h2+c+d|0,this.h3+f+n|0,this.h4+r+s|0,this.h0+o+a|0)}roundClean(){(0,T.clean)(S)}destroy(){this.destroyed=!0,(0,T.clean)(this.buffer),this.set(0,0,0,0,0)}}t.RIPEMD160=x,t.ripemd160=(0,T.createHasher)(()=>new x)}),Z=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0,t.RIPEMD160=Y.RIPEMD160,t.ripemd160=Y.ripemd160}),J=V(function(e,t){var r=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=void 0;const n=r(W);t.ripemd160=(0,n.default)(Z.ripemd160)}),Q=V(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_256=t.SHA512_256=t.sha512_224=t.SHA512_224=t.sha384=t.SHA384=t.sha512=t.SHA512=void 0,t.SHA512=M.SHA512,t.sha512=M.sha512,t.SHA384=M.SHA384,t.sha384=M.sha384,t.SHA512_224=M.SHA512_224,t.sha512_224=M.sha512_224,t.SHA512_256=M.SHA512_256,t.sha512_256=M.sha512_256}),ee=V(function(e,t){var r=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha512=void 0;const n=r(W);t.sha512=(0,n.default)(Q.sha512)});class te{constructor(){this.hash=ee.sha512.create()}static half(e){return(new te).add(e).first256()}add(e){return this.hash.update(e),this}addU32(e){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),this.add(t)}finish(){return this.hash.digest()}first256(){return this.finish().slice(0,32)}first256BigInt(){return(0,g.default.bytesToNumberBE)(this.first256())}}var re=/*#__PURE__*/Object.defineProperty({default:te},"__esModule",{value:!0}),ne=V(function(e,t){var r=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.accountPublicFromPublicGenerator=t.derivePrivateKey=void 0;const n=r(re),o=BigInt(0);function s(e,t){const r=p.default.secp256k1.CURVE.n;for(let s=0;s<=4294967295;s++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(s);const a=i.first256BigInt();if(a>o&&a<r)return a}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=p.default.secp256k1.CURVE.n,o=s(e);return r?o:(s(p.default.secp256k1.ProjectivePoint.BASE.multiply(o).toRawBytes(!0),t.accountIndex||0)+o)%n},t.accountPublicFromPublicGenerator=function(e){const t=p.default.secp256k1.ProjectivePoint.fromHex(e),r=s(e,0),n=p.default.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),oe=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),se=V(function(e,t){var r;Object.defineProperty(t,"__esModule",{value:!0}),t.getAlgorithmFromPrivateKey=t.getAlgorithmFromPublicKey=t.getAlgorithmFromKey=void 0,function(e){e[e.NONE=-1]="NONE",e[e.ED25519=237]="ED25519",e[e.SECP256K1_PUB_X=2]="SECP256K1_PUB_X",e[e.SECP256K1_PUB_X_ODD_Y=3]="SECP256K1_PUB_X_ODD_Y",e[e.SECP256K1_PUB_XY=4]="SECP256K1_PUB_XY",e[e.SECP256K1_PRIVATE=0]="SECP256K1_PRIVATE"}(r||(r={}));const n={[`private_${r.NONE}_32`]:"ecdsa-secp256k1",[`private_${r.SECP256K1_PRIVATE}_33`]:"ecdsa-secp256k1",[`private_${r.ED25519}_33`]:"ed25519",[`public_${r.ED25519}_33`]:"ed25519",[`public_${r.SECP256K1_PUB_X}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_X_ODD_Y}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_XY}_65`]:"ecdsa-secp256k1"};function o(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function s(e,t){const{prefix:s,len:i}=function(e){return{prefix:e.length<2?r.NONE:parseInt(e.slice(0,2),16),len:e.length/2}}(e),a="private"===t&&32===i?r.NONE:s,c=n[`${t}_${a}_${i}`];if(!c)throw new Error(function({key:e,type:t,prefix:r,len:s}){const i=function(e){return Object.entries(n).filter(([t])=>t.startsWith(e)).map(([e,t])=>{const[,r,n]=e.split("_");return`${t.padEnd(17)} - Prefix: ${o(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${o(r)} \nLength: ${s} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:a}));return c}t.getAlgorithmFromKey=s,t.getAlgorithmFromPublicKey=function(e){return s(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return s(e,"private")}}),ie=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const ae=ie(oe),ce=ie(re);var ue=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,ne.derivePrivateKey)(e,t);return{privateKey:"00"+(0,C.bytesToHex)((0,g.default.numberToBytesBE)(r,32)),publicKey:(0,C.bytesToHex)(p.default.secp256k1.getPublicKey(r,!0))}},sign(e,t){ae.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return p.default.secp256k1.sign(ce.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=p.default.secp256k1.Signature.fromDER(t);return p.default.secp256k1.verify(n,ce.default.half(e),r)}}},"__esModule",{value:!0}),fe=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const de=fe(oe),he=fe(re);var le=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=he.default.half(e);return{privateKey:"ED"+(0,C.bytesToHex)(t),publicKey:"ED"+(0,C.bytesToHex)(A.default.ed25519.getPublicKey(t))}},sign:(e,t)=>(de.default.ok(e instanceof Uint8Array,"message must be array of octets"),de.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,C.bytesToHex)(A.default.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(de.default.ok(66===r.length,"public key must be 33 bytes including prefix"),A.default.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),ye=V(function(e,t){var r=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeSeed=t.deriveNodeAddress=t.deriveAddress=t.verify=t.sign=t.deriveKeypair=t.generateSeed=void 0,Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return z.decodeSeed}});const n=r(re),o=r(oe),s=r(ue),i=r(le);function a(e){return{"ecdsa-secp256k1":s.default,ed25519:i.default}[e]}function c(e){return(0,z.encodeAccountID)(function(e){return(0,J.ripemd160)((0,q.sha256)(e))}(e))}t.generateSeed=function(e={}){o.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,C.randomBytes)(16);return(0,z.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const o=(0,z.decodeSeed)(e),s=a("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:o.type)?"ed25519":"ecdsa-secp256k1"),i=s.deriveKeypair(o.bytes,t),c=n.default.half("This test message should verify."),u=s.sign(c,i.privateKey);if(!s.verify(c,u,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return a((0,se.getAlgorithmFromPrivateKey)(t)).sign((0,C.hexToBytes)(e),t)},t.verify=function(e,t,r){return a((0,se.getAlgorithmFromPublicKey)(r)).verify((0,C.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return c((0,C.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,z.decodeNodePublic)(e);return c((0,ne.accountPublicFromPublicGenerator)(t))}}),pe="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function be(e,t,r){if(!e.s){if(r instanceof ve){if(!r.s)return void(r.o=be.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(be.bind(null,e,t),be.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var ve=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var s=1&o?t:r;if(s){try{be(n,1,s(this.v))}catch(e){be(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?be(n,1,t?t(o):o):r?be(n,1,r(o)):be(n,2,o)}catch(e){be(n,2,e)}},n},e}();function ge(e){return e instanceof ve&&1&e.s}var Ae=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function me(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Pe=function(e,t){try{var r,n,o=function(e){if(r)return e;throw s},s=new Error("No attempts made"),i=0,a=function(e,t,r){for(var n;;){var o=e();if(_e(o)&&(o=o.v),!o)return s;if(o.then){n=0;break}var s=r();if(s&&s.then){if(!_e(s)){n=1;break}s=s.s}if(t){var i=t();if(i&&i.then&&!_e(i)){n=2;break}}}var a=new xe,c=Se.bind(null,a,2);return(0===n?o.then(f):1===n?s.then(u):i.then(d)).then(void 0,c),a;function u(n){s=n;do{if(t&&(i=t())&&i.then&&!_e(i))return void i.then(d).then(void 0,c);if(!(o=e())||_e(o)&&!o.v)return void Se(a,1,s);if(o.then)return void o.then(f).then(void 0,c);_e(s=r())&&(s=s.v)}while(!s||!s.then);s.then(u).then(void 0,c)}function f(e){e?(s=r())&&s.then?s.then(u).then(void 0,c):u(s):Se(a,1,s)}function d(){(o=e())?o.then?o.then(f).then(void 0,c):f(o):Se(a,1,s)}}(function(){return!(n||r)&&i<=t},function(){return i++},function(){return me(function(){return Promise.resolve(e()).then(function(e){return r=1,e})},function(e){var r,o,a=e instanceof Error?e:new Error(String(e));if(s=a,null!=(r=a.message)&&r.includes("Invalid signature")||null!=(o=a.message)&&o.includes("Account not found"))throw a;if(i!==t){var c=Math.min(1e3*Math.pow(2,i),5e3);return Promise.resolve(new Promise(function(e){return setTimeout(e,c)})).then(function(){})}n=1})});return Promise.resolve(a&&a.then?a.then(o):o(a))}catch(e){return Promise.reject(e)}};function Se(e,t,r){if(!e.s){if(r instanceof xe){if(!r.s)return void(r.o=Se.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Se.bind(null,e,t),Se.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var xe=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var s=1&o?t:r;if(s){try{Se(n,1,s(this.v))}catch(e){Se(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Se(n,1,t?t(o):o):r?Se(n,1,r(o)):Se(n,2,o)}catch(e){Se(n,2,e)}},n},e}();function _e(e){return e instanceof xe&&1&e.s}var He={testnet:{grpcUrl:"https://grpc.testnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.testnet.concordium.com"},mainnet:{grpcUrl:"https://grpc.mainnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.mainnet.concordium.software"}},Ee={network:"testnet",timeout:5e4,retries:3,testMode:!0};function we(e){try{if("string"==typeof e)return e;if(e&&"object"==typeof e){var t=function(e){if("string"==typeof e)return e;if(e&&"object"==typeof e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=e[r];if("string"==typeof n)return n;if("object"==typeof n){var o=t(n);if(o)return o}}return null},r=t(e);if(r)return r}throw new Error("Unable to extract signature from object")}catch(e){var n=e instanceof Error?e.message:"Unknown error";throw new Error("Invalid signature format: "+n)}}exports.verifyProof=function(t,o){try{switch(t.type){case e.ProofTypes.SelfDeclaration:return Promise.resolve(S({},t,{status:t.confirmed?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}));case e.ProofTypes.Screenshot:return Promise.resolve(S({},t,{status:t.url?e.ProofStatus.FLAGGED:e.ProofStatus.FAILED}));case e.ProofTypes.CIP8:return Promise.resolve(function(t){try{var r=t.address.split(/:/),n=r[2],o=t.chainSpecificData&&"cardanoCoseKey"in t.chainSpecificData?t.chainSpecificData.cardanoCoseKey:null;if("cardano"!==r[0]||!o)return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));try{var s=v.default(t.proof,o,t.attestation,n);return Promise.resolve(S({},t,{status:s?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(r){return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.EIP191:return Promise.resolve(function(t){try{var r=t.address.split(/:/),o=r[2];if("eip155"!==r[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));var s=function(e,t,r){try{var o=n.PersonalMessage.getSignPayload(n.Hex.fromString(t)),s=n.Signature.fromHex(r),i=n.Secp256k1.recoverPublicKey({payload:o,signature:s});return n.Address.checksum(n.Address.fromPublicKey(i)).toString()===n.Address.checksum(e)}catch(e){return!1}}(o,t.attestation,t.proof);return Promise.resolve(S({},t,{status:s?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.ED25519:return Promise.resolve(function(t){try{var n=t.address.split(/:/),o=n[2];if("solana"!==n[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));try{var s=r.base58.decode(o),i=(new TextEncoder).encode(t.attestation),a=r.base64.decode(t.proof),c=b.default.sign.detached.verify(i,a,s);return Promise.resolve(S({},t,{status:c?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(r){return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.SOL_SIWX:return Promise.resolve(function(t){try{if("solana"!==t.address.split(/:/)[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));if(!t.chainSpecificData||!function(e){if(!e||"object"!=typeof e)return!1;var t=e;if(!t.account||"object"!=typeof t.account)return!1;var r=t.account;if("string"!=typeof r.address)return!1;if(!r.publicKey)return!1;if(!(r.publicKey instanceof Uint8Array)){var n=r.publicKey;if("object"!=typeof n)return!1;var o=Object.keys(n).filter(function(e){return!isNaN(Number(e))}).sort(function(e,t){return Number(e)-Number(t)});if(32!==o.length)return!1;var s=o.map(function(e){return Number(n[e])});if(!s.every(function(e){return"number"==typeof e&&e>=0&&e<=255}))return!1;r.publicKey=new Uint8Array(s)}if(!t.signedMessage)return!1;if(!(t.signedMessage instanceof Uint8Array)){var i=t.signedMessage;if("Buffer"!==i.type||!Array.isArray(i.data))return!1;t.signedMessage=new Uint8Array(i.data)}if(!t.signature)return!1;if(!(t.signature instanceof Uint8Array)){var a=t.signature;if("Buffer"!==a.type||!Array.isArray(a.data))return!1;t.signature=new Uint8Array(a.data)}if(!t.message||"object"!=typeof t.message)return!1;var c=t.message;if("object"==typeof c&&null!==c){var u=c;if(!u.address&&t.signedMessage instanceof Uint8Array)try{var f=(new TextDecoder).decode(t.signedMessage).split("\n");if(f.length>=2){var d=f[1].trim();d&&/^[a-zA-Z0-9]{32,44}$/.test(d)&&(u.address=d)}}catch(e){}}return!!function(e){return!(!e||"object"!=typeof e)&&"string"==typeof e.domain&&"string"==typeof e.address&&(void 0===e.statement||"string"==typeof e.statement)&&(void 0===e.uri||"string"==typeof e.uri)&&(void 0===e.version||"string"==typeof e.version)&&(void 0===e.chainId||"string"==typeof e.chainId)&&(void 0===e.nonce||"string"==typeof e.nonce)&&(void 0===e.issuedAt||"string"==typeof e.issuedAt)&&(void 0===e.expirationTime||"string"==typeof e.expirationTime)&&(void 0===e.notBefore||"string"==typeof e.notBefore)&&(void 0===e.requestId||"string"==typeof e.requestId)&&(void 0===e.resources||Array.isArray(e.resources))}(t.message)}(t.chainSpecificData))return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));try{var r=t.chainSpecificData,n=(new TextDecoder).decode(r.signedMessage),o=function(e){try{var t=e.split("\n"),r=function(e){var t,r=null==(t=e[0])?void 0:t.match(/^(.+) wants you to sign in with your Solana account:$/);if(!r)return null;var n=r[1],o=e[1];return o&&/^[a-zA-Z0-9]{32,44}$/.test(o)?{domain:n,address:o}:null}(t);if(!r)return null;var n=S({},r),o=2,s=function(e,t){var r=t;if(""===e[r]&&e[r+1]&&!e[r+1].includes(":")){var n=e[++r];return""===e[++r]&&r++,{statement:n,nextIndex:r}}return{nextIndex:r}}(t,o);void 0!==s.statement&&(n.statement=s.statement,o=s.nextIndex);var i=function(e,t){for(var r={},n=[{prefix:"URI: ",key:"uri"},{prefix:"Version: ",key:"version"},{prefix:"Chain ID: ",key:"chainId"},{prefix:"Nonce: ",key:"nonce"},{prefix:"Issued At: ",key:"issuedAt"},{prefix:"Expiration Time: ",key:"expirationTime"},{prefix:"Not Before: ",key:"notBefore"},{prefix:"Request ID: ",key:"requestId"}],o=t;o<e.length;){var s=e[o];if(s){if(s.startsWith("Resources:")){var i=B(e,o+1);if(i.length>0){r.resources=i,o+=i.length+1;continue}}for(var a,c=P(n);!(a=c()).done;){var u=a.value,f=u.prefix,d=u.key;if(s.startsWith(f)){var h=s.substring(f.length);r[d]=h;break}}o++}else o++}return r}(t,o);return Object.assign(n,i),n}catch(e){return null}}(n);if(!o)return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));if(!function(e,t){if(e.domain!==t.domain||e.address!==t.address)return!1;for(var r=[{inputKey:"statement",parsedKey:"statement"},{inputKey:"uri",parsedKey:"uri"},{inputKey:"version",parsedKey:"version"},{inputKey:"chainId",parsedKey:"chainId"},{inputKey:"nonce",parsedKey:"nonce"},{inputKey:"issuedAt",parsedKey:"issuedAt"},{inputKey:"expirationTime",parsedKey:"expirationTime"},{inputKey:"notBefore",parsedKey:"notBefore"},{inputKey:"requestId",parsedKey:"requestId"},{inputKey:"resources",parsedKey:"resources",validator:function(e,t){return!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every(function(e,r){return e===t[r]})}}],n=0,o=r;n<o.length;n++){var s=o[n],i=s.validator,a=t[s.inputKey],c=e[s.parsedKey];if(void 0!==a)if(i){if(!i(a,c))return!1}else if(a!==c)return!1}return function(e){var t=Date.now();if(e.issuedAt){var r=new Date(e.issuedAt);if(Math.abs(r.getTime()-t)>864e5)return!1}return!(e.expirationTime&&new Date(e.expirationTime).getTime()<=t||e.notBefore&&new Date(e.notBefore).getTime()>t)}(e)}(o,r.message))return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));if(function(e){var t=e.domain+" wants you to sign in with your Solana account:\n";t+=""+e.address,e.statement&&(t+="\n\n"+e.statement);var r=function(e){for(var t=[],r=[{key:"uri",prefix:"URI: "},{key:"version",prefix:"Version: "},{key:"chainId",prefix:"Chain ID: "},{key:"nonce",prefix:"Nonce: "},{key:"issuedAt",prefix:"Issued At: "},{key:"expirationTime",prefix:"Expiration Time: "},{key:"notBefore",prefix:"Not Before: "},{key:"requestId",prefix:"Request ID: "},{key:"resources",prefix:"Resources:",formatter:function(e){return Array.isArray(e)&&e.length>0?["Resources:"].concat(e.map(function(e){return"- "+e})):[]}}],n=0,o=r;n<o.length;n++){var s=o[n],i=s.prefix,a=s.formatter,c=e[s.key];if(void 0!==c)if(a){var u=a(c);t.push.apply(t,u)}else"string"==typeof c&&t.push(""+i+c)}return t}(e);return r.length&&(t+="\n\n"+r.join("\n")),t}(o)!==n)return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));var s=b.default.sign.detached.verify(r.signedMessage,r.signature,r.account.publicKey);return Promise.resolve(S({},t,{status:s?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(r){return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.XRP_ED25519:return Promise.resolve(function(t,r){try{var n=function(){if(!r)return S({},t,{status:e.ProofStatus.FAILED});var n=function(e,t,r){return ye.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return S({},t,{status:n?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})},o=t.address.split(/:/),s=o[2];if("xrpl"!==o[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));var i=function(){if(!r)return Promise.resolve(function(e){try{var t;return Promise.resolve(function(e,t,r){if("function"==typeof e[pe]){var n,o,s,i=function(e){try{for(;!((n=a.next()).done||r&&r());)if((e=t(n.value))&&e.then){if(!ge(e))return void e.then(i,s||(s=be.bind(null,o=new ve,2)));e=e.v}o?be(o,1,e):o=e}catch(e){be(o||(o=new ve),2,e)}},a=e[pe]();if(i(),a.return){var c=function(e){try{n.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var u=[],f=0;f<e.length;f++)u.push(e[f]);return function(e,t,r){var n,o,s=-1;return function i(a){try{for(;++s<e.length&&(!r||!r());)if((a=t(s))&&a.then){if(!ge(a))return void a.then(i,o||(o=be.bind(null,n=new ve,2)));a=a.v}n?be(n,1,a):n=a}catch(e){be(n||(n=new ve),2,e)}}(),n}(u,function(e){return t(u[e])},r)}(Ae,function(r){return function(n,o){try{var s=(i=new c.Client(r),Promise.resolve(i.connect()).then(function(){return Promise.resolve(i.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1})).then(function(e){return Promise.resolve(i.disconnect()).then(function(){var r,n=function(e){for(var t=0;t<e.length;t++){var r,n;return null!=(r=null==(n=e[t])||null==(n=n.tx_json)?void 0:n.SigningPubKey)?r:"0x"}throw new Error("No valid pubkey found in the latest transactions")}(null==(r=e.result)?void 0:r.transactions);return t=1,n})})}))}catch(e){return o(e)}var i;return s&&s.then?s.then(void 0,o):s}(0,function(e){var t="Connection to XRPL server failed";e instanceof Error&&(t+=": "+e.message),console.error(t)})},function(){return t}))}catch(e){return Promise.reject(e)}}(s)).then(function(e){r=e})}();return Promise.resolve(i&&i.then?i.then(n):n())}catch(e){return Promise.reject(e)}}(t,o));case e.ProofTypes.XLM_ED25519:return Promise.resolve(function(t){var r=t.address.split(/:/),n=r[2];if("stellar"!==r[0])return S({},t,{status:e.ProofStatus.FAILED});try{var o=d.Keypair.fromPublicKey(n),s=Buffer.from(t.attestation,"utf-8"),i=Buffer.from(t.proof,"base64");return S({},t,{status:o.verify(s,i)?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})}catch(r){return console.error(r),S({},t,{status:e.ProofStatus.FAILED})}}(t));case e.ProofTypes.CONCORDIUM:return Promise.resolve(function(t,r){void 0===r&&(r={});try{var n=S({},Ee,r),o=t.address.split(/:/),s=o[1],i=o[2];if("ccd"!==o[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));var a=n.network;return s&&(a=s.includes("testnet")?"testnet":"mainnet"),Promise.resolve(me(function(){var r;try{r=JSON.parse(t.proof)}catch(r){return S({},t,{status:e.ProofStatus.FAILED})}if(!r||"object"!=typeof r||0===Object.keys(r).length)return S({},t,{status:e.ProofStatus.FAILED});if(n.testMode)try{var o=we(r);return!o||o.length<64||!/^[0-9a-fA-F]+$/.test(o)?S({},t,{status:e.ProofStatus.FAILED}):S({},t,{status:e.ProofStatus.VERIFIED})}catch(r){return S({},t,{status:e.ProofStatus.FAILED})}return Promise.resolve(Pe(function(){return function(e,t,r){try{var n=He[t];return Promise.resolve(me(function(){var t=new AbortController,o=setTimeout(function(){return t.abort()},r);return Promise.resolve(fetch(n.walletProxyUrl+"/v0/accEncryptionKey/"+e,{method:"GET",headers:{Accept:"application/json","User-Agent":"verify-proof/1.6.0"},signal:t.signal})).then(function(e){return clearTimeout(o),e.ok})},function(e){if(e instanceof Error&&"AbortError"===e.name)throw new Error("Account validation timeout after "+r+"ms");throw e}))}catch(e){return Promise.reject(e)}}(i,a,n.timeout)},n.retries)).then(function(o){return o?Promise.resolve(Pe(function(){return function(e,t){try{try{var r=we(e);return Promise.resolve(!(!r||r.length<64)&&r.length>=64&&/^[0-9a-fA-F]+$/.test(r))}catch(e){if(e instanceof Error){var n,o,s;if(null!=(n=e.message)&&n.includes("timeout"))throw new Error("Signature verification timeout after "+t+"ms");if(null!=(o=e.message)&&o.includes("UNAVAILABLE"))throw new Error("Concordium node unavailable");if(null!=(s=e.message)&&s.includes("NOT_FOUND"))return Promise.resolve(!1)}throw e}}catch(e){return Promise.reject(e)}}(r,n.timeout)},n.retries)).then(function(r){return S({},t,r?{status:e.ProofStatus.VERIFIED}:{status:e.ProofStatus.FAILED})}):S({},t,{status:e.ProofStatus.FAILED})})},function(){return S({},t,{status:e.ProofStatus.FAILED})}))}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.EIP712:case e.ProofTypes.BIP137:case e.ProofTypes.BIP322:return Promise.resolve(function(t){try{var r=t.address.split(/:/),n=r[2];if("bip122"!==r[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));var o=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?_.bitcoin:e.startsWith("t1")||e.startsWith("t3")?_.zcash:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?_.litecoin:e.startsWith("D")||e.startsWith("A")?_.dogecoin:e.startsWith("X")||e.startsWith("7")?_.dash:e.startsWith("q")?_.bitcoincash:e.startsWith("tb1")?_.testnet:_.bitcoin}(n);if(!o)return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));if(n.startsWith("t1")||n.startsWith("t3"))return Promise.resolve(E(n,t,o));if(o.isTestnet)return Promise.resolve(H(n,t));try{switch(t.type){case e.ProofTypes.BIP137:return Promise.resolve(E(n,t,o));case e.ProofTypes.BIP322:return Promise.resolve(H(n,t));default:return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}))}}catch(r){return console.error("error verifying proof",r),Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.TIP191:return Promise.resolve(function(t){try{var o=t.address.split(/:/),s=o[2];if("tron"!==o[0])return Promise.resolve(S({},t,{status:e.ProofStatus.FAILED}));var i=function(e,t,o){try{var s=(h=n.Hex.fromString(t),n.Hash.keccak256(function(e){var t=n.Hex.from(e);return n.Hex.concat("0x19",n.Hex.fromString("TRON Signed Message:\n"+n.Hex.size(t)),t)}(h))),i=n.Signature.fromHex(o),a=n.Secp256k1.recoverPublicKey({payload:s,signature:i}),c="0x41"+n.Hash.keccak256("0x"+n.PublicKey.toHex(a).slice(4)).substring(26),u=n.Bytes.from(c),f=n.Bytes.from(n.Hash.sha256(n.Hash.sha256(c))).slice(0,4),d=n.Bytes.concat(u,f);return r.base58.encode(d)===e}catch(e){return!1}var h}(s,t.attestation,t.proof);return Promise.resolve(S({},t,{status:i?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(e){return Promise.reject(e)}}(t))}return Promise.resolve(t)}catch(e){return Promise.reject(e)}};
1
+ var e=require("@notabene/javascript-sdk"),t=require("varuint-bitcoin"),r=require("@scure/base"),n=require("ox"),o=require("@noble/curves/secp256k1"),s=require("bip322-js"),i=require("tweetnacl"),a=require("@cardano-foundation/cardano-verify-datasignature"),c=require("xrpl"),u=require("@noble/curves/abstract/utils"),f=require("@noble/curves/ed25519"),h=require("@stellar/stellar-sdk"),d=require("@cosmjs/amino");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p,y=/*#__PURE__*/l(r),b=/*#__PURE__*/l(o),g=/*#__PURE__*/l(i),v=/*#__PURE__*/l(a),A=/*#__PURE__*/l(u),m=/*#__PURE__*/l(f);function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function S(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return P(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},w.apply(null,arguments)}!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(p||(p={}));var x,E={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},litecoin:{messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc",isTestnet:!1},dogecoin:{messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22,isTestnet:!1},dash:{messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16,isTestnet:!1},zcash:{messagePrefix:"Zcash Signed Message:\n",pubKeyHashVersion:Uint8Array.from([28,184]),scriptHashVersion:Uint8Array.from([28,189]),isTestnet:!1},testnet:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:111,scriptHashVersion:196,bech32Prefix:"tb",isTestnet:!0}};function _(t,r){return w({},r,{status:s.Verifier.verifySignature(t,r.attestation,r.proof)?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})}function H(s,i,a){var c=function(e){if(e.match("^(bc1|tb1|ltc1).*"))return x.NATIVE;if(e.match("^[32M].*"))return x.SEGWIT;if(e.match("^[1nmL].*"))return x.LEGACY;if(e.match("^(D).*"))return x.DOGECOIN;if(e.match("^(q).*"))return x.BCH;if(e.match("^(t1|t3).*"))return x.LEGACY;if(e.match("^[X7].*"))return x.LEGACY;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(s),u=Boolean(a.bech32Prefix&&(c===x.NATIVE||c===x.SEGWIT&&!s.startsWith("1"))),f=function(e,s,i,a,c){var u=function(e){var t=r.base64.decode(e);if(65!==t.length)throw new Error("Invalid signature length");var n=t[0]-27;if(n>15||n<0)throw new Error("Invalid signature parameter");var s=!!(12&n),i=3&n,a=o.secp256k1.Signature.fromCompact(t.slice(1));return{compressed:s,segwitType:8&n?4&n?p.P2WPKH:p.P2SH_P2WPKH:void 0,signature:a.addRecoveryBit(i)}}(i),f=u.compressed,h=u.segwitType,d=u.signature;if(a&&!f)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");var l=function(e,r){var o=(new TextEncoder).encode(r),s=(new TextEncoder).encode(e),i=t.encode(s.length).buffer,a=new Uint8Array(o.length+i.byteLength+s.length);return a.set(o),a.set(new Uint8Array(i),o.length),a.set(s,o.length+i.byteLength),function(e){return n.Hash.sha256(n.Hash.sha256(e))}(a)}(e,c.messagePrefix),y=B(d.recoverPublicKey(l).toRawBytes(f)),b="";if(s.startsWith("q"))return(b=D(c.pubKeyHashVersion,y)).startsWith("1");if(h)b=h===p.P2SH_P2WPKH?D(c.scriptHashVersion,y):c.bech32Prefix?L(y,c.bech32Prefix):D(c.scriptHashVersion,y);else if(s.startsWith("3")&&!h){var g=new Uint8Array(22);g[0]=0,g[1]=20,g.set(y,2);var v=B(g),A=D(c.scriptHashVersion,v),m=D(c.scriptHashVersion,y);if(s===A||s===m)return!0;b=m}else if(a&&c.bech32Prefix)try{b=L(y,c.bech32Prefix)}catch(e){b=D(c.scriptHashVersion,y)}else b=D(c.pubKeyHashVersion,y);return b===s}(i.attestation,s,i.proof,u,a);return w({},i,{status:f?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})}!function(e){e.LEGACY="Legacy",e.NATIVE="Native SegWit",e.SEGWIT="SegWit",e.P2SH_SEGWIT="p2sh",e.BCH="Bitcoin Cash",e.ETHEREUM="Ethereum",e.DOGECOIN="Dogecoin",e.UNKNOWN="Unknown"}(x||(x={}));var I=r.createBase58check(n.Hash.sha256);function D(e,t){var r="number"==typeof e?Uint8Array.of(e):e,n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),I.encode(n)}function L(e,t){void 0===t&&(t="bc");var n=r.bech32.toWords(e);return n.unshift(0),r.bech32.encode(t,n)}function B(e){return n.Hash.ripemd160(n.Hash.sha256(e))}function U(e,t){for(var r=[],n=t;n<e.length&&null!=(o=e[n])&&o.startsWith("- ");){var o;r.push(e[n].substring(2)),n++}return r}var V="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function C(e){var t={exports:{}};return e(t,t.exports),t.exports}var k=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0}),T=C(function(e,t){function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function o(e,...t){if(!r(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function s(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function i(e){for(let t=0;t<e.length;t++)e[t]=s(e[t]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=r,t.anumber=n,t.abytes=o,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");n(e.outputLen),n(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){o(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=s,t.byteSwap32=i,t.bytesToHex=function(e){if(o(e),a)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=c[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(a)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=f(e.charCodeAt(o)),s=f(e.charCodeAt(o+1));if(void 0===r||void 0===s)throw new Error('hex string expected, got non-hex character "'+(e[o]+e[o+1])+'" at index '+o);n[t]=16*r+s}return n},t.asyncLoop=async function(e,r,n){let o=Date.now();for(let s=0;s<e;s++){n(s);const e=Date.now()-o;e>=0&&e<r||(await(0,t.nextTick)(),o+=e)}},t.utf8ToBytes=h,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=d,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=h(e)),o(e),e},t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];o(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=l,t.createOptHasher=p,t.createXOFer=y,t.randomBytes=function(e=32){if(k.crypto&&"function"==typeof k.crypto.getRandomValues)return k.crypto.getRandomValues(new Uint8Array(e));if(k.crypto&&"function"==typeof k.crypto.randomBytes)return Uint8Array.from(k.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>s(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:i;const a=/* @__PURE__ */(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),c=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),u={_0:48,_9:57,A:65,F:70,a:97,f:102};function f(e){return e>=u._0&&e<=u._9?e-u._0:e>=u.A&&e<=u.F?e-(u.A-10):e>=u.a&&e<=u.f?e-(u.a-10):void 0}function h(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function d(e){return"string"==typeof e&&(e=h(e)),o(e),e}function l(e){const t=t=>e().update(d(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function p(e){const t=(t,r)=>e(r).update(d(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}function y(e){const t=(t,r)=>e(r).update(d(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=l,t.wrapConstructorWithOpts=p,t.wrapXOFConstructorWithOpts=y}),F=T,j=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equal=t.concat=t.HEX_REGEX=void 0,t.HEX_REGEX=/^[A-F0-9]*$/iu,t.concat=function(e){return(0,F.concatBytes)(...e)},t.equal=function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Int8Array(e),n=new Int8Array(t);for(let t=0;t!==e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}}),O=C(function(e,t){var r=V&&V.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=V&&V.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.stringToHex=t.hexToString=t.hexToBytes=t.bytesToHex=void 0,t.bytesToHex=e=>(0,F.bytesToHex)(e instanceof Uint8Array?e:Uint8Array.from(e)).toUpperCase(),t.hexToBytes=e=>{const t=new Uint8Array(e.length/2);if(!j.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,o=e.slice(n,n+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}return t},t.hexToString=(e,r="utf8")=>new TextDecoder(r).decode((0,t.hexToBytes)(e)),t.stringToHex=e=>(0,t.bytesToHex)((new TextEncoder).encode(e)),t.randomBytes=F.randomBytes,n(j,t)}),M=C(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),c=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+c,a,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=r,t.Chi=function(e,t,r){return e&t^~e&r},t.Maj=function(e,t,r){return e&t^e&r^t&r},t.HashMD=class extends F.Hash{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,F.createView)(this.buffer)}update(e){(0,F.aexists)(this),e=(0,F.toBytes)(e),(0,F.abytes)(e);const{view:t,buffer:r,blockLen:n}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);if(i===n){const t=(0,F.createView)(e);for(;n<=o-s;s+=n)this.process(t,s);continue}r.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,F.aexists)(this),(0,F.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:s}=this;let{pos:i}=this;t[i++]=128,(0,F.clean)(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let e=i;e<o;e++)t[e]=0;r(n,o-8,BigInt(8*this.length),s),this.process(n,0);const a=(0,F.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)a.setUint32(4*e,f[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}},t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),K=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=A,t.fromBig=o,t.split=s;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function o(e,t=!1){return t?{h:Number(e&r),l:Number(e>>n&r)}:{h:0|Number(e>>n&r),l:0|Number(e&r)}}function s(e,t=!1){const r=e.length;let n=new Uint32Array(r),s=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:a}=o(e[i],t);[n[i],s[i]]=[r,a]}return[n,s]}const i=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>0);t.toBig=i;const a=(e,t,r)=>e>>>r;t.shrSH=a;const c=(e,t,r)=>e<<32-r|t>>>r;t.shrSL=c;const u=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=u;const f=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=f;const h=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=h;const d=(e,t,r)=>e>>>r-32|t<<64-r;t.rotrBL=d;const l=(e,t)=>t;t.rotr32H=l;const p=(e,t)=>e;t.rotr32L=p;const y=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=y;const b=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=b;const g=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=g;const v=(e,t,r)=>e<<r-32|t>>>64-r;function A(e,t,r,n){const o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:0|o}}t.rotlBL=v;const m=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=m;const P=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=P;const S=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=S;const w=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;t.add4H=w;const x=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);t.add5L=x;const E=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;t.add5H=E,t.default={fromBig:o,split:s,toBig:i,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:d,rotr32H:l,rotr32L:p,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:v,add:A,add3L:m,add3H:P,add4L:S,add4H:w,add5H:E,add5L:x}}),N=M,R=K,W=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=/* @__PURE__ */Uint32Array.from([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]),n=/* @__PURE__ */new Uint32Array(64);class o extends N.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|N.SHA256_IV[0],this.B=0|N.SHA256_IV[1],this.C=0|N.SHA256_IV[2],this.D=0|N.SHA256_IV[3],this.E=0|N.SHA256_IV[4],this.F=0|N.SHA256_IV[5],this.G=0|N.SHA256_IV[6],this.H=0|N.SHA256_IV[7]}get(){const{A:e,B:t,C:r,D:n,E:o,F:s,G:i,H:a}=this;return[e,t,r,n,o,s,i,a]}set(e,t,r,n,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=n[e-15],r=n[e-2],o=(0,F.rotr)(t,7)^(0,F.rotr)(t,18)^t>>>3,s=(0,F.rotr)(r,17)^(0,F.rotr)(r,19)^r>>>10;n[e]=s+n[e-7]+o+n[e-16]|0}let{A:o,B:s,C:i,D:a,E:c,F:u,G:f,H:h}=this;for(let e=0;e<64;e++){const t=h+((0,F.rotr)(c,6)^(0,F.rotr)(c,11)^(0,F.rotr)(c,25))+(0,N.Chi)(c,u,f)+r[e]+n[e]|0,d=((0,F.rotr)(o,2)^(0,F.rotr)(o,13)^(0,F.rotr)(o,22))+(0,N.Maj)(o,s,i)|0;h=f,f=u,u=c,c=a+t|0,a=i,i=s,s=o,o=t+d|0}o=o+this.A|0,s=s+this.B|0,i=i+this.C|0,a=a+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(o,s,i,a,c,u,f,h)}roundClean(){(0,F.clean)(n)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,F.clean)(this.buffer)}}t.SHA256=o;class s extends o{constructor(){super(28),this.A=0|N.SHA224_IV[0],this.B=0|N.SHA224_IV[1],this.C=0|N.SHA224_IV[2],this.D=0|N.SHA224_IV[3],this.E=0|N.SHA224_IV[4],this.F=0|N.SHA224_IV[5],this.G=0|N.SHA224_IV[6],this.H=0|N.SHA224_IV[7]}}t.SHA224=s;const i=/* @__PURE__ */(()=>R.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(e=>BigInt(e))))(),a=/* @__PURE__ */(()=>i[0])(),c=/* @__PURE__ */(()=>i[1])(),u=/* @__PURE__ */new Uint32Array(80),f=/* @__PURE__ */new Uint32Array(80);class h extends N.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|N.SHA512_IV[0],this.Al=0|N.SHA512_IV[1],this.Bh=0|N.SHA512_IV[2],this.Bl=0|N.SHA512_IV[3],this.Ch=0|N.SHA512_IV[4],this.Cl=0|N.SHA512_IV[5],this.Dh=0|N.SHA512_IV[6],this.Dl=0|N.SHA512_IV[7],this.Eh=0|N.SHA512_IV[8],this.El=0|N.SHA512_IV[9],this.Fh=0|N.SHA512_IV[10],this.Fl=0|N.SHA512_IV[11],this.Gh=0|N.SHA512_IV[12],this.Gl=0|N.SHA512_IV[13],this.Hh=0|N.SHA512_IV[14],this.Hl=0|N.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:o,Cl:s,Dh:i,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:d,Gl:l,Hh:p,Hl:y}=this;return[e,t,r,n,o,s,i,a,c,u,f,h,d,l,p,y]}set(e,t,r,n,o,s,i,a,c,u,f,h,d,l,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|d,this.Gl=0|l,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let r=0;r<16;r++,t+=4)u[r]=e.getUint32(t),f[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|u[e-15],r=0|f[e-15],n=R.rotrSH(t,r,1)^R.rotrSH(t,r,8)^R.shrSH(t,r,7),o=R.rotrSL(t,r,1)^R.rotrSL(t,r,8)^R.shrSL(t,r,7),s=0|u[e-2],i=0|f[e-2],a=R.rotrSH(s,i,19)^R.rotrBH(s,i,61)^R.shrSH(s,i,6),c=R.rotrSL(s,i,19)^R.rotrBL(s,i,61)^R.shrSL(s,i,6),h=R.add4L(o,c,f[e-7],f[e-16]),d=R.add4H(h,n,a,u[e-7],u[e-16]);u[e]=0|d,f[e]=0|h}let{Ah:r,Al:n,Bh:o,Bl:s,Ch:i,Cl:h,Dh:d,Dl:l,Eh:p,El:y,Fh:b,Fl:g,Gh:v,Gl:A,Hh:m,Hl:P}=this;for(let e=0;e<80;e++){const t=R.rotrSH(p,y,14)^R.rotrSH(p,y,18)^R.rotrBH(p,y,41),S=R.rotrSL(p,y,14)^R.rotrSL(p,y,18)^R.rotrBL(p,y,41),w=p&b^~p&v,x=R.add5L(P,S,y&g^~y&A,c[e],f[e]),E=R.add5H(x,m,t,w,a[e],u[e]),_=0|x,H=R.rotrSH(r,n,28)^R.rotrBH(r,n,34)^R.rotrBH(r,n,39),I=R.rotrSL(r,n,28)^R.rotrBL(r,n,34)^R.rotrBL(r,n,39),D=r&o^r&i^o&i,L=n&s^n&h^s&h;m=0|v,P=0|A,v=0|b,A=0|g,b=0|p,g=0|y,({h:p,l:y}=R.add(0|d,0|l,0|E,0|_)),d=0|i,l=0|h,i=0|o,h=0|s,o=0|r,s=0|n;const B=R.add3L(_,I,L);r=R.add3H(B,E,H,D),n=0|B}({h:r,l:n}=R.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:s}=R.add(0|this.Bh,0|this.Bl,0|o,0|s)),({h:i,l:h}=R.add(0|this.Ch,0|this.Cl,0|i,0|h)),({h:d,l:l}=R.add(0|this.Dh,0|this.Dl,0|d,0|l)),({h:p,l:y}=R.add(0|this.Eh,0|this.El,0|p,0|y)),({h:b,l:g}=R.add(0|this.Fh,0|this.Fl,0|b,0|g)),({h:v,l:A}=R.add(0|this.Gh,0|this.Gl,0|v,0|A)),({h:m,l:P}=R.add(0|this.Hh,0|this.Hl,0|m,0|P)),this.set(r,n,o,s,i,h,d,l,p,y,b,g,v,A,m,P)}roundClean(){(0,F.clean)(u,f)}destroy(){(0,F.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=h;class d extends h{constructor(){super(48),this.Ah=0|N.SHA384_IV[0],this.Al=0|N.SHA384_IV[1],this.Bh=0|N.SHA384_IV[2],this.Bl=0|N.SHA384_IV[3],this.Ch=0|N.SHA384_IV[4],this.Cl=0|N.SHA384_IV[5],this.Dh=0|N.SHA384_IV[6],this.Dl=0|N.SHA384_IV[7],this.Eh=0|N.SHA384_IV[8],this.El=0|N.SHA384_IV[9],this.Fh=0|N.SHA384_IV[10],this.Fl=0|N.SHA384_IV[11],this.Gh=0|N.SHA384_IV[12],this.Gl=0|N.SHA384_IV[13],this.Hh=0|N.SHA384_IV[14],this.Hl=0|N.SHA384_IV[15]}}t.SHA384=d;const l=/* @__PURE__ */Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),p=/* @__PURE__ */Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class y extends h{constructor(){super(28),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}}t.SHA512_224=y;class b extends h{constructor(){super(32),this.Ah=0|p[0],this.Al=0|p[1],this.Bh=0|p[2],this.Bl=0|p[3],this.Ch=0|p[4],this.Cl=0|p[5],this.Dh=0|p[6],this.Dl=0|p[7],this.Eh=0|p[8],this.El=0|p[9],this.Fh=0|p[10],this.Fl=0|p[11],this.Gh=0|p[12],this.Gl=0|p[13],this.Hh=0|p[14],this.Hl=0|p[15]}}t.SHA512_256=b,t.sha256=(0,F.createHasher)(()=>new o),t.sha224=(0,F.createHasher)(()=>new s),t.sha512=(0,F.createHasher)(()=>new h),t.sha384=(0,F.createHasher)(()=>new d),t.sha512_256=(0,F.createHasher)(()=>new b),t.sha512_224=(0,F.createHasher)(()=>new y)}),G=W,q=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.SHA224=t.sha256=t.SHA256=void 0,t.SHA256=G.SHA256,t.sha256=G.sha256,t.SHA224=G.SHA224,t.sha224=G.sha224});const X=(V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:function(e){return Array.isArray(e)?new Uint8Array(e):e}},"__esModule",{value:!0}));var $=/*#__PURE__*/Object.defineProperty({default:function(e){function t(t){return e((0,X.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,X.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),z=q,Y=C(function(e,t){var r=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha256=void 0;const n=r($);t.sha256=(0,n.default)(z.sha256)}),Z=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.concatArgs=t.arrayEqual=void 0,t.arrayEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])},t.concatArgs=function(...e){return e.flatMap(e=>"number"==typeof e?[e]:Array.from(e))}}),J=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.encodeNodePublic=t.decodeNodePublic=t.decodeAddress=t.decodeAccountID=t.encodeAddress=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0;const r=[1,225,75],n={sha256:Y.sha256},o=new class{constructor(e){this._sha256=e.sha256,this._codec=y.default.base58xrp}encode(e,t){return this._encodeVersioned(e,t.versions,t.expectedLength)}decode(e,t){var r;const n=t.versions,o=t.versionTypes,s=this.decodeChecked(e);if(n.length>1&&!t.expectedLength)throw new Error("expectedLength is required because there are >= 2 possible versions");const i=null!==(r=t.expectedLength)&&void 0!==r?r:s.length-("number"==typeof n[0]?1:n[0].length),a=s.slice(0,-i),c=s.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,Z.arrayEqual)(a,t))return{version:t,bytes:c,type:o?o[e]:null}}throw new Error("version_invalid: version bytes do not match any of the provided version(s)")}encodeChecked(e){const t=this._sha256(this._sha256(e)).slice(0,4);return this._encodeRaw(Uint8Array.from((0,Z.concatArgs)(e,t)))}decodeChecked(e){const t=this._decodeRaw(e);if(t.byteLength<5)throw new Error("invalid_input_size: decoded data must have length >= 5");if(!this._verifyCheckSum(t))throw new Error("checksum_invalid");return t.slice(0,-4)}_encodeVersioned(e,t,r){if(!a(e,r))throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Uint8Array.");return this.encodeChecked((0,Z.concatArgs)(t,e))}_encodeRaw(e){return this._codec.encode(Uint8Array.from(e))}_decodeRaw(e){return this._codec.decode(e)}_verifyCheckSum(e){const t=this._sha256(this._sha256(e.slice(0,-4))).slice(0,4),r=e.slice(-4);return(0,Z.arrayEqual)(t,r)}}(n);function s(e){return o.encode(e,{versions:[0],expectedLength:20})}function i(e){return o.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=o,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return o.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return o.decode(e,t)},t.encodeAccountID=s,t.encodeAddress=s,t.decodeAccountID=i,t.decodeAddress=i,t.decodeNodePublic=function(e){return o.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return o.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return o.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return o.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{i(e)}catch(e){return!1}return!0}}),Q=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidXAddress=t.decodeXAddress=t.xAddressToClassicAddress=t.encodeXAddress=t.classicAddressToXAddress=t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.decodeNodePublic=t.encodeNodePublic=t.decodeAccountID=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0,Object.defineProperty(t,"codec",{enumerable:!0,get:function(){return J.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return J.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return J.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return J.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return J.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return J.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return J.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return J.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return J.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return J.isValidClassicAddress}});const r={main:Uint8Array.from([5,68]),test:Uint8Array.from([4,147])};function n(e,t,n){if(20!==e.length)throw new Error("Account ID must be 20 bytes");if(!1!==t&&t>4294967295)throw new Error("Invalid tag");const o=t||0,s=(0,O.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0])]);return J.codec.encodeChecked(s)}function o(e){const t=J.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,O.equal)(r.main,t))return!1;if((0,O.equal)(r.test,t))return!0;throw new Error("Invalid X-address: bad prefix")}(t);return{accountId:t.slice(2,22),tag:function(e){const t=e[22];if(t>=2)throw new Error("Unsupported X-address");if(1===t)return e[23]+256*e[24]+65536*e[25]+16777216*e[26];if(0!==t)throw new Error("flag must be zero to indicate no tag");if(!(0,O.equal)((0,O.hexToBytes)("0000000000000000"),e.slice(23,31)))throw new Error("remaining bytes must be zero");return!1}(t),test:n}}t.classicAddressToXAddress=function(e,t,r){return n((0,J.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=o(e);return{classicAddress:(0,J.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=o,t.isValidXAddress=function(e){try{o(e)}catch(e){return!1}return!0}}),ee=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=t.md5=t.MD5=t.sha1=t.SHA1=void 0;const r=/* @__PURE__ */Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),n=/* @__PURE__ */new Uint32Array(80);class o extends N.HashMD{constructor(){super(64,20,8,!1),this.A=0|r[0],this.B=0|r[1],this.C=0|r[2],this.D=0|r[3],this.E=0|r[4]}get(){const{A:e,B:t,C:r,D:n,E:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)n[e]=(0,F.rotl)(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let{A:r,B:o,C:s,D:i,E:a}=this;for(let e=0;e<80;e++){let t,c;e<20?(t=(0,N.Chi)(o,s,i),c=1518500249):e<40?(t=o^s^i,c=1859775393):e<60?(t=(0,N.Maj)(o,s,i),c=2400959708):(t=o^s^i,c=3395469782);const u=(0,F.rotl)(r,5)+t+a+c+n[e]|0;a=i,i=s,s=(0,F.rotl)(o,30),o=r,r=u}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,this.set(r,o,s,i,a)}roundClean(){(0,F.clean)(n)}destroy(){this.set(0,0,0,0,0),(0,F.clean)(this.buffer)}}t.SHA1=o,t.sha1=(0,F.createHasher)(()=>new o);const s=/* @__PURE__ */Math.pow(2,32),i=/* @__PURE__ */Array.from({length:64},(e,t)=>Math.floor(s*Math.abs(Math.sin(t+1)))),a=/* @__PURE__ */r.slice(0,4),c=/* @__PURE__ */new Uint32Array(16);class u extends N.HashMD{constructor(){super(64,16,8,!0),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3]}get(){const{A:e,B:t,C:r,D:n}=this;return[e,t,r,n]}set(e,t,r,n){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n}process(e,t){for(let r=0;r<16;r++,t+=4)c[r]=e.getUint32(t,!0);let{A:r,B:n,C:o,D:s}=this;for(let e=0;e<64;e++){let t,a,u;e<16?(t=(0,N.Chi)(n,o,s),a=e,u=[7,12,17,22]):e<32?(t=(0,N.Chi)(s,n,o),a=(5*e+1)%16,u=[5,9,14,20]):e<48?(t=n^o^s,a=(3*e+5)%16,u=[4,11,16,23]):(t=o^(n|~s),a=7*e%16,u=[6,10,15,21]),t=t+r+i[e]+c[a],r=s,s=o,o=n,n+=(0,F.rotl)(t,u[e%4])}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,s=s+this.D|0,this.set(r,n,o,s)}roundClean(){(0,F.clean)(c)}destroy(){this.set(0,0,0,0),(0,F.clean)(this.buffer)}}t.MD5=u,t.md5=(0,F.createHasher)(()=>new u);const f=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),h=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),d=/* @__PURE__ */(()=>h.map(e=>(9*e+5)%16))(),l=/* @__PURE__ */(()=>{const e=[[h],[d]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>f[e]));return e})(),p=/* @__PURE__ */(()=>l[0])(),y=/* @__PURE__ */(()=>l[1])(),b=/* @__PURE__ */[[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(e=>Uint8Array.from(e)),g=/* @__PURE__ */p.map((e,t)=>e.map(e=>b[t][e])),v=/* @__PURE__ */y.map((e,t)=>e.map(e=>b[t][e])),A=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),m=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function P(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const S=/* @__PURE__ */new Uint32Array(16);class w extends N.HashMD{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:t,h2:r,h3:n,h4:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)S[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,i=0|this.h2,a=i,c=0|this.h3,u=c,f=0|this.h4,h=f;for(let e=0;e<5;e++){const t=4-e,d=A[e],l=m[e],b=p[e],w=y[e],x=g[e],E=v[e];for(let t=0;t<16;t++){const n=(0,F.rotl)(r+P(e,o,i,c)+S[b[t]]+d,x[t])+f|0;r=f,f=c,c=0|(0,F.rotl)(i,10),i=o,o=n}for(let e=0;e<16;e++){const r=(0,F.rotl)(n+P(t,s,a,u)+S[w[e]]+l,E[e])+h|0;n=h,h=u,u=0|(0,F.rotl)(a,10),a=s,s=r}}this.set(this.h1+i+u|0,this.h2+c+h|0,this.h3+f+n|0,this.h4+r+s|0,this.h0+o+a|0)}roundClean(){(0,F.clean)(S)}destroy(){this.destroyed=!0,(0,F.clean)(this.buffer),this.set(0,0,0,0,0)}}t.RIPEMD160=w,t.ripemd160=(0,F.createHasher)(()=>new w)}),te=ee,re=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0,t.RIPEMD160=te.RIPEMD160,t.ripemd160=te.ripemd160}),ne=C(function(e,t){var r=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=void 0;const n=r($);t.ripemd160=(0,n.default)(re.ripemd160)}),oe=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_256=t.SHA512_256=t.sha512_224=t.SHA512_224=t.sha384=t.SHA384=t.sha512=t.SHA512=void 0,t.SHA512=G.SHA512,t.sha512=G.sha512,t.SHA384=G.SHA384,t.sha384=G.sha384,t.SHA512_224=G.SHA512_224,t.sha512_224=G.sha512_224,t.SHA512_256=G.SHA512_256,t.sha512_256=G.sha512_256}),se=C(function(e,t){var r=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha512=void 0;const n=r($);t.sha512=(0,n.default)(oe.sha512)});class ie{constructor(){this.hash=se.sha512.create()}static half(e){return(new ie).add(e).first256()}add(e){return this.hash.update(e),this}addU32(e){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),this.add(t)}finish(){return this.hash.digest()}first256(){return this.finish().slice(0,32)}first256BigInt(){return(0,A.default.bytesToNumberBE)(this.first256())}}var ae=/*#__PURE__*/Object.defineProperty({default:ie},"__esModule",{value:!0}),ce=C(function(e,t){var r=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.accountPublicFromPublicGenerator=t.derivePrivateKey=void 0;const n=r(ae),o=BigInt(0);function s(e,t){const r=b.default.secp256k1.CURVE.n;for(let s=0;s<=4294967295;s++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(s);const a=i.first256BigInt();if(a>o&&a<r)return a}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=b.default.secp256k1.CURVE.n,o=s(e);return r?o:(s(b.default.secp256k1.ProjectivePoint.BASE.multiply(o).toRawBytes(!0),t.accountIndex||0)+o)%n},t.accountPublicFromPublicGenerator=function(e){const t=b.default.secp256k1.ProjectivePoint.fromHex(e),r=s(e,0),n=b.default.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),ue=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),fe=C(function(e,t){var r;Object.defineProperty(t,"__esModule",{value:!0}),t.getAlgorithmFromPrivateKey=t.getAlgorithmFromPublicKey=t.getAlgorithmFromKey=void 0,function(e){e[e.NONE=-1]="NONE",e[e.ED25519=237]="ED25519",e[e.SECP256K1_PUB_X=2]="SECP256K1_PUB_X",e[e.SECP256K1_PUB_X_ODD_Y=3]="SECP256K1_PUB_X_ODD_Y",e[e.SECP256K1_PUB_XY=4]="SECP256K1_PUB_XY",e[e.SECP256K1_PRIVATE=0]="SECP256K1_PRIVATE"}(r||(r={}));const n={[`private_${r.NONE}_32`]:"ecdsa-secp256k1",[`private_${r.SECP256K1_PRIVATE}_33`]:"ecdsa-secp256k1",[`private_${r.ED25519}_33`]:"ed25519",[`public_${r.ED25519}_33`]:"ed25519",[`public_${r.SECP256K1_PUB_X}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_X_ODD_Y}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_XY}_65`]:"ecdsa-secp256k1"};function o(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function s(e,t){const{prefix:s,len:i}=function(e){return{prefix:e.length<2?r.NONE:parseInt(e.slice(0,2),16),len:e.length/2}}(e),a="private"===t&&32===i?r.NONE:s,c=n[`${t}_${a}_${i}`];if(!c)throw new Error(function({key:e,type:t,prefix:r,len:s}){const i=function(e){return Object.entries(n).filter(([t])=>t.startsWith(e)).map(([e,t])=>{const[,r,n]=e.split("_");return`${t.padEnd(17)} - Prefix: ${o(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${o(r)} \nLength: ${s} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:a}));return c}t.getAlgorithmFromKey=s,t.getAlgorithmFromPublicKey=function(e){return s(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return s(e,"private")}}),he=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const de=he(ue),le=he(ae);var pe=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,ce.derivePrivateKey)(e,t);return{privateKey:"00"+(0,O.bytesToHex)((0,A.default.numberToBytesBE)(r,32)),publicKey:(0,O.bytesToHex)(b.default.secp256k1.getPublicKey(r,!0))}},sign(e,t){de.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return b.default.secp256k1.sign(le.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=b.default.secp256k1.Signature.fromDER(t);return b.default.secp256k1.verify(n,le.default.half(e),r)}}},"__esModule",{value:!0}),ye=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const be=ye(ue),ge=ye(ae);var ve=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=ge.default.half(e);return{privateKey:"ED"+(0,O.bytesToHex)(t),publicKey:"ED"+(0,O.bytesToHex)(m.default.ed25519.getPublicKey(t))}},sign:(e,t)=>(be.default.ok(e instanceof Uint8Array,"message must be array of octets"),be.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,O.bytesToHex)(m.default.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(be.default.ok(66===r.length,"public key must be 33 bytes including prefix"),m.default.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),Ae=C(function(e,t){var r=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeSeed=t.deriveNodeAddress=t.deriveAddress=t.verify=t.sign=t.deriveKeypair=t.generateSeed=void 0,Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return Q.decodeSeed}});const n=r(ae),o=r(ue),s=r(pe),i=r(ve);function a(e){return{"ecdsa-secp256k1":s.default,ed25519:i.default}[e]}function c(e){return(0,Q.encodeAccountID)(function(e){return(0,ne.ripemd160)((0,Y.sha256)(e))}(e))}t.generateSeed=function(e={}){o.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,O.randomBytes)(16);return(0,Q.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const o=(0,Q.decodeSeed)(e),s=a("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:o.type)?"ed25519":"ecdsa-secp256k1"),i=s.deriveKeypair(o.bytes,t),c=n.default.half("This test message should verify."),u=s.sign(c,i.privateKey);if(!s.verify(c,u,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return a((0,fe.getAlgorithmFromPrivateKey)(t)).sign((0,O.hexToBytes)(e),t)},t.verify=function(e,t,r){return a((0,fe.getAlgorithmFromPublicKey)(r)).verify((0,O.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return c((0,O.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,Q.decodeNodePublic)(e);return c((0,ce.accountPublicFromPublicGenerator)(t))}}),me="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Pe(e,t,r){if(!e.s){if(r instanceof Se){if(!r.s)return void(r.o=Pe.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Pe.bind(null,e,t),Pe.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var Se=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var s=1&o?t:r;if(s){try{Pe(n,1,s(this.v))}catch(e){Pe(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pe(n,1,t?t(o):o):r?Pe(n,1,r(o)):Pe(n,2,o)}catch(e){Pe(n,2,e)}},n},e}();function we(e){return e instanceof Se&&1&e.s}var xe=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function Ee(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var _e=function(e,t){try{var r,n,o=function(e){if(r)return e;throw s},s=new Error("No attempts made"),i=0,a=function(e,t,r){for(var n;;){var o=e();if(De(o)&&(o=o.v),!o)return s;if(o.then){n=0;break}var s=r();if(s&&s.then){if(!De(s)){n=1;break}s=s.s}if(t){var i=t();if(i&&i.then&&!De(i)){n=2;break}}}var a=new Ie,c=He.bind(null,a,2);return(0===n?o.then(f):1===n?s.then(u):i.then(h)).then(void 0,c),a;function u(n){s=n;do{if(t&&(i=t())&&i.then&&!De(i))return void i.then(h).then(void 0,c);if(!(o=e())||De(o)&&!o.v)return void He(a,1,s);if(o.then)return void o.then(f).then(void 0,c);De(s=r())&&(s=s.v)}while(!s||!s.then);s.then(u).then(void 0,c)}function f(e){e?(s=r())&&s.then?s.then(u).then(void 0,c):u(s):He(a,1,s)}function h(){(o=e())?o.then?o.then(f).then(void 0,c):f(o):He(a,1,s)}}(function(){return!(n||r)&&i<=t},function(){return i++},function(){return Ee(function(){return Promise.resolve(e()).then(function(e){return r=1,e})},function(e){var r,o,a=e instanceof Error?e:new Error(String(e));if(s=a,null!=(r=a.message)&&r.includes("Invalid signature")||null!=(o=a.message)&&o.includes("Account not found"))throw a;if(i!==t){var c=Math.min(1e3*Math.pow(2,i),5e3);return Promise.resolve(new Promise(function(e){return setTimeout(e,c)})).then(function(){})}n=1})});return Promise.resolve(a&&a.then?a.then(o):o(a))}catch(e){return Promise.reject(e)}};function He(e,t,r){if(!e.s){if(r instanceof Ie){if(!r.s)return void(r.o=He.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(He.bind(null,e,t),He.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var Ie=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var s=1&o?t:r;if(s){try{He(n,1,s(this.v))}catch(e){He(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?He(n,1,t?t(o):o):r?He(n,1,r(o)):He(n,2,o)}catch(e){He(n,2,e)}},n},e}();function De(e){return e instanceof Ie&&1&e.s}var Le={testnet:{grpcUrl:"https://grpc.testnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.testnet.concordium.com"},mainnet:{grpcUrl:"https://grpc.mainnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.mainnet.concordium.software"}},Be={network:"testnet",timeout:5e4,retries:3,testMode:!0};function Ue(e){try{if("string"==typeof e)return e;if(e&&"object"==typeof e){var t=function(e){if("string"==typeof e)return e;if(e&&"object"==typeof e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=e[r];if("string"==typeof n)return n;if("object"==typeof n){var o=t(n);if(o)return o}}return null},r=t(e);if(r)return r}throw new Error("Unable to extract signature from object")}catch(e){var n=e instanceof Error?e.message:"Unknown error";throw new Error("Invalid signature format: "+n)}}var Ve=C(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let e=0;e<32;e++){const t=r.charAt(e);n[t]=e}function o(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function s(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=o(t)^n>>5}t=o(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=o(t)^31&n}return t}function i(e,t,r,n){let o=0,s=0;const i=(1<<r)-1,a=[];for(let n=0;n<e.length;++n)for(o=o<<t|e[n],s+=t;s>=r;)s-=r,a.push(o>>s&i);if(n)s>0&&a.push(o<<r-s&i);else{if(s>=t)return"Excess padding";if(o<<r-s&i)return"Non-zero padding"}return a}function a(e){return i(e,8,5,!0)}function c(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t}function u(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function f(e){let t;function i(e,r){if(e.length<8)return e+" too short";if(e.length>(r=r||90))return"Exceeds length limit";const i=e.toLowerCase(),a=e.toUpperCase();if(e!==i&&e!==a)return"Mixed-case string "+e;const c=(e=i).lastIndexOf("1");if(-1===c)return"No separator character for "+e;if(0===c)return"Missing prefix for "+e;const u=e.slice(0,c),f=e.slice(c+1);if(f.length<6)return"Data too short";let h=s(u);if("string"==typeof h)return h;const d=[];for(let e=0;e<f.length;++e){const t=f.charAt(e),r=n[t];if(void 0===r)return"Unknown character "+t;h=o(h)^r,e+6>=f.length||d.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:u,words:d}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=i(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=i(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,n,i){if(e.length+7+n.length>(i=i||90))throw new TypeError("Exceeds length limit");let a=s(e=e.toLowerCase());if("string"==typeof a)throw new Error(a);let c=e+"1";for(let e=0;e<n.length;++e){const t=n[e];if(t>>5)throw new Error("Non 5-bit word");a=o(a)^t,c+=r.charAt(t)}for(let e=0;e<6;++e)a=o(a);a^=t;for(let e=0;e<6;++e)c+=r.charAt(a>>5*(5-e)&31);return c},toWords:a,fromWordsUnsafe:c,fromWords:u}}t.bech32=f("bech32"),t.bech32m=f("bech32m")});function Ce(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ke(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Te(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Fe(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function je(e,t){return e<<32-t|e>>>t}function Oe(e,t){return e<<t|e>>>32-t>>>0}function Me(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Ce(e),e}class Ke{}function Ne(e){const t=t=>e().update(Me(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Re(e,t,r){return e&t^~e&r}function We(e,t,r){return e&t^e&r^t&r}class Ge extends Ke{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Fe(this.buffer)}update(e){ke(this),Ce(e=Me(e));const{view:t,buffer:r,blockLen:n}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);if(i===n){const t=Fe(e);for(;n<=o-s;s+=n)this.process(t,s);continue}r.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ke(this),function(e,t){Ce(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:o}=this;let{pos:s}=this;t[s++]=128,Te(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(r,0),s=0);for(let e=s;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),c=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+c,a,n)}(r,n-8,BigInt(8*this.length),o),this.process(r,0);const i=Fe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)i.setUint32(4*e,u[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const qe=/* @__PURE__ */Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xe=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),$e=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),ze=/* @__PURE__ */(()=>$e.map(e=>(9*e+5)%16))(),Ye=/* @__PURE__ */(()=>{const e=[[$e],[ze]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>Xe[e]));return e})(),Ze=/* @__PURE__ */(()=>Ye[0])(),Je=/* @__PURE__ */(()=>Ye[1])(),Qe=/* @__PURE__ */[[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(e=>Uint8Array.from(e)),et=/* @__PURE__ */Ze.map((e,t)=>e.map(e=>Qe[t][e])),tt=/* @__PURE__ */Je.map((e,t)=>e.map(e=>Qe[t][e])),rt=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),nt=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function ot(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const st=/* @__PURE__ */new Uint32Array(16);class it extends Ge{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:t,h2:r,h3:n,h4:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)st[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,i=0|this.h2,a=i,c=0|this.h3,u=c,f=0|this.h4,h=f;for(let e=0;e<5;e++){const t=4-e,d=rt[e],l=nt[e],p=Ze[e],y=Je[e],b=et[e],g=tt[e];for(let t=0;t<16;t++){const n=Oe(r+ot(e,o,i,c)+st[p[t]]+d,b[t])+f|0;r=f,f=c,c=0|Oe(i,10),i=o,o=n}for(let e=0;e<16;e++){const r=Oe(n+ot(t,s,a,u)+st[y[e]]+l,g[e])+h|0;n=h,h=u,u=0|Oe(a,10),a=s,s=r}}this.set(this.h1+i+u|0,this.h2+c+h|0,this.h3+f+n|0,this.h4+r+s|0,this.h0+o+a|0)}roundClean(){Te(st)}destroy(){this.destroyed=!0,Te(this.buffer),this.set(0,0,0,0,0)}}const at=/* @__PURE__ */Ne(()=>new it),ct=/* @__PURE__ */Uint32Array.from([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]),ut=/* @__PURE__ */new Uint32Array(64);class ft extends Ge{constructor(e=32){super(64,e,8,!1),this.A=0|qe[0],this.B=0|qe[1],this.C=0|qe[2],this.D=0|qe[3],this.E=0|qe[4],this.F=0|qe[5],this.G=0|qe[6],this.H=0|qe[7]}get(){const{A:e,B:t,C:r,D:n,E:o,F:s,G:i,H:a}=this;return[e,t,r,n,o,s,i,a]}set(e,t,r,n,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)ut[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ut[e-15],r=ut[e-2],n=je(t,7)^je(t,18)^t>>>3,o=je(r,17)^je(r,19)^r>>>10;ut[e]=o+ut[e-7]+n+ut[e-16]|0}let{A:r,B:n,C:o,D:s,E:i,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(je(i,6)^je(i,11)^je(i,25))+Re(i,a,c)+ct[e]+ut[e]|0,f=(je(r,2)^je(r,13)^je(r,22))+We(r,n,o)|0;u=c,c=a,a=i,i=s+t|0,s=o,o=n,n=r,r=t+f|0}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,o,s,i,a,c,u)}roundClean(){Te(ut)}destroy(){this.set(0,0,0,0,0,0,0,0),Te(this.buffer)}}const ht=/* @__PURE__ */Ne(()=>new ft);function dt(e){return Uint8Array.from(atob(e),function(e){return e.charCodeAt(0)})}function lt(e){for(var t=(new TextEncoder).encode(e),r="",n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r)}exports.verifyProof=function(t,s){try{switch(t.type){case e.ProofTypes.SelfDeclaration:return Promise.resolve(w({},t,{status:t.confirmed?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}));case e.ProofTypes.Screenshot:return Promise.resolve(w({},t,{status:t.url?e.ProofStatus.FLAGGED:e.ProofStatus.FAILED}));case e.ProofTypes.CIP8:return Promise.resolve(function(t){try{var r=t.address.split(/:/),n=r[2],o=t.chainSpecificData&&"cardanoCoseKey"in t.chainSpecificData?t.chainSpecificData.cardanoCoseKey:null;if("cardano"!==r[0]||!o)return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));try{var s=v.default(t.proof,o,t.attestation,n);return Promise.resolve(w({},t,{status:s?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(r){return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.EIP191:return Promise.resolve(function(t){try{var r=t.address.split(/:/),o=r[2];if("eip155"!==r[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));var s=function(e,t,r){try{var o=n.PersonalMessage.getSignPayload(n.Hex.fromString(t)),s=n.Signature.fromHex(r),i=n.Secp256k1.recoverPublicKey({payload:o,signature:s});return n.Address.checksum(n.Address.fromPublicKey(i)).toString()===n.Address.checksum(e)}catch(e){return!1}}(o,t.attestation,t.proof);return Promise.resolve(w({},t,{status:s?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.ED25519:return Promise.resolve(function(t){try{var n=t.address.split(/:/),o=n[2];if("solana"!==n[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));try{var s=r.base58.decode(o),i=(new TextEncoder).encode(t.attestation),a=r.base64.decode(t.proof),c=g.default.sign.detached.verify(i,a,s);return Promise.resolve(w({},t,{status:c?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(r){return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.SOL_SIWX:return Promise.resolve(function(t){try{if("solana"!==t.address.split(/:/)[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));if(!t.chainSpecificData||!function(e){if(!e||"object"!=typeof e)return!1;var t=e;if(!t.account||"object"!=typeof t.account)return!1;var r=t.account;if("string"!=typeof r.address)return!1;if(!r.publicKey)return!1;if(!(r.publicKey instanceof Uint8Array)){var n=r.publicKey;if("object"!=typeof n)return!1;var o=Object.keys(n).filter(function(e){return!isNaN(Number(e))}).sort(function(e,t){return Number(e)-Number(t)});if(32!==o.length)return!1;var s=o.map(function(e){return Number(n[e])});if(!s.every(function(e){return"number"==typeof e&&e>=0&&e<=255}))return!1;r.publicKey=new Uint8Array(s)}if(!t.signedMessage)return!1;if(!(t.signedMessage instanceof Uint8Array)){var i=t.signedMessage;if("Buffer"!==i.type||!Array.isArray(i.data))return!1;t.signedMessage=new Uint8Array(i.data)}if(!t.signature)return!1;if(!(t.signature instanceof Uint8Array)){var a=t.signature;if("Buffer"!==a.type||!Array.isArray(a.data))return!1;t.signature=new Uint8Array(a.data)}if(!t.message||"object"!=typeof t.message)return!1;var c=t.message;if("object"==typeof c&&null!==c){var u=c;if(!u.address&&t.signedMessage instanceof Uint8Array)try{var f=(new TextDecoder).decode(t.signedMessage).split("\n");if(f.length>=2){var h=f[1].trim();h&&/^[a-zA-Z0-9]{32,44}$/.test(h)&&(u.address=h)}}catch(e){}}return!!function(e){return!(!e||"object"!=typeof e)&&"string"==typeof e.domain&&"string"==typeof e.address&&(void 0===e.statement||"string"==typeof e.statement)&&(void 0===e.uri||"string"==typeof e.uri)&&(void 0===e.version||"string"==typeof e.version)&&(void 0===e.chainId||"string"==typeof e.chainId)&&(void 0===e.nonce||"string"==typeof e.nonce)&&(void 0===e.issuedAt||"string"==typeof e.issuedAt)&&(void 0===e.expirationTime||"string"==typeof e.expirationTime)&&(void 0===e.notBefore||"string"==typeof e.notBefore)&&(void 0===e.requestId||"string"==typeof e.requestId)&&(void 0===e.resources||Array.isArray(e.resources))}(t.message)}(t.chainSpecificData))return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));try{var r=t.chainSpecificData,n=(new TextDecoder).decode(r.signedMessage),o=function(e){try{var t=e.split("\n"),r=function(e){var t,r=null==(t=e[0])?void 0:t.match(/^(.+) wants you to sign in with your Solana account:$/);if(!r)return null;var n=r[1],o=e[1];return o&&/^[a-zA-Z0-9]{32,44}$/.test(o)?{domain:n,address:o}:null}(t);if(!r)return null;var n=w({},r),o=2,s=function(e,t){var r=t;if(""===e[r]&&e[r+1]&&!e[r+1].includes(":")){var n=e[++r];return""===e[++r]&&r++,{statement:n,nextIndex:r}}return{nextIndex:r}}(t,o);void 0!==s.statement&&(n.statement=s.statement,o=s.nextIndex);var i=function(e,t){for(var r={},n=[{prefix:"URI: ",key:"uri"},{prefix:"Version: ",key:"version"},{prefix:"Chain ID: ",key:"chainId"},{prefix:"Nonce: ",key:"nonce"},{prefix:"Issued At: ",key:"issuedAt"},{prefix:"Expiration Time: ",key:"expirationTime"},{prefix:"Not Before: ",key:"notBefore"},{prefix:"Request ID: ",key:"requestId"}],o=t;o<e.length;){var s=e[o];if(s){if(s.startsWith("Resources:")){var i=U(e,o+1);if(i.length>0){r.resources=i,o+=i.length+1;continue}}for(var a,c=S(n);!(a=c()).done;){var u=a.value,f=u.prefix,h=u.key;if(s.startsWith(f)){var d=s.substring(f.length);r[h]=d;break}}o++}else o++}return r}(t,o);return Object.assign(n,i),n}catch(e){return null}}(n);if(!o)return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));if(!function(e,t){if(e.domain!==t.domain||e.address!==t.address)return!1;for(var r=[{inputKey:"statement",parsedKey:"statement"},{inputKey:"uri",parsedKey:"uri"},{inputKey:"version",parsedKey:"version"},{inputKey:"chainId",parsedKey:"chainId"},{inputKey:"nonce",parsedKey:"nonce"},{inputKey:"issuedAt",parsedKey:"issuedAt"},{inputKey:"expirationTime",parsedKey:"expirationTime"},{inputKey:"notBefore",parsedKey:"notBefore"},{inputKey:"requestId",parsedKey:"requestId"},{inputKey:"resources",parsedKey:"resources",validator:function(e,t){return!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every(function(e,r){return e===t[r]})}}],n=0,o=r;n<o.length;n++){var s=o[n],i=s.validator,a=t[s.inputKey],c=e[s.parsedKey];if(void 0!==a)if(i){if(!i(a,c))return!1}else if(a!==c)return!1}return function(e){var t=Date.now();if(e.issuedAt){var r=new Date(e.issuedAt);if(Math.abs(r.getTime()-t)>864e5)return!1}return!(e.expirationTime&&new Date(e.expirationTime).getTime()<=t||e.notBefore&&new Date(e.notBefore).getTime()>t)}(e)}(o,r.message))return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));if(function(e){var t=e.domain+" wants you to sign in with your Solana account:\n";t+=""+e.address,e.statement&&(t+="\n\n"+e.statement);var r=function(e){for(var t=[],r=[{key:"uri",prefix:"URI: "},{key:"version",prefix:"Version: "},{key:"chainId",prefix:"Chain ID: "},{key:"nonce",prefix:"Nonce: "},{key:"issuedAt",prefix:"Issued At: "},{key:"expirationTime",prefix:"Expiration Time: "},{key:"notBefore",prefix:"Not Before: "},{key:"requestId",prefix:"Request ID: "},{key:"resources",prefix:"Resources:",formatter:function(e){return Array.isArray(e)&&e.length>0?["Resources:"].concat(e.map(function(e){return"- "+e})):[]}}],n=0,o=r;n<o.length;n++){var s=o[n],i=s.prefix,a=s.formatter,c=e[s.key];if(void 0!==c)if(a){var u=a(c);t.push.apply(t,u)}else"string"==typeof c&&t.push(""+i+c)}return t}(e);return r.length&&(t+="\n\n"+r.join("\n")),t}(o)!==n)return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));var s=g.default.sign.detached.verify(r.signedMessage,r.signature,r.account.publicKey);return Promise.resolve(w({},t,{status:s?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(r){return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.XRP_ED25519:return Promise.resolve(function(t,r){try{var n=function(){if(!r)return w({},t,{status:e.ProofStatus.FAILED});var n=function(e,t,r){return Ae.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return w({},t,{status:n?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})},o=t.address.split(/:/),s=o[2];if("xrpl"!==o[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));var i=function(){if(!r)return Promise.resolve(function(e){try{var t;return Promise.resolve(function(e,t,r){if("function"==typeof e[me]){var n,o,s,i=function(e){try{for(;!((n=a.next()).done||r&&r());)if((e=t(n.value))&&e.then){if(!we(e))return void e.then(i,s||(s=Pe.bind(null,o=new Se,2)));e=e.v}o?Pe(o,1,e):o=e}catch(e){Pe(o||(o=new Se),2,e)}},a=e[me]();if(i(),a.return){var c=function(e){try{n.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var u=[],f=0;f<e.length;f++)u.push(e[f]);return function(e,t,r){var n,o,s=-1;return function i(a){try{for(;++s<e.length&&(!r||!r());)if((a=t(s))&&a.then){if(!we(a))return void a.then(i,o||(o=Pe.bind(null,n=new Se,2)));a=a.v}n?Pe(n,1,a):n=a}catch(e){Pe(n||(n=new Se),2,e)}}(),n}(u,function(e){return t(u[e])},r)}(xe,function(r){return function(n,o){try{var s=(i=new c.Client(r),Promise.resolve(i.connect()).then(function(){return Promise.resolve(i.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1})).then(function(e){return Promise.resolve(i.disconnect()).then(function(){var r,n=function(e){for(var t=0;t<e.length;t++){var r,n;return null!=(r=null==(n=e[t])||null==(n=n.tx_json)?void 0:n.SigningPubKey)?r:"0x"}throw new Error("No valid pubkey found in the latest transactions")}(null==(r=e.result)?void 0:r.transactions);return t=1,n})})}))}catch(e){return o(e)}var i;return s&&s.then?s.then(void 0,o):s}(0,function(e){var t="Connection to XRPL server failed";e instanceof Error&&(t+=": "+e.message),console.error(t)})},function(){return t}))}catch(e){return Promise.reject(e)}}(s)).then(function(e){r=e})}();return Promise.resolve(i&&i.then?i.then(n):n())}catch(e){return Promise.reject(e)}}(t,s));case e.ProofTypes.XLM_ED25519:return Promise.resolve(function(t){var r=t.address.split(/:/),n=r[2];if("stellar"!==r[0])return w({},t,{status:e.ProofStatus.FAILED});try{var o=h.Keypair.fromPublicKey(n),s=Buffer.from(t.attestation,"utf-8"),i=Buffer.from(t.proof,"base64");return w({},t,{status:o.verify(s,i)?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})}catch(r){return console.error(r),w({},t,{status:e.ProofStatus.FAILED})}}(t));case e.ProofTypes.CONCORDIUM:return Promise.resolve(function(t,r){void 0===r&&(r={});try{var n=w({},Be,r),o=t.address.split(/:/),s=o[1],i=o[2];if("ccd"!==o[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));var a=n.network;return s&&(a=s.includes("testnet")?"testnet":"mainnet"),Promise.resolve(Ee(function(){var r;try{r=JSON.parse(t.proof)}catch(r){return w({},t,{status:e.ProofStatus.FAILED})}if(!r||"object"!=typeof r||0===Object.keys(r).length)return w({},t,{status:e.ProofStatus.FAILED});if(n.testMode)try{var o=Ue(r);return!o||o.length<64||!/^[0-9a-fA-F]+$/.test(o)?w({},t,{status:e.ProofStatus.FAILED}):w({},t,{status:e.ProofStatus.VERIFIED})}catch(r){return w({},t,{status:e.ProofStatus.FAILED})}return Promise.resolve(_e(function(){return function(e,t,r){try{var n=Le[t];return Promise.resolve(Ee(function(){var t=new AbortController,o=setTimeout(function(){return t.abort()},r);return Promise.resolve(fetch(n.walletProxyUrl+"/v0/accEncryptionKey/"+e,{method:"GET",headers:{Accept:"application/json","User-Agent":"verify-proof/1.6.0"},signal:t.signal})).then(function(e){return clearTimeout(o),e.ok})},function(e){if(e instanceof Error&&"AbortError"===e.name)throw new Error("Account validation timeout after "+r+"ms");throw e}))}catch(e){return Promise.reject(e)}}(i,a,n.timeout)},n.retries)).then(function(o){return o?Promise.resolve(_e(function(){return function(e,t){try{try{var r=Ue(e);return Promise.resolve(!(!r||r.length<64)&&r.length>=64&&/^[0-9a-fA-F]+$/.test(r))}catch(e){if(e instanceof Error){var n,o,s;if(null!=(n=e.message)&&n.includes("timeout"))throw new Error("Signature verification timeout after "+t+"ms");if(null!=(o=e.message)&&o.includes("UNAVAILABLE"))throw new Error("Concordium node unavailable");if(null!=(s=e.message)&&s.includes("NOT_FOUND"))return Promise.resolve(!1)}throw e}}catch(e){return Promise.reject(e)}}(r,n.timeout)},n.retries)).then(function(r){return w({},t,r?{status:e.ProofStatus.VERIFIED}:{status:e.ProofStatus.FAILED})}):w({},t,{status:e.ProofStatus.FAILED})})},function(){return w({},t,{status:e.ProofStatus.FAILED})}))}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.COSMOS:return Promise.resolve(function(t){try{return Promise.resolve(function(r,n){try{var s=function(){var r=t.address.split(/:/),n=r[2];if("cosmos"!==r[0])return w({},t,{status:e.ProofStatus.FAILED});var s=dt(t.chainSpecificData.pub_key.value),i=dt(t.proof);if(function(e,t){void 0===t&&(t="cosmos");var r=ht(e),n=at(r);return Ve.bech32.encode(t,Ve.bech32.toWords(n))}(s)!==n)return w({},t,{status:e.ProofStatus.FAILED});var a={chain_id:"",account_number:"0",sequence:"0",fee:{amount:[],gas:"0"},msgs:[{type:"sign/MsgSignData",value:{signer:n,data:lt(t.attestation)}}],memo:""};return Promise.resolve(d.serializeSignDoc(a)).then(function(r){var n=ht(r),a=o.secp256k1.verify(i,n,s);return w({},t,{status:a?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})})}()}catch(e){return n()}return s&&s.then?s.then(void 0,n):s}(0,function(){return w({},t,{status:e.ProofStatus.FAILED})}))}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.EIP712:case e.ProofTypes.BIP137:case e.ProofTypes.BIP322:return Promise.resolve(function(t){try{var r=t.address.split(/:/),n=r[2];if("bip122"!==r[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));var o=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?E.bitcoin:e.startsWith("t1")||e.startsWith("t3")?E.zcash:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?E.litecoin:e.startsWith("D")||e.startsWith("A")?E.dogecoin:e.startsWith("X")||e.startsWith("7")?E.dash:e.startsWith("q")?E.bitcoincash:e.startsWith("tb1")?E.testnet:E.bitcoin}(n);if(!o)return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));if(n.startsWith("t1")||n.startsWith("t3"))return Promise.resolve(H(n,t,o));if(o.isTestnet)return Promise.resolve(_(n,t));try{switch(t.type){case e.ProofTypes.BIP137:return Promise.resolve(H(n,t,o));case e.ProofTypes.BIP322:return Promise.resolve(_(n,t));default:return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}))}}catch(r){return console.error("error verifying proof",r),Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}))}}catch(e){return Promise.reject(e)}}(t));case e.ProofTypes.TIP191:return Promise.resolve(function(t){try{var o=t.address.split(/:/),s=o[2];if("tron"!==o[0])return Promise.resolve(w({},t,{status:e.ProofStatus.FAILED}));var i=function(e,t,o){try{var s=(d=n.Hex.fromString(t),n.Hash.keccak256(function(e){var t=n.Hex.from(e);return n.Hex.concat("0x19",n.Hex.fromString("TRON Signed Message:\n"+n.Hex.size(t)),t)}(d))),i=n.Signature.fromHex(o),a=n.Secp256k1.recoverPublicKey({payload:s,signature:i}),c="0x41"+n.Hash.keccak256("0x"+n.PublicKey.toHex(a).slice(4)).substring(26),u=n.Bytes.from(c),f=n.Bytes.from(n.Hash.sha256(n.Hash.sha256(c))).slice(0,4),h=n.Bytes.concat(u,f);return r.base58.encode(h)===e}catch(e){return!1}var d}(s,t.attestation,t.proof);return Promise.resolve(w({},t,{status:i?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}))}catch(e){return Promise.reject(e)}}(t))}return Promise.resolve(t)}catch(e){return Promise.reject(e)}};
2
2
  //# sourceMappingURL=index.cjs.map