@libp2p/memory 1.1.12 → 1.1.13-58abe8702

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,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 Xe=Object.defineProperty;var Gr=Object.getOwnPropertyDescriptor;var Qr=Object.getOwnPropertyNames;var Xr=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var t in e)Xe(r,t,{get:e[t],enumerable:!0})},Jr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qr(e))!Xr.call(r,o)&&o!==t&&Xe(r,o,{get:()=>e[o],enumerable:!(n=Gr(e,o))||n.enumerable});return r};var Kr=r=>Jr(Xe({},"__esModule",{value:!0}),r);var Es={};N(Es,{memory:()=>ws});var Qt=Symbol.for("@libp2p/transport");var Gt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Gt||(Gt={}));var J=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}};var Ie=class extends Error{static name="ListenError";constructor(e="Listen error"){super(e),this.name="ListenError"}};var Se=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 Xt=Symbol.for("@libp2p/service-capabilities"),Ds=Symbol.for("@libp2p/service-dependencies");var De=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",l=2**(8*o)-1;for(;;){let y=this.readAtomically(()=>{let P=this.readChar();if(P===void 0)return;let O=Number.parseInt(P,e);if(!Number.isNaN(O))return O});if(y===void 0)break;if(s*=e,s+=y,s>l||(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 Zr=45,Yr=15,Pe=new De;function Je(r){if(!(r.length>Yr))return Pe.new(r).parseWith(()=>Pe.readIPv4Addr())}function Ke(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Zr))return Pe.new(r).parseWith(()=>Pe.readIPv6Addr())}function K(r){return!!Je(r)}function Te(r){return!!Ke(r)}var rt={};N(rt,{base58btc:()=>A,base58flickr:()=>an});var Ys=new Uint8Array(0);function Kt(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 R(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 Zt(r){return new TextEncoder().encode(r)}function Yt(r){return new TextDecoder().decode(r)}function en(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),l=Math.log(a)/Math.log(256),y=Math.log(256)/Math.log(a);function P(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var w=0,d=0,E=0,T=m.length;E!==T&&m[E]===0;)E++,w++;for(var v=(T-E)*y+1>>>0,_=new Uint8Array(v);E!==T;){for(var L=m[E],$=0,z=v-1;(L!==0||$<d)&&z!==-1;z--,$++)L+=256*_[z]>>>0,_[z]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");d=$,E++}for(var B=v-d;B!==v&&_[B]===0;)B++;for(var ve=c.repeat(w);B<v;++B)ve+=r.charAt(_[B]);return ve}function O(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var w=0;if(m[w]!==" "){for(var d=0,E=0;m[w]===c;)d++,w++;for(var T=(m.length-w)*l+1>>>0,v=new Uint8Array(T);m[w];){var _=t[m.charCodeAt(w)];if(_===255)return;for(var L=0,$=T-1;(_!==0||L<E)&&$!==-1;$--,L++)_+=a*v[$]>>>0,v[$]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");E=L,w++}if(m[w]!==" "){for(var z=T-E;z!==T&&v[z]===0;)z++;for(var B=new Uint8Array(d+(T-z)),ve=d;z!==T;)B[ve++]=v[z++];return B}}}function ce(m){var w=O(m);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:P,decodeUnsafe:O,decode:ce}}var tn=en,rn=tn,tr=rn;var Ze=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")}},Ye=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 rr(this,e)}},et=class{decoders;constructor(e){this.decoders=e}or(e){return rr(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 rr(r,e){return new et({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var tt=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 Ze(e,t,n),this.decoder=new Ye(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Z({name:r,prefix:e,encode:t,decode:n}){return new tt(r,e,t,n)}function V({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=tr(t,r);return Z({prefix:e,name:r,encode:n,decode:s=>R(o(s))})}function nn(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let y=e[r[l]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|y,i+=t,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=t||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function on(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 sn(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function g({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=sn(n);return Z({prefix:e,name:r,encode(s){return on(s,n,t)},decode(s){return nn(s,o,t,r)}})}var A=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),an=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var nt={};N(nt,{base64:()=>cn,base64pad:()=>ln,base64url:()=>le,base64urlpad:()=>un});var cn=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ln=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),le=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),un=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pn=r=>r.toString().split("/").slice(1),Y=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),u=r=>({match:e=>Y(t=>t===r).match(e),pattern:r}),G=()=>({match:r=>Y(e=>typeof e=="string").match(r),pattern:"{string}"}),ee=()=>({match:r=>Y(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),h=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{A.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{le.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})`}),S=(...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(", ")})`}),p=(...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 x(...r){function e(o){let s=pn(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 dn=h(),pi=x(dn),Oe=p(u("dns4"),G()),_e=p(u("dns6"),G()),Ne=p(u("dnsaddr"),G()),st=p(u("dns"),G()),di=x(Oe,f(h())),fi=x(_e,f(h())),hi=x(Ne,f(h())),mi=x(S(st,Ne,Oe,_e),f(h())),nr=p(u("ip4"),Y(K)),or=p(u("ip6"),Y(Te)),it=S(nr,or),k=S(it,st,Oe,_e,Ne),xi=x(S(it,p(S(st,Ne,Oe,_e),f(h())))),bi=x(nr),yi=x(or),gi=x(it),at=p(k,u("tcp"),ee()),pe=p(k,u("udp"),ee()),wi=x(p(at,f(h()))),Ei=x(pe),ct=p(pe,u("quic"),f(h())),Ue=p(pe,u("quic-v1"),f(h())),fn=S(ct,Ue),Ci=x(ct),vi=x(Ue),ot=S(k,at,pe,ct,Ue),sr=S(p(ot,u("ws"),f(h()))),Ii=x(sr),ir=S(p(ot,u("wss"),f(h())),p(ot,u("tls"),f(p(u("sni"),G())),u("ws"),f(h()))),Si=x(ir),ar=p(pe,u("webrtc-direct"),f(ue()),f(ue()),f(h())),Di=x(ar),cr=p(Ue,u("webtransport"),f(ue()),f(ue()),f(h())),Pi=x(cr),Ae=S(sr,ir,p(at,f(h())),p(fn,f(h())),p(k,f(h())),ar,cr,h()),Ti=x(Ae),hn=p(Ae,u("p2p-circuit"),h()),Ai=x(hn),mn=S(p(Ae,u("p2p-circuit"),u("webrtc"),f(h())),p(Ae,u("webrtc"),f(h())),p(u("webrtc"),f(h()))),Oi=x(mn),xn=S(p(k,u("tcp"),ee(),u("http"),f(h())),p(k,u("http"),f(h()))),_i=x(xn),bn=S(p(k,u("tcp"),S(p(u("443"),u("http")),p(ee(),u("https")),p(ee(),u("tls"),u("http"))),f(h())),p(k,u("tls"),u("http"),f(h())),p(k,u("https"),f(h()))),Ni=x(bn),yn=S(p(u("memory"),G(),f(h()))),lr=x(yn);var lt={};N(lt,{base10:()=>gn});var gn=V({prefix:"9",name:"base10",alphabet:"0123456789"});var ut={};N(ut,{base16:()=>wn,base16upper:()=>En});var wn=g({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),En=g({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pt={};N(pt,{base2:()=>Cn});var Cn=g({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dt={};N(dt,{base256emoji:()=>Pn});var ur=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}"),vn=ur.reduce((r,e,t)=>(r[t]=e,r),[]),In=ur.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Sn(r){return r.reduce((e,t)=>(e+=vn[t],e),"")}function Dn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=In[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Pn=Z({prefix:"\u{1F680}",name:"base256emoji",encode:Sn,decode:Dn});var ft={};N(ft,{base32:()=>W,base32hex:()=>_n,base32hexpad:()=>Un,base32hexpadupper:()=>Ln,base32hexupper:()=>Nn,base32pad:()=>An,base32padupper:()=>On,base32upper:()=>Tn,base32z:()=>Mn});var W=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tn=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),An=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),On=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_n=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Nn=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Un=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ln=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Mn=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ht={};N(ht,{base36:()=>de,base36upper:()=>zn});var de=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zn=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var mt={};N(mt,{base8:()=>Bn});var Bn=g({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var xt={};N(xt,{identity:()=>Rn});var Rn=Z({prefix:"\0",name:"identity",encode:r=>Yt(r),decode:r=>Zt(r)});var Wi=new TextEncoder,ji=new TextDecoder;var yt={};N(yt,{identity:()=>ao});var $n=fr,pr=128,Vn=127,Wn=~Vn,jn=Math.pow(2,31);function fr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=jn;)e[t++]=r&255|pr,r/=128;for(;r&Wn;)e[t++]=r&255|pr,r>>>=7;return e[t]=r|0,fr.bytes=t-n+1,e}var qn=bt,Hn=128,dr=127;function bt(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw bt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&dr)<<o:(i&dr)*Math.pow(2,o),o+=7}while(i>=Hn);return bt.bytes=s-n,t}var Gn=Math.pow(2,7),Qn=Math.pow(2,14),Xn=Math.pow(2,21),Jn=Math.pow(2,28),Kn=Math.pow(2,35),Zn=Math.pow(2,42),Yn=Math.pow(2,49),eo=Math.pow(2,56),to=Math.pow(2,63),ro=function(r){return r<Gn?1:r<Qn?2:r<Xn?3:r<Jn?4:r<Kn?5:r<Zn?6:r<Yn?7:r<eo?8:r<to?9:10},no={encode:$n,decode:qn,encodingLength:ro},oo=no,fe=oo;function he(r,e=0){return[fe.decode(r,e),fe.decode.bytes]}function te(r,e,t=0){return fe.encode(r,e,t),e}function re(r){return fe.encodingLength(r)}function Q(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 hr(r){let e=R(r),[t,n]=he(e),[o,s]=he(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 mr(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Kt(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 xr=0,so="identity",br=R;function io(r){return Q(xr,br(r))}var ao={code:xr,name:so,encode:br,digest:io};var Et={};N(Et,{sha256:()=>co,sha512:()=>lo});function wt({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?Q(this.code,t):t.then(n=>Q(this.code,n))}else throw Error("Unknown type, must be binary type")}};function gr(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var co=wt({name:"sha2-256",code:18,encode:gr("SHA-256")}),lo=wt({name:"sha2-512",code:19,encode:gr("SHA-512")});function wr(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return po(t,Ct(r),e??A.encoder);default:return fo(t,Ct(r),e??W.encoder)}}var Er=new WeakMap;function Ct(r){let e=Er.get(r);if(e==null){let t=new Map;return Er.set(r,t),t}return e}var j=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!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ho)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=Q(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&&mr(e.multihash,n.multihash)}toString(e){return wr(this,e)}toJSON(){return{"/":wr(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??Cr(n,o,s.bytes))}else if(t[mo]===!0){let{version:n,multihash:o,code:s}=t,i=hr(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!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Cr(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,xe,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=R(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[P,O]=he(e.subarray(t));return t+=O,P},o=n(),s=xe;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(),l=t+c,y=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:y,size:l}}static parse(e,t){let[n,o]=uo(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 Ct(s).set(n,e),s}};function uo(r,e){switch(r[0]){case"Q":{let t=e??A;return[A.prefix,t.decode(`${A.prefix}${r}`)]}case A.prefix:{let t=e??A;return[A.prefix,t.decode(r)]}case W.prefix:{let t=e??W;return[W.prefix,t.decode(r)]}case de.prefix:{let t=e??de;return[de.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 po(r,e,t){let{prefix:n}=t;if(n!==A.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 fo(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 xe=112,ho=18;function Cr(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 mo=Symbol.for("@ipld/js-cid/CID");var be={...xt,...pt,...mt,...lt,...ut,...ft,...ht,...rt,...nt,...dt},da={...Et,...yt};function ye(r=0){return new Uint8Array(r)}function Ir(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var vr=Ir("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vt=Ir("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=ye(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),xo={utf8:vr,"utf-8":vr,hex:be.base16,latin1:vt,ascii:vt,binary:vt,...be},Me=xo;function M(r,e="utf8"){let t=Me[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var I=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},F=class extends Error{static name="ValidationError";name="ValidationError"},ge=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},ze=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};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}function q(r,e="utf8"){let t=Me[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var bo=Math.pow(2,7),yo=Math.pow(2,14),go=Math.pow(2,21),It=Math.pow(2,28),St=Math.pow(2,35),Dt=Math.pow(2,42),Pt=Math.pow(2,49),b=128,D=127;function oe(r){if(r<bo)return 1;if(r<yo)return 2;if(r<go)return 3;if(r<It)return 4;if(r<St)return 5;if(r<Dt)return 6;if(r<Pt)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Tt(r,e,t=0){switch(oe(r)){case 8:e[t++]=r&255|b,r/=128;case 7:e[t++]=r&255|b,r/=128;case 6:e[t++]=r&255|b,r/=128;case 5:e[t++]=r&255|b,r/=128;case 4:e[t++]=r&255|b,r>>>=7;case 3:e[t++]=r&255|b,r>>>=7;case 2:e[t++]=r&255|b,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function wo(r,e){let t=r[e],n=0;if(n+=t&D,t<b||(t=r[e+1],n+=(t&D)<<7,t<b)||(t=r[e+2],n+=(t&D)<<14,t<b)||(t=r[e+3],n+=(t&D)<<21,t<b)||(t=r[e+4],n+=(t&D)*It,t<b)||(t=r[e+5],n+=(t&D)*St,t<b)||(t=r[e+6],n+=(t&D)*Dt,t<b)||(t=r[e+7],n+=(t&D)*Pt,t<b))return n;throw new RangeError("Could not decode varint")}function Eo(r,e){let t=r.get(e),n=0;if(n+=t&D,t<b||(t=r.get(e+1),n+=(t&D)<<7,t<b)||(t=r.get(e+2),n+=(t&D)<<14,t<b)||(t=r.get(e+3),n+=(t&D)<<21,t<b)||(t=r.get(e+4),n+=(t&D)*It,t<b)||(t=r.get(e+5),n+=(t&D)*St,t<b)||(t=r.get(e+6),n+=(t&D)*Dt,t<b)||(t=r.get(e+7),n+=(t&D)*Pt,t<b))return n;throw new RangeError("Could not decode varint")}function At(r,e=0){return r instanceof Uint8Array?wo(r,e):Eo(r,e)}function we(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=ye(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function _t(r){return e=>M(e,r)}function Nt(r){return e=>q(e,r)}function se(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function X(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function Dr(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=q(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=X(n);return we([t,o],t.length+o.length)}function Pr(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=W.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=X(n);return we([t,o],t.length+o.length)}function Ut(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=M(e,"base32"),o=se(t);return`${n}:${o}`}var Lt=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new I("Invalid byte value in IP address");e[n]=o}),e},Tr=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=K(t[n]),i;s&&(i=Lt(t[n]),t[n]=M(i.subarray(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,M(i.subarray(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++){t[n]===""&&(t[n]="0");let s=parseInt(t[n],16);if(isNaN(s)||s<0||s>65535)throw new I("Invalid byte value in IP address");o[e++]=s>>8&255,o[e++]=s&255}return o},Ar=function(r){if(r.byteLength!==4)throw new I("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},Or=function(r){if(r.byteLength!==16)throw new I("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;e.push(i)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new I(`Invalid IPv6 address "${t}"`)}};function _r(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new I(`Invalid IPv6 address "${r}"`)}}var Ot=Object.values(be).map(r=>r.decoder),vo=function(){let r=Ot[0].or(Ot[1]);return Ot.slice(2).forEach(e=>r=r.or(e)),r}();function Nr(r){return vo.decode(r)}function Ur(r){return e=>r.encoder.encode(e)}function Io(r){if(parseInt(r).toString()!==r)throw new F("Value must be an integer")}function So(r){if(r<0)throw new F("Value must be a positive integer, or zero")}function Do(r){return e=>{if(e>r)throw new F(`Value must be smaller than or equal to ${r}`)}}function Po(...r){return e=>{for(let t of r)t(e)}}var Ee=Po(Io,So,Do(65535));var C=-1,Mt=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new ze(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},U=new Mt,ns=[{code:4,name:"ip4",size:32,valueToBytes:Lt,bytesToValue:Ar,validate:r=>{if(!K(r))throw new F(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:X,bytesToValue:se,validate:Ee},{code:273,name:"udp",size:16,valueToBytes:X,bytesToValue:se,validate:Ee},{code:33,name:"dccp",size:16,valueToBytes:X,bytesToValue:se,validate:Ee},{code:41,name:"ip6",size:128,valueToBytes:Tr,bytesToValue:Or,stringToValue:_r,validate:r=>{if(!Te(r))throw new F(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:C},{code:43,name:"ipcidr",size:8,bytesToValue:_t("base10"),valueToBytes:Nt("base10")},{code:53,name:"dns",size:C,resolvable:!0},{code:54,name:"dns4",size:C,resolvable:!0},{code:55,name:"dns6",size:C,resolvable:!0},{code:56,name:"dnsaddr",size:C,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:X,bytesToValue:se,validate:Ee},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:C,path:!0,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:C,bytesToValue:_t("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Nt("base58btc")(r):j.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Ut,valueToBytes:Dr},{code:445,name:"onion3",size:296,bytesToValue:Ut,valueToBytes:Pr},{code:446,name:"garlic64",size:C},{code:447,name:"garlic32",size:C},{code:448,name:"tls"},{code:449,name:"sni",size:C},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:C,bytesToValue:Ur(le),valueToBytes:Nr},{code:480,name:"http"},{code:481,name:"http-path",size:C,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:C}];ns.forEach(r=>{U.addProtocol(r)});function Lr(r){let e=[],t=0;for(;t<r.length;){let n=At(r,t),o=U.getProtocol(n),s=oe(n),i=os(o,r,t+s),a=0;i>0&&o.size===C&&(a=oe(i));let c=s+a+i,l={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(i>0){let y=t+s+a,P=r.subarray(y,y+i);l.value=o.bytesToValue?.(P)??M(P)}e.push(l),t+=c}return e}function Mr(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=U.getProtocol(n.code),s=oe(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??q(n.value),a=i.byteLength,o.size===C&&(c=oe(a)));let l=new Uint8Array(s+c+a),y=0;Tt(n.code,l,y),y+=s,i!=null&&(o.size===C&&(Tt(a,l,y),y+=c),l.set(i,y)),n.bytes=l}t.push(n.bytes),e+=n.bytes.byteLength}return we(t,e)}function zr(r){if(r.charAt(0)!=="/")throw new I('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(t==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=U.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new I(`Component ${o} was missing value`);t="value"}else if(t==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new I(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}e.push(l),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new I("Incomplete multiaddr");return e}function Br(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=U.getProtocol(e.code);if(t==null)throw new I(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function os(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:At(e,t)}var ss=Symbol.for("nodejs.util.inspect.custom"),Wt=Symbol.for("@multiformats/multiaddr"),is=[53,54,55,56],Vt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}};function as(r){if(r==null&&(r="/"),kr(r))return r.getComponents();if(r instanceof Uint8Array)return Lr(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),zr(r);if(Array.isArray(r))return r;throw new I("Must be a string, Uint8Array, Component[], or another Multiaddr")}var $e=class r{[Wt]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=as(e),t.validate!==!1&&cs(this)}get bytes(){return this.#r==null&&(this.#r=Mr(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Br(this.#e)),this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="";for(let{code:a,name:c,value:l}of this.#e)a===42&&(s=`%${l??""}`),is.includes(a)&&(t="tcp",o=443,n=`${l??""}${s}`,e=a===55?6:4),(a===6||a===273)&&(t=c==="tcp"?"tcp":"udp",o=parseInt(l??"")),(a===4||a===41)&&(t="tcp",n=`${l??""}${s}`,e=a===41?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}}getComponents(){return[...this.#e]}protos(){return this.#e.map(({code:e,value:t})=>{let n=U.getProtocol(e);return{code:e,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#e.map(({code:e})=>e)}protoNames(){return this.#e.map(({name:e})=>e)}tuples(){return this.#e.map(({code:e,value:t})=>{if(t==null)return[e];let n=U.getProtocol(e),o=[e];return t!=null&&o.push(n.valueToBytes?.(t)??q(t)),o})}stringTuples(){return this.#e.map(({code:e,value:t})=>t==null?[e]:[e,t])}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new ge(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}getPeerId(){try{let e=[];this.#e.forEach(({code:n,value:o})=>{n===421&&e.push([n,o]),n===290&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?M(A.decode(`z${n}`),"base58btc"):M(j.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let e of this.#e)if(U.getProtocol(e.code).path)return e.value??null;return null}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=Rr.get(t.name);if(n==null)throw new Vt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>H(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(){return!(this.#e.length!==2||this.#e[0].code!==4&&this.#e[0].code!==41||this.#e[1].code!==6&&this.#e[1].code!==273)}[ss](){return`Multiaddr(${this.toString()})`}};function cs(r){r.getComponents().forEach(e=>{let t=U.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}var yc=parseInt("0xFFFF",16),gc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Rr=new Map;function kr(r){return!!r?.[Wt]}function H(r){return new $e(r)}var Vr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},fs=new WeakMap;function hs({clearTimeout:r,setTimeout:e}={}){return(t,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Vr());let s,i,a,c=r??clearTimeout,l=()=>{c(s),a(Vr())},y=()=>{o&&o.removeEventListener("abort",l)},P=new Promise((O,ce)=>{i=()=>{y(),O(n)},a=ce,s=(e??setTimeout)(i,t)});return o&&o.addEventListener("abort",l,{once:!0}),fs.set(P,()=>{c(s),s=null,i()}),P}}var ms=hs(),Ve=ms;function xs(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 Wr=xs;function bs(r){return r[Symbol.asyncIterator]!=null}function ys(r,e){let t=0;if(bs(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Wr(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(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 jt=ys;function We(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var je=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 je(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 je(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 qt=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Ht(r={}){return gs(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 gs(r,e){e=e??{};let t=e.onEnd,n=new ie,o,s,i,a=We(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((d,E)=>{s=T=>{s=null,n.push(T);try{d(r(n))}catch(v){E(v)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=We()})}},l=d=>s!=null?s(d):(n.push(d),o),y=d=>(n=new ie,s!=null?s({error:d}):(n.push({error:d}),o)),P=d=>{if(i)return o;if(e?.objectMode!==!0&&d?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:d})},O=d=>i?o:(i=!0,d!=null?y(d):l({done:!0})),ce=()=>(n=new ie,O(),{done:!0}),m=d=>(O(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:ce,throw:m,push:P,end:O,get readableLength(){return n.size},onEmpty:async d=>{let E=d?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let T,v;E!=null&&(T=new Promise((_,L)=>{v=()=>{L(new qt)},E.addEventListener("abort",v)}));try{await Promise.race([a.promise,T])}finally{v!=null&&E!=null&&E?.removeEventListener("abort",v)}}},t==null)return o;let w=o;return o={[Symbol.asyncIterator](){return this},next(){return w.next()},throw(d){return w.throw(d),t!=null&&(t(d),t=void 0),{done:!0}},return(){return w.return(),t!=null&&(t(),t=void 0),{done:!0}},push:P,end(d){return w.end(d),t!=null&&(t(d),t=void 0),o},get readableLength(){return w.readableLength},onEmpty:d=>w.onEmpty(d)},o}var qe=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 jr(r,e,t){if(e==null)return r;if(e.aborted)return r.catch(()=>{}),Promise.reject(new qe(t?.errorMessage,t?.errorCode,t?.errorName));let n,o=new qe(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,He=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=Ht(),o=Ht(),s=this,i={source:async function*(){yield*jt(o,async c=>(s.latency>0&&await Ve(s.latency),c))}(),sink:async c=>{for await(let l of c)n.push(l)},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:H(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},a={source:async function*(){yield*jt(n,async c=>(s.latency>0&&await Ve(s.latency),c))}(),sink:async c=>{for await(let l of c)o.push(l)},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:H(`${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 jr(Ve(this.latency),t),this.init.onConnection(a),i}close(){[...this.connections].forEach(e=>{e.abort(new J("Memory Connection closed"))})}};var qr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Hr=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=qr[t[r]&63];return e};var Ge=class extends Se{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??Hr()}`;if(t!=null&&ae.has(n))throw new Ie(`Memory address ${n} already in use`);this.connection=new He(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=H(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 Qe=class{components;init;constructor(e,t={}){this.components=e,this.init=t}[Qt]=!0;[Symbol.toStringTag]="@libp2p/memory";[Xt]=["@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 J(`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 Ge(this.components,{...e,...this.init})}listenFilter(e){return e.filter(t=>lr.exactMatch(t))}dialFilter(e){return this.listenFilter(e)}};function ws(r){return e=>new Qe(e,r)}return Kr(Es);})();
2
+ "use strict";var Libp2PMemory=(()=>{var rt=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var an=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var t in e)rt(r,t,{get:e[t],enumerable:!0})},cn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of sn(e))!an.call(r,o)&&o!==t&&rt(r,o,{get:()=>e[o],enumerable:!(n=on(e,o))||n.enumerable});return r};var ln=r=>cn(rt({},"__esModule",{value:!0}),r);var bs={};N(bs,{memory:()=>xs});var or=Symbol.for("@libp2p/transport");var nr;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(nr||(nr={}));var Y=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}};var Ne=class extends Error{static name="ListenError";constructor(e="Listen error"){super(e),this.name="ListenError"}};var Ue=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 sr=Symbol.for("@libp2p/service-capabilities"),Cs=Symbol.for("@libp2p/service-dependencies");var at={};N(at,{base10:()=>xn});var js=new Uint8Array(0);function ir(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 F(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 ar(r){return new TextEncoder().encode(r)}function cr(r){return new TextDecoder().decode(r)}function un(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),u=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function T(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var E=0,p=0,C=0,A=m.length;C!==A&&m[C]===0;)C++,E++;for(var D=(A-C)*g+1>>>0,O=new Uint8Array(D);C!==A;){for(var M=m[C],$=0,B=D-1;(M!==0||$<p)&&B!==-1;B--,$++)M+=256*O[B]>>>0,O[B]=M%a>>>0,M=M/a>>>0;if(M!==0)throw new Error("Non-zero carry");p=$,C++}for(var k=D-p;k!==D&&O[k]===0;)k++;for(var Oe=c.repeat(E);k<D;++k)Oe+=r.charAt(O[k]);return Oe}function _(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var E=0;if(m[E]!==" "){for(var p=0,C=0;m[E]===c;)p++,E++;for(var A=(m.length-E)*u+1>>>0,D=new Uint8Array(A);m[E];){var O=t[m.charCodeAt(E)];if(O===255)return;for(var M=0,$=A-1;(O!==0||M<C)&&$!==-1;$--,M++)O+=a*D[$]>>>0,D[$]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");C=M,E++}if(m[E]!==" "){for(var B=A-C;B!==A&&D[B]===0;)B++;for(var k=new Uint8Array(p+(A-B)),Oe=p;B!==A;)k[Oe++]=D[B++];return k}}}function he(m){var E=_(m);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:T,decodeUnsafe:_,decode:he}}var pn=un,dn=pn,ur=dn;var nt=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")}},ot=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 pr(this,e)}},st=class{decoders;constructor(e){this.decoders=e}or(e){return pr(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 pr(r,e){return new st({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var it=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 nt(e,t,n),this.decoder=new ot(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ee({name:r,prefix:e,encode:t,decode:n}){return new it(r,e,t,n)}function W({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ur(t,r);return ee({prefix:e,name:r,encode:n,decode:s=>F(o(s))})}function fn(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),i=0,a=0,c=0;for(let u=0;u<o;++u){let g=e[r[u]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|g,i+=t,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=t||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function hn(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 mn(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function w({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=mn(n);return ee({prefix:e,name:r,encode(s){return hn(s,n,t)},decode(s){return fn(s,o,t,r)}})}var xn=W({prefix:"9",name:"base10",alphabet:"0123456789"});var ct={};N(ct,{base16:()=>bn,base16upper:()=>yn});var bn=w({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),yn=w({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lt={};N(lt,{base2:()=>gn});var gn=w({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ut={};N(ut,{base256emoji:()=>Dn});var dr=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}"),wn=dr.reduce((r,e,t)=>(r[t]=e,r),[]),En=dr.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Cn(r){return r.reduce((e,t)=>(e+=wn[t],e),"")}function vn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=En[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Dn=ee({prefix:"\u{1F680}",name:"base256emoji",encode:Cn,decode:vn});var pt={};N(pt,{base32:()=>j,base32hex:()=>Tn,base32hexpad:()=>_n,base32hexpadupper:()=>On,base32hexupper:()=>An,base32pad:()=>Sn,base32padupper:()=>Pn,base32upper:()=>In,base32z:()=>Nn});var j=w({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),In=w({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Sn=w({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Pn=w({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Tn=w({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),An=w({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_n=w({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),On=w({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Nn=w({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var dt={};N(dt,{base36:()=>me,base36upper:()=>Un});var me=W({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Un=W({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ft={};N(ft,{base58btc:()=>R,base58flickr:()=>Mn});var R=W({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mn=W({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mt={};N(mt,{base64:()=>Rn,base64pad:()=>Ln,base64url:()=>ht,base64urlpad:()=>Bn});var Rn=w({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ln=w({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ht=w({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bn=w({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xt={};N(xt,{base8:()=>zn});var zn=w({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bt={};N(bt,{identity:()=>kn});var kn=ee({prefix:"\0",name:"identity",encode:r=>cr(r),decode:r=>ar(r)});var ii=new TextEncoder,ai=new TextDecoder;var gt={};N(gt,{identity:()=>co});var $n=mr,fr=128,Wn=127,jn=~Wn,qn=Math.pow(2,31);function mr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=qn;)e[t++]=r&255|fr,r/=128;for(;r&jn;)e[t++]=r&255|fr,r>>>=7;return e[t]=r|0,mr.bytes=t-n+1,e}var Hn=yt,Qn=128,hr=127;function yt(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw yt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&hr)<<o:(i&hr)*Math.pow(2,o),o+=7}while(i>=Qn);return yt.bytes=s-n,t}var Gn=Math.pow(2,7),Xn=Math.pow(2,14),Jn=Math.pow(2,21),Kn=Math.pow(2,28),Zn=Math.pow(2,35),Yn=Math.pow(2,42),eo=Math.pow(2,49),to=Math.pow(2,56),ro=Math.pow(2,63),no=function(r){return r<Gn?1:r<Xn?2:r<Jn?3:r<Kn?4:r<Zn?5:r<Yn?6:r<eo?7:r<to?8:r<ro?9:10},oo={encode:$n,decode:Hn,encodingLength:no},so=oo,xe=so;function be(r,e=0){return[xe.decode(r,e),xe.decode.bytes]}function te(r,e,t=0){return xe.encode(r,e,t),e}function re(r){return xe.encodingLength(r)}function G(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 xr(r){let e=F(r),[t,n]=be(e),[o,s]=be(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 br(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ir(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 yr=0,io="identity",gr=F;function ao(r){return G(yr,gr(r))}var co={code:yr,name:io,encode:gr,digest:ao};var Ct={};N(Ct,{sha256:()=>lo,sha512:()=>uo});function Et({name:r,code:e,encode:t}){return new wt(r,e,t)}var wt=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?G(this.code,t):t.then(n=>G(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Er(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var lo=Et({name:"sha2-256",code:18,encode:Er("SHA-256")}),uo=Et({name:"sha2-512",code:19,encode:Er("SHA-512")});function Cr(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return fo(t,vt(r),e??R.encoder);default:return ho(t,vt(r),e??j.encoder)}}var vr=new WeakMap;function vt(r){let e=vr.get(r);if(e==null){let t=new Map;return vr.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!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==mo)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=G(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&&br(e.multihash,n.multihash)}toString(e){return Cr(this,e)}toJSON(){return{"/":Cr(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??Dr(n,o,s.bytes))}else if(t[xo]===!0){let{version:n,multihash:o,code:s}=t,i=xr(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!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Dr(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ge,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=F(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[T,_]=be(e.subarray(t));return t+=_,T},o=n(),s=ge;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(),u=t+c,g=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:g,size:u}}static parse(e,t){let[n,o]=po(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 vt(s).set(n,e),s}};function po(r,e){switch(r[0]){case"Q":{let t=e??R;return[R.prefix,t.decode(`${R.prefix}${r}`)]}case R.prefix:{let t=e??R;return[R.prefix,t.decode(r)]}case j.prefix:{let t=e??j;return[j.prefix,t.decode(r)]}case me.prefix:{let t=e??me;return[me.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 fo(r,e,t){let{prefix:n}=t;if(n!==R.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 ho(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 ge=112,mo=18;function Dr(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 xo=Symbol.for("@ipld/js-cid/CID");var we={...bt,...lt,...xt,...at,...ct,...pt,...dt,...ft,...mt,...ut},Ai={...Ct,...gt};function Ee(r=0){return new Uint8Array(r)}function Sr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ir=Sr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Dt=Sr("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}),bo={utf8:Ir,"utf-8":Ir,hex:we.base16,latin1:Dt,ascii:Dt,binary:Dt,...we},Re=bo;function L(r,e="utf8"){let t=Re[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var I=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},V=class extends Error{static name="ValidationError";name="ValidationError"},Ce=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Le=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function Pr(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 H(r,e="utf8"){let t=Re[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var yo=Math.pow(2,7),go=Math.pow(2,14),wo=Math.pow(2,21),It=Math.pow(2,28),St=Math.pow(2,35),Pt=Math.pow(2,42),Tt=Math.pow(2,49),y=128,S=127;function oe(r){if(r<yo)return 1;if(r<go)return 2;if(r<wo)return 3;if(r<It)return 4;if(r<St)return 5;if(r<Pt)return 6;if(r<Tt)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function At(r,e,t=0){switch(oe(r)){case 8:e[t++]=r&255|y,r/=128;case 7:e[t++]=r&255|y,r/=128;case 6:e[t++]=r&255|y,r/=128;case 5:e[t++]=r&255|y,r/=128;case 4:e[t++]=r&255|y,r>>>=7;case 3:e[t++]=r&255|y,r>>>=7;case 2:e[t++]=r&255|y,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Eo(r,e){let t=r[e],n=0;if(n+=t&S,t<y||(t=r[e+1],n+=(t&S)<<7,t<y)||(t=r[e+2],n+=(t&S)<<14,t<y)||(t=r[e+3],n+=(t&S)<<21,t<y)||(t=r[e+4],n+=(t&S)*It,t<y)||(t=r[e+5],n+=(t&S)*St,t<y)||(t=r[e+6],n+=(t&S)*Pt,t<y)||(t=r[e+7],n+=(t&S)*Tt,t<y))return n;throw new RangeError("Could not decode varint")}function Co(r,e){let t=r.get(e),n=0;if(n+=t&S,t<y||(t=r.get(e+1),n+=(t&S)<<7,t<y)||(t=r.get(e+2),n+=(t&S)<<14,t<y)||(t=r.get(e+3),n+=(t&S)<<21,t<y)||(t=r.get(e+4),n+=(t&S)*It,t<y)||(t=r.get(e+5),n+=(t&S)*St,t<y)||(t=r.get(e+6),n+=(t&S)*Pt,t<y)||(t=r.get(e+7),n+=(t&S)*Tt,t<y))return n;throw new RangeError("Could not decode varint")}function _t(r,e=0){return r instanceof Uint8Array?Eo(r,e):Co(r,e)}function ve(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 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",u=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let T=this.readChar();if(T===void 0)return;let _=Number.parseInt(T,e);if(!Number.isNaN(_))return _});if(g===void 0)break;if(s*=e,s+=g,s>u||(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 Do=45,Io=15,ze=new Be;function Ot(r){if(!(r.length>Io))return ze.new(r).parseWith(()=>ze.readIPv4Addr())}function Nt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Do))return ze.new(r).parseWith(()=>ze.readIPv6Addr())}function ke(r){return!!Ot(r)}function Ar(r){return!!Nt(r)}function Mt(r){return e=>L(e,r)}function Rt(r){return e=>H(e,r)}function se(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function X(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function _r(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=H(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=X(n);return ve([t,o],t.length+o.length)}function Or(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=j.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=X(n);return ve([t,o],t.length+o.length)}function Lt(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=L(e,"base32"),o=se(t);return`${n}:${o}`}var Bt=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new I("Invalid byte value in IP address");e[n]=o}),e},Nr=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=ke(t[n]),i;s&&(i=Bt(t[n]),t[n]=L(i.subarray(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,L(i.subarray(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++){t[n]===""&&(t[n]="0");let s=parseInt(t[n],16);if(isNaN(s)||s<0||s>65535)throw new I("Invalid byte value in IP address");o[e++]=s>>8&255,o[e++]=s&255}return o},Ur=function(r){if(r.byteLength!==4)throw new I("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},Mr=function(r){if(r.byteLength!==16)throw new I("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;e.push(i)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new I(`Invalid IPv6 address "${t}"`)}};function Rr(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new I(`Invalid IPv6 address "${r}"`)}}var Ut=Object.values(we).map(r=>r.decoder),So=function(){let r=Ut[0].or(Ut[1]);return Ut.slice(2).forEach(e=>r=r.or(e)),r}();function Lr(r){return So.decode(r)}function Br(r){return e=>r.encoder.encode(e)}function Po(r){if(parseInt(r).toString()!==r)throw new V("Value must be an integer")}function To(r){if(r<0)throw new V("Value must be a positive integer, or zero")}function Ao(r){return e=>{if(e>r)throw new V(`Value must be smaller than or equal to ${r}`)}}function _o(...r){return e=>{for(let t of r)t(e)}}var De=_o(Po,To,Ao(65535));var v=-1,zt=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new Le(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},U=new zt,qo=[{code:4,name:"ip4",size:32,valueToBytes:Bt,bytesToValue:Ur,validate:r=>{if(!ke(r))throw new V(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:X,bytesToValue:se,validate:De},{code:273,name:"udp",size:16,valueToBytes:X,bytesToValue:se,validate:De},{code:33,name:"dccp",size:16,valueToBytes:X,bytesToValue:se,validate:De},{code:41,name:"ip6",size:128,valueToBytes:Nr,bytesToValue:Mr,stringToValue:Rr,validate:r=>{if(!Ar(r))throw new V(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:v},{code:43,name:"ipcidr",size:8,bytesToValue:Mt("base10"),valueToBytes:Rt("base10")},{code:53,name:"dns",size:v,resolvable:!0},{code:54,name:"dns4",size:v,resolvable:!0},{code:55,name:"dns6",size:v,resolvable:!0},{code:56,name:"dnsaddr",size:v,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:X,bytesToValue:se,validate:De},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:v,path:!0,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:v,bytesToValue:Mt("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Rt("base58btc")(r):q.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Lt,valueToBytes:_r},{code:445,name:"onion3",size:296,bytesToValue:Lt,valueToBytes:Or},{code:446,name:"garlic64",size:v},{code:447,name:"garlic32",size:v},{code:448,name:"tls"},{code:449,name:"sni",size:v},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:v,bytesToValue:Br(ht),valueToBytes:Lr},{code:480,name:"http"},{code:481,name:"http-path",size:v,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:v}];qo.forEach(r=>{U.addProtocol(r)});function zr(r){let e=[],t=0;for(;t<r.length;){let n=_t(r,t),o=U.getProtocol(n),s=oe(n),i=Ho(o,r,t+s),a=0;i>0&&o.size===v&&(a=oe(i));let c=s+a+i,u={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(i>0){let g=t+s+a,T=r.subarray(g,g+i);u.value=o.bytesToValue?.(T)??L(T)}e.push(u),t+=c}return e}function kr(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=U.getProtocol(n.code),s=oe(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??H(n.value),a=i.byteLength,o.size===v&&(c=oe(a)));let u=new Uint8Array(s+c+a),g=0;At(n.code,u,g),g+=s,i!=null&&(o.size===v&&(At(a,u,g),g+=c),u.set(i,g)),n.bytes=u}t.push(n.bytes),e+=n.bytes.byteLength}return ve(t,e)}function Fr(r){if(r.charAt(0)!=="/")throw new I('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(t==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=U.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new I(`Component ${o} was missing value`);t="value"}else if(t==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new I(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}e.push(u),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new I("Incomplete multiaddr");return e}function Vr(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=U.getProtocol(e.code);if(t==null)throw new I(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function Ho(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:_t(e,t)}var Qo=Symbol.for("nodejs.util.inspect.custom"),Gt=Symbol.for("@multiformats/multiaddr"),Go=[53,54,55,56],Qt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}};function Xo(r){if(r==null&&(r="/"),Wr(r))return r.getComponents();if(r instanceof Uint8Array)return zr(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),Fr(r);if(Array.isArray(r))return r;throw new I("Must be a string, Uint8Array, Component[], or another Multiaddr")}var We=class r{[Gt]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=Xo(e),t.validate!==!1&&Jo(this)}get bytes(){return this.#r==null&&(this.#r=kr(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Vr(this.#e)),this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="";for(let{code:a,name:c,value:u}of this.#e)a===42&&(s=`%${u??""}`),Go.includes(a)&&(t="tcp",o=443,n=`${u??""}${s}`,e=a===55?6:4),(a===6||a===273)&&(t=c==="tcp"?"tcp":"udp",o=parseInt(u??"")),(a===4||a===41)&&(t="tcp",n=`${u??""}${s}`,e=a===41?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}}getComponents(){return[...this.#e]}protos(){return this.#e.map(({code:e,value:t})=>{let n=U.getProtocol(e);return{code:e,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#e.map(({code:e})=>e)}protoNames(){return this.#e.map(({name:e})=>e)}tuples(){return this.#e.map(({code:e,value:t})=>{if(t==null)return[e];let n=U.getProtocol(e),o=[e];return t!=null&&o.push(n.valueToBytes?.(t)??H(t)),o})}stringTuples(){return this.#e.map(({code:e,value:t})=>t==null?[e]:[e,t])}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Ce(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}getPeerId(){try{let e=[];this.#e.forEach(({code:n,value:o})=>{n===421&&e.push([n,o]),n===290&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?L(R.decode(`z${n}`),"base58btc"):L(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let e of this.#e)if(U.getProtocol(e.code).path)return e.value??null;return null}equals(e){return Pr(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=$r.get(t.name);if(n==null)throw new Qt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>Q(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(){return!(this.#e.length!==2||this.#e[0].code!==4&&this.#e[0].code!==41||this.#e[1].code!==6&&this.#e[1].code!==273)}[Qo](){return`Multiaddr(${this.toString()})`}};function Jo(r){r.getComponents().forEach(e=>{let t=U.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}var Fa=parseInt("0xFFFF",16),Va=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var $r=new Map;function Wr(r){return!!r?.[Gt]}function Q(r){return new We(r)}var b=r=>({match:e=>{let t=e[0];return t==null||t.code!==r||t.value!=null?!1:e.slice(1)}}),l=(r,e)=>({match:t=>{let n=t[0];return n?.code!==r||n.value==null||e!=null&&n.value!==e?!1:t.slice(1)}}),d=r=>({match:e=>{let t=r.match(e);return t===!1?e:t}}),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}}),h=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e}});function x(...r){function e(o){let s=o.getComponents();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 ts=l(421),Ac=x(ts),qe=l(54),He=l(55),Qe=l(56),Jt=l(53),_c=x(qe,d(l(421))),Oc=x(He,d(l(421))),Nc=x(Qe,d(l(421))),Uc=x(P(Jt,Qe,qe,He),d(l(421))),Hr=h(l(4),d(l(43))),Qr=h(d(l(42)),l(41),d(l(43))),Kt=P(Hr,Qr),Z=P(Kt,Jt,qe,He,Qe),Mc=x(P(Kt,h(P(Jt,Qe,qe,He),d(l(421))))),Rc=x(Hr),Lc=x(Qr),Bc=x(Kt),Zt=h(Z,l(6)),_e=h(Z,l(273)),zc=x(h(Zt,d(l(421)))),kc=x(_e),Yt=h(_e,b(460),d(l(421))),Ge=h(_e,b(461),d(l(421))),rs=P(Yt,Ge),Fc=x(Yt),Vc=x(Ge),Xt=P(Z,Zt,_e,Yt,Ge),Gr=P(h(Xt,b(477),d(l(421)))),$c=x(Gr),Xr=P(h(Xt,b(478),d(l(421))),h(Xt,b(448),d(l(449)),b(477),d(l(421)))),Wc=x(Xr),Jr=h(_e,b(280),d(l(466)),d(l(466)),d(l(421))),jc=x(Jr),Kr=h(Ge,b(465),d(l(466)),d(l(466)),d(l(421))),qc=x(Kr),je=P(Gr,Xr,h(Zt,d(l(421))),h(rs,d(l(421))),h(Z,d(l(421))),Jr,Kr,l(421)),Hc=x(je),ns=h(je,b(290),l(421)),Qc=x(ns),os=P(h(je,b(290),b(281),d(l(421))),h(je,b(281),d(l(421))),h(b(281),d(l(421)))),Gc=x(os),ss=P(h(Z,l(6),b(480),d(l(421))),h(Z,b(480),d(l(421)))),Xc=x(ss),is=h(Z,P(h(l(6,"443"),b(480)),h(l(6),b(443)),h(l(6),b(448),b(480)),h(b(448),b(480)),b(448),b(443)),d(l(421))),Jc=x(is),as=P(h(l(777),d(l(421)))),Zr=x(as),cs=P(h(l(400),d(l(421)))),Kc=x(cs);var Yr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},ls=new WeakMap;function us({clearTimeout:r,setTimeout:e}={}){return(t,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Yr());let s,i,a,c=r??clearTimeout,u=()=>{c(s),a(Yr())},g=()=>{o&&o.removeEventListener("abort",u)},T=new Promise((_,he)=>{i=()=>{g(),_(n)},a=he,s=(e??setTimeout)(i,t)});return o&&o.addEventListener("abort",u,{once:!0}),ls.set(T,()=>{c(s),s=null,i()}),T}}var ps=us(),Xe=ps;function ds(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 en=ds;function fs(r){return r[Symbol.asyncIterator]!=null}function hs(r,e){let t=0;if(fs(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=en(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(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 er=hs;function Je(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ke=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}},de=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ke(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 Ke(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 tr=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function rr(r={}){return ms(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 ms(r,e){e=e??{};let t=e.onEnd,n=new de,o,s,i,a=Je(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,C)=>{s=A=>{s=null,n.push(A);try{p(r(n))}catch(D){C(D)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=Je()})}},u=p=>s!=null?s(p):(n.push(p),o),g=p=>(n=new de,s!=null?s({error:p}):(n.push({error:p}),o)),T=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 u({done:!1,value:p})},_=p=>i?o:(i=!0,p!=null?g(p):u({done:!0})),he=()=>(n=new de,_(),{done:!0}),m=p=>(_(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:he,throw:m,push:T,end:_,get readableLength(){return n.size},onEmpty:async p=>{let C=p?.signal;if(C?.throwIfAborted(),n.isEmpty())return;let A,D;C!=null&&(A=new Promise((O,M)=>{D=()=>{M(new tr)},C.addEventListener("abort",D)}));try{await Promise.race([a.promise,A])}finally{D!=null&&C!=null&&C?.removeEventListener("abort",D)}}},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:T,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 Ze=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 tn(r,e,t){if(e==null)return r;if(e.aborted)return r.catch(()=>{}),Promise.reject(new Ze(t?.errorMessage,t?.errorCode,t?.errorName));let n,o=new Ze(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 fe=new Map,Ye=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=rr(),o=rr(),s=this,i={source:async function*(){yield*er(o,async c=>(s.latency>0&&await Xe(s.latency),c))}(),sink:async c=>{for await(let u of c)n.push(u)},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:Q(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},a={source:async function*(){yield*er(n,async c=>(s.latency>0&&await Xe(s.latency),c))}(),sink:async c=>{for await(let u of c)o.push(u)},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:Q(`${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 tn(Xe(this.latency),t),this.init.onConnection(a),i}close(){[...this.connections].forEach(e=>{e.abort(new Y("Memory Connection closed"))})}};var rn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var nn=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=rn[t[r]&63];return e};var et=class extends Ue{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??nn()}`;if(t!=null&&fe.has(n))throw new Ne(`Memory address ${n} already in use`);this.connection=new Ye(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=Q(n),fe.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&&fe.delete(this.listenAddr.toString()),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var tt=class{components;init;constructor(e,t={}){this.components=e,this.init=t}[or]=!0;[Symbol.toStringTag]="@libp2p/memory";[sr]=["@libp2p/transport"];async dial(e,t){t.signal.throwIfAborted();let n=fe.get(`${e.getPeerId()==null?e:e.decapsulate("/p2p")}`);if(n==null)throw new Y(`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 et(this.components,{...e,...this.init})}listenFilter(e){return e.filter(t=>Zr.exactMatch(t))}dialFilter(e){return this.listenFilter(e)}};function xs(r){return e=>new tt(e,r)}return ln(bs);})();
3
3
  return Libp2PMemory}));
4
4
  //# sourceMappingURL=index.min.js.map