@libp2p/daemon-server 5.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +4 -4
- package/dist/src/dht.d.ts +3 -3
- package/dist/src/dht.d.ts.map +1 -1
- package/dist/src/dht.js +3 -2
- package/dist/src/dht.js.map +1 -1
- package/dist/src/index.d.ts +13 -23
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +27 -17
- package/dist/src/index.js.map +1 -1
- package/dist/src/pubsub.d.ts +2 -2
- package/dist/src/pubsub.d.ts.map +1 -1
- package/dist/src/pubsub.js +4 -3
- package/dist/src/pubsub.js.map +1 -1
- package/dist/typedoc-urls.json +11 -0
- package/package.json +16 -25
- package/src/dht.ts +6 -6
- package/src/index.ts +33 -47
- package/src/pubsub.ts +6 -6
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 vh=Object.create;var tn=Object.defineProperty;var Eh=Object.getOwnPropertyDescriptor;var Sh=Object.getOwnPropertyNames;var Ah=Object.getPrototypeOf,Th=Object.prototype.hasOwnProperty;var Rt=(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 P=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),U=(r,t)=>{for(var e in t)tn(r,e,{get:t[e],enumerable:!0})},Xs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sh(t))!Th.call(r,o)&&o!==e&&tn(r,o,{get:()=>t[o],enumerable:!(n=Eh(t,o))||n.enumerable});return r};var G=(r,t,e)=>(e=r!=null?vh(Ah(r)):{},Xs(t||!r||!r.__esModule?tn(e,"default",{value:r,enumerable:!0}):e,r)),Ih=r=>Xs(tn({},"__esModule",{value:!0}),r);var Ks=P((Vg,Ws)=>{"use strict";Ws.exports=Ch;function Ch(r,t){for(var e=new Array(arguments.length-1),n=0,o=2,i=!0;o<arguments.length;)e[n++]=arguments[o++];return new Promise(function(u,l){e[n]=function(h){if(i)if(i=!1,h)l(h);else{for(var b=new Array(arguments.length-1),w=0;w<b.length;)b[w++]=arguments[w];u.apply(null,b)}};try{r.apply(t||null,e)}catch(m){i&&(i=!1,l(m))}})}});var ta=P(Ys=>{"use strict";var en=Ys;en.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 Ue=new Array(64),Qs=new Array(123);for(Ot=0;Ot<64;)Qs[Ue[Ot]=Ot<26?Ot+65:Ot<52?Ot+71:Ot<62?Ot-4:Ot-59|43]=Ot++;var Ot;en.encode=function(t,e,n){for(var o=null,i=[],s=0,u=0,l;e<n;){var m=t[e++];switch(u){case 0:i[s++]=Ue[m>>2],l=(m&3)<<4,u=1;break;case 1:i[s++]=Ue[l|m>>4],l=(m&15)<<2,u=2;break;case 2:i[s++]=Ue[l|m>>6],i[s++]=Ue[m&63],u=0;break}s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0)}return u&&(i[s++]=Ue[l],i[s++]=61,u===1&&(i[s++]=61)),o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))};var Zs="invalid encoding";en.decode=function(t,e,n){for(var o=n,i=0,s,u=0;u<t.length;){var l=t.charCodeAt(u++);if(l===61&&i>1)break;if((l=Qs[l])===void 0)throw Error(Zs);switch(i){case 0:s=l,i=1;break;case 1:e[n++]=s<<2|(l&48)>>4,s=l,i=2;break;case 2:e[n++]=(s&15)<<4|(l&60)>>2,s=l,i=3;break;case 3:e[n++]=(s&3)<<6|l,i=0;break}}if(i===1)throw Error(Zs);return n-o};en.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var ra=P((Gg,ea)=>{"use strict";ea.exports=rn;function rn(){this._listeners={}}rn.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};rn.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],o=0;o<n.length;)n[o].fn===e?n.splice(o,1):++o;return this};rn.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],o=1;o<arguments.length;)n.push(arguments[o++]);for(o=0;o<e.length;)e[o].fn.apply(e[o++].ctx,n)}return this}});var ua=P((Hg,ca)=>{"use strict";ca.exports=na(na);function na(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function o(l,m,h){t[0]=l,m[h]=e[0],m[h+1]=e[1],m[h+2]=e[2],m[h+3]=e[3]}function i(l,m,h){t[0]=l,m[h]=e[3],m[h+1]=e[2],m[h+2]=e[1],m[h+3]=e[0]}r.writeFloatLE=n?o:i,r.writeFloatBE=n?i:o;function s(l,m){return e[0]=l[m],e[1]=l[m+1],e[2]=l[m+2],e[3]=l[m+3],t[0]}function u(l,m){return e[3]=l[m],e[2]=l[m+1],e[1]=l[m+2],e[0]=l[m+3],t[0]}r.readFloatLE=n?s:u,r.readFloatBE=n?u:s}():function(){function t(n,o,i,s){var u=o<0?1:0;if(u&&(o=-o),o===0)n(1/o>0?0:2147483648,i,s);else if(isNaN(o))n(2143289344,i,s);else if(o>34028234663852886e22)n((u<<31|2139095040)>>>0,i,s);else if(o<11754943508222875e-54)n((u<<31|Math.round(o/1401298464324817e-60))>>>0,i,s);else{var l=Math.floor(Math.log(o)/Math.LN2),m=Math.round(o*Math.pow(2,-l)*8388608)&8388607;n((u<<31|l+127<<23|m)>>>0,i,s)}}r.writeFloatLE=t.bind(null,oa),r.writeFloatBE=t.bind(null,ia);function e(n,o,i){var s=n(o,i),u=(s>>31)*2+1,l=s>>>23&255,m=s&8388607;return l===255?m?NaN:u*(1/0):l===0?u*1401298464324817e-60*m:u*Math.pow(2,l-150)*(m+8388608)}r.readFloatLE=e.bind(null,sa),r.readFloatBE=e.bind(null,aa)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function o(l,m,h){t[0]=l,m[h]=e[0],m[h+1]=e[1],m[h+2]=e[2],m[h+3]=e[3],m[h+4]=e[4],m[h+5]=e[5],m[h+6]=e[6],m[h+7]=e[7]}function i(l,m,h){t[0]=l,m[h]=e[7],m[h+1]=e[6],m[h+2]=e[5],m[h+3]=e[4],m[h+4]=e[3],m[h+5]=e[2],m[h+6]=e[1],m[h+7]=e[0]}r.writeDoubleLE=n?o:i,r.writeDoubleBE=n?i:o;function s(l,m){return e[0]=l[m],e[1]=l[m+1],e[2]=l[m+2],e[3]=l[m+3],e[4]=l[m+4],e[5]=l[m+5],e[6]=l[m+6],e[7]=l[m+7],t[0]}function u(l,m){return e[7]=l[m],e[6]=l[m+1],e[5]=l[m+2],e[4]=l[m+3],e[3]=l[m+4],e[2]=l[m+5],e[1]=l[m+6],e[0]=l[m+7],t[0]}r.readDoubleLE=n?s:u,r.readDoubleBE=n?u:s}():function(){function t(n,o,i,s,u,l){var m=s<0?1:0;if(m&&(s=-s),s===0)n(0,u,l+o),n(1/s>0?0:2147483648,u,l+i);else if(isNaN(s))n(0,u,l+o),n(2146959360,u,l+i);else if(s>17976931348623157e292)n(0,u,l+o),n((m<<31|2146435072)>>>0,u,l+i);else{var h;if(s<22250738585072014e-324)h=s/5e-324,n(h>>>0,u,l+o),n((m<<31|h/4294967296)>>>0,u,l+i);else{var b=Math.floor(Math.log(s)/Math.LN2);b===1024&&(b=1023),h=s*Math.pow(2,-b),n(h*4503599627370496>>>0,u,l+o),n((m<<31|b+1023<<20|h*1048576&1048575)>>>0,u,l+i)}}}r.writeDoubleLE=t.bind(null,oa,0,4),r.writeDoubleBE=t.bind(null,ia,4,0);function e(n,o,i,s,u){var l=n(s,u+o),m=n(s,u+i),h=(m>>31)*2+1,b=m>>>20&2047,w=4294967296*(m&1048575)+l;return b===2047?w?NaN:h*(1/0):b===0?h*5e-324*w:h*Math.pow(2,b-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,sa,0,4),r.readDoubleBE=e.bind(null,aa,4,0)}(),r}function oa(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 ia(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 sa(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function aa(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var fa=P((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 ha=P(la=>{"use strict";var uo=la;uo.length=function(t){for(var e=0,n=0,o=0;o<t.length;++o)n=t.charCodeAt(o),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(o+1)&64512)===56320?(++o,e+=4):e+=3;return e};uo.read=function(t,e,n){var o=n-e;if(o<1)return"";for(var i=null,s=[],u=0,l;e<n;)l=t[e++],l<128?s[u++]=l:l>191&&l<224?s[u++]=(l&31)<<6|t[e++]&63:l>239&&l<365?(l=((l&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,s[u++]=55296+(l>>10),s[u++]=56320+(l&1023)):s[u++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,u>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),u=0);return i?(u&&i.push(String.fromCharCode.apply(String,s.slice(0,u))),i.join("")):String.fromCharCode.apply(String,s.slice(0,u))};uo.write=function(t,e,n){for(var o=n,i,s,u=0;u<t.length;++u)i=t.charCodeAt(u),i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=i&63|128):(i&64512)===55296&&((s=t.charCodeAt(u+1))&64512)===56320?(i=65536+((i&1023)<<10)+(s&1023),++u,e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=i&63|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=i&63|128);return n-o}});var da=P((jg,pa)=>{"use strict";pa.exports=Dh;function Dh(r,t,e){var n=e||8192,o=n>>>1,i=null,s=n;return function(l){if(l<1||l>o)return r(l);s+l>n&&(i=r(n),s=0);var m=t.call(i,s,s+=l);return s&7&&(s=(s|7)+1),m}}});var ba=P((Jg,ma)=>{"use strict";ma.exports=et;var Sr=ge();function et(r,t){this.lo=r>>>0,this.hi=t>>>0}var be=et.zero=new et(0,0);be.toNumber=function(){return 0};be.zzEncode=be.zzDecode=function(){return this};be.length=function(){return 1};var kh=et.zeroHash="\0\0\0\0\0\0\0\0";et.fromNumber=function(t){if(t===0)return be;var e=t<0;e&&(t=-t);var n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new et(n,o)};et.from=function(t){if(typeof t=="number")return et.fromNumber(t);if(Sr.isString(t))if(Sr.Long)t=Sr.Long.fromString(t);else return et.fromNumber(parseInt(t,10));return t.low||t.high?new et(t.low>>>0,t.high>>>0):be};et.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};et.prototype.toLong=function(t){return Sr.Long?new Sr.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var ee=String.prototype.charCodeAt;et.fromHash=function(t){return t===kh?be:new et((ee.call(t,0)|ee.call(t,1)<<8|ee.call(t,2)<<16|ee.call(t,3)<<24)>>>0,(ee.call(t,4)|ee.call(t,5)<<8|ee.call(t,6)<<16|ee.call(t,7)<<24)>>>0)};et.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)};et.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};et.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};et.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 ge=P(fo=>{"use strict";var L=fo;L.asPromise=Ks();L.base64=ta();L.EventEmitter=ra();L.float=ua();L.inquire=fa();L.utf8=ha();L.pool=da();L.LongBits=ba();L.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);L.global=L.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||fo;L.emptyArray=Object.freeze?Object.freeze([]):[];L.emptyObject=Object.freeze?Object.freeze({}):{};L.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};L.isString=function(t){return typeof t=="string"||t instanceof String};L.isObject=function(t){return t&&typeof t=="object"};L.isset=L.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};L.Buffer=function(){try{var r=L.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();L._Buffer_from=null;L._Buffer_allocUnsafe=null;L.newBuffer=function(t){return typeof t=="number"?L.Buffer?L._Buffer_allocUnsafe(t):new L.Array(t):L.Buffer?L._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};L.Array=typeof Uint8Array<"u"?Uint8Array:Array;L.Long=L.global.dcodeIO&&L.global.dcodeIO.Long||L.global.Long||L.inquire("long");L.key2Re=/^true|false|0|1$/;L.key32Re=/^-?(?:0|[1-9][0-9]*)$/;L.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;L.longToHash=function(t){return t?L.LongBits.from(t).toHash():L.LongBits.zeroHash};L.longFromHash=function(t,e){var n=L.LongBits.fromHash(t);return L.Long?L.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function ga(r,t,e){for(var n=Object.keys(t),o=0;o<n.length;++o)(r[n[o]]===void 0||!e)&&(r[n[o]]=t[n[o]]);return r}L.merge=ga;L.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function ya(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&&ga(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}L.newError=ya;L.ProtocolError=ya("ProtocolError");L.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var o=Object.keys(this),i=o.length-1;i>-1;--i)if(e[o[i]]===1&&this[o[i]]!==void 0&&this[o[i]]!==null)return o[i]}};L.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};L.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};L._configure=function(){var r=L.Buffer;if(!r){L._Buffer_from=L._Buffer_allocUnsafe=null;return}L._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},L._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var po=P((Wg,Sa)=>{"use strict";Sa.exports=J;var _t=ge(),ho,va=_t.LongBits,Bh=_t.utf8;function Mt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function J(r){this.buf=r,this.pos=0,this.len=r.length}var wa=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new J(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new J(t);throw Error("illegal buffer")},Ea=function(){return _t.Buffer?function(e){return(J.create=function(o){return _t.Buffer.isBuffer(o)?new ho(o):wa(o)})(e)}:wa};J.create=Ea();J.prototype._slice=_t.Array.prototype.subarray||_t.Array.prototype.slice;J.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,Mt(this,10);return t}}();J.prototype.int32=function(){return this.uint32()|0};J.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function lo(){var r=new va(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 Mt(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 Mt(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")}J.prototype.bool=function(){return this.uint32()!==0};function nn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}J.prototype.fixed32=function(){if(this.pos+4>this.len)throw Mt(this,4);return nn(this.buf,this.pos+=4)};J.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Mt(this,4);return nn(this.buf,this.pos+=4)|0};function xa(){if(this.pos+8>this.len)throw Mt(this,8);return new va(nn(this.buf,this.pos+=4),nn(this.buf,this.pos+=4))}J.prototype.float=function(){if(this.pos+4>this.len)throw Mt(this,4);var t=_t.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};J.prototype.double=function(){if(this.pos+8>this.len)throw Mt(this,4);var t=_t.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};J.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Mt(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)};J.prototype.string=function(){var t=this.bytes();return Bh.read(t,0,t.length)};J.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Mt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Mt(this);while(this.buf[this.pos++]&128);return this};J.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};J._configure=function(r){ho=r,J.create=Ea(),ho._configure();var t=_t.Long?"toLong":"toNumber";_t.merge(J.prototype,{int64:function(){return lo.call(this)[t](!1)},uint64:function(){return lo.call(this)[t](!0)},sint64:function(){return lo.call(this).zzDecode()[t](!1)},fixed64:function(){return xa.call(this)[t](!0)},sfixed64:function(){return xa.call(this)[t](!1)}})}});var Ca=P((Kg,Ia)=>{"use strict";Ia.exports=ye;var Ta=po();(ye.prototype=Object.create(Ta.prototype)).constructor=ye;var Aa=ge();function ye(r){Ta.call(this,r)}ye._configure=function(){Aa.Buffer&&(ye.prototype._slice=Aa.Buffer.prototype.slice)};ye.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))};ye._configure()});var vo=P((Zg,Na)=>{"use strict";Na.exports=_;var Et=ge(),mo,on=Et.LongBits,Da=Et.base64,ka=Et.utf8;function Ar(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function go(){}function Nh(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function _(){this.len=0,this.head=new Ar(go,0,0),this.tail=this.head,this.states=null}var Ba=function(){return Et.Buffer?function(){return(_.create=function(){return new mo})()}:function(){return new _}};_.create=Ba();_.alloc=function(t){return new Et.Array(t)};Et.Array!==Array&&(_.alloc=Et.pool(_.alloc,Et.Array.prototype.subarray));_.prototype._push=function(t,e,n){return this.tail=this.tail.next=new Ar(t,e,n),this.len+=e,this};function yo(r,t,e){t[e]=r&255}function Lh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function wo(r,t){this.len=r,this.next=void 0,this.val=t}wo.prototype=Object.create(Ar.prototype);wo.prototype.fn=Lh;_.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new wo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};_.prototype.int32=function(t){return t<0?this._push(xo,10,on.fromNumber(t)):this.uint32(t)};_.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function xo(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}_.prototype.uint64=function(t){var e=on.from(t);return this._push(xo,e.length(),e)};_.prototype.int64=_.prototype.uint64;_.prototype.sint64=function(t){var e=on.from(t).zzEncode();return this._push(xo,e.length(),e)};_.prototype.bool=function(t){return this._push(yo,1,t?1:0)};function bo(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}_.prototype.fixed32=function(t){return this._push(bo,4,t>>>0)};_.prototype.sfixed32=_.prototype.fixed32;_.prototype.fixed64=function(t){var e=on.from(t);return this._push(bo,4,e.lo)._push(bo,4,e.hi)};_.prototype.sfixed64=_.prototype.fixed64;_.prototype.float=function(t){return this._push(Et.float.writeFloatLE,4,t)};_.prototype.double=function(t){return this._push(Et.float.writeDoubleLE,8,t)};var Rh=Et.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var o=0;o<t.length;++o)e[n+o]=t[o]};_.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(yo,1,0);if(Et.isString(t)){var n=_.alloc(e=Da.length(t));Da.decode(t,n,0),t=n}return this.uint32(e)._push(Rh,e,t)};_.prototype.string=function(t){var e=ka.length(t);return e?this.uint32(e)._push(ka.write,e,t):this._push(yo,1,0)};_.prototype.fork=function(){return this.states=new Nh(this),this.head=this.tail=new Ar(go,0,0),this.len=0,this};_.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 Ar(go,0,0),this.len=0),this};_.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};_.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};_._configure=function(r){mo=r,_.create=Ba(),mo._configure()}});var Oa=P((Qg,Ra)=>{"use strict";Ra.exports=Ft;var La=vo();(Ft.prototype=Object.create(La.prototype)).constructor=Ft;var re=ge();function Ft(){La.call(this)}Ft._configure=function(){Ft.alloc=re._Buffer_allocUnsafe,Ft.writeBytesBuffer=re.Buffer&&re.Buffer.prototype instanceof Uint8Array&&re.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var o=0;o<t.length;)e[n++]=t[o++]}};Ft.prototype.bytes=function(t){re.isString(t)&&(t=re._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Ft.writeBytesBuffer,e,t),this};function Oh(r,t,e){r.length<40?re.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Ft.prototype.string=function(t){var e=re.Buffer.byteLength(t);return this.uint32(e),e&&this._push(Oh,e,t),this};Ft._configure()});var za=P((gy,Fa)=>{var Fe=1e3,ze=Fe*60,Ve=ze*60,ve=Ve*24,_h=ve*7,Fh=ve*365.25;Fa.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return zh(r);if(e==="number"&&isFinite(r))return t.long?$h(r):Vh(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function zh(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*Fh;case"weeks":case"week":case"w":return e*_h;case"days":case"day":case"d":return e*ve;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Ve;case"minutes":case"minute":case"mins":case"min":case"m":return e*ze;case"seconds":case"second":case"secs":case"sec":case"s":return e*Fe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Vh(r){var t=Math.abs(r);return t>=ve?Math.round(r/ve)+"d":t>=Ve?Math.round(r/Ve)+"h":t>=ze?Math.round(r/ze)+"m":t>=Fe?Math.round(r/Fe)+"s":r+"ms"}function $h(r){var t=Math.abs(r);return t>=ve?bn(r,t,ve,"day"):t>=Ve?bn(r,t,Ve,"hour"):t>=ze?bn(r,t,ze,"minute"):t>=Fe?bn(r,t,Fe,"second"):r+" ms"}function bn(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var Io=P((yy,Va)=>{function Gh(r){e.debug=e,e.default=e,e.coerce=l,e.disable=i,e.enable=o,e.enabled=s,e.humanize=za(),e.destroy=m,Object.keys(r).forEach(h=>{e[h]=r[h]}),e.names=[],e.skips=[],e.formatters={};function t(h){let b=0;for(let w=0;w<h.length;w++)b=(b<<5)-b+h.charCodeAt(w),b|=0;return e.colors[Math.abs(b)%e.colors.length]}e.selectColor=t;function e(h){let b,w=null,T,p;function y(...E){if(!y.enabled)return;let v=y,S=Number(new Date),I=S-(b||S);v.diff=I,v.prev=b,v.curr=S,b=S,E[0]=e.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let C=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(M,B)=>{if(M==="%%")return"%";C++;let R=e.formatters[B];if(typeof R=="function"){let F=E[C];M=R.call(v,F),E.splice(C,1),C--}return M}),e.formatArgs.call(v,E),(v.log||e.log).apply(v,E)}return y.namespace=h,y.useColors=e.useColors(),y.color=e.selectColor(h),y.extend=n,y.destroy=e.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(T!==e.namespaces&&(T=e.namespaces,p=e.enabled(h)),p),set:E=>{w=E}}),typeof e.init=="function"&&e.init(y),y}function n(h,b){let w=e(this.namespace+(typeof b>"u"?":":b)+h);return w.log=this.log,w}function o(h){e.save(h),e.namespaces=h,e.names=[],e.skips=[];let b,w=(typeof h=="string"?h:"").split(/[\s,]+/),T=w.length;for(b=0;b<T;b++)w[b]&&(h=w[b].replace(/\*/g,".*?"),h[0]==="-"?e.skips.push(new RegExp("^"+h.slice(1)+"$")):e.names.push(new RegExp("^"+h+"$")))}function i(){let h=[...e.names.map(u),...e.skips.map(u).map(b=>"-"+b)].join(",");return e.enable(""),h}function s(h){if(h[h.length-1]==="*")return!0;let b,w;for(b=0,w=e.skips.length;b<w;b++)if(e.skips[b].test(h))return!1;for(b=0,w=e.names.length;b<w;b++)if(e.names[b].test(h))return!0;return!1}function u(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function m(){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}Va.exports=Gh});var $a=P((mt,gn)=>{mt.formatArgs=qh;mt.save=jh;mt.load=Jh;mt.useColors=Hh;mt.storage=Xh();mt.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();mt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Hh(){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 qh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+gn.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}mt.log=console.debug||console.log||(()=>{});function jh(r){try{r?mt.storage.setItem("debug",r):mt.storage.removeItem("debug")}catch{}}function Jh(){let r;try{r=mt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Xh(){try{return localStorage}catch{}}gn.exports=Io()(mt);var{formatters:Wh}=gn.exports;Wh.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Ha=P((wy,Ga)=>{"use strict";Ga.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),o=t.indexOf("--");return n!==-1&&(o===-1?!0:n<o)}});var ja=P((xy,qa)=>{"use strict";var Kh=Rt("os"),Ut=Ha(),ot=process.env,$e;Ut("no-color")||Ut("no-colors")||Ut("color=false")?$e=!1:(Ut("color")||Ut("colors")||Ut("color=true")||Ut("color=always"))&&($e=!0);"FORCE_COLOR"in ot&&($e=ot.FORCE_COLOR.length===0||parseInt(ot.FORCE_COLOR,10)!==0);function Zh(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Qh(r){if($e===!1)return 0;if(Ut("color=16m")||Ut("color=full")||Ut("color=truecolor"))return 3;if(Ut("color=256"))return 2;if(r&&!r.isTTY&&$e!==!0)return 0;let t=$e?1:0;if(process.platform==="win32"){let e=Kh.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 ot)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in ot)||ot.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in ot)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ot.TEAMCITY_VERSION)?1:0;if(ot.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in ot){let e=parseInt((ot.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ot.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ot.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ot.TERM)||"COLORTERM"in ot?1:(ot.TERM==="dumb",t)}function Co(r){let t=Qh(r);return Zh(t)}qa.exports={supportsColor:Co,stdout:Co(process.stdout),stderr:Co(process.stderr)}});var Xa=P((nt,wn)=>{var Yh=Rt("tty"),yn=Rt("util");nt.init=sp;nt.log=np;nt.formatArgs=ep;nt.save=op;nt.load=ip;nt.useColors=tp;nt.destroy=yn.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");nt.colors=[6,2,3,4,5,1];try{let r=ja();r&&(r.stderr||r).level>=2&&(nt.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{}nt.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,i)=>i.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 tp(){return"colors"in nt.inspectOpts?!!nt.inspectOpts.colors:Yh.isatty(process.stderr.fd)}function ep(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),i=` ${o};1m${t} \x1B[0m`;r[0]=i+r[0].split(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+
|
|
5
|
-
`)}function
|
|
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.dht!=null&&(this.dhtOperations=new vn({dht:n.dht})),n.pubsub!=null&&(this.pubsubOperations=new Sn({pubsub:n.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.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.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
|
+
`+i),r.push(o+"m+"+wn.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=rp()+t+" "+r[0]}function rp(){return nt.inspectOpts.hideDate?"":new Date().toISOString()+" "}function np(...r){return process.stderr.write(yn.format(...r)+`
|
|
5
|
+
`)}function op(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function ip(){return process.env.DEBUG}function sp(r){r.inspectOpts={};let t=Object.keys(nt.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=nt.inspectOpts[t[e]]}wn.exports=Io()(nt);var{formatters:Ja}=wn.exports;Ja.o=function(r){return this.inspectOpts.colors=this.useColors,yn.inspect(r,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};Ja.O=function(r){return this.inspectOpts.colors=this.useColors,yn.inspect(r,this.inspectOpts)}});var Wa=P((vy,Do)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Do.exports=$a():Do.exports=Xa()});var fc=P((Bw,uc)=>{"use strict";function cc(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Sp(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 cc(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),cc(new o,e)}}uc.exports=Sp});var gu=P((_1,bu)=>{bu.exports=Pi;var mu=128,T0=127,I0=~T0,C0=Math.pow(2,31);function Pi(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Pi.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=C0;)t[e++]=r&255|mu,r/=128;for(;r&I0;)t[e++]=r&255|mu,r>>>=7;return t[e]=r|0,Pi.bytes=e-n+1,t}});var xu=P((F1,wu)=>{wu.exports=_i;var D0=128,yu=127;function _i(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u||o>49)throw _i.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&yu)<<o:(s&yu)*Math.pow(2,o),o+=7}while(s>=D0);return _i.bytes=i-n,e}});var Eu=P((z1,vu)=>{var k0=Math.pow(2,7),B0=Math.pow(2,14),N0=Math.pow(2,21),L0=Math.pow(2,28),R0=Math.pow(2,35),O0=Math.pow(2,42),M0=Math.pow(2,49),U0=Math.pow(2,56),P0=Math.pow(2,63);vu.exports=function(r){return r<k0?1:r<B0?2:r<N0?3:r<L0?4:r<R0?5:r<O0?6:r<M0?7:r<U0?8:r<P0?9:10}});var Fi=P((V1,Su)=>{Su.exports={encode:gu(),decode:xu(),encodingLength:Eu()}});var ms=P((Hn,Yu)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(a,c,f){a!=null&&(typeof a=="number"?this.fromNumber(a,c,f):c==null&&typeof a!="string"?this.fromString(a,256):this.fromString(a,c))}function o(){return new n(null)}function i(a,c,f,d,g,x){for(;--x>=0;){var A=c*this[a++]+f[d]+g;g=Math.floor(A/67108864),f[d++]=A&67108863}return g}function s(a,c,f,d,g,x){for(var A=c&32767,k=c>>15;--x>=0;){var V=this[a]&32767,tt=this[a++]>>15,vt=k*V+tt*A;V=A*V+((vt&32767)<<15)+f[d]+(g&1073741823),g=(V>>>30)+(vt>>>15)+k*tt+(g>>>30),f[d++]=V&1073741823}return g}function u(a,c,f,d,g,x){for(var A=c&16383,k=c>>14;--x>=0;){var V=this[a]&16383,tt=this[a++]>>14,vt=k*V+tt*A;V=A*V+((vt&16383)<<14)+f[d]+g,g=(V>>28)+(vt>>14)+k*tt,f[d++]=V&268435455}return g}var l=typeof navigator<"u";l&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,r=30):l&&e&&navigator.appName!="Netscape"?(n.prototype.am=i,r=26):(n.prototype.am=u,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var m=52;n.prototype.FV=Math.pow(2,m),n.prototype.F1=m-r,n.prototype.F2=2*r-m;var h="0123456789abcdefghijklmnopqrstuvwxyz",b=new Array,w,T;for(w="0".charCodeAt(0),T=0;T<=9;++T)b[w++]=T;for(w="a".charCodeAt(0),T=10;T<36;++T)b[w++]=T;for(w="A".charCodeAt(0),T=10;T<36;++T)b[w++]=T;function p(a){return h.charAt(a)}function y(a,c){var f=b[a.charCodeAt(c)];return f??-1}function E(a){for(var c=this.t-1;c>=0;--c)a[c]=this[c];a.t=this.t,a.s=this.s}function v(a){this.t=1,this.s=a<0?-1:0,a>0?this[0]=a:a<-1?this[0]=a+this.DV:this.t=0}function S(a){var c=o();return c.fromInt(a),c}function I(a,c){var f;if(c==16)f=4;else if(c==8)f=3;else if(c==256)f=8;else if(c==2)f=1;else if(c==32)f=5;else if(c==4)f=2;else{this.fromRadix(a,c);return}this.t=0,this.s=0;for(var d=a.length,g=!1,x=0;--d>=0;){var A=f==8?a[d]&255:y(a,d);if(A<0){a.charAt(d)=="-"&&(g=!0);continue}g=!1,x==0?this[this.t++]=A:x+f>this.DB?(this[this.t-1]|=(A&(1<<this.DB-x)-1)<<x,this[this.t++]=A>>this.DB-x):this[this.t-1]|=A<<x,x+=f,x>=this.DB&&(x-=this.DB)}f==8&&a[0]&128&&(this.s=-1,x>0&&(this[this.t-1]|=(1<<this.DB-x)-1<<x)),this.clamp(),g&&n.ZERO.subTo(this,this)}function C(){for(var a=this.s&this.DM;this.t>0&&this[this.t-1]==a;)--this.t}function N(a){if(this.s<0)return"-"+this.negate().toString(a);var c;if(a==16)c=4;else if(a==8)c=3;else if(a==2)c=1;else if(a==32)c=5;else if(a==4)c=2;else return this.toRadix(a);var f=(1<<c)-1,d,g=!1,x="",A=this.t,k=this.DB-A*this.DB%c;if(A-- >0)for(k<this.DB&&(d=this[A]>>k)>0&&(g=!0,x=p(d));A>=0;)k<c?(d=(this[A]&(1<<k)-1)<<c-k,d|=this[--A]>>(k+=this.DB-c)):(d=this[A]>>(k-=c)&f,k<=0&&(k+=this.DB,--A)),d>0&&(g=!0),g&&(x+=p(d));return g?x:"0"}function M(){var a=o();return n.ZERO.subTo(this,a),a}function B(){return this.s<0?this.negate():this}function R(a){var c=this.s-a.s;if(c!=0)return c;var f=this.t;if(c=f-a.t,c!=0)return this.s<0?-c:c;for(;--f>=0;)if((c=this[f]-a[f])!=0)return c;return 0}function F(a){var c=1,f;return(f=a>>>16)!=0&&(a=f,c+=16),(f=a>>8)!=0&&(a=f,c+=8),(f=a>>4)!=0&&(a=f,c+=4),(f=a>>2)!=0&&(a=f,c+=2),(f=a>>1)!=0&&(a=f,c+=1),c}function Vf(){return this.t<=0?0:this.DB*(this.t-1)+F(this[this.t-1]^this.s&this.DM)}function $f(a,c){var f;for(f=this.t-1;f>=0;--f)c[f+a]=this[f];for(f=a-1;f>=0;--f)c[f]=0;c.t=this.t+a,c.s=this.s}function Gf(a,c){for(var f=a;f<this.t;++f)c[f-a]=this[f];c.t=Math.max(this.t-a,0),c.s=this.s}function Hf(a,c){var f=a%this.DB,d=this.DB-f,g=(1<<d)-1,x=Math.floor(a/this.DB),A=this.s<<f&this.DM,k;for(k=this.t-1;k>=0;--k)c[k+x+1]=this[k]>>d|A,A=(this[k]&g)<<f;for(k=x-1;k>=0;--k)c[k]=0;c[x]=A,c.t=this.t+x+1,c.s=this.s,c.clamp()}function qf(a,c){c.s=this.s;var f=Math.floor(a/this.DB);if(f>=this.t){c.t=0;return}var d=a%this.DB,g=this.DB-d,x=(1<<d)-1;c[0]=this[f]>>d;for(var A=f+1;A<this.t;++A)c[A-f-1]|=(this[A]&x)<<g,c[A-f]=this[A]>>d;d>0&&(c[this.t-f-1]|=(this.s&x)<<g),c.t=this.t-f,c.clamp()}function jf(a,c){for(var f=0,d=0,g=Math.min(a.t,this.t);f<g;)d+=this[f]-a[f],c[f++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;f<this.t;)d+=this[f],c[f++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;f<a.t;)d-=a[f],c[f++]=d&this.DM,d>>=this.DB;d-=a.s}c.s=d<0?-1:0,d<-1?c[f++]=this.DV+d:d>0&&(c[f++]=d),c.t=f,c.clamp()}function Jf(a,c){var f=this.abs(),d=a.abs(),g=f.t;for(c.t=g+d.t;--g>=0;)c[g]=0;for(g=0;g<d.t;++g)c[g+f.t]=f.am(0,d[g],c,g,0,f.t);c.s=0,c.clamp(),this.s!=a.s&&n.ZERO.subTo(c,c)}function Xf(a){for(var c=this.abs(),f=a.t=2*c.t;--f>=0;)a[f]=0;for(f=0;f<c.t-1;++f){var d=c.am(f,c[f],a,2*f,0,1);(a[f+c.t]+=c.am(f+1,2*c[f],a,2*f+1,d,c.t-f-1))>=c.DV&&(a[f+c.t]-=c.DV,a[f+c.t+1]=1)}a.t>0&&(a[a.t-1]+=c.am(f,c[f],a,2*f,0,1)),a.s=0,a.clamp()}function Wf(a,c,f){var d=a.abs();if(!(d.t<=0)){var g=this.abs();if(g.t<d.t){c?.fromInt(0),f!=null&&this.copyTo(f);return}f==null&&(f=o());var x=o(),A=this.s,k=a.s,V=this.DB-F(d[d.t-1]);V>0?(d.lShiftTo(V,x),g.lShiftTo(V,f)):(d.copyTo(x),g.copyTo(f));var tt=x.t,vt=x[tt-1];if(vt!=0){var dt=vt*(1<<this.F1)+(tt>1?x[tt-2]>>this.F2:0),qt=this.FV/dt,Qr=(1<<this.F1)/dt,Nt=1<<this.F2,Lt=f.t,Yr=Lt-tt,te=c??o();for(x.dlShiftTo(Yr,te),f.compareTo(te)>=0&&(f[f.t++]=1,f.subTo(te,f)),n.ONE.dlShiftTo(tt,te),te.subTo(x,x);x.t<tt;)x[x.t++]=0;for(;--Yr>=0;){var co=f[--Lt]==vt?this.DM:Math.floor(f[Lt]*qt+(f[Lt-1]+Nt)*Qr);if((f[Lt]+=x.am(0,co,f,Yr,0,tt))<co)for(x.dlShiftTo(Yr,te),f.subTo(te,f);f[Lt]<--co;)f.subTo(te,f)}c!=null&&(f.drShiftTo(tt,c),A!=k&&n.ZERO.subTo(c,c)),f.t=tt,f.clamp(),V>0&&f.rShiftTo(V,f),A<0&&n.ZERO.subTo(f,f)}}}function Kf(a){var c=o();return this.abs().divRemTo(a,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&a.subTo(c,c),c}function pe(a){this.m=a}function Zf(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function Qf(a){return a}function Yf(a){a.divRemTo(this.m,null,a)}function tl(a,c,f){a.multiplyTo(c,f),this.reduce(f)}function el(a,c){a.squareTo(c),this.reduce(c)}pe.prototype.convert=Zf,pe.prototype.revert=Qf,pe.prototype.reduce=Yf,pe.prototype.mulTo=tl,pe.prototype.sqrTo=el;function rl(){if(this.t<1)return 0;var a=this[0];if(!(a&1))return 0;var c=a&3;return c=c*(2-(a&15)*c)&15,c=c*(2-(a&255)*c)&255,c=c*(2-((a&65535)*c&65535))&65535,c=c*(2-a*c%this.DV)%this.DV,c>0?this.DV-c:-c}function de(a){this.m=a,this.mp=a.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<a.DB-15)-1,this.mt2=2*a.t}function nl(a){var c=o();return a.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),a.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function ol(a){var c=o();return a.copyTo(c),this.reduce(c),c}function il(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var c=0;c<this.m.t;++c){var f=a[c]&32767,d=f*this.mpl+((f*this.mph+(a[c]>>15)*this.mpl&this.um)<<15)&a.DM;for(f=c+this.m.t,a[f]+=this.m.am(0,d,a,c,0,this.m.t);a[f]>=a.DV;)a[f]-=a.DV,a[++f]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function sl(a,c){a.squareTo(c),this.reduce(c)}function al(a,c,f){a.multiplyTo(c,f),this.reduce(f)}de.prototype.convert=nl,de.prototype.revert=ol,de.prototype.reduce=il,de.prototype.mulTo=al,de.prototype.sqrTo=sl;function cl(){return(this.t>0?this[0]&1:this.s)==0}function ul(a,c){if(a>4294967295||a<1)return n.ONE;var f=o(),d=o(),g=c.convert(this),x=F(a)-1;for(g.copyTo(f);--x>=0;)if(c.sqrTo(f,d),(a&1<<x)>0)c.mulTo(d,g,f);else{var A=f;f=d,d=A}return c.revert(f)}function fl(a,c){var f;return a<256||c.isEven()?f=new pe(c):f=new de(c),this.exp(a,f)}n.prototype.copyTo=E,n.prototype.fromInt=v,n.prototype.fromString=I,n.prototype.clamp=C,n.prototype.dlShiftTo=$f,n.prototype.drShiftTo=Gf,n.prototype.lShiftTo=Hf,n.prototype.rShiftTo=qf,n.prototype.subTo=jf,n.prototype.multiplyTo=Jf,n.prototype.squareTo=Xf,n.prototype.divRemTo=Wf,n.prototype.invDigit=rl,n.prototype.isEven=cl,n.prototype.exp=ul,n.prototype.toString=N,n.prototype.negate=M,n.prototype.abs=B,n.prototype.compareTo=R,n.prototype.bitLength=Vf,n.prototype.mod=Kf,n.prototype.modPowInt=fl,n.ZERO=S(0),n.ONE=S(1);function ll(){var a=o();return this.copyTo(a),a}function hl(){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 pl(){return this.t==0?this.s:this[0]<<24>>24}function dl(){return this.t==0?this.s:this[0]<<16>>16}function ml(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bl(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function gl(a){if(a==null&&(a=10),this.signum()==0||a<2||a>36)return"0";var c=this.chunkSize(a),f=Math.pow(a,c),d=S(f),g=o(),x=o(),A="";for(this.divRemTo(d,g,x);g.signum()>0;)A=(f+x.intValue()).toString(a).substr(1)+A,g.divRemTo(d,g,x);return x.intValue().toString(a)+A}function yl(a,c){this.fromInt(0),c==null&&(c=10);for(var f=this.chunkSize(c),d=Math.pow(c,f),g=!1,x=0,A=0,k=0;k<a.length;++k){var V=y(a,k);if(V<0){a.charAt(k)=="-"&&this.signum()==0&&(g=!0);continue}A=c*A+V,++x>=f&&(this.dMultiply(d),this.dAddOffset(A,0),x=0,A=0)}x>0&&(this.dMultiply(Math.pow(c,x)),this.dAddOffset(A,0)),g&&n.ZERO.subTo(this,this)}function wl(a,c,f){if(typeof c=="number")if(a<2)this.fromInt(1);else for(this.fromNumber(a,f),this.testBit(a-1)||this.bitwiseTo(n.ONE.shiftLeft(a-1),oo,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(n.ONE.shiftLeft(a-1),this);else{var d=new Array,g=a&7;d.length=(a>>3)+1,c.nextBytes(d),g>0?d[0]&=(1<<g)-1:d[0]=0,this.fromString(d,256)}}function xl(){var a=this.t,c=new Array;c[0]=this.s;var f=this.DB-a*this.DB%8,d,g=0;if(a-- >0)for(f<this.DB&&(d=this[a]>>f)!=(this.s&this.DM)>>f&&(c[g++]=d|this.s<<this.DB-f);a>=0;)f<8?(d=(this[a]&(1<<f)-1)<<8-f,d|=this[--a]>>(f+=this.DB-8)):(d=this[a]>>(f-=8)&255,f<=0&&(f+=this.DB,--a)),d&128&&(d|=-256),g==0&&(this.s&128)!=(d&128)&&++g,(g>0||d!=this.s)&&(c[g++]=d);return c}function vl(a){return this.compareTo(a)==0}function El(a){return this.compareTo(a)<0?this:a}function Sl(a){return this.compareTo(a)>0?this:a}function Al(a,c,f){var d,g,x=Math.min(a.t,this.t);for(d=0;d<x;++d)f[d]=c(this[d],a[d]);if(a.t<this.t){for(g=a.s&this.DM,d=x;d<this.t;++d)f[d]=c(this[d],g);f.t=this.t}else{for(g=this.s&this.DM,d=x;d<a.t;++d)f[d]=c(g,a[d]);f.t=a.t}f.s=c(this.s,a.s),f.clamp()}function Tl(a,c){return a&c}function Il(a){var c=o();return this.bitwiseTo(a,Tl,c),c}function oo(a,c){return a|c}function Cl(a){var c=o();return this.bitwiseTo(a,oo,c),c}function $s(a,c){return a^c}function Dl(a){var c=o();return this.bitwiseTo(a,$s,c),c}function Gs(a,c){return a&~c}function kl(a){var c=o();return this.bitwiseTo(a,Gs,c),c}function Bl(){for(var a=o(),c=0;c<this.t;++c)a[c]=this.DM&~this[c];return a.t=this.t,a.s=~this.s,a}function Nl(a){var c=o();return a<0?this.rShiftTo(-a,c):this.lShiftTo(a,c),c}function Ll(a){var c=o();return a<0?this.lShiftTo(-a,c):this.rShiftTo(a,c),c}function Rl(a){if(a==0)return-1;var c=0;return a&65535||(a>>=16,c+=16),a&255||(a>>=8,c+=8),a&15||(a>>=4,c+=4),a&3||(a>>=2,c+=2),a&1||++c,c}function Ol(){for(var a=0;a<this.t;++a)if(this[a]!=0)return a*this.DB+Rl(this[a]);return this.s<0?this.t*this.DB:-1}function Ml(a){for(var c=0;a!=0;)a&=a-1,++c;return c}function Ul(){for(var a=0,c=this.s&this.DM,f=0;f<this.t;++f)a+=Ml(this[f]^c);return a}function Pl(a){var c=Math.floor(a/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<a%this.DB)!=0}function _l(a,c){var f=n.ONE.shiftLeft(a);return this.bitwiseTo(f,c,f),f}function Fl(a){return this.changeBit(a,oo)}function zl(a){return this.changeBit(a,Gs)}function Vl(a){return this.changeBit(a,$s)}function $l(a,c){for(var f=0,d=0,g=Math.min(a.t,this.t);f<g;)d+=this[f]+a[f],c[f++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;f<this.t;)d+=this[f],c[f++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;f<a.t;)d+=a[f],c[f++]=d&this.DM,d>>=this.DB;d+=a.s}c.s=d<0?-1:0,d>0?c[f++]=d:d<-1&&(c[f++]=this.DV+d),c.t=f,c.clamp()}function Gl(a){var c=o();return this.addTo(a,c),c}function Hl(a){var c=o();return this.subTo(a,c),c}function ql(a){var c=o();return this.multiplyTo(a,c),c}function jl(){var a=o();return this.squareTo(a),a}function Jl(a){var c=o();return this.divRemTo(a,c,null),c}function Xl(a){var c=o();return this.divRemTo(a,null,c),c}function Wl(a){var c=o(),f=o();return this.divRemTo(a,c,f),new Array(c,f)}function Kl(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()}function Zl(a,c){if(a!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=a;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function Er(){}function Hs(a){return a}function Ql(a,c,f){a.multiplyTo(c,f)}function Yl(a,c){a.squareTo(c)}Er.prototype.convert=Hs,Er.prototype.revert=Hs,Er.prototype.mulTo=Ql,Er.prototype.sqrTo=Yl;function th(a){return this.exp(a,new Er)}function eh(a,c,f){var d=Math.min(this.t+a.t,c);for(f.s=0,f.t=d;d>0;)f[--d]=0;var g;for(g=f.t-this.t;d<g;++d)f[d+this.t]=this.am(0,a[d],f,d,0,this.t);for(g=Math.min(a.t,c);d<g;++d)this.am(0,a[d],f,d,0,c-d);f.clamp()}function rh(a,c,f){--c;var d=f.t=this.t+a.t-c;for(f.s=0;--d>=0;)f[d]=0;for(d=Math.max(c-this.t,0);d<a.t;++d)f[this.t+d-c]=this.am(c-d,a[d],f,0,0,this.t+d-c);f.clamp(),f.drShiftTo(1,f)}function me(a){this.r2=o(),this.q3=o(),n.ONE.dlShiftTo(2*a.t,this.r2),this.mu=this.r2.divide(a),this.m=a}function nh(a){if(a.s<0||a.t>2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var c=o();return a.copyTo(c),this.reduce(c),c}function oh(a){return a}function ih(a){for(a.drShiftTo(this.m.t-1,this.r2),a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);a.compareTo(this.r2)<0;)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);a.compareTo(this.m)>=0;)a.subTo(this.m,a)}function sh(a,c){a.squareTo(c),this.reduce(c)}function ah(a,c,f){a.multiplyTo(c,f),this.reduce(f)}me.prototype.convert=nh,me.prototype.revert=oh,me.prototype.reduce=ih,me.prototype.mulTo=ah,me.prototype.sqrTo=sh;function ch(a,c){var f=a.bitLength(),d,g=S(1),x;if(f<=0)return g;f<18?d=1:f<48?d=3:f<144?d=4:f<768?d=5:d=6,f<8?x=new pe(c):c.isEven()?x=new me(c):x=new de(c);var A=new Array,k=3,V=d-1,tt=(1<<d)-1;if(A[1]=x.convert(this),d>1){var vt=o();for(x.sqrTo(A[1],vt);k<=tt;)A[k]=o(),x.mulTo(vt,A[k-2],A[k]),k+=2}var dt=a.t-1,qt,Qr=!0,Nt=o(),Lt;for(f=F(a[dt])-1;dt>=0;){for(f>=V?qt=a[dt]>>f-V&tt:(qt=(a[dt]&(1<<f+1)-1)<<V-f,dt>0&&(qt|=a[dt-1]>>this.DB+f-V)),k=d;!(qt&1);)qt>>=1,--k;if((f-=k)<0&&(f+=this.DB,--dt),Qr)A[qt].copyTo(g),Qr=!1;else{for(;k>1;)x.sqrTo(g,Nt),x.sqrTo(Nt,g),k-=2;k>0?x.sqrTo(g,Nt):(Lt=g,g=Nt,Nt=Lt),x.mulTo(Nt,A[qt],g)}for(;dt>=0&&!(a[dt]&1<<f);)x.sqrTo(g,Nt),Lt=g,g=Nt,Nt=Lt,--f<0&&(f=this.DB-1,--dt)}return x.revert(g)}function uh(a){var c=this.s<0?this.negate():this.clone(),f=a.s<0?a.negate():a.clone();if(c.compareTo(f)<0){var d=c;c=f,f=d}var g=c.getLowestSetBit(),x=f.getLowestSetBit();if(x<0)return c;for(g<x&&(x=g),x>0&&(c.rShiftTo(x,c),f.rShiftTo(x,f));c.signum()>0;)(g=c.getLowestSetBit())>0&&c.rShiftTo(g,c),(g=f.getLowestSetBit())>0&&f.rShiftTo(g,f),c.compareTo(f)>=0?(c.subTo(f,c),c.rShiftTo(1,c)):(f.subTo(c,f),f.rShiftTo(1,f));return x>0&&f.lShiftTo(x,f),f}function fh(a){if(a<=0)return 0;var c=this.DV%a,f=this.s<0?a-1:0;if(this.t>0)if(c==0)f=this[0]%a;else for(var d=this.t-1;d>=0;--d)f=(c*f+this[d])%a;return f}function lh(a){var c=a.isEven();if(this.isEven()&&c||a.signum()==0)return n.ZERO;for(var f=a.clone(),d=this.clone(),g=S(1),x=S(0),A=S(0),k=S(1);f.signum()!=0;){for(;f.isEven();)f.rShiftTo(1,f),c?((!g.isEven()||!x.isEven())&&(g.addTo(this,g),x.subTo(a,x)),g.rShiftTo(1,g)):x.isEven()||x.subTo(a,x),x.rShiftTo(1,x);for(;d.isEven();)d.rShiftTo(1,d),c?((!A.isEven()||!k.isEven())&&(A.addTo(this,A),k.subTo(a,k)),A.rShiftTo(1,A)):k.isEven()||k.subTo(a,k),k.rShiftTo(1,k);f.compareTo(d)>=0?(f.subTo(d,f),c&&g.subTo(A,g),x.subTo(k,x)):(d.subTo(f,d),c&&A.subTo(g,A),k.subTo(x,k))}if(d.compareTo(n.ONE)!=0)return n.ZERO;if(k.compareTo(a)>=0)return k.subtract(a);if(k.signum()<0)k.addTo(a,k);else return k;return k.signum()<0?k.add(a):k}var ut=[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],hh=(1<<26)/ut[ut.length-1];function ph(a){var c,f=this.abs();if(f.t==1&&f[0]<=ut[ut.length-1]){for(c=0;c<ut.length;++c)if(f[0]==ut[c])return!0;return!1}if(f.isEven())return!1;for(c=1;c<ut.length;){for(var d=ut[c],g=c+1;g<ut.length&&d<hh;)d*=ut[g++];for(d=f.modInt(d);c<g;)if(d%ut[c++]==0)return!1}return f.millerRabin(a)}function dh(a){var c=this.subtract(n.ONE),f=c.getLowestSetBit();if(f<=0)return!1;var d=c.shiftRight(f);a=a+1>>1,a>ut.length&&(a=ut.length);for(var g=o(),x=0;x<a;++x){g.fromInt(ut[Math.floor(Math.random()*ut.length)]);var A=g.modPow(d,this);if(A.compareTo(n.ONE)!=0&&A.compareTo(c)!=0){for(var k=1;k++<f&&A.compareTo(c)!=0;)if(A=A.modPowInt(2,this),A.compareTo(n.ONE)==0)return!1;if(A.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=ml,n.prototype.toRadix=gl,n.prototype.fromRadix=yl,n.prototype.fromNumber=wl,n.prototype.bitwiseTo=Al,n.prototype.changeBit=_l,n.prototype.addTo=$l,n.prototype.dMultiply=Kl,n.prototype.dAddOffset=Zl,n.prototype.multiplyLowerTo=eh,n.prototype.multiplyUpperTo=rh,n.prototype.modInt=fh,n.prototype.millerRabin=dh,n.prototype.clone=ll,n.prototype.intValue=hl,n.prototype.byteValue=pl,n.prototype.shortValue=dl,n.prototype.signum=bl,n.prototype.toByteArray=xl,n.prototype.equals=vl,n.prototype.min=El,n.prototype.max=Sl,n.prototype.and=Il,n.prototype.or=Cl,n.prototype.xor=Dl,n.prototype.andNot=kl,n.prototype.not=Bl,n.prototype.shiftLeft=Nl,n.prototype.shiftRight=Ll,n.prototype.getLowestSetBit=Ol,n.prototype.bitCount=Ul,n.prototype.testBit=Pl,n.prototype.setBit=Fl,n.prototype.clearBit=zl,n.prototype.flipBit=Vl,n.prototype.add=Gl,n.prototype.subtract=Hl,n.prototype.multiply=ql,n.prototype.divide=Jl,n.prototype.remainder=Xl,n.prototype.divideAndRemainder=Wl,n.prototype.modPow=ch,n.prototype.modInverse=lh,n.prototype.pow=th,n.prototype.gcd=uh,n.prototype.isProbablePrime=ph,n.prototype.square=jl,n.prototype.Barrett=me;var Zr,pt,Y;function mh(a){pt[Y++]^=a&255,pt[Y++]^=a>>8&255,pt[Y++]^=a>>16&255,pt[Y++]^=a>>24&255,Y>=ao&&(Y-=ao)}function qs(){mh(new Date().getTime())}if(pt==null){pt=new Array,Y=0;var Bt;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var js=new Uint8Array(32);for(window.crypto.getRandomValues(js),Bt=0;Bt<32;++Bt)pt[Y++]=js[Bt]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var Js=window.crypto.random(32);for(Bt=0;Bt<Js.length;++Bt)pt[Y++]=Js.charCodeAt(Bt)&255}}for(;Y<ao;)Bt=Math.floor(65536*Math.random()),pt[Y++]=Bt>>>8,pt[Y++]=Bt&255;Y=0,qs()}function bh(){if(Zr==null){for(qs(),Zr=xh(),Zr.init(pt),Y=0;Y<pt.length;++Y)pt[Y]=0;Y=0}return Zr.next()}function gh(a){var c;for(c=0;c<a.length;++c)a[c]=bh()}function io(){}io.prototype.nextBytes=gh;function so(){this.i=0,this.j=0,this.S=new Array}function yh(a){var c,f,d;for(c=0;c<256;++c)this.S[c]=c;for(f=0,c=0;c<256;++c)f=f+this.S[c]+a[c%a.length]&255,d=this.S[c],this.S[c]=this.S[f],this.S[f]=d;this.i=0,this.j=0}function wh(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}so.prototype.init=yh,so.prototype.next=wh;function xh(){return new so}var ao=256;typeof Hn<"u"?Hn=Yu.exports={default:n,BigInteger:n,SecureRandom:io}:this.jsbn={BigInteger:n,SecureRandom:io}}).call(Hn)});var Hr=P(qn=>{(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(s){return n(i(s),arguments)}function e(s,u){return t.apply(null,[s].concat(u||[]))}function n(s,u){var l=1,m=s.length,h,b="",w,T,p,y,E,v,S,I;for(w=0;w<m;w++)if(typeof s[w]=="string")b+=s[w];else if(typeof s[w]=="object"){if(p=s[w],p.keys)for(h=u[l],T=0;T<p.keys.length;T++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',p.keys[T],p.keys[T-1]));h=h[p.keys[T]]}else p.param_no?h=u[p.param_no]:h=u[l++];if(r.not_type.test(p.type)&&r.not_primitive.test(p.type)&&h instanceof Function&&(h=h()),r.numeric_arg.test(p.type)&&typeof h!="number"&&isNaN(h))throw new TypeError(t("[sprintf] expecting number but found %T",h));switch(r.number.test(p.type)&&(S=h>=0),p.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,p.width?parseInt(p.width):0);break;case"e":h=p.precision?parseFloat(h).toExponential(p.precision):parseFloat(h).toExponential();break;case"f":h=p.precision?parseFloat(h).toFixed(p.precision):parseFloat(h);break;case"g":h=p.precision?String(Number(h.toPrecision(p.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=p.precision?h.substring(0,p.precision):h;break;case"t":h=String(!!h),h=p.precision?h.substring(0,p.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=p.precision?h.substring(0,p.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=p.precision?h.substring(0,p.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(p.type)?b+=h:(r.number.test(p.type)&&(!S||p.sign)?(I=S?"+":"-",h=h.toString().replace(r.sign,"")):I="",E=p.pad_char?p.pad_char==="0"?"0":p.pad_char.charAt(1):" ",v=p.width-(I+h).length,y=p.width&&v>0?E.repeat(v):"",b+=p.align?I+h+y:E==="0"?I+y+h:y+I+h)}return b}var o=Object.create(null);function i(s){if(o[s])return o[s];for(var u=s,l,m=[],h=0;u;){if((l=r.text.exec(u))!==null)m.push(l[0]);else if((l=r.modulo.exec(u))!==null)m.push("%");else if((l=r.placeholder.exec(u))!==null){if(l[2]){h|=1;var b=[],w=l[2],T=[];if((T=r.key.exec(w))!==null)for(b.push(T[1]);(w=w.substring(T[0].length))!=="";)if((T=r.key_access.exec(w))!==null)b.push(T[1]);else if((T=r.index_access.exec(w))!==null)b.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");l[2]=b}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");m.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");u=u.substring(l[0].length)}return o[s]=m}typeof qn<"u"&&(qn.sprintf=t,qn.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var Wn=P((eE,lf)=>{lf.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 pf=P((rE,hf)=>{hf.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 Is=P((nE,df)=>{var $b=pf();df.exports=r=>async t=>{t=$b(t);let e=v=>{typeof v.return=="function"&&v.return()},n=null,o=null,i=v=>{n=v,o&&o(v),e(t)},s=null,u=!1,l=()=>{u=!0,s&&s()},m=null,h=!1,b=()=>{h=!0,m&&m()},w=null,T=()=>{w&&w()},p=()=>new Promise((v,S)=>{s=w=v,o=S,r.once("drain",T)}),y=()=>(e(t),new Promise((v,S)=>{if(u||h||n)return v();m=s=v,o=S})),E=()=>{r.removeListener("error",i),r.removeListener("close",l),r.removeListener("finish",b),r.removeListener("drain",T)};r.once("error",i),r.once("close",l),r.once("finish",b);try{for await(let v of t){if(!r.writable||r.destroyed||n)break;r.write(v)===!1&&await p()}}catch(v){n||r.destroy(),n=v}try{if(r.writable&&r.end(),await y(),n)throw n}finally{E()}}});var Cs=P((oE,mf)=>{var Gb=Is(),Hb=Wn();mf.exports=r=>({sink:Gb(r),source:Hb(r)})});var gf=P((iE,bf)=>{var qb=Cs();bf.exports=r=>async function*(t){let e=qb(r),n;if(e.sink(t).catch(o=>{n=o}),yield*e.source,n)throw n}});var yf=P((sE,br)=>{br.exports=Wn();br.exports.source=Wn();br.exports.sink=Is();br.exports.transform=gf();br.exports.duplex=Cs()});var Fg={};U(Fg,{Server:()=>no,createServer:()=>_g});var Eo=G(po(),1),Ma=G(Ca(),1),Ua=G(ge(),1),So=G(vo(),1),Pa=G(Oa(),1);function Mh(){Ua.default._configure(),Eo.default._configure(Ma.default),So.default._configure(Pa.default)}Mh();var _a=["uint64","int64","sint64","fixed64","sfixed64"];function Uh(r){for(let t of _a){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function Ao(r){return Uh(new Eo.default(r))}function Ph(r){for(let t of _a){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function To(){return Ph(So.default.create())}function W(r,t){let e=Ao(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function K(r,t){let e=To();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Pe;(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"})(Pe||(Pe={}));function sn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function jt(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let u=t(i);s.int32(u)},n=function(i){let s=i.int32();return t(s)};return sn("enum",Pe.VARINT,e,n)}function Z(r,t){return sn("message",Pe.LENGTH_DELIMITED,r,t)}var St;(function(r){let t;(function(o){o.IDENTIFY="IDENTIFY",o.CONNECT="CONNECT",o.STREAM_OPEN="STREAM_OPEN",o.STREAM_HANDLER="STREAM_HANDLER",o.DHT="DHT",o.LIST_PEERS="LIST_PEERS",o.CONNMANAGER="CONNMANAGER",o.DISCONNECT="DISCONNECT",o.PUBSUB="PUBSUB",o.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.IDENTIFY=0]="IDENTIFY",o[o.CONNECT=1]="CONNECT",o[o.STREAM_OPEN=2]="STREAM_OPEN",o[o.STREAM_HANDLER=3]="STREAM_HANDLER",o[o.DHT=4]="DHT",o[o.LIST_PEERS=5]="LIST_PEERS",o[o.CONNMANAGER=6]="CONNMANAGER",o[o.DISCONNECT=7]="DISCONNECT",o[o.PUBSUB=8]="PUBSUB",o[o.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.connect!=null&&(i.uint32(18),cn.codec().encode(o.connect,i)),o.streamOpen!=null&&(i.uint32(26),un.codec().encode(o.streamOpen,i)),o.streamHandler!=null&&(i.uint32(34),fn.codec().encode(o.streamHandler,i)),o.dht!=null&&(i.uint32(42),At.codec().encode(o.dht,i)),o.connManager!=null&&(i.uint32(50),hn.codec().encode(o.connManager,i)),o.disconnect!=null&&(i.uint32(58),pn.codec().encode(o.disconnect,i)),o.pubsub!=null&&(i.uint32(66),Jt.codec().encode(o.pubsub,i)),o.peerStore!=null&&(i.uint32(74),xe.codec().encode(o.peerStore,i)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.connect=cn.codec().decode(o,o.uint32());break;case 3:s.streamOpen=un.codec().decode(o,o.uint32());break;case 4:s.streamHandler=fn.codec().decode(o,o.uint32());break;case 5:s.dht=At.codec().decode(o,o.uint32());break;case 6:s.connManager=hn.codec().decode(o,o.uint32());break;case 7:s.disconnect=pn.codec().decode(o,o.uint32());break;case 8:s.pubsub=Jt.codec().decode(o,o.uint32());break;case 9:s.peerStore=xe.codec().decode(o,o.uint32());break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(St||(St={}));var we;(function(r){let t;(function(o){o.OK="OK",o.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.OK=0]="OK",o[o.ERROR=1]="ERROR"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.error!=null&&(i.uint32(18),ln.codec().encode(o.error,i)),o.streamInfo!=null&&(i.uint32(26),_e.codec().encode(o.streamInfo,i)),o.identify!=null&&(i.uint32(34),an.codec().encode(o.identify,i)),o.dht!=null&&(i.uint32(42),rt.codec().encode(o.dht,i)),o.peers!=null)for(let u of o.peers)i.uint32(50),ne.codec().encode(u,i);o.pubsub!=null&&(i.uint32(58),dn.codec().encode(o.pubsub,i)),o.peerStore!=null&&(i.uint32(66),mn.codec().encode(o.peerStore,i)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={peers:[]},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.error=ln.codec().decode(o,o.uint32());break;case 3:s.streamInfo=_e.codec().decode(o,o.uint32());break;case 4:s.identify=an.codec().decode(o,o.uint32());break;case 5:s.dht=rt.codec().decode(o,o.uint32());break;case 6:s.peers.push(ne.codec().decode(o,o.uint32()));break;case 7:s.pubsub=dn.codec().decode(o,o.uint32());break;case 8:s.peerStore=mn.codec().decode(o,o.uint32());break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(we||(we={}));var an;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let i of e.addrs)n.uint32(18),n.bytes(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={id:new Uint8Array(0),addrs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.id=e.bytes();break;case 2:o.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(an||(an={}));var cn;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let i of e.addrs)n.uint32(18),n.bytes(i);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),addrs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;case 2:o.addrs.push(e.bytes());break;case 3:o.timeout=e.int64();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(cn||(cn={}));var un;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let i of e.proto)n.uint32(18),n.string(i);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),proto:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;case 2:o.proto.push(e.string());break;case 3:o.timeout=e.int64();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(un||(un={}));var fn;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let i of e.proto)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={addr:new Uint8Array(0),proto:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.addr=e.bytes();break;case 2:o.proto.push(e.string());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(fn||(fn={}));var ln;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={msg:""},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.msg=e.string();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(ln||(ln={}));var _e;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{o.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)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;case 2:o.addr=e.bytes();break;case 3:o.proto=e.string();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(_e||(_e={}));var At;(function(r){let t;(function(o){o.FIND_PEER="FIND_PEER",o.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",o.FIND_PROVIDERS="FIND_PROVIDERS",o.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",o.GET_PUBLIC_KEY="GET_PUBLIC_KEY",o.GET_VALUE="GET_VALUE",o.SEARCH_VALUE="SEARCH_VALUE",o.PUT_VALUE="PUT_VALUE",o.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.FIND_PEER=0]="FIND_PEER",o[o.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",o[o.FIND_PROVIDERS=2]="FIND_PROVIDERS",o[o.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",o[o.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",o[o.GET_VALUE=5]="GET_VALUE",o[o.SEARCH_VALUE=6]="SEARCH_VALUE",o[o.PUT_VALUE=7]="PUT_VALUE",o[o.PROVIDE=8]="PROVIDE"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.peer!=null&&(i.uint32(18),i.bytes(o.peer)),o.cid!=null&&(i.uint32(26),i.bytes(o.cid)),o.key!=null&&(i.uint32(34),i.bytes(o.key)),o.value!=null&&(i.uint32(42),i.bytes(o.value)),o.count!=null&&(i.uint32(48),i.int32(o.count)),o.timeout!=null&&(i.uint32(56),i.int64(o.timeout)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.peer=o.bytes();break;case 3:s.cid=o.bytes();break;case 4:s.key=o.bytes();break;case 5:s.value=o.bytes();break;case 6:s.count=o.int32();break;case 7:s.timeout=o.int64();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(At||(At={}));var rt;(function(r){let t;(function(o){o.BEGIN="BEGIN",o.VALUE="VALUE",o.END="END"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.BEGIN=0]="BEGIN",o[o.VALUE=1]="VALUE",o[o.END=2]="END"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.peer!=null&&(i.uint32(18),ne.codec().encode(o.peer,i)),o.value!=null&&(i.uint32(26),i.bytes(o.value)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.peer=ne.codec().decode(o,o.uint32());break;case 3:s.value=o.bytes();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(rt||(rt={}));var ne;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let i of e.addrs)n.uint32(18),n.bytes(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={id:new Uint8Array(0),addrs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.id=e.bytes();break;case 2:o.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(ne||(ne={}));var hn;(function(r){let t;(function(o){o.TAG_PEER="TAG_PEER",o.UNTAG_PEER="UNTAG_PEER",o.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.TAG_PEER=0]="TAG_PEER",o[o.UNTAG_PEER=1]="UNTAG_PEER",o[o.TRIM=2]="TRIM"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.peer!=null&&(i.uint32(18),i.bytes(o.peer)),o.tag!=null&&(i.uint32(26),i.string(o.tag)),o.weight!=null&&(i.uint32(32),i.int64(o.weight)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.peer=o.bytes();break;case 3:s.tag=o.string();break;case 4:s.weight=o.int64();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(hn||(hn={}));var pn;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(pn||(pn={}));var Jt;(function(r){let t;(function(o){o.GET_TOPICS="GET_TOPICS",o.LIST_PEERS="LIST_PEERS",o.PUBLISH="PUBLISH",o.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.GET_TOPICS=0]="GET_TOPICS",o[o.LIST_PEERS=1]="LIST_PEERS",o[o.PUBLISH=2]="PUBLISH",o[o.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.topic!=null&&(i.uint32(18),i.string(o.topic)),o.data!=null&&(i.uint32(26),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.topic=o.string();break;case 3:s.data=o.bytes();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(Jt||(Jt={}));var Tr;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.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 i of e.topicIDs)n.uint32(34),n.string(i);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={topicIDs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.from=e.bytes();break;case 2:o.data=e.bytes();break;case 3:o.seqno=e.bytes();break;case 4:o.topicIDs.push(e.string());break;case 5:o.signature=e.bytes();break;case 6:o.key=e.bytes();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(Tr||(Tr={}));var dn;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let i of e.topics)n.uint32(10),n.string(i);if(e.peerIDs!=null)for(let i of e.peerIDs)n.uint32(18),n.bytes(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={topics:[],peerIDs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.topics.push(e.string());break;case 2:o.peerIDs.push(e.bytes());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(dn||(dn={}));var xe;(function(r){let t;(function(o){o.UNSPECIFIED="UNSPECIFIED",o.GET_PROTOCOLS="GET_PROTOCOLS",o.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNSPECIFIED=0]="UNSPECIFIED",o[o.GET_PROTOCOLS=1]="GET_PROTOCOLS",o[o.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(o){o.codec=()=>jt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Z((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.id!=null&&(i.uint32(18),i.bytes(o.id)),o.protos!=null)for(let u of o.protos)i.uint32(26),i.string(u);s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={protos:[]},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.id=o.bytes();break;case 3:s.protos.push(o.string());break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>K(o,r.codec()),r.decode=o=>W(o,r.codec())})(xe||(xe={}));var mn;(function(r){let t;r.codec=()=>(t==null&&(t=Z((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),ne.codec().encode(e.peer,n)),e.protos!=null)for(let i of e.protos)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={protos:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=ne.codec().decode(e,e.uint32());break;case 2:o.protos.push(e.string());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>K(e,r.codec()),r.decode=e=>W(e,r.codec())})(mn||(mn={}));var bt=G(Wa(),1);function ap(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function b(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,E=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var I=(S-v)*h+1>>>0,C=new Uint8Array(I);v!==S;){for(var N=p[v],M=0,B=I-1;(N!==0||M<E)&&B!==-1;B--,M++)N+=256*C[B]>>>0,C[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");E=M,v++}for(var R=I-E;R!==I&&C[R]===0;)R++;for(var F=l.repeat(y);R<I;++R)F+=r.charAt(C[R]);return F}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var E=0,v=0;p[y]===l;)E++,y++;for(var S=(p.length-y)*m+1>>>0,I=new Uint8Array(S);p[y];){var C=e[p.charCodeAt(y)];if(C===255)return;for(var N=0,M=S-1;(C!==0||N<v)&&M!==-1;M--,N++)C+=u*I[M]>>>0,I[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&I[B]===0;)B++;for(var R=new Uint8Array(E+(S-B)),F=E;B!==S;)R[F++]=I[B++];return R}}}function T(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:w,decode:T}}var cp=ap,up=cp,Ka=up;var Sy=new Uint8Array(0);var Za=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 ko=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")}},Bo=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 Qa(this,t)}},No=class{constructor(t){this.decoders=t}or(t){return Qa(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`)}},Qa=(r,t)=>new No({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Lo=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new ko(t,e,n),this.decoder=new Bo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Ya=({name:r,prefix:t,encode:e,decode:n})=>new Lo(r,t,e,n),Ro=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Ka(e,t);return Ya({prefix:r,name:t,encode:n,decode:i=>Za(o(i))})},fp=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let b=o[r[h]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},lp=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},ft=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Ya({prefix:t,name:r,encode(o){return lp(o,n,e)},decode(o){return fp(o,n,e,r)}});var tc=ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ky=ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),By=ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ny=ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ly=ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ry=ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Oy=ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),My=ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Uy=ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ec=Ro({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fy=Ro({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var rc=ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$y=ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Gy=ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Hy=ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});bt.default.formatters.b=r=>r==null?"undefined":ec.baseEncode(r);bt.default.formatters.t=r=>r==null?"undefined":tc.baseEncode(r);bt.default.formatters.m=r=>r==null?"undefined":rc.baseEncode(r);bt.default.formatters.p=r=>r==null?"undefined":r.toString();bt.default.formatters.c=r=>r==null?"undefined":r.toString();bt.default.formatters.k=r=>r==null?"undefined":r.toString();bt.default.formatters.a=r=>r==null?"undefined":r.toString();function hp(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function it(r){let t=hp(`${r}:trace`);return bt.default.enabled(`${r}:trace`)&&bt.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,bt.default)(`${r}:trace`)),Object.assign((0,bt.default)(r),{error:(0,bt.default)(`${r}:error`),trace:t})}function Ee(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Xt(r=0){return globalThis.Buffer?.alloc!=null?Ee(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Pt(r=0){return globalThis.Buffer?.allocUnsafe!=null?Ee(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Tt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return Ee(e)}function Se(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 oc=Symbol.for("@achingbrain/uint8arraylist");function nc(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function xn(r){return!!r?.[oc]}var zt=class r{constructor(...t){Object.defineProperty(this,oc,{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(xn(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(xn(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=nc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=nc(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(xn(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:o}=this._subList(t,e);return Tt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Tt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=n,i}_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=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],u=o,l=u+s.byteLength;if(o=l,t>=l)continue;let m=t>=u&&t<l,h=e>u&&e<=l;if(m&&h){if(t===u&&e===l){n.push(s);break}let b=t-u;n.push(s.subarray(b,b+(e-t)));break}if(m){if(t===0){n.push(s);continue}n.push(s.subarray(t-u));continue}if(h){if(e===l){n.push(s);break}n.push(s.subarray(0,e-u));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!xn(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 o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let b=0;b<i;b++)s[b]=-1;for(let b=0;b<o;b++)s[n[b]]=b;let u=s,l=this.byteLength-n.byteLength,m=n.byteLength-1,h;for(let b=e;b<=l;b+=h){h=0;for(let w=m;w>=0;w--){let T=this.get(b+w);if(n[w]!==T){h=Math.max(1,w-u[T]);break}}if(h===0)return b}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=Pt(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 o=Xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,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 o=Xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,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 o=Xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,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=Pt(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 o=Xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,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 o=Xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,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 o=Xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,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 o=Xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,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 o=Xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,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(!Se(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((o,i)=>o+i.byteLength,0)),n.length=e,n}};function ic(r){let t=async function*(){let e=yield,n=new zt;for await(let o of r){if(e==null){n.append(o),e=yield n,n=new zt;continue}for(n.append(o);n.length>=e;){let i=n.sublist(0,e);if(n.consume(e),e=yield i,e==null){n.length>0&&(e=yield n,n=new zt);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 Ge(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var vn=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}},He=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new vn(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 vn(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 Oo=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function oe(r={}){return pp(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 pp(r,t){t=t??{};let e=t.onEnd,n=new He,o,i,s,u=Ge(),l=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((E,v)=>{i=S=>{i=null,n.push(S);try{E(r(n))}catch(I){v(I)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=Ge()})}},m=E=>i!=null?i(E):(n.push(E),o),h=E=>(n=new He,i!=null?i({error:E}):(n.push({error:E}),o)),b=E=>{if(s)return o;if(t?.objectMode!==!0&&E?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return m({done:!1,value:E})},w=E=>s?o:(s=!0,E!=null?h(E):m({done:!0})),T=()=>(n=new He,w(),{done:!0}),p=E=>(w(E),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:l,return:T,throw:p,push:b,end:w,get readableLength(){return n.size},onEmpty:async E=>{let v=E?.signal;if(v?.throwIfAborted(),n.isEmpty())return;let S,I;v!=null&&(S=new Promise((C,N)=>{I=()=>{N(new Oo)},v.addEventListener("abort",I)}));try{await Promise.race([u.promise,S])}finally{I!=null&&v!=null&&v?.removeEventListener("abort",I)}}},e==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(E){return y.throw(E),e!=null&&(e(E),e=void 0),{done:!0}},return(){return y.return(),e!=null&&(e(),e=void 0),{done:!0}},push:b,end(E){return y.end(E),e!=null&&(e(E),e=void 0),o},get readableLength(){return y.readableLength}},o}function sc(r){let t=oe(),e=ic(r.source),n=Ge(),o,i=r.sink(async function*(){yield*t,yield*await n.promise}());return i.catch(u=>{o=u}),{reader:e,writer:t,stream:{sink:async u=>{if(o!=null){await Promise.reject(o);return}n.resolve(u),await i},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let u=await e.next();if(u.value!=null)return u.value}}}function En(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 ac=4294967296,Ir=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=En(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,o=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,o=~o>>>0,++o>ac&&(o=0,++n>ac&&(n=0))),new r(n,o)}static fromNumber(t){if(t===0)return new r;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(o,n)}static fromBytes(t,e=0){let n=En(t),o=new r,i=0;if(t.length-e>4){for(;i<4;++i)if(o.lo=(o.lo|(n.get(e)&127)<<i*7)>>>0,n.get(e++)<128)return o;if(o.lo=(o.lo|(n.get(e)&127)<<28)>>>0,o.hi=(o.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return o;i=0}else for(;i<4;++i){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(o.lo=(o.lo|(n.get(e)&127)<<i*7)>>>0,n.get(e++)<128)return o}if(t.length-e>4){for(;i<5;++i)if(o.hi=(o.hi|(n.get(e)&127)<<i*7+3)>>>0,n.get(e++)<128)return o}else if(e<t.byteLength)for(;i<5;++i){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(o.hi=(o.hi|(n.get(e)&127)<<i*7+3)>>>0,n.get(e++)<128)return o}throw RangeError("invalid varint encoding")}};var dp=Math.pow(2,7),mp=Math.pow(2,14),bp=Math.pow(2,21),gp=Math.pow(2,28),yp=Math.pow(2,35),wp=Math.pow(2,42),xp=Math.pow(2,49),vp=Math.pow(2,56),Ep=Math.pow(2,63),Ae={encodingLength(r){return r<dp?1:r<mp?2:r<bp?3:r<gp?4:r<yp?5:r<wp?6:r<xp?7:r<vp?8:r<Ep?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=Pt(Ae.encodingLength(r))),Ir.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return Ir.fromBytes(r,t).toNumber(!0)}};function Sn(r){return r[Symbol.asyncIterator]!=null}var An=r=>{let t=Ae.encodingLength(r),e=Pt(t);return Ae.encode(r,e),An.bytes=t,e};An.bytes=0;function qe(r,t){t=t??{};let e=t.lengthEncoder??An;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return Sn(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}qe.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??An;return new zt(e(r.byteLength),r)};var je=G(fc(),1);var Ap=8,Tp=1024*1024*4,Te;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Te||(Te={}));var Mo=r=>{let t=Ae.decode(r);return Mo.bytes=Ae.encodingLength(t),t};Mo.bytes=0;function Cr(r,t){let e=new zt,n=Te.LENGTH,o=-1,i=t?.lengthDecoder??Mo,s=t?.maxLengthLength??Ap,u=t?.maxDataLength??Tp;function*l(){for(;e.byteLength>0;){if(n===Te.LENGTH)try{if(o=i(e),o<0)throw(0,je.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>u)throw(0,je.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let m=i.bytes;e.consume(m),t?.onLength!=null&&t.onLength(o),n=Te.DATA}catch(m){if(m instanceof RangeError){if(e.byteLength>s)throw(0,je.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw m}if(n===Te.DATA){if(e.byteLength<o)break;let m=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(m),yield m,n=Te.LENGTH}}}return Sn(r)?async function*(){for await(let m of r)e.append(m),yield*l();if(e.byteLength>0)throw(0,je.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let m of r)e.append(m),yield*l();if(e.byteLength>0)throw(0,je.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Cr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:s}=await r.next(e);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return Cr(n,{...t??{},onLength:i=>{e=i}})};var Uo=it("libp2p:daemon-protocol:stream-handler"),Tn=class{stream;shake;decoder;constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=sc(this.stream),this.decoder=Cr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Uo("read received no value, closing stream"),await this.close()}write(t){Uo("write message"),this.shake.write(qe.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Uo("closing the stream"),await this.rest().sink([])}};var Po={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Je=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"},It=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var hc=Symbol.for("@libp2p/peer-id");var $o={};U($o,{base58btc:()=>gt,base58flickr:()=>Np});function Ip(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function b(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,E=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var I=(S-v)*h+1>>>0,C=new Uint8Array(I);v!==S;){for(var N=p[v],M=0,B=I-1;(N!==0||M<E)&&B!==-1;B--,M++)N+=256*C[B]>>>0,C[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");E=M,v++}for(var R=I-E;R!==I&&C[R]===0;)R++;for(var F=l.repeat(y);R<I;++R)F+=r.charAt(C[R]);return F}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var E=0,v=0;p[y]===l;)E++,y++;for(var S=(p.length-y)*m+1>>>0,I=new Uint8Array(S);p[y];){var C=e[p.charCodeAt(y)];if(C===255)return;for(var N=0,M=S-1;(C!==0||N<v)&&M!==-1;M--,N++)C+=u*I[M]>>>0,I[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&I[B]===0;)B++;for(var R=new Uint8Array(E+(S-B)),F=E;B!==S;)R[F++]=I[B++];return R}}}function T(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:w,decode:T}}var Cp=Ip,Dp=Cp,pc=Dp;var Hw=new Uint8Array(0);var dc=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},Ct=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var mc=r=>new TextEncoder().encode(r),bc=r=>new TextDecoder().decode(r);var _o=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")}},Fo=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 yc(this,t)}},zo=class{constructor(t){this.decoders=t}or(t){return yc(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`)}},yc=(r,t)=>new zo({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Vo=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new _o(t,e,n),this.decoder=new Fo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Xe=({name:r,prefix:t,encode:e,decode:n})=>new Vo(r,t,e,n),ie=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=pc(e,t);return Xe({prefix:r,name:t,encode:n,decode:i=>Ct(o(i))})},kp=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let b=o[r[h]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},Bp=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},H=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Xe({prefix:t,name:r,encode(o){return Bp(o,n,e)},decode(o){return kp(o,n,e,r)}});var gt=ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Np=ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Go={};U(Go,{identity:()=>Lp});var Lp=Xe({prefix:"\0",name:"identity",encode:r=>bc(r),decode:r=>mc(r)});var Ho={};U(Ho,{base2:()=>Rp});var Rp=H({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qo={};U(qo,{base8:()=>Op});var Op=H({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jo={};U(jo,{base10:()=>Mp});var Mp=ie({prefix:"9",name:"base10",alphabet:"0123456789"});var Jo={};U(Jo,{base16:()=>Up,base16upper:()=>Pp});var Up=H({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Pp=H({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Xo={};U(Xo,{base32:()=>We,base32hex:()=>Vp,base32hexpad:()=>Gp,base32hexpadupper:()=>Hp,base32hexupper:()=>$p,base32pad:()=>Fp,base32padupper:()=>zp,base32upper:()=>_p,base32z:()=>qp});var We=H({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_p=H({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fp=H({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zp=H({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vp=H({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$p=H({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gp=H({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hp=H({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qp=H({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Wo={};U(Wo,{base36:()=>jp,base36upper:()=>Jp});var jp=ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Jp=ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ko={};U(Ko,{base64:()=>Xp,base64pad:()=>Wp,base64url:()=>Kp,base64urlpad:()=>Zp});var Xp=H({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wp=H({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kp=H({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zp=H({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zo={};U(Zo,{base256emoji:()=>rd});var wc=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}"),Qp=wc.reduce((r,t,e)=>(r[e]=t,r),[]),Yp=wc.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function td(r){return r.reduce((t,e)=>(t+=Qp[e],t),"")}function ed(r){let t=[];for(let e of r){let n=Yp[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var rd=Xe({prefix:"\u{1F680}",name:"base256emoji",encode:td,decode:ed});var ri={};U(ri,{sha256:()=>Cn,sha512:()=>vd});var ei=G(Rt("crypto"),1);var nd=Ec,xc=128,od=127,id=~od,sd=Math.pow(2,31);function Ec(r,t,e){t=t||[],e=e||0;for(var n=e;r>=sd;)t[e++]=r&255|xc,r/=128;for(;r&id;)t[e++]=r&255|xc,r>>>=7;return t[e]=r|0,Ec.bytes=e-n+1,t}var ad=Qo,cd=128,vc=127;function Qo(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw Qo.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&vc)<<o:(s&vc)*Math.pow(2,o),o+=7}while(s>=cd);return Qo.bytes=i-n,e}var ud=Math.pow(2,7),fd=Math.pow(2,14),ld=Math.pow(2,21),hd=Math.pow(2,28),pd=Math.pow(2,35),dd=Math.pow(2,42),md=Math.pow(2,49),bd=Math.pow(2,56),gd=Math.pow(2,63),yd=function(r){return r<ud?1:r<fd?2:r<ld?3:r<hd?4:r<pd?5:r<dd?6:r<md?7:r<bd?8:r<gd?9:10},wd={encode:nd,decode:ad,encodingLength:yd},xd=wd,Dr=xd;var kr=(r,t=0)=>[Dr.decode(r,t),Dr.decode.bytes],Ke=(r,t,e=0)=>(Dr.encode(r,t,e),t),Ze=r=>Dr.encodingLength(r);var se=(r,t)=>{let e=t.byteLength,n=Ze(r),o=n+Ze(e),i=new Uint8Array(o+e);return Ke(r,i,0),Ke(e,i,n),i.set(t,o),new Qe(r,e,t,i)},Br=r=>{let t=Ct(r),[e,n]=kr(t),[o,i]=kr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Qe(e,o,s,t)},Sc=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&dc(r.bytes,e.bytes)}},Qe=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ti=({name:r,code:t,encode:e})=>new Yo(r,t,e),Yo=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?se(this.code,e):e.then(n=>se(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Cn=ti({name:"sha2-256",code:18,encode:r=>Ct(ei.default.createHash("sha256").update(r).digest())}),vd=ti({name:"sha2-512",code:19,encode:r=>Ct(ei.default.createHash("sha512").update(r).digest())});var ni={};U(ni,{identity:()=>Dn});var Tc=0,Ed="identity",Ic=Ct,Sd=r=>se(Tc,Ic(r)),Dn={code:Tc,name:Ed,encode:Ic,digest:Sd};var h2=new TextEncoder,p2=new TextDecoder;var Cc=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Cd(e,oi(r),t||gt.encoder);default:return Dd(e,oi(r),t||We.encoder)}};var Dc=new WeakMap,oi=r=>{let t=Dc.get(r);if(t==null){let e=new Map;return Dc.set(r,e),e}return t},Ie=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Nr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==kd)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=se(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&&Sc(t.multihash,n.multihash)}toString(t){return Cc(this,t)}toJSON(){return{"/":Cc(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||kc(n,o,i.bytes))}else if(e[Bd]===!0){let{version:n,multihash:o,code:i}=e,s=Br(o);return r.create(n,i,s)}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 o=kc(t,e,n.bytes);return new r(t,e,n,o)}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,o=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new Qe(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,w]=kr(t.subarray(e));return e+=w,b},o=n(),i=Nr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=Id(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return oi(i).set(n,t),i}},Id=(r,t)=>{switch(r[0]){case"Q":{let e=t||gt;return[gt.prefix,e.decode(`${gt.prefix}${r}`)]}case gt.prefix:{let e=t||gt;return[gt.prefix,e.decode(r)]}case We.prefix:{let e=t||We;return[We.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)]}}},Cd=(r,t,e)=>{let{prefix:n}=e;if(n!==gt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},Dd=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},Nr=112,kd=18,kc=(r,t,e)=>{let n=Ze(r),o=n+Ze(t),i=new Uint8Array(o+e.byteLength);return Ke(r,i,0),Ke(t,i,n),i.set(e,o),i},Bd=Symbol.for("@ipld/js-cid/CID");var ii={...Go,...Ho,...qo,...jo,...Jo,...Xo,...Wo,...$o,...Ko,...Zo},S2={...ri,...ni};var Nd=Symbol.for("nodejs.util.inspect.custom"),Bc=Object.values(ii).map(r=>r.decoder).reduce((r,t)=>r.or(t),ii.identity.decoder),Nc=114,Lc=36,Rc=37,Lr=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()})`}[hc]=!0;toString(){return this.string==null&&(this.string=gt.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ie.createV1(Nc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return Se(this.multihash.bytes,t);if(typeof t=="string")return Ld(t).equals(this);if(t?.multihash?.bytes!=null)return Se(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Nd](){return`PeerId(${this.toString()})`}},Rr=class extends Lr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Or=class extends Lr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},Mr=class extends Lr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Ld(r,t){if(t=t??Bc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Br(gt.decode(`z${r}`));return r.startsWith("12D")?new Or({multihash:e}):r.startsWith("16U")?new Mr({multihash:e}):new Rr({multihash:e})}return Ce(Bc.decode(r))}function Ce(r){try{let t=Br(r);if(t.code===Dn.code){if(t.digest.length===Lc)return new Or({multihash:t});if(t.digest.length===Rc)return new Mr({multihash:t})}if(t.code===Cn.code)return new Rr({multihash:t})}catch{return Rd(Ie.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Rd(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Nc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Cn.code)return new Rr({multihash:r.multihash});if(t.code===Dn.code){if(t.digest.length===Lc)return new Or({multihash:r.multihash});if(t.digest.length===Rc)return new Mr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Ef=G(Rt("net"),1);var Mc=Symbol.for("@libp2p/transport");var Oc;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Oc||(Oc={}));var kn=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var fi={};U(fi,{base58btc:()=>lt,base58flickr:()=>Fd});function Od(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function b(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,E=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var I=(S-v)*h+1>>>0,C=new Uint8Array(I);v!==S;){for(var N=p[v],M=0,B=I-1;(N!==0||M<E)&&B!==-1;B--,M++)N+=256*C[B]>>>0,C[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");E=M,v++}for(var R=I-E;R!==I&&C[R]===0;)R++;for(var F=l.repeat(y);R<I;++R)F+=r.charAt(C[R]);return F}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var E=0,v=0;p[y]===l;)E++,y++;for(var S=(p.length-y)*m+1>>>0,I=new Uint8Array(S);p[y];){var C=e[p.charCodeAt(y)];if(C===255)return;for(var N=0,M=S-1;(C!==0||N<v)&&M!==-1;M--,N++)C+=u*I[M]>>>0,I[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&I[B]===0;)B++;for(var R=new Uint8Array(E+(S-B)),F=E;B!==S;)R[F++]=I[B++];return R}}}function T(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:w,decode:T}}var Md=Od,Ud=Md,Uc=Ud;var P2=new Uint8Array(0);var Pc=(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},Dt=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 _c=r=>new TextEncoder().encode(r),Fc=r=>new TextDecoder().decode(r);var si=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")}},ai=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 Vc(this,t)}},ci=class{constructor(t){this.decoders=t}or(t){return Vc(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`)}},Vc=(r,t)=>new ci({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),ui=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new si(t,e,n),this.decoder=new ai(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},tr=({name:r,prefix:t,encode:e,decode:n})=>new ui(r,t,e,n),ae=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Uc(e,t);return tr({prefix:r,name:t,encode:n,decode:i=>Dt(o(i))})},Pd=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let b=o[r[h]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},_d=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},q=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>tr({prefix:t,name:r,encode(o){return _d(o,n,e)},decode(o){return Pd(o,n,e,r)}});var lt=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fd=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var zd=Hc,$c=128,Vd=127,$d=~Vd,Gd=Math.pow(2,31);function Hc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Gd;)t[e++]=r&255|$c,r/=128;for(;r&$d;)t[e++]=r&255|$c,r>>>=7;return t[e]=r|0,Hc.bytes=e-n+1,t}var Hd=li,qd=128,Gc=127;function li(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw li.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Gc)<<o:(s&Gc)*Math.pow(2,o),o+=7}while(s>=qd);return li.bytes=i-n,e}var jd=Math.pow(2,7),Jd=Math.pow(2,14),Xd=Math.pow(2,21),Wd=Math.pow(2,28),Kd=Math.pow(2,35),Zd=Math.pow(2,42),Qd=Math.pow(2,49),Yd=Math.pow(2,56),tm=Math.pow(2,63),em=function(r){return r<jd?1:r<Jd?2:r<Xd?3:r<Wd?4:r<Kd?5:r<Zd?6:r<Qd?7:r<Yd?8:r<tm?9:10},rm={encode:zd,decode:Hd,encodingLength:em},nm=rm,Ur=nm;var Pr=(r,t=0)=>[Ur.decode(r,t),Ur.decode.bytes],er=(r,t,e=0)=>(Ur.encode(r,t,e),t),rr=r=>Ur.encodingLength(r);var De=(r,t)=>{let e=t.byteLength,n=rr(r),o=n+rr(e),i=new Uint8Array(o+e);return er(r,i,0),er(e,i,n),i.set(t,o),new nr(r,e,t,i)},Nn=r=>{let t=Dt(r),[e,n]=Pr(t),[o,i]=Pr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new nr(e,o,s,t)},qc=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Pc(r.bytes,e.bytes)}},nr=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var hi={};U(hi,{base32:()=>Wt,base32hex:()=>am,base32hexpad:()=>um,base32hexpadupper:()=>fm,base32hexupper:()=>cm,base32pad:()=>im,base32padupper:()=>sm,base32upper:()=>om,base32z:()=>lm});var Wt=q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),om=q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),im=q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sm=q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),am=q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cm=q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),um=q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fm=q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lm=q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jc=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return pm(e,pi(r),t||lt.encoder);default:return dm(e,pi(r),t||Wt.encoder)}};var Jc=new WeakMap,pi=r=>{let t=Jc.get(r);if(t==null){let e=new Map;return Jc.set(r,e),e}return t},ce=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==_r)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==mm)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=De(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&&qc(t.multihash,n.multihash)}toString(t){return jc(this,t)}toJSON(){return{"/":jc(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||Xc(n,o,i.bytes))}else if(e[bm]===!0){let{version:n,multihash:o,code:i}=e,s=Nn(o);return r.create(n,i,s)}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!==_r)throw new Error(`Version 0 CID must use dag-pb (code: ${_r}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Xc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_r,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Dt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new nr(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,w]=Pr(t.subarray(e));return e+=w,b},o=n(),i=_r;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=hm(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pi(i).set(n,t),i}},hm=(r,t)=>{switch(r[0]){case"Q":{let e=t||lt;return[lt.prefix,e.decode(`${lt.prefix}${r}`)]}case lt.prefix:{let e=t||lt;return[lt.prefix,e.decode(r)]}case Wt.prefix:{let e=t||Wt;return[Wt.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)]}}},pm=(r,t,e)=>{let{prefix:n}=e;if(n!==lt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},dm=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},_r=112,mm=18,Xc=(r,t,e)=>{let n=rr(r),o=n+rr(t),i=new Uint8Array(o+e.byteLength);return er(r,i,0),er(t,i,n),i.set(e,o),i},bm=Symbol.for("@ipld/js-cid/CID");var yi={};U(yi,{identity:()=>Em});function gm(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function b(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,E=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var I=(S-v)*h+1>>>0,C=new Uint8Array(I);v!==S;){for(var N=p[v],M=0,B=I-1;(N!==0||M<E)&&B!==-1;B--,M++)N+=256*C[B]>>>0,C[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");E=M,v++}for(var R=I-E;R!==I&&C[R]===0;)R++;for(var F=l.repeat(y);R<I;++R)F+=r.charAt(C[R]);return F}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var E=0,v=0;p[y]===l;)E++,y++;for(var S=(p.length-y)*m+1>>>0,I=new Uint8Array(S);p[y];){var C=e[p.charCodeAt(y)];if(C===255)return;for(var N=0,M=S-1;(C!==0||N<v)&&M!==-1;M--,N++)C+=u*I[M]>>>0,I[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&I[B]===0;)B++;for(var R=new Uint8Array(E+(S-B)),F=E;B!==S;)R[F++]=I[B++];return R}}}function T(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:w,decode:T}}var ym=gm,wm=ym,Wc=wm;var Q2=new Uint8Array(0);var Kc=(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},kt=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 Zc=r=>new TextEncoder().encode(r),Qc=r=>new TextDecoder().decode(r);var di=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")}},mi=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 tu(this,t)}},bi=class{constructor(t){this.decoders=t}or(t){return tu(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`)}},tu=(r,t)=>new bi({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),gi=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new di(t,e,n),this.decoder=new mi(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ir=({name:r,prefix:t,encode:e,decode:n})=>new gi(r,t,e,n),ue=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Wc(e,t);return ir({prefix:r,name:t,encode:n,decode:i=>kt(o(i))})},xm=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let b=o[r[h]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},vm=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},j=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>ir({prefix:t,name:r,encode(o){return vm(o,n,e)},decode(o){return xm(o,n,e,r)}});var Em=ir({prefix:"\0",name:"identity",encode:r=>Qc(r),decode:r=>Zc(r)});var wi={};U(wi,{base2:()=>Sm});var Sm=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var xi={};U(xi,{base8:()=>Am});var Am=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var vi={};U(vi,{base10:()=>Tm});var Tm=ue({prefix:"9",name:"base10",alphabet:"0123456789"});var Ei={};U(Ei,{base16:()=>Im,base16upper:()=>Cm});var Im=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cm=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Si={};U(Si,{base32:()=>sr,base32hex:()=>Nm,base32hexpad:()=>Rm,base32hexpadupper:()=>Om,base32hexupper:()=>Lm,base32pad:()=>km,base32padupper:()=>Bm,base32upper:()=>Dm,base32z:()=>Mm});var sr=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dm=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),km=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bm=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Nm=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lm=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rm=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Om=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Mm=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ai={};U(Ai,{base36:()=>Um,base36upper:()=>Pm});var Um=ue({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pm=ue({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ti={};U(Ti,{base58btc:()=>Vt,base58flickr:()=>_m});var Vt=ue({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_m=ue({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ii={};U(Ii,{base64:()=>Fm,base64pad:()=>zm,base64url:()=>Vm,base64urlpad:()=>$m});var Fm=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zm=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Vm=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$m=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ci={};U(Ci,{base256emoji:()=>Jm});var eu=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}"),Gm=eu.reduce((r,t,e)=>(r[e]=t,r),[]),Hm=eu.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function qm(r){return r.reduce((t,e)=>(t+=Gm[e],t),"")}function jm(r){let t=[];for(let e of r){let n=Hm[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Jm=ir({prefix:"\u{1F680}",name:"base256emoji",encode:qm,decode:jm});var Li={};U(Li,{sha256:()=>h0,sha512:()=>p0});var Ni=G(Rt("crypto"),1);var Xm=ou,ru=128,Wm=127,Km=~Wm,Zm=Math.pow(2,31);function ou(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Zm;)t[e++]=r&255|ru,r/=128;for(;r&Km;)t[e++]=r&255|ru,r>>>=7;return t[e]=r|0,ou.bytes=e-n+1,t}var Qm=Di,Ym=128,nu=127;function Di(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw Di.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&nu)<<o:(s&nu)*Math.pow(2,o),o+=7}while(s>=Ym);return Di.bytes=i-n,e}var t0=Math.pow(2,7),e0=Math.pow(2,14),r0=Math.pow(2,21),n0=Math.pow(2,28),o0=Math.pow(2,35),i0=Math.pow(2,42),s0=Math.pow(2,49),a0=Math.pow(2,56),c0=Math.pow(2,63),u0=function(r){return r<t0?1:r<e0?2:r<r0?3:r<n0?4:r<o0?5:r<i0?6:r<s0?7:r<a0?8:r<c0?9:10},f0={encode:Xm,decode:Qm,encodingLength:u0},l0=f0,Fr=l0;var zr=(r,t=0)=>[Fr.decode(r,t),Fr.decode.bytes],ar=(r,t,e=0)=>(Fr.encode(r,t,e),t),cr=r=>Fr.encodingLength(r);var ke=(r,t)=>{let e=t.byteLength,n=cr(r),o=n+cr(e),i=new Uint8Array(o+e);return ar(r,i,0),ar(e,i,n),i.set(t,o),new ur(r,e,t,i)},iu=r=>{let t=kt(r),[e,n]=zr(t),[o,i]=zr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ur(e,o,s,t)},su=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Kc(r.bytes,e.bytes)}},ur=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Bi=({name:r,code:t,encode:e})=>new ki(r,t,e),ki=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?ke(this.code,e):e.then(n=>ke(this.code,n))}else throw Error("Unknown type, must be binary type")}};var h0=Bi({name:"sha2-256",code:18,encode:r=>kt(Ni.default.createHash("sha256").update(r).digest())}),p0=Bi({name:"sha2-512",code:19,encode:r=>kt(Ni.default.createHash("sha512").update(r).digest())});var Ri={};U(Ri,{identity:()=>b0});var cu=0,d0="identity",uu=kt,m0=r=>ke(cu,uu(r)),b0={code:cu,name:d0,encode:uu,digest:m0};var x1=new TextEncoder,v1=new TextDecoder;var fu=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return x0(e,Oi(r),t||Vt.encoder);default:return v0(e,Oi(r),t||sr.encoder)}};var lu=new WeakMap,Oi=r=>{let t=lu.get(r);if(t==null){let e=new Map;return lu.set(r,e),e}return t},Rn=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==$r)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==E0)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=ke(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&&su(t.multihash,n.multihash)}toString(t){return fu(this,t)}toJSON(){return{"/":fu(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||hu(n,o,i.bytes))}else if(e[S0]===!0){let{version:n,multihash:o,code:i}=e,s=iu(o);return r.create(n,i,s)}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!==$r)throw new Error(`Version 0 CID must use dag-pb (code: ${$r}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=hu(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,$r,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=kt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new ur(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,w]=zr(t.subarray(e));return e+=w,b},o=n(),i=$r;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=w0(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oi(i).set(n,t),i}},w0=(r,t)=>{switch(r[0]){case"Q":{let e=t||Vt;return[Vt.prefix,e.decode(`${Vt.prefix}${r}`)]}case Vt.prefix:{let e=t||Vt;return[Vt.prefix,e.decode(r)]}case sr.prefix:{let e=t||sr;return[sr.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)]}}},x0=(r,t,e)=>{let{prefix:n}=e;if(n!==Vt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},v0=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},$r=112,E0=18,hu=(r,t,e)=>{let n=cr(r),o=n+cr(t),i=new Uint8Array(o+e.byteLength);return ar(r,i,0),ar(t,i,n),i.set(e,o),i},S0=Symbol.for("@ipld/js-cid/CID");var Mi={...yi,...wi,...xi,...vi,...Ei,...Si,...Ai,...Ti,...Ii,...Ci},N1={...Li,...Ri};function du(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var pu=du("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ui=du("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=Pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),A0={utf8:pu,"utf-8":pu,hex:Mi.base16,latin1:Ui,ascii:Ui,binary:Ui,...Mi},On=A0;function ht(r,t="utf8"){let e=On[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 lr=G(Fi(),1);var Mn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,u=this.peekChar();if(u===void 0)return;let l=u==="0",m=2**(8*o)-1;for(;;){let h=this.readAtomically(()=>{let b=this.readChar();if(b===void 0)return;let w=Number.parseInt(b,t);if(!Number.isNaN(w))return w});if(h===void 0)break;if(i*=t,i+=h,i>m||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&l&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[u]=t(i.subarray(0,s));return e.set(i.subarray(0,u),16-u),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var H1=new Mn;var Q1=parseInt("0xFFFF",16),Y1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var zi={};U(zi,{identity:()=>G0});var G0=tr({prefix:"\0",name:"identity",encode:r=>Fc(r),decode:r=>_c(r)});var Vi={};U(Vi,{base2:()=>H0});var H0=q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $i={};U($i,{base8:()=>q0});var q0=q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gi={};U(Gi,{base10:()=>j0});var j0=ae({prefix:"9",name:"base10",alphabet:"0123456789"});var Hi={};U(Hi,{base16:()=>J0,base16upper:()=>X0});var J0=q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),X0=q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qi={};U(qi,{base36:()=>W0,base36upper:()=>K0});var W0=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),K0=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ji={};U(ji,{base64:()=>Z0,base64pad:()=>Q0,base64url:()=>Y0,base64urlpad:()=>tb});var Z0=q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Q0=q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Y0=q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tb=q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ji={};U(Ji,{base256emoji:()=>ib});var Iu=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}"),eb=Iu.reduce((r,t,e)=>(r[e]=t,r),[]),rb=Iu.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function nb(r){return r.reduce((t,e)=>(t+=eb[e],t),"")}function ob(r){let t=[];for(let e of r){let n=rb[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ib=tr({prefix:"\u{1F680}",name:"base256emoji",encode:nb,decode:ob});var Zi={};U(Zi,{sha256:()=>sb,sha512:()=>ab});var Ki=G(Rt("crypto"),1);var Wi=({name:r,code:t,encode:e})=>new Xi(r,t,e),Xi=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?De(this.code,e):e.then(n=>De(this.code,n))}else throw Error("Unknown type, must be binary type")}};var sb=Wi({name:"sha2-256",code:18,encode:r=>Dt(Ki.default.createHash("sha256").update(r).digest())}),ab=Wi({name:"sha2-512",code:19,encode:r=>Dt(Ki.default.createHash("sha512").update(r).digest())});var Qi={};U(Qi,{identity:()=>fb});var Du=0,cb="identity",ku=Dt,ub=r=>De(Du,ku(r)),fb={code:Du,name:cb,encode:ku,digest:ub};var Ux=new TextEncoder,Px=new TextDecoder;var Bu={...zi,...Vi,...$i,...Gi,...Hi,...hi,...qi,...fi,...ji,...Ji},$x={...Zi,...Qi};function Gr(r,t="utf8"){let e=On[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ee(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var $t=G(Fi(),1);var fe=Rt("node:net");function Un(r){return!!(0,fe.isIP)(r)}var Nu=fe.isIPv4,pb=fe.isIPv6,Yi=function(r){let t=0;if(r=r.toString().trim(),Nu(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(pb(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Nu(e[n]),s;i&&(s=Yi(e[n]),e[n]=ht(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,ht(s.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 i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Lu=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var fr={},ts={},mb=[[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"]];mb.forEach(r=>{let t=bb(...r);ts[t.code]=t,fr[t.name]=t});function bb(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function z(r){if(typeof r=="number"){if(ts[r]!=null)return ts[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(fr[r]!=null)return fr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var av=z("ip4"),cv=z("ip6"),uv=z("ipcidr");function rs(r,t){switch(z(r).code){case 4:case 41:return yb(t);case 42:return Mu(t);case 6:case 273:case 33:case 132:return Pu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Mu(t);case 421:return Eb(t);case 444:return Uu(t);case 445:return Uu(t);case 466:return vb(t);default:return ht(t,"base16")}}function ns(r,t){switch(z(r).code){case 4:return Ru(t);case 41:return Ru(t);case 42:return Ou(t);case 6:case 273:case 33:case 132:return os(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ou(t);case 421:return wb(t);case 444:return Sb(t);case 445:return Ab(t);case 466:return xb(t);default:return Gr(t,"base16")}}var es=Object.values(Bu).map(r=>r.decoder),gb=function(){let r=es[0].or(es[1]);return es.slice(2).forEach(t=>r=r.or(t)),r}();function Ru(r){if(!Un(r))throw new Error("invalid ip address");return Yi(r)}function yb(r){let t=Lu(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Un(t))throw new Error("invalid ip address");return t}function os(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Pu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ou(r){let t=Gr(r),e=Uint8Array.from($t.default.encode(t.length));return Tt([e,t],e.length+t.length)}function Mu(r){let t=$t.default.decode(r);if(r=r.slice($t.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return ht(r)}function wb(r){let t;r[0]==="Q"||r[0]==="1"?t=Nn(lt.decode(`z${r}`)).bytes:t=ce.parse(r).multihash.bytes;let e=Uint8Array.from($t.default.encode(t.length));return Tt([e,t],e.length+t.length)}function xb(r){let t=gb.decode(r),e=Uint8Array.from($t.default.encode(t.length));return Tt([e,t],e.length+t.length)}function vb(r){let t=$t.default.decode(r),e=r.slice($t.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+ht(e,"base64url")}function Eb(r){let t=$t.default.decode(r),e=r.slice($t.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return ht(e,"base58btc")}function Sb(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=Wt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=os(n);return Tt([e,o],e.length+o.length)}function Ab(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=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=os(n);return Tt([e,o],e.length+o.length)}function Uu(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ht(t,"base32"),o=Pu(e);return`${n}:${o}`}function _u(r){r=is(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],u=z(s);if(u.size===0){t.push([u.code]),e.push([u.code]);continue}if(i++,i>=o.length)throw zu("invalid address: "+r);if(u.path===!0){n=is(o.slice(i).join("/")),t.push([u.code,ns(u.code,n)]),e.push([u.code,n]);break}let l=ns(u.code,o[i]);t.push([u.code,l]),e.push([u.code,rs(u.code,l)])}return{string:Fu(e),bytes:as(t),tuples:t,stringTuples:e,path:n}}function ss(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=lr.default.decode(r,o),s=lr.default.decode.bytes??0,u=z(i),l=Tb(u,r.slice(o+s));if(l===0){t.push([i]),e.push([i]),o+=s;continue}let m=r.slice(o+s,o+s+l);if(o+=l+s,o>r.length)throw zu("Invalid address Uint8Array: "+ht(r,"base16"));t.push([i,m]);let h=rs(i,m);if(e.push([i,h]),u.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:Fu(e),tuples:t,stringTuples:e,path:n}}function Fu(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),is(t.join("/"))}function as(r){return Tt(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(lr.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=Tt([n,t[1]])),n}))}function Tb(r,t){return r.size>0?r.size/8:r.size===0?0:lr.default.decode(t)+(lr.default.decode.bytes??0)}function is(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function zu(r){return new Error("Error parsing address: "+r)}var Ib=Symbol.for("nodejs.util.inspect.custom"),Cb=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],Db=new Map,Vu=Symbol.for("@multiformats/js-multiaddr/multiaddr");function kb(r){return!!r?.[Vu]}var cs=class r{bytes;#t;#e;#r;#n;[Vu]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ss(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=_u(t)}else if(kb(t))e=ss(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=z("tcp"),u=z("udp"),l=z("ip4"),m=z("ip6"),h=z("dns6"),b=z("ip6zone");for(let[T,p]of this.stringTuples())T===b.code&&(i=`%${p??""}`),Cb.includes(T)&&(e=s.name,o=443,n=`${p??""}${i}`,t=T===h.code?6:4),(T===s.code||T===u.code)&&(e=z(T).name,o=parseInt(p??"")),(T===l.code||T===m.code)&&(e=z(T).name,n=`${p??""}${i}`,t=T===m.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},z(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>z(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(as(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===fr.p2p.code&&t.push([n,o]),n===fr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?ht(lt.decode(`z${n}`),"base58btc"):ht(ce.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Se(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Db.get(e.name);if(n==null)throw new kn(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>new r(i))}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)}[Ib](){return`Multiaddr(${this.#t})`}};function yt(r){return new cs(r)}var Bb=D("dns4"),Nb=D("dns6"),Lb=D("dnsaddr"),Ne=X(D("dns"),Lb,Bb,Nb),Fn=X(D("ip4"),D("ip6")),he=X(O(Fn,D("tcp")),O(Ne,D("tcp"))),zn=O(Fn,D("udp")),Rb=O(zn,D("utp")),Ob=O(zn,D("quic")),Mb=O(zn,D("quic-v1")),us=X(O(he,D("ws")),O(Ne,D("ws"))),Pn=X(O(us,D("p2p")),us),fs=X(O(he,D("wss")),O(Ne,D("wss")),O(he,D("tls"),D("ws")),O(Ne,D("tls"),D("ws"))),_n=X(O(fs,D("p2p")),fs),ls=X(O(he,D("http")),O(Fn,D("http")),O(Ne,D("http"))),hs=X(O(he,D("https")),O(Fn,D("https")),O(Ne,D("https"))),$u=O(zn,D("webrtc-direct"),D("certhash")),qu=X(O($u,D("p2p")),$u),Gu=O(Mb,D("webtransport"),D("certhash"),D("certhash")),ju=X(O(Gu,D("p2p")),Gu),Ju=X(O(Pn,D("p2p-webrtc-star"),D("p2p")),O(_n,D("p2p-webrtc-star"),D("p2p")),O(Pn,D("p2p-webrtc-star")),O(_n,D("p2p-webrtc-star"))),Nv=X(O(Pn,D("p2p-websocket-star"),D("p2p")),O(_n,D("p2p-websocket-star"),D("p2p")),O(Pn,D("p2p-websocket-star")),O(_n,D("p2p-websocket-star"))),Xu=X(O(ls,D("p2p-webrtc-direct"),D("p2p")),O(hs,D("p2p-webrtc-direct"),D("p2p")),O(ls,D("p2p-webrtc-direct")),O(hs,D("p2p-webrtc-direct"))),Le=X(us,fs,ls,hs,Ju,Xu,he,Rb,Ob,Ne,qu,ju),Lv=X(O(Le,D("p2p-stardust"),D("p2p")),O(Le,D("p2p-stardust"))),le=X(O(Le,D("p2p")),Ju,Xu,qu,ju,D("p2p")),Hu=X(O(le,D("p2p-circuit"),le),O(le,D("p2p-circuit")),O(D("p2p-circuit"),le),O(Le,D("p2p-circuit")),O(D("p2p-circuit"),Le),D("p2p-circuit")),Wu=()=>X(O(Hu,Wu),Hu),Be=Wu(),Rv=X(O(Be,le,Be),O(le,Be),O(Be,le),Be,le);var Ov=X(O(Be,D("webrtc"),D("p2p")),O(Be,D("webrtc")),O(Le,D("webrtc"),D("p2p")),O(Le,D("webrtc")),D("webrtc"));function Ku(r){function t(e){let n;try{n=yt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function O(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ku(t),partialMatch:t}}function X(...r){function t(n){let o=null;return r.some(i=>{let s=typeof i=="function"?i().partialMatch(n):i.partialMatch(n);return s!=null?(o=s,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ku(t),partialMatch:t}}function D(r){let t=r;function e(o){let i;try{i=yt(o)}catch{return!1}let s=i.protoNames();return s.length===1&&s[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var vf=G(Rt("net"),1);var Vn=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:i})=>i!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new hr(t,e))}},ps=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},hr=globalThis.CustomEvent??ps;function $n(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Gn(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var pr=/^(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,ds=/\/\d{1,2}$/;var st=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var dr=G(ms(),1),Re=G(Hr(),1),wt=class r{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Gn(32),this.isInSubnet=$n,this.address=t;let e=ds.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 st("Invalid subnet mask.");t=t.replace(ds,"")}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(pr))throw new st("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],o;for(o=0;o<8;o+=2){let i=e.slice(o,o+2);n.push(parseInt(i,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,Re.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,Re.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,Re.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new dr.BigInteger(this.parsedAddress.map(t=>(0,Re.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new dr.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new dr.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new dr.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new dr.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,Re.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(pr,(0,Re.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 ef={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},bs={"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"},gs=/([^0-9a-f:/%])/gi,ys=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,ws=/\/\d{1,3}(?=%|$)/,xs=/%.*$/,rf=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),nf=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var sf=G(Hr(),1);function Pb(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function jn(r,t=0){return r.split(":").map((n,o)=>/group-v4/.test(n)?n:(0,sf.sprintf)('<span class="hover-group group-%d">%s</span>',o+t,Pb(n)))}var Me=G(Hr(),1);function Es(r){return(0,Me.sprintf)("(%s)",r.join("|"))}function vs(r){return r.length<4?(0,Me.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ss="[^A-Fa-f0-9:]";function Jn(r){let t=[];r.forEach((n,o)=>{parseInt(n,16)===0&&t.push(o)});let e=t.map(n=>r.map((o,i)=>{if(i===n){let s=i===0||i===8-1?":":"";return Es([vs(o),s])}return vs(o)}).join(":"));return e.push(r.map(vs).join(":")),Es(e)}function As(r,t,e){let n=t?"":":",o=e?"":":",i=[];!t&&!e&&i.push("::"),t&&e&&i.push(""),(e&&!t||!e&&t)&&i.push(":"),i.push((0,Me.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),i.push((0,Me.sprintf)("(0{1,4}:){1,%d}%s",r-1,o)),i.push((0,Me.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let s=1;s<r-1;s++)for(let u=1;u<r-s;u++)i.push((0,Me.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",u,r-u-s-1));return Es(i)}var at=G(ms(),1),ct=G(Hr(),1);function Xn(r){if(!r)throw new Error("Assertion failed.")}function _b(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function Fb(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 zb(r,t){let e=[],n=[],o;for(o=0;o<r.length;o++)o<t[0]?e.push(r[o]):o>t[1]&&n.push(r[o]);return e.concat(["compact"]).concat(n)}function cf(r){return(0,ct.sprintf)("%04x",parseInt(r,16))}function uf(r){return r&255}var qr=class r{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=$n,this.isCorrect=Gn(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=ws.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 st("Invalid subnet mask.");t=t.replace(ws,"")}else if(/\//.test(t))throw new st("Invalid subnet mask.");let o=xs.exec(t);o&&(this.zone=o[0],t=t.replace(xs,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new r(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],o;for(o=0;o<8;o++)n.push(e.slice(o*4,(o+1)*4));return new r(n.join(":"))}static fromURL(t){let e,n=null,o;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(o=nf.exec(t),o===null)return{error:"failed to parse address with port",address:null,port:null};e=o[1],n=o[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),o=rf.exec(t),o===null)return{error:"failed to parse address from URL",address:null,port:null};e=o[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new r(e),port:n}}static fromAddress4(t){let e=new wt(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 st("Invalid 'ip6.arpa' form.");let o=e.split(".").reverse();for(let i=n;i>0;i--){let s=i*4;o.splice(s,0,":")}return e=o.join(""),new r(e)}microsoftTranscription(){return(0,ct.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),o=e-n;return o<0?"0":_b(new at.BigInteger("2",10).pow(o).toString(10))}_startAddress(){return new at.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new at.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new at.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new at.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=ef[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(bs))if(this.isInSubnet(new r(t)))return bs[t];return"Global unicast"}getBits(t,e){return new at.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,ct.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,o=[];for(t=0;t<this.parsedAddress.length;t++){let u=parseInt(this.parsedAddress[t],16);u===0&&n++,u!==0&&n>0&&(n>1&&o.push([t-n,t-1]),n=0)}n>1&&o.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let i=o.map(u=>u[1]-u[0]+1);if(o.length>0){let u=i.indexOf(Math.max(...i));e=zb(this.parsedAddress,o[u])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let s=e.join(":");return s=s.replace(/^compact$/,"::"),s=s.replace(/^compact|compact$/,":"),s=s.replace(/compact/,""),s}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),o=e.slice(-1)[0].match(pr);if(o){this.parsedAddress4=o[0],this.address4=new wt(this.parsedAddress4);for(let i=0;i<this.address4.groups;i++)if(/^0[0-9]+/.test(this.address4.parsedAddress[i]))throw new st("IPv4 addresses can't have leading zeroes.",t.replace(pr,this.address4.parsedAddress.map(Fb).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(gs);if(e)throw new st((0,ct.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(gs,'<span class="parse-error">$1</span>'));let n=t.match(ys);if(n)throw new st((0,ct.sprintf)("Address failed regex: %s",n.join("")),t.replace(ys,'<span class="parse-error">$1</span>'));let o=[],i=t.split("::");if(i.length===2){let s=i[0].split(":"),u=i[1].split(":");s.length===1&&s[0]===""&&(s=[]),u.length===1&&u[0]===""&&(u=[]);let l=this.groups-(s.length+u.length);if(!l)throw new st("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,o=o.concat(s);for(let m=0;m<l;m++)o.push("0");o=o.concat(u)}else if(i.length===1)o=t.split(":"),this.elidedGroups=0;else throw new st("Too many :: groups found");if(o=o.map(s=>(0,ct.sprintf)("%x",parseInt(s,16))),o.length!==this.groups)throw new st("Incorrect number of groups found");return o}canonicalForm(){return this.parsedAddress.map(cf).join(":")}decimal(){return this.parsedAddress.map(t=>(0,ct.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new at.BigInteger(this.parsedAddress.map(cf).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return wt.fromHex(new at.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new r(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),o="";return/:$/.test(n)||(o=":"),n+o+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new at.BigInteger("ffff",16)).toString(),n=wt.fromHex(this.getBitsBase16(32,64)),o=wt.fromHex(this.getBits(96,128).xor(new at.BigInteger("ffffffff",16)).toString(16)),i=this.getBits(64,80),s=this.getBitsBase2(64,80),u=i.testBit(15),l=i.testBit(14),m=i.testBit(8),h=i.testBit(9),b=new at.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,ct.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:o.address,flags:s,coneNat:u,microsoft:{reserved:l,universalLocal:h,groupIndividual:m,nonce:b},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=wt.fromHex(this.getBitsBase16(16,48));return{prefix:(0,ct.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(uf)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(uf))}static fromUnsignedByteArray(t){let e=new at.BigInteger("256",10),n=new at.BigInteger("0",10),o=new at.BigInteger("1",10);for(let i=t.length-1;i>=0;i--)n=n.add(o.multiply(new at.BigInteger(t[i].toString(10),10))),o=o.multiply(e);return r.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new r("2001::/32"))}is6to4(){return this.isInSubnet(new r("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,ct.sprintf)(":%s",t),(0,ct.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,ct.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,ct.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return jn(this.address).join(":");Xn(typeof this.elidedGroups=="number"),Xn(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...jn(e)):t.push("");let o=["hover-group"];for(let i=this.elisionBegin;i<this.elisionBegin+this.elidedGroups;i++)o.push((0,ct.sprintf)("group-%d",i));return t.push((0,ct.sprintf)('<span class="%s"></span>',o.join(" "))),n.length?t.push(...jn(n,this.elisionEnd)):t.push(""),this.is4()&&(Xn(this.address4 instanceof wt),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(Jn(n.parsedAddress));else if(n.elidedGroups===8)e.push(As(8));else{let o=n.address.split("::");o[0].length&&e.push(Jn(o[0].split(":"))),Xn(typeof n.elidedGroups=="number"),e.push(As(n.elidedGroups,o[0].length!==0,o[1].length!==0)),o[1].length&&e.push(Jn(o[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ss,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ss,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Vb=it("libp2p:ip-port-to-multiaddr"),Ts={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function ff(r,t){if(typeof r!="string")throw new It(`invalid ip provided: ${r}`,Ts.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new It(`invalid port provided: ${t}`,Ts.ERR_INVALID_PORT_PARAMETER);try{return new wt(r),yt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new qr(r);return e.is4()?yt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):yt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Vb.error(n),new It(n,Ts.ERR_INVALID_IP)}}var xf=G(yf(),1);var Ds=G(Rt("os"),1),wf=G(Rt("path"),1);var jb={ip4:"IPv4",ip6:"IPv6"};function gr(r,t={}){let e=r.getPath();return e!=null?Ds.default.platform()==="win32"?{path:wf.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function ks(r,t,e){let n=o=>yt(`/${r}/${o}/tcp/${e}`);return(Jb(t)?Wb(jb[r]):[t]).map(n)}function Jb(r){return["0.0.0.0","::"].includes(r)}var Xb=Ds.default.networkInterfaces();function Wb(r){let t=[];for(let[,e]of Object.entries(Xb))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Gt=it("libp2p:tcp:socket"),Kn=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",o=t.socketInactivityTimeout??3e5,i=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let s;if(t.remoteAddr!=null)s=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new It("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");s=ff(r.remoteAddress,r.remotePort)}let u=gr(s),l=u.path??`${u.host??""}:${u.port??""}`,{sink:m,source:h}=xf.default.duplex(r);r.setTimeout(o,()=>{Gt("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new It("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Gt("%s socket close",l),e?.increment({[`${n}close`]:!0}),b.timeline.close==null&&(b.timeline.close=Date.now())}),r.once("end",()=>{Gt("%s socket end",l),e?.increment({[`${n}end`]:!0})});let b={async sink(w){try{await m(w)}catch(T){T.type!=="aborted"&&Gt(T)}r.end()},source:h,remoteAddr:s,timeline:{open:Date.now()},async close(w={}){if(r.destroyed){Gt("%s socket was already destroyed when trying to close",l);return}w.signal=w.signal??AbortSignal.timeout(i);try{Gt("%s closing socket",l),await new Promise((T,p)=>{r.once("close",()=>{Gt("%s socket closed",l),T()}),r.once("error",y=>{Gt("%s socket error",l,y),b.timeline.close==null&&(b.timeline.close=Date.now()),p(y)}),r.setTimeout(i),r.end(),r.writableLength>0?r.once("drain",()=>{Gt("%s socket drained",l),r.destroy()}):r.destroy()})}catch(T){this.abort(T)}},abort:w=>{Gt("%s socket abort due to error",l,w),r.destroy(w)}};return b};var xt=it("libp2p:tcp:listener");async function Bs(r){try{await r.close()}catch(t){xt.error("an error occurred closing the connection",t)}}var Qb=1,Yb=0,Zn=class extends Vn{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=vf.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]:Qb})}this.dispatchEvent(new hr("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new hr("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Yb}),this.dispatchEvent(new hr("close"))})}onSocket(t){t.on("error",n=>{xt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=Kn(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){xt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}xt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{xt("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(o=>{xt.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new hr("connection",{detail:n}))}).catch(async n=>{xt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Bs(e)}).catch(n=>{xt.error("closing inbound connection failed",n)})}catch(n){xt.error("inbound connection failed",n),Bs(e).catch(o=>{xt.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(ks("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(ks("ip6",e.address,e.port)))}catch(i){xt.error("could not turn %s:%s into multiaddr",e.address,e.port,i)}return t.map(i=>o!=null?i.encapsulate(`/p2p/${o}`):i)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:o}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:gr(n,{backlog:o})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Bs(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)}),xt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(xt("Closing server on %s",this.server.address()),this.server.close())}};var Zt=it("libp2p:tcp"),Ls=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"})})}[Mc]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",u=>{Zt("socket error",u)});let o=Kn(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),i=()=>{o.close().catch(u=>{Zt.error("Error closing maConn after abort",u)})};e.signal?.addEventListener("abort",i,{once:!0}),Zt("new outbound connection %s",o.remoteAddr);let s=await e.upgrader.upgradeOutbound(o);if(Zt("outbound connection %s upgraded",o.remoteAddr),e.signal?.removeEventListener("abort",i),e.signal?.aborted===!0)throw s.close().catch(u=>{Zt.error("Error closing conn after abort",u)}),new Je;return s}async _connect(t,e){if(e.signal?.aborted===!0)throw new Je;return new Promise((n,o)=>{let i=Date.now(),s=gr(t),u=s.path??`${s.host??""}:${s.port}`;Zt("dialing %j",s);let l=Ef.default.connect(s),m=p=>{p.message=`connection error ${u}: ${p.message}`,this.metrics?.dialerEvents.increment({error:!0}),T(p)},h=()=>{Zt("connection timeout %s",u),this.metrics?.dialerEvents.increment({timeout:!0});let p=new It(`connection timeout after ${Date.now()-i}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",p)},b=()=>{Zt("connection opened %j",s),this.metrics?.dialerEvents.increment({connect:!0}),T()},w=()=>{Zt("connection aborted %j",s),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),T(new Je)},T=p=>{if(l.removeListener("error",m),l.removeListener("timeout",h),l.removeListener("connect",b),e.signal!=null&&e.signal.removeEventListener("abort",w),p!=null){o(p);return}n(l)};l.on("error",m),l.on("timeout",h),l.on("connect",b),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new Zn({...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:he.matches(e.decapsulateCode(421)))}};function Sf(r={}){return(t={})=>new Ls(t,r)}function rg(r){return r[Symbol.asyncIterator]!=null}function ng(...r){let t=[];for(let e of r)rg(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=oe({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)e.push(o)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var Af=ng;function Qn(r,...t){if(r==null)throw new Error("Empty pipeline");if(Rs(r)){let n=r;r=()=>n.source}else if(If(r)||Tf(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Rs(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++)Rs(e[n])&&(e[n]=ig(e[n]));return og(...e)}var og=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Tf=r=>r?.[Symbol.asyncIterator]!=null,If=r=>r?.[Symbol.iterator]!=null,Rs=r=>r==null?!1:r.sink!=null&&r.source!=null,ig=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=oe({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(Tf(i))o=async function*(){yield*i,n.end()};else if(If(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Af(n,o())}return r.source};var sg=kf,Cf=128,ag=127,cg=~ag,ug=Math.pow(2,31);function kf(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ug;)t[e++]=r&255|Cf,r/=128;for(;r&cg;)t[e++]=r&255|Cf,r>>>=7;return t[e]=r|0,kf.bytes=e-n+1,t}var fg=Os,lg=128,Df=127;function Os(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw Os.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Df)<<o:(s&Df)*Math.pow(2,o),o+=7}while(s>=lg);return Os.bytes=i-n,e}var hg=Math.pow(2,7),pg=Math.pow(2,14),dg=Math.pow(2,21),mg=Math.pow(2,28),bg=Math.pow(2,35),gg=Math.pow(2,42),yg=Math.pow(2,49),wg=Math.pow(2,56),xg=Math.pow(2,63),vg=function(r){return r<hg?1:r<pg?2:r<dg?3:r<mg?4:r<bg?5:r<gg?6:r<yg?7:r<wg?8:r<xg?9:10},Eg={encode:sg,decode:fg,encodingLength:vg},Sg=Eg,jr=Sg;var Jr=(r,t=0)=>[jr.decode(r,t),jr.decode.bytes],yr=(r,t,e=0)=>(jr.encode(r,t,e),t),wr=r=>jr.encodingLength(r);var UE=new Uint8Array(0);var Nf=(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},xr=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 Lf=(r,t)=>{let e=t.byteLength,n=wr(r),o=n+wr(e),i=new Uint8Array(o+e);return yr(r,i,0),yr(e,i,n),i.set(t,o),new vr(r,e,t,i)},Rf=r=>{let t=xr(r),[e,n]=Jr(t),[o,i]=Jr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new vr(e,o,s,t)},Of=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Nf(r.bytes,e.bytes)}},vr=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Tg(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function b(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,E=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var I=(S-v)*h+1>>>0,C=new Uint8Array(I);v!==S;){for(var N=p[v],M=0,B=I-1;(N!==0||M<E)&&B!==-1;B--,M++)N+=256*C[B]>>>0,C[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");E=M,v++}for(var R=I-E;R!==I&&C[R]===0;)R++;for(var F=l.repeat(y);R<I;++R)F+=r.charAt(C[R]);return F}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var E=0,v=0;p[y]===l;)E++,y++;for(var S=(p.length-y)*m+1>>>0,I=new Uint8Array(S);p[y];){var C=e[p.charCodeAt(y)];if(C===255)return;for(var N=0,M=S-1;(C!==0||N<v)&&M!==-1;M--,N++)C+=u*I[M]>>>0,I[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&I[B]===0;)B++;for(var R=new Uint8Array(E+(S-B)),F=E;B!==S;)R[F++]=I[B++];return R}}}function T(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:w,decode:T}}var Ig=Tg,Cg=Ig,Mf=Cg;var Ms=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")}},Us=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 Uf(this,t)}},Ps=class{constructor(t){this.decoders=t}or(t){return Uf(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`)}},Uf=(r,t)=>new Ps({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),_s=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ms(t,e,n),this.decoder=new Us(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Pf=({name:r,prefix:t,encode:e,decode:n})=>new _s(r,t,e,n),Fs=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Mf(e,t);return Pf({prefix:r,name:t,encode:n,decode:i=>xr(o(i))})},Dg=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let b=o[r[h]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},kg=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},Ht=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Pf({prefix:t,name:r,encode(o){return kg(o,n,e)},decode(o){return Dg(o,n,e,r)}});var Qt=Fs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),HE=Fs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xr=Ht({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),JE=Ht({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),XE=Ht({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),WE=Ht({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),KE=Ht({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ZE=Ht({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),QE=Ht({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),YE=Ht({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),t6=Ht({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _f=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Ng(e,zs(r),t||Qt.encoder);default:return Lg(e,zs(r),t||Xr.encoder)}};var Ff=new WeakMap,zs=r=>{let t=Ff.get(r);if(t==null){let e=new Map;return Ff.set(r,e),e}return t},Kr=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Rg)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=Lf(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&&Of(t.multihash,n.multihash)}toString(t){return _f(this,t)}toJSON(){return{"/":_f(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||zf(n,o,i.bytes))}else if(e[Og]===!0){let{version:n,multihash:o,code:i}=e,s=Rf(o);return r.create(n,i,s)}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!==Wr)throw new Error(`Version 0 CID must use dag-pb (code: ${Wr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=zf(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Wr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=xr(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new vr(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,w]=Jr(t.subarray(e));return e+=w,b},o=n(),i=Wr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=Bg(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return zs(i).set(n,t),i}},Bg=(r,t)=>{switch(r[0]){case"Q":{let e=t||Qt;return[Qt.prefix,e.decode(`${Qt.prefix}${r}`)]}case Qt.prefix:{let e=t||Qt;return[Qt.prefix,e.decode(r)]}case Xr.prefix:{let e=t||Xr;return[Xr.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)]}}},Ng=(r,t,e)=>{let{prefix:n}=e;if(n!==Qt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},Lg=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},Wr=112,Rg=18,zf=(r,t,e)=>{let n=wr(r),o=n+wr(t),i=new Uint8Array(o+e.byteLength);return yr(r,i,0),yr(t,i,n),i.set(e,o),i},Og=Symbol.for("@ipld/js-cid/CID");function Mg(r){return r[Symbol.asyncIterator]!=null}function Ug(r){if(Mg(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Vs=Ug;function Q(r){return we.encode({type:we.Type.OK,peers:[],...r}).subarray()}function $(r){return we.encode({type:we.Type.ERROR,error:{msg:r.message},peers:[]}).subarray()}var Yn=it("libp2p:daemon-server:dht"),to=class{dht;constructor(t){let{dht:e}=t;this.dht=e}async*provide(t){try{await Vs(this.dht.provide(t)),yield Q()}catch(e){Yn.error(e),yield $(e)}}async*getClosestPeers(t){yield Q({dht:{type:rt.Type.BEGIN}});for await(let e of this.dht.getClosestPeers(t))e.name==="PEER_RESPONSE"&&(yield*e.closer.map(n=>rt.encode({type:rt.Type.VALUE,value:n.id.toBytes()})));yield rt.encode({type:rt.Type.END})}async*getPublicKey(t){yield $(new Error("FIX ME: not implemented"))}async*getValue(t){try{for await(let e of this.dht.get(t))e.name==="VALUE"&&(yield Q({dht:{type:rt.Type.VALUE,value:e.value}}))}catch(e){Yn.error(e),yield $(e)}}async*putValue(t,e){try{await Vs(this.dht.put(t,e)),yield Q()}catch(n){Yn.error(n),yield $(n)}}async*findPeer(t){try{for await(let e of this.dht.findPeer(t))e.name==="FINAL_PEER"&&(yield Q({dht:{type:rt.Type.VALUE,peer:{id:e.peer.id.toBytes(),addrs:e.peer.multiaddrs.map(n=>n.bytes)}}}));throw new Error("Peer not found")}catch(e){Yn.error(e),yield $(e)}}async*findProviders(t,e){yield Q({dht:{type:rt.Type.BEGIN}});try{let n=e,o=0;for await(let i of this.dht.findProviders(t))if(i.name==="PEER_RESPONSE"){for(let s of i.providers)o++,yield rt.encode({type:rt.Type.VALUE,peer:{id:s.id.toBytes(),addrs:(s.multiaddrs??[]).map(u=>u.bytes)}});if(n===o)break}}catch(n){yield $(n)}yield rt.encode({type:rt.Type.END})}};var eo=it("libp2p:daemon-server:pubsub"),ro=class{pubsub;constructor(t){let{pubsub:e}=t;this.pubsub=e}async*getTopics(){try{yield Q({pubsub:{topics:this.pubsub.getTopics(),peerIDs:[]}})}catch(t){eo.error(t),yield $(t)}}async*subscribe(t){try{let e=oe();this.pubsub.subscribe(t),this.pubsub.addEventListener("message",n=>{let o=n.detail;o.topic===t&&(o.type==="signed"?e.push(Tr.encode({from:o.from.toBytes(),data:o.data,seqno:o.sequenceNumber==null?void 0:Gr(o.sequenceNumber.toString(16).padStart(16,"0"),"base16"),topicIDs:[o.topic],signature:o.signature,key:o.key}).subarray()):e.push(Tr.encode({data:o.data,topicIDs:[o.topic]}).subarray()))}),yield Q(),yield*e}catch(e){eo.error(e),yield $(e)}}async*publish(t,e){try{await this.pubsub.publish(t,e),yield Q()}catch(n){eo.error(n),yield $(n)}}async*listPeers(t){try{yield Q({pubsub:{topics:[t],peerIDs:this.pubsub.getSubscribers(t).map(e=>e.toBytes())}})}catch(e){eo.error(e),yield $(e)}}};var Pg=1<<22,Yt=it("libp2p:daemon-server"),no=class{multiaddr;libp2p;tcp;listener;dhtOperations;pubsubOperations;constructor(t){let{multiaddr:e,libp2pNode:n}=t;this.multiaddr=e,this.libp2p=n,this.tcp=Sf()(),this.listener=this.tcp.createListener({handler:this.handleConnection.bind(this),upgrader:Po}),this._onExit=this._onExit.bind(this),n.services.dht!=null&&(this.dhtOperations=new to({dht:n.services.dht})),n.services.pubsub!=null&&(this.pubsubOperations=new ro({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(i=>yt(i)),o=Ce(e);return await this.libp2p.peerStore.merge(o,{multiaddrs:n}),this.libp2p.dial(o)}async openStream(t){if(t.streamOpen==null||t.streamOpen.proto==null)throw new Error("Invalid request");let{peer:e,proto:n}=t.streamOpen,o=Ce(e),i=await this.libp2p.dial(o),s=await i.newStream(n,{runOnTransientConnection:!0});return{streamInfo:{peer:o.toBytes(),addr:i.remoteAddr.bytes,proto:s.protocol??""},connection:s}}async registerStreamHandler(t){if(t.streamHandler==null||t.streamHandler.proto==null)throw new Error("Invalid request");let e=t.streamHandler.proto,n=yt(t.streamHandler.addr),o;await this.libp2p.handle(e,({connection:i,stream:s})=>{Promise.resolve().then(async()=>{o=await this.tcp.dial(n,{upgrader:Po});let u=_e.encode({peer:i.remotePeer.toBytes(),addr:i.remoteAddr.bytes,proto:s.protocol??""}),l=qe.single(u);await Qn(async function*(){yield l,yield*s.source}(),async function*(m){for await(let h of m)yield*h},o,s.sink)}).catch(async u=>{Yt.error(u),o!=null&&await o.close(u)}).finally(()=>{o?.close().catch(u=>{Yt.error(u)})})},{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=>{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 xe.Type.GET_PROTOCOLS:if(t.id==null)throw new Error("Invalid request");let e=Ce(t.id),o=(await this.libp2p.peerStore.get(e)).protocols;yield Q({peerStore:{protos:o}});return;case xe.Type.GET_PEER_INFO:throw new Error("ERR_NOT_IMPLEMENTED");default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Yt.error(e),yield $(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 $(e)}}async*handleDHTRequest(t){try{if(this.libp2p.services.dht==null||this.dhtOperations==null)throw new Error("DHT not configured");switch(t.type){case At.Type.FIND_PEER:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.findPeer(Ce(t.peer));return;case At.Type.FIND_PROVIDERS:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.findProviders(Kr.decode(t.cid),t.count??20);return;case At.Type.PROVIDE:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.provide(Kr.decode(t.cid));return;case At.Type.GET_CLOSEST_PEERS:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getClosestPeers(t.key);return;case At.Type.GET_PUBLIC_KEY:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.getPublicKey(Ce(t.peer));return;case At.Type.GET_VALUE:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getValue(t.key);return;case At.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 $(e)}}handleConnection(t){let e=this,n=new Tn({stream:t,maxLength:Pg});Qn(n.decoder,o=>async function*(){let i;for await(let s of o)try{switch(i=St.decode(s),i.type){case St.Type.CONNECT:{try{await e.connect(i)}catch(u){yield $(u);break}yield Q();break}case St.Type.IDENTIFY:{yield Q({identify:{id:e.libp2p.peerId.toBytes(),addrs:e.libp2p.getMultiaddrs().map(u=>u.decapsulateCode(z("p2p").code)).map(u=>u.bytes)}});break}case St.Type.LIST_PEERS:{let u=[],l=new Set;for(let m of e.libp2p.getConnections()){let h=m.remotePeer.toString();l.has(h)||(l.add(h),u.push({id:m.remotePeer.toBytes(),addrs:[m.remoteAddr.bytes]}))}yield Q({peers:u});break}case St.Type.STREAM_OPEN:{let u;try{u=await e.openStream(i)}catch(m){yield $(m);break}yield Q({streamInfo:u.streamInfo});let l=n.rest();await Qn(l,u.connection,async function*(m){for await(let h of m)yield*h},l);return}case St.Type.STREAM_HANDLER:{try{await e.registerStreamHandler(i)}catch(u){yield $(u);break}yield Q();break}case St.Type.PEERSTORE:{if(i.peerStore==null){yield $(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePeerStoreRequest(i.peerStore);break}case St.Type.PUBSUB:{if(i.pubsub==null){yield $(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePubsubRequest(i.pubsub);break}case St.Type.DHT:{if(i.dht==null){yield $(new Error("ERR_INVALID_REQUEST"));break}yield*e.handleDHTRequest(i.dht);break}default:yield $(new Error("ERR_INVALID_REQUEST_TYPE"));break}}catch(u){Yt.error(u),yield $(u);continue}}(),async function(o){for await(let i of o)n.write(i)}).catch(o=>{Yt(o)})}},_g=(r,t)=>new no({multiaddr:r,libp2pNode:t});return Ih(Fg);})();
|
|
7
7
|
return Libp2PDaemonServer}));
|