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