libp2p-gossipsub
Version:
A typescript implementation of gossipsub
2 lines • 608 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2pGossipsub = factory()}(typeof self !== 'undefined' ? self : this, function () {
var Libp2pGossipsub=(()=>{var Tf=Object.defineProperty;var Sb=t=>Tf(t,"__esModule",{value:!0});var Rf=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Ee=(t,e)=>()=>(t&&(e=t(t=0)),e);var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),lt=(t,e)=>{Sb(t);for(var r in e)Tf(t,r,{get:e[r],enumerable:!0})};var Pf=E((gT,Df)=>{var Tn=1e3,Rn=Tn*60,Dn=Rn*60,$i=Dn*24,_b=$i*7,Ib=$i*365.25;Df.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Bb(t);if(r==="number"&&isFinite(t))return e.long?Cb(t):Ab(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Bb(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!!e){var r=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*Ib;case"weeks":case"week":case"w":return r*_b;case"days":case"day":case"d":return r*$i;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Dn;case"minutes":case"minute":case"mins":case"min":case"m":return r*Rn;case"seconds":case"second":case"secs":case"sec":case"s":return r*Tn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Ab(t){var e=Math.abs(t);return e>=$i?Math.round(t/$i)+"d":e>=Dn?Math.round(t/Dn)+"h":e>=Rn?Math.round(t/Rn)+"m":e>=Tn?Math.round(t/Tn)+"s":t+"ms"}function Cb(t){var e=Math.abs(t);return e>=$i?Ta(t,e,$i,"day"):e>=Dn?Ta(t,e,Dn,"hour"):e>=Rn?Ta(t,e,Rn,"minute"):e>=Tn?Ta(t,e,Tn,"second"):t+" ms"}function Ta(t,e,r,i){var n=e>=r*1.5;return Math.round(t/r)+" "+i+(n?"s":"")}});var Nf=E((vT,kf)=>{function Tb(t){r.debug=r,r.default=r,r.coerce=f,r.disable=s,r.enable=n,r.enabled=a,r.humanize=Pf(),r.destroy=u,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let h=0;for(let l=0;l<c.length;l++)h=(h<<5)-h+c.charCodeAt(l),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=e;function r(c){let h,l=null,d,p;function y(...g){if(!y.enabled)return;let v=y,x=Number(new Date),w=x-(h||x);v.diff=w,v.prev=h,v.curr=x,h=x,g[0]=r.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let P=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(S,G)=>{if(S==="%%")return"%";P++;let z=r.formatters[G];if(typeof z=="function"){let se=g[P];S=z.call(v,se),g.splice(P,1),P--}return S}),r.formatArgs.call(v,g),(v.log||r.log).apply(v,g)}return y.namespace=c,y.useColors=r.useColors(),y.color=r.selectColor(c),y.extend=i,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>l!==null?l:(d!==r.namespaces&&(d=r.namespaces,p=r.enabled(c)),p),set:g=>{l=g}}),typeof r.init=="function"&&r.init(y),y}function i(c,h){let l=r(this.namespace+(typeof h=="undefined"?":":h)+c);return l.log=this.log,l}function n(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let h,l=(typeof c=="string"?c:"").split(/[\s,]+/),d=l.length;for(h=0;h<d;h++)!l[h]||(c=l[h].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.substr(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...r.names.map(o),...r.skips.map(o).map(h=>"-"+h)].join(",");return r.enable(""),c}function a(c){if(c[c.length-1]==="*")return!0;let h,l;for(h=0,l=r.skips.length;h<l;h++)if(r.skips[h].test(c))return!1;for(h=0,l=r.names.length;h<l;h++)if(r.names[h].test(c))return!0;return!1}function o(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function f(c){return c instanceof Error?c.stack||c.message:c}function u(){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 r.enable(r.load()),r}kf.exports=Tb});var Is=E((Lt,Ra)=>{Lt.formatArgs=Db;Lt.save=Pb;Lt.load=kb;Lt.useColors=Rb;Lt.storage=Nb();Lt.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();Lt.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 Rb(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Db(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Ra.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(i=r))}),t.splice(i,0,e)}Lt.log=console.debug||console.log||(()=>{});function Pb(t){try{t?Lt.storage.setItem("debug",t):Lt.storage.removeItem("debug")}catch(e){}}function kb(){let t;try{t=Lt.storage.getItem("debug")}catch(e){}return!t&&typeof process!="undefined"&&"env"in process&&(t=process.env.DEBUG),t}function Nb(){try{return localStorage}catch(t){}}Ra.exports=Nf()(Lt);var{formatters:Ob}=Ra.exports;Ob.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var B0=E((xT,I0)=>{"use strict";var Pn=typeof Reflect=="object"?Reflect:null,Of=Pn&&typeof Pn.apply=="function"?Pn.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Da;Pn&&typeof Pn.ownKeys=="function"?Da=Pn.ownKeys:Object.getOwnPropertySymbols?Da=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Da=function(e){return Object.getOwnPropertyNames(e)};function Lb(t){console&&console.warn&&console.warn(t)}var Lf=Number.isNaN||function(e){return e!==e};function we(){we.init.call(this)}I0.exports=we;I0.exports.once=Ub;we.EventEmitter=we;we.prototype._events=void 0;we.prototype._eventsCount=0;we.prototype._maxListeners=void 0;var Mf=10;function Pa(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(we,"defaultMaxListeners",{enumerable:!0,get:function(){return Mf},set:function(t){if(typeof t!="number"||t<0||Lf(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Mf=t}});we.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};we.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Lf(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Kf(t){return t._maxListeners===void 0?we.defaultMaxListeners:t._maxListeners}we.prototype.getMaxListeners=function(){return Kf(this)};we.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var a;if(r.length>0&&(a=r[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")Of(f,this,r);else for(var u=f.length,c=Gf(f,u),i=0;i<u;++i)Of(c[i],this,r);return!0};function Ff(t,e,r,i){var n,s,a;if(Pa(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),a=s[e]),a===void 0)a=s[e]=r,++t._eventsCount;else if(typeof a=="function"?a=s[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),n=Kf(t),n>0&&a.length>n&&!a.warned){a.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=a.length,Lb(o)}return t}we.prototype.addListener=function(e,r){return Ff(this,e,r,!1)};we.prototype.on=we.prototype.addListener;we.prototype.prependListener=function(e,r){return Ff(this,e,r,!0)};function Mb(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Uf(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Mb.bind(i);return n.listener=r,i.wrapFn=n,n}we.prototype.once=function(e,r){return Pa(r),this.on(e,Uf(this,e,r)),this};we.prototype.prependOnceListener=function(e,r){return Pa(r),this.prependListener(e,Uf(this,e,r)),this};we.prototype.removeListener=function(e,r){var i,n,s,a,o;if(Pa(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount==0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,a=i.length-1;a>=0;a--)if(i[a]===r||i[a].listener===r){o=i[a].listener,s=a;break}if(s<0)return this;s===0?i.shift():Kb(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,o||r)}return this};we.prototype.off=we.prototype.removeListener;we.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),a;for(n=0;n<s.length;++n)a=s[n],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function qf(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?Fb(n):Gf(n,n.length)}we.prototype.listeners=function(e){return qf(this,e,!0)};we.prototype.rawListeners=function(e){return qf(this,e,!1)};we.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Vf.call(t,e)};we.prototype.listenerCount=Vf;function Vf(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}we.prototype.eventNames=function(){return this._eventsCount>0?Da(this._events):[]};function Gf(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Kb(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Fb(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Ub(t,e){return new Promise(function(r,i){function n(a){t.removeListener(e,s),i(a)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}Hf(t,e,s,{once:!0}),e!=="error"&&qb(t,n,{once:!0})})}function qb(t,e,r){typeof t.on=="function"&&Hf(t,"error",e,r)}function Hf(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var Oe=E((bT,jf)=>{"use strict";function zf(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function Vb(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return zf(t,r)}catch(i){r.message=t.message,r.stack=t.stack;let n=function(){};return n.prototype=Object.create(Object.getPrototypeOf(t)),zf(new n,r)}}jf.exports=Vb});var C0=E((mT,kn)=>{var Wf=(...t)=>{let e;for(;t.length;)e=t.shift()(e);return e},A0=t=>t&&(typeof t[Symbol.asyncIterator]=="function"||typeof t[Symbol.iterator]=="function"||typeof t.next=="function"),ka=t=>t&&typeof t.sink=="function"&&A0(t.source),Gb=t=>e=>(t.sink(e),t.source),Yf=(...t)=>{if(ka(t[0])){let e=t[0];t[0]=()=>e.source}else if(A0(t[0])){let e=t[0];t[0]=()=>e}if(t.length>1&&ka(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let e=1;e<t.length-1;e++)ka(t[e])&&(t[e]=Gb(t[e]));return Wf(...t)};kn.exports=Yf;kn.exports.pipe=Yf;kn.exports.rawPipe=Wf;kn.exports.isIterable=A0;kn.exports.isDuplex=ka});var Qf=E((ET,T0)=>{"use strict";var Hb=Object.prototype.hasOwnProperty,St="~";function Bs(){}Object.create&&(Bs.prototype=Object.create(null),new Bs().__proto__||(St=!1));function zb(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function $f(t,e,r,i,n){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new zb(r,i||t,n),a=St?St+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],s]:t._events[a].push(s):(t._events[a]=s,t._eventsCount++),t}function Na(t,e){--t._eventsCount==0?t._events=new Bs:delete t._events[e]}function pt(){this._events=new Bs,this._eventsCount=0}pt.prototype.eventNames=function(){var e=[],r,i;if(this._eventsCount===0)return e;for(i in r=this._events)Hb.call(r,i)&&e.push(St?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};pt.prototype.listeners=function(e){var r=St?St+e:e,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,a=new Array(s);n<s;n++)a[n]=i[n].fn;return a};pt.prototype.listenerCount=function(e){var r=St?St+e:e,i=this._events[r];return i?i.fn?1:i.length:0};pt.prototype.emit=function(e,r,i,n,s,a){var o=St?St+e:e;if(!this._events[o])return!1;var f=this._events[o],u=arguments.length,c,h;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),u){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,r),!0;case 3:return f.fn.call(f.context,r,i),!0;case 4:return f.fn.call(f.context,r,i,n),!0;case 5:return f.fn.call(f.context,r,i,n,s),!0;case 6:return f.fn.call(f.context,r,i,n,s,a),!0}for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];f.fn.apply(f.context,c)}else{var l=f.length,d;for(h=0;h<l;h++)switch(f[h].once&&this.removeListener(e,f[h].fn,void 0,!0),u){case 1:f[h].fn.call(f[h].context);break;case 2:f[h].fn.call(f[h].context,r);break;case 3:f[h].fn.call(f[h].context,r,i);break;case 4:f[h].fn.call(f[h].context,r,i,n);break;default:if(!c)for(d=1,c=new Array(u-1);d<u;d++)c[d-1]=arguments[d];f[h].fn.apply(f[h].context,c)}}return!0};pt.prototype.on=function(e,r,i){return $f(this,e,r,i,!1)};pt.prototype.once=function(e,r,i){return $f(this,e,r,i,!0)};pt.prototype.removeListener=function(e,r,i,n){var s=St?St+e:e;if(!this._events[s])return this;if(!r)return Na(this,s),this;var a=this._events[s];if(a.fn)a.fn===r&&(!n||a.once)&&(!i||a.context===i)&&Na(this,s);else{for(var o=0,f=[],u=a.length;o<u;o++)(a[o].fn!==r||n&&!a[o].once||i&&a[o].context!==i)&&f.push(a[o]);f.length?this._events[s]=f.length===1?f[0]:f:Na(this,s)}return this};pt.prototype.removeAllListeners=function(e){var r;return e?(r=St?St+e:e,this._events[r]&&Na(this,r)):(this._events=new Bs,this._eventsCount=0),this};pt.prototype.off=pt.prototype.removeListener;pt.prototype.addListener=pt.prototype.on;pt.prefixed=St;pt.EventEmitter=pt;typeof T0!="undefined"&&(T0.exports=pt)});var Xf=E((wT,Zf)=>{"use strict";Zf.exports=(t,e)=>(e=e||(()=>{}),t.then(r=>new Promise(i=>{i(e())}).then(()=>r),r=>new Promise(i=>{i(e())}).then(()=>{throw r})))});var eh=E((ST,Oa)=>{"use strict";var jb=Xf(),R0=class extends Error{constructor(e){super(e);this.name="TimeoutError"}},Jf=(t,e,r)=>new Promise((i,n)=>{if(typeof e!="number"||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0){i(t);return}let s=setTimeout(()=>{if(typeof r=="function"){try{i(r())}catch(f){n(f)}return}let a=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,o=r instanceof Error?r:new R0(a);typeof t.cancel=="function"&&t.cancel(),n(o)},e);jb(t.then(i,n),()=>{clearTimeout(s)})});Oa.exports=Jf;Oa.exports.default=Jf;Oa.exports.TimeoutError=R0});var th=E(D0=>{"use strict";Object.defineProperty(D0,"__esModule",{value:!0});function Wb(t,e,r){let i=0,n=t.length;for(;n>0;){let s=n/2|0,a=i+s;r(t[a],e)<=0?(i=++a,n-=s+1):n=s}return i}D0.default=Wb});var ih=E(P0=>{"use strict";Object.defineProperty(P0,"__esModule",{value:!0});var Yb=th(),rh=class{constructor(){this._queue=[]}enqueue(e,r){r=Object.assign({priority:0},r);let i={priority:r.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(i);return}let n=Yb.default(this._queue,i,(s,a)=>a.priority-s.priority);this._queue.splice(n,0,i)}dequeue(){let e=this._queue.shift();return e==null?void 0:e.run}filter(e){return this._queue.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this._queue.length}};P0.default=rh});var ah=E(k0=>{"use strict";Object.defineProperty(k0,"__esModule",{value:!0});var $b=Qf(),nh=eh(),Qb=ih(),La=()=>{},Zb=new nh.TimeoutError,sh=class extends $b{constructor(e){var r,i,n,s;super();if(this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=La,this._resolveIdle=La,e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:Qb.default},e),!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(n=e.interval)===null||n===void 0?void 0:n.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||e.interval===0,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=e.throwOnTimeout===!0,this._isPaused=e.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=La,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=La,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let e=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-e;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),e&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,r={}){return new Promise((i,n)=>{let s=async()=>{this._pendingCount++,this._intervalCount++;try{let a=this._timeout===void 0&&r.timeout===void 0?e():nh.default(Promise.resolve(e()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&n(Zb)});i(await a)}catch(a){n(a)}this._next()};this._queue.enqueue(s,r),this._tryToStartAnother(),this.emit("add")})}async addAll(e,r){return Promise.all(e.map(async i=>this.add(i,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(e=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),e()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(e=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),e()}})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}};k0.default=sh});var hh=E((AT,fh)=>{"use strict";var oh=()=>{},uh=Symbol.for("@libp2p/js-interfaces/topology"),ch=class{constructor({min:e=0,max:r=1/0,handlers:i={}}){this.min=e,this.max=r,this._onConnect=i.onConnect||oh,this._onDisconnect=i.onDisconnect||oh,this.peers=new Set}get[Symbol.toStringTag](){return"Topology"}get[uh](){return!0}static isTopology(e){return Boolean(e&&e[uh])}async setRegistrar(e){this._registrar=e}disconnect(e){this._onDisconnect(e)}};fh.exports=ch});var vh=E((CT,gh)=>{"use strict";var Xb=hh(),lh=Symbol.for("@libp2p/js-interfaces/topology/multicodec-topology"),ph=Is(),dh=Object.assign(ph("libp2p:topology:multicodec-topology"),{error:ph("libp2p:topology:multicodec-topology:error")}),yh=class extends Xb{constructor({min:e,max:r,multicodecs:i,handlers:n}){super({min:e,max:r,handlers:n});if(!i)throw new Error("one or more multicodec should be provided");if(!n)throw new Error("the handlers should be provided");if(typeof n.onConnect!="function")throw new Error("the 'onConnect' handler must be provided");if(typeof n.onDisconnect!="function")throw new Error("the 'onDisconnect' handler must be provided");this.multicodecs=Array.isArray(i)?i:[i],this._registrar=void 0,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this)}get[Symbol.toStringTag](){return"Topology"}get[lh](){return!0}static isMulticodecTopology(e){return Boolean(e&&e[lh])}async setRegistrar(e){this._registrar=e,this._registrar.peerStore.on("change:protocols",this._onProtocolChange),this._registrar.connectionManager.on("peer:connect",this._onPeerConnect),await this._updatePeers(this._registrar.peerStore.getPeers())}async _updatePeers(e){for await(let{id:r,protocols:i}of e)if(this.multicodecs.filter(n=>i.includes(n)).length){this.peers.add(r.toB58String());let n=this._registrar.getConnection(r);n&&this._onConnect(r,n)}else this.peers.delete(r.toB58String())}async _onProtocolChange({peerId:e,protocols:r}){try{let i=this.peers.has(e.toB58String()),n=r.filter(s=>this.multicodecs.includes(s));i&&n.length===0&&this._onDisconnect(e);for(let s of r)if(this.multicodecs.includes(s)){let a=await this._registrar.peerStore.get(e);await this._updatePeers([a]);return}}catch(i){dh.error(i)}}async _onPeerConnect(e){try{let r=e.remotePeer,i=await this._registrar.peerStore.protoBook.get(r);if(!i)return;this.multicodecs.find(n=>i.includes(n))&&(this.peers.add(r.toB58String()),this._onConnect(r,e))}catch(r){dh.error(r)}}};gh.exports=yh});var Ma=E(xh=>{"use strict";xh.codes={ERR_INVALID_SIGNATURE_POLICY:"ERR_INVALID_SIGNATURE_POLICY",ERR_UNHANDLED_SIGNATURE_POLICY:"ERR_UNHANDLED_SIGNATURE_POLICY",ERR_MISSING_SIGNATURE:"ERR_MISSING_SIGNATURE",ERR_MISSING_SEQNO:"ERR_MISSING_SEQNO",ERR_INVALID_SIGNATURE:"ERR_INVALID_SIGNATURE",ERR_UNEXPECTED_FROM:"ERR_UNEXPECTED_FROM",ERR_UNEXPECTED_SIGNATURE:"ERR_UNEXPECTED_SIGNATURE",ERR_UNEXPECTED_KEY:"ERR_UNEXPECTED_KEY",ERR_UNEXPECTED_SEQNO:"ERR_UNEXPECTED_SEQNO"}});var mh=E((RT,bh)=>{"use strict";bh.exports=Jb;function Jb(t,e){for(var r=new Array(arguments.length-1),i=0,n=2,s=!0;n<arguments.length;)r[i++]=arguments[n++];return new Promise(function(o,f){r[i]=function(c){if(s)if(s=!1,c)f(c);else{for(var h=new Array(arguments.length-1),l=0;l<h.length;)h[l++]=arguments[l];o.apply(null,h)}};try{t.apply(e||null,r)}catch(u){s&&(s=!1,f(u))}})}});var _h=E(Sh=>{"use strict";var Ka=Sh;Ka.length=function(e){var r=e.length;if(!r)return 0;for(var i=0;--r%4>1&&e.charAt(r)==="=";)++i;return Math.ceil(e.length*3)/4-i};var Nn=new Array(64),Eh=new Array(123);for(Jt=0;Jt<64;)Eh[Nn[Jt]=Jt<26?Jt+65:Jt<52?Jt+71:Jt<62?Jt-4:Jt-59|43]=Jt++;var Jt;Ka.encode=function(e,r,i){for(var n=null,s=[],a=0,o=0,f;r<i;){var u=e[r++];switch(o){case 0:s[a++]=Nn[u>>2],f=(u&3)<<4,o=1;break;case 1:s[a++]=Nn[f|u>>4],f=(u&15)<<2,o=2;break;case 2:s[a++]=Nn[f|u>>6],s[a++]=Nn[u&63],o=0;break}a>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,s)),a=0)}return o&&(s[a++]=Nn[f],s[a++]=61,o===1&&(s[a++]=61)),n?(a&&n.push(String.fromCharCode.apply(String,s.slice(0,a))),n.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var wh="invalid encoding";Ka.decode=function(e,r,i){for(var n=i,s=0,a,o=0;o<e.length;){var f=e.charCodeAt(o++);if(f===61&&s>1)break;if((f=Eh[f])===void 0)throw Error(wh);switch(s){case 0:a=f,s=1;break;case 1:r[i++]=a<<2|(f&48)>>4,a=f,s=2;break;case 2:r[i++]=(a&15)<<4|(f&60)>>2,a=f,s=3;break;case 3:r[i++]=(a&3)<<6|f,s=0;break}}if(s===1)throw Error(wh);return i-n};Ka.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}});var Bh=E((PT,Ih)=>{"use strict";Ih.exports=Fa;function Fa(){this._listeners={}}Fa.prototype.on=function(e,r,i){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:r,ctx:i||this}),this};Fa.prototype.off=function(e,r){if(e===void 0)this._listeners={};else if(r===void 0)this._listeners[e]=[];else for(var i=this._listeners[e],n=0;n<i.length;)i[n].fn===r?i.splice(n,1):++n;return this};Fa.prototype.emit=function(e){var r=this._listeners[e];if(r){for(var i=[],n=1;n<arguments.length;)i.push(arguments[n++]);for(n=0;n<r.length;)r[n].fn.apply(r[n++].ctx,i)}return this}});var kh=E((kT,Ph)=>{"use strict";Ph.exports=Ah(Ah);function Ah(t){return typeof Float32Array!="undefined"?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),i=r[3]===128;function n(f,u,c){e[0]=f,u[c]=r[0],u[c+1]=r[1],u[c+2]=r[2],u[c+3]=r[3]}function s(f,u,c){e[0]=f,u[c]=r[3],u[c+1]=r[2],u[c+2]=r[1],u[c+3]=r[0]}t.writeFloatLE=i?n:s,t.writeFloatBE=i?s:n;function a(f,u){return r[0]=f[u],r[1]=f[u+1],r[2]=f[u+2],r[3]=f[u+3],e[0]}function o(f,u){return r[3]=f[u],r[2]=f[u+1],r[1]=f[u+2],r[0]=f[u+3],e[0]}t.readFloatLE=i?a:o,t.readFloatBE=i?o:a}():function(){function e(i,n,s,a){var o=n<0?1:0;if(o&&(n=-n),n===0)i(1/n>0?0:2147483648,s,a);else if(isNaN(n))i(2143289344,s,a);else if(n>34028234663852886e22)i((o<<31|2139095040)>>>0,s,a);else if(n<11754943508222875e-54)i((o<<31|Math.round(n/1401298464324817e-60))>>>0,s,a);else{var f=Math.floor(Math.log(n)/Math.LN2),u=Math.round(n*Math.pow(2,-f)*8388608)&8388607;i((o<<31|f+127<<23|u)>>>0,s,a)}}t.writeFloatLE=e.bind(null,Ch),t.writeFloatBE=e.bind(null,Th);function r(i,n,s){var a=i(n,s),o=(a>>31)*2+1,f=a>>>23&255,u=a&8388607;return f===255?u?NaN:o*(1/0):f===0?o*1401298464324817e-60*u:o*Math.pow(2,f-150)*(u+8388608)}t.readFloatLE=r.bind(null,Rh),t.readFloatBE=r.bind(null,Dh)}(),typeof Float64Array!="undefined"?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),i=r[7]===128;function n(f,u,c){e[0]=f,u[c]=r[0],u[c+1]=r[1],u[c+2]=r[2],u[c+3]=r[3],u[c+4]=r[4],u[c+5]=r[5],u[c+6]=r[6],u[c+7]=r[7]}function s(f,u,c){e[0]=f,u[c]=r[7],u[c+1]=r[6],u[c+2]=r[5],u[c+3]=r[4],u[c+4]=r[3],u[c+5]=r[2],u[c+6]=r[1],u[c+7]=r[0]}t.writeDoubleLE=i?n:s,t.writeDoubleBE=i?s:n;function a(f,u){return r[0]=f[u],r[1]=f[u+1],r[2]=f[u+2],r[3]=f[u+3],r[4]=f[u+4],r[5]=f[u+5],r[6]=f[u+6],r[7]=f[u+7],e[0]}function o(f,u){return r[7]=f[u],r[6]=f[u+1],r[5]=f[u+2],r[4]=f[u+3],r[3]=f[u+4],r[2]=f[u+5],r[1]=f[u+6],r[0]=f[u+7],e[0]}t.readDoubleLE=i?a:o,t.readDoubleBE=i?o:a}():function(){function e(i,n,s,a,o,f){var u=a<0?1:0;if(u&&(a=-a),a===0)i(0,o,f+n),i(1/a>0?0:2147483648,o,f+s);else if(isNaN(a))i(0,o,f+n),i(2146959360,o,f+s);else if(a>17976931348623157e292)i(0,o,f+n),i((u<<31|2146435072)>>>0,o,f+s);else{var c;if(a<22250738585072014e-324)c=a/5e-324,i(c>>>0,o,f+n),i((u<<31|c/4294967296)>>>0,o,f+s);else{var h=Math.floor(Math.log(a)/Math.LN2);h===1024&&(h=1023),c=a*Math.pow(2,-h),i(c*4503599627370496>>>0,o,f+n),i((u<<31|h+1023<<20|c*1048576&1048575)>>>0,o,f+s)}}}t.writeDoubleLE=e.bind(null,Ch,0,4),t.writeDoubleBE=e.bind(null,Th,4,0);function r(i,n,s,a,o){var f=i(a,o+n),u=i(a,o+s),c=(u>>31)*2+1,h=u>>>20&2047,l=4294967296*(u&1048575)+f;return h===2047?l?NaN:c*(1/0):h===0?c*5e-324*l:c*Math.pow(2,h-1075)*(l+4503599627370496)}t.readDoubleLE=r.bind(null,Rh,0,4),t.readDoubleBE=r.bind(null,Dh,4,0)}(),t}function Ch(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Th(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=t&255}function Rh(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function Dh(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}});var Nh=E((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(t){}return null}});var Lh=E(Oh=>{"use strict";var N0=Oh;N0.length=function(e){for(var r=0,i=0,n=0;n<e.length;++n)i=e.charCodeAt(n),i<128?r+=1:i<2048?r+=2:(i&64512)==55296&&(e.charCodeAt(n+1)&64512)==56320?(++n,r+=4):r+=3;return r};N0.read=function(e,r,i){var n=i-r;if(n<1)return"";for(var s=null,a=[],o=0,f;r<i;)f=e[r++],f<128?a[o++]=f:f>191&&f<224?a[o++]=(f&31)<<6|e[r++]&63:f>239&&f<365?(f=((f&7)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,a[o++]=55296+(f>>10),a[o++]=56320+(f&1023)):a[o++]=(f&15)<<12|(e[r++]&63)<<6|e[r++]&63,o>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),o=0);return s?(o&&s.push(String.fromCharCode.apply(String,a.slice(0,o))),s.join("")):String.fromCharCode.apply(String,a.slice(0,o))};N0.write=function(e,r,i){for(var n=i,s,a,o=0;o<e.length;++o)s=e.charCodeAt(o),s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):(s&64512)==55296&&((a=e.charCodeAt(o+1))&64512)==56320?(s=65536+((s&1023)<<10)+(a&1023),++o,r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128);return i-n}});var Kh=E((OT,Mh)=>{"use strict";Mh.exports=em;function em(t,e,r){var i=r||8192,n=i>>>1,s=null,a=i;return function(f){if(f<1||f>n)return t(f);a+f>i&&(s=t(i),a=0);var u=e.call(s,a,a+=f);return a&7&&(a=(a|7)+1),u}}});var Uh=E((LT,Fh)=>{"use strict";Fh.exports=tt;var As=pi();function tt(t,e){this.lo=t>>>0,this.hi=e>>>0}var Qi=tt.zero=new tt(0,0);Qi.toNumber=function(){return 0};Qi.zzEncode=Qi.zzDecode=function(){return this};Qi.length=function(){return 1};var tm=tt.zeroHash="\0\0\0\0\0\0\0\0";tt.fromNumber=function(e){if(e===0)return Qi;var r=e<0;r&&(e=-e);var i=e>>>0,n=(e-i)/4294967296>>>0;return r&&(n=~n>>>0,i=~i>>>0,++i>4294967295&&(i=0,++n>4294967295&&(n=0))),new tt(i,n)};tt.from=function(e){if(typeof e=="number")return tt.fromNumber(e);if(As.isString(e))if(As.Long)e=As.Long.fromString(e);else return tt.fromNumber(parseInt(e,10));return e.low||e.high?new tt(e.low>>>0,e.high>>>0):Qi};tt.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var r=~this.lo+1>>>0,i=~this.hi>>>0;return r||(i=i+1>>>0),-(r+i*4294967296)}return this.lo+this.hi*4294967296};tt.prototype.toLong=function(e){return As.Long?new As.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var li=String.prototype.charCodeAt;tt.fromHash=function(e){return e===tm?Qi:new tt((li.call(e,0)|li.call(e,1)<<8|li.call(e,2)<<16|li.call(e,3)<<24)>>>0,(li.call(e,4)|li.call(e,5)<<8|li.call(e,6)<<16|li.call(e,7)<<24)>>>0)};tt.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)};tt.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this};tt.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};tt.prototype.length=function(){var e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return i===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:i<128?9:10}});var pi=E(O0=>{"use strict";var j=O0;j.asPromise=mh();j.base64=_h();j.EventEmitter=Bh();j.float=kh();j.inquire=Nh();j.utf8=Lh();j.pool=Kh();j.LongBits=Uh();j.isNode=Boolean(typeof globalThis!="undefined"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);j.global=j.isNode&&globalThis||typeof window!="undefined"&&window||typeof self!="undefined"&&self||O0;j.emptyArray=Object.freeze?Object.freeze([]):[];j.emptyObject=Object.freeze?Object.freeze({}):{};j.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};j.isString=function(e){return typeof e=="string"||e instanceof String};j.isObject=function(e){return e&&typeof e=="object"};j.isset=j.isSet=function(e,r){var i=e[r];return i!=null&&e.hasOwnProperty(r)?typeof i!="object"||(Array.isArray(i)?i.length:Object.keys(i).length)>0:!1};j.Buffer=function(){try{var t=j.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(e){return null}}();j._Buffer_from=null;j._Buffer_allocUnsafe=null;j.newBuffer=function(e){return typeof e=="number"?j.Buffer?j._Buffer_allocUnsafe(e):new j.Array(e):j.Buffer?j._Buffer_from(e):typeof Uint8Array=="undefined"?e:new Uint8Array(e)};j.Array=typeof Uint8Array!="undefined"?Uint8Array:Array;j.Long=j.global.dcodeIO&&j.global.dcodeIO.Long||j.global.Long||j.inquire("long");j.key2Re=/^true|false|0|1$/;j.key32Re=/^-?(?:0|[1-9][0-9]*)$/;j.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;j.longToHash=function(e){return e?j.LongBits.from(e).toHash():j.LongBits.zeroHash};j.longFromHash=function(e,r){var i=j.LongBits.fromHash(e);return j.Long?j.Long.fromBits(i.lo,i.hi,r):i.toNumber(Boolean(r))};function qh(t,e,r){for(var i=Object.keys(e),n=0;n<i.length;++n)(t[i[n]]===void 0||!r)&&(t[i[n]]=e[i[n]]);return t}j.merge=qh;j.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function Vh(t){function e(r,i){if(!(this instanceof e))return new e(r,i);Object.defineProperty(this,"message",{get:function(){return r}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),i&&qh(this,i)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return t}}),e.prototype.toString=function(){return this.name+": "+this.message},e}j.newError=Vh;j.ProtocolError=Vh("ProtocolError");j.oneOfGetter=function(e){for(var r={},i=0;i<e.length;++i)r[e[i]]=1;return function(){for(var n=Object.keys(this),s=n.length-1;s>-1;--s)if(r[n[s]]===1&&this[n[s]]!==void 0&&this[n[s]]!==null)return n[s]}};j.oneOfSetter=function(e){return function(r){for(var i=0;i<e.length;++i)e[i]!==r&&delete this[e[i]]}};j.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};j._configure=function(){var t=j.Buffer;if(!t){j._Buffer_from=j._Buffer_allocUnsafe=null;return}j._Buffer_from=t.from!==Uint8Array.from&&t.from||function(r,i){return new t(r,i)},j._Buffer_allocUnsafe=t.allocUnsafe||function(r){return new t(r)}}});var V0=E((KT,jh)=>{"use strict";jh.exports=ce;var Ft=pi(),L0,Ua=Ft.LongBits,Gh=Ft.base64,Hh=Ft.utf8;function Cs(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function M0(){}function rm(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function ce(){this.len=0,this.head=new Cs(M0,0,0),this.tail=this.head,this.states=null}var zh=function(){return Ft.Buffer?function(){return(ce.create=function(){return new L0})()}:function(){return new ce}};ce.create=zh();ce.alloc=function(e){return new Ft.Array(e)};Ft.Array!==Array&&(ce.alloc=Ft.pool(ce.alloc,Ft.Array.prototype.subarray));ce.prototype._push=function(e,r,i){return this.tail=this.tail.next=new Cs(e,r,i),this.len+=r,this};function K0(t,e,r){e[r]=t&255}function im(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}function F0(t,e){this.len=t,this.next=void 0,this.val=e}F0.prototype=Object.create(Cs.prototype);F0.prototype.fn=im;ce.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new F0((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};ce.prototype.int32=function(e){return e<0?this._push(U0,10,Ua.fromNumber(e)):this.uint32(e)};ce.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function U0(t,e,r){for(;t.hi;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}ce.prototype.uint64=function(e){var r=Ua.from(e);return this._push(U0,r.length(),r)};ce.prototype.int64=ce.prototype.uint64;ce.prototype.sint64=function(e){var r=Ua.from(e).zzEncode();return this._push(U0,r.length(),r)};ce.prototype.bool=function(e){return this._push(K0,1,e?1:0)};function q0(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}ce.prototype.fixed32=function(e){return this._push(q0,4,e>>>0)};ce.prototype.sfixed32=ce.prototype.fixed32;ce.prototype.fixed64=function(e){var r=Ua.from(e);return this._push(q0,4,r.lo)._push(q0,4,r.hi)};ce.prototype.sfixed64=ce.prototype.fixed64;ce.prototype.float=function(e){return this._push(Ft.float.writeFloatLE,4,e)};ce.prototype.double=function(e){return this._push(Ft.float.writeDoubleLE,8,e)};var nm=Ft.Array.prototype.set?function(e,r,i){r.set(e,i)}:function(e,r,i){for(var n=0;n<e.length;++n)r[i+n]=e[n]};ce.prototype.bytes=function(e){var r=e.length>>>0;if(!r)return this._push(K0,1,0);if(Ft.isString(e)){var i=ce.alloc(r=Gh.length(e));Gh.decode(e,i,0),e=i}return this.uint32(r)._push(nm,r,e)};ce.prototype.string=function(e){var r=Hh.length(e);return r?this.uint32(r)._push(Hh.write,r,e):this._push(K0,1,0)};ce.prototype.fork=function(){return this.states=new rm(this),this.head=this.tail=new Cs(M0,0,0),this.len=0,this};ce.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 Cs(M0,0,0),this.len=0),this};ce.prototype.ldelim=function(){var e=this.head,r=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=e.next,this.tail=r,this.len+=i),this};ce.prototype.finish=function(){for(var e=this.head.next,r=this.constructor.alloc(this.len),i=0;e;)e.fn(e.val,r,i),i+=e.len,e=e.next;return r};ce._configure=function(t){L0=t,ce.create=zh(),L0._configure()}});var $h=E((FT,Yh)=>{"use strict";Yh.exports=dr;var Wh=V0();(dr.prototype=Object.create(Wh.prototype)).constructor=dr;var di=pi();function dr(){Wh.call(this)}dr._configure=function(){dr.alloc=di._Buffer_allocUnsafe,dr.writeBytesBuffer=di.Buffer&&di.Buffer.prototype instanceof Uint8Array&&di.Buffer.prototype.set.name==="set"?function(e,r,i){r.set(e,i)}:function(e,r,i){if(e.copy)e.copy(r,i,0,e.length);else for(var n=0;n<e.length;)r[i++]=e[n++]}};dr.prototype.bytes=function(e){di.isString(e)&&(e=di._Buffer_from(e,"base64"));var r=e.length>>>0;return this.uint32(r),r&&this._push(dr.writeBytesBuffer,r,e),this};function sm(t,e,r){t.length<40?di.utf8.write(t,e,r):e.utf8Write?e.utf8Write(t,r):e.write(t,r)}dr.prototype.string=function(e){var r=di.Buffer.byteLength(e);return this.uint32(r),r&&this._push(sm,r,e),this};dr._configure()});var z0=E((UT,el)=>{"use strict";el.exports=je;var yr=pi(),G0,Qh=yr.LongBits,am=yr.utf8;function er(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function je(t){this.buf=t,this.pos=0,this.len=t.length}var Zh=typeof Uint8Array!="undefined"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new je(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new je(e);throw Error("illegal buffer")},Xh=function(){return yr.Buffer?function(r){return(je.create=function(n){return yr.Buffer.isBuffer(n)?new G0(n):Zh(n)})(r)}:Zh};je.create=Xh();je.prototype._slice=yr.Array.prototype.subarray||yr.Array.prototype.slice;je.prototype.uint32=function(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,er(this,10);return e}}();je.prototype.int32=function(){return this.uint32()|0};je.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function H0(){var t=new Qh(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 er(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 er(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")}je.prototype.bool=function(){return this.uint32()!==0};function qa(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}je.prototype.fixed32=function(){if(this.pos+4>this.len)throw er(this,4);return qa(this.buf,this.pos+=4)};je.prototype.sfixed32=function(){if(this.pos+4>this.len)throw er(this,4);return qa(this.buf,this.pos+=4)|0};function Jh(){if(this.pos+8>this.len)throw er(this,8);return new Qh(qa(this.buf,this.pos+=4),qa(this.buf,this.pos+=4))}je.prototype.float=function(){if(this.pos+4>this.len)throw er(this,4);var e=yr.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};je.prototype.double=function(){if(this.pos+8>this.len)throw er(this,4);var e=yr.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};je.prototype.bytes=function(){var e=this.uint32(),r=this.pos,i=this.pos+e;if(i>this.len)throw er(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(r,i):r===i?new this.buf.constructor(0):this._slice.call(this.buf,r,i)};je.prototype.string=function(){var e=this.bytes();return am.read(e,0,e.length)};je.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw er(this,e);this.pos+=e}else do if(this.pos>=this.len)throw er(this);while(this.buf[this.pos++]&128);return this};je.prototype.skipType=function(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};je._configure=function(t){G0=t,je.create=Xh(),G0._configure();var e=yr.Long?"toLong":"toNumber";yr.merge(je.prototype,{int64:function(){return H0.call(this)[e](!1)},uint64:function(){return H0.call(this)[e](!0)},sint64:function(){return H0.call(this).zzDecode()[e](!1)},fixed64:function(){return Jh.call(this)[e](!0)},sfixed64:function(){return Jh.call(this)[e](!1)}})}});var nl=E((qT,il)=>{"use strict";il.exports=Zi;var tl=z0();(Zi.prototype=Object.create(tl.prototype)).constructor=Zi;var rl=pi();function Zi(t){tl.call(this,t)}Zi._configure=function(){rl.Buffer&&(Zi.prototype._slice=rl.Buffer.prototype.slice)};Zi.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))};Zi._configure()});var al=E((VT,sl)=>{"use strict";sl.exports=Ts;var j0=pi();(Ts.prototype=Object.create(j0.EventEmitter.prototype)).constructor=Ts;function Ts(t,e,r){if(typeof t!="function")throw TypeError("rpcImpl must be a function");j0.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(r)}Ts.prototype.rpcCall=function t(e,r,i,n,s){if(!n)throw TypeError("request must be specified");var a=this;if(!s)return j0.asPromise(t,a,e,r,i,n);if(!a.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return a.rpcImpl(e,r[a.requestDelimited?"encodeDelimited":"encode"](n).finish(),function(f,u){if(f)return a.emit("error",f,e),s(f);if(u===null){a.end(!0);return}if(!(u instanceof i))try{u=i[a.responseDelimited?"decodeDelimited":"decode"](u)}catch(c){return a.emit("error",c,e),s(c)}return a.emit("data",u,e),s(null,u)})}catch(o){a.emit("error",o,e),setTimeout(function(){s(o)},0);return}};Ts.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var ul=E(ol=>{"use strict";var om=ol;om.Service=al()});var fl=E((HT,cl)=>{"use strict";cl.exports={}});var pl=E(ll=>{"use strict";var Tt=ll;Tt.build="minimal";Tt.Writer=V0();Tt.BufferWriter=$h();Tt.Reader=z0();Tt.BufferReader=nl();Tt.util=pi();Tt.rpc=ul();Tt.roots=fl();Tt.configure=hl;function hl(){Tt.util._configure(),Tt.Writer._configure(Tt.BufferWriter),Tt.Reader._configure(Tt.BufferReader)}hl()});var Xi=E((jT,dl)=>{"use strict";dl.exports=pl()});var Y0=E((WT,yl)=>{"use strict";var yi=Xi(),On=yi.Reader,W0=yi.Writer,ee=yi.util,Xe=yi.roots["libp2p-pubsub-rpc"]||(yi.roots["libp2p-pubsub-rpc"]={});Xe.RPC=function(){function t(e){if(this.subscriptions=[],this.msgs=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.subscriptions=ee.emptyArray,t.prototype.msgs=ee.emptyArray,t.encode=function(r,i){if(i||(i=W0.create()),r.subscriptions!=null&&r.subscriptions.length)for(var n=0;n<r.subscriptions.length;++n)Xe.RPC.SubOpts.encode(r.subscriptions[n],i.uint32(10).fork()).ldelim();if(r.msgs!=null&&r.msgs.length)for(var n=0;n<r.msgs.length;++n)Xe.RPC.Message.encode(r.msgs[n],i.uint32(18).fork()).ldelim();return i},t.decode=function(r,i){r instanceof On||(r=On.create(r));for(var n=i===void 0?r.len:r.pos+i,s=new Xe.RPC;r.pos<n;){var a=r.uint32();switch(a>>>3){case 1:s.subscriptions&&s.subscriptions.length||(s.subscriptions=[]),s.subscriptions.push(Xe.RPC.SubOpts.decode(r,r.uint32()));break;case 2:s.msgs&&s.msgs.length||(s.msgs=[]),s.msgs.push(Xe.RPC.Message.decode(r,r.uint32()));break;default:r.skipType(a&7);break}}return s},t.fromObject=function(r){if(r instanceof Xe.RPC)return r;var i=new Xe.RPC;if(r.subscriptions){if(!Array.isArray(r.subscriptions))throw TypeError(".RPC.subscriptions: array expected");i.subscriptions=[];for(var n=0;n<r.subscriptions.length;++n){if(typeof r.subscriptions[n]!="object")throw TypeError(".RPC.subscriptions: object expected");i.subscriptions[n]=Xe.RPC.SubOpts.fromObject(r.subscriptions[n])}}if(r.msgs){if(!Array.isArray(r.msgs))throw TypeError(".RPC.msgs: array expected");i.msgs=[];for(var n=0;n<r.msgs.length;++n){if(typeof r.msgs[n]!="object")throw TypeError(".RPC.msgs: object expected");i.msgs[n]=Xe.RPC.Message.fromObject(r.msgs[n])}}return i},t.toObject=function(r,i){i||(i={});var n={};if((i.arrays||i.defaults)&&(n.subscriptions=[],n.msgs=[]),r.subscriptions&&r.subscriptions.length){n.subscriptions=[];for(var s=0;s<r.subscriptions.length;++s)n.subscriptions[s]=Xe.RPC.SubOpts.toObject(r.subscriptions[s],i)}if(r.msgs&&r.msgs.length){n.msgs=[];for(var s=0;s<r.msgs.length;++s)n.msgs[s]=Xe.RPC.Message.toObject(r.msgs[s],i)}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,yi.util.toJSONOptions)},t.SubOpts=function(){function e(i){if(i)for(var n=Object.keys(i),s=0;s<n.length;++s)i[n[s]]!=null&&(this[n[s]]=i[n[s]])}e.prototype.subscribe=null,e.prototype.topicID=null;var r;return Object.defineProp