@libp2p/tcp 7.0.3-b36ec7f2 → 7.0.3-c999d6a7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js 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 Za=Object.create;var we=Object.defineProperty;var Ja=Object.getOwnPropertyDescriptor;var Xa=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Qa=Object.prototype.hasOwnProperty;var Ya=(r,t,e)=>t in r?we(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var wt=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var H=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),U=(r,t)=>{for(var e in t)we(r,e,{get:t[e],enumerable:!0})},ns=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Xa(t))!Qa.call(r,s)&&s!==e&&we(r,s,{get:()=>t[s],enumerable:!(n=Ja(t,s))||n.enumerable});return r};var X=(r,t,e)=>(e=r!=null?Za(Wa(r)):{},ns(t||!r||!r.__esModule?we(e,"default",{value:r,enumerable:!0}):e,r)),Ka=r=>ns(we({},"__esModule",{value:!0}),r);var De=(r,t,e)=>(Ya(r,typeof t!="symbol"?t+"":t,e),e);var as=H((fl,is)=>{var Xt=1e3,Wt=Xt*60,Qt=Wt*60,$t=Qt*24,tc=$t*7,ec=$t*365.25;is.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return rc(r);if(e==="number"&&isFinite(r))return t.long?sc(r):nc(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function rc(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*ec;case"weeks":case"week":case"w":return e*tc;case"days":case"day":case"d":return e*$t;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Qt;case"minutes":case"minute":case"mins":case"min":case"m":return e*Wt;case"seconds":case"second":case"secs":case"sec":case"s":return e*Xt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function nc(r){var t=Math.abs(r);return t>=$t?Math.round(r/$t)+"d":t>=Qt?Math.round(r/Qt)+"h":t>=Wt?Math.round(r/Wt)+"m":t>=Xt?Math.round(r/Xt)+"s":r+"ms"}function sc(r){var t=Math.abs(r);return t>=$t?Pe(r,t,$t,"day"):t>=Qt?Pe(r,t,Qt,"hour"):t>=Wt?Pe(r,t,Wt,"minute"):t>=Xt?Pe(r,t,Xt,"second"):r+" ms"}function Pe(r,t,e,n){var s=t>=e*1.5;return Math.round(r/e)+" "+n+(s?"s":"")}});var mr=H((ul,cs)=>{function oc(r){e.debug=e,e.default=e,e.coerce=m,e.disable=c,e.enable=s,e.enabled=u,e.humanize=as(),e.destroy=I,Object.keys(r).forEach(p=>{e[p]=r[p]}),e.names=[],e.skips=[],e.formatters={};function t(p){let g=0;for(let w=0;w<p.length;w++)g=(g<<5)-g+p.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(p){let g,w=null,E,l;function x(...R){if(!x.enabled)return;let T=x,A=Number(new Date),M=A-(g||A);T.diff=M,T.prev=g,T.curr=A,g=A,R[0]=e.coerce(R[0]),typeof R[0]!="string"&&R.unshift("%O");let B=0;R[0]=R[0].replace(/%([a-zA-Z%])/g,(O,D)=>{if(O==="%%")return"%";B++;let P=e.formatters[D];if(typeof P=="function"){let j=R[B];O=P.call(T,j),R.splice(B,1),B--}return O}),e.formatArgs.call(T,R),(T.log||e.log).apply(T,R)}return x.namespace=p,x.useColors=e.useColors(),x.color=e.selectColor(p),x.extend=n,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(E!==e.namespaces&&(E=e.namespaces,l=e.enabled(p)),l),set:R=>{w=R}}),typeof e.init=="function"&&e.init(x),x}function n(p,g){let w=e(this.namespace+(typeof g>"u"?":":g)+p);return w.log=this.log,w}function s(p){e.save(p),e.namespaces=p,e.names=[],e.skips=[];let g,w=(typeof p=="string"?p:"").split(/[\s,]+/),E=w.length;for(g=0;g<E;g++)w[g]&&(p=w[g].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(h),...e.skips.map(h).map(g=>"-"+g)].join(",");return e.enable(""),p}function u(p){if(p[p.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(p))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(p))return!0;return!1}function h(p){return p.toString().substring(2,p.toString().length-2).replace(/\.\*\?$/,"*")}function m(p){return p instanceof Error?p.stack||p.message:p}function I(){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}cs.exports=oc});var fs=H((at,Oe)=>{at.formatArgs=ac;at.save=cc;at.load=fc;at.useColors=ic;at.storage=uc();at.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`."))}})();at.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 ic(){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 ac(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Oe.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,s=>{s!=="%%"&&(e++,s==="%c"&&(n=e))}),r.splice(n,0,t)}at.log=console.debug||console.log||(()=>{});function cc(r){try{r?at.storage.setItem("debug",r):at.storage.removeItem("debug")}catch{}}function fc(){let r;try{r=at.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function uc(){try{return localStorage}catch{}}Oe.exports=mr()(at);var{formatters:pc}=Oe.exports;pc.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ps=H((pl,us)=>{"use strict";us.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),s=t.indexOf("--");return n!==-1&&(s===-1?!0:n<s)}});var hs=H((ll,ls)=>{"use strict";var lc=wt("os"),gt=ps(),Q=process.env,Yt;gt("no-color")||gt("no-colors")||gt("color=false")?Yt=!1:(gt("color")||gt("colors")||gt("color=true")||gt("color=always"))&&(Yt=!0);"FORCE_COLOR"in Q&&(Yt=Q.FORCE_COLOR.length===0||parseInt(Q.FORCE_COLOR,10)!==0);function hc(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function dc(r){if(Yt===!1)return 0;if(gt("color=16m")||gt("color=full")||gt("color=truecolor"))return 3;if(gt("color=256"))return 2;if(r&&!r.isTTY&&Yt!==!0)return 0;let t=Yt?1:0;if(process.platform==="win32"){let e=lc.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 Q)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in Q)||Q.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in Q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION)?1:0;if(Q.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Q){let e=parseInt((Q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Q.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM)||"COLORTERM"in Q?1:(Q.TERM==="dumb",t)}function br(r){let t=dc(r);return hc(t)}ls.exports={supportsColor:br,stdout:br(process.stdout),stderr:br(process.stderr)}});var ms=H((W,Fe)=>{var mc=wt("tty"),Ne=wt("util");W.init=Sc;W.log=yc;W.formatArgs=gc;W.save=vc;W.load=xc;W.useColors=bc;W.destroy=Ne.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");W.colors=[6,2,3,4,5,1];try{let r=hs();r&&(r.stderr||r).level>=2&&(W.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{}W.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(s,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 bc(){return"colors"in W.inspectOpts?!!W.inspectOpts.colors:mc.isatty(process.stderr.fd)}function gc(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,s="\x1B[3"+(n<8?n:"8;5;"+n),c=` ${s};1m${t} \x1B[0m`;r[0]=c+r[0].split(`
2
+ "use strict";var Libp2PTcp=(()=>{var Ga=Object.create;var Be=Object.defineProperty;var Ha=Object.getOwnPropertyDescriptor;var Za=Object.getOwnPropertyNames;var Ja=Object.getPrototypeOf,Xa=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 V=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),U=(r,t)=>{for(var e in t)Be(r,e,{get:t[e],enumerable:!0})},es=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Za(t))!Xa.call(r,s)&&s!==e&&Be(r,s,{get:()=>t[s],enumerable:!(n=Ha(t,s))||n.enumerable});return r};var G=(r,t,e)=>(e=r!=null?Ga(Ja(r)):{},es(t||!r||!r.__esModule?Be(e,"default",{value:r,enumerable:!0}):e,r)),Wa=r=>es(Be({},"__esModule",{value:!0}),r);var os=V((ol,ss)=>{var Ht=1e3,Zt=Ht*60,Jt=Zt*60,Ft=Jt*24,Qa=Ft*7,Ya=Ft*365.25;ss.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Ka(r);if(e==="number"&&isFinite(r))return t.long?ec(r):tc(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Ka(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*Ya;case"weeks":case"week":case"w":return e*Qa;case"days":case"day":case"d":return e*Ft;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Jt;case"minutes":case"minute":case"mins":case"min":case"m":return e*Zt;case"seconds":case"second":case"secs":case"sec":case"s":return e*Ht;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function tc(r){var t=Math.abs(r);return t>=Ft?Math.round(r/Ft)+"d":t>=Jt?Math.round(r/Jt)+"h":t>=Zt?Math.round(r/Zt)+"m":t>=Ht?Math.round(r/Ht)+"s":r+"ms"}function ec(r){var t=Math.abs(r);return t>=Ft?Me(r,t,Ft,"day"):t>=Jt?Me(r,t,Jt,"hour"):t>=Zt?Me(r,t,Zt,"minute"):t>=Ht?Me(r,t,Ht,"second"):r+" ms"}function Me(r,t,e,n){var s=t>=e*1.5;return Math.round(r/e)+" "+n+(s?"s":"")}});var lr=V((il,is)=>{function rc(r){e.debug=e,e.default=e,e.coerce=m,e.disable=c,e.enable=s,e.enabled=u,e.humanize=os(),e.destroy=I,Object.keys(r).forEach(p=>{e[p]=r[p]}),e.names=[],e.skips=[],e.formatters={};function t(p){let g=0;for(let w=0;w<p.length;w++)g=(g<<5)-g+p.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(p){let g,w=null,C,l;function x(...M){if(!x.enabled)return;let T=x,A=Number(new Date),R=A-(g||A);T.diff=R,T.prev=g,T.curr=A,g=A,M[0]=e.coerce(M[0]),typeof M[0]!="string"&&M.unshift("%O");let B=0;M[0]=M[0].replace(/%([a-zA-Z%])/g,(O,D)=>{if(O==="%%")return"%";B++;let k=e.formatters[D];if(typeof k=="function"){let $=M[B];O=k.call(T,$),M.splice(B,1),B--}return O}),e.formatArgs.call(T,M),(T.log||e.log).apply(T,M)}return x.namespace=p,x.useColors=e.useColors(),x.color=e.selectColor(p),x.extend=n,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(C!==e.namespaces&&(C=e.namespaces,l=e.enabled(p)),l),set:M=>{w=M}}),typeof e.init=="function"&&e.init(x),x}function n(p,g){let w=e(this.namespace+(typeof g>"u"?":":g)+p);return w.log=this.log,w}function s(p){e.save(p),e.namespaces=p,e.names=[],e.skips=[];let g,w=(typeof p=="string"?p:"").split(/[\s,]+/),C=w.length;for(g=0;g<C;g++)w[g]&&(p=w[g].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(h),...e.skips.map(h).map(g=>"-"+g)].join(",");return e.enable(""),p}function u(p){if(p[p.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(p))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(p))return!0;return!1}function h(p){return p.toString().substring(2,p.toString().length-2).replace(/\.\*\?$/,"*")}function m(p){return p instanceof Error?p.stack||p.message:p}function I(){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}is.exports=rc});var as=V((nt,Re)=>{nt.formatArgs=sc;nt.save=oc;nt.load=ic;nt.useColors=nc;nt.storage=ac();nt.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`."))}})();nt.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 nc(){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 sc(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Re.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,s=>{s!=="%%"&&(e++,s==="%c"&&(n=e))}),r.splice(n,0,t)}nt.log=console.debug||console.log||(()=>{});function oc(r){try{r?nt.storage.setItem("debug",r):nt.storage.removeItem("debug")}catch{}}function ic(){let r;try{r=nt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function ac(){try{return localStorage}catch{}}Re.exports=lr()(nt);var{formatters:cc}=Re.exports;cc.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var fs=V((al,cs)=>{"use strict";cs.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),s=t.indexOf("--");return n!==-1&&(s===-1?!0:n<s)}});var ps=V((cl,us)=>{"use strict";var fc=mt("os"),dt=fs(),Z=process.env,Xt;dt("no-color")||dt("no-colors")||dt("color=false")?Xt=!1:(dt("color")||dt("colors")||dt("color=true")||dt("color=always"))&&(Xt=!0);"FORCE_COLOR"in Z&&(Xt=Z.FORCE_COLOR.length===0||parseInt(Z.FORCE_COLOR,10)!==0);function uc(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function pc(r){if(Xt===!1)return 0;if(dt("color=16m")||dt("color=full")||dt("color=truecolor"))return 3;if(dt("color=256"))return 2;if(r&&!r.isTTY&&Xt!==!0)return 0;let t=Xt?1:0;if(process.platform==="win32"){let e=fc.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 hr(r){let t=pc(r);return uc(t)}us.exports={supportsColor:hr,stdout:hr(process.stdout),stderr:hr(process.stderr)}});var hs=V((H,Pe)=>{var lc=mt("tty"),De=mt("util");H.init=yc;H.log=bc;H.formatArgs=dc;H.save=gc;H.load=wc;H.useColors=hc;H.destroy=De.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");H.colors=[6,2,3,4,5,1];try{let r=ps();r&&(r.stderr||r).level>=2&&(H.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{}H.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(s,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 hc(){return"colors"in H.inspectOpts?!!H.inspectOpts.colors:lc.isatty(process.stderr.fd)}function dc(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,s="\x1B[3"+(n<8?n:"8;5;"+n),c=` ${s};1m${t} \x1B[0m`;r[0]=c+r[0].split(`
3
3
  `).join(`
4
- `+c),r.push(s+"m+"+Fe.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=wc()+t+" "+r[0]}function wc(){return W.inspectOpts.hideDate?"":new Date().toISOString()+" "}function yc(...r){return process.stderr.write(Ne.format(...r)+`
5
- `)}function vc(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function xc(){return process.env.DEBUG}function Sc(r){r.inspectOpts={};let t=Object.keys(W.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=W.inspectOpts[t[e]]}Fe.exports=mr()(W);var{formatters:ds}=Fe.exports;ds.o=function(r){return this.inspectOpts.colors=this.useColors,Ne.inspect(r,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};ds.O=function(r){return this.inspectOpts.colors=this.useColors,Ne.inspect(r,this.inspectOpts)}});var bs=H((hl,gr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?gr.exports=fs():gr.exports=ms()});var io=H((Wh,oo)=>{oo.exports=tn;var so=128,xu=127,Su=~xu,Tu=Math.pow(2,31);function tn(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw tn.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Tu;)t[e++]=r&255|so,r/=128;for(;r&Su;)t[e++]=r&255|so,r>>>=7;return t[e]=r|0,tn.bytes=e-n+1,t}});var fo=H((Qh,co)=>{co.exports=en;var Eu=128,ao=127;function en(r,n){var e=0,n=n||0,s=0,c=n,u,h=r.length;do{if(c>=h||s>49)throw en.bytes=0,new RangeError("Could not decode varint");u=r[c++],e+=s<28?(u&ao)<<s:(u&ao)*Math.pow(2,s),s+=7}while(u>=Eu);return en.bytes=c-n,e}});var po=H((Yh,uo)=>{var Au=Math.pow(2,7),Cu=Math.pow(2,14),Iu=Math.pow(2,21),Bu=Math.pow(2,28),Ru=Math.pow(2,35),Mu=Math.pow(2,42),Du=Math.pow(2,49),ku=Math.pow(2,56),Pu=Math.pow(2,63);uo.exports=function(r){return r<Au?1:r<Cu?2:r<Iu?3:r<Bu?4:r<Ru?5:r<Mu?6:r<Du?7:r<ku?8:r<Pu?9:10}});var je=H((Kh,lo)=>{lo.exports={encode:io(),decode:fo(),encodingLength:po()}});var Pn=H((rr,qo)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(o,i,a){o!=null&&(typeof o=="number"?this.fromNumber(o,i,a):i==null&&typeof o!="string"?this.fromString(o,256):this.fromString(o,i))}function s(){return new n(null)}function c(o,i,a,f,d,b){for(;--b>=0;){var y=i*this[o++]+a[f]+d;d=Math.floor(y/67108864),a[f++]=y&67108863}return d}function u(o,i,a,f,d,b){for(var y=i&32767,S=i>>15;--b>=0;){var F=this[o]&32767,J=this[o++]>>15,ut=S*F+J*y;F=y*F+((ut&32767)<<15)+a[f]+(d&1073741823),d=(F>>>30)+(ut>>>15)+S*J+(d>>>30),a[f++]=F&1073741823}return d}function h(o,i,a,f,d,b){for(var y=i&16383,S=i>>14;--b>=0;){var F=this[o]&16383,J=this[o++]>>14,ut=S*F+J*y;F=y*F+((ut&16383)<<14)+a[f]+d,d=(F>>28)+(ut>>14)+S*J,a[f++]=F&268435455}return d}var m=typeof navigator<"u";m&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=u,r=30):m&&e&&navigator.appName!="Netscape"?(n.prototype.am=c,r=26):(n.prototype.am=h,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var I=52;n.prototype.FV=Math.pow(2,I),n.prototype.F1=I-r,n.prototype.F2=2*r-I;var p="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,E;for(w="0".charCodeAt(0),E=0;E<=9;++E)g[w++]=E;for(w="a".charCodeAt(0),E=10;E<36;++E)g[w++]=E;for(w="A".charCodeAt(0),E=10;E<36;++E)g[w++]=E;function l(o){return p.charAt(o)}function x(o,i){var a=g[o.charCodeAt(i)];return a??-1}function R(o){for(var i=this.t-1;i>=0;--i)o[i]=this[i];o.t=this.t,o.s=this.s}function T(o){this.t=1,this.s=o<0?-1:0,o>0?this[0]=o:o<-1?this[0]=o+this.DV:this.t=0}function A(o){var i=s();return i.fromInt(o),i}function M(o,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(o,i);return}this.t=0,this.s=0;for(var f=o.length,d=!1,b=0;--f>=0;){var y=a==8?o[f]&255:x(o,f);if(y<0){o.charAt(f)=="-"&&(d=!0);continue}d=!1,b==0?this[this.t++]=y:b+a>this.DB?(this[this.t-1]|=(y&(1<<this.DB-b)-1)<<b,this[this.t++]=y>>this.DB-b):this[this.t-1]|=y<<b,b+=a,b>=this.DB&&(b-=this.DB)}a==8&&o[0]&128&&(this.s=-1,b>0&&(this[this.t-1]|=(1<<this.DB-b)-1<<b)),this.clamp(),d&&n.ZERO.subTo(this,this)}function B(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function k(o){if(this.s<0)return"-"+this.negate().toString(o);var i;if(o==16)i=4;else if(o==8)i=3;else if(o==2)i=1;else if(o==32)i=5;else if(o==4)i=2;else return this.toRadix(o);var a=(1<<i)-1,f,d=!1,b="",y=this.t,S=this.DB-y*this.DB%i;if(y-- >0)for(S<this.DB&&(f=this[y]>>S)>0&&(d=!0,b=l(f));y>=0;)S<i?(f=(this[y]&(1<<S)-1)<<i-S,f|=this[--y]>>(S+=this.DB-i)):(f=this[y]>>(S-=i)&a,S<=0&&(S+=this.DB,--y)),f>0&&(d=!0),d&&(b+=l(f));return d?b:"0"}function O(){var o=s();return n.ZERO.subTo(this,o),o}function D(){return this.s<0?this.negate():this}function P(o){var i=this.s-o.s;if(i!=0)return i;var a=this.t;if(i=a-o.t,i!=0)return this.s<0?-i:i;for(;--a>=0;)if((i=this[a]-o[a])!=0)return i;return 0}function j(o){var i=1,a;return(a=o>>>16)!=0&&(o=a,i+=16),(a=o>>8)!=0&&(o=a,i+=8),(a=o>>4)!=0&&(o=a,i+=4),(a=o>>2)!=0&&(o=a,i+=2),(a=o>>1)!=0&&(o=a,i+=1),i}function hi(){return this.t<=0?0:this.DB*(this.t-1)+j(this[this.t-1]^this.s&this.DM)}function di(o,i){var a;for(a=this.t-1;a>=0;--a)i[a+o]=this[a];for(a=o-1;a>=0;--a)i[a]=0;i.t=this.t+o,i.s=this.s}function mi(o,i){for(var a=o;a<this.t;++a)i[a-o]=this[a];i.t=Math.max(this.t-o,0),i.s=this.s}function bi(o,i){var a=o%this.DB,f=this.DB-a,d=(1<<f)-1,b=Math.floor(o/this.DB),y=this.s<<a&this.DM,S;for(S=this.t-1;S>=0;--S)i[S+b+1]=this[S]>>f|y,y=(this[S]&d)<<a;for(S=b-1;S>=0;--S)i[S]=0;i[b]=y,i.t=this.t+b+1,i.s=this.s,i.clamp()}function gi(o,i){i.s=this.s;var a=Math.floor(o/this.DB);if(a>=this.t){i.t=0;return}var f=o%this.DB,d=this.DB-f,b=(1<<f)-1;i[0]=this[a]>>f;for(var y=a+1;y<this.t;++y)i[y-a-1]|=(this[y]&b)<<d,i[y-a]=this[y]>>f;f>0&&(i[this.t-a-1]|=(this.s&b)<<d),i.t=this.t-a,i.clamp()}function wi(o,i){for(var a=0,f=0,d=Math.min(o.t,this.t);a<d;)f+=this[a]-o[a],i[a++]=f&this.DM,f>>=this.DB;if(o.t<this.t){for(f-=o.s;a<this.t;)f+=this[a],i[a++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;a<o.t;)f-=o[a],i[a++]=f&this.DM,f>>=this.DB;f-=o.s}i.s=f<0?-1:0,f<-1?i[a++]=this.DV+f:f>0&&(i[a++]=f),i.t=a,i.clamp()}function yi(o,i){var a=this.abs(),f=o.abs(),d=a.t;for(i.t=d+f.t;--d>=0;)i[d]=0;for(d=0;d<f.t;++d)i[d+a.t]=a.am(0,f[d],i,d,0,a.t);i.s=0,i.clamp(),this.s!=o.s&&n.ZERO.subTo(i,i)}function vi(o){for(var i=this.abs(),a=o.t=2*i.t;--a>=0;)o[a]=0;for(a=0;a<i.t-1;++a){var f=i.am(a,i[a],o,2*a,0,1);(o[a+i.t]+=i.am(a+1,2*i[a],o,2*a+1,f,i.t-a-1))>=i.DV&&(o[a+i.t]-=i.DV,o[a+i.t+1]=1)}o.t>0&&(o[o.t-1]+=i.am(a,i[a],o,2*a,0,1)),o.s=0,o.clamp()}function xi(o,i,a){var f=o.abs();if(!(f.t<=0)){var d=this.abs();if(d.t<f.t){i?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=s());var b=s(),y=this.s,S=o.s,F=this.DB-j(f[f.t-1]);F>0?(f.lShiftTo(F,b),d.lShiftTo(F,a)):(f.copyTo(b),d.copyTo(a));var J=b.t,ut=b[J-1];if(ut!=0){var it=ut*(1<<this.F1)+(J>1?b[J-2]>>this.F2:0),Tt=this.FV/it,Re=(1<<this.F1)/it,dt=1<<this.F2,mt=a.t,Me=mt-J,Rt=i??s();for(b.dlShiftTo(Me,Rt),a.compareTo(Rt)>=0&&(a[a.t++]=1,a.subTo(Rt,a)),n.ONE.dlShiftTo(J,Rt),Rt.subTo(b,b);b.t<J;)b[b.t++]=0;for(;--Me>=0;){var dr=a[--mt]==ut?this.DM:Math.floor(a[mt]*Tt+(a[mt-1]+dt)*Re);if((a[mt]+=b.am(0,dr,a,Me,0,J))<dr)for(b.dlShiftTo(Me,Rt),a.subTo(Rt,a);a[mt]<--dr;)a.subTo(Rt,a)}i!=null&&(a.drShiftTo(J,i),y!=S&&n.ZERO.subTo(i,i)),a.t=J,a.clamp(),F>0&&a.rShiftTo(F,a),y<0&&n.ZERO.subTo(a,a)}}}function Si(o){var i=s();return this.abs().divRemTo(o,null,i),this.s<0&&i.compareTo(n.ZERO)>0&&o.subTo(i,i),i}function Ut(o){this.m=o}function Ti(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function Ei(o){return o}function Ai(o){o.divRemTo(this.m,null,o)}function Ci(o,i,a){o.multiplyTo(i,a),this.reduce(a)}function Ii(o,i){o.squareTo(i),this.reduce(i)}Ut.prototype.convert=Ti,Ut.prototype.revert=Ei,Ut.prototype.reduce=Ai,Ut.prototype.mulTo=Ci,Ut.prototype.sqrTo=Ii;function Bi(){if(this.t<1)return 0;var o=this[0];if(!(o&1))return 0;var i=o&3;return i=i*(2-(o&15)*i)&15,i=i*(2-(o&255)*i)&255,i=i*(2-((o&65535)*i&65535))&65535,i=i*(2-o*i%this.DV)%this.DV,i>0?this.DV-i:-i}function _t(o){this.m=o,this.mp=o.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<o.DB-15)-1,this.mt2=2*o.t}function Ri(o){var i=s();return o.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),o.s<0&&i.compareTo(n.ZERO)>0&&this.m.subTo(i,i),i}function Mi(o){var i=s();return o.copyTo(i),this.reduce(i),i}function Di(o){for(;o.t<=this.mt2;)o[o.t++]=0;for(var i=0;i<this.m.t;++i){var a=o[i]&32767,f=a*this.mpl+((a*this.mph+(o[i]>>15)*this.mpl&this.um)<<15)&o.DM;for(a=i+this.m.t,o[a]+=this.m.am(0,f,o,i,0,this.m.t);o[a]>=o.DV;)o[a]-=o.DV,o[++a]++}o.clamp(),o.drShiftTo(this.m.t,o),o.compareTo(this.m)>=0&&o.subTo(this.m,o)}function ki(o,i){o.squareTo(i),this.reduce(i)}function Pi(o,i,a){o.multiplyTo(i,a),this.reduce(a)}_t.prototype.convert=Ri,_t.prototype.revert=Mi,_t.prototype.reduce=Di,_t.prototype.mulTo=Pi,_t.prototype.sqrTo=ki;function Oi(){return(this.t>0?this[0]&1:this.s)==0}function Ni(o,i){if(o>4294967295||o<1)return n.ONE;var a=s(),f=s(),d=i.convert(this),b=j(o)-1;for(d.copyTo(a);--b>=0;)if(i.sqrTo(a,f),(o&1<<b)>0)i.mulTo(f,d,a);else{var y=a;a=f,f=y}return i.revert(a)}function Fi(o,i){var a;return o<256||i.isEven()?a=new Ut(i):a=new _t(i),this.exp(o,a)}n.prototype.copyTo=R,n.prototype.fromInt=T,n.prototype.fromString=M,n.prototype.clamp=B,n.prototype.dlShiftTo=di,n.prototype.drShiftTo=mi,n.prototype.lShiftTo=bi,n.prototype.rShiftTo=gi,n.prototype.subTo=wi,n.prototype.multiplyTo=yi,n.prototype.squareTo=vi,n.prototype.divRemTo=xi,n.prototype.invDigit=Bi,n.prototype.isEven=Oi,n.prototype.exp=Ni,n.prototype.toString=k,n.prototype.negate=O,n.prototype.abs=D,n.prototype.compareTo=P,n.prototype.bitLength=hi,n.prototype.mod=Si,n.prototype.modPowInt=Fi,n.ZERO=A(0),n.ONE=A(1);function Ui(){var o=s();return this.copyTo(o),o}function _i(){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 Li(){return this.t==0?this.s:this[0]<<24>>24}function $i(){return this.t==0?this.s:this[0]<<16>>16}function zi(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function Vi(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function ji(o){if(o==null&&(o=10),this.signum()==0||o<2||o>36)return"0";var i=this.chunkSize(o),a=Math.pow(o,i),f=A(a),d=s(),b=s(),y="";for(this.divRemTo(f,d,b);d.signum()>0;)y=(a+b.intValue()).toString(o).substr(1)+y,d.divRemTo(f,d,b);return b.intValue().toString(o)+y}function qi(o,i){this.fromInt(0),i==null&&(i=10);for(var a=this.chunkSize(i),f=Math.pow(i,a),d=!1,b=0,y=0,S=0;S<o.length;++S){var F=x(o,S);if(F<0){o.charAt(S)=="-"&&this.signum()==0&&(d=!0);continue}y=i*y+F,++b>=a&&(this.dMultiply(f),this.dAddOffset(y,0),b=0,y=0)}b>0&&(this.dMultiply(Math.pow(i,b)),this.dAddOffset(y,0)),d&&n.ZERO.subTo(this,this)}function Gi(o,i,a){if(typeof i=="number")if(o<2)this.fromInt(1);else for(this.fromNumber(o,a),this.testBit(o-1)||this.bitwiseTo(n.ONE.shiftLeft(o-1),ur,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>o&&this.subTo(n.ONE.shiftLeft(o-1),this);else{var f=new Array,d=o&7;f.length=(o>>3)+1,i.nextBytes(f),d>0?f[0]&=(1<<d)-1:f[0]=0,this.fromString(f,256)}}function Hi(){var o=this.t,i=new Array;i[0]=this.s;var a=this.DB-o*this.DB%8,f,d=0;if(o-- >0)for(a<this.DB&&(f=this[o]>>a)!=(this.s&this.DM)>>a&&(i[d++]=f|this.s<<this.DB-a);o>=0;)a<8?(f=(this[o]&(1<<a)-1)<<8-a,f|=this[--o]>>(a+=this.DB-8)):(f=this[o]>>(a-=8)&255,a<=0&&(a+=this.DB,--o)),f&128&&(f|=-256),d==0&&(this.s&128)!=(f&128)&&++d,(d>0||f!=this.s)&&(i[d++]=f);return i}function Zi(o){return this.compareTo(o)==0}function Ji(o){return this.compareTo(o)<0?this:o}function Xi(o){return this.compareTo(o)>0?this:o}function Wi(o,i,a){var f,d,b=Math.min(o.t,this.t);for(f=0;f<b;++f)a[f]=i(this[f],o[f]);if(o.t<this.t){for(d=o.s&this.DM,f=b;f<this.t;++f)a[f]=i(this[f],d);a.t=this.t}else{for(d=this.s&this.DM,f=b;f<o.t;++f)a[f]=i(d,o[f]);a.t=o.t}a.s=i(this.s,o.s),a.clamp()}function Qi(o,i){return o&i}function Yi(o){var i=s();return this.bitwiseTo(o,Qi,i),i}function ur(o,i){return o|i}function Ki(o){var i=s();return this.bitwiseTo(o,ur,i),i}function Qn(o,i){return o^i}function ta(o){var i=s();return this.bitwiseTo(o,Qn,i),i}function Yn(o,i){return o&~i}function ea(o){var i=s();return this.bitwiseTo(o,Yn,i),i}function ra(){for(var o=s(),i=0;i<this.t;++i)o[i]=this.DM&~this[i];return o.t=this.t,o.s=~this.s,o}function na(o){var i=s();return o<0?this.rShiftTo(-o,i):this.lShiftTo(o,i),i}function sa(o){var i=s();return o<0?this.lShiftTo(-o,i):this.rShiftTo(o,i),i}function oa(o){if(o==0)return-1;var i=0;return o&65535||(o>>=16,i+=16),o&255||(o>>=8,i+=8),o&15||(o>>=4,i+=4),o&3||(o>>=2,i+=2),o&1||++i,i}function ia(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+oa(this[o]);return this.s<0?this.t*this.DB:-1}function aa(o){for(var i=0;o!=0;)o&=o-1,++i;return i}function ca(){for(var o=0,i=this.s&this.DM,a=0;a<this.t;++a)o+=aa(this[a]^i);return o}function fa(o){var i=Math.floor(o/this.DB);return i>=this.t?this.s!=0:(this[i]&1<<o%this.DB)!=0}function ua(o,i){var a=n.ONE.shiftLeft(o);return this.bitwiseTo(a,i,a),a}function pa(o){return this.changeBit(o,ur)}function la(o){return this.changeBit(o,Yn)}function ha(o){return this.changeBit(o,Qn)}function da(o,i){for(var a=0,f=0,d=Math.min(o.t,this.t);a<d;)f+=this[a]+o[a],i[a++]=f&this.DM,f>>=this.DB;if(o.t<this.t){for(f+=o.s;a<this.t;)f+=this[a],i[a++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;a<o.t;)f+=o[a],i[a++]=f&this.DM,f>>=this.DB;f+=o.s}i.s=f<0?-1:0,f>0?i[a++]=f:f<-1&&(i[a++]=this.DV+f),i.t=a,i.clamp()}function ma(o){var i=s();return this.addTo(o,i),i}function ba(o){var i=s();return this.subTo(o,i),i}function ga(o){var i=s();return this.multiplyTo(o,i),i}function wa(){var o=s();return this.squareTo(o),o}function ya(o){var i=s();return this.divRemTo(o,i,null),i}function va(o){var i=s();return this.divRemTo(o,null,i),i}function xa(o){var i=s(),a=s();return this.divRemTo(o,i,a),new Array(i,a)}function Sa(o){this[this.t]=this.am(0,o-1,this,0,0,this.t),++this.t,this.clamp()}function Ta(o,i){if(o!=0){for(;this.t<=i;)this[this.t++]=0;for(this[i]+=o;this[i]>=this.DV;)this[i]-=this.DV,++i>=this.t&&(this[this.t++]=0),++this[i]}}function ge(){}function Kn(o){return o}function Ea(o,i,a){o.multiplyTo(i,a)}function Aa(o,i){o.squareTo(i)}ge.prototype.convert=Kn,ge.prototype.revert=Kn,ge.prototype.mulTo=Ea,ge.prototype.sqrTo=Aa;function Ca(o){return this.exp(o,new ge)}function Ia(o,i,a){var f=Math.min(this.t+o.t,i);for(a.s=0,a.t=f;f>0;)a[--f]=0;var d;for(d=a.t-this.t;f<d;++f)a[f+this.t]=this.am(0,o[f],a,f,0,this.t);for(d=Math.min(o.t,i);f<d;++f)this.am(0,o[f],a,f,0,i-f);a.clamp()}function Ba(o,i,a){--i;var f=a.t=this.t+o.t-i;for(a.s=0;--f>=0;)a[f]=0;for(f=Math.max(i-this.t,0);f<o.t;++f)a[this.t+f-i]=this.am(i-f,o[f],a,0,0,this.t+f-i);a.clamp(),a.drShiftTo(1,a)}function Lt(o){this.r2=s(),this.q3=s(),n.ONE.dlShiftTo(2*o.t,this.r2),this.mu=this.r2.divide(o),this.m=o}function Ra(o){if(o.s<0||o.t>2*this.m.t)return o.mod(this.m);if(o.compareTo(this.m)<0)return o;var i=s();return o.copyTo(i),this.reduce(i),i}function Ma(o){return o}function Da(o){for(o.drShiftTo(this.m.t-1,this.r2),o.t>this.m.t+1&&(o.t=this.m.t+1,o.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);o.compareTo(this.r2)<0;)o.dAddOffset(1,this.m.t+1);for(o.subTo(this.r2,o);o.compareTo(this.m)>=0;)o.subTo(this.m,o)}function ka(o,i){o.squareTo(i),this.reduce(i)}function Pa(o,i,a){o.multiplyTo(i,a),this.reduce(a)}Lt.prototype.convert=Ra,Lt.prototype.revert=Ma,Lt.prototype.reduce=Da,Lt.prototype.mulTo=Pa,Lt.prototype.sqrTo=ka;function Oa(o,i){var a=o.bitLength(),f,d=A(1),b;if(a<=0)return d;a<18?f=1:a<48?f=3:a<144?f=4:a<768?f=5:f=6,a<8?b=new Ut(i):i.isEven()?b=new Lt(i):b=new _t(i);var y=new Array,S=3,F=f-1,J=(1<<f)-1;if(y[1]=b.convert(this),f>1){var ut=s();for(b.sqrTo(y[1],ut);S<=J;)y[S]=s(),b.mulTo(ut,y[S-2],y[S]),S+=2}var it=o.t-1,Tt,Re=!0,dt=s(),mt;for(a=j(o[it])-1;it>=0;){for(a>=F?Tt=o[it]>>a-F&J:(Tt=(o[it]&(1<<a+1)-1)<<F-a,it>0&&(Tt|=o[it-1]>>this.DB+a-F)),S=f;!(Tt&1);)Tt>>=1,--S;if((a-=S)<0&&(a+=this.DB,--it),Re)y[Tt].copyTo(d),Re=!1;else{for(;S>1;)b.sqrTo(d,dt),b.sqrTo(dt,d),S-=2;S>0?b.sqrTo(d,dt):(mt=d,d=dt,dt=mt),b.mulTo(dt,y[Tt],d)}for(;it>=0&&!(o[it]&1<<a);)b.sqrTo(d,dt),mt=d,d=dt,dt=mt,--a<0&&(a=this.DB-1,--it)}return b.revert(d)}function Na(o){var i=this.s<0?this.negate():this.clone(),a=o.s<0?o.negate():o.clone();if(i.compareTo(a)<0){var f=i;i=a,a=f}var d=i.getLowestSetBit(),b=a.getLowestSetBit();if(b<0)return i;for(d<b&&(b=d),b>0&&(i.rShiftTo(b,i),a.rShiftTo(b,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 b>0&&a.lShiftTo(b,a),a}function Fa(o){if(o<=0)return 0;var i=this.DV%o,a=this.s<0?o-1:0;if(this.t>0)if(i==0)a=this[0]%o;else for(var f=this.t-1;f>=0;--f)a=(i*a+this[f])%o;return a}function Ua(o){var i=o.isEven();if(this.isEven()&&i||o.signum()==0)return n.ZERO;for(var a=o.clone(),f=this.clone(),d=A(1),b=A(0),y=A(0),S=A(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),i?((!d.isEven()||!b.isEven())&&(d.addTo(this,d),b.subTo(o,b)),d.rShiftTo(1,d)):b.isEven()||b.subTo(o,b),b.rShiftTo(1,b);for(;f.isEven();)f.rShiftTo(1,f),i?((!y.isEven()||!S.isEven())&&(y.addTo(this,y),S.subTo(o,S)),y.rShiftTo(1,y)):S.isEven()||S.subTo(o,S),S.rShiftTo(1,S);a.compareTo(f)>=0?(a.subTo(f,a),i&&d.subTo(y,d),b.subTo(S,b)):(f.subTo(a,f),i&&y.subTo(d,y),S.subTo(b,S))}if(f.compareTo(n.ONE)!=0)return n.ZERO;if(S.compareTo(o)>=0)return S.subtract(o);if(S.signum()<0)S.addTo(o,S);else return S;return S.signum()<0?S.add(o):S}var et=[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],_a=(1<<26)/et[et.length-1];function La(o){var i,a=this.abs();if(a.t==1&&a[0]<=et[et.length-1]){for(i=0;i<et.length;++i)if(a[0]==et[i])return!0;return!1}if(a.isEven())return!1;for(i=1;i<et.length;){for(var f=et[i],d=i+1;d<et.length&&f<_a;)f*=et[d++];for(f=a.modInt(f);i<d;)if(f%et[i++]==0)return!1}return a.millerRabin(o)}function $a(o){var i=this.subtract(n.ONE),a=i.getLowestSetBit();if(a<=0)return!1;var f=i.shiftRight(a);o=o+1>>1,o>et.length&&(o=et.length);for(var d=s(),b=0;b<o;++b){d.fromInt(et[Math.floor(Math.random()*et.length)]);var y=d.modPow(f,this);if(y.compareTo(n.ONE)!=0&&y.compareTo(i)!=0){for(var S=1;S++<a&&y.compareTo(i)!=0;)if(y=y.modPowInt(2,this),y.compareTo(n.ONE)==0)return!1;if(y.compareTo(i)!=0)return!1}}return!0}n.prototype.chunkSize=zi,n.prototype.toRadix=ji,n.prototype.fromRadix=qi,n.prototype.fromNumber=Gi,n.prototype.bitwiseTo=Wi,n.prototype.changeBit=ua,n.prototype.addTo=da,n.prototype.dMultiply=Sa,n.prototype.dAddOffset=Ta,n.prototype.multiplyLowerTo=Ia,n.prototype.multiplyUpperTo=Ba,n.prototype.modInt=Fa,n.prototype.millerRabin=$a,n.prototype.clone=Ui,n.prototype.intValue=_i,n.prototype.byteValue=Li,n.prototype.shortValue=$i,n.prototype.signum=Vi,n.prototype.toByteArray=Hi,n.prototype.equals=Zi,n.prototype.min=Ji,n.prototype.max=Xi,n.prototype.and=Yi,n.prototype.or=Ki,n.prototype.xor=ta,n.prototype.andNot=ea,n.prototype.not=ra,n.prototype.shiftLeft=na,n.prototype.shiftRight=sa,n.prototype.getLowestSetBit=ia,n.prototype.bitCount=ca,n.prototype.testBit=fa,n.prototype.setBit=pa,n.prototype.clearBit=la,n.prototype.flipBit=ha,n.prototype.add=ma,n.prototype.subtract=ba,n.prototype.multiply=ga,n.prototype.divide=ya,n.prototype.remainder=va,n.prototype.divideAndRemainder=xa,n.prototype.modPow=Oa,n.prototype.modInverse=Ua,n.prototype.pow=Ca,n.prototype.gcd=Na,n.prototype.isProbablePrime=La,n.prototype.square=wa,n.prototype.Barrett=Lt;var Be,ot,Z;function za(o){ot[Z++]^=o&255,ot[Z++]^=o>>8&255,ot[Z++]^=o>>16&255,ot[Z++]^=o>>24&255,Z>=hr&&(Z-=hr)}function ts(){za(new Date().getTime())}if(ot==null){ot=new Array,Z=0;var ht;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var es=new Uint8Array(32);for(window.crypto.getRandomValues(es),ht=0;ht<32;++ht)ot[Z++]=es[ht]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var rs=window.crypto.random(32);for(ht=0;ht<rs.length;++ht)ot[Z++]=rs.charCodeAt(ht)&255}}for(;Z<hr;)ht=Math.floor(65536*Math.random()),ot[Z++]=ht>>>8,ot[Z++]=ht&255;Z=0,ts()}function Va(){if(Be==null){for(ts(),Be=Ha(),Be.init(ot),Z=0;Z<ot.length;++Z)ot[Z]=0;Z=0}return Be.next()}function ja(o){var i;for(i=0;i<o.length;++i)o[i]=Va()}function pr(){}pr.prototype.nextBytes=ja;function lr(){this.i=0,this.j=0,this.S=new Array}function qa(o){var i,a,f;for(i=0;i<256;++i)this.S[i]=i;for(a=0,i=0;i<256;++i)a=a+this.S[i]+o[i%o.length]&255,f=this.S[i],this.S[i]=this.S[a],this.S[a]=f;this.i=0,this.j=0}function Ga(){var o;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,o=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=o,this.S[o+this.S[this.i]&255]}lr.prototype.init=qa,lr.prototype.next=Ga;function Ha(){return new lr}var hr=256;typeof rr<"u"?rr=qo.exports={default:n,BigInteger:n,SecureRandom:pr}:this.jsbn={BigInteger:n,SecureRandom:pr}}).call(rr)});var Ie=H(nr=>{(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(u){return n(c(u),arguments)}function e(u,h){return t.apply(null,[u].concat(h||[]))}function n(u,h){var m=1,I=u.length,p,g="",w,E,l,x,R,T,A,M;for(w=0;w<I;w++)if(typeof u[w]=="string")g+=u[w];else if(typeof u[w]=="object"){if(l=u[w],l.keys)for(p=h[m],E=0;E<l.keys.length;E++){if(p==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',l.keys[E],l.keys[E-1]));p=p[l.keys[E]]}else l.param_no?p=h[l.param_no]:p=h[m++];if(r.not_type.test(l.type)&&r.not_primitive.test(l.type)&&p instanceof Function&&(p=p()),r.numeric_arg.test(l.type)&&typeof p!="number"&&isNaN(p))throw new TypeError(t("[sprintf] expecting number but found %T",p));switch(r.number.test(l.type)&&(A=p>=0),l.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,l.width?parseInt(l.width):0);break;case"e":p=l.precision?parseFloat(p).toExponential(l.precision):parseFloat(p).toExponential();break;case"f":p=l.precision?parseFloat(p).toFixed(l.precision):parseFloat(p);break;case"g":p=l.precision?String(Number(p.toPrecision(l.precision))):parseFloat(p);break;case"o":p=(parseInt(p,10)>>>0).toString(8);break;case"s":p=String(p),p=l.precision?p.substring(0,l.precision):p;break;case"t":p=String(!!p),p=l.precision?p.substring(0,l.precision):p;break;case"T":p=Object.prototype.toString.call(p).slice(8,-1).toLowerCase(),p=l.precision?p.substring(0,l.precision):p;break;case"u":p=parseInt(p,10)>>>0;break;case"v":p=p.valueOf(),p=l.precision?p.substring(0,l.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(l.type)?g+=p:(r.number.test(l.type)&&(!A||l.sign)?(M=A?"+":"-",p=p.toString().replace(r.sign,"")):M="",R=l.pad_char?l.pad_char==="0"?"0":l.pad_char.charAt(1):" ",T=l.width-(M+p).length,x=l.width&&T>0?R.repeat(T):"",g+=l.align?M+p+x:R==="0"?M+x+p:x+M+p)}return g}var s=Object.create(null);function c(u){if(s[u])return s[u];for(var h=u,m,I=[],p=0;h;){if((m=r.text.exec(h))!==null)I.push(m[0]);else if((m=r.modulo.exec(h))!==null)I.push("%");else if((m=r.placeholder.exec(h))!==null){if(m[2]){p|=1;var g=[],w=m[2],E=[];if((E=r.key.exec(w))!==null)for(g.push(E[1]);(w=w.substring(E[0].length))!=="";)if((E=r.key_access.exec(w))!==null)g.push(E[1]);else if((E=r.index_access.exec(w))!==null)g.push(E[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");m[2]=g}else p|=2;if(p===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");I.push({placeholder:m[0],param_no:m[1],keys:m[2],sign:m[3],pad_char:m[4],align:m[5],width:m[6],precision:m[7],type:m[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");h=h.substring(m[0].length)}return s[u]=I}typeof nr<"u"&&(nr.sprintf=t,nr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var ar=H((d0,ei)=>{ei.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 ni=H((m0,ri)=>{ri.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 qn=H((b0,si)=>{var jp=ni();si.exports=r=>async t=>{t=jp(t);let e=T=>{typeof T.return=="function"&&T.return()},n=null,s=null,c=T=>{n=T,s&&s(T),e(t)},u=null,h=!1,m=()=>{h=!0,u&&u()},I=null,p=!1,g=()=>{p=!0,I&&I()},w=null,E=()=>{w&&w()},l=()=>new Promise((T,A)=>{u=w=T,s=A,r.once("drain",E)}),x=()=>(e(t),new Promise((T,A)=>{if(h||p||n)return T();I=u=T,s=A})),R=()=>{r.removeListener("error",c),r.removeListener("close",m),r.removeListener("finish",g),r.removeListener("drain",E)};r.once("error",c),r.once("close",m),r.once("finish",g);try{for await(let T of t){if(!r.writable||r.destroyed||n)break;r.write(T)===!1&&await l()}}catch(T){n||r.destroy(),n=T}try{if(r.writable&&r.end(),await x(),n)throw n}finally{R()}}});var Gn=H((g0,oi)=>{var qp=qn(),Gp=ar();oi.exports=r=>({sink:qp(r),source:Gp(r)})});var ai=H((w0,ii)=>{var Hp=Gn();ii.exports=r=>async function*(t){let e=Hp(r),n;if(e.sink(t).catch(s=>{n=s}),yield*e.source,n)throw n}});var ci=H((y0,me)=>{me.exports=ar();me.exports.source=ar();me.exports.sink=qn();me.exports.transform=ai();me.exports.duplex=Gn()});var sl={};U(sl,{tcp:()=>nl});var li=X(wt("net"),1);var ke=class extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=ke.code,this.type=ke.type}},Mt=ke;De(Mt,"code","ABORT_ERR"),De(Mt,"type","aborted");var bt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var os=Symbol.for("@libp2p/transport");var ss;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(ss||(ss={}));var ct=X(bs(),1);function Tc(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 s=0;s<r.length;s++){var c=r.charAt(s),u=c.charCodeAt(0);if(e[u]!==255)throw new TypeError(c+" is ambiguous");e[u]=s}var h=r.length,m=r.charAt(0),I=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,R=0,T=0,A=l.length;T!==A&&l[T]===0;)T++,x++;for(var M=(A-T)*p+1>>>0,B=new Uint8Array(M);T!==A;){for(var k=l[T],O=0,D=M-1;(k!==0||O<R)&&D!==-1;D--,O++)k+=256*B[D]>>>0,B[D]=k%h>>>0,k=k/h>>>0;if(k!==0)throw new Error("Non-zero carry");R=O,T++}for(var P=M-R;P!==M&&B[P]===0;)P++;for(var j=m.repeat(x);P<M;++P)j+=r.charAt(B[P]);return j}function w(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var R=0,T=0;l[x]===m;)R++,x++;for(var A=(l.length-x)*I+1>>>0,M=new Uint8Array(A);l[x];){var B=e[l.charCodeAt(x)];if(B===255)return;for(var k=0,O=A-1;(B!==0||k<T)&&O!==-1;O--,k++)B+=h*M[O]>>>0,M[O]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");T=k,x++}if(l[x]!==" "){for(var D=A-T;D!==A&&M[D]===0;)D++;for(var P=new Uint8Array(R+(A-D)),j=R;D!==A;)P[j++]=M[D++];return P}}}function E(l){var x=w(l);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:E}}var Ec=Tc,Ac=Ec,gs=Ac;var ml=new Uint8Array(0);var ws=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 wr=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")}},yr=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 ys(this,t)}},vr=class{constructor(t){this.decoders=t}or(t){return ys(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`)}},ys=(r,t)=>new vr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),xr=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new wr(t,e,n),this.decoder=new yr(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},vs=({name:r,prefix:t,encode:e,decode:n})=>new xr(r,t,e,n),Sr=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:s}=gs(e,t);return vs({prefix:r,name:t,encode:n,decode:c=>ws(s(c))})},Cc=(r,t,e,n)=>{let s={};for(let p=0;p<t.length;++p)s[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*e/8|0),h=0,m=0,I=0;for(let p=0;p<c;++p){let g=s[r[p]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<e|g,h+=e,h>=8&&(h-=8,u[I++]=255&m>>h)}if(h>=e||255&m<<8-h)throw new SyntaxError("Unexpected end of data");return u},Ic=(r,t,e)=>{let n=t[t.length-1]==="=",s=(1<<e)-1,c="",u=0,h=0;for(let m=0;m<r.length;++m)for(h=h<<8|r[m],u+=8;u>e;)u-=e,c+=t[s&h>>u];if(u&&(c+=t[s&h<<e-u]),n)for(;c.length*e&7;)c+="=";return c},rt=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>vs({prefix:t,name:r,encode(s){return Ic(s,n,e)},decode(s){return Cc(s,n,e,r)}});var xs=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xl=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Sl=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tl=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),El=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Al=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cl=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Il=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bl=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ss=Sr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dl=Sr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ts=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ol=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nl=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fl=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});ct.default.formatters.b=r=>r==null?"undefined":Ss.baseEncode(r);ct.default.formatters.t=r=>r==null?"undefined":xs.baseEncode(r);ct.default.formatters.m=r=>r==null?"undefined":Ts.baseEncode(r);ct.default.formatters.p=r=>r==null?"undefined":r.toString();ct.default.formatters.c=r=>r==null?"undefined":r.toString();ct.default.formatters.k=r=>r==null?"undefined":r.toString();ct.default.formatters.a=r=>r==null?"undefined":r.toString();function Bc(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 Dt(r){let t=Bc(`${r}:trace`);return ct.default.enabled(`${r}:trace`)&&ct.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,ct.default)(`${r}:trace`)),Object.assign((0,ct.default)(r),{error:(0,ct.default)(`${r}:error`),trace:t})}var Ue=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Ir={};U(Ir,{base58btc:()=>nt,base58flickr:()=>Oc});function Rc(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 s=0;s<r.length;s++){var c=r.charAt(s),u=c.charCodeAt(0);if(e[u]!==255)throw new TypeError(c+" is ambiguous");e[u]=s}var h=r.length,m=r.charAt(0),I=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,R=0,T=0,A=l.length;T!==A&&l[T]===0;)T++,x++;for(var M=(A-T)*p+1>>>0,B=new Uint8Array(M);T!==A;){for(var k=l[T],O=0,D=M-1;(k!==0||O<R)&&D!==-1;D--,O++)k+=256*B[D]>>>0,B[D]=k%h>>>0,k=k/h>>>0;if(k!==0)throw new Error("Non-zero carry");R=O,T++}for(var P=M-R;P!==M&&B[P]===0;)P++;for(var j=m.repeat(x);P<M;++P)j+=r.charAt(B[P]);return j}function w(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var R=0,T=0;l[x]===m;)R++,x++;for(var A=(l.length-x)*I+1>>>0,M=new Uint8Array(A);l[x];){var B=e[l.charCodeAt(x)];if(B===255)return;for(var k=0,O=A-1;(B!==0||k<T)&&O!==-1;O--,k++)B+=h*M[O]>>>0,M[O]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");T=k,x++}if(l[x]!==" "){for(var D=A-T;D!==A&&M[D]===0;)D++;for(var P=new Uint8Array(R+(A-D)),j=R;D!==A;)P[j++]=M[D++];return P}}}function E(l){var x=w(l);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:E}}var Mc=Rc,Dc=Mc,Es=Dc;var Gl=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},pt=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),Is=r=>new TextDecoder().decode(r);var Tr=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")}},Er=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 Rs(this,t)}},Ar=class{constructor(t){this.decoders=t}or(t){return Rs(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`)}},Rs=(r,t)=>new Ar({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Cr=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new Tr(t,e,n),this.decoder=new Er(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Kt=({name:r,prefix:t,encode:e,decode:n})=>new Cr(r,t,e,n),kt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:s}=Es(e,t);return Kt({prefix:r,name:t,encode:n,decode:c=>pt(s(c))})},kc=(r,t,e,n)=>{let s={};for(let p=0;p<t.length;++p)s[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*e/8|0),h=0,m=0,I=0;for(let p=0;p<c;++p){let g=s[r[p]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<e|g,h+=e,h>=8&&(h-=8,u[I++]=255&m>>h)}if(h>=e||255&m<<8-h)throw new SyntaxError("Unexpected end of data");return u},Pc=(r,t,e)=>{let n=t[t.length-1]==="=",s=(1<<e)-1,c="",u=0,h=0;for(let m=0;m<r.length;++m)for(h=h<<8|r[m],u+=8;u>e;)u-=e,c+=t[s&h>>u];if(u&&(c+=t[s&h<<e-u]),n)for(;c.length*e&7;)c+="=";return c},$=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Kt({prefix:t,name:r,encode(s){return Pc(s,n,e)},decode(s){return kc(s,n,e,r)}});var nt=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Oc=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nc=ks,Ms=128,Fc=127,Uc=~Fc,_c=Math.pow(2,31);function ks(r,t,e){t=t||[],e=e||0;for(var n=e;r>=_c;)t[e++]=r&255|Ms,r/=128;for(;r&Uc;)t[e++]=r&255|Ms,r>>>=7;return t[e]=r|0,ks.bytes=e-n+1,t}var Lc=Br,$c=128,Ds=127;function Br(r,n){var e=0,n=n||0,s=0,c=n,u,h=r.length;do{if(c>=h)throw Br.bytes=0,new RangeError("Could not decode varint");u=r[c++],e+=s<28?(u&Ds)<<s:(u&Ds)*Math.pow(2,s),s+=7}while(u>=$c);return Br.bytes=c-n,e}var zc=Math.pow(2,7),Vc=Math.pow(2,14),jc=Math.pow(2,21),qc=Math.pow(2,28),Gc=Math.pow(2,35),Hc=Math.pow(2,42),Zc=Math.pow(2,49),Jc=Math.pow(2,56),Xc=Math.pow(2,63),Wc=function(r){return r<zc?1:r<Vc?2:r<jc?3:r<qc?4:r<Gc?5:r<Hc?6:r<Zc?7:r<Jc?8:r<Xc?9:10},Qc={encode:Nc,decode:Lc,encodingLength:Wc},Yc=Qc,ye=Yc;var ve=(r,t=0)=>[ye.decode(r,t),ye.decode.bytes],te=(r,t,e=0)=>(ye.encode(r,t,e),t),ee=r=>ye.encodingLength(r);var zt=(r,t)=>{let e=t.byteLength,n=ee(r),s=n+ee(e),c=new Uint8Array(s+e);return te(r,c,0),te(e,c,n),c.set(t,s),new re(r,e,t,c)},Le=r=>{let t=pt(r),[e,n]=ve(t),[s,c]=ve(t.subarray(n)),u=t.subarray(n+c);if(u.byteLength!==s)throw new Error("Incorrect length");return new re(e,s,u,t)},Ps=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&As(r.bytes,e.bytes)}},re=class{constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Rr={};U(Rr,{base32:()=>Et,base32hex:()=>rf,base32hexpad:()=>sf,base32hexpadupper:()=>of,base32hexupper:()=>nf,base32pad:()=>tf,base32padupper:()=>ef,base32upper:()=>Kc,base32z:()=>af});var Et=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Kc=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tf=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ef=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rf=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nf=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),sf=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),of=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),af=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Os=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return ff(e,Mr(r),t||nt.encoder);default:return uf(e,Mr(r),t||Et.encoder)}};var Ns=new WeakMap,Mr=r=>{let t=Ns.get(r);if(t==null){let e=new Map;return Ns.set(r,e),e}return t},_=class{constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}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!==pf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return _.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=zt(t,e);return _.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 _.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Ps(t.multihash,n.multihash)}toString(t){return Os(this,t)}toJSON(){return{"/":Os(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 _)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:c,bytes:u}=e;return new _(n,s,c,u||Fs(n,s,c.bytes))}else if(e[lf]===!0){let{version:n,multihash:s,code:c}=e,u=Le(s);return _.create(n,c,u)}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 _(t,e,n,n.bytes)}case 1:{let s=Fs(t,e,n.bytes);return new _(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return _.create(0,xe,t)}static createV1(t,e){return _.create(1,t,e)}static decode(t){let[e,n]=_.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=_.inspectBytes(t),n=e.size-e.multihashSize,s=pt(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let c=s.subarray(e.multihashSize-e.digestSize),u=new re(e.multihashCode,e.digestSize,c,s);return[e.version===0?_.createV0(u):_.createV1(e.codec,u),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=ve(t.subarray(e));return e+=w,g},s=n(),c=xe;if(s===18?(s=0,e=0):c=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let u=e,h=n(),m=n(),I=e+m,p=I-u;return{version:s,codec:c,multihashCode:h,digestSize:m,multihashSize:p,size:I}}static parse(t,e){let[n,s]=cf(t,e),c=_.decode(s);if(c.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Mr(c).set(n,t),c}},cf=(r,t)=>{switch(r[0]){case"Q":{let e=t||nt;return[nt.prefix,e.decode(`${nt.prefix}${r}`)]}case nt.prefix:{let e=t||nt;return[nt.prefix,e.decode(r)]}case Et.prefix:{let e=t||Et;return[Et.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)]}}},ff=(r,t,e)=>{let{prefix:n}=e;if(n!==nt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let c=e.encode(r).slice(1);return t.set(n,c),c}else return s},uf=(r,t,e)=>{let{prefix:n}=e,s=t.get(n);if(s==null){let c=e.encode(r);return t.set(n,c),c}else return s},xe=112,pf=18,Fs=(r,t,e)=>{let n=ee(r),s=n+ee(t),c=new Uint8Array(s+e.byteLength);return te(r,c,0),te(t,c,n),c.set(e,s),c},lf=Symbol.for("@ipld/js-cid/CID");function Us(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 Nr={};U(Nr,{identity:()=>wf});function hf(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 s=0;s<r.length;s++){var c=r.charAt(s),u=c.charCodeAt(0);if(e[u]!==255)throw new TypeError(c+" is ambiguous");e[u]=s}var h=r.length,m=r.charAt(0),I=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,R=0,T=0,A=l.length;T!==A&&l[T]===0;)T++,x++;for(var M=(A-T)*p+1>>>0,B=new Uint8Array(M);T!==A;){for(var k=l[T],O=0,D=M-1;(k!==0||O<R)&&D!==-1;D--,O++)k+=256*B[D]>>>0,B[D]=k%h>>>0,k=k/h>>>0;if(k!==0)throw new Error("Non-zero carry");R=O,T++}for(var P=M-R;P!==M&&B[P]===0;)P++;for(var j=m.repeat(x);P<M;++P)j+=r.charAt(B[P]);return j}function w(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var R=0,T=0;l[x]===m;)R++,x++;for(var A=(l.length-x)*I+1>>>0,M=new Uint8Array(A);l[x];){var B=e[l.charCodeAt(x)];if(B===255)return;for(var k=0,O=A-1;(B!==0||k<T)&&O!==-1;O--,k++)B+=h*M[O]>>>0,M[O]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");T=k,x++}if(l[x]!==" "){for(var D=A-T;D!==A&&M[D]===0;)D++;for(var P=new Uint8Array(R+(A-D)),j=R;D!==A;)P[j++]=M[D++];return P}}}function E(l){var x=w(l);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:E}}var df=hf,mf=df,_s=mf;var ah=new Uint8Array(0);var Ls=(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},lt=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 $s=r=>new TextEncoder().encode(r),zs=r=>new TextDecoder().decode(r);var Dr=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")}},kr=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 js(this,t)}},Pr=class{constructor(t){this.decoders=t}or(t){return js(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`)}},js=(r,t)=>new Pr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Or=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new Dr(t,e,n),this.decoder=new kr(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},se=({name:r,prefix:t,encode:e,decode:n})=>new Or(r,t,e,n),Pt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:s}=_s(e,t);return se({prefix:r,name:t,encode:n,decode:c=>lt(s(c))})},bf=(r,t,e,n)=>{let s={};for(let p=0;p<t.length;++p)s[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*e/8|0),h=0,m=0,I=0;for(let p=0;p<c;++p){let g=s[r[p]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<e|g,h+=e,h>=8&&(h-=8,u[I++]=255&m>>h)}if(h>=e||255&m<<8-h)throw new SyntaxError("Unexpected end of data");return u},gf=(r,t,e)=>{let n=t[t.length-1]==="=",s=(1<<e)-1,c="",u=0,h=0;for(let m=0;m<r.length;++m)for(h=h<<8|r[m],u+=8;u>e;)u-=e,c+=t[s&h>>u];if(u&&(c+=t[s&h<<e-u]),n)for(;c.length*e&7;)c+="=";return c},z=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>se({prefix:t,name:r,encode(s){return gf(s,n,e)},decode(s){return bf(s,n,e,r)}});var wf=se({prefix:"\0",name:"identity",encode:r=>zs(r),decode:r=>$s(r)});var Fr={};U(Fr,{base2:()=>yf});var yf=z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ur={};U(Ur,{base8:()=>vf});var vf=z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _r={};U(_r,{base10:()=>xf});var xf=Pt({prefix:"9",name:"base10",alphabet:"0123456789"});var Lr={};U(Lr,{base16:()=>Sf,base16upper:()=>Tf});var Sf=z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Tf=z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $r={};U($r,{base32:()=>oe,base32hex:()=>If,base32hexpad:()=>Rf,base32hexpadupper:()=>Mf,base32hexupper:()=>Bf,base32pad:()=>Af,base32padupper:()=>Cf,base32upper:()=>Ef,base32z:()=>Df});var oe=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ef=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Af=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Cf=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),If=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Bf=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rf=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mf=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Df=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zr={};U(zr,{base36:()=>kf,base36upper:()=>Pf});var kf=Pt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pf=Pt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vr={};U(Vr,{base58btc:()=>yt,base58flickr:()=>Of});var yt=Pt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Of=Pt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jr={};U(jr,{base64:()=>Nf,base64pad:()=>Ff,base64url:()=>Uf,base64urlpad:()=>_f});var Nf=z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ff=z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Uf=z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_f=z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qr={};U(qr,{base256emoji:()=>jf});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}"),Lf=qs.reduce((r,t,e)=>(r[e]=t,r),[]),$f=qs.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function zf(r){return r.reduce((t,e)=>(t+=Lf[e],t),"")}function Vf(r){let t=[];for(let e of r){let n=$f[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var jf=se({prefix:"\u{1F680}",name:"base256emoji",encode:zf,decode:Vf});var Xr={};U(Xr,{sha256:()=>cu,sha512:()=>fu});var Jr=X(wt("crypto"),1);var qf=Zs,Gs=128,Gf=127,Hf=~Gf,Zf=Math.pow(2,31);function Zs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Zf;)t[e++]=r&255|Gs,r/=128;for(;r&Hf;)t[e++]=r&255|Gs,r>>>=7;return t[e]=r|0,Zs.bytes=e-n+1,t}var Jf=Gr,Xf=128,Hs=127;function Gr(r,n){var e=0,n=n||0,s=0,c=n,u,h=r.length;do{if(c>=h)throw Gr.bytes=0,new RangeError("Could not decode varint");u=r[c++],e+=s<28?(u&Hs)<<s:(u&Hs)*Math.pow(2,s),s+=7}while(u>=Xf);return Gr.bytes=c-n,e}var Wf=Math.pow(2,7),Qf=Math.pow(2,14),Yf=Math.pow(2,21),Kf=Math.pow(2,28),tu=Math.pow(2,35),eu=Math.pow(2,42),ru=Math.pow(2,49),nu=Math.pow(2,56),su=Math.pow(2,63),ou=function(r){return r<Wf?1:r<Qf?2:r<Yf?3:r<Kf?4:r<tu?5:r<eu?6:r<ru?7:r<nu?8:r<su?9:10},iu={encode:qf,decode:Jf,encodingLength:ou},au=iu,Se=au;var Te=(r,t=0)=>[Se.decode(r,t),Se.decode.bytes],ie=(r,t,e=0)=>(Se.encode(r,t,e),t),ae=r=>Se.encodingLength(r);var Vt=(r,t)=>{let e=t.byteLength,n=ae(r),s=n+ae(e),c=new Uint8Array(s+e);return ie(r,c,0),ie(e,c,n),c.set(t,s),new ce(r,e,t,c)},Js=r=>{let t=lt(r),[e,n]=Te(t),[s,c]=Te(t.subarray(n)),u=t.subarray(n+c);if(u.byteLength!==s)throw new Error("Incorrect length");return new ce(e,s,u,t)},Xs=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ls(r.bytes,e.bytes)}},ce=class{constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Zr=({name:r,code:t,encode:e})=>new Hr(r,t,e),Hr=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?Vt(this.code,e):e.then(n=>Vt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var cu=Zr({name:"sha2-256",code:18,encode:r=>lt(Jr.default.createHash("sha256").update(r).digest())}),fu=Zr({name:"sha2-512",code:19,encode:r=>lt(Jr.default.createHash("sha512").update(r).digest())});var Wr={};U(Wr,{identity:()=>lu});var Qs=0,uu="identity",Ys=lt,pu=r=>Vt(Qs,Ys(r)),lu={code:Qs,name:uu,encode:Ys,digest:pu};var Rh=new TextEncoder,Mh=new TextDecoder;var Ks=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return bu(e,Qr(r),t||yt.encoder);default:return gu(e,Qr(r),t||oe.encoder)}};var to=new WeakMap,Qr=r=>{let t=to.get(r);if(t==null){let e=new Map;return to.set(r,e),e}return t},G=class{constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}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!==Ae)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==wu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return G.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=Vt(t,e);return G.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 G.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Xs(t.multihash,n.multihash)}toString(t){return Ks(this,t)}toJSON(){return{"/":Ks(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 G)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:c,bytes:u}=e;return new G(n,s,c,u||eo(n,s,c.bytes))}else if(e[yu]===!0){let{version:n,multihash:s,code:c}=e,u=Js(s);return G.create(n,c,u)}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!==Ae)throw new Error(`Version 0 CID must use dag-pb (code: ${Ae}) block encoding`);return new G(t,e,n,n.bytes)}case 1:{let s=eo(t,e,n.bytes);return new G(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return G.create(0,Ae,t)}static createV1(t,e){return G.create(1,t,e)}static decode(t){let[e,n]=G.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=G.inspectBytes(t),n=e.size-e.multihashSize,s=lt(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let c=s.subarray(e.multihashSize-e.digestSize),u=new ce(e.multihashCode,e.digestSize,c,s);return[e.version===0?G.createV0(u):G.createV1(e.codec,u),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=Te(t.subarray(e));return e+=w,g},s=n(),c=Ae;if(s===18?(s=0,e=0):c=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let u=e,h=n(),m=n(),I=e+m,p=I-u;return{version:s,codec:c,multihashCode:h,digestSize:m,multihashSize:p,size:I}}static parse(t,e){let[n,s]=mu(t,e),c=G.decode(s);if(c.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Qr(c).set(n,t),c}},mu=(r,t)=>{switch(r[0]){case"Q":{let e=t||yt;return[yt.prefix,e.decode(`${yt.prefix}${r}`)]}case yt.prefix:{let e=t||yt;return[yt.prefix,e.decode(r)]}case oe.prefix:{let e=t||oe;return[oe.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)]}}},bu=(r,t,e)=>{let{prefix:n}=e;if(n!==yt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let c=e.encode(r).slice(1);return t.set(n,c),c}else return s},gu=(r,t,e)=>{let{prefix:n}=e,s=t.get(n);if(s==null){let c=e.encode(r);return t.set(n,c),c}else return s},Ae=112,wu=18,eo=(r,t,e)=>{let n=ae(r),s=n+ae(t),c=new Uint8Array(s+e.byteLength);return ie(r,c,0),ie(t,c,n),c.set(e,s),c},yu=Symbol.for("@ipld/js-cid/CID");var Yr={...Nr,...Fr,...Ur,..._r,...Lr,...$r,...zr,...Vr,...jr,...qr},$h={...Xr,...Wr};function fe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ze(r=0){return globalThis.Buffer?.allocUnsafe!=null?fe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function no(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ro=no("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Kr=no("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=ze(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),vu={utf8:ro,"utf-8":ro,hex:Yr.base16,latin1:Kr,ascii:Kr,binary:Kr,...Yr},Ve=vu;function st(r,t="utf8"){let e=Ve[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 Cn=X(je(),1);function At(r,t){t==null&&(t=r.reduce((s,c)=>s+c.length,0));let e=ze(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return fe(e)}var ue=X(je(),1);var qe=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,s){return this.readAtomically(()=>{let c=0,u=0,h=this.peekChar();if(h===void 0)return;let m=h==="0",I=2**(8*s)-1;for(;;){let p=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(p===void 0)break;if(c*=t,c+=p,c>I||(u+=1,e!==void 0&&u>e))return}if(u!==0)return!n&&m&&u>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 s=n*2;if(n<e.length-3){let u=this.readSeparator(":",n,()=>this.readIPv4Addr());if(u!==void 0)return e[s]=u[0],e[s+1]=u[1],e[s+2]=u[2],e[s+3]=u[3],[s+4,!0]}let c=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(c===void 0)return[s,!1];e[s]=c>>8,e[s+1]=c&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let c=new Uint8Array(14),u=16-(n+2),[h]=t(c.subarray(0,u));return e.set(c.subarray(0,h),16-h),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var od=new qe;var hd=parseInt("0xFFFF",16),dd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var rn={};U(rn,{identity:()=>Lu});var Lu=Kt({prefix:"\0",name:"identity",encode:r=>Is(r),decode:r=>Cs(r)});var nn={};U(nn,{base2:()=>$u});var $u=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sn={};U(sn,{base8:()=>zu});var zu=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var on={};U(on,{base10:()=>Vu});var Vu=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var an={};U(an,{base16:()=>ju,base16upper:()=>qu});var ju=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qu=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var cn={};U(cn,{base36:()=>Gu,base36upper:()=>Hu});var Gu=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Hu=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var fn={};U(fn,{base64:()=>Zu,base64pad:()=>Ju,base64url:()=>Xu,base64urlpad:()=>Wu});var Zu=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ju=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xu=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wu=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var un={};U(un,{base256emoji:()=>ep});var bo=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}"),Qu=bo.reduce((r,t,e)=>(r[e]=t,r),[]),Yu=bo.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ku(r){return r.reduce((t,e)=>(t+=Qu[e],t),"")}function tp(r){let t=[];for(let e of r){let n=Yu[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ep=Kt({prefix:"\u{1F680}",name:"base256emoji",encode:Ku,decode:tp});var dn={};U(dn,{sha256:()=>rp,sha512:()=>np});var hn=X(wt("crypto"),1);var ln=({name:r,code:t,encode:e})=>new pn(r,t,e),pn=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?zt(this.code,e):e.then(n=>zt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var rp=ln({name:"sha2-256",code:18,encode:r=>pt(hn.default.createHash("sha256").update(r).digest())}),np=ln({name:"sha2-512",code:19,encode:r=>pt(hn.default.createHash("sha512").update(r).digest())});var mn={};U(mn,{identity:()=>ip});var wo=0,sp="identity",yo=pt,op=r=>zt(wo,yo(r)),ip={code:wo,name:sp,encode:yo,digest:op};var Qd=new TextEncoder,Yd=new TextDecoder;var vo={...rn,...nn,...sn,...on,...an,...Rr,...cn,...Ir,...fn,...un},nm={...dn,...mn};function bn(r,t="utf8"){let e=Ve[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?fe(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var vt=X(je(),1);var Ot=wt("node:net");function Ge(r){return!!(0,Ot.isIP)(r)}var xo=Ot.isIPv4,fp=Ot.isIPv6,gn=function(r){let t=0;if(r=r.toString().trim(),xo(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(fp(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let c=xo(e[n]),u;c&&(u=gn(e[n]),e[n]=st(u.slice(0,2),"base16")),u!=null&&++n<8&&e.splice(n,0,st(u.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 s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let c=parseInt(e[n],16);s[t++]=c>>8&255,s[t++]=c&255}return s}throw new Error("invalid ip address")},So=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let c=0;c<e;c++)s.push(r[t+c]);return s.join(".")}if(e===16){let s=[];for(let c=0;c<e;c+=2)s.push(n.getUint16(t+c).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ce={},wn={},pp=[[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"]];pp.forEach(r=>{let t=lp(...r);wn[t.code]=t,Ce[t.name]=t});function lp(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function N(r){if(typeof r=="number"){if(wn[r]!=null)return wn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ce[r]!=null)return Ce[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Sm=N("ip4"),Tm=N("ip6"),Em=N("ipcidr");function Io(r,t){switch(N(r).code){case 4:case 41:return dp(t);case 42:return Ao(t);case 6:case 273:case 33:case 132:return Ro(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ao(t);case 421:return wp(t);case 444:return Co(t);case 445:return Co(t);case 466:return gp(t);default:return st(t,"base16")}}function Bo(r,t){switch(N(r).code){case 4:return To(t);case 41:return To(t);case 42:return Eo(t);case 6:case 273:case 33:case 132:return vn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Eo(t);case 421:return mp(t);case 444:return yp(t);case 445:return vp(t);case 466:return bp(t);default:return bn(t,"base16")}}var yn=Object.values(vo).map(r=>r.decoder),hp=function(){let r=yn[0].or(yn[1]);return yn.slice(2).forEach(t=>r=r.or(t)),r}();function To(r){if(!Ge(r))throw new Error("invalid ip address");return gn(r)}function dp(r){let t=So(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ge(t))throw new Error("invalid ip address");return t}function vn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ro(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Eo(r){let t=bn(r),e=Uint8Array.from(vt.default.encode(t.length));return At([e,t],e.length+t.length)}function Ao(r){let t=vt.default.decode(r);if(r=r.slice(vt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return st(r)}function mp(r){let t;r[0]==="Q"||r[0]==="1"?t=Le(nt.decode(`z${r}`)).bytes:t=_.parse(r).multihash.bytes;let e=Uint8Array.from(vt.default.encode(t.length));return At([e,t],e.length+t.length)}function bp(r){let t=hp.decode(r),e=Uint8Array.from(vt.default.encode(t.length));return At([e,t],e.length+t.length)}function gp(r){let t=vt.default.decode(r),e=r.slice(vt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+st(e,"base64url")}function wp(r){let t=vt.default.decode(r),e=r.slice(vt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return st(e,"base58btc")}function yp(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=Et.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 s=vn(n);return At([e,s],e.length+s.length)}function vp(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=Et.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 s=vn(n);return At([e,s],e.length+s.length)}function Co(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=st(t,"base32"),s=Ro(e);return`${n}:${s}`}function xp(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let s=e[n],c=N(s);if(c.size===0){t.push([s]);continue}if(n++,n>=e.length)throw Do("invalid address: "+r);if(c.path===!0){t.push([s,An(e.slice(n).join("/"))]);break}t.push([s,e[n]])}return t}function Sp(r){let t=[];return r.map(e=>{let n=Je(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),An(t.join("/"))}function Tp(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Je(t);return t.length>1?[e.code,Bo(e.code,t[1])]:[e.code]})}function xn(r){return r.map(t=>{let e=Je(t);return t[1]!=null?[e.code,Io(e.code,t[1])]:[e.code]})}function Sn(r){return Ze(At(r.map(t=>{let e=Je(t),n=Uint8Array.from(ue.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=At([n,t[1]])),n})))}function Tn(r,t){return r.size>0?r.size/8:r.size===0?0:ue.default.decode(t)+(ue.default.decode.bytes??0)}function He(r){let t=[],e=0;for(;e<r.length;){let n=ue.default.decode(r,e),s=ue.default.decode.bytes??0,c=N(n),u=Tn(c,r.slice(e+s));if(u===0){t.push([n]),e+=s;continue}let h=r.slice(e+s,e+s+u);if(e+=u+s,e>r.length)throw Do("Invalid address Uint8Array: "+st(r,"base16"));t.push([n,h])}return t}function En(r){let t=He(r),e=xn(t);return Sp(e)}function Ep(r){r=An(r);let t=xp(r),e=Tp(t);return Sn(e)}function Mo(r){return Ep(r)}function Ze(r){let t=Ap(r);if(t!=null)throw t;return Uint8Array.from(r)}function Ap(r){try{He(r)}catch(t){return t}}function An(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Do(r){return new Error("Error parsing address: "+r)}function Je(r){return N(r[0])}var Ip=Symbol.for("nodejs.util.inspect.custom"),Bp=[N("dns").code,N("dns4").code,N("dns6").code,N("dnsaddr").code],Rp=new Map,ko=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Mp(r){return!!r?.[ko]}var Ct=class{bytes;#t;#r;#n;#e;[ko]=!0;constructor(t){if(t==null&&(t=""),t instanceof Uint8Array)this.bytes=Ze(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Mo(t)}else if(Mp(t))this.bytes=Ze(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=En(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,s,c="",u=N("tcp"),h=N("udp"),m=N("ip4"),I=N("ip6"),p=N("dns6"),g=N("ip6zone");for(let[E,l]of this.stringTuples())E===g.code&&(c=`%${l??""}`),Bp.includes(E)&&(e=u.name,s=443,n=`${l??""}${c}`,t=E===p.code?6:4),(E===u.code||E===h.code)&&(e=N(E).name,s=parseInt(l??"")),(E===m.code||E===I.code)&&(e=N(E).name,n=`${l??""}${c}`,t=E===I.code?6:4);if(t==null||e==null||n==null||s==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:s}}protos(){return this.protoCodes().map(t=>Object.assign({},N(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let s=Cn.default.decode(e,n),c=Cn.default.decode.bytes??0,u=N(s),h=Tn(u,e.slice(n+c));n+=h+c,t.push(s)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return this.#r==null&&(this.#r=He(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=xn(this.tuples())),this.#n}encapsulate(t){return t=new Ct(t),new Ct(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new Ct(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new Ct(Sn(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Ce.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?st(nt.decode(`z${n}`),"base58btc"):st(_.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(t=>N(t[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(t){return Us(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(c=>c.resolvable);if(e==null)return[this];let n=Rp.get(e.name);if(n==null)throw new Ue(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(c=>new Ct(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)}[Ip](){return`Multiaddr(${En(this.bytes)})`}};function xt(r){return new Ct(r)}var Dp=v("dns4"),kp=v("dns6"),Pp=v("dnsaddr"),qt=q(v("dns"),Pp,Dp,kp),Qe=q(v("ip4"),v("ip6")),Ft=q(C(Qe,v("tcp")),C(qt,v("tcp"))),Ye=C(Qe,v("udp")),Op=C(Ye,v("utp")),Np=C(Ye,v("quic")),Fp=C(Ye,v("quic-v1")),In=q(C(Ft,v("ws")),C(qt,v("ws"))),Xe=q(C(In,v("p2p")),In),Bn=q(C(Ft,v("wss")),C(qt,v("wss")),C(Ft,v("tls"),v("ws")),C(qt,v("tls"),v("ws"))),We=q(C(Bn,v("p2p")),Bn),Rn=q(C(Ft,v("http")),C(Qe,v("http")),C(qt,v("http"))),Mn=q(C(Ft,v("https")),C(Qe,v("https")),C(qt,v("https"))),Po=C(Ye,v("webrtc-direct"),v("certhash")),Fo=q(C(Po,v("p2p")),Po),Oo=C(Fp,v("webtransport"),v("certhash"),v("certhash")),Uo=q(C(Oo,v("p2p")),Oo),_o=q(C(Xe,v("p2p-webrtc-star"),v("p2p")),C(We,v("p2p-webrtc-star"),v("p2p")),C(Xe,v("p2p-webrtc-star")),C(We,v("p2p-webrtc-star"))),qm=q(C(Xe,v("p2p-websocket-star"),v("p2p")),C(We,v("p2p-websocket-star"),v("p2p")),C(Xe,v("p2p-websocket-star")),C(We,v("p2p-websocket-star"))),Lo=q(C(Rn,v("p2p-webrtc-direct"),v("p2p")),C(Mn,v("p2p-webrtc-direct"),v("p2p")),C(Rn,v("p2p-webrtc-direct")),C(Mn,v("p2p-webrtc-direct"))),Gt=q(In,Bn,Rn,Mn,_o,Lo,Ft,Op,Np,qt,Fo,Uo),Gm=q(C(Gt,v("p2p-stardust"),v("p2p")),C(Gt,v("p2p-stardust"))),Nt=q(C(Gt,v("p2p")),_o,Lo,Fo,Uo,v("p2p")),No=q(C(Nt,v("p2p-circuit"),Nt),C(Nt,v("p2p-circuit")),C(v("p2p-circuit"),Nt),C(Gt,v("p2p-circuit")),C(v("p2p-circuit"),Gt),v("p2p-circuit")),$o=()=>q(C(No,$o),No),jt=$o(),Hm=q(C(jt,Nt,jt),C(Nt,jt),C(jt,Nt),jt,Nt);var Zm=q(C(jt,v("webrtc"),v("p2p")),C(jt,v("webrtc")),C(Gt,v("webrtc"),v("p2p")),C(Gt,v("webrtc")),v("webrtc"));function zo(r){function t(e){let n;try{n=xt(e)}catch{return!1}let s=r(n.protoNames());return s===null?!1:s===!0||s===!1?s:s.length===0}return t}function C(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(s=>(n=typeof s=="function"?s().partialMatch(e):s.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:zo(t),partialMatch:t}}function q(...r){function t(n){let s=null;return r.some(c=>{let u=typeof c=="function"?c().partialMatch(n):c.partialMatch(n);return u!=null?(s=u,!0):!1}),s}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:zo(t),partialMatch:t}}function v(r){let t=r;function e(s){let c;try{c=xt(s)}catch{return!1}let u=c.protoNames();return u.length===1&&u[0]===t}function n(s){return s.length===0?null:s[0]===t?s.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var pi=X(wt("net"),1);var Ke=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 s=this.#t.get(t);s==null&&(s=[],this.#t.set(t,s)),s.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let s=this.#t.get(t);s!=null&&(s=s.filter(({callback:c})=>c!==e),this.#t.set(t,s))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:s})=>!s),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new pe(t,e))}},Dn=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},pe=globalThis.CustomEvent??Dn;function tr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function er(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var le=/^(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,kn=/\/\d{1,2}$/;var Y=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var he=X(Pn(),1),Ht=X(Ie(),1),L=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=er(32),this.isInSubnet=tr,this.address=t;let e=kn.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 Y("Invalid subnet mask.");t=t.replace(kn,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new L(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(le))throw new Y("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=[],s;for(s=0;s<8;s+=2){let c=e.slice(s,s+2);n.push(parseInt(c,16))}return new L(n.join("."))}static fromInteger(t){return L.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new L(n)}toHex(){return this.parsedAddress.map(t=>(0,Ht.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,Ht.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,Ht.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new he.BigInteger(this.parsedAddress.map(t=>(0,Ht.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new he.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return L.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new he.BigInteger("1");return L.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new he.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return L.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new he.BigInteger("1");return L.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return L.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,Ht.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new L("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(le,(0,Ht.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 Ho={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},On={"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"},Nn=/([^0-9a-f:/%])/gi,Fn=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Un=/\/\d{1,3}(?=%|$)/,_n=/%.*$/,Zo=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Jo=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Wo=X(Ie(),1);function _p(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function sr(r,t=0){return r.split(":").map((n,s)=>/group-v4/.test(n)?n:(0,Wo.sprintf)('<span class="hover-group group-%d">%s</span>',s+t,_p(n)))}var Jt=X(Ie(),1);function $n(r){return(0,Jt.sprintf)("(%s)",r.join("|"))}function Ln(r){return r.length<4?(0,Jt.sprintf)("0{0,%d}%s",4-r.length,r):r}var zn="[^A-Fa-f0-9:]";function or(r){let t=[];r.forEach((n,s)=>{parseInt(n,16)===0&&t.push(s)});let e=t.map(n=>r.map((s,c)=>{if(c===n){let u=c===0||c===8-1?":":"";return $n([Ln(s),u])}return Ln(s)}).join(":"));return e.push(r.map(Ln).join(":")),$n(e)}function Vn(r,t,e){let n=t?"":":",s=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,s)),c.push((0,Jt.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let u=1;u<r-1;u++)for(let h=1;h<r-u;h++)c.push((0,Jt.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",h,r-h-u-1));return $n(c)}var K=X(Pn(),1),tt=X(Ie(),1);function ir(r){if(!r)throw new Error("Assertion failed.")}function Lp(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function $p(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 zp(r,t){let e=[],n=[],s;for(s=0;s<r.length;s++)s<t[0]?e.push(r[s]):s>t[1]&&n.push(r[s]);return e.concat(["compact"]).concat(n)}function Yo(r){return(0,tt.sprintf)("%04x",parseInt(r,16))}function Ko(r){return r&255}var V=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=tr,this.isCorrect=er(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Un.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 Y("Invalid subnet mask.");t=t.replace(Un,"")}else if(/\//.test(t))throw new Y("Invalid subnet mask.");let s=_n.exec(t);s&&(this.zone=s[0],t=t.replace(_n,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new V(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],s;for(s=0;s<8;s++)n.push(e.slice(s*4,(s+1)*4));return new V(n.join(":"))}static fromURL(t){let e,n=null,s;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(s=Jo.exec(t),s===null)return{error:"failed to parse address with port",address:null,port:null};e=s[1],n=s[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),s=Zo.exec(t),s===null)return{error:"failed to parse address from URL",address:null,port:null};e=s[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new V(e),port:n}}static fromAddress4(t){let e=new L(t),n=128-(32-e.subnetMask);return new V(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new Y("Invalid 'ip6.arpa' form.");let s=e.split(".").reverse();for(let c=n;c>0;c--){let u=c*4;s.splice(u,0,":")}return e=s.join(""),new V(e)}microsoftTranscription(){return(0,tt.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),s=e-n;return s<0?"0":Lp(new K.BigInteger("2",10).pow(s).toString(10))}_startAddress(){return new K.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return V.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new K.BigInteger("1");return V.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new K.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return V.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new K.BigInteger("1");return V.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Ho[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(On))if(this.isInSubnet(new V(t)))return On[t];return"Global unicast"}getBits(t,e){return new K.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,tt.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,s=[];for(t=0;t<this.parsedAddress.length;t++){let h=parseInt(this.parsedAddress[t],16);h===0&&n++,h!==0&&n>0&&(n>1&&s.push([t-n,t-1]),n=0)}n>1&&s.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let c=s.map(h=>h[1]-h[0]+1);if(s.length>0){let h=c.indexOf(Math.max(...c));e=zp(this.parsedAddress,s[h])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let u=e.join(":");return u=u.replace(/^compact$/,"::"),u=u.replace(/^compact|compact$/,":"),u=u.replace(/compact/,""),u}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),s=e.slice(-1)[0].match(le);if(s){this.parsedAddress4=s[0],this.address4=new L(this.parsedAddress4);for(let c=0;c<this.address4.groups;c++)if(/^0[0-9]+/.test(this.address4.parsedAddress[c]))throw new Y("IPv4 addresses can't have leading zeroes.",t.replace(le,this.address4.parsedAddress.map($p).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(Nn);if(e)throw new Y((0,tt.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(Nn,'<span class="parse-error">$1</span>'));let n=t.match(Fn);if(n)throw new Y((0,tt.sprintf)("Address failed regex: %s",n.join("")),t.replace(Fn,'<span class="parse-error">$1</span>'));let s=[],c=t.split("::");if(c.length===2){let u=c[0].split(":"),h=c[1].split(":");u.length===1&&u[0]===""&&(u=[]),h.length===1&&h[0]===""&&(h=[]);let m=this.groups-(u.length+h.length);if(!m)throw new Y("Error parsing groups");this.elidedGroups=m,this.elisionBegin=u.length,this.elisionEnd=u.length+this.elidedGroups,s=s.concat(u);for(let I=0;I<m;I++)s.push("0");s=s.concat(h)}else if(c.length===1)s=t.split(":"),this.elidedGroups=0;else throw new Y("Too many :: groups found");if(s=s.map(u=>(0,tt.sprintf)("%x",parseInt(u,16))),s.length!==this.groups)throw new Y("Incorrect number of groups found");return s}canonicalForm(){return this.parsedAddress.map(Yo).join(":")}decimal(){return this.parsedAddress.map(t=>(0,tt.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new K.BigInteger(this.parsedAddress.map(Yo).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return L.fromHex(new K.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new V(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),s="";return/:$/.test(n)||(s=":"),n+s+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new K.BigInteger("ffff",16)).toString(),n=L.fromHex(this.getBitsBase16(32,64)),s=L.fromHex(this.getBits(96,128).xor(new K.BigInteger("ffffffff",16)).toString(16)),c=this.getBits(64,80),u=this.getBitsBase2(64,80),h=c.testBit(15),m=c.testBit(14),I=c.testBit(8),p=c.testBit(9),g=new K.BigInteger(u.slice(2,6)+u.slice(8,16),2).toString(10);return{prefix:(0,tt.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:s.address,flags:u,coneNat:h,microsoft:{reserved:m,universalLocal:p,groupIndividual:I,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=L.fromHex(this.getBitsBase16(16,48));return{prefix:(0,tt.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 V(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Ko)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Ko))}static fromUnsignedByteArray(t){let e=new K.BigInteger("256",10),n=new K.BigInteger("0",10),s=new K.BigInteger("1",10);for(let c=t.length-1;c>=0;c--)n=n.add(s.multiply(new K.BigInteger(t[c].toString(10),10))),s=s.multiply(e);return V.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 V("2001::/32"))}is6to4(){return this.isInSubnet(new V("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,tt.sprintf)(":%s",t),(0,tt.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,tt.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,tt.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return sr(this.address).join(":");ir(typeof this.elidedGroups=="number"),ir(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...sr(e)):t.push("");let s=["hover-group"];for(let c=this.elisionBegin;c<this.elisionBegin+this.elidedGroups;c++)s.push((0,tt.sprintf)("group-%d",c));return t.push((0,tt.sprintf)('<span class="%s"></span>',s.join(" "))),n.length?t.push(...sr(n,this.elisionEnd)):t.push(""),this.is4()&&(ir(this.address4 instanceof L),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new V(this.correctForm());if(n.elidedGroups===0)e.push(or(n.parsedAddress));else if(n.elidedGroups===8)e.push(Vn(8));else{let s=n.address.split("::");s[0].length&&e.push(or(s[0].split(":"))),ir(typeof n.elidedGroups=="number"),e.push(Vn(n.elidedGroups,s[0].length!==0,s[1].length!==0)),s[1].length&&e.push(or(s[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",zn,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",zn,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Vp=Dt("libp2p:ip-port-to-multiaddr"),jn={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function ti(r,t){if(typeof r!="string")throw new bt(`invalid ip provided: ${r}`,jn.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new bt(`invalid port provided: ${t}`,jn.ERR_INVALID_PORT_PARAMETER);try{return new L(r),xt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new V(r);return e.is4()?xt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):xt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Vp.error(n),new bt(n,jn.ERR_INVALID_IP)}}var ui=X(ci(),1);var Hn=X(wt("os"),1),fi=X(wt("path"),1);var Zp={ip4:"IPv4",ip6:"IPv6"};function be(r,t={}){let e=r.getPath();return e!=null?Hn.default.platform()==="win32"?{path:fi.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function Zn(r,t,e){let n=s=>xt(`/${r}/${s}/tcp/${e}`);return(Jp(t)?Wp(Zp[r]):[t]).map(n)}function Jp(r){return["0.0.0.0","::"].includes(r)}var Xp=Hn.default.networkInterfaces();function Wp(r){let t=[];for(let[,e]of Object.entries(Xp))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var St=Dt("libp2p:tcp:socket"),cr=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",s=t.socketInactivityTimeout??3e5,c=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let u;if(t.remoteAddr!=null)u=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new bt("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");u=ti(r.remoteAddress,r.remotePort)}let h=be(u),m=h.path??`${h.host??""}:${h.port??""}`,{sink:I,source:p}=ui.default.duplex(r);r.setTimeout(s,()=>{St("%s socket read timeout",m),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new bt("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{St("%s socket close",m),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{St("%s socket end",m),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await I(w)}catch(E){E.type!=="aborted"&&St(E)}r.end()},source:p,remoteAddr:u,timeline:{open:Date.now()},async close(w={}){if(r.destroyed){St("%s socket was already destroyed when trying to close",m);return}w.signal=w.signal??AbortSignal.timeout(c);try{St("%s closing socket",m),await new Promise((E,l)=>{r.once("close",()=>{St("%s socket closed",m),E()}),r.once("error",x=>{St("%s socket error",m,x),g.timeline.close==null&&(g.timeline.close=Date.now()),l(x)}),r.setTimeout(c),r.end(),r.writableLength>0?r.once("drain",()=>{St("%s socket drained",m),r.destroy()}):r.destroy()})}catch(E){this.abort(E)}},abort:w=>{St("%s socket abort due to error",m,w),r.destroy(w)}};return g};var ft=Dt("libp2p:tcp:listener");async function Jn(r){try{await r.close()}catch(t){ft.error("an error occurred closing the connection",t)}}var Kp=1,tl=0,fr=class extends Ke{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=pi.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]:Kp})}this.dispatchEvent(new pe("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new pe("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:tl}),this.dispatchEvent(new pe("close"))})}onSocket(t){t.on("error",n=>{ft("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=cr(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){ft.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}ft("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{ft("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(s=>{ft.error("error attempting to listen server once connection count under limit",s),this.context.closeServerOnMaxConnections?.onListenError?.(s)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new pe("connection",{detail:n}))}).catch(async n=>{ft.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Jn(e)}).catch(n=>{ft.error("closing inbound connection failed",n)})}catch(n){ft.error("inbound connection failed",n),Jn(e).catch(s=>{ft.error("closing inbound connection failed",s),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:s}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Zn("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Zn("ip6",e.address,e.port)))}catch(c){ft.error("could not turn %s:%s into multiaddr",e.address,e.port,c)}return t.map(c=>s!=null?c.encapsulate(`/p2p/${s}`):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:s}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:be(n,{backlog:s})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Jn(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)}),ft("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(ft("Closing server on %s",this.server.address()),this.server.close())}};var Bt=Dt("libp2p:tcp"),Wn=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[os]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",h=>{Bt("socket error",h)});let s=cr(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),c=()=>{s.close().catch(h=>{Bt.error("Error closing maConn after abort",h)})};e.signal?.addEventListener("abort",c,{once:!0}),Bt("new outbound connection %s",s.remoteAddr);let u=await e.upgrader.upgradeOutbound(s);if(Bt("outbound connection %s upgraded",s.remoteAddr),e.signal?.removeEventListener("abort",c),e.signal?.aborted===!0)throw u.close().catch(h=>{Bt.error("Error closing conn after abort",h)}),new Mt;return u}async _connect(t,e){if(e.signal?.aborted===!0)throw new Mt;return new Promise((n,s)=>{let c=Date.now(),u=be(t),h=u.path??`${u.host??""}:${u.port}`;Bt("dialing %j",u);let m=li.default.connect(u),I=l=>{l.message=`connection error ${h}: ${l.message}`,this.metrics?.dialerEvents.increment({error:!0}),E(l)},p=()=>{Bt("connection timeout %s",h),this.metrics?.dialerEvents.increment({timeout:!0});let l=new bt(`connection timeout after ${Date.now()-c}ms`,"ERR_CONNECT_TIMEOUT");m.emit("error",l)},g=()=>{Bt("connection opened %j",u),this.metrics?.dialerEvents.increment({connect:!0}),E()},w=()=>{Bt("connection aborted %j",u),this.metrics?.dialerEvents.increment({abort:!0}),m.destroy(),E(new Mt)},E=l=>{if(m.removeListener("error",I),m.removeListener("timeout",p),m.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),l!=null){s(l);return}n(m)};m.on("error",I),m.on("timeout",p),m.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new fr({...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:Ft.matches(e.decapsulateCode(421)))}};function nl(r={}){return(t={})=>new Wn(t,r)}return Ka(sl);})();
4
+ `+c),r.push(s+"m+"+Pe.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=mc()+t+" "+r[0]}function mc(){return H.inspectOpts.hideDate?"":new Date().toISOString()+" "}function bc(...r){return process.stderr.write(De.format(...r)+`
5
+ `)}function gc(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function wc(){return process.env.DEBUG}function yc(r){r.inspectOpts={};let t=Object.keys(H.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=H.inspectOpts[t[e]]}Pe.exports=lr()(H);var{formatters:ls}=Pe.exports;ls.o=function(r){return this.inspectOpts.colors=this.useColors,De.inspect(r,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};ls.O=function(r){return this.inspectOpts.colors=this.useColors,De.inspect(r,this.inspectOpts)}});var ds=V((fl,dr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?dr.exports=as():dr.exports=hs()});var so=V((Gh,no)=>{no.exports=Qr;var ro=128,wu=127,yu=~wu,vu=Math.pow(2,31);function Qr(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Qr.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=vu;)t[e++]=r&255|ro,r/=128;for(;r&yu;)t[e++]=r&255|ro,r>>>=7;return t[e]=r|0,Qr.bytes=e-n+1,t}});var ao=V((Hh,io)=>{io.exports=Yr;var xu=128,oo=127;function Yr(r,n){var e=0,n=n||0,s=0,c=n,u,h=r.length;do{if(c>=h||s>49)throw Yr.bytes=0,new RangeError("Could not decode varint");u=r[c++],e+=s<28?(u&oo)<<s:(u&oo)*Math.pow(2,s),s+=7}while(u>=xu);return Yr.bytes=c-n,e}});var fo=V((Zh,co)=>{var Su=Math.pow(2,7),Tu=Math.pow(2,14),Cu=Math.pow(2,21),Au=Math.pow(2,28),Eu=Math.pow(2,35),Iu=Math.pow(2,42),Bu=Math.pow(2,49),Mu=Math.pow(2,56),Ru=Math.pow(2,63);co.exports=function(r){return r<Su?1:r<Tu?2:r<Cu?3:r<Au?4:r<Eu?5:r<Iu?6:r<Bu?7:r<Mu?8:r<Ru?9:10}});var $e=V((Jh,uo)=>{uo.exports={encode:so(),decode:ao(),encodingLength:fo()}});var Dn=V((Ke,Vo)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(o,i,a){o!=null&&(typeof o=="number"?this.fromNumber(o,i,a):i==null&&typeof o!="string"?this.fromString(o,256):this.fromString(o,i))}function s(){return new n(null)}function c(o,i,a,f,d,b){for(;--b>=0;){var y=i*this[o++]+a[f]+d;d=Math.floor(y/67108864),a[f++]=y&67108863}return d}function u(o,i,a,f,d,b){for(var y=i&32767,S=i>>15;--b>=0;){var F=this[o]&32767,q=this[o++]>>15,at=S*F+q*y;F=y*F+((at&32767)<<15)+a[f]+(d&1073741823),d=(F>>>30)+(at>>>15)+S*q+(d>>>30),a[f++]=F&1073741823}return d}function h(o,i,a,f,d,b){for(var y=i&16383,S=i>>14;--b>=0;){var F=this[o]&16383,q=this[o++]>>14,at=S*F+q*y;F=y*F+((at&16383)<<14)+a[f]+d,d=(F>>28)+(at>>14)+S*q,a[f++]=F&268435455}return d}var m=typeof navigator<"u";m&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=u,r=30):m&&e&&navigator.appName!="Netscape"?(n.prototype.am=c,r=26):(n.prototype.am=h,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var I=52;n.prototype.FV=Math.pow(2,I),n.prototype.F1=I-r,n.prototype.F2=2*r-I;var p="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,C;for(w="0".charCodeAt(0),C=0;C<=9;++C)g[w++]=C;for(w="a".charCodeAt(0),C=10;C<36;++C)g[w++]=C;for(w="A".charCodeAt(0),C=10;C<36;++C)g[w++]=C;function l(o){return p.charAt(o)}function x(o,i){var a=g[o.charCodeAt(i)];return a??-1}function M(o){for(var i=this.t-1;i>=0;--i)o[i]=this[i];o.t=this.t,o.s=this.s}function T(o){this.t=1,this.s=o<0?-1:0,o>0?this[0]=o:o<-1?this[0]=o+this.DV:this.t=0}function A(o){var i=s();return i.fromInt(o),i}function R(o,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(o,i);return}this.t=0,this.s=0;for(var f=o.length,d=!1,b=0;--f>=0;){var y=a==8?o[f]&255:x(o,f);if(y<0){o.charAt(f)=="-"&&(d=!0);continue}d=!1,b==0?this[this.t++]=y:b+a>this.DB?(this[this.t-1]|=(y&(1<<this.DB-b)-1)<<b,this[this.t++]=y>>this.DB-b):this[this.t-1]|=y<<b,b+=a,b>=this.DB&&(b-=this.DB)}a==8&&o[0]&128&&(this.s=-1,b>0&&(this[this.t-1]|=(1<<this.DB-b)-1<<b)),this.clamp(),d&&n.ZERO.subTo(this,this)}function B(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function P(o){if(this.s<0)return"-"+this.negate().toString(o);var i;if(o==16)i=4;else if(o==8)i=3;else if(o==2)i=1;else if(o==32)i=5;else if(o==4)i=2;else return this.toRadix(o);var a=(1<<i)-1,f,d=!1,b="",y=this.t,S=this.DB-y*this.DB%i;if(y-- >0)for(S<this.DB&&(f=this[y]>>S)>0&&(d=!0,b=l(f));y>=0;)S<i?(f=(this[y]&(1<<S)-1)<<i-S,f|=this[--y]>>(S+=this.DB-i)):(f=this[y]>>(S-=i)&a,S<=0&&(S+=this.DB,--y)),f>0&&(d=!0),d&&(b+=l(f));return d?b:"0"}function O(){var o=s();return n.ZERO.subTo(this,o),o}function D(){return this.s<0?this.negate():this}function k(o){var i=this.s-o.s;if(i!=0)return i;var a=this.t;if(i=a-o.t,i!=0)return this.s<0?-i:i;for(;--a>=0;)if((i=this[a]-o[a])!=0)return i;return 0}function $(o){var i=1,a;return(a=o>>>16)!=0&&(o=a,i+=16),(a=o>>8)!=0&&(o=a,i+=8),(a=o>>4)!=0&&(o=a,i+=4),(a=o>>2)!=0&&(o=a,i+=2),(a=o>>1)!=0&&(o=a,i+=1),i}function pi(){return this.t<=0?0:this.DB*(this.t-1)+$(this[this.t-1]^this.s&this.DM)}function li(o,i){var a;for(a=this.t-1;a>=0;--a)i[a+o]=this[a];for(a=o-1;a>=0;--a)i[a]=0;i.t=this.t+o,i.s=this.s}function hi(o,i){for(var a=o;a<this.t;++a)i[a-o]=this[a];i.t=Math.max(this.t-o,0),i.s=this.s}function di(o,i){var a=o%this.DB,f=this.DB-a,d=(1<<f)-1,b=Math.floor(o/this.DB),y=this.s<<a&this.DM,S;for(S=this.t-1;S>=0;--S)i[S+b+1]=this[S]>>f|y,y=(this[S]&d)<<a;for(S=b-1;S>=0;--S)i[S]=0;i[b]=y,i.t=this.t+b+1,i.s=this.s,i.clamp()}function mi(o,i){i.s=this.s;var a=Math.floor(o/this.DB);if(a>=this.t){i.t=0;return}var f=o%this.DB,d=this.DB-f,b=(1<<f)-1;i[0]=this[a]>>f;for(var y=a+1;y<this.t;++y)i[y-a-1]|=(this[y]&b)<<d,i[y-a]=this[y]>>f;f>0&&(i[this.t-a-1]|=(this.s&b)<<d),i.t=this.t-a,i.clamp()}function bi(o,i){for(var a=0,f=0,d=Math.min(o.t,this.t);a<d;)f+=this[a]-o[a],i[a++]=f&this.DM,f>>=this.DB;if(o.t<this.t){for(f-=o.s;a<this.t;)f+=this[a],i[a++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;a<o.t;)f-=o[a],i[a++]=f&this.DM,f>>=this.DB;f-=o.s}i.s=f<0?-1:0,f<-1?i[a++]=this.DV+f:f>0&&(i[a++]=f),i.t=a,i.clamp()}function gi(o,i){var a=this.abs(),f=o.abs(),d=a.t;for(i.t=d+f.t;--d>=0;)i[d]=0;for(d=0;d<f.t;++d)i[d+a.t]=a.am(0,f[d],i,d,0,a.t);i.s=0,i.clamp(),this.s!=o.s&&n.ZERO.subTo(i,i)}function wi(o){for(var i=this.abs(),a=o.t=2*i.t;--a>=0;)o[a]=0;for(a=0;a<i.t-1;++a){var f=i.am(a,i[a],o,2*a,0,1);(o[a+i.t]+=i.am(a+1,2*i[a],o,2*a+1,f,i.t-a-1))>=i.DV&&(o[a+i.t]-=i.DV,o[a+i.t+1]=1)}o.t>0&&(o[o.t-1]+=i.am(a,i[a],o,2*a,0,1)),o.s=0,o.clamp()}function yi(o,i,a){var f=o.abs();if(!(f.t<=0)){var d=this.abs();if(d.t<f.t){i?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=s());var b=s(),y=this.s,S=o.s,F=this.DB-$(f[f.t-1]);F>0?(f.lShiftTo(F,b),d.lShiftTo(F,a)):(f.copyTo(b),d.copyTo(a));var q=b.t,at=b[q-1];if(at!=0){var rt=at*(1<<this.F1)+(q>1?b[q-2]>>this.F2:0),vt=this.FV/rt,Ee=(1<<this.F1)/rt,pt=1<<this.F2,lt=a.t,Ie=lt-q,At=i??s();for(b.dlShiftTo(Ie,At),a.compareTo(At)>=0&&(a[a.t++]=1,a.subTo(At,a)),n.ONE.dlShiftTo(q,At),At.subTo(b,b);b.t<q;)b[b.t++]=0;for(;--Ie>=0;){var pr=a[--lt]==at?this.DM:Math.floor(a[lt]*vt+(a[lt-1]+pt)*Ee);if((a[lt]+=b.am(0,pr,a,Ie,0,q))<pr)for(b.dlShiftTo(Ie,At),a.subTo(At,a);a[lt]<--pr;)a.subTo(At,a)}i!=null&&(a.drShiftTo(q,i),y!=S&&n.ZERO.subTo(i,i)),a.t=q,a.clamp(),F>0&&a.rShiftTo(F,a),y<0&&n.ZERO.subTo(a,a)}}}function vi(o){var i=s();return this.abs().divRemTo(o,null,i),this.s<0&&i.compareTo(n.ZERO)>0&&o.subTo(i,i),i}function kt(o){this.m=o}function xi(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function Si(o){return o}function Ti(o){o.divRemTo(this.m,null,o)}function Ci(o,i,a){o.multiplyTo(i,a),this.reduce(a)}function Ai(o,i){o.squareTo(i),this.reduce(i)}kt.prototype.convert=xi,kt.prototype.revert=Si,kt.prototype.reduce=Ti,kt.prototype.mulTo=Ci,kt.prototype.sqrTo=Ai;function Ei(){if(this.t<1)return 0;var o=this[0];if(!(o&1))return 0;var i=o&3;return i=i*(2-(o&15)*i)&15,i=i*(2-(o&255)*i)&255,i=i*(2-((o&65535)*i&65535))&65535,i=i*(2-o*i%this.DV)%this.DV,i>0?this.DV-i:-i}function Ot(o){this.m=o,this.mp=o.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<o.DB-15)-1,this.mt2=2*o.t}function Ii(o){var i=s();return o.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),o.s<0&&i.compareTo(n.ZERO)>0&&this.m.subTo(i,i),i}function Bi(o){var i=s();return o.copyTo(i),this.reduce(i),i}function Mi(o){for(;o.t<=this.mt2;)o[o.t++]=0;for(var i=0;i<this.m.t;++i){var a=o[i]&32767,f=a*this.mpl+((a*this.mph+(o[i]>>15)*this.mpl&this.um)<<15)&o.DM;for(a=i+this.m.t,o[a]+=this.m.am(0,f,o,i,0,this.m.t);o[a]>=o.DV;)o[a]-=o.DV,o[++a]++}o.clamp(),o.drShiftTo(this.m.t,o),o.compareTo(this.m)>=0&&o.subTo(this.m,o)}function Ri(o,i){o.squareTo(i),this.reduce(i)}function Di(o,i,a){o.multiplyTo(i,a),this.reduce(a)}Ot.prototype.convert=Ii,Ot.prototype.revert=Bi,Ot.prototype.reduce=Mi,Ot.prototype.mulTo=Di,Ot.prototype.sqrTo=Ri;function Pi(){return(this.t>0?this[0]&1:this.s)==0}function ki(o,i){if(o>4294967295||o<1)return n.ONE;var a=s(),f=s(),d=i.convert(this),b=$(o)-1;for(d.copyTo(a);--b>=0;)if(i.sqrTo(a,f),(o&1<<b)>0)i.mulTo(f,d,a);else{var y=a;a=f,f=y}return i.revert(a)}function Oi(o,i){var a;return o<256||i.isEven()?a=new kt(i):a=new Ot(i),this.exp(o,a)}n.prototype.copyTo=M,n.prototype.fromInt=T,n.prototype.fromString=R,n.prototype.clamp=B,n.prototype.dlShiftTo=li,n.prototype.drShiftTo=hi,n.prototype.lShiftTo=di,n.prototype.rShiftTo=mi,n.prototype.subTo=bi,n.prototype.multiplyTo=gi,n.prototype.squareTo=wi,n.prototype.divRemTo=yi,n.prototype.invDigit=Ei,n.prototype.isEven=Pi,n.prototype.exp=ki,n.prototype.toString=P,n.prototype.negate=O,n.prototype.abs=D,n.prototype.compareTo=k,n.prototype.bitLength=pi,n.prototype.mod=vi,n.prototype.modPowInt=Oi,n.ZERO=A(0),n.ONE=A(1);function Ni(){var o=s();return this.copyTo(o),o}function Fi(){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 Ui(){return this.t==0?this.s:this[0]<<24>>24}function _i(){return this.t==0?this.s:this[0]<<16>>16}function Li(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function $i(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function zi(o){if(o==null&&(o=10),this.signum()==0||o<2||o>36)return"0";var i=this.chunkSize(o),a=Math.pow(o,i),f=A(a),d=s(),b=s(),y="";for(this.divRemTo(f,d,b);d.signum()>0;)y=(a+b.intValue()).toString(o).substr(1)+y,d.divRemTo(f,d,b);return b.intValue().toString(o)+y}function Vi(o,i){this.fromInt(0),i==null&&(i=10);for(var a=this.chunkSize(i),f=Math.pow(i,a),d=!1,b=0,y=0,S=0;S<o.length;++S){var F=x(o,S);if(F<0){o.charAt(S)=="-"&&this.signum()==0&&(d=!0);continue}y=i*y+F,++b>=a&&(this.dMultiply(f),this.dAddOffset(y,0),b=0,y=0)}b>0&&(this.dMultiply(Math.pow(i,b)),this.dAddOffset(y,0)),d&&n.ZERO.subTo(this,this)}function ji(o,i,a){if(typeof i=="number")if(o<2)this.fromInt(1);else for(this.fromNumber(o,a),this.testBit(o-1)||this.bitwiseTo(n.ONE.shiftLeft(o-1),ar,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>o&&this.subTo(n.ONE.shiftLeft(o-1),this);else{var f=new Array,d=o&7;f.length=(o>>3)+1,i.nextBytes(f),d>0?f[0]&=(1<<d)-1:f[0]=0,this.fromString(f,256)}}function qi(){var o=this.t,i=new Array;i[0]=this.s;var a=this.DB-o*this.DB%8,f,d=0;if(o-- >0)for(a<this.DB&&(f=this[o]>>a)!=(this.s&this.DM)>>a&&(i[d++]=f|this.s<<this.DB-a);o>=0;)a<8?(f=(this[o]&(1<<a)-1)<<8-a,f|=this[--o]>>(a+=this.DB-8)):(f=this[o]>>(a-=8)&255,a<=0&&(a+=this.DB,--o)),f&128&&(f|=-256),d==0&&(this.s&128)!=(f&128)&&++d,(d>0||f!=this.s)&&(i[d++]=f);return i}function Gi(o){return this.compareTo(o)==0}function Hi(o){return this.compareTo(o)<0?this:o}function Zi(o){return this.compareTo(o)>0?this:o}function Ji(o,i,a){var f,d,b=Math.min(o.t,this.t);for(f=0;f<b;++f)a[f]=i(this[f],o[f]);if(o.t<this.t){for(d=o.s&this.DM,f=b;f<this.t;++f)a[f]=i(this[f],d);a.t=this.t}else{for(d=this.s&this.DM,f=b;f<o.t;++f)a[f]=i(d,o[f]);a.t=o.t}a.s=i(this.s,o.s),a.clamp()}function Xi(o,i){return o&i}function Wi(o){var i=s();return this.bitwiseTo(o,Xi,i),i}function ar(o,i){return o|i}function Qi(o){var i=s();return this.bitwiseTo(o,ar,i),i}function Xn(o,i){return o^i}function Yi(o){var i=s();return this.bitwiseTo(o,Xn,i),i}function Wn(o,i){return o&~i}function Ki(o){var i=s();return this.bitwiseTo(o,Wn,i),i}function ta(){for(var o=s(),i=0;i<this.t;++i)o[i]=this.DM&~this[i];return o.t=this.t,o.s=~this.s,o}function ea(o){var i=s();return o<0?this.rShiftTo(-o,i):this.lShiftTo(o,i),i}function ra(o){var i=s();return o<0?this.lShiftTo(-o,i):this.rShiftTo(o,i),i}function na(o){if(o==0)return-1;var i=0;return o&65535||(o>>=16,i+=16),o&255||(o>>=8,i+=8),o&15||(o>>=4,i+=4),o&3||(o>>=2,i+=2),o&1||++i,i}function sa(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+na(this[o]);return this.s<0?this.t*this.DB:-1}function oa(o){for(var i=0;o!=0;)o&=o-1,++i;return i}function ia(){for(var o=0,i=this.s&this.DM,a=0;a<this.t;++a)o+=oa(this[a]^i);return o}function aa(o){var i=Math.floor(o/this.DB);return i>=this.t?this.s!=0:(this[i]&1<<o%this.DB)!=0}function ca(o,i){var a=n.ONE.shiftLeft(o);return this.bitwiseTo(a,i,a),a}function fa(o){return this.changeBit(o,ar)}function ua(o){return this.changeBit(o,Wn)}function pa(o){return this.changeBit(o,Xn)}function la(o,i){for(var a=0,f=0,d=Math.min(o.t,this.t);a<d;)f+=this[a]+o[a],i[a++]=f&this.DM,f>>=this.DB;if(o.t<this.t){for(f+=o.s;a<this.t;)f+=this[a],i[a++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;a<o.t;)f+=o[a],i[a++]=f&this.DM,f>>=this.DB;f+=o.s}i.s=f<0?-1:0,f>0?i[a++]=f:f<-1&&(i[a++]=this.DV+f),i.t=a,i.clamp()}function ha(o){var i=s();return this.addTo(o,i),i}function da(o){var i=s();return this.subTo(o,i),i}function ma(o){var i=s();return this.multiplyTo(o,i),i}function ba(){var o=s();return this.squareTo(o),o}function ga(o){var i=s();return this.divRemTo(o,i,null),i}function wa(o){var i=s();return this.divRemTo(o,null,i),i}function ya(o){var i=s(),a=s();return this.divRemTo(o,i,a),new Array(i,a)}function va(o){this[this.t]=this.am(0,o-1,this,0,0,this.t),++this.t,this.clamp()}function xa(o,i){if(o!=0){for(;this.t<=i;)this[this.t++]=0;for(this[i]+=o;this[i]>=this.DV;)this[i]-=this.DV,++i>=this.t&&(this[this.t++]=0),++this[i]}}function de(){}function Qn(o){return o}function Sa(o,i,a){o.multiplyTo(i,a)}function Ta(o,i){o.squareTo(i)}de.prototype.convert=Qn,de.prototype.revert=Qn,de.prototype.mulTo=Sa,de.prototype.sqrTo=Ta;function Ca(o){return this.exp(o,new de)}function Aa(o,i,a){var f=Math.min(this.t+o.t,i);for(a.s=0,a.t=f;f>0;)a[--f]=0;var d;for(d=a.t-this.t;f<d;++f)a[f+this.t]=this.am(0,o[f],a,f,0,this.t);for(d=Math.min(o.t,i);f<d;++f)this.am(0,o[f],a,f,0,i-f);a.clamp()}function Ea(o,i,a){--i;var f=a.t=this.t+o.t-i;for(a.s=0;--f>=0;)a[f]=0;for(f=Math.max(i-this.t,0);f<o.t;++f)a[this.t+f-i]=this.am(i-f,o[f],a,0,0,this.t+f-i);a.clamp(),a.drShiftTo(1,a)}function Nt(o){this.r2=s(),this.q3=s(),n.ONE.dlShiftTo(2*o.t,this.r2),this.mu=this.r2.divide(o),this.m=o}function Ia(o){if(o.s<0||o.t>2*this.m.t)return o.mod(this.m);if(o.compareTo(this.m)<0)return o;var i=s();return o.copyTo(i),this.reduce(i),i}function Ba(o){return o}function Ma(o){for(o.drShiftTo(this.m.t-1,this.r2),o.t>this.m.t+1&&(o.t=this.m.t+1,o.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);o.compareTo(this.r2)<0;)o.dAddOffset(1,this.m.t+1);for(o.subTo(this.r2,o);o.compareTo(this.m)>=0;)o.subTo(this.m,o)}function Ra(o,i){o.squareTo(i),this.reduce(i)}function Da(o,i,a){o.multiplyTo(i,a),this.reduce(a)}Nt.prototype.convert=Ia,Nt.prototype.revert=Ba,Nt.prototype.reduce=Ma,Nt.prototype.mulTo=Da,Nt.prototype.sqrTo=Ra;function Pa(o,i){var a=o.bitLength(),f,d=A(1),b;if(a<=0)return d;a<18?f=1:a<48?f=3:a<144?f=4:a<768?f=5:f=6,a<8?b=new kt(i):i.isEven()?b=new Nt(i):b=new Ot(i);var y=new Array,S=3,F=f-1,q=(1<<f)-1;if(y[1]=b.convert(this),f>1){var at=s();for(b.sqrTo(y[1],at);S<=q;)y[S]=s(),b.mulTo(at,y[S-2],y[S]),S+=2}var rt=o.t-1,vt,Ee=!0,pt=s(),lt;for(a=$(o[rt])-1;rt>=0;){for(a>=F?vt=o[rt]>>a-F&q:(vt=(o[rt]&(1<<a+1)-1)<<F-a,rt>0&&(vt|=o[rt-1]>>this.DB+a-F)),S=f;!(vt&1);)vt>>=1,--S;if((a-=S)<0&&(a+=this.DB,--rt),Ee)y[vt].copyTo(d),Ee=!1;else{for(;S>1;)b.sqrTo(d,pt),b.sqrTo(pt,d),S-=2;S>0?b.sqrTo(d,pt):(lt=d,d=pt,pt=lt),b.mulTo(pt,y[vt],d)}for(;rt>=0&&!(o[rt]&1<<a);)b.sqrTo(d,pt),lt=d,d=pt,pt=lt,--a<0&&(a=this.DB-1,--rt)}return b.revert(d)}function ka(o){var i=this.s<0?this.negate():this.clone(),a=o.s<0?o.negate():o.clone();if(i.compareTo(a)<0){var f=i;i=a,a=f}var d=i.getLowestSetBit(),b=a.getLowestSetBit();if(b<0)return i;for(d<b&&(b=d),b>0&&(i.rShiftTo(b,i),a.rShiftTo(b,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 b>0&&a.lShiftTo(b,a),a}function Oa(o){if(o<=0)return 0;var i=this.DV%o,a=this.s<0?o-1:0;if(this.t>0)if(i==0)a=this[0]%o;else for(var f=this.t-1;f>=0;--f)a=(i*a+this[f])%o;return a}function Na(o){var i=o.isEven();if(this.isEven()&&i||o.signum()==0)return n.ZERO;for(var a=o.clone(),f=this.clone(),d=A(1),b=A(0),y=A(0),S=A(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),i?((!d.isEven()||!b.isEven())&&(d.addTo(this,d),b.subTo(o,b)),d.rShiftTo(1,d)):b.isEven()||b.subTo(o,b),b.rShiftTo(1,b);for(;f.isEven();)f.rShiftTo(1,f),i?((!y.isEven()||!S.isEven())&&(y.addTo(this,y),S.subTo(o,S)),y.rShiftTo(1,y)):S.isEven()||S.subTo(o,S),S.rShiftTo(1,S);a.compareTo(f)>=0?(a.subTo(f,a),i&&d.subTo(y,d),b.subTo(S,b)):(f.subTo(a,f),i&&y.subTo(d,y),S.subTo(b,S))}if(f.compareTo(n.ONE)!=0)return n.ZERO;if(S.compareTo(o)>=0)return S.subtract(o);if(S.signum()<0)S.addTo(o,S);else return S;return S.signum()<0?S.add(o):S}var Q=[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],Fa=(1<<26)/Q[Q.length-1];function Ua(o){var i,a=this.abs();if(a.t==1&&a[0]<=Q[Q.length-1]){for(i=0;i<Q.length;++i)if(a[0]==Q[i])return!0;return!1}if(a.isEven())return!1;for(i=1;i<Q.length;){for(var f=Q[i],d=i+1;d<Q.length&&f<Fa;)f*=Q[d++];for(f=a.modInt(f);i<d;)if(f%Q[i++]==0)return!1}return a.millerRabin(o)}function _a(o){var i=this.subtract(n.ONE),a=i.getLowestSetBit();if(a<=0)return!1;var f=i.shiftRight(a);o=o+1>>1,o>Q.length&&(o=Q.length);for(var d=s(),b=0;b<o;++b){d.fromInt(Q[Math.floor(Math.random()*Q.length)]);var y=d.modPow(f,this);if(y.compareTo(n.ONE)!=0&&y.compareTo(i)!=0){for(var S=1;S++<a&&y.compareTo(i)!=0;)if(y=y.modPowInt(2,this),y.compareTo(n.ONE)==0)return!1;if(y.compareTo(i)!=0)return!1}}return!0}n.prototype.chunkSize=Li,n.prototype.toRadix=zi,n.prototype.fromRadix=Vi,n.prototype.fromNumber=ji,n.prototype.bitwiseTo=Ji,n.prototype.changeBit=ca,n.prototype.addTo=la,n.prototype.dMultiply=va,n.prototype.dAddOffset=xa,n.prototype.multiplyLowerTo=Aa,n.prototype.multiplyUpperTo=Ea,n.prototype.modInt=Oa,n.prototype.millerRabin=_a,n.prototype.clone=Ni,n.prototype.intValue=Fi,n.prototype.byteValue=Ui,n.prototype.shortValue=_i,n.prototype.signum=$i,n.prototype.toByteArray=qi,n.prototype.equals=Gi,n.prototype.min=Hi,n.prototype.max=Zi,n.prototype.and=Wi,n.prototype.or=Qi,n.prototype.xor=Yi,n.prototype.andNot=Ki,n.prototype.not=ta,n.prototype.shiftLeft=ea,n.prototype.shiftRight=ra,n.prototype.getLowestSetBit=sa,n.prototype.bitCount=ia,n.prototype.testBit=aa,n.prototype.setBit=fa,n.prototype.clearBit=ua,n.prototype.flipBit=pa,n.prototype.add=ha,n.prototype.subtract=da,n.prototype.multiply=ma,n.prototype.divide=ga,n.prototype.remainder=wa,n.prototype.divideAndRemainder=ya,n.prototype.modPow=Pa,n.prototype.modInverse=Na,n.prototype.pow=Ca,n.prototype.gcd=ka,n.prototype.isProbablePrime=Ua,n.prototype.square=ba,n.prototype.Barrett=Nt;var Ae,et,j;function La(o){et[j++]^=o&255,et[j++]^=o>>8&255,et[j++]^=o>>16&255,et[j++]^=o>>24&255,j>=ur&&(j-=ur)}function Yn(){La(new Date().getTime())}if(et==null){et=new Array,j=0;var ut;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Kn=new Uint8Array(32);for(window.crypto.getRandomValues(Kn),ut=0;ut<32;++ut)et[j++]=Kn[ut]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var ts=window.crypto.random(32);for(ut=0;ut<ts.length;++ut)et[j++]=ts.charCodeAt(ut)&255}}for(;j<ur;)ut=Math.floor(65536*Math.random()),et[j++]=ut>>>8,et[j++]=ut&255;j=0,Yn()}function $a(){if(Ae==null){for(Yn(),Ae=qa(),Ae.init(et),j=0;j<et.length;++j)et[j]=0;j=0}return Ae.next()}function za(o){var i;for(i=0;i<o.length;++i)o[i]=$a()}function cr(){}cr.prototype.nextBytes=za;function fr(){this.i=0,this.j=0,this.S=new Array}function Va(o){var i,a,f;for(i=0;i<256;++i)this.S[i]=i;for(a=0,i=0;i<256;++i)a=a+this.S[i]+o[i%o.length]&255,f=this.S[i],this.S[i]=this.S[a],this.S[a]=f;this.i=0,this.j=0}function ja(){var o;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,o=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=o,this.S[o+this.S[this.i]&255]}fr.prototype.init=Va,fr.prototype.next=ja;function qa(){return new fr}var ur=256;typeof Ke<"u"?Ke=Vo.exports={default:n,BigInteger:n,SecureRandom:cr}:this.jsbn={BigInteger:n,SecureRandom:cr}}).call(Ke)});var Te=V(tr=>{(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(u){return n(c(u),arguments)}function e(u,h){return t.apply(null,[u].concat(h||[]))}function n(u,h){var m=1,I=u.length,p,g="",w,C,l,x,M,T,A,R;for(w=0;w<I;w++)if(typeof u[w]=="string")g+=u[w];else if(typeof u[w]=="object"){if(l=u[w],l.keys)for(p=h[m],C=0;C<l.keys.length;C++){if(p==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',l.keys[C],l.keys[C-1]));p=p[l.keys[C]]}else l.param_no?p=h[l.param_no]:p=h[m++];if(r.not_type.test(l.type)&&r.not_primitive.test(l.type)&&p instanceof Function&&(p=p()),r.numeric_arg.test(l.type)&&typeof p!="number"&&isNaN(p))throw new TypeError(t("[sprintf] expecting number but found %T",p));switch(r.number.test(l.type)&&(A=p>=0),l.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,l.width?parseInt(l.width):0);break;case"e":p=l.precision?parseFloat(p).toExponential(l.precision):parseFloat(p).toExponential();break;case"f":p=l.precision?parseFloat(p).toFixed(l.precision):parseFloat(p);break;case"g":p=l.precision?String(Number(p.toPrecision(l.precision))):parseFloat(p);break;case"o":p=(parseInt(p,10)>>>0).toString(8);break;case"s":p=String(p),p=l.precision?p.substring(0,l.precision):p;break;case"t":p=String(!!p),p=l.precision?p.substring(0,l.precision):p;break;case"T":p=Object.prototype.toString.call(p).slice(8,-1).toLowerCase(),p=l.precision?p.substring(0,l.precision):p;break;case"u":p=parseInt(p,10)>>>0;break;case"v":p=p.valueOf(),p=l.precision?p.substring(0,l.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(l.type)?g+=p:(r.number.test(l.type)&&(!A||l.sign)?(R=A?"+":"-",p=p.toString().replace(r.sign,"")):R="",M=l.pad_char?l.pad_char==="0"?"0":l.pad_char.charAt(1):" ",T=l.width-(R+p).length,x=l.width&&T>0?M.repeat(T):"",g+=l.align?R+p+x:M==="0"?R+x+p:x+R+p)}return g}var s=Object.create(null);function c(u){if(s[u])return s[u];for(var h=u,m,I=[],p=0;h;){if((m=r.text.exec(h))!==null)I.push(m[0]);else if((m=r.modulo.exec(h))!==null)I.push("%");else if((m=r.placeholder.exec(h))!==null){if(m[2]){p|=1;var g=[],w=m[2],C=[];if((C=r.key.exec(w))!==null)for(g.push(C[1]);(w=w.substring(C[0].length))!=="";)if((C=r.key_access.exec(w))!==null)g.push(C[1]);else if((C=r.index_access.exec(w))!==null)g.push(C[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");m[2]=g}else p|=2;if(p===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");I.push({placeholder:m[0],param_no:m[1],keys:m[2],sign:m[3],pad_char:m[4],align:m[5],width:m[6],precision:m[7],type:m[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");h=h.substring(m[0].length)}return s[u]=I}typeof tr<"u"&&(tr.sprintf=t,tr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var sr=V((f0,Ko)=>{Ko.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 ei=V((u0,ti)=>{ti.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 Vn=V((p0,ri)=>{var $p=ei();ri.exports=r=>async t=>{t=$p(t);let e=T=>{typeof T.return=="function"&&T.return()},n=null,s=null,c=T=>{n=T,s&&s(T),e(t)},u=null,h=!1,m=()=>{h=!0,u&&u()},I=null,p=!1,g=()=>{p=!0,I&&I()},w=null,C=()=>{w&&w()},l=()=>new Promise((T,A)=>{u=w=T,s=A,r.once("drain",C)}),x=()=>(e(t),new Promise((T,A)=>{if(h||p||n)return T();I=u=T,s=A})),M=()=>{r.removeListener("error",c),r.removeListener("close",m),r.removeListener("finish",g),r.removeListener("drain",C)};r.once("error",c),r.once("close",m),r.once("finish",g);try{for await(let T of t){if(!r.writable||r.destroyed||n)break;r.write(T)===!1&&await l()}}catch(T){n||r.destroy(),n=T}try{if(r.writable&&r.end(),await x(),n)throw n}finally{M()}}});var jn=V((l0,ni)=>{var zp=Vn(),Vp=sr();ni.exports=r=>({sink:zp(r),source:Vp(r)})});var oi=V((h0,si)=>{var jp=jn();si.exports=r=>async function*(t){let e=jp(r),n;if(e.sink(t).catch(s=>{n=s}),yield*e.source,n)throw n}});var ii=V((d0,le)=>{le.exports=sr();le.exports.source=sr();le.exports.sink=Vn();le.exports.transform=oi();le.exports.duplex=jn()});var el={};U(el,{tcp:()=>tl});var ui=G(mt("net"),1);var Gt=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"},ht=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ns=Symbol.for("@libp2p/transport");var rs;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(rs||(rs={}));var st=G(ds(),1);function vc(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 s=0;s<r.length;s++){var c=r.charAt(s),u=c.charCodeAt(0);if(e[u]!==255)throw new TypeError(c+" is ambiguous");e[u]=s}var h=r.length,m=r.charAt(0),I=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,M=0,T=0,A=l.length;T!==A&&l[T]===0;)T++,x++;for(var R=(A-T)*p+1>>>0,B=new Uint8Array(R);T!==A;){for(var P=l[T],O=0,D=R-1;(P!==0||O<M)&&D!==-1;D--,O++)P+=256*B[D]>>>0,B[D]=P%h>>>0,P=P/h>>>0;if(P!==0)throw new Error("Non-zero carry");M=O,T++}for(var k=R-M;k!==R&&B[k]===0;)k++;for(var $=m.repeat(x);k<R;++k)$+=r.charAt(B[k]);return $}function w(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var M=0,T=0;l[x]===m;)M++,x++;for(var A=(l.length-x)*I+1>>>0,R=new Uint8Array(A);l[x];){var B=e[l.charCodeAt(x)];if(B===255)return;for(var P=0,O=A-1;(B!==0||P<T)&&O!==-1;O--,P++)B+=h*R[O]>>>0,R[O]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");T=P,x++}if(l[x]!==" "){for(var D=A-T;D!==A&&R[D]===0;)D++;for(var k=new Uint8Array(M+(A-D)),$=M;D!==A;)k[$++]=R[D++];return k}}}function C(l){var x=w(l);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:C}}var xc=vc,Sc=xc,ms=Sc;var pl=new Uint8Array(0);var bs=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 mr=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")}},br=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 gs(this,t)}},gr=class{constructor(t){this.decoders=t}or(t){return gs(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`)}},gs=(r,t)=>new gr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),wr=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new mr(t,e,n),this.decoder=new br(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ws=({name:r,prefix:t,encode:e,decode:n})=>new wr(r,t,e,n),yr=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:s}=ms(e,t);return ws({prefix:r,name:t,encode:n,decode:c=>bs(s(c))})},Tc=(r,t,e,n)=>{let s={};for(let p=0;p<t.length;++p)s[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*e/8|0),h=0,m=0,I=0;for(let p=0;p<c;++p){let g=s[r[p]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<e|g,h+=e,h>=8&&(h-=8,u[I++]=255&m>>h)}if(h>=e||255&m<<8-h)throw new SyntaxError("Unexpected end of data");return u},Cc=(r,t,e)=>{let n=t[t.length-1]==="=",s=(1<<e)-1,c="",u=0,h=0;for(let m=0;m<r.length;++m)for(h=h<<8|r[m],u+=8;u>e;)u-=e,c+=t[s&h>>u];if(u&&(c+=t[s&h<<e-u]),n)for(;c.length*e&7;)c+="=";return c},Y=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>ws({prefix:t,name:r,encode(s){return Cc(s,n,e)},decode(s){return Tc(s,n,e,r)}});var ys=Y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gl=Y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wl=Y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yl=Y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vl=Y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xl=Y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sl=Y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tl=Y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cl=Y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vs=yr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Il=yr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xs=Y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Rl=Y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dl=Y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pl=Y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});st.default.formatters.b=r=>r==null?"undefined":vs.baseEncode(r);st.default.formatters.t=r=>r==null?"undefined":ys.baseEncode(r);st.default.formatters.m=r=>r==null?"undefined":xs.baseEncode(r);st.default.formatters.p=r=>r==null?"undefined":r.toString();st.default.formatters.c=r=>r==null?"undefined":r.toString();st.default.formatters.k=r=>r==null?"undefined":r.toString();st.default.formatters.a=r=>r==null?"undefined":r.toString();function Ac(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Et(r){let t=Ac(`${r}:trace`);return st.default.enabled(`${r}:trace`)&&st.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,st.default)(`${r}:trace`)),Object.assign((0,st.default)(r),{error:(0,st.default)(`${r}:error`),trace:t})}var ke=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Cr={};U(Cr,{base58btc:()=>K,base58flickr:()=>Dc});function Ec(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 s=0;s<r.length;s++){var c=r.charAt(s),u=c.charCodeAt(0);if(e[u]!==255)throw new TypeError(c+" is ambiguous");e[u]=s}var h=r.length,m=r.charAt(0),I=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,M=0,T=0,A=l.length;T!==A&&l[T]===0;)T++,x++;for(var R=(A-T)*p+1>>>0,B=new Uint8Array(R);T!==A;){for(var P=l[T],O=0,D=R-1;(P!==0||O<M)&&D!==-1;D--,O++)P+=256*B[D]>>>0,B[D]=P%h>>>0,P=P/h>>>0;if(P!==0)throw new Error("Non-zero carry");M=O,T++}for(var k=R-M;k!==R&&B[k]===0;)k++;for(var $=m.repeat(x);k<R;++k)$+=r.charAt(B[k]);return $}function w(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var M=0,T=0;l[x]===m;)M++,x++;for(var A=(l.length-x)*I+1>>>0,R=new Uint8Array(A);l[x];){var B=e[l.charCodeAt(x)];if(B===255)return;for(var P=0,O=A-1;(B!==0||P<T)&&O!==-1;O--,P++)B+=h*R[O]>>>0,R[O]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");T=P,x++}if(l[x]!==" "){for(var D=A-T;D!==A&&R[D]===0;)D++;for(var k=new Uint8Array(M+(A-D)),$=M;D!==A;)k[$++]=R[D++];return k}}}function C(l){var x=w(l);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:C}}var Ic=Ec,Bc=Ic,Ss=Bc;var $l=new Uint8Array(0);var Ts=(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 Cs=r=>new TextEncoder().encode(r),As=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 Is(this,t)}},Sr=class{constructor(t){this.decoders=t}or(t){return Is(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`)}},Is=(r,t)=>new Sr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Tr=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new vr(t,e,n),this.decoder=new xr(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Wt=({name:r,prefix:t,encode:e,decode:n})=>new Tr(r,t,e,n),It=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:s}=Ss(e,t);return Wt({prefix:r,name:t,encode:n,decode:c=>ct(s(c))})},Mc=(r,t,e,n)=>{let s={};for(let p=0;p<t.length;++p)s[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*e/8|0),h=0,m=0,I=0;for(let p=0;p<c;++p){let g=s[r[p]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<e|g,h+=e,h>=8&&(h-=8,u[I++]=255&m>>h)}if(h>=e||255&m<<8-h)throw new SyntaxError("Unexpected end of data");return u},Rc=(r,t,e)=>{let n=t[t.length-1]==="=",s=(1<<e)-1,c="",u=0,h=0;for(let m=0;m<r.length;++m)for(h=h<<8|r[m],u+=8;u>e;)u-=e,c+=t[s&h>>u];if(u&&(c+=t[s&h<<e-u]),n)for(;c.length*e&7;)c+="=";return c},_=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Wt({prefix:t,name:r,encode(s){return Rc(s,n,e)},decode(s){return Mc(s,n,e,r)}});var K=It({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dc=It({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pc=Rs,Bs=128,kc=127,Oc=~kc,Nc=Math.pow(2,31);function Rs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Nc;)t[e++]=r&255|Bs,r/=128;for(;r&Oc;)t[e++]=r&255|Bs,r>>>=7;return t[e]=r|0,Rs.bytes=e-n+1,t}var Fc=Ar,Uc=128,Ms=127;function Ar(r,n){var e=0,n=n||0,s=0,c=n,u,h=r.length;do{if(c>=h)throw Ar.bytes=0,new RangeError("Could not decode varint");u=r[c++],e+=s<28?(u&Ms)<<s:(u&Ms)*Math.pow(2,s),s+=7}while(u>=Uc);return Ar.bytes=c-n,e}var _c=Math.pow(2,7),Lc=Math.pow(2,14),$c=Math.pow(2,21),zc=Math.pow(2,28),Vc=Math.pow(2,35),jc=Math.pow(2,42),qc=Math.pow(2,49),Gc=Math.pow(2,56),Hc=Math.pow(2,63),Zc=function(r){return r<_c?1:r<Lc?2:r<$c?3:r<zc?4:r<Vc?5:r<jc?6:r<qc?7:r<Gc?8:r<Hc?9:10},Jc={encode:Pc,decode:Fc,encodingLength:Zc},Xc=Jc,me=Xc;var be=(r,t=0)=>[me.decode(r,t),me.decode.bytes],Qt=(r,t,e=0)=>(me.encode(r,t,e),t),Yt=r=>me.encodingLength(r);var Ut=(r,t)=>{let e=t.byteLength,n=Yt(r),s=n+Yt(e),c=new Uint8Array(s+e);return Qt(r,c,0),Qt(e,c,n),c.set(t,s),new Kt(r,e,t,c)},Ne=r=>{let t=ct(r),[e,n]=be(t),[s,c]=be(t.subarray(n)),u=t.subarray(n+c);if(u.byteLength!==s)throw new Error("Incorrect length");return new Kt(e,s,u,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&&Ts(r.bytes,e.bytes)}},Kt=class{constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Er={};U(Er,{base32:()=>xt,base32hex:()=>Kc,base32hexpad:()=>ef,base32hexpadupper:()=>rf,base32hexupper:()=>tf,base32pad:()=>Qc,base32padupper:()=>Yc,base32upper:()=>Wc,base32z:()=>nf});var xt=_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wc=_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qc=_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yc=_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Kc=_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),tf=_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ef=_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rf=_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nf=_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ps=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return of(e,Ir(r),t||K.encoder);default:return af(e,Ir(r),t||xt.encoder)}};var ks=new WeakMap,Ir=r=>{let t=ks.get(r);if(t==null){let e=new Map;return ks.set(r,e),e}return t},Bt=class r{constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}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!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==cf)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=Ut(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 Ps(this,t)}toJSON(){return{"/":Ps(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:s,multihash:c,bytes:u}=e;return new r(n,s,c,u||Os(n,s,c.bytes))}else if(e[ff]===!0){let{version:n,multihash:s,code:c}=e,u=Ne(s);return r.create(n,c,u)}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!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=Os(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ge,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,s=ct(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let c=s.subarray(e.multihashSize-e.digestSize),u=new Kt(e.multihashCode,e.digestSize,c,s);return[e.version===0?r.createV0(u):r.createV1(e.codec,u),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=be(t.subarray(e));return e+=w,g},s=n(),c=ge;if(s===18?(s=0,e=0):c=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let u=e,h=n(),m=n(),I=e+m,p=I-u;return{version:s,codec:c,multihashCode:h,digestSize:m,multihashSize:p,size:I}}static parse(t,e){let[n,s]=sf(t,e),c=r.decode(s);if(c.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ir(c).set(n,t),c}},sf=(r,t)=>{switch(r[0]){case"Q":{let e=t||K;return[K.prefix,e.decode(`${K.prefix}${r}`)]}case K.prefix:{let e=t||K;return[K.prefix,e.decode(r)]}case xt.prefix:{let e=t||xt;return[xt.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)]}}},of=(r,t,e)=>{let{prefix:n}=e;if(n!==K.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let c=e.encode(r).slice(1);return t.set(n,c),c}else return s},af=(r,t,e)=>{let{prefix:n}=e,s=t.get(n);if(s==null){let c=e.encode(r);return t.set(n,c),c}else return s},ge=112,cf=18,Os=(r,t,e)=>{let n=Yt(r),s=n+Yt(t),c=new Uint8Array(s+e.byteLength);return Qt(r,c,0),Qt(t,c,n),c.set(e,s),c},ff=Symbol.for("@ipld/js-cid/CID");function Ns(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 Pr={};U(Pr,{identity:()=>mf});function uf(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 s=0;s<r.length;s++){var c=r.charAt(s),u=c.charCodeAt(0);if(e[u]!==255)throw new TypeError(c+" is ambiguous");e[u]=s}var h=r.length,m=r.charAt(0),I=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,M=0,T=0,A=l.length;T!==A&&l[T]===0;)T++,x++;for(var R=(A-T)*p+1>>>0,B=new Uint8Array(R);T!==A;){for(var P=l[T],O=0,D=R-1;(P!==0||O<M)&&D!==-1;D--,O++)P+=256*B[D]>>>0,B[D]=P%h>>>0,P=P/h>>>0;if(P!==0)throw new Error("Non-zero carry");M=O,T++}for(var k=R-M;k!==R&&B[k]===0;)k++;for(var $=m.repeat(x);k<R;++k)$+=r.charAt(B[k]);return $}function w(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var M=0,T=0;l[x]===m;)M++,x++;for(var A=(l.length-x)*I+1>>>0,R=new Uint8Array(A);l[x];){var B=e[l.charCodeAt(x)];if(B===255)return;for(var P=0,O=A-1;(B!==0||P<T)&&O!==-1;O--,P++)B+=h*R[O]>>>0,R[O]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");T=P,x++}if(l[x]!==" "){for(var D=A-T;D!==A&&R[D]===0;)D++;for(var k=new Uint8Array(M+(A-D)),$=M;D!==A;)k[$++]=R[D++];return k}}}function C(l){var x=w(l);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:C}}var pf=uf,lf=pf,Fs=lf;var rh=new Uint8Array(0);var Us=(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},ft=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 _s=r=>new TextEncoder().encode(r),Ls=r=>new TextDecoder().decode(r);var Br=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")}},Mr=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 zs(this,t)}},Rr=class{constructor(t){this.decoders=t}or(t){return zs(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`)}},zs=(r,t)=>new Rr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Dr=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new Br(t,e,n),this.decoder=new Mr(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ee=({name:r,prefix:t,encode:e,decode:n})=>new Dr(r,t,e,n),Mt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:s}=Fs(e,t);return ee({prefix:r,name:t,encode:n,decode:c=>ft(s(c))})},hf=(r,t,e,n)=>{let s={};for(let p=0;p<t.length;++p)s[t[p]]=p;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*e/8|0),h=0,m=0,I=0;for(let p=0;p<c;++p){let g=s[r[p]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<e|g,h+=e,h>=8&&(h-=8,u[I++]=255&m>>h)}if(h>=e||255&m<<8-h)throw new SyntaxError("Unexpected end of data");return u},df=(r,t,e)=>{let n=t[t.length-1]==="=",s=(1<<e)-1,c="",u=0,h=0;for(let m=0;m<r.length;++m)for(h=h<<8|r[m],u+=8;u>e;)u-=e,c+=t[s&h>>u];if(u&&(c+=t[s&h<<e-u]),n)for(;c.length*e&7;)c+="=";return c},L=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>ee({prefix:t,name:r,encode(s){return df(s,n,e)},decode(s){return hf(s,n,e,r)}});var mf=ee({prefix:"\0",name:"identity",encode:r=>Ls(r),decode:r=>_s(r)});var kr={};U(kr,{base2:()=>bf});var bf=L({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Or={};U(Or,{base8:()=>gf});var gf=L({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Nr={};U(Nr,{base10:()=>wf});var wf=Mt({prefix:"9",name:"base10",alphabet:"0123456789"});var Fr={};U(Fr,{base16:()=>yf,base16upper:()=>vf});var yf=L({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vf=L({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ur={};U(Ur,{base32:()=>re,base32hex:()=>Cf,base32hexpad:()=>Ef,base32hexpadupper:()=>If,base32hexupper:()=>Af,base32pad:()=>Sf,base32padupper:()=>Tf,base32upper:()=>xf,base32z:()=>Bf});var re=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xf=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Sf=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tf=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Cf=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Af=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ef=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),If=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bf=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _r={};U(_r,{base36:()=>Mf,base36upper:()=>Rf});var Mf=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Rf=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Lr={};U(Lr,{base58btc:()=>bt,base58flickr:()=>Df});var bt=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Df=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $r={};U($r,{base64:()=>Pf,base64pad:()=>kf,base64url:()=>Of,base64urlpad:()=>Nf});var Pf=L({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),kf=L({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Of=L({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Nf=L({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zr={};U(zr,{base256emoji:()=>$f});var Vs=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}"),Ff=Vs.reduce((r,t,e)=>(r[e]=t,r),[]),Uf=Vs.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function _f(r){return r.reduce((t,e)=>(t+=Ff[e],t),"")}function Lf(r){let t=[];for(let e of r){let n=Uf[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var $f=ee({prefix:"\u{1F680}",name:"base256emoji",encode:_f,decode:Lf});var Hr={};U(Hr,{sha256:()=>ou,sha512:()=>iu});var Gr=G(mt("crypto"),1);var zf=Gs,js=128,Vf=127,jf=~Vf,qf=Math.pow(2,31);function Gs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=qf;)t[e++]=r&255|js,r/=128;for(;r&jf;)t[e++]=r&255|js,r>>>=7;return t[e]=r|0,Gs.bytes=e-n+1,t}var Gf=Vr,Hf=128,qs=127;function Vr(r,n){var e=0,n=n||0,s=0,c=n,u,h=r.length;do{if(c>=h)throw Vr.bytes=0,new RangeError("Could not decode varint");u=r[c++],e+=s<28?(u&qs)<<s:(u&qs)*Math.pow(2,s),s+=7}while(u>=Hf);return Vr.bytes=c-n,e}var Zf=Math.pow(2,7),Jf=Math.pow(2,14),Xf=Math.pow(2,21),Wf=Math.pow(2,28),Qf=Math.pow(2,35),Yf=Math.pow(2,42),Kf=Math.pow(2,49),tu=Math.pow(2,56),eu=Math.pow(2,63),ru=function(r){return r<Zf?1:r<Jf?2:r<Xf?3:r<Wf?4:r<Qf?5:r<Yf?6:r<Kf?7:r<tu?8:r<eu?9:10},nu={encode:zf,decode:Gf,encodingLength:ru},su=nu,we=su;var ye=(r,t=0)=>[we.decode(r,t),we.decode.bytes],ne=(r,t,e=0)=>(we.encode(r,t,e),t),se=r=>we.encodingLength(r);var _t=(r,t)=>{let e=t.byteLength,n=se(r),s=n+se(e),c=new Uint8Array(s+e);return ne(r,c,0),ne(e,c,n),c.set(t,s),new oe(r,e,t,c)},Hs=r=>{let t=ft(r),[e,n]=ye(t),[s,c]=ye(t.subarray(n)),u=t.subarray(n+c);if(u.byteLength!==s)throw new Error("Incorrect length");return new oe(e,s,u,t)},Zs=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Us(r.bytes,e.bytes)}},oe=class{constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var qr=({name:r,code:t,encode:e})=>new jr(r,t,e),jr=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 ou=qr({name:"sha2-256",code:18,encode:r=>ft(Gr.default.createHash("sha256").update(r).digest())}),iu=qr({name:"sha2-512",code:19,encode:r=>ft(Gr.default.createHash("sha512").update(r).digest())});var Zr={};U(Zr,{identity:()=>fu});var Xs=0,au="identity",Ws=ft,cu=r=>_t(Xs,Ws(r)),fu={code:Xs,name:au,encode:Ws,digest:cu};var Ch=new TextEncoder,Ah=new TextDecoder;var Qs=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return hu(e,Jr(r),t||bt.encoder);default:return du(e,Jr(r),t||re.encoder)}};var Ys=new WeakMap,Jr=r=>{let t=Ys.get(r);if(t==null){let e=new Map;return Ys.set(r,e),e}return t},Ue=class r{constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}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!==mu)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&&Zs(t.multihash,n.multihash)}toString(t){return Qs(this,t)}toJSON(){return{"/":Qs(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:s,multihash:c,bytes:u}=e;return new r(n,s,c,u||Ks(n,s,c.bytes))}else if(e[bu]===!0){let{version:n,multihash:s,code:c}=e,u=Hs(s);return r.create(n,c,u)}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 s=Ks(t,e,n.bytes);return new r(t,e,n,s)}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,s=ft(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let c=s.subarray(e.multihashSize-e.digestSize),u=new oe(e.multihashCode,e.digestSize,c,s);return[e.version===0?r.createV0(u):r.createV1(e.codec,u),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=ye(t.subarray(e));return e+=w,g},s=n(),c=xe;if(s===18?(s=0,e=0):c=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let u=e,h=n(),m=n(),I=e+m,p=I-u;return{version:s,codec:c,multihashCode:h,digestSize:m,multihashSize:p,size:I}}static parse(t,e){let[n,s]=lu(t,e),c=r.decode(s);if(c.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Jr(c).set(n,t),c}},lu=(r,t)=>{switch(r[0]){case"Q":{let e=t||bt;return[bt.prefix,e.decode(`${bt.prefix}${r}`)]}case bt.prefix:{let e=t||bt;return[bt.prefix,e.decode(r)]}case re.prefix:{let e=t||re;return[re.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)]}}},hu=(r,t,e)=>{let{prefix:n}=e;if(n!==bt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let c=e.encode(r).slice(1);return t.set(n,c),c}else return s},du=(r,t,e)=>{let{prefix:n}=e,s=t.get(n);if(s==null){let c=e.encode(r);return t.set(n,c),c}else return s},xe=112,mu=18,Ks=(r,t,e)=>{let n=se(r),s=n+se(t),c=new Uint8Array(s+e.byteLength);return ne(r,c,0),ne(t,c,n),c.set(e,s),c},bu=Symbol.for("@ipld/js-cid/CID");var Xr={...Pr,...kr,...Or,...Nr,...Fr,...Ur,..._r,...Lr,...$r,...zr},Nh={...Hr,...Zr};function ie(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function _e(r=0){return globalThis.Buffer?.allocUnsafe!=null?ie(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function eo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var to=eo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Wr=eo("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}),gu={utf8:to,"utf-8":to,hex:Xr.base16,latin1:Wr,ascii:Wr,binary:Wr,...Xr},Le=gu;function tt(r,t="utf8"){let e=Le[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 Tn=G($e(),1);function St(r,t){t==null&&(t=r.reduce((s,c)=>s+c.length,0));let e=_e(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return ie(e)}var ae=G($e(),1);var ze=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,s){return this.readAtomically(()=>{let c=0,u=0,h=this.peekChar();if(h===void 0)return;let m=h==="0",I=2**(8*s)-1;for(;;){let p=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(p===void 0)break;if(c*=t,c+=p,c>I||(u+=1,e!==void 0&&u>e))return}if(u!==0)return!n&&m&&u>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 s=n*2;if(n<e.length-3){let u=this.readSeparator(":",n,()=>this.readIPv4Addr());if(u!==void 0)return e[s]=u[0],e[s+1]=u[1],e[s+2]=u[2],e[s+3]=u[3],[s+4,!0]}let c=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(c===void 0)return[s,!1];e[s]=c>>8,e[s+1]=c&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let c=new Uint8Array(14),u=16-(n+2),[h]=t(c.subarray(0,u));return e.set(c.subarray(0,h),16-h),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var td=new ze;var cd=parseInt("0xFFFF",16),fd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Kr={};U(Kr,{identity:()=>Fu});var Fu=Wt({prefix:"\0",name:"identity",encode:r=>As(r),decode:r=>Cs(r)});var tn={};U(tn,{base2:()=>Uu});var Uu=_({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var en={};U(en,{base8:()=>_u});var _u=_({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var rn={};U(rn,{base10:()=>Lu});var Lu=It({prefix:"9",name:"base10",alphabet:"0123456789"});var nn={};U(nn,{base16:()=>$u,base16upper:()=>zu});var $u=_({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zu=_({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var sn={};U(sn,{base36:()=>Vu,base36upper:()=>ju});var Vu=It({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ju=It({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var on={};U(on,{base64:()=>qu,base64pad:()=>Gu,base64url:()=>Hu,base64urlpad:()=>Zu});var qu=_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gu=_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hu=_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zu=_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var an={};U(an,{base256emoji:()=>Yu});var ho=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ju=ho.reduce((r,t,e)=>(r[e]=t,r),[]),Xu=ho.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Wu(r){return r.reduce((t,e)=>(t+=Ju[e],t),"")}function Qu(r){let t=[];for(let e of r){let n=Xu[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Yu=Wt({prefix:"\u{1F680}",name:"base256emoji",encode:Wu,decode:Qu});var pn={};U(pn,{sha256:()=>Ku,sha512:()=>tp});var un=G(mt("crypto"),1);var fn=({name:r,code:t,encode:e})=>new cn(r,t,e),cn=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?Ut(this.code,e):e.then(n=>Ut(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ku=fn({name:"sha2-256",code:18,encode:r=>ct(un.default.createHash("sha256").update(r).digest())}),tp=fn({name:"sha2-512",code:19,encode:r=>ct(un.default.createHash("sha512").update(r).digest())});var ln={};U(ln,{identity:()=>np});var bo=0,ep="identity",go=ct,rp=r=>Ut(bo,go(r)),np={code:bo,name:ep,encode:go,digest:rp};var Hd=new TextEncoder,Zd=new TextDecoder;var wo={...Kr,...tn,...en,...rn,...nn,...Er,...sn,...Cr,...on,...an},Yd={...pn,...ln};function hn(r,t="utf8"){let e=Le[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ie(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var gt=G($e(),1);var Rt=mt("node:net");function Ve(r){return!!(0,Rt.isIP)(r)}var yo=Rt.isIPv4,ip=Rt.isIPv6,dn=function(r){let t=0;if(r=r.toString().trim(),yo(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ip(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let c=yo(e[n]),u;c&&(u=dn(e[n]),e[n]=tt(u.slice(0,2),"base16")),u!=null&&++n<8&&e.splice(n,0,tt(u.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 s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let c=parseInt(e[n],16);s[t++]=c>>8&255,s[t++]=c&255}return s}throw new Error("invalid ip address")},vo=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let c=0;c<e;c++)s.push(r[t+c]);return s.join(".")}if(e===16){let s=[];for(let c=0;c<e;c+=2)s.push(n.getUint16(t+c).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Se={},mn={},cp=[[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"]];cp.forEach(r=>{let t=fp(...r);mn[t.code]=t,Se[t.name]=t});function fp(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function N(r){if(typeof r=="number"){if(mn[r]!=null)return mn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Se[r]!=null)return Se[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var gm=N("ip4"),wm=N("ip6"),ym=N("ipcidr");function Ao(r,t){switch(N(r).code){case 4:case 41:return pp(t);case 42:return To(t);case 6:case 273:case 33:case 132:return Io(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return To(t);case 421:return mp(t);case 444:return Co(t);case 445:return Co(t);case 466:return dp(t);default:return tt(t,"base16")}}function Eo(r,t){switch(N(r).code){case 4:return xo(t);case 41:return xo(t);case 42:return So(t);case 6:case 273:case 33:case 132:return gn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return So(t);case 421:return lp(t);case 444:return bp(t);case 445:return gp(t);case 466:return hp(t);default:return hn(t,"base16")}}var bn=Object.values(wo).map(r=>r.decoder),up=function(){let r=bn[0].or(bn[1]);return bn.slice(2).forEach(t=>r=r.or(t)),r}();function xo(r){if(!Ve(r))throw new Error("invalid ip address");return dn(r)}function pp(r){let t=vo(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ve(t))throw new Error("invalid ip address");return t}function gn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Io(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function So(r){let t=hn(r),e=Uint8Array.from(gt.default.encode(t.length));return St([e,t],e.length+t.length)}function To(r){let t=gt.default.decode(r);if(r=r.slice(gt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return tt(r)}function lp(r){let t;r[0]==="Q"||r[0]==="1"?t=Ne(K.decode(`z${r}`)).bytes:t=Bt.parse(r).multihash.bytes;let e=Uint8Array.from(gt.default.encode(t.length));return St([e,t],e.length+t.length)}function hp(r){let t=up.decode(r),e=Uint8Array.from(gt.default.encode(t.length));return St([e,t],e.length+t.length)}function dp(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"+tt(e,"base64url")}function mp(r){let t=gt.default.decode(r),e=r.slice(gt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return tt(e,"base58btc")}function bp(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=xt.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 s=gn(n);return St([e,s],e.length+s.length)}function gp(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=xt.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 s=gn(n);return St([e,s],e.length+s.length)}function Co(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=tt(t,"base32"),s=Io(e);return`${n}:${s}`}function wp(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let s=e[n],c=N(s);if(c.size===0){t.push([s]);continue}if(n++,n>=e.length)throw Mo("invalid address: "+r);if(c.path===!0){t.push([s,Sn(e.slice(n).join("/"))]);break}t.push([s,e[n]])}return t}function yp(r){let t=[];return r.map(e=>{let n=Ge(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Sn(t.join("/"))}function vp(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Ge(t);return t.length>1?[e.code,Eo(e.code,t[1])]:[e.code]})}function wn(r){return r.map(t=>{let e=Ge(t);return t[1]!=null?[e.code,Ao(e.code,t[1])]:[e.code]})}function yn(r){return qe(St(r.map(t=>{let e=Ge(t),n=Uint8Array.from(ae.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=St([n,t[1]])),n})))}function vn(r,t){return r.size>0?r.size/8:r.size===0?0:ae.default.decode(t)+(ae.default.decode.bytes??0)}function je(r){let t=[],e=0;for(;e<r.length;){let n=ae.default.decode(r,e),s=ae.default.decode.bytes??0,c=N(n),u=vn(c,r.slice(e+s));if(u===0){t.push([n]),e+=s;continue}let h=r.slice(e+s,e+s+u);if(e+=u+s,e>r.length)throw Mo("Invalid address Uint8Array: "+tt(r,"base16"));t.push([n,h])}return t}function xn(r){let t=je(r),e=wn(t);return yp(e)}function xp(r){r=Sn(r);let t=wp(r),e=vp(t);return yn(e)}function Bo(r){return xp(r)}function qe(r){let t=Sp(r);if(t!=null)throw t;return Uint8Array.from(r)}function Sp(r){try{je(r)}catch(t){return t}}function Sn(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Mo(r){return new Error("Error parsing address: "+r)}function Ge(r){return N(r[0])}var Cp=Symbol.for("nodejs.util.inspect.custom"),Ap=[N("dns").code,N("dns4").code,N("dns6").code,N("dnsaddr").code],Ep=new Map,Ro=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Ip(r){return!!r?.[Ro]}var Cn=class r{bytes;#t;#r;#n;#e;[Ro]=!0;constructor(t){if(t==null&&(t=""),t instanceof Uint8Array)this.bytes=qe(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Bo(t)}else if(Ip(t))this.bytes=qe(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=xn(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,s,c="",u=N("tcp"),h=N("udp"),m=N("ip4"),I=N("ip6"),p=N("dns6"),g=N("ip6zone");for(let[C,l]of this.stringTuples())C===g.code&&(c=`%${l??""}`),Ap.includes(C)&&(e=u.name,s=443,n=`${l??""}${c}`,t=C===p.code?6:4),(C===u.code||C===h.code)&&(e=N(C).name,s=parseInt(l??"")),(C===m.code||C===I.code)&&(e=N(C).name,n=`${l??""}${c}`,t=C===I.code?6:4);if(t==null||e==null||n==null||s==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:s}}protos(){return this.protoCodes().map(t=>Object.assign({},N(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let s=Tn.default.decode(e,n),c=Tn.default.decode.bytes??0,u=N(s),h=vn(u,e.slice(n+c));n+=h+c,t.push(s)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return this.#r==null&&(this.#r=je(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=wn(this.tuples())),this.#n}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(yn(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Se.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?tt(K.decode(`z${n}`),"base58btc"):tt(Bt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(t=>N(t[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(t){return Ns(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(c=>c.resolvable);if(e==null)return[this];let n=Ep.get(e.name);if(n==null)throw new ke(`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)}[Cp](){return`Multiaddr(${xn(this.bytes)})`}};function wt(r){return new Cn(r)}var Bp=v("dns4"),Mp=v("dns6"),Rp=v("dnsaddr"),$t=z(v("dns"),Rp,Bp,Mp),Je=z(v("ip4"),v("ip6")),Pt=z(E(Je,v("tcp")),E($t,v("tcp"))),Xe=E(Je,v("udp")),Dp=E(Xe,v("utp")),Pp=E(Xe,v("quic")),kp=E(Xe,v("quic-v1")),An=z(E(Pt,v("ws")),E($t,v("ws"))),He=z(E(An,v("p2p")),An),En=z(E(Pt,v("wss")),E($t,v("wss")),E(Pt,v("tls"),v("ws")),E($t,v("tls"),v("ws"))),Ze=z(E(En,v("p2p")),En),In=z(E(Pt,v("http")),E(Je,v("http")),E($t,v("http"))),Bn=z(E(Pt,v("https")),E(Je,v("https")),E($t,v("https"))),Do=E(Xe,v("webrtc-direct"),v("certhash")),Oo=z(E(Do,v("p2p")),Do),Po=E(kp,v("webtransport"),v("certhash"),v("certhash")),No=z(E(Po,v("p2p")),Po),Fo=z(E(He,v("p2p-webrtc-star"),v("p2p")),E(Ze,v("p2p-webrtc-star"),v("p2p")),E(He,v("p2p-webrtc-star")),E(Ze,v("p2p-webrtc-star"))),Lm=z(E(He,v("p2p-websocket-star"),v("p2p")),E(Ze,v("p2p-websocket-star"),v("p2p")),E(He,v("p2p-websocket-star")),E(Ze,v("p2p-websocket-star"))),Uo=z(E(In,v("p2p-webrtc-direct"),v("p2p")),E(Bn,v("p2p-webrtc-direct"),v("p2p")),E(In,v("p2p-webrtc-direct")),E(Bn,v("p2p-webrtc-direct"))),zt=z(An,En,In,Bn,Fo,Uo,Pt,Dp,Pp,$t,Oo,No),$m=z(E(zt,v("p2p-stardust"),v("p2p")),E(zt,v("p2p-stardust"))),Dt=z(E(zt,v("p2p")),Fo,Uo,Oo,No,v("p2p")),ko=z(E(Dt,v("p2p-circuit"),Dt),E(Dt,v("p2p-circuit")),E(v("p2p-circuit"),Dt),E(zt,v("p2p-circuit")),E(v("p2p-circuit"),zt),v("p2p-circuit")),_o=()=>z(E(ko,_o),ko),Lt=_o(),zm=z(E(Lt,Dt,Lt),E(Dt,Lt),E(Lt,Dt),Lt,Dt);var Vm=z(E(Lt,v("webrtc"),v("p2p")),E(Lt,v("webrtc")),E(zt,v("webrtc"),v("p2p")),E(zt,v("webrtc")),v("webrtc"));function Lo(r){function t(e){let n;try{n=wt(e)}catch{return!1}let s=r(n.protoNames());return s===null?!1:s===!0||s===!1?s:s.length===0}return t}function E(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(s=>(n=typeof s=="function"?s().partialMatch(e):s.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Lo(t),partialMatch:t}}function z(...r){function t(n){let s=null;return r.some(c=>{let u=typeof c=="function"?c().partialMatch(n):c.partialMatch(n);return u!=null?(s=u,!0):!1}),s}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Lo(t),partialMatch:t}}function v(r){let t=r;function e(s){let c;try{c=wt(s)}catch{return!1}let u=c.protoNames();return u.length===1&&u[0]===t}function n(s){return s.length===0?null:s[0]===t?s.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var fi=G(mt("net"),1);var We=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 s=this.#t.get(t);s==null&&(s=[],this.#t.set(t,s)),s.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let s=this.#t.get(t);s!=null&&(s=s.filter(({callback:c})=>c!==e),this.#t.set(t,s))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:s})=>!s),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new ce(t,e))}},Mn=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},ce=globalThis.CustomEvent??Mn;function Qe(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Ye(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var fe=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,Rn=/\/\d{1,2}$/;var J=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var ue=G(Dn(),1),Vt=G(Te(),1),ot=class r{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Ye(32),this.isInSubnet=Qe,this.address=t;let e=Rn.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(Rn,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new r(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(fe))throw new 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=[],s;for(s=0;s<8;s+=2){let c=e.slice(s,s+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,Vt.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,Vt.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,Vt.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new ue.BigInteger(this.parsedAddress.map(t=>(0,Vt.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new ue.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new ue.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new ue.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new ue.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,Vt.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new r("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(fe,(0,Vt.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 qo={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},Pn={"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"},kn=/([^0-9a-f:/%])/gi,On=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Nn=/\/\d{1,3}(?=%|$)/,Fn=/%.*$/,Go=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Ho=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Jo=G(Te(),1);function Np(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function er(r,t=0){return r.split(":").map((n,s)=>/group-v4/.test(n)?n:(0,Jo.sprintf)('<span class="hover-group group-%d">%s</span>',s+t,Np(n)))}var qt=G(Te(),1);function _n(r){return(0,qt.sprintf)("(%s)",r.join("|"))}function Un(r){return r.length<4?(0,qt.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ln="[^A-Fa-f0-9:]";function rr(r){let t=[];r.forEach((n,s)=>{parseInt(n,16)===0&&t.push(s)});let e=t.map(n=>r.map((s,c)=>{if(c===n){let u=c===0||c===8-1?":":"";return _n([Un(s),u])}return Un(s)}).join(":"));return e.push(r.map(Un).join(":")),_n(e)}function $n(r,t,e){let n=t?"":":",s=e?"":":",c=[];!t&&!e&&c.push("::"),t&&e&&c.push(""),(e&&!t||!e&&t)&&c.push(":"),c.push((0,qt.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),c.push((0,qt.sprintf)("(0{1,4}:){1,%d}%s",r-1,s)),c.push((0,qt.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let u=1;u<r-1;u++)for(let h=1;h<r-u;h++)c.push((0,qt.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",h,r-h-u-1));return _n(c)}var X=G(Dn(),1),W=G(Te(),1);function nr(r){if(!r)throw new Error("Assertion failed.")}function Fp(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 _p(r,t){let e=[],n=[],s;for(s=0;s<r.length;s++)s<t[0]?e.push(r[s]):s>t[1]&&n.push(r[s]);return e.concat(["compact"]).concat(n)}function Wo(r){return(0,W.sprintf)("%04x",parseInt(r,16))}function Qo(r){return r&255}var Ce=class r{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Qe,this.isCorrect=Ye(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Nn.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(Nn,"")}else if(/\//.test(t))throw new J("Invalid subnet mask.");let s=Fn.exec(t);s&&(this.zone=s[0],t=t.replace(Fn,"")),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=[],s;for(s=0;s<8;s++)n.push(e.slice(s*4,(s+1)*4));return new r(n.join(":"))}static fromURL(t){let e,n=null,s;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(s=Ho.exec(t),s===null)return{error:"failed to parse address with port",address:null,port:null};e=s[1],n=s[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),s=Go.exec(t),s===null)return{error:"failed to parse address from URL",address:null,port:null};e=s[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 ot(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 s=e.split(".").reverse();for(let c=n;c>0;c--){let u=c*4;s.splice(u,0,":")}return e=s.join(""),new r(e)}microsoftTranscription(){return(0,W.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),s=e-n;return s<0?"0":Fp(new X.BigInteger("2",10).pow(s).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=qo[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(Pn))if(this.isInSubnet(new r(t)))return Pn[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,W.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,s=[];for(t=0;t<this.parsedAddress.length;t++){let h=parseInt(this.parsedAddress[t],16);h===0&&n++,h!==0&&n>0&&(n>1&&s.push([t-n,t-1]),n=0)}n>1&&s.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let c=s.map(h=>h[1]-h[0]+1);if(s.length>0){let h=c.indexOf(Math.max(...c));e=_p(this.parsedAddress,s[h])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let u=e.join(":");return u=u.replace(/^compact$/,"::"),u=u.replace(/^compact|compact$/,":"),u=u.replace(/compact/,""),u}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),s=e.slice(-1)[0].match(fe);if(s){this.parsedAddress4=s[0],this.address4=new ot(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(fe,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(kn);if(e)throw new J((0,W.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(kn,'<span class="parse-error">$1</span>'));let n=t.match(On);if(n)throw new J((0,W.sprintf)("Address failed regex: %s",n.join("")),t.replace(On,'<span class="parse-error">$1</span>'));let s=[],c=t.split("::");if(c.length===2){let u=c[0].split(":"),h=c[1].split(":");u.length===1&&u[0]===""&&(u=[]),h.length===1&&h[0]===""&&(h=[]);let m=this.groups-(u.length+h.length);if(!m)throw new J("Error parsing groups");this.elidedGroups=m,this.elisionBegin=u.length,this.elisionEnd=u.length+this.elidedGroups,s=s.concat(u);for(let I=0;I<m;I++)s.push("0");s=s.concat(h)}else if(c.length===1)s=t.split(":"),this.elidedGroups=0;else throw new J("Too many :: groups found");if(s=s.map(u=>(0,W.sprintf)("%x",parseInt(u,16))),s.length!==this.groups)throw new J("Incorrect number of groups found");return s}canonicalForm(){return this.parsedAddress.map(Wo).join(":")}decimal(){return this.parsedAddress.map(t=>(0,W.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new X.BigInteger(this.parsedAddress.map(Wo).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return ot.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(),s="";return/:$/.test(n)||(s=":"),n+s+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new X.BigInteger("ffff",16)).toString(),n=ot.fromHex(this.getBitsBase16(32,64)),s=ot.fromHex(this.getBits(96,128).xor(new X.BigInteger("ffffffff",16)).toString(16)),c=this.getBits(64,80),u=this.getBitsBase2(64,80),h=c.testBit(15),m=c.testBit(14),I=c.testBit(8),p=c.testBit(9),g=new X.BigInteger(u.slice(2,6)+u.slice(8,16),2).toString(10);return{prefix:(0,W.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:s.address,flags:u,coneNat:h,microsoft:{reserved:m,universalLocal:p,groupIndividual:I,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=ot.fromHex(this.getBitsBase16(16,48));return{prefix:(0,W.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(Qo)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Qo))}static fromUnsignedByteArray(t){let e=new X.BigInteger("256",10),n=new X.BigInteger("0",10),s=new X.BigInteger("1",10);for(let c=t.length-1;c>=0;c--)n=n.add(s.multiply(new X.BigInteger(t[c].toString(10),10))),s=s.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,W.sprintf)(":%s",t),(0,W.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,W.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,W.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return er(this.address).join(":");nr(typeof this.elidedGroups=="number"),nr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...er(e)):t.push("");let s=["hover-group"];for(let c=this.elisionBegin;c<this.elisionBegin+this.elidedGroups;c++)s.push((0,W.sprintf)("group-%d",c));return t.push((0,W.sprintf)('<span class="%s"></span>',s.join(" "))),n.length?t.push(...er(n,this.elisionEnd)):t.push(""),this.is4()&&(nr(this.address4 instanceof ot),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(rr(n.parsedAddress));else if(n.elidedGroups===8)e.push($n(8));else{let s=n.address.split("::");s[0].length&&e.push(rr(s[0].split(":"))),nr(typeof n.elidedGroups=="number"),e.push($n(n.elidedGroups,s[0].length!==0,s[1].length!==0)),s[1].length&&e.push(rr(s[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ln,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ln,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Lp=Et("libp2p:ip-port-to-multiaddr"),zn={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Yo(r,t){if(typeof r!="string")throw new ht(`invalid ip provided: ${r}`,zn.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new ht(`invalid port provided: ${t}`,zn.ERR_INVALID_PORT_PARAMETER);try{return new ot(r),wt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new Ce(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 Lp.error(n),new ht(n,zn.ERR_INVALID_IP)}}var ci=G(ii(),1);var qn=G(mt("os"),1),ai=G(mt("path"),1);var qp={ip4:"IPv4",ip6:"IPv6"};function he(r,t={}){let e=r.getPath();return e!=null?qn.default.platform()==="win32"?{path:ai.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function Gn(r,t,e){let n=s=>wt(`/${r}/${s}/tcp/${e}`);return(Gp(t)?Zp(qp[r]):[t]).map(n)}function Gp(r){return["0.0.0.0","::"].includes(r)}var Hp=qn.default.networkInterfaces();function Zp(r){let t=[];for(let[,e]of Object.entries(Hp))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var yt=Et("libp2p:tcp:socket"),or=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",s=t.socketInactivityTimeout??3e5,c=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let u;if(t.remoteAddr!=null)u=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new ht("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");u=Yo(r.remoteAddress,r.remotePort)}let h=he(u),m=h.path??`${h.host??""}:${h.port??""}`,{sink:I,source:p}=ci.default.duplex(r);r.setTimeout(s,()=>{yt("%s socket read timeout",m),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new ht("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{yt("%s socket close",m),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{yt("%s socket end",m),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await I(w)}catch(C){C.type!=="aborted"&&yt(C)}r.end()},source:p,remoteAddr:u,timeline:{open:Date.now()},async close(w={}){if(r.destroyed){yt("%s socket was already destroyed when trying to close",m);return}w.signal=w.signal??AbortSignal.timeout(c);try{yt("%s closing socket",m),await new Promise((C,l)=>{r.once("close",()=>{yt("%s socket closed",m),C()}),r.once("error",x=>{yt("%s socket error",m,x),g.timeline.close==null&&(g.timeline.close=Date.now()),l(x)}),r.setTimeout(c),r.end(),r.writableLength>0?r.once("drain",()=>{yt("%s socket drained",m),r.destroy()}):r.destroy()})}catch(C){this.abort(C)}},abort:w=>{yt("%s socket abort due to error",m,w),r.destroy(w)}};return g};var it=Et("libp2p:tcp:listener");async function Hn(r){try{await r.close()}catch(t){it.error("an error occurred closing the connection",t)}}var Wp=1,Qp=0,ir=class extends We{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=fi.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]:Wp})}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]:Qp}),this.dispatchEvent(new ce("close"))})}onSocket(t){t.on("error",n=>{it("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=or(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(s=>{it.error("error attempting to listen server once connection count under limit",s),this.context.closeServerOnMaxConnections?.onListenError?.(s)})}),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=>{it.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Hn(e)}).catch(n=>{it.error("closing inbound connection failed",n)})}catch(n){it.error("inbound connection failed",n),Hn(e).catch(s=>{it.error("closing inbound connection failed",s),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:s}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Gn("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Gn("ip6",e.address,e.port)))}catch(c){it.error("could not turn %s:%s into multiaddr",e.address,e.port,c)}return t.map(c=>s!=null?c.encapsulate(`/p2p/${s}`):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:s}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:he(n,{backlog:s})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Hn(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 Ct=Et("libp2p:tcp"),Jn=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"})})}[ns]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",h=>{Ct("socket error",h)});let s=or(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),c=()=>{s.close().catch(h=>{Ct.error("Error closing maConn after abort",h)})};e.signal?.addEventListener("abort",c,{once:!0}),Ct("new outbound connection %s",s.remoteAddr);let u=await e.upgrader.upgradeOutbound(s);if(Ct("outbound connection %s upgraded",s.remoteAddr),e.signal?.removeEventListener("abort",c),e.signal?.aborted===!0)throw u.close().catch(h=>{Ct.error("Error closing conn after abort",h)}),new Gt;return u}async _connect(t,e){if(e.signal?.aborted===!0)throw new Gt;return new Promise((n,s)=>{let c=Date.now(),u=he(t),h=u.path??`${u.host??""}:${u.port}`;Ct("dialing %j",u);let m=ui.default.connect(u),I=l=>{l.message=`connection error ${h}: ${l.message}`,this.metrics?.dialerEvents.increment({error:!0}),C(l)},p=()=>{Ct("connection timeout %s",h),this.metrics?.dialerEvents.increment({timeout:!0});let l=new ht(`connection timeout after ${Date.now()-c}ms`,"ERR_CONNECT_TIMEOUT");m.emit("error",l)},g=()=>{Ct("connection opened %j",u),this.metrics?.dialerEvents.increment({connect:!0}),C()},w=()=>{Ct("connection aborted %j",u),this.metrics?.dialerEvents.increment({abort:!0}),m.destroy(),C(new Gt)},C=l=>{if(m.removeListener("error",I),m.removeListener("timeout",p),m.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),l!=null){s(l);return}n(m)};m.on("error",I),m.on("timeout",p),m.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new ir({...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:Pt.matches(e.decapsulateCode(421)))}};function tl(r={}){return(t={})=>new Jn(t,r)}return Wa(el);})();
7
7
  return Libp2PTcp}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/tcp",
3
- "version": "7.0.3-b36ec7f2",
3
+ "version": "7.0.3-c999d6a7",
4
4
  "description": "A TCP transport for libp2p",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/transport-tcp#readme",
@@ -50,24 +50,21 @@
50
50
  "test:electron-main": "aegir test -t electron-main"
51
51
  },
52
52
  "dependencies": {
53
- "@libp2p/interface": "0.0.1-b36ec7f2",
54
- "@libp2p/logger": "2.1.1-b36ec7f2",
55
- "@libp2p/utils": "3.0.12-b36ec7f2",
53
+ "@libp2p/interface": "0.0.1-c999d6a7",
54
+ "@libp2p/logger": "2.1.1-c999d6a7",
55
+ "@libp2p/utils": "3.0.12-c999d6a7",
56
56
  "@multiformats/mafmt": "^12.1.2",
57
57
  "@multiformats/multiaddr": "^12.1.3",
58
58
  "@types/sinon": "^10.0.15",
59
59
  "stream-to-it": "^0.2.2"
60
60
  },
61
61
  "devDependencies": {
62
- "@libp2p/interface-compliance-tests": "3.0.7-b36ec7f2",
63
- "aegir": "^39.0.13",
62
+ "@libp2p/interface-compliance-tests": "3.0.7-c999d6a7",
63
+ "aegir": "^40.0.1",
64
64
  "it-all": "^3.0.1",
65
65
  "it-pipe": "^3.0.1",
66
66
  "p-defer": "^4.0.0",
67
67
  "sinon": "^15.1.2",
68
68
  "uint8arrays": "^4.0.4"
69
- },
70
- "typedoc": {
71
- "entryPoint": "./src/index.ts"
72
69
  }
73
70
  }