@libp2p/bootstrap 10.0.24-352699ab5 → 10.0.24-4bd8e4f79

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,3 +1,3 @@
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 Dt=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var Ar=Object.prototype.hasOwnProperty;var v=(r,t)=>{for(var e in t)Dt(r,e,{get:t[e],enumerable:!0})},Ir=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sr(t))!Ar.call(r,o)&&o!==e&&Dt(r,o,{get:()=>t[o],enumerable:!(n=vr(t,o))||n.enumerable});return r};var Tr=r=>Ir(Dt({},"__esModule",{value:!0}),r);var So={};v(So,{bootstrap:()=>vo});var Ee=Symbol.for("@libp2p/peer-discovery");var ve=Symbol.for("@libp2p/peer-id");var mt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Se=(r,...t)=>{try{[...t]}catch{}};var gt=class extends EventTarget{#t=new Map;constructor(){super(),Se(1/0,this)}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new Pr(t,e))}},Ut=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Pr=globalThis.CustomEvent??Ut;var Lt={};v(Lt,{base58btc:()=>w,base58flickr:()=>Fr});var No=new Uint8Array(0);function Ae(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 M(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 Ie(r){return new TextEncoder().encode(r)}function Te(r){return new TextDecoder().decode(r)}function Cr(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),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var p=r.length,h=r.charAt(0),b=Math.log(p)/Math.log(256),g=Math.log(256)/Math.log(p);function I(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var y=0,q=0,T=0,D=u.length;T!==D&&u[T]===0;)T++,y++;for(var U=(D-T)*g+1>>>0,A=new Uint8Array(U);T!==D;){for(var N=u[T],O=0,P=U-1;(N!==0||O<q)&&P!==-1;P--,O++)N+=256*A[P]>>>0,A[P]=N%p>>>0,N=N/p>>>0;if(N!==0)throw new Error("Non-zero carry");q=O,T++}for(var F=U-q;F!==U&&A[F]===0;)F++;for(var ft=h.repeat(y);F<U;++F)ft+=r.charAt(A[F]);return ft}function z(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var q=0,T=0;u[y]===h;)q++,y++;for(var D=(u.length-y)*b+1>>>0,U=new Uint8Array(D);u[y];){var A=e[u.charCodeAt(y)];if(A===255)return;for(var N=0,O=D-1;(A!==0||N<T)&&O!==-1;O--,N++)A+=p*U[O]>>>0,U[O]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");T=N,y++}if(u[y]!==" "){for(var P=D-T;P!==D&&U[P]===0;)P++;for(var F=new Uint8Array(q+(D-P)),ft=q;P!==D;)F[ft++]=U[P++];return F}}}function S(u){var y=z(u);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:z,decode:S}}var Dr=Cr,Ur=Dr,Ce=Ur;var Nt=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")}},Rt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return De(this,t)}},Ft=class{decoders;constructor(t){this.decoders=t}or(t){return De(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 De(r,t){return new Ft({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Mt=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 Nt(t,e,n),this.decoder=new Rt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Q({name:r,prefix:t,encode:e,decode:n}){return new Mt(r,t,e,n)}function B({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ce(e,r);return Q({prefix:t,name:r,encode:n,decode:s=>M(o(s))})}function Nr(r,t,e,n){let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),p=0,h=0,b=0;for(let g=0;g<s;++g){let I=o[r[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<e|I,p+=e,p>=8&&(p-=8,c[b++]=255&h>>p)}if(p>=e||255&h<<8-p)throw new SyntaxError("Unexpected end of data");return c}function Rr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,p=0;for(let h=0;h<r.length;++h)for(p=p<<8|r[h],c+=8;c>e;)c-=e,s+=t[o&p>>c];if(c!==0&&(s+=t[o&p<<e-c]),n)for(;s.length*e&7;)s+="=";return s}function f({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Q({prefix:t,name:r,encode(o){return Rr(o,n,e)},decode(o){return Nr(o,n,e,r)}})}var w=B({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fr=B({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};v(kt,{base10:()=>Mr});var Mr=B({prefix:"9",name:"base10",alphabet:"0123456789"});var zt={};v(zt,{base16:()=>Lr,base16upper:()=>kr});var Lr=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),kr=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ot={};v(Ot,{base2:()=>zr});var zr=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bt={};v(Bt,{base256emoji:()=>$r});var Ue=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}"),Or=Ue.reduce((r,t,e)=>(r[e]=t,r),[]),Br=Ue.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Vr(r){return r.reduce((t,e)=>(t+=Or[e],t),"")}function _r(r){let t=[];for(let e of r){let n=Br[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var $r=Q({prefix:"\u{1F680}",name:"base256emoji",encode:Vr,decode:_r});var Vt={};v(Vt,{base32:()=>L,base32hex:()=>Wr,base32hexpad:()=>Kr,base32hexpadupper:()=>Jr,base32hexupper:()=>Hr,base32pad:()=>qr,base32padupper:()=>Gr,base32upper:()=>jr,base32z:()=>Xr});var L=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jr=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qr=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gr=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wr=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hr=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Kr=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Jr=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xr=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _t={};v(_t,{base36:()=>Qr,base36upper:()=>Yr});var Qr=B({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yr=B({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $t={};v($t,{base64:()=>Zr,base64pad:()=>tn,base64url:()=>en,base64urlpad:()=>rn});var Zr=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tn=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),en=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rn=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jt={};v(jt,{base8:()=>nn});var nn=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qt={};v(qt,{identity:()=>on});var on=Q({prefix:"\0",name:"identity",encode:r=>Te(r),decode:r=>Ie(r)});var Ho=new TextEncoder,Ko=new TextDecoder;var Wt={};v(Wt,{identity:()=>xt});var an=Fe,Ne=128,pn=127,un=~pn,dn=Math.pow(2,31);function Fe(r,t,e){t=t||[],e=e||0;for(var n=e;r>=dn;)t[e++]=r&255|Ne,r/=128;for(;r&un;)t[e++]=r&255|Ne,r>>>=7;return t[e]=r|0,Fe.bytes=e-n+1,t}var ln=Gt,hn=128,Re=127;function Gt(r,n){var e=0,n=n||0,o=0,s=n,c,p=r.length;do{if(s>=p)throw Gt.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&Re)<<o:(c&Re)*Math.pow(2,o),o+=7}while(c>=hn);return Gt.bytes=s-n,e}var fn=Math.pow(2,7),mn=Math.pow(2,14),gn=Math.pow(2,21),wn=Math.pow(2,28),xn=Math.pow(2,35),bn=Math.pow(2,42),yn=Math.pow(2,49),En=Math.pow(2,56),vn=Math.pow(2,63),Sn=function(r){return r<fn?1:r<mn?2:r<gn?3:r<wn?4:r<xn?5:r<bn?6:r<yn?7:r<En?8:r<vn?9:10},An={encode:an,decode:ln,encodingLength:Sn},In=An,it=In;function ct(r,t=0){return[it.decode(r,t),it.decode.bytes]}function Y(r,t,e=0){return it.encode(r,t,e),t}function Z(r){return it.encodingLength(r)}function V(r,t){let e=t.byteLength,n=Z(r),o=n+Z(e),s=new Uint8Array(o+e);return Y(r,s,0),Y(e,s,n),s.set(t,o),new tt(r,e,t,s)}function G(r){let t=M(r),[e,n]=ct(t),[o,s]=ct(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new tt(e,o,c,t)}function Me(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ae(r.bytes,e.bytes)}}var tt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Le=0,Tn="identity",ke=M;function Pn(r){return V(Le,ke(r))}var xt={code:Le,name:Tn,encode:ke,digest:Pn};var Jt={};v(Jt,{sha256:()=>bt,sha512:()=>Cn});function Kt({name:r,code:t,encode:e}){return new Ht(r,t,e)}var Ht=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?V(this.code,e):e.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Oe(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var bt=Kt({name:"sha2-256",code:18,encode:Oe("SHA-256")}),Cn=Kt({name:"sha2-512",code:19,encode:Oe("SHA-512")});function Be(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Un(e,Xt(r),t??w.encoder);default:return Nn(e,Xt(r),t??L.encoder)}}var Ve=new WeakMap;function Xt(r){let t=Ve.get(r);if(t==null){let e=new Map;return Ve.set(r,e),e}return t}var C=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!==at)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Rn)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=V(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&&Me(t.multihash,n.multihash)}toString(t){return Be(this,t)}toJSON(){return{"/":Be(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:c}=e;return new r(n,o,s,c??_e(n,o,s.bytes))}else if(e[Fn]===!0){let{version:n,multihash:o,code:s}=e,c=G(o);return r.create(n,s,c)}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!==at)throw new Error(`Version 0 CID must use dag-pb (code: ${at}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=_e(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,at,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=M(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new tt(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[I,z]=ct(t.subarray(e));return e+=z,I},o=n(),s=at;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,p=n(),h=n(),b=e+h,g=b-c;return{version:o,codec:s,multihashCode:p,digestSize:h,multihashSize:g,size:b}}static parse(t,e){let[n,o]=Dn(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 Xt(s).set(n,t),s}};function Dn(r,t){switch(r[0]){case"Q":{let e=t??w;return[w.prefix,e.decode(`${w.prefix}${r}`)]}case w.prefix:{let e=t??w;return[w.prefix,e.decode(r)]}case L.prefix:{let e=t??L;return[L.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Un(r,t,e){let{prefix:n}=e;if(n!==w.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 Nn(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 at=112,Rn=18;function _e(r,t,e){let n=Z(r),o=n+Z(t),s=new Uint8Array(o+e.byteLength);return Y(r,s,0),Y(t,s,n),s.set(e,o),s}var Fn=Symbol.for("@ipld/js-cid/CID");var _={...qt,...Ot,...jt,...kt,...zt,...Vt,..._t,...Lt,...$t,...Bt},ms={...Jt,...Wt};function pt(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}var Mn=Symbol.for("nodejs.util.inspect.custom"),$e=Object.values(_).map(r=>r.decoder).reduce((r,t)=>r.or(t),_.identity.decoder),je=114,qe=36,Ge=37,ut=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[ve]=!0;toString(){return this.string==null&&(this.string=w.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C.createV1(je,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return pt(this.multihash.bytes,t);if(typeof t=="string")return Qt(t).equals(this);if(t?.multihash?.bytes!=null)return pt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Mn](){return`PeerId(${this.toString()})`}},dt=class extends ut{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},lt=class extends ut{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},ht=class extends ut{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Qt(r,t){if(t=t??$e,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=G(w.decode(`z${r}`));return r.startsWith("12D")?new lt({multihash:e}):r.startsWith("16U")?new ht({multihash:e}):new dt({multihash:e})}return Ln($e.decode(r))}function Ln(r){try{let t=G(r);if(t.code===xt.code){if(t.digest.length===qe)return new lt({multihash:t});if(t.digest.length===Ge)return new ht({multihash:t})}if(t.code===bt.code)return new dt({multihash:t})}catch{return kn(C.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function kn(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==je)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===bt.code)return new dt({multihash:r.multihash});if(t.code===xt.code){if(t.digest.length===qe)return new lt({multihash:r.multihash});if(t.digest.length===Ge)return new ht({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function et(r=0){return new Uint8Array(r)}function He(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var We=He("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yt=He("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=et(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),zn={utf8:We,"utf-8":We,hex:_.base16,latin1:Yt,ascii:Yt,binary:Yt,..._},yt=zn;function E(r,t="utf8"){let e=yt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var On=Math.pow(2,7),Bn=Math.pow(2,14),Vn=Math.pow(2,21),Zt=Math.pow(2,28),te=Math.pow(2,35),ee=Math.pow(2,42),re=Math.pow(2,49),d=128,x=127;function R(r){if(r<On)return 1;if(r<Bn)return 2;if(r<Vn)return 3;if(r<Zt)return 4;if(r<te)return 5;if(r<ee)return 6;if(r<re)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function _n(r,t,e=0){switch(R(r)){case 8:t[e++]=r&255|d,r/=128;case 7:t[e++]=r&255|d,r/=128;case 6:t[e++]=r&255|d,r/=128;case 5:t[e++]=r&255|d,r/=128;case 4:t[e++]=r&255|d,r>>>=7;case 3:t[e++]=r&255|d,r>>>=7;case 2:t[e++]=r&255|d,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function $n(r,t,e=0){switch(R(r)){case 8:t.set(e++,r&255|d),r/=128;case 7:t.set(e++,r&255|d),r/=128;case 6:t.set(e++,r&255|d),r/=128;case 5:t.set(e++,r&255|d),r/=128;case 4:t.set(e++,r&255|d),r>>>=7;case 3:t.set(e++,r&255|d),r>>>=7;case 2:t.set(e++,r&255|d),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&x,e<d||(e=r[t+1],n+=(e&x)<<7,e<d)||(e=r[t+2],n+=(e&x)<<14,e<d)||(e=r[t+3],n+=(e&x)<<21,e<d)||(e=r[t+4],n+=(e&x)*Zt,e<d)||(e=r[t+5],n+=(e&x)*te,e<d)||(e=r[t+6],n+=(e&x)*ee,e<d)||(e=r[t+7],n+=(e&x)*re,e<d))return n;throw new RangeError("Could not decode varint")}function qn(r,t){let e=r.get(t),n=0;if(n+=e&x,e<d||(e=r.get(t+1),n+=(e&x)<<7,e<d)||(e=r.get(t+2),n+=(e&x)<<14,e<d)||(e=r.get(t+3),n+=(e&x)<<21,e<d)||(e=r.get(t+4),n+=(e&x)*Zt,e<d)||(e=r.get(t+5),n+=(e&x)*te,e<d)||(e=r.get(t+6),n+=(e&x)*ee,e<d)||(e=r.get(t+7),n+=(e&x)*re,e<d))return n;throw new RangeError("Could not decode varint")}function rt(r,t,e=0){return t==null&&(t=et(R(r))),t instanceof Uint8Array?_n(r,t,e):$n(r,t,e)}function H(r,t=0){return r instanceof Uint8Array?jn(r,t):qn(r,t)}function k(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=et(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Et=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,c=0,p=this.peekChar();if(p===void 0)return;let h=p==="0",b=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let z=Number.parseInt(I,t);if(!Number.isNaN(z))return z});if(g===void 0)break;if(s*=t,s+=g,s>b||(c+=1,e!==void 0&&c>e))return}if(c!==0)return!n&&h&&c>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 c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return e[o]=c[0],e[o+1]=c[1],e[o+2]=c[2],e[o+3]=c[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),c=16-(n+2),[p]=t(s.subarray(0,c));return e.set(s.subarray(0,p),16-p),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Je=45,Gn=15,nt=new Et;function ne(r){if(!(r.length>Gn))return nt.new(r).parseWith(()=>nt.readIPv4Addr())}function oe(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Je))return nt.new(r).parseWith(()=>nt.readIPv6Addr())}function vt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Je))return nt.new(r).parseWith(()=>nt.readIPAddr())}var Hs=parseInt("0xFFFF",16),Ks=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function se(r,t="utf8"){let e=yt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Ye(r){return!!ne(r)}function Ze(r){return!!oe(r)}function St(r){return!!vt(r)}var tr=Ye,Xn=Ze,ie=function(r){let t=0;if(r=r.toString().trim(),tr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Xn(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=tr(e[n]),c;s&&(c=ie(e[n]),e[n]=E(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,E(c.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")},er=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 ot={},ce={},Yn=[[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"],[777,-1,"memory"]];Yn.forEach(r=>{let t=Zn(...r);ce[t.code]=t,ot[t.name]=t});function Zn(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function l(r){if(typeof r=="number"){if(ce[r]!=null)return ce[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ot[r]!=null)return ot[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Fi=l("ip4"),Mi=l("ip6"),Li=l("ipcidr");function pe(r,t){switch(l(r).code){case 4:case 41:return eo(t);case 42:return or(t);case 6:case 273:case 33:case 132:return ir(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return or(t);case 421:return so(t);case 444:return sr(t);case 445:return sr(t);case 466:return oo(t);default:return E(t,"base16")}}function ue(r,t){switch(l(r).code){case 4:return rr(t);case 41:return rr(t);case 42:return nr(t);case 6:case 273:case 33:case 132:return de(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return nr(t);case 421:return ro(t);case 444:return io(t);case 445:return co(t);case 466:return no(t);default:return se(t,"base16")}}var ae=Object.values(_).map(r=>r.decoder),to=function(){let r=ae[0].or(ae[1]);return ae.slice(2).forEach(t=>r=r.or(t)),r}();function rr(r){if(!St(r))throw new Error("invalid ip address");return ie(r)}function eo(r){let t=er(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!St(t))throw new Error("invalid ip address");return t}function de(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function ir(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function nr(r){let t=se(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function or(r){let t=H(r);if(r=r.slice(R(t)),r.length!==t)throw new Error("inconsistent lengths");return E(r)}function ro(r){let t;r[0]==="Q"||r[0]==="1"?t=G(w.decode(`z${r}`)).bytes:t=C.parse(r).multihash.bytes;let e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function no(r){let t=to.decode(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function oo(r){let t=H(r),e=r.slice(R(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+E(e,"base64url")}function so(r){let t=H(r),e=r.slice(R(t));if(e.length!==t)throw new Error("inconsistent lengths");return E(e,"base58btc")}function io(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=L.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=de(n);return k([e,o],e.length+o.length)}function co(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=L.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=de(n);return k([e,o],e.length+o.length)}function sr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=E(t,"base32"),o=ir(e);return`${n}:${o}`}function cr(r){r=le(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 c=o[s],p=l(c);if(p.size===0){t.push([p.code]),e.push([p.code]);continue}if(s++,s>=o.length)throw pr("invalid address: "+r);if(p.path===!0){n=le(o.slice(s).join("/")),t.push([p.code,ue(p.code,n)]),e.push([p.code,n]);break}let h=ue(p.code,o[s]);t.push([p.code,h]),e.push([p.code,pe(p.code,h)])}return{string:ar(e),bytes:fe(t),tuples:t,stringTuples:e,path:n}}function he(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=H(r,o),c=R(s),p=l(s),h=ao(p,r.slice(o+c));if(h===0){t.push([s]),e.push([s]),o+=c;continue}let b=r.slice(o+c,o+c+h);if(o+=h+c,o>r.length)throw pr("Invalid address Uint8Array: "+E(r,"base16"));t.push([s,b]);let g=pe(s,b);if(e.push([s,g]),p.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:ar(e),tuples:t,stringTuples:e,path:n}}function ar(r){let t=[];return r.map(e=>{let n=l(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),le(t.join("/"))}function fe(r){return k(r.map(t=>{let e=l(t[0]),n=Uint8Array.from(rt(e.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function ao(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=H(t instanceof Uint8Array?t:Uint8Array.from(t));return e+R(e)}}function le(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function pr(r){return new Error("Error parsing address: "+r)}var po=Symbol.for("nodejs.util.inspect.custom"),me=Symbol.for("@multiformats/js-multiaddr/multiaddr"),uo=[l("dns").code,l("dns4").code,l("dns6").code,l("dnsaddr").code],At=class r{bytes;#t;#e;#r;#n;[me]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=he(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=cr(t)}else if(dr(t))e=he(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="",c=l("tcp"),p=l("udp"),h=l("ip4"),b=l("ip6"),g=l("dns6"),I=l("ip6zone");for(let[S,u]of this.stringTuples())S===I.code&&(s=`%${u??""}`),uo.includes(S)&&(e=c.name,o=443,n=`${u??""}${s}`,t=S===g.code?6:4),(S===c.code||S===p.code)&&(e=l(S).name,o=parseInt(u??"")),(S===h.code||S===b.code)&&(e=l(S).name,n=`${u??""}${s}`,t=S===b.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({},l(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>l(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(fe(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ot.p2p.code&&t.push([n,o]),n===ot["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?E(w.decode(`z${n}`),"base58btc"):E(C.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=ur.get(e.name);if(n==null)throw new mt(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>$(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)}[po](){return`Multiaddr(${this.#t})`}};var ur=new Map;function dr(r){return!!r?.[me]}function $(r){return new At(r)}var lo=i("dns4"),ho=i("dns6"),fo=i("dnsaddr"),J=m(i("dns"),fo,lo,ho),Pt=m(i("ip4"),i("ip6")),st=m(a(Pt,i("tcp")),a(J,i("tcp"))),Ct=a(Pt,i("udp")),mo=a(Ct,i("utp")),go=a(Ct,i("quic")),wo=a(Ct,i("quic-v1")),ge=m(a(st,i("ws")),a(J,i("ws"))),It=m(a(ge,i("p2p")),ge),we=m(a(st,i("wss")),a(J,i("wss")),a(st,i("tls"),i("ws")),a(J,i("tls"),i("ws"))),Tt=m(a(we,i("p2p")),we),xe=m(a(st,i("http")),a(Pt,i("http")),a(J,i("http"))),be=m(a(st,i("https")),a(Pt,i("https")),a(J,i("https"))),lr=a(Ct,i("webrtc-direct"),i("certhash")),mr=m(a(lr,i("p2p")),lr),hr=a(wo,i("webtransport"),i("certhash"),i("certhash")),gr=m(a(hr,i("p2p")),hr),wr=m(a(It,i("p2p-webrtc-star"),i("p2p")),a(Tt,i("p2p-webrtc-star"),i("p2p")),a(It,i("p2p-webrtc-star")),a(Tt,i("p2p-webrtc-star"))),cc=m(a(It,i("p2p-websocket-star"),i("p2p")),a(Tt,i("p2p-websocket-star"),i("p2p")),a(It,i("p2p-websocket-star")),a(Tt,i("p2p-websocket-star"))),xr=m(a(xe,i("p2p-webrtc-direct"),i("p2p")),a(be,i("p2p-webrtc-direct"),i("p2p")),a(xe,i("p2p-webrtc-direct")),a(be,i("p2p-webrtc-direct"))),X=m(ge,we,xe,be,wr,xr,st,mo,go,J,mr,gr),ac=m(a(X,i("p2p-stardust"),i("p2p")),a(X,i("p2p-stardust"))),j=m(a(X,i("p2p")),wr,xr,mr,gr,i("p2p")),fr=m(a(j,i("p2p-circuit"),j),a(j,i("p2p-circuit")),a(i("p2p-circuit"),j),a(X,i("p2p-circuit")),a(i("p2p-circuit"),X),i("p2p-circuit")),br=()=>m(a(fr,br),fr),K=br(),yr=m(a(K,j,K),a(j,K),a(K,j),K,j);var pc=m(a(K,i("webrtc"),i("p2p")),a(K,i("webrtc")),a(X,i("webrtc"),i("p2p")),a(X,i("webrtc")),i("webrtc"));function Er(r){function t(e){let n;try{n=$(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function a(...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:Er(t),partialMatch:t}}function m(...r){function t(n){let o=null;return r.some(s=>{let c=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return c!=null?(o=c,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Er(t),partialMatch:t}}function i(r){let t=r;function e(o){let s;try{s=$(o)}catch{return!1}let c=s.protoNames();return c.length===1&&c[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 xo="bootstrap",bo=50,yo=12e4,Eo=1e3,ye=class extends gt{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??Eo,this.list=[];for(let n of e.list){if(!yr.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let c={id:Qt(s),multiaddrs:[o]};this.list.push(c)}this._init=e}[Ee]=this;[Symbol.toStringTag]="@libp2p/bootstrap";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??xo]:{value:this._init.tagValue??bo,ttl:this._init.tagTTL??yo}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function vo(r){return t=>new ye(t,r)}return Tr(So);})();
2
+ "use strict";var Libp2PBootstrap=(()=>{var Dt=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var Ar=Object.prototype.hasOwnProperty;var v=(r,t)=>{for(var e in t)Dt(r,e,{get:t[e],enumerable:!0})},Ir=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sr(t))!Ar.call(r,o)&&o!==e&&Dt(r,o,{get:()=>t[o],enumerable:!(n=vr(t,o))||n.enumerable});return r};var Tr=r=>Ir(Dt({},"__esModule",{value:!0}),r);var So={};v(So,{bootstrap:()=>vo});var Se=Symbol.for("@libp2p/peer-discovery");var Ae=Symbol.for("@libp2p/peer-id");var mt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Ie=(r,...t)=>{try{[...t]}catch{}};var gt=class extends EventTarget{#t=new Map;constructor(){super(),Ie(1/0,this)}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new Pr(t,e))}},Ut=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Pr=globalThis.CustomEvent??Ut;var Lt={};v(Lt,{base58btc:()=>w,base58flickr:()=>Fr});var Ro=new Uint8Array(0);function Te(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 M(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 Pe(r){return new TextEncoder().encode(r)}function Ce(r){return new TextDecoder().decode(r)}function Cr(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),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var p=r.length,h=r.charAt(0),b=Math.log(p)/Math.log(256),g=Math.log(256)/Math.log(p);function I(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var y=0,q=0,T=0,D=u.length;T!==D&&u[T]===0;)T++,y++;for(var U=(D-T)*g+1>>>0,A=new Uint8Array(U);T!==D;){for(var R=u[T],O=0,P=U-1;(R!==0||O<q)&&P!==-1;P--,O++)R+=256*A[P]>>>0,A[P]=R%p>>>0,R=R/p>>>0;if(R!==0)throw new Error("Non-zero carry");q=O,T++}for(var F=U-q;F!==U&&A[F]===0;)F++;for(var ft=h.repeat(y);F<U;++F)ft+=r.charAt(A[F]);return ft}function z(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var q=0,T=0;u[y]===h;)q++,y++;for(var D=(u.length-y)*b+1>>>0,U=new Uint8Array(D);u[y];){var A=e[u.charCodeAt(y)];if(A===255)return;for(var R=0,O=D-1;(A!==0||R<T)&&O!==-1;O--,R++)A+=p*U[O]>>>0,U[O]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");T=R,y++}if(u[y]!==" "){for(var P=D-T;P!==D&&U[P]===0;)P++;for(var F=new Uint8Array(q+(D-P)),ft=q;P!==D;)F[ft++]=U[P++];return F}}}function S(u){var y=z(u);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:z,decode:S}}var Dr=Cr,Ur=Dr,Ue=Ur;var Rt=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")}},Nt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Re(this,t)}},Ft=class{decoders;constructor(t){this.decoders=t}or(t){return Re(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 Re(r,t){return new Ft({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Mt=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 Rt(t,e,n),this.decoder=new Nt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Q({name:r,prefix:t,encode:e,decode:n}){return new Mt(r,t,e,n)}function V({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ue(e,r);return Q({prefix:t,name:r,encode:n,decode:s=>M(o(s))})}function Rr(r,t,e,n){let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),p=0,h=0,b=0;for(let g=0;g<s;++g){let I=o[r[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<e|I,p+=e,p>=8&&(p-=8,c[b++]=255&h>>p)}if(p>=e||255&h<<8-p)throw new SyntaxError("Unexpected end of data");return c}function Nr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,p=0;for(let h=0;h<r.length;++h)for(p=p<<8|r[h],c+=8;c>e;)c-=e,s+=t[o&p>>c];if(c!==0&&(s+=t[o&p<<e-c]),n)for(;s.length*e&7;)s+="=";return s}function f({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Q({prefix:t,name:r,encode(o){return Nr(o,n,e)},decode(o){return Rr(o,n,e,r)}})}var w=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fr=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};v(kt,{base10:()=>Mr});var Mr=V({prefix:"9",name:"base10",alphabet:"0123456789"});var zt={};v(zt,{base16:()=>Lr,base16upper:()=>kr});var Lr=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),kr=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ot={};v(Ot,{base2:()=>zr});var zr=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vt={};v(Vt,{base256emoji:()=>$r});var Ne=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}"),Or=Ne.reduce((r,t,e)=>(r[e]=t,r),[]),Vr=Ne.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Br(r){return r.reduce((t,e)=>(t+=Or[e],t),"")}function _r(r){let t=[];for(let e of r){let n=Vr[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var $r=Q({prefix:"\u{1F680}",name:"base256emoji",encode:Br,decode:_r});var Bt={};v(Bt,{base32:()=>L,base32hex:()=>Wr,base32hexpad:()=>Kr,base32hexpadupper:()=>Jr,base32hexupper:()=>Hr,base32pad:()=>qr,base32padupper:()=>Gr,base32upper:()=>jr,base32z:()=>Xr});var L=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jr=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qr=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gr=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wr=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hr=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Kr=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Jr=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xr=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _t={};v(_t,{base36:()=>Qr,base36upper:()=>Yr});var Qr=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yr=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $t={};v($t,{base64:()=>Zr,base64pad:()=>tn,base64url:()=>en,base64urlpad:()=>rn});var Zr=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tn=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),en=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rn=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jt={};v(jt,{base8:()=>nn});var nn=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qt={};v(qt,{identity:()=>on});var on=Q({prefix:"\0",name:"identity",encode:r=>Ce(r),decode:r=>Pe(r)});var Ho=new TextEncoder,Ko=new TextDecoder;var Wt={};v(Wt,{identity:()=>xt});var an=Le,Fe=128,pn=127,un=~pn,dn=Math.pow(2,31);function Le(r,t,e){t=t||[],e=e||0;for(var n=e;r>=dn;)t[e++]=r&255|Fe,r/=128;for(;r&un;)t[e++]=r&255|Fe,r>>>=7;return t[e]=r|0,Le.bytes=e-n+1,t}var ln=Gt,hn=128,Me=127;function Gt(r,n){var e=0,n=n||0,o=0,s=n,c,p=r.length;do{if(s>=p)throw Gt.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&Me)<<o:(c&Me)*Math.pow(2,o),o+=7}while(c>=hn);return Gt.bytes=s-n,e}var fn=Math.pow(2,7),mn=Math.pow(2,14),gn=Math.pow(2,21),wn=Math.pow(2,28),xn=Math.pow(2,35),bn=Math.pow(2,42),yn=Math.pow(2,49),En=Math.pow(2,56),vn=Math.pow(2,63),Sn=function(r){return r<fn?1:r<mn?2:r<gn?3:r<wn?4:r<xn?5:r<bn?6:r<yn?7:r<En?8:r<vn?9:10},An={encode:an,decode:ln,encodingLength:Sn},In=An,it=In;function ct(r,t=0){return[it.decode(r,t),it.decode.bytes]}function Y(r,t,e=0){return it.encode(r,t,e),t}function Z(r){return it.encodingLength(r)}function B(r,t){let e=t.byteLength,n=Z(r),o=n+Z(e),s=new Uint8Array(o+e);return Y(r,s,0),Y(e,s,n),s.set(t,o),new tt(r,e,t,s)}function G(r){let t=M(r),[e,n]=ct(t),[o,s]=ct(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new tt(e,o,c,t)}function ke(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Te(r.bytes,e.bytes)}}var tt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ze=0,Tn="identity",Oe=M;function Pn(r){return B(ze,Oe(r))}var xt={code:ze,name:Tn,encode:Oe,digest:Pn};var Jt={};v(Jt,{sha256:()=>bt,sha512:()=>Cn});function Kt({name:r,code:t,encode:e}){return new Ht(r,t,e)}var Ht=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?B(this.code,e):e.then(n=>B(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Be(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var bt=Kt({name:"sha2-256",code:18,encode:Be("SHA-256")}),Cn=Kt({name:"sha2-512",code:19,encode:Be("SHA-512")});function _e(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Un(e,Xt(r),t??w.encoder);default:return Rn(e,Xt(r),t??L.encoder)}}var $e=new WeakMap;function Xt(r){let t=$e.get(r);if(t==null){let e=new Map;return $e.set(r,e),e}return t}var C=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!==at)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Nn)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=B(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&&ke(t.multihash,n.multihash)}toString(t){return _e(this,t)}toJSON(){return{"/":_e(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:c}=e;return new r(n,o,s,c??je(n,o,s.bytes))}else if(e[Fn]===!0){let{version:n,multihash:o,code:s}=e,c=G(o);return r.create(n,s,c)}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!==at)throw new Error(`Version 0 CID must use dag-pb (code: ${at}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=je(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,at,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=M(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new tt(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[I,z]=ct(t.subarray(e));return e+=z,I},o=n(),s=at;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,p=n(),h=n(),b=e+h,g=b-c;return{version:o,codec:s,multihashCode:p,digestSize:h,multihashSize:g,size:b}}static parse(t,e){let[n,o]=Dn(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 Xt(s).set(n,t),s}};function Dn(r,t){switch(r[0]){case"Q":{let e=t??w;return[w.prefix,e.decode(`${w.prefix}${r}`)]}case w.prefix:{let e=t??w;return[w.prefix,e.decode(r)]}case L.prefix:{let e=t??L;return[L.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Un(r,t,e){let{prefix:n}=e;if(n!==w.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 Rn(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 at=112,Nn=18;function je(r,t,e){let n=Z(r),o=n+Z(t),s=new Uint8Array(o+e.byteLength);return Y(r,s,0),Y(t,s,n),s.set(e,o),s}var Fn=Symbol.for("@ipld/js-cid/CID");var _={...qt,...Ot,...jt,...kt,...zt,...Bt,..._t,...Lt,...$t,...Vt},ms={...Jt,...Wt};function pt(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}var Mn=Symbol.for("nodejs.util.inspect.custom"),qe=Object.values(_).map(r=>r.decoder).reduce((r,t)=>r.or(t),_.identity.decoder),Ge=114,We=36,He=37,ut=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ae]=!0;toString(){return this.string==null&&(this.string=w.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C.createV1(Ge,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return pt(this.multihash.bytes,t);if(typeof t=="string")return Qt(t).equals(this);if(t?.multihash?.bytes!=null)return pt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Mn](){return`PeerId(${this.toString()})`}},dt=class extends ut{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},lt=class extends ut{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},ht=class extends ut{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Qt(r,t){if(t=t??qe,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=G(w.decode(`z${r}`));return r.startsWith("12D")?new lt({multihash:e}):r.startsWith("16U")?new ht({multihash:e}):new dt({multihash:e})}return Ln(qe.decode(r))}function Ln(r){try{let t=G(r);if(t.code===xt.code){if(t.digest.length===We)return new lt({multihash:t});if(t.digest.length===He)return new ht({multihash:t})}if(t.code===bt.code)return new dt({multihash:t})}catch{return kn(C.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function kn(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ge)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===bt.code)return new dt({multihash:r.multihash});if(t.code===xt.code){if(t.digest.length===We)return new lt({multihash:r.multihash});if(t.digest.length===He)return new ht({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function et(r=0){return new Uint8Array(r)}function Je(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ke=Je("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yt=Je("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=et(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),zn={utf8:Ke,"utf-8":Ke,hex:_.base16,latin1:Yt,ascii:Yt,binary:Yt,..._},yt=zn;function E(r,t="utf8"){let e=yt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var On=Math.pow(2,7),Vn=Math.pow(2,14),Bn=Math.pow(2,21),Zt=Math.pow(2,28),te=Math.pow(2,35),ee=Math.pow(2,42),re=Math.pow(2,49),d=128,x=127;function N(r){if(r<On)return 1;if(r<Vn)return 2;if(r<Bn)return 3;if(r<Zt)return 4;if(r<te)return 5;if(r<ee)return 6;if(r<re)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function _n(r,t,e=0){switch(N(r)){case 8:t[e++]=r&255|d,r/=128;case 7:t[e++]=r&255|d,r/=128;case 6:t[e++]=r&255|d,r/=128;case 5:t[e++]=r&255|d,r/=128;case 4:t[e++]=r&255|d,r>>>=7;case 3:t[e++]=r&255|d,r>>>=7;case 2:t[e++]=r&255|d,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function $n(r,t,e=0){switch(N(r)){case 8:t.set(e++,r&255|d),r/=128;case 7:t.set(e++,r&255|d),r/=128;case 6:t.set(e++,r&255|d),r/=128;case 5:t.set(e++,r&255|d),r/=128;case 4:t.set(e++,r&255|d),r>>>=7;case 3:t.set(e++,r&255|d),r>>>=7;case 2:t.set(e++,r&255|d),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&x,e<d||(e=r[t+1],n+=(e&x)<<7,e<d)||(e=r[t+2],n+=(e&x)<<14,e<d)||(e=r[t+3],n+=(e&x)<<21,e<d)||(e=r[t+4],n+=(e&x)*Zt,e<d)||(e=r[t+5],n+=(e&x)*te,e<d)||(e=r[t+6],n+=(e&x)*ee,e<d)||(e=r[t+7],n+=(e&x)*re,e<d))return n;throw new RangeError("Could not decode varint")}function qn(r,t){let e=r.get(t),n=0;if(n+=e&x,e<d||(e=r.get(t+1),n+=(e&x)<<7,e<d)||(e=r.get(t+2),n+=(e&x)<<14,e<d)||(e=r.get(t+3),n+=(e&x)<<21,e<d)||(e=r.get(t+4),n+=(e&x)*Zt,e<d)||(e=r.get(t+5),n+=(e&x)*te,e<d)||(e=r.get(t+6),n+=(e&x)*ee,e<d)||(e=r.get(t+7),n+=(e&x)*re,e<d))return n;throw new RangeError("Could not decode varint")}function rt(r,t,e=0){return t==null&&(t=et(N(r))),t instanceof Uint8Array?_n(r,t,e):$n(r,t,e)}function H(r,t=0){return r instanceof Uint8Array?jn(r,t):qn(r,t)}function k(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=et(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Et=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,c=0,p=this.peekChar();if(p===void 0)return;let h=p==="0",b=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let z=Number.parseInt(I,t);if(!Number.isNaN(z))return z});if(g===void 0)break;if(s*=t,s+=g,s>b||(c+=1,e!==void 0&&c>e))return}if(c!==0)return!n&&h&&c>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 c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return e[o]=c[0],e[o+1]=c[1],e[o+2]=c[2],e[o+3]=c[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),c=16-(n+2),[p]=t(s.subarray(0,c));return e.set(s.subarray(0,p),16-p),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Qe=45,Gn=15,nt=new Et;function ne(r){if(!(r.length>Gn))return nt.new(r).parseWith(()=>nt.readIPv4Addr())}function oe(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Qe))return nt.new(r).parseWith(()=>nt.readIPv6Addr())}function vt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Qe))return nt.new(r).parseWith(()=>nt.readIPAddr())}var Hs=parseInt("0xFFFF",16),Ks=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function se(r,t="utf8"){let e=yt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function tr(r){return!!ne(r)}function er(r){return!!oe(r)}function St(r){return!!vt(r)}var rr=tr,Xn=er,ie=function(r){let t=0;if(r=r.toString().trim(),rr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Xn(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=rr(e[n]),c;s&&(c=ie(e[n]),e[n]=E(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,E(c.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")},nr=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 ot={},ce={},Yn=[[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"]];Yn.forEach(r=>{let t=Zn(...r);ce[t.code]=t,ot[t.name]=t});function Zn(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function l(r){if(typeof r=="number"){if(ce[r]!=null)return ce[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ot[r]!=null)return ot[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Fi=l("ip4"),Mi=l("ip6"),Li=l("ipcidr");function de(r,t){switch(l(r).code){case 4:case 41:return eo(t);case 42:return ue(t);case 6:case 273:case 33:case 132:return ir(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ue(t);case 421:return so(t);case 444:return sr(t);case 445:return sr(t);case 466:return oo(t);case 481:return globalThis.encodeURIComponent(ue(t));default:return E(t,"base16")}}function le(r,t){switch(l(r).code){case 4:return or(t);case 41:return or(t);case 42:return pe(t);case 6:case 273:case 33:case 132:return he(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pe(t);case 421:return ro(t);case 444:return io(t);case 445:return co(t);case 466:return no(t);case 481:return pe(globalThis.decodeURIComponent(t));default:return se(t,"base16")}}var ae=Object.values(_).map(r=>r.decoder),to=function(){let r=ae[0].or(ae[1]);return ae.slice(2).forEach(t=>r=r.or(t)),r}();function or(r){if(!St(r))throw new Error("invalid ip address");return ie(r)}function eo(r){let t=nr(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!St(t))throw new Error("invalid ip address");return t}function he(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function ir(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function pe(r){let t=se(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function ue(r){let t=H(r);if(r=r.slice(N(t)),r.length!==t)throw new Error("inconsistent lengths");return E(r)}function ro(r){let t;r[0]==="Q"||r[0]==="1"?t=G(w.decode(`z${r}`)).bytes:t=C.parse(r).multihash.bytes;let e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function no(r){let t=to.decode(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function oo(r){let t=H(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+E(e,"base64url")}function so(r){let t=H(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return E(e,"base58btc")}function io(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=L.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=he(n);return k([e,o],e.length+o.length)}function co(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=L.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=he(n);return k([e,o],e.length+o.length)}function sr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=E(t,"base32"),o=ir(e);return`${n}:${o}`}function cr(r){r=fe(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 c=o[s],p=l(c);if(p.size===0){t.push([p.code]),e.push([p.code]);continue}if(s++,s>=o.length)throw pr("invalid address: "+r);if(p.path===!0){n=fe(o.slice(s).join("/")),t.push([p.code,le(p.code,n)]),e.push([p.code,n]);break}let h=le(p.code,o[s]);t.push([p.code,h]),e.push([p.code,de(p.code,h)])}return{string:ar(e),bytes:ge(t),tuples:t,stringTuples:e,path:n}}function me(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=H(r,o),c=N(s),p=l(s),h=ao(p,r.slice(o+c));if(h===0){t.push([s]),e.push([s]),o+=c;continue}let b=r.slice(o+c,o+c+h);if(o+=h+c,o>r.length)throw pr("Invalid address Uint8Array: "+E(r,"base16"));t.push([s,b]);let g=de(s,b);if(e.push([s,g]),p.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:ar(e),tuples:t,stringTuples:e,path:n}}function ar(r){let t=[];return r.map(e=>{let n=l(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),fe(t.join("/"))}function ge(r){return k(r.map(t=>{let e=l(t[0]),n=Uint8Array.from(rt(e.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function ao(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=H(t instanceof Uint8Array?t:Uint8Array.from(t));return e+N(e)}}function fe(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function pr(r){return new Error("Error parsing address: "+r)}var po=Symbol.for("nodejs.util.inspect.custom"),we=Symbol.for("@multiformats/js-multiaddr/multiaddr"),uo=[l("dns").code,l("dns4").code,l("dns6").code,l("dnsaddr").code],At=class r{bytes;#t;#e;#r;#n;[we]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=me(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=cr(t)}else if(dr(t))e=me(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="",c=l("tcp"),p=l("udp"),h=l("ip4"),b=l("ip6"),g=l("dns6"),I=l("ip6zone");for(let[S,u]of this.stringTuples())S===I.code&&(s=`%${u??""}`),uo.includes(S)&&(e=c.name,o=443,n=`${u??""}${s}`,t=S===g.code?6:4),(S===c.code||S===p.code)&&(e=l(S).name,o=parseInt(u??"")),(S===h.code||S===b.code)&&(e=l(S).name,n=`${u??""}${s}`,t=S===b.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({},l(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>l(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(ge(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ot.p2p.code&&t.push([n,o]),n===ot["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?E(w.decode(`z${n}`),"base58btc"):E(C.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=ur.get(e.name);if(n==null)throw new mt(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>$(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)}[po](){return`Multiaddr(${this.#t})`}};var ur=new Map;function dr(r){return!!r?.[we]}function $(r){return new At(r)}var lo=i("dns4"),ho=i("dns6"),fo=i("dnsaddr"),J=m(i("dns"),fo,lo,ho),Pt=m(i("ip4"),i("ip6")),st=m(a(Pt,i("tcp")),a(J,i("tcp"))),Ct=a(Pt,i("udp")),mo=a(Ct,i("utp")),go=a(Ct,i("quic")),wo=a(Ct,i("quic-v1")),xe=m(a(st,i("ws")),a(J,i("ws"))),It=m(a(xe,i("p2p")),xe),be=m(a(st,i("wss")),a(J,i("wss")),a(st,i("tls"),i("ws")),a(J,i("tls"),i("ws"))),Tt=m(a(be,i("p2p")),be),ye=m(a(st,i("http")),a(Pt,i("http")),a(J,i("http"))),Ee=m(a(st,i("https")),a(Pt,i("https")),a(J,i("https"))),lr=a(Ct,i("webrtc-direct"),i("certhash")),mr=m(a(lr,i("p2p")),lr),hr=a(wo,i("webtransport"),i("certhash"),i("certhash")),gr=m(a(hr,i("p2p")),hr),wr=m(a(It,i("p2p-webrtc-star"),i("p2p")),a(Tt,i("p2p-webrtc-star"),i("p2p")),a(It,i("p2p-webrtc-star")),a(Tt,i("p2p-webrtc-star"))),cc=m(a(It,i("p2p-websocket-star"),i("p2p")),a(Tt,i("p2p-websocket-star"),i("p2p")),a(It,i("p2p-websocket-star")),a(Tt,i("p2p-websocket-star"))),xr=m(a(ye,i("p2p-webrtc-direct"),i("p2p")),a(Ee,i("p2p-webrtc-direct"),i("p2p")),a(ye,i("p2p-webrtc-direct")),a(Ee,i("p2p-webrtc-direct"))),X=m(xe,be,ye,Ee,wr,xr,st,mo,go,J,mr,gr),ac=m(a(X,i("p2p-stardust"),i("p2p")),a(X,i("p2p-stardust"))),j=m(a(X,i("p2p")),wr,xr,mr,gr,i("p2p")),fr=m(a(j,i("p2p-circuit"),j),a(j,i("p2p-circuit")),a(i("p2p-circuit"),j),a(X,i("p2p-circuit")),a(i("p2p-circuit"),X),i("p2p-circuit")),br=()=>m(a(fr,br),fr),K=br(),yr=m(a(K,j,K),a(j,K),a(K,j),K,j);var pc=m(a(K,i("webrtc"),i("p2p")),a(K,i("webrtc")),a(X,i("webrtc"),i("p2p")),a(X,i("webrtc")),i("webrtc"));function Er(r){function t(e){let n;try{n=$(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function a(...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:Er(t),partialMatch:t}}function m(...r){function t(n){let o=null;return r.some(s=>{let c=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return c!=null?(o=c,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Er(t),partialMatch:t}}function i(r){let t=r;function e(o){let s;try{s=$(o)}catch{return!1}let c=s.protoNames();return c.length===1&&c[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 xo="bootstrap",bo=50,yo=12e4,Eo=1e3,ve=class extends gt{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??Eo,this.list=[];for(let n of e.list){if(!yr.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let c={id:Qt(s),multiaddrs:[o]};this.list.push(c)}this._init=e}[Se]=this;[Symbol.toStringTag]="@libp2p/bootstrap";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??xo]:{value:this._init.tagValue??bo,ttl:this._init.tagTTL??yo}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function vo(r){return t=>new ve(t,r)}return Tr(So);})();
3
3
  return Libp2PBootstrap}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/bootstrap",
3
- "version": "10.0.24-352699ab5",
3
+ "version": "10.0.24-4bd8e4f79",
4
4
  "description": "Peer discovery via a list of bootstrap peers",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme",
@@ -54,15 +54,15 @@
54
54
  "test:electron-main": "aegir test -t electron-main"
55
55
  },
56
56
  "dependencies": {
57
- "@libp2p/interface": "1.4.0-352699ab5",
58
- "@libp2p/peer-id": "4.1.2-352699ab5",
57
+ "@libp2p/interface": "1.4.0-4bd8e4f79",
58
+ "@libp2p/peer-id": "4.1.2-4bd8e4f79",
59
59
  "@multiformats/mafmt": "^12.1.6",
60
60
  "@multiformats/multiaddr": "^12.2.3"
61
61
  },
62
62
  "devDependencies": {
63
- "@libp2p/interface-compliance-tests": "5.4.5-352699ab5",
64
- "@libp2p/logger": "4.0.13-352699ab5",
65
- "aegir": "^42.2.11",
63
+ "@libp2p/interface-compliance-tests": "5.4.5-4bd8e4f79",
64
+ "@libp2p/logger": "4.0.13-4bd8e4f79",
65
+ "aegir": "^43.0.1",
66
66
  "sinon-ts": "^2.0.0"
67
67
  },
68
68
  "sideEffects": false