@libp2p/daemon-client 4.0.2 → 4.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/dist/index.min.js +4 -4
- package/dist/src/dht.d.ts.map +1 -1
- package/dist/src/pubsub.d.ts +1 -1
- package/dist/src/pubsub.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/dht.ts +2 -2
- package/src/index.ts +2 -2
- package/src/pubsub.ts +2 -2
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 Su=Object.create;var gr=Object.defineProperty;var xu=Object.getOwnPropertyDescriptor;var Au=Object.getOwnPropertyNames;var _u=Object.getPrototypeOf,Iu=Object.prototype.hasOwnProperty;var Nt=(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 new Error('Dynamic require of "'+r+'" is not supported')});var L=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),dt=(r,t)=>{for(var e in t)gr(r,e,{get:t[e],enumerable:!0})},ns=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Au(t))!Iu.call(r,i)&&i!==e&&gr(r,i,{get:()=>t[i],enumerable:!(n=xu(t,i))||n.enumerable});return r};var P=(r,t,e)=>(e=r!=null?Su(_u(r)):{},ns(t||!r||!r.__esModule?gr(e,"default",{value:r,enumerable:!0}):e,r)),Ru=r=>ns(gr({},"__esModule",{value:!0}),r);var Is=L((kp,_s)=>{_s.exports=Hn;var As=128,Ul=127,Fl=~Ul,Gl=Math.pow(2,31);function Hn(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Hn.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Gl;)t[e++]=r&255|As,r/=128;for(;r&Fl;)t[e++]=r&255|As,r>>>=7;return t[e]=r|0,Hn.bytes=e-n+1,t}});var Cs=L((Pp,Ds)=>{Ds.exports=qn;var $l=128,Rs=127;function qn(r,n){var e=0,n=n||0,i=0,s=n,a,h=r.length;do{if(s>=h||i>49)throw qn.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&Rs)<<i:(a&Rs)*Math.pow(2,i),i+=7}while(a>=$l);return qn.bytes=s-n,e}});var Ls=L((Mp,Bs)=>{var Vl=Math.pow(2,7),zl=Math.pow(2,14),Hl=Math.pow(2,21),ql=Math.pow(2,28),Kl=Math.pow(2,35),Yl=Math.pow(2,42),Wl=Math.pow(2,49),Zl=Math.pow(2,56),jl=Math.pow(2,63);Bs.exports=function(r){return r<Vl?1:r<zl?2:r<Hl?3:r<ql?4:r<Kl?5:r<Yl?6:r<Wl?7:r<Zl?8:r<jl?9:10}});var Tr=L((Up,Os)=>{Os.exports={encode:Is(),decode:Cs(),encodingLength:Ls()}});var _r=L((id,Hs)=>{"use strict";function zs(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function hf(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 zs(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),zs(new i,e)}}Hs.exports=hf});var eo=L((gd,to)=>{var Be=1e3,Le=Be*60,Oe=Le*60,de=Oe*24,Tf=de*7,Sf=de*365.25;to.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return xf(r);if(e==="number"&&isFinite(r))return t.long?_f(r):Af(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function xf(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*Sf;case"weeks":case"week":case"w":return e*Tf;case"days":case"day":case"d":return e*de;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Oe;case"minutes":case"minute":case"mins":case"min":case"m":return e*Le;case"seconds":case"second":case"secs":case"sec":case"s":return e*Be;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Af(r){var t=Math.abs(r);return t>=de?Math.round(r/de)+"d":t>=Oe?Math.round(r/Oe)+"h":t>=Le?Math.round(r/Le)+"m":t>=Be?Math.round(r/Be)+"s":r+"ms"}function _f(r){var t=Math.abs(r);return t>=de?Rr(r,t,de,"day"):t>=Oe?Rr(r,t,Oe,"hour"):t>=Le?Rr(r,t,Le,"minute"):t>=Be?Rr(r,t,Be,"second"):r+" ms"}function Rr(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var si=L((yd,ro)=>{function If(r){e.debug=e,e.default=e,e.coerce=l,e.disable=s,e.enable=i,e.enabled=a,e.humanize=eo(),e.destroy=d,Object.keys(r).forEach(f=>{e[f]=r[f]}),e.names=[],e.skips=[],e.formatters={};function t(f){let g=0;for(let b=0;b<f.length;b++)g=(g<<5)-g+f.charCodeAt(b),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(f){let g,b=null,S,w;function x(...B){if(!x.enabled)return;let I=x,C=Number(new Date),$=C-(g||C);I.diff=$,I.prev=g,I.curr=C,g=C,B[0]=e.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let Y=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(ct,it)=>{if(ct==="%%")return"%";Y++;let at=e.formatters[it];if(typeof at=="function"){let At=B[Y];ct=at.call(I,At),B.splice(Y,1),Y--}return ct}),e.formatArgs.call(I,B),(I.log||e.log).apply(I,B)}return x.namespace=f,x.useColors=e.useColors(),x.color=e.selectColor(f),x.extend=n,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>b!==null?b:(S!==e.namespaces&&(S=e.namespaces,w=e.enabled(f)),w),set:B=>{b=B}}),typeof e.init=="function"&&e.init(x),x}function n(f,g){let b=e(this.namespace+(typeof g>"u"?":":g)+f);return b.log=this.log,b}function i(f){e.save(f),e.namespaces=f,e.names=[],e.skips=[];let g,b=(typeof f=="string"?f:"").split(/[\s,]+/),S=b.length;for(g=0;g<S;g++)b[g]&&(f=b[g].replace(/\*/g,".*?"),f[0]==="-"?e.skips.push(new RegExp("^"+f.slice(1)+"$")):e.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...e.names.map(h),...e.skips.map(h).map(g=>"-"+g)].join(",");return e.enable(""),f}function a(f){if(f[f.length-1]==="*")return!0;let g,b;for(g=0,b=e.skips.length;g<b;g++)if(e.skips[g].test(f))return!1;for(g=0,b=e.names.length;g<b;g++)if(e.names[g].test(f))return!0;return!1}function h(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function l(f){return f instanceof Error?f.stack||f.message:f}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}ro.exports=If});var no=L((mt,Dr)=>{mt.formatArgs=Df;mt.save=Cf;mt.load=Bf;mt.useColors=Rf;mt.storage=Lf();mt.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`."))}})();mt.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 Rf(){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 Df(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Dr.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)}mt.log=console.debug||console.log||(()=>{});function Cf(r){try{r?mt.storage.setItem("debug",r):mt.storage.removeItem("debug")}catch{}}function Bf(){let r;try{r=mt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Lf(){try{return localStorage}catch{}}Dr.exports=si()(mt);var{formatters:Of}=Dr.exports;Of.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var so=L((wd,io)=>{"use strict";io.exports=(r,t=process.argv)=>{let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}});var ao=L((bd,co)=>{"use strict";var Nf=Nt("os"),oo=Nt("tty"),vt=so(),{env:X}=process,te;vt("no-color")||vt("no-colors")||vt("color=false")||vt("color=never")?te=0:(vt("color")||vt("colors")||vt("color=true")||vt("color=always"))&&(te=1);"FORCE_COLOR"in X&&(X.FORCE_COLOR==="true"?te=1:X.FORCE_COLOR==="false"?te=0:te=X.FORCE_COLOR.length===0?1:Math.min(parseInt(X.FORCE_COLOR,10),3));function oi(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function ci(r,t){if(te===0)return 0;if(vt("color=16m")||vt("color=full")||vt("color=truecolor"))return 3;if(vt("color=256"))return 2;if(r&&!t&&te===void 0)return 0;let e=te||0;if(X.TERM==="dumb")return e;if(process.platform==="win32"){let n=Nf.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in X)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in X)||X.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in X)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(X.TEAMCITY_VERSION)?1:0;if(X.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in X){let n=parseInt((X.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(X.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(X.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(X.TERM)||"COLORTERM"in X?1:e}function kf(r){let t=ci(r,r&&r.isTTY);return oi(t)}co.exports={supportsColor:kf,stdout:oi(ci(!0,oo.isatty(1))),stderr:oi(ci(!0,oo.isatty(2)))}});var lo=L((Q,Br)=>{var Pf=Nt("tty"),Cr=Nt("util");Q.init=zf;Q.log=Gf;Q.formatArgs=Uf;Q.save=$f;Q.load=Vf;Q.useColors=Mf;Q.destroy=Cr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Q.colors=[6,2,3,4,5,1];try{let r=ao();r&&(r.stderr||r).level>=2&&(Q.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{}Q.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 Mf(){return"colors"in Q.inspectOpts?Boolean(Q.inspectOpts.colors):Pf.isatty(process.stderr.fd)}function Uf(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 vu=Object.create;var gr=Object.defineProperty;var Tu=Object.getOwnPropertyDescriptor;var Su=Object.getOwnPropertyNames;var xu=Object.getPrototypeOf,Au=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 new Error('Dynamic require of "'+r+'" is not supported')});var L=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),dt=(r,t)=>{for(var e in t)gr(r,e,{get:t[e],enumerable:!0})},rs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Su(t))!Au.call(r,i)&&i!==e&&gr(r,i,{get:()=>t[i],enumerable:!(n=Tu(t,i))||n.enumerable});return r};var P=(r,t,e)=>(e=r!=null?vu(xu(r)):{},rs(t||!r||!r.__esModule?gr(e,"default",{value:r,enumerable:!0}):e,r)),_u=r=>rs(gr({},"__esModule",{value:!0}),r);var _s=L((Op,As)=>{As.exports=Hn;var xs=128,Pl=127,Ml=~Pl,Ul=Math.pow(2,31);function Hn(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Hn.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Ul;)t[e++]=r&255|xs,r/=128;for(;r&Ml;)t[e++]=r&255|xs,r>>>=7;return t[e]=r|0,Hn.bytes=e-n+1,t}});var Ds=L((kp,Rs)=>{Rs.exports=qn;var Fl=128,Is=127;function qn(r,n){var e=0,n=n||0,i=0,s=n,a,h=r.length;do{if(s>=h||i>49)throw qn.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&Is)<<i:(a&Is)*Math.pow(2,i),i+=7}while(a>=Fl);return qn.bytes=s-n,e}});var Bs=L((Pp,Cs)=>{var Gl=Math.pow(2,7),$l=Math.pow(2,14),Vl=Math.pow(2,21),zl=Math.pow(2,28),Hl=Math.pow(2,35),ql=Math.pow(2,42),Kl=Math.pow(2,49),Yl=Math.pow(2,56),Wl=Math.pow(2,63);Cs.exports=function(r){return r<Gl?1:r<$l?2:r<Vl?3:r<zl?4:r<Hl?5:r<ql?6:r<Kl?7:r<Yl?8:r<Wl?9:10}});var Tr=L((Mp,Ls)=>{Ls.exports={encode:_s(),decode:Ds(),encodingLength:Bs()}});var _r=L((nd,zs)=>{"use strict";function Vs(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function lf(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 Vs(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),Vs(new i,e)}}zs.exports=lf});var to=L((md,Qs)=>{var Ce=1e3,Be=Ce*60,Le=Be*60,pe=Le*24,Ef=pe*7,vf=pe*365.25;Qs.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Tf(r);if(e==="number"&&isFinite(r))return t.long?xf(r):Sf(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Tf(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*vf;case"weeks":case"week":case"w":return e*Ef;case"days":case"day":case"d":return e*pe;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Le;case"minutes":case"minute":case"mins":case"min":case"m":return e*Be;case"seconds":case"second":case"secs":case"sec":case"s":return e*Ce;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Sf(r){var t=Math.abs(r);return t>=pe?Math.round(r/pe)+"d":t>=Le?Math.round(r/Le)+"h":t>=Be?Math.round(r/Be)+"m":t>=Ce?Math.round(r/Ce)+"s":r+"ms"}function xf(r){var t=Math.abs(r);return t>=pe?Rr(r,t,pe,"day"):t>=Le?Rr(r,t,Le,"hour"):t>=Be?Rr(r,t,Be,"minute"):t>=Ce?Rr(r,t,Ce,"second"):r+" ms"}function Rr(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var si=L((gd,eo)=>{function Af(r){e.debug=e,e.default=e,e.coerce=l,e.disable=s,e.enable=i,e.enabled=a,e.humanize=to(),e.destroy=d,Object.keys(r).forEach(f=>{e[f]=r[f]}),e.names=[],e.skips=[],e.formatters={};function t(f){let g=0;for(let w=0;w<f.length;w++)g=(g<<5)-g+f.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(f){let g,w=null,S,b;function x(...B){if(!x.enabled)return;let I=x,C=Number(new Date),$=C-(g||C);I.diff=$,I.prev=g,I.curr=C,g=C,B[0]=e.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let Y=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(ct,it)=>{if(ct==="%%")return"%";Y++;let at=e.formatters[it];if(typeof at=="function"){let xt=B[Y];ct=at.call(I,xt),B.splice(Y,1),Y--}return ct}),e.formatArgs.call(I,B),(I.log||e.log).apply(I,B)}return x.namespace=f,x.useColors=e.useColors(),x.color=e.selectColor(f),x.extend=n,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(S!==e.namespaces&&(S=e.namespaces,b=e.enabled(f)),b),set:B=>{w=B}}),typeof e.init=="function"&&e.init(x),x}function n(f,g){let w=e(this.namespace+(typeof g>"u"?":":g)+f);return w.log=this.log,w}function i(f){e.save(f),e.namespaces=f,e.names=[],e.skips=[];let g,w=(typeof f=="string"?f:"").split(/[\s,]+/),S=w.length;for(g=0;g<S;g++)w[g]&&(f=w[g].replace(/\*/g,".*?"),f[0]==="-"?e.skips.push(new RegExp("^"+f.slice(1)+"$")):e.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...e.names.map(h),...e.skips.map(h).map(g=>"-"+g)].join(",");return e.enable(""),f}function a(f){if(f[f.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(f))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(f))return!0;return!1}function h(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function l(f){return f instanceof Error?f.stack||f.message:f}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}eo.exports=Af});var ro=L((mt,Dr)=>{mt.formatArgs=If;mt.save=Rf;mt.load=Df;mt.useColors=_f;mt.storage=Cf();mt.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`."))}})();mt.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 _f(){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 If(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Dr.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)}mt.log=console.debug||console.log||(()=>{});function Rf(r){try{r?mt.storage.setItem("debug",r):mt.storage.removeItem("debug")}catch{}}function Df(){let r;try{r=mt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Cf(){try{return localStorage}catch{}}Dr.exports=si()(mt);var{formatters:Bf}=Dr.exports;Bf.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var io=L((yd,no)=>{"use strict";no.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 oo=L((bd,so)=>{"use strict";var Lf=Ft("os"),Dt=io(),tt=process.env,Ne;Dt("no-color")||Dt("no-colors")||Dt("color=false")?Ne=!1:(Dt("color")||Dt("colors")||Dt("color=true")||Dt("color=always"))&&(Ne=!0);"FORCE_COLOR"in tt&&(Ne=tt.FORCE_COLOR.length===0||parseInt(tt.FORCE_COLOR,10)!==0);function Nf(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Of(r){if(Ne===!1)return 0;if(Dt("color=16m")||Dt("color=full")||Dt("color=truecolor"))return 3;if(Dt("color=256"))return 2;if(r&&!r.isTTY&&Ne!==!0)return 0;let t=Ne?1:0;if(process.platform==="win32"){let e=Lf.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 tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in tt)||tt.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(tt.TEAMCITY_VERSION)?1:0;if(tt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in tt){let e=parseInt((tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(tt.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(tt.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(tt.TERM)||"COLORTERM"in tt?1:(tt.TERM==="dumb",t)}function oi(r){let t=Of(r);return Nf(t)}so.exports={supportsColor:oi,stdout:oi(process.stdout),stderr:oi(process.stderr)}});var ao=L((J,Br)=>{var kf=Ft("tty"),Cr=Ft("util");J.init=Vf;J.log=Ff;J.formatArgs=Mf;J.save=Gf;J.load=$f;J.useColors=Pf;J.destroy=Cr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");J.colors=[6,2,3,4,5,1];try{let r=oo();r&&(r.stderr||r).level>=2&&(J.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{}J.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 Pf(){return"colors"in J.inspectOpts?Boolean(J.inspectOpts.colors):kf.isatty(process.stderr.fd)}function Mf(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(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+s),r.push(i+"m+"+Br.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=
|
|
5
|
-
`)}function
|
|
6
|
-
`).map(t=>t.trim()).join(" ")};uo.O=function(r){return this.inspectOpts.colors=this.useColors,Cr.inspect(r,this.inspectOpts)}});var fo=L((Ed,ai)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ai.exports=no():ai.exports=lo()});var Lr=L((Ad,ho)=>{ho.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 mo=L((_d,po)=>{po.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 ui=L((Id,go)=>{var Hf=mo();go.exports=r=>async t=>{t=Hf(t);let e=I=>{typeof I.return=="function"&&I.return()},n=null,i=null,s=I=>{n=I,i&&i(I),e(t)},a=null,h=!1,l=()=>{h=!0,a&&a()},d=null,f=!1,g=()=>{f=!0,d&&d()},b=null,S=()=>{b&&b()},w=()=>new Promise((I,C)=>{a=b=I,i=C,r.once("drain",S)}),x=()=>(e(t),new Promise((I,C)=>{if(h||f||n)return I();d=a=I,i=C})),B=()=>{r.removeListener("error",s),r.removeListener("close",l),r.removeListener("finish",g),r.removeListener("drain",S)};r.once("error",s),r.once("close",l),r.once("finish",g);try{for await(let I of t){if(!r.writable||r.destroyed||n)break;r.write(I)===!1&&await w()}}catch(I){n||r.destroy(),n=I}try{if(r.writable&&r.end(),await x(),n)throw n}finally{B()}}});var li=L((Rd,yo)=>{var qf=ui(),Kf=Lr();yo.exports=r=>({sink:qf(r),source:Kf(r)})});var bo=L((Dd,wo)=>{var Yf=li();wo.exports=r=>async function*(t){let e=Yf(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var Eo=L((Cd,Ne)=>{Ne.exports=Lr();Ne.exports.source=Lr();Ne.exports.sink=ui();Ne.exports.transform=bo();Ne.exports.duplex=li()});var hi=L((kr,So)=>{(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 E=c*this[o++]+u[p]+m;m=Math.floor(E/67108864),u[p++]=E&67108863}return m}function a(o,c,u,p,m,y){for(var E=c&32767,T=c>>15;--y>=0;){var k=this[o]&32767,j=this[o++]>>15,wt=T*k+j*E;k=E*k+((wt&32767)<<15)+u[p]+(m&1073741823),m=(k>>>30)+(wt>>>15)+T*j+(m>>>30),u[p++]=k&1073741823}return m}function h(o,c,u,p,m,y){for(var E=c&16383,T=c>>14;--y>=0;){var k=this[o]&16383,j=this[o++]>>14,wt=T*k+j*E;k=E*k+((wt&16383)<<14)+u[p]+m,m=(k>>28)+(wt>>14)+T*j,u[p++]=k&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=h,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 f="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,b,S;for(b="0".charCodeAt(0),S=0;S<=9;++S)g[b++]=S;for(b="a".charCodeAt(0),S=10;S<36;++S)g[b++]=S;for(b="A".charCodeAt(0),S=10;S<36;++S)g[b++]=S;function w(o){return f.charAt(o)}function x(o,c){var u=g[o.charCodeAt(c)];return u??-1}function B(o){for(var c=this.t-1;c>=0;--c)o[c]=this[c];o.t=this.t,o.s=this.s}function I(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 C(o){var c=i();return c.fromInt(o),c}function $(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 E=u==8?o[p]&255:x(o,p);if(E<0){o.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=E:y+u>this.DB?(this[this.t-1]|=(E&(1<<this.DB-y)-1)<<y,this[this.t++]=E>>this.DB-y):this[this.t-1]|=E<<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 Y(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function ft(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="",E=this.t,T=this.DB-E*this.DB%c;if(E-- >0)for(T<this.DB&&(p=this[E]>>T)>0&&(m=!0,y=w(p));E>=0;)T<c?(p=(this[E]&(1<<T)-1)<<c-T,p|=this[--E]>>(T+=this.DB-c)):(p=this[E]>>(T-=c)&u,T<=0&&(T+=this.DB,--E)),p>0&&(m=!0),m&&(y+=w(p));return m?y:"0"}function ct(){var o=i();return n.ZERO.subTo(this,o),o}function it(){return this.s<0?this.negate():this}function at(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 At(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 zc(){return this.t<=0?0:this.DB*(this.t-1)+At(this[this.t-1]^this.s&this.DM)}function Hc(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 qc(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 Kc(o,c){var u=o%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(o/this.DB),E=this.s<<u&this.DM,T;for(T=this.t-1;T>=0;--T)c[T+y+1]=this[T]>>p|E,E=(this[T]&m)<<u;for(T=y-1;T>=0;--T)c[T]=0;c[y]=E,c.t=this.t+y+1,c.s=this.s,c.clamp()}function Yc(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 E=u+1;E<this.t;++E)c[E-u-1]|=(this[E]&y)<<m,c[E-u]=this[E]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function Wc(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 jc(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 Xc(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(),E=this.s,T=o.s,k=this.DB-At(p[p.t-1]);k>0?(p.lShiftTo(k,y),m.lShiftTo(k,u)):(p.copyTo(y),m.copyTo(u));var j=y.t,wt=y[j-1];if(wt!=0){var pt=wt*(1<<this.F1)+(j>1?y[j-2]>>this.F2:0),Ft=this.FV/pt,dr=(1<<this.F1)/pt,It=1<<this.F2,Rt=u.t,mr=Rt-j,Wt=c??i();for(y.dlShiftTo(mr,Wt),u.compareTo(Wt)>=0&&(u[u.t++]=1,u.subTo(Wt,u)),n.ONE.dlShiftTo(j,Wt),Wt.subTo(y,y);y.t<j;)y[y.t++]=0;for(;--mr>=0;){var wn=u[--Rt]==wt?this.DM:Math.floor(u[Rt]*Ft+(u[Rt-1]+It)*dr);if((u[Rt]+=y.am(0,wn,u,mr,0,j))<wn)for(y.dlShiftTo(mr,Wt),u.subTo(Wt,u);u[Rt]<--wn;)u.subTo(Wt,u)}c!=null&&(u.drShiftTo(j,c),E!=T&&n.ZERO.subTo(c,c)),u.t=j,u.clamp(),k>0&&u.rShiftTo(k,u),E<0&&n.ZERO.subTo(u,u)}}}function Jc(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 oe(o){this.m=o}function Qc(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function ta(o){return o}function ea(o){o.divRemTo(this.m,null,o)}function ra(o,c,u){o.multiplyTo(c,u),this.reduce(u)}function na(o,c){o.squareTo(c),this.reduce(c)}oe.prototype.convert=Qc,oe.prototype.revert=ta,oe.prototype.reduce=ea,oe.prototype.mulTo=ra,oe.prototype.sqrTo=na;function ia(){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 ce(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 sa(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 oa(o){var c=i();return o.copyTo(c),this.reduce(c),c}function ca(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 aa(o,c){o.squareTo(c),this.reduce(c)}function ua(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ce.prototype.convert=sa,ce.prototype.revert=oa,ce.prototype.reduce=ca,ce.prototype.mulTo=ua,ce.prototype.sqrTo=aa;function la(){return(this.t>0?this[0]&1:this.s)==0}function fa(o,c){if(o>4294967295||o<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=At(o)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(o&1<<y)>0)c.mulTo(p,m,u);else{var E=u;u=p,p=E}return c.revert(u)}function ha(o,c){var u;return o<256||c.isEven()?u=new oe(c):u=new ce(c),this.exp(o,u)}n.prototype.copyTo=B,n.prototype.fromInt=I,n.prototype.fromString=$,n.prototype.clamp=Y,n.prototype.dlShiftTo=Hc,n.prototype.drShiftTo=qc,n.prototype.lShiftTo=Kc,n.prototype.rShiftTo=Yc,n.prototype.subTo=Wc,n.prototype.multiplyTo=Zc,n.prototype.squareTo=jc,n.prototype.divRemTo=Xc,n.prototype.invDigit=ia,n.prototype.isEven=la,n.prototype.exp=fa,n.prototype.toString=ft,n.prototype.negate=ct,n.prototype.abs=it,n.prototype.compareTo=at,n.prototype.bitLength=zc,n.prototype.mod=Jc,n.prototype.modPowInt=ha,n.ZERO=C(0),n.ONE=C(1);function pa(){var o=i();return this.copyTo(o),o}function da(){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 ma(){return this.t==0?this.s:this[0]<<24>>24}function ga(){return this.t==0?this.s:this[0]<<16>>16}function ya(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function wa(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function ba(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=C(u),m=i(),y=i(),E="";for(this.divRemTo(p,m,y);m.signum()>0;)E=(u+y.intValue()).toString(o).substr(1)+E,m.divRemTo(p,m,y);return y.intValue().toString(o)+E}function Ea(o,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,E=0,T=0;T<o.length;++T){var k=x(o,T);if(k<0){o.charAt(T)=="-"&&this.signum()==0&&(m=!0);continue}E=c*E+k,++y>=u&&(this.dMultiply(p),this.dAddOffset(E,0),y=0,E=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(E,0)),m&&n.ZERO.subTo(this,this)}function va(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),dn,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 Ta(){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 Sa(o){return this.compareTo(o)==0}function xa(o){return this.compareTo(o)<0?this:o}function Aa(o){return this.compareTo(o)>0?this:o}function _a(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 Ia(o,c){return o&c}function Ra(o){var c=i();return this.bitwiseTo(o,Ia,c),c}function dn(o,c){return o|c}function Da(o){var c=i();return this.bitwiseTo(o,dn,c),c}function Xi(o,c){return o^c}function Ca(o){var c=i();return this.bitwiseTo(o,Xi,c),c}function Ji(o,c){return o&~c}function Ba(o){var c=i();return this.bitwiseTo(o,Ji,c),c}function La(){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 Oa(o){var c=i();return o<0?this.rShiftTo(-o,c):this.lShiftTo(o,c),c}function Na(o){var c=i();return o<0?this.lShiftTo(-o,c):this.rShiftTo(o,c),c}function ka(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 Pa(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+ka(this[o]);return this.s<0?this.t*this.DB:-1}function Ma(o){for(var c=0;o!=0;)o&=o-1,++c;return c}function Ua(){for(var o=0,c=this.s&this.DM,u=0;u<this.t;++u)o+=Ma(this[u]^c);return o}function Fa(o){var c=Math.floor(o/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<o%this.DB)!=0}function Ga(o,c){var u=n.ONE.shiftLeft(o);return this.bitwiseTo(u,c,u),u}function $a(o){return this.changeBit(o,dn)}function Va(o){return this.changeBit(o,Ji)}function za(o){return this.changeBit(o,Xi)}function Ha(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 qa(o){var c=i();return this.addTo(o,c),c}function Ka(o){var c=i();return this.subTo(o,c),c}function Ya(o){var c=i();return this.multiplyTo(o,c),c}function Wa(){var o=i();return this.squareTo(o),o}function Za(o){var c=i();return this.divRemTo(o,c,null),c}function ja(o){var c=i();return this.divRemTo(o,null,c),c}function Xa(o){var c=i(),u=i();return this.divRemTo(o,c,u),new Array(c,u)}function Ja(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 qe(){}function Qi(o){return o}function tu(o,c,u){o.multiplyTo(c,u)}function eu(o,c){o.squareTo(c)}qe.prototype.convert=Qi,qe.prototype.revert=Qi,qe.prototype.mulTo=tu,qe.prototype.sqrTo=eu;function ru(o){return this.exp(o,new qe)}function nu(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 iu(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 ae(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 su(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 ou(o){return o}function cu(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 au(o,c){o.squareTo(c),this.reduce(c)}function uu(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ae.prototype.convert=su,ae.prototype.revert=ou,ae.prototype.reduce=cu,ae.prototype.mulTo=uu,ae.prototype.sqrTo=au;function lu(o,c){var u=o.bitLength(),p,m=C(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 oe(c):c.isEven()?y=new ae(c):y=new ce(c);var E=new Array,T=3,k=p-1,j=(1<<p)-1;if(E[1]=y.convert(this),p>1){var wt=i();for(y.sqrTo(E[1],wt);T<=j;)E[T]=i(),y.mulTo(wt,E[T-2],E[T]),T+=2}var pt=o.t-1,Ft,dr=!0,It=i(),Rt;for(u=At(o[pt])-1;pt>=0;){for(u>=k?Ft=o[pt]>>u-k&j:(Ft=(o[pt]&(1<<u+1)-1)<<k-u,pt>0&&(Ft|=o[pt-1]>>this.DB+u-k)),T=p;!(Ft&1);)Ft>>=1,--T;if((u-=T)<0&&(u+=this.DB,--pt),dr)E[Ft].copyTo(m),dr=!1;else{for(;T>1;)y.sqrTo(m,It),y.sqrTo(It,m),T-=2;T>0?y.sqrTo(m,It):(Rt=m,m=It,It=Rt),y.mulTo(It,E[Ft],m)}for(;pt>=0&&!(o[pt]&1<<u);)y.sqrTo(m,It),Rt=m,m=It,It=Rt,--u<0&&(u=this.DB-1,--pt)}return y.revert(m)}function fu(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 hu(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 pu(o){var c=o.isEven();if(this.isEven()&&c||o.signum()==0)return n.ZERO;for(var u=o.clone(),p=this.clone(),m=C(1),y=C(0),E=C(0),T=C(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?((!E.isEven()||!T.isEven())&&(E.addTo(this,E),T.subTo(o,T)),E.rShiftTo(1,E)):T.isEven()||T.subTo(o,T),T.rShiftTo(1,T);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(E,m),y.subTo(T,y)):(p.subTo(u,p),c&&E.subTo(m,E),T.subTo(y,T))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(T.compareTo(o)>=0)return T.subtract(o);if(T.signum()<0)T.addTo(o,T);else return T;return T.signum()<0?T.add(o):T}var st=[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],du=(1<<26)/st[st.length-1];function mu(o){var c,u=this.abs();if(u.t==1&&u[0]<=st[st.length-1]){for(c=0;c<st.length;++c)if(u[0]==st[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<st.length;){for(var p=st[c],m=c+1;m<st.length&&p<du;)p*=st[m++];for(p=u.modInt(p);c<m;)if(p%st[c++]==0)return!1}return u.millerRabin(o)}function gu(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>st.length&&(o=st.length);for(var m=i(),y=0;y<o;++y){m.fromInt(st[Math.floor(Math.random()*st.length)]);var E=m.modPow(p,this);if(E.compareTo(n.ONE)!=0&&E.compareTo(c)!=0){for(var T=1;T++<u&&E.compareTo(c)!=0;)if(E=E.modPowInt(2,this),E.compareTo(n.ONE)==0)return!1;if(E.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=ya,n.prototype.toRadix=ba,n.prototype.fromRadix=Ea,n.prototype.fromNumber=va,n.prototype.bitwiseTo=_a,n.prototype.changeBit=Ga,n.prototype.addTo=Ha,n.prototype.dMultiply=Ja,n.prototype.dAddOffset=Qa,n.prototype.multiplyLowerTo=nu,n.prototype.multiplyUpperTo=iu,n.prototype.modInt=hu,n.prototype.millerRabin=gu,n.prototype.clone=pa,n.prototype.intValue=da,n.prototype.byteValue=ma,n.prototype.shortValue=ga,n.prototype.signum=wa,n.prototype.toByteArray=Ta,n.prototype.equals=Sa,n.prototype.min=xa,n.prototype.max=Aa,n.prototype.and=Ra,n.prototype.or=Da,n.prototype.xor=Ca,n.prototype.andNot=Ba,n.prototype.not=La,n.prototype.shiftLeft=Oa,n.prototype.shiftRight=Na,n.prototype.getLowestSetBit=Pa,n.prototype.bitCount=Ua,n.prototype.testBit=Fa,n.prototype.setBit=$a,n.prototype.clearBit=Va,n.prototype.flipBit=za,n.prototype.add=qa,n.prototype.subtract=Ka,n.prototype.multiply=Ya,n.prototype.divide=Za,n.prototype.remainder=ja,n.prototype.divideAndRemainder=Xa,n.prototype.modPow=lu,n.prototype.modInverse=pu,n.prototype.pow=ru,n.prototype.gcd=fu,n.prototype.isProbablePrime=mu,n.prototype.square=Wa,n.prototype.Barrett=ae;var pr,ht,Z;function yu(o){ht[Z++]^=o&255,ht[Z++]^=o>>8&255,ht[Z++]^=o>>16&255,ht[Z++]^=o>>24&255,Z>=yn&&(Z-=yn)}function ts(){yu(new Date().getTime())}if(ht==null){ht=new Array,Z=0;var _t;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var es=new Uint8Array(32);for(window.crypto.getRandomValues(es),_t=0;_t<32;++_t)ht[Z++]=es[_t]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var rs=window.crypto.random(32);for(_t=0;_t<rs.length;++_t)ht[Z++]=rs.charCodeAt(_t)&255}}for(;Z<yn;)_t=Math.floor(65536*Math.random()),ht[Z++]=_t>>>8,ht[Z++]=_t&255;Z=0,ts()}function wu(){if(pr==null){for(ts(),pr=Tu(),pr.init(ht),Z=0;Z<ht.length;++Z)ht[Z]=0;Z=0}return pr.next()}function bu(o){var c;for(c=0;c<o.length;++c)o[c]=wu()}function mn(){}mn.prototype.nextBytes=bu;function gn(){this.i=0,this.j=0,this.S=new Array}function Eu(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 vu(){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]}gn.prototype.init=Eu,gn.prototype.next=vu;function Tu(){return new gn}var yn=256;typeof kr<"u"?kr=So.exports={default:n,BigInteger:n,SecureRandom:mn}:this.jsbn={BigInteger:n,SecureRandom:mn}}).call(kr)});var nr=L(Pr=>{(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,h){return t.apply(null,[a].concat(h||[]))}function n(a,h){var l=1,d=a.length,f,g="",b,S,w,x,B,I,C,$;for(b=0;b<d;b++)if(typeof a[b]=="string")g+=a[b];else if(typeof a[b]=="object"){if(w=a[b],w.keys)for(f=h[l],S=0;S<w.keys.length;S++){if(f==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',w.keys[S],w.keys[S-1]));f=f[w.keys[S]]}else w.param_no?f=h[w.param_no]:f=h[l++];if(r.not_type.test(w.type)&&r.not_primitive.test(w.type)&&f instanceof Function&&(f=f()),r.numeric_arg.test(w.type)&&typeof f!="number"&&isNaN(f))throw new TypeError(t("[sprintf] expecting number but found %T",f));switch(r.number.test(w.type)&&(C=f>=0),w.type){case"b":f=parseInt(f,10).toString(2);break;case"c":f=String.fromCharCode(parseInt(f,10));break;case"d":case"i":f=parseInt(f,10);break;case"j":f=JSON.stringify(f,null,w.width?parseInt(w.width):0);break;case"e":f=w.precision?parseFloat(f).toExponential(w.precision):parseFloat(f).toExponential();break;case"f":f=w.precision?parseFloat(f).toFixed(w.precision):parseFloat(f);break;case"g":f=w.precision?String(Number(f.toPrecision(w.precision))):parseFloat(f);break;case"o":f=(parseInt(f,10)>>>0).toString(8);break;case"s":f=String(f),f=w.precision?f.substring(0,w.precision):f;break;case"t":f=String(!!f),f=w.precision?f.substring(0,w.precision):f;break;case"T":f=Object.prototype.toString.call(f).slice(8,-1).toLowerCase(),f=w.precision?f.substring(0,w.precision):f;break;case"u":f=parseInt(f,10)>>>0;break;case"v":f=f.valueOf(),f=w.precision?f.substring(0,w.precision):f;break;case"x":f=(parseInt(f,10)>>>0).toString(16);break;case"X":f=(parseInt(f,10)>>>0).toString(16).toUpperCase();break}r.json.test(w.type)?g+=f:(r.number.test(w.type)&&(!C||w.sign)?($=C?"+":"-",f=f.toString().replace(r.sign,"")):$="",B=w.pad_char?w.pad_char==="0"?"0":w.pad_char.charAt(1):" ",I=w.width-($+f).length,x=w.width&&I>0?B.repeat(I):"",g+=w.align?$+f+x:B==="0"?$+x+f:x+$+f)}return g}var i=Object.create(null);function s(a){if(i[a])return i[a];for(var h=a,l,d=[],f=0;h;){if((l=r.text.exec(h))!==null)d.push(l[0]);else if((l=r.modulo.exec(h))!==null)d.push("%");else if((l=r.placeholder.exec(h))!==null){if(l[2]){f|=1;var g=[],b=l[2],S=[];if((S=r.key.exec(b))!==null)for(g.push(S[1]);(b=b.substring(S[0].length))!=="";)if((S=r.key_access.exec(b))!==null)g.push(S[1]);else if((S=r.index_access.exec(b))!==null)g.push(S[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 f|=2;if(f===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");h=h.substring(l[0].length)}return i[a]=d}typeof Pr<"u"&&(Pr.sprintf=t,Pr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var Vo=L((bm,$o)=>{"use strict";$o.exports=uh;function uh(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(h,l){e[n]=function(f){if(s)if(s=!1,f)l(f);else{for(var g=new Array(arguments.length-1),b=0;b<g.length;)g[b++]=arguments[b];h.apply(null,g)}};try{r.apply(t||null,e)}catch(d){s&&(s=!1,l(d))}})}});var Ko=L(qo=>{"use strict";var Hr=qo;Hr.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 Ge=new Array(64),Ho=new Array(123);for(Bt=0;Bt<64;)Ho[Ge[Bt]=Bt<26?Bt+65:Bt<52?Bt+71:Bt<62?Bt-4:Bt-59|43]=Bt++;var Bt;Hr.encode=function(t,e,n){for(var i=null,s=[],a=0,h=0,l;e<n;){var d=t[e++];switch(h){case 0:s[a++]=Ge[d>>2],l=(d&3)<<4,h=1;break;case 1:s[a++]=Ge[l|d>>4],l=(d&15)<<2,h=2;break;case 2:s[a++]=Ge[l|d>>6],s[a++]=Ge[d&63],h=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return h&&(s[a++]=Ge[l],s[a++]=61,h===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 zo="invalid encoding";Hr.decode=function(t,e,n){for(var i=n,s=0,a,h=0;h<t.length;){var l=t.charCodeAt(h++);if(l===61&&s>1)break;if((l=Ho[l])===void 0)throw Error(zo);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(zo);return n-i};Hr.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var Wo=L((vm,Yo)=>{"use strict";Yo.exports=qr;function qr(){this._listeners={}}qr.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};qr.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};qr.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 ec=L((Tm,tc)=>{"use strict";tc.exports=Zo(Zo);function Zo(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(l,d,f){t[0]=l,d[f]=e[0],d[f+1]=e[1],d[f+2]=e[2],d[f+3]=e[3]}function s(l,d,f){t[0]=l,d[f]=e[3],d[f+1]=e[2],d[f+2]=e[1],d[f+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 h(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:h,r.readFloatBE=n?h:a}():function(){function t(n,i,s,a){var h=i<0?1:0;if(h&&(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((h<<31|2139095040)>>>0,s,a);else if(i<11754943508222875e-54)n((h<<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((h<<31|l+127<<23|d)>>>0,s,a)}}r.writeFloatLE=t.bind(null,jo),r.writeFloatBE=t.bind(null,Xo);function e(n,i,s){var a=n(i,s),h=(a>>31)*2+1,l=a>>>23&255,d=a&8388607;return l===255?d?NaN:h*(1/0):l===0?h*1401298464324817e-60*d:h*Math.pow(2,l-150)*(d+8388608)}r.readFloatLE=e.bind(null,Jo),r.readFloatBE=e.bind(null,Qo)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(l,d,f){t[0]=l,d[f]=e[0],d[f+1]=e[1],d[f+2]=e[2],d[f+3]=e[3],d[f+4]=e[4],d[f+5]=e[5],d[f+6]=e[6],d[f+7]=e[7]}function s(l,d,f){t[0]=l,d[f]=e[7],d[f+1]=e[6],d[f+2]=e[5],d[f+3]=e[4],d[f+4]=e[3],d[f+5]=e[2],d[f+6]=e[1],d[f+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 h(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:h,r.readDoubleBE=n?h:a}():function(){function t(n,i,s,a,h,l){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,h,l+i),n(1/a>0?0:2147483648,h,l+s);else if(isNaN(a))n(0,h,l+i),n(2146959360,h,l+s);else if(a>17976931348623157e292)n(0,h,l+i),n((d<<31|2146435072)>>>0,h,l+s);else{var f;if(a<22250738585072014e-324)f=a/5e-324,n(f>>>0,h,l+i),n((d<<31|f/4294967296)>>>0,h,l+s);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),f=a*Math.pow(2,-g),n(f*4503599627370496>>>0,h,l+i),n((d<<31|g+1023<<20|f*1048576&1048575)>>>0,h,l+s)}}}r.writeDoubleLE=t.bind(null,jo,0,4),r.writeDoubleBE=t.bind(null,Xo,4,0);function e(n,i,s,a,h){var l=n(a,h+i),d=n(a,h+s),f=(d>>31)*2+1,g=d>>>20&2047,b=4294967296*(d&1048575)+l;return g===2047?b?NaN:f*(1/0):g===0?f*5e-324*b:f*Math.pow(2,g-1075)*(b+4503599627370496)}r.readDoubleLE=e.bind(null,Jo,0,4),r.readDoubleBE=e.bind(null,Qo,4,0)}(),r}function jo(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 Xo(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 Jo(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function Qo(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var rc=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 ic=L(nc=>{"use strict";var Di=nc;Di.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};Di.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var s=null,a=[],h=0,l;e<n;)l=t[e++],l<128?a[h++]=l:l>191&&l<224?a[h++]=(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[h++]=55296+(l>>10),a[h++]=56320+(l&1023)):a[h++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,h>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),h=0);return s?(h&&s.push(String.fromCharCode.apply(String,a.slice(0,h))),s.join("")):String.fromCharCode.apply(String,a.slice(0,h))};Di.write=function(t,e,n){for(var i=n,s,a,h=0;h<t.length;++h)s=t.charCodeAt(h),s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&((a=t.charCodeAt(h+1))&64512)===56320?(s=65536+((s&1023)<<10)+(a&1023),++h,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 oc=L((xm,sc)=>{"use strict";sc.exports=lh;function lh(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 ac=L((Am,cc)=>{"use strict";cc.exports=J;var ir=Ee();function J(r,t){this.lo=r>>>0,this.hi=t>>>0}var be=J.zero=new J(0,0);be.toNumber=function(){return 0};be.zzEncode=be.zzDecode=function(){return this};be.length=function(){return 1};var fh=J.zeroHash="\0\0\0\0\0\0\0\0";J.fromNumber=function(t){if(t===0)return be;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 J(n,i)};J.from=function(t){if(typeof t=="number")return J.fromNumber(t);if(ir.isString(t))if(ir.Long)t=ir.Long.fromString(t);else return J.fromNumber(parseInt(t,10));return t.low||t.high?new J(t.low>>>0,t.high>>>0):be};J.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};J.prototype.toLong=function(t){return ir.Long?new ir.Long(this.lo|0,this.hi|0,Boolean(t)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(t)}};var ee=String.prototype.charCodeAt;J.fromHash=function(t){return t===fh?be:new J((ee.call(t,0)|ee.call(t,1)<<8|ee.call(t,2)<<16|ee.call(t,3)<<24)>>>0,(ee.call(t,4)|ee.call(t,5)<<8|ee.call(t,6)<<16|ee.call(t,7)<<24)>>>0)};J.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)};J.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};J.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};J.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 Ee=L(Ci=>{"use strict";var A=Ci;A.asPromise=Vo();A.base64=Ko();A.EventEmitter=Wo();A.float=ec();A.inquire=rc();A.utf8=ic();A.pool=oc();A.LongBits=ac();A.isNode=Boolean(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||Ci;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(Boolean(e))};function uc(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=uc;A.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function lc(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&&uc(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=lc;A.ProtocolError=lc("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 Oi=L((Im,mc)=>{"use strict";mc.exports=V;var Mt=Ee(),Li,pc=Mt.LongBits,hh=Mt.utf8;function Lt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function V(r){this.buf=r,this.pos=0,this.len=r.length}var fc=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new V(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new V(t);throw Error("illegal buffer")},dc=function(){return Mt.Buffer?function(e){return(V.create=function(i){return Mt.Buffer.isBuffer(i)?new Li(i):fc(i)})(e)}:fc};V.create=dc();V.prototype._slice=Mt.Array.prototype.subarray||Mt.Array.prototype.slice;V.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,Lt(this,10);return t}}();V.prototype.int32=function(){return this.uint32()|0};V.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Bi(){var r=new pc(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 Lt(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 Lt(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")}V.prototype.bool=function(){return this.uint32()!==0};function Kr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}V.prototype.fixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return Kr(this.buf,this.pos+=4)};V.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return Kr(this.buf,this.pos+=4)|0};function hc(){if(this.pos+8>this.len)throw Lt(this,8);return new pc(Kr(this.buf,this.pos+=4),Kr(this.buf,this.pos+=4))}V.prototype.float=function(){if(this.pos+4>this.len)throw Lt(this,4);var t=Mt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};V.prototype.double=function(){if(this.pos+8>this.len)throw Lt(this,4);var t=Mt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};V.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(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)};V.prototype.string=function(){var t=this.bytes();return hh.read(t,0,t.length)};V.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while(this.buf[this.pos++]&128);return this};V.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};V._configure=function(r){Li=r,V.create=dc(),Li._configure();var t=Mt.Long?"toLong":"toNumber";Mt.merge(V.prototype,{int64:function(){return Bi.call(this)[t](!1)},uint64:function(){return Bi.call(this)[t](!0)},sint64:function(){return Bi.call(this).zzDecode()[t](!1)},fixed64:function(){return hc.call(this)[t](!0)},sfixed64:function(){return hc.call(this)[t](!1)}})}});var bc=L((Rm,wc)=>{"use strict";wc.exports=ve;var yc=Oi();(ve.prototype=Object.create(yc.prototype)).constructor=ve;var gc=Ee();function ve(r){yc.call(this,r)}ve._configure=function(){gc.Buffer&&(ve.prototype._slice=gc.Buffer.prototype.slice)};ve.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))};ve._configure()});var Gi=L((Dm,Sc)=>{"use strict";Sc.exports=O;var St=Ee(),Ni,Yr=St.LongBits,Ec=St.base64,vc=St.utf8;function sr(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function Pi(){}function ph(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function O(){this.len=0,this.head=new sr(Pi,0,0),this.tail=this.head,this.states=null}var Tc=function(){return St.Buffer?function(){return(O.create=function(){return new Ni})()}:function(){return new O}};O.create=Tc();O.alloc=function(t){return new St.Array(t)};St.Array!==Array&&(O.alloc=St.pool(O.alloc,St.Array.prototype.subarray));O.prototype._push=function(t,e,n){return this.tail=this.tail.next=new sr(t,e,n),this.len+=e,this};function Mi(r,t,e){t[e]=r&255}function dh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function Ui(r,t){this.len=r,this.next=void 0,this.val=t}Ui.prototype=Object.create(sr.prototype);Ui.prototype.fn=dh;O.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Ui((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};O.prototype.int32=function(t){return t<0?this._push(Fi,10,Yr.fromNumber(t)):this.uint32(t)};O.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Fi(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}O.prototype.uint64=function(t){var e=Yr.from(t);return this._push(Fi,e.length(),e)};O.prototype.int64=O.prototype.uint64;O.prototype.sint64=function(t){var e=Yr.from(t).zzEncode();return this._push(Fi,e.length(),e)};O.prototype.bool=function(t){return this._push(Mi,1,t?1:0)};function ki(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}O.prototype.fixed32=function(t){return this._push(ki,4,t>>>0)};O.prototype.sfixed32=O.prototype.fixed32;O.prototype.fixed64=function(t){var e=Yr.from(t);return this._push(ki,4,e.lo)._push(ki,4,e.hi)};O.prototype.sfixed64=O.prototype.fixed64;O.prototype.float=function(t){return this._push(St.float.writeFloatLE,4,t)};O.prototype.double=function(t){return this._push(St.float.writeDoubleLE,8,t)};var mh=St.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]};O.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(Mi,1,0);if(St.isString(t)){var n=O.alloc(e=Ec.length(t));Ec.decode(t,n,0),t=n}return this.uint32(e)._push(mh,e,t)};O.prototype.string=function(t){var e=vc.length(t);return e?this.uint32(e)._push(vc.write,e,t):this._push(Mi,1,0)};O.prototype.fork=function(){return this.states=new ph(this),this.head=this.tail=new sr(Pi,0,0),this.len=0,this};O.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 sr(Pi,0,0),this.len=0),this};O.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};O.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};O._configure=function(r){Ni=r,O.create=Tc(),Ni._configure()}});var _c=L((Cm,Ac)=>{"use strict";Ac.exports=Ut;var xc=Gi();(Ut.prototype=Object.create(xc.prototype)).constructor=Ut;var re=Ee();function Ut(){xc.call(this)}Ut._configure=function(){Ut.alloc=re._Buffer_allocUnsafe,Ut.writeBytesBuffer=re.Buffer&&re.Buffer.prototype instanceof Uint8Array&&re.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++]}};Ut.prototype.bytes=function(t){re.isString(t)&&(t=re._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Ut.writeBytesBuffer,e,t),this};function gh(r,t,e){r.length<40?re.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Ut.prototype.string=function(t){var e=re.Buffer.byteLength(t);return this.uint32(e),e&&this._push(gh,e,t),this};Ut._configure()});var Mh={};dt(Mh,{createClient:()=>Ph});var Gt=class extends Error{constructor(t="The operation was aborted"){super(t),this.code=Gt.code,this.type=Gt.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},v=class extends Error{constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Fo=P(Nt("net"),1);var Zt=Nt("node:net");function yr(r){return Boolean((0,Zt.isIP)(r))}var Sn={};dt(Sn,{identity:()=>Nu});function Du(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 h=r.length,l=r.charAt(0),d=Math.log(h)/Math.log(256),f=Math.log(256)/Math.log(h);function g(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var x=0,B=0,I=0,C=w.length;I!==C&&w[I]===0;)I++,x++;for(var $=(C-I)*f+1>>>0,Y=new Uint8Array($);I!==C;){for(var ft=w[I],ct=0,it=$-1;(ft!==0||ct<B)&&it!==-1;it--,ct++)ft+=256*Y[it]>>>0,Y[it]=ft%h>>>0,ft=ft/h>>>0;if(ft!==0)throw new Error("Non-zero carry");B=ct,I++}for(var at=$-B;at!==$&&Y[at]===0;)at++;for(var At=l.repeat(x);at<$;++at)At+=r.charAt(Y[at]);return At}function b(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var x=0;if(w[x]!==" "){for(var B=0,I=0;w[x]===l;)B++,x++;for(var C=(w.length-x)*d+1>>>0,$=new Uint8Array(C);w[x];){var Y=e[w.charCodeAt(x)];if(Y===255)return;for(var ft=0,ct=C-1;(Y!==0||ft<I)&&ct!==-1;ct--,ft++)Y+=h*$[ct]>>>0,$[ct]=Y%256>>>0,Y=Y/256>>>0;if(Y!==0)throw new Error("Non-zero carry");I=ft,x++}if(w[x]!==" "){for(var it=C-I;it!==C&&$[it]===0;)it++;for(var at=new Uint8Array(B+(C-it)),At=B;it!==C;)at[At++]=$[it++];return at}}}function S(w){var x=b(w);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:b,decode:S}}var Cu=Du,Bu=Cu,is=Bu;var Vh=new Uint8Array(0);var ss=(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},bt=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 os=r=>new TextEncoder().encode(r),cs=r=>new TextDecoder().decode(r);var bn=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")}},En=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 us(this,t)}},vn=class{constructor(t){this.decoders=t}or(t){return us(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`)}},us=(r,t)=>new vn({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Tn=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new bn(t,e,n),this.decoder=new En(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},xe=({name:r,prefix:t,encode:e,decode:n})=>new Tn(r,t,e,n),jt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=is(e,t);return xe({prefix:r,name:t,encode:n,decode:s=>bt(i(s))})},Lu=(r,t,e,n)=>{let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*e/8|0),h=0,l=0,d=0;for(let f=0;f<s;++f){let g=i[r[f]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,h+=e,h>=8&&(h-=8,a[d++]=255&l>>h)}if(h>=e||255&l<<8-h)throw new SyntaxError("Unexpected end of data");return a},Ou=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,s="",a=0,h=0;for(let l=0;l<r.length;++l)for(h=h<<8|r[l],a+=8;a>e;)a-=e,s+=t[i&h>>a];if(a&&(s+=t[i&h<<e-a]),n)for(;s.length*e&7;)s+="=";return s},F=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>xe({prefix:t,name:r,encode(i){return Ou(i,n,e)},decode(i){return Lu(i,n,e,r)}});var Nu=xe({prefix:"\0",name:"identity",encode:r=>cs(r),decode:r=>os(r)});var xn={};dt(xn,{base2:()=>ku});var ku=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var An={};dt(An,{base8:()=>Pu});var Pu=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _n={};dt(_n,{base10:()=>Mu});var Mu=jt({prefix:"9",name:"base10",alphabet:"0123456789"});var In={};dt(In,{base16:()=>Uu,base16upper:()=>Fu});var Uu=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fu=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rn={};dt(Rn,{base32:()=>Dt,base32hex:()=>zu,base32hexpad:()=>qu,base32hexpadupper:()=>Ku,base32hexupper:()=>Hu,base32pad:()=>$u,base32padupper:()=>Vu,base32upper:()=>Gu,base32z:()=>Yu});var Dt=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gu=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$u=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vu=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zu=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hu=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qu=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ku=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yu=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Dn={};dt(Dn,{base36:()=>Wu,base36upper:()=>Zu});var Wu=jt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zu=jt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Cn={};dt(Cn,{base58btc:()=>W,base58flickr:()=>ju});var W=jt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ju=jt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ln={};dt(Ln,{base64:()=>Bn,base64pad:()=>Xu,base64url:()=>Ju,base64urlpad:()=>Qu});var Bn=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xu=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ju=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qu=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var On={};dt(On,{base256emoji:()=>il});var ls=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}"),tl=ls.reduce((r,t,e)=>(r[e]=t,r),[]),el=ls.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function rl(r){return r.reduce((t,e)=>(t+=tl[e],t),"")}function nl(r){let t=[];for(let e of r){let n=el[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var il=xe({prefix:"\u{1F680}",name:"base256emoji",encode:rl,decode:nl});var Un={};dt(Un,{sha256:()=>br,sha512:()=>Sl});var Mn=P(Nt("crypto"),1);var sl=ps,fs=128,ol=127,cl=~ol,al=Math.pow(2,31);function ps(r,t,e){t=t||[],e=e||0;for(var n=e;r>=al;)t[e++]=r&255|fs,r/=128;for(;r&cl;)t[e++]=r&255|fs,r>>>=7;return t[e]=r|0,ps.bytes=e-n+1,t}var ul=Nn,ll=128,hs=127;function Nn(r,n){var e=0,n=n||0,i=0,s=n,a,h=r.length;do{if(s>=h)throw Nn.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&hs)<<i:(a&hs)*Math.pow(2,i),i+=7}while(a>=ll);return Nn.bytes=s-n,e}var fl=Math.pow(2,7),hl=Math.pow(2,14),pl=Math.pow(2,21),dl=Math.pow(2,28),ml=Math.pow(2,35),gl=Math.pow(2,42),yl=Math.pow(2,49),wl=Math.pow(2,56),bl=Math.pow(2,63),El=function(r){return r<fl?1:r<hl?2:r<pl?3:r<dl?4:r<ml?5:r<gl?6:r<yl?7:r<wl?8:r<bl?9:10},vl={encode:sl,decode:ul,encodingLength:El},Tl=vl,Ke=Tl;var Ye=(r,t=0)=>[Ke.decode(r,t),Ke.decode.bytes],Ae=(r,t,e=0)=>(Ke.encode(r,t,e),t),_e=r=>Ke.encodingLength(r);var Xt=(r,t)=>{let e=t.byteLength,n=_e(r),i=n+_e(e),s=new Uint8Array(i+e);return Ae(r,s,0),Ae(e,s,n),s.set(t,i),new Ie(r,e,t,s)},ue=r=>{let t=bt(r),[e,n]=Ye(t),[i,s]=Ye(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new Ie(e,i,a,t)},ds=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ss(r.bytes,e.bytes)}},Ie=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Pn=({name:r,code:t,encode:e})=>new kn(r,t,e),kn=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 br=Pn({name:"sha2-256",code:18,encode:r=>bt(Mn.default.createHash("sha256").update(r).digest())}),Sl=Pn({name:"sha2-512",code:19,encode:r=>bt(Mn.default.createHash("sha512").update(r).digest())});var Fn={};dt(Fn,{identity:()=>Er});var gs=0,xl="identity",ys=bt,Al=r=>Xt(gs,ys(r)),Er={code:gs,name:xl,encode:ys,digest:Al};var lp=new TextEncoder,fp=new TextDecoder;var ws=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Dl(e,Gn(r),t||W.encoder);default:return Cl(e,Gn(r),t||Dt.encoder)}};var bs=new WeakMap,Gn=r=>{let t=bs.get(r);if(t==null){let e=new Map;return bs.set(r,e),e}return t},N=class{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!==We)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Bl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return N.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 N.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 N.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&ds(t.multihash,n.multihash)}toString(t){return ws(this,t)}toJSON(){return{"/":ws(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 N)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:s,bytes:a}=e;return new N(n,i,s,a||Es(n,i,s.bytes))}else if(e[Ll]===!0){let{version:n,multihash:i,code:s}=e,a=ue(i);return N.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!==We)throw new Error(`Version 0 CID must use dag-pb (code: ${We}) block encoding`);return new N(t,e,n,n.bytes)}case 1:{let i=Es(t,e,n.bytes);return new N(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return N.create(0,We,t)}static createV1(t,e){return N.create(1,t,e)}static decode(t){let[e,n]=N.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=N.inspectBytes(t),n=e.size-e.multihashSize,i=bt(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 Ie(e.multihashCode,e.digestSize,s,i);return[e.version===0?N.createV0(a):N.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,b]=Ye(t.subarray(e));return e+=b,g},i=n(),s=We;if(i===18?(i=0,e=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,h=n(),l=n(),d=e+l,f=d-a;return{version:i,codec:s,multihashCode:h,digestSize:l,multihashSize:f,size:d}}static parse(t,e){let[n,i]=Rl(t,e),s=N.decode(i);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Gn(s).set(n,t),s}},Rl=(r,t)=>{switch(r[0]){case"Q":{let e=t||W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t||W;return[W.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)]}}},Dl=(r,t,e)=>{let{prefix:n}=e;if(n!==W.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},Cl=(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},We=112,Bl=18,Es=(r,t,e)=>{let n=_e(r),i=n+_e(t),s=new Uint8Array(i+e.byteLength);return Ae(r,s,0),Ae(t,s,n),s.set(e,i),s},Ll=Symbol.for("@ipld/js-cid/CID");var Jt={...Sn,...xn,...An,..._n,...In,...Rn,...Dn,...Cn,...Ln,...On},vp={...Un,...Fn};function fe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function $t(r=0){return globalThis.Buffer?.alloc!=null?fe(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Vt(r=0){return globalThis.Buffer?.allocUnsafe!=null?fe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Ts(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var vs=Ts("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$n=Ts("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=Vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ol={utf8:vs,"utf-8":vs,hex:Jt.base16,latin1:$n,ascii:$n,binary:$n,...Jt},vr=Ol;function ut(r,t="utf8"){let e=vr[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 Ss=Zt.isIPv4,Nl=Zt.isIPv6,Vn=function(r){let t=0;if(r=r.toString().trim(),Ss(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Nl(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ss(e[n]),a;s&&(a=Vn(e[n]),e[n]=ut(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,ut(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")},xs=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 Ze={},zn={},Pl=[[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"],[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"],[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"]];Pl.forEach(r=>{let t=Ml(...r);zn[t.code]=t,Ze[t.name]=t});function Ml(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:Boolean(n),path:Boolean(i)}}function U(r){if(typeof r=="number"){if(zn[r]!=null)return zn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ze[r]!=null)return Ze[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var kt=P(Tr(),1);function Kn(r,t="utf8"){let e=vr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?fe(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Et(r,t){t==null&&(t=r.reduce((i,s)=>i+s.length,0));let e=Vt(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return fe(e)}function Us(r,t){switch(U(r).code){case 4:case 41:return Jl(t);case 42:return Ps(t);case 6:case 273:case 33:case 132:return Gs(t).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Ps(t);case 421:return rf(t);case 444:return Ms(t);case 445:return Ms(t);case 466:return ef(t);default:return ut(t,"base16")}}function Fs(r,t){switch(U(r).code){case 4:return Ns(t);case 41:return Ns(t);case 42:return ks(t);case 6:case 273:case 33:case 132:return Wn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 777:return ks(t);case 421:return Ql(t);case 444:return nf(t);case 445:return sf(t);case 466:return tf(t);default:return Kn(t,"base16")}}var Yn=Object.values(Jt).map(r=>r.decoder),Xl=function(){let r=Yn[0].or(Yn[1]);return Yn.slice(2).forEach(t=>r=r.or(t)),r}();function Ns(r){if(!yr(r))throw new Error("invalid ip address");return Vn(r)}function Jl(r){let t=xs(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!yr(t))throw new Error("invalid ip address");return t}function Wn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Gs(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ks(r){let t=Kn(r),e=Uint8Array.from(kt.default.encode(t.length));return Et([e,t],e.length+t.length)}function Ps(r){let t=kt.default.decode(r);if(r=r.slice(kt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return ut(r)}function Ql(r){let t;r[0]==="Q"||r[0]==="1"?t=ue(W.decode(`z${r}`)).bytes:t=N.parse(r).multihash.bytes;let e=Uint8Array.from(kt.default.encode(t.length));return Et([e,t],e.length+t.length)}function tf(r){let t=Xl.decode(r),e=Uint8Array.from(kt.default.encode(t.length));return Et([e,t],e.length+t.length)}function ef(r){let t=kt.default.decode(r),e=r.slice(kt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+ut(e,"base64url")}function rf(r){let t=kt.default.decode(r),e=r.slice(kt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return ut(e,"base58btc")}function nf(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=Wn(n);return Et([e,i],e.length+i.length)}function sf(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=Wn(n);return Et([e,i],e.length+i.length)}function Ms(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ut(t,"base32"),i=Gs(e);return`${n}:${i}`}var Re=P(Tr(),1);function of(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let i=e[n],s=U(i);if(s.size===0){t.push([i]);continue}if(n++,n>=e.length)throw Vs("invalid address: "+r);if(s.path===!0){t.push([i,Qn(e.slice(n).join("/"))]);break}t.push([i,e[n]])}return t}function cf(r){let t=[];return r.map(e=>{let n=Ar(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Qn(t.join("/"))}function af(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Ar(t);return t.length>1?[e.code,Fs(e.code,t[1])]:[e.code]})}function Zn(r){return r.map(t=>{let e=Ar(t);return t[1]!=null?[e.code,Us(e.code,t[1])]:[e.code]})}function jn(r){return xr(Et(r.map(t=>{let e=Ar(t),n=Uint8Array.from(Re.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=Et([n,t[1]])),n})))}function Xn(r,t){return r.size>0?r.size/8:r.size===0?0:Re.default.decode(t)+(Re.default.decode.bytes??0)}function Sr(r){let t=[],e=0;for(;e<r.length;){let n=Re.default.decode(r,e),i=Re.default.decode.bytes??0,s=U(n),a=Xn(s,r.slice(e+i));if(a===0){t.push([n]),e+=i;continue}let h=r.slice(e+i,e+i+a);if(e+=a+i,e>r.length)throw Vs("Invalid address Uint8Array: "+ut(r,"base16"));t.push([n,h])}return t}function Jn(r){let t=Sr(r),e=Zn(t);return cf(e)}function uf(r){r=Qn(r);let t=of(r),e=af(t);return jn(e)}function $s(r){return uf(r)}function xr(r){let t=lf(r);if(t!=null)throw t;return Uint8Array.from(r)}function lf(r){try{Sr(r)}catch(t){return t}}function Qn(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Vs(r){return new Error("Error parsing address: "+r)}function Ar(r){return U(r[0])}var ei=P(Tr(),1);var Ks=P(_r(),1);function he(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 De=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ti=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},je,Xe,Je,qs,pf=Symbol.for("nodejs.util.inspect.custom"),df=[U("dns").code,U("dns4").code,U("dns6").code,U("dnsaddr").code],mf=new Map,Ys=Symbol.for("@multiformats/js-multiaddr/multiaddr");function ri(r){return Boolean(r?.[Ys])}var zt=class{constructor(t){if(je.set(this,void 0),Xe.set(this,void 0),Je.set(this,void 0),this[qs]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=xr(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=$s(t)}else if(ri(t))this.bytes=xr(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return De(this,je,"f")==null&&ti(this,je,Jn(this.bytes),"f"),De(this,je,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,i,s="",a=U("tcp"),h=U("udp"),l=U("ip4"),d=U("ip6"),f=U("dns6"),g=U("ip6zone");for(let[S,w]of this.stringTuples())S===g.code&&(s=`%${w??""}`),df.includes(S)&&(e=a.name,i=443,n=`${w??""}${s}`,t=S===f.code?6:4),(S===a.code||S===h.code)&&(e=U(S).name,i=parseInt(w??"")),(S===l.code||S===d.code)&&(e=U(S).name,n=`${w??""}${s}`,t=S===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.protoCodes().map(t=>Object.assign({},U(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let i=ei.default.decode(e,n),s=ei.default.decode.bytes??0,a=U(i),h=Xn(a,e.slice(n+s));n+=h+s,t.push(i)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return De(this,Xe,"f")==null&&ti(this,Xe,Sr(this.bytes),"f"),De(this,Xe,"f")}stringTuples(){return De(this,Je,"f")==null&&ti(this,Je,Zn(this.tuples()),"f"),De(this,Je,"f")}encapsulate(t){return t=new zt(t),new zt(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 zt(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 zt(jn(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Ze.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?ut(W.decode(`z${n}`),"base58btc"):ut(N.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>U(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return he(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=mf.get(e.name);if(n==null)throw(0,Ks.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new zt(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)}[(je=new WeakMap,Xe=new WeakMap,Je=new WeakMap,qs=Ys,pf)](){return`Multiaddr(${Jn(this.bytes)})`}};function ot(r){return new zt(r)}var gf=_("dns4"),yf=_("dns6"),wf=_("dnsaddr"),Ce=tt(_("dns"),wf,gf,yf),Ir=tt(_("ip4"),_("ip6")),pe=tt(R(Ir,_("tcp")),R(Ce,_("tcp"))),Zs=R(Ir,_("udp")),bf=R(Zs,_("utp")),Ef=R(Zs,_("quic")),tr=tt(R(pe,_("ws")),R(Ce,_("ws"))),er=tt(R(pe,_("wss")),R(Ce,_("wss"))),ni=tt(R(pe,_("http")),R(Ir,_("http")),R(Ce,_("http"))),ii=tt(R(pe,_("https")),R(Ir,_("https")),R(Ce,_("https"))),js=tt(R(tr,_("p2p-webrtc-star"),_("p2p")),R(er,_("p2p-webrtc-star"),_("p2p")),R(tr,_("p2p-webrtc-star")),R(er,_("p2p-webrtc-star"))),pd=tt(R(tr,_("p2p-websocket-star"),_("p2p")),R(er,_("p2p-websocket-star"),_("p2p")),R(tr,_("p2p-websocket-star")),R(er,_("p2p-websocket-star"))),Xs=tt(R(ni,_("p2p-webrtc-direct"),_("p2p")),R(ii,_("p2p-webrtc-direct"),_("p2p")),R(ni,_("p2p-webrtc-direct")),R(ii,_("p2p-webrtc-direct"))),rr=tt(tr,er,ni,ii,js,Xs,pe,bf,Ef,Ce),dd=tt(R(rr,_("p2p-stardust"),_("p2p")),R(rr,_("p2p-stardust"))),Qt=tt(R(rr,_("p2p")),js,Xs,_("p2p")),Ws=tt(R(Qt,_("p2p-circuit"),Qt),R(Qt,_("p2p-circuit")),R(_("p2p-circuit"),Qt),R(rr,_("p2p-circuit")),R(_("p2p-circuit"),rr),_("p2p-circuit")),Js=()=>tt(R(Ws,Js),Ws),Qe=Js(),md=tt(R(Qe,Qt,Qe),R(Qt,Qe),R(Qe,Qt),Qe,Qt);function Qs(r){function t(e){let n;try{n=ot(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:Qs(t),partialMatch:t}}function tt(...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:Qs(t),partialMatch:t}}function _(r){let t=r;function e(i){let s;try{s=ot(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 Pt=P(fo(),1);Pt.default.formatters.b=r=>r==null?"undefined":W.baseEncode(r);Pt.default.formatters.t=r=>r==null?"undefined":Dt.baseEncode(r);Pt.default.formatters.m=r=>r==null?"undefined":Bn.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();function Tt(r){return Object.assign((0,Pt.default)(r),{error:(0,Pt.default)(`${r}:error`),trace:(0,Pt.default)(`${r}:trace`)})}var ko=P(Eo(),1);var Gr=P(_r(),1);function Or(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Nr(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var ke=/^(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,fi=/\/\d{1,2}$/;var et=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var Pe=P(hi(),1),me=P(nr(),1),M=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Nr(32),this.isInSubnet=Or,this.address=t;let e=fi.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 et("Invalid subnet mask.");t=t.replace(fi,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new M(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(ke))throw new et("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 M(n.join("."))}static fromInteger(t){return M.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new M(n)}toHex(){return this.parsedAddress.map(t=>(0,me.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,me.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,me.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new Pe.BigInteger(this.parsedAddress.map(t=>(0,me.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Pe.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return M.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Pe.BigInteger("1");return M.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Pe.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return M.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Pe.BigInteger("1");return M.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return M.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,me.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new M("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(ke,(0,me.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 Ao={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},pi={"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"},di=/([^0-9a-f:/%])/gi,mi=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,gi=/\/\d{1,3}(?=%|$)/,yi=/%.*$/,_o=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Io=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Do=P(nr(),1);function Wf(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function Mr(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Do.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,Wf(n)))}var ye=P(nr(),1);function bi(r){return(0,ye.sprintf)("(%s)",r.join("|"))}function wi(r){return r.length<4?(0,ye.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ei="[^A-Fa-f0-9:]";function Ur(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 bi([wi(i),a])}return wi(i)}).join(":"));return e.push(r.map(wi).join(":")),bi(e)}function vi(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,ye.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),s.push((0,ye.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),s.push((0,ye.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let h=1;h<r-a;h++)s.push((0,ye.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",h,r-h-a-1));return bi(s)}var rt=P(hi(),1),nt=P(nr(),1);function Fr(r){if(!r)throw new Error("Assertion failed.")}function Zf(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function jf(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 Xf(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 Bo(r){return(0,nt.sprintf)("%04x",parseInt(r,16))}function Lo(r){return r&255}var G=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Or,this.isCorrect=Nr(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=gi.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 et("Invalid subnet mask.");t=t.replace(gi,"")}else if(/\//.test(t))throw new et("Invalid subnet mask.");let i=yi.exec(t);i&&(this.zone=i[0],t=t.replace(yi,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new G(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 G(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=Io.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=_o.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 G(e),port:n}}static fromAddress4(t){let e=new M(t),n=128-(32-e.subnetMask);return new G(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new et("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 G(e)}microsoftTranscription(){return(0,nt.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":Zf(new rt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new rt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return G.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new rt.BigInteger("1");return G.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new rt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return G.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new rt.BigInteger("1");return G.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Ao[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(pi))if(this.isInSubnet(new G(t)))return pi[t];return"Global unicast"}getBits(t,e){return new rt.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,nt.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 h=parseInt(this.parsedAddress[t],16);h===0&&n++,h!==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(h=>h[1]-h[0]+1);if(i.length>0){let h=s.indexOf(Math.max(...s));e=Xf(this.parsedAddress,i[h])}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(ke);if(i){this.parsedAddress4=i[0],this.address4=new M(this.parsedAddress4);for(let s=0;s<this.address4.groups;s++)if(/^0[0-9]+/.test(this.address4.parsedAddress[s]))throw new et("IPv4 addresses can't have leading zeroes.",t.replace(ke,this.address4.parsedAddress.map(jf).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(di);if(e)throw new et((0,nt.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(di,'<span class="parse-error">$1</span>'));let n=t.match(mi);if(n)throw new et((0,nt.sprintf)("Address failed regex: %s",n.join("")),t.replace(mi,'<span class="parse-error">$1</span>'));let i=[],s=t.split("::");if(s.length===2){let a=s[0].split(":"),h=s[1].split(":");a.length===1&&a[0]===""&&(a=[]),h.length===1&&h[0]===""&&(h=[]);let l=this.groups-(a.length+h.length);if(!l)throw new et("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(h)}else if(s.length===1)i=t.split(":"),this.elidedGroups=0;else throw new et("Too many :: groups found");if(i=i.map(a=>(0,nt.sprintf)("%x",parseInt(a,16))),i.length!==this.groups)throw new et("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(Bo).join(":")}decimal(){return this.parsedAddress.map(t=>(0,nt.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new rt.BigInteger(this.parsedAddress.map(Bo).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return M.fromHex(new rt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new G(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 rt.BigInteger("ffff",16)).toString(),n=M.fromHex(this.getBitsBase16(32,64)),i=M.fromHex(this.getBits(96,128).xor(new rt.BigInteger("ffffffff",16)).toString(16)),s=this.getBits(64,80),a=this.getBitsBase2(64,80),h=s.testBit(15),l=s.testBit(14),d=s.testBit(8),f=s.testBit(9),g=new rt.BigInteger(a.slice(2,6)+a.slice(8,16),2).toString(10);return{prefix:(0,nt.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:a,coneNat:h,microsoft:{reserved:l,universalLocal:f,groupIndividual:d,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=M.fromHex(this.getBitsBase16(16,48));return{prefix:(0,nt.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 G(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Lo)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Lo))}static fromUnsignedByteArray(t){let e=new rt.BigInteger("256",10),n=new rt.BigInteger("0",10),i=new rt.BigInteger("1",10);for(let s=t.length-1;s>=0;s--)n=n.add(i.multiply(new rt.BigInteger(t[s].toString(10),10))),i=i.multiply(e);return G.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 G("2001::/32"))}is6to4(){return this.isInSubnet(new G("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,nt.sprintf)(":%s",t),(0,nt.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,nt.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,nt.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return Mr(this.address).join(":");Fr(typeof this.elidedGroups=="number"),Fr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...Mr(e)):t.push("");let i=["hover-group"];for(let s=this.elisionBegin;s<this.elisionBegin+this.elidedGroups;s++)i.push((0,nt.sprintf)("group-%d",s));return t.push((0,nt.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...Mr(n,this.elisionEnd)):t.push(""),this.is4()&&(Fr(this.address4 instanceof M),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new G(this.correctForm());if(n.elidedGroups===0)e.push(Ur(n.parsedAddress));else if(n.elidedGroups===8)e.push(vi(8));else{let i=n.address.split("::");i[0].length&&e.push(Ur(i[0].split(":"))),Fr(typeof n.elidedGroups=="number"),e.push(vi(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Ur(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ei,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ei,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Jf=Tt("libp2p:ip-port-to-multiaddr"),Ti={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Oo(r,t){if(typeof r!="string")throw(0,Gr.default)(new Error(`invalid ip provided: ${r}`),Ti.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw(0,Gr.default)(new Error(`invalid port provided: ${t}`),Ti.ERR_INVALID_PORT_PARAMETER);try{return new M(r),ot(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new G(r);return e.is4()?ot(`/ip4/${e.to4().correctForm()}/tcp/${t}`):ot(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Jf.error(n),(0,Gr.default)(new Error(n),Ti.ERR_INVALID_IP)}}var Si=P(Nt("os"),1),No=P(Nt("path"),1),Qf={ip4:"IPv4",ip6:"IPv6"};function Ue(r){let t=r.getPath();return t!=null?Si.default.platform()==="win32"?{path:No.default.join("\\\\.\\pipe\\",t)}:{path:t}:r.toOptions()}function xi(r,t,e){let n=i=>ot(`/${r}/${i}/tcp/${e}`);return(th(t)?rh(Qf[r]):[t]).map(n)}function th(r){return["0.0.0.0","::"].includes(r)}var eh=Si.default.networkInterfaces();function rh(r){let t=[];for(let[,e]of Object.entries(eh))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Ct=Tt("libp2p:tcp:socket"),$r=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,s=t.socketCloseTimeout??2e3;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 v("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Oo(r.remoteAddress,r.remotePort)}let h=Ue(a),l=h.path??`${h.host??""}:${h.port??""}`,{sink:d,source:f}=ko.default.duplex(r);r.setTimeout(i,()=>{Ct("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let b;r.readable&&(b=new v("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(b)}),r.once("close",()=>{Ct("%s socket close",l),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Ct("%s socket end",l),e?.increment({[`${n}end`]:!0})});let g={async sink(b){try{await d(b)}catch(S){S.type!=="aborted"&&Ct(S)}r.end()},source:f,remoteAddr:a,timeline:{open:Date.now()},async close(){if(r.destroyed){Ct("%s socket was already destroyed when trying to close",l);return}Ct("%s closing socket",l),await new Promise((b,S)=>{let w=Date.now(),x=setTimeout(()=>{r.destroyed?(Ct("%s is already destroyed",l),b()):(Ct("%s socket close timeout after %dms, destroying it manually",l,Date.now()-w),r.destroy(new v("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},s).unref();r.once("close",()=>{Ct("%s socket closed",l),clearTimeout(x),b()}),r.once("error",B=>{Ct("%s socket error",l,B),g.timeline.close==null&&(g.timeline.close=Date.now()),r.destroyed&&clearTimeout(x),S(B)}),r.setTimeout(s),r.end(),r.writableLength>0?r.once("drain",()=>{Ct("%s socket drained",l),r.destroy()}):r.destroy()})}};return g};var Po=P(Nt("net"),1);var we=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},qt,Vr=class extends EventTarget{constructor(){super(...arguments),qt.set(this,new Map)}listenerCount(t){let e=we(this,qt,"f").get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=we(this,qt,"f").get(t);i==null&&(i=[],we(this,qt,"f").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=we(this,qt,"f").get(t);i!=null&&(i=i.filter(({callback:s})=>s!==e),we(this,qt,"f").set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=we(this,qt,"f").get(t.type);return n==null||(n=n.filter(({once:i})=>!i),we(this,qt,"f").set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new Fe(t,e))}};qt=new WeakMap;var Ai=class extends Event{constructor(t,e){super(t,e),this.detail=e?.detail}},Fe=globalThis.CustomEvent??Ai;var gt=Tt("libp2p:tcp:listener");async function _i(r){try{await r.close()}catch(t){gt.error("an error occurred closing the connection",t)}}var sh=1,oh=0,zr=class extends Vr{constructor(t){if(super(),this.context=t,this.connections=new Set,this.status={started:!1},t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Po.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]:sh})}this.dispatchEvent(new Fe("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Fe("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:oh}),this.dispatchEvent(new Fe("close"))})}onSocket(t){t.on("error",n=>{gt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=$r(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){gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}gt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{gt("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=>{gt.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 Fe("connection",{detail:n}))}).catch(async n=>{gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await _i(e)}).catch(n=>{gt.error("closing inbound connection failed",n)})}catch(n){gt.error("inbound connection failed",n),_i(e).catch(i=>{gt.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(xi("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(xi("ip6",e.address,e.port)))}catch(s){gt.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;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:Ue(n)},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await _i(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)}),gt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(gt("Closing server on %s",this.server.address()),this.server.close())}};var Uo=Symbol.for("@libp2p/transport");var Mo;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Mo||(Mo={}));var Kt=Tt("libp2p:tcp"),Ri=class{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"})})}get[Uo](){return!0}get[Symbol.toStringTag](){return"@libp2p/tcp"}async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",h=>{Kt("socket error",h)});let i=$r(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{i.close().catch(h=>{Kt.error("Error closing maConn after abort",h)})};e.signal?.addEventListener("abort",s,{once:!0}),Kt("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(Kt("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw a.close().catch(h=>{Kt.error("Error closing conn after abort",h)}),new Gt;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Gt;return await new Promise((n,i)=>{let s=Date.now(),a=Ue(t),h=a.path??`${a.host??""}:${a.port}`;Kt("dialing %j",a);let l=Fo.default.connect(a),d=w=>{w.message=`connection error ${h}: ${w.message}`,this.metrics?.dialerEvents.increment({error:!0}),S(w)},f=()=>{Kt("connection timeout %s",h),this.metrics?.dialerEvents.increment({timeout:!0});let w=new v(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",w)},g=()=>{Kt("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),S()},b=()=>{Kt("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),S(new Gt)},S=w=>{if(l.removeListener("error",d),l.removeListener("timeout",f),l.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",b),w!=null){i(w);return}n(l)};l.on("error",d),l.on("timeout",f),l.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",b)})}createListener(t){return new zr({...t,maxConnections:this.opts.maxConnections,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:pe.matches(e.decapsulateCode(421)))}};function Go(r={}){return(t={})=>new Ri(t,r)}var $i=P(Oi(),1),Ic=P(bc(),1),Vi=P(Gi(),1),Rc=P(_c(),1),Dc=P(Ee(),1);function yh(){Dc.default._configure(),$i.default._configure(Ic.default),Vi.default._configure(Rc.default)}yh();var Cc=["uint64","int64","sint64","fixed64","sfixed64"];function wh(r){for(let t of Cc){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function zi(r){return wh(new $i.default(r))}function bh(r){for(let t of Cc){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function Hi(){return bh(Vi.default.create())}function H(r,t){let e=zi(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function q(r,t){let e=Hi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var $e;(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"})($e||($e={}));function Wr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Yt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(s,a){let h=t(s);a.int32(h)},n=function(s){let a=s.int32();return t(a)};return Wr("enum",$e.VARINT,e,n)}function K(r,t){return Wr("message",$e.LENGTH_DELIMITED,r,t)}var z;(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=()=>Yt(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),jr.codec().encode(i.connect,s,{writeDefaults:!1})),i.streamOpen!=null&&(s.uint32(26),Xr.codec().encode(i.streamOpen,s,{writeDefaults:!1})),i.streamHandler!=null&&(s.uint32(34),Jr.codec().encode(i.streamHandler,s,{writeDefaults:!1})),i.dht!=null&&(s.uint32(42),xt.codec().encode(i.dht,s,{writeDefaults:!1})),i.connManager!=null&&(s.uint32(50),tn.codec().encode(i.connManager,s,{writeDefaults:!1})),i.disconnect!=null&&(s.uint32(58),en.codec().encode(i.disconnect,s,{writeDefaults:!1})),i.pubsub!=null&&(s.uint32(66),ie.codec().encode(i.pubsub,s,{writeDefaults:!1})),i.peerStore!=null&&(s.uint32(74),sn.codec().encode(i.peerStore,s,{writeDefaults:!1})),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=jr.codec().decode(i,i.uint32());break;case 3:a.streamOpen=Xr.codec().decode(i,i.uint32());break;case 4:a.streamHandler=Jr.codec().decode(i,i.uint32());break;case 5:a.dht=xt.codec().decode(i,i.uint32());break;case 6:a.connManager=tn.codec().decode(i,i.uint32());break;case 7:a.disconnect=en.codec().decode(i,i.uint32());break;case 8:a.pubsub=ie.codec().decode(i,i.uint32());break;case 9:a.peerStore=sn.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(z||(z={}));var D;(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=()=>Yt(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),Qr.codec().encode(i.error,s,{writeDefaults:!1})),i.streamInfo!=null&&(s.uint32(26),Ve.codec().encode(i.streamInfo,s,{writeDefaults:!1})),i.identify!=null&&(s.uint32(34),Zr.codec().encode(i.identify,s,{writeDefaults:!1})),i.dht!=null&&(s.uint32(42),Ot.codec().encode(i.dht,s,{writeDefaults:!1})),i.peers!=null)for(let h of i.peers)s.uint32(50),ne.codec().encode(h,s,{writeDefaults:!0});i.pubsub!=null&&(s.uint32(58),nn.codec().encode(i.pubsub,s,{writeDefaults:!1})),i.peerStore!=null&&(s.uint32(66),on.codec().encode(i.peerStore,s,{writeDefaults:!1})),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={peers:[]},h=s==null?i.len:i.pos+s;for(;i.pos<h;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=Qr.codec().decode(i,i.uint32());break;case 3:a.streamInfo=Ve.codec().decode(i,i.uint32());break;case 4:a.identify=Zr.codec().decode(i,i.uint32());break;case 5:a.dht=Ot.codec().decode(i,i.uint32());break;case 6:a.peers.push(ne.codec().decode(i,i.uint32()));break;case 7:a.pubsub=nn.codec().decode(i,i.uint32());break;case 8:a.peerStore=on.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(D||(D={}));var Zr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Zr||(Zr={}));var jr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(jr||(jr={}));var Xr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Xr||(Xr={}));var Jr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Jr||(Jr={}));var Qr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Qr||(Qr={}));var Ve;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.peer!=null&&e.peer.byteLength>0)&&(n.uint32(10),n.bytes(e.peer)),(i.writeDefaults===!0||e.addr!=null&&e.addr.byteLength>0)&&(n.uint32(18),n.bytes(e.addr)),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Ve||(Ve={}));var xt;(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=()=>Yt(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={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(xt||(xt={}));var Ot;(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=()=>Yt(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),ne.codec().encode(i.peer,s,{writeDefaults:!1})),i.value!=null&&(s.uint32(26),s.bytes(i.value)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=ne.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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(Ot||(Ot={}));var ne;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(ne||(ne={}));var tn;(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=()=>Yt(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={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(tn||(tn={}));var en;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(en||(en={}));var ie;(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=()=>Yt(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={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(ie||(ie={}));var rn;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(rn||(rn={}));var nn;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(nn||(nn={}));var sn;(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=()=>Yt(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 h of i.protos)s.uint32(26),s.string(h);a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={protos:[]},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(sn||(sn={}));var on;(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),ne.codec().encode(e.peer,n,{writeDefaults:!1})),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=ne.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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(on||(on={}));var Lc=Symbol.for("@achingbrain/uint8arraylist");function Bc(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 cn(r){return Boolean(r?.[Lc])}var lt=class{constructor(...t){Object.defineProperty(this,Lc,{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(cn(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(cn(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=Bc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Bc(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(cn(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 Et(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:Et(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),s=new lt;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],h=i,l=h+a.byteLength;if(i=l,t>=l)continue;let d=t>=h&&t<l,f=e>h&&e<=l;if(d&&f){if(t===h&&e===l){n.push(a);break}let g=t-h;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-h));continue}if(f){if(e===l){n.push(a);break}n.push(a.subarray(0,e-h));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!cn(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 h=a,l=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let g=e;g<=l;g+=f){f=0;for(let b=d;b>=0;b--){let S=this.get(g+b);if(n[b]!==S){f=Math.max(1,b-h[S]);break}}if(f===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=Vt(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=$t(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=$t(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=$t(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=Vt(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=$t(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=$t(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=$t(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=$t(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=$t(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof lt)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!he(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new lt;return n.bufs=t,e==null&&(e=t.reduce((i,s)=>i+s.byteLength,0)),n.length=e,n}};function an(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 Oc=4294967296,yt=class{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 yt(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 yt(e,n)}toBytes(t,e=0){let n=an(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 yt;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>Oc&&(i=0,++n>Oc&&(n=0))),new yt(n,i)}static fromNumber(t){if(t===0)return new yt;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 yt(i,n)}static fromBytes(t,e=0){let n=an(t),i=new yt,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 Eh=Math.pow(2,7),vh=Math.pow(2,14),Th=Math.pow(2,21),Sh=Math.pow(2,28),xh=Math.pow(2,35),Ah=Math.pow(2,42),_h=Math.pow(2,49),Ih=Math.pow(2,56),Rh=Math.pow(2,63),Te={encodingLength(r){return r<Eh?1:r<vh?2:r<Th?3:r<Sh?4:r<xh?5:r<Ah?6:r<_h?7:r<Ih?8:r<Rh?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=Vt(Te.encodingLength(r))),yt.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return yt.fromBytes(r,t).toNumber(!0)}};function Nc(r){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var un=r=>{let t=Te.encodingLength(r),e=Nc(t);return Te.encode(r,e),un.bytes=t,e};un.bytes=0;function ln(r){r=r??{};let t=r.lengthEncoder??un;return async function*(n){for await(let i of n){let s=t(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}}}ln.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??un;return new lt(e(r.byteLength),r)};var or=P(_r(),1),Dh=8,Ch=1024*1024*4,Se;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Se||(Se={}));var qi=r=>{let t=Te.decode(r);return qi.bytes=Te.encodingLength(t),t};qi.bytes=0;function cr(r){return async function*(e){let n=new lt,i=Se.LENGTH,s=-1,a=r?.lengthDecoder??qi,h=r?.maxLengthLength??Dh,l=r?.maxDataLength??Ch;for await(let d of e)for(n.append(d);n.byteLength>0;){if(i===Se.LENGTH)try{if(s=a(n),s<0)throw(0,or.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>l)throw(0,or.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let f=a.bytes;n.consume(f),r?.onLength!=null&&r.onLength(s),i=Se.DATA}catch(f){if(f instanceof RangeError){if(n.byteLength>h)throw(0,or.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw f}if(i===Se.DATA){if(n.byteLength<s)break;let f=n.sublist(0,s);n.consume(s),r?.onData!=null&&r.onData(f),yield f,i=Se.LENGTH}}if(n.byteLength>0)throw(0,or.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}cr.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 cr({...t??{},onLength:s=>{e=s}})(n)};function kc(r){let t=async function*(){let e=yield,n=new lt;for await(let i of r){if(e==null){n.append(i),e=yield n,n=new lt;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 lt);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}var fn=class{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}},ze=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new fn(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 fn(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()}};function Pc(r={}){return Lh(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 Lh(r,t){t=t??{};let e=t.onEnd,n=new ze,i,s,a,h=async()=>n.isEmpty()?a?{done:!0}:await new Promise((x,B)=>{s=I=>{s=null,n.push(I);try{x(r(n))}catch(C){B(C)}return i}}):r(n),l=x=>s!=null?s(x):(n.push(x),i),d=x=>(n=new ze,s!=null?s({error:x}):(n.push({error:x}),i)),f=x=>{if(a)return i;if(t?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:x})},g=x=>a?i:(a=!0,x!=null?d(x):l({done:!0})),b=()=>(n=new ze,g(),{done:!0}),S=x=>(g(x),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:h,return:b,throw:S,push:f,end:g,get readableLength(){return n.size}},e==null)return i;let w=i;return i={[Symbol.asyncIterator](){return this},next(){return w.next()},throw(x){return w.throw(x),e!=null&&(e(x),e=void 0),{done:!0}},return(){return w.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(x){return w.end(x),e!=null&&(e(x),e=void 0),i},get readableLength(){return w.readableLength}},i}function Ki(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function Mc(r){let t=Pc(),e=kc(r.source),n=Ki(),i,s=r.sink(async function*(){yield*t,yield*await n.promise}());return s.catch(h=>{i=h}),{reader:e,writer:t,stream:{sink:async h=>i!=null?await Promise.reject(i):(n.resolve(h),await s),source:e},rest:()=>t.end(),write:t.push,read:async()=>{let h=await e.next();if(h.value!=null)return h.value}}}var Yi=Tt("libp2p:daemon-protocol:stream-handler"),ar=class{constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=Mc(this.stream),this.decoder=cr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Yi("read received no value, closing stream"),await this.close()}write(t){Yi("write message"),this.shake.write(ln.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Yi("closing the stream"),await this.rest().sink([])}};var Wi=Symbol.for("@libp2p/peer-id");function He(r){return r!=null&&Boolean(r[Wi])}var Oh=Symbol.for("nodejs.util.inspect.custom"),Uc=Object.values(Jt).map(r=>r.decoder).reduce((r,t)=>r.or(t),Jt.identity.decoder),Fc=114,Gc=36,$c=37,ur=class{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()})`}get[Wi](){return!0}toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return N.createV1(Fc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return he(this.multihash.bytes,t);if(typeof t=="string")return Nh(t).equals(this);if(t?.multihash?.bytes!=null)return he(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Oh](){return`PeerId(${this.toString()})`}},lr=class extends ur{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},fr=class extends ur{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},hr=class extends ur{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function Nh(r,t){if(t=t??Uc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=ue(W.decode(`z${r}`));return r.startsWith("12D")?new fr({multihash:e}):r.startsWith("16U")?new hr({multihash:e}):new lr({multihash:e})}return se(Uc.decode(r))}function se(r){try{let t=ue(r);if(t.code===Er.code){if(t.digest.length===Gc)return new fr({multihash:t});if(t.digest.length===$c)return new hr({multihash:t})}if(t.code===br.code)return new lr({multihash:t})}catch{return kh(N.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function kh(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Fc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===br.code)return new lr({multihash:r.multihash});if(t.code===Er.code){if(t.digest.length===Gc)return new fr({multihash:r.multihash});if(t.digest.length===$c)return new hr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var hn=class{constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new v("value received is not a Uint8Array","ERR_INVALID_VALUE");let n=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.PUT_VALUE,key:t,value:e}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(await n.close(),s.type!==D.Type.OK)throw new v(s.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.GET_VALUE,key:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(i.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(i.dht==null||i.dht.value==null)throw new v("Invalid DHT get response","ERR_DHT_GET_FAILED");return i.dht.value}async findPeer(t){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.FIND_PEER,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(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 v("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:se(i.dht.peer.id),multiaddrs:i.dht.peer.addrs.map(s=>ot(s)),protocols:[]}}async provide(t){if(t==null||N.asCID(t)==null)throw new v("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.PROVIDE,cid:t.bytes}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(i.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||N.asCID(t)==null)throw new v("invalid cid received","ERR_INVALID_CID");let n=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(s.type!==D.Type.OK)throw await n.close(),new v(s.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(i=await n.read(),i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let a=Ot.decode(i);if(a.type===Ot.Type.END){await n.close();return}if(a.type===Ot.Type.VALUE&&a.peer!=null&&a.peer?.addrs!=null)yield{id:se(a.peer.id),multiaddrs:a.peer.addrs.map(h=>ot(h)),protocols:[]};else throw await n.close(),new v("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.GET_CLOSEST_PEERS,key:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(i.type!==D.Type.OK)throw await e.close(),new v(i.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await e.read(),n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=Ot.decode(n);if(s.type===Ot.Type.END){await e.close();return}if(s.type===Ot.Type.VALUE&&s.value!=null)yield{id:se(s.value),multiaddrs:[],protocols:[]};else throw await e.close(),new v("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:z.Type.DHT,dht:{type:xt.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(i.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(i.dht==null)throw new v("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return i.dht.value}};var pn=class{constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:z.Type.PUBSUB,pubsub:{type:ie.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=D.decode(e);if(await t.close(),n.type!==D.Type.OK)throw new v(n.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new v("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return n.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new v("data received is not a Uint8Array","ERR_INVALID_DATA");let n=await this.client.send({type:z.Type.PUBSUB,pubsub:{type:ie.Type.PUBLISH,topic:t,data:e}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(await n.close(),s.type!==D.Type.OK)throw new v(s.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async*subscribe(t){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:z.Type.PUBSUB,pubsub:{type:ie.Type.SUBSCRIBE,topic:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(i.type!==D.Type.OK)throw new v(i.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");for(;;){if(n=await e.read(),n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");yield rn.decode(n)}}};var Zi={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Vc=Tt("libp2p:daemon-client"),ji=class{constructor(t){this.multiaddr=t,this.tcp=Go()(),this.dht=new hn(this),this.pubsub=new pn(this)}async connectDaemon(){return await this.tcp.dial(this.multiaddr,{upgrader:Zi})}async send(t){let e=await this.connectDaemon(),n=new ar({stream:e});return n.write(z.encode(t)),n}async connect(t,e){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new v("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(a=>{if(!ri(a))throw new v("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let n=await this.send({type:z.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(a=>a.bytes)}}),i=await n.read();if(i==null)throw new v("unspecified","ERR_CONNECT_FAILED");let s=D.decode(i);if(s.type!==D.Type.OK){let a=s.error??{msg:"unspecified"};throw new v(a.msg??"unspecified","ERR_CONNECT_FAILED")}await n.close()}async identify(){let t=await this.send({type:z.Type.IDENTIFY}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=D.decode(e);if(n.type!==D.Type.OK)throw new v(n.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(n.identify==null||n.identify.addrs==null)throw new v("Invalid response","ERR_IDENTIFY_FAILED");let i=se(n.identify?.id),s=n.identify.addrs.map(a=>ot(a));return await t.close(),{peerId:i,addrs:s}}async listPeers(){let t=await this.send({type:z.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=D.decode(e);if(n.type!==D.Type.OK)throw new v(n.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),n.peers.map(i=>se(i.id))}async openStream(t,e){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new v("invalid protocol received","ERR_INVALID_PROTOCOL");let n=await this.send({type:z.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(s.type!==D.Type.OK)throw await n.close(),new v(s.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return n.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new v("invalid protocol received","ERR_INVALID_PROTOCOL");let n=this.tcp.createListener({upgrader:Zi,handler:l=>{Promise.resolve().then(async()=>{let d=new ar({stream:l}),f=await d.read();if(f==null)throw new v("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(Ve.decode(f).proto!==t)throw new v("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(d.rest())}).finally(()=>{l.close().catch(d=>{Vc.error(d)}),n.close().catch(d=>{Vc.error(d)})})}});await n.listen(ot("/ip4/127.0.0.1/tcp/0"));let i=n.getAddrs()[0];if(i==null)throw new v("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let s=await this.send({type:z.Type.STREAM_HANDLER,streamHandler:{addr:i.bytes,proto:[t]}}),a=await s.read();if(a==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let h=D.decode(a);if(await s.close(),h.type!==D.Type.OK)throw new v(h.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function Ph(r){return new ji(r)}return Ru(Mh);})();
|
|
4
|
+
`+s),r.push(i+"m+"+Br.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Uf()+t+" "+r[0]}function Uf(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ff(...r){return process.stderr.write(Cr.format(...r)+`
|
|
5
|
+
`)}function Gf(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function $f(){return process.env.DEBUG}function Vf(r){r.inspectOpts={};let t=Object.keys(J.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=J.inspectOpts[t[e]]}Br.exports=si()(J);var{formatters:co}=Br.exports;co.o=function(r){return this.inspectOpts.colors=this.useColors,Cr.inspect(r,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};co.O=function(r){return this.inspectOpts.colors=this.useColors,Cr.inspect(r,this.inspectOpts)}});var uo=L((wd,ci)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ci.exports=ro():ci.exports=ao()});var Lr=L((xd,lo)=>{lo.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 ho=L((Ad,fo)=>{fo.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 ai=L((_d,po)=>{var zf=ho();po.exports=r=>async t=>{t=zf(t);let e=I=>{typeof I.return=="function"&&I.return()},n=null,i=null,s=I=>{n=I,i&&i(I),e(t)},a=null,h=!1,l=()=>{h=!0,a&&a()},d=null,f=!1,g=()=>{f=!0,d&&d()},w=null,S=()=>{w&&w()},b=()=>new Promise((I,C)=>{a=w=I,i=C,r.once("drain",S)}),x=()=>(e(t),new Promise((I,C)=>{if(h||f||n)return I();d=a=I,i=C})),B=()=>{r.removeListener("error",s),r.removeListener("close",l),r.removeListener("finish",g),r.removeListener("drain",S)};r.once("error",s),r.once("close",l),r.once("finish",g);try{for await(let I of t){if(!r.writable||r.destroyed||n)break;r.write(I)===!1&&await b()}}catch(I){n||r.destroy(),n=I}try{if(r.writable&&r.end(),await x(),n)throw n}finally{B()}}});var ui=L((Id,mo)=>{var Hf=ai(),qf=Lr();mo.exports=r=>({sink:Hf(r),source:qf(r)})});var yo=L((Rd,go)=>{var Kf=ui();go.exports=r=>async function*(t){let e=Kf(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var bo=L((Dd,Oe)=>{Oe.exports=Lr();Oe.exports.source=Lr();Oe.exports.sink=ai();Oe.exports.transform=yo();Oe.exports.duplex=ui()});var fi=L((kr,vo)=>{(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 E=c*this[o++]+u[p]+m;m=Math.floor(E/67108864),u[p++]=E&67108863}return m}function a(o,c,u,p,m,y){for(var E=c&32767,T=c>>15;--y>=0;){var k=this[o]&32767,X=this[o++]>>15,bt=T*k+X*E;k=E*k+((bt&32767)<<15)+u[p]+(m&1073741823),m=(k>>>30)+(bt>>>15)+T*X+(m>>>30),u[p++]=k&1073741823}return m}function h(o,c,u,p,m,y){for(var E=c&16383,T=c>>14;--y>=0;){var k=this[o]&16383,X=this[o++]>>14,bt=T*k+X*E;k=E*k+((bt&16383)<<14)+u[p]+m,m=(k>>28)+(bt>>14)+T*X,u[p++]=k&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=h,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 f="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,S;for(w="0".charCodeAt(0),S=0;S<=9;++S)g[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)g[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)g[w++]=S;function b(o){return f.charAt(o)}function x(o,c){var u=g[o.charCodeAt(c)];return u??-1}function B(o){for(var c=this.t-1;c>=0;--c)o[c]=this[c];o.t=this.t,o.s=this.s}function I(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 C(o){var c=i();return c.fromInt(o),c}function $(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 E=u==8?o[p]&255:x(o,p);if(E<0){o.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=E:y+u>this.DB?(this[this.t-1]|=(E&(1<<this.DB-y)-1)<<y,this[this.t++]=E>>this.DB-y):this[this.t-1]|=E<<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 Y(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function ft(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="",E=this.t,T=this.DB-E*this.DB%c;if(E-- >0)for(T<this.DB&&(p=this[E]>>T)>0&&(m=!0,y=b(p));E>=0;)T<c?(p=(this[E]&(1<<T)-1)<<c-T,p|=this[--E]>>(T+=this.DB-c)):(p=this[E]>>(T-=c)&u,T<=0&&(T+=this.DB,--E)),p>0&&(m=!0),m&&(y+=b(p));return m?y:"0"}function ct(){var o=i();return n.ZERO.subTo(this,o),o}function it(){return this.s<0?this.negate():this}function at(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 xt(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 $c(){return this.t<=0?0:this.DB*(this.t-1)+xt(this[this.t-1]^this.s&this.DM)}function Vc(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 zc(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 Hc(o,c){var u=o%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(o/this.DB),E=this.s<<u&this.DM,T;for(T=this.t-1;T>=0;--T)c[T+y+1]=this[T]>>p|E,E=(this[T]&m)<<u;for(T=y-1;T>=0;--T)c[T]=0;c[y]=E,c.t=this.t+y+1,c.s=this.s,c.clamp()}function qc(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 E=u+1;E<this.t;++E)c[E-u-1]|=(this[E]&y)<<m,c[E-u]=this[E]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function Kc(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 Yc(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 Wc(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 Zc(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(),E=this.s,T=o.s,k=this.DB-xt(p[p.t-1]);k>0?(p.lShiftTo(k,y),m.lShiftTo(k,u)):(p.copyTo(y),m.copyTo(u));var X=y.t,bt=y[X-1];if(bt!=0){var pt=bt*(1<<this.F1)+(X>1?y[X-2]>>this.F2:0),Ut=this.FV/pt,dr=(1<<this.F1)/pt,_t=1<<this.F2,It=u.t,mr=It-X,Wt=c??i();for(y.dlShiftTo(mr,Wt),u.compareTo(Wt)>=0&&(u[u.t++]=1,u.subTo(Wt,u)),n.ONE.dlShiftTo(X,Wt),Wt.subTo(y,y);y.t<X;)y[y.t++]=0;for(;--mr>=0;){var bn=u[--It]==bt?this.DM:Math.floor(u[It]*Ut+(u[It-1]+_t)*dr);if((u[It]+=y.am(0,bn,u,mr,0,X))<bn)for(y.dlShiftTo(mr,Wt),u.subTo(Wt,u);u[It]<--bn;)u.subTo(Wt,u)}c!=null&&(u.drShiftTo(X,c),E!=T&&n.ZERO.subTo(c,c)),u.t=X,u.clamp(),k>0&&u.rShiftTo(k,u),E<0&&n.ZERO.subTo(u,u)}}}function Xc(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 se(o){this.m=o}function jc(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function Jc(o){return o}function Qc(o){o.divRemTo(this.m,null,o)}function ta(o,c,u){o.multiplyTo(c,u),this.reduce(u)}function ea(o,c){o.squareTo(c),this.reduce(c)}se.prototype.convert=jc,se.prototype.revert=Jc,se.prototype.reduce=Qc,se.prototype.mulTo=ta,se.prototype.sqrTo=ea;function ra(){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 oe(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 na(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 ia(o){var c=i();return o.copyTo(c),this.reduce(c),c}function sa(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 oa(o,c){o.squareTo(c),this.reduce(c)}function ca(o,c,u){o.multiplyTo(c,u),this.reduce(u)}oe.prototype.convert=na,oe.prototype.revert=ia,oe.prototype.reduce=sa,oe.prototype.mulTo=ca,oe.prototype.sqrTo=oa;function aa(){return(this.t>0?this[0]&1:this.s)==0}function ua(o,c){if(o>4294967295||o<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=xt(o)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(o&1<<y)>0)c.mulTo(p,m,u);else{var E=u;u=p,p=E}return c.revert(u)}function la(o,c){var u;return o<256||c.isEven()?u=new se(c):u=new oe(c),this.exp(o,u)}n.prototype.copyTo=B,n.prototype.fromInt=I,n.prototype.fromString=$,n.prototype.clamp=Y,n.prototype.dlShiftTo=Vc,n.prototype.drShiftTo=zc,n.prototype.lShiftTo=Hc,n.prototype.rShiftTo=qc,n.prototype.subTo=Kc,n.prototype.multiplyTo=Yc,n.prototype.squareTo=Wc,n.prototype.divRemTo=Zc,n.prototype.invDigit=ra,n.prototype.isEven=aa,n.prototype.exp=ua,n.prototype.toString=ft,n.prototype.negate=ct,n.prototype.abs=it,n.prototype.compareTo=at,n.prototype.bitLength=$c,n.prototype.mod=Xc,n.prototype.modPowInt=la,n.ZERO=C(0),n.ONE=C(1);function fa(){var o=i();return this.copyTo(o),o}function ha(){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 pa(){return this.t==0?this.s:this[0]<<24>>24}function da(){return this.t==0?this.s:this[0]<<16>>16}function ma(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function ga(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function ya(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=C(u),m=i(),y=i(),E="";for(this.divRemTo(p,m,y);m.signum()>0;)E=(u+y.intValue()).toString(o).substr(1)+E,m.divRemTo(p,m,y);return y.intValue().toString(o)+E}function ba(o,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,E=0,T=0;T<o.length;++T){var k=x(o,T);if(k<0){o.charAt(T)=="-"&&this.signum()==0&&(m=!0);continue}E=c*E+k,++y>=u&&(this.dMultiply(p),this.dAddOffset(E,0),y=0,E=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(E,0)),m&&n.ZERO.subTo(this,this)}function wa(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),dn,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 Ea(){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 va(o){return this.compareTo(o)==0}function Ta(o){return this.compareTo(o)<0?this:o}function Sa(o){return this.compareTo(o)>0?this:o}function xa(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 Aa(o,c){return o&c}function _a(o){var c=i();return this.bitwiseTo(o,Aa,c),c}function dn(o,c){return o|c}function Ia(o){var c=i();return this.bitwiseTo(o,dn,c),c}function Xi(o,c){return o^c}function Ra(o){var c=i();return this.bitwiseTo(o,Xi,c),c}function ji(o,c){return o&~c}function Da(o){var c=i();return this.bitwiseTo(o,ji,c),c}function Ca(){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 Ba(o){var c=i();return o<0?this.rShiftTo(-o,c):this.lShiftTo(o,c),c}function La(o){var c=i();return o<0?this.lShiftTo(-o,c):this.rShiftTo(o,c),c}function Na(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 Oa(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+Na(this[o]);return this.s<0?this.t*this.DB:-1}function ka(o){for(var c=0;o!=0;)o&=o-1,++c;return c}function Pa(){for(var o=0,c=this.s&this.DM,u=0;u<this.t;++u)o+=ka(this[u]^c);return o}function Ma(o){var c=Math.floor(o/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<o%this.DB)!=0}function Ua(o,c){var u=n.ONE.shiftLeft(o);return this.bitwiseTo(u,c,u),u}function Fa(o){return this.changeBit(o,dn)}function Ga(o){return this.changeBit(o,ji)}function $a(o){return this.changeBit(o,Xi)}function Va(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 za(o){var c=i();return this.addTo(o,c),c}function Ha(o){var c=i();return this.subTo(o,c),c}function qa(o){var c=i();return this.multiplyTo(o,c),c}function Ka(){var o=i();return this.squareTo(o),o}function Ya(o){var c=i();return this.divRemTo(o,c,null),c}function Wa(o){var c=i();return this.divRemTo(o,null,c),c}function Za(o){var c=i(),u=i();return this.divRemTo(o,c,u),new Array(c,u)}function Xa(o){this[this.t]=this.am(0,o-1,this,0,0,this.t),++this.t,this.clamp()}function ja(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 qe(){}function Ji(o){return o}function Ja(o,c,u){o.multiplyTo(c,u)}function Qa(o,c){o.squareTo(c)}qe.prototype.convert=Ji,qe.prototype.revert=Ji,qe.prototype.mulTo=Ja,qe.prototype.sqrTo=Qa;function tu(o){return this.exp(o,new qe)}function eu(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 ru(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 ce(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 nu(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 iu(o){return o}function su(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 ou(o,c){o.squareTo(c),this.reduce(c)}function cu(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ce.prototype.convert=nu,ce.prototype.revert=iu,ce.prototype.reduce=su,ce.prototype.mulTo=cu,ce.prototype.sqrTo=ou;function au(o,c){var u=o.bitLength(),p,m=C(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 se(c):c.isEven()?y=new ce(c):y=new oe(c);var E=new Array,T=3,k=p-1,X=(1<<p)-1;if(E[1]=y.convert(this),p>1){var bt=i();for(y.sqrTo(E[1],bt);T<=X;)E[T]=i(),y.mulTo(bt,E[T-2],E[T]),T+=2}var pt=o.t-1,Ut,dr=!0,_t=i(),It;for(u=xt(o[pt])-1;pt>=0;){for(u>=k?Ut=o[pt]>>u-k&X:(Ut=(o[pt]&(1<<u+1)-1)<<k-u,pt>0&&(Ut|=o[pt-1]>>this.DB+u-k)),T=p;!(Ut&1);)Ut>>=1,--T;if((u-=T)<0&&(u+=this.DB,--pt),dr)E[Ut].copyTo(m),dr=!1;else{for(;T>1;)y.sqrTo(m,_t),y.sqrTo(_t,m),T-=2;T>0?y.sqrTo(m,_t):(It=m,m=_t,_t=It),y.mulTo(_t,E[Ut],m)}for(;pt>=0&&!(o[pt]&1<<u);)y.sqrTo(m,_t),It=m,m=_t,_t=It,--u<0&&(u=this.DB-1,--pt)}return y.revert(m)}function uu(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 lu(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 fu(o){var c=o.isEven();if(this.isEven()&&c||o.signum()==0)return n.ZERO;for(var u=o.clone(),p=this.clone(),m=C(1),y=C(0),E=C(0),T=C(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?((!E.isEven()||!T.isEven())&&(E.addTo(this,E),T.subTo(o,T)),E.rShiftTo(1,E)):T.isEven()||T.subTo(o,T),T.rShiftTo(1,T);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(E,m),y.subTo(T,y)):(p.subTo(u,p),c&&E.subTo(m,E),T.subTo(y,T))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(T.compareTo(o)>=0)return T.subtract(o);if(T.signum()<0)T.addTo(o,T);else return T;return T.signum()<0?T.add(o):T}var st=[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],hu=(1<<26)/st[st.length-1];function pu(o){var c,u=this.abs();if(u.t==1&&u[0]<=st[st.length-1]){for(c=0;c<st.length;++c)if(u[0]==st[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<st.length;){for(var p=st[c],m=c+1;m<st.length&&p<hu;)p*=st[m++];for(p=u.modInt(p);c<m;)if(p%st[c++]==0)return!1}return u.millerRabin(o)}function du(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>st.length&&(o=st.length);for(var m=i(),y=0;y<o;++y){m.fromInt(st[Math.floor(Math.random()*st.length)]);var E=m.modPow(p,this);if(E.compareTo(n.ONE)!=0&&E.compareTo(c)!=0){for(var T=1;T++<u&&E.compareTo(c)!=0;)if(E=E.modPowInt(2,this),E.compareTo(n.ONE)==0)return!1;if(E.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=ma,n.prototype.toRadix=ya,n.prototype.fromRadix=ba,n.prototype.fromNumber=wa,n.prototype.bitwiseTo=xa,n.prototype.changeBit=Ua,n.prototype.addTo=Va,n.prototype.dMultiply=Xa,n.prototype.dAddOffset=ja,n.prototype.multiplyLowerTo=eu,n.prototype.multiplyUpperTo=ru,n.prototype.modInt=lu,n.prototype.millerRabin=du,n.prototype.clone=fa,n.prototype.intValue=ha,n.prototype.byteValue=pa,n.prototype.shortValue=da,n.prototype.signum=ga,n.prototype.toByteArray=Ea,n.prototype.equals=va,n.prototype.min=Ta,n.prototype.max=Sa,n.prototype.and=_a,n.prototype.or=Ia,n.prototype.xor=Ra,n.prototype.andNot=Da,n.prototype.not=Ca,n.prototype.shiftLeft=Ba,n.prototype.shiftRight=La,n.prototype.getLowestSetBit=Oa,n.prototype.bitCount=Pa,n.prototype.testBit=Ma,n.prototype.setBit=Fa,n.prototype.clearBit=Ga,n.prototype.flipBit=$a,n.prototype.add=za,n.prototype.subtract=Ha,n.prototype.multiply=qa,n.prototype.divide=Ya,n.prototype.remainder=Wa,n.prototype.divideAndRemainder=Za,n.prototype.modPow=au,n.prototype.modInverse=fu,n.prototype.pow=tu,n.prototype.gcd=uu,n.prototype.isProbablePrime=pu,n.prototype.square=Ka,n.prototype.Barrett=ce;var pr,ht,Z;function mu(o){ht[Z++]^=o&255,ht[Z++]^=o>>8&255,ht[Z++]^=o>>16&255,ht[Z++]^=o>>24&255,Z>=yn&&(Z-=yn)}function Qi(){mu(new Date().getTime())}if(ht==null){ht=new Array,Z=0;var At;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var ts=new Uint8Array(32);for(window.crypto.getRandomValues(ts),At=0;At<32;++At)ht[Z++]=ts[At]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var es=window.crypto.random(32);for(At=0;At<es.length;++At)ht[Z++]=es.charCodeAt(At)&255}}for(;Z<yn;)At=Math.floor(65536*Math.random()),ht[Z++]=At>>>8,ht[Z++]=At&255;Z=0,Qi()}function gu(){if(pr==null){for(Qi(),pr=Eu(),pr.init(ht),Z=0;Z<ht.length;++Z)ht[Z]=0;Z=0}return pr.next()}function yu(o){var c;for(c=0;c<o.length;++c)o[c]=gu()}function mn(){}mn.prototype.nextBytes=yu;function gn(){this.i=0,this.j=0,this.S=new Array}function bu(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 wu(){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]}gn.prototype.init=bu,gn.prototype.next=wu;function Eu(){return new gn}var yn=256;typeof kr<"u"?kr=vo.exports={default:n,BigInteger:n,SecureRandom:mn}:this.jsbn={BigInteger:n,SecureRandom:mn}}).call(kr)});var nr=L(Pr=>{(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,h){return t.apply(null,[a].concat(h||[]))}function n(a,h){var l=1,d=a.length,f,g="",w,S,b,x,B,I,C,$;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(f=h[l],S=0;S<b.keys.length;S++){if(f==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',b.keys[S],b.keys[S-1]));f=f[b.keys[S]]}else b.param_no?f=h[b.param_no]:f=h[l++];if(r.not_type.test(b.type)&&r.not_primitive.test(b.type)&&f instanceof Function&&(f=f()),r.numeric_arg.test(b.type)&&typeof f!="number"&&isNaN(f))throw new TypeError(t("[sprintf] expecting number but found %T",f));switch(r.number.test(b.type)&&(C=f>=0),b.type){case"b":f=parseInt(f,10).toString(2);break;case"c":f=String.fromCharCode(parseInt(f,10));break;case"d":case"i":f=parseInt(f,10);break;case"j":f=JSON.stringify(f,null,b.width?parseInt(b.width):0);break;case"e":f=b.precision?parseFloat(f).toExponential(b.precision):parseFloat(f).toExponential();break;case"f":f=b.precision?parseFloat(f).toFixed(b.precision):parseFloat(f);break;case"g":f=b.precision?String(Number(f.toPrecision(b.precision))):parseFloat(f);break;case"o":f=(parseInt(f,10)>>>0).toString(8);break;case"s":f=String(f),f=b.precision?f.substring(0,b.precision):f;break;case"t":f=String(!!f),f=b.precision?f.substring(0,b.precision):f;break;case"T":f=Object.prototype.toString.call(f).slice(8,-1).toLowerCase(),f=b.precision?f.substring(0,b.precision):f;break;case"u":f=parseInt(f,10)>>>0;break;case"v":f=f.valueOf(),f=b.precision?f.substring(0,b.precision):f;break;case"x":f=(parseInt(f,10)>>>0).toString(16);break;case"X":f=(parseInt(f,10)>>>0).toString(16).toUpperCase();break}r.json.test(b.type)?g+=f:(r.number.test(b.type)&&(!C||b.sign)?($=C?"+":"-",f=f.toString().replace(r.sign,"")):$="",B=b.pad_char?b.pad_char==="0"?"0":b.pad_char.charAt(1):" ",I=b.width-($+f).length,x=b.width&&I>0?B.repeat(I):"",g+=b.align?$+f+x:B==="0"?$+x+f:x+$+f)}return g}var i=Object.create(null);function s(a){if(i[a])return i[a];for(var h=a,l,d=[],f=0;h;){if((l=r.text.exec(h))!==null)d.push(l[0]);else if((l=r.modulo.exec(h))!==null)d.push("%");else if((l=r.placeholder.exec(h))!==null){if(l[2]){f|=1;var g=[],w=l[2],S=[];if((S=r.key.exec(w))!==null)for(g.push(S[1]);(w=w.substring(S[0].length))!=="";)if((S=r.key_access.exec(w))!==null)g.push(S[1]);else if((S=r.index_access.exec(w))!==null)g.push(S[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 f|=2;if(f===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");h=h.substring(l[0].length)}return i[a]=d}typeof Pr<"u"&&(Pr.sprintf=t,Pr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var Go=L((bm,Fo)=>{"use strict";Fo.exports=ah;function ah(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(h,l){e[n]=function(f){if(s)if(s=!1,f)l(f);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];h.apply(null,g)}};try{r.apply(t||null,e)}catch(d){s&&(s=!1,l(d))}})}});var Ho=L(zo=>{"use strict";var Hr=zo;Hr.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 Ge=new Array(64),Vo=new Array(123);for(Bt=0;Bt<64;)Vo[Ge[Bt]=Bt<26?Bt+65:Bt<52?Bt+71:Bt<62?Bt-4:Bt-59|43]=Bt++;var Bt;Hr.encode=function(t,e,n){for(var i=null,s=[],a=0,h=0,l;e<n;){var d=t[e++];switch(h){case 0:s[a++]=Ge[d>>2],l=(d&3)<<4,h=1;break;case 1:s[a++]=Ge[l|d>>4],l=(d&15)<<2,h=2;break;case 2:s[a++]=Ge[l|d>>6],s[a++]=Ge[d&63],h=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return h&&(s[a++]=Ge[l],s[a++]=61,h===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 $o="invalid encoding";Hr.decode=function(t,e,n){for(var i=n,s=0,a,h=0;h<t.length;){var l=t.charCodeAt(h++);if(l===61&&s>1)break;if((l=Vo[l])===void 0)throw Error($o);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($o);return n-i};Hr.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var Ko=L((Em,qo)=>{"use strict";qo.exports=qr;function qr(){this._listeners={}}qr.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};qr.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};qr.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 Qo=L((vm,Jo)=>{"use strict";Jo.exports=Yo(Yo);function Yo(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(l,d,f){t[0]=l,d[f]=e[0],d[f+1]=e[1],d[f+2]=e[2],d[f+3]=e[3]}function s(l,d,f){t[0]=l,d[f]=e[3],d[f+1]=e[2],d[f+2]=e[1],d[f+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 h(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:h,r.readFloatBE=n?h:a}():function(){function t(n,i,s,a){var h=i<0?1:0;if(h&&(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((h<<31|2139095040)>>>0,s,a);else if(i<11754943508222875e-54)n((h<<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((h<<31|l+127<<23|d)>>>0,s,a)}}r.writeFloatLE=t.bind(null,Wo),r.writeFloatBE=t.bind(null,Zo);function e(n,i,s){var a=n(i,s),h=(a>>31)*2+1,l=a>>>23&255,d=a&8388607;return l===255?d?NaN:h*(1/0):l===0?h*1401298464324817e-60*d:h*Math.pow(2,l-150)*(d+8388608)}r.readFloatLE=e.bind(null,Xo),r.readFloatBE=e.bind(null,jo)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(l,d,f){t[0]=l,d[f]=e[0],d[f+1]=e[1],d[f+2]=e[2],d[f+3]=e[3],d[f+4]=e[4],d[f+5]=e[5],d[f+6]=e[6],d[f+7]=e[7]}function s(l,d,f){t[0]=l,d[f]=e[7],d[f+1]=e[6],d[f+2]=e[5],d[f+3]=e[4],d[f+4]=e[3],d[f+5]=e[2],d[f+6]=e[1],d[f+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 h(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:h,r.readDoubleBE=n?h:a}():function(){function t(n,i,s,a,h,l){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,h,l+i),n(1/a>0?0:2147483648,h,l+s);else if(isNaN(a))n(0,h,l+i),n(2146959360,h,l+s);else if(a>17976931348623157e292)n(0,h,l+i),n((d<<31|2146435072)>>>0,h,l+s);else{var f;if(a<22250738585072014e-324)f=a/5e-324,n(f>>>0,h,l+i),n((d<<31|f/4294967296)>>>0,h,l+s);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),f=a*Math.pow(2,-g),n(f*4503599627370496>>>0,h,l+i),n((d<<31|g+1023<<20|f*1048576&1048575)>>>0,h,l+s)}}}r.writeDoubleLE=t.bind(null,Wo,0,4),r.writeDoubleBE=t.bind(null,Zo,4,0);function e(n,i,s,a,h){var l=n(a,h+i),d=n(a,h+s),f=(d>>31)*2+1,g=d>>>20&2047,w=4294967296*(d&1048575)+l;return g===2047?w?NaN:f*(1/0):g===0?f*5e-324*w:f*Math.pow(2,g-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,Xo,0,4),r.readDoubleBE=e.bind(null,jo,4,0)}(),r}function Wo(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 Zo(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 Xo(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function jo(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var tc=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 rc=L(ec=>{"use strict";var Ri=ec;Ri.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};Ri.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var s=null,a=[],h=0,l;e<n;)l=t[e++],l<128?a[h++]=l:l>191&&l<224?a[h++]=(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[h++]=55296+(l>>10),a[h++]=56320+(l&1023)):a[h++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,h>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),h=0);return s?(h&&s.push(String.fromCharCode.apply(String,a.slice(0,h))),s.join("")):String.fromCharCode.apply(String,a.slice(0,h))};Ri.write=function(t,e,n){for(var i=n,s,a,h=0;h<t.length;++h)s=t.charCodeAt(h),s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&((a=t.charCodeAt(h+1))&64512)===56320?(s=65536+((s&1023)<<10)+(a&1023),++h,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 ic=L((Sm,nc)=>{"use strict";nc.exports=uh;function uh(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 oc=L((xm,sc)=>{"use strict";sc.exports=j;var ir=we();function j(r,t){this.lo=r>>>0,this.hi=t>>>0}var be=j.zero=new j(0,0);be.toNumber=function(){return 0};be.zzEncode=be.zzDecode=function(){return this};be.length=function(){return 1};var lh=j.zeroHash="\0\0\0\0\0\0\0\0";j.fromNumber=function(t){if(t===0)return be;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 j(n,i)};j.from=function(t){if(typeof t=="number")return j.fromNumber(t);if(ir.isString(t))if(ir.Long)t=ir.Long.fromString(t);else return j.fromNumber(parseInt(t,10));return t.low||t.high?new j(t.low>>>0,t.high>>>0):be};j.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};j.prototype.toLong=function(t){return ir.Long?new ir.Long(this.lo|0,this.hi|0,Boolean(t)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(t)}};var te=String.prototype.charCodeAt;j.fromHash=function(t){return t===lh?be:new j((te.call(t,0)|te.call(t,1)<<8|te.call(t,2)<<16|te.call(t,3)<<24)>>>0,(te.call(t,4)|te.call(t,5)<<8|te.call(t,6)<<16|te.call(t,7)<<24)>>>0)};j.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)};j.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};j.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};j.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 we=L(Di=>{"use strict";var A=Di;A.asPromise=Go();A.base64=Ho();A.EventEmitter=Ko();A.float=Qo();A.inquire=tc();A.utf8=rc();A.pool=ic();A.LongBits=oc();A.isNode=Boolean(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||Di;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(Boolean(e))};function cc(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=cc;A.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function ac(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&&cc(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=ac;A.ProtocolError=ac("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 Li=L((_m,pc)=>{"use strict";pc.exports=V;var Pt=we(),Bi,fc=Pt.LongBits,fh=Pt.utf8;function Lt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function V(r){this.buf=r,this.pos=0,this.len=r.length}var uc=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new V(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new V(t);throw Error("illegal buffer")},hc=function(){return Pt.Buffer?function(e){return(V.create=function(i){return Pt.Buffer.isBuffer(i)?new Bi(i):uc(i)})(e)}:uc};V.create=hc();V.prototype._slice=Pt.Array.prototype.subarray||Pt.Array.prototype.slice;V.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,Lt(this,10);return t}}();V.prototype.int32=function(){return this.uint32()|0};V.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Ci(){var r=new fc(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 Lt(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 Lt(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")}V.prototype.bool=function(){return this.uint32()!==0};function Kr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}V.prototype.fixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return Kr(this.buf,this.pos+=4)};V.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return Kr(this.buf,this.pos+=4)|0};function lc(){if(this.pos+8>this.len)throw Lt(this,8);return new fc(Kr(this.buf,this.pos+=4),Kr(this.buf,this.pos+=4))}V.prototype.float=function(){if(this.pos+4>this.len)throw Lt(this,4);var t=Pt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};V.prototype.double=function(){if(this.pos+8>this.len)throw Lt(this,4);var t=Pt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};V.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(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)};V.prototype.string=function(){var t=this.bytes();return fh.read(t,0,t.length)};V.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while(this.buf[this.pos++]&128);return this};V.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};V._configure=function(r){Bi=r,V.create=hc(),Bi._configure();var t=Pt.Long?"toLong":"toNumber";Pt.merge(V.prototype,{int64:function(){return Ci.call(this)[t](!1)},uint64:function(){return Ci.call(this)[t](!0)},sint64:function(){return Ci.call(this).zzDecode()[t](!1)},fixed64:function(){return lc.call(this)[t](!0)},sfixed64:function(){return lc.call(this)[t](!1)}})}});var yc=L((Im,gc)=>{"use strict";gc.exports=Ee;var mc=Li();(Ee.prototype=Object.create(mc.prototype)).constructor=Ee;var dc=we();function Ee(r){mc.call(this,r)}Ee._configure=function(){dc.Buffer&&(Ee.prototype._slice=dc.Buffer.prototype.slice)};Ee.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))};Ee._configure()});var Fi=L((Rm,vc)=>{"use strict";vc.exports=N;var Tt=we(),Ni,Yr=Tt.LongBits,bc=Tt.base64,wc=Tt.utf8;function sr(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function ki(){}function hh(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 sr(ki,0,0),this.tail=this.head,this.states=null}var Ec=function(){return Tt.Buffer?function(){return(N.create=function(){return new Ni})()}:function(){return new N}};N.create=Ec();N.alloc=function(t){return new Tt.Array(t)};Tt.Array!==Array&&(N.alloc=Tt.pool(N.alloc,Tt.Array.prototype.subarray));N.prototype._push=function(t,e,n){return this.tail=this.tail.next=new sr(t,e,n),this.len+=e,this};function Pi(r,t,e){t[e]=r&255}function ph(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function Mi(r,t){this.len=r,this.next=void 0,this.val=t}Mi.prototype=Object.create(sr.prototype);Mi.prototype.fn=ph;N.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Mi((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(Ui,10,Yr.fromNumber(t)):this.uint32(t)};N.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Ui(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=Yr.from(t);return this._push(Ui,e.length(),e)};N.prototype.int64=N.prototype.uint64;N.prototype.sint64=function(t){var e=Yr.from(t).zzEncode();return this._push(Ui,e.length(),e)};N.prototype.bool=function(t){return this._push(Pi,1,t?1:0)};function Oi(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(Oi,4,t>>>0)};N.prototype.sfixed32=N.prototype.fixed32;N.prototype.fixed64=function(t){var e=Yr.from(t);return this._push(Oi,4,e.lo)._push(Oi,4,e.hi)};N.prototype.sfixed64=N.prototype.fixed64;N.prototype.float=function(t){return this._push(Tt.float.writeFloatLE,4,t)};N.prototype.double=function(t){return this._push(Tt.float.writeDoubleLE,8,t)};var dh=Tt.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(Pi,1,0);if(Tt.isString(t)){var n=N.alloc(e=bc.length(t));bc.decode(t,n,0),t=n}return this.uint32(e)._push(dh,e,t)};N.prototype.string=function(t){var e=wc.length(t);return e?this.uint32(e)._push(wc.write,e,t):this._push(Pi,1,0)};N.prototype.fork=function(){return this.states=new hh(this),this.head=this.tail=new sr(ki,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 sr(ki,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){Ni=r,N.create=Ec(),Ni._configure()}});var xc=L((Dm,Sc)=>{"use strict";Sc.exports=Mt;var Tc=Fi();(Mt.prototype=Object.create(Tc.prototype)).constructor=Mt;var ee=we();function Mt(){Tc.call(this)}Mt._configure=function(){Mt.alloc=ee._Buffer_allocUnsafe,Mt.writeBytesBuffer=ee.Buffer&&ee.Buffer.prototype instanceof Uint8Array&&ee.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++]}};Mt.prototype.bytes=function(t){ee.isString(t)&&(t=ee._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Mt.writeBytesBuffer,e,t),this};function mh(r,t,e){r.length<40?ee.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Mt.prototype.string=function(t){var e=ee.Buffer.byteLength(t);return this.uint32(e),e&&this._push(mh,e,t),this};Mt._configure()});var Ph={};dt(Ph,{createClient:()=>kh});var Gt=class extends Error{constructor(t="The operation was aborted"){super(t),this.code=Gt.code,this.type=Gt.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},v=class extends Error{constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Mo=P(Ft("net"),1);var Zt=Ft("node:net");function yr(r){return Boolean((0,Zt.isIP)(r))}var Sn={};dt(Sn,{identity:()=>Lu});function Iu(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 h=r.length,l=r.charAt(0),d=Math.log(h)/Math.log(256),f=Math.log(256)/Math.log(h);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 x=0,B=0,I=0,C=b.length;I!==C&&b[I]===0;)I++,x++;for(var $=(C-I)*f+1>>>0,Y=new Uint8Array($);I!==C;){for(var ft=b[I],ct=0,it=$-1;(ft!==0||ct<B)&&it!==-1;it--,ct++)ft+=256*Y[it]>>>0,Y[it]=ft%h>>>0,ft=ft/h>>>0;if(ft!==0)throw new Error("Non-zero carry");B=ct,I++}for(var at=$-B;at!==$&&Y[at]===0;)at++;for(var xt=l.repeat(x);at<$;++at)xt+=r.charAt(Y[at]);return xt}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var x=0;if(b[x]!==" "){for(var B=0,I=0;b[x]===l;)B++,x++;for(var C=(b.length-x)*d+1>>>0,$=new Uint8Array(C);b[x];){var Y=e[b.charCodeAt(x)];if(Y===255)return;for(var ft=0,ct=C-1;(Y!==0||ft<I)&&ct!==-1;ct--,ft++)Y+=h*$[ct]>>>0,$[ct]=Y%256>>>0,Y=Y/256>>>0;if(Y!==0)throw new Error("Non-zero carry");I=ft,x++}if(b[x]!==" "){for(var it=C-I;it!==C&&$[it]===0;)it++;for(var at=new Uint8Array(B+(C-it)),xt=B;it!==C;)at[xt++]=$[it++];return at}}}function S(b){var x=w(b);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:S}}var Ru=Iu,Du=Ru,ns=Du;var $h=new Uint8Array(0);var is=(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 ss=r=>new TextEncoder().encode(r),os=r=>new TextDecoder().decode(r);var wn=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")}},En=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 as(this,t)}},vn=class{constructor(t){this.decoders=t}or(t){return as(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`)}},as=(r,t)=>new vn({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Tn=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new wn(t,e,n),this.decoder=new En(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Se=({name:r,prefix:t,encode:e,decode:n})=>new Tn(r,t,e,n),Xt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=ns(e,t);return Se({prefix:r,name:t,encode:n,decode:s=>wt(i(s))})},Cu=(r,t,e,n)=>{let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*e/8|0),h=0,l=0,d=0;for(let f=0;f<s;++f){let g=i[r[f]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,h+=e,h>=8&&(h-=8,a[d++]=255&l>>h)}if(h>=e||255&l<<8-h)throw new SyntaxError("Unexpected end of data");return a},Bu=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,s="",a=0,h=0;for(let l=0;l<r.length;++l)for(h=h<<8|r[l],a+=8;a>e;)a-=e,s+=t[i&h>>a];if(a&&(s+=t[i&h<<e-a]),n)for(;s.length*e&7;)s+="=";return s},F=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Se({prefix:t,name:r,encode(i){return Bu(i,n,e)},decode(i){return Cu(i,n,e,r)}});var Lu=Se({prefix:"\0",name:"identity",encode:r=>os(r),decode:r=>ss(r)});var xn={};dt(xn,{base2:()=>Nu});var Nu=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var An={};dt(An,{base8:()=>Ou});var Ou=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _n={};dt(_n,{base10:()=>ku});var ku=Xt({prefix:"9",name:"base10",alphabet:"0123456789"});var In={};dt(In,{base16:()=>Pu,base16upper:()=>Mu});var Pu=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Mu=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rn={};dt(Rn,{base32:()=>Rt,base32hex:()=>$u,base32hexpad:()=>zu,base32hexpadupper:()=>Hu,base32hexupper:()=>Vu,base32pad:()=>Fu,base32padupper:()=>Gu,base32upper:()=>Uu,base32z:()=>qu});var Rt=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Uu=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fu=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gu=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$u=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vu=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),zu=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hu=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qu=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Dn={};dt(Dn,{base36:()=>Ku,base36upper:()=>Yu});var Ku=Xt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yu=Xt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Cn={};dt(Cn,{base58btc:()=>W,base58flickr:()=>Wu});var W=Xt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wu=Xt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ln={};dt(Ln,{base64:()=>Bn,base64pad:()=>Zu,base64url:()=>Xu,base64urlpad:()=>ju});var Bn=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Zu=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xu=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ju=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nn={};dt(Nn,{base256emoji:()=>rl});var us=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}"),Ju=us.reduce((r,t,e)=>(r[e]=t,r),[]),Qu=us.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function tl(r){return r.reduce((t,e)=>(t+=Ju[e],t),"")}function el(r){let t=[];for(let e of r){let n=Qu[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var rl=Se({prefix:"\u{1F680}",name:"base256emoji",encode:tl,decode:el});var Un={};dt(Un,{sha256:()=>wr,sha512:()=>vl});var Mn=P(Ft("crypto"),1);var nl=hs,ls=128,il=127,sl=~il,ol=Math.pow(2,31);function hs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ol;)t[e++]=r&255|ls,r/=128;for(;r&sl;)t[e++]=r&255|ls,r>>>=7;return t[e]=r|0,hs.bytes=e-n+1,t}var cl=On,al=128,fs=127;function On(r,n){var e=0,n=n||0,i=0,s=n,a,h=r.length;do{if(s>=h)throw On.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&fs)<<i:(a&fs)*Math.pow(2,i),i+=7}while(a>=al);return On.bytes=s-n,e}var ul=Math.pow(2,7),ll=Math.pow(2,14),fl=Math.pow(2,21),hl=Math.pow(2,28),pl=Math.pow(2,35),dl=Math.pow(2,42),ml=Math.pow(2,49),gl=Math.pow(2,56),yl=Math.pow(2,63),bl=function(r){return r<ul?1:r<ll?2:r<fl?3:r<hl?4:r<pl?5:r<dl?6:r<ml?7:r<gl?8:r<yl?9:10},wl={encode:nl,decode:cl,encodingLength:bl},El=wl,Ke=El;var Ye=(r,t=0)=>[Ke.decode(r,t),Ke.decode.bytes],xe=(r,t,e=0)=>(Ke.encode(r,t,e),t),Ae=r=>Ke.encodingLength(r);var jt=(r,t)=>{let e=t.byteLength,n=Ae(r),i=n+Ae(e),s=new Uint8Array(i+e);return xe(r,s,0),xe(e,s,n),s.set(t,i),new _e(r,e,t,s)},ae=r=>{let t=wt(r),[e,n]=Ye(t),[i,s]=Ye(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new _e(e,i,a,t)},ps=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&is(r.bytes,e.bytes)}},_e=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Pn=({name:r,code:t,encode:e})=>new kn(r,t,e),kn=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?jt(this.code,e):e.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var wr=Pn({name:"sha2-256",code:18,encode:r=>wt(Mn.default.createHash("sha256").update(r).digest())}),vl=Pn({name:"sha2-512",code:19,encode:r=>wt(Mn.default.createHash("sha512").update(r).digest())});var Fn={};dt(Fn,{identity:()=>Er});var ms=0,Tl="identity",gs=wt,Sl=r=>jt(ms,gs(r)),Er={code:ms,name:Tl,encode:gs,digest:Sl};var up=new TextEncoder,lp=new TextDecoder;var ys=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Il(e,Gn(r),t||W.encoder);default:return Rl(e,Gn(r),t||Rt.encoder)}};var bs=new WeakMap,Gn=r=>{let t=bs.get(r);if(t==null){let e=new Map;return bs.set(r,e),e}return t},O=class{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!==We)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Dl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return O.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=jt(t,e);return O.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 O.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&ps(t.multihash,n.multihash)}toString(t){return ys(this,t)}toJSON(){return{"/":ys(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 O)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:s,bytes:a}=e;return new O(n,i,s,a||ws(n,i,s.bytes))}else if(e[Cl]===!0){let{version:n,multihash:i,code:s}=e,a=ae(i);return O.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!==We)throw new Error(`Version 0 CID must use dag-pb (code: ${We}) block encoding`);return new O(t,e,n,n.bytes)}case 1:{let i=ws(t,e,n.bytes);return new O(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return O.create(0,We,t)}static createV1(t,e){return O.create(1,t,e)}static decode(t){let[e,n]=O.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=O.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 _e(e.multihashCode,e.digestSize,s,i);return[e.version===0?O.createV0(a):O.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=Ye(t.subarray(e));return e+=w,g},i=n(),s=We;if(i===18?(i=0,e=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,h=n(),l=n(),d=e+l,f=d-a;return{version:i,codec:s,multihashCode:h,digestSize:l,multihashSize:f,size:d}}static parse(t,e){let[n,i]=_l(t,e),s=O.decode(i);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Gn(s).set(n,t),s}},_l=(r,t)=>{switch(r[0]){case"Q":{let e=t||W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t||W;return[W.prefix,e.decode(r)]}case Rt.prefix:{let e=t||Rt;return[Rt.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)]}}},Il=(r,t,e)=>{let{prefix:n}=e;if(n!==W.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},Rl=(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},We=112,Dl=18,ws=(r,t,e)=>{let n=Ae(r),i=n+Ae(t),s=new Uint8Array(i+e.byteLength);return xe(r,s,0),xe(t,s,n),s.set(e,i),s},Cl=Symbol.for("@ipld/js-cid/CID");var Jt={...Sn,...xn,...An,..._n,...In,...Rn,...Dn,...Cn,...Ln,...Nn},Ep={...Un,...Fn};function le(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function $t(r=0){return globalThis.Buffer?.alloc!=null?le(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Vt(r=0){return globalThis.Buffer?.allocUnsafe!=null?le(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function vs(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Es=vs("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$n=vs("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=Vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Bl={utf8:Es,"utf-8":Es,hex:Jt.base16,latin1:$n,ascii:$n,binary:$n,...Jt},vr=Bl;function ut(r,t="utf8"){let e=vr[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 Ts=Zt.isIPv4,Ll=Zt.isIPv6,Vn=function(r){let t=0;if(r=r.toString().trim(),Ts(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Ll(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ts(e[n]),a;s&&(a=Vn(e[n]),e[n]=ut(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,ut(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")},Ss=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 Ze={},zn={},Ol=[[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"],[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"],[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"]];Ol.forEach(r=>{let t=kl(...r);zn[t.code]=t,Ze[t.name]=t});function kl(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:Boolean(n),path:Boolean(i)}}function U(r){if(typeof r=="number"){if(zn[r]!=null)return zn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ze[r]!=null)return Ze[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ot=P(Tr(),1);function Kn(r,t="utf8"){let e=vr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?le(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Et(r,t){t==null&&(t=r.reduce((i,s)=>i+s.length,0));let e=Vt(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return le(e)}function Ms(r,t){switch(U(r).code){case 4:case 41:return Xl(t);case 42:return ks(t);case 6:case 273:case 33:case 132:return Fs(t).toString();case 53:case 54:case 55:case 56:case 400:case 777:return ks(t);case 421:return tf(t);case 444:return Ps(t);case 445:return Ps(t);case 466:return Ql(t);default:return ut(t,"base16")}}function Us(r,t){switch(U(r).code){case 4:return Ns(t);case 41:return Ns(t);case 42:return Os(t);case 6:case 273:case 33:case 132:return Wn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 777:return Os(t);case 421:return jl(t);case 444:return ef(t);case 445:return rf(t);case 466:return Jl(t);default:return Kn(t,"base16")}}var Yn=Object.values(Jt).map(r=>r.decoder),Zl=function(){let r=Yn[0].or(Yn[1]);return Yn.slice(2).forEach(t=>r=r.or(t)),r}();function Ns(r){if(!yr(r))throw new Error("invalid ip address");return Vn(r)}function Xl(r){let t=Ss(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!yr(t))throw new Error("invalid ip address");return t}function Wn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Fs(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Os(r){let t=Kn(r),e=Uint8Array.from(Ot.default.encode(t.length));return Et([e,t],e.length+t.length)}function ks(r){let t=Ot.default.decode(r);if(r=r.slice(Ot.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return ut(r)}function jl(r){let t;r[0]==="Q"||r[0]==="1"?t=ae(W.decode(`z${r}`)).bytes:t=O.parse(r).multihash.bytes;let e=Uint8Array.from(Ot.default.encode(t.length));return Et([e,t],e.length+t.length)}function Jl(r){let t=Zl.decode(r),e=Uint8Array.from(Ot.default.encode(t.length));return Et([e,t],e.length+t.length)}function Ql(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"+ut(e,"base64url")}function tf(r){let t=Ot.default.decode(r),e=r.slice(Ot.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return ut(e,"base58btc")}function ef(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=Rt.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=Wn(n);return Et([e,i],e.length+i.length)}function rf(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=Rt.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=Wn(n);return Et([e,i],e.length+i.length)}function Ps(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ut(t,"base32"),i=Fs(e);return`${n}:${i}`}var Ie=P(Tr(),1);function nf(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let i=e[n],s=U(i);if(s.size===0){t.push([i]);continue}if(n++,n>=e.length)throw $s("invalid address: "+r);if(s.path===!0){t.push([i,Qn(e.slice(n).join("/"))]);break}t.push([i,e[n]])}return t}function sf(r){let t=[];return r.map(e=>{let n=Ar(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Qn(t.join("/"))}function of(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Ar(t);return t.length>1?[e.code,Us(e.code,t[1])]:[e.code]})}function Zn(r){return r.map(t=>{let e=Ar(t);return t[1]!=null?[e.code,Ms(e.code,t[1])]:[e.code]})}function Xn(r){return xr(Et(r.map(t=>{let e=Ar(t),n=Uint8Array.from(Ie.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=Et([n,t[1]])),n})))}function jn(r,t){return r.size>0?r.size/8:r.size===0?0:Ie.default.decode(t)+(Ie.default.decode.bytes??0)}function Sr(r){let t=[],e=0;for(;e<r.length;){let n=Ie.default.decode(r,e),i=Ie.default.decode.bytes??0,s=U(n),a=jn(s,r.slice(e+i));if(a===0){t.push([n]),e+=i;continue}let h=r.slice(e+i,e+i+a);if(e+=a+i,e>r.length)throw $s("Invalid address Uint8Array: "+ut(r,"base16"));t.push([n,h])}return t}function Jn(r){let t=Sr(r),e=Zn(t);return sf(e)}function cf(r){r=Qn(r);let t=nf(r),e=of(t);return Xn(e)}function Gs(r){return cf(r)}function xr(r){let t=af(r);if(t!=null)throw t;return Uint8Array.from(r)}function af(r){try{Sr(r)}catch(t){return t}}function Qn(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function $s(r){return new Error("Error parsing address: "+r)}function Ar(r){return U(r[0])}var ei=P(Tr(),1);var qs=P(_r(),1);function fe(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 Re=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ti=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Xe,je,Je,Hs,ff=Symbol.for("nodejs.util.inspect.custom"),hf=[U("dns").code,U("dns4").code,U("dns6").code,U("dnsaddr").code],pf=new Map,Ks=Symbol.for("@multiformats/js-multiaddr/multiaddr");function ri(r){return Boolean(r?.[Ks])}var zt=class{constructor(t){if(Xe.set(this,void 0),je.set(this,void 0),Je.set(this,void 0),this[Hs]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=xr(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Gs(t)}else if(ri(t))this.bytes=xr(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Re(this,Xe,"f")==null&&ti(this,Xe,Jn(this.bytes),"f"),Re(this,Xe,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,i,s="",a=U("tcp"),h=U("udp"),l=U("ip4"),d=U("ip6"),f=U("dns6"),g=U("ip6zone");for(let[S,b]of this.stringTuples())S===g.code&&(s=`%${b??""}`),hf.includes(S)&&(e=a.name,i=443,n=`${b??""}${s}`,t=S===f.code?6:4),(S===a.code||S===h.code)&&(e=U(S).name,i=parseInt(b??"")),(S===l.code||S===d.code)&&(e=U(S).name,n=`${b??""}${s}`,t=S===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.protoCodes().map(t=>Object.assign({},U(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let i=ei.default.decode(e,n),s=ei.default.decode.bytes??0,a=U(i),h=jn(a,e.slice(n+s));n+=h+s,t.push(i)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return Re(this,je,"f")==null&&ti(this,je,Sr(this.bytes),"f"),Re(this,je,"f")}stringTuples(){return Re(this,Je,"f")==null&&ti(this,Je,Zn(this.tuples()),"f"),Re(this,Je,"f")}encapsulate(t){return t=new zt(t),new zt(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 zt(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 zt(Xn(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Ze.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?ut(W.decode(`z${n}`),"base58btc"):ut(O.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>U(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return fe(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=pf.get(e.name);if(n==null)throw(0,qs.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new zt(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)}[(Xe=new WeakMap,je=new WeakMap,Je=new WeakMap,Hs=Ks,ff)](){return`Multiaddr(${Jn(this.bytes)})`}};function ot(r){return new zt(r)}var df=_("dns4"),mf=_("dns6"),gf=_("dnsaddr"),De=Q(_("dns"),gf,df,mf),Ir=Q(_("ip4"),_("ip6")),he=Q(R(Ir,_("tcp")),R(De,_("tcp"))),Ws=R(Ir,_("udp")),yf=R(Ws,_("utp")),bf=R(Ws,_("quic")),tr=Q(R(he,_("ws")),R(De,_("ws"))),er=Q(R(he,_("wss")),R(De,_("wss"))),ni=Q(R(he,_("http")),R(Ir,_("http")),R(De,_("http"))),ii=Q(R(he,_("https")),R(Ir,_("https")),R(De,_("https"))),Zs=Q(R(tr,_("p2p-webrtc-star"),_("p2p")),R(er,_("p2p-webrtc-star"),_("p2p")),R(tr,_("p2p-webrtc-star")),R(er,_("p2p-webrtc-star"))),hd=Q(R(tr,_("p2p-websocket-star"),_("p2p")),R(er,_("p2p-websocket-star"),_("p2p")),R(tr,_("p2p-websocket-star")),R(er,_("p2p-websocket-star"))),Xs=Q(R(ni,_("p2p-webrtc-direct"),_("p2p")),R(ii,_("p2p-webrtc-direct"),_("p2p")),R(ni,_("p2p-webrtc-direct")),R(ii,_("p2p-webrtc-direct"))),rr=Q(tr,er,ni,ii,Zs,Xs,he,yf,bf,De),pd=Q(R(rr,_("p2p-stardust"),_("p2p")),R(rr,_("p2p-stardust"))),Qt=Q(R(rr,_("p2p")),Zs,Xs,_("p2p")),Ys=Q(R(Qt,_("p2p-circuit"),Qt),R(Qt,_("p2p-circuit")),R(_("p2p-circuit"),Qt),R(rr,_("p2p-circuit")),R(_("p2p-circuit"),rr),_("p2p-circuit")),js=()=>Q(R(Ys,js),Ys),Qe=js(),dd=Q(R(Qe,Qt,Qe),R(Qt,Qe),R(Qe,Qt),Qe,Qt);function Js(r){function t(e){let n;try{n=ot(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:Js(t),partialMatch:t}}function Q(...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:Js(t),partialMatch:t}}function _(r){let t=r;function e(i){let s;try{s=ot(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 kt=P(uo(),1);kt.default.formatters.b=r=>r==null?"undefined":W.baseEncode(r);kt.default.formatters.t=r=>r==null?"undefined":Rt.baseEncode(r);kt.default.formatters.m=r=>r==null?"undefined":Bn.baseEncode(r);kt.default.formatters.p=r=>r==null?"undefined":r.toString();kt.default.formatters.c=r=>r==null?"undefined":r.toString();kt.default.formatters.k=r=>r==null?"undefined":r.toString();function vt(r){return Object.assign((0,kt.default)(r),{error:(0,kt.default)(`${r}:error`),trace:(0,kt.default)(`${r}:trace`)})}var No=P(bo(),1);var Gr=P(_r(),1);function Nr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Or(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var ke=/^(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,li=/\/\d{1,2}$/;var et=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var Pe=P(fi(),1),de=P(nr(),1),M=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Or(32),this.isInSubnet=Nr,this.address=t;let e=li.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 et("Invalid subnet mask.");t=t.replace(li,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new M(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(ke))throw new et("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 M(n.join("."))}static fromInteger(t){return M.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new M(n)}toHex(){return this.parsedAddress.map(t=>(0,de.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,de.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,de.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new Pe.BigInteger(this.parsedAddress.map(t=>(0,de.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Pe.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return M.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Pe.BigInteger("1");return M.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Pe.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return M.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Pe.BigInteger("1");return M.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return M.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,de.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new M("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(ke,(0,de.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 So={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},hi={"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"},pi=/([^0-9a-f:/%])/gi,di=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,mi=/\/\d{1,3}(?=%|$)/,gi=/%.*$/,xo=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Ao=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Io=P(nr(),1);function Yf(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function Mr(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Io.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,Yf(n)))}var ge=P(nr(),1);function bi(r){return(0,ge.sprintf)("(%s)",r.join("|"))}function yi(r){return r.length<4?(0,ge.sprintf)("0{0,%d}%s",4-r.length,r):r}var wi="[^A-Fa-f0-9:]";function Ur(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 bi([yi(i),a])}return yi(i)}).join(":"));return e.push(r.map(yi).join(":")),bi(e)}function Ei(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,ge.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),s.push((0,ge.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),s.push((0,ge.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let h=1;h<r-a;h++)s.push((0,ge.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",h,r-h-a-1));return bi(s)}var rt=P(fi(),1),nt=P(nr(),1);function Fr(r){if(!r)throw new Error("Assertion failed.")}function Wf(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function Zf(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 Xf(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 Do(r){return(0,nt.sprintf)("%04x",parseInt(r,16))}function Co(r){return r&255}var G=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Nr,this.isCorrect=Or(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=mi.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 et("Invalid subnet mask.");t=t.replace(mi,"")}else if(/\//.test(t))throw new et("Invalid subnet mask.");let i=gi.exec(t);i&&(this.zone=i[0],t=t.replace(gi,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new G(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 G(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=Ao.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=xo.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 G(e),port:n}}static fromAddress4(t){let e=new M(t),n=128-(32-e.subnetMask);return new G(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new et("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 G(e)}microsoftTranscription(){return(0,nt.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":Wf(new rt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new rt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return G.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new rt.BigInteger("1");return G.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new rt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return G.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new rt.BigInteger("1");return G.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=So[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(hi))if(this.isInSubnet(new G(t)))return hi[t];return"Global unicast"}getBits(t,e){return new rt.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,nt.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 h=parseInt(this.parsedAddress[t],16);h===0&&n++,h!==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(h=>h[1]-h[0]+1);if(i.length>0){let h=s.indexOf(Math.max(...s));e=Xf(this.parsedAddress,i[h])}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(ke);if(i){this.parsedAddress4=i[0],this.address4=new M(this.parsedAddress4);for(let s=0;s<this.address4.groups;s++)if(/^0[0-9]+/.test(this.address4.parsedAddress[s]))throw new et("IPv4 addresses can't have leading zeroes.",t.replace(ke,this.address4.parsedAddress.map(Zf).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(pi);if(e)throw new et((0,nt.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(pi,'<span class="parse-error">$1</span>'));let n=t.match(di);if(n)throw new et((0,nt.sprintf)("Address failed regex: %s",n.join("")),t.replace(di,'<span class="parse-error">$1</span>'));let i=[],s=t.split("::");if(s.length===2){let a=s[0].split(":"),h=s[1].split(":");a.length===1&&a[0]===""&&(a=[]),h.length===1&&h[0]===""&&(h=[]);let l=this.groups-(a.length+h.length);if(!l)throw new et("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(h)}else if(s.length===1)i=t.split(":"),this.elidedGroups=0;else throw new et("Too many :: groups found");if(i=i.map(a=>(0,nt.sprintf)("%x",parseInt(a,16))),i.length!==this.groups)throw new et("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(Do).join(":")}decimal(){return this.parsedAddress.map(t=>(0,nt.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new rt.BigInteger(this.parsedAddress.map(Do).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return M.fromHex(new rt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new G(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 rt.BigInteger("ffff",16)).toString(),n=M.fromHex(this.getBitsBase16(32,64)),i=M.fromHex(this.getBits(96,128).xor(new rt.BigInteger("ffffffff",16)).toString(16)),s=this.getBits(64,80),a=this.getBitsBase2(64,80),h=s.testBit(15),l=s.testBit(14),d=s.testBit(8),f=s.testBit(9),g=new rt.BigInteger(a.slice(2,6)+a.slice(8,16),2).toString(10);return{prefix:(0,nt.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:a,coneNat:h,microsoft:{reserved:l,universalLocal:f,groupIndividual:d,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=M.fromHex(this.getBitsBase16(16,48));return{prefix:(0,nt.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 G(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Co)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Co))}static fromUnsignedByteArray(t){let e=new rt.BigInteger("256",10),n=new rt.BigInteger("0",10),i=new rt.BigInteger("1",10);for(let s=t.length-1;s>=0;s--)n=n.add(i.multiply(new rt.BigInteger(t[s].toString(10),10))),i=i.multiply(e);return G.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 G("2001::/32"))}is6to4(){return this.isInSubnet(new G("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,nt.sprintf)(":%s",t),(0,nt.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,nt.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,nt.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return Mr(this.address).join(":");Fr(typeof this.elidedGroups=="number"),Fr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...Mr(e)):t.push("");let i=["hover-group"];for(let s=this.elisionBegin;s<this.elisionBegin+this.elidedGroups;s++)i.push((0,nt.sprintf)("group-%d",s));return t.push((0,nt.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...Mr(n,this.elisionEnd)):t.push(""),this.is4()&&(Fr(this.address4 instanceof M),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new G(this.correctForm());if(n.elidedGroups===0)e.push(Ur(n.parsedAddress));else if(n.elidedGroups===8)e.push(Ei(8));else{let i=n.address.split("::");i[0].length&&e.push(Ur(i[0].split(":"))),Fr(typeof n.elidedGroups=="number"),e.push(Ei(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Ur(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",wi,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",wi,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var jf=vt("libp2p:ip-port-to-multiaddr"),vi={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Bo(r,t){if(typeof r!="string")throw(0,Gr.default)(new Error(`invalid ip provided: ${r}`),vi.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw(0,Gr.default)(new Error(`invalid port provided: ${t}`),vi.ERR_INVALID_PORT_PARAMETER);try{return new M(r),ot(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new G(r);return e.is4()?ot(`/ip4/${e.to4().correctForm()}/tcp/${t}`):ot(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw jf.error(n),(0,Gr.default)(new Error(n),vi.ERR_INVALID_IP)}}var Ti=P(Ft("os"),1),Lo=P(Ft("path"),1),Jf={ip4:"IPv4",ip6:"IPv6"};function Ue(r){let t=r.getPath();return t!=null?Ti.default.platform()==="win32"?{path:Lo.default.join("\\\\.\\pipe\\",t)}:{path:t}:r.toOptions()}function Si(r,t,e){let n=i=>ot(`/${r}/${i}/tcp/${e}`);return(Qf(t)?eh(Jf[r]):[t]).map(n)}function Qf(r){return["0.0.0.0","::"].includes(r)}var th=Ti.default.networkInterfaces();function eh(r){let t=[];for(let[,e]of Object.entries(th))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Ct=vt("libp2p:tcp:socket"),$r=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,s=t.socketCloseTimeout??2e3;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 v("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Bo(r.remoteAddress,r.remotePort)}let h=Ue(a),l=h.path??`${h.host??""}:${h.port??""}`,{sink:d,source:f}=No.default.duplex(r);r.setTimeout(i,()=>{Ct("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new v("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Ct("%s socket close",l),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Ct("%s socket end",l),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await d(w)}catch(S){S.type!=="aborted"&&Ct(S)}r.end()},source:f,remoteAddr:a,timeline:{open:Date.now()},async close(){if(r.destroyed){Ct("%s socket was already destroyed when trying to close",l);return}Ct("%s closing socket",l),await new Promise((w,S)=>{let b=Date.now(),x=setTimeout(()=>{r.destroyed?(Ct("%s is already destroyed",l),w()):(Ct("%s socket close timeout after %dms, destroying it manually",l,Date.now()-b),r.destroy(new v("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},s).unref();r.once("close",()=>{Ct("%s socket closed",l),clearTimeout(x),w()}),r.once("error",B=>{Ct("%s socket error",l,B),g.timeline.close==null&&(g.timeline.close=Date.now()),r.destroyed&&clearTimeout(x),S(B)}),r.setTimeout(s),r.end(),r.writableLength>0?r.once("drain",()=>{Ct("%s socket drained",l),r.destroy()}):r.destroy()})}};return g};var Oo=P(Ft("net"),1);var ye=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},qt,Vr=class extends EventTarget{constructor(){super(...arguments),qt.set(this,new Map)}listenerCount(t){let e=ye(this,qt,"f").get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=ye(this,qt,"f").get(t);i==null&&(i=[],ye(this,qt,"f").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=ye(this,qt,"f").get(t);i!=null&&(i=i.filter(({callback:s})=>s!==e),ye(this,qt,"f").set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=ye(this,qt,"f").get(t.type);return n==null||(n=n.filter(({once:i})=>!i),ye(this,qt,"f").set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new Fe(t,e))}};qt=new WeakMap;var xi=class extends Event{constructor(t,e){super(t,e),this.detail=e?.detail}},Fe=globalThis.CustomEvent??xi;var gt=vt("libp2p:tcp:listener");async function Ai(r){try{await r.close()}catch(t){gt.error("an error occurred closing the connection",t)}}var ih=1,sh=0,zr=class extends Vr{constructor(t){if(super(),this.context=t,this.connections=new Set,this.status={started:!1},t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Oo.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]:ih})}this.dispatchEvent(new Fe("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Fe("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:sh}),this.dispatchEvent(new Fe("close"))})}onSocket(t){t.on("error",n=>{gt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=$r(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){gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}gt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{gt("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=>{gt.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 Fe("connection",{detail:n}))}).catch(async n=>{gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Ai(e)}).catch(n=>{gt.error("closing inbound connection failed",n)})}catch(n){gt.error("inbound connection failed",n),Ai(e).catch(i=>{gt.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(Si("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Si("ip6",e.address,e.port)))}catch(s){gt.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;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:Ue(n)},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Ai(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)}),gt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(gt("Closing server on %s",this.server.address()),this.server.close())}};var Po=Symbol.for("@libp2p/transport");var ko;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(ko||(ko={}));var Kt=vt("libp2p:tcp"),Ii=class{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"})})}get[Po](){return!0}get[Symbol.toStringTag](){return"@libp2p/tcp"}async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",h=>{Kt("socket error",h)});let i=$r(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{i.close().catch(h=>{Kt.error("Error closing maConn after abort",h)})};e.signal?.addEventListener("abort",s,{once:!0}),Kt("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(Kt("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw a.close().catch(h=>{Kt.error("Error closing conn after abort",h)}),new Gt;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Gt;return await new Promise((n,i)=>{let s=Date.now(),a=Ue(t),h=a.path??`${a.host??""}:${a.port}`;Kt("dialing %j",a);let l=Mo.default.connect(a),d=b=>{b.message=`connection error ${h}: ${b.message}`,this.metrics?.dialerEvents.increment({error:!0}),S(b)},f=()=>{Kt("connection timeout %s",h),this.metrics?.dialerEvents.increment({timeout:!0});let b=new v(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",b)},g=()=>{Kt("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),S()},w=()=>{Kt("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),S(new Gt)},S=b=>{if(l.removeListener("error",d),l.removeListener("timeout",f),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",f),l.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new zr({...t,maxConnections:this.opts.maxConnections,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:he.matches(e.decapsulateCode(421)))}};function Uo(r={}){return(t={})=>new Ii(t,r)}var Gi=P(Li(),1),Ac=P(yc(),1),_c=P(we(),1),$i=P(Fi(),1),Ic=P(xc(),1);function gh(){_c.default._configure(),Gi.default._configure(Ac.default),$i.default._configure(Ic.default)}gh();var Rc=["uint64","int64","sint64","fixed64","sfixed64"];function yh(r){for(let t of Rc){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function Vi(r){return yh(new Gi.default(r))}function bh(r){for(let t of Rc){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function zi(){return bh($i.default.create())}function H(r,t){let e=Vi(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function q(r,t){let e=zi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var $e;(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"})($e||($e={}));function Wr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Yt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(s,a){let h=t(s);a.int32(h)},n=function(s){let a=s.int32();return t(a)};return Wr("enum",$e.VARINT,e,n)}function K(r,t){return Wr("message",$e.LENGTH_DELIMITED,r,t)}var z;(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=()=>Yt(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),Xr.codec().encode(i.connect,s)),i.streamOpen!=null&&(s.uint32(26),jr.codec().encode(i.streamOpen,s)),i.streamHandler!=null&&(s.uint32(34),Jr.codec().encode(i.streamHandler,s)),i.dht!=null&&(s.uint32(42),St.codec().encode(i.dht,s)),i.connManager!=null&&(s.uint32(50),tn.codec().encode(i.connManager,s)),i.disconnect!=null&&(s.uint32(58),en.codec().encode(i.disconnect,s)),i.pubsub!=null&&(s.uint32(66),ne.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(74),sn.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=Xr.codec().decode(i,i.uint32());break;case 3:a.streamOpen=jr.codec().decode(i,i.uint32());break;case 4:a.streamHandler=Jr.codec().decode(i,i.uint32());break;case 5:a.dht=St.codec().decode(i,i.uint32());break;case 6:a.connManager=tn.codec().decode(i,i.uint32());break;case 7:a.disconnect=en.codec().decode(i,i.uint32());break;case 8:a.pubsub=ne.codec().decode(i,i.uint32());break;case 9:a.peerStore=sn.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(z||(z={}));var D;(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=()=>Yt(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),Qr.codec().encode(i.error,s)),i.streamInfo!=null&&(s.uint32(26),Ve.codec().encode(i.streamInfo,s)),i.identify!=null&&(s.uint32(34),Zr.codec().encode(i.identify,s)),i.dht!=null&&(s.uint32(42),Nt.codec().encode(i.dht,s)),i.peers!=null)for(let h of i.peers)s.uint32(50),re.codec().encode(h,s);i.pubsub!=null&&(s.uint32(58),nn.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(66),on.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={peers:[]},h=s==null?i.len:i.pos+s;for(;i.pos<h;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=Qr.codec().decode(i,i.uint32());break;case 3:a.streamInfo=Ve.codec().decode(i,i.uint32());break;case 4:a.identify=Zr.codec().decode(i,i.uint32());break;case 5:a.dht=Nt.codec().decode(i,i.uint32());break;case 6:a.peers.push(re.codec().decode(i,i.uint32()));break;case 7:a.pubsub=nn.codec().decode(i,i.uint32());break;case 8:a.peerStore=on.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(D||(D={}));var Zr;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Zr||(Zr={}));var Xr;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Xr||(Xr={}));var jr;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(jr||(jr={}));var Jr;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Jr||(Jr={}));var Qr;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Qr||(Qr={}));var Ve;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(Ve||(Ve={}));var St;(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=()=>Yt(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={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(St||(St={}));var Nt;(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=()=>Yt(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),re.codec().encode(i.peer,s)),i.value!=null&&(s.uint32(26),s.bytes(i.value)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=re.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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(Nt||(Nt={}));var re;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(re||(re={}));var tn;(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=()=>Yt(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={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(tn||(tn={}));var en;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(en||(en={}));var ne;(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=()=>Yt(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={},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(ne||(ne={}));var rn;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(rn||(rn={}));var nn;(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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(nn||(nn={}));var sn;(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=()=>Yt(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 h of i.protos)s.uint32(26),s.string(h);a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={protos:[]},h=s==null?i.len:i.pos+s;for(;i.pos<h;){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=>q(i,r.codec()),r.decode=i=>H(i,r.codec())})(sn||(sn={}));var on;(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),re.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=re.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=>q(e,r.codec()),r.decode=e=>H(e,r.codec())})(on||(on={}));var Cc=Symbol.for("@achingbrain/uint8arraylist");function Dc(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 cn(r){return Boolean(r?.[Cc])}var lt=class{constructor(...t){Object.defineProperty(this,Cc,{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(cn(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(cn(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=Dc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Dc(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(cn(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 Et(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:Et(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),s=new lt;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],h=i,l=h+a.byteLength;if(i=l,t>=l)continue;let d=t>=h&&t<l,f=e>h&&e<=l;if(d&&f){if(t===h&&e===l){n.push(a);break}let g=t-h;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-h));continue}if(f){if(e===l){n.push(a);break}n.push(a.subarray(0,e-h));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!cn(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 h=a,l=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let g=e;g<=l;g+=f){f=0;for(let w=d;w>=0;w--){let S=this.get(g+w);if(n[w]!==S){f=Math.max(1,w-h[S]);break}}if(f===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=Vt(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=$t(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=$t(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=$t(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=Vt(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=$t(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=$t(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=$t(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=$t(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=$t(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof lt)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!fe(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new lt;return n.bufs=t,e==null&&(e=t.reduce((i,s)=>i+s.byteLength,0)),n.length=e,n}};function an(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 Bc=4294967296,yt=class{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 yt(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 yt(e,n)}toBytes(t,e=0){let n=an(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 yt;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>Bc&&(i=0,++n>Bc&&(n=0))),new yt(n,i)}static fromNumber(t){if(t===0)return new yt;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 yt(i,n)}static fromBytes(t,e=0){let n=an(t),i=new yt,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 wh=Math.pow(2,7),Eh=Math.pow(2,14),vh=Math.pow(2,21),Th=Math.pow(2,28),Sh=Math.pow(2,35),xh=Math.pow(2,42),Ah=Math.pow(2,49),_h=Math.pow(2,56),Ih=Math.pow(2,63),ve={encodingLength(r){return r<wh?1:r<Eh?2:r<vh?3:r<Th?4:r<Sh?5:r<xh?6:r<Ah?7:r<_h?8:r<Ih?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=Vt(ve.encodingLength(r))),yt.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return yt.fromBytes(r,t).toNumber(!0)}};function Lc(r){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var un=r=>{let t=ve.encodingLength(r),e=Lc(t);return ve.encode(r,e),un.bytes=t,e};un.bytes=0;function ln(r){r=r??{};let t=r.lengthEncoder??un;return async function*(n){for await(let i of n){let s=t(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}}}ln.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??un;return new lt(e(r.byteLength),r)};var or=P(_r(),1),Rh=8,Dh=1024*1024*4,Te;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Te||(Te={}));var Hi=r=>{let t=ve.decode(r);return Hi.bytes=ve.encodingLength(t),t};Hi.bytes=0;function cr(r){return async function*(e){let n=new lt,i=Te.LENGTH,s=-1,a=r?.lengthDecoder??Hi,h=r?.maxLengthLength??Rh,l=r?.maxDataLength??Dh;for await(let d of e)for(n.append(d);n.byteLength>0;){if(i===Te.LENGTH)try{if(s=a(n),s<0)throw(0,or.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>l)throw(0,or.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let f=a.bytes;n.consume(f),r?.onLength!=null&&r.onLength(s),i=Te.DATA}catch(f){if(f instanceof RangeError){if(n.byteLength>h)throw(0,or.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw f}if(i===Te.DATA){if(n.byteLength<s)break;let f=n.sublist(0,s);n.consume(s),r?.onData!=null&&r.onData(f),yield f,i=Te.LENGTH}}if(n.byteLength>0)throw(0,or.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}cr.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 cr({...t??{},onLength:s=>{e=s}})(n)};function Nc(r){let t=async function*(){let e=yield,n=new lt;for await(let i of r){if(e==null){n.append(i),e=yield n,n=new lt;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 lt);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}var fn=class{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}},ze=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new fn(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 fn(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()}};function Oc(r={}){return Bh(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 Bh(r,t){t=t??{};let e=t.onEnd,n=new ze,i,s,a,h=async()=>n.isEmpty()?a?{done:!0}:await new Promise((x,B)=>{s=I=>{s=null,n.push(I);try{x(r(n))}catch(C){B(C)}return i}}):r(n),l=x=>s!=null?s(x):(n.push(x),i),d=x=>(n=new ze,s!=null?s({error:x}):(n.push({error:x}),i)),f=x=>{if(a)return i;if(t?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:x})},g=x=>a?i:(a=!0,x!=null?d(x):l({done:!0})),w=()=>(n=new ze,g(),{done:!0}),S=x=>(g(x),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:h,return:w,throw:S,push:f,end:g,get readableLength(){return n.size}},e==null)return i;let b=i;return i={[Symbol.asyncIterator](){return this},next(){return b.next()},throw(x){return b.throw(x),e!=null&&(e(x),e=void 0),{done:!0}},return(){return b.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(x){return b.end(x),e!=null&&(e(x),e=void 0),i},get readableLength(){return b.readableLength}},i}function qi(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function kc(r){let t=Oc(),e=Nc(r.source),n=qi(),i,s=r.sink(async function*(){yield*t,yield*await n.promise}());return s.catch(h=>{i=h}),{reader:e,writer:t,stream:{sink:async h=>i!=null?await Promise.reject(i):(n.resolve(h),await s),source:e},rest:()=>t.end(),write:t.push,read:async()=>{let h=await e.next();if(h.value!=null)return h.value}}}var Ki=vt("libp2p:daemon-protocol:stream-handler"),ar=class{constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=kc(this.stream),this.decoder=cr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Ki("read received no value, closing stream"),await this.close()}write(t){Ki("write message"),this.shake.write(ln.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Ki("closing the stream"),await this.rest().sink([])}};var Yi=Symbol.for("@libp2p/peer-id");function He(r){return r!=null&&Boolean(r[Yi])}var Lh=Symbol.for("nodejs.util.inspect.custom"),Pc=Object.values(Jt).map(r=>r.decoder).reduce((r,t)=>r.or(t),Jt.identity.decoder),Mc=114,Uc=36,Fc=37,ur=class{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()})`}get[Yi](){return!0}toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return O.createV1(Mc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return fe(this.multihash.bytes,t);if(typeof t=="string")return Nh(t).equals(this);if(t?.multihash?.bytes!=null)return fe(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Lh](){return`PeerId(${this.toString()})`}},lr=class extends ur{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},fr=class extends ur{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},hr=class extends ur{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function Nh(r,t){if(t=t??Pc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=ae(W.decode(`z${r}`));return r.startsWith("12D")?new fr({multihash:e}):r.startsWith("16U")?new hr({multihash:e}):new lr({multihash:e})}return ie(Pc.decode(r))}function ie(r){try{let t=ae(r);if(t.code===Er.code){if(t.digest.length===Uc)return new fr({multihash:t});if(t.digest.length===Fc)return new hr({multihash:t})}if(t.code===wr.code)return new lr({multihash:t})}catch{return Oh(O.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Oh(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Mc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===wr.code)return new lr({multihash:r.multihash});if(t.code===Er.code){if(t.digest.length===Uc)return new fr({multihash:r.multihash});if(t.digest.length===Fc)return new hr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var hn=class{constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new v("value received is not a Uint8Array","ERR_INVALID_VALUE");let n=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.PUT_VALUE,key:t,value:e}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(await n.close(),s.type!==D.Type.OK)throw new v(s.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.GET_VALUE,key:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(i.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(i.dht==null||i.dht.value==null)throw new v("Invalid DHT get response","ERR_DHT_GET_FAILED");return i.dht.value}async findPeer(t){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.FIND_PEER,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(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 v("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:ie(i.dht.peer.id),multiaddrs:i.dht.peer.addrs.map(s=>ot(s)),protocols:[]}}async provide(t){if(t==null||O.asCID(t)==null)throw new v("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.PROVIDE,cid:t.bytes}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(i.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||O.asCID(t)==null)throw new v("invalid cid received","ERR_INVALID_CID");let n=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(s.type!==D.Type.OK)throw await n.close(),new v(s.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(i=await n.read(),i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let a=Nt.decode(i);if(a.type===Nt.Type.END){await n.close();return}if(a.type===Nt.Type.VALUE&&a.peer!=null&&a.peer?.addrs!=null)yield{id:ie(a.peer.id),multiaddrs:a.peer.addrs.map(h=>ot(h)),protocols:[]};else throw await n.close(),new v("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.GET_CLOSEST_PEERS,key:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(i.type!==D.Type.OK)throw await e.close(),new v(i.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await e.read(),n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=Nt.decode(n);if(s.type===Nt.Type.END){await e.close();return}if(s.type===Nt.Type.VALUE&&s.value!=null)yield{id:ie(s.value),multiaddrs:[],protocols:[]};else throw await e.close(),new v("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:z.Type.DHT,dht:{type:St.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(await e.close(),i.type!==D.Type.OK)throw new v(i.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(i.dht==null)throw new v("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return i.dht.value}};var pn=class{constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:z.Type.PUBSUB,pubsub:{type:ne.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=D.decode(e);if(await t.close(),n.type!==D.Type.OK)throw new v(n.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new v("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return n.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new v("data received is not a Uint8Array","ERR_INVALID_DATA");let n=await this.client.send({type:z.Type.PUBSUB,pubsub:{type:ne.Type.PUBLISH,topic:t,data:e}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(await n.close(),s.type!==D.Type.OK)throw new v(s.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async*subscribe(t){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:z.Type.PUBSUB,pubsub:{type:ne.Type.SUBSCRIBE,topic:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let i=D.decode(n);if(i.type!==D.Type.OK)throw new v(i.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");for(;;){if(n=await e.read(),n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");yield rn.decode(n)}}};var Wi={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Gc=vt("libp2p:daemon-client"),Zi=class{constructor(t){this.multiaddr=t,this.tcp=Uo()(),this.dht=new hn(this),this.pubsub=new pn(this)}async connectDaemon(){return await this.tcp.dial(this.multiaddr,{upgrader:Wi})}async send(t){let e=await this.connectDaemon(),n=new ar({stream:e});return n.write(z.encode(t)),n}async connect(t,e){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new v("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(a=>{if(!ri(a))throw new v("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let n=await this.send({type:z.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(a=>a.bytes)}}),i=await n.read();if(i==null)throw new v("unspecified","ERR_CONNECT_FAILED");let s=D.decode(i);if(s.type!==D.Type.OK){let a=s.error??{msg:"unspecified"};throw new v(a.msg??"unspecified","ERR_CONNECT_FAILED")}await n.close()}async identify(){let t=await this.send({type:z.Type.IDENTIFY}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=D.decode(e);if(n.type!==D.Type.OK)throw new v(n.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(n.identify==null||n.identify.addrs==null)throw new v("Invalid response","ERR_IDENTIFY_FAILED");let i=ie(n.identify?.id),s=n.identify.addrs.map(a=>ot(a));return await t.close(),{peerId:i,addrs:s}}async listPeers(){let t=await this.send({type:z.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=D.decode(e);if(n.type!==D.Type.OK)throw new v(n.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),n.peers.map(i=>ie(i.id))}async openStream(t,e){if(!He(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new v("invalid protocol received","ERR_INVALID_PROTOCOL");let n=await this.send({type:z.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),i=await n.read();if(i==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=D.decode(i);if(s.type!==D.Type.OK)throw await n.close(),new v(s.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return n.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new v("invalid protocol received","ERR_INVALID_PROTOCOL");let n=this.tcp.createListener({upgrader:Wi,handler:l=>{Promise.resolve().then(async()=>{let d=new ar({stream:l}),f=await d.read();if(f==null)throw new v("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(Ve.decode(f).proto!==t)throw new v("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(d.rest())}).finally(()=>{l.close().catch(d=>{Gc.error(d)}),n.close().catch(d=>{Gc.error(d)})})}});await n.listen(ot("/ip4/127.0.0.1/tcp/0"));let i=n.getAddrs()[0];if(i==null)throw new v("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let s=await this.send({type:z.Type.STREAM_HANDLER,streamHandler:{addr:i.bytes,proto:[t]}}),a=await s.read();if(a==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let h=D.decode(a);if(await s.close(),h.type!==D.Type.OK)throw new v(h.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function kh(r){return new Zi(r)}return _u(Ph);})();
|
|
7
7
|
return Libp2PDaemonClient}));
|
package/dist/src/dht.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dht.d.ts","sourceRoot":"","sources":["../../src/dht.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAStC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAY,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAG3D,qBAAa,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAExB,MAAM,EAAE,YAAY;IAIjC;;OAEG;IACG,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC7D;;OAEG;IACG,GAAG,CAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAkChD;;OAEG;IACG,QAAQ,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsClD;;OAEG;IACG,OAAO,CAAE,GAAG,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"dht.d.ts","sourceRoot":"","sources":["../../src/dht.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAStC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAY,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAG3D,qBAAa,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAExB,MAAM,EAAE,YAAY;IAIjC;;OAEG;IACG,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC7D;;OAEG;IACG,GAAG,CAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAkChD;;OAEG;IACG,QAAQ,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsClD;;OAEG;IACG,OAAO,CAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BvC;;OAEG;IACK,aAAa,CAAE,GAAG,EAAE,GAAG,EAAE,KAAK,GAAE,MAAU,GAAG,aAAa,CAAC,QAAQ,CAAC;IA0D5E;;OAEG;IACK,eAAe,CAAE,GAAG,EAAE,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC;IA2DlE;;OAEG;IACG,YAAY,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;CAiCrE"}
|
package/dist/src/pubsub.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export declare class Pubsub {
|
|
|
16
16
|
/**
|
|
17
17
|
* Request to subscribe a certain topic
|
|
18
18
|
*/
|
|
19
|
-
subscribe(topic: string): AsyncGenerator<PSMessage, void,
|
|
19
|
+
subscribe(topic: string): AsyncGenerator<PSMessage, void, undefined>;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=pubsub.d.ts.map
|
package/dist/src/pubsub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pubsub.d.ts","sourceRoot":"","sources":["../../src/pubsub.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EACV,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAExB,MAAM,EAAE,YAAY;IAIjC;;;;OAIG;IACG,SAAS,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IA6BrC;;OAEG;IACG,OAAO,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"pubsub.d.ts","sourceRoot":"","sources":["../../src/pubsub.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EACV,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAExB,MAAM,EAAE,YAAY;IAIjC;;;;OAIG;IACG,SAAS,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IA6BrC;;OAEG;IACG,OAAO,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC9D;;OAEG;IACK,SAAS,CAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC;CAoC9E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/daemon-client",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.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",
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
},
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"@libp2p/daemon-protocol": "^3.0.0",
|
|
138
|
+
"@libp2p/interface-connection": "^3.0.8",
|
|
138
139
|
"@libp2p/interface-peer-id": "^2.0.0",
|
|
139
140
|
"@libp2p/interface-peer-info": "^1.0.1",
|
|
140
141
|
"@libp2p/interface-transport": "^2.0.0",
|
|
@@ -149,13 +150,11 @@
|
|
|
149
150
|
},
|
|
150
151
|
"devDependencies": {
|
|
151
152
|
"@libp2p/daemon-server": "^4.0.0",
|
|
152
|
-
"@libp2p/interface-compliance-tests": "^3.0.1",
|
|
153
153
|
"@libp2p/interface-dht": "^2.0.0",
|
|
154
154
|
"@libp2p/interface-mocks": "^9.0.0",
|
|
155
155
|
"@libp2p/interface-peer-store": "^1.0.0",
|
|
156
156
|
"@libp2p/interface-pubsub": "^3.0.0",
|
|
157
|
-
"
|
|
158
|
-
"aegir": "^37.9.1",
|
|
157
|
+
"aegir": "^38.1.6",
|
|
159
158
|
"it-all": "^2.0.0",
|
|
160
159
|
"it-pipe": "^2.0.3",
|
|
161
160
|
"sinon": "^15.0.1",
|
package/src/dht.ts
CHANGED
|
@@ -136,7 +136,7 @@ export class DHT {
|
|
|
136
136
|
/**
|
|
137
137
|
* Announce to the network that the peer have data addressed by the provided CID
|
|
138
138
|
*/
|
|
139
|
-
async provide (cid: CID) {
|
|
139
|
+
async provide (cid: CID): Promise<void> {
|
|
140
140
|
if (cid == null || CID.asCID(cid) == null) {
|
|
141
141
|
throw new CodeError('invalid cid received', 'ERR_INVALID_CID')
|
|
142
142
|
}
|
|
@@ -290,7 +290,7 @@ export class DHT {
|
|
|
290
290
|
/**
|
|
291
291
|
* Query the DHT routing table for a given peer's public key.
|
|
292
292
|
*/
|
|
293
|
-
async getPublicKey (peerId: PeerId) {
|
|
293
|
+
async getPublicKey (peerId: PeerId): Promise<Uint8Array | undefined> {
|
|
294
294
|
if (!isPeerId(peerId)) {
|
|
295
295
|
throw new CodeError('invalid peer id received', 'ERR_INVALID_PEER_ID')
|
|
296
296
|
}
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ class Client implements DaemonClient {
|
|
|
51
51
|
* Sends the request to the daemon and returns a stream. This
|
|
52
52
|
* should only be used when sending daemon requests.
|
|
53
53
|
*/
|
|
54
|
-
async send (request: Request) {
|
|
54
|
+
async send (request: Request): Promise<StreamHandler> {
|
|
55
55
|
const maConn = await this.connectDaemon()
|
|
56
56
|
|
|
57
57
|
const streamHandler = new StreamHandler({ stream: maConn })
|
|
@@ -62,7 +62,7 @@ class Client implements DaemonClient {
|
|
|
62
62
|
/**
|
|
63
63
|
* Connect requests a connection to a known peer on a given set of addresses
|
|
64
64
|
*/
|
|
65
|
-
async connect (peerId: PeerId, addrs: Multiaddr[]) {
|
|
65
|
+
async connect (peerId: PeerId, addrs: Multiaddr[]): Promise<void> {
|
|
66
66
|
if (!isPeerId(peerId)) {
|
|
67
67
|
throw new CodeError('invalid peer id received', 'ERR_INVALID_PEER_ID')
|
|
68
68
|
}
|
package/src/pubsub.ts
CHANGED
|
@@ -51,7 +51,7 @@ export class Pubsub {
|
|
|
51
51
|
/**
|
|
52
52
|
* Publish data under a topic
|
|
53
53
|
*/
|
|
54
|
-
async publish (topic: string, data: Uint8Array) {
|
|
54
|
+
async publish (topic: string, data: Uint8Array): Promise<void> {
|
|
55
55
|
if (typeof topic !== 'string') {
|
|
56
56
|
throw new CodeError('invalid topic received', 'ERR_INVALID_TOPIC')
|
|
57
57
|
}
|
|
@@ -87,7 +87,7 @@ export class Pubsub {
|
|
|
87
87
|
/**
|
|
88
88
|
* Request to subscribe a certain topic
|
|
89
89
|
*/
|
|
90
|
-
async * subscribe (topic: string) {
|
|
90
|
+
async * subscribe (topic: string): AsyncGenerator<PSMessage, void, undefined> {
|
|
91
91
|
if (typeof topic !== 'string') {
|
|
92
92
|
throw new CodeError('invalid topic received', 'ERR_INVALID_TOPIC')
|
|
93
93
|
}
|