@libp2p/bootstrap 11.0.1 → 11.0.2-b3272cfce
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.
- package/dist/index.min.js +1 -1
- package/package.json +6 -6
- package/dist/typedoc-urls.json +0 -8
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var Rr=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var di=Object.prototype.hasOwnProperty;var ht=(r,t)=>{for(var e in t)Rr(r,e,{get:t[e],enumerable:!0})},hi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of li(t))!di.call(r,o)&&o!==e&&Rr(r,o,{get:()=>t[o],enumerable:!(n=fi(t,o))||n.enumerable});return r};var pi=r=>hi(Rr({},"__esModule",{value:!0}),r);var Ru={};ht(Ru,{bootstrap:()=>Lu});var po=Symbol.for("@libp2p/peer-discovery");var Cr=Symbol.for("@libp2p/peer-id");var de=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Fe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var $e=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Re=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var mo=(r,...t)=>{try{[...t]}catch{}};var Ge=class extends EventTarget{#t=new Map;constructor(){super(),mo(1/0,this)}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var xo=Symbol.for("@libp2p/service-capabilities"),ku=Symbol.for("@libp2p/service-dependencies");var Dr={};ht(Dr,{base58btc:()=>Y,base58flickr:()=>wi});var af=new Uint8Array(0);function go(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Tt(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 bo(r){return new TextEncoder().encode(r)}function yo(r){return new TextDecoder().decode(r)}function mi(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var g=0,l=0,b=0,B=E.length;b!==B&&E[b]===0;)b++,g++;for(var m=(B-b)*u+1>>>0,I=new Uint8Array(m);b!==B;){for(var _=E[b],P=0,A=m-1;(_!==0||P<l)&&A!==-1;A--,P++)_+=256*I[A]>>>0,I[A]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");l=P,b++}for(var T=m-l;T!==m&&I[T]===0;)T++;for(var C=a.repeat(g);T<m;++T)C+=r.charAt(I[T]);return C}function p(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var g=0;if(E[g]!==" "){for(var l=0,b=0;E[g]===a;)l++,g++;for(var B=(E.length-g)*f+1>>>0,m=new Uint8Array(B);E[g];){var I=e[E.charCodeAt(g)];if(I===255)return;for(var _=0,P=B-1;(I!==0||_<b)&&P!==-1;P--,_++)I+=c*m[P]>>>0,m[P]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");b=_,g++}if(E[g]!==" "){for(var A=B-b;A!==B&&m[A]===0;)A++;for(var T=new Uint8Array(l+(B-A)),C=l;A!==B;)T[C++]=m[A++];return T}}}function v(E){var g=p(E);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:p,decode:v}}var xi=mi,gi=xi,Eo=gi;var Pr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},_r=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),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 So(this,t)}},Ur=class{decoders;constructor(t){this.decoders=t}or(t){return So(this,t)}decode(t){let e=t[0],n=this.decoders[e];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 So(r,t){return new Ur({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Nr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pr(t,e,n),this.decoder=new _r(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function he({name:r,prefix:t,encode:e,decode:n}){return new Nr(r,t,e,n)}function kt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Eo(e,r);return he({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function bi(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,f=0;for(let u=0;u<s;++u){let h=o[r[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|h,c+=e,c>=8&&(c-=8,i[f++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i}function yi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;s.length*e&7;)s+="=";return s}function W({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return he({prefix:t,name:r,encode(o){return yi(o,n,e)},decode(o){return bi(o,n,e,r)}})}var Y=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wi=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Or={};ht(Or,{base32:()=>Lt,base32hex:()=>Bi,base32hexpad:()=>Ai,base32hexpadupper:()=>Ti,base32hexupper:()=>Ii,base32pad:()=>Si,base32padupper:()=>vi,base32upper:()=>Ei,base32z:()=>Li});var Lt=W({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ei=W({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Si=W({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vi=W({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bi=W({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ii=W({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ai=W({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ti=W({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Li=W({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ri=Io,vo=128,Ci=127,Pi=~Ci,_i=Math.pow(2,31);function Io(r,t,e){t=t||[],e=e||0;for(var n=e;r>=_i;)t[e++]=r&255|vo,r/=128;for(;rΠ)t[e++]=r&255|vo,r>>>=7;return t[e]=r|0,Io.bytes=e-n+1,t}var Ui=kr,Ni=128,Bo=127;function kr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw kr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Bo)<<o:(i&Bo)*Math.pow(2,o),o+=7}while(i>=Ni);return kr.bytes=s-n,e}var Di=Math.pow(2,7),Oi=Math.pow(2,14),ki=Math.pow(2,21),Mi=Math.pow(2,28),Hi=Math.pow(2,35),Ki=Math.pow(2,42),qi=Math.pow(2,49),zi=Math.pow(2,56),Vi=Math.pow(2,63),Fi=function(r){return r<Di?1:r<Oi?2:r<ki?3:r<Mi?4:r<Hi?5:r<Ki?6:r<qi?7:r<zi?8:r<Vi?9:10},$i={encode:Ri,decode:Ui,encodingLength:Fi},Gi=$i,Ce=Gi;function Pe(r,t=0){return[Ce.decode(r,t),Ce.decode.bytes]}function pe(r,t,e=0){return Ce.encode(r,t,e),t}function me(r){return Ce.encodingLength(r)}function Yt(r,t){let e=t.byteLength,n=me(r),o=n+me(e),s=new Uint8Array(o+e);return pe(r,s,0),pe(e,s,n),s.set(t,o),new xe(r,e,t,s)}function Xt(r){let t=Tt(r),[e,n]=Pe(t),[o,s]=Pe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(e,o,i,t)}function Ao(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&go(r.bytes,e.bytes)}}var xe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function To(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Zi(e,Mr(r),t??Y.encoder);default:return Wi(e,Mr(r),t??Lt.encoder)}}var Lo=new WeakMap;function Mr(r){let t=Lo.get(r);if(t==null){let e=new Map;return Lo.set(r,e),e}return t}var lt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==_e)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Yi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=Yt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Ao(t.multihash,n.multihash)}toString(t){return To(this,t)}toJSON(){return{"/":To(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Ro(n,o,s.bytes))}else if(e[Xi]===!0){let{version:n,multihash:o,code:s}=e,i=Xt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==_e)throw new Error(`Version 0 CID must use dag-pb (code: ${_e}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Ro(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_e,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new xe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,p]=Pe(t.subarray(e));return e+=p,h},o=n(),s=_e;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=ji(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Mr(s).set(n,t),s}};function ji(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case Lt.prefix:{let e=t??Lt;return[Lt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Zi(r,t,e){let{prefix:n}=e;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Wi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var _e=112,Yi=18;function Ro(r,t,e){let n=me(r),o=n+me(t),s=new Uint8Array(o+e.byteLength);return pe(r,s,0),pe(t,s,n),s.set(e,o),s}var Xi=Symbol.for("@ipld/js-cid/CID");var Hr={};ht(Hr,{identity:()=>Rt});var Co=0,Qi="identity",Po=Tt;function Ji(r){return Yt(Co,Po(r))}var Rt={code:Co,name:Qi,encode:Po,digest:Ji};function Ct(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function _o(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function tc(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ge(r,...t){if(!tc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Uo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_o(r.outputLen),_o(r.blockLen)}function be(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function No(r,t){ge(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ze=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),yt=(r,t)=>r<<32-t|r>>>t;var Rf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Do(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ue(r){return typeof r=="string"&&(r=Do(r)),ge(r),r}function Kr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ge(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var ye=class{clone(){return this._cloneInto()}},Cf={}.toString;function We(r){let t=n=>r().update(Ue(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ye(r=32){if(Jt&&typeof Jt.getRandomValues=="function")return Jt.getRandomValues(new Uint8Array(r));if(Jt&&typeof Jt.randomBytes=="function")return Jt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function ec(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,f=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+f,c,n)}var Oo=(r,t,e)=>r&t^~r&e,ko=(r,t,e)=>r&t^r&e^t&e,we=class extends ye{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ze(this.buffer)}update(t){be(this);let{view:e,buffer:n,blockLen:o}=this;t=Ue(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Ze(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){be(this),No(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)e[h]=0;ec(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Ze(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Xe=BigInt(4294967295),qr=BigInt(32);function Mo(r,t=!1){return t?{h:Number(r&Xe),l:Number(r>>qr&Xe)}:{h:Number(r>>qr&Xe)|0,l:Number(r&Xe)|0}}function rc(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Mo(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var nc=(r,t)=>BigInt(r>>>0)<<qr|BigInt(t>>>0),oc=(r,t,e)=>r>>>e,sc=(r,t,e)=>r<<32-e|t>>>e,ic=(r,t,e)=>r>>>e|t<<32-e,cc=(r,t,e)=>r<<32-e|t>>>e,ac=(r,t,e)=>r<<64-e|t>>>e-32,uc=(r,t,e)=>r>>>e-32|t<<64-e,fc=(r,t)=>t,lc=(r,t)=>r,dc=(r,t,e)=>r<<e|t>>>32-e,hc=(r,t,e)=>t<<e|r>>>32-e,pc=(r,t,e)=>t<<e-32|r>>>64-e,mc=(r,t,e)=>r<<e-32|t>>>64-e;function xc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var gc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),bc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,yc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),wc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Ec=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Sc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var vc={fromBig:Mo,split:rc,toBig:nc,shrSH:oc,shrSL:sc,rotrSH:ic,rotrSL:cc,rotrBH:ac,rotrBL:uc,rotr32H:fc,rotr32L:lc,rotlSH:dc,rotlSL:hc,rotlBH:pc,rotlBL:mc,add:xc,add3L:gc,add3H:bc,add4L:yc,add4H:wc,add5H:Sc,add5L:Ec},O=vc;var[Bc,Ic]=O.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Mt=new Uint32Array(80),Ht=new Uint32Array(80),zr=class extends we{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:h,Fl:p,Gh:v,Gl:E,Hh:g,Hl:l}=this;return[t,e,n,o,s,i,c,a,f,u,h,p,v,E,g,l]}set(t,e,n,o,s,i,c,a,f,u,h,p,v,E,g,l){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=h|0,this.Fl=p|0,this.Gh=v|0,this.Gl=E|0,this.Hh=g|0,this.Hl=l|0}process(t,e){for(let m=0;m<16;m++,e+=4)Mt[m]=t.getUint32(e),Ht[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=Mt[m-15]|0,_=Ht[m-15]|0,P=O.rotrSH(I,_,1)^O.rotrSH(I,_,8)^O.shrSH(I,_,7),A=O.rotrSL(I,_,1)^O.rotrSL(I,_,8)^O.shrSL(I,_,7),T=Mt[m-2]|0,C=Ht[m-2]|0,J=O.rotrSH(T,C,19)^O.rotrBH(T,C,61)^O.shrSH(T,C,6),q=O.rotrSL(T,C,19)^O.rotrBL(T,C,61)^O.shrSL(T,C,6),k=O.add4L(A,q,Ht[m-7],Ht[m-16]),tt=O.add4H(k,P,J,Mt[m-7],Mt[m-16]);Mt[m]=tt|0,Ht[m]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:h,El:p,Fh:v,Fl:E,Gh:g,Gl:l,Hh:b,Hl:B}=this;for(let m=0;m<80;m++){let I=O.rotrSH(h,p,14)^O.rotrSH(h,p,18)^O.rotrBH(h,p,41),_=O.rotrSL(h,p,14)^O.rotrSL(h,p,18)^O.rotrBL(h,p,41),P=h&v^~h&g,A=p&E^~p&l,T=O.add5L(B,_,A,Ic[m],Ht[m]),C=O.add5H(T,b,I,P,Bc[m],Mt[m]),J=T|0,q=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),k=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),tt=n&s^n&c^s&c,S=o&i^o&a^i&a;b=g|0,B=l|0,g=v|0,l=E|0,v=h|0,E=p|0,{h,l:p}=O.add(f|0,u|0,C|0,J|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let L=O.add3L(J,k,S);n=O.add3H(L,C,q,tt),o=L|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=O.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=O.add(this.Dh|0,this.Dl|0,f|0,u|0),{h,l:p}=O.add(this.Eh|0,this.El|0,h|0,p|0),{h:v,l:E}=O.add(this.Fh|0,this.Fl|0,v|0,E|0),{h:g,l}=O.add(this.Gh|0,this.Gl|0,g|0,l|0),{h:b,l:B}=O.add(this.Hh|0,this.Hl|0,b|0,B|0),this.set(n,o,s,i,c,a,f,u,h,p,v,E,g,l,b,B)}roundClean(){Mt.fill(0),Ht.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ho=We(()=>new zr);var Je={};ht(Je,{aInRange:()=>pt,abool:()=>wt,abytes:()=>Ee,bitGet:()=>Pc,bitLen:()=>jr,bitMask:()=>De,bitSet:()=>_c,bytesToHex:()=>_t,bytesToNumberBE:()=>Ut,bytesToNumberLE:()=>qt,concatBytes:()=>Nt,createHmacDrbg:()=>Zr,ensureBytes:()=>X,equalBytes:()=>Rc,hexToBytes:()=>ee,hexToNumber:()=>Gr,inRange:()=>Ne,isBytes:()=>Kt,memoized:()=>ne,notImplemented:()=>Nc,numberToBytesBE:()=>zt,numberToBytesLE:()=>re,numberToHexUnpadded:()=>te,numberToVarBytesBE:()=>Lc,utf8ToBytes:()=>Cc,validateObject:()=>Bt});var $r=BigInt(0),Qe=BigInt(1),Ac=BigInt(2);function Kt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ee(r){if(!Kt(r))throw new Error("Uint8Array expected")}function wt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var Tc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function _t(r){Ee(r);let t="";for(let e=0;e<r.length;e++)t+=Tc[r[e]];return t}function te(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Gr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ko(r){if(r>=Pt._0&&r<=Pt._9)return r-Pt._0;if(r>=Pt._A&&r<=Pt._F)return r-(Pt._A-10);if(r>=Pt._a&&r<=Pt._f)return r-(Pt._a-10)}function ee(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Ko(r.charCodeAt(s)),c=Ko(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Ut(r){return Gr(_t(r))}function qt(r){return Ee(r),Gr(_t(Uint8Array.from(r).reverse()))}function zt(r,t){return ee(r.toString(16).padStart(t*2,"0"))}function re(r,t){return zt(r,t).reverse()}function Lc(r){return ee(te(r))}function X(r,t,e){let n;if(typeof t=="string")try{n=ee(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Kt(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function Nt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ee(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Rc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Cc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Vr=r=>typeof r=="bigint"&&$r<=r;function Ne(r,t,e){return Vr(r)&&Vr(t)&&Vr(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!Ne(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function jr(r){let t;for(t=0;r>$r;r>>=Qe,t+=1);return t}function Pc(r,t){return r>>BigInt(t)&Qe}function _c(r,t,e){return r|(e?Qe:$r)<<BigInt(t)}var De=r=>(Ac<<BigInt(r-1))-Qe,Fr=r=>new Uint8Array(r),qo=r=>Uint8Array.from(r);function Zr(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Fr(r),o=Fr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...h)=>e(o,n,...h),a=(h=Fr())=>{o=c(qo([0]),h),n=c(),h.length!==0&&(o=c(qo([1]),h),n=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,p=[];for(;h<t;){n=c();let v=n.slice();p.push(v),h+=n.length}return Nt(...p)};return(h,p)=>{i(),a(h);let v;for(;!(v=p(f()));)a();return i(),v}}var Uc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Kt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Bt(r,t,e={}){let n=(o,s,i)=>{let c=Uc[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var Nc=()=>{throw new Error("not implemented")};function ne(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var rt=BigInt(0),j=BigInt(1),oe=BigInt(2),Dc=BigInt(3),Wr=BigInt(4),zo=BigInt(5),Vo=BigInt(8),Oc=BigInt(9),kc=BigInt(16);function F(r,t){let e=r%t;return e>=rt?e:t+e}function Mc(r,t,e){if(e<=rt||t<rt)throw new Error("Expected power/modulo > 0");if(e===j)return rt;let n=j;for(;t>rt;)t&j&&(n=n*r%e),r=r*r%e,t>>=j;return n}function Z(r,t,e){let n=r;for(;t-- >rt;)n*=n,n%=e;return n}function tr(r,t){if(r===rt||t<=rt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=F(r,t),n=t,o=rt,s=j,i=j,c=rt;for(;e!==rt;){let f=n/e,u=n%e,h=o-i*f,p=s-c*f;n=e,e=u,o=i,s=c,i=h,c=p}if(n!==j)throw new Error("invert: does not exist");return F(o,t)}function Hc(r){let t=(r-j)/oe,e,n,o;for(e=r-j,n=0;e%oe===rt;e/=oe,n++);for(o=oe;o<r&&Mc(o,t,r)!==r-j;o++);if(n===1){let i=(r+j)/Wr;return function(a,f){let u=a.pow(f,i);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+j)/oe;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),h=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let v=1;for(let g=c.sqr(p);v<f&&!c.eql(g,c.ONE);v++)g=c.sqr(g);let E=c.pow(u,j<<BigInt(f-v-1));u=c.sqr(E),h=c.mul(h,E),p=c.mul(p,u),f=v}return h}}function Kc(r){if(r%Wr===Dc){let t=(r+j)/Wr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Vo===zo){let t=(r-zo)/Vo;return function(n,o){let s=n.mul(o,oe),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,oe),i),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%kc,Hc(r)}var Fo=(r,t)=>(F(r,t)&j)===j,qc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Yr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=qc.reduce((n,o)=>(n[o]="function",n),t);return Bt(r,e)}function zc(r,t,e){if(e<rt)throw new Error("Expected power > 0");if(e===rt)return r.ONE;if(e===j)return t;let n=r.ONE,o=t;for(;e>rt;)e&j&&(n=r.mul(n,o)),o=r.sqr(o),e>>=j;return n}function Vc(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function Xr(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Vt(r,t,e=!1,n={}){if(r<=rt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Xr(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Kc(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:De(o),ZERO:rt,ONE:j,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return rt<=a&&a<r},is0:a=>a===rt,isOdd:a=>(a&j)===j,neg:a=>F(-a,r),eql:(a,f)=>a===f,sqr:a=>F(a*a,r),add:(a,f)=>F(a+f,r),sub:(a,f)=>F(a-f,r),mul:(a,f)=>F(a*f,r),pow:(a,f)=>zc(c,a,f),div:(a,f)=>F(a*tr(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>tr(a,r),sqrt:n.sqrt||(a=>i(c,a)),invertBatch:a=>Vc(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?re(a,s):zt(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return e?qt(a):Ut(a)}});return Object.freeze(c)}function $o(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Qr(r){let t=$o(r);return t+Math.ceil(t/2)}function Go(r,t,e=!1){let n=r.length,o=$o(t),s=Qr(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?Ut(r):qt(r),c=F(i,t-j)+j;return e?re(c,o):zt(c,o)}var $c=BigInt(0),Jr=BigInt(1),tn=new WeakMap,jo=new WeakMap;function er(r,t){let e=(s,i)=>{let c=i.negate();return s?c:i},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},o=s=>{n(s);let i=Math.ceil(t/s)+1,c=2**(s-1);return{windows:i,windowSize:c}};return{constTimeNegate:e,unsafeLadder(s,i){let c=r.ZERO,a=s;for(;i>$c;)i&Jr&&(c=c.add(a)),a=a.double(),i>>=Jr;return c},precomputeWindow(s,i){let{windows:c,windowSize:a}=o(i),f=[],u=s,h=u;for(let p=0;p<c;p++){h=u,f.push(h);for(let v=1;v<a;v++)h=h.add(u),f.push(h);u=h.double()}return f},wNAF(s,i,c){let{windows:a,windowSize:f}=o(s),u=r.ZERO,h=r.BASE,p=BigInt(2**s-1),v=2**s,E=BigInt(s);for(let g=0;g<a;g++){let l=g*f,b=Number(c&p);c>>=E,b>f&&(b-=v,c+=Jr);let B=l,m=l+Math.abs(b)-1,I=g%2!==0,_=b<0;b===0?h=h.add(e(I,i[B])):u=u.add(e(_,i[m]))}return{p:u,f:h}},wNAFCached(s,i,c){let a=jo.get(s)||1,f=tn.get(s);return f||(f=this.precomputeWindow(s,a),a!==1&&tn.set(s,c(f))),this.wNAF(a,f,i)},setWindowSize(s,i){n(i),jo.set(s,i),tn.delete(s)}}}function rr(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,h)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${h}`)}),e.forEach((u,h)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${h}`)});let o=jr(BigInt(e.length)),s=o>12?o-3:o>4?o-2:o?2:1,i=(1<<s)-1,c=new Array(i+1).fill(r.ZERO),a=Math.floor((t.BITS-1)/s)*s,f=r.ZERO;for(let u=a;u>=0;u-=s){c.fill(r.ZERO);for(let p=0;p<n.length;p++){let v=n[p],E=Number(v>>BigInt(u)&BigInt(i));c[E]=c[E].add(e[p])}let h=r.ZERO;for(let p=c.length-1,v=r.ZERO;p>0;p--)v=v.add(c[p]),h=h.add(v);if(f=f.add(h),u!==0)for(let p=0;p<s;p++)f=f.double()}return f}function Oe(r){return Yr(r.Fp),Bt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Et=BigInt(0),mt=BigInt(1),nr=BigInt(2),Gc=BigInt(8),jc={zip215:!0};function Zc(r){let t=Oe(r);return Bt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Zo(r){let t=Zc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,f=nr<<BigInt(c*8)-mt,u=e.create,h=Vt(t.n,t.nBitLength),p=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(d))}}catch{return{isValid:!1,value:Et}}}),v=t.adjustScalarBytes||(x=>x),E=t.domain||((x,d,y)=>{if(wt("phflag",y),d.length||y)throw new Error("Contexts/pre-hash are not supported");return x});function g(x,d){pt("coordinate "+x,d,Et,f)}function l(x){if(!(x instanceof m))throw new Error("ExtendedPoint expected")}let b=ne((x,d)=>{let{ex:y,ey:R,ez:N}=x,D=x.is0();d==null&&(d=D?Gc:e.inv(N));let M=u(y*d),K=u(R*d),H=u(N*d);if(D)return{x:Et,y:mt};if(H!==mt)throw new Error("invZ was invalid");return{x:M,y:K}}),B=ne(x=>{let{a:d,d:y}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:R,ey:N,ez:D,et:M}=x,K=u(R*R),H=u(N*N),V=u(D*D),G=u(V*V),nt=u(K*d),ot=u(V*u(nt+H)),ct=u(G+u(y*u(K*H)));if(ot!==ct)throw new Error("bad point: equation left != right (1)");let ft=u(R*N),et=u(D*M);if(ft!==et)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,y,R,N){this.ex=d,this.ey=y,this.ez=R,this.et=N,g("x",d),g("y",y),g("z",R),g("t",N),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x:y,y:R}=d||{};return g("x",y),g("y",R),new m(y,R,mt,u(y*R))}static normalizeZ(d){let y=e.invertBatch(d.map(R=>R.ez));return d.map((R,N)=>R.toAffine(y[N])).map(m.fromAffine)}static msm(d,y){return rr(m,h,d,y)}_setWindowSize(d){P.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){l(d);let{ex:y,ey:R,ez:N}=this,{ex:D,ey:M,ez:K}=d,H=u(y*K),V=u(D*N),G=u(R*K),nt=u(M*N);return H===V&&G===nt}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:y,ey:R,ez:N}=this,D=u(y*y),M=u(R*R),K=u(nr*u(N*N)),H=u(d*D),V=y+R,G=u(u(V*V)-D-M),nt=H+M,ot=nt-K,ct=H-M,ft=u(G*ot),et=u(nt*ct),dt=u(G*ct),At=u(ot*nt);return new m(ft,et,At,dt)}add(d){l(d);let{a:y,d:R}=t,{ex:N,ey:D,ez:M,et:K}=this,{ex:H,ey:V,ez:G,et:nt}=d;if(y===BigInt(-1)){let io=u((D-N)*(V+H)),co=u((D+N)*(V-H)),Lr=u(co-io);if(Lr===Et)return this.double();let ao=u(M*nr*nt),uo=u(K*nr*G),fo=uo+ao,lo=co+io,ho=uo-ao,ii=u(fo*Lr),ci=u(lo*ho),ai=u(fo*ho),ui=u(Lr*lo);return new m(ii,ci,ui,ai)}let ot=u(N*H),ct=u(D*V),ft=u(K*R*nt),et=u(M*G),dt=u((N+D)*(H+V)-ot-ct),At=et-ft,Te=et+ft,Le=u(ct-y*ot),ri=u(dt*At),ni=u(Te*Le),oi=u(dt*Le),si=u(At*Te);return new m(ri,ni,si,oi)}subtract(d){return this.add(d.negate())}wNAF(d){return P.wNAFCached(this,d,m.normalizeZ)}multiply(d){let y=d;pt("scalar",y,mt,n);let{p:R,f:N}=this.wNAF(y);return m.normalizeZ([R,N])[0]}multiplyUnsafe(d){let y=d;return pt("scalar",y,Et,n),y===Et?_:this.equals(_)||y===mt?this:this.equals(I)?this.wNAF(y).p:P.unsafeLadder(this,y)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===mt?this:this.multiplyUnsafe(d)}static fromHex(d,y=!1){let{d:R,a:N}=t,D=e.BYTES;d=X("pointHex",d,D),wt("zip215",y);let M=d.slice(),K=d[D-1];M[D-1]=K&-129;let H=qt(M),V=y?f:e.ORDER;pt("pointHex.y",H,Et,V);let G=u(H*H),nt=u(G-mt),ot=u(R*G-N),{isValid:ct,value:ft}=p(nt,ot);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let et=(ft&mt)===mt,dt=(K&128)!==0;if(!y&&ft===Et&&dt)throw new Error("Point.fromHex: x=0 and x_0=1");return dt!==et&&(ft=u(-ft)),m.fromAffine({x:ft,y:H})}static fromPrivateKey(d){return C(d).point}toRawBytes(){let{x:d,y}=this.toAffine(),R=re(y,e.BYTES);return R[R.length-1]|=d&mt?128:0,R}toHex(){return _t(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,mt,u(t.Gx*t.Gy)),m.ZERO=new m(Et,mt,mt,Et);let{BASE:I,ZERO:_}=m,P=er(m,c*8);function A(x){return F(x,n)}function T(x){return A(qt(x))}function C(x){let d=c;x=X("private key",x,d);let y=X("hashed private key",s(x),2*d),R=v(y.slice(0,d)),N=y.slice(d,2*d),D=T(R),M=I.multiply(D),K=M.toRawBytes();return{head:R,prefix:N,scalar:D,point:M,pointBytes:K}}function J(x){return C(x).pointBytes}function q(x=new Uint8Array,...d){let y=Nt(...d);return T(s(E(y,X("context",x),!!o)))}function k(x,d,y={}){x=X("message",x),o&&(x=o(x));let{prefix:R,scalar:N,pointBytes:D}=C(d),M=q(y.context,R,x),K=I.multiply(M).toRawBytes(),H=q(y.context,K,D,x),V=A(M+H*N);pt("signature.s",V,Et,n);let G=Nt(K,re(V,e.BYTES));return X("result",G,c*2)}let tt=jc;function S(x,d,y,R=tt){let{context:N,zip215:D}=R,M=e.BYTES;x=X("signature",x,2*M),d=X("message",d),D!==void 0&&wt("zip215",D),o&&(d=o(d));let K=qt(x.slice(M,2*M)),H,V,G;try{H=m.fromHex(y,D),V=m.fromHex(x.slice(0,M),D),G=I.multiplyUnsafe(K)}catch{return!1}if(!D&&H.isSmallOrder())return!1;let nt=q(N,V.toRawBytes(),H.toRawBytes(),d);return V.add(H.multiplyUnsafe(nt)).subtract(G).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:J,sign:k,verify:S,ExtendedPoint:m,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,d=m.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var en=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Wo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Jf=BigInt(0),Wc=BigInt(1),Yo=BigInt(2),tl=BigInt(3),Yc=BigInt(5),Xc=BigInt(8);function Qc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=en,c=r*r%s*r%s,a=Z(c,Yo,s)*c%s,f=Z(a,Wc,s)*r%s,u=Z(f,Yc,s)*f%s,h=Z(u,t,s)*u%s,p=Z(h,e,s)*h%s,v=Z(p,n,s)*p%s,E=Z(v,o,s)*v%s,g=Z(E,o,s)*v%s,l=Z(g,t,s)*u%s;return{pow_p_5_8:Z(l,Yo,s)*r%s,b2:c}}function Jc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ta(r,t){let e=en,n=F(t*t*t,e),o=F(n*n*t,e),s=Qc(r*o).pow_p_5_8,i=F(r*n*s,e),c=F(t*i*i,e),a=i,f=F(i*Wo,e),u=c===r,h=c===F(-r,e),p=c===F(-r*Wo,e);return u&&(i=a),(h||p)&&(i=f),Fo(i,e)&&(i=F(-i,e)),{isValid:u||h,value:i}}var ea=Vt(en,void 0,!0),ra={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ea,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Xc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ho,randomBytes:Ye,adjustScalarBytes:Jc,uvRatio:ta},Xo=Zo(ra);var or=32;function Qo(r,t,e){return Xo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var sr=class{type="Ed25519";raw;constructor(t){this.raw=rn(t,or)}toMultihash(){return Rt.digest(ir(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ct(this.raw,t.raw)}verify(t,e){return Qo(this.raw,e,t)}};function ts(r){return r=rn(r,or),new sr(r)}function rn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new de(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function St(r=0){return new Uint8Array(r)}var oa=Math.pow(2,7),sa=Math.pow(2,14),ia=Math.pow(2,21),nn=Math.pow(2,28),on=Math.pow(2,35),sn=Math.pow(2,42),cn=Math.pow(2,49),z=128,at=127;function xt(r){if(r<oa)return 1;if(r<sa)return 2;if(r<ia)return 3;if(r<nn)return 4;if(r<on)return 5;if(r<sn)return 6;if(r<cn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function an(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|z,r/=128;case 7:t[e++]=r&255|z,r/=128;case 6:t[e++]=r&255|z,r/=128;case 5:t[e++]=r&255|z,r/=128;case 4:t[e++]=r&255|z,r>>>=7;case 3:t[e++]=r&255|z,r>>>=7;case 2:t[e++]=r&255|z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ca(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|z),r/=128;case 7:t.set(e++,r&255|z),r/=128;case 6:t.set(e++,r&255|z),r/=128;case 5:t.set(e++,r&255|z),r/=128;case 4:t.set(e++,r&255|z),r>>>=7;case 3:t.set(e++,r&255|z),r>>>=7;case 2:t.set(e++,r&255|z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function un(r,t){let e=r[t],n=0;if(n+=e&at,e<z||(e=r[t+1],n+=(e&at)<<7,e<z)||(e=r[t+2],n+=(e&at)<<14,e<z)||(e=r[t+3],n+=(e&at)<<21,e<z)||(e=r[t+4],n+=(e&at)*nn,e<z)||(e=r[t+5],n+=(e&at)*on,e<z)||(e=r[t+6],n+=(e&at)*sn,e<z)||(e=r[t+7],n+=(e&at)*cn,e<z))return n;throw new RangeError("Could not decode varint")}function aa(r,t){let e=r.get(t),n=0;if(n+=e&at,e<z||(e=r.get(t+1),n+=(e&at)<<7,e<z)||(e=r.get(t+2),n+=(e&at)<<14,e<z)||(e=r.get(t+3),n+=(e&at)<<21,e<z)||(e=r.get(t+4),n+=(e&at)*nn,e<z)||(e=r.get(t+5),n+=(e&at)*on,e<z)||(e=r.get(t+6),n+=(e&at)*sn,e<z)||(e=r.get(t+7),n+=(e&at)*cn,e<z))return n;throw new RangeError("Could not decode varint")}function Se(r,t,e=0){return t==null&&(t=St(xt(r))),t instanceof Uint8Array?an(r,t,e):ca(r,t,e)}function se(r,t=0){return r instanceof Uint8Array?un(r,t):aa(r,t)}var fn=new Float32Array([-0]),Ft=new Uint8Array(fn.buffer);function rs(r,t,e){fn[0]=r,t[e]=Ft[0],t[e+1]=Ft[1],t[e+2]=Ft[2],t[e+3]=Ft[3]}function ns(r,t){return Ft[0]=r[t],Ft[1]=r[t+1],Ft[2]=r[t+2],Ft[3]=r[t+3],fn[0]}var ln=new Float64Array([-0]),ut=new Uint8Array(ln.buffer);function os(r,t,e){ln[0]=r,t[e]=ut[0],t[e+1]=ut[1],t[e+2]=ut[2],t[e+3]=ut[3],t[e+4]=ut[4],t[e+5]=ut[5],t[e+6]=ut[6],t[e+7]=ut[7]}function ss(r,t){return ut[0]=r[t],ut[1]=r[t+1],ut[2]=r[t+2],ut[3]=r[t+3],ut[4]=r[t+4],ut[5]=r[t+5],ut[6]=r[t+6],ut[7]=r[t+7],ln[0]}var ua=BigInt(Number.MAX_SAFE_INTEGER),fa=BigInt(Number.MIN_SAFE_INTEGER),gt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+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 e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(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,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ie;if(t<ua&&t>fa)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>is&&(o=0n,++n>is&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ie;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ie}},ie=new gt(0,0);ie.toBigInt=function(){return 0n};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var is=4294967296n;function cs(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function as(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function dn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function vt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function cr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var hn=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,vt(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 vt(this,4);return cr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw vt(this,4);return cr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw vt(this,4);let t=ns(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw vt(this,4);let t=ss(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw vt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return as(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw vt(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 gt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*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;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw vt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw vt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw vt(this,8);let t=cr(this.buf,this.pos+=4),e=cr(this.buf,this.pos+=4);return new gt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=un(this.buf,this.pos);return this.pos+=xt(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 pn(r){return new hn(r instanceof Uint8Array?r:r.subarray())}function ar(r,t,e){let n=pn(r);return t.decode(n,void 0,e)}var mn={};ht(mn,{base10:()=>la});var la=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var xn={};ht(xn,{base16:()=>da,base16upper:()=>ha});var da=W({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ha=W({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gn={};ht(gn,{base2:()=>pa});var pa=W({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var bn={};ht(bn,{base256emoji:()=>ya});var fs=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}"),ma=fs.reduce((r,t,e)=>(r[e]=t,r),[]),xa=fs.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function ga(r){return r.reduce((t,e)=>(t+=ma[e],t),"")}function ba(r){let t=[];for(let e of r){let n=xa[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ya=he({prefix:"\u{1F680}",name:"base256emoji",encode:ga,decode:ba});var yn={};ht(yn,{base36:()=>wa,base36upper:()=>Ea});var wa=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ea=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var wn={};ht(wn,{base64:()=>Sa,base64pad:()=>va,base64url:()=>Ba,base64urlpad:()=>Ia});var Sa=W({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),va=W({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ba=W({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ia=W({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var En={};ht(En,{base8:()=>Aa});var Aa=W({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Sn={};ht(Sn,{identity:()=>Ta});var Ta=he({prefix:"\0",name:"identity",encode:r=>yo(r),decode:r=>bo(r)});var kl=new TextEncoder,Ml=new TextDecoder;var In={};ht(In,{sha256:()=>ke,sha512:()=>Ca});function Bn({name:r,code:t,encode:e}){return new vn(r,t,e)}var vn=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Yt(this.code,e):e.then(n=>Yt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ds(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ke=Bn({name:"sha2-256",code:18,encode:ds("SHA-256")}),Ca=Bn({name:"sha2-512",code:19,encode:ds("SHA-512")});var Me={...Sn,...gn,...En,...mn,...xn,...Or,...yn,...Dr,...wn,...bn},Yl={...In,...Hr};function ps(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var hs=ps("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),An=ps("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=St(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Pa={utf8:hs,"utf-8":hs,hex:Me.base16,latin1:An,ascii:An,binary:An,...Me},ur=Pa;function $t(r,t="utf8"){let e=ur[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Tn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return St(i);o+i>t&&(n=St(t),o=0);let c=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),c}}var ce=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Ln(){}var Cn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},_a=Tn();function Ua(r){return globalThis.Buffer!=null?St(r):_a(r)}var Ke=class{len;head;tail;states;constructor(){this.len=0,this.head=new ce(Ln,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ce(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Pn((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(fr,10,gt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=gt.fromBigInt(t);return this._push(fr,e.length(),e)}uint64Number(t){return this._push(an,xt(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 e=gt.fromBigInt(t).zzEncode();return this._push(fr,e.length(),e)}sint64Number(t){let e=gt.fromNumber(t).zzEncode();return this._push(fr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Rn,1,t?1:0)}fixed32(t){return this._push(He,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=gt.fromBigInt(t);return this._push(He,4,e.lo)._push(He,4,e.hi)}fixed64Number(t){let e=gt.fromNumber(t);return this._push(He,4,e.lo)._push(He,4,e.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(rs,4,t)}double(t){return this._push(os,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Rn,1,0):this.uint32(e)._push(Da,e,t)}string(t){let e=cs(t);return e!==0?this.uint32(e)._push(dn,e,t):this._push(Rn,1,0)}fork(){return this.states=new Cn(this),this.head=this.tail=new ce(Ln,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 ce(Ln,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Ua(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Rn(r,t,e){t[e]=r&255}function Na(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Pn=class extends ce{next;constructor(t,e){super(Na,t,e),this.next=void 0}};function fr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function He(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Da(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ke.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Oa,t,r),this},Ke.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ka,t,r),this});function Oa(r,t,e){t.set(r,e)}function ka(r,t,e){r.length<40?dn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($t(r),e)}function _n(){return new Ke}function lr(r,t){let e=_n();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var ve;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(ve||(ve={}));function dr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Un(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return dr("enum",ve.VARINT,e,n)}function hr(r,t){return dr("message",ve.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(bt||(bt={}));var Nn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Nn||(Nn={}));(function(r){r.codec=()=>Un(Nn)})(bt||(bt={}));var qe;(function(r){let t;r.codec=()=>(t==null&&(t=hr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>lr(e,r.codec()),r.decode=(e,n)=>ar(e,r.codec(),n)})(qe||(qe={}));var Dn;(function(r){let t;r.codec=()=>(t==null&&(t=hr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>lr(e,r.codec()),r.decode=(e,n)=>ar(e,r.codec(),n)})(Dn||(Dn={}));var Ha=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jt=new Uint32Array(64),On=class extends we{constructor(){super(64,32,8,!1),this.A=Gt[0]|0,this.B=Gt[1]|0,this.C=Gt[2]|0,this.D=Gt[3]|0,this.E=Gt[4]|0,this.F=Gt[5]|0,this.G=Gt[6]|0,this.H=Gt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let h=0;h<16;h++,e+=4)jt[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let p=jt[h-15],v=jt[h-2],E=yt(p,7)^yt(p,18)^p>>>3,g=yt(v,17)^yt(v,19)^v>>>10;jt[h]=g+jt[h-7]+E+jt[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let h=0;h<64;h++){let p=yt(c,6)^yt(c,11)^yt(c,25),v=u+p+Oo(c,a,f)+Ha[h]+jt[h]|0,g=(yt(n,2)^yt(n,13)^yt(n,22))+ko(n,o,s)|0;u=f,f=a,a=c,c=i+v|0,i=s,s=o,o=n,n=v+g|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ms=We(()=>new On);function st(r,t="utf8"){let e=ur[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ze=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var pr=class extends ye{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Uo(t);let n=Ue(e);if(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 o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return be(this),this.iHash.update(t),this}digestInto(t){be(this),ge(t,this.outputLen),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||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},kn=(r,t,e)=>new pr(r,t).update(e).digest();kn.create=(r,t)=>new pr(r,t);function xs(r){r.lowS!==void 0&&wt("lowS",r.lowS),r.prehash!==void 0&&wt("prehash",r.prehash)}function Ka(r){let t=Oe(r);Bt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:qa,hexToBytes:za}=Je,Dt={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=Dt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=te(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?te(o.length/2|128):"";return`${te(r)}${s}${o}${t}`},decode(r,t){let{Err:e}=Dt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Dt;if(r<Ot)throw new t("integer: negative integers are not allowed");let e=te(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=Dt;if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return qa(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Dt,o=typeof r=="string"?za(r):r;Ee(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("Invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=Dt,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},Ot=BigInt(0),it=BigInt(1),Hd=BigInt(2),gs=BigInt(3),Kd=BigInt(4);function Va(r){let t=Ka(r),{Fp:e}=t,n=Vt(t.n,t.nBitLength),o=t.toBytes||((g,l,b)=>{let B=l.toAffine();return Nt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(g=>{let l=g.subarray(1),b=e.fromBytes(l.subarray(0,e.BYTES)),B=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:b,y:B}});function i(g){let{a:l,b}=t,B=e.sqr(g),m=e.mul(B,g);return e.add(e.add(m,e.mul(g,l)),b)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return Ne(g,it,t.n)}function a(g){let{allowedPrivateKeyLengths:l,nByteLength:b,wrapPrivateKey:B,n:m}=t;if(l&&typeof g!="bigint"){if(Kt(g)&&(g=_t(g)),typeof g!="string"||!l.includes(g.length))throw new Error("Invalid key");g=g.padStart(b*2,"0")}let I;try{I=typeof g=="bigint"?g:Ut(X("private key",g,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof g}`)}return B&&(I=F(I,m)),pt("private key",I,it,m),I}function f(g){if(!(g instanceof p))throw new Error("ProjectivePoint expected")}let u=ne((g,l)=>{let{px:b,py:B,pz:m}=g;if(e.eql(m,e.ONE))return{x:b,y:B};let I=g.is0();l==null&&(l=I?e.ONE:e.inv(m));let _=e.mul(b,l),P=e.mul(B,l),A=e.mul(m,l);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(A,e.ONE))throw new Error("invZ was invalid");return{x:_,y:P}}),h=ne(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:l,y:b}=g.toAffine();if(!e.isValid(l)||!e.isValid(b))throw new Error("bad point: x or y not FE");let B=e.sqr(b),m=i(l);if(!e.eql(B,m))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(l,b,B){if(this.px=l,this.py=b,this.pz=B,l==null||!e.isValid(l))throw new Error("x required");if(b==null||!e.isValid(b))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(l){let{x:b,y:B}=l||{};if(!l||!e.isValid(b)||!e.isValid(B))throw new Error("invalid affine point");if(l instanceof p)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(b)&&m(B)?p.ZERO:new p(b,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){let b=e.invertBatch(l.map(B=>B.pz));return l.map((B,m)=>B.toAffine(b[m])).map(p.fromAffine)}static fromHex(l){let b=p.fromAffine(s(X("pointHex",l)));return b.assertValidity(),b}static fromPrivateKey(l){return p.BASE.multiply(a(l))}static msm(l,b){return rr(p,n,l,b)}_setWindowSize(l){E.setWindowSize(this,l)}assertValidity(){h(this)}hasEvenY(){let{y:l}=this.toAffine();if(e.isOdd)return!e.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){f(l);let{px:b,py:B,pz:m}=this,{px:I,py:_,pz:P}=l,A=e.eql(e.mul(b,P),e.mul(I,m)),T=e.eql(e.mul(B,P),e.mul(_,m));return A&&T}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b}=t,B=e.mul(b,gs),{px:m,py:I,pz:_}=this,P=e.ZERO,A=e.ZERO,T=e.ZERO,C=e.mul(m,m),J=e.mul(I,I),q=e.mul(_,_),k=e.mul(m,I);return k=e.add(k,k),T=e.mul(m,_),T=e.add(T,T),P=e.mul(l,T),A=e.mul(B,q),A=e.add(P,A),P=e.sub(J,A),A=e.add(J,A),A=e.mul(P,A),P=e.mul(k,P),T=e.mul(B,T),q=e.mul(l,q),k=e.sub(C,q),k=e.mul(l,k),k=e.add(k,T),T=e.add(C,C),C=e.add(T,C),C=e.add(C,q),C=e.mul(C,k),A=e.add(A,C),q=e.mul(I,_),q=e.add(q,q),C=e.mul(q,k),P=e.sub(P,C),T=e.mul(q,J),T=e.add(T,T),T=e.add(T,T),new p(P,A,T)}add(l){f(l);let{px:b,py:B,pz:m}=this,{px:I,py:_,pz:P}=l,A=e.ZERO,T=e.ZERO,C=e.ZERO,J=t.a,q=e.mul(t.b,gs),k=e.mul(b,I),tt=e.mul(B,_),S=e.mul(m,P),L=e.add(b,B),x=e.add(I,_);L=e.mul(L,x),x=e.add(k,tt),L=e.sub(L,x),x=e.add(b,m);let d=e.add(I,P);return x=e.mul(x,d),d=e.add(k,S),x=e.sub(x,d),d=e.add(B,m),A=e.add(_,P),d=e.mul(d,A),A=e.add(tt,S),d=e.sub(d,A),C=e.mul(J,x),A=e.mul(q,S),C=e.add(A,C),A=e.sub(tt,C),C=e.add(tt,C),T=e.mul(A,C),tt=e.add(k,k),tt=e.add(tt,k),S=e.mul(J,S),x=e.mul(q,x),tt=e.add(tt,S),S=e.sub(k,S),S=e.mul(J,S),x=e.add(x,S),k=e.mul(tt,x),T=e.add(T,k),k=e.mul(d,x),A=e.mul(L,A),A=e.sub(A,k),k=e.mul(L,tt),C=e.mul(d,C),C=e.add(C,k),new p(A,T,C)}subtract(l){return this.add(l.negate())}is0(){return this.equals(p.ZERO)}wNAF(l){return E.wNAFCached(this,l,p.normalizeZ)}multiplyUnsafe(l){pt("scalar",l,Ot,t.n);let b=p.ZERO;if(l===Ot)return b;if(l===it)return this;let{endo:B}=t;if(!B)return E.unsafeLadder(this,l);let{k1neg:m,k1:I,k2neg:_,k2:P}=B.splitScalar(l),A=b,T=b,C=this;for(;I>Ot||P>Ot;)I&it&&(A=A.add(C)),P&it&&(T=T.add(C)),C=C.double(),I>>=it,P>>=it;return m&&(A=A.negate()),_&&(T=T.negate()),T=new p(e.mul(T.px,B.beta),T.py,T.pz),A.add(T)}multiply(l){let{endo:b,n:B}=t;pt("scalar",l,it,B);let m,I;if(b){let{k1neg:_,k1:P,k2neg:A,k2:T}=b.splitScalar(l),{p:C,f:J}=this.wNAF(P),{p:q,f:k}=this.wNAF(T);C=E.constTimeNegate(_,C),q=E.constTimeNegate(A,q),q=new p(e.mul(q.px,b.beta),q.py,q.pz),m=C.add(q),I=J.add(k)}else{let{p:_,f:P}=this.wNAF(l);m=_,I=P}return p.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(l,b,B){let m=p.BASE,I=(P,A)=>A===Ot||A===it||!P.equals(m)?P.multiplyUnsafe(A):P.multiply(A),_=I(this,b).add(I(l,B));return _.is0()?void 0:_}toAffine(l){return u(this,l)}isTorsionFree(){let{h:l,isTorsionFree:b}=t;if(l===it)return!0;if(b)return b(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:l,clearCofactor:b}=t;return l===it?this:b?b(p,this):this.multiplyUnsafe(t.h)}toRawBytes(l=!0){return wt("isCompressed",l),this.assertValidity(),o(p,this,l)}toHex(l=!0){return wt("isCompressed",l),_t(this.toRawBytes(l))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let v=t.nBitLength,E=er(p,t.endo?Math.ceil(v/2):v);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Fa(r){let t=Oe(r);return Bt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function bs(r){let t=Fa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(S){return F(S,n)}function c(S){return tr(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:h}=Va({...t,toBytes(S,L,x){let d=L.toAffine(),y=e.toBytes(d.x),R=Nt;return wt("isCompressed",x),x?R(Uint8Array.from([L.hasEvenY()?2:3]),y):R(Uint8Array.from([4]),y,e.toBytes(d.y))},fromBytes(S){let L=S.length,x=S[0],d=S.subarray(1);if(L===o&&(x===2||x===3)){let y=Ut(d);if(!Ne(y,it,e.ORDER))throw new Error("Point is not on curve");let R=u(y),N;try{N=e.sqrt(R)}catch(K){let H=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+H)}let D=(N&it)===it;return(x&1)===1!==D&&(N=e.neg(N)),{x:y,y:N}}else if(L===s&&x===4){let y=e.fromBytes(d.subarray(0,e.BYTES)),R=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:y,y:R}}else throw new Error(`Point of length ${L} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),p=S=>_t(zt(S,t.nByteLength));function v(S){let L=n>>it;return S>L}function E(S){return v(S)?i(-S):S}let g=(S,L,x)=>Ut(S.slice(L,x));class l{constructor(L,x,d){this.r=L,this.s=x,this.recovery=d,this.assertValidity()}static fromCompact(L){let x=t.nByteLength;return L=X("compactSignature",L,x*2),new l(g(L,0,x),g(L,x,2*x))}static fromDER(L){let{r:x,s:d}=Dt.toSig(X("DER",L));return new l(x,d)}assertValidity(){pt("r",this.r,it,n),pt("s",this.s,it,n)}addRecoveryBit(L){return new l(this.r,this.s,L)}recoverPublicKey(L){let{r:x,s:d,recovery:y}=this,R=P(X("msgHash",L));if(y==null||![0,1,2,3].includes(y))throw new Error("recovery id invalid");let N=y===2||y===3?x+t.n:x;if(N>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=y&1?"03":"02",M=a.fromHex(D+p(N)),K=c(N),H=i(-R*K),V=i(d*K),G=a.BASE.multiplyAndAddUnsafe(M,H,V);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new l(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return ee(this.toDERHex())}toDERHex(){return Dt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ee(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let b={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Qr(t.n);return Go(t.randomBytes(S),t.n)},precompute(S=8,L=a.BASE){return L._setWindowSize(S),L.multiply(BigInt(3)),L}};function B(S,L=!0){return a.fromPrivateKey(S).toRawBytes(L)}function m(S){let L=Kt(S),x=typeof S=="string",d=(L||x)&&S.length;return L?d===o||d===s:x?d===2*o||d===2*s:S instanceof a}function I(S,L,x=!0){if(m(S))throw new Error("first arg must be private key");if(!m(L))throw new Error("second arg must be public key");return a.fromHex(L).multiply(f(S)).toRawBytes(x)}let _=t.bits2int||function(S){let L=Ut(S),x=S.length*8-t.nBitLength;return x>0?L>>BigInt(x):L},P=t.bits2int_modN||function(S){return i(_(S))},A=De(t.nBitLength);function T(S){return pt(`num < 2^${t.nBitLength}`,S,Ot,A),zt(S,t.nByteLength)}function C(S,L,x=J){if(["recovered","canonical"].some(ot=>ot in x))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:y}=t,{lowS:R,prehash:N,extraEntropy:D}=x;R==null&&(R=!0),S=X("msgHash",S),xs(x),N&&(S=X("prehashed msgHash",d(S)));let M=P(S),K=f(L),H=[T(K),T(M)];if(D!=null&&D!==!1){let ot=D===!0?y(e.BYTES):D;H.push(X("extraEntropy",ot))}let V=Nt(...H),G=M;function nt(ot){let ct=_(ot);if(!h(ct))return;let ft=c(ct),et=a.BASE.multiply(ct).toAffine(),dt=i(et.x);if(dt===Ot)return;let At=i(ft*i(G+dt*K));if(At===Ot)return;let Te=(et.x===dt?0:2)|Number(et.y&it),Le=At;return R&&v(At)&&(Le=E(At),Te^=1),new l(dt,Le,Te)}return{seed:V,k2sig:nt}}let J={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function k(S,L,x=J){let{seed:d,k2sig:y}=C(S,L,x),R=t;return Zr(R.hash.outputLen,R.nByteLength,R.hmac)(d,y)}a.BASE._setWindowSize(8);function tt(S,L,x,d=q){let y=S;if(L=X("msgHash",L),x=X("publicKey",x),"strict"in d)throw new Error("options.strict was renamed to lowS");xs(d);let{lowS:R,prehash:N}=d,D,M;try{if(typeof y=="string"||Kt(y))try{D=l.fromDER(y)}catch(et){if(!(et instanceof Dt.Err))throw et;D=l.fromCompact(y)}else if(typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint"){let{r:et,s:dt}=y;D=new l(et,dt)}else throw new Error("PARSE");M=a.fromHex(x)}catch(et){if(et.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(R&&D.hasHighS())return!1;N&&(L=t.hash(L));let{r:K,s:H}=D,V=P(L),G=c(H),nt=i(V*G),ot=i(K*G),ct=a.BASE.multiplyAndAddUnsafe(M,nt,ot)?.toAffine();return ct?i(ct.x)===K:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:I,sign:k,verify:tt,ProjectivePoint:a,Signature:l,utils:b}}function $a(r){return{hash:r,hmac:(t,...e)=>kn(r,t,Kr(...e)),randomBytes:Ye}}function ys(r,t){let e=n=>bs({...r,...$a(n)});return Object.freeze({...e(t),create:e})}var Ss=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ws=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ga=BigInt(1),Mn=BigInt(2),Es=(r,t)=>(r+t/Mn)/t;function ja(r){let t=Ss,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,h=Z(u,e,t)*u%t,p=Z(h,e,t)*u%t,v=Z(p,Mn,t)*f%t,E=Z(v,o,t)*v%t,g=Z(E,s,t)*E%t,l=Z(g,c,t)*g%t,b=Z(l,a,t)*l%t,B=Z(b,c,t)*g%t,m=Z(B,e,t)*u%t,I=Z(m,i,t)*E%t,_=Z(I,n,t)*f%t,P=Z(_,Mn,t);if(!Hn.eql(Hn.sqr(P),r))throw new Error("Cannot find square root");return P}var Hn=Vt(Ss,void 0,void 0,{sqrt:ja}),ae=ys({a:BigInt(0),b:BigInt(7),Fp:Hn,n:ws,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ws,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ga*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Es(s*r,t),a=Es(-n*r,t),f=F(r-c*e-a*o,t),u=F(-c*n-a*s,t),h=f>i,p=u>i;if(h&&(f=t-f),p&&(u=t-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:h,k1:f,k2neg:p,k2:u}}}},ms),Wd=BigInt(0);var Yd=ae.ProjectivePoint;function It(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=St(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function vs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Bs(r,t,e){let n=ke.digest(e instanceof Uint8Array?e:e.subarray());if(vs(n))return n.then(({digest:o})=>ae.verify(t,o,r)).catch(o=>{throw new ze(String(o))});try{return ae.verify(t,n.digest,r)}catch(o){throw new ze(String(o))}}var mr=class{type="secp256k1";raw;_key;constructor(t){this._key=As(t),this.raw=Is(this._key)}toMultihash(){return Rt.digest(ir(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ct(this.raw,t.raw)}verify(t,e){return Bs(this._key,e,t)}};function Ts(r){return new mr(r)}function Is(r){return ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function As(r){try{return ae.ProjectivePoint.fromHex(r),r}catch(t){throw new Fe(String(t))}}function Ls(r){let{Type:t,Data:e}=qe.decode(r.digest),n=e??new Uint8Array;switch(t){case bt.Ed25519:return ts(n);case bt.secp256k1:return Ts(n);default:throw new Re}}function ir(r){return qe.encode({Type:bt[r.type],Data:r.raw})}var Rs=Symbol.for("nodejs.util.inspect.custom"),Za=114,Ve=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Cr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(Za,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Ct(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Ct(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Rs](){return`PeerId(${this.toString()})`}},xr=class extends Ve{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},gr=class extends Ve{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},br=class extends Ve{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Wa=2336,yr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Rt.digest($t(this.url))}[Rs](){return`PeerId(${this.url})`}[Cr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(Wa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=st(t)),t.toString()===this.toString())}};function Cs(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Xt(Y.decode(`z${r}`));else{if(t==null)throw new de('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Xt(t.decode(r))}return Ya(e)}function Ya(r){if(Qa(r))return new xr({multihash:r});if(Xa(r))try{let t=Ls(r);if(t.type==="Ed25519")return new gr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new br({multihash:r,publicKey:t})}catch{let e=st(r.digest);return new yr(new URL(e))}throw new $e("Supplied PeerID Multihash is invalid")}function Xa(r){return r.code===Rt.code}function Qa(r){return r.code===ke.code}var wr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let h=this.readChar();if(h===void 0)return;let p=Number.parseInt(h,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=t,s+=u,s>f||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ps=45,Ja=15,Be=new wr;function Kn(r){if(!(r.length>Ja))return Be.new(r).parseWith(()=>Be.readIPv4Addr())}function qn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ps))return Be.new(r).parseWith(()=>Be.readIPv6Addr())}function Er(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ps))return Be.new(r).parseWith(()=>Be.readIPAddr())}var lp=parseInt("0xFFFF",16),dp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ns(r){return!!Kn(r)}function Ds(r){return!!qn(r)}function Sr(r){return!!Er(r)}var Os=Ns,ou=Ds,zn=function(r){let t=0;if(r=r.toString().trim(),Os(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ou(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Os(e[n]),i;s&&(i=zn(e[n]),e[n]=st(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,st(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},ks=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ie={},Vn={},iu=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];iu.forEach(r=>{let t=cu(...r);Vn[t.code]=t,Ie[t.name]=t});function cu(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function $(r){if(typeof r=="number"){if(Vn[r]!=null)return Vn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Wp=$("ip4"),Yp=$("ip6"),Xp=$("ipcidr");function jn(r,t){switch($(r).code){case 4:case 41:return uu(t);case 42:return Gn(t);case 6:case 273:case 33:case 132:return Ks(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gn(t);case 421:return hu(t);case 444:return Hs(t);case 445:return Hs(t);case 466:return du(t);case 481:return globalThis.encodeURIComponent(Gn(t));default:return st(t,"base16")}}function Zn(r,t){switch($(r).code){case 4:return Ms(t);case 41:return Ms(t);case 42:return $n(t);case 6:case 273:case 33:case 132:return Wn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return $n(t);case 421:return fu(t);case 444:return pu(t);case 445:return mu(t);case 466:return lu(t);case 481:return $n(globalThis.decodeURIComponent(t));default:return $t(t,"base16")}}var Fn=Object.values(Me).map(r=>r.decoder),au=function(){let r=Fn[0].or(Fn[1]);return Fn.slice(2).forEach(t=>r=r.or(t)),r}();function Ms(r){if(!Sr(r))throw new Error("invalid ip address");return zn(r)}function uu(r){let t=ks(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Sr(t))throw new Error("invalid ip address");return t}function Wn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ks(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function $n(r){let t=$t(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function Gn(r){let t=se(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return st(r)}function fu(r){let t;r[0]==="Q"||r[0]==="1"?t=Xt(Y.decode(`z${r}`)).bytes:t=lt.parse(r).multihash.bytes;let e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function lu(r){let t=au.decode(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function du(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+st(e,"base64url")}function hu(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return st(e,"base58btc")}function pu(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Lt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Wn(n);return It([e,o],e.length+o.length)}function mu(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Lt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Wn(n);return It([e,o],e.length+o.length)}function Hs(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=st(t,"base32"),o=Ks(e);return`${n}:${o}`}function qs(r){r=Yn(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=$(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw Vs("invalid address: "+r);if(c.path===!0){n=Yn(o.slice(s).join("/")),t.push([c.code,Zn(c.code,n)]),e.push([c.code,n]);break}let a=Zn(c.code,o[s]);t.push([c.code,a]),e.push([c.code,jn(c.code,a)])}return{string:zs(e),bytes:Qn(t),tuples:t,stringTuples:e,path:n}}function Xn(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=se(r,o),i=xt(s),c=$(s),a=xu(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw Vs("Invalid address Uint8Array: "+st(r,"base16"));t.push([s,f]);let u=jn(s,f);if(e.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:zs(e),tuples:t,stringTuples:e,path:n}}function zs(r){let t=[];return r.map(e=>{let n=$(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Yn(t.join("/"))}function Qn(r){return It(r.map(t=>{let e=$(t[0]),n=Uint8Array.from(Se(e.code));return t.length>1&&t[1]!=null&&(n=It([n,t[1]])),n}))}function xu(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=se(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function Yn(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Vs(r){return new Error("Error parsing address: "+r)}var gu=Symbol.for("nodejs.util.inspect.custom"),to=Symbol.for("@multiformats/js-multiaddr/multiaddr"),bu=[$("dns").code,$("dns4").code,$("dns6").code,$("dnsaddr").code],Jn=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},vr=class r{bytes;#t;#e;#r;#n;[to]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Xn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=qs(t)}else if($s(t))e=Xn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=$("tcp"),c=$("udp"),a=$("ip4"),f=$("ip6"),u=$("dns6"),h=$("ip6zone");for(let[v,E]of this.stringTuples())v===h.code&&(s=`%${E??""}`),bu.includes(v)&&(e=i.name,o=443,n=`${E??""}${s}`,t=v===u.code?6:4),(v===i.code||v===c.code)&&(e=$(v).name,o=parseInt(E??"")),(v===a.code||v===f.code)&&(e=$(v).name,n=`${E??""}${s}`,t=v===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},$(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>$(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Qn(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Ie.p2p.code&&t.push([n,o]),n===Ie["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?st(Y.decode(`z${n}`),"base58btc"):st(lt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Ct(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Fs.get(e.name);if(n==null)throw new Jn(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Zt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[gu](){return`Multiaddr(${this.#t})`}};var Fs=new Map;function $s(r){return!!r?.[to]}function Zt(r){return new vr(r)}var yu=w("dns4"),wu=w("dns6"),Eu=w("dnsaddr"),fe=Q(w("dns"),Eu,yu,wu),Ar=Q(w("ip4"),w("ip6")),Ae=Q(U(Ar,w("tcp")),U(fe,w("tcp"))),Tr=U(Ar,w("udp")),Su=U(Tr,w("utp")),vu=U(Tr,w("quic")),Bu=U(Tr,w("quic-v1")),eo=Q(U(Ae,w("ws")),U(fe,w("ws"))),Br=Q(U(eo,w("p2p")),eo),ro=Q(U(Ae,w("wss")),U(fe,w("wss")),U(Ae,w("tls"),w("ws")),U(fe,w("tls"),w("ws"))),Ir=Q(U(ro,w("p2p")),ro),no=Q(U(Ae,w("http")),U(Ar,w("http")),U(fe,w("http"))),oo=Q(U(Ae,w("https")),U(Ar,w("https")),U(fe,w("https"))),Gs=U(Tr,w("webrtc-direct"),w("certhash")),Ws=Q(U(Gs,w("p2p")),Gs),js=U(Bu,w("webtransport"),w("certhash"),w("certhash")),Ys=Q(U(js,w("p2p")),js),Xs=Q(U(Br,w("p2p-webrtc-star"),w("p2p")),U(Ir,w("p2p-webrtc-star"),w("p2p")),U(Br,w("p2p-webrtc-star")),U(Ir,w("p2p-webrtc-star"))),S0=Q(U(Br,w("p2p-websocket-star"),w("p2p")),U(Ir,w("p2p-websocket-star"),w("p2p")),U(Br,w("p2p-websocket-star")),U(Ir,w("p2p-websocket-star"))),Qs=Q(U(no,w("p2p-webrtc-direct"),w("p2p")),U(oo,w("p2p-webrtc-direct"),w("p2p")),U(no,w("p2p-webrtc-direct")),U(oo,w("p2p-webrtc-direct"))),le=Q(eo,ro,no,oo,Xs,Qs,Ae,Su,vu,fe,Ws,Ys),v0=Q(U(le,w("p2p-stardust"),w("p2p")),U(le,w("p2p-stardust"))),Wt=Q(U(le,w("p2p")),Xs,Qs,Ws,Ys,w("p2p")),Zs=Q(U(Wt,w("p2p-circuit"),Wt),U(Wt,w("p2p-circuit")),U(w("p2p-circuit"),Wt),U(le,w("p2p-circuit")),U(w("p2p-circuit"),le),w("p2p-circuit")),Js=()=>Q(U(Zs,Js),Zs),ue=Js(),ti=Q(U(ue,Wt,ue),U(Wt,ue),U(ue,Wt),ue,Wt);var B0=Q(U(ue,w("webrtc"),w("p2p")),U(ue,w("webrtc")),U(le,w("webrtc"),w("p2p")),U(le,w("webrtc")),w("webrtc"));function ei(r){function t(e){let n;try{n=Zt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function U(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:ei(t),partialMatch:t}}function Q(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:ei(t),partialMatch:t}}function w(r){let t=r;function e(o){let s;try{s=Zt(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Iu="bootstrap",Au=50,Tu=1e3,so=class extends Ge{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Tu,this.list=[];for(let n of e.list){if(!ti.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Zt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Cs(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[po]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[xo]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??Iu]:{value:this._init.tagValue??Au,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Lu(r){return t=>new so(t,r)}return pi(Ru);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Cr=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var hi=Object.prototype.hasOwnProperty;var ht=(r,t)=>{for(var e in t)Cr(r,e,{get:t[e],enumerable:!0})},pi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of di(t))!hi.call(r,o)&&o!==e&&Cr(r,o,{get:()=>t[o],enumerable:!(n=li(t,o))||n.enumerable});return r};var mi=r=>pi(Cr({},"__esModule",{value:!0}),r);var Ru={};ht(Ru,{bootstrap:()=>Lu});var mo=Symbol.for("@libp2p/peer-discovery");var Pr=Symbol.for("@libp2p/peer-id");var de=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},$e=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ge=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Re=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var xo=(r,...t)=>{try{[...t]}catch{}};var je=class extends EventTarget{#t=new Map;constructor(){super(),xo(1/0,this)}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var go=Symbol.for("@libp2p/service-capabilities"),ku=Symbol.for("@libp2p/service-dependencies");var Or={};ht(Or,{base58btc:()=>Y,base58flickr:()=>Ei});var af=new Uint8Array(0);function bo(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Tt(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 yo(r){return new TextEncoder().encode(r)}function wo(r){return new TextDecoder().decode(r)}function xi(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var g=0,l=0,b=0,B=E.length;b!==B&&E[b]===0;)b++,g++;for(var m=(B-b)*u+1>>>0,I=new Uint8Array(m);b!==B;){for(var _=E[b],P=0,A=m-1;(_!==0||P<l)&&A!==-1;A--,P++)_+=256*I[A]>>>0,I[A]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");l=P,b++}for(var T=m-l;T!==m&&I[T]===0;)T++;for(var C=a.repeat(g);T<m;++T)C+=r.charAt(I[T]);return C}function p(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var g=0;if(E[g]!==" "){for(var l=0,b=0;E[g]===a;)l++,g++;for(var B=(E.length-g)*f+1>>>0,m=new Uint8Array(B);E[g];){var I=e[E.charCodeAt(g)];if(I===255)return;for(var _=0,P=B-1;(I!==0||_<b)&&P!==-1;P--,_++)I+=c*m[P]>>>0,m[P]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");b=_,g++}if(E[g]!==" "){for(var A=B-b;A!==B&&m[A]===0;)A++;for(var T=new Uint8Array(l+(B-A)),C=l;A!==B;)T[C++]=m[A++];return T}}}function v(E){var g=p(E);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:p,decode:v}}var gi=xi,bi=gi,So=bi;var _r=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ur=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.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 vo(this,t)}},Nr=class{decoders;constructor(t){this.decoders=t}or(t){return vo(this,t)}decode(t){let e=t[0],n=this.decoders[e];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 vo(r,t){return new Nr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Dr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new _r(t,e,n),this.decoder=new Ur(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function he({name:r,prefix:t,encode:e,decode:n}){return new Dr(r,t,e,n)}function kt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=So(e,r);return he({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function yi(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,f=0;for(let u=0;u<s;++u){let h=o[r[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|h,c+=e,c>=8&&(c-=8,i[f++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i}function wi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;s.length*e&7;)s+="=";return s}function W({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return he({prefix:t,name:r,encode(o){return wi(o,n,e)},decode(o){return yi(o,n,e,r)}})}var Y=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ei=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kr={};ht(kr,{base32:()=>Lt,base32hex:()=>Ii,base32hexpad:()=>Ti,base32hexpadupper:()=>Li,base32hexupper:()=>Ai,base32pad:()=>vi,base32padupper:()=>Bi,base32upper:()=>Si,base32z:()=>Ri});var Lt=W({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Si=W({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vi=W({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bi=W({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ii=W({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ai=W({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ti=W({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Li=W({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ri=W({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mr={};ht(Mr,{base36:()=>Ce,base36upper:()=>Ci});var Ce=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ci=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Pi=Ao,Bo=128,_i=127,Ui=~_i,Ni=Math.pow(2,31);function Ao(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ni;)t[e++]=r&255|Bo,r/=128;for(;r&Ui;)t[e++]=r&255|Bo,r>>>=7;return t[e]=r|0,Ao.bytes=e-n+1,t}var Di=Hr,Oi=128,Io=127;function Hr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Hr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Io)<<o:(i&Io)*Math.pow(2,o),o+=7}while(i>=Oi);return Hr.bytes=s-n,e}var ki=Math.pow(2,7),Mi=Math.pow(2,14),Hi=Math.pow(2,21),Ki=Math.pow(2,28),qi=Math.pow(2,35),zi=Math.pow(2,42),Vi=Math.pow(2,49),Fi=Math.pow(2,56),$i=Math.pow(2,63),Gi=function(r){return r<ki?1:r<Mi?2:r<Hi?3:r<Ki?4:r<qi?5:r<zi?6:r<Vi?7:r<Fi?8:r<$i?9:10},ji={encode:Pi,decode:Di,encodingLength:Gi},Zi=ji,Pe=Zi;function _e(r,t=0){return[Pe.decode(r,t),Pe.decode.bytes]}function pe(r,t,e=0){return Pe.encode(r,t,e),t}function me(r){return Pe.encodingLength(r)}function Yt(r,t){let e=t.byteLength,n=me(r),o=n+me(e),s=new Uint8Array(o+e);return pe(r,s,0),pe(e,s,n),s.set(t,o),new xe(r,e,t,s)}function Xt(r){let t=Tt(r),[e,n]=_e(t),[o,s]=_e(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(e,o,i,t)}function To(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&bo(r.bytes,e.bytes)}}var xe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Lo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Yi(e,Kr(r),t??Y.encoder);default:return Xi(e,Kr(r),t??Lt.encoder)}}var Ro=new WeakMap;function Kr(r){let t=Ro.get(r);if(t==null){let e=new Map;return Ro.set(r,e),e}return t}var lt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==Ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Qi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=Yt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&To(t.multihash,n.multihash)}toString(t){return Lo(this,t)}toJSON(){return{"/":Lo(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Co(n,o,s.bytes))}else if(e[Ji]===!0){let{version:n,multihash:o,code:s}=e,i=Xt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==Ue)throw new Error(`Version 0 CID must use dag-pb (code: ${Ue}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Co(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ue,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new xe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,p]=_e(t.subarray(e));return e+=p,h},o=n(),s=Ue;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Wi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Kr(s).set(n,t),s}};function Wi(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case Lt.prefix:{let e=t??Lt;return[Lt.prefix,e.decode(r)]}case Ce.prefix:{let e=t??Ce;return[Ce.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Yi(r,t,e){let{prefix:n}=e;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Xi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Ue=112,Qi=18;function Co(r,t,e){let n=me(r),o=n+me(t),s=new Uint8Array(o+e.byteLength);return pe(r,s,0),pe(t,s,n),s.set(e,o),s}var Ji=Symbol.for("@ipld/js-cid/CID");var qr={};ht(qr,{identity:()=>Rt});var Po=0,tc="identity",_o=Tt;function ec(r){return Yt(Po,_o(r))}var Rt={code:Po,name:tc,encode:_o,digest:ec};function Ct(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Uo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function rc(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ge(r,...t){if(!rc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function No(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Uo(r.outputLen),Uo(r.blockLen)}function be(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Do(r,t){ge(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var We=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),yt=(r,t)=>r<<32-t|r>>>t;var Pf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Oo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ne(r){return typeof r=="string"&&(r=Oo(r)),ge(r),r}function zr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ge(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var ye=class{clone(){return this._cloneInto()}},_f={}.toString;function Ye(r){let t=n=>r().update(Ne(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Xe(r=32){if(Jt&&typeof Jt.getRandomValues=="function")return Jt.getRandomValues(new Uint8Array(r));if(Jt&&typeof Jt.randomBytes=="function")return Jt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function nc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,f=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+f,c,n)}var ko=(r,t,e)=>r&t^~r&e,Mo=(r,t,e)=>r&t^r&e^t&e,we=class extends ye{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=We(this.buffer)}update(t){be(this);let{view:e,buffer:n,blockLen:o}=this;t=Ne(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=We(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){be(this),Do(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)e[h]=0;nc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=We(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Qe=BigInt(4294967295),Vr=BigInt(32);function Ho(r,t=!1){return t?{h:Number(r&Qe),l:Number(r>>Vr&Qe)}:{h:Number(r>>Vr&Qe)|0,l:Number(r&Qe)|0}}function oc(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Ho(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var sc=(r,t)=>BigInt(r>>>0)<<Vr|BigInt(t>>>0),ic=(r,t,e)=>r>>>e,cc=(r,t,e)=>r<<32-e|t>>>e,ac=(r,t,e)=>r>>>e|t<<32-e,uc=(r,t,e)=>r<<32-e|t>>>e,fc=(r,t,e)=>r<<64-e|t>>>e-32,lc=(r,t,e)=>r>>>e-32|t<<64-e,dc=(r,t)=>t,hc=(r,t)=>r,pc=(r,t,e)=>r<<e|t>>>32-e,mc=(r,t,e)=>t<<e|r>>>32-e,xc=(r,t,e)=>t<<e-32|r>>>64-e,gc=(r,t,e)=>r<<e-32|t>>>64-e;function bc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var yc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),wc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ec=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Sc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,vc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Bc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Ic={fromBig:Ho,split:oc,toBig:sc,shrSH:ic,shrSL:cc,rotrSH:ac,rotrSL:uc,rotrBH:fc,rotrBL:lc,rotr32H:dc,rotr32L:hc,rotlSH:pc,rotlSL:mc,rotlBH:xc,rotlBL:gc,add:bc,add3L:yc,add3H:wc,add4L:Ec,add4H:Sc,add5H:Bc,add5L:vc},O=Ic;var[Ac,Tc]=O.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Mt=new Uint32Array(80),Ht=new Uint32Array(80),Fr=class extends we{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:h,Fl:p,Gh:v,Gl:E,Hh:g,Hl:l}=this;return[t,e,n,o,s,i,c,a,f,u,h,p,v,E,g,l]}set(t,e,n,o,s,i,c,a,f,u,h,p,v,E,g,l){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=h|0,this.Fl=p|0,this.Gh=v|0,this.Gl=E|0,this.Hh=g|0,this.Hl=l|0}process(t,e){for(let m=0;m<16;m++,e+=4)Mt[m]=t.getUint32(e),Ht[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=Mt[m-15]|0,_=Ht[m-15]|0,P=O.rotrSH(I,_,1)^O.rotrSH(I,_,8)^O.shrSH(I,_,7),A=O.rotrSL(I,_,1)^O.rotrSL(I,_,8)^O.shrSL(I,_,7),T=Mt[m-2]|0,C=Ht[m-2]|0,J=O.rotrSH(T,C,19)^O.rotrBH(T,C,61)^O.shrSH(T,C,6),q=O.rotrSL(T,C,19)^O.rotrBL(T,C,61)^O.shrSL(T,C,6),k=O.add4L(A,q,Ht[m-7],Ht[m-16]),tt=O.add4H(k,P,J,Mt[m-7],Mt[m-16]);Mt[m]=tt|0,Ht[m]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:h,El:p,Fh:v,Fl:E,Gh:g,Gl:l,Hh:b,Hl:B}=this;for(let m=0;m<80;m++){let I=O.rotrSH(h,p,14)^O.rotrSH(h,p,18)^O.rotrBH(h,p,41),_=O.rotrSL(h,p,14)^O.rotrSL(h,p,18)^O.rotrBL(h,p,41),P=h&v^~h&g,A=p&E^~p&l,T=O.add5L(B,_,A,Tc[m],Ht[m]),C=O.add5H(T,b,I,P,Ac[m],Mt[m]),J=T|0,q=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),k=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),tt=n&s^n&c^s&c,S=o&i^o&a^i&a;b=g|0,B=l|0,g=v|0,l=E|0,v=h|0,E=p|0,{h,l:p}=O.add(f|0,u|0,C|0,J|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let L=O.add3L(J,k,S);n=O.add3H(L,C,q,tt),o=L|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=O.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=O.add(this.Dh|0,this.Dl|0,f|0,u|0),{h,l:p}=O.add(this.Eh|0,this.El|0,h|0,p|0),{h:v,l:E}=O.add(this.Fh|0,this.Fl|0,v|0,E|0),{h:g,l}=O.add(this.Gh|0,this.Gl|0,g|0,l|0),{h:b,l:B}=O.add(this.Hh|0,this.Hl|0,b|0,B|0),this.set(n,o,s,i,c,a,f,u,h,p,v,E,g,l,b,B)}roundClean(){Mt.fill(0),Ht.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ko=Ye(()=>new Fr);var tr={};ht(tr,{aInRange:()=>pt,abool:()=>wt,abytes:()=>Ee,bitGet:()=>Uc,bitLen:()=>Wr,bitMask:()=>Oe,bitSet:()=>Nc,bytesToHex:()=>_t,bytesToNumberBE:()=>Ut,bytesToNumberLE:()=>qt,concatBytes:()=>Nt,createHmacDrbg:()=>Yr,ensureBytes:()=>X,equalBytes:()=>Pc,hexToBytes:()=>ee,hexToNumber:()=>Zr,inRange:()=>De,isBytes:()=>Kt,memoized:()=>ne,notImplemented:()=>Oc,numberToBytesBE:()=>zt,numberToBytesLE:()=>re,numberToHexUnpadded:()=>te,numberToVarBytesBE:()=>Cc,utf8ToBytes:()=>_c,validateObject:()=>Bt});var jr=BigInt(0),Je=BigInt(1),Lc=BigInt(2);function Kt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ee(r){if(!Kt(r))throw new Error("Uint8Array expected")}function wt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var Rc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function _t(r){Ee(r);let t="";for(let e=0;e<r.length;e++)t+=Rc[r[e]];return t}function te(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Zr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qo(r){if(r>=Pt._0&&r<=Pt._9)return r-Pt._0;if(r>=Pt._A&&r<=Pt._F)return r-(Pt._A-10);if(r>=Pt._a&&r<=Pt._f)return r-(Pt._a-10)}function ee(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=qo(r.charCodeAt(s)),c=qo(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Ut(r){return Zr(_t(r))}function qt(r){return Ee(r),Zr(_t(Uint8Array.from(r).reverse()))}function zt(r,t){return ee(r.toString(16).padStart(t*2,"0"))}function re(r,t){return zt(r,t).reverse()}function Cc(r){return ee(te(r))}function X(r,t,e){let n;if(typeof t=="string")try{n=ee(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Kt(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function Nt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ee(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Pc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function _c(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var $r=r=>typeof r=="bigint"&&jr<=r;function De(r,t,e){return $r(r)&&$r(t)&&$r(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!De(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function Wr(r){let t;for(t=0;r>jr;r>>=Je,t+=1);return t}function Uc(r,t){return r>>BigInt(t)&Je}function Nc(r,t,e){return r|(e?Je:jr)<<BigInt(t)}var Oe=r=>(Lc<<BigInt(r-1))-Je,Gr=r=>new Uint8Array(r),zo=r=>Uint8Array.from(r);function Yr(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Gr(r),o=Gr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...h)=>e(o,n,...h),a=(h=Gr())=>{o=c(zo([0]),h),n=c(),h.length!==0&&(o=c(zo([1]),h),n=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,p=[];for(;h<t;){n=c();let v=n.slice();p.push(v),h+=n.length}return Nt(...p)};return(h,p)=>{i(),a(h);let v;for(;!(v=p(f()));)a();return i(),v}}var Dc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Kt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Bt(r,t,e={}){let n=(o,s,i)=>{let c=Dc[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var Oc=()=>{throw new Error("not implemented")};function ne(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var rt=BigInt(0),j=BigInt(1),oe=BigInt(2),kc=BigInt(3),Xr=BigInt(4),Vo=BigInt(5),Fo=BigInt(8),Mc=BigInt(9),Hc=BigInt(16);function F(r,t){let e=r%t;return e>=rt?e:t+e}function Kc(r,t,e){if(e<=rt||t<rt)throw new Error("Expected power/modulo > 0");if(e===j)return rt;let n=j;for(;t>rt;)t&j&&(n=n*r%e),r=r*r%e,t>>=j;return n}function Z(r,t,e){let n=r;for(;t-- >rt;)n*=n,n%=e;return n}function er(r,t){if(r===rt||t<=rt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=F(r,t),n=t,o=rt,s=j,i=j,c=rt;for(;e!==rt;){let f=n/e,u=n%e,h=o-i*f,p=s-c*f;n=e,e=u,o=i,s=c,i=h,c=p}if(n!==j)throw new Error("invert: does not exist");return F(o,t)}function qc(r){let t=(r-j)/oe,e,n,o;for(e=r-j,n=0;e%oe===rt;e/=oe,n++);for(o=oe;o<r&&Kc(o,t,r)!==r-j;o++);if(n===1){let i=(r+j)/Xr;return function(a,f){let u=a.pow(f,i);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+j)/oe;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),h=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let v=1;for(let g=c.sqr(p);v<f&&!c.eql(g,c.ONE);v++)g=c.sqr(g);let E=c.pow(u,j<<BigInt(f-v-1));u=c.sqr(E),h=c.mul(h,E),p=c.mul(p,u),f=v}return h}}function zc(r){if(r%Xr===kc){let t=(r+j)/Xr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Fo===Vo){let t=(r-Vo)/Fo;return function(n,o){let s=n.mul(o,oe),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,oe),i),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Hc,qc(r)}var $o=(r,t)=>(F(r,t)&j)===j,Vc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vc.reduce((n,o)=>(n[o]="function",n),t);return Bt(r,e)}function Fc(r,t,e){if(e<rt)throw new Error("Expected power > 0");if(e===rt)return r.ONE;if(e===j)return t;let n=r.ONE,o=t;for(;e>rt;)e&j&&(n=r.mul(n,o)),o=r.sqr(o),e>>=j;return n}function $c(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function Jr(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Vt(r,t,e=!1,n={}){if(r<=rt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Jr(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=zc(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Oe(o),ZERO:rt,ONE:j,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return rt<=a&&a<r},is0:a=>a===rt,isOdd:a=>(a&j)===j,neg:a=>F(-a,r),eql:(a,f)=>a===f,sqr:a=>F(a*a,r),add:(a,f)=>F(a+f,r),sub:(a,f)=>F(a-f,r),mul:(a,f)=>F(a*f,r),pow:(a,f)=>Fc(c,a,f),div:(a,f)=>F(a*er(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>er(a,r),sqrt:n.sqrt||(a=>i(c,a)),invertBatch:a=>$c(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?re(a,s):zt(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return e?qt(a):Ut(a)}});return Object.freeze(c)}function Go(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function tn(r){let t=Go(r);return t+Math.ceil(t/2)}function jo(r,t,e=!1){let n=r.length,o=Go(t),s=tn(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?Ut(r):qt(r),c=F(i,t-j)+j;return e?re(c,o):zt(c,o)}var jc=BigInt(0),en=BigInt(1),rn=new WeakMap,Zo=new WeakMap;function rr(r,t){let e=(s,i)=>{let c=i.negate();return s?c:i},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},o=s=>{n(s);let i=Math.ceil(t/s)+1,c=2**(s-1);return{windows:i,windowSize:c}};return{constTimeNegate:e,unsafeLadder(s,i){let c=r.ZERO,a=s;for(;i>jc;)i&en&&(c=c.add(a)),a=a.double(),i>>=en;return c},precomputeWindow(s,i){let{windows:c,windowSize:a}=o(i),f=[],u=s,h=u;for(let p=0;p<c;p++){h=u,f.push(h);for(let v=1;v<a;v++)h=h.add(u),f.push(h);u=h.double()}return f},wNAF(s,i,c){let{windows:a,windowSize:f}=o(s),u=r.ZERO,h=r.BASE,p=BigInt(2**s-1),v=2**s,E=BigInt(s);for(let g=0;g<a;g++){let l=g*f,b=Number(c&p);c>>=E,b>f&&(b-=v,c+=en);let B=l,m=l+Math.abs(b)-1,I=g%2!==0,_=b<0;b===0?h=h.add(e(I,i[B])):u=u.add(e(_,i[m]))}return{p:u,f:h}},wNAFCached(s,i,c){let a=Zo.get(s)||1,f=rn.get(s);return f||(f=this.precomputeWindow(s,a),a!==1&&rn.set(s,c(f))),this.wNAF(a,f,i)},setWindowSize(s,i){n(i),Zo.set(s,i),rn.delete(s)}}}function nr(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,h)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${h}`)}),e.forEach((u,h)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${h}`)});let o=Wr(BigInt(e.length)),s=o>12?o-3:o>4?o-2:o?2:1,i=(1<<s)-1,c=new Array(i+1).fill(r.ZERO),a=Math.floor((t.BITS-1)/s)*s,f=r.ZERO;for(let u=a;u>=0;u-=s){c.fill(r.ZERO);for(let p=0;p<n.length;p++){let v=n[p],E=Number(v>>BigInt(u)&BigInt(i));c[E]=c[E].add(e[p])}let h=r.ZERO;for(let p=c.length-1,v=r.ZERO;p>0;p--)v=v.add(c[p]),h=h.add(v);if(f=f.add(h),u!==0)for(let p=0;p<s;p++)f=f.double()}return f}function ke(r){return Qr(r.Fp),Bt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Et=BigInt(0),mt=BigInt(1),or=BigInt(2),Zc=BigInt(8),Wc={zip215:!0};function Yc(r){let t=ke(r);return Bt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Wo(r){let t=Yc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,f=or<<BigInt(c*8)-mt,u=e.create,h=Vt(t.n,t.nBitLength),p=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(d))}}catch{return{isValid:!1,value:Et}}}),v=t.adjustScalarBytes||(x=>x),E=t.domain||((x,d,y)=>{if(wt("phflag",y),d.length||y)throw new Error("Contexts/pre-hash are not supported");return x});function g(x,d){pt("coordinate "+x,d,Et,f)}function l(x){if(!(x instanceof m))throw new Error("ExtendedPoint expected")}let b=ne((x,d)=>{let{ex:y,ey:R,ez:N}=x,D=x.is0();d==null&&(d=D?Zc:e.inv(N));let M=u(y*d),K=u(R*d),H=u(N*d);if(D)return{x:Et,y:mt};if(H!==mt)throw new Error("invZ was invalid");return{x:M,y:K}}),B=ne(x=>{let{a:d,d:y}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:R,ey:N,ez:D,et:M}=x,K=u(R*R),H=u(N*N),V=u(D*D),G=u(V*V),nt=u(K*d),ot=u(V*u(nt+H)),ct=u(G+u(y*u(K*H)));if(ot!==ct)throw new Error("bad point: equation left != right (1)");let ft=u(R*N),et=u(D*M);if(ft!==et)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,y,R,N){this.ex=d,this.ey=y,this.ez=R,this.et=N,g("x",d),g("y",y),g("z",R),g("t",N),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x:y,y:R}=d||{};return g("x",y),g("y",R),new m(y,R,mt,u(y*R))}static normalizeZ(d){let y=e.invertBatch(d.map(R=>R.ez));return d.map((R,N)=>R.toAffine(y[N])).map(m.fromAffine)}static msm(d,y){return nr(m,h,d,y)}_setWindowSize(d){P.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){l(d);let{ex:y,ey:R,ez:N}=this,{ex:D,ey:M,ez:K}=d,H=u(y*K),V=u(D*N),G=u(R*K),nt=u(M*N);return H===V&&G===nt}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:y,ey:R,ez:N}=this,D=u(y*y),M=u(R*R),K=u(or*u(N*N)),H=u(d*D),V=y+R,G=u(u(V*V)-D-M),nt=H+M,ot=nt-K,ct=H-M,ft=u(G*ot),et=u(nt*ct),dt=u(G*ct),At=u(ot*nt);return new m(ft,et,At,dt)}add(d){l(d);let{a:y,d:R}=t,{ex:N,ey:D,ez:M,et:K}=this,{ex:H,ey:V,ez:G,et:nt}=d;if(y===BigInt(-1)){let co=u((D-N)*(V+H)),ao=u((D+N)*(V-H)),Rr=u(ao-co);if(Rr===Et)return this.double();let uo=u(M*or*nt),fo=u(K*or*G),lo=fo+uo,ho=ao+co,po=fo-uo,ci=u(lo*Rr),ai=u(ho*po),ui=u(lo*po),fi=u(Rr*ho);return new m(ci,ai,fi,ui)}let ot=u(N*H),ct=u(D*V),ft=u(K*R*nt),et=u(M*G),dt=u((N+D)*(H+V)-ot-ct),At=et-ft,Te=et+ft,Le=u(ct-y*ot),ni=u(dt*At),oi=u(Te*Le),si=u(dt*Le),ii=u(At*Te);return new m(ni,oi,ii,si)}subtract(d){return this.add(d.negate())}wNAF(d){return P.wNAFCached(this,d,m.normalizeZ)}multiply(d){let y=d;pt("scalar",y,mt,n);let{p:R,f:N}=this.wNAF(y);return m.normalizeZ([R,N])[0]}multiplyUnsafe(d){let y=d;return pt("scalar",y,Et,n),y===Et?_:this.equals(_)||y===mt?this:this.equals(I)?this.wNAF(y).p:P.unsafeLadder(this,y)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===mt?this:this.multiplyUnsafe(d)}static fromHex(d,y=!1){let{d:R,a:N}=t,D=e.BYTES;d=X("pointHex",d,D),wt("zip215",y);let M=d.slice(),K=d[D-1];M[D-1]=K&-129;let H=qt(M),V=y?f:e.ORDER;pt("pointHex.y",H,Et,V);let G=u(H*H),nt=u(G-mt),ot=u(R*G-N),{isValid:ct,value:ft}=p(nt,ot);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let et=(ft&mt)===mt,dt=(K&128)!==0;if(!y&&ft===Et&&dt)throw new Error("Point.fromHex: x=0 and x_0=1");return dt!==et&&(ft=u(-ft)),m.fromAffine({x:ft,y:H})}static fromPrivateKey(d){return C(d).point}toRawBytes(){let{x:d,y}=this.toAffine(),R=re(y,e.BYTES);return R[R.length-1]|=d&mt?128:0,R}toHex(){return _t(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,mt,u(t.Gx*t.Gy)),m.ZERO=new m(Et,mt,mt,Et);let{BASE:I,ZERO:_}=m,P=rr(m,c*8);function A(x){return F(x,n)}function T(x){return A(qt(x))}function C(x){let d=c;x=X("private key",x,d);let y=X("hashed private key",s(x),2*d),R=v(y.slice(0,d)),N=y.slice(d,2*d),D=T(R),M=I.multiply(D),K=M.toRawBytes();return{head:R,prefix:N,scalar:D,point:M,pointBytes:K}}function J(x){return C(x).pointBytes}function q(x=new Uint8Array,...d){let y=Nt(...d);return T(s(E(y,X("context",x),!!o)))}function k(x,d,y={}){x=X("message",x),o&&(x=o(x));let{prefix:R,scalar:N,pointBytes:D}=C(d),M=q(y.context,R,x),K=I.multiply(M).toRawBytes(),H=q(y.context,K,D,x),V=A(M+H*N);pt("signature.s",V,Et,n);let G=Nt(K,re(V,e.BYTES));return X("result",G,c*2)}let tt=Wc;function S(x,d,y,R=tt){let{context:N,zip215:D}=R,M=e.BYTES;x=X("signature",x,2*M),d=X("message",d),D!==void 0&&wt("zip215",D),o&&(d=o(d));let K=qt(x.slice(M,2*M)),H,V,G;try{H=m.fromHex(y,D),V=m.fromHex(x.slice(0,M),D),G=I.multiplyUnsafe(K)}catch{return!1}if(!D&&H.isSmallOrder())return!1;let nt=q(N,V.toRawBytes(),H.toRawBytes(),d);return V.add(H.multiplyUnsafe(nt)).subtract(G).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:J,sign:k,verify:S,ExtendedPoint:m,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,d=m.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var nn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Yo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),el=BigInt(0),Xc=BigInt(1),Xo=BigInt(2),rl=BigInt(3),Qc=BigInt(5),Jc=BigInt(8);function ta(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=nn,c=r*r%s*r%s,a=Z(c,Xo,s)*c%s,f=Z(a,Xc,s)*r%s,u=Z(f,Qc,s)*f%s,h=Z(u,t,s)*u%s,p=Z(h,e,s)*h%s,v=Z(p,n,s)*p%s,E=Z(v,o,s)*v%s,g=Z(E,o,s)*v%s,l=Z(g,t,s)*u%s;return{pow_p_5_8:Z(l,Xo,s)*r%s,b2:c}}function ea(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ra(r,t){let e=nn,n=F(t*t*t,e),o=F(n*n*t,e),s=ta(r*o).pow_p_5_8,i=F(r*n*s,e),c=F(t*i*i,e),a=i,f=F(i*Yo,e),u=c===r,h=c===F(-r,e),p=c===F(-r*Yo,e);return u&&(i=a),(h||p)&&(i=f),$o(i,e)&&(i=F(-i,e)),{isValid:u||h,value:i}}var na=Vt(nn,void 0,!0),oa={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:na,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Jc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ko,randomBytes:Xe,adjustScalarBytes:ea,uvRatio:ra},Qo=Wo(oa);var sr=32;function Jo(r,t,e){return Qo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ir=class{type="Ed25519";raw;constructor(t){this.raw=on(t,sr)}toMultihash(){return Rt.digest(cr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ct(this.raw,t.raw)}verify(t,e){return Jo(this.raw,e,t)}};function es(r){return r=on(r,sr),new ir(r)}function on(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new de(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function St(r=0){return new Uint8Array(r)}var ia=Math.pow(2,7),ca=Math.pow(2,14),aa=Math.pow(2,21),sn=Math.pow(2,28),cn=Math.pow(2,35),an=Math.pow(2,42),un=Math.pow(2,49),z=128,at=127;function xt(r){if(r<ia)return 1;if(r<ca)return 2;if(r<aa)return 3;if(r<sn)return 4;if(r<cn)return 5;if(r<an)return 6;if(r<un)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function fn(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|z,r/=128;case 7:t[e++]=r&255|z,r/=128;case 6:t[e++]=r&255|z,r/=128;case 5:t[e++]=r&255|z,r/=128;case 4:t[e++]=r&255|z,r>>>=7;case 3:t[e++]=r&255|z,r>>>=7;case 2:t[e++]=r&255|z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ua(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|z),r/=128;case 7:t.set(e++,r&255|z),r/=128;case 6:t.set(e++,r&255|z),r/=128;case 5:t.set(e++,r&255|z),r/=128;case 4:t.set(e++,r&255|z),r>>>=7;case 3:t.set(e++,r&255|z),r>>>=7;case 2:t.set(e++,r&255|z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function ln(r,t){let e=r[t],n=0;if(n+=e&at,e<z||(e=r[t+1],n+=(e&at)<<7,e<z)||(e=r[t+2],n+=(e&at)<<14,e<z)||(e=r[t+3],n+=(e&at)<<21,e<z)||(e=r[t+4],n+=(e&at)*sn,e<z)||(e=r[t+5],n+=(e&at)*cn,e<z)||(e=r[t+6],n+=(e&at)*an,e<z)||(e=r[t+7],n+=(e&at)*un,e<z))return n;throw new RangeError("Could not decode varint")}function fa(r,t){let e=r.get(t),n=0;if(n+=e&at,e<z||(e=r.get(t+1),n+=(e&at)<<7,e<z)||(e=r.get(t+2),n+=(e&at)<<14,e<z)||(e=r.get(t+3),n+=(e&at)<<21,e<z)||(e=r.get(t+4),n+=(e&at)*sn,e<z)||(e=r.get(t+5),n+=(e&at)*cn,e<z)||(e=r.get(t+6),n+=(e&at)*an,e<z)||(e=r.get(t+7),n+=(e&at)*un,e<z))return n;throw new RangeError("Could not decode varint")}function Se(r,t,e=0){return t==null&&(t=St(xt(r))),t instanceof Uint8Array?fn(r,t,e):ua(r,t,e)}function se(r,t=0){return r instanceof Uint8Array?ln(r,t):fa(r,t)}var dn=new Float32Array([-0]),Ft=new Uint8Array(dn.buffer);function ns(r,t,e){dn[0]=r,t[e]=Ft[0],t[e+1]=Ft[1],t[e+2]=Ft[2],t[e+3]=Ft[3]}function os(r,t){return Ft[0]=r[t],Ft[1]=r[t+1],Ft[2]=r[t+2],Ft[3]=r[t+3],dn[0]}var hn=new Float64Array([-0]),ut=new Uint8Array(hn.buffer);function ss(r,t,e){hn[0]=r,t[e]=ut[0],t[e+1]=ut[1],t[e+2]=ut[2],t[e+3]=ut[3],t[e+4]=ut[4],t[e+5]=ut[5],t[e+6]=ut[6],t[e+7]=ut[7]}function is(r,t){return ut[0]=r[t],ut[1]=r[t+1],ut[2]=r[t+2],ut[3]=r[t+3],ut[4]=r[t+4],ut[5]=r[t+5],ut[6]=r[t+6],ut[7]=r[t+7],hn[0]}var la=BigInt(Number.MAX_SAFE_INTEGER),da=BigInt(Number.MIN_SAFE_INTEGER),gt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+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 e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(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,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ie;if(t<la&&t>da)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>cs&&(o=0n,++n>cs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ie;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ie}},ie=new gt(0,0);ie.toBigInt=function(){return 0n};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var cs=4294967296n;function as(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function us(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function pn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function vt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ar(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var mn=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,vt(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 vt(this,4);return ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw vt(this,4);return ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw vt(this,4);let t=os(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw vt(this,4);let t=is(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw vt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return us(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw vt(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 gt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*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;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw vt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw vt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw vt(this,8);let t=ar(this.buf,this.pos+=4),e=ar(this.buf,this.pos+=4);return new gt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ln(this.buf,this.pos);return this.pos+=xt(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 xn(r){return new mn(r instanceof Uint8Array?r:r.subarray())}function ur(r,t,e){let n=xn(r);return t.decode(n,void 0,e)}var gn={};ht(gn,{base10:()=>ha});var ha=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var bn={};ht(bn,{base16:()=>pa,base16upper:()=>ma});var pa=W({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ma=W({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yn={};ht(yn,{base2:()=>xa});var xa=W({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wn={};ht(wn,{base256emoji:()=>Ea});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}"),ga=ls.reduce((r,t,e)=>(r[e]=t,r),[]),ba=ls.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function ya(r){return r.reduce((t,e)=>(t+=ga[e],t),"")}function wa(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=ba[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ea=he({prefix:"\u{1F680}",name:"base256emoji",encode:ya,decode:wa});var En={};ht(En,{base64:()=>Sa,base64pad:()=>va,base64url:()=>Ba,base64urlpad:()=>Ia});var Sa=W({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),va=W({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ba=W({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ia=W({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Sn={};ht(Sn,{base8:()=>Aa});var Aa=W({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var vn={};ht(vn,{identity:()=>Ta});var Ta=he({prefix:"\0",name:"identity",encode:r=>wo(r),decode:r=>yo(r)});var Ml=new TextEncoder,Hl=new TextDecoder;var An={};ht(An,{sha256:()=>Me,sha512:()=>Ca});function In({name:r,code:t,encode:e}){return new Bn(r,t,e)}var Bn=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Yt(this.code,e):e.then(n=>Yt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function hs(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Me=In({name:"sha2-256",code:18,encode:hs("SHA-256")}),Ca=In({name:"sha2-512",code:19,encode:hs("SHA-512")});var He={...vn,...yn,...Sn,...gn,...bn,...kr,...Mr,...Or,...En,...wn},Xl={...An,...qr};function ms(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ps=ms("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Tn=ms("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=St(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Pa={utf8:ps,"utf-8":ps,hex:He.base16,latin1:Tn,ascii:Tn,binary:Tn,...He},fr=Pa;function $t(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Ln(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return St(i);o+i>t&&(n=St(t),o=0);let c=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),c}}var ce=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Rn(){}var Pn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},_a=Ln();function Ua(r){return globalThis.Buffer!=null?St(r):_a(r)}var qe=class{len;head;tail;states;constructor(){this.len=0,this.head=new ce(Rn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ce(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new _n((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(lr,10,gt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=gt.fromBigInt(t);return this._push(lr,e.length(),e)}uint64Number(t){return this._push(fn,xt(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 e=gt.fromBigInt(t).zzEncode();return this._push(lr,e.length(),e)}sint64Number(t){let e=gt.fromNumber(t).zzEncode();return this._push(lr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Cn,1,t?1:0)}fixed32(t){return this._push(Ke,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=gt.fromBigInt(t);return this._push(Ke,4,e.lo)._push(Ke,4,e.hi)}fixed64Number(t){let e=gt.fromNumber(t);return this._push(Ke,4,e.lo)._push(Ke,4,e.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(ns,4,t)}double(t){return this._push(ss,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Cn,1,0):this.uint32(e)._push(Da,e,t)}string(t){let e=as(t);return e!==0?this.uint32(e)._push(pn,e,t):this._push(Cn,1,0)}fork(){return this.states=new Pn(this),this.head=this.tail=new ce(Rn,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 ce(Rn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Ua(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Cn(r,t,e){t[e]=r&255}function Na(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var _n=class extends ce{next;constructor(t,e){super(Na,t,e),this.next=void 0}};function lr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ke(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Da(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(qe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Oa,t,r),this},qe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ka,t,r),this});function Oa(r,t,e){t.set(r,e)}function ka(r,t,e){r.length<40?pn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($t(r),e)}function Un(){return new qe}function dr(r,t){let e=Un();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var ve;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(ve||(ve={}));function hr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Nn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return hr("enum",ve.VARINT,e,n)}function pr(r,t){return hr("message",ve.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(bt||(bt={}));var Dn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Dn||(Dn={}));(function(r){r.codec=()=>Nn(Dn)})(bt||(bt={}));var ze;(function(r){let t;r.codec=()=>(t==null&&(t=pr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>dr(e,r.codec()),r.decode=(e,n)=>ur(e,r.codec(),n)})(ze||(ze={}));var On;(function(r){let t;r.codec=()=>(t==null&&(t=pr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>dr(e,r.codec()),r.decode=(e,n)=>ur(e,r.codec(),n)})(On||(On={}));var Ha=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jt=new Uint32Array(64),kn=class extends we{constructor(){super(64,32,8,!1),this.A=Gt[0]|0,this.B=Gt[1]|0,this.C=Gt[2]|0,this.D=Gt[3]|0,this.E=Gt[4]|0,this.F=Gt[5]|0,this.G=Gt[6]|0,this.H=Gt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let h=0;h<16;h++,e+=4)jt[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let p=jt[h-15],v=jt[h-2],E=yt(p,7)^yt(p,18)^p>>>3,g=yt(v,17)^yt(v,19)^v>>>10;jt[h]=g+jt[h-7]+E+jt[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let h=0;h<64;h++){let p=yt(c,6)^yt(c,11)^yt(c,25),v=u+p+ko(c,a,f)+Ha[h]+jt[h]|0,g=(yt(n,2)^yt(n,13)^yt(n,22))+Mo(n,o,s)|0;u=f,f=a,a=c,c=i+v|0,i=s,s=o,o=n,n=v+g|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xs=Ye(()=>new kn);function st(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ve=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var mr=class extends ye{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,No(t);let n=Ne(e);if(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 o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return be(this),this.iHash.update(t),this}digestInto(t){be(this),ge(t,this.outputLen),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||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Mn=(r,t,e)=>new mr(r,t).update(e).digest();Mn.create=(r,t)=>new mr(r,t);function gs(r){r.lowS!==void 0&&wt("lowS",r.lowS),r.prehash!==void 0&&wt("prehash",r.prehash)}function Ka(r){let t=ke(r);Bt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:qa,hexToBytes:za}=tr,Dt={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=Dt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=te(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?te(o.length/2|128):"";return`${te(r)}${s}${o}${t}`},decode(r,t){let{Err:e}=Dt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Dt;if(r<Ot)throw new t("integer: negative integers are not allowed");let e=te(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=Dt;if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return qa(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Dt,o=typeof r=="string"?za(r):r;Ee(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("Invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=Dt,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},Ot=BigInt(0),it=BigInt(1),Kd=BigInt(2),bs=BigInt(3),qd=BigInt(4);function Va(r){let t=Ka(r),{Fp:e}=t,n=Vt(t.n,t.nBitLength),o=t.toBytes||((g,l,b)=>{let B=l.toAffine();return Nt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(g=>{let l=g.subarray(1),b=e.fromBytes(l.subarray(0,e.BYTES)),B=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:b,y:B}});function i(g){let{a:l,b}=t,B=e.sqr(g),m=e.mul(B,g);return e.add(e.add(m,e.mul(g,l)),b)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return De(g,it,t.n)}function a(g){let{allowedPrivateKeyLengths:l,nByteLength:b,wrapPrivateKey:B,n:m}=t;if(l&&typeof g!="bigint"){if(Kt(g)&&(g=_t(g)),typeof g!="string"||!l.includes(g.length))throw new Error("Invalid key");g=g.padStart(b*2,"0")}let I;try{I=typeof g=="bigint"?g:Ut(X("private key",g,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof g}`)}return B&&(I=F(I,m)),pt("private key",I,it,m),I}function f(g){if(!(g instanceof p))throw new Error("ProjectivePoint expected")}let u=ne((g,l)=>{let{px:b,py:B,pz:m}=g;if(e.eql(m,e.ONE))return{x:b,y:B};let I=g.is0();l==null&&(l=I?e.ONE:e.inv(m));let _=e.mul(b,l),P=e.mul(B,l),A=e.mul(m,l);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(A,e.ONE))throw new Error("invZ was invalid");return{x:_,y:P}}),h=ne(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:l,y:b}=g.toAffine();if(!e.isValid(l)||!e.isValid(b))throw new Error("bad point: x or y not FE");let B=e.sqr(b),m=i(l);if(!e.eql(B,m))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(l,b,B){if(this.px=l,this.py=b,this.pz=B,l==null||!e.isValid(l))throw new Error("x required");if(b==null||!e.isValid(b))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(l){let{x:b,y:B}=l||{};if(!l||!e.isValid(b)||!e.isValid(B))throw new Error("invalid affine point");if(l instanceof p)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(b)&&m(B)?p.ZERO:new p(b,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){let b=e.invertBatch(l.map(B=>B.pz));return l.map((B,m)=>B.toAffine(b[m])).map(p.fromAffine)}static fromHex(l){let b=p.fromAffine(s(X("pointHex",l)));return b.assertValidity(),b}static fromPrivateKey(l){return p.BASE.multiply(a(l))}static msm(l,b){return nr(p,n,l,b)}_setWindowSize(l){E.setWindowSize(this,l)}assertValidity(){h(this)}hasEvenY(){let{y:l}=this.toAffine();if(e.isOdd)return!e.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){f(l);let{px:b,py:B,pz:m}=this,{px:I,py:_,pz:P}=l,A=e.eql(e.mul(b,P),e.mul(I,m)),T=e.eql(e.mul(B,P),e.mul(_,m));return A&&T}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b}=t,B=e.mul(b,bs),{px:m,py:I,pz:_}=this,P=e.ZERO,A=e.ZERO,T=e.ZERO,C=e.mul(m,m),J=e.mul(I,I),q=e.mul(_,_),k=e.mul(m,I);return k=e.add(k,k),T=e.mul(m,_),T=e.add(T,T),P=e.mul(l,T),A=e.mul(B,q),A=e.add(P,A),P=e.sub(J,A),A=e.add(J,A),A=e.mul(P,A),P=e.mul(k,P),T=e.mul(B,T),q=e.mul(l,q),k=e.sub(C,q),k=e.mul(l,k),k=e.add(k,T),T=e.add(C,C),C=e.add(T,C),C=e.add(C,q),C=e.mul(C,k),A=e.add(A,C),q=e.mul(I,_),q=e.add(q,q),C=e.mul(q,k),P=e.sub(P,C),T=e.mul(q,J),T=e.add(T,T),T=e.add(T,T),new p(P,A,T)}add(l){f(l);let{px:b,py:B,pz:m}=this,{px:I,py:_,pz:P}=l,A=e.ZERO,T=e.ZERO,C=e.ZERO,J=t.a,q=e.mul(t.b,bs),k=e.mul(b,I),tt=e.mul(B,_),S=e.mul(m,P),L=e.add(b,B),x=e.add(I,_);L=e.mul(L,x),x=e.add(k,tt),L=e.sub(L,x),x=e.add(b,m);let d=e.add(I,P);return x=e.mul(x,d),d=e.add(k,S),x=e.sub(x,d),d=e.add(B,m),A=e.add(_,P),d=e.mul(d,A),A=e.add(tt,S),d=e.sub(d,A),C=e.mul(J,x),A=e.mul(q,S),C=e.add(A,C),A=e.sub(tt,C),C=e.add(tt,C),T=e.mul(A,C),tt=e.add(k,k),tt=e.add(tt,k),S=e.mul(J,S),x=e.mul(q,x),tt=e.add(tt,S),S=e.sub(k,S),S=e.mul(J,S),x=e.add(x,S),k=e.mul(tt,x),T=e.add(T,k),k=e.mul(d,x),A=e.mul(L,A),A=e.sub(A,k),k=e.mul(L,tt),C=e.mul(d,C),C=e.add(C,k),new p(A,T,C)}subtract(l){return this.add(l.negate())}is0(){return this.equals(p.ZERO)}wNAF(l){return E.wNAFCached(this,l,p.normalizeZ)}multiplyUnsafe(l){pt("scalar",l,Ot,t.n);let b=p.ZERO;if(l===Ot)return b;if(l===it)return this;let{endo:B}=t;if(!B)return E.unsafeLadder(this,l);let{k1neg:m,k1:I,k2neg:_,k2:P}=B.splitScalar(l),A=b,T=b,C=this;for(;I>Ot||P>Ot;)I&it&&(A=A.add(C)),P&it&&(T=T.add(C)),C=C.double(),I>>=it,P>>=it;return m&&(A=A.negate()),_&&(T=T.negate()),T=new p(e.mul(T.px,B.beta),T.py,T.pz),A.add(T)}multiply(l){let{endo:b,n:B}=t;pt("scalar",l,it,B);let m,I;if(b){let{k1neg:_,k1:P,k2neg:A,k2:T}=b.splitScalar(l),{p:C,f:J}=this.wNAF(P),{p:q,f:k}=this.wNAF(T);C=E.constTimeNegate(_,C),q=E.constTimeNegate(A,q),q=new p(e.mul(q.px,b.beta),q.py,q.pz),m=C.add(q),I=J.add(k)}else{let{p:_,f:P}=this.wNAF(l);m=_,I=P}return p.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(l,b,B){let m=p.BASE,I=(P,A)=>A===Ot||A===it||!P.equals(m)?P.multiplyUnsafe(A):P.multiply(A),_=I(this,b).add(I(l,B));return _.is0()?void 0:_}toAffine(l){return u(this,l)}isTorsionFree(){let{h:l,isTorsionFree:b}=t;if(l===it)return!0;if(b)return b(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:l,clearCofactor:b}=t;return l===it?this:b?b(p,this):this.multiplyUnsafe(t.h)}toRawBytes(l=!0){return wt("isCompressed",l),this.assertValidity(),o(p,this,l)}toHex(l=!0){return wt("isCompressed",l),_t(this.toRawBytes(l))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let v=t.nBitLength,E=rr(p,t.endo?Math.ceil(v/2):v);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Fa(r){let t=ke(r);return Bt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ys(r){let t=Fa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(S){return F(S,n)}function c(S){return er(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:h}=Va({...t,toBytes(S,L,x){let d=L.toAffine(),y=e.toBytes(d.x),R=Nt;return wt("isCompressed",x),x?R(Uint8Array.from([L.hasEvenY()?2:3]),y):R(Uint8Array.from([4]),y,e.toBytes(d.y))},fromBytes(S){let L=S.length,x=S[0],d=S.subarray(1);if(L===o&&(x===2||x===3)){let y=Ut(d);if(!De(y,it,e.ORDER))throw new Error("Point is not on curve");let R=u(y),N;try{N=e.sqrt(R)}catch(K){let H=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+H)}let D=(N&it)===it;return(x&1)===1!==D&&(N=e.neg(N)),{x:y,y:N}}else if(L===s&&x===4){let y=e.fromBytes(d.subarray(0,e.BYTES)),R=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:y,y:R}}else throw new Error(`Point of length ${L} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),p=S=>_t(zt(S,t.nByteLength));function v(S){let L=n>>it;return S>L}function E(S){return v(S)?i(-S):S}let g=(S,L,x)=>Ut(S.slice(L,x));class l{constructor(L,x,d){this.r=L,this.s=x,this.recovery=d,this.assertValidity()}static fromCompact(L){let x=t.nByteLength;return L=X("compactSignature",L,x*2),new l(g(L,0,x),g(L,x,2*x))}static fromDER(L){let{r:x,s:d}=Dt.toSig(X("DER",L));return new l(x,d)}assertValidity(){pt("r",this.r,it,n),pt("s",this.s,it,n)}addRecoveryBit(L){return new l(this.r,this.s,L)}recoverPublicKey(L){let{r:x,s:d,recovery:y}=this,R=P(X("msgHash",L));if(y==null||![0,1,2,3].includes(y))throw new Error("recovery id invalid");let N=y===2||y===3?x+t.n:x;if(N>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=y&1?"03":"02",M=a.fromHex(D+p(N)),K=c(N),H=i(-R*K),V=i(d*K),G=a.BASE.multiplyAndAddUnsafe(M,H,V);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new l(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return ee(this.toDERHex())}toDERHex(){return Dt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ee(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let b={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=tn(t.n);return jo(t.randomBytes(S),t.n)},precompute(S=8,L=a.BASE){return L._setWindowSize(S),L.multiply(BigInt(3)),L}};function B(S,L=!0){return a.fromPrivateKey(S).toRawBytes(L)}function m(S){let L=Kt(S),x=typeof S=="string",d=(L||x)&&S.length;return L?d===o||d===s:x?d===2*o||d===2*s:S instanceof a}function I(S,L,x=!0){if(m(S))throw new Error("first arg must be private key");if(!m(L))throw new Error("second arg must be public key");return a.fromHex(L).multiply(f(S)).toRawBytes(x)}let _=t.bits2int||function(S){let L=Ut(S),x=S.length*8-t.nBitLength;return x>0?L>>BigInt(x):L},P=t.bits2int_modN||function(S){return i(_(S))},A=Oe(t.nBitLength);function T(S){return pt(`num < 2^${t.nBitLength}`,S,Ot,A),zt(S,t.nByteLength)}function C(S,L,x=J){if(["recovered","canonical"].some(ot=>ot in x))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:y}=t,{lowS:R,prehash:N,extraEntropy:D}=x;R==null&&(R=!0),S=X("msgHash",S),gs(x),N&&(S=X("prehashed msgHash",d(S)));let M=P(S),K=f(L),H=[T(K),T(M)];if(D!=null&&D!==!1){let ot=D===!0?y(e.BYTES):D;H.push(X("extraEntropy",ot))}let V=Nt(...H),G=M;function nt(ot){let ct=_(ot);if(!h(ct))return;let ft=c(ct),et=a.BASE.multiply(ct).toAffine(),dt=i(et.x);if(dt===Ot)return;let At=i(ft*i(G+dt*K));if(At===Ot)return;let Te=(et.x===dt?0:2)|Number(et.y&it),Le=At;return R&&v(At)&&(Le=E(At),Te^=1),new l(dt,Le,Te)}return{seed:V,k2sig:nt}}let J={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function k(S,L,x=J){let{seed:d,k2sig:y}=C(S,L,x),R=t;return Yr(R.hash.outputLen,R.nByteLength,R.hmac)(d,y)}a.BASE._setWindowSize(8);function tt(S,L,x,d=q){let y=S;if(L=X("msgHash",L),x=X("publicKey",x),"strict"in d)throw new Error("options.strict was renamed to lowS");gs(d);let{lowS:R,prehash:N}=d,D,M;try{if(typeof y=="string"||Kt(y))try{D=l.fromDER(y)}catch(et){if(!(et instanceof Dt.Err))throw et;D=l.fromCompact(y)}else if(typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint"){let{r:et,s:dt}=y;D=new l(et,dt)}else throw new Error("PARSE");M=a.fromHex(x)}catch(et){if(et.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(R&&D.hasHighS())return!1;N&&(L=t.hash(L));let{r:K,s:H}=D,V=P(L),G=c(H),nt=i(V*G),ot=i(K*G),ct=a.BASE.multiplyAndAddUnsafe(M,nt,ot)?.toAffine();return ct?i(ct.x)===K:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:I,sign:k,verify:tt,ProjectivePoint:a,Signature:l,utils:b}}function $a(r){return{hash:r,hmac:(t,...e)=>Mn(r,t,zr(...e)),randomBytes:Xe}}function ws(r,t){let e=n=>ys({...r,...$a(n)});return Object.freeze({...e(t),create:e})}var vs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Es=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ga=BigInt(1),Hn=BigInt(2),Ss=(r,t)=>(r+t/Hn)/t;function ja(r){let t=vs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,h=Z(u,e,t)*u%t,p=Z(h,e,t)*u%t,v=Z(p,Hn,t)*f%t,E=Z(v,o,t)*v%t,g=Z(E,s,t)*E%t,l=Z(g,c,t)*g%t,b=Z(l,a,t)*l%t,B=Z(b,c,t)*g%t,m=Z(B,e,t)*u%t,I=Z(m,i,t)*E%t,_=Z(I,n,t)*f%t,P=Z(_,Hn,t);if(!Kn.eql(Kn.sqr(P),r))throw new Error("Cannot find square root");return P}var Kn=Vt(vs,void 0,void 0,{sqrt:ja}),ae=ws({a:BigInt(0),b:BigInt(7),Fp:Kn,n:Es,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Es,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ga*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Ss(s*r,t),a=Ss(-n*r,t),f=F(r-c*e-a*o,t),u=F(-c*n-a*s,t),h=f>i,p=u>i;if(h&&(f=t-f),p&&(u=t-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:h,k1:f,k2neg:p,k2:u}}}},xs),Yd=BigInt(0);var Xd=ae.ProjectivePoint;function It(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=St(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Bs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Is(r,t,e){let n=Me.digest(e instanceof Uint8Array?e:e.subarray());if(Bs(n))return n.then(({digest:o})=>ae.verify(t,o,r)).catch(o=>{throw new Ve(String(o))});try{return ae.verify(t,n.digest,r)}catch(o){throw new Ve(String(o))}}var xr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ts(t),this.raw=As(this._key)}toMultihash(){return Rt.digest(cr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ct(this.raw,t.raw)}verify(t,e){return Is(this._key,e,t)}};function Ls(r){return new xr(r)}function As(r){return ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ts(r){try{return ae.ProjectivePoint.fromHex(r),r}catch(t){throw new $e(String(t))}}function Rs(r){let{Type:t,Data:e}=ze.decode(r.digest),n=e??new Uint8Array;switch(t){case bt.Ed25519:return es(n);case bt.secp256k1:return Ls(n);default:throw new Re}}function cr(r){return ze.encode({Type:bt[r.type],Data:r.raw})}var Cs=Symbol.for("nodejs.util.inspect.custom"),Za=114,Fe=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Pr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(Za,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Ct(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Ct(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Cs](){return`PeerId(${this.toString()})`}},gr=class extends Fe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},br=class extends Fe{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},yr=class extends Fe{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Wa=2336,wr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Rt.digest($t(this.url))}[Cs](){return`PeerId(${this.url})`}[Pr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(Wa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=st(t)),t.toString()===this.toString())}};function Ps(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Xt(Y.decode(`z${r}`));else{if(t==null)throw new de('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Xt(t.decode(r))}return Ya(e)}function Ya(r){if(Qa(r))return new gr({multihash:r});if(Xa(r))try{let t=Rs(r);if(t.type==="Ed25519")return new br({multihash:r,publicKey:t});if(t.type==="secp256k1")return new yr({multihash:r,publicKey:t})}catch{let e=st(r.digest);return new wr(new URL(e))}throw new Ge("Supplied PeerID Multihash is invalid")}function Xa(r){return r.code===Rt.code}function Qa(r){return r.code===Me.code}var Er=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let h=this.readChar();if(h===void 0)return;let p=Number.parseInt(h,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=t,s+=u,s>f||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var _s=45,Ja=15,Be=new Er;function qn(r){if(!(r.length>Ja))return Be.new(r).parseWith(()=>Be.readIPv4Addr())}function zn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>_s))return Be.new(r).parseWith(()=>Be.readIPv6Addr())}function Sr(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>_s))return Be.new(r).parseWith(()=>Be.readIPAddr())}var dp=parseInt("0xFFFF",16),hp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ds(r){return!!qn(r)}function Os(r){return!!zn(r)}function vr(r){return!!Sr(r)}var ks=Ds,ou=Os,Vn=function(r){let t=0;if(r=r.toString().trim(),ks(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ou(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=ks(e[n]),i;s&&(i=Vn(e[n]),e[n]=st(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,st(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Ms=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ie={},Fn={},iu=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];iu.forEach(r=>{let t=cu(...r);Fn[t.code]=t,Ie[t.name]=t});function cu(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function $(r){if(typeof r=="number"){if(Fn[r]!=null)return Fn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Yp=$("ip4"),Xp=$("ip6"),Qp=$("ipcidr");function Zn(r,t){switch($(r).code){case 4:case 41:return uu(t);case 42:return jn(t);case 6:case 273:case 33:case 132:return qs(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return jn(t);case 421:return hu(t);case 444:return Ks(t);case 445:return Ks(t);case 466:return du(t);case 481:return globalThis.encodeURIComponent(jn(t));default:return st(t,"base16")}}function Wn(r,t){switch($(r).code){case 4:return Hs(t);case 41:return Hs(t);case 42:return Gn(t);case 6:case 273:case 33:case 132:return Yn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gn(t);case 421:return fu(t);case 444:return pu(t);case 445:return mu(t);case 466:return lu(t);case 481:return Gn(globalThis.decodeURIComponent(t));default:return $t(t,"base16")}}var $n=Object.values(He).map(r=>r.decoder),au=function(){let r=$n[0].or($n[1]);return $n.slice(2).forEach(t=>r=r.or(t)),r}();function Hs(r){if(!vr(r))throw new Error("invalid ip address");return Vn(r)}function uu(r){let t=Ms(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!vr(t))throw new Error("invalid ip address");return t}function Yn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function qs(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Gn(r){let t=$t(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function jn(r){let t=se(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return st(r)}function fu(r){let t;r[0]==="Q"||r[0]==="1"?t=Xt(Y.decode(`z${r}`)).bytes:t=lt.parse(r).multihash.bytes;let e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function lu(r){let t=au.decode(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function du(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+st(e,"base64url")}function hu(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return st(e,"base58btc")}function pu(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Lt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Yn(n);return It([e,o],e.length+o.length)}function mu(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Lt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Yn(n);return It([e,o],e.length+o.length)}function Ks(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=st(t,"base32"),o=qs(e);return`${n}:${o}`}function zs(r){r=Xn(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=$(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw Fs("invalid address: "+r);if(c.path===!0){n=Xn(o.slice(s).join("/")),t.push([c.code,Wn(c.code,n)]),e.push([c.code,n]);break}let a=Wn(c.code,o[s]);t.push([c.code,a]),e.push([c.code,Zn(c.code,a)])}return{string:Vs(e),bytes:Jn(t),tuples:t,stringTuples:e,path:n}}function Qn(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=se(r,o),i=xt(s),c=$(s),a=xu(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw Fs("Invalid address Uint8Array: "+st(r,"base16"));t.push([s,f]);let u=Zn(s,f);if(e.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Vs(e),tuples:t,stringTuples:e,path:n}}function Vs(r){let t=[];return r.map(e=>{let n=$(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Xn(t.join("/"))}function Jn(r){return It(r.map(t=>{let e=$(t[0]),n=Uint8Array.from(Se(e.code));return t.length>1&&t[1]!=null&&(n=It([n,t[1]])),n}))}function xu(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=se(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function Xn(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Fs(r){return new Error("Error parsing address: "+r)}var gu=Symbol.for("nodejs.util.inspect.custom"),eo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),bu=[$("dns").code,$("dns4").code,$("dns6").code,$("dnsaddr").code],to=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Br=class r{bytes;#t;#e;#r;#n;[eo]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Qn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=zs(t)}else if(Gs(t))e=Qn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=$("tcp"),c=$("udp"),a=$("ip4"),f=$("ip6"),u=$("dns6"),h=$("ip6zone");for(let[v,E]of this.stringTuples())v===h.code&&(s=`%${E??""}`),bu.includes(v)&&(e=i.name,o=443,n=`${E??""}${s}`,t=v===u.code?6:4),(v===i.code||v===c.code)&&(e=$(v).name,o=parseInt(E??"")),(v===a.code||v===f.code)&&(e=$(v).name,n=`${E??""}${s}`,t=v===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},$(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>$(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Jn(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Ie.p2p.code&&t.push([n,o]),n===Ie["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?st(Y.decode(`z${n}`),"base58btc"):st(lt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Ct(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=$s.get(e.name);if(n==null)throw new to(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Zt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[gu](){return`Multiaddr(${this.#t})`}};var $s=new Map;function Gs(r){return!!r?.[eo]}function Zt(r){return new Br(r)}var yu=w("dns4"),wu=w("dns6"),Eu=w("dnsaddr"),fe=Q(w("dns"),Eu,yu,wu),Tr=Q(w("ip4"),w("ip6")),Ae=Q(U(Tr,w("tcp")),U(fe,w("tcp"))),Lr=U(Tr,w("udp")),Su=U(Lr,w("utp")),vu=U(Lr,w("quic")),Bu=U(Lr,w("quic-v1")),ro=Q(U(Ae,w("ws")),U(fe,w("ws"))),Ir=Q(U(ro,w("p2p")),ro),no=Q(U(Ae,w("wss")),U(fe,w("wss")),U(Ae,w("tls"),w("ws")),U(fe,w("tls"),w("ws"))),Ar=Q(U(no,w("p2p")),no),oo=Q(U(Ae,w("http")),U(Tr,w("http")),U(fe,w("http"))),so=Q(U(Ae,w("https")),U(Tr,w("https")),U(fe,w("https"))),js=U(Lr,w("webrtc-direct"),w("certhash")),Ys=Q(U(js,w("p2p")),js),Zs=U(Bu,w("webtransport"),w("certhash"),w("certhash")),Xs=Q(U(Zs,w("p2p")),Zs),Qs=Q(U(Ir,w("p2p-webrtc-star"),w("p2p")),U(Ar,w("p2p-webrtc-star"),w("p2p")),U(Ir,w("p2p-webrtc-star")),U(Ar,w("p2p-webrtc-star"))),v0=Q(U(Ir,w("p2p-websocket-star"),w("p2p")),U(Ar,w("p2p-websocket-star"),w("p2p")),U(Ir,w("p2p-websocket-star")),U(Ar,w("p2p-websocket-star"))),Js=Q(U(oo,w("p2p-webrtc-direct"),w("p2p")),U(so,w("p2p-webrtc-direct"),w("p2p")),U(oo,w("p2p-webrtc-direct")),U(so,w("p2p-webrtc-direct"))),le=Q(ro,no,oo,so,Qs,Js,Ae,Su,vu,fe,Ys,Xs),B0=Q(U(le,w("p2p-stardust"),w("p2p")),U(le,w("p2p-stardust"))),Wt=Q(U(le,w("p2p")),Qs,Js,Ys,Xs,w("p2p")),Ws=Q(U(Wt,w("p2p-circuit"),Wt),U(Wt,w("p2p-circuit")),U(w("p2p-circuit"),Wt),U(le,w("p2p-circuit")),U(w("p2p-circuit"),le),w("p2p-circuit")),ti=()=>Q(U(Ws,ti),Ws),ue=ti(),ei=Q(U(ue,Wt,ue),U(Wt,ue),U(ue,Wt),ue,Wt);var I0=Q(U(ue,w("webrtc"),w("p2p")),U(ue,w("webrtc")),U(le,w("webrtc"),w("p2p")),U(le,w("webrtc")),w("webrtc"));function ri(r){function t(e){let n;try{n=Zt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function U(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:ri(t),partialMatch:t}}function Q(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:ri(t),partialMatch:t}}function w(r){let t=r;function e(o){let s;try{s=Zt(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Iu="bootstrap",Au=50,Tu=1e3,io=class extends je{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Tu,this.list=[];for(let n of e.list){if(!ei.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Zt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Ps(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[mo]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[go]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??Iu]:{value:this._init.tagValue??Au,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Lu(r){return t=>new io(t,r)}return mi(Ru);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.2-b3272cfce",
|
|
4
4
|
"description": "Peer discovery via a list of bootstrap peers",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"test:electron-main": "aegir test -t electron-main"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@libp2p/interface": "
|
|
58
|
-
"@libp2p/interface-internal": "
|
|
59
|
-
"@libp2p/peer-id": "
|
|
57
|
+
"@libp2p/interface": "2.1.0-b3272cfce",
|
|
58
|
+
"@libp2p/interface-internal": "2.0.2-b3272cfce",
|
|
59
|
+
"@libp2p/peer-id": "5.0.2-b3272cfce",
|
|
60
60
|
"@multiformats/mafmt": "^12.1.6",
|
|
61
61
|
"@multiformats/multiaddr": "^12.2.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@libp2p/interface-compliance-tests": "
|
|
65
|
-
"@libp2p/logger": "
|
|
64
|
+
"@libp2p/interface-compliance-tests": "6.1.0-b3272cfce",
|
|
65
|
+
"@libp2p/logger": "5.0.2-b3272cfce",
|
|
66
66
|
"aegir": "^44.0.1",
|
|
67
67
|
"sinon-ts": "^2.0.0"
|
|
68
68
|
},
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
3
|
-
".:BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
4
|
-
"BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
5
|
-
".:BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
6
|
-
"bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html",
|
|
7
|
-
".:bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html"
|
|
8
|
-
}
|