@libp2p/bootstrap 11.0.38 → 11.0.39-ae595d8db

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 CHANGED
@@ -1,11 +1,11 @@
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 zr=Object.defineProperty;var Qi=Object.getOwnPropertyDescriptor;var Ji=Object.getOwnPropertyNames;var tc=Object.prototype.hasOwnProperty;var yt=(r,t)=>{for(var e in t)zr(r,e,{get:t[e],enumerable:!0})},ec=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ji(t))!tc.call(r,o)&&o!==e&&zr(r,o,{get:()=>t[o],enumerable:!(n=Qi(t,o))||n.enumerable});return r};var rc=r=>ec(zr({},"__esModule",{value:!0}),r);var rf={};yt(rf,{bootstrap:()=>ef});var Do=Symbol.for("@libp2p/peer-discovery");var Fr=Symbol.for("@libp2p/peer-id");var Ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},or=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var sr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},ir=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var cr=class extends EventTarget{#t=new Map;constructor(){super()}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 No=Symbol.for("@libp2p/service-capabilities"),uf=Symbol.for("@libp2p/service-dependencies");var $r={};yt($r,{base58btc:()=>$,base58flickr:()=>uc});var _f=new Uint8Array(0);function Ro(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 Nt(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 Ko(r){return new TextEncoder().encode(r)}function ko(r){return new TextDecoder().decode(r)}function nc(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 a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(A){if(A instanceof Uint8Array||(ArrayBuffer.isView(A)?A=new Uint8Array(A.buffer,A.byteOffset,A.byteLength):Array.isArray(A)&&(A=Uint8Array.from(A))),!(A instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(A.length===0)return"";for(var x=0,R=0,K=0,F=A.length;K!==F&&A[K]===0;)K++,x++;for(var S=(F-K)*u+1>>>0,f=new Uint8Array(S);K!==F;){for(var m=A[K],I=0,T=S-1;(m!==0||I<R)&&T!==-1;T--,I++)m+=256*f[T]>>>0,f[T]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");R=I,K++}for(var P=S-R;P!==S&&f[P]===0;)P++;for(var N=c.repeat(x);P<S;++P)N+=r.charAt(f[P]);return N}function y(A){if(typeof A!="string")throw new TypeError("Expected String");if(A.length===0)return new Uint8Array;var x=0;if(A[x]!==" "){for(var R=0,K=0;A[x]===c;)R++,x++;for(var F=(A.length-x)*h+1>>>0,S=new Uint8Array(F);A[x];){var f=e[A.charCodeAt(x)];if(f===255)return;for(var m=0,I=F-1;(f!==0||m<K)&&I!==-1;I--,m++)f+=a*S[I]>>>0,S[I]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");K=m,x++}if(A[x]!==" "){for(var T=F-K;T!==F&&S[T]===0;)T++;for(var P=new Uint8Array(R+(F-T)),N=R;T!==F;)P[N++]=S[T++];return P}}}function B(A){var x=y(A);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:y,decode:B}}var oc=nc,sc=oc,Mo=sc;var jr=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")}},Gr=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 Ho(this,t)}},Zr=class{decoders;constructor(t){this.decoders=t}or(t){return Ho(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 Ho(r,t){return new Zr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Wr=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 jr(t,e,n),this.decoder=new Gr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ge({name:r,prefix:t,encode:e,decode:n}){return new Wr(r,t,e,n)}function jt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Mo(e,r);return ge({prefix:t,name:r,encode:n,decode:s=>Nt(o(s))})}function ic(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let h=0;h<o;++h){let u=t[r[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function cc(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function ac(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function Q({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=ac(n);return ge({prefix:t,name:r,encode(s){return cc(s,n,e)},decode(s){return ic(s,o,e,r)}})}var $=jt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uc=jt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Yr={};yt(Yr,{base32:()=>Rt,base32hex:()=>dc,base32hexpad:()=>mc,base32hexpadupper:()=>xc,base32hexupper:()=>pc,base32pad:()=>lc,base32padupper:()=>hc,base32upper:()=>fc,base32z:()=>gc});var Rt=Q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fc=Q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lc=Q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hc=Q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),dc=Q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pc=Q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mc=Q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xc=Q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gc=Q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xr={};yt(Xr,{base36:()=>ke,base36upper:()=>yc});var ke=jt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yc=jt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var bc=zo,Vo=128,wc=127,Ec=~wc,Sc=Math.pow(2,31);function zo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Sc;)t[e++]=r&255|Vo,r/=128;for(;r&Ec;)t[e++]=r&255|Vo,r>>>=7;return t[e]=r|0,zo.bytes=e-n+1,t}var vc=Qr,Ac=128,qo=127;function Qr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Qr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&qo)<<o:(i&qo)*Math.pow(2,o),o+=7}while(i>=Ac);return Qr.bytes=s-n,e}var Bc=Math.pow(2,7),Ic=Math.pow(2,14),Tc=Math.pow(2,21),Pc=Math.pow(2,28),Lc=Math.pow(2,35),Cc=Math.pow(2,42),Uc=Math.pow(2,49),_c=Math.pow(2,56),Dc=Math.pow(2,63),Nc=function(r){return r<Bc?1:r<Ic?2:r<Tc?3:r<Pc?4:r<Lc?5:r<Cc?6:r<Uc?7:r<_c?8:r<Dc?9:10},Rc={encode:bc,decode:vc,encodingLength:Nc},Kc=Rc,Oe=Kc;function Me(r,t=0){return[Oe.decode(r,t),Oe.decode.bytes]}function ye(r,t,e=0){return Oe.encode(r,t,e),t}function be(r){return Oe.encodingLength(r)}function te(r,t){let e=t.byteLength,n=be(r),o=n+be(e),s=new Uint8Array(o+e);return ye(r,s,0),ye(e,s,n),s.set(t,o),new we(r,e,t,s)}function ee(r){let t=Nt(r),[e,n]=Me(t),[o,s]=Me(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new we(e,o,i,t)}function Fo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ro(r.bytes,e.bytes)}}var we=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function jo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Oc(e,Jr(r),t??$.encoder);default:return Mc(e,Jr(r),t??Rt.encoder)}}var Go=new WeakMap;function Jr(r){let t=Go.get(r);if(t==null){let e=new Map;return Go.set(r,e),e}return t}var nt=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!==He)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Hc)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=te(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&&Fo(t.multihash,n.multihash)}toString(t){return jo(this,t)}toJSON(){return{"/":jo(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??Zo(n,o,s.bytes))}else if(e[Vc]===!0){let{version:n,multihash:o,code:s}=e,i=ee(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!==He)throw new Error(`Version 0 CID must use dag-pb (code: ${He}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Zo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,He,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=Nt(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 we(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[d,y]=Me(t.subarray(e));return e+=y,d},o=n(),s=He;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),h=e+c,u=h-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:h}}static parse(t,e){let[n,o]=kc(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 Jr(s).set(n,t),s}};function kc(r,t){switch(r[0]){case"Q":{let e=t??$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t??$;return[$.prefix,e.decode(r)]}case Rt.prefix:{let e=t??Rt;return[Rt.prefix,e.decode(r)]}case ke.prefix:{let e=t??ke;return[ke.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 Oc(r,t,e){let{prefix:n}=e;if(n!==$.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 Mc(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 He=112,Hc=18;function Zo(r,t,e){let n=be(r),o=n+be(t),s=new Uint8Array(o+e.byteLength);return ye(r,s,0),ye(t,s,n),s.set(e,o),s}var Vc=Symbol.for("@ipld/js-cid/CID");var tn={};yt(tn,{identity:()=>Tt});var Wo=0,qc="identity",$o=Nt;function zc(r){return te(Wo,$o(r))}var Tt={code:Wo,name:qc,encode:$o,digest:zc};function bt(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 Kt(r=0){return new Uint8Array(r)}function mt(r=0){return new Uint8Array(r)}function wt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=mt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Xo=Symbol.for("@achingbrain/uint8arraylist");function Yo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ur(r){return!!r?.[Xo]}var Et=class r{bufs;length;[Xo]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ur(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ur(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Yo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Yo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ur(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return wt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:wt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let h=t>=a&&t<c,u=e>a&&e<=c;if(h&&u){if(t===a&&e===c){n.push(i);break}let d=t-a;n.push(i.subarray(d,d+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ur(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let d=0;d<s;d++)i[d]=-1;for(let d=0;d<o;d++)i[n[d]]=d;let a=i,c=this.byteLength-n.byteLength,h=n.byteLength-1,u;for(let d=e;d<=c;d+=u){u=0;for(let y=h;y>=0;y--){let B=this.get(d+y);if(n[y]!==B){u=Math.max(1,y-a[B]);break}}if(u===0)return d}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Kt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Kt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Kt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Kt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Kt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Kt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Kt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Kt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!bt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var en={};yt(en,{base10:()=>Fc});var Fc=jt({prefix:"9",name:"base10",alphabet:"0123456789"});var rn={};yt(rn,{base16:()=>jc,base16upper:()=>Gc});var jc=Q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gc=Q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var nn={};yt(nn,{base2:()=>Zc});var Zc=Q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var on={};yt(on,{base256emoji:()=>Qc});var Qo=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}"),Wc=Qo.reduce((r,t,e)=>(r[e]=t,r),[]),$c=Qo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Yc(r){return r.reduce((t,e)=>(t+=Wc[e],t),"")}function Xc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=$c[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Qc=ge({prefix:"\u{1F680}",name:"base256emoji",encode:Yc,decode:Xc});var sn={};yt(sn,{base64:()=>Jc,base64pad:()=>ta,base64url:()=>ea,base64urlpad:()=>ra});var Jc=Q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ta=Q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ea=Q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ra=Q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var cn={};yt(cn,{base8:()=>na});var na=Q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var an={};yt(an,{identity:()=>oa});var oa=ge({prefix:"\0",name:"identity",encode:r=>ko(r),decode:r=>Ko(r)});var ml=new TextEncoder,xl=new TextDecoder;var ln={};yt(ln,{sha256:()=>Ve,sha512:()=>ca});function fn({name:r,code:t,encode:e}){return new un(r,t,e)}var un=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?te(this.code,e):e.then(n=>te(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ts(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ve=fn({name:"sha2-256",code:18,encode:ts("SHA-256")}),ca=fn({name:"sha2-512",code:19,encode:ts("SHA-512")});var qe={...an,...nn,...cn,...en,...rn,...Yr,...Xr,...$r,...sn,...on},Pl={...ln,...tn};function rs(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var es=rs("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),hn=rs("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=mt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),aa={utf8:es,"utf-8":es,hex:qe.base16,latin1:hn,ascii:hn,binary:hn,...qe},fr=aa;function Bt(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Z(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ua=parseInt("11111",2),dn=parseInt("10000000",2),fa=parseInt("01111111",2),ns={0:ze,1:ze,2:la,3:pa,4:ma,5:da,6:ha,16:ze,22:ze,48:ze};function pn(r,t={offset:0}){let e=r[t.offset]&ua;if(t.offset++,ns[e]!=null)return ns[e](r,t);throw new Error("No decoder for tag "+e)}function Fe(r,t){let e=0;if((r[t.offset]&dn)===dn){let n=r[t.offset]&fa,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function ze(r,t){Fe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=pn(r,t);if(n===null)break;e.push(n)}return e}function la(r,t){let e=Fe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function ha(r,t){let e=Fe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let h=r[t.offset];if(t.offset++,c.push(h&127),h<128){c.reverse();let u=0;for(let d=0;d<c.length;d++)u+=c[d]<<d*7;a+=`.${u}`,c=[]}}return a}function da(r,t){return t.offset++,null}function pa(r,t){let e=Fe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function ma(r,t){let e=Fe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function xa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new Et;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function mn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=xa(r.byteLength);return new Et(Uint8Array.from([t.byteLength|dn]),t)}function os(r){let t=new Et,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new Et(Uint8Array.from([2]),mn(t),t)}function ss(r){let t=Uint8Array.from([0]),e=new Et(t,r);return new Et(Uint8Array.from([3]),mn(e),e)}function lr(r,t=48){let e=new Et;for(let n of r)e.append(n);return new Et(Uint8Array.from([t]),mn(e),e)}async function is(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var ga=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ya=Uint8Array.from([6,5,43,129,4,0,34]),ba=Uint8Array.from([6,5,43,129,4,0,35]),wa={ext:!0,kty:"EC",crv:"P-256"},Ea={ext:!0,kty:"EC",crv:"P-384"},Sa={ext:!0,kty:"EC",crv:"P-521"},xn=32,gn=48,yn=66;function cs(r){let t=pn(r);return as(t)}function as(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===xn*2+1)return n=Z(t.subarray(e,e+xn),"base64url"),o=Z(t.subarray(e+xn),"base64url"),new Ee({...wa,key_ops:["verify"],x:n,y:o});if(t.byteLength===gn*2+1)return n=Z(t.subarray(e,e+gn),"base64url"),o=Z(t.subarray(e+gn),"base64url"),new Ee({...Ea,key_ops:["verify"],x:n,y:o});if(t.byteLength===yn*2+1)return n=Z(t.subarray(e,e+yn),"base64url"),o=Z(t.subarray(e+yn),"base64url"),new Ee({...Sa,key_ops:["verify"],x:n,y:o});throw new Ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function us(r){return lr([os(Uint8Array.from([1])),lr([va(r.crv)],160),lr([ss(new Et(Uint8Array.from([4]),Bt(r.x??"","base64url"),Bt(r.y??"","base64url")))],161)]).subarray()}function va(r){if(r==="P-256")return ga;if(r==="P-384")return ya;if(r==="P-521")return ba;throw new Ct(`Invalid curve ${r}`)}var Ee=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=us(this.jwk)),this._raw}toMultihash(){return Tt.digest(Se(this))}toCID(){return nt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}async verify(t,e){return is(this.jwk,e,t)}};var ne=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Aa(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function hr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function oe(r,...t){if(!Aa(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function fs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");hr(r.outputLen),hr(r.blockLen)}function Ae(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 ls(r,t){oe(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function kt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function dr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Pt(r,t){return r<<32-t|r>>>t}function hs(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function je(r){return typeof r=="string"&&(r=hs(r)),oe(r),r}function bn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];oe(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 ve=class{};function wn(r){let t=n=>r().update(je(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function pr(r=32){if(ne&&typeof ne.getRandomValues=="function")return ne.getRandomValues(new Uint8Array(r));if(ne&&typeof ne.randomBytes=="function")return Uint8Array.from(ne.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Ba(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),a=Number(e&s),c=n?4:0,h=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+h,a,n)}function ds(r,t,e){return r&t^~r&e}function ps(r,t,e){return r&t^r&e^t&e}var Ge=class extends ve{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=dr(this.buffer)}update(t){Ae(this),t=je(t),oe(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=dr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ae(this),ls(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,kt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let d=i;d<o;d++)e[d]=0;Ba(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=dr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=c/4,u=this.get();if(h>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<h;d++)a.setUint32(4*d,u[d],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:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ot=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var at=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var mr=BigInt(4294967295),ms=BigInt(32);function Ia(r,t=!1){return t?{h:Number(r&mr),l:Number(r>>ms&mr)}:{h:Number(r>>ms&mr)|0,l:Number(r&mr)|0}}function xs(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=Ia(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var En=(r,t,e)=>r>>>e,Sn=(r,t,e)=>r<<32-e|t>>>e,se=(r,t,e)=>r>>>e|t<<32-e,ie=(r,t,e)=>r<<32-e|t>>>e,Ze=(r,t,e)=>r<<64-e|t>>>e-32,We=(r,t,e)=>r>>>e-32|t<<64-e;function Ut(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var gs=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),ys=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,bs=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ws=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Es=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ss=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Pa=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array(64),vn=class extends Ge{constructor(t=32){super(64,t,8,!1),this.A=Ot[0]|0,this.B=Ot[1]|0,this.C=Ot[2]|0,this.D=Ot[3]|0,this.E=Ot[4]|0,this.F=Ot[5]|0,this.G=Ot[6]|0,this.H=Ot[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){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=a|0,this.H=c|0}process(t,e){for(let d=0;d<16;d++,e+=4)Gt[d]=t.getUint32(e,!1);for(let d=16;d<64;d++){let y=Gt[d-15],B=Gt[d-2],A=Pt(y,7)^Pt(y,18)^y>>>3,x=Pt(B,17)^Pt(B,19)^B>>>10;Gt[d]=x+Gt[d-7]+A+Gt[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:h,H:u}=this;for(let d=0;d<64;d++){let y=Pt(a,6)^Pt(a,11)^Pt(a,25),B=u+y+ds(a,c,h)+Pa[d]+Gt[d]|0,x=(Pt(n,2)^Pt(n,13)^Pt(n,22))+ps(n,o,s)|0;u=h,h=c,c=a,a=i+B|0,i=s,s=o,o=n,n=B+x|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,c,h,u)}roundClean(){kt(Gt)}destroy(){this.set(0,0,0,0,0,0,0,0),kt(this.buffer)}};var vs=xs(["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))),La=vs[0],Ca=vs[1],Zt=new Uint32Array(80),Wt=new Uint32Array(80),An=class extends Ge{constructor(t=64){super(128,t,16,!1),this.Ah=at[0]|0,this.Al=at[1]|0,this.Bh=at[2]|0,this.Bl=at[3]|0,this.Ch=at[4]|0,this.Cl=at[5]|0,this.Dh=at[6]|0,this.Dl=at[7]|0,this.Eh=at[8]|0,this.El=at[9]|0,this.Fh=at[10]|0,this.Fl=at[11]|0,this.Gh=at[12]|0,this.Gl=at[13]|0,this.Hh=at[14]|0,this.Hl=at[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:h,El:u,Fh:d,Fl:y,Gh:B,Gl:A,Hh:x,Hl:R}=this;return[t,e,n,o,s,i,a,c,h,u,d,y,B,A,x,R]}set(t,e,n,o,s,i,a,c,h,u,d,y,B,A,x,R){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=a|0,this.Dl=c|0,this.Eh=h|0,this.El=u|0,this.Fh=d|0,this.Fl=y|0,this.Gh=B|0,this.Gl=A|0,this.Hh=x|0,this.Hl=R|0}process(t,e){for(let S=0;S<16;S++,e+=4)Zt[S]=t.getUint32(e),Wt[S]=t.getUint32(e+=4);for(let S=16;S<80;S++){let f=Zt[S-15]|0,m=Wt[S-15]|0,I=se(f,m,1)^se(f,m,8)^En(f,m,7),T=ie(f,m,1)^ie(f,m,8)^Sn(f,m,7),P=Zt[S-2]|0,N=Wt[S-2]|0,M=se(P,N,19)^Ze(P,N,61)^En(P,N,6),U=ie(P,N,19)^We(P,N,61)^Sn(P,N,6),k=bs(T,U,Wt[S-7],Wt[S-16]),D=ws(k,I,M,Zt[S-7],Zt[S-16]);Zt[S]=D|0,Wt[S]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:h,Dl:u,Eh:d,El:y,Fh:B,Fl:A,Gh:x,Gl:R,Hh:K,Hl:F}=this;for(let S=0;S<80;S++){let f=se(d,y,14)^se(d,y,18)^Ze(d,y,41),m=ie(d,y,14)^ie(d,y,18)^We(d,y,41),I=d&B^~d&x,T=y&A^~y&R,P=Es(F,m,T,Ca[S],Wt[S]),N=Ss(P,K,f,I,La[S],Zt[S]),M=P|0,U=se(n,o,28)^Ze(n,o,34)^Ze(n,o,39),k=ie(n,o,28)^We(n,o,34)^We(n,o,39),D=n&s^n&a^s&a,et=o&i^o&c^i&c;K=x|0,F=R|0,x=B|0,R=A|0,B=d|0,A=y|0,{h:d,l:y}=Ut(h|0,u|0,N|0,M|0),h=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let w=gs(M,k,et);n=ys(w,N,U,D),o=w|0}({h:n,l:o}=Ut(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Ut(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Ut(this.Ch|0,this.Cl|0,a|0,c|0),{h,l:u}=Ut(this.Dh|0,this.Dl|0,h|0,u|0),{h:d,l:y}=Ut(this.Eh|0,this.El|0,d|0,y|0),{h:B,l:A}=Ut(this.Fh|0,this.Fl|0,B|0,A|0),{h:x,l:R}=Ut(this.Gh|0,this.Gl|0,x|0,R|0),{h:K,l:F}=Ut(this.Hh|0,this.Hl|0,K|0,F|0),this.set(n,o,s,i,a,c,h,u,d,y,B,A,x,R,K,F)}roundClean(){kt(Zt,Wt)}destroy(){kt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var As=wn(()=>new vn);var Bs=wn(()=>new An);var Pn=BigInt(0),Tn=BigInt(1);function Be(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ln(r){if(!Be(r))throw new Error("Uint8Array expected")}function _t(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function $e(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Ps(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Pn:BigInt("0x"+r)}var Ls=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ua=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function $t(r){if(Ln(r),Ls)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Ua[r[e]];return t}var Mt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Is(r){if(r>=Mt._0&&r<=Mt._9)return r-Mt._0;if(r>=Mt.A&&r<=Mt.F)return r-(Mt.A-10);if(r>=Mt.a&&r<=Mt.f)return r-(Mt.a-10)}function Ye(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Ls)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("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=Is(r.charCodeAt(s)),a=Is(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Ht(r){return Ps($t(r))}function ce(r){return Ln(r),Ps($t(Uint8Array.from(r).reverse()))}function ae(r,t){return Ye(r.toString(16).padStart(t*2,"0"))}function Ie(r,t){return ae(r,t).reverse()}function Y(r,t,e){let n;if(typeof t=="string")try{n=Ye(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Be(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+" of length "+e+" expected, got "+o);return n}function Yt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ln(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 Bn=r=>typeof r=="bigint"&&Pn<=r;function xr(r,t,e){return Bn(r)&&Bn(t)&&Bn(e)&&t<=r&&r<e}function St(r,t,e,n){if(!xr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Cs(r){let t;for(t=0;r>Pn;r>>=Tn,t+=1);return t}var ue=r=>(Tn<<BigInt(r))-Tn,In=r=>new Uint8Array(r),Ts=r=>Uint8Array.from(r);function Us(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=In(r),o=In(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...d)=>e(o,n,...d),c=(d=In(0))=>{o=a(Ts([0]),d),n=a(),d.length!==0&&(o=a(Ts([1]),d),n=a())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,y=[];for(;d<t;){n=a();let B=n.slice();y.push(B),d+=n.length}return Yt(...y)};return(d,y)=>{i(),c(d);let B;for(;!(B=y(h()));)c();return i(),B}}var _a={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"||Be(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 Vt(r,t,e={}){let n=(o,s,i)=>{let a=_a[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};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}function Te(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 ht=BigInt(0),st=BigInt(1),fe=BigInt(2),Da=BigInt(3),Ds=BigInt(4),Ns=BigInt(5),Rs=BigInt(8);function G(r,t){let e=r%t;return e>=ht?e:t+e}function X(r,t,e){let n=r;for(;t-- >ht;)n*=n,n%=e;return n}function gr(r,t){if(r===ht)throw new Error("invert: expected non-zero number");if(t<=ht)throw new Error("invert: expected positive modulus, got "+t);let e=G(r,t),n=t,o=ht,s=st,i=st,a=ht;for(;e!==ht;){let h=n/e,u=n%e,d=o-i*h,y=s-a*h;n=e,e=u,o=i,s=a,i=d,a=y}if(n!==st)throw new Error("invert: does not exist");return G(o,t)}function Ks(r,t){let e=(r.ORDER+st)/Ds,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function Na(r,t){let e=(r.ORDER-Ns)/Rs,n=r.mul(t,fe),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,fe),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function Ra(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-st,e=0;for(;t%fe===ht;)t/=fe,e++;let n=fe,o=qt(r);for(;_s(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Ks;let s=o.pow(n,t),i=(t+st)/fe;return function(c,h){if(c.is0(h))return h;if(_s(c,h)!==1)throw new Error("Cannot find square root");let u=e,d=c.mul(c.ONE,s),y=c.pow(h,t),B=c.pow(h,i);for(;!c.eql(y,c.ONE);){if(c.is0(y))return c.ZERO;let A=1,x=c.sqr(y);for(;!c.eql(x,c.ONE);)if(A++,x=c.sqr(x),A===u)throw new Error("Cannot find square root");let R=st<<BigInt(u-A-1),K=c.pow(d,R);u=A,d=c.sqr(K),y=c.mul(y,d),B=c.mul(B,K)}return B}}function Ka(r){return r%Ds===Da?Ks:r%Rs===Ns?Na:Ra(r)}var ks=(r,t)=>(G(r,t)&st)===st,ka=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=ka.reduce((n,o)=>(n[o]="function",n),t);return Vt(r,e)}function Oa(r,t,e){if(e<ht)throw new Error("invalid exponent, negatives unsupported");if(e===ht)return r.ONE;if(e===st)return t;let n=r.ONE,o=t;for(;e>ht;)e&st&&(n=r.mul(n,o)),o=r.sqr(o),e>>=st;return n}function Pe(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function _s(r,t){let e=(r.ORDER-st)/fe,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Un(r,t){t!==void 0&&hr(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function qt(r,t,e=!1,n={}){if(r<=ht)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Un(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:ue(o),ZERO:ht,ONE:st,create:c=>G(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ht<=c&&c<r},is0:c=>c===ht,isOdd:c=>(c&st)===st,neg:c=>G(-c,r),eql:(c,h)=>c===h,sqr:c=>G(c*c,r),add:(c,h)=>G(c+h,r),sub:(c,h)=>G(c-h,r),mul:(c,h)=>G(c*h,r),pow:(c,h)=>Oa(a,c,h),div:(c,h)=>G(c*gr(h,r),r),sqrN:c=>c*c,addN:(c,h)=>c+h,subN:(c,h)=>c-h,mulN:(c,h)=>c*h,inv:c=>gr(c,r),sqrt:n.sqrt||(c=>(i||(i=Ka(r)),i(a,c))),toBytes:c=>e?Ie(c,s):ae(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?ce(c):Ht(c)},invertBatch:c=>Pe(a,c),cmov:(c,h,u)=>u?h:c});return Object.freeze(a)}function Os(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 _n(r){let t=Os(r);return t+Math.ceil(t/2)}function Ms(r,t,e=!1){let n=r.length,o=Os(t),s=_n(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ce(r):Ht(r),a=G(i,t-st)+st;return e?Ie(a,o):ae(a,o)}var Hs=BigInt(0),kn=BigInt(1);function Dn(r,t){let e=t.negate();return r?e:t}function qs(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Nn(r,t){qs(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=ue(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Vs(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=kn);let h=t*n,u=h+Math.abs(a)-1,d=a===0,y=a<0,B=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:y,isNegF:B,offsetF:h}}function Ma(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Ha(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Rn=new WeakMap,zs=new WeakMap;function Kn(r){return zs.get(r)||1}function yr(r,t){return{constTimeNegate:Dn,hasPrecomputes(e){return Kn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Hs;)n&kn&&(o=o.add(s)),s=s.double(),n>>=kn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Nn(n,t),i=[],a=e,c=a;for(let h=0;h<o;h++){c=a,i.push(c);for(let u=1;u<s;u++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Nn(e,t);for(let c=0;c<a.windows;c++){let{nextN:h,offset:u,isZero:d,isNeg:y,isNegF:B,offsetF:A}=Vs(o,c,a);o=h,d?i=i.add(Dn(B,n[A])):s=s.add(Dn(y,n[u]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Nn(e,t);for(let a=0;a<i.windows&&o!==Hs;a++){let{nextN:c,offset:h,isZero:u,isNeg:d}=Vs(o,a,i);if(o=c,!u){let y=n[h];s=s.add(d?y.negate():y)}}return s},getPrecomputes(e,n,o){let s=Rn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Rn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Kn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Kn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){qs(n,t),zs.set(e,n),Rn.delete(e)}}}function br(r,t,e,n){Ma(e,r),Ha(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=Cs(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let h=ue(c),u=new Array(Number(h)+1).fill(i),d=Math.floor((t.BITS-1)/c)*c,y=i;for(let B=d;B>=0;B-=c){u.fill(i);for(let x=0;x<s;x++){let R=n[x],K=Number(R>>BigInt(B)&h);u[K]=u[K].add(e[x])}let A=i;for(let x=u.length-1,R=i;x>0;x--)R=R.add(u[x]),A=A.add(R);if(y=y.add(A),B!==0)for(let x=0;x<c;x++)y=y.double()}return y}function Xe(r){return Cn(r.Fp),Vt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Un(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Dt=BigInt(0),dt=BigInt(1),Fs=BigInt(2),Va=BigInt(8),qa={zip215:!0};function za(r){let t=Xe(r);return Vt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function js(r){let t=za(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,h=Fs<<BigInt(a*8)-dt,u=e.create,d=qt(t.n,t.nBitLength);function y(g,l){let p=e.sqr(g),E=e.sqr(l),_=e.add(e.mul(t.a,p),E),O=e.add(e.ONE,e.mul(t.d,e.mul(p,E)));return e.eql(_,O)}if(!y(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let B=t.uvRatio||((g,l)=>{try{return{isValid:!0,value:e.sqrt(g*e.inv(l))}}catch{return{isValid:!1,value:Dt}}}),A=t.adjustScalarBytes||(g=>g),x=t.domain||((g,l,p)=>{if(_t("phflag",p),l.length||p)throw new Error("Contexts/pre-hash are not supported");return g});function R(g,l,p=!1){let E=p?dt:Dt;St("coordinate "+g,l,E,h)}function K(g){if(!(g instanceof f))throw new Error("ExtendedPoint expected")}let F=Te((g,l)=>{let{ex:p,ey:E,ez:_}=g,O=g.is0();l==null&&(l=O?Va:e.inv(_));let H=u(p*l),V=u(E*l),q=u(_*l);if(O)return{x:Dt,y:dt};if(q!==dt)throw new Error("invZ was invalid");return{x:H,y:V}}),S=Te(g=>{let{a:l,d:p}=t;if(g.is0())throw new Error("bad point: ZERO");let{ex:E,ey:_,ez:O,et:H}=g,V=u(E*E),q=u(_*_),j=u(O*O),rt=u(j*j),J=u(V*l),ct=u(j*u(J+q)),pt=u(rt+u(p*u(V*q)));if(ct!==pt)throw new Error("bad point: equation left != right (1)");let ot=u(E*_),ut=u(O*H);if(ot!==ut)throw new Error("bad point: equation left != right (2)");return!0});class f{constructor(l,p,E,_){R("x",l),R("y",p),R("z",E,!0),R("t",_),this.ex=l,this.ey=p,this.ez=E,this.et=_,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(l){if(l instanceof f)throw new Error("extended point not allowed");let{x:p,y:E}=l||{};return R("x",p),R("y",E),new f(p,E,dt,u(p*E))}static normalizeZ(l){let p=Pe(e,l.map(E=>E.ez));return l.map((E,_)=>E.toAffine(p[_])).map(f.fromAffine)}static msm(l,p){return br(f,d,l,p)}_setWindowSize(l){T.setWindowSize(this,l)}assertValidity(){S(this)}equals(l){K(l);let{ex:p,ey:E,ez:_}=this,{ex:O,ey:H,ez:V}=l,q=u(p*V),j=u(O*_),rt=u(E*V),J=u(H*_);return q===j&&rt===J}is0(){return this.equals(f.ZERO)}negate(){return new f(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:l}=t,{ex:p,ey:E,ez:_}=this,O=u(p*p),H=u(E*E),V=u(Fs*u(_*_)),q=u(l*O),j=p+E,rt=u(u(j*j)-O-H),J=q+H,ct=J-V,pt=q-H,ot=u(rt*ct),ut=u(J*pt),gt=u(rt*pt),It=u(ct*J);return new f(ot,ut,It,gt)}add(l){K(l);let{a:p,d:E}=t,{ex:_,ey:O,ez:H,et:V}=this,{ex:q,ey:j,ez:rt,et:J}=l,ct=u(_*q),pt=u(O*j),ot=u(V*E*J),ut=u(H*rt),gt=u((_+O)*(q+j)-ct-pt),It=ut-ot,Re=ut+ot,_o=u(pt-p*ct),Wi=u(gt*It),$i=u(Re*_o),Yi=u(gt*_o),Xi=u(It*Re);return new f(Wi,$i,Xi,Yi)}subtract(l){return this.add(l.negate())}wNAF(l){return T.wNAFCached(this,l,f.normalizeZ)}multiply(l){let p=l;St("scalar",p,dt,n);let{p:E,f:_}=this.wNAF(p);return f.normalizeZ([E,_])[0]}multiplyUnsafe(l,p=f.ZERO){let E=l;return St("scalar",E,Dt,n),E===Dt?I:this.is0()||E===dt?this:T.wNAFCachedUnsafe(this,E,f.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(l){return F(this,l)}clearCofactor(){let{h:l}=t;return l===dt?this:this.multiplyUnsafe(l)}static fromHex(l,p=!1){let{d:E,a:_}=t,O=e.BYTES;l=Y("pointHex",l,O),_t("zip215",p);let H=l.slice(),V=l[O-1];H[O-1]=V&-129;let q=ce(H),j=p?h:e.ORDER;St("pointHex.y",q,Dt,j);let rt=u(q*q),J=u(rt-dt),ct=u(E*rt-_),{isValid:pt,value:ot}=B(J,ct);if(!pt)throw new Error("Point.fromHex: invalid y coordinate");let ut=(ot&dt)===dt,gt=(V&128)!==0;if(!p&&ot===Dt&&gt)throw new Error("Point.fromHex: x=0 and x_0=1");return gt!==ut&&(ot=u(-ot)),f.fromAffine({x:ot,y:q})}static fromPrivateKey(l){let{scalar:p}=M(l);return m.multiply(p)}toRawBytes(){let{x:l,y:p}=this.toAffine(),E=Ie(p,e.BYTES);return E[E.length-1]|=l&dt?128:0,E}toHex(){return $t(this.toRawBytes())}}f.BASE=new f(t.Gx,t.Gy,dt,u(t.Gx*t.Gy)),f.ZERO=new f(Dt,dt,dt,Dt);let{BASE:m,ZERO:I}=f,T=yr(f,a*8);function P(g){return G(g,n)}function N(g){return P(ce(g))}function M(g){let l=e.BYTES;g=Y("private key",g,l);let p=Y("hashed private key",s(g),2*l),E=A(p.slice(0,l)),_=p.slice(l,2*l),O=N(E);return{head:E,prefix:_,scalar:O}}function U(g){let{head:l,prefix:p,scalar:E}=M(g),_=m.multiply(E),O=_.toRawBytes();return{head:l,prefix:p,scalar:E,point:_,pointBytes:O}}function k(g){return U(g).pointBytes}function D(g=Uint8Array.of(),...l){let p=Yt(...l);return N(s(x(p,Y("context",g),!!o)))}function et(g,l,p={}){g=Y("message",g),o&&(g=o(g));let{prefix:E,scalar:_,pointBytes:O}=U(l),H=D(p.context,E,g),V=m.multiply(H).toRawBytes(),q=D(p.context,V,O,g),j=P(H+q*_);St("signature.s",j,Dt,n);let rt=Yt(V,Ie(j,e.BYTES));return Y("result",rt,e.BYTES*2)}let w=qa;function b(g,l,p,E=w){let{context:_,zip215:O}=E,H=e.BYTES;g=Y("signature",g,2*H),l=Y("message",l),p=Y("publicKey",p,H),O!==void 0&&_t("zip215",O),o&&(l=o(l));let V=ce(g.slice(H,2*H)),q,j,rt;try{q=f.fromHex(p,O),j=f.fromHex(g.slice(0,H),O),rt=m.multiplyUnsafe(V)}catch{return!1}if(!O&&q.isSmallOrder())return!1;let J=D(_,j.toRawBytes(),q.toRawBytes(),l);return j.add(q.multiplyUnsafe(J)).subtract(rt).clearCofactor().equals(f.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:k,sign:et,verify:b,ExtendedPoint:f,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(e.BYTES),precompute(g=8,l=f.BASE){return l._setWindowSize(g),l.multiply(BigInt(3)),l}}}}var On=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Gs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Uh=BigInt(0),Fa=BigInt(1),Zs=BigInt(2),_h=BigInt(3),ja=BigInt(5),Ga=BigInt(8);function Za(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=On,a=r*r%s*r%s,c=X(a,Zs,s)*a%s,h=X(c,Fa,s)*r%s,u=X(h,ja,s)*h%s,d=X(u,t,s)*u%s,y=X(d,e,s)*d%s,B=X(y,n,s)*y%s,A=X(B,o,s)*B%s,x=X(A,o,s)*B%s,R=X(x,t,s)*u%s;return{pow_p_5_8:X(R,Zs,s)*r%s,b2:a}}function Wa(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function $a(r,t){let e=On,n=G(t*t*t,e),o=G(n*n*t,e),s=Za(r*o).pow_p_5_8,i=G(r*n*s,e),a=G(t*i*i,e),c=i,h=G(i*Gs,e),u=a===r,d=a===G(-r,e),y=a===G(-r*Gs,e);return u&&(i=c),(d||y)&&(i=h),ks(i,e)&&(i=G(-i,e)),{isValid:u||d,value:i}}var Ws=qt(On,void 0,!0),Ya={a:Ws.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ws,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ga,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Bs,randomBytes:pr,adjustScalarBytes:Wa,uvRatio:$a},$s=js(Ya);var wr=32;function Ys(r,t,e){return $s.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Er=class{type="Ed25519";raw;constructor(t){this.raw=Mn(t,wr)}toMultihash(){return Tt.digest(Se(this))}toCID(){return nt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Ys(this.raw,e,t)}};function Qs(r){return r=Mn(r,wr),new Er(r)}function Mn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Ct(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Qa=Math.pow(2,7),Ja=Math.pow(2,14),tu=Math.pow(2,21),Hn=Math.pow(2,28),Vn=Math.pow(2,35),qn=Math.pow(2,42),zn=Math.pow(2,49),z=128,ft=127;function xt(r){if(r<Qa)return 1;if(r<Ja)return 2;if(r<tu)return 3;if(r<Hn)return 4;if(r<Vn)return 5;if(r<qn)return 6;if(r<zn)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 eu(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 jn(r,t){let e=r[t],n=0;if(n+=e&ft,e<z||(e=r[t+1],n+=(e&ft)<<7,e<z)||(e=r[t+2],n+=(e&ft)<<14,e<z)||(e=r[t+3],n+=(e&ft)<<21,e<z)||(e=r[t+4],n+=(e&ft)*Hn,e<z)||(e=r[t+5],n+=(e&ft)*Vn,e<z)||(e=r[t+6],n+=(e&ft)*qn,e<z)||(e=r[t+7],n+=(e&ft)*zn,e<z))return n;throw new RangeError("Could not decode varint")}function ru(r,t){let e=r.get(t),n=0;if(n+=e&ft,e<z||(e=r.get(t+1),n+=(e&ft)<<7,e<z)||(e=r.get(t+2),n+=(e&ft)<<14,e<z)||(e=r.get(t+3),n+=(e&ft)<<21,e<z)||(e=r.get(t+4),n+=(e&ft)*Hn,e<z)||(e=r.get(t+5),n+=(e&ft)*Vn,e<z)||(e=r.get(t+6),n+=(e&ft)*qn,e<z)||(e=r.get(t+7),n+=(e&ft)*zn,e<z))return n;throw new RangeError("Could not decode varint")}function Le(r,t,e=0){return t==null&&(t=mt(xt(r))),t instanceof Uint8Array?Fn(r,t,e):eu(r,t,e)}function le(r,t=0){return r instanceof Uint8Array?jn(r,t):ru(r,t)}var Gn=new Float32Array([-0]),Xt=new Uint8Array(Gn.buffer);function ti(r,t,e){Gn[0]=r,t[e]=Xt[0],t[e+1]=Xt[1],t[e+2]=Xt[2],t[e+3]=Xt[3]}function ei(r,t){return Xt[0]=r[t],Xt[1]=r[t+1],Xt[2]=r[t+2],Xt[3]=r[t+3],Gn[0]}var Zn=new Float64Array([-0]),lt=new Uint8Array(Zn.buffer);function ri(r,t,e){Zn[0]=r,t[e]=lt[0],t[e+1]=lt[1],t[e+2]=lt[2],t[e+3]=lt[3],t[e+4]=lt[4],t[e+5]=lt[5],t[e+6]=lt[6],t[e+7]=lt[7]}function ni(r,t){return lt[0]=r[t],lt[1]=r[t+1],lt[2]=r[t+2],lt[3]=r[t+3],lt[4]=r[t+4],lt[5]=r[t+5],lt[6]=r[t+6],lt[7]=r[t+7],Zn[0]}var nu=BigInt(Number.MAX_SAFE_INTEGER),ou=BigInt(Number.MIN_SAFE_INTEGER),vt=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 he;if(t<nu&&t>ou)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>oi&&(o=0n,++n>oi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return he;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):he}},he=new vt(0,0);he.toBigInt=function(){return 0n};he.zzEncode=he.zzDecode=function(){return this};he.length=function(){return 1};var oi=4294967296n;function si(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 ii(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&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 Wn(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 Lt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Sr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var $n=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,Lt(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 Lt(this,4);return Sr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return Sr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=ei(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=ni(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 Lt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return ii(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while((this.buf[this.pos++]&128)!==0);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 vt(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 Lt(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 Lt(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 Lt(this,8);let t=Sr(this.buf,this.pos+=4),e=Sr(this.buf,this.pos+=4);return new vt(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=jn(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 Yn(r){return new $n(r instanceof Uint8Array?r:r.subarray())}function vr(r,t,e){let n=Yn(r);return t.decode(n,void 0,e)}function Xn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return mt(i);o+i>t&&(n=mt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var de=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Qn(){}var to=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},su=Xn();function iu(r){return globalThis.Buffer!=null?mt(r):su(r)}var Je=class{len;head;tail;states;constructor(){this.len=0,this.head=new de(Qn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new de(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new eo((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(Ar,10,vt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=vt.fromBigInt(t);return this._push(Ar,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=vt.fromBigInt(t).zzEncode();return this._push(Ar,e.length(),e)}sint64Number(t){let e=vt.fromNumber(t).zzEncode();return this._push(Ar,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Jn,1,t?1:0)}fixed32(t){return this._push(Qe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=vt.fromBigInt(t);return this._push(Qe,4,e.lo)._push(Qe,4,e.hi)}fixed64Number(t){let e=vt.fromNumber(t);return this._push(Qe,4,e.lo)._push(Qe,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(ti,4,t)}double(t){return this._push(ri,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Jn,1,0):this.uint32(e)._push(au,e,t)}string(t){let e=si(t);return e!==0?this.uint32(e)._push(Wn,e,t):this._push(Jn,1,0)}fork(){return this.states=new to(this),this.head=this.tail=new de(Qn,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 de(Qn,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=iu(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Jn(r,t,e){t[e]=r&255}function cu(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var eo=class extends de{next;constructor(t,e){super(cu,t,e),this.next=void 0}};function Ar(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 Qe(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 au(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Je.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(uu,t,r),this},Je.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(fu,t,r),this});function uu(r,t,e){t.set(r,e)}function fu(r,t,e){r.length<40?Wn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Bt(r),e)}function ro(){return new Je}function Br(r,t){let e=ro();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ce;(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"})(Ce||(Ce={}));function Ir(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function no(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Ir("enum",Ce.VARINT,e,n)}function Tr(r,t){return Ir("message",Ce.LENGTH_DELIMITED,r,t)}var At;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(At||(At={}));var oo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(oo||(oo={}));(function(r){r.codec=()=>no(oo)})(At||(At={}));var tr;(function(r){let t;r.codec=()=>(t==null&&(t=Tr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),At.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 a=e.uint32();switch(a>>>3){case 1:{s.Type=At.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>Br(e,r.codec()),r.decode=(e,n)=>vr(e,r.codec(),n)})(tr||(tr={}));var so;(function(r){let t;r.codec=()=>(t==null&&(t=Tr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),At.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 a=e.uint32();switch(a>>>3){case 1:{s.Type=At.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>Br(e,r.codec()),r.decode=(e,n)=>vr(e,r.codec(),n)})(so||(so={}));var er=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Pr=class extends ve{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,fs(t);let n=je(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),kt(s)}update(t){return Ae(this),this.iHash.update(t),this}digestInto(t){Ae(this),oe(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:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},io=(r,t,e)=>new Pr(r,t).update(e).digest();io.create=(r,t)=>new Pr(r,t);function ai(r){r.lowS!==void 0&&_t("lowS",r.lowS),r.prehash!==void 0&&_t("prehash",r.prehash)}function hu(r){let t=Xe(r);Vt(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var uo=class extends Error{constructor(t=""){super(t)}},zt={Err:uo,_tlv:{encode:(r,t)=>{let{Err:e}=zt;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=$e(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?$e(o.length/2|128):"";return $e(r)+s+o+t},decode(r,t){let{Err:e}=zt,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 c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+c);if(h.length!==c)throw new e("tlv.decode: length bytes not complete");if(h[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of h)i=i<<8|u;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=zt;if(r<Ft)throw new t("integer: negative integers are not allowed");let e=$e(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=zt;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 Ht(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=zt,o=Y("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:h,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(h)}},hexFromSig(r){let{_tlv:t,_int:e}=zt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function co(r,t){return $t(ae(r,t))}var Ft=BigInt(0),it=BigInt(1),Nd=BigInt(2),ao=BigInt(3),du=BigInt(4);function pu(r){let t=hu(r),{Fp:e}=t,n=qt(t.n,t.nBitLength),o=t.toBytes||((S,f,m)=>{let I=f.toAffine();return Yt(Uint8Array.from([4]),e.toBytes(I.x),e.toBytes(I.y))}),s=t.fromBytes||(S=>{let f=S.subarray(1),m=e.fromBytes(f.subarray(0,e.BYTES)),I=e.fromBytes(f.subarray(e.BYTES,2*e.BYTES));return{x:m,y:I}});function i(S){let{a:f,b:m}=t,I=e.sqr(S),T=e.mul(I,S);return e.add(e.add(T,e.mul(S,f)),m)}function a(S,f){let m=e.sqr(f),I=i(S);return e.eql(m,I)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let c=e.mul(e.pow(t.a,ao),du),h=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(c,h)))throw new Error("bad curve params: a or b");function u(S){return xr(S,it,t.n)}function d(S){let{allowedPrivateKeyLengths:f,nByteLength:m,wrapPrivateKey:I,n:T}=t;if(f&&typeof S!="bigint"){if(Be(S)&&(S=$t(S)),typeof S!="string"||!f.includes(S.length))throw new Error("invalid private key");S=S.padStart(m*2,"0")}let P;try{P=typeof S=="bigint"?S:Ht(Y("private key",S,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof S)}return I&&(P=G(P,T)),St("private key",P,it,T),P}function y(S){if(!(S instanceof x))throw new Error("ProjectivePoint expected")}let B=Te((S,f)=>{let{px:m,py:I,pz:T}=S;if(e.eql(T,e.ONE))return{x:m,y:I};let P=S.is0();f==null&&(f=P?e.ONE:e.inv(T));let N=e.mul(m,f),M=e.mul(I,f),U=e.mul(T,f);if(P)return{x:e.ZERO,y:e.ZERO};if(!e.eql(U,e.ONE))throw new Error("invZ was invalid");return{x:N,y:M}}),A=Te(S=>{if(S.is0()){if(t.allowInfinityPoint&&!e.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:f,y:m}=S.toAffine();if(!e.isValid(f)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!a(f,m))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class x{constructor(f,m,I){if(f==null||!e.isValid(f))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(I==null||!e.isValid(I))throw new Error("z required");this.px=f,this.py=m,this.pz=I,Object.freeze(this)}static fromAffine(f){let{x:m,y:I}=f||{};if(!f||!e.isValid(m)||!e.isValid(I))throw new Error("invalid affine point");if(f instanceof x)throw new Error("projective point not allowed");let T=P=>e.eql(P,e.ZERO);return T(m)&&T(I)?x.ZERO:new x(m,I,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){let m=Pe(e,f.map(I=>I.pz));return f.map((I,T)=>I.toAffine(m[T])).map(x.fromAffine)}static fromHex(f){let m=x.fromAffine(s(Y("pointHex",f)));return m.assertValidity(),m}static fromPrivateKey(f){return x.BASE.multiply(d(f))}static msm(f,m){return br(x,n,f,m)}_setWindowSize(f){F.setWindowSize(this,f)}assertValidity(){A(this)}hasEvenY(){let{y:f}=this.toAffine();if(e.isOdd)return!e.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){y(f);let{px:m,py:I,pz:T}=this,{px:P,py:N,pz:M}=f,U=e.eql(e.mul(m,M),e.mul(P,T)),k=e.eql(e.mul(I,M),e.mul(N,T));return U&&k}negate(){return new x(this.px,e.neg(this.py),this.pz)}double(){let{a:f,b:m}=t,I=e.mul(m,ao),{px:T,py:P,pz:N}=this,M=e.ZERO,U=e.ZERO,k=e.ZERO,D=e.mul(T,T),et=e.mul(P,P),w=e.mul(N,N),b=e.mul(T,P);return b=e.add(b,b),k=e.mul(T,N),k=e.add(k,k),M=e.mul(f,k),U=e.mul(I,w),U=e.add(M,U),M=e.sub(et,U),U=e.add(et,U),U=e.mul(M,U),M=e.mul(b,M),k=e.mul(I,k),w=e.mul(f,w),b=e.sub(D,w),b=e.mul(f,b),b=e.add(b,k),k=e.add(D,D),D=e.add(k,D),D=e.add(D,w),D=e.mul(D,b),U=e.add(U,D),w=e.mul(P,N),w=e.add(w,w),D=e.mul(w,b),M=e.sub(M,D),k=e.mul(w,et),k=e.add(k,k),k=e.add(k,k),new x(M,U,k)}add(f){y(f);let{px:m,py:I,pz:T}=this,{px:P,py:N,pz:M}=f,U=e.ZERO,k=e.ZERO,D=e.ZERO,et=t.a,w=e.mul(t.b,ao),b=e.mul(m,P),L=e.mul(I,N),g=e.mul(T,M),l=e.add(m,I),p=e.add(P,N);l=e.mul(l,p),p=e.add(b,L),l=e.sub(l,p),p=e.add(m,T);let E=e.add(P,M);return p=e.mul(p,E),E=e.add(b,g),p=e.sub(p,E),E=e.add(I,T),U=e.add(N,M),E=e.mul(E,U),U=e.add(L,g),E=e.sub(E,U),D=e.mul(et,p),U=e.mul(w,g),D=e.add(U,D),U=e.sub(L,D),D=e.add(L,D),k=e.mul(U,D),L=e.add(b,b),L=e.add(L,b),g=e.mul(et,g),p=e.mul(w,p),L=e.add(L,g),g=e.sub(b,g),g=e.mul(et,g),p=e.add(p,g),b=e.mul(L,p),k=e.add(k,b),b=e.mul(E,p),U=e.mul(l,U),U=e.sub(U,b),b=e.mul(l,L),D=e.mul(E,D),D=e.add(D,b),new x(U,k,D)}subtract(f){return this.add(f.negate())}is0(){return this.equals(x.ZERO)}wNAF(f){return F.wNAFCached(this,f,x.normalizeZ)}multiplyUnsafe(f){let{endo:m,n:I}=t;St("scalar",f,Ft,I);let T=x.ZERO;if(f===Ft)return T;if(this.is0()||f===it)return this;if(!m||F.hasPrecomputes(this))return F.wNAFCachedUnsafe(this,f,x.normalizeZ);let{k1neg:P,k1:N,k2neg:M,k2:U}=m.splitScalar(f),k=T,D=T,et=this;for(;N>Ft||U>Ft;)N&it&&(k=k.add(et)),U&it&&(D=D.add(et)),et=et.double(),N>>=it,U>>=it;return P&&(k=k.negate()),M&&(D=D.negate()),D=new x(e.mul(D.px,m.beta),D.py,D.pz),k.add(D)}multiply(f){let{endo:m,n:I}=t;St("scalar",f,it,I);let T,P;if(m){let{k1neg:N,k1:M,k2neg:U,k2:k}=m.splitScalar(f),{p:D,f:et}=this.wNAF(M),{p:w,f:b}=this.wNAF(k);D=F.constTimeNegate(N,D),w=F.constTimeNegate(U,w),w=new x(e.mul(w.px,m.beta),w.py,w.pz),T=D.add(w),P=et.add(b)}else{let{p:N,f:M}=this.wNAF(f);T=N,P=M}return x.normalizeZ([T,P])[0]}multiplyAndAddUnsafe(f,m,I){let T=x.BASE,P=(M,U)=>U===Ft||U===it||!M.equals(T)?M.multiplyUnsafe(U):M.multiply(U),N=P(this,m).add(P(f,I));return N.is0()?void 0:N}toAffine(f){return B(this,f)}isTorsionFree(){let{h:f,isTorsionFree:m}=t;if(f===it)return!0;if(m)return m(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:f,clearCofactor:m}=t;return f===it?this:m?m(x,this):this.multiplyUnsafe(t.h)}toRawBytes(f=!0){return _t("isCompressed",f),this.assertValidity(),o(x,this,f)}toHex(f=!0){return _t("isCompressed",f),$t(this.toRawBytes(f))}}x.BASE=new x(t.Gx,t.Gy,e.ONE),x.ZERO=new x(e.ZERO,e.ONE,e.ZERO);let{endo:R,nBitLength:K}=t,F=yr(x,R?Math.ceil(K/2):K);return{CURVE:t,ProjectivePoint:x,normPrivateKeyToScalar:d,weierstrassEquation:i,isWithinCurveOrder:u}}function mu(r){let t=Xe(r);return Vt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ui(r){let t=mu(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,a=2*e.BYTES+1;function c(w){return G(w,n)}function h(w){return gr(w,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:d,weierstrassEquation:y,isWithinCurveOrder:B}=pu({...t,toBytes(w,b,L){let g=b.toAffine(),l=e.toBytes(g.x),p=Yt;return _t("isCompressed",L),L?p(Uint8Array.from([b.hasEvenY()?2:3]),l):p(Uint8Array.from([4]),l,e.toBytes(g.y))},fromBytes(w){let b=w.length,L=w[0],g=w.subarray(1);if(b===i&&(L===2||L===3)){let l=Ht(g);if(!xr(l,it,e.ORDER))throw new Error("Point is not on curve");let p=y(l),E;try{E=e.sqrt(p)}catch(H){let V=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+V)}let _=(E&it)===it;return(L&1)===1!==_&&(E=e.neg(E)),{x:l,y:E}}else if(b===a&&L===4){let l=e.fromBytes(g.subarray(0,e.BYTES)),p=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:l,y:p}}else{let l=i,p=a;throw new Error("invalid Point, expected length of "+l+", or uncompressed "+p+", got "+b)}}});function A(w){let b=n>>it;return w>b}function x(w){return A(w)?c(-w):w}let R=(w,b,L)=>Ht(w.slice(b,L));class K{constructor(b,L,g){St("r",b,it,n),St("s",L,it,n),this.r=b,this.s=L,g!=null&&(this.recovery=g),Object.freeze(this)}static fromCompact(b){let L=o;return b=Y("compactSignature",b,L*2),new K(R(b,0,L),R(b,L,2*L))}static fromDER(b){let{r:L,s:g}=zt.toSig(Y("DER",b));return new K(L,g)}assertValidity(){}addRecoveryBit(b){return new K(this.r,this.s,b)}recoverPublicKey(b){let{r:L,s:g,recovery:l}=this,p=T(Y("msgHash",b));if(l==null||![0,1,2,3].includes(l))throw new Error("recovery id invalid");let E=l===2||l===3?L+t.n:L;if(E>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=(l&1)===0?"02":"03",O=u.fromHex(_+co(E,e.BYTES)),H=h(E),V=c(-p*H),q=c(g*H),j=u.BASE.multiplyAndAddUnsafe(O,V,q);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Ye(this.toDERHex())}toDERHex(){return zt.hexFromSig(this)}toCompactRawBytes(){return Ye(this.toCompactHex())}toCompactHex(){let b=o;return co(this.r,b)+co(this.s,b)}}let F={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let w=_n(t.n);return Ms(t.randomBytes(w),t.n)},precompute(w=8,b=u.BASE){return b._setWindowSize(w),b.multiply(BigInt(3)),b}};function S(w,b=!0){return u.fromPrivateKey(w).toRawBytes(b)}function f(w){if(typeof w=="bigint")return!1;if(w instanceof u)return!0;let L=Y("key",w).length,g=e.BYTES,l=g+1,p=2*g+1;if(!(t.allowedPrivateKeyLengths||o===l))return L===l||L===p}function m(w,b,L=!0){if(f(w)===!0)throw new Error("first arg must be private key");if(f(b)===!1)throw new Error("second arg must be public key");return u.fromHex(b).multiply(d(w)).toRawBytes(L)}let I=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let b=Ht(w),L=w.length*8-s;return L>0?b>>BigInt(L):b},T=t.bits2int_modN||function(w){return c(I(w))},P=ue(s);function N(w){return St("num < 2^"+s,w,Ft,P),ae(w,o)}function M(w,b,L=U){if(["recovered","canonical"].some(J=>J in L))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:l}=t,{lowS:p,prehash:E,extraEntropy:_}=L;p==null&&(p=!0),w=Y("msgHash",w),ai(L),E&&(w=Y("prehashed msgHash",g(w)));let O=T(w),H=d(b),V=[N(H),N(O)];if(_!=null&&_!==!1){let J=_===!0?l(e.BYTES):_;V.push(Y("extraEntropy",J))}let q=Yt(...V),j=O;function rt(J){let ct=I(J);if(!B(ct))return;let pt=h(ct),ot=u.BASE.multiply(ct).toAffine(),ut=c(ot.x);if(ut===Ft)return;let gt=c(pt*c(j+ut*H));if(gt===Ft)return;let It=(ot.x===ut?0:2)|Number(ot.y&it),Re=gt;return p&&A(gt)&&(Re=x(gt),It^=1),new K(ut,Re,It)}return{seed:q,k2sig:rt}}let U={lowS:t.lowS,prehash:!1},k={lowS:t.lowS,prehash:!1};function D(w,b,L=U){let{seed:g,k2sig:l}=M(w,b,L),p=t;return Us(p.hash.outputLen,p.nByteLength,p.hmac)(g,l)}u.BASE._setWindowSize(8);function et(w,b,L,g=k){let l=w;b=Y("msgHash",b),L=Y("publicKey",L);let{lowS:p,prehash:E,format:_}=g;if(ai(g),"strict"in g)throw new Error("options.strict was renamed to lowS");if(_!==void 0&&_!=="compact"&&_!=="der")throw new Error("format must be compact or der");let O=typeof l=="string"||Be(l),H=!O&&!_&&typeof l=="object"&&l!==null&&typeof l.r=="bigint"&&typeof l.s=="bigint";if(!O&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,q;try{if(H&&(V=new K(l.r,l.s)),O){try{_!=="compact"&&(V=K.fromDER(l))}catch(It){if(!(It instanceof zt.Err))throw It}!V&&_!=="der"&&(V=K.fromCompact(l))}q=u.fromHex(L)}catch{return!1}if(!V||p&&V.hasHighS())return!1;E&&(b=t.hash(b));let{r:j,s:rt}=V,J=T(b),ct=h(rt),pt=c(J*ct),ot=c(j*ct),ut=u.BASE.multiplyAndAddUnsafe(q,pt,ot)?.toAffine();return ut?c(ut.x)===j:!1}return{CURVE:t,getPublicKey:S,getSharedSecret:m,sign:D,verify:et,ProjectivePoint:u,Signature:K,utils:F}}function xu(r){return{hash:r,hmac:(t,...e)=>io(r,t,bn(...e)),randomBytes:pr}}function fi(r,t){let e=n=>ui({...r,...xu(n)});return{...e(t),create:e}}var di=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),li=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),gu=BigInt(0),yu=BigInt(1),fo=BigInt(2),hi=(r,t)=>(r+t/fo)/t;function bu(r){let t=di,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),h=r*r*r%t,u=h*h*r%t,d=X(u,e,t)*u%t,y=X(d,e,t)*u%t,B=X(y,fo,t)*h%t,A=X(B,o,t)*B%t,x=X(A,s,t)*A%t,R=X(x,a,t)*x%t,K=X(R,c,t)*R%t,F=X(K,a,t)*x%t,S=X(F,e,t)*u%t,f=X(S,i,t)*A%t,m=X(f,n,t)*h%t,I=X(m,fo,t);if(!lo.eql(lo.sqr(I),r))throw new Error("Cannot find square root");return I}var lo=qt(di,void 0,void 0,{sqrt:bu}),Ue=fi({a:gu,b:BigInt(7),Fp:lo,n:li,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=li,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-yu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=hi(s*r,t),c=hi(-n*r,t),h=G(r-a*e-c*o,t),u=G(-a*n-c*s,t),d=h>i,y=u>i;if(d&&(h=t-h),y&&(u=t-u),h>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:h,k2neg:y,k2:u}}}},As);function pi(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function mi(r,t,e){let n=Ve.digest(e instanceof Uint8Array?e:e.subarray());if(pi(n))return n.then(({digest:o})=>Ue.verify(t,o,r)).catch(o=>{throw new er(String(o))});try{return Ue.verify(t,n.digest,r)}catch(o){throw new er(String(o))}}var Lr=class{type="secp256k1";raw;_key;constructor(t){this._key=gi(t),this.raw=xi(this._key)}toMultihash(){return Tt.digest(Se(this))}toCID(){return nt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return mi(this._key,e,t)}};function yi(r){return new Lr(r)}function xi(r){return Ue.ProjectivePoint.fromHex(r).toRawBytes(!0)}function gi(r){try{return Ue.ProjectivePoint.fromHex(r),r}catch(t){throw new or(String(t))}}function bi(r){let{Type:t,Data:e}=tr.decode(r.digest),n=e??new Uint8Array;switch(t){case At.Ed25519:return Qs(n);case At.secp256k1:return yi(n);case At.ECDSA:return cs(n);default:throw new Ke}}function Se(r){return tr.encode({Type:At[r.type],Data:r.raw})}var wi=Symbol.for("nodejs.util.inspect.custom"),wu=114,rr=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()})`}[Fr]=!0;toString(){return this.string==null&&(this.string=$.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return nt.createV1(wu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[wi](){return`PeerId(${this.toString()})`}},Cr=class extends rr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ur=class extends rr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},_r=class extends rr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Eu=2336,nr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Tt.digest(Bt(this.url))}[wi](){return`PeerId(${this.url})`}[Fr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return nt.createV1(Eu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Z(t)),t.toString()===this.toString())}};var Su=114,Ei=2336;function Si(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=ee($.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return vu(nt.parse(r));if(t==null)throw new Ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=ee(t.decode(r))}return vi(e)}function vi(r){if(Bu(r))return new Cr({multihash:r});if(Au(r))try{let t=bi(r);if(t.type==="Ed25519")return new Ur({multihash:r,publicKey:t});if(t.type==="secp256k1")return new _r({multihash:r,publicKey:t})}catch{let e=Z(r.digest);return new nr(new URL(e))}throw new ir("Supplied PeerID Multihash is invalid")}function vu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Su&&r.code!==Ei)throw new sr("Supplied PeerID CID is invalid");if(r.code===Ei){let t=Z(r.multihash.digest);return new nr(new URL(t))}return vi(r.multihash)}function Au(r){return r.code===Tt.code}function Bu(r){return r.code===Ve.code}var Dr=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,a=this.peekChar();if(a===void 0)return;let c=a==="0",h=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let y=Number.parseInt(d,t);if(!Number.isNaN(y))return y});if(u===void 0)break;if(s*=t,s+=u,s>h||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&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),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ai=45,Iu=15,_e=new Dr;function ho(r){if(!(r.length>Iu))return _e.new(r).parseWith(()=>_e.readIPv4Addr())}function po(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ai))return _e.new(r).parseWith(()=>_e.readIPv6Addr())}function Nr(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Ai)return;let e=_e.new(r).parseWith(()=>_e.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var e0=parseInt("0xFFFF",16),r0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ti(r){return!!ho(r)}function Pi(r){return!!po(r)}function Rr(r){return!!Nr(r)}var Li=Ti,Uu=Pi,mo=function(r){let t=0;if(r=r.toString().trim(),Li(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Uu(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Li(e[n]),i;s&&(i=mo(e[n]),e[n]=Z(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,Z(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")},Ci=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 De={},xo={},Du=[[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"]];Du.forEach(r=>{let t=Nu(...r);xo[t.code]=t,De[t.name]=t});function Nu(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function W(r){if(typeof r=="number"){if(xo[r]!=null)return xo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(De[r]!=null)return De[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var M0=W("ip4"),H0=W("ip6"),V0=W("ipcidr");function wo(r,t){switch(W(r).code){case 4:case 41:return Ku(t);case 42:return bo(t);case 43:return Z(t,"base10");case 6:case 273:case 33:case 132:return Di(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bo(t);case 421:return Hu(t);case 444:return _i(t);case 445:return _i(t);case 466:return Mu(t);case 481:return globalThis.encodeURIComponent(bo(t));default:return Z(t,"base16")}}function Eo(r,t){switch(W(r).code){case 4:return Ui(t);case 41:return Ui(t);case 42:return yo(t);case 43:return Bt(t,"base10");case 6:case 273:case 33:case 132:return So(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return yo(t);case 421:return ku(t);case 444:return Vu(t);case 445:return qu(t);case 466:return Ou(t);case 481:return yo(globalThis.decodeURIComponent(t));default:return Bt(t,"base16")}}var go=Object.values(qe).map(r=>r.decoder),Ru=function(){let r=go[0].or(go[1]);return go.slice(2).forEach(t=>r=r.or(t)),r}();function Ui(r){if(!Rr(r))throw new Error("invalid ip address");return mo(r)}function Ku(r){let t=Ci(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Rr(t))throw new Error("invalid ip address");return t}function So(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Di(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function yo(r){let t=Bt(r),e=Uint8Array.from(Le(t.length));return wt([e,t],e.length+t.length)}function bo(r){let t=le(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return Z(r)}function ku(r){let t;r[0]==="Q"||r[0]==="1"?t=ee($.decode(`z${r}`)).bytes:t=nt.parse(r).multihash.bytes;let e=Uint8Array.from(Le(t.length));return wt([e,t],e.length+t.length)}function Ou(r){let t=Ru.decode(r),e=Uint8Array.from(Le(t.length));return wt([e,t],e.length+t.length)}function Mu(r){let t=le(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+Z(e,"base64url")}function Hu(r){let t=le(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return Z(e,"base58btc")}function Vu(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=Rt.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=So(n);return wt([e,o],e.length+o.length)}function qu(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=Rt.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=So(n);return wt([e,o],e.length+o.length)}function _i(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=Z(t,"base32"),o=Di(e);return`${n}:${o}`}function Ni(r){r=vo(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],a=W(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw new Kr("invalid address: "+r);if(a.path===!0){n=vo(o.slice(s).join("/")),t.push([a.code,Eo(a.code,n)]),e.push([a.code,n]);break}let c=Eo(a.code,o[s]);t.push([a.code,c]),e.push([a.code,wo(a.code,c)])}return{string:Ri(e),bytes:kr(t),tuples:t,stringTuples:e,path:n}}function Ao(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=le(r,o),i=xt(s),a=W(s),c=zu(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let h=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new Kr("Invalid address Uint8Array: "+Z(r,"base16"));t.push([s,h]);let u=wo(s,h);if(e.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Ri(e),tuples:t,stringTuples:e,path:n}}function Ri(r){let t=[];return r.map(e=>{let n=W(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),vo(t.join("/"))}function kr(r){return wt(r.map(t=>{let e=W(t[0]),n=Uint8Array.from(Le(e.code));return t.length>1&&t[1]!=null&&(n=wt([n,t[1]])),n}))}function zu(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=le(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function vo(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Kr=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Fu=Symbol.for("nodejs.util.inspect.custom"),Io=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ju=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],Bo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Or=class r{bytes;#t;#e;#r;#n;[Io]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ao(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ni(t)}else if(ki(t))e=Ao(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=W("tcp"),a=W("udp"),c=W("ip4"),h=W("ip6"),u=W("dns6"),d=W("ip6zone");for(let[B,A]of this.stringTuples())B===d.code&&(s=`%${A??""}`),ju.includes(B)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${A??""}${s}`,t=B===u.code?6:4),(B===i.code||B===a.code)&&(e=W(B).name==="tcp"?"tcp":"udp",o=parseInt(A??"")),(B===c.code||B===h.code)&&(e=W(B).name==="tcp"?"tcp":"udp",n=`${A??""}${s}`,t=B===h.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({},W(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>W(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}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(kr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===De.p2p.code&&t.push([n,o]),n===De["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?Z($.decode(`z${n}`),"base58btc"):Z(nt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return bt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Ki.get(e.name);if(n==null)throw new Bo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Qt(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)}[Fu](){return`Multiaddr(${this.#t})`}};var Ki=new Map;function ki(r){return!!r?.[Io]}function Qt(r){return new Or(r)}var Gu=v("dns4"),Zu=v("dns6"),Wu=v("dnsaddr"),me=tt(v("dns"),Wu,Gu,Zu),Vr=tt(v("ip4"),v("ip6")),Ne=tt(C(Vr,v("tcp")),C(me,v("tcp"))),qr=C(Vr,v("udp")),$u=C(qr,v("utp")),Yu=C(qr,v("quic")),Xu=C(qr,v("quic-v1")),To=tt(C(Ne,v("ws")),C(me,v("ws"))),Mr=tt(C(To,v("p2p")),To),Po=tt(C(Ne,v("wss")),C(me,v("wss")),C(Ne,v("tls"),v("ws")),C(me,v("tls"),v("ws"))),Hr=tt(C(Po,v("p2p")),Po),Lo=tt(C(Ne,v("http")),C(Vr,v("http")),C(me,v("http"))),Co=tt(C(Ne,v("https")),C(Vr,v("https")),C(me,v("https"))),Oi=C(qr,v("webrtc-direct"),v("certhash")),Vi=tt(C(Oi,v("p2p")),Oi),Mi=C(Xu,v("webtransport"),v("certhash"),v("certhash")),qi=tt(C(Mi,v("p2p")),Mi),zi=tt(C(Mr,v("p2p-webrtc-star"),v("p2p")),C(Hr,v("p2p-webrtc-star"),v("p2p")),C(Mr,v("p2p-webrtc-star")),C(Hr,v("p2p-webrtc-star"))),pm=tt(C(Mr,v("p2p-websocket-star"),v("p2p")),C(Hr,v("p2p-websocket-star"),v("p2p")),C(Mr,v("p2p-websocket-star")),C(Hr,v("p2p-websocket-star"))),Fi=tt(C(Lo,v("p2p-webrtc-direct"),v("p2p")),C(Co,v("p2p-webrtc-direct"),v("p2p")),C(Lo,v("p2p-webrtc-direct")),C(Co,v("p2p-webrtc-direct"))),xe=tt(To,Po,Lo,Co,zi,Fi,Ne,$u,Yu,me,Vi,qi),mm=tt(C(xe,v("p2p-stardust"),v("p2p")),C(xe,v("p2p-stardust"))),Jt=tt(C(xe,v("p2p")),zi,Fi,Vi,qi,v("p2p")),Hi=tt(C(Jt,v("p2p-circuit"),Jt),C(Jt,v("p2p-circuit")),C(v("p2p-circuit"),Jt),C(xe,v("p2p-circuit")),C(v("p2p-circuit"),xe),v("p2p-circuit")),ji=()=>tt(C(Hi,ji),Hi),pe=ji(),Gi=tt(C(pe,Jt,pe),C(Jt,pe),C(pe,Jt),pe,Jt);var xm=tt(C(pe,v("webrtc"),v("p2p")),C(pe,v("webrtc")),C(xe,v("webrtc"),v("p2p")),C(xe,v("webrtc")),v("webrtc"));function Zi(r){function t(e){let n;try{n=Qt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function C(...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:Zi(t),partialMatch:t}}function tt(...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:Zi(t),partialMatch:t}}function v(r){let t=r;function e(o){let s;try{s=Qt(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 Qu="bootstrap",Ju=50,tf=1e3,Uo=class extends cr{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??tf,this.list=[];for(let n of e.list){if(!Gi.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Qt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Si(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Do]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[No]=["@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??Qu]:{value:this._init.tagValue??Ju,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 ef(r){return t=>new Uo(t,r)}return rc(rf);})();
2
+ "use strict";var Libp2PBootstrap=(()=>{var Gr=Object.defineProperty;var ji=Object.getOwnPropertyDescriptor;var Gi=Object.getOwnPropertyNames;var Zi=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)Gr(r,e,{get:t[e],enumerable:!0})},$i=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gi(t))!Zi.call(r,o)&&o!==e&&Gr(r,o,{get:()=>t[o],enumerable:!(n=ji(t,o))||n.enumerable});return r};var Wi=r=>$i(Gr({},"__esModule",{value:!0}),r);var ou={};ut(ou,{bootstrap:()=>nu});var _o=Symbol.for("@libp2p/peer-discovery");var Zr=Symbol.for("@libp2p/peer-id");var St=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},er=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var rr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},nr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Pe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var or=class extends EventTarget{#t=new Map;constructor(){super()}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 Lo=Symbol.for("@libp2p/service-capabilities"),uu=Symbol.for("@libp2p/service-dependencies");var Qr={};ut(Qr,{base58btc:()=>z,base58flickr:()=>ra});var Du=new Uint8Array(0);function Po(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 It(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 Co(r){return new TextEncoder().encode(r)}function Do(r){return new TextDecoder().decode(r)}function Yi(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 a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(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 S=0,y=0,v=0,P=E.length;v!==P&&E[v]===0;)v++,S++;for(var I=(P-v)*f+1>>>0,N=new Uint8Array(I);v!==P;){for(var m=E[v],D=0,C=I-1;(m!==0||D<y)&&C!==-1;C--,D++)m+=256*N[C]>>>0,N[C]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");y=D,v++}for(var T=I-y;T!==I&&N[T]===0;)T++;for(var l=c.repeat(S);T<I;++T)l+=r.charAt(N[T]);return l}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var S=0;if(E[S]!==" "){for(var y=0,v=0;E[S]===c;)y++,S++;for(var P=(E.length-S)*h+1>>>0,I=new Uint8Array(P);E[S];){var N=e[E.charCodeAt(S)];if(N===255)return;for(var m=0,D=P-1;(N!==0||m<v)&&D!==-1;D--,m++)N+=a*I[D]>>>0,I[D]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");v=m,S++}if(E[S]!==" "){for(var C=P-v;C!==P&&I[C]===0;)C++;for(var T=new Uint8Array(y+(P-C)),l=y;C!==P;)T[l++]=I[C++];return T}}}function d(E){var S=x(E);if(S)return S;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:x,decode:d}}var Xi=Yi,Qi=Xi,No=Qi;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")}},Wr=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 Ro(this,t)}},Yr=class{decoders;constructor(t){this.decoders=t}or(t){return Ro(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 Ro(r,t){return new Yr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Xr=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 Wr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ce({name:r,prefix:t,encode:e,decode:n}){return new Xr(r,t,e,n)}function Nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=No(e,r);return ce({prefix:t,name:r,encode:n,decode:s=>It(o(s))})}function Ji(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let h=0;h<o;++h){let f=t[r[h]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function ta(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function ea(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function Z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=ea(n);return ce({prefix:t,name:r,encode(s){return ta(s,n,e)},decode(s){return Ji(s,o,e,r)}})}var z=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ra=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Jr={};ut(Jr,{base32:()=>Tt,base32hex:()=>ia,base32hexpad:()=>ca,base32hexpadupper:()=>fa,base32hexupper:()=>aa,base32pad:()=>oa,base32padupper:()=>sa,base32upper:()=>na,base32z:()=>ua});var Tt=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),na=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),oa=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sa=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ia=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),aa=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ca=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fa=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ua=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var tn={};ut(tn,{base36:()=>Ce,base36upper:()=>la});var Ce=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),la=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ha=Oo,Ko=128,da=127,pa=~da,ma=Math.pow(2,31);function Oo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ma;)t[e++]=r&255|Ko,r/=128;for(;r&pa;)t[e++]=r&255|Ko,r>>>=7;return t[e]=r|0,Oo.bytes=e-n+1,t}var ya=en,ba=128,ko=127;function en(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw en.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&ko)<<o:(i&ko)*Math.pow(2,o),o+=7}while(i>=ba);return en.bytes=s-n,e}var xa=Math.pow(2,7),ga=Math.pow(2,14),wa=Math.pow(2,21),Ea=Math.pow(2,28),Sa=Math.pow(2,35),va=Math.pow(2,42),Aa=Math.pow(2,49),Ba=Math.pow(2,56),Ia=Math.pow(2,63),Ta=function(r){return r<xa?1:r<ga?2:r<wa?3:r<Ea?4:r<Sa?5:r<va?6:r<Aa?7:r<Ba?8:r<Ia?9:10},_a={encode:ha,decode:ya,encodingLength:Ta},La=_a,De=La;function Ue(r,t=0){return[De.decode(r,t),De.decode.bytes]}function fe(r,t,e=0){return De.encode(r,t,e),t}function ue(r){return De.encodingLength(r)}function Ft(r,t){let e=t.byteLength,n=ue(r),o=n+ue(e),s=new Uint8Array(o+e);return fe(r,s,0),fe(e,s,n),s.set(t,o),new le(r,e,t,s)}function jt(r){let t=It(r),[e,n]=Ue(t),[o,s]=Ue(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new le(e,o,i,t)}function Mo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Po(r.bytes,e.bytes)}}var le=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Ho(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ca(e,rn(r),t??z.encoder);default:return Da(e,rn(r),t??Tt.encoder)}}var qo=new WeakMap;function rn(r){let t=qo.get(r);if(t==null){let e=new Map;return qo.set(r,e),e}return t}var X=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!==Ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ua)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=Ft(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&&Mo(t.multihash,n.multihash)}toString(t){return Ho(this,t)}toJSON(){return{"/":Ho(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??Vo(n,o,s.bytes))}else if(e[Na]===!0){let{version:n,multihash:o,code:s}=e,i=jt(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!==Ne)throw new Error(`Version 0 CID must use dag-pb (code: ${Ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Vo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ne,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=It(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 le(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[u,x]=Ue(t.subarray(e));return e+=x,u},o=n(),s=Ne;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),h=e+c,f=h-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:h}}static parse(t,e){let[n,o]=Pa(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 rn(s).set(n,t),s}};function Pa(r,t){switch(r[0]){case"Q":{let e=t??z;return[z.prefix,e.decode(`${z.prefix}${r}`)]}case z.prefix:{let e=t??z;return[z.prefix,e.decode(r)]}case Tt.prefix:{let e=t??Tt;return[Tt.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 Ca(r,t,e){let{prefix:n}=e;if(n!==z.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 Da(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 Ne=112,Ua=18;function Vo(r,t,e){let n=ue(r),o=n+ue(t),s=new Uint8Array(o+e.byteLength);return fe(r,s,0),fe(t,s,n),s.set(e,o),s}var Na=Symbol.for("@ipld/js-cid/CID");var nn={};ut(nn,{identity:()=>xt});var zo=0,Ra="identity",Fo=It;function Ka(r){return Ft(zo,Fo(r))}var xt={code:zo,name:Ra,encode:Fo,digest:Ka};function lt(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 _t(r=0){return new Uint8Array(r)}function ct(r=0){return new Uint8Array(r)}function ht(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ct(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Go=Symbol.for("@achingbrain/uint8arraylist");function jo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ir(r){return!!r?.[Go]}var dt=class r{bufs;length;[Go]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ir(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ir(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=jo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=jo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ir(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return ht(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:ht(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let h=t>=a&&t<c,f=e>a&&e<=c;if(h&&f){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ir(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,h=n.byteLength-1,f;for(let u=e;u<=c;u+=f){f=0;for(let x=h;x>=0;x--){let d=this.get(u+x);if(n[x]!==d){f=Math.max(1,x-a[d]);break}}if(f===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=_t(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=_t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=_t(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=_t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=_t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!lt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var on={};ut(on,{base10:()=>ka});var ka=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var sn={};ut(sn,{base16:()=>Oa,base16upper:()=>Ma});var Oa=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ma=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var an={};ut(an,{base2:()=>Ha});var Ha=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var cn={};ut(cn,{base256emoji:()=>ja});var Zo=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}"),qa=Zo.reduce((r,t,e)=>(r[e]=t,r),[]),Va=Zo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function za(r){return r.reduce((t,e)=>(t+=qa[e],t),"")}function Fa(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Va[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ja=ce({prefix:"\u{1F680}",name:"base256emoji",encode:za,decode:Fa});var fn={};ut(fn,{base64:()=>Ga,base64pad:()=>Za,base64url:()=>$a,base64urlpad:()=>Wa});var Ga=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Za=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$a=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wa=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var un={};ut(un,{base8:()=>Ya});var Ya=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ln={};ut(ln,{identity:()=>Xa});var Xa=ce({prefix:"\0",name:"identity",encode:r=>Do(r),decode:r=>Co(r)});var ml=new TextEncoder,yl=new TextDecoder;var pn={};ut(pn,{sha256:()=>Re,sha512:()=>tc});function dn({name:r,code:t,encode:e}){return new hn(r,t,e)}var hn=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?Ft(this.code,e):e.then(n=>Ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Wo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=dn({name:"sha2-256",code:18,encode:Wo("SHA-256")}),tc=dn({name:"sha2-512",code:19,encode:Wo("SHA-512")});var Ke={...ln,...an,...un,...on,...sn,...Jr,...tn,...Qr,...fn,...cn},_l={...pn,...nn};function Xo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Yo=Xo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),mn=Xo("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=ct(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ec={utf8:Yo,"utf-8":Yo,hex:Ke.base16,latin1:mn,ascii:mn,binary:mn,...Ke},ar=ec;function bt(r,t="utf8"){let e=ar[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function H(r,t="utf8"){let e=ar[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var rc=parseInt("11111",2),yn=parseInt("10000000",2),nc=parseInt("01111111",2),Qo={0:ke,1:ke,2:oc,3:ac,4:cc,5:ic,6:sc,16:ke,22:ke,48:ke};function bn(r,t={offset:0}){let e=r[t.offset]&rc;if(t.offset++,Qo[e]!=null)return Qo[e](r,t);throw new Error("No decoder for tag "+e)}function Oe(r,t){let e=0;if((r[t.offset]&yn)===yn){let n=r[t.offset]&nc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function ke(r,t){Oe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=bn(r,t);if(n===null)break;e.push(n)}return e}function oc(r,t){let e=Oe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function sc(r,t){let e=Oe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let h=r[t.offset];if(t.offset++,c.push(h&127),h<128){c.reverse();let f=0;for(let u=0;u<c.length;u++)f+=c[u]<<u*7;a+=`.${f}`,c=[]}}return a}function ic(r,t){return t.offset++,null}function ac(r,t){let e=Oe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function cc(r,t){let e=Oe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function fc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new dt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function xn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=fc(r.byteLength);return new dt(Uint8Array.from([t.byteLength|yn]),t)}function Jo(r){let t=new dt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new dt(Uint8Array.from([2]),xn(t),t)}function ts(r){let t=Uint8Array.from([0]),e=new dt(t,r);return new dt(Uint8Array.from([3]),xn(e),e)}function cr(r,t=48){let e=new dt;for(let n of r)e.append(n);return new dt(Uint8Array.from([t]),xn(e),e)}async function es(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var uc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),lc=Uint8Array.from([6,5,43,129,4,0,34]),hc=Uint8Array.from([6,5,43,129,4,0,35]),dc={ext:!0,kty:"EC",crv:"P-256"},pc={ext:!0,kty:"EC",crv:"P-384"},mc={ext:!0,kty:"EC",crv:"P-521"},gn=32,wn=48,En=66;function rs(r){let t=bn(r);return ns(t)}function ns(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===gn*2+1)return n=H(t.subarray(e,e+gn),"base64url"),o=H(t.subarray(e+gn),"base64url"),new he({...dc,key_ops:["verify"],x:n,y:o});if(t.byteLength===wn*2+1)return n=H(t.subarray(e,e+wn),"base64url"),o=H(t.subarray(e+wn),"base64url"),new he({...pc,key_ops:["verify"],x:n,y:o});if(t.byteLength===En*2+1)return n=H(t.subarray(e,e+En),"base64url"),o=H(t.subarray(e+En),"base64url"),new he({...mc,key_ops:["verify"],x:n,y:o});throw new St(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function os(r){return cr([Jo(Uint8Array.from([1])),cr([yc(r.crv)],160),cr([ts(new dt(Uint8Array.from([4]),bt(r.x??"","base64url"),bt(r.y??"","base64url")))],161)]).subarray()}function yc(r){if(r==="P-256")return uc;if(r==="P-384")return lc;if(r==="P-521")return hc;throw new St(`Invalid curve ${r}`)}var he=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=os(this.jwk)),this._raw}toMultihash(){return xt.digest(de(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}async verify(t,e,n){return es(this.jwk,e,t,n)}};var Zt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function me(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Me(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function rt(r,...t){if(!me(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function is(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Me(r.outputLen),Me(r.blockLen)}function ye(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 as(r,t){rt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Pt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function fr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function gt(r,t){return r<<32-t|r>>>t}var cs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",bc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function vt(r){if(rt(r),cs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=bc[r[e]];return t}var Lt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ss(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt.A&&r<=Lt.F)return r-(Lt.A-10);if(r>=Lt.a&&r<=Lt.f)return r-(Lt.a-10)}function be(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(cs)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("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=ss(r.charCodeAt(s)),a=ss(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function fs(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function He(r){return typeof r=="string"&&(r=fs(r)),rt(r),r}function pt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];rt(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 pe=class{};function Sn(r){let t=n=>r().update(He(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function qe(r=32){if(Zt&&typeof Zt.getRandomValues=="function")return Zt.getRandomValues(new Uint8Array(r));if(Zt&&typeof Zt.randomBytes=="function")return Uint8Array.from(Zt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function xc(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),a=Number(e&s),c=n?4:0,h=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+h,a,n)}function us(r,t,e){return r&t^~r&e}function ls(r,t,e){return r&t^r&e^t&e}var Ve=class extends pe{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=fr(this.buffer)}update(t){ye(this),t=He(t),rt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=fr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ye(this),as(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Pt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)e[u]=0;xc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=fr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=c/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)a.setUint32(4*u,f[u],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:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ct=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ur=BigInt(4294967295),hs=BigInt(32);function gc(r,t=!1){return t?{h:Number(r&ur),l:Number(r>>hs&ur)}:{h:Number(r>>hs&ur)|0,l:Number(r&ur)|0}}function ds(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=gc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var vn=(r,t,e)=>r>>>e,An=(r,t,e)=>r<<32-e|t>>>e,$t=(r,t,e)=>r>>>e|t<<32-e,Wt=(r,t,e)=>r<<32-e|t>>>e,ze=(r,t,e)=>r<<64-e|t>>>e-32,Fe=(r,t,e)=>r>>>e-32|t<<64-e;function At(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ps=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),ms=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ys=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),bs=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,xs=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),gs=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Ec=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Rt=new Uint32Array(64),Bn=class extends Ve{constructor(t=32){super(64,t,8,!1),this.A=Ct[0]|0,this.B=Ct[1]|0,this.C=Ct[2]|0,this.D=Ct[3]|0,this.E=Ct[4]|0,this.F=Ct[5]|0,this.G=Ct[6]|0,this.H=Ct[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){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=a|0,this.H=c|0}process(t,e){for(let u=0;u<16;u++,e+=4)Rt[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let x=Rt[u-15],d=Rt[u-2],E=gt(x,7)^gt(x,18)^x>>>3,S=gt(d,17)^gt(d,19)^d>>>10;Rt[u]=S+Rt[u-7]+E+Rt[u-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:h,H:f}=this;for(let u=0;u<64;u++){let x=gt(a,6)^gt(a,11)^gt(a,25),d=f+x+us(a,c,h)+Ec[u]+Rt[u]|0,S=(gt(n,2)^gt(n,13)^gt(n,22))+ls(n,o,s)|0;f=h,h=c,c=a,a=i+d|0,i=s,s=o,o=n,n=d+S|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,h,f)}roundClean(){Pt(Rt)}destroy(){this.set(0,0,0,0,0,0,0,0),Pt(this.buffer)}};var ws=ds(["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))),Sc=ws[0],vc=ws[1],Kt=new Uint32Array(80),kt=new Uint32Array(80),In=class extends Ve{constructor(t=64){super(128,t,16,!1),this.Ah=tt[0]|0,this.Al=tt[1]|0,this.Bh=tt[2]|0,this.Bl=tt[3]|0,this.Ch=tt[4]|0,this.Cl=tt[5]|0,this.Dh=tt[6]|0,this.Dl=tt[7]|0,this.Eh=tt[8]|0,this.El=tt[9]|0,this.Fh=tt[10]|0,this.Fl=tt[11]|0,this.Gh=tt[12]|0,this.Gl=tt[13]|0,this.Hh=tt[14]|0,this.Hl=tt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:h,El:f,Fh:u,Fl:x,Gh:d,Gl:E,Hh:S,Hl:y}=this;return[t,e,n,o,s,i,a,c,h,f,u,x,d,E,S,y]}set(t,e,n,o,s,i,a,c,h,f,u,x,d,E,S,y){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=a|0,this.Dl=c|0,this.Eh=h|0,this.El=f|0,this.Fh=u|0,this.Fl=x|0,this.Gh=d|0,this.Gl=E|0,this.Hh=S|0,this.Hl=y|0}process(t,e){for(let I=0;I<16;I++,e+=4)Kt[I]=t.getUint32(e),kt[I]=t.getUint32(e+=4);for(let I=16;I<80;I++){let N=Kt[I-15]|0,m=kt[I-15]|0,D=$t(N,m,1)^$t(N,m,8)^vn(N,m,7),C=Wt(N,m,1)^Wt(N,m,8)^An(N,m,7),T=Kt[I-2]|0,l=kt[I-2]|0,g=$t(T,l,19)^ze(T,l,61)^vn(T,l,6),p=Wt(T,l,19)^Fe(T,l,61)^An(T,l,6),b=ys(C,p,kt[I-7],kt[I-16]),w=bs(b,D,g,Kt[I-7],Kt[I-16]);Kt[I]=w|0,kt[I]=b|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:h,Dl:f,Eh:u,El:x,Fh:d,Fl:E,Gh:S,Gl:y,Hh:v,Hl:P}=this;for(let I=0;I<80;I++){let N=$t(u,x,14)^$t(u,x,18)^ze(u,x,41),m=Wt(u,x,14)^Wt(u,x,18)^Fe(u,x,41),D=u&d^~u&S,C=x&E^~x&y,T=xs(P,m,C,vc[I],kt[I]),l=gs(T,v,N,D,Sc[I],Kt[I]),g=T|0,p=$t(n,o,28)^ze(n,o,34)^ze(n,o,39),b=Wt(n,o,28)^Fe(n,o,34)^Fe(n,o,39),w=n&s^n&a^s&a,_=o&i^o&c^i&c;v=S|0,P=y|0,S=d|0,y=E|0,d=u|0,E=x|0,{h:u,l:x}=At(h|0,f|0,l|0,g|0),h=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let B=ps(g,b,_);n=ms(B,l,p,w),o=B|0}({h:n,l:o}=At(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=At(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=At(this.Ch|0,this.Cl|0,a|0,c|0),{h,l:f}=At(this.Dh|0,this.Dl|0,h|0,f|0),{h:u,l:x}=At(this.Eh|0,this.El|0,u|0,x|0),{h:d,l:E}=At(this.Fh|0,this.Fl|0,d|0,E|0),{h:S,l:y}=At(this.Gh|0,this.Gl|0,S|0,y|0),{h:v,l:P}=At(this.Hh|0,this.Hl|0,v|0,P|0),this.set(n,o,s,i,a,c,h,f,u,x,d,E,S,y,v,P)}roundClean(){Pt(Kt,kt)}destroy(){Pt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Es=Sn(()=>new Bn);var Ss=Sn(()=>new In);var Ln=BigInt(0),_n=BigInt(1);function Dt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function je(r){let t=r.toString(16);return t.length&1?"0"+t:t}function vs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Ln:BigInt("0x"+r)}function xe(r){return vs(vt(r))}function Yt(r){return rt(r),vs(vt(Uint8Array.from(r).reverse()))}function lr(r,t){return be(r.toString(16).padStart(t*2,"0"))}function ge(r,t){return lr(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=be(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(me(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+" of length "+e+" expected, got "+o);return n}var Tn=r=>typeof r=="bigint"&&Ln<=r;function As(r,t,e){return Tn(r)&&Tn(t)&&Tn(e)&&t<=r&&r<e}function Ot(r,t,e,n){if(!As(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Bs(r){let t;for(t=0;r>Ln;r>>=_n,t+=1);return t}var Xt=r=>(_n<<BigInt(r))-_n;function Is(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=d=>new Uint8Array(d),o=d=>Uint8Array.of(d),s=n(r),i=n(r),a=0,c=()=>{s.fill(1),i.fill(0),a=0},h=(...d)=>e(i,s,...d),f=(d=n(0))=>{i=h(o(0),d),s=h(),d.length!==0&&(i=h(o(1),d),s=h())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,E=[];for(;d<t;){s=h();let S=s.slice();E.push(S),d+=s.length}return pt(...E)};return(d,E)=>{c(),f(d);let S;for(;!(S=E(u()));)f();return c(),S}}function Mt(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(o,s,i){let a=r[o];if(i&&a===void 0)return;let c=typeof a;if(c!==s||a===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${c}`)}Object.entries(t).forEach(([o,s])=>n(o,s,!1)),Object.entries(e).forEach(([o,s])=>n(o,s,!0))}function we(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 it=BigInt(0),J=BigInt(1),Qt=BigInt(2),Ac=BigInt(3),Ls=BigInt(4),Ps=BigInt(5),Cs=BigInt(8);function G(r,t){let e=r%t;return e>=it?e:t+e}function j(r,t,e){let n=r;for(;t-- >it;)n*=n,n%=e;return n}function Ts(r,t){if(r===it)throw new Error("invert: expected non-zero number");if(t<=it)throw new Error("invert: expected positive modulus, got "+t);let e=G(r,t),n=t,o=it,s=J,i=J,a=it;for(;e!==it;){let h=n/e,f=n%e,u=o-i*h,x=s-a*h;n=e,e=f,o=i,s=a,i=u,a=x}if(n!==J)throw new Error("invert: does not exist");return G(o,t)}function Ds(r,t){let e=(r.ORDER+J)/Ls,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function Bc(r,t){let e=(r.ORDER-Ps)/Cs,n=r.mul(t,Qt),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,Qt),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function Ic(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-J,e=0;for(;t%Qt===it;)t/=Qt,e++;let n=Qt,o=wt(r);for(;_s(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Ds;let s=o.pow(n,t),i=(t+J)/Qt;return function(c,h){if(c.is0(h))return h;if(_s(c,h)!==1)throw new Error("Cannot find square root");let f=e,u=c.mul(c.ONE,s),x=c.pow(h,t),d=c.pow(h,i);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let E=1,S=c.sqr(x);for(;!c.eql(S,c.ONE);)if(E++,S=c.sqr(S),E===f)throw new Error("Cannot find square root");let y=J<<BigInt(f-E-1),v=c.pow(u,y);f=E,u=c.sqr(v),x=c.mul(x,u),d=c.mul(d,v)}return d}}function Tc(r){return r%Ls===Ac?Ds:r%Cs===Ps?Bc:Ic(r)}var Us=(r,t)=>(G(r,t)&J)===J,_c=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=_c.reduce((n,o)=>(n[o]="function",n),t);return Mt(r,e),r}function Lc(r,t,e){if(e<it)throw new Error("invalid exponent, negatives unsupported");if(e===it)return r.ONE;if(e===J)return t;let n=r.ONE,o=t;for(;e>it;)e&J&&(n=r.mul(n,o)),o=r.sqr(o),e>>=J;return n}function Ge(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function _s(r,t){let e=(r.ORDER-J)/Qt,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Ns(r,t){t!==void 0&&Me(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function wt(r,t,e=!1,n={}){if(r<=it)throw new Error("invalid field: expected ORDER > 0, got "+r);let o,s;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(e=f.isLE)}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:i,nByteLength:a}=Ns(r,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,h=Object.freeze({ORDER:r,isLE:e,BITS:i,BYTES:a,MASK:Xt(i),ZERO:it,ONE:J,create:f=>G(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return it<=f&&f<r},is0:f=>f===it,isValidNot0:f=>!h.is0(f)&&h.isValid(f),isOdd:f=>(f&J)===J,neg:f=>G(-f,r),eql:(f,u)=>f===u,sqr:f=>G(f*f,r),add:(f,u)=>G(f+u,r),sub:(f,u)=>G(f-u,r),mul:(f,u)=>G(f*u,r),pow:(f,u)=>Lc(h,f,u),div:(f,u)=>G(f*Ts(u,r),r),sqrN:f=>f*f,addN:(f,u)=>f+u,subN:(f,u)=>f-u,mulN:(f,u)=>f*u,inv:f=>Ts(f,r),sqrt:s||(f=>(c||(c=Tc(r)),c(h,f))),toBytes:f=>e?ge(f,a):lr(f,a),fromBytes:f=>{if(f.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);return e?Yt(f):xe(f)},invertBatch:f=>Ge(h,f),cmov:(f,u,x)=>x?u:f});return Object.freeze(h)}function Rs(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 Cn(r){let t=Rs(r);return t+Math.ceil(t/2)}function Ks(r,t,e=!1){let n=r.length,o=Rs(t),s=Cn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Yt(r):xe(r),a=G(i,t-J)+J;return e?ge(a,o):lr(a,o)}var Se=BigInt(0),Jt=BigInt(1);function Ee(r,t){let e=t.negate();return r?e:t}function hr(r,t,e){let n=t==="pz"?i=>i.pz:i=>i.ez,o=Ge(r.Fp,e.map(n));return e.map((i,a)=>i.toAffine(o[a])).map(r.fromAffine)}function Hs(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Dn(r,t){Hs(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Xt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ks(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Jt);let h=t*n,f=h+Math.abs(a)-1,u=a===0,x=a<0,d=t%2!==0;return{nextN:c,offset:f,isZero:u,isNeg:x,isNegF:d,offsetF:h}}function Pc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Cc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Un=new WeakMap,qs=new WeakMap;function Nn(r){return qs.get(r)||1}function Os(r){if(r!==Se)throw new Error("invalid wNAF")}function dr(r,t){return{constTimeNegate:Ee,hasPrecomputes(e){return Nn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Se;)n&Jt&&(o=o.add(s)),s=s.double(),n>>=Jt;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Dn(n,t),i=[],a=e,c=a;for(let h=0;h<o;h++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Dn(e,t);for(let c=0;c<a.windows;c++){let{nextN:h,offset:f,isZero:u,isNeg:x,isNegF:d,offsetF:E}=ks(o,c,a);o=h,u?i=i.add(Ee(d,n[E])):s=s.add(Ee(x,n[f]))}return Os(o),{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Dn(e,t);for(let a=0;a<i.windows&&o!==Se;a++){let{nextN:c,offset:h,isZero:f,isNeg:u}=ks(o,a,i);if(o=c,!f){let x=n[h];s=s.add(u?x.negate():x)}}return Os(o),s},getPrecomputes(e,n,o){let s=Un.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&(typeof o=="function"&&(s=o(s)),Un.set(n,s))),s},wNAFCached(e,n,o){let s=Nn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Nn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Hs(n,t),qs.set(e,n),Un.delete(e)}}}function Vs(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>Se||n>Se;)e&Jt&&(s=s.add(o)),n&Jt&&(i=i.add(o)),o=o.double(),e>>=Jt,n>>=Jt;return{p1:s,p2:i}}function pr(r,t,e,n){Pc(e,r),Cc(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=Bs(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let h=Xt(c),f=new Array(Number(h)+1).fill(i),u=Math.floor((t.BITS-1)/c)*c,x=i;for(let d=u;d>=0;d-=c){f.fill(i);for(let S=0;S<s;S++){let y=n[S],v=Number(y>>BigInt(d)&h);f[v]=f[v].add(e[S])}let E=i;for(let S=f.length-1,y=i;S>0;S--)y=y.add(f[S]),E=E.add(y);if(x=x.add(E),d!==0)for(let S=0;S<c;S++)x=x.double()}return x}function Ms(r,t){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Pn(t),t}else return wt(r)}function mr(r,t,e={}){if(!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>Se))throw new Error(`CURVE.${a} must be positive bigint`)}let n=Ms(t.p,e.Fp),o=Ms(t.n,e.Fn),i=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let a of i)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var Bt=BigInt(0),at=BigInt(1),Rn=BigInt(2),Dc=BigInt(8),Uc={zip215:!0};function Nc(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),a=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,a)}function Rc(r,t={}){let{Fp:e,Fn:n}=mr("edwards",r,t),{h:o,n:s}=r;Mt(t,{},{uvRatio:"function"});let i=Rn<<BigInt(n.BYTES*8)-at,a=S=>e.create(S),c=t.uvRatio||((S,y)=>{try{return{isValid:!0,value:e.sqrt(e.div(S,y))}}catch{return{isValid:!1,value:Bt}}});if(!Nc(e,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function h(S,y,v=!1){let P=v?at:Bt;return Ot("coordinate "+S,y,P,i),y}function f(S){if(!(S instanceof d))throw new Error("ExtendedPoint expected")}let u=we((S,y)=>{let{ex:v,ey:P,ez:I}=S,N=S.is0();y==null&&(y=N?Dc:e.inv(I));let m=a(v*y),D=a(P*y),C=a(I*y);if(N)return{x:Bt,y:at};if(C!==at)throw new Error("invZ was invalid");return{x:m,y:D}}),x=we(S=>{let{a:y,d:v}=r;if(S.is0())throw new Error("bad point: ZERO");let{ex:P,ey:I,ez:N,et:m}=S,D=a(P*P),C=a(I*I),T=a(N*N),l=a(T*T),g=a(D*y),p=a(T*a(g+C)),b=a(l+a(v*a(D*C)));if(p!==b)throw new Error("bad point: equation left != right (1)");let w=a(P*I),_=a(N*m);if(w!==_)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(y,v,P,I){this.ex=h("x",y),this.ey=h("y",v),this.ez=h("z",P,!0),this.et=h("t",I),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(y){if(y instanceof d)throw new Error("extended point not allowed");let{x:v,y:P}=y||{};return h("x",v),h("y",P),new d(v,P,at,a(v*P))}static normalizeZ(y){return hr(d,"ez",y)}static msm(y,v){return pr(d,n,y,v)}_setWindowSize(y){this.precompute(y)}precompute(y=8,v=!0){return E.setWindowSize(this,y),v||this.multiply(Rn),this}assertValidity(){x(this)}equals(y){f(y);let{ex:v,ey:P,ez:I}=this,{ex:N,ey:m,ez:D}=y,C=a(v*D),T=a(N*I),l=a(P*D),g=a(m*I);return C===T&&l===g}is0(){return this.equals(d.ZERO)}negate(){return new d(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:y}=r,{ex:v,ey:P,ez:I}=this,N=a(v*v),m=a(P*P),D=a(Rn*a(I*I)),C=a(y*N),T=v+P,l=a(a(T*T)-N-m),g=C+m,p=g-D,b=C-m,w=a(l*p),_=a(g*b),B=a(l*b),L=a(p*g);return new d(w,_,L,B)}add(y){f(y);let{a:v,d:P}=r,{ex:I,ey:N,ez:m,et:D}=this,{ex:C,ey:T,ez:l,et:g}=y,p=a(I*C),b=a(N*T),w=a(D*P*g),_=a(m*l),B=a((I+N)*(C+T)-p-b),L=_-w,K=_+w,R=a(b-v*p),$=a(B*L),M=a(K*R),k=a(B*R),Y=a(L*K);return new d($,M,Y,k)}subtract(y){return this.add(y.negate())}multiply(y){let v=y;Ot("scalar",v,at,s);let{p:P,f:I}=E.wNAFCached(this,v,d.normalizeZ);return d.normalizeZ([P,I])[0]}multiplyUnsafe(y,v=d.ZERO){let P=y;return Ot("scalar",P,Bt,s),P===Bt?d.ZERO:this.is0()||P===at?this:E.wNAFCachedUnsafe(this,P,d.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return E.wNAFCachedUnsafe(this,s).is0()}toAffine(y){return u(this,y)}clearCofactor(){return o===at?this:this.multiplyUnsafe(o)}static fromBytes(y,v=!1){return rt(y),this.fromHex(y,v)}static fromHex(y,v=!1){let{d:P,a:I}=r,N=e.BYTES;y=F("pointHex",y,N),Dt("zip215",v);let m=y.slice(),D=y[N-1];m[N-1]=D&-129;let C=Yt(m),T=v?i:e.ORDER;Ot("pointHex.y",C,Bt,T);let l=a(C*C),g=a(l-at),p=a(P*l-I),{isValid:b,value:w}=c(g,p);if(!b)throw new Error("Point.fromHex: invalid y coordinate");let _=(w&at)===at,B=(D&128)!==0;if(!v&&w===Bt&&B)throw new Error("Point.fromHex: x=0 and x_0=1");return B!==_&&(w=a(-w)),d.fromAffine({x:w,y:C})}static fromPrivateScalar(y){return d.BASE.multiply(y)}toBytes(){let{x:y,y:v}=this.toAffine(),P=ge(v,e.BYTES);return P[P.length-1]|=y&at?128:0,P}toRawBytes(){return this.toBytes()}toHex(){return vt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}d.BASE=new d(r.Gx,r.Gy,at,a(r.Gx*r.Gy)),d.ZERO=new d(Bt,at,at,Bt),d.Fp=e,d.Fn=n;let E=dr(d,n.BYTES*8);return d}function Kc(r,t){Mt(t,{hash:"function"},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:e,hash:n}=t,{BASE:o,Fp:s,Fn:i}=r,a=i.ORDER,c=t.randomBytes||qe,h=t.adjustScalarBytes||(m=>m),f=t.domain||((m,D,C)=>{if(Dt("phflag",C),D.length||C)throw new Error("Contexts/pre-hash are not supported");return m});function u(m){return i.create(m)}function x(m){return u(Yt(m))}function d(m){let D=s.BYTES;m=F("private key",m,D);let C=F("hashed private key",n(m),2*D),T=h(C.slice(0,D)),l=C.slice(D,2*D),g=x(T);return{head:T,prefix:l,scalar:g}}function E(m){let{head:D,prefix:C,scalar:T}=d(m),l=o.multiply(T),g=l.toBytes();return{head:D,prefix:C,scalar:T,point:l,pointBytes:g}}function S(m){return E(m).pointBytes}function y(m=Uint8Array.of(),...D){let C=pt(...D);return x(n(f(C,F("context",m),!!e)))}function v(m,D,C={}){m=F("message",m),e&&(m=e(m));let{prefix:T,scalar:l,pointBytes:g}=E(D),p=y(C.context,T,m),b=o.multiply(p).toBytes(),w=y(C.context,b,g,m),_=u(p+w*l);Ot("signature.s",_,Bt,a);let B=s.BYTES,L=pt(b,ge(_,B));return F("result",L,B*2)}let P=Uc;function I(m,D,C,T=P){let{context:l,zip215:g}=T,p=s.BYTES;m=F("signature",m,2*p),D=F("message",D),C=F("publicKey",C,p),g!==void 0&&Dt("zip215",g),e&&(D=e(D));let b=Yt(m.slice(p,2*p)),w,_,B;try{w=r.fromHex(C,g),_=r.fromHex(m.slice(0,p),g),B=o.multiplyUnsafe(b)}catch{return!1}if(!g&&w.isSmallOrder())return!1;let L=y(l,_.toBytes(),w.toBytes(),D);return _.add(w.multiplyUnsafe(L)).subtract(B).clearCofactor().is0()}return o.precompute(8),{getPublicKey:S,sign:v,verify:I,utils:{getExtendedPublicKey:E,randomPrivateKey:()=>c(s.BYTES),precompute(m=8,D=r.BASE){return D.precompute(m,!1)}},Point:r}}function kc(r){let t={a:r.a,d:r.d,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wt(t.n,r.nBitLength,!0),o={Fp:e,Fn:n,uvRatio:r.uvRatio},s={hash:r.hash,randomBytes:r.randomBytes,adjustScalarBytes:r.adjustScalarBytes,domain:r.domain,prehash:r.prehash,mapToCurve:r.mapToCurve};return{CURVE:t,curveOpts:o,eddsaOpts:s}}function Oc(r,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:r})}function zs(r){let{CURVE:t,curveOpts:e,eddsaOpts:n}=kc(r),o=Rc(t,e),s=Kc(o,n);return Oc(r,s)}var Uh=BigInt(0),Mc=BigInt(1),Fs=BigInt(2),Nh=BigInt(3),Hc=BigInt(5),qc=BigInt(8),yr={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:qc,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Vc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=yr.p,a=r*r%s*r%s,c=j(a,Fs,s)*a%s,h=j(c,Mc,s)*r%s,f=j(h,Hc,s)*h%s,u=j(f,t,s)*f%s,x=j(u,e,s)*u%s,d=j(x,n,s)*x%s,E=j(d,o,s)*d%s,S=j(E,o,s)*d%s,y=j(S,t,s)*f%s;return{pow_p_5_8:j(y,Fs,s)*r%s,b2:a}}function zc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var js=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Fc(r,t){let e=yr.p,n=G(t*t*t,e),o=G(n*n*t,e),s=Vc(r*o).pow_p_5_8,i=G(r*n*s,e),a=G(t*i*i,e),c=i,h=G(i*js,e),f=a===r,u=a===G(-r,e),x=a===G(-r*js,e);return f&&(i=c),(u||x)&&(i=h),Us(i,e)&&(i=G(-i,e)),{isValid:f||u,value:i}}var jc=wt(yr.p,void 0,!0),Gc={...yr,Fp:jc,hash:Ss,adjustScalarBytes:zc,uvRatio:Fc},Gs=zs(Gc);var Ze=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},br=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Zs={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new br("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var xr=Zs;var gr=32;var Kn,Zc=(async()=>{try{return await xr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function $c(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await xr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await xr.get().subtle.verify({name:"Ed25519"},n,t,e instanceof Uint8Array?e:e.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Wc(r,t,e){return Gs.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function $s(r,t,e){return Kn==null&&(Kn=await Zc),Kn?$c(r,t,e):Wc(r,t,e)}function wr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Er=class{type="Ed25519";raw;constructor(t){this.raw=kn(t,gr)}toMultihash(){return xt.digest(de(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=$s(this.raw,e,t);return wr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Ys(r){return r=kn(r,gr),new Er(r)}function kn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new St(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Xc=Math.pow(2,7),Qc=Math.pow(2,14),Jc=Math.pow(2,21),On=Math.pow(2,28),Mn=Math.pow(2,35),Hn=Math.pow(2,42),qn=Math.pow(2,49),O=128,nt=127;function ft(r){if(r<Xc)return 1;if(r<Qc)return 2;if(r<Jc)return 3;if(r<On)return 4;if(r<Mn)return 5;if(r<Hn)return 6;if(r<qn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Vn(r,t,e=0){switch(ft(r)){case 8:t[e++]=r&255|O,r/=128;case 7:t[e++]=r&255|O,r/=128;case 6:t[e++]=r&255|O,r/=128;case 5:t[e++]=r&255|O,r/=128;case 4:t[e++]=r&255|O,r>>>=7;case 3:t[e++]=r&255|O,r>>>=7;case 2:t[e++]=r&255|O,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function tf(r,t,e=0){switch(ft(r)){case 8:t.set(e++,r&255|O),r/=128;case 7:t.set(e++,r&255|O),r/=128;case 6:t.set(e++,r&255|O),r/=128;case 5:t.set(e++,r&255|O),r/=128;case 4:t.set(e++,r&255|O),r>>>=7;case 3:t.set(e++,r&255|O),r>>>=7;case 2:t.set(e++,r&255|O),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function zn(r,t){let e=r[t],n=0;if(n+=e&nt,e<O||(e=r[t+1],n+=(e&nt)<<7,e<O)||(e=r[t+2],n+=(e&nt)<<14,e<O)||(e=r[t+3],n+=(e&nt)<<21,e<O)||(e=r[t+4],n+=(e&nt)*On,e<O)||(e=r[t+5],n+=(e&nt)*Mn,e<O)||(e=r[t+6],n+=(e&nt)*Hn,e<O)||(e=r[t+7],n+=(e&nt)*qn,e<O))return n;throw new RangeError("Could not decode varint")}function ef(r,t){let e=r.get(t),n=0;if(n+=e&nt,e<O||(e=r.get(t+1),n+=(e&nt)<<7,e<O)||(e=r.get(t+2),n+=(e&nt)<<14,e<O)||(e=r.get(t+3),n+=(e&nt)<<21,e<O)||(e=r.get(t+4),n+=(e&nt)*On,e<O)||(e=r.get(t+5),n+=(e&nt)*Mn,e<O)||(e=r.get(t+6),n+=(e&nt)*Hn,e<O)||(e=r.get(t+7),n+=(e&nt)*qn,e<O))return n;throw new RangeError("Could not decode varint")}function ve(r,t,e=0){return t==null&&(t=ct(ft(r))),t instanceof Uint8Array?Vn(r,t,e):tf(r,t,e)}function te(r,t=0){return r instanceof Uint8Array?zn(r,t):ef(r,t)}var Fn=new Float32Array([-0]),Ht=new Uint8Array(Fn.buffer);function Qs(r,t,e){Fn[0]=r,t[e]=Ht[0],t[e+1]=Ht[1],t[e+2]=Ht[2],t[e+3]=Ht[3]}function Js(r,t){return Ht[0]=r[t],Ht[1]=r[t+1],Ht[2]=r[t+2],Ht[3]=r[t+3],Fn[0]}var jn=new Float64Array([-0]),ot=new Uint8Array(jn.buffer);function ti(r,t,e){jn[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3],t[e+4]=ot[4],t[e+5]=ot[5],t[e+6]=ot[6],t[e+7]=ot[7]}function ei(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],ot[4]=r[t+4],ot[5]=r[t+5],ot[6]=r[t+6],ot[7]=r[t+7],jn[0]}var rf=BigInt(Number.MAX_SAFE_INTEGER),nf=BigInt(Number.MIN_SAFE_INTEGER),mt=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 ee;if(t<rf&&t>nf)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>ri&&(o=0n,++n>ri&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ee;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):ee}},ee=new mt(0,0);ee.toBigInt=function(){return 0n};ee.zzEncode=ee.zzDecode=function(){return this};ee.length=function(){return 1};var ri=4294967296n;function ni(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 oi(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&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 Gn(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 Et(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Sr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Zn=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,Et(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 Et(this,4);return Sr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Et(this,4);return Sr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Et(this,4);let t=Js(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Et(this,4);let t=ei(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 Et(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return oi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Et(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Et(this);while((this.buf[this.pos++]&128)!==0);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 mt(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 Et(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 Et(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 Et(this,8);let t=Sr(this.buf,this.pos+=4),e=Sr(this.buf,this.pos+=4);return new mt(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=zn(this.buf,this.pos);return this.pos+=ft(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 $n(r){return new Zn(r instanceof Uint8Array?r:r.subarray())}function vr(r,t,e){let n=$n(r);return t.decode(n,void 0,e)}function Wn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ct(i);o+i>t&&(n=ct(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var re=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Yn(){}var Qn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},of=Wn();function sf(r){return globalThis.Buffer!=null?ct(r):of(r)}var We=class{len;head;tail;states;constructor(){this.len=0,this.head=new re(Yn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new re(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Jn((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(Ar,10,mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=mt.fromBigInt(t);return this._push(Ar,e.length(),e)}uint64Number(t){return this._push(Vn,ft(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=mt.fromBigInt(t).zzEncode();return this._push(Ar,e.length(),e)}sint64Number(t){let e=mt.fromNumber(t).zzEncode();return this._push(Ar,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Xn,1,t?1:0)}fixed32(t){return this._push($e,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=mt.fromBigInt(t);return this._push($e,4,e.lo)._push($e,4,e.hi)}fixed64Number(t){let e=mt.fromNumber(t);return this._push($e,4,e.lo)._push($e,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(Qs,4,t)}double(t){return this._push(ti,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Xn,1,0):this.uint32(e)._push(cf,e,t)}string(t){let e=ni(t);return e!==0?this.uint32(e)._push(Gn,e,t):this._push(Xn,1,0)}fork(){return this.states=new Qn(this),this.head=this.tail=new re(Yn,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 re(Yn,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=sf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Xn(r,t,e){t[e]=r&255}function af(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Jn=class extends re{next;constructor(t,e){super(af,t,e),this.next=void 0}};function Ar(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 $e(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 cf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(We.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ff,t,r),this},We.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(uf,t,r),this});function ff(r,t,e){t.set(r,e)}function uf(r,t,e){r.length<40?Gn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(bt(r),e)}function to(){return new We}function Br(r,t){let e=to();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ae;(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"})(Ae||(Ae={}));function Ir(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function eo(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Ir("enum",Ae.VARINT,e,n)}function Tr(r,t){return Ir("message",Ae.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(yt||(yt={}));var ro;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(ro||(ro={}));(function(r){r.codec=()=>eo(ro)})(yt||(yt={}));var Ye;(function(r){let t;r.codec=()=>(t==null&&(t=Tr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.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 a=e.uint32();switch(a>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>Br(e,r.codec()),r.decode=(e,n)=>vr(e,r.codec(),n)})(Ye||(Ye={}));var no;(function(r){let t;r.codec=()=>(t==null&&(t=Tr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.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 a=e.uint32();switch(a>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>Br(e,r.codec()),r.decode=(e,n)=>vr(e,r.codec(),n)})(no||(no={}));var _r=class extends pe{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,is(t);let n=He(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),Pt(s)}update(t){return ye(this),this.iHash.update(t),this}digestInto(t){ye(this),rt(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:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},oo=(r,t,e)=>new _r(r,t).update(e).digest();oo.create=(r,t)=>new _r(r,t);function ii(r){r.lowS!==void 0&&Dt("lowS",r.lowS),r.prehash!==void 0&&Dt("prehash",r.prehash)}var so=class extends Error{constructor(t=""){super(t)}},Ut={Err:so,_tlv:{encode:(r,t)=>{let{Err:e}=Ut;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=je(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?je(o.length/2|128):"";return je(r)+s+o+t},decode(r,t){let{Err:e}=Ut,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 c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+c);if(h.length!==c)throw new e("tlv.decode: length bytes not complete");if(h[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of h)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Ut;if(r<Xe)throw new t("integer: negative integers are not allowed");let e=je(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ut;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 xe(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ut,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:h,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(h)}},hexFromSig(r){let{_tlv:t,_int:e}=Ut,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Xe=BigInt(0),Qe=BigInt(1),hf=BigInt(2),Lr=BigInt(3),df=BigInt(4);function pf(r,t,e){function n(o){let s=r.sqr(o),i=r.mul(s,o);return r.add(r.add(i,r.mul(o,t)),e)}return n}function ai(r,t,e){let{BYTES:n}=r;function o(s){let i;if(typeof s=="bigint")i=s;else{let a=F("private key",s);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");let c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{i=r.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof s}`)}}if(e&&(i=r.create(i)),!r.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}return o}function mf(r,t={}){let{Fp:e,Fn:n}=mr("weierstrass",r,t),{h:o,n:s}=r;Mt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:i}=t;if(i&&(!e.is0(r.a)||typeof i.beta!="bigint"||typeof i.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!e.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(T,l,g){let{x:p,y:b}=l.toAffine(),w=e.toBytes(p);if(Dt("isCompressed",g),g){a();let _=!e.isOdd(b);return pt(ci(_),w)}else return pt(Uint8Array.of(4),w,e.toBytes(b))}function h(T){rt(T);let l=e.BYTES,g=l+1,p=2*l+1,b=T.length,w=T[0],_=T.subarray(1);if(b===g&&(w===2||w===3)){let B=e.fromBytes(_);if(!e.isValid(B))throw new Error("bad point: is not on curve, wrong x");let L=x(B),K;try{K=e.sqrt(L)}catch(M){let k=M instanceof Error?": "+M.message:"";throw new Error("bad point: is not on curve, sqrt error"+k)}a();let R=e.isOdd(K);return(w&1)===1!==R&&(K=e.neg(K)),{x:B,y:K}}else if(b===p&&w===4){let B=e.fromBytes(_.subarray(l*0,l*1)),L=e.fromBytes(_.subarray(l*1,l*2));if(!d(B,L))throw new Error("bad point: is not on curve");return{x:B,y:L}}else throw new Error(`bad point: got length ${b}, expected compressed=${g} or uncompressed=${p}`)}let f=t.toBytes||c,u=t.fromBytes||h,x=pf(e,r.a,r.b);function d(T,l){let g=e.sqr(l),p=x(T);return e.eql(g,p)}if(!d(r.Gx,r.Gy))throw new Error("bad curve params: generator point");let E=e.mul(e.pow(r.a,Lr),df),S=e.mul(e.sqr(r.b),BigInt(27));if(e.is0(e.add(E,S)))throw new Error("bad curve params: a or b");function y(T,l,g=!1){if(!e.isValid(l)||g&&e.is0(l))throw new Error(`bad point coordinate ${T}`);return l}function v(T){if(!(T instanceof m))throw new Error("ProjectivePoint expected")}let P=we((T,l)=>{let{px:g,py:p,pz:b}=T;if(e.eql(b,e.ONE))return{x:g,y:p};let w=T.is0();l==null&&(l=w?e.ONE:e.inv(b));let _=e.mul(g,l),B=e.mul(p,l),L=e.mul(b,l);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:_,y:B}}),I=we(T=>{if(T.is0()){if(t.allowInfinityPoint&&!e.is0(T.py))return;throw new Error("bad point: ZERO")}let{x:l,y:g}=T.toAffine();if(!e.isValid(l)||!e.isValid(g))throw new Error("bad point: x or y not field elements");if(!d(l,g))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function N(T,l,g,p,b){return g=new m(e.mul(g.px,T),g.py,g.pz),l=Ee(p,l),g=Ee(b,g),l.add(g)}class m{constructor(l,g,p){this.px=y("x",l),this.py=y("y",g,!0),this.pz=y("z",p),Object.freeze(this)}static fromAffine(l){let{x:g,y:p}=l||{};if(!l||!e.isValid(g)||!e.isValid(p))throw new Error("invalid affine point");if(l instanceof m)throw new Error("projective point not allowed");return e.is0(g)&&e.is0(p)?m.ZERO:new m(g,p,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){return hr(m,"pz",l)}static fromBytes(l){return rt(l),m.fromHex(l)}static fromHex(l){let g=m.fromAffine(u(F("pointHex",l)));return g.assertValidity(),g}static fromPrivateKey(l){let g=ai(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return m.BASE.multiply(g(l))}static msm(l,g){return pr(m,n,l,g)}precompute(l=8,g=!0){return C.setWindowSize(this,l),g||this.multiply(Lr),this}_setWindowSize(l){this.precompute(l)}assertValidity(){I(this)}hasEvenY(){let{y:l}=this.toAffine();if(!e.isOdd)throw new Error("Field doesn't support isOdd");return!e.isOdd(l)}equals(l){v(l);let{px:g,py:p,pz:b}=this,{px:w,py:_,pz:B}=l,L=e.eql(e.mul(g,B),e.mul(w,b)),K=e.eql(e.mul(p,B),e.mul(_,b));return L&&K}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b:g}=r,p=e.mul(g,Lr),{px:b,py:w,pz:_}=this,B=e.ZERO,L=e.ZERO,K=e.ZERO,R=e.mul(b,b),$=e.mul(w,w),M=e.mul(_,_),k=e.mul(b,w);return k=e.add(k,k),K=e.mul(b,_),K=e.add(K,K),B=e.mul(l,K),L=e.mul(p,M),L=e.add(B,L),B=e.sub($,L),L=e.add($,L),L=e.mul(B,L),B=e.mul(k,B),K=e.mul(p,K),M=e.mul(l,M),k=e.sub(R,M),k=e.mul(l,k),k=e.add(k,K),K=e.add(R,R),R=e.add(K,R),R=e.add(R,M),R=e.mul(R,k),L=e.add(L,R),M=e.mul(w,_),M=e.add(M,M),R=e.mul(M,k),B=e.sub(B,R),K=e.mul(M,$),K=e.add(K,K),K=e.add(K,K),new m(B,L,K)}add(l){v(l);let{px:g,py:p,pz:b}=this,{px:w,py:_,pz:B}=l,L=e.ZERO,K=e.ZERO,R=e.ZERO,$=r.a,M=e.mul(r.b,Lr),k=e.mul(g,w),Y=e.mul(p,_),Q=e.mul(b,B),et=e.add(g,p),V=e.add(w,_);et=e.mul(et,V),V=e.add(k,Y),et=e.sub(et,V),V=e.add(g,b);let st=e.add(w,B);return V=e.mul(V,st),st=e.add(k,Q),V=e.sub(V,st),st=e.add(p,b),L=e.add(_,B),st=e.mul(st,L),L=e.add(Y,Q),st=e.sub(st,L),R=e.mul($,V),L=e.mul(M,Q),R=e.add(L,R),L=e.sub(Y,R),R=e.add(Y,R),K=e.mul(L,R),Y=e.add(k,k),Y=e.add(Y,k),Q=e.mul($,Q),V=e.mul(M,V),Y=e.add(Y,Q),Q=e.sub(k,Q),Q=e.mul($,Q),V=e.add(V,Q),k=e.mul(Y,V),K=e.add(K,k),k=e.mul(st,V),L=e.mul(et,L),L=e.sub(L,k),k=e.mul(et,Y),R=e.mul(st,R),R=e.add(R,k),new m(L,K,R)}subtract(l){return this.add(l.negate())}is0(){return this.equals(m.ZERO)}multiply(l){let{endo:g}=t;if(!n.isValidNot0(l))throw new Error("invalid scalar: out of range");let p,b,w=_=>C.wNAFCached(this,_,m.normalizeZ);if(g){let{k1neg:_,k1:B,k2neg:L,k2:K}=g.splitScalar(l),{p:R,f:$}=w(B),{p:M,f:k}=w(K);b=$.add(k),p=N(g.beta,R,M,_,L)}else{let{p:_,f:B}=w(l);p=_,b=B}return m.normalizeZ([p,b])[0]}multiplyUnsafe(l){let{endo:g}=t,p=this;if(!n.isValid(l))throw new Error("invalid scalar: out of range");if(l===Xe||p.is0())return m.ZERO;if(l===Qe)return p;if(C.hasPrecomputes(this))return this.multiply(l);if(g){let{k1neg:b,k1:w,k2neg:_,k2:B}=g.splitScalar(l),{p1:L,p2:K}=Vs(m,p,w,B);return N(g.beta,L,K,b,_)}else return C.wNAFCachedUnsafe(p,l)}multiplyAndAddUnsafe(l,g,p){let b=this.multiplyUnsafe(g).add(l.multiplyUnsafe(p));return b.is0()?void 0:b}toAffine(l){return P(this,l)}isTorsionFree(){let{isTorsionFree:l}=t;return o===Qe?!0:l?l(m,this):C.wNAFCachedUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:l}=t;return o===Qe?this:l?l(m,this):this.multiplyUnsafe(o)}toBytes(l=!0){return Dt("isCompressed",l),this.assertValidity(),f(m,this,l)}toRawBytes(l=!0){return this.toBytes(l)}toHex(l=!0){return vt(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}m.BASE=new m(r.Gx,r.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO),m.Fp=e,m.Fn=n;let D=n.BITS,C=dr(m,t.endo?Math.ceil(D/2):D);return m}function ci(r){return Uint8Array.of(r?2:3)}function yf(r,t,e={}){Mt(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=t.randomBytes||qe,o=t.hmac||((p,...b)=>oo(t.hash,p,pt(...b))),{Fp:s,Fn:i}=r,{ORDER:a,BITS:c}=i;function h(p){let b=a>>Qe;return p>b}function f(p){return h(p)?i.neg(p):p}function u(p,b){if(!i.isValidNot0(b))throw new Error(`invalid signature ${p}: out of range 1..CURVE.n`)}class x{constructor(b,w,_){u("r",b),u("s",w),this.r=b,this.s=w,_!=null&&(this.recovery=_),Object.freeze(this)}static fromCompact(b){let w=i.BYTES,_=F("compactSignature",b,w*2);return new x(i.fromBytes(_.subarray(0,w)),i.fromBytes(_.subarray(w,w*2)))}static fromDER(b){let{r:w,s:_}=Ut.toSig(F("DER",b));return new x(w,_)}assertValidity(){}addRecoveryBit(b){return new x(this.r,this.s,b)}recoverPublicKey(b){let w=s.ORDER,{r:_,s:B,recovery:L}=this;if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");if(a*hf<w&&L>1)throw new Error("recovery id is ambiguous for h>1 curve");let R=L===2||L===3?_+a:_;if(!s.isValid(R))throw new Error("recovery id 2 or 3 invalid");let $=s.toBytes(R),M=r.fromHex(pt(ci((L&1)===0),$)),k=i.inv(R),Y=I(F("msgHash",b)),Q=i.create(-Y*k),et=i.create(B*k),V=r.BASE.multiplyUnsafe(Q).add(M.multiplyUnsafe(et));if(V.is0())throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,i.neg(this.s),this.recovery):this}toBytes(b){if(b==="compact")return pt(i.toBytes(this.r),i.toBytes(this.s));if(b==="der")return be(Ut.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return vt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return vt(this.toBytes("compact"))}}let d=ai(i,e.allowedPrivateKeyLengths,e.wrapPrivateKey),E={isValidPrivateKey(p){try{return d(p),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let p=a;return Ks(n(Cn(p)),p)},precompute(p=8,b=r.BASE){return b.precompute(p,!1)}};function S(p,b=!0){return r.fromPrivateKey(p).toBytes(b)}function y(p){if(typeof p=="bigint")return!1;if(p instanceof r)return!0;let w=F("key",p).length,_=s.BYTES,B=_+1,L=2*_+1;if(!(e.allowedPrivateKeyLengths||i.BYTES===B))return w===B||w===L}function v(p,b,w=!0){if(y(p)===!0)throw new Error("first arg must be private key");if(y(b)===!1)throw new Error("second arg must be public key");return r.fromHex(b).multiply(d(p)).toBytes(w)}let P=t.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");let b=xe(p),w=p.length*8-c;return w>0?b>>BigInt(w):b},I=t.bits2int_modN||function(p){return i.create(P(p))},N=Xt(c);function m(p){return Ot("num < 2^"+c,p,Xe,N),i.toBytes(p)}function D(p,b,w=C){if(["recovered","canonical"].some(et=>et in w))throw new Error("sign() legacy options not supported");let{hash:_}=t,{lowS:B,prehash:L,extraEntropy:K}=w;B==null&&(B=!0),p=F("msgHash",p),ii(w),L&&(p=F("prehashed msgHash",_(p)));let R=I(p),$=d(b),M=[m($),m(R)];if(K!=null&&K!==!1){let et=K===!0?n(s.BYTES):K;M.push(F("extraEntropy",et))}let k=pt(...M),Y=R;function Q(et){let V=P(et);if(!i.isValidNot0(V))return;let st=i.inv(V),Le=r.BASE.multiply(V).toAffine(),ie=i.create(Le.x);if(ie===Xe)return;let zt=i.create(st*i.create(Y+ie*$));if(zt===Xe)return;let jr=(Le.x===ie?0:2)|Number(Le.y&Qe),ae=zt;return B&&h(zt)&&(ae=f(zt),jr^=1),new x(ie,ae,jr)}return{seed:k,k2sig:Q}}let C={lowS:t.lowS,prehash:!1},T={lowS:t.lowS,prehash:!1};function l(p,b,w=C){let{seed:_,k2sig:B}=D(p,b,w);return Is(t.hash.outputLen,i.BYTES,o)(_,B)}r.BASE.precompute(8);function g(p,b,w,_=T){let B=p;b=F("msgHash",b),w=F("publicKey",w),ii(_);let{lowS:L,prehash:K,format:R}=_;if("strict"in _)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&!["compact","der","js"].includes(R))throw new Error('format must be "compact", "der" or "js"');let $=typeof B=="string"||me(B),M=!$&&!R&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!$&&!M)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let k,Y;try{if(M)if(R===void 0||R==="js")k=new x(B.r,B.s);else throw new Error("invalid format");if($){try{R!=="compact"&&(k=x.fromDER(B))}catch(ae){if(!(ae instanceof Ut.Err))throw ae}!k&&R!=="der"&&(k=x.fromCompact(B))}Y=r.fromHex(w)}catch{return!1}if(!k||L&&k.hasHighS())return!1;K&&(b=t.hash(b));let{r:Q,s:et}=k,V=I(b),st=i.inv(et),Le=i.create(V*st),ie=i.create(Q*st),zt=r.BASE.multiplyUnsafe(Le).add(Y.multiplyUnsafe(ie));return zt.is0()?!1:i.create(zt.x)===Q}return Object.freeze({getPublicKey:S,getSharedSecret:v,sign:l,verify:g,utils:E,Point:r,Signature:x})}function bf(r){let t={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wt(t.n,r.nBitLength),o={Fp:e,Fn:n,allowedPrivateKeyLengths:r.allowedPrivateKeyLengths,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,wrapPrivateKey:r.wrapPrivateKey,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:t,curveOpts:o}}function xf(r){let{CURVE:t,curveOpts:e}=bf(r),n={hash:r.hash,hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:t,curveOpts:e,ecdsaOpts:n}}function gf(r,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:r})}function fi(r){let{CURVE:t,curveOpts:e,ecdsaOpts:n}=xf(r),o=mf(t,e),s=yf(o,n,e);return gf(r,s)}function ui(r,t){let e=n=>fi({...r,hash:n});return{...e(t),create:e}}var Pr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Jd=BigInt(0),wf=BigInt(1),io=BigInt(2),li=(r,t)=>(r+t/io)/t;function Ef(r){let t=Pr.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),h=r*r*r%t,f=h*h*r%t,u=j(f,e,t)*f%t,x=j(u,e,t)*f%t,d=j(x,io,t)*h%t,E=j(d,o,t)*d%t,S=j(E,s,t)*E%t,y=j(S,a,t)*S%t,v=j(y,c,t)*y%t,P=j(v,a,t)*S%t,I=j(P,e,t)*f%t,N=j(I,i,t)*E%t,m=j(N,n,t)*h%t,D=j(m,io,t);if(!ao.eql(ao.sqr(D),r))throw new Error("Cannot find square root");return D}var ao=wt(Pr.p,void 0,void 0,{sqrt:Ef}),Be=ui({...Pr,Fp:ao,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Pr.n,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=li(s*r,t),c=li(-n*r,t),h=G(r-a*e-c*o,t),f=G(-a*n-c*s,t),u=h>i,x=f>i;if(u&&(h=t-h),x&&(f=t-f),h>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:h,k2neg:x,k2:f}}}},Es);function hi(r,t,e,n){let o=Re.digest(e instanceof Uint8Array?e:e.subarray());if(wr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Be.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new Ze(String(s))});try{return n?.signal?.throwIfAborted(),Be.verify(t,o.digest,r)}catch(s){throw new Ze(String(s))}}var Cr=class{type="secp256k1";raw;_key;constructor(t){this._key=pi(t),this.raw=di(this._key)}toMultihash(){return xt.digest(de(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e,n){return hi(this._key,e,t,n)}};function mi(r){return new Cr(r)}function di(r){return Be.ProjectivePoint.fromHex(r).toRawBytes(!0)}function pi(r){try{return Be.ProjectivePoint.fromHex(r),r}catch(t){throw new er(String(t))}}function yi(r){let{Type:t,Data:e}=Ye.decode(r.digest),n=e??new Uint8Array;switch(t){case yt.Ed25519:return Ys(n);case yt.secp256k1:return mi(n);case yt.ECDSA:return rs(n);default:throw new Pe}}function de(r){return Ye.encode({Type:yt[r.type],Data:r.raw})}var bi=Symbol.for("nodejs.util.inspect.custom"),Sf=114,Je=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()})`}[Zr]=!0;toString(){return this.string==null&&(this.string=z.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(Sf,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return lt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return lt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[bi](){return`PeerId(${this.toString()})`}},Dr=class extends Je{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ur=class extends Je{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Nr=class extends Je{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},vf=2336,tr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=xt.digest(bt(this.url))}[bi](){return`PeerId(${this.url})`}[Zr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(vf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=H(t)),t.toString()===this.toString())}};var Af=114,xi=2336;function gi(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=jt(z.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Bf(X.parse(r));if(t==null)throw new St('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=jt(t.decode(r))}return wi(e)}function wi(r){if(Tf(r))return new Dr({multihash:r});if(If(r))try{let t=yi(r);if(t.type==="Ed25519")return new Ur({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Nr({multihash:r,publicKey:t})}catch{let e=H(r.digest);return new tr(new URL(e))}throw new nr("Supplied PeerID Multihash is invalid")}function Bf(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Af&&r.code!==xi)throw new rr("Supplied PeerID CID is invalid");if(r.code===xi){let t=H(r.multihash.digest);return new tr(new URL(t))}return wi(r.multihash)}function If(r){return r.code===xt.code}function Tf(r){return r.code===Re.code}var Rr=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,a=this.peekChar();if(a===void 0)return;let c=a==="0",h=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let x=Number.parseInt(u,t);if(!Number.isNaN(x))return x});if(f===void 0)break;if(s*=t,s+=f,s>h||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&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),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ei=45,_f=15,Ie=new Rr;function co(r){if(!(r.length>_f))return Ie.new(r).parseWith(()=>Ie.readIPv4Addr())}function fo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ei))return Ie.new(r).parseWith(()=>Ie.readIPv6Addr())}function Kr(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Ei)return;let e=Ie.new(r).parseWith(()=>Ie.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var f0=parseInt("0xFFFF",16),u0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ai(r){return!!co(r)}function Bi(r){return!!fo(r)}function kr(r){return!!Kr(r)}var Ii=Ai,Uf=Bi,uo=function(r){let t=0;if(r=r.toString().trim(),Ii(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Uf(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ii(e[n]),i;s&&(i=uo(e[n]),e[n]=H(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,H(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")},Ti=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 Te={},lo={},Rf=[[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"]];Rf.forEach(r=>{let t=Kf(...r);lo[t.code]=t,Te[t.name]=t});function Kf(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function q(r){if(typeof r=="number"){if(lo[r]!=null)return lo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Te[r]!=null)return Te[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Z0=q("ip4"),$0=q("ip6"),W0=q("ipcidr");function yo(r,t){switch(q(r).code){case 4:case 41:return Of(t);case 42:return mo(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return Pi(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return mo(t);case 421:return Vf(t);case 444:return Li(t);case 445:return Li(t);case 466:return qf(t);case 481:return globalThis.encodeURIComponent(mo(t));default:return H(t,"base16")}}function bo(r,t){switch(q(r).code){case 4:return _i(t);case 41:return _i(t);case 42:return po(t);case 43:return bt(t,"base10");case 6:case 273:case 33:case 132:return xo(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return po(t);case 421:return Mf(t);case 444:return zf(t);case 445:return Ff(t);case 466:return Hf(t);case 481:return po(globalThis.decodeURIComponent(t));default:return bt(t,"base16")}}var ho=Object.values(Ke).map(r=>r.decoder),kf=function(){let r=ho[0].or(ho[1]);return ho.slice(2).forEach(t=>r=r.or(t)),r}();function _i(r){if(!kr(r))throw new Error("invalid ip address");return uo(r)}function Of(r){let t=Ti(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!kr(t))throw new Error("invalid ip address");return t}function xo(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Pi(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function po(r){let t=bt(r),e=Uint8Array.from(ve(t.length));return ht([e,t],e.length+t.length)}function mo(r){let t=te(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return H(r)}function Mf(r){let t;r[0]==="Q"||r[0]==="1"?t=jt(z.decode(`z${r}`)).bytes:t=X.parse(r).multihash.bytes;let e=Uint8Array.from(ve(t.length));return ht([e,t],e.length+t.length)}function Hf(r){let t=kf.decode(r),e=Uint8Array.from(ve(t.length));return ht([e,t],e.length+t.length)}function qf(r){let t=te(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+H(e,"base64url")}function Vf(r){let t=te(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return H(e,"base58btc")}function zf(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=Tt.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=xo(n);return ht([e,o],e.length+o.length)}function Ff(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=Tt.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=xo(n);return ht([e,o],e.length+o.length)}function Li(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=H(t,"base32"),o=Pi(e);return`${n}:${o}`}function Ci(r){r=go(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],a=q(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw new Or("invalid address: "+r);if(a.path===!0){n=go(o.slice(s).join("/")),t.push([a.code,bo(a.code,n)]),e.push([a.code,n]);break}let c=bo(a.code,o[s]);t.push([a.code,c]),e.push([a.code,yo(a.code,c)])}return{string:Di(e),bytes:Mr(t),tuples:t,stringTuples:e,path:n}}function wo(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=te(r,o),i=ft(s),a=q(s),c=jf(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let h=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new Or("Invalid address Uint8Array: "+H(r,"base16"));t.push([s,h]);let f=yo(s,h);if(e.push([s,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:Di(e),tuples:t,stringTuples:e,path:n}}function Di(r){let t=[];return r.map(e=>{let n=q(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),go(t.join("/"))}function Mr(r){return ht(r.map(t=>{let e=q(t[0]),n=Uint8Array.from(ve(e.code));return t.length>1&&t[1]!=null&&(n=ht([n,t[1]])),n}))}function jf(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=te(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function go(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Or=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Gf=Symbol.for("nodejs.util.inspect.custom"),So=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Zf=[q("dns").code,q("dns4").code,q("dns6").code,q("dnsaddr").code],Eo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Hr=class r{bytes;#t;#e;#r;#n;[So]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=wo(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ci(t)}else if(Ni(t))e=wo(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=q("tcp"),a=q("udp"),c=q("ip4"),h=q("ip6"),f=q("dns6"),u=q("ip6zone");for(let[d,E]of this.stringTuples())d===u.code&&(s=`%${E??""}`),Zf.includes(d)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${E??""}${s}`,t=d===f.code?6:4),(d===i.code||d===a.code)&&(e=q(d).name==="tcp"?"tcp":"udp",o=parseInt(E??"")),(d===c.code||d===h.code)&&(e=q(d).name==="tcp"?"tcp":"udp",n=`${E??""}${s}`,t=d===h.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({},q(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>q(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}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(Mr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Te.p2p.code&&t.push([n,o]),n===Te["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?H(z.decode(`z${n}`),"base58btc"):H(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return lt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Ui.get(e.name);if(n==null)throw new Eo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>qt(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)}[Gf](){return`Multiaddr(${this.#t})`}};var Ui=new Map;function Ni(r){return!!r?.[So]}function qt(r){return new Hr(r)}var $f=A("dns4"),Wf=A("dns6"),Yf=A("dnsaddr"),oe=W(A("dns"),Yf,$f,Wf),zr=W(A("ip4"),A("ip6")),_e=W(U(zr,A("tcp")),U(oe,A("tcp"))),Fr=U(zr,A("udp")),Xf=U(Fr,A("utp")),Qf=U(Fr,A("quic")),Jf=U(Fr,A("quic-v1")),vo=W(U(_e,A("ws")),U(oe,A("ws"))),qr=W(U(vo,A("p2p")),vo),Ao=W(U(_e,A("wss")),U(oe,A("wss")),U(_e,A("tls"),A("ws")),U(oe,A("tls"),A("ws"))),Vr=W(U(Ao,A("p2p")),Ao),Bo=W(U(_e,A("http")),U(zr,A("http")),U(oe,A("http"))),Io=W(U(_e,A("https")),U(zr,A("https")),U(oe,A("https"))),Ri=U(Fr,A("webrtc-direct"),A("certhash")),Oi=W(U(Ri,A("p2p")),Ri),Ki=U(Jf,A("webtransport"),A("certhash"),A("certhash")),Mi=W(U(Ki,A("p2p")),Ki),Hi=W(U(qr,A("p2p-webrtc-star"),A("p2p")),U(Vr,A("p2p-webrtc-star"),A("p2p")),U(qr,A("p2p-webrtc-star")),U(Vr,A("p2p-webrtc-star"))),Sm=W(U(qr,A("p2p-websocket-star"),A("p2p")),U(Vr,A("p2p-websocket-star"),A("p2p")),U(qr,A("p2p-websocket-star")),U(Vr,A("p2p-websocket-star"))),qi=W(U(Bo,A("p2p-webrtc-direct"),A("p2p")),U(Io,A("p2p-webrtc-direct"),A("p2p")),U(Bo,A("p2p-webrtc-direct")),U(Io,A("p2p-webrtc-direct"))),se=W(vo,Ao,Bo,Io,Hi,qi,_e,Xf,Qf,oe,Oi,Mi),vm=W(U(se,A("p2p-stardust"),A("p2p")),U(se,A("p2p-stardust"))),Vt=W(U(se,A("p2p")),Hi,qi,Oi,Mi,A("p2p")),ki=W(U(Vt,A("p2p-circuit"),Vt),U(Vt,A("p2p-circuit")),U(A("p2p-circuit"),Vt),U(se,A("p2p-circuit")),U(A("p2p-circuit"),se),A("p2p-circuit")),Vi=()=>W(U(ki,Vi),ki),ne=Vi(),zi=W(U(ne,Vt,ne),U(Vt,ne),U(ne,Vt),ne,Vt);var Am=W(U(ne,A("webrtc"),A("p2p")),U(ne,A("webrtc")),U(se,A("webrtc"),A("p2p")),U(se,A("webrtc")),A("webrtc"));function Fi(r){function t(e){let n;try{n=qt(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:Fi(t),partialMatch:t}}function W(...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:Fi(t),partialMatch:t}}function A(r){let t=r;function e(o){let s;try{s=qt(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 tu="bootstrap",eu=50,ru=1e3,To=class extends or{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??ru,this.list=[];for(let n of e.list){if(!zi.matches(n)){this.log.error("Invalid multiaddr");continue}let o=qt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:gi(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[_o]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Lo]=["@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??tu]:{value:this._init.tagValue??eu,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 nu(r){return t=>new To(t,r)}return Wi(ou);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js:
6
6
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
7
7
 
8
- @noble/curves/esm/abstract/utils.js:
8
+ @noble/curves/esm/utils.js:
9
9
  @noble/curves/esm/abstract/modular.js:
10
10
  @noble/curves/esm/abstract/curve.js:
11
11
  @noble/curves/esm/abstract/edwards.js: