@libp2p/tcp 7.0.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.min.js +4 -4
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/listener.d.ts +4 -4
- package/dist/src/listener.d.ts.map +1 -1
- package/dist/src/listener.js +1 -1
- package/dist/src/listener.js.map +1 -1
- package/dist/src/socket-to-conn.d.ts +2 -2
- package/dist/src/socket-to-conn.d.ts.map +1 -1
- package/dist/src/socket-to-conn.js +41 -54
- package/dist/src/socket-to-conn.js.map +1 -1
- package/package.json +14 -109
- package/src/constants.ts +1 -1
- package/src/index.ts +4 -4
- package/src/listener.ts +4 -4
- package/src/socket-to-conn.ts +45 -59
- package/dist/typedoc-urls.json +0 -10
package/dist/index.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PTcp = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PTcp=(()=>{var
|
|
2
|
+
"use strict";var Libp2PTcp=(()=>{var Ba=Object.create;var Ie=Object.defineProperty;var Ma=Object.getOwnPropertyDescriptor;var Ra=Object.getOwnPropertyNames;var Da=Object.getPrototypeOf,Pa=Object.prototype.hasOwnProperty;var mt=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var z=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),O=(r,t)=>{for(var e in t)Ie(r,e,{get:t[e],enumerable:!0})},Hn=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ra(t))!Pa.call(r,o)&&o!==e&&Ie(r,o,{get:()=>t[o],enumerable:!(n=Ma(t,o))||n.enumerable});return r};var H=(r,t,e)=>(e=r!=null?Ba(Da(r)):{},Hn(t||!r||!r.__esModule?Ie(e,"default",{value:r,enumerable:!0}):e,r)),ka=r=>Hn(Ie({},"__esModule",{value:!0}),r);var Xn=z((Dp,Jn)=>{var Gt=1e3,Ht=Gt*60,Zt=Ht*60,Nt=Zt*24,Oa=Nt*7,Na=Nt*365.25;Jn.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Fa(r);if(e==="number"&&isFinite(r))return t.long?Ua(r):_a(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Fa(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*Na;case"weeks":case"week":case"w":return e*Oa;case"days":case"day":case"d":return e*Nt;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Zt;case"minutes":case"minute":case"mins":case"min":case"m":return e*Ht;case"seconds":case"second":case"secs":case"sec":case"s":return e*Gt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function _a(r){var t=Math.abs(r);return t>=Nt?Math.round(r/Nt)+"d":t>=Zt?Math.round(r/Zt)+"h":t>=Ht?Math.round(r/Ht)+"m":t>=Gt?Math.round(r/Gt)+"s":r+"ms"}function Ua(r){var t=Math.abs(r);return t>=Nt?Be(r,t,Nt,"day"):t>=Zt?Be(r,t,Zt,"hour"):t>=Ht?Be(r,t,Ht,"minute"):t>=Gt?Be(r,t,Gt,"second"):r+" ms"}function Be(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var ar=z((Pp,Qn)=>{function La(r){e.debug=e,e.default=e,e.coerce=g,e.disable=c,e.enable=o,e.enabled=f,e.humanize=Xn(),e.destroy=A,Object.keys(r).forEach(p=>{e[p]=r[p]}),e.names=[],e.skips=[],e.formatters={};function t(p){let b=0;for(let y=0;y<p.length;y++)b=(b<<5)-b+p.charCodeAt(y),b|=0;return e.colors[Math.abs(b)%e.colors.length]}e.selectColor=t;function e(p){let b,y=null,S,h;function T(...B){if(!T.enabled)return;let C=T,I=Number(new Date),M=I-(b||I);C.diff=M,C.prev=b,C.curr=I,b=I,B[0]=e.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let R=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(_,D)=>{if(_==="%%")return"%";R++;let F=e.formatters[D];if(typeof F=="function"){let G=B[R];_=F.call(C,G),B.splice(R,1),R--}return _}),e.formatArgs.call(C,B),(C.log||e.log).apply(C,B)}return T.namespace=p,T.useColors=e.useColors(),T.color=e.selectColor(p),T.extend=n,T.destroy=e.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(S!==e.namespaces&&(S=e.namespaces,h=e.enabled(p)),h),set:B=>{y=B}}),typeof e.init=="function"&&e.init(T),T}function n(p,b){let y=e(this.namespace+(typeof b>"u"?":":b)+p);return y.log=this.log,y}function o(p){e.save(p),e.namespaces=p,e.names=[],e.skips=[];let b,y=(typeof p=="string"?p:"").split(/[\s,]+/),S=y.length;for(b=0;b<S;b++)y[b]&&(p=y[b].replace(/\*/g,".*?"),p[0]==="-"?e.skips.push(new RegExp("^"+p.slice(1)+"$")):e.names.push(new RegExp("^"+p+"$")))}function c(){let p=[...e.names.map(l),...e.skips.map(l).map(b=>"-"+b)].join(",");return e.enable(""),p}function f(p){if(p[p.length-1]==="*")return!0;let b,y;for(b=0,y=e.skips.length;b<y;b++)if(e.skips[b].test(p))return!1;for(b=0,y=e.names.length;b<y;b++)if(e.names[b].test(p))return!0;return!1}function l(p){return p.toString().substring(2,p.toString().length-2).replace(/\.\*\?$/,"*")}function g(p){return p instanceof Error?p.stack||p.message:p}function A(){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}Qn.exports=La});var Yn=z((rt,Me)=>{rt.formatArgs=za;rt.save=Va;rt.load=ja;rt.useColors=$a;rt.storage=qa();rt.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`."))}})();rt.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 $a(){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 za(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Me.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,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}rt.log=console.debug||console.log||(()=>{});function Va(r){try{r?rt.storage.setItem("debug",r):rt.storage.removeItem("debug")}catch{}}function ja(){let r;try{r=rt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function qa(){try{return localStorage}catch{}}Me.exports=ar()(rt);var{formatters:Ga}=Me.exports;Ga.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ts=z((kp,Kn)=>{"use strict";Kn.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),o=t.indexOf("--");return n!==-1&&(o===-1?!0:n<o)}});var rs=z((Op,es)=>{"use strict";var Ha=mt("os"),ht=ts(),Z=process.env,Wt;ht("no-color")||ht("no-colors")||ht("color=false")?Wt=!1:(ht("color")||ht("colors")||ht("color=true")||ht("color=always"))&&(Wt=!0);"FORCE_COLOR"in Z&&(Wt=Z.FORCE_COLOR.length===0||parseInt(Z.FORCE_COLOR,10)!==0);function Za(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Wa(r){if(Wt===!1)return 0;if(ht("color=16m")||ht("color=full")||ht("color=truecolor"))return 3;if(ht("color=256"))return 2;if(r&&!r.isTTY&&Wt!==!0)return 0;let t=Wt?1:0;if(process.platform==="win32"){let e=Ha.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 Z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in Z)||Z.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in Z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Z.TEAMCITY_VERSION)?1:0;if(Z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Z){let e=parseInt((Z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Z.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Z.TERM)||"COLORTERM"in Z?1:(Z.TERM==="dumb",t)}function cr(r){let t=Wa(r);return Za(t)}es.exports={supportsColor:cr,stdout:cr(process.stdout),stderr:cr(process.stderr)}});var ss=z((q,De)=>{var Ja=mt("tty"),Re=mt("util");q.init=rc;q.log=Ka;q.formatArgs=Qa;q.save=tc;q.load=ec;q.useColors=Xa;q.destroy=Re.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=rs();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,(o,c)=>c.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 Xa(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:Ja.isatty(process.stderr.fd)}function Qa(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),c=` ${o};1m${t} \x1B[0m`;r[0]=c+r[0].split(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+
|
|
5
|
-
`)}function
|
|
6
|
-
`).map(t=>t.trim()).join(" ")};En.O=function(r){return this.inspectOpts.colors=this.useColors,ye.inspect(r,this.inspectOpts)}});var In=L((Lu,tr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?tr.exports=vn():tr.exports=An()});var Jn=L((_f,Xn)=>{Xn.exports=Cr;var Wn=128,gc=127,bc=~gc,wc=Math.pow(2,31);function Cr(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Cr.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=wc;)t[e++]=r&255|Wn,r/=128;for(;r&bc;)t[e++]=r&255|Wn,r>>>=7;return t[e]=r|0,Cr.bytes=e-n+1,t}});var Kn=L((Ff,Qn)=>{Qn.exports=Er;var yc=128,Yn=127;function Er(r,n){var e=0,n=n||0,i=0,u=n,f,d=r.length;do{if(u>=d||i>49)throw Er.bytes=0,new RangeError("Could not decode varint");f=r[u++],e+=i<28?(f&Yn)<<i:(f&Yn)*Math.pow(2,i),i+=7}while(f>=yc);return Er.bytes=u-n,e}});var es=L((Nf,ts)=>{var vc=Math.pow(2,7),xc=Math.pow(2,14),Sc=Math.pow(2,21),Tc=Math.pow(2,28),Cc=Math.pow(2,35),Ec=Math.pow(2,42),Ac=Math.pow(2,49),Ic=Math.pow(2,56),Bc=Math.pow(2,63);ts.exports=function(r){return r<vc?1:r<xc?2:r<Sc?3:r<Tc?4:r<Cc?5:r<Ec?6:r<Ac?7:r<Ic?8:r<Bc?9:10}});var Ee=L((Lf,rs)=>{rs.exports={encode:Jn(),decode:Kn(),encodingLength:es()}});var zr=L((Le,Bs)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(s,o,a){s!=null&&(typeof s=="number"?this.fromNumber(s,o,a):o==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,o))}function i(){return new n(null)}function u(s,o,a,c,p,h){for(;--h>=0;){var b=o*this[s++]+a[c]+p;p=Math.floor(b/67108864),a[c++]=b&67108863}return p}function f(s,o,a,c,p,h){for(var b=o&32767,v=o>>15;--h>=0;){var M=this[s]&32767,$=this[s++]>>15,at=v*M+$*b;M=b*M+((at&32767)<<15)+a[c]+(p&1073741823),p=(M>>>30)+(at>>>15)+v*$+(p>>>30),a[c++]=M&1073741823}return p}function d(s,o,a,c,p,h){for(var b=o&16383,v=o>>14;--h>=0;){var M=this[s]&16383,$=this[s++]>>14,at=v*M+$*b;M=b*M+((at&16383)<<14)+a[c]+p,p=(M>>28)+(at>>14)+v*$,a[c++]=M&268435455}return p}var g=typeof navigator<"u";g&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=f,r=30):g&&e&&navigator.appName!="Netscape"?(n.prototype.am=u,r=26):(n.prototype.am=d,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var A=52;n.prototype.FV=Math.pow(2,A),n.prototype.F1=A-r,n.prototype.F2=2*r-A;var l="0123456789abcdefghijklmnopqrstuvwxyz",y=new Array,x,S;for(x="0".charCodeAt(0),S=0;S<=9;++S)y[x++]=S;for(x="a".charCodeAt(0),S=10;S<36;++S)y[x++]=S;for(x="A".charCodeAt(0),S=10;S<36;++S)y[x++]=S;function m(s){return l.charAt(s)}function C(s,o){var a=y[s.charCodeAt(o)];return a??-1}function B(s){for(var o=this.t-1;o>=0;--o)s[o]=this[o];s.t=this.t,s.s=this.s}function E(s){this.t=1,this.s=s<0?-1:0,s>0?this[0]=s:s<-1?this[0]=s+this.DV:this.t=0}function I(s){var o=i();return o.fromInt(s),o}function _(s,o){var a;if(o==16)a=4;else if(o==8)a=3;else if(o==256)a=8;else if(o==2)a=1;else if(o==32)a=5;else if(o==4)a=2;else{this.fromRadix(s,o);return}this.t=0,this.s=0;for(var c=s.length,p=!1,h=0;--c>=0;){var b=a==8?s[c]&255:C(s,c);if(b<0){s.charAt(c)=="-"&&(p=!0);continue}p=!1,h==0?this[this.t++]=b:h+a>this.DB?(this[this.t-1]|=(b&(1<<this.DB-h)-1)<<h,this[this.t++]=b>>this.DB-h):this[this.t-1]|=b<<h,h+=a,h>=this.DB&&(h-=this.DB)}a==8&&s[0]&128&&(this.s=-1,h>0&&(this[this.t-1]|=(1<<this.DB-h)-1<<h)),this.clamp(),p&&n.ZERO.subTo(this,this)}function N(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t}function tt(s){if(this.s<0)return"-"+this.negate().toString(s);var o;if(s==16)o=4;else if(s==8)o=3;else if(s==2)o=1;else if(s==32)o=5;else if(s==4)o=2;else return this.toRadix(s);var a=(1<<o)-1,c,p=!1,h="",b=this.t,v=this.DB-b*this.DB%o;if(b-- >0)for(v<this.DB&&(c=this[b]>>v)>0&&(p=!0,h=m(c));b>=0;)v<o?(c=(this[b]&(1<<v)-1)<<o-v,c|=this[--b]>>(v+=this.DB-o)):(c=this[b]>>(v-=o)&a,v<=0&&(v+=this.DB,--b)),c>0&&(p=!0),p&&(h+=m(c));return p?h:"0"}function J(){var s=i();return n.ZERO.subTo(this,s),s}function W(){return this.s<0?this.negate():this}function Y(s){var o=this.s-s.s;if(o!=0)return o;var a=this.t;if(o=a-s.t,o!=0)return this.s<0?-o:o;for(;--a>=0;)if((o=this[a]-s[a])!=0)return o;return 0}function ut(s){var o=1,a;return(a=s>>>16)!=0&&(s=a,o+=16),(a=s>>8)!=0&&(s=a,o+=8),(a=s>>4)!=0&&(s=a,o+=4),(a=s>>2)!=0&&(s=a,o+=2),(a=s>>1)!=0&&(s=a,o+=1),o}function Ys(){return this.t<=0?0:this.DB*(this.t-1)+ut(this[this.t-1]^this.s&this.DM)}function Qs(s,o){var a;for(a=this.t-1;a>=0;--a)o[a+s]=this[a];for(a=s-1;a>=0;--a)o[a]=0;o.t=this.t+s,o.s=this.s}function Ks(s,o){for(var a=s;a<this.t;++a)o[a-s]=this[a];o.t=Math.max(this.t-s,0),o.s=this.s}function to(s,o){var a=s%this.DB,c=this.DB-a,p=(1<<c)-1,h=Math.floor(s/this.DB),b=this.s<<a&this.DM,v;for(v=this.t-1;v>=0;--v)o[v+h+1]=this[v]>>c|b,b=(this[v]&p)<<a;for(v=h-1;v>=0;--v)o[v]=0;o[h]=b,o.t=this.t+h+1,o.s=this.s,o.clamp()}function eo(s,o){o.s=this.s;var a=Math.floor(s/this.DB);if(a>=this.t){o.t=0;return}var c=s%this.DB,p=this.DB-c,h=(1<<c)-1;o[0]=this[a]>>c;for(var b=a+1;b<this.t;++b)o[b-a-1]|=(this[b]&h)<<p,o[b-a]=this[b]>>c;c>0&&(o[this.t-a-1]|=(this.s&h)<<p),o.t=this.t-a,o.clamp()}function ro(s,o){for(var a=0,c=0,p=Math.min(s.t,this.t);a<p;)c+=this[a]-s[a],o[a++]=c&this.DM,c>>=this.DB;if(s.t<this.t){for(c-=s.s;a<this.t;)c+=this[a],o[a++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;a<s.t;)c-=s[a],o[a++]=c&this.DM,c>>=this.DB;c-=s.s}o.s=c<0?-1:0,c<-1?o[a++]=this.DV+c:c>0&&(o[a++]=c),o.t=a,o.clamp()}function no(s,o){var a=this.abs(),c=s.abs(),p=a.t;for(o.t=p+c.t;--p>=0;)o[p]=0;for(p=0;p<c.t;++p)o[p+a.t]=a.am(0,c[p],o,p,0,a.t);o.s=0,o.clamp(),this.s!=s.s&&n.ZERO.subTo(o,o)}function so(s){for(var o=this.abs(),a=s.t=2*o.t;--a>=0;)s[a]=0;for(a=0;a<o.t-1;++a){var c=o.am(a,o[a],s,2*a,0,1);(s[a+o.t]+=o.am(a+1,2*o[a],s,2*a+1,c,o.t-a-1))>=o.DV&&(s[a+o.t]-=o.DV,s[a+o.t+1]=1)}s.t>0&&(s[s.t-1]+=o.am(a,o[a],s,2*a,0,1)),s.s=0,s.clamp()}function oo(s,o,a){var c=s.abs();if(!(c.t<=0)){var p=this.abs();if(p.t<c.t){o?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=i());var h=i(),b=this.s,v=s.s,M=this.DB-ut(c[c.t-1]);M>0?(c.lShiftTo(M,h),p.lShiftTo(M,a)):(c.copyTo(h),p.copyTo(a));var $=h.t,at=h[$-1];if(at!=0){var rt=at*(1<<this.F1)+($>1?h[$-2]>>this.F2:0),wt=this.FV/rt,de=(1<<this.F1)/rt,lt=1<<this.F2,pt=a.t,me=pt-$,Ct=o??i();for(h.dlShiftTo(me,Ct),a.compareTo(Ct)>=0&&(a[a.t++]=1,a.subTo(Ct,a)),n.ONE.dlShiftTo($,Ct),Ct.subTo(h,h);h.t<$;)h[h.t++]=0;for(;--me>=0;){var Je=a[--pt]==at?this.DM:Math.floor(a[pt]*wt+(a[pt-1]+lt)*de);if((a[pt]+=h.am(0,Je,a,me,0,$))<Je)for(h.dlShiftTo(me,Ct),a.subTo(Ct,a);a[pt]<--Je;)a.subTo(Ct,a)}o!=null&&(a.drShiftTo($,o),b!=v&&n.ZERO.subTo(o,o)),a.t=$,a.clamp(),M>0&&a.rShiftTo(M,a),b<0&&n.ZERO.subTo(a,a)}}}function io(s){var o=i();return this.abs().divRemTo(s,null,o),this.s<0&&o.compareTo(n.ZERO)>0&&s.subTo(o,o),o}function Dt(s){this.m=s}function ao(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s}function co(s){return s}function uo(s){s.divRemTo(this.m,null,s)}function fo(s,o,a){s.multiplyTo(o,a),this.reduce(a)}function lo(s,o){s.squareTo(o),this.reduce(o)}Dt.prototype.convert=ao,Dt.prototype.revert=co,Dt.prototype.reduce=uo,Dt.prototype.mulTo=fo,Dt.prototype.sqrTo=lo;function po(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var o=s&3;return o=o*(2-(s&15)*o)&15,o=o*(2-(s&255)*o)&255,o=o*(2-((s&65535)*o&65535))&65535,o=o*(2-s*o%this.DV)%this.DV,o>0?this.DV-o:-o}function kt(s){this.m=s,this.mp=s.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<s.DB-15)-1,this.mt2=2*s.t}function ho(s){var o=i();return s.abs().dlShiftTo(this.m.t,o),o.divRemTo(this.m,null,o),s.s<0&&o.compareTo(n.ZERO)>0&&this.m.subTo(o,o),o}function mo(s){var o=i();return s.copyTo(o),this.reduce(o),o}function go(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var o=0;o<this.m.t;++o){var a=s[o]&32767,c=a*this.mpl+((a*this.mph+(s[o]>>15)*this.mpl&this.um)<<15)&s.DM;for(a=o+this.m.t,s[a]+=this.m.am(0,c,s,o,0,this.m.t);s[a]>=s.DV;)s[a]-=s.DV,s[++a]++}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s)}function bo(s,o){s.squareTo(o),this.reduce(o)}function wo(s,o,a){s.multiplyTo(o,a),this.reduce(a)}kt.prototype.convert=ho,kt.prototype.revert=mo,kt.prototype.reduce=go,kt.prototype.mulTo=wo,kt.prototype.sqrTo=bo;function yo(){return(this.t>0?this[0]&1:this.s)==0}function vo(s,o){if(s>4294967295||s<1)return n.ONE;var a=i(),c=i(),p=o.convert(this),h=ut(s)-1;for(p.copyTo(a);--h>=0;)if(o.sqrTo(a,c),(s&1<<h)>0)o.mulTo(c,p,a);else{var b=a;a=c,c=b}return o.revert(a)}function xo(s,o){var a;return s<256||o.isEven()?a=new Dt(o):a=new kt(o),this.exp(s,a)}n.prototype.copyTo=B,n.prototype.fromInt=E,n.prototype.fromString=_,n.prototype.clamp=N,n.prototype.dlShiftTo=Qs,n.prototype.drShiftTo=Ks,n.prototype.lShiftTo=to,n.prototype.rShiftTo=eo,n.prototype.subTo=ro,n.prototype.multiplyTo=no,n.prototype.squareTo=so,n.prototype.divRemTo=oo,n.prototype.invDigit=po,n.prototype.isEven=yo,n.prototype.exp=vo,n.prototype.toString=tt,n.prototype.negate=J,n.prototype.abs=W,n.prototype.compareTo=Y,n.prototype.bitLength=Ys,n.prototype.mod=io,n.prototype.modPowInt=xo,n.ZERO=I(0),n.ONE=I(1);function So(){var s=i();return this.copyTo(s),s}function To(){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 Co(){return this.t==0?this.s:this[0]<<24>>24}function Eo(){return this.t==0?this.s:this[0]<<16>>16}function Ao(s){return Math.floor(Math.LN2*this.DB/Math.log(s))}function Io(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Bo(s){if(s==null&&(s=10),this.signum()==0||s<2||s>36)return"0";var o=this.chunkSize(s),a=Math.pow(s,o),c=I(a),p=i(),h=i(),b="";for(this.divRemTo(c,p,h);p.signum()>0;)b=(a+h.intValue()).toString(s).substr(1)+b,p.divRemTo(c,p,h);return h.intValue().toString(s)+b}function Ro(s,o){this.fromInt(0),o==null&&(o=10);for(var a=this.chunkSize(o),c=Math.pow(o,a),p=!1,h=0,b=0,v=0;v<s.length;++v){var M=C(s,v);if(M<0){s.charAt(v)=="-"&&this.signum()==0&&(p=!0);continue}b=o*b+M,++h>=a&&(this.dMultiply(c),this.dAddOffset(b,0),h=0,b=0)}h>0&&(this.dMultiply(Math.pow(o,h)),this.dAddOffset(b,0)),p&&n.ZERO.subTo(this,this)}function Mo(s,o,a){if(typeof o=="number")if(s<2)this.fromInt(1);else for(this.fromNumber(s,a),this.testBit(s-1)||this.bitwiseTo(n.ONE.shiftLeft(s-1),He,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(o);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(n.ONE.shiftLeft(s-1),this);else{var c=new Array,p=s&7;c.length=(s>>3)+1,o.nextBytes(c),p>0?c[0]&=(1<<p)-1:c[0]=0,this.fromString(c,256)}}function Do(){var s=this.t,o=new Array;o[0]=this.s;var a=this.DB-s*this.DB%8,c,p=0;if(s-- >0)for(a<this.DB&&(c=this[s]>>a)!=(this.s&this.DM)>>a&&(o[p++]=c|this.s<<this.DB-a);s>=0;)a<8?(c=(this[s]&(1<<a)-1)<<8-a,c|=this[--s]>>(a+=this.DB-8)):(c=this[s]>>(a-=8)&255,a<=0&&(a+=this.DB,--s)),c&128&&(c|=-256),p==0&&(this.s&128)!=(c&128)&&++p,(p>0||c!=this.s)&&(o[p++]=c);return o}function ko(s){return this.compareTo(s)==0}function Po(s){return this.compareTo(s)<0?this:s}function Oo(s){return this.compareTo(s)>0?this:s}function _o(s,o,a){var c,p,h=Math.min(s.t,this.t);for(c=0;c<h;++c)a[c]=o(this[c],s[c]);if(s.t<this.t){for(p=s.s&this.DM,c=h;c<this.t;++c)a[c]=o(this[c],p);a.t=this.t}else{for(p=this.s&this.DM,c=h;c<s.t;++c)a[c]=o(p,s[c]);a.t=s.t}a.s=o(this.s,s.s),a.clamp()}function Fo(s,o){return s&o}function No(s){var o=i();return this.bitwiseTo(s,Fo,o),o}function He(s,o){return s|o}function Lo(s){var o=i();return this.bitwiseTo(s,He,o),o}function cn(s,o){return s^o}function Uo(s){var o=i();return this.bitwiseTo(s,cn,o),o}function un(s,o){return s&~o}function $o(s){var o=i();return this.bitwiseTo(s,un,o),o}function Vo(){for(var s=i(),o=0;o<this.t;++o)s[o]=this.DM&~this[o];return s.t=this.t,s.s=~this.s,s}function jo(s){var o=i();return s<0?this.rShiftTo(-s,o):this.lShiftTo(s,o),o}function zo(s){var o=i();return s<0?this.lShiftTo(-s,o):this.rShiftTo(s,o),o}function qo(s){if(s==0)return-1;var o=0;return s&65535||(s>>=16,o+=16),s&255||(s>>=8,o+=8),s&15||(s>>=4,o+=4),s&3||(s>>=2,o+=2),s&1||++o,o}function Go(){for(var s=0;s<this.t;++s)if(this[s]!=0)return s*this.DB+qo(this[s]);return this.s<0?this.t*this.DB:-1}function Ho(s){for(var o=0;s!=0;)s&=s-1,++o;return o}function Zo(){for(var s=0,o=this.s&this.DM,a=0;a<this.t;++a)s+=Ho(this[a]^o);return s}function Wo(s){var o=Math.floor(s/this.DB);return o>=this.t?this.s!=0:(this[o]&1<<s%this.DB)!=0}function Xo(s,o){var a=n.ONE.shiftLeft(s);return this.bitwiseTo(a,o,a),a}function Jo(s){return this.changeBit(s,He)}function Yo(s){return this.changeBit(s,un)}function Qo(s){return this.changeBit(s,cn)}function Ko(s,o){for(var a=0,c=0,p=Math.min(s.t,this.t);a<p;)c+=this[a]+s[a],o[a++]=c&this.DM,c>>=this.DB;if(s.t<this.t){for(c+=s.s;a<this.t;)c+=this[a],o[a++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;a<s.t;)c+=s[a],o[a++]=c&this.DM,c>>=this.DB;c+=s.s}o.s=c<0?-1:0,c>0?o[a++]=c:c<-1&&(o[a++]=this.DV+c),o.t=a,o.clamp()}function ti(s){var o=i();return this.addTo(s,o),o}function ei(s){var o=i();return this.subTo(s,o),o}function ri(s){var o=i();return this.multiplyTo(s,o),o}function ni(){var s=i();return this.squareTo(s),s}function si(s){var o=i();return this.divRemTo(s,o,null),o}function oi(s){var o=i();return this.divRemTo(s,null,o),o}function ii(s){var o=i(),a=i();return this.divRemTo(s,o,a),new Array(o,a)}function ai(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp()}function ci(s,o){if(s!=0){for(;this.t<=o;)this[this.t++]=0;for(this[o]+=s;this[o]>=this.DV;)this[o]-=this.DV,++o>=this.t&&(this[this.t++]=0),++this[o]}}function oe(){}function fn(s){return s}function ui(s,o,a){s.multiplyTo(o,a)}function fi(s,o){s.squareTo(o)}oe.prototype.convert=fn,oe.prototype.revert=fn,oe.prototype.mulTo=ui,oe.prototype.sqrTo=fi;function li(s){return this.exp(s,new oe)}function pi(s,o,a){var c=Math.min(this.t+s.t,o);for(a.s=0,a.t=c;c>0;)a[--c]=0;var p;for(p=a.t-this.t;c<p;++c)a[c+this.t]=this.am(0,s[c],a,c,0,this.t);for(p=Math.min(s.t,o);c<p;++c)this.am(0,s[c],a,c,0,o-c);a.clamp()}function hi(s,o,a){--o;var c=a.t=this.t+s.t-o;for(a.s=0;--c>=0;)a[c]=0;for(c=Math.max(o-this.t,0);c<s.t;++c)a[this.t+c-o]=this.am(o-c,s[c],a,0,0,this.t+c-o);a.clamp(),a.drShiftTo(1,a)}function Pt(s){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*s.t,this.r2),this.mu=this.r2.divide(s),this.m=s}function di(s){if(s.s<0||s.t>2*this.m.t)return s.mod(this.m);if(s.compareTo(this.m)<0)return s;var o=i();return s.copyTo(o),this.reduce(o),o}function mi(s){return s}function gi(s){for(s.drShiftTo(this.m.t-1,this.r2),s.t>this.m.t+1&&(s.t=this.m.t+1,s.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);s.compareTo(this.r2)<0;)s.dAddOffset(1,this.m.t+1);for(s.subTo(this.r2,s);s.compareTo(this.m)>=0;)s.subTo(this.m,s)}function bi(s,o){s.squareTo(o),this.reduce(o)}function wi(s,o,a){s.multiplyTo(o,a),this.reduce(a)}Pt.prototype.convert=di,Pt.prototype.revert=mi,Pt.prototype.reduce=gi,Pt.prototype.mulTo=wi,Pt.prototype.sqrTo=bi;function yi(s,o){var a=s.bitLength(),c,p=I(1),h;if(a<=0)return p;a<18?c=1:a<48?c=3:a<144?c=4:a<768?c=5:c=6,a<8?h=new Dt(o):o.isEven()?h=new Pt(o):h=new kt(o);var b=new Array,v=3,M=c-1,$=(1<<c)-1;if(b[1]=h.convert(this),c>1){var at=i();for(h.sqrTo(b[1],at);v<=$;)b[v]=i(),h.mulTo(at,b[v-2],b[v]),v+=2}var rt=s.t-1,wt,de=!0,lt=i(),pt;for(a=ut(s[rt])-1;rt>=0;){for(a>=M?wt=s[rt]>>a-M&$:(wt=(s[rt]&(1<<a+1)-1)<<M-a,rt>0&&(wt|=s[rt-1]>>this.DB+a-M)),v=c;!(wt&1);)wt>>=1,--v;if((a-=v)<0&&(a+=this.DB,--rt),de)b[wt].copyTo(p),de=!1;else{for(;v>1;)h.sqrTo(p,lt),h.sqrTo(lt,p),v-=2;v>0?h.sqrTo(p,lt):(pt=p,p=lt,lt=pt),h.mulTo(lt,b[wt],p)}for(;rt>=0&&!(s[rt]&1<<a);)h.sqrTo(p,lt),pt=p,p=lt,lt=pt,--a<0&&(a=this.DB-1,--rt)}return h.revert(p)}function vi(s){var o=this.s<0?this.negate():this.clone(),a=s.s<0?s.negate():s.clone();if(o.compareTo(a)<0){var c=o;o=a,a=c}var p=o.getLowestSetBit(),h=a.getLowestSetBit();if(h<0)return o;for(p<h&&(h=p),h>0&&(o.rShiftTo(h,o),a.rShiftTo(h,a));o.signum()>0;)(p=o.getLowestSetBit())>0&&o.rShiftTo(p,o),(p=a.getLowestSetBit())>0&&a.rShiftTo(p,a),o.compareTo(a)>=0?(o.subTo(a,o),o.rShiftTo(1,o)):(a.subTo(o,a),a.rShiftTo(1,a));return h>0&&a.lShiftTo(h,a),a}function xi(s){if(s<=0)return 0;var o=this.DV%s,a=this.s<0?s-1:0;if(this.t>0)if(o==0)a=this[0]%s;else for(var c=this.t-1;c>=0;--c)a=(o*a+this[c])%s;return a}function Si(s){var o=s.isEven();if(this.isEven()&&o||s.signum()==0)return n.ZERO;for(var a=s.clone(),c=this.clone(),p=I(1),h=I(0),b=I(0),v=I(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),o?((!p.isEven()||!h.isEven())&&(p.addTo(this,p),h.subTo(s,h)),p.rShiftTo(1,p)):h.isEven()||h.subTo(s,h),h.rShiftTo(1,h);for(;c.isEven();)c.rShiftTo(1,c),o?((!b.isEven()||!v.isEven())&&(b.addTo(this,b),v.subTo(s,v)),b.rShiftTo(1,b)):v.isEven()||v.subTo(s,v),v.rShiftTo(1,v);a.compareTo(c)>=0?(a.subTo(c,a),o&&p.subTo(b,p),h.subTo(v,h)):(c.subTo(a,c),o&&b.subTo(p,b),v.subTo(h,v))}if(c.compareTo(n.ONE)!=0)return n.ZERO;if(v.compareTo(s)>=0)return v.subtract(s);if(v.signum()<0)v.addTo(s,v);else return v;return v.signum()<0?v.add(s):v}var X=[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],Ti=(1<<26)/X[X.length-1];function Ci(s){var o,a=this.abs();if(a.t==1&&a[0]<=X[X.length-1]){for(o=0;o<X.length;++o)if(a[0]==X[o])return!0;return!1}if(a.isEven())return!1;for(o=1;o<X.length;){for(var c=X[o],p=o+1;p<X.length&&c<Ti;)c*=X[p++];for(c=a.modInt(c);o<p;)if(c%X[o++]==0)return!1}return a.millerRabin(s)}function Ei(s){var o=this.subtract(n.ONE),a=o.getLowestSetBit();if(a<=0)return!1;var c=o.shiftRight(a);s=s+1>>1,s>X.length&&(s=X.length);for(var p=i(),h=0;h<s;++h){p.fromInt(X[Math.floor(Math.random()*X.length)]);var b=p.modPow(c,this);if(b.compareTo(n.ONE)!=0&&b.compareTo(o)!=0){for(var v=1;v++<a&&b.compareTo(o)!=0;)if(b=b.modPowInt(2,this),b.compareTo(n.ONE)==0)return!1;if(b.compareTo(o)!=0)return!1}}return!0}n.prototype.chunkSize=Ao,n.prototype.toRadix=Bo,n.prototype.fromRadix=Ro,n.prototype.fromNumber=Mo,n.prototype.bitwiseTo=_o,n.prototype.changeBit=Xo,n.prototype.addTo=Ko,n.prototype.dMultiply=ai,n.prototype.dAddOffset=ci,n.prototype.multiplyLowerTo=pi,n.prototype.multiplyUpperTo=hi,n.prototype.modInt=xi,n.prototype.millerRabin=Ei,n.prototype.clone=So,n.prototype.intValue=To,n.prototype.byteValue=Co,n.prototype.shortValue=Eo,n.prototype.signum=Io,n.prototype.toByteArray=Do,n.prototype.equals=ko,n.prototype.min=Po,n.prototype.max=Oo,n.prototype.and=No,n.prototype.or=Lo,n.prototype.xor=Uo,n.prototype.andNot=$o,n.prototype.not=Vo,n.prototype.shiftLeft=jo,n.prototype.shiftRight=zo,n.prototype.getLowestSetBit=Go,n.prototype.bitCount=Zo,n.prototype.testBit=Wo,n.prototype.setBit=Jo,n.prototype.clearBit=Yo,n.prototype.flipBit=Qo,n.prototype.add=ti,n.prototype.subtract=ei,n.prototype.multiply=ri,n.prototype.divide=si,n.prototype.remainder=oi,n.prototype.divideAndRemainder=ii,n.prototype.modPow=yi,n.prototype.modInverse=Si,n.prototype.pow=li,n.prototype.gcd=vi,n.prototype.isProbablePrime=Ci,n.prototype.square=ni,n.prototype.Barrett=Pt;var he,et,U;function Ai(s){et[U++]^=s&255,et[U++]^=s>>8&255,et[U++]^=s>>16&255,et[U++]^=s>>24&255,U>=Xe&&(U-=Xe)}function ln(){Ai(new Date().getTime())}if(et==null){et=new Array,U=0;var ft;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var pn=new Uint8Array(32);for(window.crypto.getRandomValues(pn),ft=0;ft<32;++ft)et[U++]=pn[ft]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var hn=window.crypto.random(32);for(ft=0;ft<hn.length;++ft)et[U++]=hn.charCodeAt(ft)&255}}for(;U<Xe;)ft=Math.floor(65536*Math.random()),et[U++]=ft>>>8,et[U++]=ft&255;U=0,ln()}function Ii(){if(he==null){for(ln(),he=Di(),he.init(et),U=0;U<et.length;++U)et[U]=0;U=0}return he.next()}function Bi(s){var o;for(o=0;o<s.length;++o)s[o]=Ii()}function Ze(){}Ze.prototype.nextBytes=Bi;function We(){this.i=0,this.j=0,this.S=new Array}function Ri(s){var o,a,c;for(o=0;o<256;++o)this.S[o]=o;for(a=0,o=0;o<256;++o)a=a+this.S[o]+s[o%s.length]&255,c=this.S[o],this.S[o]=this.S[a],this.S[a]=c;this.i=0,this.j=0}function Mi(){var s;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,s=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=s,this.S[s+this.S[this.i]&255]}We.prototype.init=Ri,We.prototype.next=Mi;function Di(){return new We}var Xe=256;typeof Le<"u"?Le=Bs.exports={default:n,BigInteger:n,SecureRandom:Ze}:this.jsbn={BigInteger:n,SecureRandom:Ze}}).call(Le)});var pe=L(Ue=>{(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(f){return n(u(f),arguments)}function e(f,d){return t.apply(null,[f].concat(d||[]))}function n(f,d){var g=1,A=f.length,l,y="",x,S,m,C,B,E,I,_;for(x=0;x<A;x++)if(typeof f[x]=="string")y+=f[x];else if(typeof f[x]=="object"){if(m=f[x],m.keys)for(l=d[g],S=0;S<m.keys.length;S++){if(l==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',m.keys[S],m.keys[S-1]));l=l[m.keys[S]]}else m.param_no?l=d[m.param_no]:l=d[g++];if(r.not_type.test(m.type)&&r.not_primitive.test(m.type)&&l instanceof Function&&(l=l()),r.numeric_arg.test(m.type)&&typeof l!="number"&&isNaN(l))throw new TypeError(t("[sprintf] expecting number but found %T",l));switch(r.number.test(m.type)&&(I=l>=0),m.type){case"b":l=parseInt(l,10).toString(2);break;case"c":l=String.fromCharCode(parseInt(l,10));break;case"d":case"i":l=parseInt(l,10);break;case"j":l=JSON.stringify(l,null,m.width?parseInt(m.width):0);break;case"e":l=m.precision?parseFloat(l).toExponential(m.precision):parseFloat(l).toExponential();break;case"f":l=m.precision?parseFloat(l).toFixed(m.precision):parseFloat(l);break;case"g":l=m.precision?String(Number(l.toPrecision(m.precision))):parseFloat(l);break;case"o":l=(parseInt(l,10)>>>0).toString(8);break;case"s":l=String(l),l=m.precision?l.substring(0,m.precision):l;break;case"t":l=String(!!l),l=m.precision?l.substring(0,m.precision):l;break;case"T":l=Object.prototype.toString.call(l).slice(8,-1).toLowerCase(),l=m.precision?l.substring(0,m.precision):l;break;case"u":l=parseInt(l,10)>>>0;break;case"v":l=l.valueOf(),l=m.precision?l.substring(0,m.precision):l;break;case"x":l=(parseInt(l,10)>>>0).toString(16);break;case"X":l=(parseInt(l,10)>>>0).toString(16).toUpperCase();break}r.json.test(m.type)?y+=l:(r.number.test(m.type)&&(!I||m.sign)?(_=I?"+":"-",l=l.toString().replace(r.sign,"")):_="",B=m.pad_char?m.pad_char==="0"?"0":m.pad_char.charAt(1):" ",E=m.width-(_+l).length,C=m.width&&E>0?B.repeat(E):"",y+=m.align?_+l+C:B==="0"?_+C+l:C+_+l)}return y}var i=Object.create(null);function u(f){if(i[f])return i[f];for(var d=f,g,A=[],l=0;d;){if((g=r.text.exec(d))!==null)A.push(g[0]);else if((g=r.modulo.exec(d))!==null)A.push("%");else if((g=r.placeholder.exec(d))!==null){if(g[2]){l|=1;var y=[],x=g[2],S=[];if((S=r.key.exec(x))!==null)for(y.push(S[1]);(x=x.substring(S[0].length))!=="";)if((S=r.key_access.exec(x))!==null)y.push(S[1]);else if((S=r.index_access.exec(x))!==null)y.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");g[2]=y}else l|=2;if(l===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");A.push({placeholder:g[0],param_no:g[1],keys:g[2],sign:g[3],pad_char:g[4],align:g[5],width:g[6],precision:g[7],type:g[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");d=d.substring(g[0].length)}return i[f]=A}typeof Ue<"u"&&(Ue.sprintf=t,Ue.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var ze=L((kp,Us)=>{Us.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 Vs=L((Pp,$s)=>{$s.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 tn=L((Op,js)=>{var du=Vs();js.exports=r=>async t=>{t=du(t);let e=E=>{typeof E.return=="function"&&E.return()},n=null,i=null,u=E=>{n=E,i&&i(E),e(t)},f=null,d=!1,g=()=>{d=!0,f&&f()},A=null,l=!1,y=()=>{l=!0,A&&A()},x=null,S=()=>{x&&x()},m=()=>new Promise((E,I)=>{f=x=E,i=I,r.once("drain",S)}),C=()=>(e(t),new Promise((E,I)=>{if(d||l||n)return E();A=f=E,i=I})),B=()=>{r.removeListener("error",u),r.removeListener("close",g),r.removeListener("finish",y),r.removeListener("drain",S)};r.once("error",u),r.once("close",g),r.once("finish",y);try{for await(let E of t){if(!r.writable||r.destroyed||n)break;r.write(E)===!1&&await m()}}catch(E){n||r.destroy(),n=E}try{if(r.writable&&r.end(),await C(),n)throw n}finally{B()}}});var en=L((_p,zs)=>{var mu=tn(),gu=ze();zs.exports=r=>({sink:mu(r),source:gu(r)})});var Gs=L((Fp,qs)=>{var bu=en();qs.exports=r=>async function*(t){let e=bu(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var Hs=L((Np,ne)=>{ne.exports=ze();ne.exports.source=ze();ne.exports.sink=tn();ne.exports.transform=Gs();ne.exports.duplex=en()});var Ru={};nt(Ru,{tcp:()=>Bu});var Js=j(yt("net"),1);var gn=Symbol.for("@libp2p/transport");var mn;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(mn||(mn={}));var ge=class extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=ge.code,this.type=ge.type}},Et=ge;Ye(Et,"code","ABORT_ERR"),Ye(Et,"type","aborted");var Q=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ot=j(In(),1);var or={};nt(or,{base58btc:()=>q,base58flickr:()=>ha});function ca(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 u=r.charAt(i),f=u.charCodeAt(0);if(e[f]!==255)throw new TypeError(u+" is ambiguous");e[f]=i}var d=r.length,g=r.charAt(0),A=Math.log(d)/Math.log(256),l=Math.log(256)/Math.log(d);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var C=0,B=0,E=0,I=m.length;E!==I&&m[E]===0;)E++,C++;for(var _=(I-E)*l+1>>>0,N=new Uint8Array(_);E!==I;){for(var tt=m[E],J=0,W=_-1;(tt!==0||J<B)&&W!==-1;W--,J++)tt+=256*N[W]>>>0,N[W]=tt%d>>>0,tt=tt/d>>>0;if(tt!==0)throw new Error("Non-zero carry");B=J,E++}for(var Y=_-B;Y!==_&&N[Y]===0;)Y++;for(var ut=g.repeat(C);Y<_;++Y)ut+=r.charAt(N[Y]);return ut}function x(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var C=0;if(m[C]!==" "){for(var B=0,E=0;m[C]===g;)B++,C++;for(var I=(m.length-C)*A+1>>>0,_=new Uint8Array(I);m[C];){var N=e[m.charCodeAt(C)];if(N===255)return;for(var tt=0,J=I-1;(N!==0||tt<E)&&J!==-1;J--,tt++)N+=d*_[J]>>>0,_[J]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");E=tt,C++}if(m[C]!==" "){for(var W=I-E;W!==I&&_[W]===0;)W++;for(var Y=new Uint8Array(B+(I-W)),ut=B;W!==I;)Y[ut++]=_[W++];return Y}}}function S(m){var C=x(m);if(C)return C;throw new Error(`Non-${t} character`)}return{encode:y,decodeUnsafe:x,decode:S}}var ua=ca,fa=ua,Bn=fa;var $u=new Uint8Array(0);var Rn=(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},ct=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 Mn=r=>new TextEncoder().encode(r),Dn=r=>new TextDecoder().decode(r);var er=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")}},rr=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 Pn(this,t)}},nr=class{constructor(t){this.decoders=t}or(t){return Pn(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`)}},Pn=(r,t)=>new nr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),sr=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new er(t,e,n),this.decoder=new rr(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Ht=({name:r,prefix:t,encode:e,decode:n})=>new sr(r,t,e,n),At=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=Bn(e,t);return Ht({prefix:r,name:t,encode:n,decode:u=>ct(i(u))})},la=(r,t,e,n)=>{let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let u=r.length;for(;r[u-1]==="=";)--u;let f=new Uint8Array(u*e/8|0),d=0,g=0,A=0;for(let l=0;l<u;++l){let y=i[r[l]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);g=g<<e|y,d+=e,d>=8&&(d-=8,f[A++]=255&g>>d)}if(d>=e||255&g<<8-d)throw new SyntaxError("Unexpected end of data");return f},pa=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,u="",f=0,d=0;for(let g=0;g<r.length;++g)for(d=d<<8|r[g],f+=8;f>e;)f-=e,u+=t[i&d>>f];if(f&&(u+=t[i&d<<e-f]),n)for(;u.length*e&7;)u+="=";return u},P=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Ht({prefix:t,name:r,encode(i){return pa(i,n,e)},decode(i){return la(i,n,e,r)}});var q=At({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ha=At({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ir={};nt(ir,{base32:()=>dt,base32hex:()=>ba,base32hexpad:()=>ya,base32hexpadupper:()=>va,base32hexupper:()=>wa,base32pad:()=>ma,base32padupper:()=>ga,base32upper:()=>da,base32z:()=>xa});var dt=P({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),da=P({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ma=P({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ga=P({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ba=P({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wa=P({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ya=P({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),va=P({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xa=P({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var cr={};nt(cr,{base64:()=>ar,base64pad:()=>Sa,base64url:()=>Ta,base64urlpad:()=>Ca});var ar=P({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Sa=P({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ta=P({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ca=P({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});ot.default.formatters.b=r=>r==null?"undefined":q.baseEncode(r);ot.default.formatters.t=r=>r==null?"undefined":dt.baseEncode(r);ot.default.formatters.m=r=>r==null?"undefined":ar.baseEncode(r);ot.default.formatters.p=r=>r==null?"undefined":r.toString();ot.default.formatters.c=r=>r==null?"undefined":r.toString();ot.default.formatters.k=r=>r==null?"undefined":r.toString();ot.default.formatters.a=r=>r==null?"undefined":r.toString();function Ea(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function It(r){let t=Ea(`${r}:trace`);return ot.default.enabled(`${r}:trace`)&&ot.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,ot.default)(`${r}:trace`)),Object.assign((0,ot.default)(r),{error:(0,ot.default)(`${r}:error`),trace:t})}var Aa=Fn,On=128,Ia=127,Ba=~Ia,Ra=Math.pow(2,31);function Fn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ra;)t[e++]=r&255|On,r/=128;for(;r&Ba;)t[e++]=r&255|On,r>>>=7;return t[e]=r|0,Fn.bytes=e-n+1,t}var Ma=ur,Da=128,_n=127;function ur(r,n){var e=0,n=n||0,i=0,u=n,f,d=r.length;do{if(u>=d)throw ur.bytes=0,new RangeError("Could not decode varint");f=r[u++],e+=i<28?(f&_n)<<i:(f&_n)*Math.pow(2,i),i+=7}while(f>=Da);return ur.bytes=u-n,e}var ka=Math.pow(2,7),Pa=Math.pow(2,14),Oa=Math.pow(2,21),_a=Math.pow(2,28),Fa=Math.pow(2,35),Na=Math.pow(2,42),La=Math.pow(2,49),Ua=Math.pow(2,56),$a=Math.pow(2,63),Va=function(r){return r<ka?1:r<Pa?2:r<Oa?3:r<_a?4:r<Fa?5:r<Na?6:r<La?7:r<Ua?8:r<$a?9:10},ja={encode:Aa,decode:Ma,encodingLength:Va},za=ja,ae=za;var ce=(r,t=0)=>[ae.decode(r,t),ae.decode.bytes],Zt=(r,t,e=0)=>(ae.encode(r,t,e),t),Wt=r=>ae.encodingLength(r);var _t=(r,t)=>{let e=t.byteLength,n=Wt(r),i=n+Wt(e),u=new Uint8Array(i+e);return Zt(r,u,0),Zt(e,u,n),u.set(t,i),new Xt(r,e,t,u)},Se=r=>{let t=ct(r),[e,n]=ce(t),[i,u]=ce(t.subarray(n)),f=t.subarray(n+u);if(f.byteLength!==i)throw new Error("Incorrect length");return new Xt(e,i,f,t)},Nn=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Rn(r.bytes,e.bytes)}},Xt=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Ln=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Ga(e,fr(r),t||q.encoder);default:return Ha(e,fr(r),t||dt.encoder)}};var Un=new WeakMap,fr=r=>{let t=Un.get(r);if(t==null){let e=new Map;return Un.set(r,e),e}return t},D=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!==ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Za)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return D.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=_t(t,e);return D.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 D.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Nn(t.multihash,n.multihash)}toString(t){return Ln(this,t)}toJSON(){return{"/":Ln(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 D)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:u,bytes:f}=e;return new D(n,i,u,f||$n(n,i,u.bytes))}else if(e[Wa]===!0){let{version:n,multihash:i,code:u}=e,f=Se(i);return D.create(n,u,f)}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!==ue)throw new Error(`Version 0 CID must use dag-pb (code: ${ue}) block encoding`);return new D(t,e,n,n.bytes)}case 1:{let i=$n(t,e,n.bytes);return new D(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return D.create(0,ue,t)}static createV1(t,e){return D.create(1,t,e)}static decode(t){let[e,n]=D.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=D.inspectBytes(t),n=e.size-e.multihashSize,i=ct(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let u=i.subarray(e.multihashSize-e.digestSize),f=new Xt(e.multihashCode,e.digestSize,u,i);return[e.version===0?D.createV0(f):D.createV1(e.codec,f),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[y,x]=ce(t.subarray(e));return e+=x,y},i=n(),u=ue;if(i===18?(i=0,e=0):u=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let f=e,d=n(),g=n(),A=e+g,l=A-f;return{version:i,codec:u,multihashCode:d,digestSize:g,multihashSize:l,size:A}}static parse(t,e){let[n,i]=qa(t,e),u=D.decode(i);if(u.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return fr(u).set(n,t),u}},qa=(r,t)=>{switch(r[0]){case"Q":{let e=t||q;return[q.prefix,e.decode(`${q.prefix}${r}`)]}case q.prefix:{let e=t||q;return[q.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)]}}},Ga=(r,t,e)=>{let{prefix:n}=e;if(n!==q.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let u=e.encode(r).slice(1);return t.set(n,u),u}else return i},Ha=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let u=e.encode(r);return t.set(n,u),u}else return i},ue=112,Za=18,$n=(r,t,e)=>{let n=Wt(r),i=n+Wt(t),u=new Uint8Array(i+e.byteLength);return Zt(r,u,0),Zt(t,u,n),u.set(e,i),u},Wa=Symbol.for("@ipld/js-cid/CID");function Vn(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 lr={};nt(lr,{identity:()=>Xa});var Xa=Ht({prefix:"\0",name:"identity",encode:r=>Dn(r),decode:r=>Mn(r)});var pr={};nt(pr,{base2:()=>Ja});var Ja=P({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hr={};nt(hr,{base8:()=>Ya});var Ya=P({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dr={};nt(dr,{base10:()=>Qa});var Qa=At({prefix:"9",name:"base10",alphabet:"0123456789"});var mr={};nt(mr,{base16:()=>Ka,base16upper:()=>tc});var Ka=P({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tc=P({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gr={};nt(gr,{base36:()=>ec,base36upper:()=>rc});var ec=At({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rc=At({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var br={};nt(br,{base256emoji:()=>ac});var jn=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}"),nc=jn.reduce((r,t,e)=>(r[e]=t,r),[]),sc=jn.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function oc(r){return r.reduce((t,e)=>(t+=nc[e],t),"")}function ic(r){let t=[];for(let e of r){let n=sc[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ac=Ht({prefix:"\u{1F680}",name:"base256emoji",encode:oc,decode:ic});var xr={};nt(xr,{sha256:()=>cc,sha512:()=>uc});var vr=j(yt("crypto"),1);var yr=({name:r,code:t,encode:e})=>new wr(r,t,e),wr=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?_t(this.code,e):e.then(n=>_t(this.code,n))}else throw Error("Unknown type, must be binary type")}};var cc=yr({name:"sha2-256",code:18,encode:r=>ct(vr.default.createHash("sha256").update(r).digest())}),uc=yr({name:"sha2-512",code:19,encode:r=>ct(vr.default.createHash("sha512").update(r).digest())});var Sr={};nt(Sr,{identity:()=>pc});var qn=0,fc="identity",Gn=ct,lc=r=>_t(qn,Gn(r)),pc={code:qn,name:fc,encode:Gn,digest:lc};var yf=new TextEncoder,vf=new TextDecoder;var fe={...lr,...pr,...hr,...dr,...mr,...ir,...gr,...or,...cr,...br},Ef={...xr,...Sr};function Yt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Te(r=0){return globalThis.Buffer?.allocUnsafe!=null?Yt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Zn(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Hn=Zn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Tr=Zn("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=Te(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),mc={utf8:Hn,"utf-8":Hn,hex:fe.base16,latin1:Tr,ascii:Tr,binary:Tr,...fe},Ce=mc;function K(r,t="utf8"){let e=Ce[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 Fr=j(Ee(),1);function vt(r,t){t==null&&(t=r.reduce((i,u)=>i+u.length,0));let e=Te(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return Yt(e)}var Qt=j(Ee(),1);var Ae=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,i){return this.readAtomically(()=>{let u=0,f=0,d=this.peekChar();if(d===void 0)return;let g=d==="0",A=2**(8*i)-1;for(;;){let l=this.readAtomically(()=>{let y=this.readChar();if(y===void 0)return;let x=Number.parseInt(y,t);if(!Number.isNaN(x))return x});if(l===void 0)break;if(u*=t,u+=l,u>A||(f+=1,e!==void 0&&f>e))return}if(f!==0)return!n&&g&&f>1?void 0:u})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let i=n*2;if(n<e.length-3){let f=this.readSeparator(":",n,()=>this.readIPv4Addr());if(f!==void 0)return e[i]=f[0],e[i+1]=f[1],e[i+2]=f[2],e[i+3]=f[3],[i+4,!0]}let u=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(u===void 0)return[i,!1];e[i]=u>>8,e[i+1]=u&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,i]=t(e);if(n===16)return e;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let u=new Uint8Array(14),f=16-(n+2),[d]=t(u.subarray(0,f));return e.set(u.subarray(0,d),16-d),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var qf=new Ae;var Qf=parseInt("0xFFFF",16),Kf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ar(r,t="utf8"){let e=Ce[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Yt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var gt=j(Ee(),1);var Bt=yt("node:net");function Ie(r){return!!(0,Bt.isIP)(r)}var os=Bt.isIPv4,Oc=Bt.isIPv6,Ir=function(r){let t=0;if(r=r.toString().trim(),os(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Oc(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let u=os(e[n]),f;u&&(f=Ir(e[n]),e[n]=K(f.slice(0,2),"base16")),f!=null&&++n<8&&e.splice(n,0,K(f.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 u=[n,1];for(n=9-e.length;n>0;n--)u.push("0");e.splice.apply(e,u)}let i=new Uint8Array(t+16);for(n=0;n<e.length;n++){let u=parseInt(e[n],16);i[t++]=u>>8&255,i[t++]=u&255}return i}throw new Error("invalid ip address")},is=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 u=0;u<e;u++)i.push(r[t+u]);return i.join(".")}if(e===16){let i=[];for(let u=0;u<e;u+=2)i.push(n.getUint16(t+u).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var le={},Br={},Fc=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Fc.forEach(r=>{let t=Nc(...r);Br[t.code]=t,le[t.name]=t});function Nc(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:!!n,path:!!i}}function R(r){if(typeof r=="number"){if(Br[r]!=null)return Br[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(le[r]!=null)return le[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var $l=R("ip4"),Vl=R("ip6"),jl=R("ipcidr");function ls(r,t){switch(R(r).code){case 4:case 41:return Uc(t);case 42:return us(t);case 6:case 273:case 33:case 132:return hs(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return us(t);case 421:return zc(t);case 444:return fs(t);case 445:return fs(t);case 466:return jc(t);default:return K(t,"base16")}}function ps(r,t){switch(R(r).code){case 4:return as(t);case 41:return as(t);case 42:return cs(t);case 6:case 273:case 33:case 132:return Mr(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return cs(t);case 421:return $c(t);case 444:return qc(t);case 445:return Gc(t);case 466:return Vc(t);default:return Ar(t,"base16")}}var Rr=Object.values(fe).map(r=>r.decoder),Lc=function(){let r=Rr[0].or(Rr[1]);return Rr.slice(2).forEach(t=>r=r.or(t)),r}();function as(r){if(!Ie(r))throw new Error("invalid ip address");return Ir(r)}function Uc(r){let t=is(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ie(t))throw new Error("invalid ip address");return t}function Mr(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function hs(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function cs(r){let t=Ar(r),e=Uint8Array.from(gt.default.encode(t.length));return vt([e,t],e.length+t.length)}function us(r){let t=gt.default.decode(r);if(r=r.slice(gt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return K(r)}function $c(r){let t;r[0]==="Q"||r[0]==="1"?t=Se(q.decode(`z${r}`)).bytes:t=D.parse(r).multihash.bytes;let e=Uint8Array.from(gt.default.encode(t.length));return vt([e,t],e.length+t.length)}function Vc(r){let t=Lc.decode(r),e=Uint8Array.from(gt.default.encode(t.length));return vt([e,t],e.length+t.length)}function jc(r){let t=gt.default.decode(r),e=r.slice(gt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+K(e,"base64url")}function zc(r){let t=gt.default.decode(r),e=r.slice(gt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return K(e,"base58btc")}function qc(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=Mr(n);return vt([e,i],e.length+i.length)}function Gc(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=Mr(n);return vt([e,i],e.length+i.length)}function fs(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=K(t,"base32"),i=hs(e);return`${n}:${i}`}function Hc(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],u=R(i);if(u.size===0){t.push([i]);continue}if(n++,n>=e.length)throw ms("invalid address: "+r);if(u.path===!0){t.push([i,_r(e.slice(n).join("/"))]);break}t.push([i,e[n]])}return t}function Zc(r){let t=[];return r.map(e=>{let n=Me(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),_r(t.join("/"))}function Wc(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Me(t);return t.length>1?[e.code,ps(e.code,t[1])]:[e.code]})}function Dr(r){return r.map(t=>{let e=Me(t);return t[1]!=null?[e.code,ls(e.code,t[1])]:[e.code]})}function kr(r){return Re(vt(r.map(t=>{let e=Me(t),n=Uint8Array.from(Qt.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=vt([n,t[1]])),n})))}function Pr(r,t){return r.size>0?r.size/8:r.size===0?0:Qt.default.decode(t)+(Qt.default.decode.bytes??0)}function Be(r){let t=[],e=0;for(;e<r.length;){let n=Qt.default.decode(r,e),i=Qt.default.decode.bytes??0,u=R(n),f=Pr(u,r.slice(e+i));if(f===0){t.push([n]),e+=i;continue}let d=r.slice(e+i,e+i+f);if(e+=f+i,e>r.length)throw ms("Invalid address Uint8Array: "+K(r,"base16"));t.push([n,d])}return t}function Or(r){let t=Be(r),e=Dr(t);return Zc(e)}function Xc(r){r=_r(r);let t=Hc(r),e=Wc(t);return kr(e)}function ds(r){return Xc(r)}function Re(r){let t=Jc(r);if(t!=null)throw t;return Uint8Array.from(r)}function Jc(r){try{Be(r)}catch(t){return t}}function _r(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function ms(r){return new Error("Error parsing address: "+r)}function Me(r){return R(r[0])}var Qc=Symbol.for("nodejs.util.inspect.custom"),Kc=[R("dns").code,R("dns4").code,R("dns6").code,R("dnsaddr").code],tu=new Map,gs=Symbol.for("@multiformats/js-multiaddr/multiaddr");function eu(r){return!!r?.[gs]}var xt=class{bytes;#t;#r;#n;#e;[gs]=!0;constructor(t){if(t==null&&(t=""),t instanceof Uint8Array)this.bytes=Re(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=ds(t)}else if(eu(t))this.bytes=Re(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=Or(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,i,u="",f=R("tcp"),d=R("udp"),g=R("ip4"),A=R("ip6"),l=R("dns6"),y=R("ip6zone");for(let[S,m]of this.stringTuples())S===y.code&&(u=`%${m??""}`),Kc.includes(S)&&(e=f.name,i=443,n=`${m??""}${u}`,t=S===l.code?6:4),(S===f.code||S===d.code)&&(e=R(S).name,i=parseInt(m??"")),(S===g.code||S===A.code)&&(e=R(S).name,n=`${m??""}${u}`,t=S===A.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({},R(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let i=Fr.default.decode(e,n),u=Fr.default.decode.bytes??0,f=R(i),d=Pr(f,e.slice(n+u));n+=d+u,t.push(i)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return this.#r==null&&(this.#r=Be(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=Dr(this.tuples())),this.#n}encapsulate(t){return t=new xt(t),new xt(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 xt(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 xt(kr(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===le.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?K(q.decode(`z${n}`),"base58btc"):K(D.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(t=>R(t[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(t){return Vn(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(u=>u.resolvable);if(e==null)return[this];let n=tu.get(e.name);if(n==null)throw new Q(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(u=>new xt(u))}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)}[Qc](){return`Multiaddr(${Or(this.bytes)})`}};function bt(r){return new xt(r)}var ru=w("dns4"),nu=w("dns6"),su=w("dnsaddr"),Nt=F(w("dns"),su,ru,nu),Pe=F(w("ip4"),w("ip6")),Mt=F(T(Pe,w("tcp")),T(Nt,w("tcp"))),Oe=T(Pe,w("udp")),ou=T(Oe,w("utp")),iu=T(Oe,w("quic")),au=T(Oe,w("quic-v1")),Nr=F(T(Mt,w("ws")),T(Nt,w("ws"))),De=F(T(Nr,w("p2p")),Nr),Lr=F(T(Mt,w("wss")),T(Nt,w("wss")),T(Mt,w("tls"),w("ws")),T(Nt,w("tls"),w("ws"))),ke=F(T(Lr,w("p2p")),Lr),Ur=F(T(Mt,w("http")),T(Pe,w("http")),T(Nt,w("http"))),$r=F(T(Mt,w("https")),T(Pe,w("https")),T(Nt,w("https"))),bs=T(Oe,w("webrtc-direct"),w("certhash")),vs=F(T(bs,w("p2p")),bs),ws=T(au,w("webtransport"),w("certhash"),w("certhash")),xs=F(T(ws,w("p2p")),ws),Ss=F(T(De,w("p2p-webrtc-star"),w("p2p")),T(ke,w("p2p-webrtc-star"),w("p2p")),T(De,w("p2p-webrtc-star")),T(ke,w("p2p-webrtc-star"))),cp=F(T(De,w("p2p-websocket-star"),w("p2p")),T(ke,w("p2p-websocket-star"),w("p2p")),T(De,w("p2p-websocket-star")),T(ke,w("p2p-websocket-star"))),Ts=F(T(Ur,w("p2p-webrtc-direct"),w("p2p")),T($r,w("p2p-webrtc-direct"),w("p2p")),T(Ur,w("p2p-webrtc-direct")),T($r,w("p2p-webrtc-direct"))),Lt=F(Nr,Lr,Ur,$r,Ss,Ts,Mt,ou,iu,Nt,vs,xs),up=F(T(Lt,w("p2p-stardust"),w("p2p")),T(Lt,w("p2p-stardust"))),Rt=F(T(Lt,w("p2p")),Ss,Ts,vs,xs,w("p2p")),ys=F(T(Rt,w("p2p-circuit"),Rt),T(Rt,w("p2p-circuit")),T(w("p2p-circuit"),Rt),T(Lt,w("p2p-circuit")),T(w("p2p-circuit"),Lt),w("p2p-circuit")),Cs=()=>F(T(ys,Cs),ys),Ft=Cs(),fp=F(T(Ft,Rt,Ft),T(Rt,Ft),T(Ft,Rt),Ft,Rt);var lp=F(T(Ft,w("webrtc"),w("p2p")),T(Ft,w("webrtc")),T(Lt,w("webrtc"),w("p2p")),T(Lt,w("webrtc")),w("webrtc"));function Es(r){function t(e){let n;try{n=bt(e)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return t}function T(...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:Es(t),partialMatch:t}}function F(...r){function t(n){let i=null;return r.some(u=>{let f=typeof u=="function"?u().partialMatch(n):u.partialMatch(n);return f!=null?(i=f,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Es(t),partialMatch:t}}function w(r){let t=r;function e(i){let u;try{u=bt(i)}catch{return!1}let f=u.protoNames();return f.length===1&&f[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 Xs=j(yt("net"),1);var _e=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=this.#t.get(t);i==null&&(i=[],this.#t.set(t,i)),i.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let i=this.#t.get(t);i!=null&&(i=i.filter(({callback:u})=>u!==e),this.#t.set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:i})=>!i),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new Kt(t,e))}},Vr=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Kt=globalThis.CustomEvent??Vr;function Fe(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Ne(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var te=/^(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,jr=/\/\d{1,2}$/;var G=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var ee=j(zr(),1),Ut=j(pe(),1),k=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Ne(32),this.isInSubnet=Fe,this.address=t;let e=jr.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 G("Invalid subnet mask.");t=t.replace(jr,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new k(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(te))throw new G("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 u=e.slice(i,i+2);n.push(parseInt(u,16))}return new k(n.join("."))}static fromInteger(t){return k.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new k(n)}toHex(){return this.parsedAddress.map(t=>(0,Ut.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,Ut.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,Ut.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new ee.BigInteger(this.parsedAddress.map(t=>(0,Ut.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new ee.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return k.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new ee.BigInteger("1");return k.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new ee.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return k.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new ee.BigInteger("1");return k.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return k.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,Ut.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new k("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(te,(0,Ut.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 Ms={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},qr={"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"},Gr=/([^0-9a-f:/%])/gi,Hr=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Zr=/\/\d{1,3}(?=%|$)/,Wr=/%.*$/,Ds=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),ks=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Os=j(pe(),1);function uu(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function $e(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Os.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,uu(n)))}var Vt=j(pe(),1);function Jr(r){return(0,Vt.sprintf)("(%s)",r.join("|"))}function Xr(r){return r.length<4?(0,Vt.sprintf)("0{0,%d}%s",4-r.length,r):r}var Yr="[^A-Fa-f0-9:]";function Ve(r){let t=[];r.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let e=t.map(n=>r.map((i,u)=>{if(u===n){let f=u===0||u===8-1?":":"";return Jr([Xr(i),f])}return Xr(i)}).join(":"));return e.push(r.map(Xr).join(":")),Jr(e)}function Qr(r,t,e){let n=t?"":":",i=e?"":":",u=[];!t&&!e&&u.push("::"),t&&e&&u.push(""),(e&&!t||!e&&t)&&u.push(":"),u.push((0,Vt.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),u.push((0,Vt.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),u.push((0,Vt.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let f=1;f<r-1;f++)for(let d=1;d<r-f;d++)u.push((0,Vt.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",d,r-d-f-1));return Jr(u)}var H=j(zr(),1),Z=j(pe(),1);function je(r){if(!r)throw new Error("Assertion failed.")}function fu(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function lu(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 pu(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 Fs(r){return(0,Z.sprintf)("%04x",parseInt(r,16))}function Ns(r){return r&255}var O=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Fe,this.isCorrect=Ne(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Zr.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 G("Invalid subnet mask.");t=t.replace(Zr,"")}else if(/\//.test(t))throw new G("Invalid subnet mask.");let i=Wr.exec(t);i&&(this.zone=i[0],t=t.replace(Wr,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new O(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 O(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=ks.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=Ds.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 O(e),port:n}}static fromAddress4(t){let e=new k(t),n=128-(32-e.subnetMask);return new O(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new G("Invalid 'ip6.arpa' form.");let i=e.split(".").reverse();for(let u=n;u>0;u--){let f=u*4;i.splice(f,0,":")}return e=i.join(""),new O(e)}microsoftTranscription(){return(0,Z.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":fu(new H.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new H.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return O.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new H.BigInteger("1");return O.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new H.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return O.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new H.BigInteger("1");return O.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Ms[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(qr))if(this.isInSubnet(new O(t)))return qr[t];return"Global unicast"}getBits(t,e){return new H.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,Z.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 d=parseInt(this.parsedAddress[t],16);d===0&&n++,d!==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 u=i.map(d=>d[1]-d[0]+1);if(i.length>0){let d=u.indexOf(Math.max(...u));e=pu(this.parsedAddress,i[d])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let f=e.join(":");return f=f.replace(/^compact$/,"::"),f=f.replace(/^compact|compact$/,":"),f=f.replace(/compact/,""),f}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),i=e.slice(-1)[0].match(te);if(i){this.parsedAddress4=i[0],this.address4=new k(this.parsedAddress4);for(let u=0;u<this.address4.groups;u++)if(/^0[0-9]+/.test(this.address4.parsedAddress[u]))throw new G("IPv4 addresses can't have leading zeroes.",t.replace(te,this.address4.parsedAddress.map(lu).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(Gr);if(e)throw new G((0,Z.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(Gr,'<span class="parse-error">$1</span>'));let n=t.match(Hr);if(n)throw new G((0,Z.sprintf)("Address failed regex: %s",n.join("")),t.replace(Hr,'<span class="parse-error">$1</span>'));let i=[],u=t.split("::");if(u.length===2){let f=u[0].split(":"),d=u[1].split(":");f.length===1&&f[0]===""&&(f=[]),d.length===1&&d[0]===""&&(d=[]);let g=this.groups-(f.length+d.length);if(!g)throw new G("Error parsing groups");this.elidedGroups=g,this.elisionBegin=f.length,this.elisionEnd=f.length+this.elidedGroups,i=i.concat(f);for(let A=0;A<g;A++)i.push("0");i=i.concat(d)}else if(u.length===1)i=t.split(":"),this.elidedGroups=0;else throw new G("Too many :: groups found");if(i=i.map(f=>(0,Z.sprintf)("%x",parseInt(f,16))),i.length!==this.groups)throw new G("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(Fs).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Z.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new H.BigInteger(this.parsedAddress.map(Fs).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return k.fromHex(new H.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new O(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 H.BigInteger("ffff",16)).toString(),n=k.fromHex(this.getBitsBase16(32,64)),i=k.fromHex(this.getBits(96,128).xor(new H.BigInteger("ffffffff",16)).toString(16)),u=this.getBits(64,80),f=this.getBitsBase2(64,80),d=u.testBit(15),g=u.testBit(14),A=u.testBit(8),l=u.testBit(9),y=new H.BigInteger(f.slice(2,6)+f.slice(8,16),2).toString(10);return{prefix:(0,Z.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:f,coneNat:d,microsoft:{reserved:g,universalLocal:l,groupIndividual:A,nonce:y},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=k.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Z.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 O(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Ns)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Ns))}static fromUnsignedByteArray(t){let e=new H.BigInteger("256",10),n=new H.BigInteger("0",10),i=new H.BigInteger("1",10);for(let u=t.length-1;u>=0;u--)n=n.add(i.multiply(new H.BigInteger(t[u].toString(10),10))),i=i.multiply(e);return O.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 O("2001::/32"))}is6to4(){return this.isInSubnet(new O("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,Z.sprintf)(":%s",t),(0,Z.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,Z.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,Z.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return $e(this.address).join(":");je(typeof this.elidedGroups=="number"),je(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...$e(e)):t.push("");let i=["hover-group"];for(let u=this.elisionBegin;u<this.elisionBegin+this.elidedGroups;u++)i.push((0,Z.sprintf)("group-%d",u));return t.push((0,Z.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...$e(n,this.elisionEnd)):t.push(""),this.is4()&&(je(this.address4 instanceof k),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new O(this.correctForm());if(n.elidedGroups===0)e.push(Ve(n.parsedAddress));else if(n.elidedGroups===8)e.push(Qr(8));else{let i=n.address.split("::");i[0].length&&e.push(Ve(i[0].split(":"))),je(typeof n.elidedGroups=="number"),e.push(Qr(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Ve(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Yr,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Yr,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var hu=It("libp2p:ip-port-to-multiaddr"),Kr={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Ls(r,t){if(typeof r!="string")throw new Q(`invalid ip provided: ${r}`,Kr.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new Q(`invalid port provided: ${t}`,Kr.ERR_INVALID_PORT_PARAMETER);try{return new k(r),bt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new O(r);return e.is4()?bt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):bt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw hu.error(n),new Q(n,Kr.ERR_INVALID_IP)}}var Ws=j(Hs(),1);var rn=j(yt("os"),1),Zs=j(yt("path"),1);var wu={ip4:"IPv4",ip6:"IPv6"};function se(r,t={}){let e=r.getPath();return e!=null?rn.default.platform()==="win32"?{path:Zs.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function nn(r,t,e){let n=i=>bt(`/${r}/${i}/tcp/${e}`);return(yu(t)?xu(wu[r]):[t]).map(n)}function yu(r){return["0.0.0.0","::"].includes(r)}var vu=rn.default.networkInterfaces();function xu(r){let t=[];for(let[,e]of Object.entries(vu))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var mt=It("libp2p:tcp:socket"),qe=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,u=t.socketCloseTimeout??2e3;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let f;if(t.remoteAddr!=null)f=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new Q("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");f=Ls(r.remoteAddress,r.remotePort)}let d=se(f),g=d.path??`${d.host??""}:${d.port??""}`,{sink:A,source:l}=Ws.default.duplex(r);r.setTimeout(i,()=>{mt("%s socket read timeout",g),e?.increment({[`${n}timeout`]:!0});let x;r.readable&&(x=new Q("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(x)}),r.once("close",()=>{mt("%s socket close",g),e?.increment({[`${n}close`]:!0}),y.timeline.close==null&&(y.timeline.close=Date.now())}),r.once("end",()=>{mt("%s socket end",g),e?.increment({[`${n}end`]:!0})});let y={async sink(x){try{await A(x)}catch(S){S.type!=="aborted"&&mt(S)}r.end()},source:l,remoteAddr:f,timeline:{open:Date.now()},async close(){if(r.destroyed){mt("%s socket was already destroyed when trying to close",g);return}mt("%s closing socket",g),await new Promise((x,S)=>{let m=Date.now(),C;r.once("close",()=>{mt("%s socket closed",g),C!==void 0&&clearTimeout(C),x()}),r.once("error",B=>{mt("%s socket error",g,B),y.timeline.close==null&&(y.timeline.close=Date.now()),r.destroyed&&C!==void 0&&clearTimeout(C),S(B)}),r.setTimeout(u),r.end(),r.writableLength>0?(C=setTimeout(()=>{r.destroyed?(mt("%s is already destroyed",g),x()):(mt("%s socket close timeout after %dms, destroying it manually",g,Date.now()-m),r.destroy(new Q("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},u).unref(),r.once("drain",()=>{mt("%s socket drained",g),r.destroy()})):r.destroy()})}};return y};var it=It("libp2p:tcp:listener");async function sn(r){try{await r.close()}catch(t){it.error("an error occurred closing the connection",t)}}var Cu=1,Eu=0,Ge=class extends _e{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Xs.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]:Cu})}this.dispatchEvent(new Kt("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Kt("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Eu}),this.dispatchEvent(new Kt("close"))})}onSocket(t){t.on("error",n=>{it("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=qe(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){it.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}it("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{it("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=>{it.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 Kt("connection",{detail:n}))}).catch(async n=>{it.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await sn(e)}).catch(n=>{it.error("closing inbound connection failed",n)})}catch(n){it.error("inbound connection failed",n),sn(e).catch(i=>{it.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(nn("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(nn("ip6",e.address,e.port)))}catch(u){it.error("could not turn %s:%s into multiaddr",e.address,e.port,u)}return t.map(u=>i!=null?u.encapsulate(`/p2p/${i}`):u)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:i}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:se(n,{backlog:i})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await sn(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)}),it("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(it("Closing server on %s",this.server.address()),this.server.close())}};var Tt=It("libp2p:tcp"),an=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[gn]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",d=>{Tt("socket error",d)});let i=qe(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),u=()=>{i.close().catch(d=>{Tt.error("Error closing maConn after abort",d)})};e.signal?.addEventListener("abort",u,{once:!0}),Tt("new outbound connection %s",i.remoteAddr);let f=await e.upgrader.upgradeOutbound(i);if(Tt("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",u),e.signal?.aborted===!0)throw f.close().catch(d=>{Tt.error("Error closing conn after abort",d)}),new Et;return f}async _connect(t,e){if(e.signal?.aborted===!0)throw new Et;return new Promise((n,i)=>{let u=Date.now(),f=se(t),d=f.path??`${f.host??""}:${f.port}`;Tt("dialing %j",f);let g=Js.default.connect(f),A=m=>{m.message=`connection error ${d}: ${m.message}`,this.metrics?.dialerEvents.increment({error:!0}),S(m)},l=()=>{Tt("connection timeout %s",d),this.metrics?.dialerEvents.increment({timeout:!0});let m=new Q(`connection timeout after ${Date.now()-u}ms`,"ERR_CONNECT_TIMEOUT");g.emit("error",m)},y=()=>{Tt("connection opened %j",f),this.metrics?.dialerEvents.increment({connect:!0}),S()},x=()=>{Tt("connection aborted %j",f),this.metrics?.dialerEvents.increment({abort:!0}),g.destroy(),S(new Et)},S=m=>{if(g.removeListener("error",A),g.removeListener("timeout",l),g.removeListener("connect",y),e.signal!=null&&e.signal.removeEventListener("abort",x),m!=null){i(m);return}n(g)};g.on("error",A),g.on("timeout",l),g.on("connect",y),e.signal!=null&&e.signal.addEventListener("abort",x)})}createListener(t){return new Ge({...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:Mt.matches(e.decapsulateCode(421)))}};function Bu(r={}){return(t={})=>new an(t,r)}return Li(Ru);})();
|
|
4
|
+
`+c),r.push(o+"m+"+De.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Ya()+t+" "+r[0]}function Ya(){return q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ka(...r){return process.stderr.write(Re.format(...r)+`
|
|
5
|
+
`)}function tc(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function ec(){return process.env.DEBUG}function rc(r){r.inspectOpts={};let t=Object.keys(q.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=q.inspectOpts[t[e]]}De.exports=ar()(q);var{formatters:ns}=De.exports;ns.o=function(r){return this.inspectOpts.colors=this.useColors,Re.inspect(r,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};ns.O=function(r){return this.inspectOpts.colors=this.useColors,Re.inspect(r,this.inspectOpts)}});var os=z((Np,ur)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ur.exports=Yn():ur.exports=ss()});var Vs=z((Ql,zs)=>{zs.exports=jr;var $s=128,Yu=127,Ku=~Yu,tf=Math.pow(2,31);function jr(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw jr.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=tf;)t[e++]=r&255|$s,r/=128;for(;r&Ku;)t[e++]=r&255|$s,r>>>=7;return t[e]=r|0,jr.bytes=e-n+1,t}});var Gs=z((Yl,qs)=>{qs.exports=qr;var ef=128,js=127;function qr(r,n){var e=0,n=n||0,o=0,c=n,f,l=r.length;do{if(c>=l||o>49)throw qr.bytes=0,new RangeError("Could not decode varint");f=r[c++],e+=o<28?(f&js)<<o:(f&js)*Math.pow(2,o),o+=7}while(f>=ef);return qr.bytes=c-n,e}});var Zs=z((Kl,Hs)=>{var rf=Math.pow(2,7),nf=Math.pow(2,14),sf=Math.pow(2,21),of=Math.pow(2,28),af=Math.pow(2,35),cf=Math.pow(2,42),uf=Math.pow(2,49),ff=Math.pow(2,56),pf=Math.pow(2,63);Hs.exports=function(r){return r<rf?1:r<nf?2:r<sf?3:r<of?4:r<af?5:r<cf?6:r<uf?7:r<ff?8:r<pf?9:10}});var Gr=z((th,Ws)=>{Ws.exports={encode:Vs(),decode:Gs(),encodingLength:Zs()}});var Sn=z((We,Eo)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(s,i,a){s!=null&&(typeof s=="number"?this.fromNumber(s,i,a):i==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,i))}function o(){return new n(null)}function c(s,i,a,u,d,m){for(;--m>=0;){var w=i*this[s++]+a[u]+d;d=Math.floor(w/67108864),a[u++]=w&67108863}return d}function f(s,i,a,u,d,m){for(var w=i&32767,x=i>>15;--m>=0;){var k=this[s]&32767,j=this[s++]>>15,it=x*k+j*w;k=w*k+((it&32767)<<15)+a[u]+(d&1073741823),d=(k>>>30)+(it>>>15)+x*j+(d>>>30),a[u++]=k&1073741823}return d}function l(s,i,a,u,d,m){for(var w=i&16383,x=i>>14;--m>=0;){var k=this[s]&16383,j=this[s++]>>14,it=x*k+j*w;k=w*k+((it&16383)<<14)+a[u]+d,d=(k>>28)+(it>>14)+x*j,a[u++]=k&268435455}return d}var g=typeof navigator<"u";g&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=f,r=30):g&&e&&navigator.appName!="Netscape"?(n.prototype.am=c,r=26):(n.prototype.am=l,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var A=52;n.prototype.FV=Math.pow(2,A),n.prototype.F1=A-r,n.prototype.F2=2*r-A;var p="0123456789abcdefghijklmnopqrstuvwxyz",b=new Array,y,S;for(y="0".charCodeAt(0),S=0;S<=9;++S)b[y++]=S;for(y="a".charCodeAt(0),S=10;S<36;++S)b[y++]=S;for(y="A".charCodeAt(0),S=10;S<36;++S)b[y++]=S;function h(s){return p.charAt(s)}function T(s,i){var a=b[s.charCodeAt(i)];return a??-1}function B(s){for(var i=this.t-1;i>=0;--i)s[i]=this[i];s.t=this.t,s.s=this.s}function C(s){this.t=1,this.s=s<0?-1:0,s>0?this[0]=s:s<-1?this[0]=s+this.DV:this.t=0}function I(s){var i=o();return i.fromInt(s),i}function M(s,i){var a;if(i==16)a=4;else if(i==8)a=3;else if(i==256)a=8;else if(i==2)a=1;else if(i==32)a=5;else if(i==4)a=2;else{this.fromRadix(s,i);return}this.t=0,this.s=0;for(var u=s.length,d=!1,m=0;--u>=0;){var w=a==8?s[u]&255:T(s,u);if(w<0){s.charAt(u)=="-"&&(d=!0);continue}d=!1,m==0?this[this.t++]=w:m+a>this.DB?(this[this.t-1]|=(w&(1<<this.DB-m)-1)<<m,this[this.t++]=w>>this.DB-m):this[this.t-1]|=w<<m,m+=a,m>=this.DB&&(m-=this.DB)}a==8&&s[0]&128&&(this.s=-1,m>0&&(this[this.t-1]|=(1<<this.DB-m)-1<<m)),this.clamp(),d&&n.ZERO.subTo(this,this)}function R(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t}function N(s){if(this.s<0)return"-"+this.negate().toString(s);var i;if(s==16)i=4;else if(s==8)i=3;else if(s==2)i=1;else if(s==32)i=5;else if(s==4)i=2;else return this.toRadix(s);var a=(1<<i)-1,u,d=!1,m="",w=this.t,x=this.DB-w*this.DB%i;if(w-- >0)for(x<this.DB&&(u=this[w]>>x)>0&&(d=!0,m=h(u));w>=0;)x<i?(u=(this[w]&(1<<x)-1)<<i-x,u|=this[--w]>>(x+=this.DB-i)):(u=this[w]>>(x-=i)&a,x<=0&&(x+=this.DB,--w)),u>0&&(d=!0),d&&(m+=h(u));return d?m:"0"}function _(){var s=o();return n.ZERO.subTo(this,s),s}function D(){return this.s<0?this.negate():this}function F(s){var i=this.s-s.s;if(i!=0)return i;var a=this.t;if(i=a-s.t,i!=0)return this.s<0?-i:i;for(;--a>=0;)if((i=this[a]-s[a])!=0)return i;return 0}function G(s){var i=1,a;return(a=s>>>16)!=0&&(s=a,i+=16),(a=s>>8)!=0&&(s=a,i+=8),(a=s>>4)!=0&&(s=a,i+=4),(a=s>>2)!=0&&(s=a,i+=2),(a=s>>1)!=0&&(s=a,i+=1),i}function Wo(){return this.t<=0?0:this.DB*(this.t-1)+G(this[this.t-1]^this.s&this.DM)}function Jo(s,i){var a;for(a=this.t-1;a>=0;--a)i[a+s]=this[a];for(a=s-1;a>=0;--a)i[a]=0;i.t=this.t+s,i.s=this.s}function Xo(s,i){for(var a=s;a<this.t;++a)i[a-s]=this[a];i.t=Math.max(this.t-s,0),i.s=this.s}function Qo(s,i){var a=s%this.DB,u=this.DB-a,d=(1<<u)-1,m=Math.floor(s/this.DB),w=this.s<<a&this.DM,x;for(x=this.t-1;x>=0;--x)i[x+m+1]=this[x]>>u|w,w=(this[x]&d)<<a;for(x=m-1;x>=0;--x)i[x]=0;i[m]=w,i.t=this.t+m+1,i.s=this.s,i.clamp()}function Yo(s,i){i.s=this.s;var a=Math.floor(s/this.DB);if(a>=this.t){i.t=0;return}var u=s%this.DB,d=this.DB-u,m=(1<<u)-1;i[0]=this[a]>>u;for(var w=a+1;w<this.t;++w)i[w-a-1]|=(this[w]&m)<<d,i[w-a]=this[w]>>u;u>0&&(i[this.t-a-1]|=(this.s&m)<<d),i.t=this.t-a,i.clamp()}function Ko(s,i){for(var a=0,u=0,d=Math.min(s.t,this.t);a<d;)u+=this[a]-s[a],i[a++]=u&this.DM,u>>=this.DB;if(s.t<this.t){for(u-=s.s;a<this.t;)u+=this[a],i[a++]=u&this.DM,u>>=this.DB;u+=this.s}else{for(u+=this.s;a<s.t;)u-=s[a],i[a++]=u&this.DM,u>>=this.DB;u-=s.s}i.s=u<0?-1:0,u<-1?i[a++]=this.DV+u:u>0&&(i[a++]=u),i.t=a,i.clamp()}function ti(s,i){var a=this.abs(),u=s.abs(),d=a.t;for(i.t=d+u.t;--d>=0;)i[d]=0;for(d=0;d<u.t;++d)i[d+a.t]=a.am(0,u[d],i,d,0,a.t);i.s=0,i.clamp(),this.s!=s.s&&n.ZERO.subTo(i,i)}function ei(s){for(var i=this.abs(),a=s.t=2*i.t;--a>=0;)s[a]=0;for(a=0;a<i.t-1;++a){var u=i.am(a,i[a],s,2*a,0,1);(s[a+i.t]+=i.am(a+1,2*i[a],s,2*a+1,u,i.t-a-1))>=i.DV&&(s[a+i.t]-=i.DV,s[a+i.t+1]=1)}s.t>0&&(s[s.t-1]+=i.am(a,i[a],s,2*a,0,1)),s.s=0,s.clamp()}function ri(s,i,a){var u=s.abs();if(!(u.t<=0)){var d=this.abs();if(d.t<u.t){i?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=o());var m=o(),w=this.s,x=s.s,k=this.DB-G(u[u.t-1]);k>0?(u.lShiftTo(k,m),d.lShiftTo(k,a)):(u.copyTo(m),d.copyTo(a));var j=m.t,it=m[j-1];if(it!=0){var et=it*(1<<this.F1)+(j>1?m[j-2]>>this.F2:0),vt=this.FV/et,Ee=(1<<this.F1)/et,ft=1<<this.F2,pt=a.t,Ae=pt-j,Ct=i??o();for(m.dlShiftTo(Ae,Ct),a.compareTo(Ct)>=0&&(a[a.t++]=1,a.subTo(Ct,a)),n.ONE.dlShiftTo(j,Ct),Ct.subTo(m,m);m.t<j;)m[m.t++]=0;for(;--Ae>=0;){var ir=a[--pt]==it?this.DM:Math.floor(a[pt]*vt+(a[pt-1]+ft)*Ee);if((a[pt]+=m.am(0,ir,a,Ae,0,j))<ir)for(m.dlShiftTo(Ae,Ct),a.subTo(Ct,a);a[pt]<--ir;)a.subTo(Ct,a)}i!=null&&(a.drShiftTo(j,i),w!=x&&n.ZERO.subTo(i,i)),a.t=j,a.clamp(),k>0&&a.rShiftTo(k,a),w<0&&n.ZERO.subTo(a,a)}}}function ni(s){var i=o();return this.abs().divRemTo(s,null,i),this.s<0&&i.compareTo(n.ZERO)>0&&s.subTo(i,i),i}function Pt(s){this.m=s}function si(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s}function oi(s){return s}function ii(s){s.divRemTo(this.m,null,s)}function ai(s,i,a){s.multiplyTo(i,a),this.reduce(a)}function ci(s,i){s.squareTo(i),this.reduce(i)}Pt.prototype.convert=si,Pt.prototype.revert=oi,Pt.prototype.reduce=ii,Pt.prototype.mulTo=ai,Pt.prototype.sqrTo=ci;function ui(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var i=s&3;return i=i*(2-(s&15)*i)&15,i=i*(2-(s&255)*i)&255,i=i*(2-((s&65535)*i&65535))&65535,i=i*(2-s*i%this.DV)%this.DV,i>0?this.DV-i:-i}function kt(s){this.m=s,this.mp=s.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<s.DB-15)-1,this.mt2=2*s.t}function fi(s){var i=o();return s.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),s.s<0&&i.compareTo(n.ZERO)>0&&this.m.subTo(i,i),i}function pi(s){var i=o();return s.copyTo(i),this.reduce(i),i}function li(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var i=0;i<this.m.t;++i){var a=s[i]&32767,u=a*this.mpl+((a*this.mph+(s[i]>>15)*this.mpl&this.um)<<15)&s.DM;for(a=i+this.m.t,s[a]+=this.m.am(0,u,s,i,0,this.m.t);s[a]>=s.DV;)s[a]-=s.DV,s[++a]++}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s)}function hi(s,i){s.squareTo(i),this.reduce(i)}function di(s,i,a){s.multiplyTo(i,a),this.reduce(a)}kt.prototype.convert=fi,kt.prototype.revert=pi,kt.prototype.reduce=li,kt.prototype.mulTo=di,kt.prototype.sqrTo=hi;function mi(){return(this.t>0?this[0]&1:this.s)==0}function gi(s,i){if(s>4294967295||s<1)return n.ONE;var a=o(),u=o(),d=i.convert(this),m=G(s)-1;for(d.copyTo(a);--m>=0;)if(i.sqrTo(a,u),(s&1<<m)>0)i.mulTo(u,d,a);else{var w=a;a=u,u=w}return i.revert(a)}function bi(s,i){var a;return s<256||i.isEven()?a=new Pt(i):a=new kt(i),this.exp(s,a)}n.prototype.copyTo=B,n.prototype.fromInt=C,n.prototype.fromString=M,n.prototype.clamp=R,n.prototype.dlShiftTo=Jo,n.prototype.drShiftTo=Xo,n.prototype.lShiftTo=Qo,n.prototype.rShiftTo=Yo,n.prototype.subTo=Ko,n.prototype.multiplyTo=ti,n.prototype.squareTo=ei,n.prototype.divRemTo=ri,n.prototype.invDigit=ui,n.prototype.isEven=mi,n.prototype.exp=gi,n.prototype.toString=N,n.prototype.negate=_,n.prototype.abs=D,n.prototype.compareTo=F,n.prototype.bitLength=Wo,n.prototype.mod=ni,n.prototype.modPowInt=bi,n.ZERO=I(0),n.ONE=I(1);function wi(){var s=o();return this.copyTo(s),s}function yi(){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 vi(){return this.t==0?this.s:this[0]<<24>>24}function xi(){return this.t==0?this.s:this[0]<<16>>16}function Si(s){return Math.floor(Math.LN2*this.DB/Math.log(s))}function Ti(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Ci(s){if(s==null&&(s=10),this.signum()==0||s<2||s>36)return"0";var i=this.chunkSize(s),a=Math.pow(s,i),u=I(a),d=o(),m=o(),w="";for(this.divRemTo(u,d,m);d.signum()>0;)w=(a+m.intValue()).toString(s).substr(1)+w,d.divRemTo(u,d,m);return m.intValue().toString(s)+w}function Ei(s,i){this.fromInt(0),i==null&&(i=10);for(var a=this.chunkSize(i),u=Math.pow(i,a),d=!1,m=0,w=0,x=0;x<s.length;++x){var k=T(s,x);if(k<0){s.charAt(x)=="-"&&this.signum()==0&&(d=!0);continue}w=i*w+k,++m>=a&&(this.dMultiply(u),this.dAddOffset(w,0),m=0,w=0)}m>0&&(this.dMultiply(Math.pow(i,m)),this.dAddOffset(w,0)),d&&n.ZERO.subTo(this,this)}function Ai(s,i,a){if(typeof i=="number")if(s<2)this.fromInt(1);else for(this.fromNumber(s,a),this.testBit(s-1)||this.bitwiseTo(n.ONE.shiftLeft(s-1),rr,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(n.ONE.shiftLeft(s-1),this);else{var u=new Array,d=s&7;u.length=(s>>3)+1,i.nextBytes(u),d>0?u[0]&=(1<<d)-1:u[0]=0,this.fromString(u,256)}}function Ii(){var s=this.t,i=new Array;i[0]=this.s;var a=this.DB-s*this.DB%8,u,d=0;if(s-- >0)for(a<this.DB&&(u=this[s]>>a)!=(this.s&this.DM)>>a&&(i[d++]=u|this.s<<this.DB-a);s>=0;)a<8?(u=(this[s]&(1<<a)-1)<<8-a,u|=this[--s]>>(a+=this.DB-8)):(u=this[s]>>(a-=8)&255,a<=0&&(a+=this.DB,--s)),u&128&&(u|=-256),d==0&&(this.s&128)!=(u&128)&&++d,(d>0||u!=this.s)&&(i[d++]=u);return i}function Bi(s){return this.compareTo(s)==0}function Mi(s){return this.compareTo(s)<0?this:s}function Ri(s){return this.compareTo(s)>0?this:s}function Di(s,i,a){var u,d,m=Math.min(s.t,this.t);for(u=0;u<m;++u)a[u]=i(this[u],s[u]);if(s.t<this.t){for(d=s.s&this.DM,u=m;u<this.t;++u)a[u]=i(this[u],d);a.t=this.t}else{for(d=this.s&this.DM,u=m;u<s.t;++u)a[u]=i(d,s[u]);a.t=s.t}a.s=i(this.s,s.s),a.clamp()}function Pi(s,i){return s&i}function ki(s){var i=o();return this.bitwiseTo(s,Pi,i),i}function rr(s,i){return s|i}function Oi(s){var i=o();return this.bitwiseTo(s,rr,i),i}function $n(s,i){return s^i}function Ni(s){var i=o();return this.bitwiseTo(s,$n,i),i}function zn(s,i){return s&~i}function Fi(s){var i=o();return this.bitwiseTo(s,zn,i),i}function _i(){for(var s=o(),i=0;i<this.t;++i)s[i]=this.DM&~this[i];return s.t=this.t,s.s=~this.s,s}function Ui(s){var i=o();return s<0?this.rShiftTo(-s,i):this.lShiftTo(s,i),i}function Li(s){var i=o();return s<0?this.lShiftTo(-s,i):this.rShiftTo(s,i),i}function $i(s){if(s==0)return-1;var i=0;return s&65535||(s>>=16,i+=16),s&255||(s>>=8,i+=8),s&15||(s>>=4,i+=4),s&3||(s>>=2,i+=2),s&1||++i,i}function zi(){for(var s=0;s<this.t;++s)if(this[s]!=0)return s*this.DB+$i(this[s]);return this.s<0?this.t*this.DB:-1}function Vi(s){for(var i=0;s!=0;)s&=s-1,++i;return i}function ji(){for(var s=0,i=this.s&this.DM,a=0;a<this.t;++a)s+=Vi(this[a]^i);return s}function qi(s){var i=Math.floor(s/this.DB);return i>=this.t?this.s!=0:(this[i]&1<<s%this.DB)!=0}function Gi(s,i){var a=n.ONE.shiftLeft(s);return this.bitwiseTo(a,i,a),a}function Hi(s){return this.changeBit(s,rr)}function Zi(s){return this.changeBit(s,zn)}function Wi(s){return this.changeBit(s,$n)}function Ji(s,i){for(var a=0,u=0,d=Math.min(s.t,this.t);a<d;)u+=this[a]+s[a],i[a++]=u&this.DM,u>>=this.DB;if(s.t<this.t){for(u+=s.s;a<this.t;)u+=this[a],i[a++]=u&this.DM,u>>=this.DB;u+=this.s}else{for(u+=this.s;a<s.t;)u+=s[a],i[a++]=u&this.DM,u>>=this.DB;u+=s.s}i.s=u<0?-1:0,u>0?i[a++]=u:u<-1&&(i[a++]=this.DV+u),i.t=a,i.clamp()}function Xi(s){var i=o();return this.addTo(s,i),i}function Qi(s){var i=o();return this.subTo(s,i),i}function Yi(s){var i=o();return this.multiplyTo(s,i),i}function Ki(){var s=o();return this.squareTo(s),s}function ta(s){var i=o();return this.divRemTo(s,i,null),i}function ea(s){var i=o();return this.divRemTo(s,null,i),i}function ra(s){var i=o(),a=o();return this.divRemTo(s,i,a),new Array(i,a)}function na(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp()}function sa(s,i){if(s!=0){for(;this.t<=i;)this[this.t++]=0;for(this[i]+=s;this[i]>=this.DV;)this[i]-=this.DV,++i>=this.t&&(this[this.t++]=0),++this[i]}}function de(){}function Vn(s){return s}function oa(s,i,a){s.multiplyTo(i,a)}function ia(s,i){s.squareTo(i)}de.prototype.convert=Vn,de.prototype.revert=Vn,de.prototype.mulTo=oa,de.prototype.sqrTo=ia;function aa(s){return this.exp(s,new de)}function ca(s,i,a){var u=Math.min(this.t+s.t,i);for(a.s=0,a.t=u;u>0;)a[--u]=0;var d;for(d=a.t-this.t;u<d;++u)a[u+this.t]=this.am(0,s[u],a,u,0,this.t);for(d=Math.min(s.t,i);u<d;++u)this.am(0,s[u],a,u,0,i-u);a.clamp()}function ua(s,i,a){--i;var u=a.t=this.t+s.t-i;for(a.s=0;--u>=0;)a[u]=0;for(u=Math.max(i-this.t,0);u<s.t;++u)a[this.t+u-i]=this.am(i-u,s[u],a,0,0,this.t+u-i);a.clamp(),a.drShiftTo(1,a)}function Ot(s){this.r2=o(),this.q3=o(),n.ONE.dlShiftTo(2*s.t,this.r2),this.mu=this.r2.divide(s),this.m=s}function fa(s){if(s.s<0||s.t>2*this.m.t)return s.mod(this.m);if(s.compareTo(this.m)<0)return s;var i=o();return s.copyTo(i),this.reduce(i),i}function pa(s){return s}function la(s){for(s.drShiftTo(this.m.t-1,this.r2),s.t>this.m.t+1&&(s.t=this.m.t+1,s.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);s.compareTo(this.r2)<0;)s.dAddOffset(1,this.m.t+1);for(s.subTo(this.r2,s);s.compareTo(this.m)>=0;)s.subTo(this.m,s)}function ha(s,i){s.squareTo(i),this.reduce(i)}function da(s,i,a){s.multiplyTo(i,a),this.reduce(a)}Ot.prototype.convert=fa,Ot.prototype.revert=pa,Ot.prototype.reduce=la,Ot.prototype.mulTo=da,Ot.prototype.sqrTo=ha;function ma(s,i){var a=s.bitLength(),u,d=I(1),m;if(a<=0)return d;a<18?u=1:a<48?u=3:a<144?u=4:a<768?u=5:u=6,a<8?m=new Pt(i):i.isEven()?m=new Ot(i):m=new kt(i);var w=new Array,x=3,k=u-1,j=(1<<u)-1;if(w[1]=m.convert(this),u>1){var it=o();for(m.sqrTo(w[1],it);x<=j;)w[x]=o(),m.mulTo(it,w[x-2],w[x]),x+=2}var et=s.t-1,vt,Ee=!0,ft=o(),pt;for(a=G(s[et])-1;et>=0;){for(a>=k?vt=s[et]>>a-k&j:(vt=(s[et]&(1<<a+1)-1)<<k-a,et>0&&(vt|=s[et-1]>>this.DB+a-k)),x=u;!(vt&1);)vt>>=1,--x;if((a-=x)<0&&(a+=this.DB,--et),Ee)w[vt].copyTo(d),Ee=!1;else{for(;x>1;)m.sqrTo(d,ft),m.sqrTo(ft,d),x-=2;x>0?m.sqrTo(d,ft):(pt=d,d=ft,ft=pt),m.mulTo(ft,w[vt],d)}for(;et>=0&&!(s[et]&1<<a);)m.sqrTo(d,ft),pt=d,d=ft,ft=pt,--a<0&&(a=this.DB-1,--et)}return m.revert(d)}function ga(s){var i=this.s<0?this.negate():this.clone(),a=s.s<0?s.negate():s.clone();if(i.compareTo(a)<0){var u=i;i=a,a=u}var d=i.getLowestSetBit(),m=a.getLowestSetBit();if(m<0)return i;for(d<m&&(m=d),m>0&&(i.rShiftTo(m,i),a.rShiftTo(m,a));i.signum()>0;)(d=i.getLowestSetBit())>0&&i.rShiftTo(d,i),(d=a.getLowestSetBit())>0&&a.rShiftTo(d,a),i.compareTo(a)>=0?(i.subTo(a,i),i.rShiftTo(1,i)):(a.subTo(i,a),a.rShiftTo(1,a));return m>0&&a.lShiftTo(m,a),a}function ba(s){if(s<=0)return 0;var i=this.DV%s,a=this.s<0?s-1:0;if(this.t>0)if(i==0)a=this[0]%s;else for(var u=this.t-1;u>=0;--u)a=(i*a+this[u])%s;return a}function wa(s){var i=s.isEven();if(this.isEven()&&i||s.signum()==0)return n.ZERO;for(var a=s.clone(),u=this.clone(),d=I(1),m=I(0),w=I(0),x=I(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),i?((!d.isEven()||!m.isEven())&&(d.addTo(this,d),m.subTo(s,m)),d.rShiftTo(1,d)):m.isEven()||m.subTo(s,m),m.rShiftTo(1,m);for(;u.isEven();)u.rShiftTo(1,u),i?((!w.isEven()||!x.isEven())&&(w.addTo(this,w),x.subTo(s,x)),w.rShiftTo(1,w)):x.isEven()||x.subTo(s,x),x.rShiftTo(1,x);a.compareTo(u)>=0?(a.subTo(u,a),i&&d.subTo(w,d),m.subTo(x,m)):(u.subTo(a,u),i&&w.subTo(d,w),x.subTo(m,x))}if(u.compareTo(n.ONE)!=0)return n.ZERO;if(x.compareTo(s)>=0)return x.subtract(s);if(x.signum()<0)x.addTo(s,x);else return x;return x.signum()<0?x.add(s):x}var Y=[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],ya=(1<<26)/Y[Y.length-1];function va(s){var i,a=this.abs();if(a.t==1&&a[0]<=Y[Y.length-1]){for(i=0;i<Y.length;++i)if(a[0]==Y[i])return!0;return!1}if(a.isEven())return!1;for(i=1;i<Y.length;){for(var u=Y[i],d=i+1;d<Y.length&&u<ya;)u*=Y[d++];for(u=a.modInt(u);i<d;)if(u%Y[i++]==0)return!1}return a.millerRabin(s)}function xa(s){var i=this.subtract(n.ONE),a=i.getLowestSetBit();if(a<=0)return!1;var u=i.shiftRight(a);s=s+1>>1,s>Y.length&&(s=Y.length);for(var d=o(),m=0;m<s;++m){d.fromInt(Y[Math.floor(Math.random()*Y.length)]);var w=d.modPow(u,this);if(w.compareTo(n.ONE)!=0&&w.compareTo(i)!=0){for(var x=1;x++<a&&w.compareTo(i)!=0;)if(w=w.modPowInt(2,this),w.compareTo(n.ONE)==0)return!1;if(w.compareTo(i)!=0)return!1}}return!0}n.prototype.chunkSize=Si,n.prototype.toRadix=Ci,n.prototype.fromRadix=Ei,n.prototype.fromNumber=Ai,n.prototype.bitwiseTo=Di,n.prototype.changeBit=Gi,n.prototype.addTo=Ji,n.prototype.dMultiply=na,n.prototype.dAddOffset=sa,n.prototype.multiplyLowerTo=ca,n.prototype.multiplyUpperTo=ua,n.prototype.modInt=ba,n.prototype.millerRabin=xa,n.prototype.clone=wi,n.prototype.intValue=yi,n.prototype.byteValue=vi,n.prototype.shortValue=xi,n.prototype.signum=Ti,n.prototype.toByteArray=Ii,n.prototype.equals=Bi,n.prototype.min=Mi,n.prototype.max=Ri,n.prototype.and=ki,n.prototype.or=Oi,n.prototype.xor=Ni,n.prototype.andNot=Fi,n.prototype.not=_i,n.prototype.shiftLeft=Ui,n.prototype.shiftRight=Li,n.prototype.getLowestSetBit=zi,n.prototype.bitCount=ji,n.prototype.testBit=qi,n.prototype.setBit=Hi,n.prototype.clearBit=Zi,n.prototype.flipBit=Wi,n.prototype.add=Xi,n.prototype.subtract=Qi,n.prototype.multiply=Yi,n.prototype.divide=ta,n.prototype.remainder=ea,n.prototype.divideAndRemainder=ra,n.prototype.modPow=ma,n.prototype.modInverse=wa,n.prototype.pow=aa,n.prototype.gcd=ga,n.prototype.isProbablePrime=va,n.prototype.square=Ki,n.prototype.Barrett=Ot;var Ce,tt,V;function Sa(s){tt[V++]^=s&255,tt[V++]^=s>>8&255,tt[V++]^=s>>16&255,tt[V++]^=s>>24&255,V>=or&&(V-=or)}function jn(){Sa(new Date().getTime())}if(tt==null){tt=new Array,V=0;var ut;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var qn=new Uint8Array(32);for(window.crypto.getRandomValues(qn),ut=0;ut<32;++ut)tt[V++]=qn[ut]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var Gn=window.crypto.random(32);for(ut=0;ut<Gn.length;++ut)tt[V++]=Gn.charCodeAt(ut)&255}}for(;V<or;)ut=Math.floor(65536*Math.random()),tt[V++]=ut>>>8,tt[V++]=ut&255;V=0,jn()}function Ta(){if(Ce==null){for(jn(),Ce=Ia(),Ce.init(tt),V=0;V<tt.length;++V)tt[V]=0;V=0}return Ce.next()}function Ca(s){var i;for(i=0;i<s.length;++i)s[i]=Ta()}function nr(){}nr.prototype.nextBytes=Ca;function sr(){this.i=0,this.j=0,this.S=new Array}function Ea(s){var i,a,u;for(i=0;i<256;++i)this.S[i]=i;for(a=0,i=0;i<256;++i)a=a+this.S[i]+s[i%s.length]&255,u=this.S[i],this.S[i]=this.S[a],this.S[a]=u;this.i=0,this.j=0}function Aa(){var s;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,s=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=s,this.S[s+this.S[this.i]&255]}sr.prototype.init=Ea,sr.prototype.next=Aa;function Ia(){return new sr}var or=256;typeof We<"u"?We=Eo.exports={default:n,BigInteger:n,SecureRandom:nr}:this.jsbn={BigInteger:n,SecureRandom:nr}}).call(We)});var Se=z(Je=>{(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(f){return n(c(f),arguments)}function e(f,l){return t.apply(null,[f].concat(l||[]))}function n(f,l){var g=1,A=f.length,p,b="",y,S,h,T,B,C,I,M;for(y=0;y<A;y++)if(typeof f[y]=="string")b+=f[y];else if(typeof f[y]=="object"){if(h=f[y],h.keys)for(p=l[g],S=0;S<h.keys.length;S++){if(p==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',h.keys[S],h.keys[S-1]));p=p[h.keys[S]]}else h.param_no?p=l[h.param_no]:p=l[g++];if(r.not_type.test(h.type)&&r.not_primitive.test(h.type)&&p instanceof Function&&(p=p()),r.numeric_arg.test(h.type)&&typeof p!="number"&&isNaN(p))throw new TypeError(t("[sprintf] expecting number but found %T",p));switch(r.number.test(h.type)&&(I=p>=0),h.type){case"b":p=parseInt(p,10).toString(2);break;case"c":p=String.fromCharCode(parseInt(p,10));break;case"d":case"i":p=parseInt(p,10);break;case"j":p=JSON.stringify(p,null,h.width?parseInt(h.width):0);break;case"e":p=h.precision?parseFloat(p).toExponential(h.precision):parseFloat(p).toExponential();break;case"f":p=h.precision?parseFloat(p).toFixed(h.precision):parseFloat(p);break;case"g":p=h.precision?String(Number(p.toPrecision(h.precision))):parseFloat(p);break;case"o":p=(parseInt(p,10)>>>0).toString(8);break;case"s":p=String(p),p=h.precision?p.substring(0,h.precision):p;break;case"t":p=String(!!p),p=h.precision?p.substring(0,h.precision):p;break;case"T":p=Object.prototype.toString.call(p).slice(8,-1).toLowerCase(),p=h.precision?p.substring(0,h.precision):p;break;case"u":p=parseInt(p,10)>>>0;break;case"v":p=p.valueOf(),p=h.precision?p.substring(0,h.precision):p;break;case"x":p=(parseInt(p,10)>>>0).toString(16);break;case"X":p=(parseInt(p,10)>>>0).toString(16).toUpperCase();break}r.json.test(h.type)?b+=p:(r.number.test(h.type)&&(!I||h.sign)?(M=I?"+":"-",p=p.toString().replace(r.sign,"")):M="",B=h.pad_char?h.pad_char==="0"?"0":h.pad_char.charAt(1):" ",C=h.width-(M+p).length,T=h.width&&C>0?B.repeat(C):"",b+=h.align?M+p+T:B==="0"?M+T+p:T+M+p)}return b}var o=Object.create(null);function c(f){if(o[f])return o[f];for(var l=f,g,A=[],p=0;l;){if((g=r.text.exec(l))!==null)A.push(g[0]);else if((g=r.modulo.exec(l))!==null)A.push("%");else if((g=r.placeholder.exec(l))!==null){if(g[2]){p|=1;var b=[],y=g[2],S=[];if((S=r.key.exec(y))!==null)for(b.push(S[1]);(y=y.substring(S[0].length))!=="";)if((S=r.key_access.exec(y))!==null)b.push(S[1]);else if((S=r.index_access.exec(y))!==null)b.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");g[2]=b}else p|=2;if(p===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");A.push({placeholder:g[0],param_no:g[1],keys:g[2],sign:g[3],pad_char:g[4],align:g[5],width:g[6],precision:g[7],type:g[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");l=l.substring(g[0].length)}return o[f]=A}typeof Je<"u"&&(Je.sprintf=t,Je.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var Ke=z((hm,Fo)=>{Fo.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 Uo=z((dm,_o)=>{_o.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 kn=z((mm,Lo)=>{var lp=Uo();Lo.exports=r=>async t=>{t=lp(t);let e=C=>{typeof C.return=="function"&&C.return()},n=null,o=null,c=C=>{n=C,o&&o(C),e(t)},f=null,l=!1,g=()=>{l=!0,f&&f()},A=null,p=!1,b=()=>{p=!0,A&&A()},y=null,S=()=>{y&&y()},h=()=>new Promise((C,I)=>{f=y=C,o=I,r.once("drain",S)}),T=()=>(e(t),new Promise((C,I)=>{if(l||p||n)return C();A=f=C,o=I})),B=()=>{r.removeListener("error",c),r.removeListener("close",g),r.removeListener("finish",b),r.removeListener("drain",S)};r.once("error",c),r.once("close",g),r.once("finish",b);try{for await(let C of t){if(!r.writable||r.destroyed||n)break;r.write(C)===!1&&await h()}}catch(C){n||r.destroy(),n=C}try{if(r.writable&&r.end(),await T(),n)throw n}finally{B()}}});var On=z((gm,$o)=>{var hp=kn(),dp=Ke();$o.exports=r=>({sink:hp(r),source:dp(r)})});var Vo=z((bm,zo)=>{var mp=On();zo.exports=r=>async function*(t){let e=mp(r),n;if(e.sink(t).catch(o=>{n=o}),yield*e.source,n)throw n}});var jo=z((wm,le)=>{le.exports=Ke();le.exports.source=Ke();le.exports.sink=kn();le.exports.transform=Vo();le.exports.duplex=On()});var Ip={};O(Ip,{tcp:()=>Ap});var Zo=H(mt("net"),1);var qt=class r extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},lt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Wn=Symbol.for("@libp2p/transport");var Zn;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Zn||(Zn={}));var nt=H(os(),1);var dr={};O(dr,{base32:()=>dt,base32hex:()=>pc,base32hexpad:()=>hc,base32hexpadupper:()=>dc,base32hexupper:()=>lc,base32pad:()=>uc,base32padupper:()=>fc,base32upper:()=>cc,base32z:()=>mc});function nc(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 o=0;o<r.length;o++){var c=r.charAt(o),f=c.charCodeAt(0);if(e[f]!==255)throw new TypeError(c+" is ambiguous");e[f]=o}var l=r.length,g=r.charAt(0),A=Math.log(l)/Math.log(256),p=Math.log(256)/Math.log(l);function b(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var T=0,B=0,C=0,I=h.length;C!==I&&h[C]===0;)C++,T++;for(var M=(I-C)*p+1>>>0,R=new Uint8Array(M);C!==I;){for(var N=h[C],_=0,D=M-1;(N!==0||_<B)&&D!==-1;D--,_++)N+=256*R[D]>>>0,R[D]=N%l>>>0,N=N/l>>>0;if(N!==0)throw new Error("Non-zero carry");B=_,C++}for(var F=M-B;F!==M&&R[F]===0;)F++;for(var G=g.repeat(T);F<M;++F)G+=r.charAt(R[F]);return G}function y(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var T=0;if(h[T]!==" "){for(var B=0,C=0;h[T]===g;)B++,T++;for(var I=(h.length-T)*A+1>>>0,M=new Uint8Array(I);h[T];){var R=e[h.charCodeAt(T)];if(R===255)return;for(var N=0,_=I-1;(R!==0||N<C)&&_!==-1;_--,N++)R+=l*M[_]>>>0,M[_]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");C=N,T++}if(h[T]!==" "){for(var D=I-C;D!==I&&M[D]===0;)D++;for(var F=new Uint8Array(B+(I-D)),G=B;D!==I;)F[G++]=M[D++];return F}}}function S(h){var T=y(h);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:y,decode:S}}var sc=nc,oc=sc,is=oc;var _p=new Uint8Array(0);var as=(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},at=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 cs=r=>new TextEncoder().encode(r),us=r=>new TextDecoder().decode(r);var fr=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")}},pr=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 ps(this,t)}},lr=class{constructor(t){this.decoders=t}or(t){return ps(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`)}},ps=(r,t)=>new lr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),hr=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new fr(t,e,n),this.decoder=new pr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Jt=({name:r,prefix:t,encode:e,decode:n})=>new hr(r,t,e,n),Et=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=is(e,t);return Jt({prefix:r,name:t,encode:n,decode:c=>at(o(c))})},ic=(r,t,e,n)=>{let o={};for(let p=0;p<t.length;++p)o[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let f=new Uint8Array(c*e/8|0),l=0,g=0,A=0;for(let p=0;p<c;++p){let b=o[r[p]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);g=g<<e|b,l+=e,l>=8&&(l-=8,f[A++]=255&g>>l)}if(l>=e||255&g<<8-l)throw new SyntaxError("Unexpected end of data");return f},ac=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,c="",f=0,l=0;for(let g=0;g<r.length;++g)for(l=l<<8|r[g],f+=8;f>e;)f-=e,c+=t[o&l>>f];if(f&&(c+=t[o&l<<e-f]),n)for(;c.length*e&7;)c+="=";return c},U=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Jt({prefix:t,name:r,encode(o){return ac(o,n,e)},decode(o){return ic(o,n,e,r)}});var dt=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),cc=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),uc=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fc=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pc=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lc=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hc=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dc=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),mc=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mr={};O(mr,{base58btc:()=>W,base58flickr:()=>gc});var W=Et({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gc=Et({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var br={};O(br,{base64:()=>gr,base64pad:()=>bc,base64url:()=>wc,base64urlpad:()=>yc});var gr=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bc=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wc=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yc=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});nt.default.formatters.b=r=>r==null?"undefined":W.baseEncode(r);nt.default.formatters.t=r=>r==null?"undefined":dt.baseEncode(r);nt.default.formatters.m=r=>r==null?"undefined":gr.baseEncode(r);nt.default.formatters.p=r=>r==null?"undefined":r.toString();nt.default.formatters.c=r=>r==null?"undefined":r.toString();nt.default.formatters.k=r=>r==null?"undefined":r.toString();nt.default.formatters.a=r=>r==null?"undefined":r.toString();function vc(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function At(r){let t=vc(`${r}:trace`);return nt.default.enabled(`${r}:trace`)&&nt.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,nt.default)(`${r}:trace`)),Object.assign((0,nt.default)(r),{error:(0,nt.default)(`${r}:error`),trace:t})}var Pe=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var xc=ds,ls=128,Sc=127,Tc=~Sc,Cc=Math.pow(2,31);function ds(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Cc;)t[e++]=r&255|ls,r/=128;for(;r&Tc;)t[e++]=r&255|ls,r>>>=7;return t[e]=r|0,ds.bytes=e-n+1,t}var Ec=wr,Ac=128,hs=127;function wr(r,n){var e=0,n=n||0,o=0,c=n,f,l=r.length;do{if(c>=l)throw wr.bytes=0,new RangeError("Could not decode varint");f=r[c++],e+=o<28?(f&hs)<<o:(f&hs)*Math.pow(2,o),o+=7}while(f>=Ac);return wr.bytes=c-n,e}var Ic=Math.pow(2,7),Bc=Math.pow(2,14),Mc=Math.pow(2,21),Rc=Math.pow(2,28),Dc=Math.pow(2,35),Pc=Math.pow(2,42),kc=Math.pow(2,49),Oc=Math.pow(2,56),Nc=Math.pow(2,63),Fc=function(r){return r<Ic?1:r<Bc?2:r<Mc?3:r<Rc?4:r<Dc?5:r<Pc?6:r<kc?7:r<Oc?8:r<Nc?9:10},_c={encode:xc,decode:Ec,encodingLength:Fc},Uc=_c,me=Uc;var ge=(r,t=0)=>[me.decode(r,t),me.decode.bytes],Xt=(r,t,e=0)=>(me.encode(r,t,e),t),Qt=r=>me.encodingLength(r);var Ft=(r,t)=>{let e=t.byteLength,n=Qt(r),o=n+Qt(e),c=new Uint8Array(o+e);return Xt(r,c,0),Xt(e,c,n),c.set(t,o),new Yt(r,e,t,c)},Oe=r=>{let t=at(r),[e,n]=ge(t),[o,c]=ge(t.subarray(n)),f=t.subarray(n+c);if(f.byteLength!==o)throw new Error("Incorrect length");return new Yt(e,o,f,t)},ms=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&as(r.bytes,e.bytes)}},Yt=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var gs=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return $c(e,yr(r),t||W.encoder);default:return zc(e,yr(r),t||dt.encoder)}};var bs=new WeakMap,yr=r=>{let t=bs.get(r);if(t==null){let e=new Map;return bs.set(r,e),e}return t},It=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==be)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Vc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Ft(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&ms(t.multihash,n.multihash)}toString(t){return gs(this,t)}toJSON(){return{"/":gs(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:c,bytes:f}=e;return new r(n,o,c,f||ws(n,o,c.bytes))}else if(e[jc]===!0){let{version:n,multihash:o,code:c}=e,f=Oe(o);return r.create(n,c,f)}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!==be)throw new Error(`Version 0 CID must use dag-pb (code: ${be}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ws(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,be,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=at(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let c=o.subarray(e.multihashSize-e.digestSize),f=new Yt(e.multihashCode,e.digestSize,c,o);return[e.version===0?r.createV0(f):r.createV1(e.codec,f),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,y]=ge(t.subarray(e));return e+=y,b},o=n(),c=be;if(o===18?(o=0,e=0):c=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let f=e,l=n(),g=n(),A=e+g,p=A-f;return{version:o,codec:c,multihashCode:l,digestSize:g,multihashSize:p,size:A}}static parse(t,e){let[n,o]=Lc(t,e),c=r.decode(o);if(c.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return yr(c).set(n,t),c}},Lc=(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)]}}},$c=(r,t,e)=>{let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let c=e.encode(r).slice(1);return t.set(n,c),c}else return o},zc=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let c=e.encode(r);return t.set(n,c),c}else return o},be=112,Vc=18,ws=(r,t,e)=>{let n=Qt(r),o=n+Qt(t),c=new Uint8Array(o+e.byteLength);return Xt(r,c,0),Xt(t,c,n),c.set(e,o),c},jc=Symbol.for("@ipld/js-cid/CID");function ys(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 Cr={};O(Cr,{identity:()=>Jc});function qc(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 o=0;o<r.length;o++){var c=r.charAt(o),f=c.charCodeAt(0);if(e[f]!==255)throw new TypeError(c+" is ambiguous");e[f]=o}var l=r.length,g=r.charAt(0),A=Math.log(l)/Math.log(256),p=Math.log(256)/Math.log(l);function b(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var T=0,B=0,C=0,I=h.length;C!==I&&h[C]===0;)C++,T++;for(var M=(I-C)*p+1>>>0,R=new Uint8Array(M);C!==I;){for(var N=h[C],_=0,D=M-1;(N!==0||_<B)&&D!==-1;D--,_++)N+=256*R[D]>>>0,R[D]=N%l>>>0,N=N/l>>>0;if(N!==0)throw new Error("Non-zero carry");B=_,C++}for(var F=M-B;F!==M&&R[F]===0;)F++;for(var G=g.repeat(T);F<M;++F)G+=r.charAt(R[F]);return G}function y(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var T=0;if(h[T]!==" "){for(var B=0,C=0;h[T]===g;)B++,T++;for(var I=(h.length-T)*A+1>>>0,M=new Uint8Array(I);h[T];){var R=e[h.charCodeAt(T)];if(R===255)return;for(var N=0,_=I-1;(R!==0||N<C)&&_!==-1;_--,N++)R+=l*M[_]>>>0,M[_]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");C=N,T++}if(h[T]!==" "){for(var D=I-C;D!==I&&M[D]===0;)D++;for(var F=new Uint8Array(B+(I-D)),G=B;D!==I;)F[G++]=M[D++];return F}}}function S(h){var T=y(h);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:y,decode:S}}var Gc=qc,Hc=Gc,vs=Hc;var ol=new Uint8Array(0);var xs=(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},ct=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),Ts=r=>new TextDecoder().decode(r);var vr=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")}},xr=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 Es(this,t)}},Sr=class{constructor(t){this.decoders=t}or(t){return Es(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`)}},Es=(r,t)=>new Sr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Tr=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new vr(t,e,n),this.decoder=new xr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},te=({name:r,prefix:t,encode:e,decode:n})=>new Tr(r,t,e,n),Bt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=vs(e,t);return te({prefix:r,name:t,encode:n,decode:c=>ct(o(c))})},Zc=(r,t,e,n)=>{let o={};for(let p=0;p<t.length;++p)o[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let f=new Uint8Array(c*e/8|0),l=0,g=0,A=0;for(let p=0;p<c;++p){let b=o[r[p]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);g=g<<e|b,l+=e,l>=8&&(l-=8,f[A++]=255&g>>l)}if(l>=e||255&g<<8-l)throw new SyntaxError("Unexpected end of data");return f},Wc=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,c="",f=0,l=0;for(let g=0;g<r.length;++g)for(l=l<<8|r[g],f+=8;f>e;)f-=e,c+=t[o&l>>f];if(f&&(c+=t[o&l<<e-f]),n)for(;c.length*e&7;)c+="=";return c},L=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>te({prefix:t,name:r,encode(o){return Wc(o,n,e)},decode(o){return Zc(o,n,e,r)}});var Jc=te({prefix:"\0",name:"identity",encode:r=>Ts(r),decode:r=>Ss(r)});var Er={};O(Er,{base2:()=>Xc});var Xc=L({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ar={};O(Ar,{base8:()=>Qc});var Qc=L({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ir={};O(Ir,{base10:()=>Yc});var Yc=Bt({prefix:"9",name:"base10",alphabet:"0123456789"});var Br={};O(Br,{base16:()=>Kc,base16upper:()=>tu});var Kc=L({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tu=L({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mr={};O(Mr,{base32:()=>ee,base32hex:()=>su,base32hexpad:()=>iu,base32hexpadupper:()=>au,base32hexupper:()=>ou,base32pad:()=>ru,base32padupper:()=>nu,base32upper:()=>eu,base32z:()=>cu});var ee=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),eu=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ru=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nu=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),su=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ou=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),iu=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),au=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cu=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rr={};O(Rr,{base36:()=>uu,base36upper:()=>fu});var uu=Bt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fu=Bt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Dr={};O(Dr,{base58btc:()=>gt,base58flickr:()=>pu});var gt=Bt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pu=Bt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pr={};O(Pr,{base64:()=>lu,base64pad:()=>hu,base64url:()=>du,base64urlpad:()=>mu});var lu=L({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hu=L({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),du=L({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mu=L({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kr={};O(kr,{base256emoji:()=>vu});var As=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}"),gu=As.reduce((r,t,e)=>(r[e]=t,r),[]),bu=As.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function wu(r){return r.reduce((t,e)=>(t+=gu[e],t),"")}function yu(r){let t=[];for(let e of r){let n=bu[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var vu=te({prefix:"\u{1F680}",name:"base256emoji",encode:wu,decode:yu});var Ur={};O(Ur,{sha256:()=>Lu,sha512:()=>$u});var _r=H(mt("crypto"),1);var xu=Ms,Is=128,Su=127,Tu=~Su,Cu=Math.pow(2,31);function Ms(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Cu;)t[e++]=r&255|Is,r/=128;for(;r&Tu;)t[e++]=r&255|Is,r>>>=7;return t[e]=r|0,Ms.bytes=e-n+1,t}var Eu=Or,Au=128,Bs=127;function Or(r,n){var e=0,n=n||0,o=0,c=n,f,l=r.length;do{if(c>=l)throw Or.bytes=0,new RangeError("Could not decode varint");f=r[c++],e+=o<28?(f&Bs)<<o:(f&Bs)*Math.pow(2,o),o+=7}while(f>=Au);return Or.bytes=c-n,e}var Iu=Math.pow(2,7),Bu=Math.pow(2,14),Mu=Math.pow(2,21),Ru=Math.pow(2,28),Du=Math.pow(2,35),Pu=Math.pow(2,42),ku=Math.pow(2,49),Ou=Math.pow(2,56),Nu=Math.pow(2,63),Fu=function(r){return r<Iu?1:r<Bu?2:r<Mu?3:r<Ru?4:r<Du?5:r<Pu?6:r<ku?7:r<Ou?8:r<Nu?9:10},_u={encode:xu,decode:Eu,encodingLength:Fu},Uu=_u,we=Uu;var ye=(r,t=0)=>[we.decode(r,t),we.decode.bytes],re=(r,t,e=0)=>(we.encode(r,t,e),t),ne=r=>we.encodingLength(r);var _t=(r,t)=>{let e=t.byteLength,n=ne(r),o=n+ne(e),c=new Uint8Array(o+e);return re(r,c,0),re(e,c,n),c.set(t,o),new se(r,e,t,c)},Rs=r=>{let t=ct(r),[e,n]=ye(t),[o,c]=ye(t.subarray(n)),f=t.subarray(n+c);if(f.byteLength!==o)throw new Error("Incorrect length");return new se(e,o,f,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&&xs(r.bytes,e.bytes)}},se=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Fr=({name:r,code:t,encode:e})=>new Nr(r,t,e),Nr=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?_t(this.code,e):e.then(n=>_t(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Lu=Fr({name:"sha2-256",code:18,encode:r=>ct(_r.default.createHash("sha256").update(r).digest())}),$u=Fr({name:"sha2-512",code:19,encode:r=>ct(_r.default.createHash("sha512").update(r).digest())});var Lr={};O(Lr,{identity:()=>ju});var ks=0,zu="identity",Os=ct,Vu=r=>_t(ks,Os(r)),ju={code:ks,name:zu,encode:Os,digest:Vu};var Il=new TextEncoder,Bl=new TextDecoder;var Ns=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Zu(e,$r(r),t||gt.encoder);default:return Wu(e,$r(r),t||ee.encoder)}};var Fs=new WeakMap,$r=r=>{let t=Fs.get(r);if(t==null){let e=new Map;return Fs.set(r,e),e}return t},Fe=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ju)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=_t(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Ds(t.multihash,n.multihash)}toString(t){return Ns(this,t)}toJSON(){return{"/":Ns(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:c,bytes:f}=e;return new r(n,o,c,f||_s(n,o,c.bytes))}else if(e[Xu]===!0){let{version:n,multihash:o,code:c}=e,f=Rs(o);return r.create(n,c,f)}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!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=_s(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,xe,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let c=o.subarray(e.multihashSize-e.digestSize),f=new se(e.multihashCode,e.digestSize,c,o);return[e.version===0?r.createV0(f):r.createV1(e.codec,f),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,y]=ye(t.subarray(e));return e+=y,b},o=n(),c=xe;if(o===18?(o=0,e=0):c=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let f=e,l=n(),g=n(),A=e+g,p=A-f;return{version:o,codec:c,multihashCode:l,digestSize:g,multihashSize:p,size:A}}static parse(t,e){let[n,o]=Hu(t,e),c=r.decode(o);if(c.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return $r(c).set(n,t),c}},Hu=(r,t)=>{switch(r[0]){case"Q":{let e=t||gt;return[gt.prefix,e.decode(`${gt.prefix}${r}`)]}case gt.prefix:{let e=t||gt;return[gt.prefix,e.decode(r)]}case ee.prefix:{let e=t||ee;return[ee.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)]}}},Zu=(r,t,e)=>{let{prefix:n}=e;if(n!==gt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let c=e.encode(r).slice(1);return t.set(n,c),c}else return o},Wu=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let c=e.encode(r);return t.set(n,c),c}else return o},xe=112,Ju=18,_s=(r,t,e)=>{let n=ne(r),o=n+ne(t),c=new Uint8Array(o+e.byteLength);return re(r,c,0),re(t,c,n),c.set(e,o),c},Xu=Symbol.for("@ipld/js-cid/CID");var zr={...Cr,...Er,...Ar,...Ir,...Br,...Mr,...Rr,...Dr,...Pr,...kr},Ul={...Ur,...Lr};function oe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function _e(r=0){return globalThis.Buffer?.allocUnsafe!=null?oe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Ls(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Us=Ls("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Vr=Ls("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=_e(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Qu={utf8:Us,"utf-8":Us,hex:zr.base16,latin1:Vr,ascii:Vr,binary:Vr,...zr},Ue=Qu;function K(r,t="utf8"){let e=Ue[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)}function xt(r,t){t==null&&(t=r.reduce((o,c)=>o+c.length,0));let e=_e(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return oe(e)}var ae=H(Gr(),1);var Le=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let c=0,f=0,l=this.peekChar();if(l===void 0)return;let g=l==="0",A=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let b=this.readChar();if(b===void 0)return;let y=Number.parseInt(b,t);if(!Number.isNaN(y))return y});if(p===void 0)break;if(c*=t,c+=p,c>A||(f+=1,e!==void 0&&f>e))return}if(f!==0)return!n&&g&&f>1?void 0:c})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let f=this.readSeparator(":",n,()=>this.readIPv4Addr());if(f!==void 0)return e[o]=f[0],e[o+1]=f[1],e[o+2]=f[2],e[o+3]=f[3],[o+4,!0]}let c=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(c===void 0)return[o,!1];e[o]=c>>8,e[o+1]=c&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let c=new Uint8Array(14),f=16-(n+2),[l]=t(c.subarray(0,f));return e.set(c.subarray(0,l),16-l),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var nh=new Le;var ph=parseInt("0xFFFF",16),lh=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Hr={};O(Hr,{identity:()=>bf});var bf=Jt({prefix:"\0",name:"identity",encode:r=>us(r),decode:r=>cs(r)});var Zr={};O(Zr,{base2:()=>wf});var wf=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Wr={};O(Wr,{base8:()=>yf});var yf=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Jr={};O(Jr,{base10:()=>vf});var vf=Et({prefix:"9",name:"base10",alphabet:"0123456789"});var Xr={};O(Xr,{base16:()=>xf,base16upper:()=>Sf});var xf=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sf=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Qr={};O(Qr,{base36:()=>Tf,base36upper:()=>Cf});var Tf=Et({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Cf=Et({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Yr={};O(Yr,{base256emoji:()=>Mf});var Qs=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}"),Ef=Qs.reduce((r,t,e)=>(r[e]=t,r),[]),Af=Qs.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function If(r){return r.reduce((t,e)=>(t+=Ef[e],t),"")}function Bf(r){let t=[];for(let e of r){let n=Af[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Mf=Jt({prefix:"\u{1F680}",name:"base256emoji",encode:If,decode:Bf});var rn={};O(rn,{sha256:()=>Rf,sha512:()=>Df});var en=H(mt("crypto"),1);var tn=({name:r,code:t,encode:e})=>new Kr(r,t,e),Kr=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?Ft(this.code,e):e.then(n=>Ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Rf=tn({name:"sha2-256",code:18,encode:r=>at(en.default.createHash("sha256").update(r).digest())}),Df=tn({name:"sha2-512",code:19,encode:r=>at(en.default.createHash("sha512").update(r).digest())});var nn={};O(nn,{identity:()=>Of});var Ks=0,Pf="identity",to=at,kf=r=>Ft(Ks,to(r)),Of={code:Ks,name:Pf,encode:to,digest:kf};var Wh=new TextEncoder,Jh=new TextDecoder;var eo={...Hr,...Zr,...Wr,...Jr,...Xr,...dr,...Qr,...mr,...br,...Yr},td={...rn,...nn};function sn(r,t="utf8"){let e=Ue[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?oe(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var bt=H(Gr(),1);var Mt=mt("node:net");function $e(r){return!!(0,Mt.isIP)(r)}var ro=Mt.isIPv4,_f=Mt.isIPv6,on=function(r){let t=0;if(r=r.toString().trim(),ro(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(_f(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let c=ro(e[n]),f;c&&(f=on(e[n]),e[n]=K(f.slice(0,2),"base16")),f!=null&&++n<8&&e.splice(n,0,K(f.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 c=[n,1];for(n=9-e.length;n>0;n--)c.push("0");e.splice.apply(e,c)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let c=parseInt(e[n],16);o[t++]=c>>8&255,o[t++]=c&255}return o}throw new Error("invalid ip address")},no=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let c=0;c<e;c++)o.push(r[t+c]);return o.join(".")}if(e===16){let o=[];for(let c=0;c<e;c+=2)o.push(n.getUint16(t+c).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ie={},an={},Lf=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Lf.forEach(r=>{let t=$f(...r);an[t.code]=t,ie[t.name]=t});function $f(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function P(r){if(typeof r=="number"){if(an[r]!=null)return an[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ie[r]!=null)return ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var yd=P("ip4"),vd=P("ip6"),xd=P("ipcidr");function un(r,t){switch(P(r).code){case 4:case 41:return Vf(t);case 42:return io(t);case 6:case 273:case 33:case 132:return co(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return io(t);case 421:return Hf(t);case 444:return ao(t);case 445:return ao(t);case 466:return Gf(t);default:return K(t,"base16")}}function fn(r,t){switch(P(r).code){case 4:return so(t);case 41:return so(t);case 42:return oo(t);case 6:case 273:case 33:case 132:return pn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return oo(t);case 421:return jf(t);case 444:return Zf(t);case 445:return Wf(t);case 466:return qf(t);default:return sn(t,"base16")}}var cn=Object.values(eo).map(r=>r.decoder),zf=function(){let r=cn[0].or(cn[1]);return cn.slice(2).forEach(t=>r=r.or(t)),r}();function so(r){if(!$e(r))throw new Error("invalid ip address");return on(r)}function Vf(r){let t=no(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!$e(t))throw new Error("invalid ip address");return t}function pn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function co(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function oo(r){let t=sn(r),e=Uint8Array.from(bt.default.encode(t.length));return xt([e,t],e.length+t.length)}function io(r){let t=bt.default.decode(r);if(r=r.slice(bt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return K(r)}function jf(r){let t;r[0]==="Q"||r[0]==="1"?t=Oe(W.decode(`z${r}`)).bytes:t=It.parse(r).multihash.bytes;let e=Uint8Array.from(bt.default.encode(t.length));return xt([e,t],e.length+t.length)}function qf(r){let t=zf.decode(r),e=Uint8Array.from(bt.default.encode(t.length));return xt([e,t],e.length+t.length)}function Gf(r){let t=bt.default.decode(r),e=r.slice(bt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+K(e,"base64url")}function Hf(r){let t=bt.default.decode(r),e=r.slice(bt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return K(e,"base58btc")}function Zf(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 o=pn(n);return xt([e,o],e.length+o.length)}function Wf(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 o=pn(n);return xt([e,o],e.length+o.length)}function ao(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=K(t,"base32"),o=co(e);return`${n}:${o}`}function uo(r){r=ln(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let c=0;c<o.length;c++){let f=o[c],l=P(f);if(l.size===0){t.push([l.code]),e.push([l.code]);continue}if(c++,c>=o.length)throw po("invalid address: "+r);if(l.path===!0){n=ln(o.slice(c).join("/")),t.push([l.code,fn(l.code,n)]),e.push([l.code,n]);break}let g=fn(l.code,o[c]);t.push([l.code,g]),e.push([l.code,un(l.code,g)])}return{string:fo(e),bytes:dn(t),tuples:t,stringTuples:e,path:n}}function hn(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let c=ae.default.decode(r,o),f=ae.default.decode.bytes??0,l=P(c),g=Jf(l,r.slice(o+f));if(g===0){t.push([c]),e.push([c]),o+=f;continue}let A=r.slice(o+f,o+f+g);if(o+=g+f,o>r.length)throw po("Invalid address Uint8Array: "+K(r,"base16"));t.push([c,A]);let p=un(c,A);if(e.push([c,p]),l.path===!0){n=p;break}}return{bytes:Uint8Array.from(r),string:fo(e),tuples:t,stringTuples:e,path:n}}function fo(r){let t=[];return r.map(e=>{let n=P(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ln(t.join("/"))}function dn(r){return xt(r.map(t=>{let e=P(t[0]),n=Uint8Array.from(ae.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=xt([n,t[1]])),n}))}function Jf(r,t){return r.size>0?r.size/8:r.size===0?0:ae.default.decode(t)+(ae.default.decode.bytes??0)}function ln(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function po(r){return new Error("Error parsing address: "+r)}var Xf=Symbol.for("nodejs.util.inspect.custom"),Qf=[P("dns").code,P("dns4").code,P("dns6").code,P("dnsaddr").code],Yf=new Map,lo=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Kf(r){return!!r?.[lo]}var mn=class r{bytes;#t;#e;#r;#n;[lo]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=hn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=uo(t)}else if(Kf(t))e=hn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,c="",f=P("tcp"),l=P("udp"),g=P("ip4"),A=P("ip6"),p=P("dns6"),b=P("ip6zone");for(let[S,h]of this.stringTuples())S===b.code&&(c=`%${h??""}`),Qf.includes(S)&&(e=f.name,o=443,n=`${h??""}${c}`,t=S===p.code?6:4),(S===f.code||S===l.code)&&(e=P(S).name,o=parseInt(h??"")),(S===g.code||S===A.code)&&(e=P(S).name,n=`${h??""}${c}`,t=S===A.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},P(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>P(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(dn(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ie.p2p.code&&t.push([n,o]),n===ie["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?K(W.decode(`z${n}`),"base58btc"):K(It.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return ys(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(c=>c.resolvable);if(e==null)return[this];let n=Yf.get(e.name);if(n==null)throw new Pe(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(c=>new r(c))}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)}[Xf](){return`Multiaddr(${this.#t})`}};function wt(r){return new mn(r)}var tp=v("dns4"),ep=v("dns6"),rp=v("dnsaddr"),Lt=$(v("dns"),rp,tp,ep),je=$(v("ip4"),v("ip6")),Dt=$(E(je,v("tcp")),E(Lt,v("tcp"))),qe=E(je,v("udp")),np=E(qe,v("utp")),sp=E(qe,v("quic")),op=E(qe,v("quic-v1")),gn=$(E(Dt,v("ws")),E(Lt,v("ws"))),ze=$(E(gn,v("p2p")),gn),bn=$(E(Dt,v("wss")),E(Lt,v("wss")),E(Dt,v("tls"),v("ws")),E(Lt,v("tls"),v("ws"))),Ve=$(E(bn,v("p2p")),bn),wn=$(E(Dt,v("http")),E(je,v("http")),E(Lt,v("http"))),yn=$(E(Dt,v("https")),E(je,v("https")),E(Lt,v("https"))),ho=E(qe,v("webrtc-direct"),v("certhash")),bo=$(E(ho,v("p2p")),ho),mo=E(op,v("webtransport"),v("certhash"),v("certhash")),wo=$(E(mo,v("p2p")),mo),yo=$(E(ze,v("p2p-webrtc-star"),v("p2p")),E(Ve,v("p2p-webrtc-star"),v("p2p")),E(ze,v("p2p-webrtc-star")),E(Ve,v("p2p-webrtc-star"))),jd=$(E(ze,v("p2p-websocket-star"),v("p2p")),E(Ve,v("p2p-websocket-star"),v("p2p")),E(ze,v("p2p-websocket-star")),E(Ve,v("p2p-websocket-star"))),vo=$(E(wn,v("p2p-webrtc-direct"),v("p2p")),E(yn,v("p2p-webrtc-direct"),v("p2p")),E(wn,v("p2p-webrtc-direct")),E(yn,v("p2p-webrtc-direct"))),$t=$(gn,bn,wn,yn,yo,vo,Dt,np,sp,Lt,bo,wo),qd=$(E($t,v("p2p-stardust"),v("p2p")),E($t,v("p2p-stardust"))),Rt=$(E($t,v("p2p")),yo,vo,bo,wo,v("p2p")),go=$(E(Rt,v("p2p-circuit"),Rt),E(Rt,v("p2p-circuit")),E(v("p2p-circuit"),Rt),E($t,v("p2p-circuit")),E(v("p2p-circuit"),$t),v("p2p-circuit")),xo=()=>$(E(go,xo),go),Ut=xo(),Gd=$(E(Ut,Rt,Ut),E(Rt,Ut),E(Ut,Rt),Ut,Rt);var Hd=$(E(Ut,v("webrtc"),v("p2p")),E(Ut,v("webrtc")),E($t,v("webrtc"),v("p2p")),E($t,v("webrtc")),v("webrtc"));function So(r){function t(e){let n;try{n=wt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function E(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:So(t),partialMatch:t}}function $(...r){function t(n){let o=null;return r.some(c=>{let f=typeof c=="function"?c().partialMatch(n):c.partialMatch(n);return f!=null?(o=f,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:So(t),partialMatch:t}}function v(r){let t=r;function e(o){let c;try{c=wt(o)}catch{return!1}let f=c.protoNames();return f.length===1&&f[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Ho=H(mt("net"),1);var Ge=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:c})=>c!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new ce(t,e))}},vn=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},ce=globalThis.CustomEvent??vn;function He(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Ze(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var ue=/^(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,xn=/\/\d{1,2}$/;var J=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var fe=H(Sn(),1),zt=H(Se(),1),st=class r{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Ze(32),this.isInSubnet=He,this.address=t;let e=xn.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 J("Invalid subnet mask.");t=t.replace(xn,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new r(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(ue))throw new J("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=[],o;for(o=0;o<8;o+=2){let c=e.slice(o,o+2);n.push(parseInt(c,16))}return new r(n.join("."))}static fromInteger(t){return r.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new r(n)}toHex(){return this.parsedAddress.map(t=>(0,zt.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,zt.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,zt.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new fe.BigInteger(this.parsedAddress.map(t=>(0,zt.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new fe.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new fe.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new fe.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new fe.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return r.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}reverseForm(t){t||(t={});let e=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?e:(0,zt.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new r("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(ue,(0,zt.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 Io={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},Tn={"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"},Cn=/([^0-9a-f:/%])/gi,En=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,An=/\/\d{1,3}(?=%|$)/,In=/%.*$/,Bo=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Mo=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Do=H(Se(),1);function ap(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function Xe(r,t=0){return r.split(":").map((n,o)=>/group-v4/.test(n)?n:(0,Do.sprintf)('<span class="hover-group group-%d">%s</span>',o+t,ap(n)))}var jt=H(Se(),1);function Mn(r){return(0,jt.sprintf)("(%s)",r.join("|"))}function Bn(r){return r.length<4?(0,jt.sprintf)("0{0,%d}%s",4-r.length,r):r}var Rn="[^A-Fa-f0-9:]";function Qe(r){let t=[];r.forEach((n,o)=>{parseInt(n,16)===0&&t.push(o)});let e=t.map(n=>r.map((o,c)=>{if(c===n){let f=c===0||c===8-1?":":"";return Mn([Bn(o),f])}return Bn(o)}).join(":"));return e.push(r.map(Bn).join(":")),Mn(e)}function Dn(r,t,e){let n=t?"":":",o=e?"":":",c=[];!t&&!e&&c.push("::"),t&&e&&c.push(""),(e&&!t||!e&&t)&&c.push(":"),c.push((0,jt.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),c.push((0,jt.sprintf)("(0{1,4}:){1,%d}%s",r-1,o)),c.push((0,jt.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let f=1;f<r-1;f++)for(let l=1;l<r-f;l++)c.push((0,jt.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",l,r-l-f-1));return Mn(c)}var X=H(Sn(),1),Q=H(Se(),1);function Ye(r){if(!r)throw new Error("Assertion failed.")}function cp(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function up(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 fp(r,t){let e=[],n=[],o;for(o=0;o<r.length;o++)o<t[0]?e.push(r[o]):o>t[1]&&n.push(r[o]);return e.concat(["compact"]).concat(n)}function ko(r){return(0,Q.sprintf)("%04x",parseInt(r,16))}function Oo(r){return r&255}var Te=class r{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=He,this.isCorrect=Ze(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=An.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 J("Invalid subnet mask.");t=t.replace(An,"")}else if(/\//.test(t))throw new J("Invalid subnet mask.");let o=In.exec(t);o&&(this.zone=o[0],t=t.replace(In,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new r(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],o;for(o=0;o<8;o++)n.push(e.slice(o*4,(o+1)*4));return new r(n.join(":"))}static fromURL(t){let e,n=null,o;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(o=Mo.exec(t),o===null)return{error:"failed to parse address with port",address:null,port:null};e=o[1],n=o[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),o=Bo.exec(t),o===null)return{error:"failed to parse address from URL",address:null,port:null};e=o[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new r(e),port:n}}static fromAddress4(t){let e=new st(t),n=128-(32-e.subnetMask);return new r(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new J("Invalid 'ip6.arpa' form.");let o=e.split(".").reverse();for(let c=n;c>0;c--){let f=c*4;o.splice(f,0,":")}return e=o.join(""),new r(e)}microsoftTranscription(){return(0,Q.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),o=e-n;return o<0?"0":cp(new X.BigInteger("2",10).pow(o).toString(10))}_startAddress(){return new X.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new X.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new X.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new X.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Io[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(Tn))if(this.isInSubnet(new r(t)))return Tn[t];return"Global unicast"}getBits(t,e){return new X.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,Q.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,o=[];for(t=0;t<this.parsedAddress.length;t++){let l=parseInt(this.parsedAddress[t],16);l===0&&n++,l!==0&&n>0&&(n>1&&o.push([t-n,t-1]),n=0)}n>1&&o.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let c=o.map(l=>l[1]-l[0]+1);if(o.length>0){let l=c.indexOf(Math.max(...c));e=fp(this.parsedAddress,o[l])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let f=e.join(":");return f=f.replace(/^compact$/,"::"),f=f.replace(/^compact|compact$/,":"),f=f.replace(/compact/,""),f}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),o=e.slice(-1)[0].match(ue);if(o){this.parsedAddress4=o[0],this.address4=new st(this.parsedAddress4);for(let c=0;c<this.address4.groups;c++)if(/^0[0-9]+/.test(this.address4.parsedAddress[c]))throw new J("IPv4 addresses can't have leading zeroes.",t.replace(ue,this.address4.parsedAddress.map(up).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(Cn);if(e)throw new J((0,Q.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(Cn,'<span class="parse-error">$1</span>'));let n=t.match(En);if(n)throw new J((0,Q.sprintf)("Address failed regex: %s",n.join("")),t.replace(En,'<span class="parse-error">$1</span>'));let o=[],c=t.split("::");if(c.length===2){let f=c[0].split(":"),l=c[1].split(":");f.length===1&&f[0]===""&&(f=[]),l.length===1&&l[0]===""&&(l=[]);let g=this.groups-(f.length+l.length);if(!g)throw new J("Error parsing groups");this.elidedGroups=g,this.elisionBegin=f.length,this.elisionEnd=f.length+this.elidedGroups,o=o.concat(f);for(let A=0;A<g;A++)o.push("0");o=o.concat(l)}else if(c.length===1)o=t.split(":"),this.elidedGroups=0;else throw new J("Too many :: groups found");if(o=o.map(f=>(0,Q.sprintf)("%x",parseInt(f,16))),o.length!==this.groups)throw new J("Incorrect number of groups found");return o}canonicalForm(){return this.parsedAddress.map(ko).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Q.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new X.BigInteger(this.parsedAddress.map(ko).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return st.fromHex(new X.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new r(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),o="";return/:$/.test(n)||(o=":"),n+o+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new X.BigInteger("ffff",16)).toString(),n=st.fromHex(this.getBitsBase16(32,64)),o=st.fromHex(this.getBits(96,128).xor(new X.BigInteger("ffffffff",16)).toString(16)),c=this.getBits(64,80),f=this.getBitsBase2(64,80),l=c.testBit(15),g=c.testBit(14),A=c.testBit(8),p=c.testBit(9),b=new X.BigInteger(f.slice(2,6)+f.slice(8,16),2).toString(10);return{prefix:(0,Q.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:o.address,flags:f,coneNat:l,microsoft:{reserved:g,universalLocal:p,groupIndividual:A,nonce:b},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=st.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Q.sprintf)("%s",t.slice(0,4)),gateway:e.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new r(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Oo)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Oo))}static fromUnsignedByteArray(t){let e=new X.BigInteger("256",10),n=new X.BigInteger("0",10),o=new X.BigInteger("1",10);for(let c=t.length-1;c>=0;c--)n=n.add(o.multiply(new X.BigInteger(t[c].toString(10),10))),o=o.multiply(e);return r.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new r("2001::/32"))}is6to4(){return this.isInSubnet(new r("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,Q.sprintf)(":%s",t),(0,Q.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,Q.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,Q.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return Xe(this.address).join(":");Ye(typeof this.elidedGroups=="number"),Ye(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...Xe(e)):t.push("");let o=["hover-group"];for(let c=this.elisionBegin;c<this.elisionBegin+this.elidedGroups;c++)o.push((0,Q.sprintf)("group-%d",c));return t.push((0,Q.sprintf)('<span class="%s"></span>',o.join(" "))),n.length?t.push(...Xe(n,this.elisionEnd)):t.push(""),this.is4()&&(Ye(this.address4 instanceof st),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new r(this.correctForm());if(n.elidedGroups===0)e.push(Qe(n.parsedAddress));else if(n.elidedGroups===8)e.push(Dn(8));else{let o=n.address.split("::");o[0].length&&e.push(Qe(o[0].split(":"))),Ye(typeof n.elidedGroups=="number"),e.push(Dn(n.elidedGroups,o[0].length!==0,o[1].length!==0)),o[1].length&&e.push(Qe(o[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Rn,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Rn,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var pp=At("libp2p:ip-port-to-multiaddr"),Pn={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function No(r,t){if(typeof r!="string")throw new lt(`invalid ip provided: ${r}`,Pn.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new lt(`invalid port provided: ${t}`,Pn.ERR_INVALID_PORT_PARAMETER);try{return new st(r),wt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new Te(r);return e.is4()?wt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):wt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw pp.error(n),new lt(n,Pn.ERR_INVALID_IP)}}var Go=H(jo(),1);var Nn=H(mt("os"),1),qo=H(mt("path"),1);var gp={ip4:"IPv4",ip6:"IPv6"};function he(r,t={}){let e=r.getPath();return e!=null?Nn.default.platform()==="win32"?{path:qo.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function Fn(r,t,e){let n=o=>wt(`/${r}/${o}/tcp/${e}`);return(bp(t)?yp(gp[r]):[t]).map(n)}function bp(r){return["0.0.0.0","::"].includes(r)}var wp=Nn.default.networkInterfaces();function yp(r){let t=[];for(let[,e]of Object.entries(wp))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var yt=At("libp2p:tcp:socket"),tr=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",o=t.socketInactivityTimeout??3e5,c=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let f;if(t.remoteAddr!=null)f=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new lt("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");f=No(r.remoteAddress,r.remotePort)}let l=he(f),g=l.path??`${l.host??""}:${l.port??""}`,{sink:A,source:p}=Go.default.duplex(r);r.setTimeout(o,()=>{yt("%s socket read timeout",g),e?.increment({[`${n}timeout`]:!0});let y;r.readable&&(y=new lt("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(y)}),r.once("close",()=>{yt("%s socket close",g),e?.increment({[`${n}close`]:!0}),b.timeline.close==null&&(b.timeline.close=Date.now())}),r.once("end",()=>{yt("%s socket end",g),e?.increment({[`${n}end`]:!0})});let b={async sink(y){try{await A(y)}catch(S){S.type!=="aborted"&&yt(S)}r.end()},source:p,remoteAddr:f,timeline:{open:Date.now()},async close(y={}){if(r.destroyed){yt("%s socket was already destroyed when trying to close",g);return}y.signal=y.signal??AbortSignal.timeout(c);try{yt("%s closing socket",g),await new Promise((S,h)=>{r.once("close",()=>{yt("%s socket closed",g),S()}),r.once("error",T=>{yt("%s socket error",g,T),b.timeline.close==null&&(b.timeline.close=Date.now()),h(T)}),r.setTimeout(c),r.end(),r.writableLength>0?r.once("drain",()=>{yt("%s socket drained",g),r.destroy()}):r.destroy()})}catch(S){this.abort(S)}},abort:y=>{yt("%s socket abort due to error",g,y),r.destroy(y)}};return b};var ot=At("libp2p:tcp:listener");async function _n(r){try{await r.close()}catch(t){ot.error("an error occurred closing the connection",t)}}var Sp=1,Tp=0,er=class extends Ge{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Ho.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]:Sp})}this.dispatchEvent(new ce("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new ce("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Tp}),this.dispatchEvent(new ce("close"))})}onSocket(t){t.on("error",n=>{ot("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=tr(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){ot.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}ot("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{ot("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(o=>{ot.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new ce("connection",{detail:n}))}).catch(async n=>{ot.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await _n(e)}).catch(n=>{ot.error("closing inbound connection failed",n)})}catch(n){ot.error("inbound connection failed",n),_n(e).catch(o=>{ot.error("closing inbound connection failed",o),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:o}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Fn("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Fn("ip6",e.address,e.port)))}catch(c){ot.error("could not turn %s:%s into multiaddr",e.address,e.port,c)}return t.map(c=>o!=null?c.encapsulate(`/p2p/${o}`):c)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:o}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:he(n,{backlog:o})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await _n(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)}),ot("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(ot("Closing server on %s",this.server.address()),this.server.close())}};var Tt=At("libp2p:tcp"),Ln=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Wn]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",l=>{Tt("socket error",l)});let o=tr(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),c=()=>{o.close().catch(l=>{Tt.error("Error closing maConn after abort",l)})};e.signal?.addEventListener("abort",c,{once:!0}),Tt("new outbound connection %s",o.remoteAddr);let f=await e.upgrader.upgradeOutbound(o);if(Tt("outbound connection %s upgraded",o.remoteAddr),e.signal?.removeEventListener("abort",c),e.signal?.aborted===!0)throw f.close().catch(l=>{Tt.error("Error closing conn after abort",l)}),new qt;return f}async _connect(t,e){if(e.signal?.aborted===!0)throw new qt;return new Promise((n,o)=>{let c=Date.now(),f=he(t),l=f.path??`${f.host??""}:${f.port}`;Tt("dialing %j",f);let g=Zo.default.connect(f),A=h=>{h.message=`connection error ${l}: ${h.message}`,this.metrics?.dialerEvents.increment({error:!0}),S(h)},p=()=>{Tt("connection timeout %s",l),this.metrics?.dialerEvents.increment({timeout:!0});let h=new lt(`connection timeout after ${Date.now()-c}ms`,"ERR_CONNECT_TIMEOUT");g.emit("error",h)},b=()=>{Tt("connection opened %j",f),this.metrics?.dialerEvents.increment({connect:!0}),S()},y=()=>{Tt("connection aborted %j",f),this.metrics?.dialerEvents.increment({abort:!0}),g.destroy(),S(new qt)},S=h=>{if(g.removeListener("error",A),g.removeListener("timeout",p),g.removeListener("connect",b),e.signal!=null&&e.signal.removeEventListener("abort",y),h!=null){o(h);return}n(g)};g.on("error",A),g.on("timeout",p),g.on("connect",b),e.signal!=null&&e.signal.addEventListener("abort",y)})}createListener(t){return new er({...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:Dt.matches(e.decapsulateCode(421)))}};function Ap(r={}){return(t={})=>new Ln(t,r)}return ka(Ip);})();
|
|
7
7
|
return Libp2PTcp}));
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const CODE_P2P = 421;
|
|
2
2
|
export declare const CODE_CIRCUIT = 290;
|
|
3
3
|
export declare const CODE_UNIX = 400;
|
|
4
|
-
export declare const CLOSE_TIMEOUT =
|
|
4
|
+
export declare const CLOSE_TIMEOUT = 500;
|
|
5
5
|
export declare const SOCKET_TIMEOUT: number;
|
|
6
6
|
//# sourceMappingURL=constants.d.ts.map
|