@libp2p/daemon-server 5.0.2 → 6.0.1

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.Libp2PDaemonServer = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PDaemonServer=(()=>{var Pu=Object.create;var Tr=Object.defineProperty;var Mu=Object.getOwnPropertyDescriptor;var Fu=Object.getOwnPropertyNames;var Uu=Object.getPrototypeOf,Gu=Object.prototype.hasOwnProperty;var $t=(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 B=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),mt=(r,t)=>{for(var e in t)Tr(r,e,{get:t[e],enumerable:!0})},lo=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Fu(t))!Gu.call(r,i)&&i!==e&&Tr(r,i,{get:()=>t[i],enumerable:!(n=Mu(t,i))||n.enumerable});return r};var M=(r,t,e)=>(e=r!=null?Pu(Uu(r)):{},lo(t||!r||!r.__esModule?Tr(e,"default",{value:r,enumerable:!0}):e,r)),$u=r=>lo(Tr({},"__esModule",{value:!0}),r);var Oo=B((ad,No)=>{No.exports=ei;var Lo=128,Yl=127,Jl=~Yl,Ql=Math.pow(2,31);function ei(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw ei.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Ql;)t[e++]=r&255|Lo,r/=128;for(;r&Jl;)t[e++]=r&255|Lo,r>>>=7;return t[e]=r|0,ei.bytes=e-n+1,t}});var Fo=B((ud,Mo)=>{Mo.exports=ri;var tf=128,Po=127;function ri(r,n){var e=0,n=n||0,i=0,o=n,a,l=r.length;do{if(o>=l||i>49)throw ri.bytes=0,new RangeError("Could not decode varint");a=r[o++],e+=i<28?(a&Po)<<i:(a&Po)*Math.pow(2,i),i+=7}while(a>=tf);return ri.bytes=o-n,e}});var Go=B((ld,Uo)=>{var ef=Math.pow(2,7),rf=Math.pow(2,14),nf=Math.pow(2,21),of=Math.pow(2,28),sf=Math.pow(2,35),cf=Math.pow(2,42),af=Math.pow(2,49),uf=Math.pow(2,56),lf=Math.pow(2,63);Uo.exports=function(r){return r<ef?1:r<rf?2:r<nf?3:r<of?4:r<sf?5:r<cf?6:r<af?7:r<uf?8:r<lf?9:10}});var Br=B((fd,$o)=>{$o.exports={encode:Oo(),decode:Fo(),encodingLength:Go()}});var fs=B((Pm,ls)=>{var Ue=1e3,Ge=Ue*60,$e=Ge*60,be=$e*24,$f=be*7,zf=be*365.25;ls.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Vf(r);if(e==="number"&&isFinite(r))return t.long?Wf(r):Hf(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Vf(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*zf;case"weeks":case"week":case"w":return e*$f;case"days":case"day":case"d":return e*be;case"hours":case"hour":case"hrs":case"hr":case"h":return e*$e;case"minutes":case"minute":case"mins":case"min":case"m":return e*Ge;case"seconds":case"second":case"secs":case"sec":case"s":return e*Ue;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Hf(r){var t=Math.abs(r);return t>=be?Math.round(r/be)+"d":t>=$e?Math.round(r/$e)+"h":t>=Ge?Math.round(r/Ge)+"m":t>=Ue?Math.round(r/Ue)+"s":r+"ms"}function Wf(r){var t=Math.abs(r);return t>=be?Mr(r,t,be,"day"):t>=$e?Mr(r,t,$e,"hour"):t>=Ge?Mr(r,t,Ge,"minute"):t>=Ue?Mr(r,t,Ue,"second"):r+" ms"}function Mr(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var pi=B((Mm,hs)=>{function qf(r){e.debug=e,e.default=e,e.coerce=f,e.disable=o,e.enable=i,e.enabled=a,e.humanize=fs(),e.destroy=d,Object.keys(r).forEach(h=>{e[h]=r[h]}),e.names=[],e.skips=[],e.formatters={};function t(h){let g=0;for(let w=0;w<h.length;w++)g=(g<<5)-g+h.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(h){let g,w=null,T,b;function S(...k){if(!S.enabled)return;let C=S,_=Number(new Date),G=_-(g||_);C.diff=G,C.prev=g,C.curr=_,g=_,k[0]=e.coerce(k[0]),typeof k[0]!="string"&&k.unshift("%O");let W=0;k[0]=k[0].replace(/%([a-zA-Z%])/g,(at,ot)=>{if(at==="%%")return"%";W++;let ut=e.formatters[ot];if(typeof ut=="function"){let Ct=k[W];at=ut.call(C,Ct),k.splice(W,1),W--}return at}),e.formatArgs.call(C,k),(C.log||e.log).apply(C,k)}return S.namespace=h,S.useColors=e.useColors(),S.color=e.selectColor(h),S.extend=n,S.destroy=e.destroy,Object.defineProperty(S,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(T!==e.namespaces&&(T=e.namespaces,b=e.enabled(h)),b),set:k=>{w=k}}),typeof e.init=="function"&&e.init(S),S}function n(h,g){let w=e(this.namespace+(typeof g>"u"?":":g)+h);return w.log=this.log,w}function i(h){e.save(h),e.namespaces=h,e.names=[],e.skips=[];let g,w=(typeof h=="string"?h:"").split(/[\s,]+/),T=w.length;for(g=0;g<T;g++)w[g]&&(h=w[g].replace(/\*/g,".*?"),h[0]==="-"?e.skips.push(new RegExp("^"+h.slice(1)+"$")):e.names.push(new RegExp("^"+h+"$")))}function o(){let h=[...e.names.map(l),...e.skips.map(l).map(g=>"-"+g)].join(",");return e.enable(""),h}function a(h){if(h[h.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(h))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(h))return!0;return!1}function l(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function f(h){return h instanceof Error?h.stack||h.message:h}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}hs.exports=qf});var ps=B((yt,Fr)=>{yt.formatArgs=Xf;yt.save=Kf;yt.load=jf;yt.useColors=Zf;yt.storage=Yf();yt.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`."))}})();yt.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 Zf(){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 Xf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Fr.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(e++,i==="%c"&&(n=e))}),r.splice(n,0,t)}yt.log=console.debug||console.log||(()=>{});function Kf(r){try{r?yt.storage.setItem("debug",r):yt.storage.removeItem("debug")}catch{}}function jf(){let r;try{r=yt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Yf(){try{return localStorage}catch{}}Fr.exports=pi()(yt);var{formatters:Jf}=Fr.exports;Jf.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ms=B((Fm,ds)=>{"use strict";ds.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),i=t.indexOf("--");return n!==-1&&(i===-1?!0:n<i)}});var ys=B((Um,gs)=>{"use strict";var Qf=$t("os"),Lt=ms(),tt=process.env,ze;Lt("no-color")||Lt("no-colors")||Lt("color=false")?ze=!1:(Lt("color")||Lt("colors")||Lt("color=true")||Lt("color=always"))&&(ze=!0);"FORCE_COLOR"in tt&&(ze=tt.FORCE_COLOR.length===0||parseInt(tt.FORCE_COLOR,10)!==0);function th(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function eh(r){if(ze===!1)return 0;if(Lt("color=16m")||Lt("color=full")||Lt("color=truecolor"))return 3;if(Lt("color=256"))return 2;if(r&&!r.isTTY&&ze!==!0)return 0;let t=ze?1:0;if(process.platform==="win32"){let e=Qf.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in tt)||tt.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(tt.TEAMCITY_VERSION)?1:0;if(tt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in tt){let e=parseInt((tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(tt.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(tt.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(tt.TERM)||"COLORTERM"in tt?1:(tt.TERM==="dumb",t)}function di(r){let t=eh(r);return th(t)}gs.exports={supportsColor:di,stdout:di(process.stdout),stderr:di(process.stderr)}});var ws=B((J,Gr)=>{var rh=$t("tty"),Ur=$t("util");J.init=uh;J.log=sh;J.formatArgs=ih;J.save=ch;J.load=ah;J.useColors=nh;J.destroy=Ur.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");J.colors=[6,2,3,4,5,1];try{let r=ys();r&&(r.stderr||r).level>=2&&(J.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}J.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(i,o)=>o.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 nh(){return"colors"in J.inspectOpts?!!J.inspectOpts.colors:rh.isatty(process.stderr.fd)}function ih(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,i="\x1B[3"+(n<8?n:"8;5;"+n),o=` ${i};1m${t} \x1B[0m`;r[0]=o+r[0].split(`
2
+ "use strict";var Libp2PDaemonServer=(()=>{var Iu=Object.create;var dr=Object.defineProperty;var Cu=Object.getOwnPropertyDescriptor;var ku=Object.getOwnPropertyNames;var Du=Object.getPrototypeOf,Bu=Object.prototype.hasOwnProperty;var Ft=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var B=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ft=(r,t)=>{for(var e in t)dr(r,e,{get:t[e],enumerable:!0})},rs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ku(t))!Bu.call(r,i)&&i!==e&&dr(r,i,{get:()=>t[i],enumerable:!(n=Cu(t,i))||n.enumerable});return r};var M=(r,t,e)=>(e=r!=null?Iu(Du(r)):{},rs(t||!r||!r.__esModule?dr(e,"default",{value:r,enumerable:!0}):e,r)),Ru=r=>rs(dr({},"__esModule",{value:!0}),r);var is=B((Jh,ns)=>{"use strict";ns.exports=_u;function _u(r,t){for(var e=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)e[n++]=arguments[i++];return new Promise(function(l,f){e[n]=function(h){if(s)if(s=!1,h)f(h);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];l.apply(null,g)}};try{r.apply(t||null,e)}catch(d){s&&(s=!1,f(d))}})}});var as=B(cs=>{"use strict";var mr=cs;mr.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var Ae=new Array(64),os=new Array(123);for(kt=0;kt<64;)os[Ae[kt]=kt<26?kt+65:kt<52?kt+71:kt<62?kt-4:kt-59|43]=kt++;var kt;mr.encode=function(t,e,n){for(var i=null,s=[],a=0,l=0,f;e<n;){var d=t[e++];switch(l){case 0:s[a++]=Ae[d>>2],f=(d&3)<<4,l=1;break;case 1:s[a++]=Ae[f|d>>4],f=(d&15)<<2,l=2;break;case 2:s[a++]=Ae[f|d>>6],s[a++]=Ae[d&63],l=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return l&&(s[a++]=Ae[f],s[a++]=61,l===1&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var ss="invalid encoding";mr.decode=function(t,e,n){for(var i=n,s=0,a,l=0;l<t.length;){var f=t.charCodeAt(l++);if(f===61&&s>1)break;if((f=os[f])===void 0)throw Error(ss);switch(s){case 0:a=f,s=1;break;case 1:e[n++]=a<<2|(f&48)>>4,a=f,s=2;break;case 2:e[n++]=(a&15)<<4|(f&60)>>2,a=f,s=3;break;case 3:e[n++]=(a&3)<<6|f,s=0;break}}if(s===1)throw Error(ss);return n-i};mr.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var ls=B((tp,us)=>{"use strict";us.exports=gr;function gr(){this._listeners={}}gr.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};gr.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===e?n.splice(i,1):++i;return this};gr.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<e.length;)e[i].fn.apply(e[i++].ctx,n)}return this}});var ys=B((ep,gs)=>{"use strict";gs.exports=fs(fs);function fs(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(f,d,h){t[0]=f,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3]}function s(f,d,h){t[0]=f,d[h]=e[3],d[h+1]=e[2],d[h+2]=e[1],d[h+3]=e[0]}r.writeFloatLE=n?i:s,r.writeFloatBE=n?s:i;function a(f,d){return e[0]=f[d],e[1]=f[d+1],e[2]=f[d+2],e[3]=f[d+3],t[0]}function l(f,d){return e[3]=f[d],e[2]=f[d+1],e[1]=f[d+2],e[0]=f[d+3],t[0]}r.readFloatLE=n?a:l,r.readFloatBE=n?l:a}():function(){function t(n,i,s,a){var l=i<0?1:0;if(l&&(i=-i),i===0)n(1/i>0?0:2147483648,s,a);else if(isNaN(i))n(2143289344,s,a);else if(i>34028234663852886e22)n((l<<31|2139095040)>>>0,s,a);else if(i<11754943508222875e-54)n((l<<31|Math.round(i/1401298464324817e-60))>>>0,s,a);else{var f=Math.floor(Math.log(i)/Math.LN2),d=Math.round(i*Math.pow(2,-f)*8388608)&8388607;n((l<<31|f+127<<23|d)>>>0,s,a)}}r.writeFloatLE=t.bind(null,hs),r.writeFloatBE=t.bind(null,ps);function e(n,i,s){var a=n(i,s),l=(a>>31)*2+1,f=a>>>23&255,d=a&8388607;return f===255?d?NaN:l*(1/0):f===0?l*1401298464324817e-60*d:l*Math.pow(2,f-150)*(d+8388608)}r.readFloatLE=e.bind(null,ds),r.readFloatBE=e.bind(null,ms)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(f,d,h){t[0]=f,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3],d[h+4]=e[4],d[h+5]=e[5],d[h+6]=e[6],d[h+7]=e[7]}function s(f,d,h){t[0]=f,d[h]=e[7],d[h+1]=e[6],d[h+2]=e[5],d[h+3]=e[4],d[h+4]=e[3],d[h+5]=e[2],d[h+6]=e[1],d[h+7]=e[0]}r.writeDoubleLE=n?i:s,r.writeDoubleBE=n?s:i;function a(f,d){return e[0]=f[d],e[1]=f[d+1],e[2]=f[d+2],e[3]=f[d+3],e[4]=f[d+4],e[5]=f[d+5],e[6]=f[d+6],e[7]=f[d+7],t[0]}function l(f,d){return e[7]=f[d],e[6]=f[d+1],e[5]=f[d+2],e[4]=f[d+3],e[3]=f[d+4],e[2]=f[d+5],e[1]=f[d+6],e[0]=f[d+7],t[0]}r.readDoubleLE=n?a:l,r.readDoubleBE=n?l:a}():function(){function t(n,i,s,a,l,f){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,l,f+i),n(1/a>0?0:2147483648,l,f+s);else if(isNaN(a))n(0,l,f+i),n(2146959360,l,f+s);else if(a>17976931348623157e292)n(0,l,f+i),n((d<<31|2146435072)>>>0,l,f+s);else{var h;if(a<22250738585072014e-324)h=a/5e-324,n(h>>>0,l,f+i),n((d<<31|h/4294967296)>>>0,l,f+s);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),h=a*Math.pow(2,-g),n(h*4503599627370496>>>0,l,f+i),n((d<<31|g+1023<<20|h*1048576&1048575)>>>0,l,f+s)}}}r.writeDoubleLE=t.bind(null,hs,0,4),r.writeDoubleBE=t.bind(null,ps,4,0);function e(n,i,s,a,l){var f=n(a,l+i),d=n(a,l+s),h=(d>>31)*2+1,g=d>>>20&2047,w=4294967296*(d&1048575)+f;return g===2047?w?NaN:h*(1/0):g===0?h*5e-324*w:h*Math.pow(2,g-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,ds,0,4),r.readDoubleBE=e.bind(null,ms,4,0)}(),r}function hs(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ps(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function ds(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function ms(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var bs=B((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var Es=B(ws=>{"use strict";var wn=ws;wn.length=function(t){for(var e=0,n=0,i=0;i<t.length;++i)n=t.charCodeAt(i),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e};wn.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var s=null,a=[],l=0,f;e<n;)f=t[e++],f<128?a[l++]=f:f>191&&f<224?a[l++]=(f&31)<<6|t[e++]&63:f>239&&f<365?(f=((f&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,a[l++]=55296+(f>>10),a[l++]=56320+(f&1023)):a[l++]=(f&15)<<12|(t[e++]&63)<<6|t[e++]&63,l>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),l=0);return s?(l&&s.push(String.fromCharCode.apply(String,a.slice(0,l))),s.join("")):String.fromCharCode.apply(String,a.slice(0,l))};wn.write=function(t,e,n){for(var i=n,s,a,l=0;l<t.length;++l)s=t.charCodeAt(l),s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&((a=t.charCodeAt(l+1))&64512)===56320?(s=65536+((s&1023)<<10)+(a&1023),++l,e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128);return n-i}});var xs=B((np,vs)=>{"use strict";vs.exports=Lu;function Lu(r,t,e){var n=e||8192,i=n>>>1,s=null,a=n;return function(f){if(f<1||f>i)return r(f);a+f>n&&(s=r(n),a=0);var d=t.call(s,a,a+=f);return a&7&&(a=(a|7)+1),d}}});var Ts=B((ip,Ss)=>{"use strict";Ss.exports=K;var Ye=ce();function K(r,t){this.lo=r>>>0,this.hi=t>>>0}var oe=K.zero=new K(0,0);oe.toNumber=function(){return 0};oe.zzEncode=oe.zzDecode=function(){return this};oe.length=function(){return 1};var Nu=K.zeroHash="\0\0\0\0\0\0\0\0";K.fromNumber=function(t){if(t===0)return oe;var e=t<0;e&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new K(n,i)};K.from=function(t){if(typeof t=="number")return K.fromNumber(t);if(Ye.isString(t))if(Ye.Long)t=Ye.Long.fromString(t);else return K.fromNumber(parseInt(t,10));return t.low||t.high?new K(t.low>>>0,t.high>>>0):oe};K.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};K.prototype.toLong=function(t){return Ye.Long?new Ye.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var Zt=String.prototype.charCodeAt;K.fromHash=function(t){return t===Nu?oe:new K((Zt.call(t,0)|Zt.call(t,1)<<8|Zt.call(t,2)<<16|Zt.call(t,3)<<24)>>>0,(Zt.call(t,4)|Zt.call(t,5)<<8|Zt.call(t,6)<<16|Zt.call(t,7)<<24)>>>0)};K.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};K.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};K.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};K.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var ce=B(En=>{"use strict";var T=En;T.asPromise=is();T.base64=as();T.EventEmitter=ls();T.float=ys();T.inquire=bs();T.utf8=Es();T.pool=xs();T.LongBits=Ts();T.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);T.global=T.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||En;T.emptyArray=Object.freeze?Object.freeze([]):[];T.emptyObject=Object.freeze?Object.freeze({}):{};T.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};T.isString=function(t){return typeof t=="string"||t instanceof String};T.isObject=function(t){return t&&typeof t=="object"};T.isset=T.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};T.Buffer=function(){try{var r=T.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();T._Buffer_from=null;T._Buffer_allocUnsafe=null;T.newBuffer=function(t){return typeof t=="number"?T.Buffer?T._Buffer_allocUnsafe(t):new T.Array(t):T.Buffer?T._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};T.Array=typeof Uint8Array<"u"?Uint8Array:Array;T.Long=T.global.dcodeIO&&T.global.dcodeIO.Long||T.global.Long||T.inquire("long");T.key2Re=/^true|false|0|1$/;T.key32Re=/^-?(?:0|[1-9][0-9]*)$/;T.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;T.longToHash=function(t){return t?T.LongBits.from(t).toHash():T.LongBits.zeroHash};T.longFromHash=function(t,e){var n=T.LongBits.fromHash(t);return T.Long?T.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function As(r,t,e){for(var n=Object.keys(t),i=0;i<n.length;++i)(r[n[i]]===void 0||!e)&&(r[n[i]]=t[n[i]]);return r}T.merge=As;T.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function Is(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&As(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}T.newError=Is;T.ProtocolError=Is("ProtocolError");T.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(e[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};T.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};T.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};T._configure=function(){var r=T.Buffer;if(!r){T._Buffer_from=T._Buffer_allocUnsafe=null;return}T._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},T._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var Sn=B((op,Rs)=>{"use strict";Rs.exports=U;var Lt=ce(),xn,Ds=Lt.LongBits,Ou=Lt.utf8;function Dt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function U(r){this.buf=r,this.pos=0,this.len=r.length}var Cs=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new U(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new U(t);throw Error("illegal buffer")},Bs=function(){return Lt.Buffer?function(e){return(U.create=function(i){return Lt.Buffer.isBuffer(i)?new xn(i):Cs(i)})(e)}:Cs};U.create=Bs();U.prototype._slice=Lt.Array.prototype.subarray||Lt.Array.prototype.slice;U.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Dt(this,10);return t}}();U.prototype.int32=function(){return this.uint32()|0};U.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function vn(){var r=new Ds(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Dt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw Dt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}U.prototype.bool=function(){return this.uint32()!==0};function yr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}U.prototype.fixed32=function(){if(this.pos+4>this.len)throw Dt(this,4);return yr(this.buf,this.pos+=4)};U.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Dt(this,4);return yr(this.buf,this.pos+=4)|0};function ks(){if(this.pos+8>this.len)throw Dt(this,8);return new Ds(yr(this.buf,this.pos+=4),yr(this.buf,this.pos+=4))}U.prototype.float=function(){if(this.pos+4>this.len)throw Dt(this,4);var t=Lt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};U.prototype.double=function(){if(this.pos+8>this.len)throw Dt(this,4);var t=Lt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};U.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Dt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};U.prototype.string=function(){var t=this.bytes();return Ou.read(t,0,t.length)};U.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Dt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Dt(this);while(this.buf[this.pos++]&128);return this};U.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};U._configure=function(r){xn=r,U.create=Bs(),xn._configure();var t=Lt.Long?"toLong":"toNumber";Lt.merge(U.prototype,{int64:function(){return vn.call(this)[t](!1)},uint64:function(){return vn.call(this)[t](!0)},sint64:function(){return vn.call(this).zzDecode()[t](!1)},fixed64:function(){return ks.call(this)[t](!0)},sfixed64:function(){return ks.call(this)[t](!1)}})}});var Os=B((cp,Ns)=>{"use strict";Ns.exports=ae;var Ls=Sn();(ae.prototype=Object.create(Ls.prototype)).constructor=ae;var _s=ce();function ae(r){Ls.call(this,r)}ae._configure=function(){_s.Buffer&&(ae.prototype._slice=_s.Buffer.prototype.slice)};ae.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};ae._configure()});var Bn=B((ap,Fs)=>{"use strict";Fs.exports=R;var bt=ce(),Tn,br=bt.LongBits,Ps=bt.base64,Ms=bt.utf8;function je(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function In(){}function Pu(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function R(){this.len=0,this.head=new je(In,0,0),this.tail=this.head,this.states=null}var Us=function(){return bt.Buffer?function(){return(R.create=function(){return new Tn})()}:function(){return new R}};R.create=Us();R.alloc=function(t){return new bt.Array(t)};bt.Array!==Array&&(R.alloc=bt.pool(R.alloc,bt.Array.prototype.subarray));R.prototype._push=function(t,e,n){return this.tail=this.tail.next=new je(t,e,n),this.len+=e,this};function Cn(r,t,e){t[e]=r&255}function Mu(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function kn(r,t){this.len=r,this.next=void 0,this.val=t}kn.prototype=Object.create(je.prototype);kn.prototype.fn=Mu;R.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new kn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};R.prototype.int32=function(t){return t<0?this._push(Dn,10,br.fromNumber(t)):this.uint32(t)};R.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Dn(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}R.prototype.uint64=function(t){var e=br.from(t);return this._push(Dn,e.length(),e)};R.prototype.int64=R.prototype.uint64;R.prototype.sint64=function(t){var e=br.from(t).zzEncode();return this._push(Dn,e.length(),e)};R.prototype.bool=function(t){return this._push(Cn,1,t?1:0)};function An(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}R.prototype.fixed32=function(t){return this._push(An,4,t>>>0)};R.prototype.sfixed32=R.prototype.fixed32;R.prototype.fixed64=function(t){var e=br.from(t);return this._push(An,4,e.lo)._push(An,4,e.hi)};R.prototype.sfixed64=R.prototype.fixed64;R.prototype.float=function(t){return this._push(bt.float.writeFloatLE,4,t)};R.prototype.double=function(t){return this._push(bt.float.writeDoubleLE,8,t)};var Uu=bt.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var i=0;i<t.length;++i)e[n+i]=t[i]};R.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(Cn,1,0);if(bt.isString(t)){var n=R.alloc(e=Ps.length(t));Ps.decode(t,n,0),t=n}return this.uint32(e)._push(Uu,e,t)};R.prototype.string=function(t){var e=Ms.length(t);return e?this.uint32(e)._push(Ms.write,e,t):this._push(Cn,1,0)};R.prototype.fork=function(){return this.states=new Pu(this),this.head=this.tail=new je(In,0,0),this.len=0,this};R.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new je(In,0,0),this.len=0),this};R.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};R.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};R._configure=function(r){Tn=r,R.create=Us(),Tn._configure()}});var zs=B((up,$s)=>{"use strict";$s.exports=Nt;var Gs=Bn();(Nt.prototype=Object.create(Gs.prototype)).constructor=Nt;var Kt=ce();function Nt(){Gs.call(this)}Nt._configure=function(){Nt.alloc=Kt._Buffer_allocUnsafe,Nt.writeBytesBuffer=Kt.Buffer&&Kt.Buffer.prototype instanceof Uint8Array&&Kt.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var i=0;i<t.length;)e[n++]=t[i++]}};Nt.prototype.bytes=function(t){Kt.isString(t)&&(t=Kt._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Nt.writeBytesBuffer,e,t),this};function Fu(r,t,e){r.length<40?Kt.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Nt.prototype.string=function(t){var e=Kt.Buffer.byteLength(t);return this.uint32(e),e&&this._push(Fu,e,t),this};Nt._configure()});var Ks=B((kp,Zs)=>{var ke=1e3,De=ke*60,Be=De*60,fe=Be*24,Vu=fe*7,Hu=fe*365.25;Zs.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Wu(r);if(e==="number"&&isFinite(r))return t.long?Zu(r):qu(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Wu(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*Hu;case"weeks":case"week":case"w":return e*Vu;case"days":case"day":case"d":return e*fe;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Be;case"minutes":case"minute":case"mins":case"min":case"m":return e*De;case"seconds":case"second":case"secs":case"sec":case"s":return e*ke;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function qu(r){var t=Math.abs(r);return t>=fe?Math.round(r/fe)+"d":t>=Be?Math.round(r/Be)+"h":t>=De?Math.round(r/De)+"m":t>=ke?Math.round(r/ke)+"s":r+"ms"}function Zu(r){var t=Math.abs(r);return t>=fe?Dr(r,t,fe,"day"):t>=Be?Dr(r,t,Be,"hour"):t>=De?Dr(r,t,De,"minute"):t>=ke?Dr(r,t,ke,"second"):r+" ms"}function Dr(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var On=B((Dp,Xs)=>{function Ku(r){e.debug=e,e.default=e,e.coerce=f,e.disable=s,e.enable=i,e.enabled=a,e.humanize=Ks(),e.destroy=d,Object.keys(r).forEach(h=>{e[h]=r[h]}),e.names=[],e.skips=[],e.formatters={};function t(h){let g=0;for(let w=0;w<h.length;w++)g=(g<<5)-g+h.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(h){let g,w=null,S,b;function k(...A){if(!k.enabled)return;let C=k,D=Number(new Date),_=D-(g||D);C.diff=_,C.prev=g,C.curr=D,g=D,A[0]=e.coerce(A[0]),typeof A[0]!="string"&&A.unshift("%O");let G=0;A[0]=A[0].replace(/%([a-zA-Z%])/g,(st,nt)=>{if(st==="%%")return"%";G++;let ot=e.formatters[nt];if(typeof ot=="function"){let Tt=A[G];st=ot.call(C,Tt),A.splice(G,1),G--}return st}),e.formatArgs.call(C,A),(C.log||e.log).apply(C,A)}return k.namespace=h,k.useColors=e.useColors(),k.color=e.selectColor(h),k.extend=n,k.destroy=e.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(S!==e.namespaces&&(S=e.namespaces,b=e.enabled(h)),b),set:A=>{w=A}}),typeof e.init=="function"&&e.init(k),k}function n(h,g){let w=e(this.namespace+(typeof g>"u"?":":g)+h);return w.log=this.log,w}function i(h){e.save(h),e.namespaces=h,e.names=[],e.skips=[];let g,w=(typeof h=="string"?h:"").split(/[\s,]+/),S=w.length;for(g=0;g<S;g++)w[g]&&(h=w[g].replace(/\*/g,".*?"),h[0]==="-"?e.skips.push(new RegExp("^"+h.slice(1)+"$")):e.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...e.names.map(l),...e.skips.map(l).map(g=>"-"+g)].join(",");return e.enable(""),h}function a(h){if(h[h.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(h))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(h))return!0;return!1}function l(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function f(h){return h instanceof Error?h.stack||h.message:h}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}Xs.exports=Ku});var Ys=B((ht,Br)=>{ht.formatArgs=Yu;ht.save=ju;ht.load=Ju;ht.useColors=Xu;ht.storage=Qu();ht.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();ht.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Xu(){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 Yu(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Br.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(e++,i==="%c"&&(n=e))}),r.splice(n,0,t)}ht.log=console.debug||console.log||(()=>{});function ju(r){try{r?ht.storage.setItem("debug",r):ht.storage.removeItem("debug")}catch{}}function Ju(){let r;try{r=ht.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Qu(){try{return localStorage}catch{}}Br.exports=On()(ht);var{formatters:tl}=Br.exports;tl.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Js=B((Bp,js)=>{"use strict";js.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),i=t.indexOf("--");return n!==-1&&(i===-1?!0:n<i)}});var to=B((Rp,Qs)=>{"use strict";var el=Ft("os"),Bt=Js(),j=process.env,Re;Bt("no-color")||Bt("no-colors")||Bt("color=false")?Re=!1:(Bt("color")||Bt("colors")||Bt("color=true")||Bt("color=always"))&&(Re=!0);"FORCE_COLOR"in j&&(Re=j.FORCE_COLOR.length===0||parseInt(j.FORCE_COLOR,10)!==0);function rl(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function nl(r){if(Re===!1)return 0;if(Bt("color=16m")||Bt("color=full")||Bt("color=truecolor"))return 3;if(Bt("color=256"))return 2;if(r&&!r.isTTY&&Re!==!0)return 0;let t=Re?1:0;if(process.platform==="win32"){let e=el.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in j)||j.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let e=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:(j.TERM==="dumb",t)}function Pn(r){let t=nl(r);return rl(t)}Qs.exports={supportsColor:Pn,stdout:Pn(process.stdout),stderr:Pn(process.stderr)}});var ro=B((Y,_r)=>{var il=Ft("tty"),Rr=Ft("util");Y.init=fl;Y.log=al;Y.formatArgs=ol;Y.save=ul;Y.load=ll;Y.useColors=sl;Y.destroy=Rr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Y.colors=[6,2,3,4,5,1];try{let r=to();r&&(r.stderr||r).level>=2&&(Y.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{}Y.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(i,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[e]=n,r},{});function sl(){return"colors"in Y.inspectOpts?!!Y.inspectOpts.colors:il.isatty(process.stderr.fd)}function ol(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,i="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${i};1m${t} \x1B[0m`;r[0]=s+r[0].split(`
3
3
  `).join(`
4
- `+o),r.push(i+"m+"+Gr.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=oh()+t+" "+r[0]}function oh(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function sh(...r){return process.stderr.write(Ur.format(...r)+`
5
- `)}function ch(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function ah(){return process.env.DEBUG}function uh(r){r.inspectOpts={};let t=Object.keys(J.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=J.inspectOpts[t[e]]}Gr.exports=pi()(J);var{formatters:bs}=Gr.exports;bs.o=function(r){return this.inspectOpts.colors=this.useColors,Ur.inspect(r,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};bs.O=function(r){return this.inspectOpts.colors=this.useColors,Ur.inspect(r,this.inspectOpts)}});var Es=B((Gm,mi)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?mi.exports=ps():mi.exports=ws()});var $r=B((Wm,vs)=>{vs.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 Ss=B((qm,xs)=>{xs.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 gi=B((Zm,Ts)=>{var fh=Ss();Ts.exports=r=>async t=>{t=fh(t);let e=C=>{typeof C.return=="function"&&C.return()},n=null,i=null,o=C=>{n=C,i&&i(C),e(t)},a=null,l=!1,f=()=>{l=!0,a&&a()},d=null,h=!1,g=()=>{h=!0,d&&d()},w=null,T=()=>{w&&w()},b=()=>new Promise((C,_)=>{a=w=C,i=_,r.once("drain",T)}),S=()=>(e(t),new Promise((C,_)=>{if(l||h||n)return C();d=a=C,i=_})),k=()=>{r.removeListener("error",o),r.removeListener("close",f),r.removeListener("finish",g),r.removeListener("drain",T)};r.once("error",o),r.once("close",f),r.once("finish",g);try{for await(let C of t){if(!r.writable||r.destroyed||n)break;r.write(C)===!1&&await b()}}catch(C){n||r.destroy(),n=C}try{if(r.writable&&r.end(),await S(),n)throw n}finally{k()}}});var yi=B((Xm,As)=>{var hh=gi(),ph=$r();As.exports=r=>({sink:hh(r),source:ph(r)})});var Cs=B((Km,Is)=>{var dh=yi();Is.exports=r=>async function*(t){let e=dh(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var _s=B((jm,Ve)=>{Ve.exports=$r();Ve.exports.source=$r();Ve.exports.sink=gi();Ve.exports.transform=Cs();Ve.exports.duplex=yi()});var wi=B((Hr,Ds)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(s,c,u){s!=null&&(typeof s=="number"?this.fromNumber(s,c,u):c==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,c))}function i(){return new n(null)}function o(s,c,u,p,m,y){for(;--y>=0;){var E=c*this[s++]+u[p]+m;m=Math.floor(E/67108864),u[p++]=E&67108863}return m}function a(s,c,u,p,m,y){for(var E=c&32767,v=c>>15;--y>=0;){var N=this[s]&32767,j=this[s++]>>15,Et=v*N+j*E;N=E*N+((Et&32767)<<15)+u[p]+(m&1073741823),m=(N>>>30)+(Et>>>15)+v*j+(m>>>30),u[p++]=N&1073741823}return m}function l(s,c,u,p,m,y){for(var E=c&16383,v=c>>14;--y>=0;){var N=this[s]&16383,j=this[s++]>>14,Et=v*N+j*E;N=E*N+((Et&16383)<<14)+u[p]+m,m=(N>>28)+(Et>>14)+v*j,u[p++]=N&268435455}return m}var f=typeof navigator<"u";f&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=a,r=30):f&&e&&navigator.appName!="Netscape"?(n.prototype.am=o,r=26):(n.prototype.am=l,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var d=52;n.prototype.FV=Math.pow(2,d),n.prototype.F1=d-r,n.prototype.F2=2*r-d;var h="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,T;for(w="0".charCodeAt(0),T=0;T<=9;++T)g[w++]=T;for(w="a".charCodeAt(0),T=10;T<36;++T)g[w++]=T;for(w="A".charCodeAt(0),T=10;T<36;++T)g[w++]=T;function b(s){return h.charAt(s)}function S(s,c){var u=g[s.charCodeAt(c)];return u??-1}function k(s){for(var c=this.t-1;c>=0;--c)s[c]=this[c];s.t=this.t,s.s=this.s}function C(s){this.t=1,this.s=s<0?-1:0,s>0?this[0]=s:s<-1?this[0]=s+this.DV:this.t=0}function _(s){var c=i();return c.fromInt(s),c}function G(s,c){var u;if(c==16)u=4;else if(c==8)u=3;else if(c==256)u=8;else if(c==2)u=1;else if(c==32)u=5;else if(c==4)u=2;else{this.fromRadix(s,c);return}this.t=0,this.s=0;for(var p=s.length,m=!1,y=0;--p>=0;){var E=u==8?s[p]&255:S(s,p);if(E<0){s.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=E:y+u>this.DB?(this[this.t-1]|=(E&(1<<this.DB-y)-1)<<y,this[this.t++]=E>>this.DB-y):this[this.t-1]|=E<<y,y+=u,y>=this.DB&&(y-=this.DB)}u==8&&s[0]&128&&(this.s=-1,y>0&&(this[this.t-1]|=(1<<this.DB-y)-1<<y)),this.clamp(),m&&n.ZERO.subTo(this,this)}function W(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t}function ht(s){if(this.s<0)return"-"+this.negate().toString(s);var c;if(s==16)c=4;else if(s==8)c=3;else if(s==2)c=1;else if(s==32)c=5;else if(s==4)c=2;else return this.toRadix(s);var u=(1<<c)-1,p,m=!1,y="",E=this.t,v=this.DB-E*this.DB%c;if(E-- >0)for(v<this.DB&&(p=this[E]>>v)>0&&(m=!0,y=b(p));E>=0;)v<c?(p=(this[E]&(1<<v)-1)<<c-v,p|=this[--E]>>(v+=this.DB-c)):(p=this[E]>>(v-=c)&u,v<=0&&(v+=this.DB,--E)),p>0&&(m=!0),m&&(y+=b(p));return m?y:"0"}function at(){var s=i();return n.ZERO.subTo(this,s),s}function ot(){return this.s<0?this.negate():this}function ut(s){var c=this.s-s.s;if(c!=0)return c;var u=this.t;if(c=u-s.t,c!=0)return this.s<0?-c:c;for(;--u>=0;)if((c=this[u]-s[u])!=0)return c;return 0}function Ct(s){var c=1,u;return(u=s>>>16)!=0&&(s=u,c+=16),(u=s>>8)!=0&&(s=u,c+=8),(u=s>>4)!=0&&(s=u,c+=4),(u=s>>2)!=0&&(s=u,c+=2),(u=s>>1)!=0&&(s=u,c+=1),c}function ra(){return this.t<=0?0:this.DB*(this.t-1)+Ct(this[this.t-1]^this.s&this.DM)}function na(s,c){var u;for(u=this.t-1;u>=0;--u)c[u+s]=this[u];for(u=s-1;u>=0;--u)c[u]=0;c.t=this.t+s,c.s=this.s}function ia(s,c){for(var u=s;u<this.t;++u)c[u-s]=this[u];c.t=Math.max(this.t-s,0),c.s=this.s}function oa(s,c){var u=s%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(s/this.DB),E=this.s<<u&this.DM,v;for(v=this.t-1;v>=0;--v)c[v+y+1]=this[v]>>p|E,E=(this[v]&m)<<u;for(v=y-1;v>=0;--v)c[v]=0;c[y]=E,c.t=this.t+y+1,c.s=this.s,c.clamp()}function sa(s,c){c.s=this.s;var u=Math.floor(s/this.DB);if(u>=this.t){c.t=0;return}var p=s%this.DB,m=this.DB-p,y=(1<<p)-1;c[0]=this[u]>>p;for(var E=u+1;E<this.t;++E)c[E-u-1]|=(this[E]&y)<<m,c[E-u]=this[E]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function ca(s,c){for(var u=0,p=0,m=Math.min(s.t,this.t);u<m;)p+=this[u]-s[u],c[u++]=p&this.DM,p>>=this.DB;if(s.t<this.t){for(p-=s.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<s.t;)p-=s[u],c[u++]=p&this.DM,p>>=this.DB;p-=s.s}c.s=p<0?-1:0,p<-1?c[u++]=this.DV+p:p>0&&(c[u++]=p),c.t=u,c.clamp()}function aa(s,c){var u=this.abs(),p=s.abs(),m=u.t;for(c.t=m+p.t;--m>=0;)c[m]=0;for(m=0;m<p.t;++m)c[m+u.t]=u.am(0,p[m],c,m,0,u.t);c.s=0,c.clamp(),this.s!=s.s&&n.ZERO.subTo(c,c)}function ua(s){for(var c=this.abs(),u=s.t=2*c.t;--u>=0;)s[u]=0;for(u=0;u<c.t-1;++u){var p=c.am(u,c[u],s,2*u,0,1);(s[u+c.t]+=c.am(u+1,2*c[u],s,2*u+1,p,c.t-u-1))>=c.DV&&(s[u+c.t]-=c.DV,s[u+c.t+1]=1)}s.t>0&&(s[s.t-1]+=c.am(u,c[u],s,2*u,0,1)),s.s=0,s.clamp()}function la(s,c,u){var p=s.abs();if(!(p.t<=0)){var m=this.abs();if(m.t<p.t){c?.fromInt(0),u!=null&&this.copyTo(u);return}u==null&&(u=i());var y=i(),E=this.s,v=s.s,N=this.DB-Ct(p[p.t-1]);N>0?(p.lShiftTo(N,y),m.lShiftTo(N,u)):(p.copyTo(y),m.copyTo(u));var j=y.t,Et=y[j-1];if(Et!=0){var dt=Et*(1<<this.F1)+(j>1?y[j-2]>>this.F2:0),Gt=this.FV/dt,xr=(1<<this.F1)/dt,kt=1<<this.F2,Bt=u.t,Sr=Bt-j,Jt=c??i();for(y.dlShiftTo(Sr,Jt),u.compareTo(Jt)>=0&&(u[u.t++]=1,u.subTo(Jt,u)),n.ONE.dlShiftTo(j,Jt),Jt.subTo(y,y);y.t<j;)y[y.t++]=0;for(;--Sr>=0;){var kn=u[--Bt]==Et?this.DM:Math.floor(u[Bt]*Gt+(u[Bt-1]+kt)*xr);if((u[Bt]+=y.am(0,kn,u,Sr,0,j))<kn)for(y.dlShiftTo(Sr,Jt),u.subTo(Jt,u);u[Bt]<--kn;)u.subTo(Jt,u)}c!=null&&(u.drShiftTo(j,c),E!=v&&n.ZERO.subTo(c,c)),u.t=j,u.clamp(),N>0&&u.rShiftTo(N,u),E<0&&n.ZERO.subTo(u,u)}}}function fa(s){var c=i();return this.abs().divRemTo(s,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&s.subTo(c,c),c}function le(s){this.m=s}function ha(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s}function pa(s){return s}function da(s){s.divRemTo(this.m,null,s)}function ma(s,c,u){s.multiplyTo(c,u),this.reduce(u)}function ga(s,c){s.squareTo(c),this.reduce(c)}le.prototype.convert=ha,le.prototype.revert=pa,le.prototype.reduce=da,le.prototype.mulTo=ma,le.prototype.sqrTo=ga;function ya(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var c=s&3;return c=c*(2-(s&15)*c)&15,c=c*(2-(s&255)*c)&255,c=c*(2-((s&65535)*c&65535))&65535,c=c*(2-s*c%this.DV)%this.DV,c>0?this.DV-c:-c}function fe(s){this.m=s,this.mp=s.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<s.DB-15)-1,this.mt2=2*s.t}function ba(s){var c=i();return s.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),s.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function wa(s){var c=i();return s.copyTo(c),this.reduce(c),c}function Ea(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var c=0;c<this.m.t;++c){var u=s[c]&32767,p=u*this.mpl+((u*this.mph+(s[c]>>15)*this.mpl&this.um)<<15)&s.DM;for(u=c+this.m.t,s[u]+=this.m.am(0,p,s,c,0,this.m.t);s[u]>=s.DV;)s[u]-=s.DV,s[++u]++}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s)}function va(s,c){s.squareTo(c),this.reduce(c)}function xa(s,c,u){s.multiplyTo(c,u),this.reduce(u)}fe.prototype.convert=ba,fe.prototype.revert=wa,fe.prototype.reduce=Ea,fe.prototype.mulTo=xa,fe.prototype.sqrTo=va;function Sa(){return(this.t>0?this[0]&1:this.s)==0}function Ta(s,c){if(s>4294967295||s<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=Ct(s)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(s&1<<y)>0)c.mulTo(p,m,u);else{var E=u;u=p,p=E}return c.revert(u)}function Aa(s,c){var u;return s<256||c.isEven()?u=new le(c):u=new fe(c),this.exp(s,u)}n.prototype.copyTo=k,n.prototype.fromInt=C,n.prototype.fromString=G,n.prototype.clamp=W,n.prototype.dlShiftTo=na,n.prototype.drShiftTo=ia,n.prototype.lShiftTo=oa,n.prototype.rShiftTo=sa,n.prototype.subTo=ca,n.prototype.multiplyTo=aa,n.prototype.squareTo=ua,n.prototype.divRemTo=la,n.prototype.invDigit=ya,n.prototype.isEven=Sa,n.prototype.exp=Ta,n.prototype.toString=ht,n.prototype.negate=at,n.prototype.abs=ot,n.prototype.compareTo=ut,n.prototype.bitLength=ra,n.prototype.mod=fa,n.prototype.modPowInt=Aa,n.ZERO=_(0),n.ONE=_(1);function Ia(){var s=i();return this.copyTo(s),s}function Ca(){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 _a(){return this.t==0?this.s:this[0]<<24>>24}function ka(){return this.t==0?this.s:this[0]<<16>>16}function Ba(s){return Math.floor(Math.LN2*this.DB/Math.log(s))}function Da(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Ra(s){if(s==null&&(s=10),this.signum()==0||s<2||s>36)return"0";var c=this.chunkSize(s),u=Math.pow(s,c),p=_(u),m=i(),y=i(),E="";for(this.divRemTo(p,m,y);m.signum()>0;)E=(u+y.intValue()).toString(s).substr(1)+E,m.divRemTo(p,m,y);return y.intValue().toString(s)+E}function La(s,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,E=0,v=0;v<s.length;++v){var N=S(s,v);if(N<0){s.charAt(v)=="-"&&this.signum()==0&&(m=!0);continue}E=c*E+N,++y>=u&&(this.dMultiply(p),this.dAddOffset(E,0),y=0,E=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(E,0)),m&&n.ZERO.subTo(this,this)}function Na(s,c,u){if(typeof c=="number")if(s<2)this.fromInt(1);else for(this.fromNumber(s,u),this.testBit(s-1)||this.bitwiseTo(n.ONE.shiftLeft(s-1),An,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(n.ONE.shiftLeft(s-1),this);else{var p=new Array,m=s&7;p.length=(s>>3)+1,c.nextBytes(p),m>0?p[0]&=(1<<m)-1:p[0]=0,this.fromString(p,256)}}function Oa(){var s=this.t,c=new Array;c[0]=this.s;var u=this.DB-s*this.DB%8,p,m=0;if(s-- >0)for(u<this.DB&&(p=this[s]>>u)!=(this.s&this.DM)>>u&&(c[m++]=p|this.s<<this.DB-u);s>=0;)u<8?(p=(this[s]&(1<<u)-1)<<8-u,p|=this[--s]>>(u+=this.DB-8)):(p=this[s]>>(u-=8)&255,u<=0&&(u+=this.DB,--s)),p&128&&(p|=-256),m==0&&(this.s&128)!=(p&128)&&++m,(m>0||p!=this.s)&&(c[m++]=p);return c}function Pa(s){return this.compareTo(s)==0}function Ma(s){return this.compareTo(s)<0?this:s}function Fa(s){return this.compareTo(s)>0?this:s}function Ua(s,c,u){var p,m,y=Math.min(s.t,this.t);for(p=0;p<y;++p)u[p]=c(this[p],s[p]);if(s.t<this.t){for(m=s.s&this.DM,p=y;p<this.t;++p)u[p]=c(this[p],m);u.t=this.t}else{for(m=this.s&this.DM,p=y;p<s.t;++p)u[p]=c(m,s[p]);u.t=s.t}u.s=c(this.s,s.s),u.clamp()}function Ga(s,c){return s&c}function $a(s){var c=i();return this.bitwiseTo(s,Ga,c),c}function An(s,c){return s|c}function za(s){var c=i();return this.bitwiseTo(s,An,c),c}function io(s,c){return s^c}function Va(s){var c=i();return this.bitwiseTo(s,io,c),c}function oo(s,c){return s&~c}function Ha(s){var c=i();return this.bitwiseTo(s,oo,c),c}function Wa(){for(var s=i(),c=0;c<this.t;++c)s[c]=this.DM&~this[c];return s.t=this.t,s.s=~this.s,s}function qa(s){var c=i();return s<0?this.rShiftTo(-s,c):this.lShiftTo(s,c),c}function Za(s){var c=i();return s<0?this.lShiftTo(-s,c):this.rShiftTo(s,c),c}function Xa(s){if(s==0)return-1;var c=0;return s&65535||(s>>=16,c+=16),s&255||(s>>=8,c+=8),s&15||(s>>=4,c+=4),s&3||(s>>=2,c+=2),s&1||++c,c}function Ka(){for(var s=0;s<this.t;++s)if(this[s]!=0)return s*this.DB+Xa(this[s]);return this.s<0?this.t*this.DB:-1}function ja(s){for(var c=0;s!=0;)s&=s-1,++c;return c}function Ya(){for(var s=0,c=this.s&this.DM,u=0;u<this.t;++u)s+=ja(this[u]^c);return s}function Ja(s){var c=Math.floor(s/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<s%this.DB)!=0}function Qa(s,c){var u=n.ONE.shiftLeft(s);return this.bitwiseTo(u,c,u),u}function tu(s){return this.changeBit(s,An)}function eu(s){return this.changeBit(s,oo)}function ru(s){return this.changeBit(s,io)}function nu(s,c){for(var u=0,p=0,m=Math.min(s.t,this.t);u<m;)p+=this[u]+s[u],c[u++]=p&this.DM,p>>=this.DB;if(s.t<this.t){for(p+=s.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<s.t;)p+=s[u],c[u++]=p&this.DM,p>>=this.DB;p+=s.s}c.s=p<0?-1:0,p>0?c[u++]=p:p<-1&&(c[u++]=this.DV+p),c.t=u,c.clamp()}function iu(s){var c=i();return this.addTo(s,c),c}function ou(s){var c=i();return this.subTo(s,c),c}function su(s){var c=i();return this.multiplyTo(s,c),c}function cu(){var s=i();return this.squareTo(s),s}function au(s){var c=i();return this.divRemTo(s,c,null),c}function uu(s){var c=i();return this.divRemTo(s,null,c),c}function lu(s){var c=i(),u=i();return this.divRemTo(s,c,u),new Array(c,u)}function fu(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp()}function hu(s,c){if(s!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=s;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function er(){}function so(s){return s}function pu(s,c,u){s.multiplyTo(c,u)}function du(s,c){s.squareTo(c)}er.prototype.convert=so,er.prototype.revert=so,er.prototype.mulTo=pu,er.prototype.sqrTo=du;function mu(s){return this.exp(s,new er)}function gu(s,c,u){var p=Math.min(this.t+s.t,c);for(u.s=0,u.t=p;p>0;)u[--p]=0;var m;for(m=u.t-this.t;p<m;++p)u[p+this.t]=this.am(0,s[p],u,p,0,this.t);for(m=Math.min(s.t,c);p<m;++p)this.am(0,s[p],u,p,0,c-p);u.clamp()}function yu(s,c,u){--c;var p=u.t=this.t+s.t-c;for(u.s=0;--p>=0;)u[p]=0;for(p=Math.max(c-this.t,0);p<s.t;++p)u[this.t+p-c]=this.am(c-p,s[p],u,0,0,this.t+p-c);u.clamp(),u.drShiftTo(1,u)}function he(s){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*s.t,this.r2),this.mu=this.r2.divide(s),this.m=s}function bu(s){if(s.s<0||s.t>2*this.m.t)return s.mod(this.m);if(s.compareTo(this.m)<0)return s;var c=i();return s.copyTo(c),this.reduce(c),c}function wu(s){return s}function Eu(s){for(s.drShiftTo(this.m.t-1,this.r2),s.t>this.m.t+1&&(s.t=this.m.t+1,s.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);s.compareTo(this.r2)<0;)s.dAddOffset(1,this.m.t+1);for(s.subTo(this.r2,s);s.compareTo(this.m)>=0;)s.subTo(this.m,s)}function vu(s,c){s.squareTo(c),this.reduce(c)}function xu(s,c,u){s.multiplyTo(c,u),this.reduce(u)}he.prototype.convert=bu,he.prototype.revert=wu,he.prototype.reduce=Eu,he.prototype.mulTo=xu,he.prototype.sqrTo=vu;function Su(s,c){var u=s.bitLength(),p,m=_(1),y;if(u<=0)return m;u<18?p=1:u<48?p=3:u<144?p=4:u<768?p=5:p=6,u<8?y=new le(c):c.isEven()?y=new he(c):y=new fe(c);var E=new Array,v=3,N=p-1,j=(1<<p)-1;if(E[1]=y.convert(this),p>1){var Et=i();for(y.sqrTo(E[1],Et);v<=j;)E[v]=i(),y.mulTo(Et,E[v-2],E[v]),v+=2}var dt=s.t-1,Gt,xr=!0,kt=i(),Bt;for(u=Ct(s[dt])-1;dt>=0;){for(u>=N?Gt=s[dt]>>u-N&j:(Gt=(s[dt]&(1<<u+1)-1)<<N-u,dt>0&&(Gt|=s[dt-1]>>this.DB+u-N)),v=p;!(Gt&1);)Gt>>=1,--v;if((u-=v)<0&&(u+=this.DB,--dt),xr)E[Gt].copyTo(m),xr=!1;else{for(;v>1;)y.sqrTo(m,kt),y.sqrTo(kt,m),v-=2;v>0?y.sqrTo(m,kt):(Bt=m,m=kt,kt=Bt),y.mulTo(kt,E[Gt],m)}for(;dt>=0&&!(s[dt]&1<<u);)y.sqrTo(m,kt),Bt=m,m=kt,kt=Bt,--u<0&&(u=this.DB-1,--dt)}return y.revert(m)}function Tu(s){var c=this.s<0?this.negate():this.clone(),u=s.s<0?s.negate():s.clone();if(c.compareTo(u)<0){var p=c;c=u,u=p}var m=c.getLowestSetBit(),y=u.getLowestSetBit();if(y<0)return c;for(m<y&&(y=m),y>0&&(c.rShiftTo(y,c),u.rShiftTo(y,u));c.signum()>0;)(m=c.getLowestSetBit())>0&&c.rShiftTo(m,c),(m=u.getLowestSetBit())>0&&u.rShiftTo(m,u),c.compareTo(u)>=0?(c.subTo(u,c),c.rShiftTo(1,c)):(u.subTo(c,u),u.rShiftTo(1,u));return y>0&&u.lShiftTo(y,u),u}function Au(s){if(s<=0)return 0;var c=this.DV%s,u=this.s<0?s-1:0;if(this.t>0)if(c==0)u=this[0]%s;else for(var p=this.t-1;p>=0;--p)u=(c*u+this[p])%s;return u}function Iu(s){var c=s.isEven();if(this.isEven()&&c||s.signum()==0)return n.ZERO;for(var u=s.clone(),p=this.clone(),m=_(1),y=_(0),E=_(0),v=_(1);u.signum()!=0;){for(;u.isEven();)u.rShiftTo(1,u),c?((!m.isEven()||!y.isEven())&&(m.addTo(this,m),y.subTo(s,y)),m.rShiftTo(1,m)):y.isEven()||y.subTo(s,y),y.rShiftTo(1,y);for(;p.isEven();)p.rShiftTo(1,p),c?((!E.isEven()||!v.isEven())&&(E.addTo(this,E),v.subTo(s,v)),E.rShiftTo(1,E)):v.isEven()||v.subTo(s,v),v.rShiftTo(1,v);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(E,m),y.subTo(v,y)):(p.subTo(u,p),c&&E.subTo(m,E),v.subTo(y,v))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(v.compareTo(s)>=0)return v.subtract(s);if(v.signum()<0)v.addTo(s,v);else return v;return v.signum()<0?v.add(s):v}var st=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Cu=(1<<26)/st[st.length-1];function _u(s){var c,u=this.abs();if(u.t==1&&u[0]<=st[st.length-1]){for(c=0;c<st.length;++c)if(u[0]==st[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<st.length;){for(var p=st[c],m=c+1;m<st.length&&p<Cu;)p*=st[m++];for(p=u.modInt(p);c<m;)if(p%st[c++]==0)return!1}return u.millerRabin(s)}function ku(s){var c=this.subtract(n.ONE),u=c.getLowestSetBit();if(u<=0)return!1;var p=c.shiftRight(u);s=s+1>>1,s>st.length&&(s=st.length);for(var m=i(),y=0;y<s;++y){m.fromInt(st[Math.floor(Math.random()*st.length)]);var E=m.modPow(p,this);if(E.compareTo(n.ONE)!=0&&E.compareTo(c)!=0){for(var v=1;v++<u&&E.compareTo(c)!=0;)if(E=E.modPowInt(2,this),E.compareTo(n.ONE)==0)return!1;if(E.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=Ba,n.prototype.toRadix=Ra,n.prototype.fromRadix=La,n.prototype.fromNumber=Na,n.prototype.bitwiseTo=Ua,n.prototype.changeBit=Qa,n.prototype.addTo=nu,n.prototype.dMultiply=fu,n.prototype.dAddOffset=hu,n.prototype.multiplyLowerTo=gu,n.prototype.multiplyUpperTo=yu,n.prototype.modInt=Au,n.prototype.millerRabin=ku,n.prototype.clone=Ia,n.prototype.intValue=Ca,n.prototype.byteValue=_a,n.prototype.shortValue=ka,n.prototype.signum=Da,n.prototype.toByteArray=Oa,n.prototype.equals=Pa,n.prototype.min=Ma,n.prototype.max=Fa,n.prototype.and=$a,n.prototype.or=za,n.prototype.xor=Va,n.prototype.andNot=Ha,n.prototype.not=Wa,n.prototype.shiftLeft=qa,n.prototype.shiftRight=Za,n.prototype.getLowestSetBit=Ka,n.prototype.bitCount=Ya,n.prototype.testBit=Ja,n.prototype.setBit=tu,n.prototype.clearBit=eu,n.prototype.flipBit=ru,n.prototype.add=iu,n.prototype.subtract=ou,n.prototype.multiply=su,n.prototype.divide=au,n.prototype.remainder=uu,n.prototype.divideAndRemainder=lu,n.prototype.modPow=Su,n.prototype.modInverse=Iu,n.prototype.pow=mu,n.prototype.gcd=Tu,n.prototype.isProbablePrime=_u,n.prototype.square=cu,n.prototype.Barrett=he;var vr,pt,K;function Bu(s){pt[K++]^=s&255,pt[K++]^=s>>8&255,pt[K++]^=s>>16&255,pt[K++]^=s>>24&255,K>=_n&&(K-=_n)}function co(){Bu(new Date().getTime())}if(pt==null){pt=new Array,K=0;var _t;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var ao=new Uint8Array(32);for(window.crypto.getRandomValues(ao),_t=0;_t<32;++_t)pt[K++]=ao[_t]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var uo=window.crypto.random(32);for(_t=0;_t<uo.length;++_t)pt[K++]=uo.charCodeAt(_t)&255}}for(;K<_n;)_t=Math.floor(65536*Math.random()),pt[K++]=_t>>>8,pt[K++]=_t&255;K=0,co()}function Du(){if(vr==null){for(co(),vr=Ou(),vr.init(pt),K=0;K<pt.length;++K)pt[K]=0;K=0}return vr.next()}function Ru(s){var c;for(c=0;c<s.length;++c)s[c]=Du()}function In(){}In.prototype.nextBytes=Ru;function Cn(){this.i=0,this.j=0,this.S=new Array}function Lu(s){var c,u,p;for(c=0;c<256;++c)this.S[c]=c;for(u=0,c=0;c<256;++c)u=u+this.S[c]+s[c%s.length]&255,p=this.S[c],this.S[c]=this.S[u],this.S[u]=p;this.i=0,this.j=0}function Nu(){var s;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,s=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=s,this.S[s+this.S[this.i]&255]}Cn.prototype.init=Lu,Cn.prototype.next=Nu;function Ou(){return new Cn}var _n=256;typeof Hr<"u"?Hr=Ds.exports={default:n,BigInteger:n,SecureRandom:In}:this.jsbn={BigInteger:n,SecureRandom:In}}).call(Hr)});var hr=B(Wr=>{(function(){"use strict";var r={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(a){return n(o(a),arguments)}function e(a,l){return t.apply(null,[a].concat(l||[]))}function n(a,l){var f=1,d=a.length,h,g="",w,T,b,S,k,C,_,G;for(w=0;w<d;w++)if(typeof a[w]=="string")g+=a[w];else if(typeof a[w]=="object"){if(b=a[w],b.keys)for(h=l[f],T=0;T<b.keys.length;T++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',b.keys[T],b.keys[T-1]));h=h[b.keys[T]]}else b.param_no?h=l[b.param_no]:h=l[f++];if(r.not_type.test(b.type)&&r.not_primitive.test(b.type)&&h instanceof Function&&(h=h()),r.numeric_arg.test(b.type)&&typeof h!="number"&&isNaN(h))throw new TypeError(t("[sprintf] expecting number but found %T",h));switch(r.number.test(b.type)&&(_=h>=0),b.type){case"b":h=parseInt(h,10).toString(2);break;case"c":h=String.fromCharCode(parseInt(h,10));break;case"d":case"i":h=parseInt(h,10);break;case"j":h=JSON.stringify(h,null,b.width?parseInt(b.width):0);break;case"e":h=b.precision?parseFloat(h).toExponential(b.precision):parseFloat(h).toExponential();break;case"f":h=b.precision?parseFloat(h).toFixed(b.precision):parseFloat(h);break;case"g":h=b.precision?String(Number(h.toPrecision(b.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=b.precision?h.substring(0,b.precision):h;break;case"t":h=String(!!h),h=b.precision?h.substring(0,b.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=b.precision?h.substring(0,b.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=b.precision?h.substring(0,b.precision):h;break;case"x":h=(parseInt(h,10)>>>0).toString(16);break;case"X":h=(parseInt(h,10)>>>0).toString(16).toUpperCase();break}r.json.test(b.type)?g+=h:(r.number.test(b.type)&&(!_||b.sign)?(G=_?"+":"-",h=h.toString().replace(r.sign,"")):G="",k=b.pad_char?b.pad_char==="0"?"0":b.pad_char.charAt(1):" ",C=b.width-(G+h).length,S=b.width&&C>0?k.repeat(C):"",g+=b.align?G+h+S:k==="0"?G+S+h:S+G+h)}return g}var i=Object.create(null);function o(a){if(i[a])return i[a];for(var l=a,f,d=[],h=0;l;){if((f=r.text.exec(l))!==null)d.push(f[0]);else if((f=r.modulo.exec(l))!==null)d.push("%");else if((f=r.placeholder.exec(l))!==null){if(f[2]){h|=1;var g=[],w=f[2],T=[];if((T=r.key.exec(w))!==null)for(g.push(T[1]);(w=w.substring(T[0].length))!=="";)if((T=r.key_access.exec(w))!==null)g.push(T[1]);else if((T=r.index_access.exec(w))!==null)g.push(T[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");f[2]=g}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:f[0],param_no:f[1],keys:f[2],sign:f[3],pad_char:f[4],align:f[5],width:f[6],precision:f[7],type:f[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");l=l.substring(f[0].length)}return i[a]=d}typeof Wr<"u"&&(Wr.sprintf=t,Wr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var tc=B((rg,Qs)=>{"use strict";function Js(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Uh(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return Js(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),Js(new i,e)}}Qs.exports=Uh});var ac=B((_g,cc)=>{"use strict";cc.exports=Zh;function Zh(r,t){for(var e=new Array(arguments.length-1),n=0,i=2,o=!0;i<arguments.length;)e[n++]=arguments[i++];return new Promise(function(l,f){e[n]=function(h){if(o)if(o=!1,h)f(h);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];l.apply(null,g)}};try{r.apply(t||null,e)}catch(d){o&&(o=!1,f(d))}})}});var hc=B(fc=>{"use strict";var sn=fc;sn.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var Je=new Array(64),lc=new Array(123);for(Ot=0;Ot<64;)lc[Je[Ot]=Ot<26?Ot+65:Ot<52?Ot+71:Ot<62?Ot-4:Ot-59|43]=Ot++;var Ot;sn.encode=function(t,e,n){for(var i=null,o=[],a=0,l=0,f;e<n;){var d=t[e++];switch(l){case 0:o[a++]=Je[d>>2],f=(d&3)<<4,l=1;break;case 1:o[a++]=Je[f|d>>4],f=(d&15)<<2,l=2;break;case 2:o[a++]=Je[f|d>>6],o[a++]=Je[d&63],l=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0)}return l&&(o[a++]=Je[f],o[a++]=61,l===1&&(o[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))};var uc="invalid encoding";sn.decode=function(t,e,n){for(var i=n,o=0,a,l=0;l<t.length;){var f=t.charCodeAt(l++);if(f===61&&o>1)break;if((f=lc[f])===void 0)throw Error(uc);switch(o){case 0:a=f,o=1;break;case 1:e[n++]=a<<2|(f&48)>>4,a=f,o=2;break;case 2:e[n++]=(a&15)<<4|(f&60)>>2,a=f,o=3;break;case 3:e[n++]=(a&3)<<6|f,o=0;break}}if(o===1)throw Error(uc);return n-i};sn.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var dc=B((Bg,pc)=>{"use strict";pc.exports=cn;function cn(){this._listeners={}}cn.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};cn.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===e?n.splice(i,1):++i;return this};cn.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<e.length;)e[i].fn.apply(e[i++].ctx,n)}return this}});var vc=B((Dg,Ec)=>{"use strict";Ec.exports=mc(mc);function mc(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(f,d,h){t[0]=f,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3]}function o(f,d,h){t[0]=f,d[h]=e[3],d[h+1]=e[2],d[h+2]=e[1],d[h+3]=e[0]}r.writeFloatLE=n?i:o,r.writeFloatBE=n?o:i;function a(f,d){return e[0]=f[d],e[1]=f[d+1],e[2]=f[d+2],e[3]=f[d+3],t[0]}function l(f,d){return e[3]=f[d],e[2]=f[d+1],e[1]=f[d+2],e[0]=f[d+3],t[0]}r.readFloatLE=n?a:l,r.readFloatBE=n?l:a}():function(){function t(n,i,o,a){var l=i<0?1:0;if(l&&(i=-i),i===0)n(1/i>0?0:2147483648,o,a);else if(isNaN(i))n(2143289344,o,a);else if(i>34028234663852886e22)n((l<<31|2139095040)>>>0,o,a);else if(i<11754943508222875e-54)n((l<<31|Math.round(i/1401298464324817e-60))>>>0,o,a);else{var f=Math.floor(Math.log(i)/Math.LN2),d=Math.round(i*Math.pow(2,-f)*8388608)&8388607;n((l<<31|f+127<<23|d)>>>0,o,a)}}r.writeFloatLE=t.bind(null,gc),r.writeFloatBE=t.bind(null,yc);function e(n,i,o){var a=n(i,o),l=(a>>31)*2+1,f=a>>>23&255,d=a&8388607;return f===255?d?NaN:l*(1/0):f===0?l*1401298464324817e-60*d:l*Math.pow(2,f-150)*(d+8388608)}r.readFloatLE=e.bind(null,bc),r.readFloatBE=e.bind(null,wc)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(f,d,h){t[0]=f,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3],d[h+4]=e[4],d[h+5]=e[5],d[h+6]=e[6],d[h+7]=e[7]}function o(f,d,h){t[0]=f,d[h]=e[7],d[h+1]=e[6],d[h+2]=e[5],d[h+3]=e[4],d[h+4]=e[3],d[h+5]=e[2],d[h+6]=e[1],d[h+7]=e[0]}r.writeDoubleLE=n?i:o,r.writeDoubleBE=n?o:i;function a(f,d){return e[0]=f[d],e[1]=f[d+1],e[2]=f[d+2],e[3]=f[d+3],e[4]=f[d+4],e[5]=f[d+5],e[6]=f[d+6],e[7]=f[d+7],t[0]}function l(f,d){return e[7]=f[d],e[6]=f[d+1],e[5]=f[d+2],e[4]=f[d+3],e[3]=f[d+4],e[2]=f[d+5],e[1]=f[d+6],e[0]=f[d+7],t[0]}r.readDoubleLE=n?a:l,r.readDoubleBE=n?l:a}():function(){function t(n,i,o,a,l,f){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,l,f+i),n(1/a>0?0:2147483648,l,f+o);else if(isNaN(a))n(0,l,f+i),n(2146959360,l,f+o);else if(a>17976931348623157e292)n(0,l,f+i),n((d<<31|2146435072)>>>0,l,f+o);else{var h;if(a<22250738585072014e-324)h=a/5e-324,n(h>>>0,l,f+i),n((d<<31|h/4294967296)>>>0,l,f+o);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),h=a*Math.pow(2,-g),n(h*4503599627370496>>>0,l,f+i),n((d<<31|g+1023<<20|h*1048576&1048575)>>>0,l,f+o)}}}r.writeDoubleLE=t.bind(null,gc,0,4),r.writeDoubleBE=t.bind(null,yc,4,0);function e(n,i,o,a,l){var f=n(a,l+i),d=n(a,l+o),h=(d>>31)*2+1,g=d>>>20&2047,w=4294967296*(d&1048575)+f;return g===2047?w?NaN:h*(1/0):g===0?h*5e-324*w:h*Math.pow(2,g-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,bc,0,4),r.readDoubleBE=e.bind(null,wc,4,0)}(),r}function gc(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function yc(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function bc(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function wc(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var xc=B((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var Tc=B(Sc=>{"use strict";var $i=Sc;$i.length=function(t){for(var e=0,n=0,i=0;i<t.length;++i)n=t.charCodeAt(i),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e};$i.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var o=null,a=[],l=0,f;e<n;)f=t[e++],f<128?a[l++]=f:f>191&&f<224?a[l++]=(f&31)<<6|t[e++]&63:f>239&&f<365?(f=((f&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,a[l++]=55296+(f>>10),a[l++]=56320+(f&1023)):a[l++]=(f&15)<<12|(t[e++]&63)<<6|t[e++]&63,l>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),l=0);return o?(l&&o.push(String.fromCharCode.apply(String,a.slice(0,l))),o.join("")):String.fromCharCode.apply(String,a.slice(0,l))};$i.write=function(t,e,n){for(var i=n,o,a,l=0;l<t.length;++l)o=t.charCodeAt(l),o<128?e[n++]=o:o<2048?(e[n++]=o>>6|192,e[n++]=o&63|128):(o&64512)===55296&&((a=t.charCodeAt(l+1))&64512)===56320?(o=65536+((o&1023)<<10)+(a&1023),++l,e[n++]=o>>18|240,e[n++]=o>>12&63|128,e[n++]=o>>6&63|128,e[n++]=o&63|128):(e[n++]=o>>12|224,e[n++]=o>>6&63|128,e[n++]=o&63|128);return n-i}});var Ic=B((Lg,Ac)=>{"use strict";Ac.exports=Xh;function Xh(r,t,e){var n=e||8192,i=n>>>1,o=null,a=n;return function(f){if(f<1||f>i)return r(f);a+f>n&&(o=r(n),a=0);var d=t.call(o,a,a+=f);return a&7&&(a=(a|7)+1),d}}});var _c=B((Ng,Cc)=>{"use strict";Cc.exports=Y;var dr=Ie();function Y(r,t){this.lo=r>>>0,this.hi=t>>>0}var Ae=Y.zero=new Y(0,0);Ae.toNumber=function(){return 0};Ae.zzEncode=Ae.zzDecode=function(){return this};Ae.length=function(){return 1};var Kh=Y.zeroHash="\0\0\0\0\0\0\0\0";Y.fromNumber=function(t){if(t===0)return Ae;var e=t<0;e&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new Y(n,i)};Y.from=function(t){if(typeof t=="number")return Y.fromNumber(t);if(dr.isString(t))if(dr.Long)t=dr.Long.fromString(t);else return Y.fromNumber(parseInt(t,10));return t.low||t.high?new Y(t.low>>>0,t.high>>>0):Ae};Y.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};Y.prototype.toLong=function(t){return dr.Long?new dr.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var ce=String.prototype.charCodeAt;Y.fromHash=function(t){return t===Kh?Ae:new Y((ce.call(t,0)|ce.call(t,1)<<8|ce.call(t,2)<<16|ce.call(t,3)<<24)>>>0,(ce.call(t,4)|ce.call(t,5)<<8|ce.call(t,6)<<16|ce.call(t,7)<<24)>>>0)};Y.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};Y.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};Y.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};Y.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var Ie=B(zi=>{"use strict";var A=zi;A.asPromise=ac();A.base64=hc();A.EventEmitter=dc();A.float=vc();A.inquire=xc();A.utf8=Tc();A.pool=Ic();A.LongBits=_c();A.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);A.global=A.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||zi;A.emptyArray=Object.freeze?Object.freeze([]):[];A.emptyObject=Object.freeze?Object.freeze({}):{};A.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};A.isString=function(t){return typeof t=="string"||t instanceof String};A.isObject=function(t){return t&&typeof t=="object"};A.isset=A.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};A.Buffer=function(){try{var r=A.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();A._Buffer_from=null;A._Buffer_allocUnsafe=null;A.newBuffer=function(t){return typeof t=="number"?A.Buffer?A._Buffer_allocUnsafe(t):new A.Array(t):A.Buffer?A._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};A.Array=typeof Uint8Array<"u"?Uint8Array:Array;A.Long=A.global.dcodeIO&&A.global.dcodeIO.Long||A.global.Long||A.inquire("long");A.key2Re=/^true|false|0|1$/;A.key32Re=/^-?(?:0|[1-9][0-9]*)$/;A.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;A.longToHash=function(t){return t?A.LongBits.from(t).toHash():A.LongBits.zeroHash};A.longFromHash=function(t,e){var n=A.LongBits.fromHash(t);return A.Long?A.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function kc(r,t,e){for(var n=Object.keys(t),i=0;i<n.length;++i)(r[n[i]]===void 0||!e)&&(r[n[i]]=t[n[i]]);return r}A.merge=kc;A.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function Bc(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&kc(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}A.newError=Bc;A.ProtocolError=Bc("ProtocolError");A.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var i=Object.keys(this),o=i.length-1;o>-1;--o)if(e[i[o]]===1&&this[i[o]]!==void 0&&this[i[o]]!==null)return i[o]}};A.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};A.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};A._configure=function(){var r=A.Buffer;if(!r){A._Buffer_from=A._Buffer_allocUnsafe=null;return}A._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},A._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var Wi=B((Pg,Oc)=>{"use strict";Oc.exports=$;var Ft=Ie(),Hi,Lc=Ft.LongBits,jh=Ft.utf8;function Pt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function $(r){this.buf=r,this.pos=0,this.len=r.length}var Dc=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new $(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new $(t);throw Error("illegal buffer")},Nc=function(){return Ft.Buffer?function(e){return($.create=function(i){return Ft.Buffer.isBuffer(i)?new Hi(i):Dc(i)})(e)}:Dc};$.create=Nc();$.prototype._slice=Ft.Array.prototype.subarray||Ft.Array.prototype.slice;$.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Pt(this,10);return t}}();$.prototype.int32=function(){return this.uint32()|0};$.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Vi(){var r=new Lc(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Pt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw Pt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}$.prototype.bool=function(){return this.uint32()!==0};function an(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}$.prototype.fixed32=function(){if(this.pos+4>this.len)throw Pt(this,4);return an(this.buf,this.pos+=4)};$.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Pt(this,4);return an(this.buf,this.pos+=4)|0};function Rc(){if(this.pos+8>this.len)throw Pt(this,8);return new Lc(an(this.buf,this.pos+=4),an(this.buf,this.pos+=4))}$.prototype.float=function(){if(this.pos+4>this.len)throw Pt(this,4);var t=Ft.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};$.prototype.double=function(){if(this.pos+8>this.len)throw Pt(this,4);var t=Ft.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};$.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Pt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};$.prototype.string=function(){var t=this.bytes();return jh.read(t,0,t.length)};$.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Pt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Pt(this);while(this.buf[this.pos++]&128);return this};$.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};$._configure=function(r){Hi=r,$.create=Nc(),Hi._configure();var t=Ft.Long?"toLong":"toNumber";Ft.merge($.prototype,{int64:function(){return Vi.call(this)[t](!1)},uint64:function(){return Vi.call(this)[t](!0)},sint64:function(){return Vi.call(this).zzDecode()[t](!1)},fixed64:function(){return Rc.call(this)[t](!0)},sfixed64:function(){return Rc.call(this)[t](!1)}})}});var Uc=B((Mg,Fc)=>{"use strict";Fc.exports=Ce;var Mc=Wi();(Ce.prototype=Object.create(Mc.prototype)).constructor=Ce;var Pc=Ie();function Ce(r){Mc.call(this,r)}Ce._configure=function(){Pc.Buffer&&(Ce.prototype._slice=Pc.Buffer.prototype.slice)};Ce.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};Ce._configure()});var Ji=B((Fg,Vc)=>{"use strict";Vc.exports=D;var Tt=Ie(),qi,un=Tt.LongBits,Gc=Tt.base64,$c=Tt.utf8;function mr(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function Xi(){}function Yh(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function D(){this.len=0,this.head=new mr(Xi,0,0),this.tail=this.head,this.states=null}var zc=function(){return Tt.Buffer?function(){return(D.create=function(){return new qi})()}:function(){return new D}};D.create=zc();D.alloc=function(t){return new Tt.Array(t)};Tt.Array!==Array&&(D.alloc=Tt.pool(D.alloc,Tt.Array.prototype.subarray));D.prototype._push=function(t,e,n){return this.tail=this.tail.next=new mr(t,e,n),this.len+=e,this};function Ki(r,t,e){t[e]=r&255}function Jh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function ji(r,t){this.len=r,this.next=void 0,this.val=t}ji.prototype=Object.create(mr.prototype);ji.prototype.fn=Jh;D.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new ji((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};D.prototype.int32=function(t){return t<0?this._push(Yi,10,un.fromNumber(t)):this.uint32(t)};D.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Yi(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}D.prototype.uint64=function(t){var e=un.from(t);return this._push(Yi,e.length(),e)};D.prototype.int64=D.prototype.uint64;D.prototype.sint64=function(t){var e=un.from(t).zzEncode();return this._push(Yi,e.length(),e)};D.prototype.bool=function(t){return this._push(Ki,1,t?1:0)};function Zi(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}D.prototype.fixed32=function(t){return this._push(Zi,4,t>>>0)};D.prototype.sfixed32=D.prototype.fixed32;D.prototype.fixed64=function(t){var e=un.from(t);return this._push(Zi,4,e.lo)._push(Zi,4,e.hi)};D.prototype.sfixed64=D.prototype.fixed64;D.prototype.float=function(t){return this._push(Tt.float.writeFloatLE,4,t)};D.prototype.double=function(t){return this._push(Tt.float.writeDoubleLE,8,t)};var Qh=Tt.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var i=0;i<t.length;++i)e[n+i]=t[i]};D.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(Ki,1,0);if(Tt.isString(t)){var n=D.alloc(e=Gc.length(t));Gc.decode(t,n,0),t=n}return this.uint32(e)._push(Qh,e,t)};D.prototype.string=function(t){var e=$c.length(t);return e?this.uint32(e)._push($c.write,e,t):this._push(Ki,1,0)};D.prototype.fork=function(){return this.states=new Yh(this),this.head=this.tail=new mr(Xi,0,0),this.len=0,this};D.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new mr(Xi,0,0),this.len=0),this};D.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};D.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};D._configure=function(r){qi=r,D.create=zc(),qi._configure()}});var qc=B((Ug,Wc)=>{"use strict";Wc.exports=Ut;var Hc=Ji();(Ut.prototype=Object.create(Hc.prototype)).constructor=Ut;var ae=Ie();function Ut(){Hc.call(this)}Ut._configure=function(){Ut.alloc=ae._Buffer_allocUnsafe,Ut.writeBytesBuffer=ae.Buffer&&ae.Buffer.prototype instanceof Uint8Array&&ae.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var i=0;i<t.length;)e[n++]=t[i++]}};Ut.prototype.bytes=function(t){ae.isString(t)&&(t=ae._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Ut.writeBytesBuffer,e,t),this};function tp(r,t,e){r.length<40?ae.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Ut.prototype.string=function(t){var e=ae.Buffer.byteLength(t);return this.uint32(e),e&&this._push(tp,e,t),this};Ut._configure()});var fp={};mt(fp,{Server:()=>Tn,createServer:()=>lp});var Zs=M($t("net"),1);var Qt=$t("node:net");function Ar(r){return!!(0,Qt.isIP)(r)}var Nn={};mt(Nn,{identity:()=>Zu});function zu(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),a=o.charCodeAt(0);if(e[a]!==255)throw new TypeError(o+" is ambiguous");e[a]=i}var l=r.length,f=r.charAt(0),d=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);function g(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var S=0,k=0,C=0,_=b.length;C!==_&&b[C]===0;)C++,S++;for(var G=(_-C)*h+1>>>0,W=new Uint8Array(G);C!==_;){for(var ht=b[C],at=0,ot=G-1;(ht!==0||at<k)&&ot!==-1;ot--,at++)ht+=256*W[ot]>>>0,W[ot]=ht%l>>>0,ht=ht/l>>>0;if(ht!==0)throw new Error("Non-zero carry");k=at,C++}for(var ut=G-k;ut!==G&&W[ut]===0;)ut++;for(var Ct=f.repeat(S);ut<G;++ut)Ct+=r.charAt(W[ut]);return Ct}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var S=0;if(b[S]!==" "){for(var k=0,C=0;b[S]===f;)k++,S++;for(var _=(b.length-S)*d+1>>>0,G=new Uint8Array(_);b[S];){var W=e[b.charCodeAt(S)];if(W===255)return;for(var ht=0,at=_-1;(W!==0||ht<C)&&at!==-1;at--,ht++)W+=l*G[at]>>>0,G[at]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");C=ht,S++}if(b[S]!==" "){for(var ot=_-C;ot!==_&&G[ot]===0;)ot++;for(var ut=new Uint8Array(k+(_-ot)),Ct=k;ot!==_;)ut[Ct++]=G[ot++];return ut}}}function T(b){var S=w(b);if(S)return S;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:T}}var Vu=zu,Hu=Vu,fo=Hu;var mp=new Uint8Array(0);var ho=(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},vt=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 po=r=>new TextEncoder().encode(r),mo=r=>new TextDecoder().decode(r);var Bn=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Dn=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 yo(this,t)}},Rn=class{constructor(t){this.decoders=t}or(t){return yo(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`)}},yo=(r,t)=>new Rn({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Ln=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Bn(t,e,n),this.decoder=new Dn(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},De=({name:r,prefix:t,encode:e,decode:n})=>new Ln(r,t,e,n),te=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=fo(e,t);return De({prefix:r,name:t,encode:n,decode:o=>vt(i(o))})},Wu=(r,t,e,n)=>{let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let o=r.length;for(;r[o-1]==="=";)--o;let a=new Uint8Array(o*e/8|0),l=0,f=0,d=0;for(let h=0;h<o;++h){let g=i[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|g,l+=e,l>=8&&(l-=8,a[d++]=255&f>>l)}if(l>=e||255&f<<8-l)throw new SyntaxError("Unexpected end of data");return a},qu=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,o="",a=0,l=0;for(let f=0;f<r.length;++f)for(l=l<<8|r[f],a+=8;a>e;)a-=e,o+=t[i&l>>a];if(a&&(o+=t[i&l<<e-a]),n)for(;o.length*e&7;)o+="=";return o},F=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>De({prefix:t,name:r,encode(i){return qu(i,n,e)},decode(i){return Wu(i,n,e,r)}});var Zu=De({prefix:"\0",name:"identity",encode:r=>mo(r),decode:r=>po(r)});var On={};mt(On,{base2:()=>Xu});var Xu=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Pn={};mt(Pn,{base8:()=>Ku});var Ku=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Mn={};mt(Mn,{base10:()=>ju});var ju=te({prefix:"9",name:"base10",alphabet:"0123456789"});var Fn={};mt(Fn,{base16:()=>Yu,base16upper:()=>Ju});var Yu=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ju=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Un={};mt(Un,{base32:()=>Dt,base32hex:()=>rl,base32hexpad:()=>il,base32hexpadupper:()=>ol,base32hexupper:()=>nl,base32pad:()=>tl,base32padupper:()=>el,base32upper:()=>Qu,base32z:()=>sl});var Dt=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qu=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tl=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),el=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rl=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nl=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),il=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ol=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sl=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gn={};mt(Gn,{base36:()=>cl,base36upper:()=>al});var cl=te({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),al=te({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $n={};mt($n,{base58btc:()=>q,base58flickr:()=>ul});var q=te({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ul=te({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vn={};mt(Vn,{base64:()=>zn,base64pad:()=>ll,base64url:()=>fl,base64urlpad:()=>hl});var zn=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ll=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fl=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hl=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Hn={};mt(Hn,{base256emoji:()=>yl});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}"),pl=bo.reduce((r,t,e)=>(r[e]=t,r),[]),dl=bo.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function ml(r){return r.reduce((t,e)=>(t+=pl[e],t),"")}function gl(r){let t=[];for(let e of r){let n=dl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var yl=De({prefix:"\u{1F680}",name:"base256emoji",encode:ml,decode:gl});var Kn={};mt(Kn,{sha256:()=>Cr,sha512:()=>Pl});var Xn=M($t("crypto"),1);var bl=vo,wo=128,wl=127,El=~wl,vl=Math.pow(2,31);function vo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=vl;)t[e++]=r&255|wo,r/=128;for(;r&El;)t[e++]=r&255|wo,r>>>=7;return t[e]=r|0,vo.bytes=e-n+1,t}var xl=Wn,Sl=128,Eo=127;function Wn(r,n){var e=0,n=n||0,i=0,o=n,a,l=r.length;do{if(o>=l)throw Wn.bytes=0,new RangeError("Could not decode varint");a=r[o++],e+=i<28?(a&Eo)<<i:(a&Eo)*Math.pow(2,i),i+=7}while(a>=Sl);return Wn.bytes=o-n,e}var Tl=Math.pow(2,7),Al=Math.pow(2,14),Il=Math.pow(2,21),Cl=Math.pow(2,28),_l=Math.pow(2,35),kl=Math.pow(2,42),Bl=Math.pow(2,49),Dl=Math.pow(2,56),Rl=Math.pow(2,63),Ll=function(r){return r<Tl?1:r<Al?2:r<Il?3:r<Cl?4:r<_l?5:r<kl?6:r<Bl?7:r<Dl?8:r<Rl?9:10},Nl={encode:bl,decode:xl,encodingLength:Ll},Ol=Nl,rr=Ol;var nr=(r,t=0)=>[rr.decode(r,t),rr.decode.bytes],Re=(r,t,e=0)=>(rr.encode(r,t,e),t),Le=r=>rr.encodingLength(r);var ee=(r,t)=>{let e=t.byteLength,n=Le(r),i=n+Le(e),o=new Uint8Array(i+e);return Re(r,o,0),Re(e,o,n),o.set(t,i),new Ne(r,e,t,o)},pe=r=>{let t=vt(r),[e,n]=nr(t),[i,o]=nr(t.subarray(n)),a=t.subarray(n+o);if(a.byteLength!==i)throw new Error("Incorrect length");return new Ne(e,i,a,t)},xo=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ho(r.bytes,e.bytes)}},Ne=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Zn=({name:r,code:t,encode:e})=>new qn(r,t,e),qn=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?ee(this.code,e):e.then(n=>ee(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Cr=Zn({name:"sha2-256",code:18,encode:r=>vt(Xn.default.createHash("sha256").update(r).digest())}),Pl=Zn({name:"sha2-512",code:19,encode:r=>vt(Xn.default.createHash("sha512").update(r).digest())});var jn={};mt(jn,{identity:()=>_r});var To=0,Ml="identity",Ao=vt,Fl=r=>ee(To,Ao(r)),_r={code:To,name:Ml,encode:Ao,digest:Fl};var Mp=new TextEncoder,Fp=new TextDecoder;var Io=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return zl(e,Yn(r),t||q.encoder);default:return Vl(e,Yn(r),t||Dt.encoder)}};var Co=new WeakMap,Yn=r=>{let t=Co.get(r);if(t==null){let e=new Map;return Co.set(r,e),e}return t},R=class{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Hl)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=ee(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&&xo(t.multihash,n.multihash)}toString(t){return Io(this,t)}toJSON(){return{"/":Io(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof R)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:a}=e;return new R(n,i,o,a||_o(n,i,o.bytes))}else if(e[Wl]===!0){let{version:n,multihash:i,code:o}=e,a=pe(i);return R.create(n,o,a)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ir)throw new Error(`Version 0 CID must use dag-pb (code: ${ir}) block encoding`);return new R(t,e,n,n.bytes)}case 1:{let i=_o(t,e,n.bytes);return new R(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return R.create(0,ir,t)}static createV1(t,e){return R.create(1,t,e)}static decode(t){let[e,n]=R.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=R.inspectBytes(t),n=e.size-e.multihashSize,i=vt(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),a=new Ne(e.multihashCode,e.digestSize,o,i);return[e.version===0?R.createV0(a):R.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=nr(t.subarray(e));return e+=w,g},i=n(),o=ir;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,l=n(),f=n(),d=e+f,h=d-a;return{version:i,codec:o,multihashCode:l,digestSize:f,multihashSize:h,size:d}}static parse(t,e){let[n,i]=$l(t,e),o=R.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Yn(o).set(n,t),o}},$l=(r,t)=>{switch(r[0]){case"Q":{let e=t||q;return[q.prefix,e.decode(`${q.prefix}${r}`)]}case q.prefix:{let e=t||q;return[q.prefix,e.decode(r)]}case Dt.prefix:{let e=t||Dt;return[Dt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},zl=(r,t,e)=>{let{prefix:n}=e;if(n!==q.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i},Vl=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i},ir=112,Hl=18,_o=(r,t,e)=>{let n=Le(r),i=n+Le(t),o=new Uint8Array(i+e.byteLength);return Re(r,o,0),Re(t,o,n),o.set(e,i),o},Wl=Symbol.for("@ipld/js-cid/CID");var re={...Nn,...On,...Pn,...Mn,...Fn,...Un,...Gn,...$n,...Vn,...Hn},Xp={...Kn,...jn};function me(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function zt(r=0){return globalThis.Buffer?.alloc!=null?me(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Rt(r=0){return globalThis.Buffer?.allocUnsafe!=null?me(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Bo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ko=Bo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Jn=Bo("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=Rt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ql={utf8:ko,"utf-8":ko,hex:re.base16,latin1:Jn,ascii:Jn,binary:Jn,...re},kr=ql;function lt(r,t="utf8"){let e=kr[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 Do=Qt.isIPv4,Zl=Qt.isIPv6,Qn=function(r){let t=0;if(r=r.toString().trim(),Do(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Zl(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=Do(e[n]),a;o&&(a=Qn(e[n]),e[n]=lt(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,lt(a.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let i=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);i[t++]=o>>8&255,i[t++]=o&255}return i}throw new Error("invalid ip address")},Ro=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let i=[];for(let o=0;o<e;o++)i.push(r[t+o]);return i.join(".")}if(e===16){let i=[];for(let o=0;o<e;o+=2)i.push(n.getUint16(t+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var or={},ti={},Kl=[[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"]];Kl.forEach(r=>{let t=jl(...r);ti[t.code]=t,or[t.name]=t});function jl(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:!!n,path:!!i}}function L(r){if(typeof r=="number"){if(ti[r]!=null)return ti[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(or[r]!=null)return or[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Mt=M(Br(),1);function sr(r,t="utf8"){let e=kr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?me(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function xt(r,t){t==null&&(t=r.reduce((i,o)=>i+o.length,0));let e=Rt(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return me(e)}var Dr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,i){return this.readAtomically(()=>{let o=0,a=0,l=this.peekChar();if(l===void 0)return;let f=l==="0",d=2**(8*i)-1;for(;;){let h=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(h===void 0)break;if(o*=t,o+=h,o>d||(a+=1,e!==void 0&&a>e))return}if(a!==0)return!n&&f&&a>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let i=n*2;if(n<e.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return e[i]=a[0],e[i+1]=a[1],e[i+2]=a[2],e[i+3]=a[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];e[i]=o>>8,e[i+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,i]=t(e);if(n===16)return e;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),a=16-(n+2),[l]=t(o.subarray(0,a));return e.set(o.subarray(0,l),16-l),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ed=new Dr;var _d=parseInt("0xFFFF",16),kd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var am=L("ip4"),um=L("ip6"),lm=L("ipcidr");function Xo(r,t){switch(L(r).code){case 4:case 41:return yf(t);case 42:return qo(t);case 6:case 273:case 33:case 132:return jo(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return qo(t);case 421:return vf(t);case 444:return Zo(t);case 445:return Zo(t);case 466:return Ef(t);default:return lt(t,"base16")}}function Ko(r,t){switch(L(r).code){case 4:return Ho(t);case 41:return Ho(t);case 42:return Wo(t);case 6:case 273:case 33:case 132:return ii(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Wo(t);case 421:return bf(t);case 444:return xf(t);case 445:return Sf(t);case 466:return wf(t);default:return sr(t,"base16")}}var ni=Object.values(re).map(r=>r.decoder),gf=function(){let r=ni[0].or(ni[1]);return ni.slice(2).forEach(t=>r=r.or(t)),r}();function Ho(r){if(!Ar(r))throw new Error("invalid ip address");return Qn(r)}function yf(r){let t=Ro(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ar(t))throw new Error("invalid ip address");return t}function ii(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function jo(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Wo(r){let t=sr(r),e=Uint8Array.from(Mt.default.encode(t.length));return xt([e,t],e.length+t.length)}function qo(r){let t=Mt.default.decode(r);if(r=r.slice(Mt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return lt(r)}function bf(r){let t;r[0]==="Q"||r[0]==="1"?t=pe(q.decode(`z${r}`)).bytes:t=R.parse(r).multihash.bytes;let e=Uint8Array.from(Mt.default.encode(t.length));return xt([e,t],e.length+t.length)}function wf(r){let t=gf.decode(r),e=Uint8Array.from(Mt.default.encode(t.length));return xt([e,t],e.length+t.length)}function Ef(r){let t=Mt.default.decode(r),e=r.slice(Mt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+lt(e,"base64url")}function vf(r){let t=Mt.default.decode(r),e=r.slice(Mt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return lt(e,"base58btc")}function xf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Dt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=ii(n);return xt([e,i],e.length+i.length)}function Sf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Dt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=ii(n);return xt([e,i],e.length+i.length)}function Zo(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=lt(t,"base32"),i=jo(e);return`${n}:${i}`}var Oe=M(Br(),1);function Tf(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let i=e[n],o=L(i);if(o.size===0){t.push([i]);continue}if(n++,n>=e.length)throw Jo("invalid address: "+r);if(o.path===!0){t.push([i,ui(e.slice(n).join("/"))]);break}t.push([i,e[n]])}return t}function Af(r){let t=[];return r.map(e=>{let n=Nr(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ui(t.join("/"))}function If(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Nr(t);return t.length>1?[e.code,Ko(e.code,t[1])]:[e.code]})}function oi(r){return r.map(t=>{let e=Nr(t);return t[1]!=null?[e.code,Xo(e.code,t[1])]:[e.code]})}function si(r){return Lr(xt(r.map(t=>{let e=Nr(t),n=Uint8Array.from(Oe.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=xt([n,t[1]])),n})))}function ci(r,t){return r.size>0?r.size/8:r.size===0?0:Oe.default.decode(t)+(Oe.default.decode.bytes??0)}function Rr(r){let t=[],e=0;for(;e<r.length;){let n=Oe.default.decode(r,e),i=Oe.default.decode.bytes??0,o=L(n),a=ci(o,r.slice(e+i));if(a===0){t.push([n]),e+=i;continue}let l=r.slice(e+i,e+i+a);if(e+=a+i,e>r.length)throw Jo("Invalid address Uint8Array: "+lt(r,"base16"));t.push([n,l])}return t}function ai(r){let t=Rr(r),e=oi(t);return Af(e)}function Cf(r){r=ui(r);let t=Tf(r),e=If(t);return si(e)}function Yo(r){return Cf(r)}function Lr(r){let t=_f(r);if(t!=null)throw t;return Uint8Array.from(r)}function _f(r){try{Rr(r)}catch(t){return t}}function ui(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Jo(r){return new Error("Error parsing address: "+r)}function Nr(r){return L(r[0])}var li=M(Br(),1);var Vt=class extends Error{constructor(t="The operation was aborted"){super(t),this.code=Vt.code,this.type=Vt.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},ct=class extends Error{constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};function ge(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 Ht=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Pe=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},cr,ar,ur,ne,Qo,Bf=Symbol.for("nodejs.util.inspect.custom"),Df=[L("dns").code,L("dns4").code,L("dns6").code,L("dnsaddr").code],Rf=new Map,ts=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Lf(r){return!!r?.[ts]}var Wt=class{constructor(t){if(cr.set(this,void 0),ar.set(this,void 0),ur.set(this,void 0),ne.set(this,void 0),this[Qo]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=Lr(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Yo(t)}else if(Lf(t))this.bytes=Lr(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Ht(this,cr,"f")==null&&Pe(this,cr,ai(this.bytes),"f"),Ht(this,cr,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,i,o="",a=L("tcp"),l=L("udp"),f=L("ip4"),d=L("ip6"),h=L("dns6"),g=L("ip6zone");for(let[T,b]of this.stringTuples())T===g.code&&(o=`%${b??""}`),Df.includes(T)&&(e=a.name,i=443,n=`${b??""}${o}`,t=T===h.code?6:4),(T===a.code||T===l.code)&&(e=L(T).name,i=parseInt(b??"")),(T===f.code||T===d.code)&&(e=L(T).name,n=`${b??""}${o}`,t=T===d.code?6:4);if(t==null||e==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:i}}protos(){return this.protoCodes().map(t=>Object.assign({},L(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let i=li.default.decode(e,n),o=li.default.decode.bytes??0,a=L(i),l=ci(a,e.slice(n+o));n+=l+o,t.push(i)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return Ht(this,ar,"f")==null&&Pe(this,ar,Rr(this.bytes),"f"),Ht(this,ar,"f")}stringTuples(){return Ht(this,ur,"f")==null&&Pe(this,ur,oi(this.tuples()),"f"),Ht(this,ur,"f")}encapsulate(t){return t=new Wt(t),new Wt(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),i=n.lastIndexOf(e);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new Wt(n.slice(0,i))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new Wt(si(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===or.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?lt(q.decode(`z${n}`),"base58btc"):lt(R.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(Ht(this,ne,"f")===void 0)try{Pe(this,ne,this.stringTuples().filter(t=>L(t[0]).path===!0)[0][1],"f"),Ht(this,ne,"f")==null&&Pe(this,ne,null,"f")}catch{Pe(this,ne,null,"f")}return Ht(this,ne,"f")}equals(t){return ge(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=Rf.get(e.name);if(n==null)throw new ct(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(o=>new Wt(o))}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)}[(cr=new WeakMap,ar=new WeakMap,ur=new WeakMap,ne=new WeakMap,Qo=ts,Bf)](){return`Multiaddr(${ai(this.bytes)})`}};function gt(r){return new Wt(r)}var Nf=x("dns4"),Of=x("dns6"),Pf=x("dnsaddr"),ye=Z(x("dns"),Pf,Nf,Of),Or=Z(x("ip4"),x("ip6")),oe=Z(I(Or,x("tcp")),I(ye,x("tcp"))),Pr=I(Or,x("udp")),Mf=I(Pr,x("utp")),Ff=I(Pr,x("quic")),Uf=I(Pr,x("quic-v1")),lr=Z(I(oe,x("ws")),I(ye,x("ws"))),fr=Z(I(oe,x("wss")),I(ye,x("wss")),I(oe,x("tls"),x("ws")),I(ye,x("tls"),x("ws"))),fi=Z(I(oe,x("http")),I(Or,x("http")),I(ye,x("http"))),hi=Z(I(oe,x("https")),I(Or,x("https")),I(ye,x("https"))),es=I(Pr,x("webrtc-direct"),x("certhash")),is=Z(I(es,x("p2p")),es),rs=I(Uf,x("webtransport"),x("certhash"),x("certhash")),os=Z(I(rs,x("p2p")),rs),ss=Z(I(lr,x("p2p-webrtc-star"),x("p2p")),I(fr,x("p2p-webrtc-star"),x("p2p")),I(lr,x("p2p-webrtc-star")),I(fr,x("p2p-webrtc-star"))),Rm=Z(I(lr,x("p2p-websocket-star"),x("p2p")),I(fr,x("p2p-websocket-star"),x("p2p")),I(lr,x("p2p-websocket-star")),I(fr,x("p2p-websocket-star"))),cs=Z(I(fi,x("p2p-webrtc-direct"),x("p2p")),I(hi,x("p2p-webrtc-direct"),x("p2p")),I(fi,x("p2p-webrtc-direct")),I(hi,x("p2p-webrtc-direct"))),Fe=Z(lr,fr,fi,hi,ss,cs,oe,Mf,Ff,ye,is,os),Lm=Z(I(Fe,x("p2p-stardust"),x("p2p")),I(Fe,x("p2p-stardust"))),ie=Z(I(Fe,x("p2p")),ss,cs,is,os,x("p2p")),ns=Z(I(ie,x("p2p-circuit"),ie),I(ie,x("p2p-circuit")),I(x("p2p-circuit"),ie),I(Fe,x("p2p-circuit")),I(x("p2p-circuit"),Fe),x("p2p-circuit")),as=()=>Z(I(ns,as),ns),Me=as(),Nm=Z(I(Me,ie,Me),I(ie,Me),I(Me,ie),Me,ie);var Om=Z(I(Me,x("webrtc")),I(Fe,x("webrtc")),x("webrtc"));function us(r){function t(e){let n;try{n=gt(e)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return t}function I(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(i=>(n=typeof i=="function"?i().partialMatch(e):i.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:us(t),partialMatch:t}}function Z(...r){function t(n){let i=null;return r.some(o=>{let a=typeof o=="function"?o().partialMatch(n):o.partialMatch(n);return a!=null?(i=a,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:us(t),partialMatch:t}}function x(r){let t=r;function e(i){let o;try{o=gt(i)}catch{return!1}let a=o.protoNames();return a.length===1&&a[0]===t}function n(i){return i.length===0?null:i[0]===t?i.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var St=M(Es(),1);St.default.formatters.b=r=>r==null?"undefined":q.baseEncode(r);St.default.formatters.t=r=>r==null?"undefined":Dt.baseEncode(r);St.default.formatters.m=r=>r==null?"undefined":zn.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();function lh(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=lh(`${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 Vs=M(_s(),1);function zr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Vr(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var He=/^(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,bi=/\/\d{1,2}$/;var rt=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var We=M(wi(),1),we=M(hr(),1),O=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Vr(32),this.isInSubnet=zr,this.address=t;let e=bi.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 rt("Invalid subnet mask.");t=t.replace(bi,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new O(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(He))throw new rt("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],i;for(i=0;i<8;i+=2){let o=e.slice(i,i+2);n.push(parseInt(o,16))}return new O(n.join("."))}static fromInteger(t){return O.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new O(n)}toHex(){return this.parsedAddress.map(t=>(0,we.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,we.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,we.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new We.BigInteger(this.parsedAddress.map(t=>(0,we.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new We.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return O.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new We.BigInteger("1");return O.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new We.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return O.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new We.BigInteger("1");return O.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return O.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,we.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new O("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(He,(0,we.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 Ls={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},Ei={"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"},vi=/([^0-9a-f:/%])/gi,xi=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Si=/\/\d{1,3}(?=%|$)/,Ti=/%.*$/,Ns=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Os=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Ms=M(hr(),1);function mh(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function qr(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Ms.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,mh(n)))}var ve=M(hr(),1);function Ii(r){return(0,ve.sprintf)("(%s)",r.join("|"))}function Ai(r){return r.length<4?(0,ve.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ci="[^A-Fa-f0-9:]";function Zr(r){let t=[];r.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let e=t.map(n=>r.map((i,o)=>{if(o===n){let a=o===0||o===8-1?":":"";return Ii([Ai(i),a])}return Ai(i)}).join(":"));return e.push(r.map(Ai).join(":")),Ii(e)}function _i(r,t,e){let n=t?"":":",i=e?"":":",o=[];!t&&!e&&o.push("::"),t&&e&&o.push(""),(e&&!t||!e&&t)&&o.push(":"),o.push((0,ve.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),o.push((0,ve.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),o.push((0,ve.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let l=1;l<r-a;l++)o.push((0,ve.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",l,r-l-a-1));return Ii(o)}var nt=M(wi(),1),it=M(hr(),1);function Xr(r){if(!r)throw new Error("Assertion failed.")}function gh(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function yh(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 bh(r,t){let e=[],n=[],i;for(i=0;i<r.length;i++)i<t[0]?e.push(r[i]):i>t[1]&&n.push(r[i]);return e.concat(["compact"]).concat(n)}function Us(r){return(0,it.sprintf)("%04x",parseInt(r,16))}function Gs(r){return r&255}var U=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=zr,this.isCorrect=Vr(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Si.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 rt("Invalid subnet mask.");t=t.replace(Si,"")}else if(/\//.test(t))throw new rt("Invalid subnet mask.");let i=Ti.exec(t);i&&(this.zone=i[0],t=t.replace(Ti,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new U(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],i;for(i=0;i<8;i++)n.push(e.slice(i*4,(i+1)*4));return new U(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=Os.exec(t),i===null)return{error:"failed to parse address with port",address:null,port:null};e=i[1],n=i[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),i=Ns.exec(t),i===null)return{error:"failed to parse address from URL",address:null,port:null};e=i[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new U(e),port:n}}static fromAddress4(t){let e=new O(t),n=128-(32-e.subnetMask);return new U(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new rt("Invalid 'ip6.arpa' form.");let i=e.split(".").reverse();for(let o=n;o>0;o--){let a=o*4;i.splice(a,0,":")}return e=i.join(""),new U(e)}microsoftTranscription(){return(0,it.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),i=e-n;return i<0?"0":gh(new nt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new nt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return U.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new nt.BigInteger("1");return U.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new nt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return U.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new nt.BigInteger("1");return U.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Ls[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(Ei))if(this.isInSubnet(new U(t)))return Ei[t];return"Global unicast"}getBits(t,e){return new nt.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,it.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,i=[];for(t=0;t<this.parsedAddress.length;t++){let l=parseInt(this.parsedAddress[t],16);l===0&&n++,l!==0&&n>0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let o=i.map(l=>l[1]-l[0]+1);if(i.length>0){let l=o.indexOf(Math.max(...o));e=bh(this.parsedAddress,i[l])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let a=e.join(":");return a=a.replace(/^compact$/,"::"),a=a.replace(/^compact|compact$/,":"),a=a.replace(/compact/,""),a}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),i=e.slice(-1)[0].match(He);if(i){this.parsedAddress4=i[0],this.address4=new O(this.parsedAddress4);for(let o=0;o<this.address4.groups;o++)if(/^0[0-9]+/.test(this.address4.parsedAddress[o]))throw new rt("IPv4 addresses can't have leading zeroes.",t.replace(He,this.address4.parsedAddress.map(yh).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(vi);if(e)throw new rt((0,it.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(vi,'<span class="parse-error">$1</span>'));let n=t.match(xi);if(n)throw new rt((0,it.sprintf)("Address failed regex: %s",n.join("")),t.replace(xi,'<span class="parse-error">$1</span>'));let i=[],o=t.split("::");if(o.length===2){let a=o[0].split(":"),l=o[1].split(":");a.length===1&&a[0]===""&&(a=[]),l.length===1&&l[0]===""&&(l=[]);let f=this.groups-(a.length+l.length);if(!f)throw new rt("Error parsing groups");this.elidedGroups=f,this.elisionBegin=a.length,this.elisionEnd=a.length+this.elidedGroups,i=i.concat(a);for(let d=0;d<f;d++)i.push("0");i=i.concat(l)}else if(o.length===1)i=t.split(":"),this.elidedGroups=0;else throw new rt("Too many :: groups found");if(i=i.map(a=>(0,it.sprintf)("%x",parseInt(a,16))),i.length!==this.groups)throw new rt("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(Us).join(":")}decimal(){return this.parsedAddress.map(t=>(0,it.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new nt.BigInteger(this.parsedAddress.map(Us).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return O.fromHex(new nt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new U(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),i="";return/:$/.test(n)||(i=":"),n+i+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new nt.BigInteger("ffff",16)).toString(),n=O.fromHex(this.getBitsBase16(32,64)),i=O.fromHex(this.getBits(96,128).xor(new nt.BigInteger("ffffffff",16)).toString(16)),o=this.getBits(64,80),a=this.getBitsBase2(64,80),l=o.testBit(15),f=o.testBit(14),d=o.testBit(8),h=o.testBit(9),g=new nt.BigInteger(a.slice(2,6)+a.slice(8,16),2).toString(10);return{prefix:(0,it.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:a,coneNat:l,microsoft:{reserved:f,universalLocal:h,groupIndividual:d,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=O.fromHex(this.getBitsBase16(16,48));return{prefix:(0,it.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 U(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Gs)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Gs))}static fromUnsignedByteArray(t){let e=new nt.BigInteger("256",10),n=new nt.BigInteger("0",10),i=new nt.BigInteger("1",10);for(let o=t.length-1;o>=0;o--)n=n.add(i.multiply(new nt.BigInteger(t[o].toString(10),10))),i=i.multiply(e);return U.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 U("2001::/32"))}is6to4(){return this.isInSubnet(new U("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,it.sprintf)(":%s",t),(0,it.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,it.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,it.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return qr(this.address).join(":");Xr(typeof this.elidedGroups=="number"),Xr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...qr(e)):t.push("");let i=["hover-group"];for(let o=this.elisionBegin;o<this.elisionBegin+this.elidedGroups;o++)i.push((0,it.sprintf)("group-%d",o));return t.push((0,it.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...qr(n,this.elisionEnd)):t.push(""),this.is4()&&(Xr(this.address4 instanceof O),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new U(this.correctForm());if(n.elidedGroups===0)e.push(Zr(n.parsedAddress));else if(n.elidedGroups===8)e.push(_i(8));else{let i=n.address.split("::");i[0].length&&e.push(Zr(i[0].split(":"))),Xr(typeof n.elidedGroups=="number"),e.push(_i(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Zr(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ci,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ci,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var wh=et("libp2p:ip-port-to-multiaddr"),ki={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function $s(r,t){if(typeof r!="string")throw new ct(`invalid ip provided: ${r}`,ki.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new ct(`invalid port provided: ${t}`,ki.ERR_INVALID_PORT_PARAMETER);try{return new O(r),gt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new U(r);return e.is4()?gt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):gt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw wh.error(n),new ct(n,ki.ERR_INVALID_IP)}}var Bi=M($t("os"),1),zs=M($t("path"),1),Eh={ip4:"IPv4",ip6:"IPv6"};function Ze(r,t={}){let e=r.getPath();return e!=null?Bi.default.platform()==="win32"?{path:zs.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function Di(r,t,e){let n=i=>gt(`/${r}/${i}/tcp/${e}`);return(vh(t)?Sh(Eh[r]):[t]).map(n)}function vh(r){return["0.0.0.0","::"].includes(r)}var xh=Bi.default.networkInterfaces();function Sh(r){let t=[];for(let[,e]of Object.entries(xh))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Nt=et("libp2p:tcp:socket"),Kr=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,o=t.socketCloseTimeout??2e3;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let a;if(t.remoteAddr!=null)a=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new ct("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=$s(r.remoteAddress,r.remotePort)}let l=Ze(a),f=l.path??`${l.host??""}:${l.port??""}`,{sink:d,source:h}=Vs.default.duplex(r);r.setTimeout(i,()=>{Nt("%s socket read timeout",f),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new ct("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Nt("%s socket close",f),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Nt("%s socket end",f),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await d(w)}catch(T){T.type!=="aborted"&&Nt(T)}r.end()},source:h,remoteAddr:a,timeline:{open:Date.now()},async close(){if(r.destroyed){Nt("%s socket was already destroyed when trying to close",f);return}Nt("%s closing socket",f),await new Promise((w,T)=>{let b=Date.now(),S;r.once("close",()=>{Nt("%s socket closed",f),S!==void 0&&clearTimeout(S),w()}),r.once("error",k=>{Nt("%s socket error",f,k),g.timeline.close==null&&(g.timeline.close=Date.now()),r.destroyed&&S!==void 0&&clearTimeout(S),T(k)}),r.setTimeout(o),r.end(),r.writableLength>0?(S=setTimeout(()=>{r.destroyed?(Nt("%s is already destroyed",f),w()):(Nt("%s socket close timeout after %dms, destroying it manually",f,Date.now()-b),r.destroy(new ct("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},o).unref(),r.once("drain",()=>{Nt("%s socket drained",f),r.destroy()})):r.destroy()})}};return g};var Hs=M($t("net"),1);var xe=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Zt,jr=class extends EventTarget{constructor(){super(...arguments),Zt.set(this,new Map)}listenerCount(t){let e=xe(this,Zt,"f").get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=xe(this,Zt,"f").get(t);i==null&&(i=[],xe(this,Zt,"f").set(t,i)),i.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let i=xe(this,Zt,"f").get(t);i!=null&&(i=i.filter(({callback:o})=>o!==e),xe(this,Zt,"f").set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=xe(this,Zt,"f").get(t.type);return n==null||(n=n.filter(({once:i})=>!i),xe(this,Zt,"f").set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new Xe(t,e))}};Zt=new WeakMap;var Ri=class extends Event{constructor(t,e){super(t,e),this.detail=e?.detail}},Xe=globalThis.CustomEvent??Ri;var bt=et("libp2p:tcp:listener");async function Li(r){try{await r.close()}catch(t){bt.error("an error occurred closing the connection",t)}}var Ih=1,Ch=0,Yr=class extends jr{constructor(t){if(super(),this.context=t,this.connections=new Set,this.status={started:!1},t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Hs.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:Ih})}this.dispatchEvent(new Xe("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Xe("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Ch}),this.dispatchEvent(new Xe("close"))})}onSocket(t){t.on("error",n=>{bt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=Kr(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){bt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}bt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{bt("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(i=>{bt.error("error attempting to listen server once connection count under limit",i),this.context.closeServerOnMaxConnections?.onListenError?.(i)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new Xe("connection",{detail:n}))}).catch(async n=>{bt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Li(e)}).catch(n=>{bt.error("closing inbound connection failed",n)})}catch(n){bt.error("inbound connection failed",n),Li(e).catch(i=>{bt.error("closing inbound connection failed",i),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:i}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Di("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Di("ip6",e.address,e.port)))}catch(o){bt.error("could not turn %s:%s into multiaddr",e.address,e.port,o)}return t.map(o=>i!=null?o.encapsulate(`/p2p/${i}`):o)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:i}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:Ze(n,{backlog:i})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Li(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)}),bt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(bt("Closing server on %s",this.server.address()),this.server.close())}};var qs=Symbol.for("@libp2p/transport");var Ws;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Ws||(Ws={}));var Xt=et("libp2p:tcp"),Oi=class{constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}get[qs](){return!0}get[Symbol.toStringTag](){return"@libp2p/tcp"}async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",l=>{Xt("socket error",l)});let i=Kr(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),o=()=>{i.close().catch(l=>{Xt.error("Error closing maConn after abort",l)})};e.signal?.addEventListener("abort",o,{once:!0}),Xt("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(Xt("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",o),e.signal?.aborted===!0)throw a.close().catch(l=>{Xt.error("Error closing conn after abort",l)}),new Vt;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Vt;return await new Promise((n,i)=>{let o=Date.now(),a=Ze(t),l=a.path??`${a.host??""}:${a.port}`;Xt("dialing %j",a);let f=Zs.default.connect(a),d=b=>{b.message=`connection error ${l}: ${b.message}`,this.metrics?.dialerEvents.increment({error:!0}),T(b)},h=()=>{Xt("connection timeout %s",l),this.metrics?.dialerEvents.increment({timeout:!0});let b=new ct(`connection timeout after ${Date.now()-o}ms`,"ERR_CONNECT_TIMEOUT");f.emit("error",b)},g=()=>{Xt("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),T()},w=()=>{Xt("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),f.destroy(),T(new Vt)},T=b=>{if(f.removeListener("error",d),f.removeListener("timeout",h),f.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),b!=null){i(b);return}n(f)};f.on("error",d),f.on("timeout",h),f.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new Yr({...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:oe.matches(e.decapsulateCode(421)))}};function Xs(r={}){return(t={})=>new Oi(t,r)}var js=Symbol.for("@achingbrain/uint8arraylist");function Ks(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let i=e+n.byteLength;if(t<i)return{buf:n,index:t-e};e=i}throw new RangeError("index is out of bounds")}function Jr(r){return!!r?.[js]}var ft=class{constructor(...t){Object.defineProperty(this,js,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Jr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Jr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Ks(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Ks(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Jr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:i}=this._subList(t,e);return xt(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:xt(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),o=new ft;return o.length=i,o.bufs=n,o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],i=0;for(let o=0;o<this.bufs.length;o++){let a=this.bufs[o],l=i,f=l+a.byteLength;if(i=f,t>=f)continue;let d=t>=l&&t<f,h=e>l&&e<=f;if(d&&h){if(t===l&&e===f){n.push(a);break}let g=t-l;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-l));continue}if(h){if(e===f){n.push(a);break}n.push(a.subarray(0,e-l));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Jr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,a=new Int32Array(o);for(let g=0;g<o;g++)a[g]=-1;for(let g=0;g<i;g++)a[n[g]]=g;let l=a,f=this.byteLength-n.byteLength,d=n.byteLength-1,h;for(let g=e;g<=f;g+=h){h=0;for(let w=d;w>=0;w--){let T=this.get(g+w);if(n[w]!==T){h=Math.max(1,w-l[T]);break}}if(h===0)return g}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Rt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let i=zt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,e,n),this.write(i,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,e,n),this.write(i,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,e,n),this.write(i,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Rt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let i=zt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,e,n),this.write(i,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,e,n),this.write(i,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,e,n),this.write(i,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,e,n),this.write(i,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof ft)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ge(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new ft;return n.bufs=t,e==null&&(e=t.reduce((i,o)=>i+o.byteLength,0)),n.length=e,n}};function Qr(r){return r instanceof Uint8Array?{get(t){return r[t]},set(t,e){r[t]=e}}:{get(t){return r.get(t)},set(t,e){r.set(t,e)}}}var Ys=4294967296,wt=class{constructor(t=0,e=0){this.hi=t,this.lo=e}toBigInt(t){if(t===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(t){return Number(this.toBigInt(t))}zzDecode(){let t=-(this.lo&1),e=((this.lo>>>1|this.hi<<31)^t)>>>0,n=(this.hi>>>1^t)>>>0;return new wt(n,e)}zzEncode(){let t=this.hi>>31,e=((this.hi<<1|this.lo>>>31)^t)>>>0,n=(this.lo<<1^t)>>>0;return new wt(e,n)}toBytes(t,e=0){let n=Qr(t);for(;this.hi>0;)n.set(e++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(e++,this.lo&127|128),this.lo=this.lo>>>7;n.set(e++,this.lo)}static fromBigInt(t){if(t===0n)return new wt;let e=t<0;e&&(t=-t);let n=Number(t>>32n)|0,i=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,i=~i>>>0,++i>Ys&&(i=0,++n>Ys&&(n=0))),new wt(n,i)}static fromNumber(t){if(t===0)return new wt;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new wt(i,n)}static fromBytes(t,e=0){let n=Qr(t),i=new wt,o=0;if(t.length-e>4){for(;o<4;++o)if(i.lo=(i.lo|(n.get(e)&127)<<o*7)>>>0,n.get(e++)<128)return i;if(i.lo=(i.lo|(n.get(e)&127)<<28)>>>0,i.hi=(i.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return i;o=0}else for(;o<4;++o){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.lo=(i.lo|(n.get(e)&127)<<o*7)>>>0,n.get(e++)<128)return i}if(t.length-e>4){for(;o<5;++o)if(i.hi=(i.hi|(n.get(e)&127)<<o*7+3)>>>0,n.get(e++)<128)return i}else if(e<t.byteLength)for(;o<5;++o){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.hi=(i.hi|(n.get(e)&127)<<o*7+3)>>>0,n.get(e++)<128)return i}throw RangeError("invalid varint encoding")}};var Bh=Math.pow(2,7),Dh=Math.pow(2,14),Rh=Math.pow(2,21),Lh=Math.pow(2,28),Nh=Math.pow(2,35),Oh=Math.pow(2,42),Ph=Math.pow(2,49),Mh=Math.pow(2,56),Fh=Math.pow(2,63),Se={encodingLength(r){return r<Bh?1:r<Dh?2:r<Rh?3:r<Lh?4:r<Nh?5:r<Oh?6:r<Ph?7:r<Mh?8:r<Fh?9:10},encode(r,t,e=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return t==null&&(t=Rt(Se.encodingLength(r))),wt.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return wt.fromBytes(r,t).toNumber(!0)}};function tn(r){return r[Symbol.asyncIterator]!=null}var en=r=>{let t=Se.encodingLength(r),e=Rt(t);return Se.encode(r,e),en.bytes=t,e};en.bytes=0;function Ke(r,t){t=t??{};let e=t.lengthEncoder??en;function*n(i){let o=e(i.byteLength);o instanceof Uint8Array?yield o:yield*o,i instanceof Uint8Array?yield i:yield*i}return tn(r)?async function*(){for await(let i of r)yield*n(i)}():function*(){for(let i of r)yield*n(i)}()}Ke.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??en;return new ft(e(r.byteLength),r)};var je=M(tc(),1);var Gh=8,$h=1024*1024*4,Te;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Te||(Te={}));var Pi=r=>{let t=Se.decode(r);return Pi.bytes=Se.encodingLength(t),t};Pi.bytes=0;function pr(r,t){let e=new ft,n=Te.LENGTH,i=-1,o=t?.lengthDecoder??Pi,a=t?.maxLengthLength??Gh,l=t?.maxDataLength??$h;function*f(){for(;e.byteLength>0;){if(n===Te.LENGTH)try{if(i=o(e),i<0)throw(0,je.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>l)throw(0,je.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=o.bytes;e.consume(d),t?.onLength!=null&&t.onLength(i),n=Te.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>a)throw(0,je.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===Te.DATA){if(e.byteLength<i)break;let d=e.sublist(0,i);e.consume(i),t?.onData!=null&&t.onData(d),yield d,n=Te.LENGTH}}}return tn(r)?async function*(){for await(let d of r)e.append(d),yield*f();if(e.byteLength>0)throw(0,je.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)e.append(d),yield*f();if(e.byteLength>0)throw(0,je.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}pr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:o,value:a}=await r.next(e);if(o===!0)return;a!=null&&(yield a)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{e=1}}();return pr(n,{...t??{},onLength:o=>{e=o}})};var rn=class{constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Ye=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new rn(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new rn(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};function se(r={}){return zh(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function zh(r,t){t=t??{};let e=t.onEnd,n=new Ye,i,o,a,l=async()=>n.isEmpty()?a?{done:!0}:await new Promise((S,k)=>{o=C=>{o=null,n.push(C);try{S(r(n))}catch(_){k(_)}return i}}):r(n),f=S=>o!=null?o(S):(n.push(S),i),d=S=>(n=new Ye,o!=null?o({error:S}):(n.push({error:S}),i)),h=S=>{if(a)return i;if(t?.objectMode!==!0&&S?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:S})},g=S=>a?i:(a=!0,S!=null?d(S):f({done:!0})),w=()=>(n=new Ye,g(),{done:!0}),T=S=>(g(S),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:l,return:w,throw:T,push:h,end:g,get readableLength(){return n.size}},e==null)return i;let b=i;return i={[Symbol.asyncIterator](){return this},next(){return b.next()},throw(S){return b.throw(S),e!=null&&(e(S),e=void 0),{done:!0}},return(){return b.return(),e!=null&&(e(),e=void 0),{done:!0}},push:h,end(S){return b.end(S),e!=null&&(e(S),e=void 0),i},get readableLength(){return b.readableLength}},i}function Vh(r){return r[Symbol.asyncIterator]!=null}function Hh(...r){let t=[];for(let e of r)Vh(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=se({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let i of n)e.push(i)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var rc=Hh;function nn(r,...t){if(r==null)throw new Error("Empty pipeline");if(Mi(r)){let n=r;r=()=>n.source}else if(ic(r)||nc(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Mi(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)Mi(e[n])&&(e[n]=qh(e[n]));return Wh(...e)}var Wh=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},nc=r=>r?.[Symbol.asyncIterator]!=null,ic=r=>r?.[Symbol.iterator]!=null,Mi=r=>r==null?!1:r.sink!=null&&r.source!=null,qh=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=se({objectMode:!0});e.then(()=>{n.end()},a=>{n.end(a)});let i,o=r.source;if(nc(o))i=async function*(){yield*o,n.end()};else if(ic(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return rc(n,i())}return r.source};function oc(r){let t=async function*(){let e=yield,n=new ft;for await(let i of r){if(e==null){n.append(i),e=yield n,n=new ft;continue}for(n.append(i);n.length>=e;){let o=n.sublist(0,e);if(n.consume(e),e=yield o,e==null){n.length>0&&(e=yield n,n=new ft);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}function Fi(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function sc(r){let t=se(),e=oc(r.source),n=Fi(),i,o=r.sink(async function*(){yield*t,yield*await n.promise}());return o.catch(l=>{i=l}),{reader:e,writer:t,stream:{sink:async l=>{if(i!=null){await Promise.reject(i);return}n.resolve(l),await o},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let l=await e.next();if(l.value!=null)return l.value}}}var Ui=et("libp2p:daemon-protocol:stream-handler"),on=class{constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=sc(this.stream),this.decoder=pr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Ui("read received no value, closing stream"),await this.close()}write(t){Ui("write message"),this.shake.write(Ke.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Ui("closing the stream"),await this.rest().sink([])}};var Gi={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Qi=M(Wi(),1),Zc=M(Uc(),1),Xc=M(Ie(),1),to=M(Ji(),1),Kc=M(qc(),1);function ep(){Xc.default._configure(),Qi.default._configure(Zc.default),to.default._configure(Kc.default)}ep();var jc=["uint64","int64","sint64","fixed64","sfixed64"];function rp(r){for(let t of jc){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function eo(r){return rp(new Qi.default(r))}function np(r){for(let t of jc){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function ro(){return np(to.default.create())}function z(r,t){let e=eo(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function V(r,t){let e=ro();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Qe;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Qe||(Qe={}));function ln(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Kt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(o,a){let l=t(o);a.int32(l)},n=function(o){let a=o.int32();return t(a)};return ln("enum",Qe.VARINT,e,n)}function H(r,t){return ln("message",Qe.LENGTH_DELIMITED,r,t)}var At;(function(r){let t;(function(i){i.IDENTIFY="IDENTIFY",i.CONNECT="CONNECT",i.STREAM_OPEN="STREAM_OPEN",i.STREAM_HANDLER="STREAM_HANDLER",i.DHT="DHT",i.LIST_PEERS="LIST_PEERS",i.CONNMANAGER="CONNMANAGER",i.DISCONNECT="DISCONNECT",i.PUBSUB="PUBSUB",i.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.IDENTIFY=0]="IDENTIFY",i[i.CONNECT=1]="CONNECT",i[i.STREAM_OPEN=2]="STREAM_OPEN",i[i.STREAM_HANDLER=3]="STREAM_HANDLER",i[i.DHT=4]="DHT",i[i.LIST_PEERS=5]="LIST_PEERS",i[i.CONNMANAGER=6]="CONNMANAGER",i[i.DISCONNECT=7]="DISCONNECT",i[i.PUBSUB=8]="PUBSUB",i[i.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.connect!=null&&(o.uint32(18),hn.codec().encode(i.connect,o)),i.streamOpen!=null&&(o.uint32(26),pn.codec().encode(i.streamOpen,o)),i.streamHandler!=null&&(o.uint32(34),dn.codec().encode(i.streamHandler,o)),i.dht!=null&&(o.uint32(42),It.codec().encode(i.dht,o)),i.connManager!=null&&(o.uint32(50),gn.codec().encode(i.connManager,o)),i.disconnect!=null&&(o.uint32(58),yn.codec().encode(i.disconnect,o)),i.pubsub!=null&&(o.uint32(66),jt.codec().encode(i.pubsub,o)),i.peerStore!=null&&(o.uint32(74),ke.codec().encode(i.peerStore,o)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=hn.codec().decode(i,i.uint32());break;case 3:a.streamOpen=pn.codec().decode(i,i.uint32());break;case 4:a.streamHandler=dn.codec().decode(i,i.uint32());break;case 5:a.dht=It.codec().decode(i,i.uint32());break;case 6:a.connManager=gn.codec().decode(i,i.uint32());break;case 7:a.disconnect=yn.codec().decode(i,i.uint32());break;case 8:a.pubsub=jt.codec().decode(i,i.uint32());break;case 9:a.peerStore=ke.codec().decode(i,i.uint32());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(At||(At={}));var _e;(function(r){let t;(function(i){i.OK="OK",i.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.OK=0]="OK",i[i.ERROR=1]="ERROR"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{if(a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.error!=null&&(o.uint32(18),mn.codec().encode(i.error,o)),i.streamInfo!=null&&(o.uint32(26),tr.codec().encode(i.streamInfo,o)),i.identify!=null&&(o.uint32(34),fn.codec().encode(i.identify,o)),i.dht!=null&&(o.uint32(42),Q.codec().encode(i.dht,o)),i.peers!=null)for(let l of i.peers)o.uint32(50),ue.codec().encode(l,o);i.pubsub!=null&&(o.uint32(58),bn.codec().encode(i.pubsub,o)),i.peerStore!=null&&(o.uint32(66),wn.codec().encode(i.peerStore,o)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={peers:[]},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=mn.codec().decode(i,i.uint32());break;case 3:a.streamInfo=tr.codec().decode(i,i.uint32());break;case 4:a.identify=fn.codec().decode(i,i.uint32());break;case 5:a.dht=Q.codec().decode(i,i.uint32());break;case 6:a.peers.push(ue.codec().decode(i,i.uint32()));break;case 7:a.pubsub=bn.codec().decode(i,i.uint32());break;case 8:a.peerStore=wn.codec().decode(i,i.uint32());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(_e||(_e={}));var fn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)n.uint32(18),n.bytes(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(fn||(fn={}));var hn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let o of e.addrs)n.uint32(18),n.bytes(o);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addrs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addrs.push(e.bytes());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(hn||(hn={}));var pn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let o of e.proto)n.uint32(18),n.string(o);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),proto:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.proto.push(e.string());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(pn||(pn={}));var dn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let o of e.proto)n.uint32(18),n.string(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={addr:new Uint8Array(0),proto:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.addr=e.bytes();break;case 2:i.proto.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(dn||(dn={}));var mn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={msg:""},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.msg=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(mn||(mn={}));var tr;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(18),n.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(n.uint32(26),n.string(e.proto)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addr=e.bytes();break;case 3:i.proto=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(tr||(tr={}));var It;(function(r){let t;(function(i){i.FIND_PEER="FIND_PEER",i.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",i.FIND_PROVIDERS="FIND_PROVIDERS",i.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",i.GET_PUBLIC_KEY="GET_PUBLIC_KEY",i.GET_VALUE="GET_VALUE",i.SEARCH_VALUE="SEARCH_VALUE",i.PUT_VALUE="PUT_VALUE",i.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.FIND_PEER=0]="FIND_PEER",i[i.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",i[i.FIND_PROVIDERS=2]="FIND_PROVIDERS",i[i.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",i[i.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",i[i.GET_VALUE=5]="GET_VALUE",i[i.SEARCH_VALUE=6]="SEARCH_VALUE",i[i.PUT_VALUE=7]="PUT_VALUE",i[i.PROVIDE=8]="PROVIDE"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.peer!=null&&(o.uint32(18),o.bytes(i.peer)),i.cid!=null&&(o.uint32(26),o.bytes(i.cid)),i.key!=null&&(o.uint32(34),o.bytes(i.key)),i.value!=null&&(o.uint32(42),o.bytes(i.value)),i.count!=null&&(o.uint32(48),o.int32(i.count)),i.timeout!=null&&(o.uint32(56),o.int64(i.timeout)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.cid=i.bytes();break;case 4:a.key=i.bytes();break;case 5:a.value=i.bytes();break;case 6:a.count=i.int32();break;case 7:a.timeout=i.int64();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(It||(It={}));var Q;(function(r){let t;(function(i){i.BEGIN="BEGIN",i.VALUE="VALUE",i.END="END"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.BEGIN=0]="BEGIN",i[i.VALUE=1]="VALUE",i[i.END=2]="END"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.peer!=null&&(o.uint32(18),ue.codec().encode(i.peer,o)),i.value!=null&&(o.uint32(26),o.bytes(i.value)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=ue.codec().decode(i,i.uint32());break;case 3:a.value=i.bytes();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(Q||(Q={}));var ue;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)n.uint32(18),n.bytes(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(ue||(ue={}));var gn;(function(r){let t;(function(i){i.TAG_PEER="TAG_PEER",i.UNTAG_PEER="UNTAG_PEER",i.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.TAG_PEER=0]="TAG_PEER",i[i.UNTAG_PEER=1]="UNTAG_PEER",i[i.TRIM=2]="TRIM"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.peer!=null&&(o.uint32(18),o.bytes(i.peer)),i.tag!=null&&(o.uint32(26),o.string(i.tag)),i.weight!=null&&(o.uint32(32),o.int64(i.weight)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.tag=i.string();break;case 4:a.weight=i.int64();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(gn||(gn={}));var yn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0)},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(yn||(yn={}));var jt;(function(r){let t;(function(i){i.GET_TOPICS="GET_TOPICS",i.LIST_PEERS="LIST_PEERS",i.PUBLISH="PUBLISH",i.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.GET_TOPICS=0]="GET_TOPICS",i[i.LIST_PEERS=1]="LIST_PEERS",i[i.PUBLISH=2]="PUBLISH",i[i.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.topic!=null&&(o.uint32(18),o.string(i.topic)),i.data!=null&&(o.uint32(26),o.bytes(i.data)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.topic=i.string();break;case 3:a.data=i.bytes();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(jt||(jt={}));var gr;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.from!=null&&(n.uint32(10),n.bytes(e.from)),e.data!=null&&(n.uint32(18),n.bytes(e.data)),e.seqno!=null&&(n.uint32(26),n.bytes(e.seqno)),e.topicIDs!=null)for(let o of e.topicIDs)n.uint32(34),n.string(o);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topicIDs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.from=e.bytes();break;case 2:i.data=e.bytes();break;case 3:i.seqno=e.bytes();break;case 4:i.topicIDs.push(e.string());break;case 5:i.signature=e.bytes();break;case 6:i.key=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(gr||(gr={}));var bn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let o of e.topics)n.uint32(10),n.string(o);if(e.peerIDs!=null)for(let o of e.peerIDs)n.uint32(18),n.bytes(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topics:[],peerIDs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.topics.push(e.string());break;case 2:i.peerIDs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(bn||(bn={}));var ke;(function(r){let t;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.GET_PROTOCOLS="GET_PROTOCOLS",i.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.GET_PROTOCOLS=1]="GET_PROTOCOLS",i[i.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(i){i.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{if(a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.id!=null&&(o.uint32(18),o.bytes(i.id)),i.protos!=null)for(let l of i.protos)o.uint32(26),o.string(l);a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={protos:[]},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.id=i.bytes();break;case 3:a.protos.push(i.string());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(ke||(ke={}));var wn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),ue.codec().encode(e.peer,n)),e.protos!=null)for(let o of e.protos)n.uint32(18),n.string(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={protos:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:i.peer=ue.codec().decode(e,e.uint32());break;case 2:i.protos.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(wn||(wn={}));function X(r){return _e.encode({type:_e.Type.OK,peers:[],...r}).subarray()}function P(r){return _e.encode({type:_e.Type.ERROR,error:{msg:r.message},peers:[]}).subarray()}function ip(r){return r[Symbol.asyncIterator]!=null}function op(r){if(ip(r))return(async()=>{for await(let t of r);})();for(let t of r);}var no=op;var En=et("libp2p:daemon-server:dht"),vn=class{constructor(t){let{dht:e}=t;this.dht=e}async*provide(t){try{await no(this.dht.provide(t)),yield X()}catch(e){En.error(e),yield P(e)}}async*getClosestPeers(t){yield X({dht:{type:Q.Type.BEGIN}});for await(let e of this.dht.getClosestPeers(t))e.name==="PEER_RESPONSE"&&(yield*e.closer.map(n=>Q.encode({type:Q.Type.VALUE,value:n.id.toBytes()})));yield Q.encode({type:Q.Type.END})}async*getPublicKey(t){yield P(new Error("FIX ME: not implemented"))}async*getValue(t){try{for await(let e of this.dht.get(t))e.name==="VALUE"&&(yield X({dht:{type:Q.Type.VALUE,value:e.value}}))}catch(e){En.error(e),yield P(e)}}async*putValue(t,e){try{await no(this.dht.put(t,e)),yield X()}catch(n){En.error(n),yield P(n)}}async*findPeer(t){try{for await(let e of this.dht.findPeer(t))e.name==="FINAL_PEER"&&(yield X({dht:{type:Q.Type.VALUE,peer:{id:e.peer.id.toBytes(),addrs:e.peer.multiaddrs.map(n=>n.bytes)}}}));throw new Error("Peer not found")}catch(e){En.error(e),yield P(e)}}async*findProviders(t,e){yield X({dht:{type:Q.Type.BEGIN}});try{let n=e,i=0;for await(let o of this.dht.findProviders(t))if(o.name==="PEER_RESPONSE"){for(let a of o.providers)i++,yield Q.encode({type:Q.Type.VALUE,peer:{id:a.id.toBytes(),addrs:(a.multiaddrs??[]).map(l=>l.bytes)}});if(n===i)break}}catch(n){yield P(n)}yield Q.encode({type:Q.Type.END})}};var Yc=Symbol.for("@libp2p/peer-id");var sp=Symbol.for("nodejs.util.inspect.custom"),Jc=Object.values(re).map(r=>r.decoder).reduce((r,t)=>r.or(t),re.identity.decoder),Qc=114,ta=36,ea=37,yr=class{constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[Yc](){return!0}toString(){return this.string==null&&(this.string=q.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return R.createV1(Qc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return ge(this.multihash.bytes,t);if(typeof t=="string")return cp(t).equals(this);if(t?.multihash?.bytes!=null)return ge(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[sp](){return`PeerId(${this.toString()})`}},br=class extends yr{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},wr=class extends yr{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},Er=class extends yr{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function cp(r,t){if(t=t??Jc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=pe(q.decode(`z${r}`));return r.startsWith("12D")?new wr({multihash:e}):r.startsWith("16U")?new Er({multihash:e}):new br({multihash:e})}return Be(Jc.decode(r))}function Be(r){try{let t=pe(r);if(t.code===_r.code){if(t.digest.length===ta)return new wr({multihash:t});if(t.digest.length===ea)return new Er({multihash:t})}if(t.code===Cr.code)return new br({multihash:t})}catch{return ap(R.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function ap(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Qc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Cr.code)return new br({multihash:r.multihash});if(t.code===_r.code){if(t.digest.length===ta)return new wr({multihash:r.multihash});if(t.digest.length===ea)return new Er({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var xn=et("libp2p:daemon-server:pubsub"),Sn=class{constructor(t){let{pubsub:e}=t;this.pubsub=e}async*getTopics(){try{yield X({pubsub:{topics:this.pubsub.getTopics(),peerIDs:[]}})}catch(t){xn.error(t),yield P(t)}}async*subscribe(t){try{let e=se();this.pubsub.subscribe(t),this.pubsub.addEventListener("message",n=>{let i=n.detail;i.topic===t&&(i.type==="signed"?e.push(gr.encode({from:i.from.toBytes(),data:i.data,seqno:i.sequenceNumber==null?void 0:sr(i.sequenceNumber.toString(16).padStart(16,"0"),"base16"),topicIDs:[i.topic],signature:i.signature,key:i.key}).subarray()):e.push(gr.encode({data:i.data,topicIDs:[i.topic]}).subarray()))}),yield X(),yield*e}catch(e){xn.error(e),yield P(e)}}async*publish(t,e){try{await this.pubsub.publish(t,e),yield X()}catch(n){xn.error(n),yield P(n)}}async*listPeers(t){try{yield X({pubsub:{topics:[t],peerIDs:this.pubsub.getSubscribers(t).map(e=>e.toBytes())}})}catch(e){xn.error(e),yield P(e)}}};var up=1<<22,Yt=et("libp2p:daemon-server"),Tn=class{constructor(t){let{multiaddr:e,libp2pNode:n}=t;this.multiaddr=e,this.libp2p=n,this.tcp=Xs()(),this.listener=this.tcp.createListener({handler:this.handleConnection.bind(this),upgrader:Gi}),this._onExit=this._onExit.bind(this),n.services.dht!=null&&(this.dhtOperations=new vn({dht:n.services.dht})),n.services.pubsub!=null&&(this.pubsubOperations=new Sn({pubsub:n.services.pubsub}))}async connect(t){if(t.connect==null||t.connect.addrs==null)throw new Error("Invalid request");let e=t.connect.peer,n=t.connect.addrs.map(o=>gt(o)),i=Be(e);return await this.libp2p.peerStore.merge(i,{multiaddrs:n}),await this.libp2p.dial(i)}async openStream(t){if(t.streamOpen==null||t.streamOpen.proto==null)throw new Error("Invalid request");let{peer:e,proto:n}=t.streamOpen,i=Be(e),o=await this.libp2p.dial(i),a=await o.newStream(n);return{streamInfo:{peer:i.toBytes(),addr:o.remoteAddr.bytes,proto:a.stat.protocol??""},connection:a}}async registerStreamHandler(t){if(t.streamHandler==null||t.streamHandler.proto==null)throw new Error("Invalid request");let e=t.streamHandler.proto,n=gt(t.streamHandler.addr),i;await this.libp2p.handle(e,({connection:o,stream:a})=>{Promise.resolve().then(async()=>{i=await this.tcp.dial(n,{upgrader:Gi});let l=tr.encode({peer:o.remotePeer.toBytes(),addr:o.remoteAddr.bytes,proto:a.stat.protocol??""}),f=Ke.single(l);await nn(async function*(){yield f,yield*a.source}(),async function*(d){for await(let h of d)yield*h},i,a.sink)}).catch(async l=>{Yt.error(l),i!=null&&await i.close(l)}).finally(()=>{i?.close().catch(l=>{Yt.error(l)})})})}_listen(){process.on("SIGTERM",this._onExit),process.on("SIGINT",this._onExit),process.on("SIGHUP",this._onExit)}_onExit(){this.stop({exit:!0}).catch(t=>{Yt.error(t)})}async start(){this._listen(),await this.libp2p.start(),await this.listener.listen(this.multiaddr)}getMultiaddr(){let t=this.listener.getAddrs();if(t.length>0)return t[0];throw new Error("Not started")}async stop(t={exit:!1}){await this.libp2p.stop(),await this.listener.close(),t.exit&&Yt("server closed, exiting"),process.removeListener("SIGTERM",this._onExit),process.removeListener("SIGINT",this._onExit),process.removeListener("SIGHUP",this._onExit)}async*handlePeerStoreRequest(t){try{switch(t.type){case ke.Type.GET_PROTOCOLS:if(t.id==null)throw new Error("Invalid request");let e=Be(t.id),i=(await this.libp2p.peerStore.get(e)).protocols;yield X({peerStore:{protos:i}});return;case ke.Type.GET_PEER_INFO:throw new Error("ERR_NOT_IMPLEMENTED");default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Yt.error(e),yield P(e)}}async*handlePubsubRequest(t){try{if(this.libp2p.services.pubsub==null||this.pubsubOperations==null)throw new Error("PubSub not configured");switch(t.type){case jt.Type.GET_TOPICS:yield*this.pubsubOperations.getTopics();return;case jt.Type.SUBSCRIBE:if(t.topic==null)throw new Error("Invalid request");yield*this.pubsubOperations.subscribe(t.topic);return;case jt.Type.PUBLISH:if(t.topic==null||t.data==null)throw new Error("Invalid request");yield*this.pubsubOperations.publish(t.topic,t.data);return;case jt.Type.LIST_PEERS:if(t.topic==null)throw new Error("Invalid request");yield*this.pubsubOperations.listPeers(t.topic);return;default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Yt.error(e),yield P(e)}}async*handleDHTRequest(t){try{if(this.libp2p.services.dht==null||this.dhtOperations==null)throw new Error("DHT not configured");switch(t.type){case It.Type.FIND_PEER:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.findPeer(Be(t.peer));return;case It.Type.FIND_PROVIDERS:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.findProviders(R.decode(t.cid),t.count??20);return;case It.Type.PROVIDE:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.provide(R.decode(t.cid));return;case It.Type.GET_CLOSEST_PEERS:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getClosestPeers(t.key);return;case It.Type.GET_PUBLIC_KEY:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.getPublicKey(Be(t.peer));return;case It.Type.GET_VALUE:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getValue(t.key);return;case It.Type.PUT_VALUE:if(t.key==null||t.value==null)throw new Error("Invalid request");yield*this.dhtOperations.putValue(t.key,t.value);return;default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Yt.error(e),yield P(e)}}handleConnection(t){let e=this,n=new on({stream:t,maxLength:up});nn(n.decoder,i=>async function*(){let o;for await(let a of i)try{switch(o=At.decode(a),o.type){case At.Type.CONNECT:{try{await e.connect(o)}catch(l){yield P(l);break}yield X();break}case At.Type.IDENTIFY:{yield X({identify:{id:e.libp2p.peerId.toBytes(),addrs:e.libp2p.getMultiaddrs().map(l=>l.decapsulateCode(L("p2p").code)).map(l=>l.bytes)}});break}case At.Type.LIST_PEERS:{let l=[],f=new Set;for(let d of e.libp2p.getConnections()){let h=d.remotePeer.toString();f.has(h)||(f.add(h),l.push({id:d.remotePeer.toBytes(),addrs:[d.remoteAddr.bytes]}))}yield X({peers:l});break}case At.Type.STREAM_OPEN:{let l;try{l=await e.openStream(o)}catch(d){yield P(d);break}yield X({streamInfo:l.streamInfo});let f=n.rest();await nn(f,l.connection,async function*(d){for await(let h of d)yield*h},f);return}case At.Type.STREAM_HANDLER:{try{await e.registerStreamHandler(o)}catch(l){yield P(l);break}yield X();break}case At.Type.PEERSTORE:{if(o.peerStore==null){yield P(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePeerStoreRequest(o.peerStore);break}case At.Type.PUBSUB:{if(o.pubsub==null){yield P(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePubsubRequest(o.pubsub);break}case At.Type.DHT:{if(o.dht==null){yield P(new Error("ERR_INVALID_REQUEST"));break}yield*e.handleDHTRequest(o.dht);break}default:yield P(new Error("ERR_INVALID_REQUEST_TYPE"));break}}catch(l){Yt.error(l),yield P(l);continue}}(),async function(i){for await(let o of i)n.write(o)}).catch(i=>{Yt(i)})}},lp=(r,t)=>new Tn({multiaddr:r,libp2pNode:t});return $u(fp);})();
4
+ `+s),r.push(i+"m+"+_r.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=cl()+t+" "+r[0]}function cl(){return Y.inspectOpts.hideDate?"":new Date().toISOString()+" "}function al(...r){return process.stderr.write(Rr.format(...r)+`
5
+ `)}function ul(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function ll(){return process.env.DEBUG}function fl(r){r.inspectOpts={};let t=Object.keys(Y.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=Y.inspectOpts[t[e]]}_r.exports=On()(Y);var{formatters:eo}=_r.exports;eo.o=function(r){return this.inspectOpts.colors=this.useColors,Rr.inspect(r,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};eo.O=function(r){return this.inspectOpts.colors=this.useColors,Rr.inspect(r,this.inspectOpts)}});var no=B((_p,Mn)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Mn.exports=Ys():Mn.exports=ro()});var bo=B((Ad,yo)=>{"use strict";function go(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Gl(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return go(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),go(new i,e)}}yo.exports=Gl});var zo=B((km,$o)=>{$o.exports=fi;var Go=128,Of=127,Pf=~Of,Mf=Math.pow(2,31);function fi(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw fi.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Mf;)t[e++]=r&255|Go,r/=128;for(;r&Pf;)t[e++]=r&255|Go,r>>>=7;return t[e]=r|0,fi.bytes=e-n+1,t}});var Wo=B((Dm,Ho)=>{Ho.exports=hi;var Uf=128,Vo=127;function hi(r,n){var e=0,n=n||0,i=0,s=n,a,l=r.length;do{if(s>=l||i>49)throw hi.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&Vo)<<i:(a&Vo)*Math.pow(2,i),i+=7}while(a>=Uf);return hi.bytes=s-n,e}});var Zo=B((Bm,qo)=>{var Ff=Math.pow(2,7),Gf=Math.pow(2,14),$f=Math.pow(2,21),zf=Math.pow(2,28),Vf=Math.pow(2,35),Hf=Math.pow(2,42),Wf=Math.pow(2,49),qf=Math.pow(2,56),Zf=Math.pow(2,63);qo.exports=function(r){return r<Ff?1:r<Gf?2:r<$f?3:r<zf?4:r<Vf?5:r<Hf?6:r<Wf?7:r<qf?8:r<Zf?9:10}});var pi=B((Rm,Ko)=>{Ko.exports={encode:zo(),decode:Wo(),encodingLength:Zo()}});var Bi=B((Qr,wc)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(o,c,u){o!=null&&(typeof o=="number"?this.fromNumber(o,c,u):c==null&&typeof o!="string"?this.fromString(o,256):this.fromString(o,c))}function i(){return new n(null)}function s(o,c,u,p,m,y){for(;--y>=0;){var E=c*this[o++]+u[p]+m;m=Math.floor(E/67108864),u[p++]=E&67108863}return m}function a(o,c,u,p,m,y){for(var E=c&32767,x=c>>15;--y>=0;){var N=this[o]&32767,Z=this[o++]>>15,yt=x*N+Z*E;N=E*N+((yt&32767)<<15)+u[p]+(m&1073741823),m=(N>>>30)+(yt>>>15)+x*Z+(m>>>30),u[p++]=N&1073741823}return m}function l(o,c,u,p,m,y){for(var E=c&16383,x=c>>14;--y>=0;){var N=this[o]&16383,Z=this[o++]>>14,yt=x*N+Z*E;N=E*N+((yt&16383)<<14)+u[p]+m,m=(N>>28)+(yt>>14)+x*Z,u[p++]=N&268435455}return m}var f=typeof navigator<"u";f&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=a,r=30):f&&e&&navigator.appName!="Netscape"?(n.prototype.am=s,r=26):(n.prototype.am=l,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var d=52;n.prototype.FV=Math.pow(2,d),n.prototype.F1=d-r,n.prototype.F2=2*r-d;var h="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,S;for(w="0".charCodeAt(0),S=0;S<=9;++S)g[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)g[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)g[w++]=S;function b(o){return h.charAt(o)}function k(o,c){var u=g[o.charCodeAt(c)];return u??-1}function A(o){for(var c=this.t-1;c>=0;--c)o[c]=this[c];o.t=this.t,o.s=this.s}function C(o){this.t=1,this.s=o<0?-1:0,o>0?this[0]=o:o<-1?this[0]=o+this.DV:this.t=0}function D(o){var c=i();return c.fromInt(o),c}function _(o,c){var u;if(c==16)u=4;else if(c==8)u=3;else if(c==256)u=8;else if(c==2)u=1;else if(c==32)u=5;else if(c==4)u=2;else{this.fromRadix(o,c);return}this.t=0,this.s=0;for(var p=o.length,m=!1,y=0;--p>=0;){var E=u==8?o[p]&255:k(o,p);if(E<0){o.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=E:y+u>this.DB?(this[this.t-1]|=(E&(1<<this.DB-y)-1)<<y,this[this.t++]=E>>this.DB-y):this[this.t-1]|=E<<y,y+=u,y>=this.DB&&(y-=this.DB)}u==8&&o[0]&128&&(this.s=-1,y>0&&(this[this.t-1]|=(1<<this.DB-y)-1<<y)),this.clamp(),m&&n.ZERO.subTo(this,this)}function G(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function rt(o){if(this.s<0)return"-"+this.negate().toString(o);var c;if(o==16)c=4;else if(o==8)c=3;else if(o==2)c=1;else if(o==32)c=5;else if(o==4)c=2;else return this.toRadix(o);var u=(1<<c)-1,p,m=!1,y="",E=this.t,x=this.DB-E*this.DB%c;if(E-- >0)for(x<this.DB&&(p=this[E]>>x)>0&&(m=!0,y=b(p));E>=0;)x<c?(p=(this[E]&(1<<x)-1)<<c-x,p|=this[--E]>>(x+=this.DB-c)):(p=this[E]>>(x-=c)&u,x<=0&&(x+=this.DB,--E)),p>0&&(m=!0),m&&(y+=b(p));return m?y:"0"}function st(){var o=i();return n.ZERO.subTo(this,o),o}function nt(){return this.s<0?this.negate():this}function ot(o){var c=this.s-o.s;if(c!=0)return c;var u=this.t;if(c=u-o.t,c!=0)return this.s<0?-c:c;for(;--u>=0;)if((c=this[u]-o[u])!=0)return c;return 0}function Tt(o){var c=1,u;return(u=o>>>16)!=0&&(o=u,c+=16),(u=o>>8)!=0&&(o=u,c+=8),(u=o>>4)!=0&&(o=u,c+=4),(u=o>>2)!=0&&(o=u,c+=2),(u=o>>1)!=0&&(o=u,c+=1),c}function qc(){return this.t<=0?0:this.DB*(this.t-1)+Tt(this[this.t-1]^this.s&this.DM)}function Zc(o,c){var u;for(u=this.t-1;u>=0;--u)c[u+o]=this[u];for(u=o-1;u>=0;--u)c[u]=0;c.t=this.t+o,c.s=this.s}function Kc(o,c){for(var u=o;u<this.t;++u)c[u-o]=this[u];c.t=Math.max(this.t-o,0),c.s=this.s}function Xc(o,c){var u=o%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(o/this.DB),E=this.s<<u&this.DM,x;for(x=this.t-1;x>=0;--x)c[x+y+1]=this[x]>>p|E,E=(this[x]&m)<<u;for(x=y-1;x>=0;--x)c[x]=0;c[y]=E,c.t=this.t+y+1,c.s=this.s,c.clamp()}function Yc(o,c){c.s=this.s;var u=Math.floor(o/this.DB);if(u>=this.t){c.t=0;return}var p=o%this.DB,m=this.DB-p,y=(1<<p)-1;c[0]=this[u]>>p;for(var E=u+1;E<this.t;++E)c[E-u-1]|=(this[E]&y)<<m,c[E-u]=this[E]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function jc(o,c){for(var u=0,p=0,m=Math.min(o.t,this.t);u<m;)p+=this[u]-o[u],c[u++]=p&this.DM,p>>=this.DB;if(o.t<this.t){for(p-=o.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<o.t;)p-=o[u],c[u++]=p&this.DM,p>>=this.DB;p-=o.s}c.s=p<0?-1:0,p<-1?c[u++]=this.DV+p:p>0&&(c[u++]=p),c.t=u,c.clamp()}function Jc(o,c){var u=this.abs(),p=o.abs(),m=u.t;for(c.t=m+p.t;--m>=0;)c[m]=0;for(m=0;m<p.t;++m)c[m+u.t]=u.am(0,p[m],c,m,0,u.t);c.s=0,c.clamp(),this.s!=o.s&&n.ZERO.subTo(c,c)}function Qc(o){for(var c=this.abs(),u=o.t=2*c.t;--u>=0;)o[u]=0;for(u=0;u<c.t-1;++u){var p=c.am(u,c[u],o,2*u,0,1);(o[u+c.t]+=c.am(u+1,2*c[u],o,2*u+1,p,c.t-u-1))>=c.DV&&(o[u+c.t]-=c.DV,o[u+c.t+1]=1)}o.t>0&&(o[o.t-1]+=c.am(u,c[u],o,2*u,0,1)),o.s=0,o.clamp()}function ta(o,c,u){var p=o.abs();if(!(p.t<=0)){var m=this.abs();if(m.t<p.t){c?.fromInt(0),u!=null&&this.copyTo(u);return}u==null&&(u=i());var y=i(),E=this.s,x=o.s,N=this.DB-Tt(p[p.t-1]);N>0?(p.lShiftTo(N,y),m.lShiftTo(N,u)):(p.copyTo(y),m.copyTo(u));var Z=y.t,yt=y[Z-1];if(yt!=0){var lt=yt*(1<<this.F1)+(Z>1?y[Z-2]>>this.F2:0),Ut=this.FV/lt,hr=(1<<this.F1)/lt,It=1<<this.F2,Ct=u.t,pr=Ct-Z,qt=c??i();for(y.dlShiftTo(pr,qt),u.compareTo(qt)>=0&&(u[u.t++]=1,u.subTo(qt,u)),n.ONE.dlShiftTo(Z,qt),qt.subTo(y,y);y.t<Z;)y[y.t++]=0;for(;--pr>=0;){var bn=u[--Ct]==yt?this.DM:Math.floor(u[Ct]*Ut+(u[Ct-1]+It)*hr);if((u[Ct]+=y.am(0,bn,u,pr,0,Z))<bn)for(y.dlShiftTo(pr,qt),u.subTo(qt,u);u[Ct]<--bn;)u.subTo(qt,u)}c!=null&&(u.drShiftTo(Z,c),E!=x&&n.ZERO.subTo(c,c)),u.t=Z,u.clamp(),N>0&&u.rShiftTo(N,u),E<0&&n.ZERO.subTo(u,u)}}}function ea(o){var c=i();return this.abs().divRemTo(o,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&o.subTo(c,c),c}function ne(o){this.m=o}function ra(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function na(o){return o}function ia(o){o.divRemTo(this.m,null,o)}function sa(o,c,u){o.multiplyTo(c,u),this.reduce(u)}function oa(o,c){o.squareTo(c),this.reduce(c)}ne.prototype.convert=ra,ne.prototype.revert=na,ne.prototype.reduce=ia,ne.prototype.mulTo=sa,ne.prototype.sqrTo=oa;function ca(){if(this.t<1)return 0;var o=this[0];if(!(o&1))return 0;var c=o&3;return c=c*(2-(o&15)*c)&15,c=c*(2-(o&255)*c)&255,c=c*(2-((o&65535)*c&65535))&65535,c=c*(2-o*c%this.DV)%this.DV,c>0?this.DV-c:-c}function ie(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 aa(o){var c=i();return o.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),o.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function ua(o){var c=i();return o.copyTo(c),this.reduce(c),c}function la(o){for(;o.t<=this.mt2;)o[o.t++]=0;for(var c=0;c<this.m.t;++c){var u=o[c]&32767,p=u*this.mpl+((u*this.mph+(o[c]>>15)*this.mpl&this.um)<<15)&o.DM;for(u=c+this.m.t,o[u]+=this.m.am(0,p,o,c,0,this.m.t);o[u]>=o.DV;)o[u]-=o.DV,o[++u]++}o.clamp(),o.drShiftTo(this.m.t,o),o.compareTo(this.m)>=0&&o.subTo(this.m,o)}function fa(o,c){o.squareTo(c),this.reduce(c)}function ha(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ie.prototype.convert=aa,ie.prototype.revert=ua,ie.prototype.reduce=la,ie.prototype.mulTo=ha,ie.prototype.sqrTo=fa;function pa(){return(this.t>0?this[0]&1:this.s)==0}function da(o,c){if(o>4294967295||o<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=Tt(o)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(o&1<<y)>0)c.mulTo(p,m,u);else{var E=u;u=p,p=E}return c.revert(u)}function ma(o,c){var u;return o<256||c.isEven()?u=new ne(c):u=new ie(c),this.exp(o,u)}n.prototype.copyTo=A,n.prototype.fromInt=C,n.prototype.fromString=_,n.prototype.clamp=G,n.prototype.dlShiftTo=Zc,n.prototype.drShiftTo=Kc,n.prototype.lShiftTo=Xc,n.prototype.rShiftTo=Yc,n.prototype.subTo=jc,n.prototype.multiplyTo=Jc,n.prototype.squareTo=Qc,n.prototype.divRemTo=ta,n.prototype.invDigit=ca,n.prototype.isEven=pa,n.prototype.exp=da,n.prototype.toString=rt,n.prototype.negate=st,n.prototype.abs=nt,n.prototype.compareTo=ot,n.prototype.bitLength=qc,n.prototype.mod=ea,n.prototype.modPowInt=ma,n.ZERO=D(0),n.ONE=D(1);function ga(){var o=i();return this.copyTo(o),o}function ya(){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 ba(){return this.t==0?this.s:this[0]<<24>>24}function wa(){return this.t==0?this.s:this[0]<<16>>16}function Ea(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function va(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function xa(o){if(o==null&&(o=10),this.signum()==0||o<2||o>36)return"0";var c=this.chunkSize(o),u=Math.pow(o,c),p=D(u),m=i(),y=i(),E="";for(this.divRemTo(p,m,y);m.signum()>0;)E=(u+y.intValue()).toString(o).substr(1)+E,m.divRemTo(p,m,y);return y.intValue().toString(o)+E}function Sa(o,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,E=0,x=0;x<o.length;++x){var N=k(o,x);if(N<0){o.charAt(x)=="-"&&this.signum()==0&&(m=!0);continue}E=c*E+N,++y>=u&&(this.dMultiply(p),this.dAddOffset(E,0),y=0,E=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(E,0)),m&&n.ZERO.subTo(this,this)}function Ta(o,c,u){if(typeof c=="number")if(o<2)this.fromInt(1);else for(this.fromNumber(o,u),this.testBit(o-1)||this.bitwiseTo(n.ONE.shiftLeft(o-1),dn,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>o&&this.subTo(n.ONE.shiftLeft(o-1),this);else{var p=new Array,m=o&7;p.length=(o>>3)+1,c.nextBytes(p),m>0?p[0]&=(1<<m)-1:p[0]=0,this.fromString(p,256)}}function Aa(){var o=this.t,c=new Array;c[0]=this.s;var u=this.DB-o*this.DB%8,p,m=0;if(o-- >0)for(u<this.DB&&(p=this[o]>>u)!=(this.s&this.DM)>>u&&(c[m++]=p|this.s<<this.DB-u);o>=0;)u<8?(p=(this[o]&(1<<u)-1)<<8-u,p|=this[--o]>>(u+=this.DB-8)):(p=this[o]>>(u-=8)&255,u<=0&&(u+=this.DB,--o)),p&128&&(p|=-256),m==0&&(this.s&128)!=(p&128)&&++m,(m>0||p!=this.s)&&(c[m++]=p);return c}function Ia(o){return this.compareTo(o)==0}function Ca(o){return this.compareTo(o)<0?this:o}function ka(o){return this.compareTo(o)>0?this:o}function Da(o,c,u){var p,m,y=Math.min(o.t,this.t);for(p=0;p<y;++p)u[p]=c(this[p],o[p]);if(o.t<this.t){for(m=o.s&this.DM,p=y;p<this.t;++p)u[p]=c(this[p],m);u.t=this.t}else{for(m=this.s&this.DM,p=y;p<o.t;++p)u[p]=c(m,o[p]);u.t=o.t}u.s=c(this.s,o.s),u.clamp()}function Ba(o,c){return o&c}function Ra(o){var c=i();return this.bitwiseTo(o,Ba,c),c}function dn(o,c){return o|c}function _a(o){var c=i();return this.bitwiseTo(o,dn,c),c}function Yi(o,c){return o^c}function La(o){var c=i();return this.bitwiseTo(o,Yi,c),c}function ji(o,c){return o&~c}function Na(o){var c=i();return this.bitwiseTo(o,ji,c),c}function Oa(){for(var o=i(),c=0;c<this.t;++c)o[c]=this.DM&~this[c];return o.t=this.t,o.s=~this.s,o}function Pa(o){var c=i();return o<0?this.rShiftTo(-o,c):this.lShiftTo(o,c),c}function Ma(o){var c=i();return o<0?this.lShiftTo(-o,c):this.rShiftTo(o,c),c}function Ua(o){if(o==0)return-1;var c=0;return o&65535||(o>>=16,c+=16),o&255||(o>>=8,c+=8),o&15||(o>>=4,c+=4),o&3||(o>>=2,c+=2),o&1||++c,c}function Fa(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+Ua(this[o]);return this.s<0?this.t*this.DB:-1}function Ga(o){for(var c=0;o!=0;)o&=o-1,++c;return c}function $a(){for(var o=0,c=this.s&this.DM,u=0;u<this.t;++u)o+=Ga(this[u]^c);return o}function za(o){var c=Math.floor(o/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<o%this.DB)!=0}function Va(o,c){var u=n.ONE.shiftLeft(o);return this.bitwiseTo(u,c,u),u}function Ha(o){return this.changeBit(o,dn)}function Wa(o){return this.changeBit(o,ji)}function qa(o){return this.changeBit(o,Yi)}function Za(o,c){for(var u=0,p=0,m=Math.min(o.t,this.t);u<m;)p+=this[u]+o[u],c[u++]=p&this.DM,p>>=this.DB;if(o.t<this.t){for(p+=o.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<o.t;)p+=o[u],c[u++]=p&this.DM,p>>=this.DB;p+=o.s}c.s=p<0?-1:0,p>0?c[u++]=p:p<-1&&(c[u++]=this.DV+p),c.t=u,c.clamp()}function Ka(o){var c=i();return this.addTo(o,c),c}function Xa(o){var c=i();return this.subTo(o,c),c}function Ya(o){var c=i();return this.multiplyTo(o,c),c}function ja(){var o=i();return this.squareTo(o),o}function Ja(o){var c=i();return this.divRemTo(o,c,null),c}function Qa(o){var c=i();return this.divRemTo(o,null,c),c}function tu(o){var c=i(),u=i();return this.divRemTo(o,c,u),new Array(c,u)}function eu(o){this[this.t]=this.am(0,o-1,this,0,0,this.t),++this.t,this.clamp()}function ru(o,c){if(o!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=o;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function Xe(){}function Ji(o){return o}function nu(o,c,u){o.multiplyTo(c,u)}function iu(o,c){o.squareTo(c)}Xe.prototype.convert=Ji,Xe.prototype.revert=Ji,Xe.prototype.mulTo=nu,Xe.prototype.sqrTo=iu;function su(o){return this.exp(o,new Xe)}function ou(o,c,u){var p=Math.min(this.t+o.t,c);for(u.s=0,u.t=p;p>0;)u[--p]=0;var m;for(m=u.t-this.t;p<m;++p)u[p+this.t]=this.am(0,o[p],u,p,0,this.t);for(m=Math.min(o.t,c);p<m;++p)this.am(0,o[p],u,p,0,c-p);u.clamp()}function cu(o,c,u){--c;var p=u.t=this.t+o.t-c;for(u.s=0;--p>=0;)u[p]=0;for(p=Math.max(c-this.t,0);p<o.t;++p)u[this.t+p-c]=this.am(c-p,o[p],u,0,0,this.t+p-c);u.clamp(),u.drShiftTo(1,u)}function se(o){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*o.t,this.r2),this.mu=this.r2.divide(o),this.m=o}function au(o){if(o.s<0||o.t>2*this.m.t)return o.mod(this.m);if(o.compareTo(this.m)<0)return o;var c=i();return o.copyTo(c),this.reduce(c),c}function uu(o){return o}function lu(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 fu(o,c){o.squareTo(c),this.reduce(c)}function hu(o,c,u){o.multiplyTo(c,u),this.reduce(u)}se.prototype.convert=au,se.prototype.revert=uu,se.prototype.reduce=lu,se.prototype.mulTo=hu,se.prototype.sqrTo=fu;function pu(o,c){var u=o.bitLength(),p,m=D(1),y;if(u<=0)return m;u<18?p=1:u<48?p=3:u<144?p=4:u<768?p=5:p=6,u<8?y=new ne(c):c.isEven()?y=new se(c):y=new ie(c);var E=new Array,x=3,N=p-1,Z=(1<<p)-1;if(E[1]=y.convert(this),p>1){var yt=i();for(y.sqrTo(E[1],yt);x<=Z;)E[x]=i(),y.mulTo(yt,E[x-2],E[x]),x+=2}var lt=o.t-1,Ut,hr=!0,It=i(),Ct;for(u=Tt(o[lt])-1;lt>=0;){for(u>=N?Ut=o[lt]>>u-N&Z:(Ut=(o[lt]&(1<<u+1)-1)<<N-u,lt>0&&(Ut|=o[lt-1]>>this.DB+u-N)),x=p;!(Ut&1);)Ut>>=1,--x;if((u-=x)<0&&(u+=this.DB,--lt),hr)E[Ut].copyTo(m),hr=!1;else{for(;x>1;)y.sqrTo(m,It),y.sqrTo(It,m),x-=2;x>0?y.sqrTo(m,It):(Ct=m,m=It,It=Ct),y.mulTo(It,E[Ut],m)}for(;lt>=0&&!(o[lt]&1<<u);)y.sqrTo(m,It),Ct=m,m=It,It=Ct,--u<0&&(u=this.DB-1,--lt)}return y.revert(m)}function du(o){var c=this.s<0?this.negate():this.clone(),u=o.s<0?o.negate():o.clone();if(c.compareTo(u)<0){var p=c;c=u,u=p}var m=c.getLowestSetBit(),y=u.getLowestSetBit();if(y<0)return c;for(m<y&&(y=m),y>0&&(c.rShiftTo(y,c),u.rShiftTo(y,u));c.signum()>0;)(m=c.getLowestSetBit())>0&&c.rShiftTo(m,c),(m=u.getLowestSetBit())>0&&u.rShiftTo(m,u),c.compareTo(u)>=0?(c.subTo(u,c),c.rShiftTo(1,c)):(u.subTo(c,u),u.rShiftTo(1,u));return y>0&&u.lShiftTo(y,u),u}function mu(o){if(o<=0)return 0;var c=this.DV%o,u=this.s<0?o-1:0;if(this.t>0)if(c==0)u=this[0]%o;else for(var p=this.t-1;p>=0;--p)u=(c*u+this[p])%o;return u}function gu(o){var c=o.isEven();if(this.isEven()&&c||o.signum()==0)return n.ZERO;for(var u=o.clone(),p=this.clone(),m=D(1),y=D(0),E=D(0),x=D(1);u.signum()!=0;){for(;u.isEven();)u.rShiftTo(1,u),c?((!m.isEven()||!y.isEven())&&(m.addTo(this,m),y.subTo(o,y)),m.rShiftTo(1,m)):y.isEven()||y.subTo(o,y),y.rShiftTo(1,y);for(;p.isEven();)p.rShiftTo(1,p),c?((!E.isEven()||!x.isEven())&&(E.addTo(this,E),x.subTo(o,x)),E.rShiftTo(1,E)):x.isEven()||x.subTo(o,x),x.rShiftTo(1,x);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(E,m),y.subTo(x,y)):(p.subTo(u,p),c&&E.subTo(m,E),x.subTo(y,x))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(x.compareTo(o)>=0)return x.subtract(o);if(x.signum()<0)x.addTo(o,x);else return x;return x.signum()<0?x.add(o):x}var it=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],yu=(1<<26)/it[it.length-1];function bu(o){var c,u=this.abs();if(u.t==1&&u[0]<=it[it.length-1]){for(c=0;c<it.length;++c)if(u[0]==it[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<it.length;){for(var p=it[c],m=c+1;m<it.length&&p<yu;)p*=it[m++];for(p=u.modInt(p);c<m;)if(p%it[c++]==0)return!1}return u.millerRabin(o)}function wu(o){var c=this.subtract(n.ONE),u=c.getLowestSetBit();if(u<=0)return!1;var p=c.shiftRight(u);o=o+1>>1,o>it.length&&(o=it.length);for(var m=i(),y=0;y<o;++y){m.fromInt(it[Math.floor(Math.random()*it.length)]);var E=m.modPow(p,this);if(E.compareTo(n.ONE)!=0&&E.compareTo(c)!=0){for(var x=1;x++<u&&E.compareTo(c)!=0;)if(E=E.modPowInt(2,this),E.compareTo(n.ONE)==0)return!1;if(E.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=Ea,n.prototype.toRadix=xa,n.prototype.fromRadix=Sa,n.prototype.fromNumber=Ta,n.prototype.bitwiseTo=Da,n.prototype.changeBit=Va,n.prototype.addTo=Za,n.prototype.dMultiply=eu,n.prototype.dAddOffset=ru,n.prototype.multiplyLowerTo=ou,n.prototype.multiplyUpperTo=cu,n.prototype.modInt=mu,n.prototype.millerRabin=wu,n.prototype.clone=ga,n.prototype.intValue=ya,n.prototype.byteValue=ba,n.prototype.shortValue=wa,n.prototype.signum=va,n.prototype.toByteArray=Aa,n.prototype.equals=Ia,n.prototype.min=Ca,n.prototype.max=ka,n.prototype.and=Ra,n.prototype.or=_a,n.prototype.xor=La,n.prototype.andNot=Na,n.prototype.not=Oa,n.prototype.shiftLeft=Pa,n.prototype.shiftRight=Ma,n.prototype.getLowestSetBit=Fa,n.prototype.bitCount=$a,n.prototype.testBit=za,n.prototype.setBit=Ha,n.prototype.clearBit=Wa,n.prototype.flipBit=qa,n.prototype.add=Ka,n.prototype.subtract=Xa,n.prototype.multiply=Ya,n.prototype.divide=Ja,n.prototype.remainder=Qa,n.prototype.divideAndRemainder=tu,n.prototype.modPow=pu,n.prototype.modInverse=gu,n.prototype.pow=su,n.prototype.gcd=du,n.prototype.isProbablePrime=bu,n.prototype.square=ja,n.prototype.Barrett=se;var fr,ut,q;function Eu(o){ut[q++]^=o&255,ut[q++]^=o>>8&255,ut[q++]^=o>>16&255,ut[q++]^=o>>24&255,q>=yn&&(q-=yn)}function Qi(){Eu(new Date().getTime())}if(ut==null){ut=new Array,q=0;var At;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var ts=new Uint8Array(32);for(window.crypto.getRandomValues(ts),At=0;At<32;++At)ut[q++]=ts[At]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var es=window.crypto.random(32);for(At=0;At<es.length;++At)ut[q++]=es.charCodeAt(At)&255}}for(;q<yn;)At=Math.floor(65536*Math.random()),ut[q++]=At>>>8,ut[q++]=At&255;q=0,Qi()}function vu(){if(fr==null){for(Qi(),fr=Au(),fr.init(ut),q=0;q<ut.length;++q)ut[q]=0;q=0}return fr.next()}function xu(o){var c;for(c=0;c<o.length;++c)o[c]=vu()}function mn(){}mn.prototype.nextBytes=xu;function gn(){this.i=0,this.j=0,this.S=new Array}function Su(o){var c,u,p;for(c=0;c<256;++c)this.S[c]=c;for(u=0,c=0;c<256;++c)u=u+this.S[c]+o[c%o.length]&255,p=this.S[c],this.S[c]=this.S[u],this.S[u]=p;this.i=0,this.j=0}function Tu(){var o;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,o=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=o,this.S[o+this.S[this.i]&255]}gn.prototype.init=Su,gn.prototype.next=Tu;function Au(){return new gn}var yn=256;typeof Qr<"u"?Qr=wc.exports={default:n,BigInteger:n,SecureRandom:mn}:this.jsbn={BigInteger:n,SecureRandom:mn}}).call(Qr)});var ur=B(tn=>{(function(){"use strict";var r={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(a){return n(s(a),arguments)}function e(a,l){return t.apply(null,[a].concat(l||[]))}function n(a,l){var f=1,d=a.length,h,g="",w,S,b,k,A,C,D,_;for(w=0;w<d;w++)if(typeof a[w]=="string")g+=a[w];else if(typeof a[w]=="object"){if(b=a[w],b.keys)for(h=l[f],S=0;S<b.keys.length;S++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',b.keys[S],b.keys[S-1]));h=h[b.keys[S]]}else b.param_no?h=l[b.param_no]:h=l[f++];if(r.not_type.test(b.type)&&r.not_primitive.test(b.type)&&h instanceof Function&&(h=h()),r.numeric_arg.test(b.type)&&typeof h!="number"&&isNaN(h))throw new TypeError(t("[sprintf] expecting number but found %T",h));switch(r.number.test(b.type)&&(D=h>=0),b.type){case"b":h=parseInt(h,10).toString(2);break;case"c":h=String.fromCharCode(parseInt(h,10));break;case"d":case"i":h=parseInt(h,10);break;case"j":h=JSON.stringify(h,null,b.width?parseInt(b.width):0);break;case"e":h=b.precision?parseFloat(h).toExponential(b.precision):parseFloat(h).toExponential();break;case"f":h=b.precision?parseFloat(h).toFixed(b.precision):parseFloat(h);break;case"g":h=b.precision?String(Number(h.toPrecision(b.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=b.precision?h.substring(0,b.precision):h;break;case"t":h=String(!!h),h=b.precision?h.substring(0,b.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=b.precision?h.substring(0,b.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=b.precision?h.substring(0,b.precision):h;break;case"x":h=(parseInt(h,10)>>>0).toString(16);break;case"X":h=(parseInt(h,10)>>>0).toString(16).toUpperCase();break}r.json.test(b.type)?g+=h:(r.number.test(b.type)&&(!D||b.sign)?(_=D?"+":"-",h=h.toString().replace(r.sign,"")):_="",A=b.pad_char?b.pad_char==="0"?"0":b.pad_char.charAt(1):" ",C=b.width-(_+h).length,k=b.width&&C>0?A.repeat(C):"",g+=b.align?_+h+k:A==="0"?_+k+h:k+_+h)}return g}var i=Object.create(null);function s(a){if(i[a])return i[a];for(var l=a,f,d=[],h=0;l;){if((f=r.text.exec(l))!==null)d.push(f[0]);else if((f=r.modulo.exec(l))!==null)d.push("%");else if((f=r.placeholder.exec(l))!==null){if(f[2]){h|=1;var g=[],w=f[2],S=[];if((S=r.key.exec(w))!==null)for(g.push(S[1]);(w=w.substring(S[0].length))!=="";)if((S=r.key_access.exec(w))!==null)g.push(S[1]);else if((S=r.index_access.exec(w))!==null)g.push(S[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");f[2]=g}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:f[0],param_no:f[1],keys:f[2],sign:f[3],pad_char:f[4],align:f[5],width:f[6],precision:f[7],type:f[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");l=l.substring(f[0].length)}return i[a]=d}typeof tn<"u"&&(tn.sprintf=t,tn.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var sn=B((Tg,Bc)=>{Bc.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 _c=B((Ag,Rc)=>{Rc.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 $i=B((Ig,Lc)=>{var kh=_c();Lc.exports=r=>async t=>{t=kh(t);let e=C=>{typeof C.return=="function"&&C.return()},n=null,i=null,s=C=>{n=C,i&&i(C),e(t)},a=null,l=!1,f=()=>{l=!0,a&&a()},d=null,h=!1,g=()=>{h=!0,d&&d()},w=null,S=()=>{w&&w()},b=()=>new Promise((C,D)=>{a=w=C,i=D,r.once("drain",S)}),k=()=>(e(t),new Promise((C,D)=>{if(l||h||n)return C();d=a=C,i=D})),A=()=>{r.removeListener("error",s),r.removeListener("close",f),r.removeListener("finish",g),r.removeListener("drain",S)};r.once("error",s),r.once("close",f),r.once("finish",g);try{for await(let C of t){if(!r.writable||r.destroyed||n)break;r.write(C)===!1&&await b()}}catch(C){n||r.destroy(),n=C}try{if(r.writable&&r.end(),await k(),n)throw n}finally{A()}}});var zi=B((Cg,Nc)=>{var Dh=$i(),Bh=sn();Nc.exports=r=>({sink:Dh(r),source:Bh(r)})});var Pc=B((kg,Oc)=>{var Rh=zi();Oc.exports=r=>async function*(t){let e=Rh(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var Mc=B((Dg,Ze)=>{Ze.exports=sn();Ze.exports.source=sn();Ze.exports.sink=$i();Ze.exports.transform=Pc();Ze.exports.duplex=zi()});var Yh={};ft(Yh,{Server:()=>pn,createServer:()=>Xh});var Rn=M(Sn(),1),Vs=M(Os(),1),Hs=M(ce(),1),_n=M(Bn(),1),Ws=M(zs(),1);function Gu(){Hs.default._configure(),Rn.default._configure(Vs.default),_n.default._configure(Ws.default)}Gu();var qs=["uint64","int64","sint64","fixed64","sfixed64"];function $u(r){for(let t of qs){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function Ln(r){return $u(new Rn.default(r))}function zu(r){for(let t of qs){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function Nn(){return zu(_n.default.create())}function $(r,t){let e=Ln(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function z(r,t){let e=Nn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ie;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ie||(Ie={}));function wr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Gt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(s,a){let l=t(s);a.int32(l)},n=function(s){let a=s.int32();return t(a)};return wr("enum",Ie.VARINT,e,n)}function V(r,t){return wr("message",Ie.LENGTH_DELIMITED,r,t)}var wt;(function(r){let t;(function(i){i.IDENTIFY="IDENTIFY",i.CONNECT="CONNECT",i.STREAM_OPEN="STREAM_OPEN",i.STREAM_HANDLER="STREAM_HANDLER",i.DHT="DHT",i.LIST_PEERS="LIST_PEERS",i.CONNMANAGER="CONNMANAGER",i.DISCONNECT="DISCONNECT",i.PUBSUB="PUBSUB",i.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.IDENTIFY=0]="IDENTIFY",i[i.CONNECT=1]="CONNECT",i[i.STREAM_OPEN=2]="STREAM_OPEN",i[i.STREAM_HANDLER=3]="STREAM_HANDLER",i[i.DHT=4]="DHT",i[i.LIST_PEERS=5]="LIST_PEERS",i[i.CONNMANAGER=6]="CONNMANAGER",i[i.DISCONNECT=7]="DISCONNECT",i[i.PUBSUB=8]="PUBSUB",i[i.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.connect!=null&&(s.uint32(18),vr.codec().encode(i.connect,s)),i.streamOpen!=null&&(s.uint32(26),xr.codec().encode(i.streamOpen,s)),i.streamHandler!=null&&(s.uint32(34),Sr.codec().encode(i.streamHandler,s)),i.dht!=null&&(s.uint32(42),Et.codec().encode(i.dht,s)),i.connManager!=null&&(s.uint32(50),Ar.codec().encode(i.connManager,s)),i.disconnect!=null&&(s.uint32(58),Ir.codec().encode(i.disconnect,s)),i.pubsub!=null&&(s.uint32(66),$t.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(74),le.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=vr.codec().decode(i,i.uint32());break;case 3:a.streamOpen=xr.codec().decode(i,i.uint32());break;case 4:a.streamHandler=Sr.codec().decode(i,i.uint32());break;case 5:a.dht=Et.codec().decode(i,i.uint32());break;case 6:a.connManager=Ar.codec().decode(i,i.uint32());break;case 7:a.disconnect=Ir.codec().decode(i,i.uint32());break;case 8:a.pubsub=$t.codec().decode(i,i.uint32());break;case 9:a.peerStore=le.codec().decode(i,i.uint32());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})(wt||(wt={}));var ue;(function(r){let t;(function(i){i.OK="OK",i.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.OK=0]="OK",i[i.ERROR=1]="ERROR"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{if(a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.error!=null&&(s.uint32(18),Tr.codec().encode(i.error,s)),i.streamInfo!=null&&(s.uint32(26),Ce.codec().encode(i.streamInfo,s)),i.identify!=null&&(s.uint32(34),Er.codec().encode(i.identify,s)),i.dht!=null&&(s.uint32(42),X.codec().encode(i.dht,s)),i.peers!=null)for(let l of i.peers)s.uint32(50),Xt.codec().encode(l,s);i.pubsub!=null&&(s.uint32(58),Cr.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(66),kr.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={peers:[]},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=Tr.codec().decode(i,i.uint32());break;case 3:a.streamInfo=Ce.codec().decode(i,i.uint32());break;case 4:a.identify=Er.codec().decode(i,i.uint32());break;case 5:a.dht=X.codec().decode(i,i.uint32());break;case 6:a.peers.push(Xt.codec().decode(i,i.uint32()));break;case 7:a.pubsub=Cr.codec().decode(i,i.uint32());break;case 8:a.peerStore=kr.codec().decode(i,i.uint32());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})(ue||(ue={}));var Er;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Er||(Er={}));var vr;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addrs.push(e.bytes());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(vr||(vr={}));var xr;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.proto.push(e.string());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(xr||(xr={}));var Sr;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={addr:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.addr=e.bytes();break;case 2:i.proto.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Sr||(Sr={}));var Tr;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={msg:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.msg=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Tr||(Tr={}));var Ce;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(18),n.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(n.uint32(26),n.string(e.proto)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addr=e.bytes();break;case 3:i.proto=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Ce||(Ce={}));var Et;(function(r){let t;(function(i){i.FIND_PEER="FIND_PEER",i.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",i.FIND_PROVIDERS="FIND_PROVIDERS",i.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",i.GET_PUBLIC_KEY="GET_PUBLIC_KEY",i.GET_VALUE="GET_VALUE",i.SEARCH_VALUE="SEARCH_VALUE",i.PUT_VALUE="PUT_VALUE",i.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.FIND_PEER=0]="FIND_PEER",i[i.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",i[i.FIND_PROVIDERS=2]="FIND_PROVIDERS",i[i.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",i[i.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",i[i.GET_VALUE=5]="GET_VALUE",i[i.SEARCH_VALUE=6]="SEARCH_VALUE",i[i.PUT_VALUE=7]="PUT_VALUE",i[i.PROVIDE=8]="PROVIDE"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),s.bytes(i.peer)),i.cid!=null&&(s.uint32(26),s.bytes(i.cid)),i.key!=null&&(s.uint32(34),s.bytes(i.key)),i.value!=null&&(s.uint32(42),s.bytes(i.value)),i.count!=null&&(s.uint32(48),s.int32(i.count)),i.timeout!=null&&(s.uint32(56),s.int64(i.timeout)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.cid=i.bytes();break;case 4:a.key=i.bytes();break;case 5:a.value=i.bytes();break;case 6:a.count=i.int32();break;case 7:a.timeout=i.int64();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})(Et||(Et={}));var X;(function(r){let t;(function(i){i.BEGIN="BEGIN",i.VALUE="VALUE",i.END="END"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.BEGIN=0]="BEGIN",i[i.VALUE=1]="VALUE",i[i.END=2]="END"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),Xt.codec().encode(i.peer,s)),i.value!=null&&(s.uint32(26),s.bytes(i.value)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=Xt.codec().decode(i,i.uint32());break;case 3:a.value=i.bytes();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})(X||(X={}));var Xt;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Xt||(Xt={}));var Ar;(function(r){let t;(function(i){i.TAG_PEER="TAG_PEER",i.UNTAG_PEER="UNTAG_PEER",i.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.TAG_PEER=0]="TAG_PEER",i[i.UNTAG_PEER=1]="UNTAG_PEER",i[i.TRIM=2]="TRIM"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),s.bytes(i.peer)),i.tag!=null&&(s.uint32(26),s.string(i.tag)),i.weight!=null&&(s.uint32(32),s.int64(i.weight)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.tag=i.string();break;case 4:a.weight=i.int64();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})(Ar||(Ar={}));var Ir;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Ir||(Ir={}));var $t;(function(r){let t;(function(i){i.GET_TOPICS="GET_TOPICS",i.LIST_PEERS="LIST_PEERS",i.PUBLISH="PUBLISH",i.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.GET_TOPICS=0]="GET_TOPICS",i[i.LIST_PEERS=1]="LIST_PEERS",i[i.PUBLISH=2]="PUBLISH",i[i.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.topic!=null&&(s.uint32(18),s.string(i.topic)),i.data!=null&&(s.uint32(26),s.bytes(i.data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.topic=i.string();break;case 3:a.data=i.bytes();break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})($t||($t={}));var Je;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.from!=null&&(n.uint32(10),n.bytes(e.from)),e.data!=null&&(n.uint32(18),n.bytes(e.data)),e.seqno!=null&&(n.uint32(26),n.bytes(e.seqno)),e.topicIDs!=null)for(let s of e.topicIDs)n.uint32(34),n.string(s);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topicIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.from=e.bytes();break;case 2:i.data=e.bytes();break;case 3:i.seqno=e.bytes();break;case 4:i.topicIDs.push(e.string());break;case 5:i.signature=e.bytes();break;case 6:i.key=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Je||(Je={}));var Cr;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let s of e.topics)n.uint32(10),n.string(s);if(e.peerIDs!=null)for(let s of e.peerIDs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topics:[],peerIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.topics.push(e.string());break;case 2:i.peerIDs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(Cr||(Cr={}));var le;(function(r){let t;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.GET_PROTOCOLS="GET_PROTOCOLS",i.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.GET_PROTOCOLS=1]="GET_PROTOCOLS",i[i.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(i){i.codec=()=>Gt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=V((i,s,a={})=>{if(a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.id!=null&&(s.uint32(18),s.bytes(i.id)),i.protos!=null)for(let l of i.protos)s.uint32(26),s.string(l);a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={protos:[]},l=s==null?i.len:i.pos+s;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.id=i.bytes();break;case 3:a.protos.push(i.string());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>z(i,r.codec()),r.decode=i=>$(i,r.codec())})(le||(le={}));var kr;(function(r){let t;r.codec=()=>(t==null&&(t=V((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),Xt.codec().encode(e.peer,n)),e.protos!=null)for(let s of e.protos)n.uint32(18),n.string(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={protos:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=Xt.codec().decode(e,e.uint32());break;case 2:i.protos.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>z(e,r.codec()),r.decode=e=>$(e,r.codec())})(kr||(kr={}));var pt=M(no(),1);var zn={};ft(zn,{base32:()=>Rt,base32hex:()=>El,base32hexpad:()=>xl,base32hexpadupper:()=>Sl,base32hexupper:()=>vl,base32pad:()=>bl,base32padupper:()=>wl,base32upper:()=>yl,base32z:()=>Tl});function hl(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var s=r.charAt(i),a=s.charCodeAt(0);if(e[a]!==255)throw new TypeError(s+" is ambiguous");e[a]=i}var l=r.length,f=r.charAt(0),d=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);function g(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var k=0,A=0,C=0,D=b.length;C!==D&&b[C]===0;)C++,k++;for(var _=(D-C)*h+1>>>0,G=new Uint8Array(_);C!==D;){for(var rt=b[C],st=0,nt=_-1;(rt!==0||st<A)&&nt!==-1;nt--,st++)rt+=256*G[nt]>>>0,G[nt]=rt%l>>>0,rt=rt/l>>>0;if(rt!==0)throw new Error("Non-zero carry");A=st,C++}for(var ot=_-A;ot!==_&&G[ot]===0;)ot++;for(var Tt=f.repeat(k);ot<_;++ot)Tt+=r.charAt(G[ot]);return Tt}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var k=0;if(b[k]!==" "){for(var A=0,C=0;b[k]===f;)A++,k++;for(var D=(b.length-k)*d+1>>>0,_=new Uint8Array(D);b[k];){var G=e[b.charCodeAt(k)];if(G===255)return;for(var rt=0,st=D-1;(G!==0||rt<C)&&st!==-1;st--,rt++)G+=l*_[st]>>>0,_[st]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");C=rt,k++}if(b[k]!==" "){for(var nt=D-C;nt!==D&&_[nt]===0;)nt++;for(var ot=new Uint8Array(A+(D-nt)),Tt=A;nt!==D;)ot[Tt++]=_[nt++];return ot}}}function S(b){var k=w(b);if(k)return k;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:S}}var pl=hl,dl=pl,io=dl;var Np=new Uint8Array(0);var so=(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},vt=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 oo=r=>new TextEncoder().encode(r),co=r=>new TextDecoder().decode(r);var Un=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")}},Fn=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 uo(this,t)}},Gn=class{constructor(t){this.decoders=t}or(t){return uo(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`)}},uo=(r,t)=>new Gn({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),$n=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Un(t,e,n),this.decoder=new Fn(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},_e=({name:r,prefix:t,encode:e,decode:n})=>new $n(r,t,e,n),Yt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=io(e,t);return _e({prefix:r,name:t,encode:n,decode:s=>vt(i(s))})},ml=(r,t,e,n)=>{let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*e/8|0),l=0,f=0,d=0;for(let h=0;h<s;++h){let g=i[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|g,l+=e,l>=8&&(l-=8,a[d++]=255&f>>l)}if(l>=e||255&f<<8-l)throw new SyntaxError("Unexpected end of data");return a},gl=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,s="",a=0,l=0;for(let f=0;f<r.length;++f)for(l=l<<8|r[f],a+=8;a>e;)a-=e,s+=t[i&l>>a];if(a&&(s+=t[i&l<<e-a]),n)for(;s.length*e&7;)s+="=";return s},P=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>_e({prefix:t,name:r,encode(i){return gl(i,n,e)},decode(i){return ml(i,n,e,r)}});var Rt=P({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yl=P({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bl=P({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wl=P({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),El=P({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vl=P({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xl=P({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sl=P({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tl=P({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vn={};ft(Vn,{base58btc:()=>H,base58flickr:()=>Al});var H=Yt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Al=Yt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Wn={};ft(Wn,{base64:()=>Hn,base64pad:()=>Il,base64url:()=>Cl,base64urlpad:()=>kl});var Hn=P({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Il=P({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cl=P({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kl=P({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});pt.default.formatters.b=r=>r==null?"undefined":H.baseEncode(r);pt.default.formatters.t=r=>r==null?"undefined":Rt.baseEncode(r);pt.default.formatters.m=r=>r==null?"undefined":Hn.baseEncode(r);pt.default.formatters.p=r=>r==null?"undefined":r.toString();pt.default.formatters.c=r=>r==null?"undefined":r.toString();pt.default.formatters.k=r=>r==null?"undefined":r.toString();pt.default.formatters.a=r=>r==null?"undefined":r.toString();function Dl(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 J(r){let t=Dl(`${r}:trace`);return pt.default.enabled(`${r}:trace`)&&pt.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,pt.default)(`${r}:trace`)),Object.assign((0,pt.default)(r),{error:(0,pt.default)(`${r}:error`),trace:t})}function he(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function zt(r=0){return globalThis.Buffer?.alloc!=null?he(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function _t(r=0){return globalThis.Buffer?.allocUnsafe!=null?he(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function xt(r,t){t==null&&(t=r.reduce((i,s)=>i+s.length,0));let e=_t(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return he(e)}function pe(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 fo=Symbol.for("@achingbrain/uint8arraylist");function lo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let i=e+n.byteLength;if(t<i)return{buf:n,index:t-e};e=i}throw new RangeError("index is out of bounds")}function Lr(r){return!!r?.[fo]}var Ot=class r{constructor(...t){Object.defineProperty(this,fo,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Lr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Lr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=lo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=lo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Lr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:i}=this._subList(t,e);return xt(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:xt(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),s=new r;return s.length=i,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],i=0;for(let s=0;s<this.bufs.length;s++){let a=this.bufs[s],l=i,f=l+a.byteLength;if(i=f,t>=f)continue;let d=t>=l&&t<f,h=e>l&&e<=f;if(d&&h){if(t===l&&e===f){n.push(a);break}let g=t-l;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-l));continue}if(h){if(e===f){n.push(a);break}n.push(a.subarray(0,e-l));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Lr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let s=256,a=new Int32Array(s);for(let g=0;g<s;g++)a[g]=-1;for(let g=0;g<i;g++)a[n[g]]=g;let l=a,f=this.byteLength-n.byteLength,d=n.byteLength-1,h;for(let g=e;g<=f;g+=h){h=0;for(let w=d;w>=0;w--){let S=this.get(g+w);if(n[w]!==S){h=Math.max(1,w-l[S]);break}}if(h===0)return g}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=_t(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let i=zt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,e,n),this.write(i,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,e,n),this.write(i,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,e,n),this.write(i,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=_t(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let i=zt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,e,n),this.write(i,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,e,n),this.write(i,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,e,n),this.write(i,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,e,n),this.write(i,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!pe(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((i,s)=>i+s.byteLength,0)),n.length=e,n}};function ho(r){let t=async function*(){let e=yield,n=new Ot;for await(let i of r){if(e==null){n.append(i),e=yield n,n=new Ot;continue}for(n.append(i);n.length>=e;){let s=n.sublist(0,e);if(n.consume(e),e=yield s,e==null){n.length>0&&(e=yield n,n=new Ot);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}function Le(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Nr=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Ne=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Nr(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Nr(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var qn=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function jt(r={}){return Bl(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Bl(r,t){t=t??{};let e=t.onEnd,n=new Ne,i,s,a,l=Le(),f=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((A,C)=>{s=D=>{s=null,n.push(D);try{A(r(n))}catch(_){C(_)}return i}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{l.resolve(),l=Le()})}},d=A=>s!=null?s(A):(n.push(A),i),h=A=>(n=new Ne,s!=null?s({error:A}):(n.push({error:A}),i)),g=A=>{if(a)return i;if(t?.objectMode!==!0&&A?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return d({done:!1,value:A})},w=A=>a?i:(a=!0,A!=null?h(A):d({done:!0})),S=()=>(n=new Ne,w(),{done:!0}),b=A=>(w(A),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:f,return:S,throw:b,push:g,end:w,get readableLength(){return n.size},onEmpty:async A=>{let C=A?.signal;if(C?.throwIfAborted(),n.isEmpty())return;let D,_;C!=null&&(D=new Promise((G,rt)=>{_=()=>{rt(new qn)},C.addEventListener("abort",_)}));try{await Promise.race([l.promise,D])}finally{_!=null&&C!=null&&C?.removeEventListener("abort",_)}}},e==null)return i;let k=i;return i={[Symbol.asyncIterator](){return this},next(){return k.next()},throw(A){return k.throw(A),e!=null&&(e(A),e=void 0),{done:!0}},return(){return k.return(),e!=null&&(e(),e=void 0),{done:!0}},push:g,end(A){return k.end(A),e!=null&&(e(A),e=void 0),i},get readableLength(){return k.readableLength}},i}function po(r){let t=jt(),e=ho(r.source),n=Le(),i,s=r.sink(async function*(){yield*t,yield*await n.promise}());return s.catch(l=>{i=l}),{reader:e,writer:t,stream:{sink:async l=>{if(i!=null){await Promise.reject(i);return}n.resolve(l),await s},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let l=await e.next();if(l.value!=null)return l.value}}}function Or(r){return r instanceof Uint8Array?{get(t){return r[t]},set(t,e){r[t]=e}}:{get(t){return r.get(t)},set(t,e){r.set(t,e)}}}var mo=4294967296,Qe=class r{constructor(t=0,e=0){this.hi=t,this.lo=e}toBigInt(t){if(t===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(t){return Number(this.toBigInt(t))}zzDecode(){let t=-(this.lo&1),e=((this.lo>>>1|this.hi<<31)^t)>>>0,n=(this.hi>>>1^t)>>>0;return new r(n,e)}zzEncode(){let t=this.hi>>31,e=((this.hi<<1|this.lo>>>31)^t)>>>0,n=(this.lo<<1^t)>>>0;return new r(e,n)}toBytes(t,e=0){let n=Or(t);for(;this.hi>0;)n.set(e++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(e++,this.lo&127|128),this.lo=this.lo>>>7;n.set(e++,this.lo)}static fromBigInt(t){if(t===0n)return new r;let e=t<0;e&&(t=-t);let n=Number(t>>32n)|0,i=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,i=~i>>>0,++i>mo&&(i=0,++n>mo&&(n=0))),new r(n,i)}static fromNumber(t){if(t===0)return new r;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(i,n)}static fromBytes(t,e=0){let n=Or(t),i=new r,s=0;if(t.length-e>4){for(;s<4;++s)if(i.lo=(i.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return i;if(i.lo=(i.lo|(n.get(e)&127)<<28)>>>0,i.hi=(i.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return i;s=0}else for(;s<4;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.lo=(i.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return i}if(t.length-e>4){for(;s<5;++s)if(i.hi=(i.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return i}else if(e<t.byteLength)for(;s<5;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.hi=(i.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return i}throw RangeError("invalid varint encoding")}};var Rl=Math.pow(2,7),_l=Math.pow(2,14),Ll=Math.pow(2,21),Nl=Math.pow(2,28),Ol=Math.pow(2,35),Pl=Math.pow(2,42),Ml=Math.pow(2,49),Ul=Math.pow(2,56),Fl=Math.pow(2,63),de={encodingLength(r){return r<Rl?1:r<_l?2:r<Ll?3:r<Nl?4:r<Ol?5:r<Pl?6:r<Ml?7:r<Ul?8:r<Fl?9:10},encode(r,t,e=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return t==null&&(t=_t(de.encodingLength(r))),Qe.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return Qe.fromBytes(r,t).toNumber(!0)}};function Pr(r){return r[Symbol.asyncIterator]!=null}var Mr=r=>{let t=de.encodingLength(r),e=_t(t);return de.encode(r,e),Mr.bytes=t,e};Mr.bytes=0;function Oe(r,t){t=t??{};let e=t.lengthEncoder??Mr;function*n(i){let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return Pr(r)?async function*(){for await(let i of r)yield*n(i)}():function*(){for(let i of r)yield*n(i)}()}Oe.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Mr;return new Ot(e(r.byteLength),r)};var Pe=M(bo(),1);var $l=8,zl=1024*1024*4,me;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(me||(me={}));var Zn=r=>{let t=de.decode(r);return Zn.bytes=de.encodingLength(t),t};Zn.bytes=0;function tr(r,t){let e=new Ot,n=me.LENGTH,i=-1,s=t?.lengthDecoder??Zn,a=t?.maxLengthLength??$l,l=t?.maxDataLength??zl;function*f(){for(;e.byteLength>0;){if(n===me.LENGTH)try{if(i=s(e),i<0)throw(0,Pe.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>l)throw(0,Pe.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=s.bytes;e.consume(d),t?.onLength!=null&&t.onLength(i),n=me.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>a)throw(0,Pe.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===me.DATA){if(e.byteLength<i)break;let d=e.sublist(0,i);e.consume(i),t?.onData!=null&&t.onData(d),yield d,n=me.LENGTH}}}return Pr(r)?async function*(){for await(let d of r)e.append(d),yield*f();if(e.byteLength>0)throw(0,Pe.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)e.append(d),yield*f();if(e.byteLength>0)throw(0,Pe.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}tr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:s,value:a}=await r.next(e);if(s===!0)return;a!=null&&(yield a)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{e=1}}();return tr(n,{...t??{},onLength:s=>{e=s}})};var Kn=J("libp2p:daemon-protocol:stream-handler"),Ur=class{stream;shake;decoder;constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=po(this.stream),this.decoder=tr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Kn("read received no value, closing stream"),await this.close()}write(t){Kn("write message"),this.shake.write(Oe.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Kn("closing the stream"),await this.rest().sink([])}};var Xn={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Me=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"},St=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Eo=Symbol.for("@libp2p/peer-id");var Yn={};ft(Yn,{identity:()=>Vl});var Vl=_e({prefix:"\0",name:"identity",encode:r=>co(r),decode:r=>oo(r)});var jn={};ft(jn,{base2:()=>Hl});var Hl=P({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Jn={};ft(Jn,{base8:()=>Wl});var Wl=P({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Qn={};ft(Qn,{base10:()=>ql});var ql=Yt({prefix:"9",name:"base10",alphabet:"0123456789"});var ti={};ft(ti,{base16:()=>Zl,base16upper:()=>Kl});var Zl=P({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kl=P({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ei={};ft(ei,{base36:()=>Xl,base36upper:()=>Yl});var Xl=Yt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yl=Yt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ri={};ft(ri,{base256emoji:()=>ef});var vo=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}"),jl=vo.reduce((r,t,e)=>(r[e]=t,r),[]),Jl=vo.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ql(r){return r.reduce((t,e)=>(t+=jl[e],t),"")}function tf(r){let t=[];for(let e of r){let n=Jl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ef=_e({prefix:"\u{1F680}",name:"base256emoji",encode:Ql,decode:tf});var ci={};ft(ci,{sha256:()=>Gr,sha512:()=>vf});var oi=M(Ft("crypto"),1);var rf=To,xo=128,nf=127,sf=~nf,of=Math.pow(2,31);function To(r,t,e){t=t||[],e=e||0;for(var n=e;r>=of;)t[e++]=r&255|xo,r/=128;for(;r&sf;)t[e++]=r&255|xo,r>>>=7;return t[e]=r|0,To.bytes=e-n+1,t}var cf=ni,af=128,So=127;function ni(r,n){var e=0,n=n||0,i=0,s=n,a,l=r.length;do{if(s>=l)throw ni.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&So)<<i:(a&So)*Math.pow(2,i),i+=7}while(a>=af);return ni.bytes=s-n,e}var uf=Math.pow(2,7),lf=Math.pow(2,14),ff=Math.pow(2,21),hf=Math.pow(2,28),pf=Math.pow(2,35),df=Math.pow(2,42),mf=Math.pow(2,49),gf=Math.pow(2,56),yf=Math.pow(2,63),bf=function(r){return r<uf?1:r<lf?2:r<ff?3:r<hf?4:r<pf?5:r<df?6:r<mf?7:r<gf?8:r<yf?9:10},wf={encode:rf,decode:cf,encodingLength:bf},Ef=wf,er=Ef;var rr=(r,t=0)=>[er.decode(r,t),er.decode.bytes],Ue=(r,t,e=0)=>(er.encode(r,t,e),t),Fe=r=>er.encodingLength(r);var Jt=(r,t)=>{let e=t.byteLength,n=Fe(r),i=n+Fe(e),s=new Uint8Array(i+e);return Ue(r,s,0),Ue(e,s,n),s.set(t,i),new Ge(r,e,t,s)},ge=r=>{let t=vt(r),[e,n]=rr(t),[i,s]=rr(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new Ge(e,i,a,t)},Ao=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&so(r.bytes,e.bytes)}},Ge=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var si=({name:r,code:t,encode:e})=>new ii(r,t,e),ii=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Jt(this.code,e):e.then(n=>Jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Gr=si({name:"sha2-256",code:18,encode:r=>vt(oi.default.createHash("sha256").update(r).digest())}),vf=si({name:"sha2-512",code:19,encode:r=>vt(oi.default.createHash("sha512").update(r).digest())});var ai={};ft(ai,{identity:()=>$r});var Co=0,xf="identity",ko=vt,Sf=r=>Jt(Co,ko(r)),$r={code:Co,name:xf,encode:ko,digest:Sf};var Qd=new TextEncoder,tm=new TextDecoder;var Do=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Cf(e,ui(r),t||H.encoder);default:return kf(e,ui(r),t||Rt.encoder)}};var Bo=new WeakMap,ui=r=>{let t=Bo.get(r);if(t==null){let e=new Map;return Bo.set(r,e),e}return t},ct=class r{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==nr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Df)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=Jt(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&&Ao(t.multihash,n.multihash)}toString(t){return Do(this,t)}toJSON(){return{"/":Do(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:s,bytes:a}=e;return new r(n,i,s,a||Ro(n,i,s.bytes))}else if(e[Bf]===!0){let{version:n,multihash:i,code:s}=e,a=ge(i);return r.create(n,s,a)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==nr)throw new Error(`Version 0 CID must use dag-pb (code: ${nr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=Ro(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,nr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=vt(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=i.subarray(e.multihashSize-e.digestSize),a=new Ge(e.multihashCode,e.digestSize,s,i);return[e.version===0?r.createV0(a):r.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=rr(t.subarray(e));return e+=w,g},i=n(),s=nr;if(i===18?(i=0,e=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,l=n(),f=n(),d=e+f,h=d-a;return{version:i,codec:s,multihashCode:l,digestSize:f,multihashSize:h,size:d}}static parse(t,e){let[n,i]=If(t,e),s=r.decode(i);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ui(s).set(n,t),s}},If=(r,t)=>{switch(r[0]){case"Q":{let e=t||H;return[H.prefix,e.decode(`${H.prefix}${r}`)]}case H.prefix:{let e=t||H;return[H.prefix,e.decode(r)]}case Rt.prefix:{let e=t||Rt;return[Rt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},Cf=(r,t,e)=>{let{prefix:n}=e;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return i},kf=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let s=e.encode(r);return t.set(n,s),s}else return i},nr=112,Df=18,Ro=(r,t,e)=>{let n=Fe(r),i=n+Fe(t),s=new Uint8Array(i+e.byteLength);return Ue(r,s,0),Ue(t,s,n),s.set(e,i),s},Bf=Symbol.for("@ipld/js-cid/CID");var Qt={...Yn,...jn,...Jn,...Qn,...ti,...zn,...ei,...Vn,...Wn,...ri},lm={...ci,...ai};var Rf=Symbol.for("nodejs.util.inspect.custom"),_o=Object.values(Qt).map(r=>r.decoder).reduce((r,t)=>r.or(t),Qt.identity.decoder),Lo=114,No=36,Oo=37,ir=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Eo]=!0;toString(){return this.string==null&&(this.string=H.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ct.createV1(Lo,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return pe(this.multihash.bytes,t);if(typeof t=="string")return _f(t).equals(this);if(t?.multihash?.bytes!=null)return pe(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Rf](){return`PeerId(${this.toString()})`}},sr=class extends ir{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},or=class extends ir{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},cr=class extends ir{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function _f(r,t){if(t=t??_o,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=ge(H.decode(`z${r}`));return r.startsWith("12D")?new or({multihash:e}):r.startsWith("16U")?new cr({multihash:e}):new sr({multihash:e})}return be(_o.decode(r))}function be(r){try{let t=ge(r);if(t.code===$r.code){if(t.digest.length===No)return new or({multihash:t});if(t.digest.length===Oo)return new cr({multihash:t})}if(t.code===Gr.code)return new sr({multihash:t})}catch{return Lf(ct.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Lf(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Lo)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Gr.code)return new sr({multihash:r.multihash});if(t.code===$r.code){if(t.digest.length===No)return new or({multihash:r.multihash});if(t.digest.length===Oo)return new cr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var $c=M(Ft("net"),1);var Mo=Symbol.for("@libp2p/transport");var Po;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Po||(Po={}));var zr=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};function Fo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Uo=Fo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),li=Fo("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=_t(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Nf={utf8:Uo,"utf-8":Uo,hex:Qt.base16,latin1:li,ascii:li,binary:li,...Qt},Vr=Nf;function at(r,t="utf8"){let e=Vr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var ze=M(pi(),1);var Hr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,i){return this.readAtomically(()=>{let s=0,a=0,l=this.peekChar();if(l===void 0)return;let f=l==="0",d=2**(8*i)-1;for(;;){let h=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(h===void 0)break;if(s*=t,s+=h,s>d||(a+=1,e!==void 0&&a>e))return}if(a!==0)return!n&&f&&a>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let i=n*2;if(n<e.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return e[i]=a[0],e[i+1]=a[1],e[i+2]=a[2],e[i+3]=a[3],[i+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[i,!1];e[i]=s>>8,e[i+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,i]=t(e);if(n===16)return e;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),a=16-(n+2),[l]=t(s.subarray(0,a));return e.set(s.subarray(0,l),16-l),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Nm=new Hr;var zm=parseInt("0xFFFF",16),Vm=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ar(r,t="utf8"){let e=Vr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?he(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var Pt=M(pi(),1);var te=Ft("node:net");function Wr(r){return!!(0,te.isIP)(r)}var jo=te.isIPv4,Qf=te.isIPv6,di=function(r){let t=0;if(r=r.toString().trim(),jo(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Qf(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=jo(e[n]),a;s&&(a=di(e[n]),e[n]=at(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,at(a.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let i=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);i[t++]=s>>8&255,i[t++]=s&255}return i}throw new Error("invalid ip address")},Jo=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let i=[];for(let s=0;s<e;s++)i.push(r[t+s]);return i.join(".")}if(e===16){let i=[];for(let s=0;s<e;s+=2)i.push(n.getUint16(t+s).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var $e={},mi={},eh=[[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"]];eh.forEach(r=>{let t=rh(...r);mi[t.code]=t,$e[t.name]=t});function rh(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:!!n,path:!!i}}function L(r){if(typeof r=="number"){if(mi[r]!=null)return mi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if($e[r]!=null)return $e[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var B0=L("ip4"),R0=L("ip6"),_0=L("ipcidr");function yi(r,t){switch(L(r).code){case 4:case 41:return ih(t);case 42:return ec(t);case 6:case 273:case 33:case 132:return nc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ec(t);case 421:return ah(t);case 444:return rc(t);case 445:return rc(t);case 466:return ch(t);default:return at(t,"base16")}}function bi(r,t){switch(L(r).code){case 4:return Qo(t);case 41:return Qo(t);case 42:return tc(t);case 6:case 273:case 33:case 132:return wi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return tc(t);case 421:return sh(t);case 444:return uh(t);case 445:return lh(t);case 466:return oh(t);default:return ar(t,"base16")}}var gi=Object.values(Qt).map(r=>r.decoder),nh=function(){let r=gi[0].or(gi[1]);return gi.slice(2).forEach(t=>r=r.or(t)),r}();function Qo(r){if(!Wr(r))throw new Error("invalid ip address");return di(r)}function ih(r){let t=Jo(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Wr(t))throw new Error("invalid ip address");return t}function wi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function nc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function tc(r){let t=ar(r),e=Uint8Array.from(Pt.default.encode(t.length));return xt([e,t],e.length+t.length)}function ec(r){let t=Pt.default.decode(r);if(r=r.slice(Pt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return at(r)}function sh(r){let t;r[0]==="Q"||r[0]==="1"?t=ge(H.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(Pt.default.encode(t.length));return xt([e,t],e.length+t.length)}function oh(r){let t=nh.decode(r),e=Uint8Array.from(Pt.default.encode(t.length));return xt([e,t],e.length+t.length)}function ch(r){let t=Pt.default.decode(r),e=r.slice(Pt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+at(e,"base64url")}function ah(r){let t=Pt.default.decode(r),e=r.slice(Pt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return at(e,"base58btc")}function uh(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Rt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=wi(n);return xt([e,i],e.length+i.length)}function lh(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Rt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=wi(n);return xt([e,i],e.length+i.length)}function rc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=at(t,"base32"),i=nc(e);return`${n}:${i}`}function ic(r){r=Ei(r);let t=[],e=[],n=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){let a=i[s],l=L(a);if(l.size===0){t.push([l.code]),e.push([l.code]);continue}if(s++,s>=i.length)throw oc("invalid address: "+r);if(l.path===!0){n=Ei(i.slice(s).join("/")),t.push([l.code,bi(l.code,n)]),e.push([l.code,n]);break}let f=bi(l.code,i[s]);t.push([l.code,f]),e.push([l.code,yi(l.code,f)])}return{string:sc(e),bytes:xi(t),tuples:t,stringTuples:e,path:n}}function vi(r){let t=[],e=[],n=null,i=0;for(;i<r.length;){let s=ze.default.decode(r,i),a=ze.default.decode.bytes??0,l=L(s),f=fh(l,r.slice(i+a));if(f===0){t.push([s]),e.push([s]),i+=a;continue}let d=r.slice(i+a,i+a+f);if(i+=f+a,i>r.length)throw oc("Invalid address Uint8Array: "+at(r,"base16"));t.push([s,d]);let h=yi(s,d);if(e.push([s,h]),l.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:sc(e),tuples:t,stringTuples:e,path:n}}function sc(r){let t=[];return r.map(e=>{let n=L(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Ei(t.join("/"))}function xi(r){return xt(r.map(t=>{let e=L(t[0]),n=Uint8Array.from(ze.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=xt([n,t[1]])),n}))}function fh(r,t){return r.size>0?r.size/8:r.size===0?0:ze.default.decode(t)+(ze.default.decode.bytes??0)}function Ei(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function oc(r){return new Error("Error parsing address: "+r)}var hh=Symbol.for("nodejs.util.inspect.custom"),ph=[L("dns").code,L("dns4").code,L("dns6").code,L("dnsaddr").code],dh=new Map,cc=Symbol.for("@multiformats/js-multiaddr/multiaddr");function mh(r){return!!r?.[cc]}var Si=class r{bytes;#t;#e;#r;#n;[cc]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=vi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=ic(t)}else if(mh(t))e=vi(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,i,s="",a=L("tcp"),l=L("udp"),f=L("ip4"),d=L("ip6"),h=L("dns6"),g=L("ip6zone");for(let[S,b]of this.stringTuples())S===g.code&&(s=`%${b??""}`),ph.includes(S)&&(e=a.name,i=443,n=`${b??""}${s}`,t=S===h.code?6:4),(S===a.code||S===l.code)&&(e=L(S).name,i=parseInt(b??"")),(S===f.code||S===d.code)&&(e=L(S).name,n=`${b??""}${s}`,t=S===d.code?6:4);if(t==null||e==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:i}}protos(){return this.#e.map(([t])=>Object.assign({},L(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>L(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),i=n.lastIndexOf(e);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,i))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(xi(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,i])=>{n===$e.p2p.code&&t.push([n,i]),n===$e["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?at(H.decode(`z${n}`),"base58btc"):at(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return pe(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=dh.get(e.name);if(n==null)throw new zr(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new r(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[hh](){return`Multiaddr(${this.#t})`}};function dt(r){return new Si(r)}var gh=v("dns4"),yh=v("dns6"),bh=v("dnsaddr"),Ee=F(v("dns"),bh,gh,yh),Kr=F(v("ip4"),v("ip6")),re=F(I(Kr,v("tcp")),I(Ee,v("tcp"))),Xr=I(Kr,v("udp")),wh=I(Xr,v("utp")),Eh=I(Xr,v("quic")),vh=I(Xr,v("quic-v1")),Ti=F(I(re,v("ws")),I(Ee,v("ws"))),qr=F(I(Ti,v("p2p")),Ti),Ai=F(I(re,v("wss")),I(Ee,v("wss")),I(re,v("tls"),v("ws")),I(Ee,v("tls"),v("ws"))),Zr=F(I(Ai,v("p2p")),Ai),Ii=F(I(re,v("http")),I(Kr,v("http")),I(Ee,v("http"))),Ci=F(I(re,v("https")),I(Kr,v("https")),I(Ee,v("https"))),ac=I(Xr,v("webrtc-direct"),v("certhash")),fc=F(I(ac,v("p2p")),ac),uc=I(vh,v("webtransport"),v("certhash"),v("certhash")),hc=F(I(uc,v("p2p")),uc),pc=F(I(qr,v("p2p-webrtc-star"),v("p2p")),I(Zr,v("p2p-webrtc-star"),v("p2p")),I(qr,v("p2p-webrtc-star")),I(Zr,v("p2p-webrtc-star"))),tg=F(I(qr,v("p2p-websocket-star"),v("p2p")),I(Zr,v("p2p-websocket-star"),v("p2p")),I(qr,v("p2p-websocket-star")),I(Zr,v("p2p-websocket-star"))),dc=F(I(Ii,v("p2p-webrtc-direct"),v("p2p")),I(Ci,v("p2p-webrtc-direct"),v("p2p")),I(Ii,v("p2p-webrtc-direct")),I(Ci,v("p2p-webrtc-direct"))),ve=F(Ti,Ai,Ii,Ci,pc,dc,re,wh,Eh,Ee,fc,hc),eg=F(I(ve,v("p2p-stardust"),v("p2p")),I(ve,v("p2p-stardust"))),ee=F(I(ve,v("p2p")),pc,dc,fc,hc,v("p2p")),lc=F(I(ee,v("p2p-circuit"),ee),I(ee,v("p2p-circuit")),I(v("p2p-circuit"),ee),I(ve,v("p2p-circuit")),I(v("p2p-circuit"),ve),v("p2p-circuit")),mc=()=>F(I(lc,mc),lc),we=mc(),rg=F(I(we,ee,we),I(ee,we),I(we,ee),we,ee);var ng=F(I(we,v("webrtc"),v("p2p")),I(we,v("webrtc")),I(ve,v("webrtc"),v("p2p")),I(ve,v("webrtc")),v("webrtc"));function gc(r){function t(e){let n;try{n=dt(e)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return t}function I(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(i=>(n=typeof i=="function"?i().partialMatch(e):i.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:gc(t),partialMatch:t}}function F(...r){function t(n){let i=null;return r.some(s=>{let a=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return a!=null?(i=a,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:gc(t),partialMatch:t}}function v(r){let t=r;function e(i){let s;try{s=dt(i)}catch{return!1}let a=s.protoNames();return a.length===1&&a[0]===t}function n(i){return i.length===0?null:i[0]===t?i.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Gc=M(Ft("net"),1);var Yr=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=this.#t.get(t);i==null&&(i=[],this.#t.set(t,i)),i.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let i=this.#t.get(t);i!=null&&(i=i.filter(({callback:s})=>s!==e),this.#t.set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:i})=>!i),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new Ve(t,e))}},ki=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Ve=globalThis.CustomEvent??ki;function jr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Jr(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var He=/^(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,Di=/\/\d{1,2}$/;var Q=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var We=M(Bi(),1),xe=M(ur(),1),mt=class r{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Jr(32),this.isInSubnet=jr,this.address=t;let e=Di.exec(t);if(e){if(this.parsedSubnet=e[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>32)throw new Q("Invalid subnet mask.");t=t.replace(Di,"")}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(He))throw new Q("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],i;for(i=0;i<8;i+=2){let s=e.slice(i,i+2);n.push(parseInt(s,16))}return new r(n.join("."))}static fromInteger(t){return r.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new r(n)}toHex(){return this.parsedAddress.map(t=>(0,xe.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,xe.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,xe.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new We.BigInteger(this.parsedAddress.map(t=>(0,xe.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new We.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new We.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new We.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new We.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,xe.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(He,(0,xe.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 vc={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},Ri={"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"},_i=/([^0-9a-f:/%])/gi,Li=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Ni=/\/\d{1,3}(?=%|$)/,Oi=/%.*$/,xc=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Sc=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Ac=M(ur(),1);function Sh(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function en(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Ac.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,Sh(n)))}var Te=M(ur(),1);function Mi(r){return(0,Te.sprintf)("(%s)",r.join("|"))}function Pi(r){return r.length<4?(0,Te.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ui="[^A-Fa-f0-9:]";function rn(r){let t=[];r.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let e=t.map(n=>r.map((i,s)=>{if(s===n){let a=s===0||s===8-1?":":"";return Mi([Pi(i),a])}return Pi(i)}).join(":"));return e.push(r.map(Pi).join(":")),Mi(e)}function Fi(r,t,e){let n=t?"":":",i=e?"":":",s=[];!t&&!e&&s.push("::"),t&&e&&s.push(""),(e&&!t||!e&&t)&&s.push(":"),s.push((0,Te.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),s.push((0,Te.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),s.push((0,Te.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let l=1;l<r-a;l++)s.push((0,Te.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",l,r-l-a-1));return Mi(s)}var tt=M(Bi(),1),et=M(ur(),1);function nn(r){if(!r)throw new Error("Assertion failed.")}function Th(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function Ah(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 Ih(r,t){let e=[],n=[],i;for(i=0;i<r.length;i++)i<t[0]?e.push(r[i]):i>t[1]&&n.push(r[i]);return e.concat(["compact"]).concat(n)}function Cc(r){return(0,et.sprintf)("%04x",parseInt(r,16))}function kc(r){return r&255}var lr=class r{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=jr,this.isCorrect=Jr(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Ni.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>128)throw new Q("Invalid subnet mask.");t=t.replace(Ni,"")}else if(/\//.test(t))throw new Q("Invalid subnet mask.");let i=Oi.exec(t);i&&(this.zone=i[0],t=t.replace(Oi,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new r(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],i;for(i=0;i<8;i++)n.push(e.slice(i*4,(i+1)*4));return new r(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=Sc.exec(t),i===null)return{error:"failed to parse address with port",address:null,port:null};e=i[1],n=i[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),i=xc.exec(t),i===null)return{error:"failed to parse address from URL",address:null,port:null};e=i[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new r(e),port:n}}static fromAddress4(t){let e=new mt(t),n=128-(32-e.subnetMask);return new r(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new Q("Invalid 'ip6.arpa' form.");let i=e.split(".").reverse();for(let s=n;s>0;s--){let a=s*4;i.splice(a,0,":")}return e=i.join(""),new r(e)}microsoftTranscription(){return(0,et.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),i=e-n;return i<0?"0":Th(new tt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new tt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new tt.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new tt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new tt.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=vc[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(Ri))if(this.isInSubnet(new r(t)))return Ri[t];return"Global unicast"}getBits(t,e){return new tt.BigInteger(this.getBitsBase2(t,e),2)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}getBitsBase16(t,e){let n=e-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,e).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,128)}reverseForm(t){t||(t={});let e=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,e).reverse().join(".");return e>0?t.omitSuffix?n:(0,et.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,i=[];for(t=0;t<this.parsedAddress.length;t++){let l=parseInt(this.parsedAddress[t],16);l===0&&n++,l!==0&&n>0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let s=i.map(l=>l[1]-l[0]+1);if(i.length>0){let l=s.indexOf(Math.max(...s));e=Ih(this.parsedAddress,i[l])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let a=e.join(":");return a=a.replace(/^compact$/,"::"),a=a.replace(/^compact|compact$/,":"),a=a.replace(/compact/,""),a}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),i=e.slice(-1)[0].match(He);if(i){this.parsedAddress4=i[0],this.address4=new mt(this.parsedAddress4);for(let s=0;s<this.address4.groups;s++)if(/^0[0-9]+/.test(this.address4.parsedAddress[s]))throw new Q("IPv4 addresses can't have leading zeroes.",t.replace(He,this.address4.parsedAddress.map(Ah).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(_i);if(e)throw new Q((0,et.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(_i,'<span class="parse-error">$1</span>'));let n=t.match(Li);if(n)throw new Q((0,et.sprintf)("Address failed regex: %s",n.join("")),t.replace(Li,'<span class="parse-error">$1</span>'));let i=[],s=t.split("::");if(s.length===2){let a=s[0].split(":"),l=s[1].split(":");a.length===1&&a[0]===""&&(a=[]),l.length===1&&l[0]===""&&(l=[]);let f=this.groups-(a.length+l.length);if(!f)throw new Q("Error parsing groups");this.elidedGroups=f,this.elisionBegin=a.length,this.elisionEnd=a.length+this.elidedGroups,i=i.concat(a);for(let d=0;d<f;d++)i.push("0");i=i.concat(l)}else if(s.length===1)i=t.split(":"),this.elidedGroups=0;else throw new Q("Too many :: groups found");if(i=i.map(a=>(0,et.sprintf)("%x",parseInt(a,16))),i.length!==this.groups)throw new Q("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(Cc).join(":")}decimal(){return this.parsedAddress.map(t=>(0,et.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new tt.BigInteger(this.parsedAddress.map(Cc).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return mt.fromHex(new tt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new r(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),i="";return/:$/.test(n)||(i=":"),n+i+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new tt.BigInteger("ffff",16)).toString(),n=mt.fromHex(this.getBitsBase16(32,64)),i=mt.fromHex(this.getBits(96,128).xor(new tt.BigInteger("ffffffff",16)).toString(16)),s=this.getBits(64,80),a=this.getBitsBase2(64,80),l=s.testBit(15),f=s.testBit(14),d=s.testBit(8),h=s.testBit(9),g=new tt.BigInteger(a.slice(2,6)+a.slice(8,16),2).toString(10);return{prefix:(0,et.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:a,coneNat:l,microsoft:{reserved:f,universalLocal:h,groupIndividual:d,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=mt.fromHex(this.getBitsBase16(16,48));return{prefix:(0,et.sprintf)("%s",t.slice(0,4)),gateway:e.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new r(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(kc)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(kc))}static fromUnsignedByteArray(t){let e=new tt.BigInteger("256",10),n=new tt.BigInteger("0",10),i=new tt.BigInteger("1",10);for(let s=t.length-1;s>=0;s--)n=n.add(i.multiply(new tt.BigInteger(t[s].toString(10),10))),i=i.multiply(e);return r.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new r("2001::/32"))}is6to4(){return this.isInSubnet(new r("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,et.sprintf)(":%s",t),(0,et.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let e=this.correctForm;return t.v4&&(e=this.to4in6),t.className?(0,et.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,et.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return en(this.address).join(":");nn(typeof this.elidedGroups=="number"),nn(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...en(e)):t.push("");let i=["hover-group"];for(let s=this.elisionBegin;s<this.elisionBegin+this.elidedGroups;s++)i.push((0,et.sprintf)("group-%d",s));return t.push((0,et.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...en(n,this.elisionEnd)):t.push(""),this.is4()&&(nn(this.address4 instanceof mt),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(rn(n.parsedAddress));else if(n.elidedGroups===8)e.push(Fi(8));else{let i=n.address.split("::");i[0].length&&e.push(rn(i[0].split(":"))),nn(typeof n.elidedGroups=="number"),e.push(Fi(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(rn(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ui,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ui,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Ch=J("libp2p:ip-port-to-multiaddr"),Gi={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Dc(r,t){if(typeof r!="string")throw new St(`invalid ip provided: ${r}`,Gi.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new St(`invalid port provided: ${t}`,Gi.ERR_INVALID_PORT_PARAMETER);try{return new mt(r),dt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new lr(r);return e.is4()?dt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):dt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Ch.error(n),new St(n,Gi.ERR_INVALID_IP)}}var Fc=M(Mc(),1);var Vi=M(Ft("os"),1),Uc=M(Ft("path"),1);var _h={ip4:"IPv4",ip6:"IPv6"};function Ke(r,t={}){let e=r.getPath();return e!=null?Vi.default.platform()==="win32"?{path:Uc.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function Hi(r,t,e){let n=i=>dt(`/${r}/${i}/tcp/${e}`);return(Lh(t)?Oh(_h[r]):[t]).map(n)}function Lh(r){return["0.0.0.0","::"].includes(r)}var Nh=Vi.default.networkInterfaces();function Oh(r){let t=[];for(let[,e]of Object.entries(Nh))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Mt=J("libp2p:tcp:socket"),on=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,s=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let a;if(t.remoteAddr!=null)a=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new St("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Dc(r.remoteAddress,r.remotePort)}let l=Ke(a),f=l.path??`${l.host??""}:${l.port??""}`,{sink:d,source:h}=Fc.default.duplex(r);r.setTimeout(i,()=>{Mt("%s socket read timeout",f),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new St("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Mt("%s socket close",f),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Mt("%s socket end",f),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await d(w)}catch(S){S.type!=="aborted"&&Mt(S)}r.end()},source:h,remoteAddr:a,timeline:{open:Date.now()},async close(w={}){if(r.destroyed){Mt("%s socket was already destroyed when trying to close",f);return}w.signal=w.signal??AbortSignal.timeout(s);try{Mt("%s closing socket",f),await new Promise((S,b)=>{r.once("close",()=>{Mt("%s socket closed",f),S()}),r.once("error",k=>{Mt("%s socket error",f,k),g.timeline.close==null&&(g.timeline.close=Date.now()),b(k)}),r.setTimeout(s),r.end(),r.writableLength>0?r.once("drain",()=>{Mt("%s socket drained",f),r.destroy()}):r.destroy()})}catch(S){this.abort(S)}},abort:w=>{Mt("%s socket abort due to error",f,w),r.destroy(w)}};return g};var gt=J("libp2p:tcp:listener");async function Wi(r){try{await r.close()}catch(t){gt.error("an error occurred closing the connection",t)}}var Uh=1,Fh=0,cn=class extends Yr{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Gc.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]:Uh})}this.dispatchEvent(new Ve("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Ve("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Fh}),this.dispatchEvent(new Ve("close"))})}onSocket(t){t.on("error",n=>{gt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=on(t,{listeningAddr:this.status.started?this.status.listeningAddr:void 0,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(n){gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}gt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{gt("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(i=>{gt.error("error attempting to listen server once connection count under limit",i),this.context.closeServerOnMaxConnections?.onListenError?.(i)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new Ve("connection",{detail:n}))}).catch(async n=>{gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Wi(e)}).catch(n=>{gt.error("closing inbound connection failed",n)})}catch(n){gt.error("inbound connection failed",n),Wi(e).catch(i=>{gt.error("closing inbound connection failed",i),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:i}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Hi("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Hi("ip6",e.address,e.port)))}catch(s){gt.error("could not turn %s:%s into multiaddr",e.address,e.port,s)}return t.map(s=>i!=null?s.encapsulate(`/p2p/${i}`):s)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:i}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:Ke(n,{backlog:i})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Wi(t)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let t=this.status.netConfig;await new Promise((e,n)=>{this.server.once("error",n),this.server.listen(t,e)}),gt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(gt("Closing server on %s",this.server.address()),this.server.close())}};var Ht=J("libp2p:tcp"),Zi=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"})})}[Mo]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",l=>{Ht("socket error",l)});let i=on(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{i.close().catch(l=>{Ht.error("Error closing maConn after abort",l)})};e.signal?.addEventListener("abort",s,{once:!0}),Ht("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(Ht("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw a.close().catch(l=>{Ht.error("Error closing conn after abort",l)}),new Me;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Me;return new Promise((n,i)=>{let s=Date.now(),a=Ke(t),l=a.path??`${a.host??""}:${a.port}`;Ht("dialing %j",a);let f=$c.default.connect(a),d=b=>{b.message=`connection error ${l}: ${b.message}`,this.metrics?.dialerEvents.increment({error:!0}),S(b)},h=()=>{Ht("connection timeout %s",l),this.metrics?.dialerEvents.increment({timeout:!0});let b=new St(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");f.emit("error",b)},g=()=>{Ht("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),S()},w=()=>{Ht("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),f.destroy(),S(new Me)},S=b=>{if(f.removeListener("error",d),f.removeListener("timeout",h),f.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),b!=null){i(b);return}n(f)};f.on("error",d),f.on("timeout",h),f.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new cn({...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:re.matches(e.decapsulateCode(421)))}};function zc(r={}){return(t={})=>new Zi(t,r)}function zh(r){return r[Symbol.asyncIterator]!=null}function Vh(...r){let t=[];for(let e of r)zh(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=jt({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let i of n)e.push(i)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var Vc=Vh;function an(r,...t){if(r==null)throw new Error("Empty pipeline");if(Ki(r)){let n=r;r=()=>n.source}else if(Wc(r)||Hc(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Ki(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)Ki(e[n])&&(e[n]=Wh(e[n]));return Hh(...e)}var Hh=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Hc=r=>r?.[Symbol.asyncIterator]!=null,Wc=r=>r?.[Symbol.iterator]!=null,Ki=r=>r==null?!1:r.sink!=null&&r.source!=null,Wh=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=jt({objectMode:!0});e.then(()=>{n.end()},a=>{n.end(a)});let i,s=r.source;if(Hc(s))i=async function*(){yield*s,n.end()};else if(Wc(s))i=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Vc(n,i())}return r.source};function qh(r){return r[Symbol.asyncIterator]!=null}function Zh(r){if(qh(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Xi=Zh;function W(r){return ue.encode({type:ue.Type.OK,peers:[],...r}).subarray()}function O(r){return ue.encode({type:ue.Type.ERROR,error:{msg:r.message},peers:[]}).subarray()}var un=J("libp2p:daemon-server:dht"),ln=class{dht;constructor(t){let{dht:e}=t;this.dht=e}async*provide(t){try{await Xi(this.dht.provide(t)),yield W()}catch(e){un.error(e),yield O(e)}}async*getClosestPeers(t){yield W({dht:{type:X.Type.BEGIN}});for await(let e of this.dht.getClosestPeers(t))e.name==="PEER_RESPONSE"&&(yield*e.closer.map(n=>X.encode({type:X.Type.VALUE,value:n.id.toBytes()})));yield X.encode({type:X.Type.END})}async*getPublicKey(t){yield O(new Error("FIX ME: not implemented"))}async*getValue(t){try{for await(let e of this.dht.get(t))e.name==="VALUE"&&(yield W({dht:{type:X.Type.VALUE,value:e.value}}))}catch(e){un.error(e),yield O(e)}}async*putValue(t,e){try{await Xi(this.dht.put(t,e)),yield W()}catch(n){un.error(n),yield O(n)}}async*findPeer(t){try{for await(let e of this.dht.findPeer(t))e.name==="FINAL_PEER"&&(yield W({dht:{type:X.Type.VALUE,peer:{id:e.peer.id.toBytes(),addrs:e.peer.multiaddrs.map(n=>n.bytes)}}}));throw new Error("Peer not found")}catch(e){un.error(e),yield O(e)}}async*findProviders(t,e){yield W({dht:{type:X.Type.BEGIN}});try{let n=e,i=0;for await(let s of this.dht.findProviders(t))if(s.name==="PEER_RESPONSE"){for(let a of s.providers)i++,yield X.encode({type:X.Type.VALUE,peer:{id:a.id.toBytes(),addrs:(a.multiaddrs??[]).map(l=>l.bytes)}});if(n===i)break}}catch(n){yield O(n)}yield X.encode({type:X.Type.END})}};var fn=J("libp2p:daemon-server:pubsub"),hn=class{pubsub;constructor(t){let{pubsub:e}=t;this.pubsub=e}async*getTopics(){try{yield W({pubsub:{topics:this.pubsub.getTopics(),peerIDs:[]}})}catch(t){fn.error(t),yield O(t)}}async*subscribe(t){try{let e=jt();this.pubsub.subscribe(t),this.pubsub.addEventListener("message",n=>{let i=n.detail;i.topic===t&&(i.type==="signed"?e.push(Je.encode({from:i.from.toBytes(),data:i.data,seqno:i.sequenceNumber==null?void 0:ar(i.sequenceNumber.toString(16).padStart(16,"0"),"base16"),topicIDs:[i.topic],signature:i.signature,key:i.key}).subarray()):e.push(Je.encode({data:i.data,topicIDs:[i.topic]}).subarray()))}),yield W(),yield*e}catch(e){fn.error(e),yield O(e)}}async*publish(t,e){try{await this.pubsub.publish(t,e),yield W()}catch(n){fn.error(n),yield O(n)}}async*listPeers(t){try{yield W({pubsub:{topics:[t],peerIDs:this.pubsub.getSubscribers(t).map(e=>e.toBytes())}})}catch(e){fn.error(e),yield O(e)}}};var Kh=1<<22,Wt=J("libp2p:daemon-server"),pn=class{multiaddr;libp2p;tcp;listener;dhtOperations;pubsubOperations;constructor(t){let{multiaddr:e,libp2pNode:n}=t;this.multiaddr=e,this.libp2p=n,this.tcp=zc()(),this.listener=this.tcp.createListener({handler:this.handleConnection.bind(this),upgrader:Xn}),this._onExit=this._onExit.bind(this),n.services.dht!=null&&(this.dhtOperations=new ln({dht:n.services.dht})),n.services.pubsub!=null&&(this.pubsubOperations=new hn({pubsub:n.services.pubsub}))}async connect(t){if(t.connect==null||t.connect.addrs==null)throw new Error("Invalid request");let e=t.connect.peer,n=t.connect.addrs.map(s=>dt(s)),i=be(e);return await this.libp2p.peerStore.merge(i,{multiaddrs:n}),this.libp2p.dial(i)}async openStream(t){if(t.streamOpen==null||t.streamOpen.proto==null)throw new Error("Invalid request");let{peer:e,proto:n}=t.streamOpen,i=be(e),s=await this.libp2p.dial(i),a=await s.newStream(n,{runOnTransientConnection:!0});return{streamInfo:{peer:i.toBytes(),addr:s.remoteAddr.bytes,proto:a.protocol??""},connection:a}}async registerStreamHandler(t){if(t.streamHandler==null||t.streamHandler.proto==null)throw new Error("Invalid request");let e=t.streamHandler.proto,n=dt(t.streamHandler.addr),i;await this.libp2p.handle(e,({connection:s,stream:a})=>{Promise.resolve().then(async()=>{i=await this.tcp.dial(n,{upgrader:Xn});let l=Ce.encode({peer:s.remotePeer.toBytes(),addr:s.remoteAddr.bytes,proto:a.protocol??""}),f=Oe.single(l);await an(async function*(){yield f,yield*a.source}(),async function*(d){for await(let h of d)yield*h},i,a.sink)}).catch(async l=>{Wt.error(l),i!=null&&await i.close(l)}).finally(()=>{i?.close().catch(l=>{Wt.error(l)})})},{runOnTransientConnection:!0})}_listen(){process.on("SIGTERM",this._onExit),process.on("SIGINT",this._onExit),process.on("SIGHUP",this._onExit)}_onExit(){this.stop({exit:!0}).catch(t=>{Wt.error(t)})}async start(){this._listen(),await this.libp2p.start(),await this.listener.listen(this.multiaddr)}getMultiaddr(){let t=this.listener.getAddrs();if(t.length>0)return t[0];throw new Error("Not started")}async stop(t={exit:!1}){await this.libp2p.stop(),await this.listener.close(),t.exit&&Wt("server closed, exiting"),process.removeListener("SIGTERM",this._onExit),process.removeListener("SIGINT",this._onExit),process.removeListener("SIGHUP",this._onExit)}async*handlePeerStoreRequest(t){try{switch(t.type){case le.Type.GET_PROTOCOLS:if(t.id==null)throw new Error("Invalid request");let e=be(t.id),i=(await this.libp2p.peerStore.get(e)).protocols;yield W({peerStore:{protos:i}});return;case le.Type.GET_PEER_INFO:throw new Error("ERR_NOT_IMPLEMENTED");default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Wt.error(e),yield O(e)}}async*handlePubsubRequest(t){try{if(this.libp2p.services.pubsub==null||this.pubsubOperations==null)throw new Error("PubSub not configured");switch(t.type){case $t.Type.GET_TOPICS:yield*this.pubsubOperations.getTopics();return;case $t.Type.SUBSCRIBE:if(t.topic==null)throw new Error("Invalid request");yield*this.pubsubOperations.subscribe(t.topic);return;case $t.Type.PUBLISH:if(t.topic==null||t.data==null)throw new Error("Invalid request");yield*this.pubsubOperations.publish(t.topic,t.data);return;case $t.Type.LIST_PEERS:if(t.topic==null)throw new Error("Invalid request");yield*this.pubsubOperations.listPeers(t.topic);return;default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Wt.error(e),yield O(e)}}async*handleDHTRequest(t){try{if(this.libp2p.services.dht==null||this.dhtOperations==null)throw new Error("DHT not configured");switch(t.type){case Et.Type.FIND_PEER:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.findPeer(be(t.peer));return;case Et.Type.FIND_PROVIDERS:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.findProviders(ct.decode(t.cid),t.count??20);return;case Et.Type.PROVIDE:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.provide(ct.decode(t.cid));return;case Et.Type.GET_CLOSEST_PEERS:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getClosestPeers(t.key);return;case Et.Type.GET_PUBLIC_KEY:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.getPublicKey(be(t.peer));return;case Et.Type.GET_VALUE:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getValue(t.key);return;case Et.Type.PUT_VALUE:if(t.key==null||t.value==null)throw new Error("Invalid request");yield*this.dhtOperations.putValue(t.key,t.value);return;default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Wt.error(e),yield O(e)}}handleConnection(t){let e=this,n=new Ur({stream:t,maxLength:Kh});an(n.decoder,i=>async function*(){let s;for await(let a of i)try{switch(s=wt.decode(a),s.type){case wt.Type.CONNECT:{try{await e.connect(s)}catch(l){yield O(l);break}yield W();break}case wt.Type.IDENTIFY:{yield W({identify:{id:e.libp2p.peerId.toBytes(),addrs:e.libp2p.getMultiaddrs().map(l=>l.decapsulateCode(L("p2p").code)).map(l=>l.bytes)}});break}case wt.Type.LIST_PEERS:{let l=[],f=new Set;for(let d of e.libp2p.getConnections()){let h=d.remotePeer.toString();f.has(h)||(f.add(h),l.push({id:d.remotePeer.toBytes(),addrs:[d.remoteAddr.bytes]}))}yield W({peers:l});break}case wt.Type.STREAM_OPEN:{let l;try{l=await e.openStream(s)}catch(d){yield O(d);break}yield W({streamInfo:l.streamInfo});let f=n.rest();await an(f,l.connection,async function*(d){for await(let h of d)yield*h},f);return}case wt.Type.STREAM_HANDLER:{try{await e.registerStreamHandler(s)}catch(l){yield O(l);break}yield W();break}case wt.Type.PEERSTORE:{if(s.peerStore==null){yield O(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePeerStoreRequest(s.peerStore);break}case wt.Type.PUBSUB:{if(s.pubsub==null){yield O(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePubsubRequest(s.pubsub);break}case wt.Type.DHT:{if(s.dht==null){yield O(new Error("ERR_INVALID_REQUEST"));break}yield*e.handleDHTRequest(s.dht);break}default:yield O(new Error("ERR_INVALID_REQUEST_TYPE"));break}}catch(l){Wt.error(l),yield O(l);continue}}(),async function(i){for await(let s of i)n.write(s)}).catch(i=>{Wt(i)})}},Xh=(r,t)=>new pn({multiaddr:r,libp2pNode:t});return Ru(Yh);})();
7
7
  return Libp2PDaemonServer}));