@wovin/connect-web3storage 0.1.25 → 0.1.27

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
+ var I=new Uint8Array(0);function J(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function N(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function R(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),o=0;o<t.length;o++)t[o]=255;for(var i=0;i<r.length;i++){var d=r.charAt(i),s=d.charCodeAt(0);if(t[s]!==255)throw new TypeError(d+" is ambiguous");t[s]=i}var f=r.length,h=r.charAt(0),m=Math.log(f)/Math.log(256),w=Math.log(256)/Math.log(f);function U(n){if(n instanceof Uint8Array||(ArrayBuffer.isView(n)?n=new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Array.isArray(n)&&(n=Uint8Array.from(n))),!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(n.length===0)return"";for(var a=0,A=0,u=0,p=n.length;u!==p&&n[u]===0;)u++,a++;for(var y=(p-u)*w+1>>>0,c=new Uint8Array(y);u!==p;){for(var g=n[u],x=0,l=y-1;(g!==0||x<A)&&l!==-1;l--,x++)g+=256*c[l]>>>0,c[l]=g%f>>>0,g=g/f>>>0;if(g!==0)throw new Error("Non-zero carry");A=x,u++}for(var v=y-A;v!==y&&c[v]===0;)v++;for(var b=h.repeat(a);v<y;++v)b+=r.charAt(c[v]);return b}function O(n){if(typeof n!="string")throw new TypeError("Expected String");if(n.length===0)return new Uint8Array;var a=0;if(n[a]!==" "){for(var A=0,u=0;n[a]===h;)A++,a++;for(var p=(n.length-a)*m+1>>>0,y=new Uint8Array(p);n[a];){var c=t[n.charCodeAt(a)];if(c===255)return;for(var g=0,x=p-1;(c!==0||g<u)&&x!==-1;x--,g++)c+=f*y[x]>>>0,y[x]=c%256>>>0,c=c/256>>>0;if(c!==0)throw new Error("Non-zero carry");u=g,a++}if(n[a]!==" "){for(var l=p-u;l!==p&&y[l]===0;)l++;for(var v=new Uint8Array(A+(p-l)),b=A;l!==p;)v[b++]=y[l++];return v}}}function D(n){var a=O(n);if(a)return a;throw new Error(`Non-${e} character`)}return{encode:U,decodeUnsafe:O,decode:D}}var B=R,T=B,_=T;var E=class{name;prefix;baseEncode;constructor(e,t,o){this.name=e,this.prefix=t,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},S=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,o){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=o}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return M(this,e)}},$=class{decoders;constructor(e){this.decoders=e}or(e){return M(this,e)}decode(e){let t=e[0],o=this.decoders[t];if(o!=null)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function M(r,e){return new $({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var z=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,o,i){this.name=e,this.prefix=t,this.baseEncode=o,this.baseDecode=i,this.encoder=new E(e,t,o),this.decoder=new S(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function k({name:r,prefix:e,encode:t,decode:o}){return new z(r,e,t,o)}function G({name:r,prefix:e,alphabet:t}){let{encode:o,decode:i}=_(t,r);return k({prefix:e,name:r,encode:o,decode:d=>N(i(d))})}function V(r,e,t,o){let i={};for(let w=0;w<e.length;++w)i[e[w]]=w;let d=r.length;for(;r[d-1]==="=";)--d;let s=new Uint8Array(d*t/8|0),f=0,h=0,m=0;for(let w=0;w<d;++w){let U=i[r[w]];if(U===void 0)throw new SyntaxError(`Non-${o} character`);h=h<<t|U,f+=t,f>=8&&(f-=8,s[m++]=255&h>>f)}if(f>=t||255&h<<8-f)throw new SyntaxError("Unexpected end of data");return s}function F(r,e,t){let o=e[e.length-1]==="=",i=(1<<t)-1,d="",s=0,f=0;for(let h=0;h<r.length;++h)for(f=f<<8|r[h],s+=8;s>t;)s-=t,d+=e[i&f>>s];if(s!==0&&(d+=e[i&f<<t-s]),o)for(;d.length*t&7;)d+="=";return d}function K({name:r,prefix:e,bitsPerChar:t,alphabet:o}){return k({prefix:e,name:r,encode(i){return F(i,o,t)},decode(i){return V(i,o,t,r)}})}export{J as a,N as b,G as c,K as d};
2
+ //# sourceMappingURL=chunk-6K4NRK7Q.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/src/bytes.ts","../../../../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/src/vendor/base-x.js","../../../../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/src/bases/base.ts"],"sourcesContent":["export const empty = new Uint8Array(0)\n\nexport function toHex (d: Uint8Array): string {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '')\n}\n\nexport function fromHex (hex: string): Uint8Array {\n const hexes = hex.match(/../g)\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty\n}\n\nexport function equals (aa: Uint8Array, bb: Uint8Array): boolean {\n if (aa === bb) return true\n if (aa.byteLength !== bb.byteLength) {\n return false\n }\n\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false\n }\n }\n\n return true\n}\n\nexport function coerce (o: ArrayBufferView | ArrayBuffer | Uint8Array): Uint8Array {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') return o\n if (o instanceof ArrayBuffer) return new Uint8Array(o)\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength)\n }\n throw new Error('Unknown type, must be binary type')\n}\n\nexport function isBinary (o: unknown): o is ArrayBuffer | ArrayBufferView {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o)\n}\n\nexport function fromString (str: string): Uint8Array {\n return new TextEncoder().encode(str)\n}\n\nexport function toString (b: Uint8Array): string {\n return new TextDecoder().decode(b)\n}\n","/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base (ALPHABET, name) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable<number>} source\n */\n function encode (source) {\n // @ts-ignore\n if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }\n return str\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') { return }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) { return }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') { return }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch\n }\n /**\n * @param {string | string[]} string\n */\n function decode (string) {\n var buffer = decodeUnsafe(string);\n if (buffer) { return buffer }\n throw new Error(`Non-${name} character`)\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n }\n}\nvar src = base;\n\nvar _brrp__multiformats_scope_baseX = src;\n\nexport default _brrp__multiformats_scope_baseX;\n","import { coerce } from '../bytes.js'\nimport basex from '../vendor/base-x.js'\nimport type { BaseCodec, BaseDecoder, BaseEncoder, CombobaseDecoder, Multibase, MultibaseCodec, MultibaseDecoder, MultibaseEncoder, UnibaseDecoder } from './interface.js'\n\ninterface EncodeFn { (bytes: Uint8Array): string }\ninterface DecodeFn { (text: string): Uint8Array }\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder<Base extends string, Prefix extends string> implements MultibaseEncoder<Prefix>, BaseEncoder {\n readonly name: Base\n readonly prefix: Prefix\n readonly baseEncode: EncodeFn\n\n constructor (name: Base, prefix: Prefix, baseEncode: EncodeFn) {\n this.name = name\n this.prefix = prefix\n this.baseEncode = baseEncode\n }\n\n encode (bytes: Uint8Array): Multibase<Prefix> {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`\n } else {\n throw Error('Unknown type, must be binary type')\n }\n }\n}\n\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder<Base extends string, Prefix extends string> implements MultibaseDecoder<Prefix>, UnibaseDecoder<Prefix>, BaseDecoder {\n readonly name: Base\n readonly prefix: Prefix\n readonly baseDecode: DecodeFn\n private readonly prefixCodePoint: number\n\n constructor (name: Base, prefix: Prefix, baseDecode: DecodeFn) {\n this.name = name\n this.prefix = prefix\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character')\n }\n this.prefixCodePoint = prefix.codePointAt(0) as number\n this.baseDecode = baseDecode\n }\n\n decode (text: string): Uint8Array {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)\n }\n return this.baseDecode(text.slice(this.prefix.length))\n } else {\n throw Error('Can only multibase decode strings')\n }\n }\n\n or<OtherPrefix extends string> (decoder: UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix> {\n return or(this, decoder)\n }\n}\n\ntype Decoders<Prefix extends string> = Record<Prefix, UnibaseDecoder<Prefix>>\n\nclass ComposedDecoder<Prefix extends string> implements MultibaseDecoder<Prefix>, CombobaseDecoder<Prefix> {\n readonly decoders: Decoders<Prefix>\n\n constructor (decoders: Decoders<Prefix>) {\n this.decoders = decoders\n }\n\n or <OtherPrefix extends string> (decoder: UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix> {\n return or(this, decoder)\n }\n\n decode (input: string): Uint8Array {\n const prefix = input[0] as Prefix\n const decoder = this.decoders[prefix]\n if (decoder != null) {\n return decoder.decode(input)\n } else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)\n }\n }\n}\n\nexport function or <L extends string, R extends string> (left: UnibaseDecoder<L> | CombobaseDecoder<L>, right: UnibaseDecoder<R> | CombobaseDecoder<R>): ComposedDecoder<L | R> {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [(left as UnibaseDecoder<L>).prefix]: left }),\n ...(right.decoders ?? { [(right as UnibaseDecoder<R>).prefix]: right })\n } as Decoders<L | R>)\n}\n\nexport class Codec<Base extends string, Prefix extends string> implements MultibaseCodec<Prefix>, MultibaseEncoder<Prefix>, MultibaseDecoder<Prefix>, BaseCodec, BaseEncoder, BaseDecoder {\n readonly name: Base\n readonly prefix: Prefix\n readonly baseEncode: EncodeFn\n readonly baseDecode: DecodeFn\n readonly encoder: Encoder<Base, Prefix>\n readonly decoder: Decoder<Base, Prefix>\n\n constructor (name: Base, prefix: Prefix, baseEncode: EncodeFn, baseDecode: DecodeFn) {\n this.name = name\n this.prefix = prefix\n this.baseEncode = baseEncode\n this.baseDecode = baseDecode\n this.encoder = new Encoder(name, prefix, baseEncode)\n this.decoder = new Decoder(name, prefix, baseDecode)\n }\n\n encode (input: Uint8Array): string {\n return this.encoder.encode(input)\n }\n\n decode (input: string): Uint8Array {\n return this.decoder.decode(input)\n }\n}\n\nexport function from <Base extends string, Prefix extends string> ({ name, prefix, encode, decode }: { name: Base, prefix: Prefix, encode: EncodeFn, decode: DecodeFn }): Codec<Base, Prefix> {\n return new Codec(name, prefix, encode, decode)\n}\n\nexport function baseX <Base extends string, Prefix extends string> ({ name, prefix, alphabet }: { name: Base, prefix: Prefix, alphabet: string }): Codec<Base, Prefix> {\n const { encode, decode } = basex(alphabet, name)\n return from({\n prefix,\n name,\n encode,\n decode: (text: string): Uint8Array => coerce(decode(text))\n })\n}\n\nfunction decode (string: string, alphabet: string, bitsPerChar: number, name: string): Uint8Array {\n // Build the character lookup table:\n const codes: Record<string, number> = {}\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i\n }\n\n // Count the padding bytes:\n let end = string.length\n while (string[end - 1] === '=') {\n --end\n }\n\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0)\n\n // Parse the data:\n let bits = 0 // Number of bits currently in the buffer\n let buffer = 0 // Bits waiting to be written out, MSB first\n let written = 0 // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]]\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`)\n }\n\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value\n bits += bitsPerChar\n\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8\n out[written++] = 0xff & (buffer >> bits)\n }\n }\n\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data')\n }\n\n return out\n}\n\nfunction encode (data: Uint8Array, alphabet: string, bitsPerChar: number): string {\n const pad = alphabet[alphabet.length - 1] === '='\n const mask = (1 << bitsPerChar) - 1\n let out = ''\n\n let bits = 0 // Number of bits currently in the buffer\n let buffer = 0 // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i]\n bits += 8\n\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar\n out += alphabet[mask & (buffer >> bits)]\n }\n }\n\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))]\n }\n\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '='\n }\n }\n\n return out\n}\n\n/**\n * RFC4648 Factory\n */\nexport function rfc4648 <Base extends string, Prefix extends string> ({ name, prefix, bitsPerChar, alphabet }: { name: Base, prefix: Prefix, bitsPerChar: number, alphabet: string }): Codec<Base, Prefix> {\n return from({\n prefix,\n name,\n encode (input: Uint8Array): string {\n return encode(input, alphabet, bitsPerChar)\n },\n decode (input: string): Uint8Array {\n return decode(input, alphabet, bitsPerChar, name)\n }\n })\n}\n"],"mappings":"AAAO,IAAMA,EAAQ,IAAI,WAAW,CAAC,EAW/B,SAAUC,EAAQC,EAAgBC,EAAc,CACpD,GAAID,IAAOC,EAAI,MAAO,GACtB,GAAID,EAAG,aAAeC,EAAG,WACvB,MAAO,GAGT,QAASC,EAAK,EAAGA,EAAKF,EAAG,WAAYE,IACnC,GAAIF,EAAGE,CAAE,IAAMD,EAAGC,CAAE,EAClB,MAAO,GAIX,MAAO,EACT,CAEM,SAAUC,EAAQC,EAA6C,CACnE,GAAIA,aAAa,YAAcA,EAAE,YAAY,OAAS,aAAc,OAAOA,EAC3E,GAAIA,aAAa,YAAa,OAAO,IAAI,WAAWA,CAAC,EACrD,GAAI,YAAY,OAAOA,CAAC,EACtB,OAAO,IAAI,WAAWA,EAAE,OAAQA,EAAE,WAAYA,EAAE,UAAU,EAE5D,MAAM,IAAI,MAAM,mCAAmC,CACrD,CCvBA,SAASC,EAAMC,EAAUC,EAAI,CAC3B,GAAID,EAAS,QAAU,IAAO,MAAM,IAAI,UAAU,mBAAmB,EAErE,QADIE,EAAW,IAAI,WAAW,GAAG,EACxBC,EAAI,EAAGA,EAAID,EAAS,OAAQC,IACnCD,EAASC,CAAC,EAAI,IAEhB,QAAS,EAAI,EAAG,EAAIH,EAAS,OAAQ,IAAK,CACxC,IAAII,EAAIJ,EAAS,OAAO,CAAC,EACrBK,EAAKD,EAAE,WAAW,CAAC,EACvB,GAAIF,EAASG,CAAE,IAAM,IAAO,MAAM,IAAI,UAAUD,EAAI,eAAe,EACnEF,EAASG,CAAE,EAAI,CACjB,CACA,IAAIC,EAAON,EAAS,OAChBO,EAASP,EAAS,OAAO,CAAC,EAC1BQ,EAAS,KAAK,IAAIF,CAAI,EAAI,KAAK,IAAI,GAAG,EACtCG,EAAU,KAAK,IAAI,GAAG,EAAI,KAAK,IAAIH,CAAI,EAI3C,SAASI,EAAQC,EAAM,CAOrB,GALIA,aAAkB,aAAuB,YAAY,OAAOA,CAAM,EACpEA,EAAS,IAAI,WAAWA,EAAO,OAAQA,EAAO,WAAYA,EAAO,UAAU,EAClE,MAAM,QAAQA,CAAM,IAC7BA,EAAS,WAAW,KAAKA,CAAM,IAE7B,EAAEA,aAAkB,YAAe,MAAM,IAAI,UAAU,qBAAqB,EAChF,GAAIA,EAAO,SAAW,EAAK,MAAO,GAMlC,QAJIC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAOJ,EAAO,OACXG,IAAWC,GAAQJ,EAAOG,CAAM,IAAM,GAC3CA,IACAF,IAMF,QAHII,GAASD,EAAOD,GAAUL,EAAU,IAAO,EAC3CQ,EAAM,IAAI,WAAWD,CAAI,EAEtBF,IAAWC,GAAM,CAItB,QAHIG,EAAQP,EAAOG,CAAM,EAErBK,EAAI,EACCC,EAAMJ,EAAO,GAAIE,IAAU,GAAKC,EAAIN,IAAYO,IAAQ,GAAKA,IAAOD,IAC3ED,GAAU,IAAMD,EAAIG,CAAG,IAAO,EAC9BH,EAAIG,CAAG,EAAKF,EAAQZ,IAAU,EAC9BY,EAASA,EAAQZ,IAAU,EAE7B,GAAIY,IAAU,EAAK,MAAM,IAAI,MAAM,gBAAgB,EACnDL,EAASM,EACTL,GACF,CAGA,QADIO,EAAML,EAAOH,EACVQ,IAAQL,GAAQC,EAAII,CAAG,IAAM,GAClCA,IAIF,QADIC,EAAMf,EAAO,OAAOK,CAAM,EACvBS,EAAML,EAAM,EAAEK,EAAOC,GAAOtB,EAAS,OAAOiB,EAAII,CAAG,CAAC,EAC3D,OAAOC,CACT,CAIA,SAASC,EAAcZ,EAAM,CAC3B,GAAI,OAAOA,GAAW,SAAY,MAAM,IAAI,UAAU,iBAAiB,EACvE,GAAIA,EAAO,SAAW,EAAK,OAAO,IAAI,WACtC,IAAIa,EAAM,EAEV,GAAIb,EAAOa,CAAG,IAAM,IAIpB,SAFIZ,EAAS,EACTC,EAAS,EACNF,EAAOa,CAAG,IAAMjB,GACrBK,IACAY,IAMF,QAHIR,GAAUL,EAAO,OAASa,GAAOhB,EAAU,IAAO,EAClDiB,EAAO,IAAI,WAAWT,CAAI,EAEvBL,EAAOa,CAAG,GAAG,CAElB,IAAIN,EAAQhB,EAASS,EAAO,WAAWa,CAAG,CAAC,EAE3C,GAAIN,IAAU,IAAO,OAErB,QADIC,EAAI,EACCO,EAAMV,EAAO,GAAIE,IAAU,GAAKC,EAAIN,IAAYa,IAAQ,GAAKA,IAAOP,IAC3ED,GAAUZ,EAAOmB,EAAKC,CAAG,IAAO,EAChCD,EAAKC,CAAG,EAAKR,EAAQ,MAAS,EAC9BA,EAASA,EAAQ,MAAS,EAE5B,GAAIA,IAAU,EAAK,MAAM,IAAI,MAAM,gBAAgB,EACnDL,EAASM,EACTK,GACF,CAEA,GAAIb,EAAOa,CAAG,IAAM,IAGpB,SADIG,EAAMX,EAAOH,EACVc,IAAQX,GAAQS,EAAKE,CAAG,IAAM,GACnCA,IAIF,QAFIC,EAAM,IAAI,WAAWhB,GAAUI,EAAOW,EAAI,EAC1CxB,EAAIS,EACDe,IAAQX,GACbY,EAAIzB,GAAG,EAAIsB,EAAKE,GAAK,EAEvB,OAAOC,GACT,CAIA,SAASC,EAAQC,EAAM,CACrB,IAAIC,EAASR,EAAaO,CAAM,EAChC,GAAIC,EAAU,OAAOA,EACrB,MAAM,IAAI,MAAM,OAAO9B,CAAI,YAAY,CACzC,CACA,MAAO,CACL,OAAQS,EACR,aAAca,EACd,OAAQM,EAEZ,CACA,IAAIG,EAAMjC,EAENkC,EAAkCD,EAEtCE,EAAeD,ECjIf,IAAME,EAAN,KAAa,CACF,KACA,OACA,WAET,YAAaC,EAAYC,EAAgBC,EAAoB,CAC3D,KAAK,KAAOF,EACZ,KAAK,OAASC,EACd,KAAK,WAAaC,CACpB,CAEA,OAAQC,EAAiB,CACvB,GAAIA,aAAiB,WACnB,MAAO,GAAG,KAAK,MAAM,GAAG,KAAK,WAAWA,CAAK,CAAC,GAE9C,MAAM,MAAM,mCAAmC,CAEnD,GAQIC,EAAN,KAAa,CACF,KACA,OACA,WACQ,gBAEjB,YAAaJ,EAAYC,EAAgBI,EAAoB,CAI3D,GAHA,KAAK,KAAOL,EACZ,KAAK,OAASC,EAEVA,EAAO,YAAY,CAAC,IAAM,OAC5B,MAAM,IAAI,MAAM,0BAA0B,EAE5C,KAAK,gBAAkBA,EAAO,YAAY,CAAC,EAC3C,KAAK,WAAaI,CACpB,CAEA,OAAQC,EAAY,CAClB,GAAI,OAAOA,GAAS,SAAU,CAC5B,GAAIA,EAAK,YAAY,CAAC,IAAM,KAAK,gBAC/B,MAAM,MAAM,qCAAqC,KAAK,UAAUA,CAAI,CAAC,KAAK,KAAK,IAAI,+CAA+C,KAAK,MAAM,EAAE,EAEjJ,OAAO,KAAK,WAAWA,EAAK,MAAM,KAAK,OAAO,MAAM,CAAC,CACvD,KACE,OAAM,MAAM,mCAAmC,CAEnD,CAEA,GAAgCC,EAAmE,CACjG,OAAOC,EAAG,KAAMD,CAAO,CACzB,GAKIE,EAAN,KAAqB,CACV,SAET,YAAaC,EAA0B,CACrC,KAAK,SAAWA,CAClB,CAEA,GAAiCH,EAAmE,CAClG,OAAOC,EAAG,KAAMD,CAAO,CACzB,CAEA,OAAQI,EAAa,CACnB,IAAMV,EAASU,EAAM,CAAC,EAChBJ,EAAU,KAAK,SAASN,CAAM,EACpC,GAAIM,GAAW,KACb,OAAOA,EAAQ,OAAOI,CAAK,EAE3B,MAAM,WAAW,qCAAqC,KAAK,UAAUA,CAAK,CAAC,+BAA+B,OAAO,KAAK,KAAK,QAAQ,CAAC,gBAAgB,CAExJ,GAGI,SAAUH,EAAyCI,EAA+CC,EAA8C,CAEpJ,OAAO,IAAIJ,EAAgB,CACzB,GAAIG,EAAK,UAAY,CAAE,CAAEA,EAA2B,MAAM,EAAGA,CAAI,EACjE,GAAIC,EAAM,UAAY,CAAE,CAAEA,EAA4B,MAAM,EAAGA,CAAK,EAClD,CACtB,CAEM,IAAOC,EAAP,KAAY,CACP,KACA,OACA,WACA,WACA,QACA,QAET,YAAad,EAAYC,EAAgBC,EAAsBG,EAAoB,CACjF,KAAK,KAAOL,EACZ,KAAK,OAASC,EACd,KAAK,WAAaC,EAClB,KAAK,WAAaG,EAClB,KAAK,QAAU,IAAIN,EAAQC,EAAMC,EAAQC,CAAU,EACnD,KAAK,QAAU,IAAIE,EAAQJ,EAAMC,EAAQI,CAAU,CACrD,CAEA,OAAQM,EAAiB,CACvB,OAAO,KAAK,QAAQ,OAAOA,CAAK,CAClC,CAEA,OAAQA,EAAa,CACnB,OAAO,KAAK,QAAQ,OAAOA,CAAK,CAClC,GAGI,SAAUI,EAAmD,CAAE,KAAAf,EAAM,OAAAC,EAAQ,OAAAe,EAAQ,OAAAC,CAAM,EAAsE,CACrK,OAAO,IAAIH,EAAMd,EAAMC,EAAQe,EAAQC,CAAM,CAC/C,CAEM,SAAUC,EAAoD,CAAE,KAAAlB,EAAM,OAAAC,EAAQ,SAAAkB,CAAQ,EAAoD,CAC9I,GAAM,CAAE,OAAAH,EAAQ,OAAAC,CAAM,EAAKG,EAAMD,EAAUnB,CAAI,EAC/C,OAAOe,EAAK,CACV,OAAAd,EACA,KAAAD,EACA,OAAAgB,EACA,OAASV,GAA6Be,EAAOJ,EAAOX,CAAI,CAAC,EAC1D,CACH,CAEA,SAASW,EAAQK,EAAgBH,EAAkBI,EAAqBvB,EAAY,CAElF,IAAMwB,EAAgC,CAAA,EACtC,QAASC,EAAI,EAAGA,EAAIN,EAAS,OAAQ,EAAEM,EACrCD,EAAML,EAASM,CAAC,CAAC,EAAIA,EAIvB,IAAIC,EAAMJ,EAAO,OACjB,KAAOA,EAAOI,EAAM,CAAC,IAAM,KACzB,EAAEA,EAIJ,IAAMC,EAAM,IAAI,WAAYD,EAAMH,EAAc,EAAK,CAAC,EAGlDK,EAAO,EACPC,EAAS,EACTC,EAAU,EACd,QAASL,EAAI,EAAGA,EAAIC,EAAK,EAAED,EAAG,CAE5B,IAAMM,EAAQP,EAAMF,EAAOG,CAAC,CAAC,EAC7B,GAAIM,IAAU,OACZ,MAAM,IAAI,YAAY,OAAO/B,CAAI,YAAY,EAI/C6B,EAAUA,GAAUN,EAAeQ,EACnCH,GAAQL,EAGJK,GAAQ,IACVA,GAAQ,EACRD,EAAIG,GAAS,EAAI,IAAQD,GAAUD,EAEvC,CAGA,GAAIA,GAAQL,GAAgB,IAAQM,GAAW,EAAID,EACjD,MAAM,IAAI,YAAY,wBAAwB,EAGhD,OAAOD,CACT,CAEA,SAASX,EAAQgB,EAAkBb,EAAkBI,EAAmB,CACtE,IAAMU,EAAMd,EAASA,EAAS,OAAS,CAAC,IAAM,IACxCe,GAAQ,GAAKX,GAAe,EAC9BI,EAAM,GAENC,EAAO,EACPC,EAAS,EACb,QAASJ,EAAI,EAAGA,EAAIO,EAAK,OAAQ,EAAEP,EAMjC,IAJAI,EAAUA,GAAU,EAAKG,EAAKP,CAAC,EAC/BG,GAAQ,EAGDA,EAAOL,GACZK,GAAQL,EACRI,GAAOR,EAASe,EAAQL,GAAUD,CAAK,EAU3C,GALIA,IAAS,IACXD,GAAOR,EAASe,EAAQL,GAAWN,EAAcK,CAAM,GAIrDK,EACF,KAASN,EAAI,OAASJ,EAAe,GACnCI,GAAO,IAIX,OAAOA,CACT,CAKM,SAAUQ,EAAsD,CAAE,KAAAnC,EAAM,OAAAC,EAAQ,YAAAsB,EAAa,SAAAJ,CAAQ,EAAyE,CAClL,OAAOJ,EAAK,CACV,OAAAd,EACA,KAAAD,EACA,OAAQW,EAAiB,CACvB,OAAOK,EAAOL,EAAOQ,EAAUI,CAAW,CAC5C,EACA,OAAQZ,EAAa,CACnB,OAAOM,EAAON,EAAOQ,EAAUI,EAAavB,CAAI,CAClD,EACD,CACH","names":["empty","equals","aa","bb","ii","coerce","o","base","ALPHABET","name","BASE_MAP","j","x","xc","BASE","LEADER","FACTOR","iFACTOR","encode","source","zeroes","length","pbegin","pend","size","b58","carry","i","it1","it2","str","decodeUnsafe","psz","b256","it3","it4","vch","decode","string","buffer","src","_brrp__multiformats_scope_baseX","base_x_default","Encoder","name","prefix","baseEncode","bytes","Decoder","baseDecode","text","decoder","or","ComposedDecoder","decoders","input","left","right","Codec","from","encode","decode","baseX","alphabet","base_x_default","coerce","string","bitsPerChar","codes","i","end","out","bits","buffer","written","value","data","pad","mask","rfc4648"]}
@@ -0,0 +1,29 @@
1
+ import{d as pr}from"./chunk-6K4NRK7Q.min.js";import{a as Qn}from"./chunk-L7VH6KZJ.min.js";import{a as Fu,b as St,c as Zi}from"./chunk-D2SZILOK.min.js";var _i=Fu((Vy,Ti)=>{"use strict";var Fy=function(){typeof Ti<"u"&&(Ti.exports=A);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(p){var m=p-p%1;return m==0&&(p<0||p===0&&1/p!=1/0)?-0:m},u=A.prototype,f=(A.fromDate=function(p){return new A(+p)},A.fromInt64BE=U(0,1,2,3,0,4),A.fromInt64LE=U(3,2,1,0,4,0),A.fromString=function(R){var m,C=new A,R=(R+="").replace(/^\s*[+\-]?\d+/,function(y){var y=+y,g=1970+(y-1970)%400;return C.year=y-g,g}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(I,y,g){return y<0&&(g*=-1),m=6e4*(60*+y+ +g),""}).replace(/\.\d+$/,function(I){return C.nano=+(I+c).substr(1,9),""}).split(/\D+/);if(1<R.length?R[1]--:R[1]=0,C.time=m=Date.UTC.apply(Date,R)-(m||0),isNaN(m))throw new TypeError("Invalid Date");return B(C)},A.fromTimeT=function(p){return T(p,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(p){return this.nano+=+p||0,this},u.getNano=function(){var p=B(this);return(p.time%1e3*a+ +p.nano+1e9)%1e9},u.getTimeT=function(){var m=B(this),p=Math.floor(m.time/1e3),m=m.year;return m&&(p+=m*r*e/t),p},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(B(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(p){var m=this,C=m.toDate(),R={H:function(){return P(C.getUTCHours())},L:function(){return F(C.getUTCMilliseconds(),3)},M:function(){return P(C.getUTCMinutes())},N:function(){return F(m.getNano(),9)},S:function(){return P(C.getUTCSeconds())},Y:function(){var I=m.getYear();return 999999<I?"+"+I:9999<I?"+"+F(I,6):0<=I?F(I,4):-999999<=I?"-"+F(-I,6):I},a:function(){return v[C.getUTCDay()]},b:function(){return x[C.getUTCMonth()]},d:function(){return P(C.getUTCDate())},e:function(){return function(I){return(9<I?"":" ")+(0|I)}(C.getUTCDate())},m:function(){return P(C.getUTCMonth()+1)}};return function I(y){return y.replace(/%./g,function(g){var S=g[1],d=b[S],S=R[S];return d?I(d):S?S():g})}(p||f)},u.writeInt64BE=E(0,1,2,3,0,4),u.writeInt64LE=E(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],b={"%":"%",F:"%Y-%m-%d",n:`
2
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return A;function A(p,m,C){var R=this;if(!(R instanceof A))return new A(p,m,C);R.time=+p||0,R.nano=+m||0,R.year=+C||0,B(R)}function B(p){var m,C,R,I=p.year,y=p.time,g=p.nano,d=((g<0||a<=g)&&(g-=(C=Math.floor(g/a))*a,y+=C,C=1),I%t);return(y<-i||i<y||d)&&((m=l(y/o))&&(I+=m*t,y-=m*o),(R=w(y)).setUTCFullYear(d+R.getUTCFullYear()),R=(y=+R)+(m=l((I-=d)/t))*o,m&&-i<=R&&R<=i&&(I-=m*t,y=R),C=1),C&&(p.year=I,p.time=y,p.nano=g),p}function w(p){var m=new Date(0);return m.setTime(p),m}function T(I,R){I=+I||0;var C=l((R=(R|0)*s)/n)+l(I/n),R=R%n+I%n,I=l(R/n);return I&&(C+=I,R-=I*n),new A(1e3*R,0,C*t)}function E(p,m,C,R,I,y){return function(d,S){var N=B(this);d=d||new Array(8),K(d,S|=0);var k=Math.floor(N.time/1e3),N=N.year*(r*e/t),D=l(N/s)+l(k/s),N=N%s+k%s,k=Math.floor(N/s);return k&&(D+=k,N-=k*s),g(d,S+I,D),g(d,S+y,N),d};function g(d,S,D){d[S+p]=D>>24&255,d[S+m]=D>>16&255,d[S+C]=D>>8&255,d[S+R]=255&D}}function U(p,m,C,R,I,y){return function(d,S){K(d,S|=0);var D=g(d,S+I);return T(g(d,S+y),D)};function g(d,S){return 16777216*d[S+p]+(d[S+m]<<16|d[S+C]<<8|d[S+R])}}function K(p,m){if(p=p&&p.length,p==null)throw new TypeError("Invalid Buffer");if(p<m+8)throw new RangeError("Out of range")}function P(p){return(9<p?"":"0")+(0|p)}function F(p,m){return(c+(0|p)).substr(-m)}}()});var bh=pr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ji=pr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xh=pr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wh=pr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var rt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ke=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}},mr=class extends Error{static name="InvalidPrivateKeyError";constructor(t="Invalid private key"){super(t),this.name="InvalidPrivateKeyError"}};var Ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var oo={};St(oo,{base58btc:()=>ot,base58flickr:()=>ju});var vh=new Uint8Array(0);function Gi(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function jt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Yi(e){return new TextEncoder().encode(e)}function Wi(e){return new TextDecoder().decode(e)}function Vu(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var A=0,B=0,w=0,T=b.length;w!==T&&b[w]===0;)w++,A++;for(var E=(T-w)*u+1>>>0,U=new Uint8Array(E);w!==T;){for(var K=b[w],P=0,F=E-1;(K!==0||P<B)&&F!==-1;F--,P++)K+=256*U[F]>>>0,U[F]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");B=P,w++}for(var p=E-B;p!==E&&U[p]===0;)p++;for(var m=c.repeat(A);p<E;++p)m+=e.charAt(U[p]);return m}function x(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var A=0;if(b[A]!==" "){for(var B=0,w=0;b[A]===c;)B++,A++;for(var T=(b.length-A)*l+1>>>0,E=new Uint8Array(T);b[A];){var U=r[b.charCodeAt(A)];if(U===255)return;for(var K=0,P=T-1;(U!==0||K<w)&&P!==-1;P--,K++)U+=a*E[P]>>>0,E[P]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");w=K,A++}if(b[A]!==" "){for(var F=T-w;F!==T&&E[F]===0;)F++;for(var p=new Uint8Array(B+(T-F)),m=B;F!==T;)p[m++]=E[F++];return p}}}function v(b){var A=x(b);if(A)return A;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:x,decode:v}}var qu=Vu,Hu=qu,Ji=Hu;var to=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},eo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Qi(this,t)}},ro=class{decoders;constructor(t){this.decoders=t}or(t){return Qi(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qi(e,t){return new ro({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var no=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new to(t,r,n),this.decoder=new eo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Oe({name:e,prefix:t,encode:r,decode:n}){return new no(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ji(r,e);return Oe({prefix:t,name:e,encode:n,decode:i=>jt(o(i))})}function $u(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function zu(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function Zu(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function tt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Zu(n);return Oe({prefix:t,name:e,encode(i){return zu(i,n,r)},decode(i){return $u(i,o,r,e)}})}var ot=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ju=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var io={};St(io,{base32:()=>ie,base32hex:()=>Xu,base32hexpad:()=>Qu,base32hexpadupper:()=>tf,base32hexupper:()=>Ju,base32pad:()=>Yu,base32padupper:()=>Wu,base32upper:()=>Gu,base32z:()=>ef});var ie=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ju=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tf=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ef=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var so={};St(so,{base36:()=>Lt,base36upper:()=>rf});var Lt=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rf=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nf=rs,ts=128,of=127,sf=~of,af=Math.pow(2,31);function rs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=af;)t[r++]=e&255|ts,e/=128;for(;e&sf;)t[r++]=e&255|ts,e>>>=7;return t[r]=e|0,rs.bytes=r-n+1,t}var cf=ao,uf=128,es=127;function ao(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw ao.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&es)<<o:(s&es)*Math.pow(2,o),o+=7}while(s>=uf);return ao.bytes=i-n,r}var ff=Math.pow(2,7),lf=Math.pow(2,14),df=Math.pow(2,21),hf=Math.pow(2,28),pf=Math.pow(2,35),mf=Math.pow(2,42),yf=Math.pow(2,49),gf=Math.pow(2,56),bf=Math.pow(2,63),xf=function(e){return e<ff?1:e<lf?2:e<df?3:e<hf?4:e<pf?5:e<mf?6:e<yf?7:e<gf?8:e<bf?9:10},wf={encode:nf,decode:cf,encodingLength:xf},Ef=wf,yr=Ef;function gr(e,t=0){return[yr.decode(e,t),yr.decode.bytes]}function Pe(e,t,r=0){return yr.encode(e,t,r),t}function Me(e){return yr.encodingLength(e)}function qt(e,t){let r=t.byteLength,n=Me(e),o=n+Me(r),i=new Uint8Array(o+r);return Pe(e,i,0),Pe(r,i,n),i.set(t,o),new Fe(e,r,t,i)}function Ve(e){let t=jt(e),[r,n]=gr(t),[o,i]=gr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Fe(r,o,s,t)}function ns(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Gi(e.bytes,r.bytes)}}var Fe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function os(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return vf(r,co(e),t??ot.encoder);default:return Af(r,co(e),t??ie.encoder)}}var is=new WeakMap;function co(e){let t=is.get(e);if(t==null){let r=new Map;return is.set(e,r),r}return t}var it=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Bf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=qt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ns(t.multihash,n.multihash)}toString(t){return os(this,t)}toJSON(){return{"/":os(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??ss(n,o,i.bytes))}else if(r[If]===!0){let{version:n,multihash:o,code:i}=r,s=Ve(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==br)throw new Error(`Version 0 CID must use dag-pb (code: ${br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ss(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=jt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Fe(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,x]=gr(t.subarray(r));return r+=x,f},o=n(),i=br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=Sf(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return co(i).set(n,t),i}};function Sf(e,t){switch(e[0]){case"Q":{let r=t??ot;return[ot.prefix,r.decode(`${ot.prefix}${e}`)]}case ot.prefix:{let r=t??ot;return[ot.prefix,r.decode(e)]}case ie.prefix:{let r=t??ie;return[ie.prefix,r.decode(e)]}case Lt.prefix:{let r=t??Lt;return[Lt.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function vf(e,t,r){let{prefix:n}=r;if(n!==ot.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Af(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var br=112,Bf=18;function ss(e,t,r){let n=Me(e),o=n+Me(t),i=new Uint8Array(o+r.byteLength);return Pe(e,i,0),Pe(t,i,n),i.set(r,o),i}var If=Symbol.for("@ipld/js-cid/CID");var uo={};St(uo,{identity:()=>ge});var as=0,Tf="identity",cs=jt;function _f(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return qt(as,cs(e))}var ge={code:as,name:Tf,encode:cs,digest:_f};function st(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Gt(e=0){return new Uint8Array(e)}function vt(e=0){return new Uint8Array(e)}function be(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=vt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var fs=Symbol.for("@achingbrain/uint8arraylist");function us(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function sn(e){return!!e?.[fs]}var pt=class e{bufs;length;[fs]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(sn(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(sn(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=us(this.bufs,t);return r.buf[r.index]}set(t,r){let n=us(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(sn(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return be(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:be(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!sn(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let x=l;x>=0;x--){let v=this.get(f+x);if(n[x]!==v){u=Math.max(1,x-a[v]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!st(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var fo={};St(fo,{base10:()=>Cf});var Cf=oe({prefix:"9",name:"base10",alphabet:"0123456789"});var lo={};St(lo,{base16:()=>Uf,base16upper:()=>Rf});var Uf=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rf=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ho={};St(ho,{base2:()=>Df});var Df=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var po={};St(po,{base256emoji:()=>Of});var ls=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Lf=ls.reduce((e,t,r)=>(e[r]=t,e),[]),Nf=ls.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function kf(e){return e.reduce((t,r)=>(t+=Lf[r],t),"")}function Kf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Nf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Of=Oe({prefix:"\u{1F680}",name:"base256emoji",encode:kf,decode:Kf});var yo={};St(yo,{base64:()=>mo,base64pad:()=>an,base64url:()=>Pf,base64urlpad:()=>Mf});var mo=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),an=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pf=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mf=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var go={};St(go,{base8:()=>Ff});var Ff=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bo={};St(bo,{identity:()=>Vf});var Vf=Oe({prefix:"\0",name:"identity",encode:e=>Wi(e),decode:e=>Yi(e)});var s0=new TextEncoder,a0=new TextDecoder;var Eo={};St(Eo,{sha256:()=>cn,sha512:()=>zf});var $f=20;function wo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new xo(e,t,r,n,o)}var xo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??$f,this.maxDigestLength=i}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?ds(n,this.code,r?.truncate):n.then(o=>ds(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ds(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return qt(t,e)}function ps(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var cn=wo({name:"sha2-256",code:18,encode:ps("SHA-256")}),zf=wo({name:"sha2-512",code:19,encode:ps("SHA-512")});var So={...bo,...ho,...go,...fo,...lo,...io,...so,...oo,...yo,...po},x0={...Eo,...uo};function ys(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ms=ys("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),vo=ys("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=vt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Zf={utf8:ms,"utf-8":ms,hex:So.base16,latin1:vo,ascii:vo,binary:vo,...So},un=Zf;function Z(e,t="utf8"){let r=un[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function j(e,t="utf8"){let r=un[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var jf=parseInt("11111",2),Ao=parseInt("10000000",2),Gf=parseInt("01111111",2),gs={0:xr,1:xr,2:Yf,3:Jf,4:Qf,5:Xf,6:Wf,16:xr,22:xr,48:xr};function Ut(e,t={offset:0}){let r=e[t.offset]&jf;if(t.offset++,gs[r]!=null)return gs[r](e,t);throw new Error("No decoder for tag "+r)}function wr(e,t){let r=0;if((e[t.offset]&Ao)===Ao){let n=e[t.offset]&Gf,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function xr(e,t){wr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Ut(e,t);if(n===null)break;r.push(n)}return r}function Yf(e,t){let r=wr(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function Wf(e,t){let r=wr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function Xf(e,t){return t.offset++,null}function Jf(e,t){let r=wr(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Qf(e,t){let r=wr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function tl(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new pt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function fn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=tl(e.byteLength);return new pt(Uint8Array.from([t.byteLength|Ao]),t)}function mt(e){let t=new pt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new pt(Uint8Array.from([2]),fn(t),t)}function Er(e){let t=Uint8Array.from([0]),r=new pt(t,e);return new pt(Uint8Array.from([3]),fn(r),r)}function bs(e){return new pt(Uint8Array.from([4]),fn(e),e)}function Nt(e,t=48){let r=new pt;for(let n of e)r.append(n);return new pt(Uint8Array.from([t]),fn(r),r)}var xs="1.2.840.10045.3.1.7",ws="1.3.132.0.34",Es="1.3.132.0.35";async function Ss(e="P-256"){let t=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",t.publicKey),privateKey:await crypto.subtle.exportKey("jwk",t.privateKey)}}async function vs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function As(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),i}var el=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),rl=Uint8Array.from([6,5,43,129,4,0,34]),nl=Uint8Array.from([6,5,43,129,4,0,35]),Bs={ext:!0,kty:"EC",crv:"P-256"},Is={ext:!0,kty:"EC",crv:"P-384"},Ts={ext:!0,kty:"EC",crv:"P-521"},qe=32,He=48,$e=66;function _s(e){let t=Ut(e);return Bo(t)}function Bo(e){let t=e[1],r=j(t,"base64url"),n=e[2][1][0],o=1,i,s;if(t.byteLength===qe)return i=j(n.subarray(o,o+qe),"base64url"),s=j(n.subarray(o+qe),"base64url"),new we({...Bs,key_ops:["sign"],d:r,x:i,y:s});if(t.byteLength===He)return i=j(n.subarray(o,o+He),"base64url"),s=j(n.subarray(o+He),"base64url"),new we({...Is,key_ops:["sign"],d:r,x:i,y:s});if(t.byteLength===$e)return i=j(n.subarray(o,o+$e),"base64url"),s=j(n.subarray(o+$e),"base64url"),new we({...Ts,key_ops:["sign"],d:r,x:i,y:s});throw new rt(`Private key length was wrong length, got ${t.byteLength}, expected 32, 48 or 66`)}function Cs(e){let t=Ut(e);return Us(t)}function Us(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===qe*2+1)return n=j(t.subarray(r,r+qe),"base64url"),o=j(t.subarray(r+qe),"base64url"),new xe({...Bs,key_ops:["verify"],x:n,y:o});if(t.byteLength===He*2+1)return n=j(t.subarray(r,r+He),"base64url"),o=j(t.subarray(r+He),"base64url"),new xe({...Is,key_ops:["verify"],x:n,y:o});if(t.byteLength===$e*2+1)return n=j(t.subarray(r,r+$e),"base64url"),o=j(t.subarray(r+$e),"base64url"),new xe({...Ts,key_ops:["verify"],x:n,y:o});throw new rt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Rs(e){return Nt([mt(Uint8Array.from([1])),bs(Z(e.d??"","base64url")),Nt([Ls(e.crv)],160),Nt([Er(new pt(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function Ds(e){return Nt([mt(Uint8Array.from([1])),Nt([Ls(e.crv)],160),Nt([Er(new pt(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function Ls(e){if(e==="P-256")return el;if(e==="P-384")return rl;if(e==="P-521")return nl;throw new rt(`Invalid curve ${e}`)}async function Ns(e="P-256"){let t=await Ss(e);return new we(t.privateKey)}var xe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ds(this.jwk)),this._raw}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}async verify(t,r,n){return As(this.jwk,r,t,n)}},we=class{type="ECDSA";jwk;publicKey;_raw;constructor(t){this.jwk=t,this.publicKey=new xe({crv:t.crv,ext:t.ext,key_ops:["verify"],kty:"EC",x:t.x,y:t.y})}get raw(){return this._raw==null&&(this._raw=Rs(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}async sign(t,r){return vs(this.jwk,t,r)}};function Ee(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ht(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function H(e,t,r=""){let n=Ee(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return e}function ln(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Ht(e.outputLen),Ht(e.blockLen)}function ze(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 Ks(e,t){H(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Wt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function dn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function kt(e,t){return e<<32-t|e>>>t}var Os=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ol=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Xt(e){if(H(e),Os)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=ol[e[r]];return t}var Yt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ks(e){if(e>=Yt._0&&e<=Yt._9)return e-Yt._0;if(e>=Yt.A&&e<=Yt.F)return e-(Yt.A-10);if(e>=Yt.a&&e<=Yt.f)return e-(Yt.a-10)}function Jt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Os)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ks(e.charCodeAt(i)),a=ks(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function bt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];H(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function Io(e,t={}){let r=(o,i)=>e(i).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Ze(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var To=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ps(e,t,r){return e&t^~e&r}function Ms(e,t,r){return e&t^e&r^t&r}var Sr=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=dn(this.buffer)}update(t){ze(this),H(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=dn(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ze(this),Ks(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,Wt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=dn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Qt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var lt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var hn=BigInt(4294967295),Fs=BigInt(32);function il(e,t=!1){return t?{h:Number(e&hn),l:Number(e>>Fs&hn)}:{h:Number(e>>Fs&hn)|0,l:Number(e&hn)|0}}function Vs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=il(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var _o=(e,t,r)=>e>>>r,Co=(e,t,r)=>e<<32-r|t>>>r,Se=(e,t,r)=>e>>>r|t<<32-r,ve=(e,t,r)=>e<<32-r|t>>>r,vr=(e,t,r)=>e<<64-r|t>>>r-32,Ar=(e,t,r)=>e>>>r-32|t<<64-r;function $t(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var qs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Hs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,$s=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),zs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Zs=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),js=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var al=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]),ae=new Uint32Array(64),Uo=class extends Sr{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)ae[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let x=ae[f-15],v=ae[f-2],b=kt(x,7)^kt(x,18)^x>>>3,A=kt(v,17)^kt(v,19)^v>>>10;ae[f]=A+ae[f-7]+b+ae[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let x=kt(a,6)^kt(a,11)^kt(a,25),v=u+x+Ps(a,c,l)+al[f]+ae[f]|0,A=(kt(n,2)^kt(n,13)^kt(n,22))+Ms(n,o,i)|0;u=l,l=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+A|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){Wt(ae)}destroy(){this.set(0,0,0,0,0,0,0,0),Wt(this.buffer)}},Ro=class extends Uo{A=Qt[0]|0;B=Qt[1]|0;C=Qt[2]|0;D=Qt[3]|0;E=Qt[4]|0;F=Qt[5]|0;G=Qt[6]|0;H=Qt[7]|0;constructor(){super(32)}};var Gs=Vs(["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))),cl=Gs[0],ul=Gs[1],ce=new Uint32Array(80),ue=new Uint32Array(80),Do=class extends Sr{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:x,Gh:v,Gl:b,Hh:A,Hl:B}=this;return[t,r,n,o,i,s,a,c,l,u,f,x,v,b,A,B]}set(t,r,n,o,i,s,a,c,l,u,f,x,v,b,A,B){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=x|0,this.Gh=v|0,this.Gl=b|0,this.Hh=A|0,this.Hl=B|0}process(t,r){for(let E=0;E<16;E++,r+=4)ce[E]=t.getUint32(r),ue[E]=t.getUint32(r+=4);for(let E=16;E<80;E++){let U=ce[E-15]|0,K=ue[E-15]|0,P=Se(U,K,1)^Se(U,K,8)^_o(U,K,7),F=ve(U,K,1)^ve(U,K,8)^Co(U,K,7),p=ce[E-2]|0,m=ue[E-2]|0,C=Se(p,m,19)^vr(p,m,61)^_o(p,m,6),R=ve(p,m,19)^Ar(p,m,61)^Co(p,m,6),I=$s(F,R,ue[E-7],ue[E-16]),y=zs(I,P,C,ce[E-7],ce[E-16]);ce[E]=y|0,ue[E]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:x,Fh:v,Fl:b,Gh:A,Gl:B,Hh:w,Hl:T}=this;for(let E=0;E<80;E++){let U=Se(f,x,14)^Se(f,x,18)^vr(f,x,41),K=ve(f,x,14)^ve(f,x,18)^Ar(f,x,41),P=f&v^~f&A,F=x&b^~x&B,p=Zs(T,K,F,ul[E],ue[E]),m=js(p,w,U,P,cl[E],ce[E]),C=p|0,R=Se(n,o,28)^vr(n,o,34)^vr(n,o,39),I=ve(n,o,28)^Ar(n,o,34)^Ar(n,o,39),y=n&i^n&a^i&a,g=o&s^o&c^s&c;w=A|0,T=B|0,A=v|0,B=b|0,v=f|0,b=x|0,{h:f,l:x}=$t(l|0,u|0,m|0,C|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let d=qs(C,I,g);n=Hs(d,m,R,y),o=d|0}({h:n,l:o}=$t(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=$t(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=$t(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=$t(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:x}=$t(this.Eh|0,this.El|0,f|0,x|0),{h:v,l:b}=$t(this.Fh|0,this.Fl|0,v|0,b|0),{h:A,l:B}=$t(this.Gh|0,this.Gl|0,A|0,B|0),{h:w,l:T}=$t(this.Hh|0,this.Hl|0,w|0,T|0),this.set(n,o,i,s,a,c,l,u,f,x,v,b,A,B,w,T)}roundClean(){Wt(ce,ue)}destroy(){Wt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Lo=class extends Do{Ah=lt[0]|0;Al=lt[1]|0;Bh=lt[2]|0;Bl=lt[3]|0;Ch=lt[4]|0;Cl=lt[5]|0;Dh=lt[6]|0;Dl=lt[7]|0;Eh=lt[8]|0;El=lt[9]|0;Fh=lt[10]|0;Fl=lt[11]|0;Gh=lt[12]|0;Gl=lt[13]|0;Hh=lt[14]|0;Hl=lt[15]|0;constructor(){super(64)}};var je=Io(()=>new Ro,To(1));var Ys=Io(()=>new Lo,To(3));var ko=BigInt(0),No=BigInt(1);function te(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function Ws(e){if(typeof e=="bigint"){if(!pn(e))throw new Error("positive bigint expected, got "+e)}else Ht(e);return e}function Br(e){let t=Ws(e).toString(16);return t.length&1?"0"+t:t}function Xs(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ko:BigInt("0x"+e)}function Ge(e){return Xs(Xt(e))}function Ae(e){return Xs(Xt(yn(H(e)).reverse()))}function mn(e,t){Ht(t),e=Ws(e);let r=Jt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function Ko(e,t){return mn(e,t).reverse()}function yn(e){return Uint8Array.from(e)}var pn=e=>typeof e=="bigint"&&ko<=e;function fl(e,t,r){return pn(e)&&pn(t)&&pn(r)&&t<=e&&e<r}function Ir(e,t,r,n){if(!fl(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Oo(e){let t;for(t=0;e>ko;e>>=No,t+=1);return t}var Tr=e=>(No<<BigInt(e))-No;function Js(e,t,r){if(Ht(e,"hashLen"),Ht(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=B=>new Uint8Array(B),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),l=n(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},x=(...B)=>r(l,bt(c,...B)),v=(B=o)=>{l=x(i,B),c=x(),B.length!==0&&(l=x(s,B),c=x())},b=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let B=0,w=[];for(;B<t;){c=x();let T=c.slice();w.push(T),B+=c.length}return bt(...w)};return(B,w)=>{f(),v(B);let T;for(;!(T=w(b()));)v();return f(),T}}function fe(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(i,s,a){let c=e[i];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${l}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}function Ye(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var yt=BigInt(0),at=BigInt(1),Be=BigInt(2),ea=BigInt(3),ra=BigInt(4),na=BigInt(5),ll=BigInt(7),oa=BigInt(8),dl=BigInt(9),ia=BigInt(16);function nt(e,t){let r=e%t;return r>=yt?r:t+r}function W(e,t,r){let n=e;for(;t-- >yt;)n*=n,n%=r;return n}function Qs(e,t){if(e===yt)throw new Error("invert: expected non-zero number");if(t<=yt)throw new Error("invert: expected positive modulus, got "+t);let r=nt(e,t),n=t,o=yt,i=at,s=at,a=yt;for(;r!==yt;){let l=n/r,u=n%r,f=o-s*l,x=i-a*l;n=r,r=u,o=s,i=a,s=f,a=x}if(n!==at)throw new Error("invert: does not exist");return nt(o,t)}function Mo(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function sa(e,t){let r=(e.ORDER+at)/ra,n=e.pow(t,r);return Mo(e,n,t),n}function hl(e,t){let r=(e.ORDER-na)/oa,n=e.mul(t,Be),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Be),o),a=e.mul(i,e.sub(s,e.ONE));return Mo(e,a,t),a}function pl(e){let t=We(e),r=aa(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+ll)/ia;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,n),f=a.mul(l,o),x=a.mul(l,i),v=a.eql(a.sqr(u),c),b=a.eql(a.sqr(f),c);l=a.cmov(l,u,v),u=a.cmov(x,f,b);let A=a.eql(a.sqr(u),c),B=a.cmov(l,u,A);return Mo(a,B,c),B}}function aa(e){if(e<ea)throw new Error("sqrt is not defined for small field");let t=e-at,r=0;for(;t%Be===yt;)t/=Be,r++;let n=Be,o=We(e);for(;ta(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return sa;let i=o.pow(n,t),s=(t+at)/Be;return function(c,l){if(c.is0(l))return l;if(ta(c,l)!==1)throw new Error("Cannot find square root");let u=r,f=c.mul(c.ONE,i),x=c.pow(l,t),v=c.pow(l,s);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let b=1,A=c.sqr(x);for(;!c.eql(A,c.ONE);)if(b++,A=c.sqr(A),b===u)throw new Error("Cannot find square root");let B=at<<BigInt(u-b-1),w=c.pow(f,B);u=b,f=c.sqr(w),x=c.mul(x,f),v=c.mul(v,w)}return v}}function ml(e){return e%ra===ea?sa:e%oa===na?hl:e%ia===dl?pl(e):aa(e)}var ca=(e,t)=>(nt(e,t)&at)===at,yl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Fo(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=yl.reduce((n,o)=>(n[o]="function",n),t);return fe(e,r),e}function gl(e,t,r){if(r<yt)throw new Error("invalid exponent, negatives unsupported");if(r===yt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>yt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function _r(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function ta(e,t){let r=(e.ORDER-at)/Be,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function bl(e,t){t!==void 0&&Ht(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var Po=class{ORDER;BITS;BYTES;isLE;ZERO=yt;ONE=at;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=yt)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=bl(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return nt(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return yt<=t&&t<this.ORDER}is0(t){return t===yt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&at)===at}neg(t){return nt(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return nt(t*t,this.ORDER)}add(t,r){return nt(t+r,this.ORDER)}sub(t,r){return nt(t-r,this.ORDER)}mul(t,r){return nt(t*r,this.ORDER)}pow(t,r){return gl(this,t,r)}div(t,r){return nt(t*Qs(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Qs(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=ml(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?Ko(t,this.BYTES):mn(t,this.BYTES)}fromBytes(t,r=!1){H(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(o);l.set(t,i?0:l.length-t.length),t=l}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?Ae(t):Ge(t);if(a&&(c=nt(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return _r(this,t)}cmov(t,r,n){return n?r:t}};function We(e,t={}){return new Po(e,t)}function ua(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Vo(e){let t=ua(e);return t+Math.ceil(t/2)}function qo(e,t,r=!1){H(e);let n=e.length,o=ua(t),i=Vo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ae(e):Ge(e),a=nt(s,t-at)+at;return r?Ko(a,o):mn(a,o)}var Xe=BigInt(0),Ie=BigInt(1);function Cr(e,t){let r=t.negate();return e?r:t}function Te(e,t){let r=_r(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function ha(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ho(e,t){ha(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Tr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function fa(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Ie);let l=t*n,u=l+Math.abs(a)-1,f=a===0,x=a<0,v=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:x,isNegF:v,offsetF:l}}var $o=new WeakMap,pa=new WeakMap;function zo(e){return pa.get(e)||1}function la(e){if(e!==Xe)throw new Error("invalid wNAF")}var Je=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Xe;)r&Ie&&(n=n.add(o)),o=o.double(),r>>=Ie;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Ho(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let l=1;l<o;l++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Ho(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:l,isZero:u,isNeg:f,isNegF:x,offsetF:v}=fa(n,a,s);n=c,u?i=i.add(Cr(x,r[v])):o=o.add(Cr(f,r[l]))}return la(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=Ho(t,this.bits);for(let s=0;s<i.windows&&n!==Xe;s++){let{nextN:a,offset:c,isZero:l,isNeg:u}=fa(n,s,i);if(n=a,!l){let f=r[c];o=o.add(u?f.negate():f)}}return la(n),o}getPrecomputes(t,r,n){let o=$o.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),$o.set(r,o))),o}cached(t,r,n){let o=zo(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=zo(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){ha(r,this.bits),pa.set(t,r),$o.delete(t)}hasCache(t){return zo(t)!==1}};function ma(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>Xe||n>Xe;)r&Ie&&(i=i.add(o)),n&Ie&&(s=s.add(o)),o=o.double(),r>>=Ie,n>>=Ie;return{p1:i,p2:s}}function da(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Fo(t),t}else return We(e,{isLE:r})}function gn(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l=="bigint"&&l>Xe))throw new Error(`CURVE.${c} must be positive bigint`)}let o=da(t.p,r.Fp,n),i=da(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function bn(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var le=BigInt(0),ct=BigInt(1),Zo=BigInt(2),xl=BigInt(8);function wl(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function ya(e,t={}){let r=gn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;fe(t,{},{uvRatio:"function"});let a=Zo<<BigInt(o.BYTES*8)-ct,c=B=>n.create(B),l=t.uvRatio||((B,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(B,w))}}catch{return{isValid:!1,value:le}}});if(!wl(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(B,w,T=!1){let E=T?ct:le;return Ir("coordinate "+B,w,E,a),w}function f(B){if(!(B instanceof b))throw new Error("EdwardsPoint expected")}let x=Ye((B,w)=>{let{X:T,Y:E,Z:U}=B,K=B.is0();w==null&&(w=K?xl:n.inv(U));let P=c(T*w),F=c(E*w),p=n.mul(U,w);if(K)return{x:le,y:ct};if(p!==ct)throw new Error("invZ was invalid");return{x:P,y:F}}),v=Ye(B=>{let{a:w,d:T}=i;if(B.is0())throw new Error("bad point: ZERO");let{X:E,Y:U,Z:K,T:P}=B,F=c(E*E),p=c(U*U),m=c(K*K),C=c(m*m),R=c(F*w),I=c(m*c(R+p)),y=c(C+c(T*c(F*p)));if(I!==y)throw new Error("bad point: equation left != right (1)");let g=c(E*U),d=c(K*P);if(g!==d)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,ct,c(i.Gx*i.Gy));static ZERO=new b(le,ct,ct,le);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,T,E,U){this.X=u("x",w),this.Y=u("y",T),this.Z=u("z",E,!0),this.T=u("t",U),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof b)throw new Error("extended point not allowed");let{x:T,y:E}=w||{};return u("x",T),u("y",E),new b(T,E,ct,c(T*E))}static fromBytes(w,T=!1){let E=n.BYTES,{a:U,d:K}=i;w=yn(H(w,E,"point")),te(T,"zip215");let P=yn(w),F=w[E-1];P[E-1]=F&-129;let p=Ae(P),m=T?a:n.ORDER;Ir("point.y",p,le,m);let C=c(p*p),R=c(C-ct),I=c(K*C-U),{isValid:y,value:g}=l(R,I);if(!y)throw new Error("bad point: invalid y coordinate");let d=(g&ct)===ct,S=(F&128)!==0;if(!T&&g===le&&S)throw new Error("bad point: x=0 and x_0=1");return S!==d&&(g=c(-g)),b.fromAffine({x:g,y:p})}static fromHex(w,T=!1){return b.fromBytes(Jt(w),T)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,T=!0){return A.createCache(this,w),T||this.multiply(Zo),this}assertValidity(){v(this)}equals(w){f(w);let{X:T,Y:E,Z:U}=this,{X:K,Y:P,Z:F}=w,p=c(T*F),m=c(K*U),C=c(E*F),R=c(P*U);return p===m&&C===R}is0(){return this.equals(b.ZERO)}negate(){return new b(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:w}=i,{X:T,Y:E,Z:U}=this,K=c(T*T),P=c(E*E),F=c(Zo*c(U*U)),p=c(w*K),m=T+E,C=c(c(m*m)-K-P),R=p+P,I=R-F,y=p-P,g=c(C*I),d=c(R*y),S=c(C*y),D=c(I*R);return new b(g,d,D,S)}add(w){f(w);let{a:T,d:E}=i,{X:U,Y:K,Z:P,T:F}=this,{X:p,Y:m,Z:C,T:R}=w,I=c(U*p),y=c(K*m),g=c(F*E*R),d=c(P*C),S=c((U+K)*(p+m)-I-y),D=d-g,N=d+g,k=c(y-T*I),O=c(S*D),M=c(N*k),q=c(S*k),X=c(D*N);return new b(O,M,X,q)}subtract(w){return this.add(w.negate())}multiply(w){if(!o.isValidNot0(w))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:T,f:E}=A.cached(this,w,U=>Te(b,U));return Te(b,[T,E])[0]}multiplyUnsafe(w,T=b.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===le?b.ZERO:this.is0()||w===ct?this:A.unsafe(this,w,E=>Te(b,E),T)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return A.unsafe(this,i.n).is0()}toAffine(w){return x(this,w)}clearCofactor(){return s===ct?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:T}=this.toAffine(),E=n.toBytes(T);return E[E.length-1]|=w&ct?128:0,E}toHex(){return Xt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let A=new Je(b,o.BITS);return b.BASE.precompute(8),b}function ga(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');fe(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=e,a=r.randomBytes||Ze,c=r.adjustScalarBytes||(p=>p),l=r.domain||((p,m,C)=>{if(te(C,"phflag"),m.length||C)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return s.create(Ae(p))}function f(p){let m=E.secretKey;H(p,E.secretKey,"secretKey");let C=H(t(p),2*m,"hashedSecretKey"),R=c(C.slice(0,m)),I=C.slice(m,2*m),y=u(R);return{head:R,prefix:I,scalar:y}}function x(p){let{head:m,prefix:C,scalar:R}=f(p),I=o.multiply(R),y=I.toBytes();return{head:m,prefix:C,scalar:R,point:I,pointBytes:y}}function v(p){return x(p).pointBytes}function b(p=Uint8Array.of(),...m){let C=bt(...m);return u(t(l(C,H(p,void 0,"context"),!!n)))}function A(p,m,C={}){p=H(p,void 0,"message"),n&&(p=n(p));let{prefix:R,scalar:I,pointBytes:y}=x(m),g=b(C.context,R,p),d=o.multiply(g).toBytes(),S=b(C.context,d,y,p),D=s.create(g+S*I);if(!s.isValid(D))throw new Error("sign failed: invalid s");let N=bt(d,s.toBytes(D));return H(N,E.signature,"result")}let B={zip215:!0};function w(p,m,C,R=B){let{context:I,zip215:y}=R,g=E.signature;p=H(p,g,"signature"),m=H(m,void 0,"message"),C=H(C,E.publicKey,"publicKey"),y!==void 0&&te(y,"zip215"),n&&(m=n(m));let d=g/2,S=p.subarray(0,d),D=Ae(p.subarray(d,g)),N,k,O;try{N=e.fromBytes(C,y),k=e.fromBytes(S,y),O=o.multiplyUnsafe(D)}catch{return!1}if(!y&&N.isSmallOrder())return!1;let M=b(I,k.toBytes(),N.toBytes(),m);return k.add(N.multiplyUnsafe(M)).subtract(O).clearCofactor().is0()}let T=i.BYTES,E={secretKey:T,publicKey:T,signature:2*T,seed:T};function U(p=a(E.seed)){return H(p,E.seed,"seed")}function K(p){return Ee(p)&&p.length===s.BYTES}function P(p,m){try{return!!e.fromBytes(p,m)}catch{return!1}}let F={getExtendedPublicKey:x,randomSecretKey:U,isValidSecretKey:K,isValidPublicKey:P,toMontgomery(p){let{y:m}=e.fromBytes(p),C=E.publicKey,R=C===32;if(!R&&C!==57)throw new Error("only defined for 25519 and 448");let I=R?i.div(ct+m,ct-m):i.div(m-ct,m+ct);return i.toBytes(I)},toMontgomerySecret(p){let m=E.secretKey;H(p,m);let C=t(p.subarray(0,m));return c(C).subarray(0,m)}};return Object.freeze({keygen:bn(U,v),getPublicKey:v,sign:A,verify:w,utils:F,Point:e,lengths:E})}var El=BigInt(1),ba=BigInt(2);var Sl=BigInt(5),vl=BigInt(8),jo=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Al={p:jo,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:vl,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Bl(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=jo,a=e*e%i*e%i,c=W(a,ba,i)*a%i,l=W(c,El,i)*e%i,u=W(l,Sl,i)*l%i,f=W(u,t,i)*u%i,x=W(f,r,i)*f%i,v=W(x,n,i)*x%i,b=W(v,o,i)*v%i,A=W(b,o,i)*v%i,B=W(A,t,i)*u%i;return{pow_p_5_8:W(B,ba,i)*e%i,b2:a}}function Il(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var xa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Tl(e,t){let r=jo,n=nt(t*t*t,r),o=nt(n*n*t,r),i=Bl(e*o).pow_p_5_8,s=nt(e*n*i,r),a=nt(t*s*s,r),c=s,l=nt(s*xa,r),u=a===e,f=a===nt(-e,r),x=a===nt(-e*xa,r);return u&&(s=c),(f||x)&&(s=l),ca(s,r)&&(s=nt(-s,r)),{isValid:u||f,value:s}}var _l=ya(Al,{uvRatio:Tl});function Cl(e){return ga(_l,Ys,Object.assign({adjustScalarBytes:Il},e))}var Ur=Cl({});var Rr=class extends Error{constructor(t="An error occurred while signing a message"){super(t),this.name="SigningError"}},Dr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},xn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var wa={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new xn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var xt=wa;var _e=32,At=64,Go=32;var Qe,Ea=(async()=>{try{return await xt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function Sa(){let e=Ur.utils.randomSecretKey(),t=Ur.getPublicKey(e);return{privateKey:Nl(e,t),publicKey:t}}async function Ul(e,t){let r;e.length===At?r=e.subarray(0,32):r=e;let n={crv:"Ed25519",kty:"OKP",x:j(e.subarray(32),"base64url"),d:j(r,"base64url"),ext:!0,key_ops:["sign"]},o=await xt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await xt.get().subtle.sign({name:"Ed25519"},o,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(i,0,i.byteLength)}function Rl(e,t){let r=e.subarray(0,Go);return Ur.sign(t instanceof Uint8Array?t:t.subarray(),r)}async function va(e,t){return Qe==null&&(Qe=await Ea),Qe?Ul(e,t):Rl(e,t)}async function Dl(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await xt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await xt.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Ll(e,t,r){return Ur.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Aa(e,t,r){return Qe==null&&(Qe=await Ea),Qe?Dl(e,t,r):Ll(e,t,r)}function Nl(e,t){let r=new Uint8Array(At);for(let n=0;n<Go;n++)r[n]=e[n],r[Go+n]=t[n];return r}function tr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Lr=class{type="Ed25519";raw;constructor(t){this.raw=rr(t,_e)}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Aa(this.raw,r,t);return tr(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},er=class{type="Ed25519";raw;publicKey;constructor(t,r){this.raw=rr(t,At),this.publicKey=new Lr(r)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){r?.signal?.throwIfAborted();let n=va(this.raw,t);return tr(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function Yo(e){if(e.length>At){e=rr(e,At+_e);let n=e.subarray(0,At),o=e.subarray(At,e.length);return new er(n,o)}e=rr(e,At);let t=e.subarray(0,At),r=e.subarray(_e);return new er(t,r)}function Ia(e){return e=rr(e,_e),new Lr(e)}async function Ta(){let{privateKey:e,publicKey:t}=Sa();return new er(e,t)}function rr(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new rt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var kl=Math.pow(2,7),Kl=Math.pow(2,14),Ol=Math.pow(2,21),_a=Math.pow(2,28),Ca=Math.pow(2,35),Ua=Math.pow(2,42),Ra=Math.pow(2,49),gt=128,de=127;function Nr(e){if(e<kl)return 1;if(e<Kl)return 2;if(e<Ol)return 3;if(e<_a)return 4;if(e<Ca)return 5;if(e<Ua)return 6;if(e<Ra)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Da(e,t,r=0){switch(Nr(e)){case 8:t[r++]=e&255|gt,e/=128;case 7:t[r++]=e&255|gt,e/=128;case 6:t[r++]=e&255|gt,e/=128;case 5:t[r++]=e&255|gt,e/=128;case 4:t[r++]=e&255|gt,e>>>=7;case 3:t[r++]=e&255|gt,e>>>=7;case 2:t[r++]=e&255|gt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function La(e,t){let r=e[t],n=0;if(n+=r&de,r<gt||(r=e[t+1],n+=(r&de)<<7,r<gt)||(r=e[t+2],n+=(r&de)<<14,r<gt)||(r=e[t+3],n+=(r&de)<<21,r<gt)||(r=e[t+4],n+=(r&de)*_a,r<gt)||(r=e[t+5],n+=(r&de)*Ca,r<gt)||(r=e[t+6],n+=(r&de)*Ua,r<gt)||(r=e[t+7],n+=(r&de)*Ra,r<gt))return n;throw new RangeError("Could not decode varint")}var Wo=new Float32Array([-0]),he=new Uint8Array(Wo.buffer);function Na(e,t,r){Wo[0]=e,t[r]=he[0],t[r+1]=he[1],t[r+2]=he[2],t[r+3]=he[3]}function ka(e,t){return he[0]=e[t],he[1]=e[t+1],he[2]=e[t+2],he[3]=e[t+3],Wo[0]}var Xo=new Float64Array([-0]),ht=new Uint8Array(Xo.buffer);function Ka(e,t,r){Xo[0]=e,t[r]=ht[0],t[r+1]=ht[1],t[r+2]=ht[2],t[r+3]=ht[3],t[r+4]=ht[4],t[r+5]=ht[5],t[r+6]=ht[6],t[r+7]=ht[7]}function Oa(e,t){return ht[0]=e[t],ht[1]=e[t+1],ht[2]=e[t+2],ht[3]=e[t+3],ht[4]=e[t+4],ht[5]=e[t+5],ht[6]=e[t+6],ht[7]=e[t+7],Xo[0]}var Pl=BigInt(Number.MAX_SAFE_INTEGER),Ml=BigInt(Number.MIN_SAFE_INTEGER),Bt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ce;if(t<Pl&&t>Ml)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Pa&&(o=0n,++n>Pa&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ce;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Ce}},Ce=new Bt(0,0);Ce.toBigInt=function(){return 0n};Ce.zzEncode=Ce.zzDecode=function(){return this};Ce.length=function(){return 1};var Pa=4294967296n;function Ma(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Fa(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Jo(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Kt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function wn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Qo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Kt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Kt(this,4);return wn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Kt(this,4);return wn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Kt(this,4);let t=ka(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Kt(this,4);let t=Oa(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Kt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Fa(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Kt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Kt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Bt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Kt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Kt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Kt(this,8);let t=wn(this.buf,this.pos+=4),r=wn(this.buf,this.pos+=4);return new Bt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=La(this.buf,this.pos);return this.pos+=Nr(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ti(e){return new Qo(e instanceof Uint8Array?e:e.subarray())}function nr(e,t,r){let n=ti(e);return t.decode(n,void 0,r)}function ei(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return vt(s);o+s>t&&(n=vt(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var Ue=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ri(){}var oi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Fl=ei();function Vl(e){return globalThis.Buffer!=null?vt(e):Fl(e)}var Kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ue(ri,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Ue(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ii((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(En,10,Bt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Bt.fromBigInt(t);return this._push(En,r.length(),r)}uint64Number(t){return this._push(Da,Nr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=Bt.fromBigInt(t).zzEncode();return this._push(En,r.length(),r)}sint64Number(t){let r=Bt.fromNumber(t).zzEncode();return this._push(En,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ni,1,t?1:0)}fixed32(t){return this._push(kr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Bt.fromBigInt(t);return this._push(kr,4,r.lo)._push(kr,4,r.hi)}fixed64Number(t){let r=Bt.fromNumber(t);return this._push(kr,4,r.lo)._push(kr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Na,4,t)}double(t){return this._push(Ka,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ni,1,0):this.uint32(r)._push(Hl,r,t)}string(t){let r=Ma(t);return r!==0?this.uint32(r)._push(Jo,r,t):this._push(ni,1,0)}fork(){return this.states=new oi(this),this.head=this.tail=new Ue(ri,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Ue(ri,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Vl(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ni(e,t,r){t[r]=e&255}function ql(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var ii=class extends Ue{next;constructor(t,r){super(ql,t,r),this.next=void 0}};function En(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function kr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Hl(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Kr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push($l,t,e),this},Kr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(zl,t,e),this});function $l(e,t,r){t.set(e,r)}function zl(e,t,r){e.length<40?Jo(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Z(e),r)}function si(){return new Kr}function or(e,t){let r=si();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ir;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(ir||(ir={}));function Sn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Or(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Sn("enum",ir.VARINT,r,n)}function sr(e,t){return Sn("message",ir.LENGTH_DELIMITED,e,t)}var et;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(et||(et={}));var ai;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(ai||(ai={}));(function(e){e.codec=()=>Or(ai)})(et||(et={}));var ee;(function(e){let t;e.codec=()=>(t==null&&(t=sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>or(r,e.codec()),e.decode=(r,n)=>nr(r,e.codec(),n)})(ee||(ee={}));var vn;(function(e){let t;e.codec=()=>(t==null&&(t=sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>or(r,e.codec()),e.decode=(r,n)=>nr(r,e.codec(),n)})(vn||(vn={}));var Mr={};St(Mr,{MAX_RSA_KEY_SIZE:()=>ci,generateRSAKeyPair:()=>gi,jwkToJWKKeyPair:()=>za,jwkToPkcs1:()=>Yl,jwkToPkix:()=>di,jwkToRSAPrivateKey:()=>yi,pkcs1MessageToJwk:()=>fi,pkcs1MessageToRSAPrivateKey:()=>An,pkcs1ToJwk:()=>Gl,pkcs1ToRSAPrivateKey:()=>hi,pkixMessageToJwk:()=>li,pkixMessageToRSAPublicKey:()=>mi,pkixToJwk:()=>Wl,pkixToRSAPublicKey:()=>pi});var ar=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return it.createV1(114,this._multihash)}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){return $a(this.jwk,r,t,n)}},Pr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){return Ha(this.jwk,t,r)}};var ci=8192,ui=18,Zl=1062,jl=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Gl(e){let t=Ut(e);return fi(t)}function fi(e){return{n:j(e[1],"base64url"),e:j(e[2],"base64url"),d:j(e[3],"base64url"),p:j(e[4],"base64url"),q:j(e[5],"base64url"),dp:j(e[6],"base64url"),dq:j(e[7],"base64url"),qi:j(e[8],"base64url"),kty:"RSA"}}function Yl(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new rt("JWK was missing components");return Nt([mt(Uint8Array.from([0])),mt(Z(e.n,"base64url")),mt(Z(e.e,"base64url")),mt(Z(e.d,"base64url")),mt(Z(e.p,"base64url")),mt(Z(e.q,"base64url")),mt(Z(e.dp,"base64url")),mt(Z(e.dq,"base64url")),mt(Z(e.qi,"base64url"))]).subarray()}function Wl(e){let t=Ut(e,{offset:0});return li(t)}function li(e){let t=Ut(e[1],{offset:0});return{kty:"RSA",n:j(t[0],"base64url"),e:j(t[1],"base64url")}}function di(e){if(e.n==null||e.e==null)throw new rt("JWK was missing components");return Nt([jl,Er(Nt([mt(Z(e.n,"base64url")),mt(Z(e.e,"base64url"))]))]).subarray()}function hi(e){let t=Ut(e);return An(t)}function An(e){let t=fi(e);return yi(t)}function pi(e,t){if(e.byteLength>=Zl)throw new ke("Key size is too large");let r=Ut(e,{offset:0});return mi(r,e,t)}function mi(e,t,r){let n=li(e);if(r==null){let o=je(ee.encode({Type:et.RSA,Data:t}));r=qt(ui,o)}return new ar(n,r)}function yi(e){if(ja(e)>ci)throw new rt("Key size is too large");let t=za(e),r=je(ee.encode({Type:et.RSA,Data:di(t.publicKey)})),n=qt(ui,r);return new Pr(t.privateKey,new ar(t.publicKey,n))}async function gi(e){if(e>ci)throw new rt("Key size is too large");let t=await Za(e),r=je(ee.encode({Type:et.RSA,Data:di(t.publicKey)})),n=qt(ui,r);return new Pr(t.privateKey,new ar(t.publicKey,n))}function za(e){if(e==null)throw new rt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Za(e,t){let r=await xt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await Xl(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Ha(e,t,r){let n=await xt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await xt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function $a(e,t,r,n){let o=await xt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await xt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Xl(e,t){if(e.privateKey==null||e.publicKey==null)throw new rt("Private and public key are required");let r=await Promise.all([xt.get().subtle.exportKey("jwk",e.privateKey),xt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function ja(e){if(e.kty!=="RSA")throw new rt("invalid key type");if(e.n==null)throw new rt("invalid key modulus");return Z(e.n,"base64url").length*8}var Bn=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(ln(t),H(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Wt(o)}update(t){return ze(this),this.iHash.update(t),this}digestInto(t){ze(this),H(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},bi=(e,t,r)=>new Bn(e,t).update(r).digest();bi.create=(e,t)=>new Bn(e,t);var Ga=(e,t)=>(e+(e>=0?t:-t)/Ya)/t;function Jl(e,t,r){let[[n,o],[i,s]]=t,a=Ga(s*e,r),c=Ga(-o*e,r),l=e-a*n-c*i,u=-a*o-c*s,f=l<re,x=u<re;f&&(l=-l),x&&(u=-u);let v=Tr(Math.ceil(Oo(r)/2))+cr;if(l<re||l>=v||u<re||u>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:l,k2neg:x,k2:u}}function wi(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function xi(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return te(r.lowS,"lowS"),te(r.prehash,"prehash"),r.format!==void 0&&wi(r.format),r}var Ei=class extends Error{constructor(t=""){super(t)}},pe={Err:Ei,_tlv:{encode:(e,t)=>{let{Err:r}=pe;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Br(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Br(o.length/2|128):"";return Br(e)+i+o+t},decode(e,t){let{Err:r}=pe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=pe;if(e<re)throw new t("integer: negative integers are not allowed");let r=Br(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=pe;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ge(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=pe,o=H(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=pe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},re=BigInt(0),cr=BigInt(1),Ya=BigInt(2),In=BigInt(3),Ql=BigInt(4);function Wa(e,t={}){let r=gn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;fe(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=Ja(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(I,y,g){let{x:d,y:S}=y.toAffine(),D=n.toBytes(d);if(te(g,"isCompressed"),g){u();let N=!n.isOdd(S);return bt(Xa(N),D)}else return bt(Uint8Array.of(4),D,n.toBytes(S))}function x(I){H(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:g}=l,d=I.length,S=I[0],D=I.subarray(1);if(d===y&&(S===2||S===3)){let N=n.fromBytes(D);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let k=A(N),O;try{O=n.sqrt(k)}catch(X){let Y=X instanceof Error?": "+X.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}u();let M=n.isOdd(O);return(S&1)===1!==M&&(O=n.neg(O)),{x:N,y:O}}else if(d===g&&S===4){let N=n.BYTES,k=n.fromBytes(D.subarray(0,N)),O=n.fromBytes(D.subarray(N,N*2));if(!B(k,O))throw new Error("bad point: is not on curve");return{x:k,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${g}`)}let v=t.toBytes||f,b=t.fromBytes||x;function A(I){let y=n.sqr(I),g=n.mul(y,I);return n.add(n.add(g,n.mul(I,i.a)),i.b)}function B(I,y){let g=n.sqr(y),d=A(I);return n.eql(g,d)}if(!B(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,In),Ql),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,T)))throw new Error("bad curve params: a or b");function E(I,y,g=!1){if(!n.isValid(y)||g&&n.is0(y))throw new Error(`bad point coordinate ${I}`);return y}function U(I){if(!(I instanceof m))throw new Error("Weierstrass Point expected")}function K(I){if(!c||!c.basises)throw new Error("no endo");return Jl(I,c.basises,o.ORDER)}let P=Ye((I,y)=>{let{X:g,Y:d,Z:S}=I;if(n.eql(S,n.ONE))return{x:g,y:d};let D=I.is0();y==null&&(y=D?n.ONE:n.inv(S));let N=n.mul(g,y),k=n.mul(d,y),O=n.mul(S,y);if(D)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:N,y:k}}),F=Ye(I=>{if(I.is0()){if(t.allowInfinityPoint&&!n.is0(I.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:g}=I.toAffine();if(!n.isValid(y)||!n.isValid(g))throw new Error("bad point: x or y not field elements");if(!B(y,g))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function p(I,y,g,d,S){return g=new m(n.mul(g.X,I),g.Y,g.Z),y=Cr(d,y),g=Cr(S,g),y.add(g)}class m{static BASE=new m(i.Gx,i.Gy,n.ONE);static ZERO=new m(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(y,g,d){this.X=E("x",y),this.Y=E("y",g,!0),this.Z=E("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(y){let{x:g,y:d}=y||{};if(!y||!n.isValid(g)||!n.isValid(d))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");return n.is0(g)&&n.is0(d)?m.ZERO:new m(g,d,n.ONE)}static fromBytes(y){let g=m.fromAffine(b(H(y,void 0,"point")));return g.assertValidity(),g}static fromHex(y){return m.fromBytes(Jt(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,g=!0){return R.createCache(this,y),g||this.multiply(In),this}assertValidity(){F(this)}hasEvenY(){let{y}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(y)}equals(y){U(y);let{X:g,Y:d,Z:S}=this,{X:D,Y:N,Z:k}=y,O=n.eql(n.mul(g,k),n.mul(D,S)),M=n.eql(n.mul(d,k),n.mul(N,S));return O&&M}negate(){return new m(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b:g}=i,d=n.mul(g,In),{X:S,Y:D,Z:N}=this,k=n.ZERO,O=n.ZERO,M=n.ZERO,q=n.mul(S,S),X=n.mul(D,D),Y=n.mul(N,N),$=n.mul(S,D);return $=n.add($,$),M=n.mul(S,N),M=n.add(M,M),k=n.mul(y,M),O=n.mul(d,Y),O=n.add(k,O),k=n.sub(X,O),O=n.add(X,O),O=n.mul(k,O),k=n.mul($,k),M=n.mul(d,M),Y=n.mul(y,Y),$=n.sub(q,Y),$=n.mul(y,$),$=n.add($,M),M=n.add(q,q),q=n.add(M,q),q=n.add(q,Y),q=n.mul(q,$),O=n.add(O,q),Y=n.mul(D,N),Y=n.add(Y,Y),q=n.mul(Y,$),k=n.sub(k,q),M=n.mul(Y,X),M=n.add(M,M),M=n.add(M,M),new m(k,O,M)}add(y){U(y);let{X:g,Y:d,Z:S}=this,{X:D,Y:N,Z:k}=y,O=n.ZERO,M=n.ZERO,q=n.ZERO,X=i.a,Y=n.mul(i.b,In),$=n.mul(g,D),J=n.mul(d,N),ft=n.mul(S,k),Vt=n.add(g,d),Q=n.add(D,N);Vt=n.mul(Vt,Q),Q=n.add($,J),Vt=n.sub(Vt,Q),Q=n.add(g,S);let dt=n.add(D,k);return Q=n.mul(Q,dt),dt=n.add($,ft),Q=n.sub(Q,dt),dt=n.add(d,S),O=n.add(N,k),dt=n.mul(dt,O),O=n.add(J,ft),dt=n.sub(dt,O),q=n.mul(X,Q),O=n.mul(Y,ft),q=n.add(O,q),O=n.sub(J,q),q=n.add(J,q),M=n.mul(O,q),J=n.add($,$),J=n.add(J,$),ft=n.mul(X,ft),Q=n.mul(Y,Q),J=n.add(J,ft),ft=n.sub($,ft),ft=n.mul(X,ft),Q=n.add(Q,ft),$=n.mul(J,Q),M=n.add(M,$),$=n.mul(dt,Q),O=n.mul(Vt,O),O=n.sub(O,$),$=n.mul(Vt,J),q=n.mul(dt,q),q=n.add(q,$),new m(O,M,q)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}multiply(y){let{endo:g}=t;if(!o.isValidNot0(y))throw new Error("invalid scalar: out of range");let d,S,D=N=>R.cached(this,N,k=>Te(m,k));if(g){let{k1neg:N,k1:k,k2neg:O,k2:M}=K(y),{p:q,f:X}=D(k),{p:Y,f:$}=D(M);S=X.add($),d=p(g.beta,q,Y,N,O)}else{let{p:N,f:k}=D(y);d=N,S=k}return Te(m,[d,S])[0]}multiplyUnsafe(y){let{endo:g}=t,d=this;if(!o.isValid(y))throw new Error("invalid scalar: out of range");if(y===re||d.is0())return m.ZERO;if(y===cr)return d;if(R.hasCache(this))return this.multiply(y);if(g){let{k1neg:S,k1:D,k2neg:N,k2:k}=K(y),{p1:O,p2:M}=ma(m,d,D,k);return p(g.beta,O,M,S,N)}else return R.unsafe(d,y)}toAffine(y){return P(this,y)}isTorsionFree(){let{isTorsionFree:y}=t;return s===cr?!0:y?y(m,this):R.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:y}=t;return s===cr?this:y?y(m,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(y=!0){return te(y,"isCompressed"),this.assertValidity(),v(m,this,y)}toHex(y=!0){return Xt(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=o.BITS,R=new Je(m,t.endo?Math.ceil(C/2):C);return m.BASE.precompute(8),m}function Xa(e){return Uint8Array.of(e?2:3)}function Ja(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function td(e,t={}){let{Fn:r}=e,n=t.randomBytes||Ze,o=Object.assign(Ja(e.Fp,r),{seed:Vo(r.ORDER)});function i(v){try{let b=r.fromBytes(v);return r.isValidNot0(b)}catch{return!1}}function s(v,b){let{publicKey:A,publicKeyUncompressed:B}=o;try{let w=v.length;return b===!0&&w!==A||b===!1&&w!==B?!1:!!e.fromBytes(v)}catch{return!1}}function a(v=n(o.seed)){return qo(H(v,o.seed,"seed"),r.ORDER)}function c(v,b=!0){return e.BASE.multiply(r.fromBytes(v)).toBytes(b)}function l(v){let{secretKey:b,publicKey:A,publicKeyUncompressed:B}=o;if(!Ee(v)||"_lengths"in r&&r._lengths||b===A)return;let w=H(v,void 0,"key").length;return w===A||w===B}function u(v,b,A=!0){if(l(v)===!0)throw new Error("first arg must be private key");if(l(b)===!1)throw new Error("second arg must be public key");let B=r.fromBytes(v);return e.fromBytes(b).multiply(B).toBytes(A)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},x=bn(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:x,Point:e,utils:f,lengths:o})}function Qa(e,t,r={}){ln(t),fe(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Ze,o=r.hmac||((g,d)=>bi(t,g,d)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:f,utils:x,lengths:v}=td(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},A=a*Ya<i.ORDER;function B(g){let d=a>>cr;return g>d}function w(g,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return d}function T(){if(A)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function E(g,d){wi(d);let S=v.signature,D=d==="compact"?S:d==="recovered"?S+1:void 0;return H(g,D)}class U{r;s;recovery;constructor(d,S,D){if(this.r=w("r",d),this.s=w("s",S),D!=null){if(T(),![0,1,2,3].includes(D))throw new Error("invalid recovery id");this.recovery=D}Object.freeze(this)}static fromBytes(d,S=b.format){E(d,S);let D;if(S==="der"){let{r:M,s:q}=pe.toSig(H(d));return new U(M,q)}S==="recovered"&&(D=d[0],S="compact",d=d.subarray(1));let N=v.signature/2,k=d.subarray(0,N),O=d.subarray(N,N*2);return new U(s.fromBytes(k),s.fromBytes(O),D)}static fromHex(d,S){return this.fromBytes(Jt(d),S)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new U(this.r,this.s,d)}recoverPublicKey(d){let{r:S,s:D}=this,N=this.assertRecovery(),k=N===2||N===3?S+a:S;if(!i.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(k),M=e.fromBytes(bt(Xa((N&1)===0),O)),q=s.inv(k),X=P(H(d,void 0,"msgHash")),Y=s.create(-X*q),$=s.create(D*q),J=e.BASE.multiplyUnsafe(Y).add(M.multiplyUnsafe($));if(J.is0())throw new Error("invalid recovery: point at infinify");return J.assertValidity(),J}hasHighS(){return B(this.s)}toBytes(d=b.format){if(wi(d),d==="der")return Jt(pe.hexFromSig(this));let{r:S,s:D}=this,N=s.toBytes(S),k=s.toBytes(D);return d==="recovered"?(T(),bt(Uint8Array.of(this.assertRecovery()),N,k)):bt(N,k)}toHex(d){return Xt(this.toBytes(d))}}let K=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let S=Ge(d),D=d.length*8-c;return D>0?S>>BigInt(D):S},P=r.bits2int_modN||function(d){return s.create(K(d))},F=Tr(c);function p(g){return Ir("num < 2^"+c,g,re,F),s.toBytes(g)}function m(g,d){return H(g,void 0,"message"),d?H(t(g),void 0,"prehashed message"):g}function C(g,d,S){let{lowS:D,prehash:N,extraEntropy:k}=xi(S,b);g=m(g,N);let O=P(g),M=s.fromBytes(d);if(!s.isValidNot0(M))throw new Error("invalid private key");let q=[p(M),p(O)];if(k!=null&&k!==!1){let J=k===!0?n(v.secretKey):k;q.push(H(J,void 0,"extraEntropy"))}let X=bt(...q),Y=O;function $(J){let ft=K(J);if(!s.isValidNot0(ft))return;let Vt=s.inv(ft),Q=e.BASE.multiply(ft).toAffine(),dt=s.create(Q.x);if(dt===re)return;let nn=s.create(Vt*s.create(Y+dt*M));if(nn===re)return;let $i=(Q.x===dt?0:2)|Number(Q.y&cr),zi=nn;return D&&B(nn)&&(zi=s.neg(nn),$i^=1),new U(dt,zi,A?void 0:$i)}return{seed:X,k2sig:$}}function R(g,d,S={}){let{seed:D,k2sig:N}=C(g,d,S);return Js(t.outputLen,s.BYTES,o)(D,N).toBytes(S.format)}function I(g,d,S,D={}){let{lowS:N,prehash:k,format:O}=xi(D,b);if(S=H(S,void 0,"publicKey"),d=m(d,k),!Ee(g)){let M=g instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+M)}E(g,O);try{let M=U.fromBytes(g,O),q=e.fromBytes(S);if(N&&M.hasHighS())return!1;let{r:X,s:Y}=M,$=P(d),J=s.inv(Y),ft=s.create($*J),Vt=s.create(X*J),Q=e.BASE.multiplyUnsafe(ft).add(q.multiplyUnsafe(Vt));return Q.is0()?!1:s.create(Q.x)===X}catch{return!1}}function y(g,d,S={}){let{prehash:D}=xi(S,b);return d=m(d,D),U.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:f,utils:x,lengths:v,Point:e,sign:R,verify:I,recoverPublicKey:y,Signature:U,hash:t})}var vi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ed={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var tc=BigInt(2);function rd(e){let t=vi.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=W(u,r,t)*u%t,x=W(f,r,t)*u%t,v=W(x,tc,t)*l%t,b=W(v,o,t)*v%t,A=W(b,i,t)*b%t,B=W(A,a,t)*A%t,w=W(B,c,t)*B%t,T=W(w,a,t)*A%t,E=W(T,r,t)*u%t,U=W(E,s,t)*b%t,K=W(U,n,t)*l%t,P=W(K,tc,t);if(!Si.eql(Si.sqr(P),e))throw new Error("Cannot find square root");return P}var Si=We(vi.p,{sqrt:rd}),nd=Wa(vi,{Fp:Si,endo:ed}),Ot=Qa(nd,je);var ec=32;function rc(e,t,r){let n=cn.digest(t instanceof Uint8Array?t:t.subarray());if(tr(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),Ot.sign(o,e,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Rr(String(o))});try{return Ot.sign(n.digest,e,{prehash:!1,format:"der"})}catch(o){throw new Rr(String(o))}}function nc(e,t,r,n){let o=cn.digest(r instanceof Uint8Array?r:r.subarray());if(tr(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Ot.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Dr(String(i))});try{return n?.signal?.throwIfAborted(),Ot.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new Dr(String(i))}}var Fr=class{type="secp256k1";raw;_key;constructor(t){this._key=sc(t),this.raw=oc(this._key)}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){return nc(this._key,r,t,n)}},Vr=class{type="secp256k1";raw;publicKey;constructor(t,r){this.raw=ic(t),this.publicKey=new Fr(r??ac(t))}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){return rc(this.raw,t,r)}};function Ai(e){return new Vr(e)}function cc(e){return new Fr(e)}async function uc(){let e=od();return new Vr(e)}function oc(e){return Ot.Point.fromBytes(e).toBytes()}function ic(e){try{return Ot.getPublicKey(e,!0),e}catch(t){throw new mr(String(t))}}function sc(e){try{return Ot.Point.fromBytes(e),e}catch(t){throw new ke(String(t))}}function ac(e){try{return Ot.getPublicKey(e,!0)}catch(t){throw new mr(String(t))}}function od(){return Ot.utils.randomSecretKey()}async function fc(e,t){if(e==="Ed25519")return Ta();if(e==="secp256k1")return uc();if(e==="RSA")return gi(id(t));if(e==="ECDSA")return Ns(sd(t));throw new Ke}function Bi(e,t){let{Type:r,Data:n}=ee.decode(e),o=n??new Uint8Array;switch(r){case et.RSA:return pi(o,t);case et.Ed25519:return Ia(o);case et.secp256k1:return cc(o);case et.ECDSA:return Cs(o);default:throw new Ke}}function se(e){return ee.encode({Type:et[e.type],Data:e.raw})}function lc(e){let t=vn.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case et.RSA:return hi(r);case et.Ed25519:return Yo(r);case et.secp256k1:return Ai(r);case et.ECDSA:return _s(r);default:throw new Ke}}function dc(e){if(e.byteLength===At)return Yo(e);if(e.byteLength===ec)return Ai(e);let t=Ut(e),r=t[2]?.[0];if(r===xs||r===ws||r===Es)return Bo(t);if(t.length>8)return An(t);throw new rt("Could not extract private key from raw bytes")}function id(e){return e==null?2048:parseInt(e,10)}function sd(e){if(e==="P-256"||e==null)return"P-256";if(e==="P-384")return"P-384";if(e==="P-521")return"P-521";throw new rt("Unsupported curve, should be P-256, P-384 or P-521")}function ad(e,t){if(typeof e=="string")return cd(e);if(typeof e=="number")return ld(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var Tn=ad;function cd(e){if(typeof e!="string"||e.length===0||e.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(e)}`);let t=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(e);if(!t?.groups)return NaN;let{value:r,unit:n="ms"}=t.groups,o=parseFloat(r),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(e)}`)}}function ud(e){let t=Math.abs(e);return t>=315576e5?`${Math.round(e/315576e5)}y`:t>=26298e5?`${Math.round(e/26298e5)}mo`:t>=6048e5?`${Math.round(e/6048e5)}w`:t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function fd(e){let t=Math.abs(e);return t>=315576e5?Re(e,t,315576e5,"year"):t>=26298e5?Re(e,t,26298e5,"month"):t>=6048e5?Re(e,t,6048e5,"week"):t>=864e5?Re(e,t,864e5,"day"):t>=36e5?Re(e,t,36e5,"hour"):t>=6e4?Re(e,t,6e4,"minute"):t>=1e3?Re(e,t,1e3,"second"):`${e} ms`}function ld(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?fd(e):ud(e)}function Re(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Ii(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Tn,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let x=0;x<u.length;x++)f=(f<<5)-f+u.charCodeAt(x),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,x=null,v,b;function A(...B){if(!A.enabled)return;let w=A,T=Number(new Date),E=T-(f||T);w.diff=E,w.prev=f,w.curr=T,f=T,B[0]=r.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let U=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(P,F)=>{if(P==="%%")return"%";U++;let p=r.formatters[F];if(typeof p=="function"){let m=B[U];P=p.call(w,m),B.splice(U,1),U--}return P}),r.formatArgs.call(w,B),(w.log||r.log).apply(w,B)}return A.namespace=u,A.useColors=r.useColors(),A.color=r.selectColor(u),A.extend=n,A.destroy=r.destroy,Object.defineProperty(A,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(v!==r.namespaces&&(v=r.namespaces,b=r.enabled(u)),b),set:B=>{x=B}}),typeof r.init=="function"&&r.init(A),A}function n(u,f){let x=r(this.namespace+(typeof f>"u"?":":f)+u);return x.log=this.log,x}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,x=(typeof u=="string"?u:"").split(/[\s,]+/),v=x.length;for(f=0;f<v;f++)x[f]&&(u=x[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,x;for(f=0,x=r.skips.length;f<x;f++)if(r.skips[f].test(u))return!1;for(f=0,x=r.names.length;f<x;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var _n=bd(),dd=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function hd(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function pd(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Tn(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var md=console.debug??console.log??(()=>{});function yd(e){try{e?_n?.setItem("debug",e):_n?.removeItem("debug")}catch{}}function gd(){let e;try{e=_n?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function bd(){try{return localStorage}catch{}}function xd(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var hc=Ii({formatArgs:pd,save:yd,load:gd,useColors:hd,setupFormatters:xd,colors:dd,storage:_n,log:md});var wt=hc;wt.formatters.b=e=>e==null?"undefined":ot.baseEncode(e);wt.formatters.t=e=>e==null?"undefined":ie.baseEncode(e);wt.formatters.m=e=>e==null?"undefined":mo.baseEncode(e);wt.formatters.p=e=>e==null?"undefined":e.toString();wt.formatters.c=e=>e==null?"undefined":e.toString();wt.formatters.k=e=>e==null?"undefined":e.toString();wt.formatters.a=e=>e==null?"undefined":e.toString();wt.formatters.e=e=>e==null?"undefined":pc(e.stack)??pc(e.message)??e.toString();function wd(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function De(e){let t=wd(`${e}:trace`);return wt.enabled(`${e}:trace`)&&wt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=wt(`${e}:trace`)),Object.assign(wt(e),{error:wt(`${e}:error`),trace:t,newScope:r=>De(`${e}:${r}`)})}function pc(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Bu=Zi(_i(),1);var Cn=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Pt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Un=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Le=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}};var qr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Rn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}};var Et;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Or(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=sr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>or(o,e.codec()),e.decode=(o,i)=>nr(o,e.codec(),i)})(Et||(Et={}));var Ed=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Ci(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=Sd(e);return r||"Object"}function Sd(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ed.includes(t))return t}var h=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var L=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Hr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",vd=new TextEncoder;function Dn(e){return Hr&&globalThis.Buffer.isBuffer(e)}function $r(e){return e instanceof Uint8Array?Dn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Ad=24,Bd=200,Ln=Hr?e=>e.length>=Ad?globalThis.Buffer.from(e):mc(e):e=>e.length>=Bd?vd.encode(e):mc(e),zt=e=>Uint8Array.from(e),yc=Hr?(e,t,r)=>Dn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),gc=Hr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),$r(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},bc=Hr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Nn(e,t){if(Dn(e)&&Dn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function mc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var Id=256,zr=class{constructor(t=Id){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=bc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=yc(n,0,this.cursor)}else r=gc(this.chunks,this.cursor);return t&&this.reset(),r}},kn=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var V="CBOR decode error:",Kn="CBOR encode error:",Zr=[];Zr[23]=1;Zr[24]=2;Zr[25]=3;Zr[26]=5;Zr[27]=9;function ne(e,t,r){if(e.length-t<r)throw new Error(`${V} not enough data for type`)}var ut=[24,256,65536,4294967296,BigInt("18446744073709551616")];function It(e,t,r){ne(e,t,1);let n=e[t];if(r.strict===!0&&n<ut[0])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Tt(e,t,r){ne(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ut[1])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function _t(e,t,r){ne(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ut[2])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Ct(e,t,r){ne(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ut[3])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${V} integers outside of the safe integer range are not supported`)}function xc(e,t,r,n){return new L(h.uint,It(e,t+1,n),2)}function wc(e,t,r,n){return new L(h.uint,Tt(e,t+1,n),3)}function Ec(e,t,r,n){return new L(h.uint,_t(e,t+1,n),5)}function Sc(e,t,r,n){return new L(h.uint,Ct(e,t+1,n),9)}function Rt(e,t){return G(e,0,t.value)}function G(e,t,r){if(r<ut[0]){let n=Number(r);e.push([t|n])}else if(r<ut[1]){let n=Number(r);e.push([t|24,n])}else if(r<ut[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ut[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ut[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${V} encountered BigInt larger than allowable range`)}}Rt.encodedSize=function(t){return G.encodedSize(t.value)};G.encodedSize=function(t){return t<ut[0]?1:t<ut[1]?2:t<ut[2]?3:t<ut[3]?5:9};Rt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function vc(e,t,r,n){return new L(h.negint,-1-It(e,t+1,n),2)}function Ac(e,t,r,n){return new L(h.negint,-1-Tt(e,t+1,n),3)}function Bc(e,t,r,n){return new L(h.negint,-1-_t(e,t+1,n),5)}var Ui=BigInt(-1),Ic=BigInt(1);function Tc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(h.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${V} integers outside of the safe integer range are not supported`);return new L(h.negint,Ui-BigInt(o),9)}function On(e,t){let r=t.value,n=typeof r=="bigint"?r*Ui-Ic:r*-1-1;G(e,t.type.majorEncoded,n)}On.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ui-Ic:r*-1-1;return n<ut[0]?1:n<ut[1]?2:n<ut[2]?3:n<ut[3]?5:9};On.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function jr(e,t,r,n){ne(e,t,r+n);let o=e.slice(t+r,t+r+n);return new L(h.bytes,o,r+n)}function _c(e,t,r,n){return jr(e,t,1,r)}function Cc(e,t,r,n){return jr(e,t,2,It(e,t+1,n))}function Uc(e,t,r,n){return jr(e,t,3,Tt(e,t+1,n))}function Rc(e,t,r,n){return jr(e,t,5,_t(e,t+1,n))}function Dc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer bytes lengths not supported`);return jr(e,t,9,o)}function Pn(e){return e.encodedBytes===void 0&&(e.encodedBytes=h.equals(e.type,h.string)?Ln(e.value):e.value),e.encodedBytes}function ur(e,t){let r=Pn(t);G(e,t.type.majorEncoded,r.length),e.push(r)}ur.encodedSize=function(t){let r=Pn(t);return G.encodedSize(r.length)+r.length};ur.compareTokens=function(t,r){return _d(Pn(t),Pn(r))};function _d(e,t){return e.length<t.length?-1:e.length>t.length?1:Nn(e,t)}var Lc=new TextDecoder,Ud=32;function Rd(e,t,r){if(r-t<Ud){let o="";for(let i=t;i<r;i++){let s=e[i];if(s&128)return Lc.decode(e.subarray(t,r));o+=String.fromCharCode(s)}return o}return Lc.decode(e.subarray(t,r))}function Gr(e,t,r,n,o){let i=r+n;ne(e,t,i);let s=new L(h.string,Rd(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+r,t+i)),s}function Nc(e,t,r,n){return Gr(e,t,1,r,n)}function kc(e,t,r,n){return Gr(e,t,2,It(e,t+1,n),n)}function Kc(e,t,r,n){return Gr(e,t,3,Tt(e,t+1,n),n)}function Oc(e,t,r,n){return Gr(e,t,5,_t(e,t+1,n),n)}function Pc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer string lengths not supported`);return Gr(e,t,9,o,n)}var Mc=ur;function fr(e,t,r,n){return new L(h.array,n,r)}function Fc(e,t,r,n){return fr(e,t,1,r)}function Vc(e,t,r,n){return fr(e,t,2,It(e,t+1,n))}function qc(e,t,r,n){return fr(e,t,3,Tt(e,t+1,n))}function Hc(e,t,r,n){return fr(e,t,5,_t(e,t+1,n))}function $c(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function zc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Mn(e,t){G(e,h.array.majorEncoded,t.value)}Mn.compareTokens=Rt.compareTokens;Mn.encodedSize=function(t){return G.encodedSize(t.value)};function lr(e,t,r,n){return new L(h.map,n,r)}function Zc(e,t,r,n){return lr(e,t,1,r)}function jc(e,t,r,n){return lr(e,t,2,It(e,t+1,n))}function Gc(e,t,r,n){return lr(e,t,3,Tt(e,t+1,n))}function Yc(e,t,r,n){return lr(e,t,5,_t(e,t+1,n))}function Wc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer map lengths not supported`);return lr(e,t,9,o)}function Xc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return lr(e,t,1,1/0)}function Fn(e,t){G(e,h.map.majorEncoded,t.value)}Fn.compareTokens=Rt.compareTokens;Fn.encodedSize=function(t){return G.encodedSize(t.value)};function Jc(e,t,r,n){return new L(h.tag,r,1)}function Qc(e,t,r,n){return new L(h.tag,It(e,t+1,n),2)}function tu(e,t,r,n){return new L(h.tag,Tt(e,t+1,n),3)}function eu(e,t,r,n){return new L(h.tag,_t(e,t+1,n),5)}function ru(e,t,r,n){return new L(h.tag,Ct(e,t+1,n),9)}function Vn(e,t){G(e,h.tag.majorEncoded,t.value)}Vn.compareTokens=Rt.compareTokens;Vn.encodedSize=function(t){return G.encodedSize(t.value)};var Ri=20,Di=21,Li=22,Ni=23;function nu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${V} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(h.null,null,1):new L(h.undefined,void 0,1)}function ou(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return new L(h.break,void 0,1)}function ki(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${V} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${V} Infinity values are not supported`)}return new L(h.float,e,t)}function iu(e,t,r,n){return ki(Ki(e,t+1),3,n)}function su(e,t,r,n){return ki(Oi(e,t+1),5,n)}function au(e,t,r,n){return ki(lu(e,t+1),9,n)}function Yr(e,t,r){let n=t.value;if(n===!1)e.push([h.float.majorEncoded|Ri]);else if(n===!0)e.push([h.float.majorEncoded|Di]);else if(n===null)e.push([h.float.majorEncoded|Li]);else if(n===void 0)e.push([h.float.majorEncoded|Ni]);else{let o,i=!1;(!r||r.float64!==!0)&&(uu(n),o=Ki(Mt,1),n===o||Number.isNaN(n)?(Mt[0]=249,e.push(Mt.slice(0,3)),i=!0):(fu(n),o=Oi(Mt,1),n===o&&(Mt[0]=250,e.push(Mt.slice(0,5)),i=!0))),i||(Kd(n),o=lu(Mt,1),Mt[0]=251,e.push(Mt.slice(0,9)))}}Yr.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){uu(n);let o=Ki(Mt,1);if(n===o||Number.isNaN(n))return 3;if(fu(n),o=Oi(Mt,1),n===o)return 5}return 9};var cu=new ArrayBuffer(9),Dt=new DataView(cu,1),Mt=new Uint8Array(cu,0);function uu(e){if(e===1/0)Dt.setUint16(0,31744,!1);else if(e===-1/0)Dt.setUint16(0,64512,!1);else if(Number.isNaN(e))Dt.setUint16(0,32256,!1);else{Dt.setFloat32(0,e);let t=Dt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Dt.setUint16(0,31744,!1);else if(r===0)Dt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Dt.setUint16(0,0):o<-14?Dt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Dt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ki(e,t){if(e.length-t<2)throw new Error(`${V} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function fu(e){Dt.setFloat32(0,e,!1)}function Oi(e,t){if(e.length-t<4)throw new Error(`${V} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Kd(e){Dt.setFloat64(0,e,!1)}function lu(e,t){if(e.length-t<8)throw new Error(`${V} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Yr.compareTokens=Rt.compareTokens;function z(e,t,r){throw new Error(`${V} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function qn(e){return()=>{throw new Error(`${V} ${e}`)}}var _=[];for(let e=0;e<=23;e++)_[e]=z;_[24]=xc;_[25]=wc;_[26]=Ec;_[27]=Sc;_[28]=z;_[29]=z;_[30]=z;_[31]=z;for(let e=32;e<=55;e++)_[e]=z;_[56]=vc;_[57]=Ac;_[58]=Bc;_[59]=Tc;_[60]=z;_[61]=z;_[62]=z;_[63]=z;for(let e=64;e<=87;e++)_[e]=_c;_[88]=Cc;_[89]=Uc;_[90]=Rc;_[91]=Dc;_[92]=z;_[93]=z;_[94]=z;_[95]=qn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)_[e]=Nc;_[120]=kc;_[121]=Kc;_[122]=Oc;_[123]=Pc;_[124]=z;_[125]=z;_[126]=z;_[127]=qn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)_[e]=Fc;_[152]=Vc;_[153]=qc;_[154]=Hc;_[155]=$c;_[156]=z;_[157]=z;_[158]=z;_[159]=zc;for(let e=160;e<=183;e++)_[e]=Zc;_[184]=jc;_[185]=Gc;_[186]=Yc;_[187]=Wc;_[188]=z;_[189]=z;_[190]=z;_[191]=Xc;for(let e=192;e<=215;e++)_[e]=Jc;_[216]=Qc;_[217]=tu;_[218]=eu;_[219]=ru;_[220]=z;_[221]=z;_[222]=z;_[223]=z;for(let e=224;e<=243;e++)_[e]=qn("simple values are not supported");_[244]=z;_[245]=z;_[246]=z;_[247]=nu;_[248]=qn("simple values are not supported");_[249]=iu;_[250]=su;_[251]=au;_[252]=z;_[253]=z;_[254]=z;_[255]=ou;var Ft=[];for(let e=0;e<24;e++)Ft[e]=new L(h.uint,e,1);for(let e=-1;e>=-24;e--)Ft[31-e]=new L(h.negint,e,1);Ft[64]=new L(h.bytes,new Uint8Array(0),1);Ft[96]=new L(h.string,"",1);Ft[128]=new L(h.array,0,1);Ft[160]=new L(h.map,0,1);Ft[244]=new L(h.false,!1,1);Ft[245]=new L(h.true,!0,1);Ft[246]=new L(h.null,null,1);function Pi(e){switch(e.type){case h.false:return zt([244]);case h.true:return zt([245]);case h.null:return zt([246]);case h.bytes:return e.value.length?void 0:zt([64]);case h.string:return e.value===""?zt([96]):void 0;case h.array:return e.value===0?zt([128]):void 0;case h.map:return e.value===0?zt([160]):void 0;case h.uint:return e.value<24?zt([Number(e.value)]):void 0;case h.negint:if(e.value>=-24)return zt([31-Number(e.value)])}}var Pd={float64:!1,mapSorter:Vd,quickEncodeToken:Pi},yu=Object.freeze({float64:!0,mapSorter:qd,quickEncodeToken:Pi});function Md(){let e=[];return e[h.uint.major]=Rt,e[h.negint.major]=On,e[h.bytes.major]=ur,e[h.string.major]=Mc,e[h.array.major]=Mn,e[h.map.major]=Fn,e[h.tag.major]=Vn,e[h.float.major]=Yr,e}var dr=Md(),Hn=new zr,Xr=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Kn} object contains circular references`);return new e(r,t)}},me={null:new L(h.null,null),undefined:new L(h.undefined,void 0),true:new L(h.true,!0),false:new L(h.false,!1),emptyArray:new L(h.array,0),emptyMap:new L(h.map,0)},Zt={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(h.float,e):e>=0?new L(h.uint,e):new L(h.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(h.uint,e):new L(h.negint,e)},Uint8Array(e,t,r,n){return new L(h.bytes,e)},string(e,t,r,n){return new L(h.string,e)},boolean(e,t,r,n){return e?me.true:me.false},null(e,t,r,n){return me.null},undefined(e,t,r,n){return me.undefined},ArrayBuffer(e,t,r,n){return new L(h.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(h.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[me.emptyArray,new L(h.break)]:me.emptyArray;n=Xr.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=$n(s,r,n);return r.addBreakTokens?[new L(h.array,e.length),o,new L(h.break)]:[new L(h.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),n=Xr.createCheck(n,e);let c=!o&&r.ignoreUndefinedProperties,l=0;for(let u of i){let f=o?e.get(u):e[u];c&&f===void 0||(a[l++]=[$n(u,r,n),$n(f,r,n)])}l<s&&(a.length=l)}return a?.length?(Fd(a,r),r.addBreakTokens?[new L(h.map,a.length),a,new L(h.break)]:[new L(h.map,a.length),a]):r.addBreakTokens===!0?[me.emptyMap,new L(h.break)]:me.emptyMap}};Zt.Map=Zt.Object;Zt.Buffer=Zt.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Zt[`${e}Array`]=Zt.DataView;function $n(e,t={},r){let n=Ci(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Zt[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Zt[n];if(!i)throw new Error(`${Kn} unsupported type: ${n}`);return i(e,n,t,r)}function Fd(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Vd(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=dr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function qd(e,t){if(e[0]instanceof L&&t[0]instanceof L){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=du(r.value)),n._keyBytes||(n._keyBytes=du(n.value)),Nn(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function du(e){return bu(e,dr,yu)}function Wr(e,t,r,n){if(Array.isArray(t))for(let o of t)Wr(e,o,r,n);else r[t.type.major](e,t,n)}var hu=h.uint.majorEncoded,pu=h.negint.majorEncoded,Hd=h.bytes.majorEncoded,$d=h.string.majorEncoded,mu=h.array.majorEncoded,zd=h.float.majorEncoded|Ri,Zd=h.float.majorEncoded|Di,jd=h.float.majorEncoded|Li,Gd=h.float.majorEncoded|Ni,Yd=BigInt(-1),Wd=BigInt(1);function Xd(e){return e.addBreakTokens!==!0}function gu(e,t,r,n){let o=Ci(t),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(t,o,r,n);if(s!=null){Wr(e,s,dr,r);return}}switch(o){case"null":e.push([jd]);return;case"undefined":e.push([Gd]);return;case"boolean":e.push([t?Zd:zd]);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?Yr(e,new L(h.float,t),r):t>=0?G(e,hu,t):G(e,pu,t*-1-1);return;case"bigint":t>=BigInt(0)?G(e,hu,t):G(e,pu,t*Yd-Wd);return;case"string":{let s=Ln(t);G(e,$d,s.length),e.push(s);return}case"Uint8Array":G(e,Hd,t.length),e.push(t);return;case"Array":if(!t.length){e.push([mu]);return}n=Xr.createCheck(n,t),G(e,mu,t.length);for(let s of t)gu(e,s,r,n);return;case"Object":case"Map":{let s=Zt.Object(t,o,r,n);Wr(e,s,dr,r)}return;default:{let s=Zt[o];if(!s)throw new Error(`${Kn} unsupported type: ${o}`);let a=s(t,o,r,n);Wr(e,a,dr,r)}}}function bu(e,t,r,n){let o=n instanceof Uint8Array,i=o?new kn(n):Hn,s=$n(e,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let l=c.encodedSize(s,r);if(o||(i=new zr(l)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():$r(i.chunks[0])}}return i.reset(),Wr(i,s,t,r),i.toBytes(!0)}function Jr(e,t){return t=Object.assign({},Pd,t),Xd(t)?(Hn.reset(),gu(Hn,e,t,void 0),Hn.toBytes(!0)):bu(e,dr,t)}var Jd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},zn=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Ft[t];if(r===void 0){let n=_[t];if(!n)throw new Error(`${V} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Qr=Symbol.for("DONE"),Zn=Symbol.for("BREAK");function Qd(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=hr(t,r);if(i===Zn){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed array`)}if(i===Qr)throw new Error(`${V} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function th(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let c=hr(t,r);if(c===Zn){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed map`)}if(c===Qr)throw new Error(`${V} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!n&&typeof c!="string")throw new Error(`${V} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${V} found repeat map key "${c}"`);let l=hr(t,r);if(l===Qr)throw new Error(`${V} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(c,l):i[c]=l}return n?s:i}function hr(e,t){if(e.done())return Qr;let r=e.next();if(h.equals(r.type,h.break))return Zn;if(r.type.terminal)return r.value;if(h.equals(r.type,h.array))return Qd(r,e,t);if(h.equals(r.type,h.map))return th(r,e,t);if(h.equals(r.type,h.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=hr(e,t);return t.tags[r.value](n)}throw new Error(`${V} tag not supported (${r.value})`)}throw new Error("unsupported")}function xu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${V} data to decode must be a Uint8Array`);t=Object.assign({},Jd,t);let r=$r(e),n=t.tokenizer||new zn(r,t),o=hr(n,t);if(o===Qr)throw new Error(`${V} did not find any content to decode`);if(o===Zn)throw new Error(`${V} got unexpected break`);return[o,e.subarray(n.pos())]}function tn(e,t){let[r,n]=xu(e,t);if(n.length>0)throw new Error(`${V} too many terminals, data makes no sense`);return r}var Jg=De("ipns:utils"),Qg=Z("/ipns/"),eh=114;function Eu(e,t,r){let n=Z(t);return be([e,r,n])}function jn(e){let t=Z("ipns-signature:");return be([t,e])}function Mi(e){return"signatureV1"in e?Et.encode({value:Z(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:Z(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Et.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function en(e){let t=Et.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Pt("Missing data or signatureV2");let r=vu(t.data),n=rh(r.Value),o=j(r.Validity);if(t.value!=null&&t.signatureV1!=null)return nh(t),{value:n,validityType:Et.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Et.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Su(e,t,r,n,o){let i;if(t===Et.ValidityType.EOL)i=0;else throw new Le("The validity type is unsupported");return Jr({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function vu(e){let t=tn(e);if(t.ValidityType===0)t.ValidityType=Et.ValidityType.EOL;else throw new Le("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function rh(e){let t=j(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${it.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${it.parse(t).toV1().toString()}`}catch{}throw new qr("Value must be a valid content path starting with /")}function Au(e){if(e!=null){let t=sh(e);if(t!=null)return t.code===eh?`/ipns/${t.toString(Lt)}`:`/ipfs/${t.toV1().toString()}`;if(oh(e))return`/ipns/${Lt.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new qr("Value must be a valid content path starting with /")}function nh(e){if(e.data==null)throw new Rn("Record data is missing");let t=vu(e.data);if(!st(t.Value,e.value??new Uint8Array(0)))throw new Pt('Field "value" did not match between protobuf and CBOR');if(!st(t.Validity,e.validity??new Uint8Array(0)))throw new Pt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Pt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Pt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Pt('Field "ttl" did not match between protobuf and CBOR')}function oh(e){return e.bytes instanceof Uint8Array}function ih(e){return typeof e?.toCID=="function"}function sh(e){if(ih(e))return e.toCID();try{return it.parse(e)}catch{}return it.asCID(e)}var ah=De("ipns"),Iu=5*60*1e9,ch="/ipns/",ab=ch.length,Tu={v1Compatible:!0,ttlNs:Iu};async function _u(e,t,r,n,o=Tu){let i=new Bu.default(Date.now()+Number(n)),s=Et.ValidityType.EOL,a=BigInt(o.ttlNs??Iu);return uh(e,t,r,s,i.toString(),a,o)}var uh=async(e,t,r,n,o,i,s=Tu)=>{r=BigInt(r);let a=Z(o),c=Au(t),l=Z(c),u=Su(l,n,a,r,i),f=jn(u),x=await e.sign(f),v;if(e.type==="RSA"&&(v=se(e.publicKey)),s.v1Compatible===!0){let b=await fh(e,l,n,a),A={value:c,signatureV1:b,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:x,data:u};return v!=null&&(A.pubKey=v),A}else{let b={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:x,data:u};return v!=null&&(b.pubKey=v),b}},fh=async(e,t,r,n)=>{try{let o=Eu(t,r,n);return await e.sign(o)}catch(o){throw ah.error("record signature creation failed",o),new Cn("Record signature creation failed")}};var Cu=Zi(_i(),1);var Gn=De("ipns:validator"),Eb=1024*10;async function Uu(e,t){let r=en(t),n;try{let o=jn(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw Gn.error("record signature verification failed"),new Pt("Record signature verification failed");if(r.validityType===Et.ValidityType.EOL){if(Cu.default.fromString(r.validity).toDate().getTime()<Date.now())throw Gn.error("record has expired"),new Un("record has expired")}else if(r.validityType!=null)throw Gn.error("the validity type is unsupported"),new Le("The validity type is unsupported");Gn("ipns record for %s is valid",r.value)}var Vi=class extends Error{constructor(t={}){var r;super((r=t.message)!==null&&r!==void 0?r:"Maximum retry limit reached."),this.options=t}},Fi=Symbol("internal_state");function qi(e={}){let{interval:t=0,maxPerInterval:r=1/0,evenlySpaced:n=!1,maxRetries:o=30,maxRetriesWithPauses:i=30}=e;if(r<1)throw new Error('"maxPerInterval" must be a positive integer.');if(t<0)throw new Error('"interval" cannot be negative.');if(o<0)throw new Error('"maxRetries" cannot be negative.');if(i<0)throw new Error('"maxRetriesWithPauses" cannot be negative.');if(n)return qi({...e,interval:Math.ceil(t/r),maxPerInterval:1,evenlySpaced:!1});let s=[],a=0,c=0,l,u=()=>{l=void 0;let x=a+t,v=Date.now();if(v<x){l=setTimeout(u,x-v);return}a=v,c=0;for(let b of s.splice(0,r))c++,b();s.length&&(l=setTimeout(u,t))},f=(x,v)=>new Promise((b,A)=>{v||(v={}),Fi in v||Object.assign(v,{[Fi]:{maxRetries:o,maxRetriesWithPauses:i}});let B=async()=>{var E,U;try{return await x({intervalStart:a,state:v})}catch(K){if(K instanceof Vi){let P=v[Fi];if(K.options.pauseQueue){if(P.maxRetriesWithPauses--<=0)throw K;c=r,l!==void 0&&clearTimeout(l),l=setTimeout(u,(U=(E=K.options.retryAfter)!==null&&E!==void 0?E:e.interval)!==null&&U!==void 0?U:500)}else{if(P.maxRetries--<=0)throw K;await new Promise(F=>{var p,m;return setTimeout(F,(m=(p=K.options.retryAfter)!==null&&p!==void 0?p:e.interval)!==null&&m!==void 0?m:500)})}return f(x,v)}throw K}},w=()=>{Promise.resolve().then(B).then(b).catch(A)},T=Date.now();l===void 0&&t&&T-a>t&&(a=T,c=0),c++<r?w():(s.push(w),l===void 0&&(l=setTimeout(u,a+t-T)))});return f}var Yn=class{endpoint;waitForRateLimit;constructor(t=new URL("https://name.web3.storage/"),r=function(){let n=qi({maxPerInterval:30,interval:1e4});return async()=>await n(()=>{})}()){this.endpoint=t,this.waitForRateLimit=r}};var Ru=()=>new Date(Date.now()+31536e6).toISOString(),dh=5n*60n*1000n*1000000n,Du=new Yn,Wn=class{_pubKey;_cid;constructor(t){this._pubKey=t,this._cid=t.toCID()}get bytes(){return this._cid.bytes}toString(){return this._cid.toString(Lt)}},Xn=class extends Wn{_privKey;constructor(t){super(t.publicKey),this._privKey=t}get key(){return this._privKey}};async function Lu(){let e=await fc("Ed25519",2048);return new Xn(e)}function hh(e){let t=it.parse(e,Lt);if(t.code!==114)throw new Error(`Invalid key, expected 114 codec code but got ${t.code}`);let r=Bi(Ve(t.multihash.bytes).bytes);return new Wn(r)}async function Hi(e){let t;try{t=dc(e)}catch{t=lc(e)}return new Xn(t)}async function Nu(e,t){return new rn(e,t,0n,Ru())}async function ku(e,t){let r=e.sequence+1n;return new rn(e.name,t,r,Ru())}var rn=class e{_name;_value;_sequence;_validity;_ttl;constructor(t,r,n,o,i){if(this._name=t,typeof r!="string")throw new Error("invalid value");if(this._value=r,typeof n!="bigint")throw new Error("invalid sequence number");if(this._sequence=n,typeof o!="string"||Number.isNaN(new Date(o).getTime()))throw new Error("invalid validity");this._validity=o;let s=i?.ttl??dh;if(typeof s!="bigint")throw new Error("invalid TTL");this._ttl=s}get name(){return this._name}get value(){return this._value}get sequence(){return this._sequence}get validity(){return this._validity}get ttl(){return this._ttl}static encode(t){return Jr({name:t._name.toString(),value:t._value,sequence:t._sequence,validity:t._validity,...t._ttl!=null?{ttl:t._ttl}:{}})}static decode(t){let r=tn(t),n=hh(r.name);return new e(n,r.value,BigInt(r.sequence),r.validity,{ttl:r.ttl!=null?BigInt(r.ttl):void 0})}};async function Ku(e,t,r=Du){let n=new URL(`name/${e.name.toString()}`,r.endpoint),o=await _u(t,e.value,e.sequence,new Date(e.validity).getTime()-Date.now(),{ttlNs:e.ttl});await r.waitForRateLimit(),await Pu(fetch(n.toString(),{method:"POST",body:an.baseEncode(Mi(o))}))}async function Ou(e,t=Du){let r=new URL(`name/${e.toString()}`,t.endpoint);await t.waitForRateLimit();let n=await Pu(fetch(r.toString())),{record:o}=await n.json(),i=an.baseDecode(o),s=en(i),a=it.decode(e.bytes),c=Bi(Ve(a.multihash.bytes).bytes);return await Uu(c,i),new rn(e,s.value,s.sequence,s.validity,{ttl:s.ttl})}async function Pu(e){let t=await e;if(t.ok)return t;let r;try{let n=await t.json();r=new Error(n.message)}catch{r=new Error(`unexpected response from API, cannot parse error response. Received status: ${t.status}`)}throw r}var{WARN:Nb,LOG:kb,DEBUG:Jn,ERROR:Mu}=Qn.setup(Qn.INFO);async function mh(e){let t=`https://name.web3.storage/name/${e.toString()}`,r;try{r=await fetch(t,{signal:AbortSignal.timeout(3e4)})}catch(o){throw Mu("[w3name] Network error resolving IPNS:",o)}if(r.status===404)return Jn("[w3name] IPNS record not found (never published):",e.toString()),null;if(!r.ok)throw Mu(`[w3name] HTTP ${r.status} resolving IPNS:`,r.statusText);return await Ou(e)}async function Kb(e,t){let n=new Promise((o,i)=>setTimeout(()=>i(new Error("publishIPNS timed out after 30000ms")),3e4));return Promise.race([yh(e,t),n])}async function yh(e,t){let r=`/ipfs/${t}`,n=await Hi(e),o,i=await mh(n);return i?(o=await ku(i,r),Jn("[w3name] incrementing revision for",n.toString())):(o=await Nu(n,r),Jn("[w3name] creating initial revision for",n.toString())),await Ku(o,n.key),Jn("[w3name] published",t.toString(),"to",n.toString()),o}function Ob(e="https://name.web3.storage"){return{name:"w3name",async publish(t,r){let n=await fetch(`${e}/name/${t}`,{method:"POST",body:ji.baseEncode(r)});if(!n.ok)throw new Error(`W3Name HTTP ${n.status}`)}}}async function Pb(){return Lu()}async function Mb(e){return(await Hi(e)).toString()}export{Kb as a,Ob as b,Pb as c,Mb as d};
3
+ /*! Bundled license information:
4
+
5
+ @noble/hashes/utils.js:
6
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
7
+
8
+ @noble/curves/utils.js:
9
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
10
+
11
+ @noble/curves/abstract/modular.js:
12
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
13
+
14
+ @noble/curves/abstract/curve.js:
15
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
16
+
17
+ @noble/curves/abstract/edwards.js:
18
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
19
+
20
+ @noble/curves/ed25519.js:
21
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
22
+
23
+ @noble/curves/abstract/weierstrass.js:
24
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
25
+
26
+ @noble/curves/secp256k1.js:
27
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
28
+ */
29
+ //# sourceMappingURL=chunk-UKHFBNOE.min.js.map