@libp2p/daemon-client 7.0.1 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # @libp2p/daemon-client <!-- omit in toc -->
2
-
3
1
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
2
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
5
3
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon)
@@ -7,37 +5,26 @@
7
5
 
8
6
  > libp2p-daemon client implementation
9
7
 
10
- ## Table of contents <!-- omit in toc -->
11
-
12
- - [Install](#install)
13
- - [Specs](#specs)
14
- - [Usage](#usage)
15
- - [Run a daemon process](#run-a-daemon-process)
16
- - [Interact with the daemon process using the client](#interact-with-the-daemon-process-using-the-client)
17
- - [API](#api)
18
- - [License](#license)
19
- - [Contribution](#contribution)
20
-
21
- ## Install
8
+ # Install
22
9
 
23
10
  ```console
24
11
  $ npm i @libp2p/daemon-client
25
12
  ```
26
13
 
27
- ## Specs
14
+ # Specs
28
15
 
29
16
  The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md)
30
17
 
31
- ## Usage
18
+ # Usage
32
19
 
33
- ### Run a daemon process
20
+ ## Run a daemon process
34
21
 
35
22
  There are currently two implementations of the `libp2p-daemon`:
36
23
 
37
24
  - [js-libp2p-daemon](https://github.com/libp2p/js-libp2p-daemon)
38
25
  - [go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon)
39
26
 
40
- ### Interact with the daemon process using the client
27
+ ## Interact with the daemon process using the client
41
28
 
42
29
  ```js
43
30
  import { createClient } from '@libp2p/daemon-client'
@@ -58,30 +45,17 @@ try {
58
45
  await client.close()
59
46
  ```
60
47
 
61
- ## API
62
-
63
- - [Getting started](API.md#getting-started)
64
- - [`close`](API.md#close)
65
- - [`connect`](API.md#connect)
66
- - [`identify`](API.md#identify)
67
- - [`listPeers`](API.md#listPeers)
68
- - [`openStream`](API.md#openStream)
69
- - [`registerStream`](API.md#registerStream)
70
- - [`dht.put`](API.md#dht.put)
71
- - [`dht.get`](API.md#dht.get)
72
- - [`dht.findPeer`](API.md#dht.findPeer)
73
- - [`dht.provide`](API.md#dht.provide)
74
- - [`dht.findProviders`](API.md#dht.findProviders)
75
- - [`dht.getClosestPeers`](API.md#dht.getClosestPeers)
76
- - [`dht.getPublicKey`](API.md#dht.getPublicKey)
77
-
78
- ## License
48
+ # API Docs
49
+
50
+ - <https://libp2p.github.io/js-libp2p-daemon/modules/_libp2p_daemon_client.html>
51
+
52
+ # License
79
53
 
80
54
  Licensed under either of
81
55
 
82
56
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
83
57
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
84
58
 
85
- ## Contribution
59
+ # Contribution
86
60
 
87
61
  Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
package/dist/index.min.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PDaemonClient=(()=>{var yu=Object.create;var ar=Object.defineProperty;var bu=Object.getOwnPropertyDescriptor;var wu=Object.getOwnPropertyNames;var Eu=Object.getPrototypeOf,vu=Object.prototype.hasOwnProperty;var Ft=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var L=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ft=(r,t)=>{for(var e in t)ar(r,e,{get:t[e],enumerable:!0})},ji=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of wu(t))!vu.call(r,i)&&i!==e&&ar(r,i,{get:()=>t[i],enumerable:!(n=bu(t,i))||n.enumerable});return r};var F=(r,t,e)=>(e=r!=null?yu(Eu(r)):{},ji(t||!r||!r.__esModule?ar(e,"default",{value:r,enumerable:!0}):e,r)),Tu=r=>ji(ar({},"__esModule",{value:!0}),r);var Qi=L((Oh,Ji)=>{"use strict";Ji.exports=Su;function Su(r,t){for(var e=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)e[n++]=arguments[i++];return new Promise(function(f,l){e[n]=function(h){if(s)if(s=!1,h)l(h);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];f.apply(null,g)}};try{r.apply(t||null,e)}catch(d){s&&(s=!1,l(d))}})}});var ns=L(rs=>{"use strict";var ur=rs;ur.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var Ee=new Array(64),es=new Array(123);for(It=0;It<64;)es[Ee[It]=It<26?It+65:It<52?It+71:It<62?It-4:It-59|43]=It++;var It;ur.encode=function(t,e,n){for(var i=null,s=[],a=0,f=0,l;e<n;){var d=t[e++];switch(f){case 0:s[a++]=Ee[d>>2],l=(d&3)<<4,f=1;break;case 1:s[a++]=Ee[l|d>>4],l=(d&15)<<2,f=2;break;case 2:s[a++]=Ee[l|d>>6],s[a++]=Ee[d&63],f=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return f&&(s[a++]=Ee[l],s[a++]=61,f===1&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var ts="invalid encoding";ur.decode=function(t,e,n){for(var i=n,s=0,a,f=0;f<t.length;){var l=t.charCodeAt(f++);if(l===61&&s>1)break;if((l=es[l])===void 0)throw Error(ts);switch(s){case 0:a=l,s=1;break;case 1:e[n++]=a<<2|(l&48)>>4,a=l,s=2;break;case 2:e[n++]=(a&15)<<4|(l&60)>>2,a=l,s=3;break;case 3:e[n++]=(a&3)<<6|l,s=0;break}}if(s===1)throw Error(ts);return n-i};ur.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var ss=L((Uh,is)=>{"use strict";is.exports=lr;function lr(){this._listeners={}}lr.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};lr.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===e?n.splice(i,1):++i;return this};lr.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<e.length;)e[i].fn.apply(e[i++].ctx,n)}return this}});var hs=L((Fh,fs)=>{"use strict";fs.exports=os(os);function os(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(l,d,h){t[0]=l,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3]}function s(l,d,h){t[0]=l,d[h]=e[3],d[h+1]=e[2],d[h+2]=e[1],d[h+3]=e[0]}r.writeFloatLE=n?i:s,r.writeFloatBE=n?s:i;function a(l,d){return e[0]=l[d],e[1]=l[d+1],e[2]=l[d+2],e[3]=l[d+3],t[0]}function f(l,d){return e[3]=l[d],e[2]=l[d+1],e[1]=l[d+2],e[0]=l[d+3],t[0]}r.readFloatLE=n?a:f,r.readFloatBE=n?f:a}():function(){function t(n,i,s,a){var f=i<0?1:0;if(f&&(i=-i),i===0)n(1/i>0?0:2147483648,s,a);else if(isNaN(i))n(2143289344,s,a);else if(i>34028234663852886e22)n((f<<31|2139095040)>>>0,s,a);else if(i<11754943508222875e-54)n((f<<31|Math.round(i/1401298464324817e-60))>>>0,s,a);else{var l=Math.floor(Math.log(i)/Math.LN2),d=Math.round(i*Math.pow(2,-l)*8388608)&8388607;n((f<<31|l+127<<23|d)>>>0,s,a)}}r.writeFloatLE=t.bind(null,cs),r.writeFloatBE=t.bind(null,as);function e(n,i,s){var a=n(i,s),f=(a>>31)*2+1,l=a>>>23&255,d=a&8388607;return l===255?d?NaN:f*(1/0):l===0?f*1401298464324817e-60*d:f*Math.pow(2,l-150)*(d+8388608)}r.readFloatLE=e.bind(null,us),r.readFloatBE=e.bind(null,ls)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(l,d,h){t[0]=l,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3],d[h+4]=e[4],d[h+5]=e[5],d[h+6]=e[6],d[h+7]=e[7]}function s(l,d,h){t[0]=l,d[h]=e[7],d[h+1]=e[6],d[h+2]=e[5],d[h+3]=e[4],d[h+4]=e[3],d[h+5]=e[2],d[h+6]=e[1],d[h+7]=e[0]}r.writeDoubleLE=n?i:s,r.writeDoubleBE=n?s:i;function a(l,d){return e[0]=l[d],e[1]=l[d+1],e[2]=l[d+2],e[3]=l[d+3],e[4]=l[d+4],e[5]=l[d+5],e[6]=l[d+6],e[7]=l[d+7],t[0]}function f(l,d){return e[7]=l[d],e[6]=l[d+1],e[5]=l[d+2],e[4]=l[d+3],e[3]=l[d+4],e[2]=l[d+5],e[1]=l[d+6],e[0]=l[d+7],t[0]}r.readDoubleLE=n?a:f,r.readDoubleBE=n?f:a}():function(){function t(n,i,s,a,f,l){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,f,l+i),n(1/a>0?0:2147483648,f,l+s);else if(isNaN(a))n(0,f,l+i),n(2146959360,f,l+s);else if(a>17976931348623157e292)n(0,f,l+i),n((d<<31|2146435072)>>>0,f,l+s);else{var h;if(a<22250738585072014e-324)h=a/5e-324,n(h>>>0,f,l+i),n((d<<31|h/4294967296)>>>0,f,l+s);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),h=a*Math.pow(2,-g),n(h*4503599627370496>>>0,f,l+i),n((d<<31|g+1023<<20|h*1048576&1048575)>>>0,f,l+s)}}}r.writeDoubleLE=t.bind(null,cs,0,4),r.writeDoubleBE=t.bind(null,as,4,0);function e(n,i,s,a,f){var l=n(a,f+i),d=n(a,f+s),h=(d>>31)*2+1,g=d>>>20&2047,w=4294967296*(d&1048575)+l;return g===2047?w?NaN:h*(1/0):g===0?h*5e-324*w:h*Math.pow(2,g-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,us,0,4),r.readDoubleBE=e.bind(null,ls,4,0)}(),r}function cs(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function as(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function us(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function ls(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var ps=L((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var ms=L(ds=>{"use strict";var fn=ds;fn.length=function(t){for(var e=0,n=0,i=0;i<t.length;++i)n=t.charCodeAt(i),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e};fn.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var s=null,a=[],f=0,l;e<n;)l=t[e++],l<128?a[f++]=l:l>191&&l<224?a[f++]=(l&31)<<6|t[e++]&63:l>239&&l<365?(l=((l&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,a[f++]=55296+(l>>10),a[f++]=56320+(l&1023)):a[f++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,f>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),f=0);return s?(f&&s.push(String.fromCharCode.apply(String,a.slice(0,f))),s.join("")):String.fromCharCode.apply(String,a.slice(0,f))};fn.write=function(t,e,n){for(var i=n,s,a,f=0;f<t.length;++f)s=t.charCodeAt(f),s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&((a=t.charCodeAt(f+1))&64512)===56320?(s=65536+((s&1023)<<10)+(a&1023),++f,e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128);return n-i}});var ys=L(($h,gs)=>{"use strict";gs.exports=xu;function xu(r,t,e){var n=e||8192,i=n>>>1,s=null,a=n;return function(l){if(l<1||l>i)return r(l);a+l>n&&(s=r(n),a=0);var d=t.call(s,a,a+=l);return a&7&&(a=(a|7)+1),d}}});var ws=L((Vh,bs)=>{"use strict";bs.exports=Z;var Ke=se();function Z(r,t){this.lo=r>>>0,this.hi=t>>>0}var ie=Z.zero=new Z(0,0);ie.toNumber=function(){return 0};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var Au=Z.zeroHash="\0\0\0\0\0\0\0\0";Z.fromNumber=function(t){if(t===0)return ie;var e=t<0;e&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new Z(n,i)};Z.from=function(t){if(typeof t=="number")return Z.fromNumber(t);if(Ke.isString(t))if(Ke.Long)t=Ke.Long.fromString(t);else return Z.fromNumber(parseInt(t,10));return t.low||t.high?new Z(t.low>>>0,t.high>>>0):ie};Z.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};Z.prototype.toLong=function(t){return Ke.Long?new Ke.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var Yt=String.prototype.charCodeAt;Z.fromHash=function(t){return t===Au?ie:new Z((Yt.call(t,0)|Yt.call(t,1)<<8|Yt.call(t,2)<<16|Yt.call(t,3)<<24)>>>0,(Yt.call(t,4)|Yt.call(t,5)<<8|Yt.call(t,6)<<16|Yt.call(t,7)<<24)>>>0)};Z.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};Z.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};Z.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};Z.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var se=L(hn=>{"use strict";var A=hn;A.asPromise=Qi();A.base64=ns();A.EventEmitter=ss();A.float=hs();A.inquire=ps();A.utf8=ms();A.pool=ys();A.LongBits=ws();A.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);A.global=A.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||hn;A.emptyArray=Object.freeze?Object.freeze([]):[];A.emptyObject=Object.freeze?Object.freeze({}):{};A.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};A.isString=function(t){return typeof t=="string"||t instanceof String};A.isObject=function(t){return t&&typeof t=="object"};A.isset=A.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};A.Buffer=function(){try{var r=A.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();A._Buffer_from=null;A._Buffer_allocUnsafe=null;A.newBuffer=function(t){return typeof t=="number"?A.Buffer?A._Buffer_allocUnsafe(t):new A.Array(t):A.Buffer?A._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};A.Array=typeof Uint8Array<"u"?Uint8Array:Array;A.Long=A.global.dcodeIO&&A.global.dcodeIO.Long||A.global.Long||A.inquire("long");A.key2Re=/^true|false|0|1$/;A.key32Re=/^-?(?:0|[1-9][0-9]*)$/;A.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;A.longToHash=function(t){return t?A.LongBits.from(t).toHash():A.LongBits.zeroHash};A.longFromHash=function(t,e){var n=A.LongBits.fromHash(t);return A.Long?A.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function Es(r,t,e){for(var n=Object.keys(t),i=0;i<n.length;++i)(r[n[i]]===void 0||!e)&&(r[n[i]]=t[n[i]]);return r}A.merge=Es;A.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function vs(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&Es(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}A.newError=vs;A.ProtocolError=vs("ProtocolError");A.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(e[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};A.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};A.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};A._configure=function(){var r=A.Buffer;if(!r){A._Buffer_from=A._Buffer_allocUnsafe=null;return}A._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},A._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var mn=L((Hh,Is)=>{"use strict";Is.exports=G;var Lt=se(),dn,xs=Lt.LongBits,Iu=Lt.utf8;function Rt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function G(r){this.buf=r,this.pos=0,this.len=r.length}var Ts=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new G(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new G(t);throw Error("illegal buffer")},As=function(){return Lt.Buffer?function(e){return(G.create=function(i){return Lt.Buffer.isBuffer(i)?new dn(i):Ts(i)})(e)}:Ts};G.create=As();G.prototype._slice=Lt.Array.prototype.subarray||Lt.Array.prototype.slice;G.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Rt(this,10);return t}}();G.prototype.int32=function(){return this.uint32()|0};G.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function pn(){var r=new xs(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Rt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw Rt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}G.prototype.bool=function(){return this.uint32()!==0};function fr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}G.prototype.fixed32=function(){if(this.pos+4>this.len)throw Rt(this,4);return fr(this.buf,this.pos+=4)};G.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Rt(this,4);return fr(this.buf,this.pos+=4)|0};function Ss(){if(this.pos+8>this.len)throw Rt(this,8);return new xs(fr(this.buf,this.pos+=4),fr(this.buf,this.pos+=4))}G.prototype.float=function(){if(this.pos+4>this.len)throw Rt(this,4);var t=Lt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};G.prototype.double=function(){if(this.pos+8>this.len)throw Rt(this,4);var t=Lt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};G.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Rt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};G.prototype.string=function(){var t=this.bytes();return Iu.read(t,0,t.length)};G.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Rt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Rt(this);while(this.buf[this.pos++]&128);return this};G.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};G._configure=function(r){dn=r,G.create=As(),dn._configure();var t=Lt.Long?"toLong":"toNumber";Lt.merge(G.prototype,{int64:function(){return pn.call(this)[t](!1)},uint64:function(){return pn.call(this)[t](!0)},sint64:function(){return pn.call(this).zzDecode()[t](!1)},fixed64:function(){return Ss.call(this)[t](!0)},sfixed64:function(){return Ss.call(this)[t](!1)}})}});var Ds=L((Kh,Cs)=>{"use strict";Cs.exports=oe;var _s=mn();(oe.prototype=Object.create(_s.prototype)).constructor=oe;var Rs=se();function oe(r){_s.call(this,r)}oe._configure=function(){Rs.Buffer&&(oe.prototype._slice=Rs.Buffer.prototype.slice)};oe.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};oe._configure()});var Tn=L((Yh,ks)=>{"use strict";ks.exports=N;var yt=se(),gn,hr=yt.LongBits,Bs=yt.base64,Ls=yt.utf8;function Ye(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function bn(){}function Ru(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function N(){this.len=0,this.head=new Ye(bn,0,0),this.tail=this.head,this.states=null}var Ns=function(){return yt.Buffer?function(){return(N.create=function(){return new gn})()}:function(){return new N}};N.create=Ns();N.alloc=function(t){return new yt.Array(t)};yt.Array!==Array&&(N.alloc=yt.pool(N.alloc,yt.Array.prototype.subarray));N.prototype._push=function(t,e,n){return this.tail=this.tail.next=new Ye(t,e,n),this.len+=e,this};function wn(r,t,e){t[e]=r&255}function _u(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function En(r,t){this.len=r,this.next=void 0,this.val=t}En.prototype=Object.create(Ye.prototype);En.prototype.fn=_u;N.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new En((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};N.prototype.int32=function(t){return t<0?this._push(vn,10,hr.fromNumber(t)):this.uint32(t)};N.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function vn(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}N.prototype.uint64=function(t){var e=hr.from(t);return this._push(vn,e.length(),e)};N.prototype.int64=N.prototype.uint64;N.prototype.sint64=function(t){var e=hr.from(t).zzEncode();return this._push(vn,e.length(),e)};N.prototype.bool=function(t){return this._push(wn,1,t?1:0)};function yn(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}N.prototype.fixed32=function(t){return this._push(yn,4,t>>>0)};N.prototype.sfixed32=N.prototype.fixed32;N.prototype.fixed64=function(t){var e=hr.from(t);return this._push(yn,4,e.lo)._push(yn,4,e.hi)};N.prototype.sfixed64=N.prototype.fixed64;N.prototype.float=function(t){return this._push(yt.float.writeFloatLE,4,t)};N.prototype.double=function(t){return this._push(yt.float.writeDoubleLE,8,t)};var Cu=yt.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var i=0;i<t.length;++i)e[n+i]=t[i]};N.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(wn,1,0);if(yt.isString(t)){var n=N.alloc(e=Bs.length(t));Bs.decode(t,n,0),t=n}return this.uint32(e)._push(Cu,e,t)};N.prototype.string=function(t){var e=Ls.length(t);return e?this.uint32(e)._push(Ls.write,e,t):this._push(wn,1,0)};N.prototype.fork=function(){return this.states=new Ru(this),this.head=this.tail=new Ye(bn,0,0),this.len=0,this};N.prototype.reset=function(){return 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 Ye(bn,0,0),this.len=0),this};N.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};N.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};N._configure=function(r){gn=r,N.create=Ns(),gn._configure()}});var Ms=L((qh,Os)=>{"use strict";Os.exports=Nt;var Ps=Tn();(Nt.prototype=Object.create(Ps.prototype)).constructor=Nt;var qt=se();function Nt(){Ps.call(this)}Nt._configure=function(){Nt.alloc=qt._Buffer_allocUnsafe,Nt.writeBytesBuffer=qt.Buffer&&qt.Buffer.prototype instanceof Uint8Array&&qt.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var i=0;i<t.length;)e[n++]=t[i++]}};Nt.prototype.bytes=function(t){qt.isString(t)&&(t=qt._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Nt.writeBytesBuffer,e,t),this};function Du(r,t,e){r.length<40?qt.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Nt.prototype.string=function(t){var e=qt.Buffer.byteLength(t);return this.uint32(e),e&&this._push(Du,e,t),this};Nt._configure()});var zs=L((hp,Vs)=>{var Se=1e3,xe=Se*60,Ae=xe*60,ce=Ae*24,ku=ce*7,Pu=ce*365.25;Vs.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Ou(r);if(e==="number"&&isFinite(r))return t.long?Uu(r):Mu(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Ou(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*Pu;case"weeks":case"week":case"w":return e*ku;case"days":case"day":case"d":return e*ce;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Ae;case"minutes":case"minute":case"mins":case"min":case"m":return e*xe;case"seconds":case"second":case"secs":case"sec":case"s":return e*Se;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Mu(r){var t=Math.abs(r);return t>=ce?Math.round(r/ce)+"d":t>=Ae?Math.round(r/Ae)+"h":t>=xe?Math.round(r/xe)+"m":t>=Se?Math.round(r/Se)+"s":r+"ms"}function Uu(r){var t=Math.abs(r);return t>=ce?Ar(r,t,ce,"day"):t>=Ae?Ar(r,t,Ae,"hour"):t>=xe?Ar(r,t,xe,"minute"):t>=Se?Ar(r,t,Se,"second"):r+" ms"}function Ar(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var Rn=L((pp,Hs)=>{function Fu(r){e.debug=e,e.default=e,e.coerce=l,e.disable=s,e.enable=i,e.enabled=a,e.humanize=zs(),e.destroy=d,Object.keys(r).forEach(h=>{e[h]=r[h]}),e.names=[],e.skips=[],e.formatters={};function t(h){let g=0;for(let w=0;w<h.length;w++)g=(g<<5)-g+h.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(h){let g,w=null,x,b;function C(...I){if(!C.enabled)return;let _=C,D=Number(new Date),k=D-(g||D);_.diff=k,_.prev=g,_.curr=D,g=D,I[0]=e.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let V=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(st,nt)=>{if(st==="%%")return"%";V++;let ot=e.formatters[nt];if(typeof ot=="function"){let Tt=I[V];st=ot.call(_,Tt),I.splice(V,1),V--}return st}),e.formatArgs.call(_,I),(_.log||e.log).apply(_,I)}return C.namespace=h,C.useColors=e.useColors(),C.color=e.selectColor(h),C.extend=n,C.destroy=e.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(x!==e.namespaces&&(x=e.namespaces,b=e.enabled(h)),b),set:I=>{w=I}}),typeof e.init=="function"&&e.init(C),C}function n(h,g){let w=e(this.namespace+(typeof g>"u"?":":g)+h);return w.log=this.log,w}function i(h){e.save(h),e.namespaces=h,e.names=[],e.skips=[];let g,w=(typeof h=="string"?h:"").split(/[\s,]+/),x=w.length;for(g=0;g<x;g++)w[g]&&(h=w[g].replace(/\*/g,".*?"),h[0]==="-"?e.skips.push(new RegExp("^"+h.slice(1)+"$")):e.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...e.names.map(f),...e.skips.map(f).map(g=>"-"+g)].join(",");return e.enable(""),h}function a(h){if(h[h.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(h))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(h))return!0;return!1}function f(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}Hs.exports=Fu});var Ks=L((ht,Ir)=>{ht.formatArgs=$u;ht.save=Vu;ht.load=zu;ht.useColors=Gu;ht.storage=Hu();ht.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();ht.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Gu(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function $u(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Ir.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(e++,i==="%c"&&(n=e))}),r.splice(n,0,t)}ht.log=console.debug||console.log||(()=>{});function Vu(r){try{r?ht.storage.setItem("debug",r):ht.storage.removeItem("debug")}catch{}}function zu(){let r;try{r=ht.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Hu(){try{return localStorage}catch{}}Ir.exports=Rn()(ht);var{formatters:Ku}=Ir.exports;Ku.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var qs=L((dp,Ys)=>{"use strict";Ys.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),i=t.indexOf("--");return n!==-1&&(i===-1?!0:n<i)}});var Zs=L((mp,Ws)=>{"use strict";var Yu=Ft("os"),Ct=qs(),j=process.env,Ie;Ct("no-color")||Ct("no-colors")||Ct("color=false")?Ie=!1:(Ct("color")||Ct("colors")||Ct("color=true")||Ct("color=always"))&&(Ie=!0);"FORCE_COLOR"in j&&(Ie=j.FORCE_COLOR.length===0||parseInt(j.FORCE_COLOR,10)!==0);function qu(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Wu(r){if(Ie===!1)return 0;if(Ct("color=16m")||Ct("color=full")||Ct("color=truecolor"))return 3;if(Ct("color=256"))return 2;if(r&&!r.isTTY&&Ie!==!0)return 0;let t=Ie?1:0;if(process.platform==="win32"){let e=Yu.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in j)||j.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let e=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:(j.TERM==="dumb",t)}function _n(r){let t=Wu(r);return qu(t)}Ws.exports={supportsColor:_n,stdout:_n(process.stdout),stderr:_n(process.stderr)}});var js=L((X,_r)=>{var Zu=Ft("tty"),Rr=Ft("util");X.init=rl;X.log=Qu;X.formatArgs=ju;X.save=tl;X.load=el;X.useColors=Xu;X.destroy=Rr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");X.colors=[6,2,3,4,5,1];try{let r=Zs();r&&(r.stderr||r).level>=2&&(X.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}X.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(i,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[e]=n,r},{});function Xu(){return"colors"in X.inspectOpts?!!X.inspectOpts.colors:Zu.isatty(process.stderr.fd)}function ju(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,i="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${i};1m${t} \x1B[0m`;r[0]=s+r[0].split(`
2
+ "use strict";var Libp2PDaemonClient=(()=>{var si=Object.create;var ye=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var li=Object.getPrototypeOf,ui=Object.prototype.hasOwnProperty;var ft=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),J=(r,t)=>{for(var e in t)ye(r,e,{get:t[e],enumerable:!0})},An=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ai(t))!ui.call(r,n)&&n!==e&&ye(r,n,{get:()=>t[n],enumerable:!(o=ci(t,n))||o.enumerable});return r};var Et=(r,t,e)=>(e=r!=null?si(li(r)):{},An(t||!r||!r.__esModule?ye(e,"default",{value:r,enumerable:!0}):e,r)),di=r=>An(ye({},"__esModule",{value:!0}),r);var qn=$((xl,Zn)=>{var Kt=1e3,Yt=Kt*60,Wt=Yt*60,Nt=Wt*24,Ts=Nt*7,Ss=Nt*365.25;Zn.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return vs(r);if(e==="number"&&isFinite(r))return t.long?Ds(r):Rs(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function vs(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return e*Ss;case"weeks":case"week":case"w":return e*Ts;case"days":case"day":case"d":return e*Nt;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Wt;case"minutes":case"minute":case"mins":case"min":case"m":return e*Yt;case"seconds":case"second":case"secs":case"sec":case"s":return e*Kt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Rs(r){var t=Math.abs(r);return t>=Nt?Math.round(r/Nt)+"d":t>=Wt?Math.round(r/Wt)+"h":t>=Yt?Math.round(r/Yt)+"m":t>=Kt?Math.round(r/Kt)+"s":r+"ms"}function Ds(r){var t=Math.abs(r);return t>=Nt?ke(r,t,Nt,"day"):t>=Wt?ke(r,t,Wt,"hour"):t>=Yt?ke(r,t,Yt,"minute"):t>=Kt?ke(r,t,Kt,"second"):r+" ms"}function ke(r,t,e,o){var n=t>=e*1.5;return Math.round(r/e)+" "+o+(n?"s":"")}});var Mr=$((Il,jn)=>{function Ls(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=n,e.enabled=s,e.humanize=qn(),e.destroy=p,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let d=0;for(let h=0;h<u.length;h++)d=(d<<5)-d+u.charCodeAt(h),d|=0;return e.colors[Math.abs(d)%e.colors.length]}e.selectColor=t;function e(u){let d,h=null,b,g;function x(...y){if(!x.enabled)return;let E=x,C=Number(new Date),_=C-(d||C);E.diff=_,E.prev=d,E.curr=C,d=C,y[0]=e.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let P=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(j,X)=>{if(j==="%%")return"%";P++;let tt=e.formatters[X];if(typeof tt=="function"){let Bt=y[P];j=tt.call(E,Bt),y.splice(P,1),P--}return j}),e.formatArgs.call(E,y),(E.log||e.log).apply(E,y)}return x.namespace=u,x.useColors=e.useColors(),x.color=e.selectColor(u),x.extend=o,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(b!==e.namespaces&&(b=e.namespaces,g=e.enabled(u)),g),set:y=>{h=y}}),typeof e.init=="function"&&e.init(x),x}function o(u,d){let h=e(this.namespace+(typeof d>"u"?":":d)+u);return h.log=this.log,h}function n(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let d,h=(typeof u=="string"?u:"").split(/[\s,]+/),b=h.length;for(d=0;d<b;d++)h[d]&&(u=h[d].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.slice(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(c),...e.skips.map(c).map(d=>"-"+d)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let d,h;for(d=0,h=e.skips.length;d<h;d++)if(e.skips[d].test(u))return!1;for(d=0,h=e.names.length;d<h;d++)if(e.names[d].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack||u.message:u}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}jn.exports=Ls});var to=$((Q,Ue)=>{Q.formatArgs=Ns;Q.save=Ps;Q.load=Os;Q.useColors=_s;Q.storage=ks();Q.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Q.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function _s(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ns(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Ue.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,o=0;r[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(e++,n==="%c"&&(o=e))}),r.splice(o,0,t)}Q.log=console.debug||console.log||(()=>{});function Ps(r){try{r?Q.storage.setItem("debug",r):Q.storage.removeItem("debug")}catch{}}function Os(){let r;try{r=Q.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function ks(){try{return localStorage}catch{}}Ue.exports=Mr()(Q);var{formatters:Us}=Ue.exports;Us.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ro=$((Al,eo)=>{"use strict";eo.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",o=t.indexOf(e+r),n=t.indexOf("--");return o!==-1&&(n===-1?!0:o<n)}});var oo=$((Cl,no)=>{"use strict";var Fs=ft("os"),at=ro(),B=process.env,Xt;at("no-color")||at("no-colors")||at("color=false")?Xt=!1:(at("color")||at("colors")||at("color=true")||at("color=always"))&&(Xt=!0);"FORCE_COLOR"in B&&(Xt=B.FORCE_COLOR.length===0||parseInt(B.FORCE_COLOR,10)!==0);function Bs(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Ms(r){if(Xt===!1)return 0;if(at("color=16m")||at("color=full")||at("color=truecolor"))return 3;if(at("color=256"))return 2;if(r&&!r.isTTY&&Xt!==!0)return 0;let t=Xt?1:0;if(process.platform==="win32"){let e=Fs.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in B)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in B)||B.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in B)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(B.TEAMCITY_VERSION)?1:0;if(B.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in B){let e=parseInt((B.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(B.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(B.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(B.TERM)||"COLORTERM"in B?1:(B.TERM==="dumb",t)}function Vr(r){let t=Ms(r);return Bs(t)}no.exports={supportsColor:Vr,stdout:Vr(process.stdout),stderr:Vr(process.stderr)}});var so=$((k,Be)=>{var Vs=ft("tty"),Fe=ft("util");k.init=Ws;k.log=Hs;k.formatArgs=$s;k.save=Ks;k.load=Ys;k.useColors=Gs;k.destroy=Fe.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");k.colors=[6,2,3,4,5,1];try{let r=oo();r&&(r.stderr||r).level>=2&&(k.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}k.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,i)=>i.toUpperCase()),o=process.env[t];return/^(yes|on|true|enabled)$/i.test(o)?o=!0:/^(no|off|false|disabled)$/i.test(o)?o=!1:o==="null"?o=null:o=Number(o),r[e]=o,r},{});function Gs(){return"colors"in k.inspectOpts?!!k.inspectOpts.colors:Vs.isatty(process.stderr.fd)}function $s(r){let{namespace:t,useColors:e}=this;if(e){let o=this.color,n="\x1B[3"+(o<8?o:"8;5;"+o),i=` ${n};1m${t} \x1B[0m`;r[0]=i+r[0].split(`
3
3
  `).join(`
4
- `+s),r.push(i+"m+"+_r.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Ju()+t+" "+r[0]}function Ju(){return X.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Qu(...r){return process.stderr.write(Rr.format(...r)+`
5
- `)}function tl(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function el(){return process.env.DEBUG}function rl(r){r.inspectOpts={};let t=Object.keys(X.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=X.inspectOpts[t[e]]}_r.exports=Rn()(X);var{formatters:Xs}=_r.exports;Xs.o=function(r){return this.inspectOpts.colors=this.useColors,Rr.inspect(r,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};Xs.O=function(r){return this.inspectOpts.colors=this.useColors,Rr.inspect(r,this.inspectOpts)}});var Js=L((gp,Cn)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Cn.exports=Ks():Cn.exports=js()});var po=L((ud,ho)=>{"use strict";function fo(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Bl(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return fo(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),fo(new i,e)}}ho.exports=Bl});var Oo=L((hm,Po)=>{Po.exports=ii;var ko=128,Rf=127,_f=~Rf,Cf=Math.pow(2,31);function ii(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw ii.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Cf;)t[e++]=r&255|ko,r/=128;for(;r&_f;)t[e++]=r&255|ko,r>>>=7;return t[e]=r|0,ii.bytes=e-n+1,t}});var Fo=L((pm,Uo)=>{Uo.exports=si;var Df=128,Mo=127;function si(r,n){var e=0,n=n||0,i=0,s=n,a,f=r.length;do{if(s>=f||i>49)throw si.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&Mo)<<i:(a&Mo)*Math.pow(2,i),i+=7}while(a>=Df);return si.bytes=s-n,e}});var $o=L((dm,Go)=>{var Bf=Math.pow(2,7),Lf=Math.pow(2,14),Nf=Math.pow(2,21),kf=Math.pow(2,28),Pf=Math.pow(2,35),Of=Math.pow(2,42),Mf=Math.pow(2,49),Uf=Math.pow(2,56),Ff=Math.pow(2,63);Go.exports=function(r){return r<Bf?1:r<Lf?2:r<Nf?3:r<kf?4:r<Pf?5:r<Of?6:r<Mf?7:r<Uf?8:r<Ff?9:10}});var oi=L((mm,Vo)=>{Vo.exports={encode:Oo(),decode:Fo(),encodingLength:$o()}});var Ai=L((Zr,pc)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(o,c,u){o!=null&&(typeof o=="number"?this.fromNumber(o,c,u):c==null&&typeof o!="string"?this.fromString(o,256):this.fromString(o,c))}function i(){return new n(null)}function s(o,c,u,p,m,y){for(;--y>=0;){var v=c*this[o++]+u[p]+m;m=Math.floor(v/67108864),u[p++]=v&67108863}return m}function a(o,c,u,p,m,y){for(var v=c&32767,S=c>>15;--y>=0;){var O=this[o]&32767,W=this[o++]>>15,gt=S*O+W*v;O=v*O+((gt&32767)<<15)+u[p]+(m&1073741823),m=(O>>>30)+(gt>>>15)+S*W+(m>>>30),u[p++]=O&1073741823}return m}function f(o,c,u,p,m,y){for(var v=c&16383,S=c>>14;--y>=0;){var O=this[o]&16383,W=this[o++]>>14,gt=S*O+W*v;O=v*O+((gt&16383)<<14)+u[p]+m,m=(O>>28)+(gt>>14)+S*W,u[p++]=O&268435455}return m}var l=typeof navigator<"u";l&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=a,r=30):l&&e&&navigator.appName!="Netscape"?(n.prototype.am=s,r=26):(n.prototype.am=f,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var d=52;n.prototype.FV=Math.pow(2,d),n.prototype.F1=d-r,n.prototype.F2=2*r-d;var h="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,x;for(w="0".charCodeAt(0),x=0;x<=9;++x)g[w++]=x;for(w="a".charCodeAt(0),x=10;x<36;++x)g[w++]=x;for(w="A".charCodeAt(0),x=10;x<36;++x)g[w++]=x;function b(o){return h.charAt(o)}function C(o,c){var u=g[o.charCodeAt(c)];return u??-1}function I(o){for(var c=this.t-1;c>=0;--c)o[c]=this[c];o.t=this.t,o.s=this.s}function _(o){this.t=1,this.s=o<0?-1:0,o>0?this[0]=o:o<-1?this[0]=o+this.DV:this.t=0}function D(o){var c=i();return c.fromInt(o),c}function k(o,c){var u;if(c==16)u=4;else if(c==8)u=3;else if(c==256)u=8;else if(c==2)u=1;else if(c==32)u=5;else if(c==4)u=2;else{this.fromRadix(o,c);return}this.t=0,this.s=0;for(var p=o.length,m=!1,y=0;--p>=0;){var v=u==8?o[p]&255:C(o,p);if(v<0){o.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=v:y+u>this.DB?(this[this.t-1]|=(v&(1<<this.DB-y)-1)<<y,this[this.t++]=v>>this.DB-y):this[this.t-1]|=v<<y,y+=u,y>=this.DB&&(y-=this.DB)}u==8&&o[0]&128&&(this.s=-1,y>0&&(this[this.t-1]|=(1<<this.DB-y)-1<<y)),this.clamp(),m&&n.ZERO.subTo(this,this)}function V(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function rt(o){if(this.s<0)return"-"+this.negate().toString(o);var c;if(o==16)c=4;else if(o==8)c=3;else if(o==2)c=1;else if(o==32)c=5;else if(o==4)c=2;else return this.toRadix(o);var u=(1<<c)-1,p,m=!1,y="",v=this.t,S=this.DB-v*this.DB%c;if(v-- >0)for(S<this.DB&&(p=this[v]>>S)>0&&(m=!0,y=b(p));v>=0;)S<c?(p=(this[v]&(1<<S)-1)<<c-S,p|=this[--v]>>(S+=this.DB-c)):(p=this[v]>>(S-=c)&u,S<=0&&(S+=this.DB,--v)),p>0&&(m=!0),m&&(y+=b(p));return m?y:"0"}function st(){var o=i();return n.ZERO.subTo(this,o),o}function nt(){return this.s<0?this.negate():this}function ot(o){var c=this.s-o.s;if(c!=0)return c;var u=this.t;if(c=u-o.t,c!=0)return this.s<0?-c:c;for(;--u>=0;)if((c=this[u]-o[u])!=0)return c;return 0}function Tt(o){var c=1,u;return(u=o>>>16)!=0&&(o=u,c+=16),(u=o>>8)!=0&&(o=u,c+=8),(u=o>>4)!=0&&(o=u,c+=4),(u=o>>2)!=0&&(o=u,c+=2),(u=o>>1)!=0&&(o=u,c+=1),c}function Mc(){return this.t<=0?0:this.DB*(this.t-1)+Tt(this[this.t-1]^this.s&this.DM)}function Uc(o,c){var u;for(u=this.t-1;u>=0;--u)c[u+o]=this[u];for(u=o-1;u>=0;--u)c[u]=0;c.t=this.t+o,c.s=this.s}function Fc(o,c){for(var u=o;u<this.t;++u)c[u-o]=this[u];c.t=Math.max(this.t-o,0),c.s=this.s}function Gc(o,c){var u=o%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(o/this.DB),v=this.s<<u&this.DM,S;for(S=this.t-1;S>=0;--S)c[S+y+1]=this[S]>>p|v,v=(this[S]&m)<<u;for(S=y-1;S>=0;--S)c[S]=0;c[y]=v,c.t=this.t+y+1,c.s=this.s,c.clamp()}function $c(o,c){c.s=this.s;var u=Math.floor(o/this.DB);if(u>=this.t){c.t=0;return}var p=o%this.DB,m=this.DB-p,y=(1<<p)-1;c[0]=this[u]>>p;for(var v=u+1;v<this.t;++v)c[v-u-1]|=(this[v]&y)<<m,c[v-u]=this[v]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function Vc(o,c){for(var u=0,p=0,m=Math.min(o.t,this.t);u<m;)p+=this[u]-o[u],c[u++]=p&this.DM,p>>=this.DB;if(o.t<this.t){for(p-=o.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<o.t;)p-=o[u],c[u++]=p&this.DM,p>>=this.DB;p-=o.s}c.s=p<0?-1:0,p<-1?c[u++]=this.DV+p:p>0&&(c[u++]=p),c.t=u,c.clamp()}function zc(o,c){var u=this.abs(),p=o.abs(),m=u.t;for(c.t=m+p.t;--m>=0;)c[m]=0;for(m=0;m<p.t;++m)c[m+u.t]=u.am(0,p[m],c,m,0,u.t);c.s=0,c.clamp(),this.s!=o.s&&n.ZERO.subTo(c,c)}function Hc(o){for(var c=this.abs(),u=o.t=2*c.t;--u>=0;)o[u]=0;for(u=0;u<c.t-1;++u){var p=c.am(u,c[u],o,2*u,0,1);(o[u+c.t]+=c.am(u+1,2*c[u],o,2*u+1,p,c.t-u-1))>=c.DV&&(o[u+c.t]-=c.DV,o[u+c.t+1]=1)}o.t>0&&(o[o.t-1]+=c.am(u,c[u],o,2*u,0,1)),o.s=0,o.clamp()}function Kc(o,c,u){var p=o.abs();if(!(p.t<=0)){var m=this.abs();if(m.t<p.t){c?.fromInt(0),u!=null&&this.copyTo(u);return}u==null&&(u=i());var y=i(),v=this.s,S=o.s,O=this.DB-Tt(p[p.t-1]);O>0?(p.lShiftTo(O,y),m.lShiftTo(O,u)):(p.copyTo(y),m.copyTo(u));var W=y.t,gt=y[W-1];if(gt!=0){var lt=gt*(1<<this.F1)+(W>1?y[W-2]>>this.F2:0),Ut=this.FV/lt,or=(1<<this.F1)/lt,xt=1<<this.F2,At=u.t,cr=At-W,Kt=c??i();for(y.dlShiftTo(cr,Kt),u.compareTo(Kt)>=0&&(u[u.t++]=1,u.subTo(Kt,u)),n.ONE.dlShiftTo(W,Kt),Kt.subTo(y,y);y.t<W;)y[y.t++]=0;for(;--cr>=0;){var ln=u[--At]==gt?this.DM:Math.floor(u[At]*Ut+(u[At-1]+xt)*or);if((u[At]+=y.am(0,ln,u,cr,0,W))<ln)for(y.dlShiftTo(cr,Kt),u.subTo(Kt,u);u[At]<--ln;)u.subTo(Kt,u)}c!=null&&(u.drShiftTo(W,c),v!=S&&n.ZERO.subTo(c,c)),u.t=W,u.clamp(),O>0&&u.rShiftTo(O,u),v<0&&n.ZERO.subTo(u,u)}}}function Yc(o){var c=i();return this.abs().divRemTo(o,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&o.subTo(c,c),c}function ee(o){this.m=o}function qc(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function Wc(o){return o}function Zc(o){o.divRemTo(this.m,null,o)}function Xc(o,c,u){o.multiplyTo(c,u),this.reduce(u)}function jc(o,c){o.squareTo(c),this.reduce(c)}ee.prototype.convert=qc,ee.prototype.revert=Wc,ee.prototype.reduce=Zc,ee.prototype.mulTo=Xc,ee.prototype.sqrTo=jc;function Jc(){if(this.t<1)return 0;var o=this[0];if(!(o&1))return 0;var c=o&3;return c=c*(2-(o&15)*c)&15,c=c*(2-(o&255)*c)&255,c=c*(2-((o&65535)*c&65535))&65535,c=c*(2-o*c%this.DV)%this.DV,c>0?this.DV-c:-c}function re(o){this.m=o,this.mp=o.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<o.DB-15)-1,this.mt2=2*o.t}function Qc(o){var c=i();return o.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),o.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function ta(o){var c=i();return o.copyTo(c),this.reduce(c),c}function ea(o){for(;o.t<=this.mt2;)o[o.t++]=0;for(var c=0;c<this.m.t;++c){var u=o[c]&32767,p=u*this.mpl+((u*this.mph+(o[c]>>15)*this.mpl&this.um)<<15)&o.DM;for(u=c+this.m.t,o[u]+=this.m.am(0,p,o,c,0,this.m.t);o[u]>=o.DV;)o[u]-=o.DV,o[++u]++}o.clamp(),o.drShiftTo(this.m.t,o),o.compareTo(this.m)>=0&&o.subTo(this.m,o)}function ra(o,c){o.squareTo(c),this.reduce(c)}function na(o,c,u){o.multiplyTo(c,u),this.reduce(u)}re.prototype.convert=Qc,re.prototype.revert=ta,re.prototype.reduce=ea,re.prototype.mulTo=na,re.prototype.sqrTo=ra;function ia(){return(this.t>0?this[0]&1:this.s)==0}function sa(o,c){if(o>4294967295||o<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=Tt(o)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(o&1<<y)>0)c.mulTo(p,m,u);else{var v=u;u=p,p=v}return c.revert(u)}function oa(o,c){var u;return o<256||c.isEven()?u=new ee(c):u=new re(c),this.exp(o,u)}n.prototype.copyTo=I,n.prototype.fromInt=_,n.prototype.fromString=k,n.prototype.clamp=V,n.prototype.dlShiftTo=Uc,n.prototype.drShiftTo=Fc,n.prototype.lShiftTo=Gc,n.prototype.rShiftTo=$c,n.prototype.subTo=Vc,n.prototype.multiplyTo=zc,n.prototype.squareTo=Hc,n.prototype.divRemTo=Kc,n.prototype.invDigit=Jc,n.prototype.isEven=ia,n.prototype.exp=sa,n.prototype.toString=rt,n.prototype.negate=st,n.prototype.abs=nt,n.prototype.compareTo=ot,n.prototype.bitLength=Mc,n.prototype.mod=Yc,n.prototype.modPowInt=oa,n.ZERO=D(0),n.ONE=D(1);function ca(){var o=i();return this.copyTo(o),o}function aa(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function ua(){return this.t==0?this.s:this[0]<<24>>24}function la(){return this.t==0?this.s:this[0]<<16>>16}function fa(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function ha(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function pa(o){if(o==null&&(o=10),this.signum()==0||o<2||o>36)return"0";var c=this.chunkSize(o),u=Math.pow(o,c),p=D(u),m=i(),y=i(),v="";for(this.divRemTo(p,m,y);m.signum()>0;)v=(u+y.intValue()).toString(o).substr(1)+v,m.divRemTo(p,m,y);return y.intValue().toString(o)+v}function da(o,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,v=0,S=0;S<o.length;++S){var O=C(o,S);if(O<0){o.charAt(S)=="-"&&this.signum()==0&&(m=!0);continue}v=c*v+O,++y>=u&&(this.dMultiply(p),this.dAddOffset(v,0),y=0,v=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(v,0)),m&&n.ZERO.subTo(this,this)}function ma(o,c,u){if(typeof c=="number")if(o<2)this.fromInt(1);else for(this.fromNumber(o,u),this.testBit(o-1)||this.bitwiseTo(n.ONE.shiftLeft(o-1),on,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>o&&this.subTo(n.ONE.shiftLeft(o-1),this);else{var p=new Array,m=o&7;p.length=(o>>3)+1,c.nextBytes(p),m>0?p[0]&=(1<<m)-1:p[0]=0,this.fromString(p,256)}}function ga(){var o=this.t,c=new Array;c[0]=this.s;var u=this.DB-o*this.DB%8,p,m=0;if(o-- >0)for(u<this.DB&&(p=this[o]>>u)!=(this.s&this.DM)>>u&&(c[m++]=p|this.s<<this.DB-u);o>=0;)u<8?(p=(this[o]&(1<<u)-1)<<8-u,p|=this[--o]>>(u+=this.DB-8)):(p=this[o]>>(u-=8)&255,u<=0&&(u+=this.DB,--o)),p&128&&(p|=-256),m==0&&(this.s&128)!=(p&128)&&++m,(m>0||p!=this.s)&&(c[m++]=p);return c}function ya(o){return this.compareTo(o)==0}function ba(o){return this.compareTo(o)<0?this:o}function wa(o){return this.compareTo(o)>0?this:o}function Ea(o,c,u){var p,m,y=Math.min(o.t,this.t);for(p=0;p<y;++p)u[p]=c(this[p],o[p]);if(o.t<this.t){for(m=o.s&this.DM,p=y;p<this.t;++p)u[p]=c(this[p],m);u.t=this.t}else{for(m=this.s&this.DM,p=y;p<o.t;++p)u[p]=c(m,o[p]);u.t=o.t}u.s=c(this.s,o.s),u.clamp()}function va(o,c){return o&c}function Ta(o){var c=i();return this.bitwiseTo(o,va,c),c}function on(o,c){return o|c}function Sa(o){var c=i();return this.bitwiseTo(o,on,c),c}function Ki(o,c){return o^c}function xa(o){var c=i();return this.bitwiseTo(o,Ki,c),c}function Yi(o,c){return o&~c}function Aa(o){var c=i();return this.bitwiseTo(o,Yi,c),c}function Ia(){for(var o=i(),c=0;c<this.t;++c)o[c]=this.DM&~this[c];return o.t=this.t,o.s=~this.s,o}function Ra(o){var c=i();return o<0?this.rShiftTo(-o,c):this.lShiftTo(o,c),c}function _a(o){var c=i();return o<0?this.lShiftTo(-o,c):this.rShiftTo(o,c),c}function Ca(o){if(o==0)return-1;var c=0;return o&65535||(o>>=16,c+=16),o&255||(o>>=8,c+=8),o&15||(o>>=4,c+=4),o&3||(o>>=2,c+=2),o&1||++c,c}function Da(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+Ca(this[o]);return this.s<0?this.t*this.DB:-1}function Ba(o){for(var c=0;o!=0;)o&=o-1,++c;return c}function La(){for(var o=0,c=this.s&this.DM,u=0;u<this.t;++u)o+=Ba(this[u]^c);return o}function Na(o){var c=Math.floor(o/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<o%this.DB)!=0}function ka(o,c){var u=n.ONE.shiftLeft(o);return this.bitwiseTo(u,c,u),u}function Pa(o){return this.changeBit(o,on)}function Oa(o){return this.changeBit(o,Yi)}function Ma(o){return this.changeBit(o,Ki)}function Ua(o,c){for(var u=0,p=0,m=Math.min(o.t,this.t);u<m;)p+=this[u]+o[u],c[u++]=p&this.DM,p>>=this.DB;if(o.t<this.t){for(p+=o.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<o.t;)p+=o[u],c[u++]=p&this.DM,p>>=this.DB;p+=o.s}c.s=p<0?-1:0,p>0?c[u++]=p:p<-1&&(c[u++]=this.DV+p),c.t=u,c.clamp()}function Fa(o){var c=i();return this.addTo(o,c),c}function Ga(o){var c=i();return this.subTo(o,c),c}function $a(o){var c=i();return this.multiplyTo(o,c),c}function Va(){var o=i();return this.squareTo(o),o}function za(o){var c=i();return this.divRemTo(o,c,null),c}function Ha(o){var c=i();return this.divRemTo(o,null,c),c}function Ka(o){var c=i(),u=i();return this.divRemTo(o,c,u),new Array(c,u)}function Ya(o){this[this.t]=this.am(0,o-1,this,0,0,this.t),++this.t,this.clamp()}function qa(o,c){if(o!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=o;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function He(){}function qi(o){return o}function Wa(o,c,u){o.multiplyTo(c,u)}function Za(o,c){o.squareTo(c)}He.prototype.convert=qi,He.prototype.revert=qi,He.prototype.mulTo=Wa,He.prototype.sqrTo=Za;function Xa(o){return this.exp(o,new He)}function ja(o,c,u){var p=Math.min(this.t+o.t,c);for(u.s=0,u.t=p;p>0;)u[--p]=0;var m;for(m=u.t-this.t;p<m;++p)u[p+this.t]=this.am(0,o[p],u,p,0,this.t);for(m=Math.min(o.t,c);p<m;++p)this.am(0,o[p],u,p,0,c-p);u.clamp()}function Ja(o,c,u){--c;var p=u.t=this.t+o.t-c;for(u.s=0;--p>=0;)u[p]=0;for(p=Math.max(c-this.t,0);p<o.t;++p)u[this.t+p-c]=this.am(c-p,o[p],u,0,0,this.t+p-c);u.clamp(),u.drShiftTo(1,u)}function ne(o){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*o.t,this.r2),this.mu=this.r2.divide(o),this.m=o}function Qa(o){if(o.s<0||o.t>2*this.m.t)return o.mod(this.m);if(o.compareTo(this.m)<0)return o;var c=i();return o.copyTo(c),this.reduce(c),c}function tu(o){return o}function eu(o){for(o.drShiftTo(this.m.t-1,this.r2),o.t>this.m.t+1&&(o.t=this.m.t+1,o.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);o.compareTo(this.r2)<0;)o.dAddOffset(1,this.m.t+1);for(o.subTo(this.r2,o);o.compareTo(this.m)>=0;)o.subTo(this.m,o)}function ru(o,c){o.squareTo(c),this.reduce(c)}function nu(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ne.prototype.convert=Qa,ne.prototype.revert=tu,ne.prototype.reduce=eu,ne.prototype.mulTo=nu,ne.prototype.sqrTo=ru;function iu(o,c){var u=o.bitLength(),p,m=D(1),y;if(u<=0)return m;u<18?p=1:u<48?p=3:u<144?p=4:u<768?p=5:p=6,u<8?y=new ee(c):c.isEven()?y=new ne(c):y=new re(c);var v=new Array,S=3,O=p-1,W=(1<<p)-1;if(v[1]=y.convert(this),p>1){var gt=i();for(y.sqrTo(v[1],gt);S<=W;)v[S]=i(),y.mulTo(gt,v[S-2],v[S]),S+=2}var lt=o.t-1,Ut,or=!0,xt=i(),At;for(u=Tt(o[lt])-1;lt>=0;){for(u>=O?Ut=o[lt]>>u-O&W:(Ut=(o[lt]&(1<<u+1)-1)<<O-u,lt>0&&(Ut|=o[lt-1]>>this.DB+u-O)),S=p;!(Ut&1);)Ut>>=1,--S;if((u-=S)<0&&(u+=this.DB,--lt),or)v[Ut].copyTo(m),or=!1;else{for(;S>1;)y.sqrTo(m,xt),y.sqrTo(xt,m),S-=2;S>0?y.sqrTo(m,xt):(At=m,m=xt,xt=At),y.mulTo(xt,v[Ut],m)}for(;lt>=0&&!(o[lt]&1<<u);)y.sqrTo(m,xt),At=m,m=xt,xt=At,--u<0&&(u=this.DB-1,--lt)}return y.revert(m)}function su(o){var c=this.s<0?this.negate():this.clone(),u=o.s<0?o.negate():o.clone();if(c.compareTo(u)<0){var p=c;c=u,u=p}var m=c.getLowestSetBit(),y=u.getLowestSetBit();if(y<0)return c;for(m<y&&(y=m),y>0&&(c.rShiftTo(y,c),u.rShiftTo(y,u));c.signum()>0;)(m=c.getLowestSetBit())>0&&c.rShiftTo(m,c),(m=u.getLowestSetBit())>0&&u.rShiftTo(m,u),c.compareTo(u)>=0?(c.subTo(u,c),c.rShiftTo(1,c)):(u.subTo(c,u),u.rShiftTo(1,u));return y>0&&u.lShiftTo(y,u),u}function ou(o){if(o<=0)return 0;var c=this.DV%o,u=this.s<0?o-1:0;if(this.t>0)if(c==0)u=this[0]%o;else for(var p=this.t-1;p>=0;--p)u=(c*u+this[p])%o;return u}function cu(o){var c=o.isEven();if(this.isEven()&&c||o.signum()==0)return n.ZERO;for(var u=o.clone(),p=this.clone(),m=D(1),y=D(0),v=D(0),S=D(1);u.signum()!=0;){for(;u.isEven();)u.rShiftTo(1,u),c?((!m.isEven()||!y.isEven())&&(m.addTo(this,m),y.subTo(o,y)),m.rShiftTo(1,m)):y.isEven()||y.subTo(o,y),y.rShiftTo(1,y);for(;p.isEven();)p.rShiftTo(1,p),c?((!v.isEven()||!S.isEven())&&(v.addTo(this,v),S.subTo(o,S)),v.rShiftTo(1,v)):S.isEven()||S.subTo(o,S),S.rShiftTo(1,S);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(v,m),y.subTo(S,y)):(p.subTo(u,p),c&&v.subTo(m,v),S.subTo(y,S))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(S.compareTo(o)>=0)return S.subtract(o);if(S.signum()<0)S.addTo(o,S);else return S;return S.signum()<0?S.add(o):S}var it=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],au=(1<<26)/it[it.length-1];function uu(o){var c,u=this.abs();if(u.t==1&&u[0]<=it[it.length-1]){for(c=0;c<it.length;++c)if(u[0]==it[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<it.length;){for(var p=it[c],m=c+1;m<it.length&&p<au;)p*=it[m++];for(p=u.modInt(p);c<m;)if(p%it[c++]==0)return!1}return u.millerRabin(o)}function lu(o){var c=this.subtract(n.ONE),u=c.getLowestSetBit();if(u<=0)return!1;var p=c.shiftRight(u);o=o+1>>1,o>it.length&&(o=it.length);for(var m=i(),y=0;y<o;++y){m.fromInt(it[Math.floor(Math.random()*it.length)]);var v=m.modPow(p,this);if(v.compareTo(n.ONE)!=0&&v.compareTo(c)!=0){for(var S=1;S++<u&&v.compareTo(c)!=0;)if(v=v.modPowInt(2,this),v.compareTo(n.ONE)==0)return!1;if(v.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=fa,n.prototype.toRadix=pa,n.prototype.fromRadix=da,n.prototype.fromNumber=ma,n.prototype.bitwiseTo=Ea,n.prototype.changeBit=ka,n.prototype.addTo=Ua,n.prototype.dMultiply=Ya,n.prototype.dAddOffset=qa,n.prototype.multiplyLowerTo=ja,n.prototype.multiplyUpperTo=Ja,n.prototype.modInt=ou,n.prototype.millerRabin=lu,n.prototype.clone=ca,n.prototype.intValue=aa,n.prototype.byteValue=ua,n.prototype.shortValue=la,n.prototype.signum=ha,n.prototype.toByteArray=ga,n.prototype.equals=ya,n.prototype.min=ba,n.prototype.max=wa,n.prototype.and=Ta,n.prototype.or=Sa,n.prototype.xor=xa,n.prototype.andNot=Aa,n.prototype.not=Ia,n.prototype.shiftLeft=Ra,n.prototype.shiftRight=_a,n.prototype.getLowestSetBit=Da,n.prototype.bitCount=La,n.prototype.testBit=Na,n.prototype.setBit=Pa,n.prototype.clearBit=Oa,n.prototype.flipBit=Ma,n.prototype.add=Fa,n.prototype.subtract=Ga,n.prototype.multiply=$a,n.prototype.divide=za,n.prototype.remainder=Ha,n.prototype.divideAndRemainder=Ka,n.prototype.modPow=iu,n.prototype.modInverse=cu,n.prototype.pow=Xa,n.prototype.gcd=su,n.prototype.isProbablePrime=uu,n.prototype.square=Va,n.prototype.Barrett=ne;var sr,ut,q;function fu(o){ut[q++]^=o&255,ut[q++]^=o>>8&255,ut[q++]^=o>>16&255,ut[q++]^=o>>24&255,q>=un&&(q-=un)}function Wi(){fu(new Date().getTime())}if(ut==null){ut=new Array,q=0;var St;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Zi=new Uint8Array(32);for(window.crypto.getRandomValues(Zi),St=0;St<32;++St)ut[q++]=Zi[St]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var Xi=window.crypto.random(32);for(St=0;St<Xi.length;++St)ut[q++]=Xi.charCodeAt(St)&255}}for(;q<un;)St=Math.floor(65536*Math.random()),ut[q++]=St>>>8,ut[q++]=St&255;q=0,Wi()}function hu(){if(sr==null){for(Wi(),sr=gu(),sr.init(ut),q=0;q<ut.length;++q)ut[q]=0;q=0}return sr.next()}function pu(o){var c;for(c=0;c<o.length;++c)o[c]=hu()}function cn(){}cn.prototype.nextBytes=pu;function an(){this.i=0,this.j=0,this.S=new Array}function du(o){var c,u,p;for(c=0;c<256;++c)this.S[c]=c;for(u=0,c=0;c<256;++c)u=u+this.S[c]+o[c%o.length]&255,p=this.S[c],this.S[c]=this.S[u],this.S[u]=p;this.i=0,this.j=0}function mu(){var o;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,o=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=o,this.S[o+this.S[this.i]&255]}an.prototype.init=du,an.prototype.next=mu;function gu(){return new an}var un=256;typeof Zr<"u"?Zr=pc.exports={default:n,BigInteger:n,SecureRandom:cn}:this.jsbn={BigInteger:n,SecureRandom:cn}}).call(Zr)});var nr=L(Xr=>{(function(){"use strict";var r={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(a){return n(s(a),arguments)}function e(a,f){return t.apply(null,[a].concat(f||[]))}function n(a,f){var l=1,d=a.length,h,g="",w,x,b,C,I,_,D,k;for(w=0;w<d;w++)if(typeof a[w]=="string")g+=a[w];else if(typeof a[w]=="object"){if(b=a[w],b.keys)for(h=f[l],x=0;x<b.keys.length;x++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',b.keys[x],b.keys[x-1]));h=h[b.keys[x]]}else b.param_no?h=f[b.param_no]:h=f[l++];if(r.not_type.test(b.type)&&r.not_primitive.test(b.type)&&h instanceof Function&&(h=h()),r.numeric_arg.test(b.type)&&typeof h!="number"&&isNaN(h))throw new TypeError(t("[sprintf] expecting number but found %T",h));switch(r.number.test(b.type)&&(D=h>=0),b.type){case"b":h=parseInt(h,10).toString(2);break;case"c":h=String.fromCharCode(parseInt(h,10));break;case"d":case"i":h=parseInt(h,10);break;case"j":h=JSON.stringify(h,null,b.width?parseInt(b.width):0);break;case"e":h=b.precision?parseFloat(h).toExponential(b.precision):parseFloat(h).toExponential();break;case"f":h=b.precision?parseFloat(h).toFixed(b.precision):parseFloat(h);break;case"g":h=b.precision?String(Number(h.toPrecision(b.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=b.precision?h.substring(0,b.precision):h;break;case"t":h=String(!!h),h=b.precision?h.substring(0,b.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=b.precision?h.substring(0,b.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=b.precision?h.substring(0,b.precision):h;break;case"x":h=(parseInt(h,10)>>>0).toString(16);break;case"X":h=(parseInt(h,10)>>>0).toString(16).toUpperCase();break}r.json.test(b.type)?g+=h:(r.number.test(b.type)&&(!D||b.sign)?(k=D?"+":"-",h=h.toString().replace(r.sign,"")):k="",I=b.pad_char?b.pad_char==="0"?"0":b.pad_char.charAt(1):" ",_=b.width-(k+h).length,C=b.width&&_>0?I.repeat(_):"",g+=b.align?k+h+C:I==="0"?k+C+h:C+k+h)}return g}var i=Object.create(null);function s(a){if(i[a])return i[a];for(var f=a,l,d=[],h=0;f;){if((l=r.text.exec(f))!==null)d.push(l[0]);else if((l=r.modulo.exec(f))!==null)d.push("%");else if((l=r.placeholder.exec(f))!==null){if(l[2]){h|=1;var g=[],w=l[2],x=[];if((x=r.key.exec(w))!==null)for(g.push(x[1]);(w=w.substring(x[0].length))!=="";)if((x=r.key_access.exec(w))!==null)g.push(x[1]);else if((x=r.index_access.exec(w))!==null)g.push(x[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=g}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");f=f.substring(l[0].length)}return i[a]=d}typeof Xr<"u"&&(Xr.sprintf=t,Xr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var tn=L((ag,xc)=>{xc.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var Ic=L((ug,Ac)=>{Ac.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var Oi=L((lg,Rc)=>{var wh=Ic();Rc.exports=r=>async t=>{t=wh(t);let e=_=>{typeof _.return=="function"&&_.return()},n=null,i=null,s=_=>{n=_,i&&i(_),e(t)},a=null,f=!1,l=()=>{f=!0,a&&a()},d=null,h=!1,g=()=>{h=!0,d&&d()},w=null,x=()=>{w&&w()},b=()=>new Promise((_,D)=>{a=w=_,i=D,r.once("drain",x)}),C=()=>(e(t),new Promise((_,D)=>{if(f||h||n)return _();d=a=_,i=D})),I=()=>{r.removeListener("error",s),r.removeListener("close",l),r.removeListener("finish",g),r.removeListener("drain",x)};r.once("error",s),r.once("close",l),r.once("finish",g);try{for await(let _ of t){if(!r.writable||r.destroyed||n)break;r.write(_)===!1&&await b()}}catch(_){n||r.destroy(),n=_}try{if(r.writable&&r.end(),await C(),n)throw n}finally{I()}}});var Mi=L((fg,_c)=>{var Eh=Oi(),vh=tn();_c.exports=r=>({sink:Eh(r),source:vh(r)})});var Dc=L((hg,Cc)=>{var Th=Mi();Cc.exports=r=>async function*(t){let e=Th(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var Bc=L((pg,Ve)=>{Ve.exports=tn();Ve.exports.source=tn();Ve.exports.sink=Oi();Ve.exports.transform=Dc();Ve.exports.duplex=Mi()});var kh={};ft(kh,{createClient:()=>Nh});var Sn=F(mn(),1),Us=F(Ds(),1),Fs=F(se(),1),xn=F(Tn(),1),Gs=F(Ms(),1);function Bu(){Fs.default._configure(),Sn.default._configure(Us.default),xn.default._configure(Gs.default)}Bu();var $s=["uint64","int64","sint64","fixed64","sfixed64"];function Lu(r){for(let t of $s){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function An(r){return Lu(new Sn.default(r))}function Nu(r){for(let t of $s){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function In(){return Nu(xn.default.create())}function z(r,t){let e=An(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function H(r,t){let e=In();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var ve;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(ve||(ve={}));function pr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Gt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(s,a){let f=t(s);a.int32(f)},n=function(s){let a=s.int32();return t(a)};return pr("enum",ve.VARINT,e,n)}function K(r,t){return pr("message",ve.LENGTH_DELIMITED,r,t)}var M;(function(r){let t;(function(i){i.IDENTIFY="IDENTIFY",i.CONNECT="CONNECT",i.STREAM_OPEN="STREAM_OPEN",i.STREAM_HANDLER="STREAM_HANDLER",i.DHT="DHT",i.LIST_PEERS="LIST_PEERS",i.CONNMANAGER="CONNMANAGER",i.DISCONNECT="DISCONNECT",i.PUBSUB="PUBSUB",i.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.IDENTIFY=0]="IDENTIFY",i[i.CONNECT=1]="CONNECT",i[i.STREAM_OPEN=2]="STREAM_OPEN",i[i.STREAM_HANDLER=3]="STREAM_HANDLER",i[i.DHT=4]="DHT",i[i.LIST_PEERS=5]="LIST_PEERS",i[i.CONNMANAGER=6]="CONNMANAGER",i[i.DISCONNECT=7]="DISCONNECT",i[i.PUBSUB=8]="PUBSUB",i[i.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.connect!=null&&(s.uint32(18),mr.codec().encode(i.connect,s)),i.streamOpen!=null&&(s.uint32(26),gr.codec().encode(i.streamOpen,s)),i.streamHandler!=null&&(s.uint32(34),yr.codec().encode(i.streamHandler,s)),i.dht!=null&&(s.uint32(42),bt.codec().encode(i.dht,s)),i.connManager!=null&&(s.uint32(50),wr.codec().encode(i.connManager,s)),i.disconnect!=null&&(s.uint32(58),Er.codec().encode(i.disconnect,s)),i.pubsub!=null&&(s.uint32(66),$t.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(74),Sr.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=mr.codec().decode(i,i.uint32());break;case 3:a.streamOpen=gr.codec().decode(i,i.uint32());break;case 4:a.streamHandler=yr.codec().decode(i,i.uint32());break;case 5:a.dht=bt.codec().decode(i,i.uint32());break;case 6:a.connManager=wr.codec().decode(i,i.uint32());break;case 7:a.disconnect=Er.codec().decode(i,i.uint32());break;case 8:a.pubsub=$t.codec().decode(i,i.uint32());break;case 9:a.peerStore=Sr.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})(M||(M={}));var B;(function(r){let t;(function(i){i.OK="OK",i.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.OK=0]="OK",i[i.ERROR=1]="ERROR"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{if(a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.error!=null&&(s.uint32(18),br.codec().encode(i.error,s)),i.streamInfo!=null&&(s.uint32(26),Te.codec().encode(i.streamInfo,s)),i.identify!=null&&(s.uint32(34),dr.codec().encode(i.identify,s)),i.dht!=null&&(s.uint32(42),_t.codec().encode(i.dht,s)),i.peers!=null)for(let f of i.peers)s.uint32(50),Wt.codec().encode(f,s);i.pubsub!=null&&(s.uint32(58),Tr.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(66),xr.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={peers:[]},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=br.codec().decode(i,i.uint32());break;case 3:a.streamInfo=Te.codec().decode(i,i.uint32());break;case 4:a.identify=dr.codec().decode(i,i.uint32());break;case 5:a.dht=_t.codec().decode(i,i.uint32());break;case 6:a.peers.push(Wt.codec().decode(i,i.uint32()));break;case 7:a.pubsub=Tr.codec().decode(i,i.uint32());break;case 8:a.peerStore=xr.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})(B||(B={}));var dr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(dr||(dr={}));var mr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addrs.push(e.bytes());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(mr||(mr={}));var gr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.proto.push(e.string());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(gr||(gr={}));var yr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={addr:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.addr=e.bytes();break;case 2:i.proto.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(yr||(yr={}));var br;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={msg:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.msg=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(br||(br={}));var Te;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(18),n.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(n.uint32(26),n.string(e.proto)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addr=e.bytes();break;case 3:i.proto=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(Te||(Te={}));var bt;(function(r){let t;(function(i){i.FIND_PEER="FIND_PEER",i.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",i.FIND_PROVIDERS="FIND_PROVIDERS",i.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",i.GET_PUBLIC_KEY="GET_PUBLIC_KEY",i.GET_VALUE="GET_VALUE",i.SEARCH_VALUE="SEARCH_VALUE",i.PUT_VALUE="PUT_VALUE",i.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.FIND_PEER=0]="FIND_PEER",i[i.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",i[i.FIND_PROVIDERS=2]="FIND_PROVIDERS",i[i.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",i[i.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",i[i.GET_VALUE=5]="GET_VALUE",i[i.SEARCH_VALUE=6]="SEARCH_VALUE",i[i.PUT_VALUE=7]="PUT_VALUE",i[i.PROVIDE=8]="PROVIDE"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),s.bytes(i.peer)),i.cid!=null&&(s.uint32(26),s.bytes(i.cid)),i.key!=null&&(s.uint32(34),s.bytes(i.key)),i.value!=null&&(s.uint32(42),s.bytes(i.value)),i.count!=null&&(s.uint32(48),s.int32(i.count)),i.timeout!=null&&(s.uint32(56),s.int64(i.timeout)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.cid=i.bytes();break;case 4:a.key=i.bytes();break;case 5:a.value=i.bytes();break;case 6:a.count=i.int32();break;case 7:a.timeout=i.int64();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})(bt||(bt={}));var _t;(function(r){let t;(function(i){i.BEGIN="BEGIN",i.VALUE="VALUE",i.END="END"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.BEGIN=0]="BEGIN",i[i.VALUE=1]="VALUE",i[i.END=2]="END"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),Wt.codec().encode(i.peer,s)),i.value!=null&&(s.uint32(26),s.bytes(i.value)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=Wt.codec().decode(i,i.uint32());break;case 3:a.value=i.bytes();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})(_t||(_t={}));var Wt;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(Wt||(Wt={}));var wr;(function(r){let t;(function(i){i.TAG_PEER="TAG_PEER",i.UNTAG_PEER="UNTAG_PEER",i.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.TAG_PEER=0]="TAG_PEER",i[i.UNTAG_PEER=1]="UNTAG_PEER",i[i.TRIM=2]="TRIM"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),s.bytes(i.peer)),i.tag!=null&&(s.uint32(26),s.string(i.tag)),i.weight!=null&&(s.uint32(32),s.int64(i.weight)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.tag=i.string();break;case 4:a.weight=i.int64();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})(wr||(wr={}));var Er;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(Er||(Er={}));var $t;(function(r){let t;(function(i){i.GET_TOPICS="GET_TOPICS",i.LIST_PEERS="LIST_PEERS",i.PUBLISH="PUBLISH",i.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.GET_TOPICS=0]="GET_TOPICS",i[i.LIST_PEERS=1]="LIST_PEERS",i[i.PUBLISH=2]="PUBLISH",i[i.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.topic!=null&&(s.uint32(18),s.string(i.topic)),i.data!=null&&(s.uint32(26),s.bytes(i.data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.topic=i.string();break;case 3:a.data=i.bytes();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})($t||($t={}));var vr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.from!=null&&(n.uint32(10),n.bytes(e.from)),e.data!=null&&(n.uint32(18),n.bytes(e.data)),e.seqno!=null&&(n.uint32(26),n.bytes(e.seqno)),e.topicIDs!=null)for(let s of e.topicIDs)n.uint32(34),n.string(s);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topicIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.from=e.bytes();break;case 2:i.data=e.bytes();break;case 3:i.seqno=e.bytes();break;case 4:i.topicIDs.push(e.string());break;case 5:i.signature=e.bytes();break;case 6:i.key=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(vr||(vr={}));var Tr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let s of e.topics)n.uint32(10),n.string(s);if(e.peerIDs!=null)for(let s of e.peerIDs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topics:[],peerIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.topics.push(e.string());break;case 2:i.peerIDs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(Tr||(Tr={}));var Sr;(function(r){let t;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.GET_PROTOCOLS="GET_PROTOCOLS",i.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.GET_PROTOCOLS=1]="GET_PROTOCOLS",i[i.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{if(a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.id!=null&&(s.uint32(18),s.bytes(i.id)),i.protos!=null)for(let f of i.protos)s.uint32(26),s.string(f);a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={protos:[]},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.id=i.bytes();break;case 3:a.protos.push(i.string());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>H(i,r.codec()),r.decode=i=>z(i,r.codec())})(Sr||(Sr={}));var xr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),Wt.codec().encode(e.peer,n)),e.protos!=null)for(let s of e.protos)n.uint32(18),n.string(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={protos:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=Wt.codec().decode(e,e.uint32());break;case 2:i.protos.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>H(e,r.codec()),r.decode=e=>z(e,r.codec())})(xr||(xr={}));var pt=F(Js(),1);var kn={};ft(kn,{base32:()=>Dt,base32hex:()=>fl,base32hexpad:()=>pl,base32hexpadupper:()=>dl,base32hexupper:()=>hl,base32pad:()=>ul,base32padupper:()=>ll,base32upper:()=>al,base32z:()=>ml});function nl(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var s=r.charAt(i),a=s.charCodeAt(0);if(e[a]!==255)throw new TypeError(s+" is ambiguous");e[a]=i}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),h=Math.log(256)/Math.log(f);function g(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var C=0,I=0,_=0,D=b.length;_!==D&&b[_]===0;)_++,C++;for(var k=(D-_)*h+1>>>0,V=new Uint8Array(k);_!==D;){for(var rt=b[_],st=0,nt=k-1;(rt!==0||st<I)&&nt!==-1;nt--,st++)rt+=256*V[nt]>>>0,V[nt]=rt%f>>>0,rt=rt/f>>>0;if(rt!==0)throw new Error("Non-zero carry");I=st,_++}for(var ot=k-I;ot!==k&&V[ot]===0;)ot++;for(var Tt=l.repeat(C);ot<k;++ot)Tt+=r.charAt(V[ot]);return Tt}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var C=0;if(b[C]!==" "){for(var I=0,_=0;b[C]===l;)I++,C++;for(var D=(b.length-C)*d+1>>>0,k=new Uint8Array(D);b[C];){var V=e[b.charCodeAt(C)];if(V===255)return;for(var rt=0,st=D-1;(V!==0||rt<_)&&st!==-1;st--,rt++)V+=f*k[st]>>>0,k[st]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");_=rt,C++}if(b[C]!==" "){for(var nt=D-_;nt!==D&&k[nt]===0;)nt++;for(var ot=new Uint8Array(I+(D-nt)),Tt=I;nt!==D;)ot[Tt++]=k[nt++];return ot}}}function x(b){var C=w(b);if(C)return C;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:x}}var il=nl,sl=il,Qs=sl;var bp=new Uint8Array(0);var to=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},wt=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")};var eo=r=>new TextEncoder().encode(r),ro=r=>new TextDecoder().decode(r);var Dn=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Bn=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return io(this,t)}},Ln=class{constructor(t){this.decoders=t}or(t){return io(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},io=(r,t)=>new Ln({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Nn=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Dn(t,e,n),this.decoder=new Bn(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Re=({name:r,prefix:t,encode:e,decode:n})=>new Nn(r,t,e,n),Zt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=Qs(e,t);return Re({prefix:r,name:t,encode:n,decode:s=>wt(i(s))})},ol=(r,t,e,n)=>{let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*e/8|0),f=0,l=0,d=0;for(let h=0;h<s;++h){let g=i[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,f+=e,f>=8&&(f-=8,a[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return a},cl=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,s="",a=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],a+=8;a>e;)a-=e,s+=t[i&f>>a];if(a&&(s+=t[i&f<<e-a]),n)for(;s.length*e&7;)s+="=";return s},U=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Re({prefix:t,name:r,encode(i){return cl(i,n,e)},decode(i){return ol(i,n,e,r)}});var Dt=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),al=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ul=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ll=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fl=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hl=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),pl=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dl=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ml=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pn={};ft(Pn,{base58btc:()=>Y,base58flickr:()=>gl});var Y=Zt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gl=Zt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mn={};ft(Mn,{base64:()=>On,base64pad:()=>yl,base64url:()=>bl,base64urlpad:()=>wl});var On=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yl=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bl=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wl=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});pt.default.formatters.b=r=>r==null?"undefined":Y.baseEncode(r);pt.default.formatters.t=r=>r==null?"undefined":Dt.baseEncode(r);pt.default.formatters.m=r=>r==null?"undefined":On.baseEncode(r);pt.default.formatters.p=r=>r==null?"undefined":r.toString();pt.default.formatters.c=r=>r==null?"undefined":r.toString();pt.default.formatters.k=r=>r==null?"undefined":r.toString();pt.default.formatters.a=r=>r==null?"undefined":r.toString();function El(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Et(r){let t=El(`${r}:trace`);return pt.default.enabled(`${r}:trace`)&&pt.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,pt.default)(`${r}:trace`)),Object.assign((0,pt.default)(r),{error:(0,pt.default)(`${r}:error`),trace:t})}function ae(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Vt(r=0){return globalThis.Buffer?.alloc!=null?ae(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Bt(r=0){return globalThis.Buffer?.allocUnsafe!=null?ae(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function vt(r,t){t==null&&(t=r.reduce((i,s)=>i+s.length,0));let e=Bt(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return ae(e)}function ue(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var oo=Symbol.for("@achingbrain/uint8arraylist");function so(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let i=e+n.byteLength;if(t<i)return{buf:n,index:t-e};e=i}throw new RangeError("index is out of bounds")}function Cr(r){return!!r?.[oo]}var kt=class r{constructor(...t){Object.defineProperty(this,oo,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Cr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Cr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=so(this.bufs,t);return e.buf[e.index]}set(t,e){let n=so(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Cr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:i}=this._subList(t,e);return vt(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:vt(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),s=new r;return s.length=i,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],i=0;for(let s=0;s<this.bufs.length;s++){let a=this.bufs[s],f=i,l=f+a.byteLength;if(i=l,t>=l)continue;let d=t>=f&&t<l,h=e>f&&e<=l;if(d&&h){if(t===f&&e===l){n.push(a);break}let g=t-f;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-f));continue}if(h){if(e===l){n.push(a);break}n.push(a.subarray(0,e-f));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Cr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let s=256,a=new Int32Array(s);for(let g=0;g<s;g++)a[g]=-1;for(let g=0;g<i;g++)a[n[g]]=g;let f=a,l=this.byteLength-n.byteLength,d=n.byteLength-1,h;for(let g=e;g<=l;g+=h){h=0;for(let w=d;w>=0;w--){let x=this.get(g+w);if(n[w]!==x){h=Math.max(1,w-f[x]);break}}if(h===0)return g}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let i=Vt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,e,n),this.write(i,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let i=Vt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,e,n),this.write(i,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let i=Vt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,e,n),this.write(i,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let i=Vt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,e,n),this.write(i,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let i=Vt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,e,n),this.write(i,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let i=Vt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,e,n),this.write(i,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let i=Vt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,e,n),this.write(i,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let i=Vt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ue(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((i,s)=>i+s.byteLength,0)),n.length=e,n}};function co(r){let t=async function*(){let e=yield,n=new kt;for await(let i of r){if(e==null){n.append(i),e=yield n,n=new kt;continue}for(n.append(i);n.length>=e;){let s=n.sublist(0,e);if(n.consume(e),e=yield s,e==null){n.length>0&&(e=yield n,n=new kt);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}function _e(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Dr=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Ce=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Dr(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Dr(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var Un=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ao(r={}){return vl(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function vl(r,t){t=t??{};let e=t.onEnd,n=new Ce,i,s,a,f=_e(),l=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((I,_)=>{s=D=>{s=null,n.push(D);try{I(r(n))}catch(k){_(k)}return i}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{f.resolve(),f=_e()})}},d=I=>s!=null?s(I):(n.push(I),i),h=I=>(n=new Ce,s!=null?s({error:I}):(n.push({error:I}),i)),g=I=>{if(a)return i;if(t?.objectMode!==!0&&I?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return d({done:!1,value:I})},w=I=>a?i:(a=!0,I!=null?h(I):d({done:!0})),x=()=>(n=new Ce,w(),{done:!0}),b=I=>(w(I),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:l,return:x,throw:b,push:g,end:w,get readableLength(){return n.size},onEmpty:async I=>{let _=I?.signal;if(_?.throwIfAborted(),n.isEmpty())return;let D,k;_!=null&&(D=new Promise((V,rt)=>{k=()=>{rt(new Un)},_.addEventListener("abort",k)}));try{await Promise.race([f.promise,D])}finally{k!=null&&_!=null&&_?.removeEventListener("abort",k)}}},e==null)return i;let C=i;return i={[Symbol.asyncIterator](){return this},next(){return C.next()},throw(I){return C.throw(I),e!=null&&(e(I),e=void 0),{done:!0}},return(){return C.return(),e!=null&&(e(),e=void 0),{done:!0}},push:g,end(I){return C.end(I),e!=null&&(e(I),e=void 0),i},get readableLength(){return C.readableLength}},i}function uo(r){let t=ao(),e=co(r.source),n=_e(),i,s=r.sink(async function*(){yield*t,yield*await n.promise}());return s.catch(f=>{i=f}),{reader:e,writer:t,stream:{sink:async f=>{if(i!=null){await Promise.reject(i);return}n.resolve(f),await s},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let f=await e.next();if(f.value!=null)return f.value}}}function Br(r){return r instanceof Uint8Array?{get(t){return r[t]},set(t,e){r[t]=e}}:{get(t){return r.get(t)},set(t,e){r.set(t,e)}}}var lo=4294967296,qe=class r{constructor(t=0,e=0){this.hi=t,this.lo=e}toBigInt(t){if(t===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(t){return Number(this.toBigInt(t))}zzDecode(){let t=-(this.lo&1),e=((this.lo>>>1|this.hi<<31)^t)>>>0,n=(this.hi>>>1^t)>>>0;return new r(n,e)}zzEncode(){let t=this.hi>>31,e=((this.hi<<1|this.lo>>>31)^t)>>>0,n=(this.lo<<1^t)>>>0;return new r(e,n)}toBytes(t,e=0){let n=Br(t);for(;this.hi>0;)n.set(e++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(e++,this.lo&127|128),this.lo=this.lo>>>7;n.set(e++,this.lo)}static fromBigInt(t){if(t===0n)return new r;let e=t<0;e&&(t=-t);let n=Number(t>>32n)|0,i=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,i=~i>>>0,++i>lo&&(i=0,++n>lo&&(n=0))),new r(n,i)}static fromNumber(t){if(t===0)return new r;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(i,n)}static fromBytes(t,e=0){let n=Br(t),i=new r,s=0;if(t.length-e>4){for(;s<4;++s)if(i.lo=(i.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return i;if(i.lo=(i.lo|(n.get(e)&127)<<28)>>>0,i.hi=(i.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return i;s=0}else for(;s<4;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.lo=(i.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return i}if(t.length-e>4){for(;s<5;++s)if(i.hi=(i.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return i}else if(e<t.byteLength)for(;s<5;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.hi=(i.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return i}throw RangeError("invalid varint encoding")}};var Tl=Math.pow(2,7),Sl=Math.pow(2,14),xl=Math.pow(2,21),Al=Math.pow(2,28),Il=Math.pow(2,35),Rl=Math.pow(2,42),_l=Math.pow(2,49),Cl=Math.pow(2,56),Dl=Math.pow(2,63),le={encodingLength(r){return r<Tl?1:r<Sl?2:r<xl?3:r<Al?4:r<Il?5:r<Rl?6:r<_l?7:r<Cl?8:r<Dl?9:10},encode(r,t,e=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return t==null&&(t=Bt(le.encodingLength(r))),qe.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return qe.fromBytes(r,t).toNumber(!0)}};function Lr(r){return r[Symbol.asyncIterator]!=null}var Nr=r=>{let t=le.encodingLength(r),e=Bt(t);return le.encode(r,e),Nr.bytes=t,e};Nr.bytes=0;function kr(r,t){t=t??{};let e=t.lengthEncoder??Nr;function*n(i){let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return Lr(r)?async function*(){for await(let i of r)yield*n(i)}():function*(){for(let i of r)yield*n(i)}()}kr.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Nr;return new kt(e(r.byteLength),r)};var De=F(po(),1);var Ll=8,Nl=1024*1024*4,fe;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(fe||(fe={}));var Fn=r=>{let t=le.decode(r);return Fn.bytes=le.encodingLength(t),t};Fn.bytes=0;function We(r,t){let e=new kt,n=fe.LENGTH,i=-1,s=t?.lengthDecoder??Fn,a=t?.maxLengthLength??Ll,f=t?.maxDataLength??Nl;function*l(){for(;e.byteLength>0;){if(n===fe.LENGTH)try{if(i=s(e),i<0)throw(0,De.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>f)throw(0,De.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=s.bytes;e.consume(d),t?.onLength!=null&&t.onLength(i),n=fe.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>a)throw(0,De.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===fe.DATA){if(e.byteLength<i)break;let d=e.sublist(0,i);e.consume(i),t?.onData!=null&&t.onData(d),yield d,n=fe.LENGTH}}}return Lr(r)?async function*(){for await(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,De.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,De.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}We.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:s,value:a}=await r.next(e);if(s===!0)return;a!=null&&(yield a)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{e=1}}();return We(n,{...t??{},onLength:s=>{e=s}})};var Gn=Et("libp2p:daemon-protocol:stream-handler"),Ze=class{stream;shake;decoder;constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=uo(this.stream),this.decoder=We.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Gn("read received no value, closing stream"),await this.close()}write(t){Gn("write message"),this.shake.write(kr.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Gn("closing the stream"),await this.rest().sink([])}};var $n={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Be=class r extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},E=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Vn=Symbol.for("@libp2p/peer-id");function Le(r){return r!=null&&!!r[Vn]}var zn={};ft(zn,{identity:()=>Pl});var Pl=Re({prefix:"\0",name:"identity",encode:r=>ro(r),decode:r=>eo(r)});var Hn={};ft(Hn,{base2:()=>Ol});var Ol=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Kn={};ft(Kn,{base8:()=>Ml});var Ml=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Yn={};ft(Yn,{base10:()=>Ul});var Ul=Zt({prefix:"9",name:"base10",alphabet:"0123456789"});var qn={};ft(qn,{base16:()=>Fl,base16upper:()=>Gl});var Fl=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gl=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wn={};ft(Wn,{base36:()=>$l,base36upper:()=>Vl});var $l=Zt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Vl=Zt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Zn={};ft(Zn,{base256emoji:()=>ql});var mo=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}"),zl=mo.reduce((r,t,e)=>(r[e]=t,r),[]),Hl=mo.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Kl(r){return r.reduce((t,e)=>(t+=zl[e],t),"")}function Yl(r){let t=[];for(let e of r){let n=Hl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ql=Re({prefix:"\u{1F680}",name:"base256emoji",encode:Kl,decode:Yl});var ti={};ft(ti,{sha256:()=>Or,sha512:()=>pf});var Qn=F(Ft("crypto"),1);var Wl=bo,go=128,Zl=127,Xl=~Zl,jl=Math.pow(2,31);function bo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=jl;)t[e++]=r&255|go,r/=128;for(;r&Xl;)t[e++]=r&255|go,r>>>=7;return t[e]=r|0,bo.bytes=e-n+1,t}var Jl=Xn,Ql=128,yo=127;function Xn(r,n){var e=0,n=n||0,i=0,s=n,a,f=r.length;do{if(s>=f)throw Xn.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&yo)<<i:(a&yo)*Math.pow(2,i),i+=7}while(a>=Ql);return Xn.bytes=s-n,e}var tf=Math.pow(2,7),ef=Math.pow(2,14),rf=Math.pow(2,21),nf=Math.pow(2,28),sf=Math.pow(2,35),of=Math.pow(2,42),cf=Math.pow(2,49),af=Math.pow(2,56),uf=Math.pow(2,63),lf=function(r){return r<tf?1:r<ef?2:r<rf?3:r<nf?4:r<sf?5:r<of?6:r<cf?7:r<af?8:r<uf?9:10},ff={encode:Wl,decode:Jl,encodingLength:lf},hf=ff,Xe=hf;var je=(r,t=0)=>[Xe.decode(r,t),Xe.decode.bytes],Ne=(r,t,e=0)=>(Xe.encode(r,t,e),t),ke=r=>Xe.encodingLength(r);var Xt=(r,t)=>{let e=t.byteLength,n=ke(r),i=n+ke(e),s=new Uint8Array(i+e);return Ne(r,s,0),Ne(e,s,n),s.set(t,i),new Pe(r,e,t,s)},he=r=>{let t=wt(r),[e,n]=je(t),[i,s]=je(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new Pe(e,i,a,t)},wo=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&to(r.bytes,e.bytes)}},Pe=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Jn=({name:r,code:t,encode:e})=>new jn(r,t,e),jn=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Xt(this.code,e):e.then(n=>Xt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Or=Jn({name:"sha2-256",code:18,encode:r=>wt(Qn.default.createHash("sha256").update(r).digest())}),pf=Jn({name:"sha2-512",code:19,encode:r=>wt(Qn.default.createHash("sha512").update(r).digest())});var ei={};ft(ei,{identity:()=>Mr});var vo=0,df="identity",To=wt,mf=r=>Xt(vo,To(r)),Mr={code:vo,name:df,encode:To,digest:mf};var Md=new TextEncoder,Ud=new TextDecoder;var So=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return wf(e,ri(r),t||Y.encoder);default:return Ef(e,ri(r),t||Dt.encoder)}};var xo=new WeakMap,ri=r=>{let t=xo.get(r);if(t==null){let e=new Map;return xo.set(r,e),e}return t},ct=class r{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Je)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==vf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Xt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&wo(t.multihash,n.multihash)}toString(t){return So(this,t)}toJSON(){return{"/":So(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:s,bytes:a}=e;return new r(n,i,s,a||Ao(n,i,s.bytes))}else if(e[Tf]===!0){let{version:n,multihash:i,code:s}=e,a=he(i);return r.create(n,s,a)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Je)throw new Error(`Version 0 CID must use dag-pb (code: ${Je}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=Ao(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Je,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=wt(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=i.subarray(e.multihashSize-e.digestSize),a=new Pe(e.multihashCode,e.digestSize,s,i);return[e.version===0?r.createV0(a):r.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=je(t.subarray(e));return e+=w,g},i=n(),s=Je;if(i===18?(i=0,e=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,f=n(),l=n(),d=e+l,h=d-a;return{version:i,codec:s,multihashCode:f,digestSize:l,multihashSize:h,size:d}}static parse(t,e){let[n,i]=bf(t,e),s=r.decode(i);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ri(s).set(n,t),s}},bf=(r,t)=>{switch(r[0]){case"Q":{let e=t||Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t||Y;return[Y.prefix,e.decode(r)]}case Dt.prefix:{let e=t||Dt;return[Dt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},wf=(r,t,e)=>{let{prefix:n}=e;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return i},Ef=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let s=e.encode(r);return t.set(n,s),s}else return i},Je=112,vf=18,Ao=(r,t,e)=>{let n=ke(r),i=n+ke(t),s=new Uint8Array(i+e.byteLength);return Ne(r,s,0),Ne(t,s,n),s.set(e,i),s},Tf=Symbol.for("@ipld/js-cid/CID");var jt={...zn,...Hn,...Kn,...Yn,...qn,...kn,...Wn,...Pn,...Mn,...Zn},Wd={...ti,...ei};var Sf=Symbol.for("nodejs.util.inspect.custom"),Io=Object.values(jt).map(r=>r.decoder).reduce((r,t)=>r.or(t),jt.identity.decoder),Ro=114,_o=36,Co=37,Qe=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Vn]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ct.createV1(Ro,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return ue(this.multihash.bytes,t);if(typeof t=="string")return xf(t).equals(this);if(t?.multihash?.bytes!=null)return ue(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Sf](){return`PeerId(${this.toString()})`}},tr=class extends Qe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},er=class extends Qe{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},rr=class extends Qe{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function xf(r,t){if(t=t??Io,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=he(Y.decode(`z${r}`));return r.startsWith("12D")?new er({multihash:e}):r.startsWith("16U")?new rr({multihash:e}):new tr({multihash:e})}return Pt(Io.decode(r))}function Pt(r){try{let t=he(r);if(t.code===Mr.code){if(t.digest.length===_o)return new er({multihash:t});if(t.digest.length===Co)return new rr({multihash:t})}if(t.code===Or.code)return new tr({multihash:t})}catch{return Af(ct.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Af(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ro)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Or.code)return new tr({multihash:r.multihash});if(t.code===Mr.code){if(t.digest.length===_o)return new er({multihash:r.multihash});if(t.digest.length===Co)return new rr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Pc=F(Ft("net"),1);var Bo=Symbol.for("@libp2p/transport");var Do;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Do||(Do={}));var Ur=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};function No(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Lo=No("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ni=No("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Bt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),If={utf8:Lo,"utf-8":Lo,hex:jt.base16,latin1:ni,ascii:ni,binary:ni,...jt},Fr=If;function at(r,t="utf8"){let e=Fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Me=F(oi(),1);var Gr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,i){return this.readAtomically(()=>{let s=0,a=0,f=this.peekChar();if(f===void 0)return;let l=f==="0",d=2**(8*i)-1;for(;;){let h=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(h===void 0)break;if(s*=t,s+=h,s>d||(a+=1,e!==void 0&&a>e))return}if(a!==0)return!n&&l&&a>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let i=n*2;if(n<e.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return e[i]=a[0],e[i+1]=a[1],e[i+2]=a[2],e[i+3]=a[3],[i+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[i,!1];e[i]=s>>8,e[i+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,i]=t(e);if(n===16)return e;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),a=16-(n+2),[f]=t(s.subarray(0,a));return e.set(s.subarray(0,f),16-f),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var bm=new Gr;var Im=parseInt("0xFFFF",16),Rm=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ci(r,t="utf8"){let e=Fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ae(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var Ot=F(oi(),1);var Jt=Ft("node:net");function $r(r){return!!(0,Jt.isIP)(r)}var Ko=Jt.isIPv4,Kf=Jt.isIPv6,ai=function(r){let t=0;if(r=r.toString().trim(),Ko(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Kf(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ko(e[n]),a;s&&(a=ai(e[n]),e[n]=at(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,at(a.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let i=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);i[t++]=s>>8&255,i[t++]=s&255}return i}throw new Error("invalid ip address")},Yo=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let i=[];for(let s=0;s<e;s++)i.push(r[t+s]);return i.join(".")}if(e===16){let i=[];for(let s=0;s<e;s+=2)i.push(n.getUint16(t+s).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Oe={},ui={},qf=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];qf.forEach(r=>{let t=Wf(...r);ui[t.code]=t,Oe[t.name]=t});function Wf(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:!!n,path:!!i}}function P(r){if(typeof r=="number"){if(ui[r]!=null)return ui[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Oe[r]!=null)return Oe[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var d0=P("ip4"),m0=P("ip6"),g0=P("ipcidr");function fi(r,t){switch(P(r).code){case 4:case 41:return Xf(t);case 42:return Zo(t);case 6:case 273:case 33:case 132:return jo(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Zo(t);case 421:return th(t);case 444:return Xo(t);case 445:return Xo(t);case 466:return Qf(t);default:return at(t,"base16")}}function hi(r,t){switch(P(r).code){case 4:return qo(t);case 41:return qo(t);case 42:return Wo(t);case 6:case 273:case 33:case 132:return pi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Wo(t);case 421:return jf(t);case 444:return eh(t);case 445:return rh(t);case 466:return Jf(t);default:return ci(t,"base16")}}var li=Object.values(jt).map(r=>r.decoder),Zf=function(){let r=li[0].or(li[1]);return li.slice(2).forEach(t=>r=r.or(t)),r}();function qo(r){if(!$r(r))throw new Error("invalid ip address");return ai(r)}function Xf(r){let t=Yo(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!$r(t))throw new Error("invalid ip address");return t}function pi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function jo(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Wo(r){let t=ci(r),e=Uint8Array.from(Ot.default.encode(t.length));return vt([e,t],e.length+t.length)}function Zo(r){let t=Ot.default.decode(r);if(r=r.slice(Ot.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return at(r)}function jf(r){let t;r[0]==="Q"||r[0]==="1"?t=he(Y.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(Ot.default.encode(t.length));return vt([e,t],e.length+t.length)}function Jf(r){let t=Zf.decode(r),e=Uint8Array.from(Ot.default.encode(t.length));return vt([e,t],e.length+t.length)}function Qf(r){let t=Ot.default.decode(r),e=r.slice(Ot.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+at(e,"base64url")}function th(r){let t=Ot.default.decode(r),e=r.slice(Ot.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return at(e,"base58btc")}function eh(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Dt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=pi(n);return vt([e,i],e.length+i.length)}function rh(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Dt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=pi(n);return vt([e,i],e.length+i.length)}function Xo(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=at(t,"base32"),i=jo(e);return`${n}:${i}`}function Jo(r){r=di(r);let t=[],e=[],n=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){let a=i[s],f=P(a);if(f.size===0){t.push([f.code]),e.push([f.code]);continue}if(s++,s>=i.length)throw tc("invalid address: "+r);if(f.path===!0){n=di(i.slice(s).join("/")),t.push([f.code,hi(f.code,n)]),e.push([f.code,n]);break}let l=hi(f.code,i[s]);t.push([f.code,l]),e.push([f.code,fi(f.code,l)])}return{string:Qo(e),bytes:gi(t),tuples:t,stringTuples:e,path:n}}function mi(r){let t=[],e=[],n=null,i=0;for(;i<r.length;){let s=Me.default.decode(r,i),a=Me.default.decode.bytes??0,f=P(s),l=nh(f,r.slice(i+a));if(l===0){t.push([s]),e.push([s]),i+=a;continue}let d=r.slice(i+a,i+a+l);if(i+=l+a,i>r.length)throw tc("Invalid address Uint8Array: "+at(r,"base16"));t.push([s,d]);let h=fi(s,d);if(e.push([s,h]),f.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:Qo(e),tuples:t,stringTuples:e,path:n}}function Qo(r){let t=[];return r.map(e=>{let n=P(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),di(t.join("/"))}function gi(r){return vt(r.map(t=>{let e=P(t[0]),n=Uint8Array.from(Me.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=vt([n,t[1]])),n}))}function nh(r,t){return r.size>0?r.size/8:r.size===0?0:Me.default.decode(t)+(Me.default.decode.bytes??0)}function di(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function tc(r){return new Error("Error parsing address: "+r)}var ih=Symbol.for("nodejs.util.inspect.custom"),sh=[P("dns").code,P("dns4").code,P("dns6").code,P("dnsaddr").code],oh=new Map,ec=Symbol.for("@multiformats/js-multiaddr/multiaddr");function bi(r){return!!r?.[ec]}var yi=class r{bytes;#t;#e;#r;#n;[ec]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=mi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Jo(t)}else if(bi(t))e=mi(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,i,s="",a=P("tcp"),f=P("udp"),l=P("ip4"),d=P("ip6"),h=P("dns6"),g=P("ip6zone");for(let[x,b]of this.stringTuples())x===g.code&&(s=`%${b??""}`),sh.includes(x)&&(e=a.name,i=443,n=`${b??""}${s}`,t=x===h.code?6:4),(x===a.code||x===f.code)&&(e=P(x).name,i=parseInt(b??"")),(x===l.code||x===d.code)&&(e=P(x).name,n=`${b??""}${s}`,t=x===d.code?6:4);if(t==null||e==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:i}}protos(){return this.#e.map(([t])=>Object.assign({},P(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>P(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),i=n.lastIndexOf(e);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,i))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(gi(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,i])=>{n===Oe.p2p.code&&t.push([n,i]),n===Oe["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?at(Y.decode(`z${n}`),"base58btc"):at(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return ue(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=oh.get(e.name);if(n==null)throw new Ur(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new r(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[ih](){return`Multiaddr(${this.#t})`}};function J(r){return new yi(r)}var ch=T("dns4"),ah=T("dns6"),uh=T("dnsaddr"),me=$(T("dns"),uh,ch,ah),Hr=$(T("ip4"),T("ip6")),te=$(R(Hr,T("tcp")),R(me,T("tcp"))),Kr=R(Hr,T("udp")),lh=R(Kr,T("utp")),fh=R(Kr,T("quic")),hh=R(Kr,T("quic-v1")),wi=$(R(te,T("ws")),R(me,T("ws"))),Vr=$(R(wi,T("p2p")),wi),Ei=$(R(te,T("wss")),R(me,T("wss")),R(te,T("tls"),T("ws")),R(me,T("tls"),T("ws"))),zr=$(R(Ei,T("p2p")),Ei),vi=$(R(te,T("http")),R(Hr,T("http")),R(me,T("http"))),Ti=$(R(te,T("https")),R(Hr,T("https")),R(me,T("https"))),rc=R(Kr,T("webrtc-direct"),T("certhash")),sc=$(R(rc,T("p2p")),rc),nc=R(hh,T("webtransport"),T("certhash"),T("certhash")),oc=$(R(nc,T("p2p")),nc),cc=$(R(Vr,T("p2p-webrtc-star"),T("p2p")),R(zr,T("p2p-webrtc-star"),T("p2p")),R(Vr,T("p2p-webrtc-star")),R(zr,T("p2p-webrtc-star"))),U0=$(R(Vr,T("p2p-websocket-star"),T("p2p")),R(zr,T("p2p-websocket-star"),T("p2p")),R(Vr,T("p2p-websocket-star")),R(zr,T("p2p-websocket-star"))),ac=$(R(vi,T("p2p-webrtc-direct"),T("p2p")),R(Ti,T("p2p-webrtc-direct"),T("p2p")),R(vi,T("p2p-webrtc-direct")),R(Ti,T("p2p-webrtc-direct"))),ge=$(wi,Ei,vi,Ti,cc,ac,te,lh,fh,me,sc,oc),F0=$(R(ge,T("p2p-stardust"),T("p2p")),R(ge,T("p2p-stardust"))),Qt=$(R(ge,T("p2p")),cc,ac,sc,oc,T("p2p")),ic=$(R(Qt,T("p2p-circuit"),Qt),R(Qt,T("p2p-circuit")),R(T("p2p-circuit"),Qt),R(ge,T("p2p-circuit")),R(T("p2p-circuit"),ge),T("p2p-circuit")),uc=()=>$(R(ic,uc),ic),de=uc(),G0=$(R(de,Qt,de),R(Qt,de),R(de,Qt),de,Qt);var $0=$(R(de,T("webrtc"),T("p2p")),R(de,T("webrtc")),R(ge,T("webrtc"),T("p2p")),R(ge,T("webrtc")),T("webrtc"));function lc(r){function t(e){let n;try{n=J(e)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return t}function R(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(i=>(n=typeof i=="function"?i().partialMatch(e):i.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:lc(t),partialMatch:t}}function $(...r){function t(n){let i=null;return r.some(s=>{let a=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return a!=null?(i=a,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:lc(t),partialMatch:t}}function T(r){let t=r;function e(i){let s;try{s=J(i)}catch{return!1}let a=s.protoNames();return a.length===1&&a[0]===t}function n(i){return i.length===0?null:i[0]===t?i.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var kc=F(Ft("net"),1);var Yr=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=this.#t.get(t);i==null&&(i=[],this.#t.set(t,i)),i.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let i=this.#t.get(t);i!=null&&(i=i.filter(({callback:s})=>s!==e),this.#t.set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:i})=>!i),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new Ue(t,e))}},Si=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Ue=globalThis.CustomEvent??Si;function qr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Wr(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var Fe=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,xi=/\/\d{1,2}$/;var Q=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var Ge=F(Ai(),1),ye=F(nr(),1),dt=class r{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Wr(32),this.isInSubnet=qr,this.address=t;let e=xi.exec(t);if(e){if(this.parsedSubnet=e[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>32)throw new Q("Invalid subnet mask.");t=t.replace(xi,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new r(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(Fe))throw new Q("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],i;for(i=0;i<8;i+=2){let s=e.slice(i,i+2);n.push(parseInt(s,16))}return new r(n.join("."))}static fromInteger(t){return r.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new r(n)}toHex(){return this.parsedAddress.map(t=>(0,ye.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],e;for(e=0;e<4;e+=2){let n=(0,ye.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,ye.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new Ge.BigInteger(this.parsedAddress.map(t=>(0,ye.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Ge.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Ge.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Ge.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Ge.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return r.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}reverseForm(t){t||(t={});let e=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?e:(0,ye.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new r("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Fe,(0,ye.sprintf)('<span class="hover-group group-v4 group-6">%s</span>.<span class="hover-group group-v4 group-7">%s</span>',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};var mc={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},Ii={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},Ri=/([^0-9a-f:/%])/gi,_i=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Ci=/\/\d{1,3}(?=%|$)/,Di=/%.*$/,gc=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),yc=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var wc=F(nr(),1);function dh(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function jr(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,wc.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,dh(n)))}var we=F(nr(),1);function Li(r){return(0,we.sprintf)("(%s)",r.join("|"))}function Bi(r){return r.length<4?(0,we.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ni="[^A-Fa-f0-9:]";function Jr(r){let t=[];r.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let e=t.map(n=>r.map((i,s)=>{if(s===n){let a=s===0||s===8-1?":":"";return Li([Bi(i),a])}return Bi(i)}).join(":"));return e.push(r.map(Bi).join(":")),Li(e)}function ki(r,t,e){let n=t?"":":",i=e?"":":",s=[];!t&&!e&&s.push("::"),t&&e&&s.push(""),(e&&!t||!e&&t)&&s.push(":"),s.push((0,we.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),s.push((0,we.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),s.push((0,we.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let f=1;f<r-a;f++)s.push((0,we.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",f,r-f-a-1));return Li(s)}var tt=F(Ai(),1),et=F(nr(),1);function Qr(r){if(!r)throw new Error("Assertion failed.")}function mh(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function gh(r){return r=r.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2'),r=r.replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2'),r}function yh(r,t){let e=[],n=[],i;for(i=0;i<r.length;i++)i<t[0]?e.push(r[i]):i>t[1]&&n.push(r[i]);return e.concat(["compact"]).concat(n)}function vc(r){return(0,et.sprintf)("%04x",parseInt(r,16))}function Tc(r){return r&255}var ir=class r{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=qr,this.isCorrect=Wr(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Ci.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>128)throw new Q("Invalid subnet mask.");t=t.replace(Ci,"")}else if(/\//.test(t))throw new Q("Invalid subnet mask.");let i=Di.exec(t);i&&(this.zone=i[0],t=t.replace(Di,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new r(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],i;for(i=0;i<8;i++)n.push(e.slice(i*4,(i+1)*4));return new r(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=yc.exec(t),i===null)return{error:"failed to parse address with port",address:null,port:null};e=i[1],n=i[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),i=gc.exec(t),i===null)return{error:"failed to parse address from URL",address:null,port:null};e=i[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new r(e),port:n}}static fromAddress4(t){let e=new dt(t),n=128-(32-e.subnetMask);return new r(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new Q("Invalid 'ip6.arpa' form.");let i=e.split(".").reverse();for(let s=n;s>0;s--){let a=s*4;i.splice(a,0,":")}return e=i.join(""),new r(e)}microsoftTranscription(){return(0,et.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),i=e-n;return i<0?"0":mh(new tt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new tt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new tt.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new tt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new tt.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=mc[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(Ii))if(this.isInSubnet(new r(t)))return Ii[t];return"Global unicast"}getBits(t,e){return new tt.BigInteger(this.getBitsBase2(t,e),2)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}getBitsBase16(t,e){let n=e-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,e).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,128)}reverseForm(t){t||(t={});let e=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,e).reverse().join(".");return e>0?t.omitSuffix?n:(0,et.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,i=[];for(t=0;t<this.parsedAddress.length;t++){let f=parseInt(this.parsedAddress[t],16);f===0&&n++,f!==0&&n>0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let s=i.map(f=>f[1]-f[0]+1);if(i.length>0){let f=s.indexOf(Math.max(...s));e=yh(this.parsedAddress,i[f])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let a=e.join(":");return a=a.replace(/^compact$/,"::"),a=a.replace(/^compact|compact$/,":"),a=a.replace(/compact/,""),a}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),i=e.slice(-1)[0].match(Fe);if(i){this.parsedAddress4=i[0],this.address4=new dt(this.parsedAddress4);for(let s=0;s<this.address4.groups;s++)if(/^0[0-9]+/.test(this.address4.parsedAddress[s]))throw new Q("IPv4 addresses can't have leading zeroes.",t.replace(Fe,this.address4.parsedAddress.map(gh).join(".")));this.v4=!0,e[e.length-1]=this.address4.toGroup6(),t=e.join(":")}return t}parse(t){t=this.parse4in6(t);let e=t.match(Ri);if(e)throw new Q((0,et.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(Ri,'<span class="parse-error">$1</span>'));let n=t.match(_i);if(n)throw new Q((0,et.sprintf)("Address failed regex: %s",n.join("")),t.replace(_i,'<span class="parse-error">$1</span>'));let i=[],s=t.split("::");if(s.length===2){let a=s[0].split(":"),f=s[1].split(":");a.length===1&&a[0]===""&&(a=[]),f.length===1&&f[0]===""&&(f=[]);let l=this.groups-(a.length+f.length);if(!l)throw new Q("Error parsing groups");this.elidedGroups=l,this.elisionBegin=a.length,this.elisionEnd=a.length+this.elidedGroups,i=i.concat(a);for(let d=0;d<l;d++)i.push("0");i=i.concat(f)}else if(s.length===1)i=t.split(":"),this.elidedGroups=0;else throw new Q("Too many :: groups found");if(i=i.map(a=>(0,et.sprintf)("%x",parseInt(a,16))),i.length!==this.groups)throw new Q("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(vc).join(":")}decimal(){return this.parsedAddress.map(t=>(0,et.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new tt.BigInteger(this.parsedAddress.map(vc).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return dt.fromHex(new tt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new r(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),i="";return/:$/.test(n)||(i=":"),n+i+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new tt.BigInteger("ffff",16)).toString(),n=dt.fromHex(this.getBitsBase16(32,64)),i=dt.fromHex(this.getBits(96,128).xor(new tt.BigInteger("ffffffff",16)).toString(16)),s=this.getBits(64,80),a=this.getBitsBase2(64,80),f=s.testBit(15),l=s.testBit(14),d=s.testBit(8),h=s.testBit(9),g=new tt.BigInteger(a.slice(2,6)+a.slice(8,16),2).toString(10);return{prefix:(0,et.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:a,coneNat:f,microsoft:{reserved:l,universalLocal:h,groupIndividual:d,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=dt.fromHex(this.getBitsBase16(16,48));return{prefix:(0,et.sprintf)("%s",t.slice(0,4)),gateway:e.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new r(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Tc)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Tc))}static fromUnsignedByteArray(t){let e=new tt.BigInteger("256",10),n=new tt.BigInteger("0",10),i=new tt.BigInteger("1",10);for(let s=t.length-1;s>=0;s--)n=n.add(i.multiply(new tt.BigInteger(t[s].toString(10),10))),i=i.multiply(e);return r.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new r("2001::/32"))}is6to4(){return this.isInSubnet(new r("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,et.sprintf)(":%s",t),(0,et.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let e=this.correctForm;return t.v4&&(e=this.to4in6),t.className?(0,et.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,et.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return jr(this.address).join(":");Qr(typeof this.elidedGroups=="number"),Qr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...jr(e)):t.push("");let i=["hover-group"];for(let s=this.elisionBegin;s<this.elisionBegin+this.elidedGroups;s++)i.push((0,et.sprintf)("group-%d",s));return t.push((0,et.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...jr(n,this.elisionEnd)):t.push(""),this.is4()&&(Qr(this.address4 instanceof dt),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new r(this.correctForm());if(n.elidedGroups===0)e.push(Jr(n.parsedAddress));else if(n.elidedGroups===8)e.push(ki(8));else{let i=n.address.split("::");i[0].length&&e.push(Jr(i[0].split(":"))),Qr(typeof n.elidedGroups=="number"),e.push(ki(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Jr(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ni,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ni,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var bh=Et("libp2p:ip-port-to-multiaddr"),Pi={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Sc(r,t){if(typeof r!="string")throw new E(`invalid ip provided: ${r}`,Pi.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new E(`invalid port provided: ${t}`,Pi.ERR_INVALID_PORT_PARAMETER);try{return new dt(r),J(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new ir(r);return e.is4()?J(`/ip4/${e.to4().correctForm()}/tcp/${t}`):J(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw bh.error(n),new E(n,Pi.ERR_INVALID_IP)}}var Nc=F(Bc(),1);var Ui=F(Ft("os"),1),Lc=F(Ft("path"),1);var Sh={ip4:"IPv4",ip6:"IPv6"};function ze(r,t={}){let e=r.getPath();return e!=null?Ui.default.platform()==="win32"?{path:Lc.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function Fi(r,t,e){let n=i=>J(`/${r}/${i}/tcp/${e}`);return(xh(t)?Ih(Sh[r]):[t]).map(n)}function xh(r){return["0.0.0.0","::"].includes(r)}var Ah=Ui.default.networkInterfaces();function Ih(r){let t=[];for(let[,e]of Object.entries(Ah))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Mt=Et("libp2p:tcp:socket"),en=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,s=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let a;if(t.remoteAddr!=null)a=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new E("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Sc(r.remoteAddress,r.remotePort)}let f=ze(a),l=f.path??`${f.host??""}:${f.port??""}`,{sink:d,source:h}=Nc.default.duplex(r);r.setTimeout(i,()=>{Mt("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new E("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Mt("%s socket close",l),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Mt("%s socket end",l),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await d(w)}catch(x){x.type!=="aborted"&&Mt(x)}r.end()},source:h,remoteAddr:a,timeline:{open:Date.now()},async close(w={}){if(r.destroyed){Mt("%s socket was already destroyed when trying to close",l);return}w.signal=w.signal??AbortSignal.timeout(s);try{Mt("%s closing socket",l),await new Promise((x,b)=>{r.once("close",()=>{Mt("%s socket closed",l),x()}),r.once("error",C=>{Mt("%s socket error",l,C),g.timeline.close==null&&(g.timeline.close=Date.now()),b(C)}),r.setTimeout(s),r.end(),r.writableLength>0?r.once("drain",()=>{Mt("%s socket drained",l),r.destroy()}):r.destroy()})}catch(x){this.abort(x)}},abort:w=>{Mt("%s socket abort due to error",l,w),r.destroy(w)}};return g};var mt=Et("libp2p:tcp:listener");async function Gi(r){try{await r.close()}catch(t){mt.error("an error occurred closing the connection",t)}}var Ch=1,Dh=0,rn=class extends Yr{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=kc.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:Ch})}this.dispatchEvent(new Ue("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Ue("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Dh}),this.dispatchEvent(new Ue("close"))})}onSocket(t){t.on("error",n=>{mt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=en(t,{listeningAddr:this.status.started?this.status.listeningAddr:void 0,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(n){mt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}mt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{mt("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(i=>{mt.error("error attempting to listen server once connection count under limit",i),this.context.closeServerOnMaxConnections?.onListenError?.(i)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new Ue("connection",{detail:n}))}).catch(async n=>{mt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Gi(e)}).catch(n=>{mt.error("closing inbound connection failed",n)})}catch(n){mt.error("inbound connection failed",n),Gi(e).catch(i=>{mt.error("closing inbound connection failed",i),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:i}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Fi("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Fi("ip6",e.address,e.port)))}catch(s){mt.error("could not turn %s:%s into multiaddr",e.address,e.port,s)}return t.map(s=>i!=null?s.encapsulate(`/p2p/${i}`):s)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:i}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:ze(n,{backlog:i})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Gi(t)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let t=this.status.netConfig;await new Promise((e,n)=>{this.server.once("error",n),this.server.listen(t,e)}),mt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(mt("Closing server on %s",this.server.address()),this.server.close())}};var Ht=Et("libp2p:tcp"),Vi=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Bo]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",f=>{Ht("socket error",f)});let i=en(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{i.close().catch(f=>{Ht.error("Error closing maConn after abort",f)})};e.signal?.addEventListener("abort",s,{once:!0}),Ht("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(Ht("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw a.close().catch(f=>{Ht.error("Error closing conn after abort",f)}),new Be;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Be;return new Promise((n,i)=>{let s=Date.now(),a=ze(t),f=a.path??`${a.host??""}:${a.port}`;Ht("dialing %j",a);let l=Pc.default.connect(a),d=b=>{b.message=`connection error ${f}: ${b.message}`,this.metrics?.dialerEvents.increment({error:!0}),x(b)},h=()=>{Ht("connection timeout %s",f),this.metrics?.dialerEvents.increment({timeout:!0});let b=new E(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",b)},g=()=>{Ht("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),x()},w=()=>{Ht("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),x(new Be)},x=b=>{if(l.removeListener("error",d),l.removeListener("timeout",h),l.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),b!=null){i(b);return}n(l)};l.on("error",d),l.on("timeout",h),l.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new rn({...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:te.matches(e.decapsulateCode(421)))}};function Oc(r={}){return(t={})=>new Vi(t,r)}var nn=class{client;constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new E("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new E("value received is not a Uint8Array","ERR_INVALID_VALUE");let n=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.PUT_VALUE,key:t,value:e}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=B.decode(i);if(await n.close(),s.type!==B.Type.OK)throw new E(s.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new E("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.GET_VALUE,key:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(await e.close(),i.type!==B.Type.OK)throw new E(i.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(i.dht==null||i.dht.value==null)throw new E("Invalid DHT get response","ERR_DHT_GET_FAILED");return i.dht.value}async findPeer(t){if(!Le(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.FIND_PEER,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(await e.close(),i.type!==B.Type.OK)throw new E(i.error?.msg??"DHT find peer failed","ERR_DHT_FIND_PEER_FAILED");if(i.dht==null||i.dht.peer==null||i.dht.peer.addrs==null)throw new E("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:Pt(i.dht.peer.id),multiaddrs:i.dht.peer.addrs.map(s=>J(s)),protocols:[]}}async provide(t){if(t==null||ct.asCID(t)==null)throw new E("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.PROVIDE,cid:t.bytes}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(await e.close(),i.type!==B.Type.OK)throw new E(i.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||ct.asCID(t)==null)throw new E("invalid cid received","ERR_INVALID_CID");let n=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=B.decode(i);if(s.type!==B.Type.OK)throw await n.close(),new E(s.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(i=await n.read(),i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let a=_t.decode(i);if(a.type===_t.Type.END){await n.close();return}if(a.type===_t.Type.VALUE&&a.peer!=null&&a.peer?.addrs!=null)yield{id:Pt(a.peer.id),multiaddrs:a.peer.addrs.map(f=>J(f)),protocols:[]};else throw await n.close(),new E("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new E("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.GET_CLOSEST_PEERS,key:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(i.type!==B.Type.OK)throw await e.close(),new E(i.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await e.read(),n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=_t.decode(n);if(s.type===_t.Type.END){await e.close();return}if(s.type===_t.Type.VALUE&&s.value!=null)yield{id:Pt(s.value),multiaddrs:[],protocols:[]};else throw await e.close(),new E("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!Le(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:M.Type.DHT,dht:{type:bt.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(await e.close(),i.type!==B.Type.OK)throw new E(i.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(i.dht==null)throw new E("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return i.dht.value}};var sn=class{client;constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:M.Type.PUBSUB,pubsub:{type:$t.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let n=B.decode(e);if(await t.close(),n.type!==B.Type.OK)throw new E(n.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new E("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return n.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new E("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new E("data received is not a Uint8Array","ERR_INVALID_DATA");let n=await this.client.send({type:M.Type.PUBSUB,pubsub:{type:$t.Type.PUBLISH,topic:t,data:e}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=B.decode(i);if(await n.close(),s.type!==B.Type.OK)throw new E(s.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async subscribe(t){if(typeof t!="string")throw new E("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:M.Type.PUBSUB,pubsub:{type:$t.Type.SUBSCRIBE,topic:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(i.type!==B.Type.OK)throw new E(i.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");let s=!0;return{async*messages(){for(;s;){if(n=await e.read(),n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");yield vr.decode(n)}},async cancel(){s=!1,await e.close()}}}async getSubscribers(t){if(typeof t!="string")throw new E("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:M.Type.PUBSUB,pubsub:{type:$t.Type.LIST_PEERS,topic:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=B.decode(n);if(await e.close(),i.type!==B.Type.OK)throw new E(i.error?.msg??"Pubsub get subscribers failed","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");if(i.pubsub==null||i.pubsub.topics==null)throw new E("Invalid response","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");return i.pubsub.peerIDs.map(s=>Pt(s))}};var zi=Et("libp2p:daemon-client"),Hi=class{multiaddr;dht;pubsub;tcp;constructor(t){this.multiaddr=t,this.tcp=Oc()(),this.dht=new nn(this),this.pubsub=new sn(this)}async connectDaemon(){return this.tcp.dial(this.multiaddr,{upgrader:$n})}async send(t){let e=await this.connectDaemon(),n=t.pubsub?.type??t.dht?.type??t.peerStore?.type??"";zi("send",t.type,n);let i=new Ze({stream:e});return i.write(M.encode(t)),i}async connect(t,e){if(!Le(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new E("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(a=>{if(!bi(a))throw new E("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let n=await this.send({type:M.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(a=>a.bytes)}}),i=await n.read();if(i==null)throw new E("unspecified","ERR_CONNECT_FAILED");let s=B.decode(i);if(s.type!==B.Type.OK){let a=s.error??{msg:"unspecified"};throw new E(a.msg??"unspecified","ERR_CONNECT_FAILED")}await n.close()}async identify(){let t=await this.send({type:M.Type.IDENTIFY}),e=await t.read();if(e==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let n=B.decode(e);if(n.type!==B.Type.OK)throw new E(n.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(n.identify==null||n.identify.addrs==null)throw new E("Invalid response","ERR_IDENTIFY_FAILED");let i=Pt(n.identify?.id),s=n.identify.addrs.map(a=>J(a));return await t.close(),{peerId:i,addrs:s}}async listPeers(){let t=await this.send({type:M.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let n=B.decode(e);if(n.type!==B.Type.OK)throw new E(n.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),n.peers.map(i=>Pt(i.id))}async openStream(t,e){if(!Le(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new E("invalid protocol received","ERR_INVALID_PROTOCOL");let n=await this.send({type:M.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=B.decode(i);if(s.type!==B.Type.OK)throw await n.close(),new E(s.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return n.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new E("invalid protocol received","ERR_INVALID_PROTOCOL");let n=this.tcp.createListener({upgrader:$n,handler:l=>{Promise.resolve().then(async()=>{let d=new Ze({stream:l}),h=await d.read();if(h==null)throw new E("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(Te.decode(h).proto!==t)throw new E("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(d.rest())}).finally(()=>{l.close().catch(d=>{zi.error(d)}),n.close().catch(d=>{zi.error(d)})})}});await n.listen(J("/ip4/127.0.0.1/tcp/0"));let i=n.getAddrs()[0];if(i==null)throw new E("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let s=await this.send({type:M.Type.STREAM_HANDLER,streamHandler:{addr:i.bytes,proto:[t]}}),a=await s.read();if(a==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let f=B.decode(a);if(await s.close(),f.type!==B.Type.OK)throw new E(f.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function Nh(r){return new Hi(r)}return Tu(kh);})();
4
+ `+i),r.push(n+"m+"+Be.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=zs()+t+" "+r[0]}function zs(){return k.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Hs(...r){return process.stderr.write(Fe.format(...r)+`
5
+ `)}function Ks(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Ys(){return process.env.DEBUG}function Ws(r){r.inspectOpts={};let t=Object.keys(k.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=k.inspectOpts[t[e]]}Be.exports=Mr()(k);var{formatters:io}=Be.exports;io.o=function(r){return this.inspectOpts.colors=this.useColors,Fe.inspect(r,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};io.O=function(r){return this.inspectOpts.colors=this.useColors,Fe.inspect(r,this.inspectOpts)}});var co=$((Tl,Gr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Gr.exports=to():Gr.exports=so()});var yo=$((ou,go)=>{"use strict";function mo(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function nc(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return mo(r,e)}catch{e.message=r.message,e.stack=r.stack;let n=function(){};return n.prototype=Object.create(Object.getPrototypeOf(r)),mo(new n,e)}}go.exports=nc});var tr=$((lf,Wo)=>{Wo.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:o}=await t.read();if(e)return;yield o}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var Jo=$((uf,Xo)=>{Xo.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var pn=$((df,Qo)=>{var Bc=Jo();Qo.exports=r=>async t=>{t=Bc(t);let e=E=>{typeof E.return=="function"&&E.return()},o=null,n=null,i=E=>{o=E,n&&n(E),e(t)},s=null,c=!1,a=()=>{c=!0,s&&s()},p=null,u=!1,d=()=>{u=!0,p&&p()},h=null,b=()=>{h&&h()},g=()=>new Promise((E,C)=>{s=h=E,n=C,r.once("drain",b)}),x=()=>(e(t),new Promise((E,C)=>{if(c||u||o)return E();p=s=E,n=C})),y=()=>{r.removeListener("error",i),r.removeListener("close",a),r.removeListener("finish",d),r.removeListener("drain",b)};r.once("error",i),r.once("close",a),r.once("finish",d);try{for await(let E of t){if(!r.writable||r.destroyed||o)break;r.write(E)===!1&&await g()}}catch(E){o||r.destroy(),o=E}try{if(r.writable&&r.end(),await x(),o)throw o}finally{y()}}});var mn=$((ff,Zo)=>{var Mc=pn(),Vc=tr();Zo.exports=r=>({sink:Mc(r),source:Vc(r)})});var jo=$((hf,qo)=>{var Gc=mn();qo.exports=r=>async function*(t){let e=Gc(r),o;if(e.sink(t).catch(n=>{o=n}),yield*e.source,o)throw o}});var ti=$((pf,re)=>{re.exports=tr();re.exports.source=tr();re.exports.sink=pn();re.exports.transform=jo();re.exports.duplex=mn()});var Zc={};J(Zc,{createClient:()=>Qc});var ir=new Float32Array([-0]),bt=new Uint8Array(ir.buffer);function Cn(r,t,e){ir[0]=r,t[e]=bt[0],t[e+1]=bt[1],t[e+2]=bt[2],t[e+3]=bt[3]}function Tn(r,t){return bt[0]=r[t],bt[1]=r[t+1],bt[2]=r[t+2],bt[3]=r[t+3],ir[0]}var sr=new Float64Array([-0]),U=new Uint8Array(sr.buffer);function Sn(r,t,e){sr[0]=r,t[e]=U[0],t[e+1]=U[1],t[e+2]=U[2],t[e+3]=U[3],t[e+4]=U[4],t[e+5]=U[5],t[e+6]=U[6],t[e+7]=U[7]}function vn(r,t){return U[0]=r[t],U[1]=r[t+1],U[2]=r[t+2],U[3]=r[t+3],U[4]=r[t+4],U[5]=r[t+5],U[6]=r[t+6],U[7]=r[t+7],sr[0]}var fi=BigInt(Number.MAX_SAFE_INTEGER),hi=BigInt(Number.MIN_SAFE_INTEGER),z=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,o=~this.hi>>>0;return e===0&&(o=o+1>>>0),-(e+o*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,o=~this.hi>>>0;return e===0&&(o=o+1>>>0),-(BigInt(e)+(BigInt(o)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,o=this.hi>>>24;return o===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:o<128?9:10}static fromBigInt(t){if(t===0n)return vt;if(t<fi&&t>hi)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let o=t>>32n,n=t-(o<<32n);return e&&(o=~o|0n,n=~n|0n,++n>Rn&&(n=0n,++o>Rn&&(o=0n))),new r(Number(n),Number(o))}static fromNumber(t){if(t===0)return vt;let e=t<0;e&&(t=-t);let o=t>>>0,n=(t-o)/4294967296>>>0;return e&&(n=~n>>>0,o=~o>>>0,++o>4294967295&&(o=0,++n>4294967295&&(n=0))),new r(o,n)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):vt}},vt=new z(0,0);vt.toBigInt=function(){return 0n};vt.zzEncode=vt.zzDecode=function(){return this};vt.length=function(){return 1};var Rn=4294967296n;function Dn(r){let t=0,e=0;for(let o=0;o<r.length;++o)e=r.charCodeAt(o),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(o+1)&64512)===56320?(++o,t+=4):t+=3;return t}function Ln(r,t,e){if(e-t<1)return"";let n,i=[],s=0,c;for(;t<e;)c=r[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),s=0);return n!=null?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function cr(r,t,e){let o=e,n,i;for(let s=0;s<r.length;++s)n=r.charCodeAt(s),n<128?t[e++]=n:n<2048?(t[e++]=n>>6|192,t[e++]=n&63|128):(n&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(n=65536+((n&1023)<<10)+(i&1023),++s,t[e++]=n>>18|240,t[e++]=n>>12&63|128,t[e++]=n>>6&63|128,t[e++]=n&63|128):(t[e++]=n>>12|224,t[e++]=n>>6&63|128,t[e++]=n&63|128);return e-o}function it(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Ee(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ar=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,it(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw it(this,4);return Ee(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw it(this,4);return Ee(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw it(this,4);let t=Tn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw it(this,4);let t=vn(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,o=this.pos+t;if(o>this.len)throw it(this,t);return this.pos+=t,e===o?new Uint8Array(0):this.buf.subarray(e,o)}string(){let t=this.bytes();return Ln(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw it(this,t);this.pos+=t}else do if(this.pos>=this.len)throw it(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new z(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw it(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw it(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw it(this,8);let t=Ee(this.buf,this.pos+=4),e=Ee(this.buf,this.pos+=4);return new z(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 lr(r){return new ar(r instanceof Uint8Array?r:r.subarray())}function R(r,t){let e=lr(r);return t.decode(e)}function Rt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ht(r=0){return globalThis.Buffer?.alloc!=null?Rt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function F(r=0){return globalThis.Buffer?.allocUnsafe!=null?Rt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var pr={};J(pr,{base10:()=>bi});function pi(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),o=0;o<e.length;o++)e[o]=255;for(var n=0;n<r.length;n++){var i=r.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var c=r.length,a=r.charAt(0),p=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function d(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var x=0,y=0,E=0,C=g.length;E!==C&&g[E]===0;)E++,x++;for(var _=(C-E)*u+1>>>0,P=new Uint8Array(_);E!==C;){for(var W=g[E],j=0,X=_-1;(W!==0||j<y)&&X!==-1;X--,j++)W+=256*P[X]>>>0,P[X]=W%c>>>0,W=W/c>>>0;if(W!==0)throw new Error("Non-zero carry");y=j,E++}for(var tt=_-y;tt!==_&&P[tt]===0;)tt++;for(var Bt=a.repeat(x);tt<_;++tt)Bt+=r.charAt(P[tt]);return Bt}function h(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var x=0;if(g[x]!==" "){for(var y=0,E=0;g[x]===a;)y++,x++;for(var C=(g.length-x)*p+1>>>0,_=new Uint8Array(C);g[x];){var P=e[g.charCodeAt(x)];if(P===255)return;for(var W=0,j=C-1;(P!==0||W<E)&&j!==-1;j--,W++)P+=c*_[j]>>>0,_[j]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");E=W,x++}if(g[x]!==" "){for(var X=C-E;X!==C&&_[X]===0;)X++;for(var tt=new Uint8Array(y+(C-X)),Bt=y;X!==C;)tt[Bt++]=_[X++];return tt}}}function b(g){var x=h(g);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:h,decode:b}}var mi=pi,gi=mi,Nn=gi;var ua=new Uint8Array(0);var Pn=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},et=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")};var On=r=>new TextEncoder().encode(r),kn=r=>new TextDecoder().decode(r);var ur=class{constructor(t,e,o){this.name=t,this.prefix=e,this.baseEncode=o}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},dr=class{constructor(t,e,o){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=o}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Fn(this,t)}},fr=class{constructor(t){this.decoders=t}or(t){return Fn(this,t)}decode(t){let e=t[0],o=this.decoders[e];if(o)return o.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Fn=(r,t)=>new fr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),hr=class{constructor(t,e,o,n){this.name=t,this.prefix=e,this.baseEncode=o,this.baseDecode=n,this.encoder=new ur(t,e,o),this.decoder=new dr(t,e,n)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Mt=({name:r,prefix:t,encode:e,decode:o})=>new hr(r,t,e,o),wt=({prefix:r,name:t,alphabet:e})=>{let{encode:o,decode:n}=Nn(e,t);return Mt({prefix:r,name:t,encode:o,decode:i=>et(n(i))})},yi=(r,t,e,o)=>{let n={};for(let u=0;u<t.length;++u)n[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,p=0;for(let u=0;u<i;++u){let d=n[r[u]];if(d===void 0)throw new SyntaxError(`Non-${o} character`);a=a<<e|d,c+=e,c>=8&&(c-=8,s[p++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s},Ei=(r,t,e)=>{let o=t[t.length-1]==="=",n=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[n&c>>s];if(s&&(i+=t[n&c<<e-s]),o)for(;i.length*e&7;)i+="=";return i},T=({name:r,prefix:t,bitsPerChar:e,alphabet:o})=>Mt({prefix:t,name:r,encode(n){return Ei(n,o,e)},decode(n){return yi(n,o,e,r)}});var bi=wt({prefix:"9",name:"base10",alphabet:"0123456789"});var mr={};J(mr,{base16:()=>wi,base16upper:()=>xi});var wi=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xi=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gr={};J(gr,{base2:()=>Ii});var Ii=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yr={};J(yr,{base256emoji:()=>vi});var Bn=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}"),Ai=Bn.reduce((r,t,e)=>(r[e]=t,r),[]),Ci=Bn.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ti(r){return r.reduce((t,e)=>(t+=Ai[e],t),"")}function Si(r){let t=[];for(let e of r){let o=Ci[e.codePointAt(0)];if(o===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var vi=Mt({prefix:"\u{1F680}",name:"base256emoji",encode:Ti,decode:Si});var Er={};J(Er,{base32:()=>st,base32hex:()=>_i,base32hexpad:()=>Pi,base32hexpadupper:()=>Oi,base32hexupper:()=>Ni,base32pad:()=>Di,base32padupper:()=>Li,base32upper:()=>Ri,base32z:()=>ki});var st=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ri=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Di=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Li=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_i=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ni=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Pi=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Oi=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ki=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var br={};J(br,{base36:()=>Ui,base36upper:()=>Fi});var Ui=wt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Fi=wt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var wr={};J(wr,{base58btc:()=>N,base58flickr:()=>Bi});var N=wt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bi=wt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ir={};J(Ir,{base64:()=>xr,base64pad:()=>Mi,base64url:()=>Vi,base64urlpad:()=>Gi});var xr=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mi=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Vi=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gi=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ar={};J(Ar,{base8:()=>$i});var $i=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Cr={};J(Cr,{identity:()=>zi});var zi=Mt({prefix:"\0",name:"identity",encode:r=>kn(r),decode:r=>On(r)});var Ta=new TextEncoder,Sa=new TextDecoder;var Sr={};J(Sr,{identity:()=>we});var Yi=Gn,Mn=128,Wi=127,Xi=~Wi,Ji=Math.pow(2,31);function Gn(r,t,e){t=t||[],e=e||0;for(var o=e;r>=Ji;)t[e++]=r&255|Mn,r/=128;for(;r&Xi;)t[e++]=r&255|Mn,r>>>=7;return t[e]=r|0,Gn.bytes=e-o+1,t}var Qi=Tr,Zi=128,Vn=127;function Tr(r,o){var e=0,o=o||0,n=0,i=o,s,c=r.length;do{if(i>=c)throw Tr.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=n<28?(s&Vn)<<n:(s&Vn)*Math.pow(2,n),n+=7}while(s>=Zi);return Tr.bytes=i-o,e}var qi=Math.pow(2,7),ji=Math.pow(2,14),ts=Math.pow(2,21),es=Math.pow(2,28),rs=Math.pow(2,35),ns=Math.pow(2,42),os=Math.pow(2,49),is=Math.pow(2,56),ss=Math.pow(2,63),cs=function(r){return r<qi?1:r<ji?2:r<ts?3:r<es?4:r<rs?5:r<ns?6:r<os?7:r<is?8:r<ss?9:10},as={encode:Yi,decode:Qi,encodingLength:cs},ls=as,oe=ls;var ie=(r,t=0)=>[oe.decode(r,t),oe.decode.bytes],Vt=(r,t,e=0)=>(oe.encode(r,t,e),t),Gt=r=>oe.encodingLength(r);var xt=(r,t)=>{let e=t.byteLength,o=Gt(r),n=o+Gt(e),i=new Uint8Array(n+e);return Vt(r,i,0),Vt(e,i,o),i.set(t,n),new $t(r,e,t,i)},Dt=r=>{let t=et(r),[e,o]=ie(t),[n,i]=ie(t.subarray(o)),s=t.subarray(o+i);if(s.byteLength!==n)throw new Error("Incorrect length");return new $t(e,n,s,t)},$n=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Pn(r.bytes,e.bytes)}},$t=class{constructor(t,e,o,n){this.code=t,this.size=e,this.digest=o,this.bytes=n}};var zn=0,us="identity",Hn=et,ds=r=>xt(zn,Hn(r)),we={code:zn,name:us,encode:Hn,digest:ds};var Lr={};J(Lr,{sha256:()=>xe,sha512:()=>fs});var Dr=Et(ft("crypto"),1);var Rr=({name:r,code:t,encode:e})=>new vr(r,t,e),vr=class{constructor(t,e,o){this.name=t,this.code=e,this.encode=o}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?xt(this.code,e):e.then(o=>xt(this.code,o))}else throw Error("Unknown type, must be binary type")}};var xe=Rr({name:"sha2-256",code:18,encode:r=>et(Dr.default.createHash("sha256").update(r).digest())}),fs=Rr({name:"sha2-512",code:19,encode:r=>et(Dr.default.createHash("sha512").update(r).digest())});var Yn=(r,t)=>{let{bytes:e,version:o}=r;switch(o){case 0:return ps(e,_r(r),t||N.encoder);default:return ms(e,_r(r),t||st.encoder)}};var Wn=new WeakMap,_r=r=>{let t=Wn.get(r);if(t==null){let e=new Map;return Wn.set(r,e),e}return t},H=class r{constructor(t,e,o,n){this.code=e,this.version=t,this.multihash=o,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==gs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,o=xt(t,e);return r.createV1(this.code,o)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let o=e;return o&&t.code===o.code&&t.version===o.version&&$n(t.multihash,o.multihash)}toString(t){return Yn(this,t)}toJSON(){return{"/":Yn(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:o,code:n,multihash:i,bytes:s}=e;return new r(o,n,i,s||Xn(o,n,i.bytes))}else if(e[ys]===!0){let{version:o,multihash:n,code:i}=e,s=Dt(n);return r.create(o,i,s)}else return null}static create(t,e,o){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(o.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==se)throw new Error(`Version 0 CID must use dag-pb (code: ${se}) block encoding`);return new r(t,e,o,o.bytes)}case 1:{let n=Xn(t,e,o.bytes);return new r(t,e,o,n)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,se,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,o]=r.decodeFirst(t);if(o.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),o=e.size-e.multihashSize,n=et(t.subarray(o,o+e.multihashSize));if(n.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=n.subarray(e.multihashSize-e.digestSize),s=new $t(e.multihashCode,e.digestSize,i,n);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,o=()=>{let[d,h]=ie(t.subarray(e));return e+=h,d},n=o(),i=se;if(n===18?(n=0,e=0):i=o(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let s=e,c=o(),a=o(),p=e+a,u=p-s;return{version:n,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:p}}static parse(t,e){let[o,n]=hs(t,e),i=r.decode(n);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return _r(i).set(o,t),i}},hs=(r,t)=>{switch(r[0]){case"Q":{let e=t||N;return[N.prefix,e.decode(`${N.prefix}${r}`)]}case N.prefix:{let e=t||N;return[N.prefix,e.decode(r)]}case st.prefix:{let e=t||st;return[st.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},ps=(r,t,e)=>{let{prefix:o}=e;if(o!==N.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let n=t.get(o);if(n==null){let i=e.encode(r).slice(1);return t.set(o,i),i}else return n},ms=(r,t,e)=>{let{prefix:o}=e,n=t.get(o);if(n==null){let i=e.encode(r);return t.set(o,i),i}else return n},se=112,gs=18,Xn=(r,t,e)=>{let o=Gt(r),n=o+Gt(t),i=new Uint8Array(n+e.byteLength);return Vt(r,i,0),Vt(t,i,o),i.set(e,n),i},ys=Symbol.for("@ipld/js-cid/CID");var It={...Cr,...gr,...Ar,...pr,...mr,...Er,...br,...wr,...Ir,...yr},za={...Lr,...Sr};function Qn(r,t,e,o){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:o}}}var Jn=Qn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Nr=Qn("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=F(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Es={utf8:Jn,"utf-8":Jn,hex:It.base16,latin1:Nr,ascii:Nr,binary:Nr,...It},Ie=Es;function ce(r,t="utf8"){let e=Ie[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Rt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Pr(r){let t=r??8192,e=t>>>1,o,n=t;return function(s){if(s<1||s>e)return F(s);n+s>t&&(o=F(t),n=0);let c=o.subarray(n,n+=s);return n&7&&(n=(n|7)+1),c}}var _t=class{fn;len;next;val;constructor(t,e,o){this.fn=t,this.len=e,this.next=void 0,this.val=o}};function Or(){}var Ur=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},bs=Pr();function ws(r){return globalThis.Buffer!=null?F(r):bs(r)}var ue=class{len;head;tail;states;constructor(){this.len=0,this.head=new _t(Or,0,0),this.tail=this.head,this.states=null}_push(t,e,o){return this.tail=this.tail.next=new _t(t,e,o),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Fr((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(ae,10,z.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=z.fromBigInt(t);return this._push(ae,e.length(),e)}uint64Number(t){let e=z.fromNumber(t);return this._push(ae,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=z.fromBigInt(t).zzEncode();return this._push(ae,e.length(),e)}sint64Number(t){let e=z.fromNumber(t).zzEncode();return this._push(ae,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(kr,1,t?1:0)}fixed32(t){return this._push(le,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=z.fromBigInt(t);return this._push(le,4,e.lo)._push(le,4,e.hi)}fixed64Number(t){let e=z.fromNumber(t);return this._push(le,4,e.lo)._push(le,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Cn,4,t)}double(t){return this._push(Sn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(kr,1,0):this.uint32(e)._push(Is,e,t)}string(t){let e=Dn(t);return e!==0?this.uint32(e)._push(cr,e,t):this._push(kr,1,0)}fork(){return this.states=new Ur(this),this.head=this.tail=new _t(Or,0,0),this.len=0,this}reset(){return this.states!=null?(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 _t(Or,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,o=this.len;return this.reset().uint32(o),o!==0&&(this.tail.next=t.next,this.tail=e,this.len+=o),this}finish(){let t=this.head.next,e=ws(this.len),o=0;for(;t!=null;)t.fn(t.val,e,o),o+=t.len,t=t.next;return e}};function kr(r,t,e){t[e]=r&255}function xs(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Fr=class extends _t{next;constructor(t,e){super(xs,t,e),this.next=void 0}};function ae(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function le(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Is(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(ue.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(As,t,r),this},ue.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Cs,t,r),this});function As(r,t,e){t.set(r,e)}function Cs(r,t,e){r.length<40?cr(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(ce(r),e)}function Br(){return new ue}function D(r,t){let e=Br();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var zt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(zt||(zt={}));function Ae(r,t,e,o){return{name:r,type:t,encode:e,decode:o}}function pt(r){function t(n){if(r[n.toString()]==null)throw new Error("Invalid enum value");return r[n]}let e=function(i,s){let c=t(i);s.int32(c)},o=function(i){let s=i.int32();return t(s)};return Ae("enum",zt.VARINT,e,o)}function L(r,t){return Ae("message",zt.LENGTH_DELIMITED,r,t)}var S;(function(r){let t;(function(n){n.IDENTIFY="IDENTIFY",n.CONNECT="CONNECT",n.STREAM_OPEN="STREAM_OPEN",n.STREAM_HANDLER="STREAM_HANDLER",n.DHT="DHT",n.LIST_PEERS="LIST_PEERS",n.CONNMANAGER="CONNMANAGER",n.DISCONNECT="DISCONNECT",n.PUBSUB="PUBSUB",n.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.IDENTIFY=0]="IDENTIFY",n[n.CONNECT=1]="CONNECT",n[n.STREAM_OPEN=2]="STREAM_OPEN",n[n.STREAM_HANDLER=3]="STREAM_HANDLER",n[n.DHT=4]="DHT",n[n.LIST_PEERS=5]="LIST_PEERS",n[n.CONNMANAGER=6]="CONNMANAGER",n[n.DISCONNECT=7]="DISCONNECT",n[n.PUBSUB=8]="PUBSUB",n[n.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.connect!=null&&(i.uint32(18),Te.codec().encode(n.connect,i)),n.streamOpen!=null&&(i.uint32(26),Se.codec().encode(n.streamOpen,i)),n.streamHandler!=null&&(i.uint32(34),ve.codec().encode(n.streamHandler,i)),n.dht!=null&&(i.uint32(42),rt.codec().encode(n.dht,i)),n.connManager!=null&&(i.uint32(50),De.codec().encode(n.connManager,i)),n.disconnect!=null&&(i.uint32(58),Le.codec().encode(n.disconnect,i)),n.pubsub!=null&&(i.uint32(66),mt.codec().encode(n.pubsub,i)),n.peerStore!=null&&(i.uint32(74),Pe.codec().encode(n.peerStore,i)),s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.connect=Te.codec().decode(n,n.uint32());break;case 3:s.streamOpen=Se.codec().decode(n,n.uint32());break;case 4:s.streamHandler=ve.codec().decode(n,n.uint32());break;case 5:s.dht=rt.codec().decode(n,n.uint32());break;case 6:s.connManager=De.codec().decode(n,n.uint32());break;case 7:s.disconnect=Le.codec().decode(n,n.uint32());break;case 8:s.pubsub=mt.codec().decode(n,n.uint32());break;case 9:s.peerStore=Pe.codec().decode(n,n.uint32());break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(S||(S={}));var w;(function(r){let t;(function(n){n.OK="OK",n.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.OK=0]="OK",n[n.ERROR=1]="ERROR"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.error!=null&&(i.uint32(18),Re.codec().encode(n.error,i)),n.streamInfo!=null&&(i.uint32(26),Ht.codec().encode(n.streamInfo,i)),n.identify!=null&&(i.uint32(34),Ce.codec().encode(n.identify,i)),n.dht!=null&&(i.uint32(42),ct.codec().encode(n.dht,i)),n.peers!=null)for(let c of n.peers)i.uint32(50),At.codec().encode(c,i);n.pubsub!=null&&(i.uint32(58),Ne.codec().encode(n.pubsub,i)),n.peerStore!=null&&(i.uint32(66),Oe.codec().encode(n.peerStore,i)),s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={peers:[]},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.error=Re.codec().decode(n,n.uint32());break;case 3:s.streamInfo=Ht.codec().decode(n,n.uint32());break;case 4:s.identify=Ce.codec().decode(n,n.uint32());break;case 5:s.dht=ct.codec().decode(n,n.uint32());break;case 6:s.peers.push(At.codec().decode(n,n.uint32()));break;case 7:s.pubsub=Ne.codec().decode(n,n.uint32());break;case 8:s.peerStore=Oe.codec().decode(n,n.uint32());break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(w||(w={}));var Ce;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.id!=null&&e.id.byteLength>0&&(o.uint32(10),o.bytes(e.id)),e.addrs!=null)for(let i of e.addrs)o.uint32(18),o.bytes(i);n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={id:new Uint8Array(0),addrs:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.id=e.bytes();break;case 2:n.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Ce||(Ce={}));var Te;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.peer!=null&&e.peer.byteLength>0&&(o.uint32(10),o.bytes(e.peer)),e.addrs!=null)for(let i of e.addrs)o.uint32(18),o.bytes(i);e.timeout!=null&&(o.uint32(24),o.int64(e.timeout)),n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={peer:new Uint8Array(0),addrs:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;case 2:n.addrs.push(e.bytes());break;case 3:n.timeout=e.int64();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Te||(Te={}));var Se;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.peer!=null&&e.peer.byteLength>0&&(o.uint32(10),o.bytes(e.peer)),e.proto!=null)for(let i of e.proto)o.uint32(18),o.string(i);e.timeout!=null&&(o.uint32(24),o.int64(e.timeout)),n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={peer:new Uint8Array(0),proto:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;case 2:n.proto.push(e.string());break;case 3:n.timeout=e.int64();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Se||(Se={}));var ve;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.addr!=null&&e.addr.byteLength>0&&(o.uint32(10),o.bytes(e.addr)),e.proto!=null)for(let i of e.proto)o.uint32(18),o.string(i);n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={addr:new Uint8Array(0),proto:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.addr=e.bytes();break;case 2:n.proto.push(e.string());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(ve||(ve={}));var Re;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{n.lengthDelimited!==!1&&o.fork(),e.msg!=null&&e.msg!==""&&(o.uint32(10),o.string(e.msg)),n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={msg:""},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.msg=e.string();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Re||(Re={}));var Ht;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{n.lengthDelimited!==!1&&o.fork(),e.peer!=null&&e.peer.byteLength>0&&(o.uint32(10),o.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(o.uint32(18),o.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(o.uint32(26),o.string(e.proto)),n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;case 2:n.addr=e.bytes();break;case 3:n.proto=e.string();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Ht||(Ht={}));var rt;(function(r){let t;(function(n){n.FIND_PEER="FIND_PEER",n.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",n.FIND_PROVIDERS="FIND_PROVIDERS",n.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",n.GET_PUBLIC_KEY="GET_PUBLIC_KEY",n.GET_VALUE="GET_VALUE",n.SEARCH_VALUE="SEARCH_VALUE",n.PUT_VALUE="PUT_VALUE",n.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.FIND_PEER=0]="FIND_PEER",n[n.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",n[n.FIND_PROVIDERS=2]="FIND_PROVIDERS",n[n.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",n[n.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",n[n.GET_VALUE=5]="GET_VALUE",n[n.SEARCH_VALUE=6]="SEARCH_VALUE",n[n.PUT_VALUE=7]="PUT_VALUE",n[n.PROVIDE=8]="PROVIDE"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.peer!=null&&(i.uint32(18),i.bytes(n.peer)),n.cid!=null&&(i.uint32(26),i.bytes(n.cid)),n.key!=null&&(i.uint32(34),i.bytes(n.key)),n.value!=null&&(i.uint32(42),i.bytes(n.value)),n.count!=null&&(i.uint32(48),i.int32(n.count)),n.timeout!=null&&(i.uint32(56),i.int64(n.timeout)),s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.cid=n.bytes();break;case 4:s.key=n.bytes();break;case 5:s.value=n.bytes();break;case 6:s.count=n.int32();break;case 7:s.timeout=n.int64();break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(rt||(rt={}));var ct;(function(r){let t;(function(n){n.BEGIN="BEGIN",n.VALUE="VALUE",n.END="END"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.BEGIN=0]="BEGIN",n[n.VALUE=1]="VALUE",n[n.END=2]="END"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.peer!=null&&(i.uint32(18),At.codec().encode(n.peer,i)),n.value!=null&&(i.uint32(26),i.bytes(n.value)),s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=At.codec().decode(n,n.uint32());break;case 3:s.value=n.bytes();break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(ct||(ct={}));var At;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.id!=null&&e.id.byteLength>0&&(o.uint32(10),o.bytes(e.id)),e.addrs!=null)for(let i of e.addrs)o.uint32(18),o.bytes(i);n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={id:new Uint8Array(0),addrs:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.id=e.bytes();break;case 2:n.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(At||(At={}));var De;(function(r){let t;(function(n){n.TAG_PEER="TAG_PEER",n.UNTAG_PEER="UNTAG_PEER",n.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.TAG_PEER=0]="TAG_PEER",n[n.UNTAG_PEER=1]="UNTAG_PEER",n[n.TRIM=2]="TRIM"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.peer!=null&&(i.uint32(18),i.bytes(n.peer)),n.tag!=null&&(i.uint32(26),i.string(n.tag)),n.weight!=null&&(i.uint32(32),i.int64(n.weight)),s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.tag=n.string();break;case 4:s.weight=n.int64();break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(De||(De={}));var Le;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{n.lengthDelimited!==!1&&o.fork(),e.peer!=null&&e.peer.byteLength>0&&(o.uint32(10),o.bytes(e.peer)),n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={peer:new Uint8Array(0)},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Le||(Le={}));var mt;(function(r){let t;(function(n){n.GET_TOPICS="GET_TOPICS",n.LIST_PEERS="LIST_PEERS",n.PUBLISH="PUBLISH",n.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.GET_TOPICS=0]="GET_TOPICS",n[n.LIST_PEERS=1]="LIST_PEERS",n[n.PUBLISH=2]="PUBLISH",n[n.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.topic!=null&&(i.uint32(18),i.string(n.topic)),n.data!=null&&(i.uint32(26),i.bytes(n.data)),s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.topic=n.string();break;case 3:s.data=n.bytes();break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(mt||(mt={}));var _e;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.from!=null&&(o.uint32(10),o.bytes(e.from)),e.data!=null&&(o.uint32(18),o.bytes(e.data)),e.seqno!=null&&(o.uint32(26),o.bytes(e.seqno)),e.topicIDs!=null)for(let i of e.topicIDs)o.uint32(34),o.string(i);e.signature!=null&&(o.uint32(42),o.bytes(e.signature)),e.key!=null&&(o.uint32(50),o.bytes(e.key)),n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={topicIDs:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.from=e.bytes();break;case 2:n.data=e.bytes();break;case 3:n.seqno=e.bytes();break;case 4:n.topicIDs.push(e.string());break;case 5:n.signature=e.bytes();break;case 6:n.key=e.bytes();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(_e||(_e={}));var Ne;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.topics!=null)for(let i of e.topics)o.uint32(10),o.string(i);if(e.peerIDs!=null)for(let i of e.peerIDs)o.uint32(18),o.bytes(i);n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={topics:[],peerIDs:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.topics.push(e.string());break;case 2:n.peerIDs.push(e.bytes());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Ne||(Ne={}));var Pe;(function(r){let t;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.GET_PROTOCOLS="GET_PROTOCOLS",n.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.GET_PROTOCOLS=1]="GET_PROTOCOLS",n[n.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let o;r.codec=()=>(o==null&&(o=L((n,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),n.type!=null&&(i.uint32(8),r.Type.codec().encode(n.type,i)),n.id!=null&&(i.uint32(18),i.bytes(n.id)),n.protos!=null)for(let c of n.protos)i.uint32(26),i.string(c);s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={protos:[]},c=i==null?n.len:n.pos+i;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.id=n.bytes();break;case 3:s.protos.push(n.string());break;default:n.skipType(a&7);break}}return s})),o),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(Pe||(Pe={}));var Oe;(function(r){let t;r.codec=()=>(t==null&&(t=L((e,o,n={})=>{if(n.lengthDelimited!==!1&&o.fork(),e.peer!=null&&(o.uint32(10),At.codec().encode(e.peer,o)),e.protos!=null)for(let i of e.protos)o.uint32(18),o.string(i);n.lengthDelimited!==!1&&o.ldelim()},(e,o)=>{let n={protos:[]},i=o==null?e.len:e.pos+o;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:n.peer=At.codec().decode(e,e.uint32());break;case 2:n.protos.push(e.string());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Oe||(Oe={}));var Z=Et(co(),1);Z.default.formatters.b=r=>r==null?"undefined":N.baseEncode(r);Z.default.formatters.t=r=>r==null?"undefined":st.baseEncode(r);Z.default.formatters.m=r=>r==null?"undefined":xr.baseEncode(r);Z.default.formatters.p=r=>r==null?"undefined":r.toString();Z.default.formatters.c=r=>r==null?"undefined":r.toString();Z.default.formatters.k=r=>r==null?"undefined":r.toString();Z.default.formatters.a=r=>r==null?"undefined":r.toString();function Xs(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function ao(){return{forComponent(r){return q(r)}}}function q(r){let t=Xs(`${r}:trace`);return Z.default.enabled(`${r}:trace`)&&Z.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,Z.default)(`${r}:trace`)),Object.assign((0,Z.default)(r),{error:(0,Z.default)(`${r}:error`),trace:t})}function nt(r,t){t==null&&(t=r.reduce((n,i)=>n+i.length,0));let e=F(t),o=0;for(let n of r)e.set(n,o),o+=n.length;return Rt(e)}function Pt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var uo=Symbol.for("@achingbrain/uint8arraylist");function lo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let o of r){let n=e+o.byteLength;if(t<n)return{buf:o,index:t-e};e=n}throw new RangeError("index is out of bounds")}function Me(r){return!!r?.[uo]}var lt=class r{constructor(...t){Object.defineProperty(this,uo,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let o of t)if(o instanceof Uint8Array)e+=o.byteLength,this.bufs.push(o);else if(Me(o))e+=o.byteLength,this.bufs.push(...o.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let o of t.reverse())if(o instanceof Uint8Array)e+=o.byteLength,this.bufs.unshift(o);else if(Me(o))e+=o.byteLength,this.bufs.unshift(...o.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=lo(this.bufs,t);return e.buf[e.index]}set(t,e){let o=lo(this.bufs,t);o.buf[o.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let o=0;o<t.length;o++)this.set(e+o,t[o]);else if(Me(t))for(let o=0;o<t.length;o++)this.set(e+o,t.get(o));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:o,length:n}=this._subList(t,e);return nt(o,n)}subarray(t,e){let{bufs:o,length:n}=this._subList(t,e);return o.length===1?o[0]:nt(o,n)}sublist(t,e){let{bufs:o,length:n}=this._subList(t,e),i=new r;return i.length=n,i.bufs=o,i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let o=[],n=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=n,a=c+s.byteLength;if(n=a,t>=a)continue;let p=t>=c&&t<a,u=e>c&&e<=a;if(p&&u){if(t===c&&e===a){o.push(s);break}let d=t-c;o.push(s.subarray(d,d+(e-t)));break}if(p){if(t===0){o.push(s);continue}o.push(s.subarray(t-c));continue}if(u){if(e===a){o.push(s);break}o.push(s.subarray(0,e-c));break}o.push(s)}return{bufs:o,length:e-t}}indexOf(t,e=0){if(!Me(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let o=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let n=o.byteLength;if(n===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let d=0;d<i;d++)s[d]=-1;for(let d=0;d<n;d++)s[o[d]]=d;let c=s,a=this.byteLength-o.byteLength,p=o.byteLength-1,u;for(let d=e;d<=a;d+=u){u=0;for(let h=p;h>=0;h--){let b=this.get(d+h);if(o[h]!==b){u=Math.max(1,h-c[b]);break}}if(u===0)return d}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let o=F(1);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt8(0,e),this.write(o,t)}getInt16(t,e){let o=this.subarray(t,t+2);return new DataView(o.buffer,o.byteOffset,o.byteLength).getInt16(0,e)}setInt16(t,e,o){let n=ht(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt16(0,e,o),this.write(n,t)}getInt32(t,e){let o=this.subarray(t,t+4);return new DataView(o.buffer,o.byteOffset,o.byteLength).getInt32(0,e)}setInt32(t,e,o){let n=ht(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt32(0,e,o),this.write(n,t)}getBigInt64(t,e){let o=this.subarray(t,t+8);return new DataView(o.buffer,o.byteOffset,o.byteLength).getBigInt64(0,e)}setBigInt64(t,e,o){let n=ht(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigInt64(0,e,o),this.write(n,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let o=F(1);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint8(0,e),this.write(o,t)}getUint16(t,e){let o=this.subarray(t,t+2);return new DataView(o.buffer,o.byteOffset,o.byteLength).getUint16(0,e)}setUint16(t,e,o){let n=ht(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint16(0,e,o),this.write(n,t)}getUint32(t,e){let o=this.subarray(t,t+4);return new DataView(o.buffer,o.byteOffset,o.byteLength).getUint32(0,e)}setUint32(t,e,o){let n=ht(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(0,e,o),this.write(n,t)}getBigUint64(t,e){let o=this.subarray(t,t+8);return new DataView(o.buffer,o.byteOffset,o.byteLength).getBigUint64(0,e)}setBigUint64(t,e,o){let n=ht(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigUint64(0,e,o),this.write(n,t)}getFloat32(t,e){let o=this.subarray(t,t+4);return new DataView(o.buffer,o.byteOffset,o.byteLength).getFloat32(0,e)}setFloat32(t,e,o){let n=ht(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat32(0,e,o),this.write(n,t)}getFloat64(t,e){let o=this.subarray(t,t+8);return new DataView(o.buffer,o.byteOffset,o.byteLength).getFloat64(0,e)}setFloat64(t,e,o){let n=ht(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat64(0,e,o),this.write(n,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Pt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let o=new r;return o.bufs=t,e==null&&(e=t.reduce((n,i)=>n+i.byteLength,0)),o.length=e,o}};function fo(r){let t=async function*(){let e=yield,o=new lt;for await(let n of r){if(e==null){o.append(n),e=yield o,o=new lt;continue}for(o.append(n);o.length>=e;){let i=o.sublist(0,e);if(o.consume(e),e=yield i,e==null){o.length>0&&(e=yield o,o=new lt);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:o})}();return t.next(),t}function Jt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Ve=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Qt=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Ve(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Ve(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var $r=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ho(r={}){return Js(e=>{let o=e.shift();if(o==null)return{done:!0};if(o.error!=null)throw o.error;return{done:o.done===!0,value:o.value}},r)}function Js(r,t){t=t??{};let e=t.onEnd,o=new Qt,n,i,s,c=Jt(),a=async()=>{try{return o.isEmpty()?s?{done:!0}:await new Promise((y,E)=>{i=C=>{i=null,o.push(C);try{y(r(o))}catch(_){E(_)}return n}}):r(o)}finally{o.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=Jt()})}},p=y=>i!=null?i(y):(o.push(y),n),u=y=>(o=new Qt,i!=null?i({error:y}):(o.push({error:y}),n)),d=y=>{if(s)return n;if(t?.objectMode!==!0&&y?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return p({done:!1,value:y})},h=y=>s?n:(s=!0,y!=null?u(y):p({done:!0})),b=()=>(o=new Qt,h(),{done:!0}),g=y=>(h(y),{done:!0});if(n={[Symbol.asyncIterator](){return this},next:a,return:b,throw:g,push:d,end:h,get readableLength(){return o.size},onEmpty:async y=>{let E=y?.signal;if(E?.throwIfAborted(),o.isEmpty())return;let C,_;E!=null&&(C=new Promise((P,W)=>{_=()=>{W(new $r)},E.addEventListener("abort",_)}));try{await Promise.race([c.promise,C])}finally{_!=null&&E!=null&&E?.removeEventListener("abort",_)}}},e==null)return n;let x=n;return n={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(y){return x.throw(y),e!=null&&(e(y),e=void 0),{done:!0}},return(){return x.return(),e!=null&&(e(),e=void 0),{done:!0}},push:d,end(y){return x.end(y),e!=null&&(e(y),e=void 0),n},get readableLength(){return x.readableLength}},n}function po(r){let t=ho(),e=fo(r.source),o=Jt(),n,i=r.sink(async function*(){yield*t,yield*await o.promise}());return i.catch(c=>{n=c}),{reader:e,writer:t,stream:{sink:async c=>{if(n!=null){await Promise.reject(n);return}o.resolve(c),await i},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let c=await e.next();if(c.value!=null)return c.value}}}var Qs=Math.pow(2,7),Zs=Math.pow(2,14),qs=Math.pow(2,21),zr=Math.pow(2,28),Hr=Math.pow(2,35),Kr=Math.pow(2,42),Yr=Math.pow(2,49),I=128,M=127;function K(r){if(r<Qs)return 1;if(r<Zs)return 2;if(r<qs)return 3;if(r<zr)return 4;if(r<Hr)return 5;if(r<Kr)return 6;if(r<Yr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function js(r,t,e=0){switch(K(r)){case 8:t[e++]=r&255|I,r/=128;case 7:t[e++]=r&255|I,r/=128;case 6:t[e++]=r&255|I,r/=128;case 5:t[e++]=r&255|I,r/=128;case 4:t[e++]=r&255|I,r>>>=7;case 3:t[e++]=r&255|I,r>>>=7;case 2:t[e++]=r&255|I,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function tc(r,t,e=0){switch(K(r)){case 8:t.set(e++,r&255|I),r/=128;case 7:t.set(e++,r&255|I),r/=128;case 6:t.set(e++,r&255|I),r/=128;case 5:t.set(e++,r&255|I),r/=128;case 4:t.set(e++,r&255|I),r>>>=7;case 3:t.set(e++,r&255|I),r>>>=7;case 2:t.set(e++,r&255|I),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function ec(r,t){let e=r[t],o=0;if(o+=e&M,e<I||(e=r[t+1],o+=(e&M)<<7,e<I)||(e=r[t+2],o+=(e&M)<<14,e<I)||(e=r[t+3],o+=(e&M)<<21,e<I)||(e=r[t+4],o+=(e&M)*zr,e<I)||(e=r[t+5],o+=(e&M)*Hr,e<I)||(e=r[t+6],o+=(e&M)*Kr,e<I)||(e=r[t+7],o+=(e&M)*Yr,e<I))return o;throw new RangeError("Could not decode varint")}function rc(r,t){let e=r.get(t),o=0;if(o+=e&M,e<I||(e=r.get(t+1),o+=(e&M)<<7,e<I)||(e=r.get(t+2),o+=(e&M)<<14,e<I)||(e=r.get(t+3),o+=(e&M)<<21,e<I)||(e=r.get(t+4),o+=(e&M)*zr,e<I)||(e=r.get(t+5),o+=(e&M)*Hr,e<I)||(e=r.get(t+6),o+=(e&M)*Kr,e<I)||(e=r.get(t+7),o+=(e&M)*Yr,e<I))return o;throw new RangeError("Could not decode varint")}function Ct(r,t,e=0){return t==null&&(t=F(K(r))),t instanceof Uint8Array?js(r,t,e):tc(r,t,e)}function gt(r,t=0){return r instanceof Uint8Array?ec(r,t):rc(r,t)}function $e(r){return r[Symbol.asyncIterator]!=null}var ze=r=>{let t=K(r),e=F(t);return Ct(r,e),ze.bytes=t,e};ze.bytes=0;function He(r,t){t=t??{};let e=t.lengthEncoder??ze;function*o(n){let i=e(n.byteLength);i instanceof Uint8Array?yield i:yield*i,n instanceof Uint8Array?yield n:yield*n}return $e(r)?async function*(){for await(let n of r)yield*o(n)}():function*(){for(let n of r)yield*o(n)}()}He.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??ze;return new lt(e(r.byteLength),r)};var Zt=Et(yo(),1);var oc=8,ic=1024*1024*4,Ot;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ot||(Ot={}));var Wr=r=>{let t=gt(r);return Wr.bytes=K(t),t};Wr.bytes=0;function de(r,t){let e=new lt,o=Ot.LENGTH,n=-1,i=t?.lengthDecoder??Wr,s=t?.maxLengthLength??oc,c=t?.maxDataLength??ic;function*a(){for(;e.byteLength>0;){if(o===Ot.LENGTH)try{if(n=i(e),n<0)throw(0,Zt.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(n>c)throw(0,Zt.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let p=i.bytes;e.consume(p),t?.onLength!=null&&t.onLength(n),o=Ot.DATA}catch(p){if(p instanceof RangeError){if(e.byteLength>s)throw(0,Zt.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw p}if(o===Ot.DATA){if(e.byteLength<n)break;let p=e.sublist(0,n);e.consume(n),t?.onData!=null&&t.onData(p),yield p,o=Ot.LENGTH}}}return $e(r)?async function*(){for await(let p of r)e.append(p),yield*a();if(e.byteLength>0)throw(0,Zt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let p of r)e.append(p),yield*a();if(e.byteLength>0)throw(0,Zt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}de.fromReader=(r,t)=>{let e=1,o=async function*(){for(;;)try{let{done:i,value:s}=await r.next(e);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return de(o,{...t??{},onLength:i=>{e=i}})};var Xr=q("libp2p:daemon-protocol:stream-handler"),fe=class{stream;shake;decoder;constructor(t){let{stream:e,maxLength:o}=t;this.stream=e,this.shake=po(this.stream),this.decoder=de.fromReader(this.shake.reader,{maxDataLength:o??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Xr("read received no value, closing stream"),await this.close()}write(t){Xr("write message"),this.shake.write(He.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Xr("closing the stream"),await this.rest().sink([])}};var Jr={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var qt=class r extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},l=class extends Error{code;props;constructor(t,e,o){super(t),this.code=e,this.name=o?.name??"CodeError",this.props=o??{}}};var Qr=Symbol.for("@libp2p/peer-id");function jt(r){return r!=null&&!!r[Qr]}var cc=Symbol.for("nodejs.util.inspect.custom"),Eo=Object.values(It).map(r=>r.decoder).reduce((r,t)=>r.or(t),It.identity.decoder),bo=114,wo=36,xo=37,he=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Qr]=!0;toString(){return this.string==null&&(this.string=N.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return H.createV1(bo,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return Pt(this.multihash.bytes,t);if(typeof t=="string")return ac(t).equals(this);if(t?.multihash?.bytes!=null)return Pt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[cc](){return`PeerId(${this.toString()})`}},pe=class extends he{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},me=class extends he{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},ge=class extends he{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function ac(r,t){if(t=t??Eo,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Dt(N.decode(`z${r}`));return r.startsWith("12D")?new me({multihash:e}):r.startsWith("16U")?new ge({multihash:e}):new pe({multihash:e})}return ut(Eo.decode(r))}function ut(r){try{let t=Dt(r);if(t.code===we.code){if(t.digest.length===wo)return new me({multihash:t});if(t.digest.length===xo)return new ge({multihash:t})}if(t.code===xe.code)return new pe({multihash:t})}catch{return lc(H.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function lc(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==bo)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===xe.code)return new pe({multihash:r.multihash});if(t.code===we.code){if(t.digest.length===wo)return new me({multihash:r.multihash});if(t.digest.length===xo)return new ge({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var oi=Et(ft("net"),1);var Ao=Symbol.for("@libp2p/transport");var Io;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Io||(Io={}));function Y(r,t="utf8"){let e=Ie[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Ke=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,o=t();return o===void 0&&(this.index=e),o}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,o){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return o()})}readNumber(t,e,o,n){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",p=2**(8*n)-1;for(;;){let u=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let h=Number.parseInt(d,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=t,i+=u,i>p||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!o&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let o=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(o===void 0)return;t[e]=o}return t})}readIPv6Addr(){let t=e=>{for(let o=0;o<e.length/2;o++){let n=o*2;if(o<e.length-3){let s=this.readSeparator(":",o,()=>this.readIPv4Addr());if(s!==void 0)return e[n]=s[0],e[n+1]=s[1],e[n+2]=s[2],e[n+3]=s[3],[n+4,!0]}let i=this.readSeparator(":",o,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[n,!1];e[n]=i>>8,e[n+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[o,n]=t(e);if(o===16)return e;if(n||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(o+2),[c]=t(i.subarray(0,s));return e.set(i.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Lu=new Ke;var Bu=parseInt("0xFFFF",16),Mu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var ot=ft("node:net");function Ye(r){return!!(0,ot.isIP)(r)}var So=ot.isIPv4,mc=ot.isIPv6,Zr=function(r){let t=0;if(r=r.toString().trim(),So(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(o=>{e[t++]=parseInt(o,10)&255}),e}if(mc(r)){let e=r.split(":",8),o;for(o=0;o<e.length;o++){let i=So(e[o]),s;i&&(s=Zr(e[o]),e[o]=Y(s.slice(0,2),"base16")),s!=null&&++o<8&&e.splice(o,0,Y(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(o=0;o<e.length&&e[o]!=="";o++);let i=[o,1];for(o=9-e.length;o>0;o--)i.push("0");e.splice.apply(e,i)}let n=new Uint8Array(t+16);for(o=0;o<e.length;o++){let i=parseInt(e[o],16);n[t++]=i>>8&255,n[t++]=i&255}return n}throw new Error("invalid ip address")},vo=function(r,t=0,e){t=~~t,e=e??r.length-t;let o=new DataView(r.buffer);if(e===4){let n=[];for(let i=0;i<e;i++)n.push(r[t+i]);return n.join(".")}if(e===16){let n=[];for(let i=0;i<e;i+=2)n.push(o.getUint16(t+i).toString(16));return n.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var te={},qr={},yc=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];yc.forEach(r=>{let t=Ec(...r);qr[t.code]=t,te[t.name]=t});function Ec(r,t,e,o,n){return{code:r,size:t,name:e,resolvable:!!o,path:!!n}}function A(r){if(typeof r=="number"){if(qr[r]!=null)return qr[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(te[r]!=null)return te[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ad=A("ip4"),Cd=A("ip6"),Td=A("ipcidr");function tn(r,t){switch(A(r).code){case 4:case 41:return wc(t);case 42:return Lo(t);case 6:case 273:case 33:case 132:return No(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Lo(t);case 421:return Cc(t);case 444:return _o(t);case 445:return _o(t);case 466:return Ac(t);default:return Y(t,"base16")}}function en(r,t){switch(A(r).code){case 4:return Ro(t);case 41:return Ro(t);case 42:return Do(t);case 6:case 273:case 33:case 132:return rn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Do(t);case 421:return xc(t);case 444:return Tc(t);case 445:return Sc(t);case 466:return Ic(t);default:return ce(t,"base16")}}var jr=Object.values(It).map(r=>r.decoder),bc=function(){let r=jr[0].or(jr[1]);return jr.slice(2).forEach(t=>r=r.or(t)),r}();function Ro(r){if(!Ye(r))throw new Error("invalid ip address");return Zr(r)}function wc(r){let t=vo(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ye(t))throw new Error("invalid ip address");return t}function rn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function No(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Do(r){let t=ce(r),e=Uint8Array.from(Ct(t.length));return nt([e,t],e.length+t.length)}function Lo(r){let t=gt(r);if(r=r.slice(K(t)),r.length!==t)throw new Error("inconsistent lengths");return Y(r)}function xc(r){let t;r[0]==="Q"||r[0]==="1"?t=Dt(N.decode(`z${r}`)).bytes:t=H.parse(r).multihash.bytes;let e=Uint8Array.from(Ct(t.length));return nt([e,t],e.length+t.length)}function Ic(r){let t=bc.decode(r),e=Uint8Array.from(Ct(t.length));return nt([e,t],e.length+t.length)}function Ac(r){let t=gt(r),e=r.slice(K(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+Y(e,"base64url")}function Cc(r){let t=gt(r),e=r.slice(K(t));if(e.length!==t)throw new Error("inconsistent lengths");return Y(e,"base58btc")}function Tc(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=st.decode("b"+t[0]),o=parseInt(t[1],10);if(o<1||o>65536)throw new Error("Port number is not in range(1, 65536)");let n=rn(o);return nt([e,n],e.length+n.length)}function Sc(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=st.decode(`b${t[0]}`),o=parseInt(t[1],10);if(o<1||o>65536)throw new Error("Port number is not in range(1, 65536)");let n=rn(o);return nt([e,n],e.length+n.length)}function _o(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),o=Y(t,"base32"),n=No(e);return`${o}:${n}`}function Po(r){r=nn(r);let t=[],e=[],o=null,n=r.split("/").slice(1);if(n.length===1&&n[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<n.length;i++){let s=n[i],c=A(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=n.length)throw ko("invalid address: "+r);if(c.path===!0){o=nn(n.slice(i).join("/")),t.push([c.code,en(c.code,o)]),e.push([c.code,o]);break}let a=en(c.code,n[i]);t.push([c.code,a]),e.push([c.code,tn(c.code,a)])}return{string:Oo(e),bytes:sn(t),tuples:t,stringTuples:e,path:o}}function on(r){let t=[],e=[],o=null,n=0;for(;n<r.length;){let i=gt(r,n),s=K(i),c=A(i),a=vc(c,r.slice(n+s));if(a===0){t.push([i]),e.push([i]),n+=s;continue}let p=r.slice(n+s,n+s+a);if(n+=a+s,n>r.length)throw ko("Invalid address Uint8Array: "+Y(r,"base16"));t.push([i,p]);let u=tn(i,p);if(e.push([i,u]),c.path===!0){o=u;break}}return{bytes:Uint8Array.from(r),string:Oo(e),tuples:t,stringTuples:e,path:o}}function Oo(r){let t=[];return r.map(e=>{let o=A(e[0]);return t.push(o.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),nn(t.join("/"))}function sn(r){return nt(r.map(t=>{let e=A(t[0]),o=Uint8Array.from(Ct(e.code));return t.length>1&&t[1]!=null&&(o=nt([o,t[1]])),o}))}function vc(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=gt(t instanceof Uint8Array?t:Uint8Array.from(t));return e+K(e)}}function nn(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function ko(r){return new Error("Error parsing address: "+r)}var Rc=Symbol.for("nodejs.util.inspect.custom"),cn=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Dc=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],We=class r{bytes;#t;#e;#r;#n;[cn]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=on(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Po(t)}else if(Xe(t))e=on(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,o,n,i="",s=A("tcp"),c=A("udp"),a=A("ip4"),p=A("ip6"),u=A("dns6"),d=A("ip6zone");for(let[b,g]of this.stringTuples())b===d.code&&(i=`%${g??""}`),Dc.includes(b)&&(e=s.name,n=443,o=`${g??""}${i}`,t=b===u.code?6:4),(b===s.code||b===c.code)&&(e=A(b).name,n=parseInt(g??"")),(b===a.code||b===p.code)&&(e=A(b).name,o=`${g??""}${i}`,t=b===p.code?6:4);if(t==null||e==null||o==null||n==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:o,transport:e,port:n}}protos(){return this.#e.map(([t])=>Object.assign({},A(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>A(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),o=this.toString(),n=o.lastIndexOf(e);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(o.slice(0,n))}decapsulateCode(t){let e=this.tuples();for(let o=e.length-1;o>=0;o--)if(e[o][0]===t)return new r(sn(e.slice(0,o)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([o,n])=>{o===te.p2p.code&&t.push([o,n]),o===te["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let o=e[1];return o[0]==="Q"||o[0]==="1"?Y(N.decode(`z${o}`),"base58btc"):Y(H.parse(o).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let o=Uo.get(e.name);if(o==null)throw new l(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await o(this,t)).map(i=>new r(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Rc](){return`Multiaddr(${this.#t})`}};var Uo=new Map;function Xe(r){return!!r?.[cn]}function V(r){return new We(r)}var Lc=f("dns4"),_c=f("dns6"),Nc=f("dnsaddr"),Ut=v(f("dns"),Nc,Lc,_c),Ze=v(f("ip4"),f("ip6")),St=v(m(Ze,f("tcp")),m(Ut,f("tcp"))),qe=m(Ze,f("udp")),Pc=m(qe,f("utp")),Oc=m(qe,f("quic")),kc=m(qe,f("quic-v1")),an=v(m(St,f("ws")),m(Ut,f("ws"))),Je=v(m(an,f("p2p")),an),ln=v(m(St,f("wss")),m(Ut,f("wss")),m(St,f("tls"),f("ws")),m(Ut,f("tls"),f("ws"))),Qe=v(m(ln,f("p2p")),ln),un=v(m(St,f("http")),m(Ze,f("http")),m(Ut,f("http"))),dn=v(m(St,f("https")),m(Ze,f("https")),m(Ut,f("https"))),Fo=m(qe,f("webrtc-direct"),f("certhash")),Vo=v(m(Fo,f("p2p")),Fo),Bo=m(kc,f("webtransport"),f("certhash"),f("certhash")),Go=v(m(Bo,f("p2p")),Bo),$o=v(m(Je,f("p2p-webrtc-star"),f("p2p")),m(Qe,f("p2p-webrtc-star"),f("p2p")),m(Je,f("p2p-webrtc-star")),m(Qe,f("p2p-webrtc-star"))),Zd=v(m(Je,f("p2p-websocket-star"),f("p2p")),m(Qe,f("p2p-websocket-star"),f("p2p")),m(Je,f("p2p-websocket-star")),m(Qe,f("p2p-websocket-star"))),zo=v(m(un,f("p2p-webrtc-direct"),f("p2p")),m(dn,f("p2p-webrtc-direct"),f("p2p")),m(un,f("p2p-webrtc-direct")),m(dn,f("p2p-webrtc-direct"))),Ft=v(an,ln,un,dn,$o,zo,St,Pc,Oc,Ut,Vo,Go),qd=v(m(Ft,f("p2p-stardust"),f("p2p")),m(Ft,f("p2p-stardust"))),Tt=v(m(Ft,f("p2p")),$o,zo,Vo,Go,f("p2p")),Mo=v(m(Tt,f("p2p-circuit"),Tt),m(Tt,f("p2p-circuit")),m(f("p2p-circuit"),Tt),m(Ft,f("p2p-circuit")),m(f("p2p-circuit"),Ft),f("p2p-circuit")),Ho=()=>v(m(Mo,Ho),Mo),kt=Ho(),jd=v(m(kt,Tt,kt),m(Tt,kt),m(kt,Tt),kt,Tt);var tf=v(m(kt,f("webrtc"),f("p2p")),m(kt,f("webrtc")),m(Ft,f("webrtc"),f("p2p")),m(Ft,f("webrtc")),f("webrtc"));function Ko(r){function t(e){let o;try{o=V(e)}catch{return!1}let n=r(o.protoNames());return n===null?!1:n===!0||n===!1?n:n.length===0}return t}function m(...r){function t(e){if(e.length<r.length)return null;let o=e;return r.some(n=>(o=typeof n=="function"?n().partialMatch(e):n.partialMatch(e),Array.isArray(o)&&(e=o),o===null)),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ko(t),partialMatch:t}}function v(...r){function t(o){let n=null;return r.some(i=>{let s=typeof i=="function"?i().partialMatch(o):i.partialMatch(o);return s!=null?(n=s,!0):!1}),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ko(t),partialMatch:t}}function f(r){let t=r;function e(n){let i;try{i=V(n)}catch{return!1}let s=i.protoNames();return s.length===1&&s[0]===t}function o(n){return n.length===0?null:n[0]===t?n.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:o}}var ni=Et(ft("net"),1);var je=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,o){super.addEventListener(t,e,o);let n=this.#t.get(t);n==null&&(n=[],this.#t.set(t,n)),n.push({callback:e,once:(o!==!0&&o!==!1&&o?.once)??!1})}removeEventListener(t,e,o){super.removeEventListener(t.toString(),e??null,o);let n=this.#t.get(t);n!=null&&(n=n.filter(({callback:i})=>i!==e),this.#t.set(t,n))}dispatchEvent(t){let e=super.dispatchEvent(t),o=this.#t.get(t.type);return o==null||(o=o.filter(({once:n})=>!n),this.#t.set(t.type,o)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new ee(t,e))}},fn=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},ee=globalThis.CustomEvent??fn;var Fc=q("libp2p:ip-port-to-multiaddr"),hn={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Yo(r,t){if(typeof r!="string")throw new l(`invalid ip provided: ${r}`,hn.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new l(`invalid port provided: ${t}`,hn.ERR_INVALID_PORT_PARAMETER);if((0,ot.isIPv4)(r))return V(`/ip4/${r}/tcp/${t}`);if((0,ot.isIPv6)(r))return V(`/ip6/${r}/tcp/${t}`);let e=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Fc.error(e),new l(e,hn.ERR_INVALID_IP)}var ri=Et(ti(),1);var gn=Et(ft("os"),1),ei=Et(ft("path"),1);var $c={ip4:"IPv4",ip6:"IPv6"};function ne(r,t={}){let e=r.getPath();return e!=null?gn.default.platform()==="win32"?{path:ei.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function yn(r,t,e){let o=n=>V(`/${r}/${n}/tcp/${e}`);return(zc(t)?Kc($c[r]):[t]).map(o)}function zc(r){return["0.0.0.0","::"].includes(r)}var Hc=gn.default.networkInterfaces();function Kc(r){let t=[];for(let[,e]of Object.entries(Hc))if(e!=null)for(let o of e)o.family===r&&t.push(o.address);return t}var dt=q("libp2p:tcp:socket"),er=(r,t)=>{let e=t.metrics,o=t.metricPrefix??"",n=t.socketInactivityTimeout??3e5,i=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let s;if(t.remoteAddr!=null)s=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new l("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");s=Yo(r.remoteAddress,r.remotePort)}let c=ne(s),a=c.path??`${c.host??""}:${c.port??""}`,{sink:p,source:u}=ri.default.duplex(r);r.setTimeout(n,()=>{dt("%s socket read timeout",a),e?.increment({[`${o}timeout`]:!0});let h;r.readable&&(h=new l("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(h)}),r.once("close",()=>{dt("%s socket close",a),e?.increment({[`${o}close`]:!0}),d.timeline.close==null&&(d.timeline.close=Date.now())}),r.once("end",()=>{dt("%s socket end",a),e?.increment({[`${o}end`]:!0})});let d={async sink(h){try{await p(h)}catch(b){b.type!=="aborted"&&dt(b)}r.end()},source:u,remoteAddr:s,timeline:{open:Date.now()},async close(h={}){if(r.destroyed){dt("%s socket was already destroyed when trying to close",a);return}if(h.signal==null){let b=AbortSignal.timeout(i);h={...h,signal:b}}try{dt("%s closing socket",a),await new Promise((b,g)=>{r.once("close",()=>{dt("%s socket closed",a),b()}),r.once("error",x=>{dt("%s socket error",a,x),d.timeline.close==null&&(d.timeline.close=Date.now()),g(x)}),r.setTimeout(i),r.end(),r.writableLength>0?r.once("drain",()=>{dt("%s socket drained",a),r.destroy()}):r.destroy()})}catch(b){this.abort(b)}},abort:h=>{dt("%s socket abort due to error",a,h),r.destroy(h)}};return d};var G=q("libp2p:tcp:listener");async function En(r){try{await r.close()}catch(t){G.error("an error occurred closing the connection",t)}}var O;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(O||(O={}));var rr=class extends je{context;server;connections=new Set;status={code:O.INACTIVE};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=ni.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw new l("closeAbove must be >= listenBelow","ERROR_CONNECTION_LIMITS");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:O.ACTIVE})}this.dispatchEvent(new ee("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new ee("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==O.PAUSED&&this.dispatchEvent(new ee("close"))})}onSocket(t){if(this.status.code!==O.ACTIVE)throw new l("Server is is not listening yet","ERR_SERVER_NOT_RUNNING");t.on("error",o=>{G("socket error",o),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=er(t,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(o){G.error("inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}G("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(o=>{G("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.resume().catch(n=>{G.error("error attempting to listen server once connection count under limit",n),this.context.closeServerOnMaxConnections?.onListenError?.(n)})}),this.context.handler!=null&&this.context.handler(o),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.pause(!1).catch(n=>{G.error("error attempting to close server once connection count over limit",n)}),this.dispatchEvent(new ee("connection",{detail:o}))}).catch(async o=>{G.error("inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await En(e)}).catch(o=>{G.error("closing inbound connection failed",o)})}catch(o){G.error("inbound connection failed",o),En(e).catch(n=>{G.error("closing inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(this.status.code===O.INACTIVE)return[];let t=[],e=this.server.address(),{listeningAddr:o,peerId:n}=this.status;if(e==null)return[];if(typeof e=="string")t=[o];else try{o.toString().startsWith("/ip4")?t=t.concat(yn("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(yn("ip6",e.address,e.port)))}catch(i){G.error("could not turn %s:%s into multiaddr",e.address,e.port,i)}return t.map(i=>n!=null?i.encapsulate(`/p2p/${n}`):i)}async listen(t){if(this.status.code===O.ACTIVE||this.status.code===O.PAUSED)throw new l("server is already listening","ERR_SERVER_ALREADY_LISTENING");let e=t.getPeerId(),o=e==null?t.decapsulateCode(421):t,{backlog:n}=this.context;try{this.status={code:O.ACTIVE,listeningAddr:o,peerId:e,netConfig:ne(o,{backlog:n})},await this.resume()}catch(i){throw this.status={code:O.INACTIVE},i}}async close(){await Promise.all([Promise.all(Array.from(this.connections.values()).map(async t=>En(t))),this.pause(!0).catch(t=>{G.error("error attempting to close server once connection count over limit",t)})])}async resume(){if(this.server.listening||this.status.code===O.INACTIVE)return;let t=this.status.netConfig;await new Promise((e,o)=>{this.server.once("error",o),this.server.listen(t,e)}),this.status={...this.status,code:O.ACTIVE},G("Listening on %s",this.server.address())}async pause(t){if(!this.server.listening&&this.status.code===O.PAUSED&&t){this.status={code:O.INACTIVE};return}!this.server.listening||this.status.code!==O.ACTIVE||(G("Closing server on %s",this.server.address()),this.status=t?{code:O.INACTIVE}:{...this.status,code:O.PAUSED},await new Promise((e,o)=>{this.server.close(n=>{n!=null?o(n):e()})}))}};var yt=q("libp2p:tcp"),wn=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Ao]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let o=await this._connect(t,e);o.on("error",c=>{yt("socket error",c)});let n=er(o,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),i=()=>{n.close().catch(c=>{yt.error("Error closing maConn after abort",c)})};e.signal?.addEventListener("abort",i,{once:!0}),yt("new outbound connection %s",n.remoteAddr);let s=await e.upgrader.upgradeOutbound(n);if(yt("outbound connection %s upgraded",n.remoteAddr),e.signal?.removeEventListener("abort",i),e.signal?.aborted===!0)throw s.close().catch(c=>{yt.error("Error closing conn after abort",c)}),new qt;return s}async _connect(t,e){if(e.signal?.aborted===!0)throw new qt;return new Promise((o,n)=>{let i=Date.now(),s=ne(t),c=s.path??`${s.host??""}:${s.port}`;yt("dialing %j",s);let a=oi.default.connect(s),p=g=>{g.message=`connection error ${c}: ${g.message}`,this.metrics?.dialerEvents.increment({error:!0}),b(g)},u=()=>{yt("connection timeout %s",c),this.metrics?.dialerEvents.increment({timeout:!0});let g=new l(`connection timeout after ${Date.now()-i}ms`,"ERR_CONNECT_TIMEOUT");a.emit("error",g)},d=()=>{yt("connection opened %j",s),this.metrics?.dialerEvents.increment({connect:!0}),b()},h=()=>{yt("connection aborted %j",s),this.metrics?.dialerEvents.increment({abort:!0}),a.destroy(),b(new qt)},b=g=>{if(a.removeListener("error",p),a.removeListener("timeout",u),a.removeListener("connect",d),e.signal!=null&&e.signal.removeEventListener("abort",h),g!=null){n(g);return}o(a)};a.on("error",p),a.on("timeout",u),a.on("connect",d),e.signal!=null&&e.signal.addEventListener("abort",h)})}createListener(t){return new rr({...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:St.matches(e.decapsulateCode(421)))}};function ii(r={}){return(t={})=>new wn(t,r)}var nr=class{client;constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new l("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new l("value received is not a Uint8Array","ERR_INVALID_VALUE");let o=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.PUT_VALUE,key:t,value:e}}),n=await o.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=w.decode(n);if(await o.close(),i.type!==w.Type.OK)throw new l(i.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new l("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.GET_VALUE,key:t}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(await e.close(),n.type!==w.Type.OK)throw new l(n.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(n.dht==null||n.dht.value==null)throw new l("Invalid DHT get response","ERR_DHT_GET_FAILED");return n.dht.value}async findPeer(t){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.FIND_PEER,peer:t.toBytes()}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(await e.close(),n.type!==w.Type.OK)throw new l(n.error?.msg??"DHT find peer failed","ERR_DHT_FIND_PEER_FAILED");if(n.dht==null||n.dht.peer==null||n.dht.peer.addrs==null)throw new l("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:ut(n.dht.peer.id),multiaddrs:n.dht.peer.addrs.map(i=>V(i)),protocols:[]}}async provide(t){if(t==null||H.asCID(t)==null)throw new l("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.PROVIDE,cid:t.bytes}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(await e.close(),n.type!==w.Type.OK)throw new l(n.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||H.asCID(t)==null)throw new l("invalid cid received","ERR_INVALID_CID");let o=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),n=await o.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=w.decode(n);if(i.type!==w.Type.OK)throw await o.close(),new l(i.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await o.read(),n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let s=ct.decode(n);if(s.type===ct.Type.END){await o.close();return}if(s.type===ct.Type.VALUE&&s.peer!=null&&s.peer?.addrs!=null)yield{id:ut(s.peer.id),multiaddrs:s.peer.addrs.map(c=>V(c)),protocols:[]};else throw await o.close(),new l("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new l("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.GET_CLOSEST_PEERS,key:t}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(n.type!==w.Type.OK)throw await e.close(),new l(n.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(o=await e.read(),o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=ct.decode(o);if(i.type===ct.Type.END){await e.close();return}if(i.type===ct.Type.VALUE&&i.value!=null)yield{id:ut(i.value),multiaddrs:[],protocols:[]};else throw await e.close(),new l("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:S.Type.DHT,dht:{type:rt.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(await e.close(),n.type!==w.Type.OK)throw new l(n.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(n.dht==null)throw new l("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return n.dht.value}};var or=class{client;constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=w.decode(e);if(await t.close(),o.type!==w.Type.OK)throw new l(o.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(o.pubsub==null||o.pubsub.topics==null)throw new l("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return o.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new l("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new l("data received is not a Uint8Array","ERR_INVALID_DATA");let o=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.PUBLISH,topic:t,data:e}}),n=await o.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=w.decode(n);if(await o.close(),i.type!==w.Type.OK)throw new l(i.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async subscribe(t){if(typeof t!="string")throw new l("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.SUBSCRIBE,topic:t}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(n.type!==w.Type.OK)throw new l(n.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");let i=!0;return{async*messages(){for(;i;){if(o=await e.read(),o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");yield _e.decode(o)}},async cancel(){i=!1,await e.close()}}}async getSubscribers(t){if(typeof t!="string")throw new l("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.LIST_PEERS,topic:t}}),o=await e.read();if(o==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=w.decode(o);if(await e.close(),n.type!==w.Type.OK)throw new l(n.error?.msg??"Pubsub get subscribers failed","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new l("Invalid response","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");return n.pubsub.peerIDs.map(i=>ut(i))}};var xn=q("libp2p:daemon-client"),In=class{multiaddr;dht;pubsub;tcp;constructor(t){this.multiaddr=t,this.tcp=ii()({logger:ao()}),this.dht=new nr(this),this.pubsub=new or(this)}async connectDaemon(){return this.tcp.dial(this.multiaddr,{upgrader:Jr})}async send(t){let e=await this.connectDaemon(),o=t.pubsub?.type??t.dht?.type??t.peerStore?.type??"";xn("send",t.type,o);let n=new fe({stream:e});return n.write(S.encode(t)),n}async connect(t,e){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new l("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(s=>{if(!Xe(s))throw new l("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let o=await this.send({type:S.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(s=>s.bytes)}}),n=await o.read();if(n==null)throw new l("unspecified","ERR_CONNECT_FAILED");let i=w.decode(n);if(i.type!==w.Type.OK){let s=i.error??{msg:"unspecified"};throw new l(s.msg??"unspecified","ERR_CONNECT_FAILED")}await o.close()}async identify(){let t=await this.send({type:S.Type.IDENTIFY}),e=await t.read();if(e==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=w.decode(e);if(o.type!==w.Type.OK)throw new l(o.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(o.identify==null||o.identify.addrs==null)throw new l("Invalid response","ERR_IDENTIFY_FAILED");let n=ut(o.identify?.id),i=o.identify.addrs.map(s=>V(s));return await t.close(),{peerId:n,addrs:i}}async listPeers(){let t=await this.send({type:S.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=w.decode(e);if(o.type!==w.Type.OK)throw new l(o.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),o.peers.map(n=>ut(n.id))}async openStream(t,e){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new l("invalid protocol received","ERR_INVALID_PROTOCOL");let o=await this.send({type:S.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),n=await o.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=w.decode(n);if(i.type!==w.Type.OK)throw await o.close(),new l(i.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return o.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new l("invalid protocol received","ERR_INVALID_PROTOCOL");let o=this.tcp.createListener({upgrader:Jr,handler:a=>{Promise.resolve().then(async()=>{let p=new fe({stream:a}),u=await p.read();if(u==null)throw new l("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(Ht.decode(u).proto!==t)throw new l("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(p.rest())}).finally(()=>{a.close().catch(p=>{xn.error(p)}),o.close().catch(p=>{xn.error(p)})})}});await o.listen(V("/ip4/127.0.0.1/tcp/0"));let n=o.getAddrs()[0];if(n==null)throw new l("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let i=await this.send({type:S.Type.STREAM_HANDLER,streamHandler:{addr:n.bytes,proto:[t]}}),s=await i.read();if(s==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let c=w.decode(s);if(await i.close(),c.type!==w.Type.OK)throw new l(c.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function Qc(r){return new In(r)}return di(Zc);})();
7
7
  return Libp2PDaemonClient}));
@@ -14,32 +14,32 @@ export interface StreamHandlerFunction {
14
14
  (stream: Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>): Promise<void>;
15
15
  }
16
16
  export interface DHTClient {
17
- put: (key: Uint8Array, value: Uint8Array) => Promise<void>;
18
- get: (key: Uint8Array) => Promise<Uint8Array>;
19
- provide: (cid: CID) => Promise<void>;
20
- findProviders: (cid: CID, count?: number) => AsyncIterable<PeerInfo>;
21
- findPeer: (peerId: PeerId) => Promise<PeerInfo>;
22
- getClosestPeers: (key: Uint8Array) => AsyncIterable<PeerInfo>;
17
+ put(key: Uint8Array, value: Uint8Array): Promise<void>;
18
+ get(key: Uint8Array): Promise<Uint8Array>;
19
+ provide(cid: CID): Promise<void>;
20
+ findProviders(cid: CID, count?: number): AsyncIterable<PeerInfo>;
21
+ findPeer(peerId: PeerId): Promise<PeerInfo>;
22
+ getClosestPeers(key: Uint8Array): AsyncIterable<PeerInfo>;
23
23
  }
24
24
  export interface Subscription {
25
- messages: () => AsyncIterable<PSMessage>;
26
- cancel: () => Promise<void>;
25
+ messages(): AsyncIterable<PSMessage>;
26
+ cancel(): Promise<void>;
27
27
  }
28
28
  export interface PubSubClient {
29
- publish: (topic: string, data: Uint8Array) => Promise<void>;
30
- subscribe: (topic: string) => Promise<Subscription>;
31
- getTopics: () => Promise<string[]>;
32
- getSubscribers: (topic: string) => Promise<PeerId[]>;
29
+ publish(topic: string, data: Uint8Array): Promise<void>;
30
+ subscribe(topic: string): Promise<Subscription>;
31
+ getTopics(): Promise<string[]>;
32
+ getSubscribers(topic: string): Promise<PeerId[]>;
33
33
  }
34
34
  export interface DaemonClient {
35
- identify: () => Promise<IdentifyResult>;
36
- listPeers: () => Promise<PeerId[]>;
37
- connect: (peerId: PeerId, addrs: Multiaddr[]) => Promise<void>;
35
+ identify(): Promise<IdentifyResult>;
36
+ listPeers(): Promise<PeerId[]>;
37
+ connect(peerId: PeerId, addrs: Multiaddr[]): Promise<void>;
38
38
  dht: DHTClient;
39
39
  pubsub: PubSubClient;
40
- send: (request: Request) => Promise<StreamHandler>;
41
- openStream: (peerId: PeerId, protocol: string) => Promise<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>>;
42
- registerStreamHandler: (protocol: string, handler: StreamHandlerFunction) => Promise<void>;
40
+ send(request: Request): Promise<StreamHandler>;
41
+ openStream(peerId: PeerId, protocol: string): Promise<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>>;
42
+ registerStreamHandler(protocol: string, handler: StreamHandlerFunction): Promise<void>;
43
43
  }
44
44
  export declare function createClient(multiaddr: Multiaddr): DaemonClient;
45
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
package/dist/src/index.js CHANGED
@@ -3,7 +3,7 @@ import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler';
3
3
  import { passThroughUpgrader } from '@libp2p/daemon-protocol/upgrader';
4
4
  import { CodeError } from '@libp2p/interface/errors';
5
5
  import { isPeerId } from '@libp2p/interface/peer-id';
6
- import { logger } from '@libp2p/logger';
6
+ import { defaultLogger, logger } from '@libp2p/logger';
7
7
  import { peerIdFromBytes } from '@libp2p/peer-id';
8
8
  import { tcp } from '@libp2p/tcp';
9
9
  import { multiaddr, isMultiaddr } from '@multiformats/multiaddr';
@@ -17,7 +17,10 @@ class Client {
17
17
  tcp;
18
18
  constructor(addr) {
19
19
  this.multiaddr = addr;
20
- this.tcp = tcp()();
20
+ this.tcp = tcp()({
21
+ // @ts-expect-error this field will be present post v1
22
+ logger: defaultLogger()
23
+ });
21
24
  this.dht = new DHT(this);
22
25
  this.pubsub = new Pubsub(this);
23
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAe,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AASpC,MAAM,GAAG,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAA;AAE1C,MAAM,MAAM;IACO,SAAS,CAAW;IAC9B,GAAG,CAAK;IACR,MAAM,CAAQ;IACJ,GAAG,CAAW;IAE/B,YAAa,IAAe;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;YACf,sDAAsD;YACtD,MAAM,EAAE,aAAa,EAAE;SACxB,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa;QACjB,0DAA0D;QAC1D,8DAA8D;QAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnC,QAAQ,EAAE,mBAAmB;SAC9B,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAE,OAAgB;QAC1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;QAEzC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,IAAI,OAAO,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAA;QAC1F,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAElC,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QAC3D,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;QAC5C,OAAO,aAAa,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAE,MAAc,EAAE,KAAkB;QAC/C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACrB,MAAM,IAAI,SAAS,CAAC,0BAA0B,EAAE,qBAAqB,CAAC,CAAA;SACvE;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACzB,MAAM,IAAI,SAAS,CAAC,oCAAoC,EAAE,wBAAwB,CAAC,CAAA;SACpF;QAED,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBACtB,MAAM,IAAI,SAAS,CAAC,6CAA6C,EAAE,2BAA2B,CAAC,CAAA;aAChG;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;YAC1B,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE;gBACtB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;aACjC;SACF,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAA;QAC/B,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAA;SACzD;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACzC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;YACtC,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,CAAA;YAC5D,MAAM,IAAI,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,aAAa,EAAE,oBAAoB,CAAC,CAAA;SAC5E;QAED,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;IAClB,CAAC;IAED;;;;OAIG;IAEH;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;SAC5B,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAA;QAE/B,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,SAAS,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAA;SACxE;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAEzC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;YACtC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,IAAI,iBAAiB,EAAE,qBAAqB,CAAC,CAAA;SACrF;QAED,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI,EAAE;YAChE,MAAM,IAAI,SAAS,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAA;SAC/D;QAED,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QAE9D,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;QAEhB,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;SAC9B,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAA;QAE/B,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,SAAS,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAA;SACxE;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAEzC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;YACtC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,IAAI,mBAAmB,EAAE,uBAAuB,CAAC,CAAA;SACzF;QAED,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;QAEhB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAE,MAAc,EAAE,QAAgB;QAChD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACrB,MAAM,IAAI,SAAS,CAAC,0BAA0B,EAAE,qBAAqB,CAAC,CAAA;SACvE;QAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,MAAM,IAAI,SAAS,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAA;SACzE;QAED,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;YAC9B,UAAU,EAAE;gBACV,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE;gBACtB,KAAK,EAAE,CAAC,QAAQ,CAAC;aAClB;SACF,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAA;QAE/B,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,SAAS,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAA;SACxE;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAEzC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;YACtC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;YAChB,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,IAAI,oBAAoB,EAAE,wBAAwB,CAAC,CAAA;SAC3F;QAED,OAAO,EAAE,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB,CAAE,QAAgB,EAAE,OAA8B;QAC3E,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,MAAM,IAAI,SAAS,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAA;SACzE;QAED,iEAAiE;QACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;YACvC,QAAQ,EAAE,mBAAmB;YAC7B,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE;gBACtB,OAAO,CAAC,OAAO,EAAE;qBACd,IAAI,CAAC,KAAK,IAAI,EAAE;oBACf,MAAM,EAAE,GAAG,IAAI,aAAa,CAAC;wBAC3B,8FAA8F;wBAC9F,MAAM,EAAE,UAAU;qBACnB,CAAC,CAAA;oBACF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAA;oBAE/B,IAAI,OAAO,IAAI,IAAI,EAAE;wBACnB,MAAM,IAAI,SAAS,CAAC,qCAAqC,EAAE,wBAAwB,CAAC,CAAA;qBACrF;oBAED,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;oBAE3C,IAAI,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE;wBAC/B,MAAM,IAAI,SAAS,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAA;qBACpE;oBAED,MAAM,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;gBAC1B,CAAC,CAAC;qBACD,OAAO,CAAC,GAAG,EAAE;oBACZ,UAAU,CAAC,KAAK,EAAE;yBACf,KAAK,CAAC,GAAG,CAAC,EAAE;wBACX,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;oBAChB,CAAC,CAAC,CAAA;oBACJ,QAAQ,CAAC,KAAK,EAAE;yBACb,KAAK,CAAC,GAAG,CAAC,EAAE;wBACX,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;oBAChB,CAAC,CAAC,CAAA;gBACN,CAAC,CAAC,CAAA;YACN,CAAC;SACF,CAAC,CAAA;QACF,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAA;QACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;QAEtC,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,SAAS,CAAC,0BAA0B,EAAE,oCAAoC,CAAC,CAAA;SACtF;QAED,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc;YACjC,aAAa,EAAE;gBACb,IAAI,EAAE,OAAO,CAAC,KAAK;gBACnB,KAAK,EAAE,CAAC,QAAQ,CAAC;aAClB;SACF,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAA;QAE/B,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,SAAS,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAA;SACxE;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAEzC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;QAEhB,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;YACtC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,IAAI,gCAAgC,EAAE,oCAAoC,CAAC,CAAA;SACnH;IACH,CAAC;CACF;AA4CD,MAAM,UAAU,YAAY,CAAE,SAAoB;IAChD,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,CAAA;AAC9B,CAAC"}
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "DHTClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DHTClient.html",
3
+ ".:DHTClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DHTClient.html",
3
4
  "DaemonClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DaemonClient.html",
5
+ ".:DaemonClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DaemonClient.html",
4
6
  "IdentifyResult": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.IdentifyResult.html",
7
+ ".:IdentifyResult": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.IdentifyResult.html",
5
8
  "PubSubClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.PubSubClient.html",
9
+ ".:PubSubClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.PubSubClient.html",
6
10
  "StreamHandlerFunction": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.StreamHandlerFunction.html",
11
+ ".:StreamHandlerFunction": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.StreamHandlerFunction.html",
7
12
  "Subscription": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.Subscription.html",
8
- "createClient": "https://libp2p.github.io/js-libp2p-daemon/functions/_libp2p_daemon_client.createClient.html"
13
+ ".:Subscription": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.Subscription.html",
14
+ "createClient": "https://libp2p.github.io/js-libp2p-daemon/functions/_libp2p_daemon_client.createClient.html",
15
+ ".:createClient": "https://libp2p.github.io/js-libp2p-daemon/functions/_libp2p_daemon_client.createClient.html"
9
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/daemon-client",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "description": "libp2p-daemon client implementation",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p-daemon/tree/master/packages/libp2p-daemon-client#readme",
@@ -31,6 +31,7 @@
31
31
  "eslintConfig": {
32
32
  "extends": "ipfs",
33
33
  "parserOptions": {
34
+ "project": true,
34
35
  "sourceType": "module"
35
36
  }
36
37
  },
@@ -145,11 +146,11 @@
145
146
  "devDependencies": {
146
147
  "@libp2p/daemon-server": "^6.0.0",
147
148
  "@libp2p/interface-compliance-tests": "^4.0.0",
148
- "aegir": "^40.0.1",
149
+ "aegir": "^41.1.6",
149
150
  "it-all": "^3.0.1",
150
151
  "it-pipe": "^3.0.1",
151
- "sinon": "^15.1.2",
152
- "sinon-ts": "^1.0.0",
152
+ "sinon": "^17.0.1",
153
+ "sinon-ts": "^2.0.0",
153
154
  "uint8arrays": "^4.0.4"
154
155
  }
155
156
  }
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@ import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler'
3
3
  import { passThroughUpgrader } from '@libp2p/daemon-protocol/upgrader'
4
4
  import { CodeError } from '@libp2p/interface/errors'
5
5
  import { isPeerId, type PeerId } from '@libp2p/interface/peer-id'
6
- import { logger } from '@libp2p/logger'
6
+ import { defaultLogger, logger } from '@libp2p/logger'
7
7
  import { peerIdFromBytes } from '@libp2p/peer-id'
8
8
  import { tcp } from '@libp2p/tcp'
9
9
  import { multiaddr, isMultiaddr } from '@multiformats/multiaddr'
@@ -27,7 +27,10 @@ class Client implements DaemonClient {
27
27
 
28
28
  constructor (addr: Multiaddr) {
29
29
  this.multiaddr = addr
30
- this.tcp = tcp()()
30
+ this.tcp = tcp()({
31
+ // @ts-expect-error this field will be present post v1
32
+ logger: defaultLogger()
33
+ })
31
34
  this.dht = new DHT(this)
32
35
  this.pubsub = new Pubsub(this)
33
36
  }
@@ -286,36 +289,36 @@ export interface StreamHandlerFunction {
286
289
  }
287
290
 
288
291
  export interface DHTClient {
289
- put: (key: Uint8Array, value: Uint8Array) => Promise<void>
290
- get: (key: Uint8Array) => Promise<Uint8Array>
291
- provide: (cid: CID) => Promise<void>
292
- findProviders: (cid: CID, count?: number) => AsyncIterable<PeerInfo>
293
- findPeer: (peerId: PeerId) => Promise<PeerInfo>
294
- getClosestPeers: (key: Uint8Array) => AsyncIterable<PeerInfo>
292
+ put(key: Uint8Array, value: Uint8Array): Promise<void>
293
+ get(key: Uint8Array): Promise<Uint8Array>
294
+ provide(cid: CID): Promise<void>
295
+ findProviders(cid: CID, count?: number): AsyncIterable<PeerInfo>
296
+ findPeer(peerId: PeerId): Promise<PeerInfo>
297
+ getClosestPeers(key: Uint8Array): AsyncIterable<PeerInfo>
295
298
  }
296
299
 
297
300
  export interface Subscription {
298
- messages: () => AsyncIterable<PSMessage>
299
- cancel: () => Promise<void>
301
+ messages(): AsyncIterable<PSMessage>
302
+ cancel(): Promise<void>
300
303
  }
301
304
 
302
305
  export interface PubSubClient {
303
- publish: (topic: string, data: Uint8Array) => Promise<void>
304
- subscribe: (topic: string) => Promise<Subscription>
305
- getTopics: () => Promise<string[]>
306
- getSubscribers: (topic: string) => Promise<PeerId[]>
306
+ publish(topic: string, data: Uint8Array): Promise<void>
307
+ subscribe(topic: string): Promise<Subscription>
308
+ getTopics(): Promise<string[]>
309
+ getSubscribers(topic: string): Promise<PeerId[]>
307
310
  }
308
311
 
309
312
  export interface DaemonClient {
310
- identify: () => Promise<IdentifyResult>
311
- listPeers: () => Promise<PeerId[]>
312
- connect: (peerId: PeerId, addrs: Multiaddr[]) => Promise<void>
313
+ identify(): Promise<IdentifyResult>
314
+ listPeers(): Promise<PeerId[]>
315
+ connect(peerId: PeerId, addrs: Multiaddr[]): Promise<void>
313
316
  dht: DHTClient
314
317
  pubsub: PubSubClient
315
318
 
316
- send: (request: Request) => Promise<StreamHandler>
317
- openStream: (peerId: PeerId, protocol: string) => Promise<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>>
318
- registerStreamHandler: (protocol: string, handler: StreamHandlerFunction) => Promise<void>
319
+ send(request: Request): Promise<StreamHandler>
320
+ openStream(peerId: PeerId, protocol: string): Promise<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>>
321
+ registerStreamHandler(protocol: string, handler: StreamHandlerFunction): Promise<void>
319
322
  }
320
323
 
321
324
  export function createClient (multiaddr: Multiaddr): DaemonClient {