@libp2p/memory 1.1.6-f1de46607 → 1.1.7

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/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # @libp2p/tcp
2
-
3
1
  # @libp2p/memory
4
2
 
5
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMemory = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PMemory=(()=>{var je=Object.defineProperty;var kr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var Lr=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var t in e)je(r,t,{get:e[t],enumerable:!0})},zr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fr(e))!Lr.call(r,o)&&o!==t&&je(r,o,{get:()=>e[o],enumerable:!(n=kr(e,o))||n.enumerable});return r};var $r=r=>zr(je({},"__esModule",{value:!0}),r);var Lo={};k(Lo,{memory:()=>Fo});var Bt=Symbol.for("@libp2p/transport");var Vt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Vt||(Vt={}));var H=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}};var we=class extends Error{static name="ListenError";constructor(e="Listen error"){super(e),this.name="ListenError"}};var ge=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Rt=Symbol.for("@libp2p/service-capabilities"),Ro=Symbol.for("@libp2p/service-dependencies");var be=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",w=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let N=Number.parseInt(I,e);if(!Number.isNaN(N))return N});if(g===void 0)break;if(s*=e,s+=g,s>w||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[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];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ot=45,Vr=15,X=new be;function qe(r){if(!(r.length>Vr))return X.new(r).parseWith(()=>X.readIPv4Addr())}function We(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ot))return X.new(r).parseWith(()=>X.readIPv6Addr())}function ye(r,e=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Ot)return;let t=X.new(r).parseWith(()=>X.readIPAddr());if(t)return e&&t.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,t[0],t[1],t[2],t[3]]):t}function Ee(r){return!!qe(r)}function ve(r){return!!We(r)}function Ie(r){return!!ye(r)}var Xe={};k(Xe,{base58btc:()=>C,base58flickr:()=>qr});var hs=new Uint8Array(0);function _t(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function V(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 jt(r){return new TextEncoder().encode(r)}function qt(r){return new TextDecoder().decode(r)}function Br(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,c=r.charAt(0),w=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function I(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var E=0,p=0,v=0,D=d.length;v!==D&&d[v]===0;)v++,E++;for(var A=(D-v)*g+1>>>0,M=new Uint8Array(A);v!==D;){for(var F=d[v],_=0,L=A-1;(F!==0||_<p)&&L!==-1;L--,_++)F+=256*M[L]>>>0,M[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");p=_,v++}for(var $=A-p;$!==A&&M[$]===0;)$++;for(var xe=c.repeat(E);$<A;++$)xe+=r.charAt(M[$]);return xe}function N(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var E=0;if(d[E]!==" "){for(var p=0,v=0;d[E]===c;)p++,E++;for(var D=(d.length-E)*w+1>>>0,A=new Uint8Array(D);d[E];){var M=t[d.charCodeAt(E)];if(M===255)return;for(var F=0,_=D-1;(M!==0||F<v)&&_!==-1;_--,F++)M+=a*A[_]>>>0,A[_]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");v=F,E++}if(d[E]!==" "){for(var L=D-v;L!==D&&A[L]===0;)L++;for(var $=new Uint8Array(p+(D-L)),xe=p;L!==D;)$[xe++]=A[L++];return $}}}function S(d){var E=N(d);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:I,decodeUnsafe:N,decode:S}}var Rr=Br,Or=Rr,Gt=Or;var Ge=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Qe=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Qt(this,e)}},Je=class{decoders;constructor(e){this.decoders=e}or(e){return Qt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qt(r,e){return new Je({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var He=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ge(e,t,n),this.decoder=new Qe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function K({name:r,prefix:e,encode:t,decode:n}){return new He(r,e,t,n)}function j({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Gt(t,r);return K({prefix:e,name:r,encode:n,decode:s=>V(o(s))})}function _r(r,e,t,n){let o={};for(let g=0;g<e.length;++g)o[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,w=0;for(let g=0;g<s;++g){let I=o[r[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|I,a+=t,a>=8&&(a-=8,i[w++]=255&c>>a)}if(a>=t||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function jr(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;(s.length*t&7)!==0;)s+="=";return s}function y({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return K({prefix:e,name:r,encode(o){return jr(o,n,t)},decode(o){return _r(o,n,t,r)}})}var C=j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qr=j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ze={};k(Ze,{base64:()=>Wr,base64pad:()=>Gr,base64url:()=>Ke,base64urlpad:()=>Qr});var Wr=y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gr=y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ke=y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qr=y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jr=r=>r.toString().split("/").slice(1),Z=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),u=r=>({match:e=>Z(t=>t===r).match(e),pattern:r}),G=()=>({match:r=>Z(e=>typeof e=="string").match(r),pattern:"{string}"}),ce=()=>({match:r=>Z(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),m=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{C.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ue=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Ke.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),f=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),P=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1},pattern:`or(${r.map(e=>e.pattern).join(", ")})`}),l=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e},pattern:`and(${r.map(e=>e.pattern).join(", ")})`});function b(...r){function e(o){let s=Jr(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function t(o){return e(o)!==!1}function n(o){let s=e(o);return s===!1?!1:s.length===0}return{matchers:r,matches:t,exactMatch:n}}var Hr=m(),Cs=b(Hr),Se=l(u("dns4"),G()),Ce=l(u("dns6"),G()),Pe=l(u("dnsaddr"),G()),et=l(u("dns"),G()),Ps=b(Se,f(m())),Ts=b(Ce,f(m())),Ds=b(Pe,f(m())),Us=b(P(et,Pe,Se,Ce),f(m())),Jt=l(u("ip4"),Z(Ee)),Ht=l(u("ip6"),Z(ve)),tt=P(Jt,Ht),B=P(tt,et,Se,Ce,Pe),Ns=b(P(tt,l(P(et,Pe,Se,Ce),f(m())))),Ms=b(Jt),ks=b(Ht),Fs=b(tt),rt=l(B,u("tcp"),ce()),le=l(B,u("udp"),ce()),Ls=b(l(rt,f(m()))),zs=b(le),nt=l(le,u("quic"),f(m())),Te=l(le,u("quic-v1"),f(m())),Xr=P(nt,Te),$s=b(nt),Vs=b(Te),Ye=P(B,rt,le,nt,Te),Xt=P(l(Ye,u("ws"),f(m()))),Bs=b(Xt),Kt=P(l(Ye,u("wss"),f(m())),l(Ye,u("tls"),f(l(u("sni"),G())),u("ws"),f(m()))),Rs=b(Kt),Zt=l(le,u("webrtc-direct"),f(ue()),f(ue()),f(m())),Os=b(Zt),Yt=l(Te,u("webtransport"),f(ue()),f(ue()),f(m())),_s=b(Yt),Ae=P(Xt,Kt,l(rt,f(m())),l(Xr,f(m())),l(B,f(m())),Zt,Yt,m()),js=b(Ae),Kr=l(Ae,u("p2p-circuit"),m()),qs=b(Kr),Zr=P(l(Ae,u("p2p-circuit"),u("webrtc"),f(m())),l(Ae,u("webrtc"),f(m())),l(u("webrtc"),f(m()))),Ws=b(Zr),Yr=P(l(B,u("tcp"),ce(),u("http"),f(m())),l(B,u("http"),f(m()))),Gs=b(Yr),en=P(l(B,u("tcp"),P(l(u("443"),u("http")),l(ce(),u("https"))),f(m())),l(B,u("tls"),u("http"),f(m())),l(B,u("https"),f(m()))),Qs=b(en),tn=P(l(u("memory"),G(),f(m()))),er=b(tn);function Y(r=0){return new Uint8Array(r)}var rn=Math.pow(2,7),nn=Math.pow(2,14),on=Math.pow(2,21),ot=Math.pow(2,28),st=Math.pow(2,35),it=Math.pow(2,42),at=Math.pow(2,49),h=128,T=127;function z(r){if(r<rn)return 1;if(r<nn)return 2;if(r<on)return 3;if(r<ot)return 4;if(r<st)return 5;if(r<it)return 6;if(r<at)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function sn(r,e,t=0){switch(z(r)){case 8:e[t++]=r&255|h,r/=128;case 7:e[t++]=r&255|h,r/=128;case 6:e[t++]=r&255|h,r/=128;case 5:e[t++]=r&255|h,r/=128;case 4:e[t++]=r&255|h,r>>>=7;case 3:e[t++]=r&255|h,r>>>=7;case 2:e[t++]=r&255|h,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function an(r,e,t=0){switch(z(r)){case 8:e.set(t++,r&255|h),r/=128;case 7:e.set(t++,r&255|h),r/=128;case 6:e.set(t++,r&255|h),r/=128;case 5:e.set(t++,r&255|h),r/=128;case 4:e.set(t++,r&255|h),r>>>=7;case 3:e.set(t++,r&255|h),r>>>=7;case 2:e.set(t++,r&255|h),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function cn(r,e){let t=r[e],n=0;if(n+=t&T,t<h||(t=r[e+1],n+=(t&T)<<7,t<h)||(t=r[e+2],n+=(t&T)<<14,t<h)||(t=r[e+3],n+=(t&T)<<21,t<h)||(t=r[e+4],n+=(t&T)*ot,t<h)||(t=r[e+5],n+=(t&T)*st,t<h)||(t=r[e+6],n+=(t&T)*it,t<h)||(t=r[e+7],n+=(t&T)*at,t<h))return n;throw new RangeError("Could not decode varint")}function un(r,e){let t=r.get(e),n=0;if(n+=t&T,t<h||(t=r.get(e+1),n+=(t&T)<<7,t<h)||(t=r.get(e+2),n+=(t&T)<<14,t<h)||(t=r.get(e+3),n+=(t&T)<<21,t<h)||(t=r.get(e+4),n+=(t&T)*ot,t<h)||(t=r.get(e+5),n+=(t&T)*st,t<h)||(t=r.get(e+6),n+=(t&T)*it,t<h)||(t=r.get(e+7),n+=(t&T)*at,t<h))return n;throw new RangeError("Could not decode varint")}function ee(r,e,t=0){return e==null&&(e=Y(z(r))),e instanceof Uint8Array?sn(r,e,t):an(r,e,t)}function Q(r,e=0){return r instanceof Uint8Array?cn(r,e):un(r,e)}function R(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Y(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var ct={};k(ct,{base10:()=>ln});var ln=j({prefix:"9",name:"base10",alphabet:"0123456789"});var ut={};k(ut,{base16:()=>pn,base16upper:()=>dn});var pn=y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dn=y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lt={};k(lt,{base2:()=>fn});var fn=y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pt={};k(pt,{base256emoji:()=>gn});var rr=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}"),hn=rr.reduce((r,e,t)=>(r[t]=e,r),[]),mn=rr.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function xn(r){return r.reduce((e,t)=>(e+=hn[t],e),"")}function wn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=mn[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var gn=K({prefix:"\u{1F680}",name:"base256emoji",encode:xn,decode:wn});var dt={};k(dt,{base32:()=>O,base32hex:()=>vn,base32hexpad:()=>An,base32hexpadupper:()=>Sn,base32hexupper:()=>In,base32pad:()=>yn,base32padupper:()=>En,base32upper:()=>bn,base32z:()=>Cn});var O=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bn=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yn=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),En=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vn=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),In=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),An=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sn=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cn=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ft={};k(ft,{base36:()=>pe,base36upper:()=>Pn});var pe=j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pn=j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ht={};k(ht,{base8:()=>Tn});var Tn=y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mt={};k(mt,{identity:()=>Dn});var Dn=K({prefix:"\0",name:"identity",encode:r=>qt(r),decode:r=>jt(r)});var pi=new TextEncoder,di=new TextDecoder;var wt={};k(wt,{identity:()=>Zn});var Mn=sr,nr=128,kn=127,Fn=~kn,Ln=Math.pow(2,31);function sr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ln;)e[t++]=r&255|nr,r/=128;for(;r&Fn;)e[t++]=r&255|nr,r>>>=7;return e[t]=r|0,sr.bytes=t-n+1,e}var zn=xt,$n=128,or=127;function xt(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw xt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&or)<<o:(i&or)*Math.pow(2,o),o+=7}while(i>=$n);return xt.bytes=s-n,t}var Vn=Math.pow(2,7),Bn=Math.pow(2,14),Rn=Math.pow(2,21),On=Math.pow(2,28),_n=Math.pow(2,35),jn=Math.pow(2,42),qn=Math.pow(2,49),Wn=Math.pow(2,56),Gn=Math.pow(2,63),Qn=function(r){return r<Vn?1:r<Bn?2:r<Rn?3:r<On?4:r<_n?5:r<jn?6:r<qn?7:r<Wn?8:r<Gn?9:10},Jn={encode:Mn,decode:zn,encodingLength:Qn},Hn=Jn,de=Hn;function fe(r,e=0){return[de.decode(r,e),de.decode.bytes]}function te(r,e,t=0){return de.encode(r,e,t),e}function re(r){return de.encodingLength(r)}function J(r,e){let t=e.byteLength,n=re(r),o=n+re(t),s=new Uint8Array(o+t);return te(r,s,0),te(t,s,n),s.set(e,o),new ne(r,t,e,s)}function Ue(r){let e=V(r),[t,n]=fe(e),[o,s]=fe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ne(t,o,i,e)}function ir(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&_t(r.bytes,t.bytes)}}var ne=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ar=0,Xn="identity",cr=V;function Kn(r){return J(ar,cr(r))}var Zn={code:ar,name:Xn,encode:cr,digest:Kn};var yt={};k(yt,{sha256:()=>Yn,sha512:()=>eo});function bt({name:r,code:e,encode:t}){return new gt(r,e,t)}var gt=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?J(this.code,t):t.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};function lr(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Yn=bt({name:"sha2-256",code:18,encode:lr("SHA-256")}),eo=bt({name:"sha2-512",code:19,encode:lr("SHA-512")});function pr(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return ro(t,Et(r),e??C.encoder);default:return no(t,Et(r),e??O.encoder)}}var dr=new WeakMap;function Et(r){let e=dr.get(r);if(e==null){let t=new Map;return dr.set(r,t),t}return e}var q=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==oo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:e,digest:t}=this.multihash,n=J(e,t);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(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ir(e.multihash,n.multihash)}toString(e){return pr(this,e)}toJSON(){return{"/":pr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??fr(n,o,s.bytes))}else if(t[so]===!0){let{version:n,multihash:o,code:s}=t,i=Ue(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=fr(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,he,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=V(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new ne(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[I,N]=fe(e.subarray(t));return t+=N,I},o=n(),s=he;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),w=t+c,g=w-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:g,size:w}}static parse(e,t){let[n,o]=to(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Et(s).set(n,e),s}};function to(r,e){switch(r[0]){case"Q":{let t=e??C;return[C.prefix,t.decode(`${C.prefix}${r}`)]}case C.prefix:{let t=e??C;return[C.prefix,t.decode(r)]}case O.prefix:{let t=e??O;return[O.prefix,t.decode(r)]}case pe.prefix:{let t=e??pe;return[pe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function ro(r,e,t){let{prefix:n}=t;if(n!==C.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function no(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var he=112,oo=18;function fr(r,e,t){let n=re(r),o=n+re(e),s=new Uint8Array(o+t.byteLength);return te(r,s,0),te(e,s,n),s.set(t,o),s}var so=Symbol.for("@ipld/js-cid/CID");var me={...mt,...lt,...ht,...ct,...ut,...dt,...ft,...Xe,...Ze,...pt},Fi={...yt,...wt};function mr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var hr=mr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vt=mr("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Y(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),io={utf8:hr,"utf-8":hr,hex:me.base16,latin1:vt,ascii:vt,binary:vt,...me},Ne=io;function U(r,e="utf8"){let t=Ne[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Qi=parseInt("0xFFFF",16),Ji=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Me(r,e="utf8"){let t=Ne[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var gr=Ee,po=ve,It=function(r){let e=0;if(r=r.toString().trim(),gr(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(po(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=gr(t[n]),i;s&&(i=It(t[n]),t[n]=U(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,U(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},br=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var se={},At={},ho=[[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"]];ho.forEach(r=>{let e=mo(...r);At[e.code]=e,se[e.name]=e});function mo(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function x(r){if(typeof r=="number"){if(At[r]!=null)return At[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(se[r]!=null)return se[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Na=x("ip4"),Ma=x("ip6"),ka=x("ipcidr");function Tt(r,e){switch(x(r).code){case 4:case 41:return wo(e);case 42:return Pt(e);case 43:return U(e,"base10");case 6:case 273:case 33:case 132:return vr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pt(e);case 421:return Eo(e);case 444:return Er(e);case 445:return Er(e);case 466:return yo(e);case 481:return globalThis.encodeURIComponent(Pt(e));default:return U(e,"base16")}}function Dt(r,e){switch(x(r).code){case 4:return yr(e);case 41:return yr(e);case 42:return Ct(e);case 43:return Me(e,"base10");case 6:case 273:case 33:case 132:return Ut(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ct(e);case 421:return go(e);case 444:return vo(e);case 445:return Io(e);case 466:return bo(e);case 481:return Ct(globalThis.decodeURIComponent(e));default:return Me(e,"base16")}}var St=Object.values(me).map(r=>r.decoder),xo=function(){let r=St[0].or(St[1]);return St.slice(2).forEach(e=>r=r.or(e)),r}();function yr(r){if(!Ie(r))throw new Error("invalid ip address");return It(r)}function wo(r){let e=br(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Ie(e))throw new Error("invalid ip address");return e}function Ut(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function vr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ct(r){let e=Me(r),t=Uint8Array.from(ee(e.length));return R([t,e],t.length+e.length)}function Pt(r){let e=Q(r);if(r=r.slice(z(e)),r.length!==e)throw new Error("inconsistent lengths");return U(r)}function go(r){let e;r[0]==="Q"||r[0]==="1"?e=Ue(C.decode(`z${r}`)).bytes:e=q.parse(r).multihash.bytes;let t=Uint8Array.from(ee(e.length));return R([t,e],t.length+e.length)}function bo(r){let e=xo.decode(r),t=Uint8Array.from(ee(e.length));return R([t,e],t.length+e.length)}function yo(r){let e=Q(r),t=r.slice(z(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+U(t,"base64url")}function Eo(r){let e=Q(r),t=r.slice(z(e));if(t.length!==e)throw new Error("inconsistent lengths");return U(t,"base58btc")}function vo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=O.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ut(n);return R([t,o],t.length+o.length)}function Io(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=O.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ut(n);return R([t,o],t.length+o.length)}function Er(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=U(e,"base32"),o=vr(t);return`${n}:${o}`}function Ir(r){r=Nt(r);let e=[],t=[],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=x(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(s++,s>=o.length)throw new ke("invalid address: "+r);if(a.path===!0){n=Nt(o.slice(s).join("/")),e.push([a.code,Dt(a.code,n)]),t.push([a.code,n]);break}let c=Dt(a.code,o[s]);e.push([a.code,c]),t.push([a.code,Tt(a.code,c)])}return{string:Ar(t),bytes:Fe(e),tuples:e,stringTuples:t,path:n}}function Mt(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=z(s),a=x(s),c=Ao(a,r.slice(o+i));if(c===0){e.push([s]),t.push([s]),o+=i;continue}let w=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new ke("Invalid address Uint8Array: "+U(r,"base16"));e.push([s,w]);let g=Tt(s,w);if(t.push([s,g]),a.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:Ar(t),tuples:e,stringTuples:t,path:n}}function Ar(r){let e=[];return r.map(t=>{let n=x(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Nt(e.join("/"))}function Fe(r){return R(r.map(e=>{let t=x(e[0]),n=Uint8Array.from(ee(t.code));return e.length>1&&e[1]!=null&&(n=R([n,e[1]])),n}))}function Ao(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Q(e instanceof Uint8Array?e:Uint8Array.from(e));return t+z(t)}}function Nt(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var ke=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};function Sr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var So=Symbol.for("nodejs.util.inspect.custom"),Ft=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Co=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],kt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Le=class r{bytes;#e;#t;#r;#n;[Ft]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Mt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Ir(e)}else if(Pr(e))t=Mt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=x("tcp"),a=x("udp"),c=x("ip4"),w=x("ip6"),g=x("dns6"),I=x("ip6zone");for(let[S,d]of this.stringTuples())S===I.code&&(s=`%${d??""}`),Co.includes(S)&&(t=i.name==="tcp"?"tcp":"udp",o=443,n=`${d??""}${s}`,e=S===g.code?6:4),(S===i.code||S===a.code)&&(t=x(S).name==="tcp"?"tcp":"udp",o=parseInt(d??"")),(S===c.code||S===w.code)&&(t=x(S).name==="tcp"?"tcp":"udp",n=`${d??""}${s}`,e=S===w.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},x(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>x(e).name)}tuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Fe(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===se.p2p.code&&e.push([n,o]),n===se["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?U(C.decode(`z${n}`),"base58btc"):U(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Sr(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Cr.get(t.name);if(n==null)throw new kt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>W(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[So](){return`Multiaddr(${this.#e})`}};var Cr=new Map;function Pr(r){return!!r?.[Ft]}function W(r){return new Le(r)}var Tr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Po=new WeakMap;function To({clearTimeout:r,setTimeout:e}={}){return(t,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Tr());let s,i,a,c=r??clearTimeout,w=()=>{c(s),a(Tr())},g=()=>{o&&o.removeEventListener("abort",w)},I=new Promise((N,S)=>{i=()=>{g(),N(n)},a=S,s=(e??setTimeout)(i,t)});return o&&o.addEventListener("abort",w,{once:!0}),Po.set(I,()=>{c(s),s=null,i()}),I}}var Do=To(),ze=Do;function Uo(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var Dr=Uo;function No(r){return r[Symbol.asyncIterator]!=null}function Mo(r,e){let t=0;if(No(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Dr(r),{value:o,done:s}=n.next();if(s===!0)return function*(){}();let i=e(o,t++);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield i;for(let c of n)yield a(c,t++)}()}var Lt=Mo;function $e(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ve=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},ie=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ve(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ve(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var zt=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function $t(r={}){return ko(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function ko(r,e){e=e??{};let t=e.onEnd,n=new ie,o,s,i,a=$e(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,v)=>{s=D=>{s=null,n.push(D);try{p(r(n))}catch(A){v(A)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$e()})}},w=p=>s!=null?s(p):(n.push(p),o),g=p=>(n=new ie,s!=null?s({error:p}):(n.push({error:p}),o)),I=p=>{if(i)return o;if(e?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return w({done:!1,value:p})},N=p=>i?o:(i=!0,p!=null?g(p):w({done:!0})),S=()=>(n=new ie,N(),{done:!0}),d=p=>(N(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:S,throw:d,push:I,end:N,get readableLength(){return n.size},onEmpty:async p=>{let v=p?.signal;if(v?.throwIfAborted(),n.isEmpty())return;let D,A;v!=null&&(D=new Promise((M,F)=>{A=()=>{F(new zt)},v.addEventListener("abort",A)}));try{await Promise.race([a.promise,D])}finally{A!=null&&v!=null&&v?.removeEventListener("abort",A)}}},t==null)return o;let E=o;return o={[Symbol.asyncIterator](){return this},next(){return E.next()},throw(p){return E.throw(p),t!=null&&(t(p),t=void 0),{done:!0}},return(){return E.return(),t!=null&&(t(),t=void 0),{done:!0}},push:I,end(p){return E.end(p),t!=null&&(t(p),t=void 0),o},get readableLength(){return E.readableLength},onEmpty:p=>E.onEmpty(p)},o}var Be=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function Ur(r,e,t){if(e==null)return r;if(e.aborted)return r.catch(()=>{}),Promise.reject(new Be(t?.errorMessage,t?.errorCode,t?.errorName));let n,o=new Be(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var ae=new Map,Re=class{components;init;connections;latency;constructor(e,t){this.components=e,this.init=t,this.connections=new Set,this.latency=t.latency??0}async dial(e,t){let n=$t(),o=$t(),s=this,i={source:async function*(){yield*Lt(o,async c=>(s.latency>0&&await ze(s.latency),c))}(),sink:async c=>{for await(let w of c)n.push(w)},close:async()=>{n.end(),this.connections.delete(i),i.timeline.close=Date.now(),o.end(),this.connections.delete(a),a.timeline.close=Date.now()},abort:c=>{n.end(c),this.connections.delete(i),i.timeline.close=Date.now(),o.end(c),this.connections.delete(a),a.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},a={source:async function*(){yield*Lt(n,async c=>(s.latency>0&&await ze(s.latency),c))}(),sink:async c=>{for await(let w of c)o.push(w)},close:async()=>{o.end(),this.connections.delete(a),a.timeline.close=Date.now(),n.end(),this.connections.delete(i),i.timeline.close=Date.now()},abort:c=>{o.end(c),this.connections.delete(a),a.timeline.close=Date.now(),n.end(c),this.connections.delete(i),i.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}-outgoing/p2p/${e}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")};return this.connections.add(i),this.connections.add(a),await Ur(ze(this.latency),t),this.init.onConnection(a),i}close(){[...this.connections].forEach(e=>{e.abort(new H("Memory Connection closed"))})}};var Nr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Mr=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=Nr[t[r]&63];return e};var Oe=class extends ge{listenAddr;connection;components;init;shutdownController;constructor(e,t){super(),this.components=e,this.init=t,this.shutdownController=new AbortController}async listen(e){let[[,t]]=e.stringTuples(),n=`/memory/${t??Mr()}`;if(t!=null&&ae.has(n))throw new we(`Memory address ${n} already in use`);this.connection=new Re(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=W(n),ae.set(n,this.connection),queueMicrotask(()=>{this.safeDispatchEvent("listening")})}onConnection(e){this.init.upgrader.upgradeInbound(e,{...this.init.upgraderOptions,signal:this.shutdownController.signal}).catch(t=>{e.abort(t)})}getAddrs(){return this.listenAddr==null?[]:[this.listenAddr]}updateAnnounceAddrs(){}async close(){this.connection?.close(),this.listenAddr!=null&&ae.delete(this.listenAddr.toString()),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var _e=class{components;init;constructor(e,t={}){this.components=e,this.init=t}[Bt]=!0;[Symbol.toStringTag]="@libp2p/memory";[Rt]=["@libp2p/transport"];async dial(e,t){t.signal.throwIfAborted();let n=ae.get(`${e.getPeerId()==null?e:e.decapsulate("/p2p")}`);if(n==null)throw new H(`No memory listener found at ${e}`);let o=await n.dial(this.components.peerId,t.signal);try{return t.signal.throwIfAborted(),await t.upgrader.upgradeOutbound(o,{...t,...this.init.upgraderOptions})}catch(s){throw o.abort(s),s}}createListener(e){return new Oe(this.components,{...e,...this.init})}listenFilter(e){return e.filter(t=>er.exactMatch(t))}dialFilter(e){return this.listenFilter(e)}};function Fo(r){return e=>new _e(e,r)}return $r(Lo);})();
2
+ "use strict";var Libp2PMemory=(()=>{var je=Object.defineProperty;var kr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var Lr=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var t in e)je(r,t,{get:e[t],enumerable:!0})},zr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fr(e))!Lr.call(r,o)&&o!==t&&je(r,o,{get:()=>e[o],enumerable:!(n=kr(e,o))||n.enumerable});return r};var $r=r=>zr(je({},"__esModule",{value:!0}),r);var Lo={};k(Lo,{memory:()=>Fo});var Bt=Symbol.for("@libp2p/transport");var Vt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Vt||(Vt={}));var H=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}};var we=class extends Error{static name="ListenError";constructor(e="Listen error"){super(e),this.name="ListenError"}};var ge=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Rt=Symbol.for("@libp2p/service-capabilities"),Ro=Symbol.for("@libp2p/service-dependencies");var be=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",w=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let N=Number.parseInt(I,e);if(!Number.isNaN(N))return N});if(g===void 0)break;if(s*=e,s+=g,s>w||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[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];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ot=45,Vr=15,X=new be;function qe(r){if(!(r.length>Vr))return X.new(r).parseWith(()=>X.readIPv4Addr())}function We(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ot))return X.new(r).parseWith(()=>X.readIPv6Addr())}function ye(r,e=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Ot)return;let t=X.new(r).parseWith(()=>X.readIPAddr());if(t)return e&&t.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,t[0],t[1],t[2],t[3]]):t}function Ee(r){return!!qe(r)}function ve(r){return!!We(r)}function Ie(r){return!!ye(r)}var Xe={};k(Xe,{base58btc:()=>C,base58flickr:()=>qr});var hs=new Uint8Array(0);function _t(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function V(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 jt(r){return new TextEncoder().encode(r)}function qt(r){return new TextDecoder().decode(r)}function Br(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,c=r.charAt(0),w=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function I(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var E=0,p=0,v=0,D=d.length;v!==D&&d[v]===0;)v++,E++;for(var A=(D-v)*g+1>>>0,M=new Uint8Array(A);v!==D;){for(var F=d[v],_=0,L=A-1;(F!==0||_<p)&&L!==-1;L--,_++)F+=256*M[L]>>>0,M[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");p=_,v++}for(var $=A-p;$!==A&&M[$]===0;)$++;for(var xe=c.repeat(E);$<A;++$)xe+=r.charAt(M[$]);return xe}function N(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var E=0;if(d[E]!==" "){for(var p=0,v=0;d[E]===c;)p++,E++;for(var D=(d.length-E)*w+1>>>0,A=new Uint8Array(D);d[E];){var M=t[d.charCodeAt(E)];if(M===255)return;for(var F=0,_=D-1;(M!==0||F<v)&&_!==-1;_--,F++)M+=a*A[_]>>>0,A[_]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");v=F,E++}if(d[E]!==" "){for(var L=D-v;L!==D&&A[L]===0;)L++;for(var $=new Uint8Array(p+(D-L)),xe=p;L!==D;)$[xe++]=A[L++];return $}}}function S(d){var E=N(d);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:I,decodeUnsafe:N,decode:S}}var Rr=Br,Or=Rr,Gt=Or;var Ge=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Qe=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Qt(this,e)}},Je=class{decoders;constructor(e){this.decoders=e}or(e){return Qt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qt(r,e){return new Je({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var He=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ge(e,t,n),this.decoder=new Qe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function K({name:r,prefix:e,encode:t,decode:n}){return new He(r,e,t,n)}function j({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Gt(t,r);return K({prefix:e,name:r,encode:n,decode:s=>V(o(s))})}function _r(r,e,t,n){let o={};for(let g=0;g<e.length;++g)o[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,w=0;for(let g=0;g<s;++g){let I=o[r[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|I,a+=t,a>=8&&(a-=8,i[w++]=255&c>>a)}if(a>=t||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function jr(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;(s.length*t&7)!==0;)s+="=";return s}function y({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return K({prefix:e,name:r,encode(o){return jr(o,n,t)},decode(o){return _r(o,n,t,r)}})}var C=j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qr=j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ze={};k(Ze,{base64:()=>Wr,base64pad:()=>Gr,base64url:()=>Ke,base64urlpad:()=>Qr});var Wr=y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gr=y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ke=y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qr=y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jr=r=>r.toString().split("/").slice(1),Z=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),u=r=>({match:e=>Z(t=>t===r).match(e),pattern:r}),G=()=>({match:r=>Z(e=>typeof e=="string").match(r),pattern:"{string}"}),Y=()=>({match:r=>Z(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),m=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{C.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ue=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Ke.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),f=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),P=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1},pattern:`or(${r.map(e=>e.pattern).join(", ")})`}),l=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e},pattern:`and(${r.map(e=>e.pattern).join(", ")})`});function b(...r){function e(o){let s=Jr(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function t(o){return e(o)!==!1}function n(o){let s=e(o);return s===!1?!1:s.length===0}return{matchers:r,matches:t,exactMatch:n}}var Hr=m(),Cs=b(Hr),Se=l(u("dns4"),G()),Ce=l(u("dns6"),G()),Pe=l(u("dnsaddr"),G()),et=l(u("dns"),G()),Ps=b(Se,f(m())),Ts=b(Ce,f(m())),Ds=b(Pe,f(m())),Us=b(P(et,Pe,Se,Ce),f(m())),Jt=l(u("ip4"),Z(Ee)),Ht=l(u("ip6"),Z(ve)),tt=P(Jt,Ht),B=P(tt,et,Se,Ce,Pe),Ns=b(P(tt,l(P(et,Pe,Se,Ce),f(m())))),Ms=b(Jt),ks=b(Ht),Fs=b(tt),rt=l(B,u("tcp"),Y()),le=l(B,u("udp"),Y()),Ls=b(l(rt,f(m()))),zs=b(le),nt=l(le,u("quic"),f(m())),Te=l(le,u("quic-v1"),f(m())),Xr=P(nt,Te),$s=b(nt),Vs=b(Te),Ye=P(B,rt,le,nt,Te),Xt=P(l(Ye,u("ws"),f(m()))),Bs=b(Xt),Kt=P(l(Ye,u("wss"),f(m())),l(Ye,u("tls"),f(l(u("sni"),G())),u("ws"),f(m()))),Rs=b(Kt),Zt=l(le,u("webrtc-direct"),f(ue()),f(ue()),f(m())),Os=b(Zt),Yt=l(Te,u("webtransport"),f(ue()),f(ue()),f(m())),_s=b(Yt),Ae=P(Xt,Kt,l(rt,f(m())),l(Xr,f(m())),l(B,f(m())),Zt,Yt,m()),js=b(Ae),Kr=l(Ae,u("p2p-circuit"),m()),qs=b(Kr),Zr=P(l(Ae,u("p2p-circuit"),u("webrtc"),f(m())),l(Ae,u("webrtc"),f(m())),l(u("webrtc"),f(m()))),Ws=b(Zr),Yr=P(l(B,u("tcp"),Y(),u("http"),f(m())),l(B,u("http"),f(m()))),Gs=b(Yr),en=P(l(B,u("tcp"),P(l(u("443"),u("http")),l(Y(),u("https")),l(Y(),u("tls"),u("http"))),f(m())),l(B,u("tls"),u("http"),f(m())),l(B,u("https"),f(m()))),Qs=b(en),tn=P(l(u("memory"),G(),f(m()))),er=b(tn);function ee(r=0){return new Uint8Array(r)}var rn=Math.pow(2,7),nn=Math.pow(2,14),on=Math.pow(2,21),ot=Math.pow(2,28),st=Math.pow(2,35),it=Math.pow(2,42),at=Math.pow(2,49),h=128,T=127;function z(r){if(r<rn)return 1;if(r<nn)return 2;if(r<on)return 3;if(r<ot)return 4;if(r<st)return 5;if(r<it)return 6;if(r<at)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function sn(r,e,t=0){switch(z(r)){case 8:e[t++]=r&255|h,r/=128;case 7:e[t++]=r&255|h,r/=128;case 6:e[t++]=r&255|h,r/=128;case 5:e[t++]=r&255|h,r/=128;case 4:e[t++]=r&255|h,r>>>=7;case 3:e[t++]=r&255|h,r>>>=7;case 2:e[t++]=r&255|h,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function an(r,e,t=0){switch(z(r)){case 8:e.set(t++,r&255|h),r/=128;case 7:e.set(t++,r&255|h),r/=128;case 6:e.set(t++,r&255|h),r/=128;case 5:e.set(t++,r&255|h),r/=128;case 4:e.set(t++,r&255|h),r>>>=7;case 3:e.set(t++,r&255|h),r>>>=7;case 2:e.set(t++,r&255|h),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function cn(r,e){let t=r[e],n=0;if(n+=t&T,t<h||(t=r[e+1],n+=(t&T)<<7,t<h)||(t=r[e+2],n+=(t&T)<<14,t<h)||(t=r[e+3],n+=(t&T)<<21,t<h)||(t=r[e+4],n+=(t&T)*ot,t<h)||(t=r[e+5],n+=(t&T)*st,t<h)||(t=r[e+6],n+=(t&T)*it,t<h)||(t=r[e+7],n+=(t&T)*at,t<h))return n;throw new RangeError("Could not decode varint")}function un(r,e){let t=r.get(e),n=0;if(n+=t&T,t<h||(t=r.get(e+1),n+=(t&T)<<7,t<h)||(t=r.get(e+2),n+=(t&T)<<14,t<h)||(t=r.get(e+3),n+=(t&T)<<21,t<h)||(t=r.get(e+4),n+=(t&T)*ot,t<h)||(t=r.get(e+5),n+=(t&T)*st,t<h)||(t=r.get(e+6),n+=(t&T)*it,t<h)||(t=r.get(e+7),n+=(t&T)*at,t<h))return n;throw new RangeError("Could not decode varint")}function te(r,e,t=0){return e==null&&(e=ee(z(r))),e instanceof Uint8Array?sn(r,e,t):an(r,e,t)}function Q(r,e=0){return r instanceof Uint8Array?cn(r,e):un(r,e)}function R(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=ee(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var ct={};k(ct,{base10:()=>ln});var ln=j({prefix:"9",name:"base10",alphabet:"0123456789"});var ut={};k(ut,{base16:()=>pn,base16upper:()=>dn});var pn=y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dn=y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lt={};k(lt,{base2:()=>fn});var fn=y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pt={};k(pt,{base256emoji:()=>gn});var rr=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}"),hn=rr.reduce((r,e,t)=>(r[t]=e,r),[]),mn=rr.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function xn(r){return r.reduce((e,t)=>(e+=hn[t],e),"")}function wn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=mn[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var gn=K({prefix:"\u{1F680}",name:"base256emoji",encode:xn,decode:wn});var dt={};k(dt,{base32:()=>O,base32hex:()=>vn,base32hexpad:()=>An,base32hexpadupper:()=>Sn,base32hexupper:()=>In,base32pad:()=>yn,base32padupper:()=>En,base32upper:()=>bn,base32z:()=>Cn});var O=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bn=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yn=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),En=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vn=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),In=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),An=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sn=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cn=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ft={};k(ft,{base36:()=>pe,base36upper:()=>Pn});var pe=j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pn=j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ht={};k(ht,{base8:()=>Tn});var Tn=y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mt={};k(mt,{identity:()=>Dn});var Dn=K({prefix:"\0",name:"identity",encode:r=>qt(r),decode:r=>jt(r)});var pi=new TextEncoder,di=new TextDecoder;var wt={};k(wt,{identity:()=>Zn});var Mn=sr,nr=128,kn=127,Fn=~kn,Ln=Math.pow(2,31);function sr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ln;)e[t++]=r&255|nr,r/=128;for(;r&Fn;)e[t++]=r&255|nr,r>>>=7;return e[t]=r|0,sr.bytes=t-n+1,e}var zn=xt,$n=128,or=127;function xt(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw xt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&or)<<o:(i&or)*Math.pow(2,o),o+=7}while(i>=$n);return xt.bytes=s-n,t}var Vn=Math.pow(2,7),Bn=Math.pow(2,14),Rn=Math.pow(2,21),On=Math.pow(2,28),_n=Math.pow(2,35),jn=Math.pow(2,42),qn=Math.pow(2,49),Wn=Math.pow(2,56),Gn=Math.pow(2,63),Qn=function(r){return r<Vn?1:r<Bn?2:r<Rn?3:r<On?4:r<_n?5:r<jn?6:r<qn?7:r<Wn?8:r<Gn?9:10},Jn={encode:Mn,decode:zn,encodingLength:Qn},Hn=Jn,de=Hn;function fe(r,e=0){return[de.decode(r,e),de.decode.bytes]}function re(r,e,t=0){return de.encode(r,e,t),e}function ne(r){return de.encodingLength(r)}function J(r,e){let t=e.byteLength,n=ne(r),o=n+ne(t),s=new Uint8Array(o+t);return re(r,s,0),re(t,s,n),s.set(e,o),new oe(r,t,e,s)}function Ue(r){let e=V(r),[t,n]=fe(e),[o,s]=fe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new oe(t,o,i,e)}function ir(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&_t(r.bytes,t.bytes)}}var oe=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ar=0,Xn="identity",cr=V;function Kn(r){return J(ar,cr(r))}var Zn={code:ar,name:Xn,encode:cr,digest:Kn};var yt={};k(yt,{sha256:()=>Yn,sha512:()=>eo});function bt({name:r,code:e,encode:t}){return new gt(r,e,t)}var gt=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?J(this.code,t):t.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};function lr(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Yn=bt({name:"sha2-256",code:18,encode:lr("SHA-256")}),eo=bt({name:"sha2-512",code:19,encode:lr("SHA-512")});function pr(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return ro(t,Et(r),e??C.encoder);default:return no(t,Et(r),e??O.encoder)}}var dr=new WeakMap;function Et(r){let e=dr.get(r);if(e==null){let t=new Map;return dr.set(r,t),t}return e}var q=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==oo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:e,digest:t}=this.multihash,n=J(e,t);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(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ir(e.multihash,n.multihash)}toString(e){return pr(this,e)}toJSON(){return{"/":pr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??fr(n,o,s.bytes))}else if(t[so]===!0){let{version:n,multihash:o,code:s}=t,i=Ue(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=fr(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,he,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=V(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new oe(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[I,N]=fe(e.subarray(t));return t+=N,I},o=n(),s=he;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),w=t+c,g=w-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:g,size:w}}static parse(e,t){let[n,o]=to(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Et(s).set(n,e),s}};function to(r,e){switch(r[0]){case"Q":{let t=e??C;return[C.prefix,t.decode(`${C.prefix}${r}`)]}case C.prefix:{let t=e??C;return[C.prefix,t.decode(r)]}case O.prefix:{let t=e??O;return[O.prefix,t.decode(r)]}case pe.prefix:{let t=e??pe;return[pe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function ro(r,e,t){let{prefix:n}=t;if(n!==C.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function no(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var he=112,oo=18;function fr(r,e,t){let n=ne(r),o=n+ne(e),s=new Uint8Array(o+t.byteLength);return re(r,s,0),re(e,s,n),s.set(t,o),s}var so=Symbol.for("@ipld/js-cid/CID");var me={...mt,...lt,...ht,...ct,...ut,...dt,...ft,...Xe,...Ze,...pt},Fi={...yt,...wt};function mr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var hr=mr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vt=mr("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ee(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),io={utf8:hr,"utf-8":hr,hex:me.base16,latin1:vt,ascii:vt,binary:vt,...me},Ne=io;function U(r,e="utf8"){let t=Ne[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Qi=parseInt("0xFFFF",16),Ji=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Me(r,e="utf8"){let t=Ne[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var gr=Ee,po=ve,It=function(r){let e=0;if(r=r.toString().trim(),gr(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(po(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=gr(t[n]),i;s&&(i=It(t[n]),t[n]=U(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,U(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},br=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ie={},At={},ho=[[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"]];ho.forEach(r=>{let e=mo(...r);At[e.code]=e,ie[e.name]=e});function mo(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function x(r){if(typeof r=="number"){if(At[r]!=null)return At[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ie[r]!=null)return ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Na=x("ip4"),Ma=x("ip6"),ka=x("ipcidr");function Tt(r,e){switch(x(r).code){case 4:case 41:return wo(e);case 42:return Pt(e);case 43:return U(e,"base10");case 6:case 273:case 33:case 132:return vr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pt(e);case 421:return Eo(e);case 444:return Er(e);case 445:return Er(e);case 466:return yo(e);case 481:return globalThis.encodeURIComponent(Pt(e));default:return U(e,"base16")}}function Dt(r,e){switch(x(r).code){case 4:return yr(e);case 41:return yr(e);case 42:return Ct(e);case 43:return Me(e,"base10");case 6:case 273:case 33:case 132:return Ut(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ct(e);case 421:return go(e);case 444:return vo(e);case 445:return Io(e);case 466:return bo(e);case 481:return Ct(globalThis.decodeURIComponent(e));default:return Me(e,"base16")}}var St=Object.values(me).map(r=>r.decoder),xo=function(){let r=St[0].or(St[1]);return St.slice(2).forEach(e=>r=r.or(e)),r}();function yr(r){if(!Ie(r))throw new Error("invalid ip address");return It(r)}function wo(r){let e=br(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Ie(e))throw new Error("invalid ip address");return e}function Ut(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function vr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ct(r){let e=Me(r),t=Uint8Array.from(te(e.length));return R([t,e],t.length+e.length)}function Pt(r){let e=Q(r);if(r=r.slice(z(e)),r.length!==e)throw new Error("inconsistent lengths");return U(r)}function go(r){let e;r[0]==="Q"||r[0]==="1"?e=Ue(C.decode(`z${r}`)).bytes:e=q.parse(r).multihash.bytes;let t=Uint8Array.from(te(e.length));return R([t,e],t.length+e.length)}function bo(r){let e=xo.decode(r),t=Uint8Array.from(te(e.length));return R([t,e],t.length+e.length)}function yo(r){let e=Q(r),t=r.slice(z(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+U(t,"base64url")}function Eo(r){let e=Q(r),t=r.slice(z(e));if(t.length!==e)throw new Error("inconsistent lengths");return U(t,"base58btc")}function vo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=O.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ut(n);return R([t,o],t.length+o.length)}function Io(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=O.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ut(n);return R([t,o],t.length+o.length)}function Er(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=U(e,"base32"),o=vr(t);return`${n}:${o}`}function Ir(r){r=Nt(r);let e=[],t=[],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=x(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(s++,s>=o.length)throw new ke("invalid address: "+r);if(a.path===!0){n=Nt(o.slice(s).join("/")),e.push([a.code,Dt(a.code,n)]),t.push([a.code,n]);break}let c=Dt(a.code,o[s]);e.push([a.code,c]),t.push([a.code,Tt(a.code,c)])}return{string:Ar(t),bytes:Fe(e),tuples:e,stringTuples:t,path:n}}function Mt(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=z(s),a=x(s),c=Ao(a,r.slice(o+i));if(c===0){e.push([s]),t.push([s]),o+=i;continue}let w=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new ke("Invalid address Uint8Array: "+U(r,"base16"));e.push([s,w]);let g=Tt(s,w);if(t.push([s,g]),a.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:Ar(t),tuples:e,stringTuples:t,path:n}}function Ar(r){let e=[];return r.map(t=>{let n=x(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Nt(e.join("/"))}function Fe(r){return R(r.map(e=>{let t=x(e[0]),n=Uint8Array.from(te(t.code));return e.length>1&&e[1]!=null&&(n=R([n,e[1]])),n}))}function Ao(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Q(e instanceof Uint8Array?e:Uint8Array.from(e));return t+z(t)}}function Nt(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var ke=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};function Sr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var So=Symbol.for("nodejs.util.inspect.custom"),Ft=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Co=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],kt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Le=class r{bytes;#e;#t;#r;#n;[Ft]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Mt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Ir(e)}else if(Pr(e))t=Mt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=x("tcp"),a=x("udp"),c=x("ip4"),w=x("ip6"),g=x("dns6"),I=x("ip6zone");for(let[S,d]of this.stringTuples())S===I.code&&(s=`%${d??""}`),Co.includes(S)&&(t=i.name==="tcp"?"tcp":"udp",o=443,n=`${d??""}${s}`,e=S===g.code?6:4),(S===i.code||S===a.code)&&(t=x(S).name==="tcp"?"tcp":"udp",o=parseInt(d??"")),(S===c.code||S===w.code)&&(t=x(S).name==="tcp"?"tcp":"udp",n=`${d??""}${s}`,e=S===w.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},x(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>x(e).name)}tuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Fe(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===ie.p2p.code&&e.push([n,o]),n===ie["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?U(C.decode(`z${n}`),"base58btc"):U(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Sr(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Cr.get(t.name);if(n==null)throw new kt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>W(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[So](){return`Multiaddr(${this.#e})`}};var Cr=new Map;function Pr(r){return!!r?.[Ft]}function W(r){return new Le(r)}var Tr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Po=new WeakMap;function To({clearTimeout:r,setTimeout:e}={}){return(t,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Tr());let s,i,a,c=r??clearTimeout,w=()=>{c(s),a(Tr())},g=()=>{o&&o.removeEventListener("abort",w)},I=new Promise((N,S)=>{i=()=>{g(),N(n)},a=S,s=(e??setTimeout)(i,t)});return o&&o.addEventListener("abort",w,{once:!0}),Po.set(I,()=>{c(s),s=null,i()}),I}}var Do=To(),ze=Do;function Uo(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var Dr=Uo;function No(r){return r[Symbol.asyncIterator]!=null}function Mo(r,e){let t=0;if(No(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Dr(r),{value:o,done:s}=n.next();if(s===!0)return function*(){}();let i=e(o,t++);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield i;for(let c of n)yield a(c,t++)}()}var Lt=Mo;function $e(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ve=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},ae=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ve(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ve(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var zt=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function $t(r={}){return ko(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function ko(r,e){e=e??{};let t=e.onEnd,n=new ae,o,s,i,a=$e(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,v)=>{s=D=>{s=null,n.push(D);try{p(r(n))}catch(A){v(A)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$e()})}},w=p=>s!=null?s(p):(n.push(p),o),g=p=>(n=new ae,s!=null?s({error:p}):(n.push({error:p}),o)),I=p=>{if(i)return o;if(e?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return w({done:!1,value:p})},N=p=>i?o:(i=!0,p!=null?g(p):w({done:!0})),S=()=>(n=new ae,N(),{done:!0}),d=p=>(N(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:S,throw:d,push:I,end:N,get readableLength(){return n.size},onEmpty:async p=>{let v=p?.signal;if(v?.throwIfAborted(),n.isEmpty())return;let D,A;v!=null&&(D=new Promise((M,F)=>{A=()=>{F(new zt)},v.addEventListener("abort",A)}));try{await Promise.race([a.promise,D])}finally{A!=null&&v!=null&&v?.removeEventListener("abort",A)}}},t==null)return o;let E=o;return o={[Symbol.asyncIterator](){return this},next(){return E.next()},throw(p){return E.throw(p),t!=null&&(t(p),t=void 0),{done:!0}},return(){return E.return(),t!=null&&(t(),t=void 0),{done:!0}},push:I,end(p){return E.end(p),t!=null&&(t(p),t=void 0),o},get readableLength(){return E.readableLength},onEmpty:p=>E.onEmpty(p)},o}var Be=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function Ur(r,e,t){if(e==null)return r;if(e.aborted)return r.catch(()=>{}),Promise.reject(new Be(t?.errorMessage,t?.errorCode,t?.errorName));let n,o=new Be(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var ce=new Map,Re=class{components;init;connections;latency;constructor(e,t){this.components=e,this.init=t,this.connections=new Set,this.latency=t.latency??0}async dial(e,t){let n=$t(),o=$t(),s=this,i={source:async function*(){yield*Lt(o,async c=>(s.latency>0&&await ze(s.latency),c))}(),sink:async c=>{for await(let w of c)n.push(w)},close:async()=>{n.end(),this.connections.delete(i),i.timeline.close=Date.now(),o.end(),this.connections.delete(a),a.timeline.close=Date.now()},abort:c=>{n.end(c),this.connections.delete(i),i.timeline.close=Date.now(),o.end(c),this.connections.delete(a),a.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},a={source:async function*(){yield*Lt(n,async c=>(s.latency>0&&await ze(s.latency),c))}(),sink:async c=>{for await(let w of c)o.push(w)},close:async()=>{o.end(),this.connections.delete(a),a.timeline.close=Date.now(),n.end(),this.connections.delete(i),i.timeline.close=Date.now()},abort:c=>{o.end(c),this.connections.delete(a),a.timeline.close=Date.now(),n.end(c),this.connections.delete(i),i.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}-outgoing/p2p/${e}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")};return this.connections.add(i),this.connections.add(a),await Ur(ze(this.latency),t),this.init.onConnection(a),i}close(){[...this.connections].forEach(e=>{e.abort(new H("Memory Connection closed"))})}};var Nr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Mr=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=Nr[t[r]&63];return e};var Oe=class extends ge{listenAddr;connection;components;init;shutdownController;constructor(e,t){super(),this.components=e,this.init=t,this.shutdownController=new AbortController,this.shutdownController.signal}async listen(e){let[[,t]]=e.stringTuples(),n=`/memory/${t??Mr()}`;if(t!=null&&ce.has(n))throw new we(`Memory address ${n} already in use`);this.connection=new Re(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=W(n),ce.set(n,this.connection),queueMicrotask(()=>{this.safeDispatchEvent("listening")})}onConnection(e){this.init.upgrader.upgradeInbound(e,{...this.init.upgraderOptions,signal:this.shutdownController.signal}).catch(t=>{e.abort(t)})}getAddrs(){return this.listenAddr==null?[]:[this.listenAddr]}updateAnnounceAddrs(){}async close(){this.connection?.close(),this.listenAddr!=null&&ce.delete(this.listenAddr.toString()),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var _e=class{components;init;constructor(e,t={}){this.components=e,this.init=t}[Bt]=!0;[Symbol.toStringTag]="@libp2p/memory";[Rt]=["@libp2p/transport"];async dial(e,t){t.signal.throwIfAborted();let n=ce.get(`${e.getPeerId()==null?e:e.decapsulate("/p2p")}`);if(n==null)throw new H(`No memory listener found at ${e}`);let o=await n.dial(this.components.peerId,t.signal);try{return t.signal.throwIfAborted(),await t.upgrader.upgradeOutbound(o,{...t,...this.init.upgraderOptions})}catch(s){throw o.abort(s),s}}createListener(e){return new Oe(this.components,{...e,...this.init})}listenFilter(e){return e.filter(t=>er.exactMatch(t))}dialFilter(e){return this.listenFilter(e)}};function Fo(r){return e=>new _e(e,r)}return $r(Lo);})();
3
3
  return Libp2PMemory}));
4
4
  //# sourceMappingURL=index.min.js.map