UNPKG

webpeerjs

Version:

WebPEER.js is Decentralized P2P network overlay inside browser.

5 lines โ€ข 749 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).webpeerjs=t()}(this,(function(){"use strict"; //! WebPEER.js -- https://github.com/nuzulul/webpeerjs const e="webpeerjs",t=e,n="/"+e+"/1.0.0",r=e+"-dbstore",s=["universal-connectivity-browser-peer-discovery"],i=[e+"-peer-discovery"],o=["_"+e+"-peer-data_"],a="https://delegated-ipfs.dev",c="https://dns.google/resolve",l="_dnsaddr.bootstrap.libp2p.io",u=15e3,h=!1,d=["QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN","QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb","QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt","QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"],p=["12D3KooWFhXabKDwALpzqMbto94sB7rvmZ6M28hs9Y9xSopDKwQr"],f=d.concat(p),g=[{Peers:[{Addrs:["/dns6/sv15.bootstrap.libp2p.io/tcp/443/wss","/dns4/sv15.bootstrap.libp2p.io/tcp/443/wss"],ID:"QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",Schema:"peer"}]},{Peers:[{Addrs:["/dns4/am6.bootstrap.libp2p.io/tcp/443/wss","/dns6/am6.bootstrap.libp2p.io/tcp/443/wss"],ID:"QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",Schema:"peer"}]},{Peers:[{Addrs:["/dns6/sg1.bootstrap.libp2p.io/tcp/443/wss","/dns4/sg1.bootstrap.libp2p.io/tcp/443/wss"],ID:"QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",Schema:"peer"}]}];function m(e=0){return new Uint8Array(e)}function y(e=0){return new Uint8Array(e)}const w=Math.pow(2,7),b=Math.pow(2,14),v=Math.pow(2,21),E=Math.pow(2,28),S=Math.pow(2,35),_=Math.pow(2,42),I=Math.pow(2,49),R=128,A=127;function T(e){if(e<w)return 1;if(e<b)return 2;if(e<v)return 3;if(e<E)return 4;if(e<S)return 5;if(e<_)return 6;if(e<I)return 7;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function k(e,t,n=0){switch(T(e)){case 8:t[n++]=255&e|R,e/=128;case 7:t[n++]=255&e|R,e/=128;case 6:t[n++]=255&e|R,e/=128;case 5:t[n++]=255&e|R,e/=128;case 4:t[n++]=255&e|R,e>>>=7;case 3:t[n++]=255&e|R,e>>>=7;case 2:t[n++]=255&e|R,e>>>=7;case 1:t[n++]=255&e,e>>>=7;break;default:throw new Error("unreachable")}return t}function D(e,t){let n=e[t],r=0;if(r+=n&A,n<R)return r;if(n=e[t+1],r+=(n&A)<<7,n<R)return r;if(n=e[t+2],r+=(n&A)<<14,n<R)return r;if(n=e[t+3],r+=(n&A)<<21,n<R)return r;if(n=e[t+4],r+=(n&A)*E,n<R)return r;if(n=e[t+5],r+=(n&A)*S,n<R)return r;if(n=e[t+6],r+=(n&A)*_,n<R)return r;if(n=e[t+7],r+=(n&A)*I,n<R)return r;throw new RangeError("Could not decode varint")}function P(e,t,n=0){return null==t&&(t=y(T(e))),t instanceof Uint8Array?k(e,t,n):function(e,t,n=0){switch(T(e)){case 8:t.set(n++,255&e|R),e/=128;case 7:t.set(n++,255&e|R),e/=128;case 6:t.set(n++,255&e|R),e/=128;case 5:t.set(n++,255&e|R),e/=128;case 4:t.set(n++,255&e|R),e>>>=7;case 3:t.set(n++,255&e|R),e>>>=7;case 2:t.set(n++,255&e|R),e>>>=7;case 1:t.set(n++,255&e),e>>>=7;break;default:throw new Error("unreachable")}return t}(e,t,n)}function C(e,t=0){return e instanceof Uint8Array?D(e,t):function(e,t){let n=e.get(t),r=0;if(r+=n&A,n<R)return r;if(n=e.get(t+1),r+=(n&A)<<7,n<R)return r;if(n=e.get(t+2),r+=(n&A)<<14,n<R)return r;if(n=e.get(t+3),r+=(n&A)<<21,n<R)return r;if(n=e.get(t+4),r+=(n&A)*E,n<R)return r;if(n=e.get(t+5),r+=(n&A)*S,n<R)return r;if(n=e.get(t+6),r+=(n&A)*_,n<R)return r;if(n=e.get(t+7),r+=(n&A)*I,n<R)return r;throw new RangeError("Could not decode varint")}(e,t)}const x=new Float32Array([-0]),N=new Uint8Array(x.buffer);function M(e,t,n){x[0]=e,t[n]=N[0],t[n+1]=N[1],t[n+2]=N[2],t[n+3]=N[3]}const O=new Float64Array([-0]),L=new Uint8Array(O.buffer);function B(e,t,n){O[0]=e,t[n]=L[0],t[n+1]=L[1],t[n+2]=L[2],t[n+3]=L[3],t[n+4]=L[4],t[n+5]=L[5],t[n+6]=L[6],t[n+7]=L[7]}const U=BigInt(Number.MAX_SAFE_INTEGER),F=BigInt(Number.MIN_SAFE_INTEGER);class V{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(e=!1){if(!e&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(0n===e)return K;if(e<U&&e>F)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let n=e>>32n,r=e-(n<<32n);return t&&(n=0n|~n,r=0n|~r,++r>$&&(r=0n,++n>$&&(n=0n))),new V(Number(r),Number(n))}static fromNumber(e){if(0===e)return K;const t=e<0;t&&(e=-e);let n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new V(n,r)}static from(e){return"number"==typeof e?V.fromNumber(e):"bigint"==typeof e?V.fromBigInt(e):"string"==typeof e?V.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new V(e.low>>>0,e.high>>>0):K}}const K=new V(0,0);K.toBigInt=function(){return 0n},K.zzEncode=K.zzDecode=function(){return this},K.length=function(){return 1};const $=4294967296n;function q(e,t,n){const r=n;let s,i;for(let r=0;r<e.length;++r)s=e.charCodeAt(r),s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):55296==(64512&s)&&56320==(64512&(i=e.charCodeAt(r+1)))?(s=65536+((1023&s)<<10)+(1023&i),++r,t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128);return n-r}function H(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function z(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class W{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,H(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw H(this,4);return z(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw H(this,4);return 0|z(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw H(this,4);const e=(t=this.buf,n=this.pos,N[0]=t[n],N[1]=t[n+1],N[2]=t[n+2],N[3]=t[n+3],x[0]);var t,n;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw H(this,4);const e=(t=this.buf,n=this.pos,L[0]=t[n],L[1]=t[n+1],L[2]=t[n+2],L[3]=t[n+3],L[4]=t[n+4],L[5]=t[n+5],L[6]=t[n+6],L[7]=t[n+7],O[0]);var t,n;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw H(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){const e=this.bytes();return function(e,t,n){if(n-t<1)return"";let r;const s=[];let i,o=0;for(;t<n;)i=e[t++],i<128?s[o++]=i:i>191&&i<224?s[o++]=(31&i)<<6|63&e[t++]:i>239&&i<365?(i=((7&i)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,s[o++]=55296+(i>>10),s[o++]=56320+(1023&i)):s[o++]=(15&i)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((r??(r=[])).push(String.fromCharCode.apply(String,s)),o=0);return null!=r?(o>0&&r.push(String.fromCharCode.apply(String,s.slice(0,o))),r.join("")):String.fromCharCode.apply(String,s.slice(0,o))}(e,0,e.length)}skip(e){if("number"==typeof e){if(this.pos+e>this.len)throw H(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw H(this)}while(128&this.buf[this.pos++]);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new V(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw H(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw H(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw H(this,8);const e=z(this.buf,this.pos+=4),t=z(this.buf,this.pos+=4);return new V(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=D(this.buf,this.pos);return this.pos+=T(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function j(e,t,n){const r=function(e){return new W(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(r,void 0,n)}function G(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Y=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),o=i.charCodeAt(0);if(255!==n[o])throw new TypeError(i+" is ambiguous");n[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var r=0,s=0;e[t]===c;)r++,t++;for(var i=(e.length-t)*l+1>>>0,o=new Uint8Array(i);e[t];){var u=n[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=i-1;(0!==u||h<s)&&-1!==d;d--,h++)u+=a*o[d]>>>0,o[d]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");s=h,t++}if(" "!==e[t]){for(var p=i-s;p!==i&&0===o[p];)p++;for(var f=new Uint8Array(r+(i-p)),g=r;p!==i;)f[g++]=o[p++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,s=0,i=t.length;s!==i&&0===t[s];)s++,n++;for(var o=(i-s)*u+1>>>0,l=new Uint8Array(o);s!==i;){for(var h=t[s],d=0,p=o-1;(0!==h||d<r)&&-1!==p;p--,d++)h+=256*l[p]>>>0,l[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");r=d,s++}for(var f=o-r;f!==o&&0===l[f];)f++;for(var g=c.repeat(n);f<o;++f)g+=e.charAt(l[f]);return g},decodeUnsafe:h,decode:function(e){var n=h(e);if(n)return n;throw new Error(`Non-${t} character`)}}},Q=Y;class J{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")}}let Z=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return ee(this,e)}};class X{decoders;constructor(e){this.decoders=e}or(e){return ee(this,e)}decode(e){const t=e[0],n=this.decoders[t];if(null!=n)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 ee(e,t){return new X({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class te{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,r){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=r,this.encoder=new J(e,t,n),this.decoder=new Z(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function ne({name:e,prefix:t,encode:n,decode:r}){return new te(e,t,n,r)}function re({name:e,prefix:t,alphabet:n}){const{encode:r,decode:s}=Q(n,e);return ne({prefix:t,name:e,encode:r,decode:e=>G(s(e))})}function se({name:e,prefix:t,bitsPerChar:n,alphabet:r}){return ne({prefix:t,name:e,encode:e=>function(e,t,n){const r="="===t[t.length-1],s=(1<<n)-1;let i="",o=0,a=0;for(let r=0;r<e.length;++r)for(a=a<<8|e[r],o+=8;o>n;)o-=n,i+=t[s&a>>o];if(0!==o&&(i+=t[s&a<<n-o]),r)for(;i.length*n&7;)i+="=";return i}(e,r,n),decode:t=>function(e,t,n,r){const s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let i=e.length;for(;"="===e[i-1];)--i;const o=new Uint8Array(i*n/8|0);let a=0,c=0,l=0;for(let t=0;t<i;++t){const i=s[e[t]];if(void 0===i)throw new SyntaxError(`Non-${r} character`);c=c<<n|i,a+=n,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=n||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}(t,r,n,e)})}const ie=re({prefix:"9",name:"base10",alphabet:"0123456789"});var oe=Object.freeze({__proto__:null,base10:ie});const ae=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ce=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var le=Object.freeze({__proto__:null,base16:ae,base16upper:ce});const ue=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var he=Object.freeze({__proto__:null,base2:ue});const de=Array.from("๐Ÿš€๐Ÿชโ˜„๐Ÿ›ฐ๐ŸŒŒ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒ๐ŸŒŽ๐Ÿ‰โ˜€๐Ÿ’ป๐Ÿ–ฅ๐Ÿ’พ๐Ÿ’ฟ๐Ÿ˜‚โค๐Ÿ˜๐Ÿคฃ๐Ÿ˜Š๐Ÿ™๐Ÿ’•๐Ÿ˜ญ๐Ÿ˜˜๐Ÿ‘๐Ÿ˜…๐Ÿ‘๐Ÿ˜๐Ÿ”ฅ๐Ÿฅฐ๐Ÿ’”๐Ÿ’–๐Ÿ’™๐Ÿ˜ข๐Ÿค”๐Ÿ˜†๐Ÿ™„๐Ÿ’ช๐Ÿ˜‰โ˜บ๐Ÿ‘Œ๐Ÿค—๐Ÿ’œ๐Ÿ˜”๐Ÿ˜Ž๐Ÿ˜‡๐ŸŒน๐Ÿคฆ๐ŸŽ‰๐Ÿ’žโœŒโœจ๐Ÿคท๐Ÿ˜ฑ๐Ÿ˜Œ๐ŸŒธ๐Ÿ™Œ๐Ÿ˜‹๐Ÿ’—๐Ÿ’š๐Ÿ˜๐Ÿ’›๐Ÿ™‚๐Ÿ’“๐Ÿคฉ๐Ÿ˜„๐Ÿ˜€๐Ÿ–ค๐Ÿ˜ƒ๐Ÿ’ฏ๐Ÿ™ˆ๐Ÿ‘‡๐ŸŽถ๐Ÿ˜’๐Ÿคญโฃ๐Ÿ˜œ๐Ÿ’‹๐Ÿ‘€๐Ÿ˜ช๐Ÿ˜‘๐Ÿ’ฅ๐Ÿ™‹๐Ÿ˜ž๐Ÿ˜ฉ๐Ÿ˜ก๐Ÿคช๐Ÿ‘Š๐Ÿฅณ๐Ÿ˜ฅ๐Ÿคค๐Ÿ‘‰๐Ÿ’ƒ๐Ÿ˜ณโœ‹๐Ÿ˜š๐Ÿ˜๐Ÿ˜ด๐ŸŒŸ๐Ÿ˜ฌ๐Ÿ™ƒ๐Ÿ€๐ŸŒท๐Ÿ˜ป๐Ÿ˜“โญโœ…๐Ÿฅบ๐ŸŒˆ๐Ÿ˜ˆ๐Ÿค˜๐Ÿ’ฆโœ”๐Ÿ˜ฃ๐Ÿƒ๐Ÿ’โ˜น๐ŸŽŠ๐Ÿ’˜๐Ÿ˜ โ˜๐Ÿ˜•๐ŸŒบ๐ŸŽ‚๐ŸŒป๐Ÿ˜๐Ÿ–•๐Ÿ’๐Ÿ™Š๐Ÿ˜น๐Ÿ—ฃ๐Ÿ’ซ๐Ÿ’€๐Ÿ‘‘๐ŸŽต๐Ÿคž๐Ÿ˜›๐Ÿ”ด๐Ÿ˜ค๐ŸŒผ๐Ÿ˜ซโšฝ๐Ÿค™โ˜•๐Ÿ†๐Ÿคซ๐Ÿ‘ˆ๐Ÿ˜ฎ๐Ÿ™†๐Ÿป๐Ÿƒ๐Ÿถ๐Ÿ’๐Ÿ˜ฒ๐ŸŒฟ๐Ÿงก๐ŸŽโšก๐ŸŒž๐ŸŽˆโŒโœŠ๐Ÿ‘‹๐Ÿ˜ฐ๐Ÿคจ๐Ÿ˜ถ๐Ÿค๐Ÿšถ๐Ÿ’ฐ๐Ÿ“๐Ÿ’ข๐ŸคŸ๐Ÿ™๐Ÿšจ๐Ÿ’จ๐Ÿคฌโœˆ๐ŸŽ€๐Ÿบ๐Ÿค“๐Ÿ˜™๐Ÿ’Ÿ๐ŸŒฑ๐Ÿ˜–๐Ÿ‘ถ๐Ÿฅดโ–ถโžกโ“๐Ÿ’Ž๐Ÿ’ธโฌ‡๐Ÿ˜จ๐ŸŒš๐Ÿฆ‹๐Ÿ˜ท๐Ÿ•บโš ๐Ÿ™…๐Ÿ˜Ÿ๐Ÿ˜ต๐Ÿ‘Ž๐Ÿคฒ๐Ÿค ๐Ÿคง๐Ÿ“Œ๐Ÿ”ต๐Ÿ’…๐Ÿง๐Ÿพ๐Ÿ’๐Ÿ˜—๐Ÿค‘๐ŸŒŠ๐Ÿคฏ๐Ÿทโ˜Ž๐Ÿ’ง๐Ÿ˜ฏ๐Ÿ’†๐Ÿ‘†๐ŸŽค๐Ÿ™‡๐Ÿ‘โ„๐ŸŒด๐Ÿ’ฃ๐Ÿธ๐Ÿ’Œ๐Ÿ“๐Ÿฅ€๐Ÿคข๐Ÿ‘…๐Ÿ’ก๐Ÿ’ฉ๐Ÿ‘๐Ÿ“ธ๐Ÿ‘ป๐Ÿค๐Ÿคฎ๐ŸŽผ๐Ÿฅต๐Ÿšฉ๐ŸŽ๐ŸŠ๐Ÿ‘ผ๐Ÿ’๐Ÿ“ฃ๐Ÿฅ‚"),pe=de.reduce(((e,t,n)=>(e[n]=t,e)),[]),fe=de.reduce(((e,t,n)=>(e[t.codePointAt(0)]=n,e)),[]);const ge=ne({prefix:"๐Ÿš€",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pe[t]),"")},decode:function(e){const t=[];for(const n of e){const e=fe[n.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${n}`);t.push(e)}return new Uint8Array(t)}});var me=Object.freeze({__proto__:null,base256emoji:ge});const ye=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),we=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),be=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ve=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ee=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Se=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_e=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ie=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Re=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ae=Object.freeze({__proto__:null,base32:ye,base32hex:Ee,base32hexpad:_e,base32hexpadupper:Ie,base32hexupper:Se,base32pad:be,base32padupper:ve,base32upper:we,base32z:Re});const Te=re({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ke=re({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var De=Object.freeze({__proto__:null,base36:Te,base36upper:ke});const Pe=re({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ce=re({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xe=Object.freeze({__proto__:null,base58btc:Pe,base58flickr:Ce});const Ne=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Me=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Oe=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Le=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Be=Object.freeze({__proto__:null,base64:Ne,base64pad:Me,base64url:Oe,base64urlpad:Le});const Ue=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fe=Object.freeze({__proto__:null,base8:Ue});const Ve=ne({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)});var Ke=Object.freeze({__proto__:null,identity:Ve});new TextEncoder,new TextDecoder;var $e=function e(t,n,r){n=n||[];var s=r=r||0;for(;t>=ze;)n[r++]=255&t|qe,t/=128;for(;t&He;)n[r++]=255&t|qe,t>>>=7;return n[r]=0|t,e.bytes=r-s+1,n},qe=128,He=-128,ze=Math.pow(2,31);var We=function e(t,n){var r,s=0,i=0,o=n=n||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");r=t[o++],s+=i<28?(r&Ge)<<i:(r&Ge)*Math.pow(2,i),i+=7}while(r>=je);return e.bytes=o-n,s},je=128,Ge=127;var Ye=Math.pow(2,7),Qe=Math.pow(2,14),Je=Math.pow(2,21),Ze=Math.pow(2,28),Xe=Math.pow(2,35),et=Math.pow(2,42),tt=Math.pow(2,49),nt=Math.pow(2,56),rt=Math.pow(2,63),st={encode:$e,decode:We,encodingLength:function(e){return e<Ye?1:e<Qe?2:e<Je?3:e<Ze?4:e<Xe?5:e<et?6:e<tt?7:e<nt?8:e<rt?9:10}};function it(e,t=0){return[st.decode(e,t),st.decode.bytes]}function ot(e,t,n=0){return st.encode(e,t,n),t}function at(e){return st.encodingLength(e)}function ct(e,t){const n=t.byteLength,r=at(e),s=r+at(n),i=new Uint8Array(s+n);return ot(e,i,0),ot(n,i,r),i.set(t,s),new ut(e,n,t,i)}function lt(e){const t=G(e),[n,r]=it(t),[s,i]=it(t.subarray(r)),o=t.subarray(r+i);if(o.byteLength!==s)throw new Error("Incorrect length");return new ut(n,s,o,t)}class ut{code;size;digest;bytes;constructor(e,t,n,r){this.code=e,this.size=t,this.digest=n,this.bytes=r}}const ht=G;const dt={code:0,name:"identity",encode:ht,digest:function(e){return ct(0,ht(e))}};class pt{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ct(this.code,t):t.then((e=>ct(this.code,e)))}throw Error("Unknown type, must be binary type")}}const ft=function({name:e,code:t,encode:n}){return new pt(e,t,n)}({name:"sha2-256",code:18,encode:function(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}("SHA-256")});function gt(e,t){const{bytes:n,version:r}=e;return 0===r?function(e,t,n){const{prefix:r}=n;if(r!==Pe.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);const s=t.get(r);if(null==s){const s=n.encode(e).slice(1);return t.set(r,s),s}return s}(n,yt(e),t??Pe.encoder):function(e,t,n){const{prefix:r}=n,s=t.get(r);if(null==s){const s=n.encode(e);return t.set(r,s),s}return s}(n,yt(e),t??ye.encoder)}const mt=new WeakMap;function yt(e){const t=mt.get(e);if(null==t){const t=new Map;return mt.set(e,t),t}return t}class wt{code;version;multihash;bytes;"/";constructor(e,t,n,r){this.code=t,this.version=e,this.multihash=n,this.bytes=r,this["/"]=r}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:{const{code:e,multihash:t}=this;if(e!==bt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return wt.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:{const{code:e,digest:t}=this.multihash,n=ct(e,t);return wt.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 wt.equals(this,e)}static equals(e,t){const n=t;return null!=n&&e.code===n.code&&e.version===n.version&&function(e,t){if(e===t)return!0;{const n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}(e.bytes,n.bytes)}}(e.multihash,n.multihash)}toString(e){return gt(this,e)}toJSON(){return{"/":gt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof wt)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:n,multihash:r,bytes:s}=t;return new wt(e,n,r,s??Et(e,n,r.bytes))}if(!0===t[St]){const{version:e,multihash:n,code:r}=t,s=lt(n);return wt.create(e,r,s)}return null}static create(e,t,n){if("number"!=typeof t)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!==bt)throw new Error(`Version 0 CID must use dag-pb (code: ${bt}) block encoding`);return new wt(e,t,n,n.bytes);case 1:{const r=Et(e,t,n.bytes);return new wt(e,t,n,r)}default:throw new Error("Invalid version")}}static createV0(e){return wt.create(0,bt,e)}static createV1(e,t){return wt.create(1,e,t)}static decode(e){const[t,n]=wt.decodeFirst(e);if(0!==n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=wt.inspectBytes(e),n=t.size-t.multihashSize,r=G(e.subarray(n,n+t.multihashSize));if(r.byteLength!==t.multihashSize)throw new Error("Incorrect length");const s=r.subarray(t.multihashSize-t.digestSize),i=new ut(t.multihashCode,t.digestSize,s,r);return[0===t.version?wt.createV0(i):wt.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const n=()=>{const[n,r]=it(e.subarray(t));return t+=r,n};let r=n(),s=bt;if(18===r?(r=0,t=0):s=n(),0!==r&&1!==r)throw new RangeError(`Invalid CID version ${r}`);const i=t,o=n(),a=n(),c=t+a;return{version:r,codec:s,multihashCode:o,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[n,r]=function(e,t){switch(e[0]){case"Q":{const n=t??Pe;return[Pe.prefix,n.decode(`${Pe.prefix}${e}`)]}case Pe.prefix:{const n=t??Pe;return[Pe.prefix,n.decode(e)]}case ye.prefix:{const n=t??ye;return[ye.prefix,n.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),s=wt.decode(r);if(0===s.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return yt(s).set(n,e),s}}const bt=112,vt=18;function Et(e,t,n){const r=at(e),s=r+at(t),i=new Uint8Array(s+n.byteLength);return ot(e,i,0),ot(t,i,r),i.set(n,s),i}const St=Symbol.for("@ipld/js-cid/CID"),_t={...Ke,...he,...Fe,...oe,...le,...Ae,...De,...xe,...Be,...me};function It(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const Rt=It("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),At=It("ascii","a",(e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}),(e=>{const t=y((e=e.substring(1)).length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t})),Tt={utf8:Rt,"utf-8":Rt,hex:_t.base16,latin1:At,ascii:At,binary:At,..._t};function kt(e,t="utf8"){const n=Tt[t];if(null==n)throw new Error(`Unsupported encoding "${t}"`);return n.decoder.decode(`${n.prefix}${e}`)}class Dt{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}}function Pt(){}class Ct{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const xt=function(e){const t=8192;let n,r=t;return function(e){if(e<1||e>4096)return y(e);r+e>t&&(n=y(t),r=0);const s=n.subarray(r,r+=e);return 7&r&&(r=1+(7|r)),s}}();class Nt{len;head;tail;states;constructor(){this.len=0,this.head=new Dt(Pt,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Dt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Lt((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Bt,10,V.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=V.fromBigInt(e);return this._push(Bt,t.length(),t)}uint64Number(e){return this._push(k,T(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=V.fromBigInt(e).zzEncode();return this._push(Bt,t.length(),t)}sint64Number(e){const t=V.fromNumber(e).zzEncode();return this._push(Bt,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Mt,1,e?1:0)}fixed32(e){return this._push(Ut,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=V.fromBigInt(e);return this._push(Ut,4,t.lo)._push(Ut,4,t.hi)}fixed64Number(e){const t=V.fromNumber(e);return this._push(Ut,4,t.lo)._push(Ut,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(M,4,e)}double(e){return this._push(B,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Mt,1,0):this.uint32(t)._push(Ft,t,e)}string(e){const t=function(e){let t=0,n=0;for(let r=0;r<e.length;++r)n=e.charCodeAt(r),n<128?t+=1:n<2048?t+=2:55296==(64512&n)&&56320==(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(q,t,e):this._push(Mt,1,0)}fork(){return this.states=new Ct(this),this.head=this.tail=new Dt(Pt,0,0),this.len=0,this}reset(){return null!=this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Dt(Pt,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),0!==n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next;const t=(n=this.len,null!=globalThis.Buffer?y(n):xt(n));var n;let r=0;for(;null!=e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t}}function Mt(e,t,n){t[n]=255&e}function Ot(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e}class Lt extends Dt{next;constructor(e,t){super(Ot,e,t),this.next=void 0}}function Bt(e,t,n){for(;0!==e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function Ut(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function Ft(e,t,n){t.set(e,n)}function Vt(e,t,n){t.set(e,n)}function Kt(e,t,n){e.length<40?q(e,t,n):null!=t.utf8Write?t.utf8Write(e,n):t.set(kt(e),n)}function $t(e,t){const n=new Nt;return t.encode(e,n,{lengthDelimited:!1}),n.finish()}var qt;function Ht(e,t,n,r){return{name:e,type:t,encode:n,decode:r}}function zt(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return Ht("enum",qt.VARINT,(function(e,n){const r=t(e);n.int32(r)}),(function(e){return t(e.int32())}))}function Wt(e,t){return Ht("message",qt.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Nt.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Vt,t,e),this},Nt.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Kt,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(qt||(qt={}));let jt=class extends Error{code;constructor(e,t,n){super(e,n),this.code=t}}; //! WebPEER.js -- https://github.com/nuzulul/webpeerjs var Gt;function Yt(e,t="utf8"){const n=Tt[t];if(null==n)throw new Error(`Unsupported encoding "${t}"`);return n.encoder.encode(e).substring(1)}!function(e){let t;e.codec=()=>(null==t&&(t=Wt(((e,t,n={})=>{if(!1!==n.lengthDelimited&&t.fork(),null!=e.publicKey&&e.publicKey.byteLength>0&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.addrs)for(const n of e.addrs)t.uint32(18),t.bytes(n);!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={publicKey:m(0),addrs:[]},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.publicKey=e.bytes();break;case 2:n.addrs.push(e.bytes());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=t=>j(t,e.codec())}(Gt||(Gt={}));const Qt="/",Jt=(new TextEncoder).encode(Qt),Zt=Jt[0];class Xt{_buf;constructor(e,t){if("string"==typeof e)this._buf=kt(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==Zt)throw new Error("Invalid key")}toString(e="utf8"){return Yt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Xt(e.join(Qt))}static random(){return new Xt(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new Xt(e):"function"==typeof e.uint8Array?new Xt(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=Jt),this._buf[0]!==Zt){const e=new Uint8Array(this._buf.byteLength+1);e.fill(Zt,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Zt;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),n=e.list();for(let e=0;e<t.length;e++){if(n.length<e+1)return!1;const r=t[e],s=n[e];if(r<s)return!0;if(r>s)return!1}return t.length<n.length}reverse(){return Xt.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Qt).slice(1)}type(){return function(e){const t=e.split(":");if(t.length<2)return"";return t.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(e){const t=e.split(":");return t[t.length-1]}(this.baseNamespace())}instance(e){return new Xt(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Qt)||(e+=Qt),e+=this.type(),new Xt(e)}parent(){const e=this.list();return 1===e.length?new Xt(Qt):new Xt(e.slice(0,-1).join(Qt))}child(e){return this.toString()===Qt?e:e.toString()===Qt?this:new Xt(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()!==this.toString()&&e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()!==this.toString()&&this.toString().startsWith(e.toString())}isTopLevel(){return 1===this.list().length}concat(...e){return Xt.withNamespaces([...this.namespaces(),...(t=e.map((e=>e.namespaces())),[].concat(...t))]);var t}}const en=Symbol.for("@libp2p/connection"),tn=Symbol.for("@libp2p/content-routing"),nn=Symbol.for("@libp2p/peer-discovery"),rn=Symbol.for("@libp2p/peer-id");function sn(e){return null!=e&&Boolean(e[rn])}const on=Symbol.for("@libp2p/peer-routing"),an="StrictSign",cn="StrictNoSign";var ln;!function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"}(ln||(ln={}));const un=Symbol.for("@libp2p/transport");var hn;!function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"}(hn||(hn={}));let dn=class e extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.name="AbortError",this.code=e.code,this.type=e.type}static code="ABORT_ERR";static type="aborted"},pn=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};class fn extends AggregateError{code;props;constructor(e,t,n,r){super(e,t),this.code=n,this.name=r?.name??"AggregateCodeError",this.props=r??{}}}const gn="ERR_TIMEOUT",mn="ERR_INVALID_MESSAGE";class yn extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){const t=this.#e.get(e);return null==t?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let r=this.#e.get(e);null==r&&(r=[],this.#e.set(e,r)),r.push({callback:t,once:(!0!==n&&!1!==n&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let r=this.#e.get(e);null!=r&&(r=r.filter((({callback:e})=>e!==t)),this.#e.set(e,r))}dispatchEvent(e){const t=super.dispatchEvent(e);let n=this.#e.get(e.type);return null==n||(n=n.filter((({once:e})=>!e)),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new bn(e,t))}}class wn extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}}const bn=globalThis.CustomEvent??wn;function vn(e){return null!=e&&"function"==typeof e.start&&"function"==typeof e.stop}const En=Symbol.for("@libp2p/service-capabilities"),Sn=Symbol.for("@libp2p/service-dependencies");function _n(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function In(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const n=y(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}const Rn=45,An=15,Tn=new class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){const t=this.index,n=e();return void 0===n&&(this.index=t),n}parseWith(e){const 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((()=>{const t=this.readChar();if(t===e)return t}))}readSeparator(e,t,n){return this.readAtomically((()=>{if(!(t>0&&void 0===this.readGivenChar(e)))return n()}))}readNumber(e,t,n,r){return this.readAtomically((()=>{let s=0,i=0;const o=this.peekChar();if(void 0===o)return;const a="0"===o,c=2**(8*r)-1;for(;;){const n=this.readAtomically((()=>{const t=this.readChar();if(void 0===t)return;const n=Number.parseInt(t,e);return Number.isNaN(n)?void 0:n}));if(void 0===n)break;if(s*=e,s+=n,s>c)return;if(i+=1,void 0!==t&&i>t)return}return 0===i||!n&&a&&i>1?void 0:s}))}readIPv4Addr(){return this.readAtomically((()=>{const e=new Uint8Array(4);for(let t=0;t<e.length;t++){const n=this.readSeparator(".",t,(()=>this.readNumber(10,3,!1,1)));if(void 0===n)return;e[t]=n}return e}))}readIPv6Addr(){const e=e=>{for(let t=0;t<e.length/2;t++){const n=2*t;if(t<e.length-3){const r=this.readSeparator(":",t,(()=>this.readIPv4Addr()));if(void 0!==r)return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],[n+4,!0]}const r=this.readSeparator(":",t,(()=>this.readNumber(16,4,!0,2)));if(void 0===r)return[n,!1];e[n]=r>>8,e[n+1]=255&r}return[e.length,!1]};return this.readAtomically((()=>{const t=new Uint8Array(16),[n,r]=e(t);if(16===n)return t;if(r)return;if(void 0===this.readGivenChar(":"))return;if(void 0===this.readGivenChar(":"))return;const s=new Uint8Array(14),i=16-(n+2),[o]=e(s.subarray(0,i));return t.set(s.subarray(0,o),16-o),t}))}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};function kn(e){return Boolean(function(e){if(!(e.length>An))return Tn.new(e).parseWith((()=>Tn.readIPv4Addr()))}(e))}function Dn(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Rn))return Tn.new(e).parseWith((()=>Tn.readIPv6Addr()))}(e))}function Pn(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Rn))return Tn.new(e).parseWith((()=>Tn.readIPAddr()))}(e))}const Cn=kn,xn=Dn,Nn=function(e){let t=0;if(e=e.toString().trim(),Cn(e)){const n=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{n[t++]=255&parseInt(e,10)})),n}if(xn(e)){const n=e.split(":",8);let r;for(r=0;r<n.length;r++){let e;Cn(n[r])&&(e=Nn(n[r]),n[r]=Yt(e.slice(0,2),"base16")),null!=e&&++r<8&&n.splice(r,0,Yt(e.slice(2,4),"base16"))}if(""===n[0])for(;n.length<8;)n.unshift("0");else if(""===n[n.length-1])for(;n.length<8;)n.push("0");else if(n.length<8){for(r=0;r<n.length&&""!==n[r];r++);const e=[r,1];for(r=9-n.length;r>0;r--)e.push("0");n.splice.apply(n,e)}const s=new Uint8Array(t+16);for(r=0;r<n.length;r++){const e=parseInt(n[r],16);s[t++]=e>>8&255,s[t++]=255&e}return s}throw new Error("invalid ip address")},Mn=function(e,t=0,n){t=~~t,n=n??e.length-t;const r=new DataView(e.buffer);if(4===n){const r=[];for(let s=0;s<n;s++)r.push(e[t+s]);return r.join(".")}if(16===n){const e=[];for(let s=0;s<n;s+=2)e.push(r.getUint16(t+s).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},On=-1,Ln={},Bn={};function Un(e){if("number"==typeof e){if(null!=Bn[e])return Bn[e];throw new Error(`no protocol with code: ${e}`)}if("string"==typeof e){if(null!=Ln[e])return Ln[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}function Fn(e,t){switch(Un(e).code){case 4:case 41:return function(e){const t=Mn(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Pn(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return jn(t);case 6:case 273:case 33:case 132:return zn(t).toString();case 421:return function(e){const t=C(e),n=e.slice(T(t));if(n.length!==t)throw new Error("inconsistent lengths");return Yt(n,"base58btc")}(t);case 444:case 445:return Gn(t);case 466:return function(e){const t=C(e),n=e.slice(T(t));if(n.length!==t)throw new Error("inconsistent lengths");return"u"+Yt(n,"base64url")}(t);case 481:return globalThis.encodeURIComponent(jn(t));default:return Yt(t,"base16")}}function Vn(e,t){switch(Un(e).code){case 4:case 41:return qn(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Wn(t);case 6:case 273:case 33:case 132:return Hn(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?lt(Pe.decode(`z${e}`)).bytes:wt.parse(e).multihash.bytes;const n=Uint8Array.from(P(t.length));return In([n,t],n.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const n=ye.decode("b"+t[0]),r=parseInt(t[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const s=Hn(r);return In([n,s],n.length+s.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const n=ye.decode(`b${t[0]}`),r=parseInt(t[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const s=Hn(r);return In([n,s],n.length+s.length)}(t);case 466:return function(e){const t=$n.decode(e),n=Uint8Array.from(P(t.length));return In([n,t],n.length+t.length)}(t);case 481:return Wn(globalThis.decodeURIComponent(t));default:return kt(t,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,On,"ip6zone"],[43,8,"ipcidr"],[53,On,"dns",!0],[54,On,"dns4",!0],[55,On,"dns6",!0],[56,On,"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,On,"unix",!1,!0],[421,On,"ipfs"],[421,On,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,On,"garlic64"],[448,0,"tls"],[449,On,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,On,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,On,"http-path"],[777,On,"memory"]].forEach((e=>{const t=function(e,t,n,r,s){return{code:e,size:t,name:n,resolvable:Boolean(r),path:Boolean(s)}}(...e);Bn[t.code]=t,Ln[t.name]=t})),Un("ip4"),Un("ip6"),Un("ipcidr");const Kn=Object.values(_t).map((e=>e.decoder)),$n=function(){let e=Kn[0].or(Kn[1]);return Kn.slice(2).forEach((t=>e=e.or(t))),e}();function qn(e){if(!Pn(e))throw new Error("invalid ip address");return Nn(e)}function Hn(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function zn(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Wn(e){const t=kt(e),n=Uint8Array.from(P(t.length));return In([n,t],n.length+t.length)}function jn(e){const t=C(e);if((e=e.slice(T(t))).length!==t)throw new Error("inconsistent lengths");return Yt(e)}function Gn(e){const t=e.slice(0,e.length-2),n=e.slice(e.length-2);return`${Yt(t,"base32")}:${zn(n)}`}function Yn(e){const t=[],n=[];let r=null,s=0;for(;s<e.length;){const i=C(e,s),o=T(i),a=Un(i),c=Zn(a,e.slice(s+o));if(0===c){t.push([i]),n.push([i]),s+=o;continue}const l=e.slice(s+o,s+o+c);if(s+=c+o,s>e.length)throw er("Invalid address Uint8Array: "+Yt(e,"base16"));t.push([i,l]);const u=Fn(i,l);if(n.push([i,u]),!0===a.path){r=u;break}}return{bytes:Uint8Array.from(e),string:Qn(n),tuples:t,stringTuples:n,path:r}}function Qn(e){const t=[];return e.map((e=>{const n=Un(e[0]);return t.push(n.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),Xn(t.join("/"))}function Jn(e){return In(e.map((e=>{const t=Un(e[0]);let n=Uint8Array.from(P(t.code));return e.length>1&&null!=e[1]&&(n=In([n,e[1]])),n})))}function Zn(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=C(t instanceof Uint8Array?t:Uint8Array.from(t));return e+T(e)}}function Xn(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function er(e){return new Error("Error parsing address: "+e)}const tr=Symbol.for("nodejs.util.inspect.custom"),nr=Symbol.for("@multiformats/js-multiaddr/multiaddr"),rr=[Un("dns").code,Un("dns4").code,Un("dns6").code,Un("dnsaddr").code];class sr{bytes;#t;#n;#r;#s;[nr]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=Yn(e);else if("string"==typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],n=[];let r=null;const s=(e=Xn(e)).split("/").slice(1);if(1===s.length&&""===s[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<s.length;i++){const o=Un(s[i]);if(0===o.size){t.push([o.code]),n.push([o.code]);continue}if(i++,i>=s.length)throw er("invalid address: "+e);if(!0===o.path){r=Xn(s.slice(i).join("/")),t.push([o.code,Vn(o.code,r)]),n.push([o.code,r]);break}const a=Vn(o.code,s[i]);t.push([o.code,a]),n.push([o.code,Fn(o.code,a)])}return{string:Qn(n),bytes:Jn(t),tuples:t,stringTuples:n,path:r}}(e)}else{if(!or(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=Yn(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#n=t.tuples,this.#r=t.stringTuples,this.#s=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,r,s="";const i=Un("tcp"),o=Un("udp"),a=Un("ip4"),c=Un("ip6"),l=Un("dns6"),u=Un("ip6zone");for(const[h,d]of this.stringTuples())h===u.code&&(s=`%${d??""}`),rr.includes(h)&&(t=i.name,r=443,n=`${d??""}${s}`,e=h===l.code?6:4),h!==i.code&&h!==o.code||(t=Un(h).name,r=parseInt(d??"")),h!==a.code&&h!==c.code||(t=Un(h).name,n=`${d??""}${s}`,e=h===c.code?6:4);if(null==e||null==t||null==n||null==r)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:r}}protos(){return this.#n.map((([e])=>Object.assign({},Un(e))))}protoCodes(){return this.#n.map((([e])=>e))}protoNames(){return this.#n.map((([e])=>Un(e).name))}tuples(){return this.#n}stringTuples(){return this.#r}encapsulate(e){return e=new sr(e),new sr(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),n=this.toString(),r=n.lastIndexOf(t);if(r<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new sr(n.slice(0,r))}decapsulateCode(e){const t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new sr(Jn(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((([t,n])=>{t===Ln.p2p.code&&e.push([t,n]),t===Ln["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?Yt(Pe.decode(`z${e}`),"base58btc"):Yt(wt.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#s}equals(e){return _n(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const n=ir.get(t.name);if(null==n)throw new pn(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map((e=>ar(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)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){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[tr](){return`Multiaddr(${this.#t})`}}const ir=new Map;function or(e){return Boolean(e?.[nr])}function ar(e){return new sr(e)}function cr(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}class lr{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)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 void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class ur{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new lr(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){if(null!=e?.value&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){const t=this.head;this.head=t.next=new lr(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}let hr=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function dr(e={}){return function(e,t){t=t??{};let n,r,s,i=t.onEnd,o=new ur,a=cr();const c=async()=>{try{return o.isEmpty()?s?{done:!0}:await new Promise(((t,s)=>{r=i=>{r=null,o.push(i);try{t(e(o))}catch(e){s(e)}return n}})):e(o)}finally{o.isEmpty()&&queueMicrotask((()=>{a.resolve(),a=cr()}))}},l=e=>null!=r?r(e):(o.push(e),n),u=e=>(o=new ur,null!=r?r({error:e}):(o.push({error:e}),n)),h=e=>{if(s)return n;if(!0!==t?.objectMode&&null==e?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:e})},d=e=>s?n:(s=!0,null!=e?u(e):l({done:!0})),p=()=>(o=new ur,d(),{done:!0}),f=e=>(d(e),{done:!0});if(n={[Symbol.asyncIterator](){return this},next:c,return:p,throw:f,push:h,end:d,get readableLength(){return o.size},onEmpty:async e=>{const t=e?.signal;if(t?.throwIfAborted(),o.isEmpty())return;let n,r;null!=t&&(n=new Promise(((e,n)=>{r=()=>{n(new hr)},t.addEventListener("abort",r)})));try{await Promise.race([a.promise,n])}finally{null!=r&&null!=t&&t?.removeEventListener("abort",r)}}},null==i)return n;const g=n;return n={[Symbol.asyncIterator](){return this},next:()=>g.next(),throw:e=>(g.throw(e),null!=i&&(i(e),i=void 0),{done:!0}),return:()=>(g.return(),null!=i&&(i(),i=void 0),{done:!0}),push:h,end:e=>(g.end(e),null!=i&&(i(e),i=void 0),n),get readableLength(){return g.readableLength},onEmpty:e=>g.onEmpty(e)},n}((e=>{const t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}}),e)}function pr(...e){const t=[];for(const n of e)null==n[Symbol.asyncIterator]&&t.push(n);return t.length===e.length?function*(){for(const e of t)yield*e}():async function*(){const t=dr({objectMode:!0});Promise.resolve().then((async()=>{try{await Promise.all(e.map((async e=>{for await(const n of e)t.push(n)}))),t.end()}catch(e){t.end(e)}})),yield*t}()}function fr(e,...t){if(null==e)throw new Error("Empty pipeline");if(wr(e)){const t=e;e=()=>t.source}else if(yr(e)||mr(e)){const t