mirror of
https://github.com/logos-messaging/lab.waku.org.git
synced 2026-01-09 09:13:06 +00:00
3 lines
1.6 MiB
3 lines
1.6 MiB
/*! For license information please see main.547d0ff0.js.LICENSE.txt */
|
|
(()=>{var __webpack_modules__={4762:e=>{"use strict";e.exports=function(e,t){var r=new Array(arguments.length-1),n=0,i=2,o=!0;for(;i<arguments.length;)r[n++]=arguments[i++];return new Promise((function(i,s){r[n]=function(e){if(o)if(o=!1,e)s(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];i.apply(null,t)}};try{e.apply(t||null,r)}catch(a){o&&(o=!1,s(a))}}))}},6762:(e,t)=>{"use strict";var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),o=0;o<64;)i[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;r.encode=function(e,t,r){for(var i,o=null,s=[],a=0,c=0;t<r;){var u=e[t++];switch(c){case 0:s[a++]=n[u>>2],i=(3&u)<<4,c=1;break;case 1:s[a++]=n[i|u>>4],i=(15&u)<<2,c=2;break;case 2:s[a++]=n[i|u>>6],s[a++]=n[63&u],c=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=n[i],s[a++]=61,1===c&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";r.decode=function(e,t,r){for(var n,o=r,a=0,c=0;c<e.length;){var u=e.charCodeAt(c++);if(61===u&&a>1)break;if(void 0===(u=i[u]))throw Error(s);switch(a){case 0:n=u,a=1;break;case 1:t[r++]=n<<2|(48&u)>>4,n=u,a=2;break;case 2:t[r++]=(15&n)<<4|(60&u)>>2,n=u,a=3;break;case 3:t[r++]=(3&n)<<6|u,a=0}}if(1===a)throw Error(s);return r-o},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},7351:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n<r.length;)r[n].fn===t?r.splice(n,1):++n;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,r)}return this}},217:e=>{"use strict";function t(e){return"undefined"!==typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function o(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:o,e.writeFloatBE=n?o:i,e.readFloatLE=n?s:a,e.readFloatBE=n?a:s}():function(){function t(e,t,r,n){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,r,n)}}function s(e,t,r){var n=e(t,r),i=2*(n>>31)+1,o=n>>>23&255,s=8388607&n;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=s.bind(null,i),e.readFloatBE=s.bind(null,o)}(),"undefined"!==typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function o(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:o,e.writeDoubleBE=n?o:i,e.readDoubleLE=n?s:a,e.readDoubleBE=n?a:s}():function(){function t(e,t,r,n,i,o){var s=n<0?1:0;if(s&&(n=-n),0===n)e(0,i,o+t),e(1/n>0?0:2147483648,i,o+r);else if(isNaN(n))e(0,i,o+t),e(2146959360,i,o+r);else if(n>17976931348623157e292)e(0,i,o+t),e((s<<31|2146435072)>>>0,i,o+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,i,o+t),e((s<<31|a/4294967296)>>>0,i,o+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,i,o+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,i,o+r)}}}function s(e,t,r,n,i){var o=e(n,i+t),s=e(n,i+r),a=2*(s>>31)+1,c=s>>>20&2047,u=4294967296*(1048575&s)+o;return 2047===c?u?NaN:a*(1/0):0===c?5e-324*a*u:a*Math.pow(2,c-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=s.bind(null,i,0,4),e.readDoubleBE=s.bind(null,o,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},4882:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},6931:e=>{"use strict";e.exports=function(e,t,r){var n=r||8192,i=n>>>1,o=null,s=n;return function(r){if(r<1||r>i)return e(r);s+r>n&&(o=e(n),s=0);var a=t.call(o,s,s+=r);return 7&s&&(s=1+(7|s)),a}}},8626:(e,t)=>{"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},r.read=function(e,t,r){if(r-t<1)return"";for(var n,i=null,o=[],s=0;t<r;)(n=e[t++])<128?o[s++]=n:n>191&&n<224?o[s++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(n>>10),o[s++]=56320+(1023&n)):o[s++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},r.write=function(e,t,r){for(var n,i,o=r,s=0;s<e.length;++s)(n=e.charCodeAt(s))<128?t[r++]=n:n<2048?(t[r++]=n>>6|192,t[r++]=63&n|128):55296===(64512&n)&&56320===(64512&(i=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&i),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-o}},6522:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&"undefined"!==typeof process&&"env"in process&&(e={NODE_ENV:"production",PUBLIC_URL:"/web-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DEBUG);return e},t.useColors=function(){if("undefined"!==typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!==typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})(),t.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"],t.log=console.debug||console.log||(()=>{}),e.exports=r(5237)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},5237:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,o,s=null;function a(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if(!a.enabled)return;const o=a,s=Number(new Date),c=s-(r||s);o.diff=c,o.prev=r,o.curr=s,r=s,n[0]=t.coerce(n[0]),"string"!==typeof n[0]&&n.unshift("%O");let u=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if("%%"===e)return"%";u++;const i=t.formatters[r];if("function"===typeof i){const t=n[u];e=i.call(o,t),n.splice(u,1),u--}return e})),t.formatArgs.call(o,n);(o.log||t.log).apply(o,n)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"===typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+("undefined"===typeof r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"===typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(7340),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},80:e=>{"use strict";function t(e,t){t=t||{};this._capacity=t.capacity,this._head=0,this._tail=0,Array.isArray(e)?this._fromArray(e):(this._capacityMask=3,this._list=new Array(4))}t.prototype.peekAt=function(e){var t=e;if(t===(0|t)){var r=this.size();if(!(t>=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},t.prototype.get=function(e){return this.peekAt(e)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.unshift=function(e){if(0===arguments.length)return this.size();var t=this._list.length;return this._head=this._head-1+t&this._capacityMask,this._list[this._head]=e,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.shift=function(){var e=this._head;if(e!==this._tail){var t=this._list[e];return this._list[e]=void 0,this._head=e+1&this._capacityMask,e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},t.prototype.push=function(e){if(0===arguments.length)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.pop=function(){var e=this._tail;if(e!==this._head){var t=this._list.length;this._tail=e-1+t&this._capacityMask;var r=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=t>>>2&&this._shrinkArray(),r}},t.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var i,o=this._list[t];if(e<r/2){for(i=e;i>0;i--)this._list[t]=this._list[t=t-1+n&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(i=r-1-e;i>0;i--)this._list[t]=this._list[t=t+1+n&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+n&this._capacityMask}return o}}},t.prototype.remove=function(e,t){var r,n=e,i=t;if(n===(0|n)&&this._head!==this._tail){var o=this.size(),s=this._list.length;if(!(n>=o||n<-o||t<1)){if(n<0&&(n+=o),1===t||!t)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+t>=o)return r=this.toArray(),this.clear(),r;var a;for(n+t>o&&(t=o-n),r=new Array(t),a=0;a<t;a++)r[a]=this._list[this._head+n+a&this._capacityMask];if(n=this._head+n&this._capacityMask,e+t===o){for(this._tail=this._tail-t+s&this._capacityMask,a=t;a>0;a--)this._list[n=n+1+s&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+s&this._capacityMask,a=t-1;a>0;a--)this._list[n=n+1+s&this._capacityMask]=void 0;return r}if(n<o/2){for(this._head=this._head+e+t+s&this._capacityMask,a=e;a>0;a--)this.unshift(this._list[n=n-1+s&this._capacityMask]);for(n=this._head-1+s&this._capacityMask;i>0;)this._list[n=n-1+s&this._capacityMask]=void 0,i--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+s&this._capacityMask,a=o-(t+e);a>0;a--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+s&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=s>>>2&&this._shrinkArray(),r}}},t.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var i,o,s,a=arguments.length,c=this._list.length,u=2;if(!n||r<n/2){for(o=new Array(r),i=0;i<r;i++)o[i]=this._list[this._head+i&this._capacityMask];for(0===t?(s=[],r>0&&(this._head=this._head+r+c&this._capacityMask)):(s=this.remove(r,t),this._head=this._head+r+c&this._capacityMask);a>u;)this.unshift(arguments[--a]);for(i=r;i>0;i--)this.unshift(o[i-1])}else{var l=(o=new Array(n-(r+t))).length;for(i=0;i<l;i++)o[i]=this._list[this._head+r+t+i&this._capacityMask];for(0===t?(s=[],r!=n&&(this._tail=this._head+r+c&this._capacityMask)):(s=this.remove(r,t),this._tail=this._tail-l+c&this._capacityMask);u<a;)this.push(arguments[u++]);for(i=0;i<l;i++)this.push(o[i])}return s}return this.remove(r,t)}}},t.prototype.clear=function(){this._list=new Array(this._list.length),this._head=0,this._tail=0},t.prototype.isEmpty=function(){return this._head===this._tail},t.prototype.toArray=function(){return this._copyArray(!1)},t.prototype._fromArray=function(e){var t=e.length,r=this._nextPowerOf2(t);this._list=new Array(r),this._capacityMask=r-1,this._tail=t;for(var n=0;n<t;n++)this._list[n]=e[n]},t.prototype._copyArray=function(e,t){var r=this._list,n=r.length,i=this.length;if((t|=i)==i&&this._head<this._tail)return this._list.slice(this._head,this._tail);var o,s=new Array(t),a=0;if(e||this._head>this._tail){for(o=this._head;o<n;o++)s[a++]=r[o];for(o=0;o<this._tail;o++)s[a++]=r[o]}else for(o=this._head;o<this._tail;o++)s[a++]=r[o];return s},t.prototype._growArray=function(){if(0!=this._head){var e=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=e}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1},t.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1},t.prototype._nextPowerOf2=function(e){var t=1<<Math.log(e)/Math.log(2)+1;return Math.max(t,4)},e.exports=t},4823:e=>{"use strict";function t(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,r,n){if(!e||"string"===typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"===typeof r&&(n=r,r=""),r&&(n.code=r);try{return t(e,n)}catch(i){n.message=e.message,n.stack=e.stack;const r=function(){};r.prototype=Object.create(Object.getPrototypeOf(e));return t(new r,n)}}},2605:(e,t,r)=>{"use strict";const n=r(9020);t.PP=n.EventIterator,n.EventIterator},9020:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;const t={value:e,done:!1};if(this.pullQueue.length){const e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn("EventIterator queue reached ".concat(this.pushQueue.length," items")))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{const t=Promise.reject(e);t.catch((()=>{})),this.pushQueue.push(t)}}remove(){Promise.resolve().then((()=>{this.removeCallback&&this.removeCallback()}))}[Symbol.asyncIterator](){return{next:e=>{const t=this.pushQueue.shift();return t?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise(((e,t)=>{this.pullQueue.push({resolve:e,reject:t})}))},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class n{constructor(e){let{highWaterMark:t=100,lowWaterMark:n=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new r;i.highWaterMark=t,i.lowWaterMark=n,i.removeCallback=e({push:e=>i.push(e),stop:()=>i.stop(),fail:e=>i.fail(e),on:(e,t)=>{i.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}}t.EventIterator=n,t.default=n},7283:e=>{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,s){if("function"!==typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,i,o,s){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,s),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||n&&a.context!==n||s(this,o);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[o]=1===u.length?u[0]:u:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a},101:e=>{e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,o){r[i]=o,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},5411:(e,t,r)=>{var n;!function(){"use strict";var t="object"===typeof window?window:{};!t.HI_BASE32_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node&&(t=r.g);var i=!t.HI_BASE32_NO_COMMON_JS&&e.exports,o=r.amdO,s="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),a={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},c=[0,0,0,0,0,0,0,0],u=function(e,t){t.length>10&&(t="..."+t.substr(-10));var r=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+e+" bytes: "+t+" <-");throw r.position=e,r},l=function(e){if(""===e)return[];if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");for(var t,r,n,i,o,s,c,u,l=[],h=0,d=(e=e.replace(/=/g,"")).length,f=0,p=d>>3<<3;f<p;)t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],o=a[e.charAt(f++)],s=a[e.charAt(f++)],c=a[e.charAt(f++)],u=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|o>>>1),l[h++]=255&(o<<7|s<<2|c>>>3),l[h++]=255&(c<<5|u);var g=d-p;return 2===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2)):4===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4)):5===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],o=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|o>>>1)):7===g&&(t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],o=a[e.charAt(f++)],s=a[e.charAt(f++)],c=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|o>>>1),l[h++]=255&(o<<7|s<<2|c>>>3)),l},h=function(e,t){if(!t)return function(e){for(var t,r,n="",i=e.length,o=0,s=0;o<i;)if((t=e[o++])<=127)n+=String.fromCharCode(t);else{t>191&&t<=223?(r=31&t,s=1):t<=239?(r=15&t,s=2):t<=247?(r=7&t,s=3):u(o,n);for(var a=0;a<s;++a)((t=e[o++])<128||t>191)&&u(o,n),r<<=6,r+=63&t;r>=55296&&r<=57343&&u(o,n),r>1114111&&u(o,n),r<=65535?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode(55296+(r>>10)),n+=String.fromCharCode(56320+(1023&r)))}return n}(l(e));if(""===e)return"";if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");var r,n,i,o,s,c,h,d,f="",p=e.indexOf("=");-1===p&&(p=e.length);for(var g=0,b=p>>3<<3;g<b;)r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],o=a[e.charAt(g++)],s=a[e.charAt(g++)],c=a[e.charAt(g++)],h=a[e.charAt(g++)],d=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))+String.fromCharCode(255&(o<<4|s>>>1))+String.fromCharCode(255&(s<<7|c<<2|h>>>3))+String.fromCharCode(255&(h<<5|d));var y=p-b;return 2===y?(r=a[e.charAt(g++)],n=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))):4===y?(r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],o=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))):5===y?(r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],o=a[e.charAt(g++)],s=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))+String.fromCharCode(255&(o<<4|s>>>1))):7===y&&(r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],o=a[e.charAt(g++)],s=a[e.charAt(g++)],c=a[e.charAt(g++)],h=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))+String.fromCharCode(255&(o<<4|s>>>1))+String.fromCharCode(255&(s<<7|c<<2|h>>>3))),f},d={encode:function(e,t){var r="string"!==typeof e;return r&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),r?function(e){for(var t,r,n,i,o,a="",c=e.length,u=0,l=5*parseInt(c/5);u<l;)t=e[u++],r=e[u++],n=e[u++],i=e[u++],o=e[u++],a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[31&(n<<1|i>>>7)]+s[i>>>2&31]+s[31&(i<<3|o>>>5)]+s[31&o];var h=c-l;return 1===h?(t=e[u],a+=s[t>>>3]+s[t<<2&31]+"======"):2===h?(t=e[u++],r=e[u],a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[r<<4&31]+"===="):3===h?(t=e[u++],r=e[u++],n=e[u],a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[n<<1&31]+"==="):4===h&&(t=e[u++],r=e[u++],n=e[u++],i=e[u],a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[31&(n<<1|i>>>7)]+s[i>>>2&31]+s[i<<3&31]+"="),a}(e):t?function(e){for(var t,r,n,i,o,a="",c=e.length,u=0,l=5*parseInt(c/5);u<l;)t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),i=e.charCodeAt(u++),o=e.charCodeAt(u++),a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[31&(n<<1|i>>>7)]+s[i>>>2&31]+s[31&(i<<3|o>>>5)]+s[31&o];var h=c-l;return 1===h?(t=e.charCodeAt(u),a+=s[t>>>3]+s[t<<2&31]+"======"):2===h?(t=e.charCodeAt(u++),r=e.charCodeAt(u),a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[r<<4&31]+"===="):3===h?(t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u),a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[n<<1&31]+"==="):4===h&&(t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),i=e.charCodeAt(u),a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[31&(n<<1|i>>>7)]+s[i>>>2&31]+s[i<<3&31]+"="),a}(e):function(e){var t,r,n,i,o,a,u,l=!1,h="",d=0,f=0,p=e.length;if(""===e)return h;do{for(c[0]=c[5],c[1]=c[6],c[2]=c[7],u=f;d<p&&u<5;++d)(a=e.charCodeAt(d))<128?c[u++]=a:a<2048?(c[u++]=192|a>>6,c[u++]=128|63&a):a<55296||a>=57344?(c[u++]=224|a>>12,c[u++]=128|a>>6&63,c[u++]=128|63&a):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++d)),c[u++]=240|a>>18,c[u++]=128|a>>12&63,c[u++]=128|a>>6&63,c[u++]=128|63&a);f=u-5,d===p&&++d,d>p&&u<6&&(l=!0),t=c[0],u>4?(r=c[1],n=c[2],i=c[3],o=c[4],h+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[31&(n<<1|i>>>7)]+s[i>>>2&31]+s[31&(i<<3|o>>>5)]+s[31&o]):1===u?h+=s[t>>>3]+s[t<<2&31]+"======":2===u?(r=c[1],h+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[r<<4&31]+"===="):3===u?(r=c[1],n=c[2],h+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[n<<1&31]+"==="):(r=c[1],n=c[2],i=c[3],h+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[31&(r<<4|n>>>4)]+s[31&(n<<1|i>>>7)]+s[i>>>2&31]+s[i<<3&31]+"=")}while(!l);return h}(e)},decode:h};h.asBytes=l,i?e.exports=d:(t.base32=d,o&&(void 0===(n=function(){return d}.call(d,r,d,e))||(e.exports=n)))}()},4053:e=>{e.exports=function(){return"undefined"!==typeof window&&"object"===typeof window.process&&"renderer"===window.process.type||(!("undefined"===typeof process||"object"!==typeof process.versions||!process.versions.electron)||"object"===typeof navigator&&"string"===typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}},8313:e=>{"use strict";e.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},2161:(e,t,r)=>{var n;!function(){"use strict";var i="input is invalid type",o="object"===typeof window,s=o?window:{};s.JS_SHA3_NO_WINDOW&&(o=!1);var a=!o&&"object"===typeof self;!s.JS_SHA3_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node?s=r.g:a&&(s=self);for(var c=!s.JS_SHA3_NO_COMMON_JS&&e.exports,u=r.amdO,l=!s.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!==typeof ArrayBuffer,h="0123456789abcdef".split(""),d=[4,1024,262144,67108864],f=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],b=[128,256],y=["hex","buffer","arrayBuffer","array","digest"],m={128:168,256:136},v=s.JS_SHA3_NO_NODE_JS||!Array.isArray?function(e){return"[object Array]"===Object.prototype.toString.call(e)}:Array.isArray,w=!l||!s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(e){return"object"===typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer},_=function(e){var t=typeof e;if("string"===t)return[e,!0];if("object"!==t||null===e)throw new Error(i);if(l&&e.constructor===ArrayBuffer)return[new Uint8Array(e),!1];if(!v(e)&&!w(e))throw new Error(i);return[e,!1]},E=function(e){return 0===_(e)[0].length},S=function(e){for(var t=[],r=0;r<e.length;++r)t[r]=e[r];return t},A=function(e,t,r){return function(n){return new q(e,t,e).update(n)[r]()}},k=function(e,t,r){return function(n,i){return new q(e,t,i).update(n)[r]()}},x=function(e,t,r){return function(t,n,i,o){return P["cshake"+e].update(t,n,i,o)[r]()}},I=function(e,t,r){return function(t,n,i,o){return P["kmac"+e].update(t,n,i,o)[r]()}},C=function(e,t,r,n){for(var i=0;i<y.length;++i){var o=y[i];e[o]=t(r,n,o)}return e},T=function(e,t){var r=A(e,t,"hex");return r.create=function(){return new q(e,t,e)},r.update=function(e){return r.create().update(e)},C(r,A,e,t)},R=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:T},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:T},{name:"shake",padding:[31,7936,2031616,520093696],bits:b,createMethod:function(e,t){var r=k(e,t,"hex");return r.create=function(r){return new q(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},C(r,k,e,t)}},{name:"cshake",padding:d,bits:b,createMethod:function(e,t){var r=m[e],n=x(e,0,"hex");return n.create=function(n,i,o){return E(i)&&E(o)?P["shake"+e].create(n):new q(e,t,n).bytepad([i,o],r)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},C(n,x,e,t)}},{name:"kmac",padding:d,bits:b,createMethod:function(e,t){var r=m[e],n=I(e,0,"hex");return n.create=function(n,i,o){return new K(e,t,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},C(n,I,e,t)}}],P={},D=[],N=0;N<R.length;++N)for(var B=R[N],U=B.bits,L=0;L<U.length;++L){var M=B.name+"_"+U[L];if(D.push(M),P[M]=B.createMethod(U[L],B.padding),"sha3"!==B.name){var O=B.name+U[L];D.push(O),P[O]=P[M]}}function q(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function K(e,t,r){q.call(this,e,t,r)}q.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t=_(e);e=t[0];for(var r,n,i=t[1],o=this.blocks,s=this.byteCount,a=e.length,c=this.blockCount,u=0,l=this.s;u<a;){if(this.reset)for(this.reset=!1,o[0]=this.block,r=1;r<c+1;++r)o[r]=0;if(i)for(r=this.start;u<a&&r<s;++u)(n=e.charCodeAt(u))<128?o[r>>2]|=n<<f[3&r++]:n<2048?(o[r>>2]|=(192|n>>6)<<f[3&r++],o[r>>2]|=(128|63&n)<<f[3&r++]):n<55296||n>=57344?(o[r>>2]|=(224|n>>12)<<f[3&r++],o[r>>2]|=(128|n>>6&63)<<f[3&r++],o[r>>2]|=(128|63&n)<<f[3&r++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++u)),o[r>>2]|=(240|n>>18)<<f[3&r++],o[r>>2]|=(128|n>>12&63)<<f[3&r++],o[r>>2]|=(128|n>>6&63)<<f[3&r++],o[r>>2]|=(128|63&n)<<f[3&r++]);else for(r=this.start;u<a&&r<s;++u)o[r>>2]|=e[u]<<f[3&r++];if(this.lastByteIndex=r,r>=s){for(this.start=r-s,this.block=o[c],r=0;r<c;++r)l[r]^=o[r];F(l),this.reset=!0}else this.start=r}return this},q.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},q.prototype.encodeString=function(e){var t=_(e);e=t[0];var r=t[1],n=0,i=e.length;if(r)for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);s<128?n+=1:s<2048?n+=2:s<55296||s>=57344?n+=3:(s=65536+((1023&s)<<10|1023&e.charCodeAt(++o)),n+=4)}else n=i;return n+=this.encode(8*n),this.update(e),n},q.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=(t-r%t)%t,o=[];return o.length=i,this.update(o),this},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];F(n)}},q.prototype.toString=q.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a="";s<n;){for(o=0;o<t&&s<n;++o,++s)e=r[o],a+=h[e>>4&15]+h[15&e]+h[e>>12&15]+h[e>>8&15]+h[e>>20&15]+h[e>>16&15]+h[e>>28&15]+h[e>>24&15];s%t===0&&(r=S(r),F(r),o=0)}return i&&(e=r[o],a+=h[e>>4&15]+h[15&e],i>1&&(a+=h[e>>12&15]+h[e>>8&15]),i>2&&(a+=h[e>>20&15]+h[e>>16&15])),a},q.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);s<n;){for(o=0;o<t&&s<n;++o,++s)c[s]=r[o];s%t===0&&(r=S(r),F(r))}return i&&(c[s]=r[o],e=e.slice(0,a)),e},q.prototype.buffer=q.prototype.arrayBuffer,q.prototype.digest=q.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,s=0,a=0,c=[];a<i;){for(s=0;s<r&&a<i;++s,++a)e=a<<2,t=n[s],c[e]=255&t,c[e+1]=t>>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r===0&&(n=S(n),F(n))}return o&&(e=a<<2,t=n[s],c[e]=255&t,o>1&&(c[e+1]=t>>8&255),o>2&&(c[e+2]=t>>16&255)),c},K.prototype=new q,K.prototype.finalize=function(){return this.encode(this.outputBits,!0),q.prototype.finalize.call(this)};var F=function(e){var t,r,n,i,o,s,a,c,u,l,h,d,f,g,b,y,m,v,w,_,E,S,A,k,x,I,C,T,R,P,D,N,B,U,L,M,O,q,K,F,V,z,j,H,G,W,Y,Q,J,X,Z,$,ee,te,re,ne,ie,oe,se,ae,ce,ue,le;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(f=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=o^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=a^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|f>>>31),r=u^(f<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,g=e[0],b=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,R=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,j=e[41]<<18|e[40]>>>14,U=e[2]<<1|e[3]>>>31,L=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,Q=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,D=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,le=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,M=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,N=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,q=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,$=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,I=e[18]<<20|e[19]>>>12,C=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,F=e[38]<<8|e[39]>>>24,V=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=g^~y&v,e[1]=b^~m&w,e[10]=k^~I&T,e[11]=x^~C&R,e[20]=U^~M&q,e[21]=L^~O&K,e[30]=H^~W&Q,e[31]=G^~Y&J,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=y^~v&_,e[3]=m^~w&E,e[12]=I^~T&P,e[13]=C^~R&D,e[22]=M^~q&F,e[23]=O^~K&V,e[32]=W^~Q&X,e[33]=Y^~J&Z,e[42]=ne^~oe&ae,e[43]=ie^~se&ce,e[4]=v^~_&S,e[5]=w^~E&A,e[14]=T^~P&N,e[15]=R^~D&B,e[24]=q^~F&z,e[25]=K^~V&j,e[34]=Q^~X&$,e[35]=J^~Z&ee,e[44]=oe^~ae&ue,e[45]=se^~ce&le,e[6]=_^~S&g,e[7]=E^~A&b,e[16]=P^~N&k,e[17]=D^~B&x,e[26]=F^~z&U,e[27]=V^~j&L,e[36]=X^~$&H,e[37]=Z^~ee&G,e[46]=ae^~ue&te,e[47]=ce^~le&re,e[8]=S^~g&y,e[9]=A^~b&m,e[18]=N^~k&I,e[19]=B^~x&C,e[28]=z^~U&M,e[29]=j^~L&O,e[38]=$^~H&W,e[39]=ee^~G&Y,e[48]=ue^~te&ne,e[49]=le^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(c)e.exports=P;else{for(N=0;N<D.length;++N)s[D[N]]=P[D[N]];u&&(void 0===(n=function(){return P}.call(t,r,t,e))||(e.exports=n))}}()},8355:function(e,t,r){"use strict";const n=r(8313),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:o}=Object,s=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=e=>{const t=[];for(const r in e)i.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)o.call(e,n)&&t.push(n)}return t};function l(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return u(e).forEach((r=>{s(t,r,l(e[r]))})),t}(e):n(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return u(e).forEach((r=>{s(t,r,l(e[r]))})),t}(e):e}const h=(e,t,r,n)=>(r.forEach((r=>{"undefined"===typeof t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?s(e,r,f(e[r],t[r],n)):s(e,r,l(t[r])))})),e),d=(e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach((t=>{const a=[];for(let r=0;r<t.length;r++)i.call(t,r)&&(a.push(String(r)),s(n,o++,t===e?t[r]:l(t[r])));n=h(n,t,u(t).filter((e=>!a.includes(e))),r)})),n};function f(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?d(e,t,r):n(t)&&n(e)?h(e,t,u(t),r):l(t)}e.exports=function(){const e=f(l(c),this!==a&&this||{},c);let t={_:{}};for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];for(const s of i)if(void 0!==s){if(!n(s))throw new TypeError("`"+s+"` is not an Option Object");t=f(t,{_:s},e)}return t._}},7340:e=>{var t=1e3,r=60*t,n=60*r,i=24*n,o=7*i,s=365.25*i;function a(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*i;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var o=Math.abs(e);if(o>=i)return a(e,o,i,"day");if(o>=n)return a(e,o,n,"hour");if(o>=r)return a(e,o,r,"minute");if(o>=t)return a(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=i)return Math.round(e/i)+"d";if(o>=n)return Math.round(e/n)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7364:function(e,t){(function(){var e,r,n,i,o,s,a,c;c=function(e){return[(e&255<<24)>>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},a=function(e){var t,n,i,o,s,a;for(t=[],i=o=0;o<=3&&0!==e.length;i=++o){if(i>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}s=(a=r(e))[0],n=a[1],e=e.substring(n),t.push(s)}if(0!==e.length)throw new Error("Invalid IP");switch(t.length){case 1:if(t[0]>4294967295)throw new Error("Invalid IP");return t[0]>>>0;case 2:if(t[0]>255||t[1]>16777215)throw new Error("Invalid IP");return(t[0]<<24|t[1])>>>0;case 3:if(t[0]>255||t[1]>255||t[2]>65535)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2])>>>0;case 4:if(t[0]>255||t[1]>255||t[2]>255||t[3]>255)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;default:throw new Error("Invalid IP")}},i=(n=function(e){return e.charCodeAt(0)})("0"),s=n("a"),o=n("A"),r=function(e){var t,r,a,c,u;for(c=0,t=10,r="9",a=0,e.length>1&&"0"===e[a]&&("x"===e[a+1]||"X"===e[a+1]?(a+=2,t=16):"0"<=e[a+1]&&e[a+1]<="9"&&(a++,t=8,r="7")),u=a;a<e.length;){if("0"<=e[a]&&e[a]<=r)c=c*t+(n(e[a])-i)>>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")c=c*t+(10+n(e[a])-s)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;c=c*t+(10+n(e[a])-o)>>>0}}if(c>4294967295)throw new Error("too large");a++}if(a===u)throw new Error("empty octet");return[c,a]},e=function(){function e(e,t){var r,n,i;if("string"!==typeof e)throw new Error("Missing `net' parameter");if(t||(i=e.split("/",2),e=i[0],t=i[1]),t||(t=32),"string"===typeof t&&t.indexOf(".")>-1){try{this.maskLong=a(t)}catch(o){throw o,new Error("Invalid mask: "+t)}for(r=n=32;n>=0;r=--n)if(this.maskLong===4294967295<<32-r>>>0){this.bitmask=r;break}}else{if(!t&&0!==t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(a(e)&this.maskLong)>>>0}catch(o){throw o,new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"===typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(a(t)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(c(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,r,n;for(n=a(this.first),r=a(this.last),t=0;n<=r;)e(c(n),n,t),t++,n++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),t.ip2long=a,t.long2ip=c,t.Netmask=e}).call(this)},9353:(e,t,r)=>{var n=r(45);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(9151),r(1655),r(3900),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=g({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return g({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=g({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return g({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){l||d();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return p(r._w,e,t,!1)},decrypt:function(e,t){return p(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!==typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i<t.length;++i)r.putByte(t[i])}}else r=n.util.createBuffer(r);if(!n.util.isArray(r)){t=r,r=[];var o=t.length();if(16===o||24===o||32===o){o>>>=2;for(i=0;i<o;++i)r.push(t.getInt32())}}if(!n.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var s=this.mode.name,a=-1!==["CFB","OFB","CTR","GCM"].indexOf(s);this._w=f(r,e.decrypt&&!a),this._init=!0}},n.aes._expandKey=function(e,t){return l||d(),f(e,t)},n.aes._updateBlock=p,i("AES-ECB",n.cipher.modes.ecb),i("AES-CBC",n.cipher.modes.cbc),i("AES-CFB",n.cipher.modes.cfb),i("AES-OFB",n.cipher.modes.ofb),i("AES-CTR",n.cipher.modes.ctr),i("AES-GCM",n.cipher.modes.gcm);var o,s,a,c,u,l=!1,h=4;function d(){l=!0,a=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;o=new Array(256),s=new Array(256),c=new Array(4),u=new Array(4);for(t=0;t<4;++t)c[t]=new Array(256),u[t]=new Array(256);var r,n,i,h,d,f,p,g=0,b=0;for(t=0;t<256;++t){h=(h=b^b<<1^b<<2^b<<3^b<<4)>>8^255&h^99,o[g]=h,s[h]=g,f=(d=e[h])<<24^h<<16^h<<8^h^d,p=((r=e[g])^(n=e[r])^(i=e[n]))<<24^(g^i)<<16^(g^n^i)<<8^g^r^i;for(var y=0;y<4;++y)c[y][g]=f,u[y][h]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===g?g=b=1:(g=r^e[e[e[r^i]]],b^=e[e[b]])}}function f(e,t){for(var r,n=e.slice(0),i=1,s=n.length,c=h*(s+6+1),l=s;l<c;++l)r=n[l-1],l%s===0?(r=o[r>>>16&255]<<24^o[r>>>8&255]<<16^o[255&r]<<8^o[r>>>24]^a[i]<<24,i++):s>6&&l%s===4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[255&r]),n[l]=n[l-s]^r;if(t){for(var d,f=u[0],p=u[1],g=u[2],b=u[3],y=n.slice(0),m=(l=0,(c=n.length)-h);l<c;l+=h,m-=h)if(0===l||l===c-h)y[l]=n[m],y[l+1]=n[m+3],y[l+2]=n[m+2],y[l+3]=n[m+1];else for(var v=0;v<h;++v)d=n[m+v],y[l+(3&-v)]=f[o[d>>>24]]^p[o[d>>>16&255]]^g[o[d>>>8&255]]^b[o[255&d]];n=y}return n}function p(e,t,r,n){var i,a,l,h,d,f,p,g,b,y,m,v,w=e.length/4-1;n?(i=u[0],a=u[1],l=u[2],h=u[3],d=s):(i=c[0],a=c[1],l=c[2],h=c[3],d=o),f=t[0]^e[0],p=t[n?3:1]^e[1],g=t[2]^e[2],b=t[n?1:3]^e[3];for(var _=3,E=1;E<w;++E)y=i[f>>>24]^a[p>>>16&255]^l[g>>>8&255]^h[255&b]^e[++_],m=i[p>>>24]^a[g>>>16&255]^l[b>>>8&255]^h[255&f]^e[++_],v=i[g>>>24]^a[b>>>16&255]^l[f>>>8&255]^h[255&p]^e[++_],b=i[b>>>24]^a[f>>>16&255]^l[p>>>8&255]^h[255&g]^e[++_],f=y,p=m,g=v;r[0]=d[f>>>24]<<24^d[p>>>16&255]<<16^d[g>>>8&255]<<8^d[255&b]^e[++_],r[n?3:1]=d[p>>>24]<<24^d[g>>>16&255]<<16^d[b>>>8&255]<<8^d[255&f]^e[++_],r[2]=d[g>>>24]<<24^d[b>>>16&255]<<16^d[f>>>8&255]<<8^d[255&p]^e[++_],r[n?1:3]=d[b>>>24]<<24^d[f>>>16&255]<<16^d[p>>>8&255]<<8^d[255&g]^e[++_]}function g(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},5465:(e,t,r)=>{var n=r(45);r(3900),r(3225);var i=e.exports=n.asn1=n.asn1||{};function o(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,o,s){if(n.util.isArray(o)){for(var a=[],c=0;c<o.length;++c)void 0!==o[c]&&a.push(o[c]);o=a}var u={tagClass:e,type:t,constructed:r,composed:r||n.util.isArray(o),value:o};return s&&"bitStringContents"in s&&(u.bitStringContents=s.bitStringContents,u.original=i.copy(u)),u},i.copy=function(e,t){var r;if(n.util.isArray(e)){r=[];for(var o=0;o<e.length;++o)r.push(i.copy(e[o],t));return r}return"string"===typeof e?e:(r={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:i.copy(e.value,t)},t&&!t.excludeBitStringContents&&(r.bitStringContents=e.bitStringContents),r)},i.equals=function(e,t,r){if(n.util.isArray(e)){if(!n.util.isArray(t))return!1;if(e.length!==t.length)return!1;for(var o=0;o<e.length;++o)if(!i.equals(e[o],t[o]))return!1;return!0}if(typeof e!==typeof t)return!1;if("string"===typeof e)return e===t;var s=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&i.equals(e.value,t.value);return r&&r.includeBitStringContents&&(s=s&&e.bitStringContents===t.bitStringContents),s},i.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};function s(e,t,r,n){var a;o(e,t,2);var c=e.getByte();t--;var u=192&c,l=31&c;a=e.length();var h,d,f=function(e,t){var r=e.getByte();if(t--,128!==r){var n;if(128&r){var i=127&r;o(e,t,i),n=e.getInt(i<<3)}else n=r;if(n<0)throw new Error("Negative length: "+n);return n}}(e,t);if(t-=a-e.length(),void 0!==f&&f>t){if(n.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=f,p}f=t}var g=32===(32&c);if(g)if(h=[],void 0===f)for(;;){if(o(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}a=e.length(),h.push(s(e,t,r+1,n)),t-=a-e.length()}else for(;f>0;)a=e.length(),h.push(s(e,f,r+1,n)),t-=a-e.length(),f-=a-e.length();if(void 0===h&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(d=e.bytes(f)),void 0===h&&n.decodeBitStrings&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&f>1){var b=e.read,y=t,m=0;if(l===i.Type.BITSTRING&&(o(e,t,1),m=e.getByte(),t--),0===m)try{a=e.length();var v=s(e,t,r+1,{strict:!0,decodeBitStrings:!0}),w=a-e.length();t-=w,l==i.Type.BITSTRING&&w++;var _=v.tagClass;w!==f||_!==i.Class.UNIVERSAL&&_!==i.Class.CONTEXT_SPECIFIC||(h=[v])}catch(S){}void 0===h&&(e.read=b,t=y)}if(void 0===h){if(void 0===f){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=t}if(l===i.Type.BMPSTRING)for(h="";f>0;f-=2)o(e,t,2),h+=String.fromCharCode(e.getInt16()),t-=2;else h=e.getBytes(f),t-=f}var E=void 0===d?null:{bitStringContents:d};return i.create(u,l,g,h,E)}i.fromDer=function(e,t){void 0===t&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"===typeof t&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.length(),i=s(e,e.length(),0,t);if(t.parseAllBytes&&0!==e.length()){var o=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw o.byteCount=r,o.remaining=e.length(),o}return i},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,o=n.util.createBuffer(),s=!1;if("bitStringContents"in e&&(s=!0,e.original&&(s=i.equals(e,e.original))),s)o.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:o.putByte(0);for(var a=0;a<e.value.length;++a)void 0!==e.value[a]&&o.putBuffer(i.toDer(e.value[a]))}else if(e.type===i.Type.BMPSTRING)for(a=0;a<e.value.length;++a)o.putInt16(e.value.charCodeAt(a));else e.type===i.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0===(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128===(128&e.value.charCodeAt(1)))?o.putBytes(e.value.substr(1)):o.putBytes(e.value);if(t.putByte(r),o.length()<=127)t.putByte(127&o.length());else{var c=o.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(o),t},i.oidToDer=function(e){var t,r,i,o,s=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c<s.length;++c){t=!0,r=[],i=parseInt(s[c],10);do{o=127&i,i>>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(e){var t;"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),o=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(o,s,a,c)),t},i.dateToUtcTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},i.dateToGeneralizedTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},i.integerToDer=function(e){var t=n.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"===typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,o){var s=!1;if(e.tagClass!==t.tagClass&&"undefined"!==typeof t.tagClass||e.type!==t.type&&"undefined"!==typeof t.type)o&&(e.tagClass!==t.tagClass&&o.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&o.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||"undefined"===typeof t.constructed){if(s=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;s&&c<t.value.length;++c)s=t.value[c].optional||!1,e.value[a]&&((s=i.validate(e.value[a],t.value[c],r,o))?++a:t.value[c].optional&&(s=!0)),!s&&o&&o.push("["+t.name+'] Tag class "'+t.tagClass+'", type "'+t.type+'" expected value length "'+t.value.length+'", got "'+e.value.length+'"');if(s&&r)if(t.capture&&(r[t.capture]=e.value),t.captureAsn1&&(r[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(r[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e)if(e.bitStringContents.length<2)r[t.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");r[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else o&&o.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');return s};var a=/[^\\u0000-\\u00ff]/;i.prettyPrint=function(e,t,r){var o="";r=r||2,(t=t||0)>0&&(o+="\n");for(var s="",c=0;c<t*r;++c)s+=" ";switch(o+=s+"Tag: ",e.tagClass){case i.Class.UNIVERSAL:o+="Universal:";break;case i.Class.APPLICATION:o+="Application:";break;case i.Class.CONTEXT_SPECIFIC:o+="Context-Specific:";break;case i.Class.PRIVATE:o+="Private:"}if(e.tagClass===i.Class.UNIVERSAL)switch(o+=e.type,e.type){case i.Type.NONE:o+=" (None)";break;case i.Type.BOOLEAN:o+=" (Boolean)";break;case i.Type.INTEGER:o+=" (Integer)";break;case i.Type.BITSTRING:o+=" (Bit string)";break;case i.Type.OCTETSTRING:o+=" (Octet string)";break;case i.Type.NULL:o+=" (Null)";break;case i.Type.OID:o+=" (Object Identifier)";break;case i.Type.ODESC:o+=" (Object Descriptor)";break;case i.Type.EXTERNAL:o+=" (External or Instance of)";break;case i.Type.REAL:o+=" (Real)";break;case i.Type.ENUMERATED:o+=" (Enumerated)";break;case i.Type.EMBEDDED:o+=" (Embedded PDV)";break;case i.Type.UTF8:o+=" (UTF8)";break;case i.Type.ROID:o+=" (Relative Object Identifier)";break;case i.Type.SEQUENCE:o+=" (Sequence)";break;case i.Type.SET:o+=" (Set)";break;case i.Type.PRINTABLESTRING:o+=" (Printable String)";break;case i.Type.IA5String:o+=" (IA5String (ASCII))";break;case i.Type.UTCTIME:o+=" (UTC time)";break;case i.Type.GENERALIZEDTIME:o+=" (Generalized time)";break;case i.Type.BMPSTRING:o+=" (BMP String)"}else o+=e.type;if(o+="\n",o+=s+"Constructed: "+e.constructed+"\n",e.composed){var u=0,l="";for(c=0;c<e.value.length;++c)void 0!==e.value[c]&&(u+=1,l+=i.prettyPrint(e.value[c],t+1,r),c+1<e.value.length&&(l+=","));o+=s+"Sub values: "+u+l}else{if(o+=s+"Value: ",e.type===i.Type.OID){var h=i.derToOid(e.value);o+=h,n.pki&&n.pki.oids&&h in n.pki.oids&&(o+=" ("+n.pki.oids[h]+") ")}if(e.type===i.Type.INTEGER)try{o+=i.derToInteger(e.value)}catch(f){o+="0x"+n.util.bytesToHex(e.value)}else if(e.type===i.Type.BITSTRING){if(e.value.length>1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?o+=" (1 unused bit shown)":d>1&&(o+=" ("+d+" unused bits shown)")}}else if(e.type===i.Type.OCTETSTRING)a.test(e.value)||(o+="("+e.value+") "),o+="0x"+n.util.bytesToHex(e.value);else if(e.type===i.Type.UTF8)try{o+=n.util.decodeUtf8(e.value)}catch(p){if("URI malformed"!==p.message)throw p;o+="0x"+n.util.bytesToHex(e.value)+" (malformed UTF8)"}else e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?o+=e.value:a.test(e.value)?o+="0x"+n.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}},6407:e=>{var t={};e.exports=t;var r={};t.encode=function(e,t,r){if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!==typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,o=t.length,s=t.charAt(0),a=[0];for(i=0;i<e.length;++i){for(var c=0,u=e[i];c<a.length;++c)u+=a[c]<<8,a[c]=u%o,u=u/o|0;for(;u>0;)a.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=s;for(i=a.length-1;i>=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),o=[0];for(r=0;r<e.length();++r){for(var s=0,a=e.at(r);s<o.length;++s)a+=o[s]<<8,o[s]=a%n,a=a/n|0;for(;a>0;)o.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=i;for(r=o.length-1;r>=0;--r)c+=t[o[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},t.decode=function(e,t){if("string"!==typeof e)throw new TypeError('"input" must be a string.');if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');var n=r[t];if(!n){n=r[t]=[];for(var i=0;i<t.length;++i)n[t.charCodeAt(i)]=i}e=e.replace(/\s/g,"");var o=t.length,s=t.charAt(0),a=[0];for(i=0;i<e.length;i++){var c=n[e.charCodeAt(i)];if(void 0===c)return;for(var u=0,l=c;u<a.length;++u)l+=a[u]*o,a[u]=255&l,l>>=8;for(;l>0;)a.push(255&l),l>>=8}for(var h=0;e[h]===s&&h<e.length-1;++h)a.push(0);return"undefined"!==typeof Buffer?Buffer.from(a.reverse()):new Uint8Array(a.reverse())}},9151:(e,t,r)=>{var n=r(45);r(3900),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},1655:(e,t,r)=>{var n=r(45);r(3900),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function o(e,t){if("string"===typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var r=e;e=n.util.createBuffer();for(var i=0;i<r.length;++i)e.putByte(r[i])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!n.util.isArray(e)){var o=[],s=t/4;for(i=0;i<s;++i)o.push(e.getInt32());e=o}return e}function s(e){e[e.length-1]=e[e.length-1]+1&4294967295}function a(e){return[e/4294967296|0,4294967295&e]}i.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.ecb.prototype.start=function(e){},i.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},i.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},i.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},i.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},i.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},i.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},i.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(o>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(o>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}s(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),s(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o<=0||r){if(r){var a=n%this.blockSize;this._cipherLength+=a,this._partialOutput.truncate(this.blockSize-a)}else this._cipherLength+=this.blockSize;for(i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),s(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),s(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize},i.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=n.util.createBuffer();var i=this._aDataLength.concat(a(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,i);var o=[];this.cipher.encrypt(this._j0,o);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^o[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},i.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i){e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r},i.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,o=new Array(i),s=0;s<i;++s){var a=[0,0,0,0],c=(n-1-s%n)*t;a[s/n|0]=1<<t-1<<c,o[s]=this.generateSubHashTable(this.multiply(a,e),t)}return o},i.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o<n;){for(var s=1;s<o;++s){var a=i[o],c=i[s];i[o+s]=[a[0]^c[0],a[1]^c[1],a[2]^c[2],a[3]^c[3]]}o*=2}for(i[0]=[0,0,0,0],o=n+1;o<r;++o){var u=i[o^n];i[o]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return i}},2986:(e,t,r)=>{var n=r(45);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(9151),r(1655),r(3900),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return f(r._keys,e,t,!1)},decrypt:function(e,t){return f(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],b=e.length()>8?3:1,y=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,w=0;w<b;w++){var _=e.getInt32(),E=e.getInt32();_^=(t=252645135&(_>>>4^E))<<4,_^=t=65535&((E^=t)>>>-16^_),_^=(t=858993459&(_>>>2^(E^=t<<-16)))<<2,_^=t=65535&((E^=t)>>>-16^_),_^=(t=1431655765&(_>>>1^(E^=t<<-16)))<<1,_^=t=16711935&((E^=t)>>>8^_),t=(_^=(t=1431655765&(_>>>1^(E^=t<<8)))<<1)<<8|(E^=t)>>>20&240,_=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=t;for(var S=0;S<m.length;++S){m[S]?(_=_<<2|_>>>26,E=E<<2|E>>>26):(_=_<<1|_>>>27,E=E<<1|E>>>27),E&=-15;var A=r[(_&=-15)>>>28]|n[_>>>24&15]|i[_>>>20&15]|o[_>>>16&15]|s[_>>>12&15]|a[_>>>8&15]|c[_>>>4&15],k=u[E>>>28]|l[E>>>24&15]|h[E>>>20&15]|d[E>>>16&15]|f[E>>>12&15]|p[E>>>8&15]|g[E>>>4&15];t=65535&(k>>>16^A),y[v++]=A^t,y[v++]=k^t<<16}}return y}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var o=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],s=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function f(e,t,r,n){var i,f,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var g=t[0],b=t[1];g^=(f=252645135&(g>>>4^b))<<4,g^=(f=65535&(g>>>16^(b^=f)))<<16,g^=f=858993459&((b^=f)>>>2^g),g^=f=16711935&((b^=f<<2)>>>8^g),g=(g^=(f=1431655765&(g>>>1^(b^=f<<8)))<<1)<<1|g>>>31,b=(b^=f)<<1|b>>>31;for(var y=0;y<p;y+=3){for(var m=i[y+1],v=i[y+2],w=i[y];w!=m;w+=v){var _=b^e[w],E=(b>>>4|b<<28)^e[w+1];f=g,g=b,b=f^(s[_>>>24&63]|c[_>>>16&63]|l[_>>>8&63]|d[63&_]|o[E>>>24&63]|a[E>>>16&63]|u[E>>>8&63]|h[63&E])}f=g,g=b,b=f}b=b>>>1|b<<31,b^=f=1431655765&((g=g>>>1|g<<31)>>>1^b),b^=(f=16711935&(b>>>8^(g^=f<<1)))<<8,b^=(f=858993459&(b>>>2^(g^=f)))<<2,b^=f=65535&((g^=f)>>>16^b),b^=f=252645135&((g^=f<<16)>>>4^b),g^=f<<4,r[0]=g,r[1]=b}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},45:e=>{e.exports={options:{usePureJavaScript:!1}}},8163:(e,t,r)=>{var n=r(45);r(5693),r(3900),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,o={start:function(o,s){if(null!==o)if("string"===typeof o){if(!((o=o.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+o+'"');t=n.md.algorithms[o].create()}else t=o;if(null===s)s=e;else{if("string"===typeof s)s=n.util.createBuffer(s);else if(n.util.isArray(s)){var a=s;s=n.util.createBuffer();for(var c=0;c<a.length;++c)s.putByte(a[c])}var u=s.length();u>t.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=s.length();for(c=0;c<u;++c){a=s.at(c);r.putByte(54^a),i.putByte(92^a)}if(u<t.blockLength)for(a=t.blockLength-u,c=0;c<a;++c)r.putByte(54),i.putByte(92);e=s,r=r.bytes(),i=i.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(i),t.update(e),t.digest()}};return o.digest=o.getMac,o}},9463:(e,t,r)=>{var n,i=r(45);e.exports=i.jsbn=i.jsbn||{};function o(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function s(){return new o(null)}function a(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=a*c+u*s;i=((c=s*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=o,"undefined"===typeof navigator?(o.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=a*c+u*s;i=((c=s*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},n=26):(o.prototype.am=a,n=28),o.prototype.DB=n,o.prototype.DM=(1<<n)-1,o.prototype.DV=1<<n;o.prototype.FV=Math.pow(2,52),o.prototype.F1=52-n,o.prototype.F2=2*n-52;var c,u,l="0123456789abcdefghijklmnopqrstuvwxyz",h=new Array;for(c="0".charCodeAt(0),u=0;u<=9;++u)h[c++]=u;for(c="a".charCodeAt(0),u=10;u<36;++u)h[c++]=u;for(c="A".charCodeAt(0),u=10;u<36;++u)h[c++]=u;function d(e){return l.charAt(e)}function f(e,t){var r=h[e.charCodeAt(t)];return null==r?-1:r}function p(e){var t=s();return t.fromInt(e),t}function g(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function b(e){this.m=e}function y(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function m(e,t){return e&t}function v(e,t){return e|t}function w(e,t){return e^t}function _(e,t){return e&~t}function E(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function A(){}function k(e){return e}function x(e){this.r2=s(),this.q3=s(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}b.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},b.prototype.revert=function(e){return e},b.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},b.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},y.prototype.convert=function(e){var t=s();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},y.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},y.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var a=8==r?255&e[n]:f(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this.data[this.t++]=a:s+r>this.DB?(this.data[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this.data[this.t++]=a>>this.DB-s):this.data[this.t-1]|=a<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&o.ZERO.subTo(this,this)},o.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},o.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,o=(1<<i)-1,s=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+s+1]=this.data[r]>>i|a,a=(this.data[r]&o)<<n;for(r=s-1;r>=0;--r)t.data[r]=0;t.data[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var s=r+1;s<this.t;++s)t.data[s-r-1]|=(this.data[s]&o)<<i,t.data[s-r]=this.data[s]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<<i),t.t=this.t-r,t.clamp()}},o.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},o.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i<n.t;++i)t.data[i+r.t]=r.am(0,n.data[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&o.ZERO.subTo(t,t)},o.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=s());var a=s(),c=this.s,u=e.s,l=this.DB-g(n.data[n.t-1]);l>0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a.data[h-1];if(0!=d){var f=d*(1<<this.F1)+(h>1?a.data[h-2]>>this.F2:0),p=this.FV/f,b=(1<<this.F1)/f,y=1<<this.F2,m=r.t,v=m-h,w=null==t?s():t;for(a.dlShiftTo(v,w),r.compareTo(w)>=0&&(r.data[r.t++]=1,r.subTo(w,r)),o.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t<h;)a.data[a.t++]=0;for(;--v>=0;){var _=r.data[--m]==d?this.DM:Math.floor(r.data[m]*p+(r.data[m-1]+y)*b);if((r.data[m]+=a.am(0,_,r,v,0,h))<_)for(a.dlShiftTo(v,w),r.subTo(w,r);r.data[m]<--_;)r.subTo(w,r)}null!=t&&(r.drShiftTo(h,t),c!=u&&o.ZERO.subTo(t,t)),r.t=h,r.clamp(),l>0&&r.rShiftTo(l,r),c<0&&o.ZERO.subTo(r,r)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var r=s(),n=s(),i=t.convert(this),a=g(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<<a)>0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this.data[s]>>a)>0&&(i=!0,o=d(r));s>=0;)a<t?(r=(this.data[s]&(1<<a)-1)<<t-a,r|=this.data[--s]>>(a+=this.DB-t)):(r=this.data[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=d(r));return i?o:"0"},o.prototype.negate=function(){var e=s();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+g(this.data[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=s();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new b(t):new y(t),this.exp(e,r)},o.ZERO=p(0),o.ONE=p(1),A.prototype.convert=k,A.prototype.revert=k,A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},A.prototype.sqrTo=function(e,t){e.squareTo(t)},x.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=s();return e.copyTo(t),this.reduce(t),t},x.prototype.revert=function(e){return e},x.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},x.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},x.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var I=[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],C=(1<<26)/I[I.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=p(r),i=s(),o=s(),a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,s=0,a=0,c=0;c<e.length;++c){var u=f(e,c);u<0?"-"==e.charAt(c)&&0==this.signum()&&(i=!0):(a=t*a+u,++s>=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),i&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),v,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},o.prototype.bitwiseTo=function(e,t,r){var n,i,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},o.prototype.changeBit=function(e,t){var r=o.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},o.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},o.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},o.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},o.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},o.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),s={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},a=0;a<e;++a){do{n=new o(this.bitLength(),s)}while(n.compareTo(o.ONE)<=0||n.compareTo(t)>=0);var c=n.modPow(i,this);if(0!=c.compareTo(o.ONE)&&0!=c.compareTo(t)){for(var u=1;u++<r&&0!=c.compareTo(t);)if(0==(c=c.modPowInt(2,this)).compareTo(o.ONE))return!1;if(0!=c.compareTo(t))return!1}}return!0},o.prototype.clone=function(){var e=s();return this.copyTo(e),e},o.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},o.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=s();return this.bitwiseTo(e,m,t),t},o.prototype.or=function(e){var t=s();return this.bitwiseTo(e,v,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,w,t),t},o.prototype.andNot=function(e){var t=s();return this.bitwiseTo(e,_,t),t},o.prototype.not=function(){for(var e=s(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},o.prototype.shiftLeft=function(e){var t=s();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},o.prototype.shiftRight=function(e){var t=s();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},o.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+E(this.data[e]);return this.s<0?this.t*this.DB:-1},o.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=S(this.data[r]^t);return e},o.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},o.prototype.setBit=function(e){return this.changeBit(e,v)},o.prototype.clearBit=function(e){return this.changeBit(e,_)},o.prototype.flipBit=function(e){return this.changeBit(e,w)},o.prototype.add=function(e){var t=s();return this.addTo(e,t),t},o.prototype.subtract=function(e){var t=s();return this.subTo(e,t),t},o.prototype.multiply=function(e){var t=s();return this.multiplyTo(e,t),t},o.prototype.divide=function(e){var t=s();return this.divRemTo(e,t,null),t},o.prototype.remainder=function(e){var t=s();return this.divRemTo(e,null,t),t},o.prototype.divideAndRemainder=function(e){var t=s(),r=s();return this.divRemTo(e,t,r),new Array(t,r)},o.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),o=p(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new b(t):t.isEven()?new x(t):new y(t);var a=new Array,c=3,u=r-1,l=(1<<r)-1;if(a[1]=n.convert(this),r>1){var h=s();for(n.sqrTo(a[1],h);c<=l;)a[c]=s(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,f,m=e.t-1,v=!0,w=s();for(i=g(e.data[m])-1;m>=0;){for(i>=u?d=e.data[m]>>i-u&l:(d=(e.data[m]&(1<<i+1)-1)<<u-i,m>0&&(d|=e.data[m-1]>>this.DB+i-u)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),v)a[d].copyTo(o),v=!1;else{for(;c>1;)n.sqrTo(o,w),n.sqrTo(w,o),c-=2;c>0?n.sqrTo(o,w):(f=o,o=w,w=f),n.mulTo(w,a[d],o)}for(;m>=0&&0==(e.data[m]&1<<i);)n.sqrTo(o,w),f=o,o=w,w=f,--i<0&&(i=this.DB-1,--m)}return n.revert(o)},o.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return o.ZERO;for(var r=e.clone(),n=this.clone(),i=p(1),s=p(0),a=p(0),c=p(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&s.isEven()||(i.addTo(this,i),s.subTo(e,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),t?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(e,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(a,i),s.subTo(c,s)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(s,c))}return 0!=n.compareTo(o.ONE)?o.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},o.prototype.pow=function(e){return this.exp(e,new A)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},o.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=I[I.length-1]){for(t=0;t<I.length;++t)if(r.data[0]==I[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<I.length;){for(var n=I[t],i=t+1;i<I.length&&n<C;)n*=I[i++];for(n=r.modInt(n);t<i;)if(n%I[t++]==0)return!1}return r.millerRabin(e)}},5693:(e,t,r)=>{var n=r(45);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},3225:(e,t,r)=>{var n=r(45);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function o(e,t){i[e]=t,i[t]=e}function s(e,t){i[e]=t}o("1.2.840.113549.1.1.1","rsaEncryption"),o("1.2.840.113549.1.1.4","md5WithRSAEncryption"),o("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),o("1.2.840.113549.1.1.7","RSAES-OAEP"),o("1.2.840.113549.1.1.8","mgf1"),o("1.2.840.113549.1.1.9","pSpecified"),o("1.2.840.113549.1.1.10","RSASSA-PSS"),o("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),o("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),o("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),o("1.3.101.112","EdDSA25519"),o("1.2.840.10040.4.3","dsa-with-sha1"),o("1.3.14.3.2.7","desCBC"),o("1.3.14.3.2.26","sha1"),o("1.3.14.3.2.29","sha1WithRSASignature"),o("2.16.840.1.101.3.4.2.1","sha256"),o("2.16.840.1.101.3.4.2.2","sha384"),o("2.16.840.1.101.3.4.2.3","sha512"),o("2.16.840.1.101.3.4.2.4","sha224"),o("2.16.840.1.101.3.4.2.5","sha512-224"),o("2.16.840.1.101.3.4.2.6","sha512-256"),o("1.2.840.113549.2.2","md2"),o("1.2.840.113549.2.5","md5"),o("1.2.840.113549.1.7.1","data"),o("1.2.840.113549.1.7.2","signedData"),o("1.2.840.113549.1.7.3","envelopedData"),o("1.2.840.113549.1.7.4","signedAndEnvelopedData"),o("1.2.840.113549.1.7.5","digestedData"),o("1.2.840.113549.1.7.6","encryptedData"),o("1.2.840.113549.1.9.1","emailAddress"),o("1.2.840.113549.1.9.2","unstructuredName"),o("1.2.840.113549.1.9.3","contentType"),o("1.2.840.113549.1.9.4","messageDigest"),o("1.2.840.113549.1.9.5","signingTime"),o("1.2.840.113549.1.9.6","counterSignature"),o("1.2.840.113549.1.9.7","challengePassword"),o("1.2.840.113549.1.9.8","unstructuredAddress"),o("1.2.840.113549.1.9.14","extensionRequest"),o("1.2.840.113549.1.9.20","friendlyName"),o("1.2.840.113549.1.9.21","localKeyId"),o("1.2.840.113549.1.9.22.1","x509Certificate"),o("1.2.840.113549.1.12.10.1.1","keyBag"),o("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),o("1.2.840.113549.1.12.10.1.3","certBag"),o("1.2.840.113549.1.12.10.1.4","crlBag"),o("1.2.840.113549.1.12.10.1.5","secretBag"),o("1.2.840.113549.1.12.10.1.6","safeContentsBag"),o("1.2.840.113549.1.5.13","pkcs5PBES2"),o("1.2.840.113549.1.5.12","pkcs5PBKDF2"),o("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),o("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),o("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),o("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),o("1.2.840.113549.2.7","hmacWithSHA1"),o("1.2.840.113549.2.8","hmacWithSHA224"),o("1.2.840.113549.2.9","hmacWithSHA256"),o("1.2.840.113549.2.10","hmacWithSHA384"),o("1.2.840.113549.2.11","hmacWithSHA512"),o("1.2.840.113549.3.7","des-EDE3-CBC"),o("2.16.840.1.101.3.4.1.2","aes128-CBC"),o("2.16.840.1.101.3.4.1.22","aes192-CBC"),o("2.16.840.1.101.3.4.1.42","aes256-CBC"),o("2.5.4.3","commonName"),o("2.5.4.4","surname"),o("2.5.4.5","serialNumber"),o("2.5.4.6","countryName"),o("2.5.4.7","localityName"),o("2.5.4.8","stateOrProvinceName"),o("2.5.4.9","streetAddress"),o("2.5.4.10","organizationName"),o("2.5.4.11","organizationalUnitName"),o("2.5.4.12","title"),o("2.5.4.13","description"),o("2.5.4.15","businessCategory"),o("2.5.4.17","postalCode"),o("2.5.4.42","givenName"),o("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),o("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),o("2.16.840.1.113730.1.1","nsCertType"),o("2.16.840.1.113730.1.13","nsComment"),s("2.5.29.1","authorityKeyIdentifier"),s("2.5.29.2","keyAttributes"),s("2.5.29.3","certificatePolicies"),s("2.5.29.4","keyUsageRestriction"),s("2.5.29.5","policyMapping"),s("2.5.29.6","subtreesConstraint"),s("2.5.29.7","subjectAltName"),s("2.5.29.8","issuerAltName"),s("2.5.29.9","subjectDirectoryAttributes"),s("2.5.29.10","basicConstraints"),s("2.5.29.11","nameConstraints"),s("2.5.29.12","policyConstraints"),s("2.5.29.13","basicConstraints"),o("2.5.29.14","subjectKeyIdentifier"),o("2.5.29.15","keyUsage"),s("2.5.29.16","privateKeyUsagePeriod"),o("2.5.29.17","subjectAltName"),o("2.5.29.18","issuerAltName"),o("2.5.29.19","basicConstraints"),s("2.5.29.20","cRLNumber"),s("2.5.29.21","cRLReason"),s("2.5.29.22","expirationDate"),s("2.5.29.23","instructionCode"),s("2.5.29.24","invalidityDate"),s("2.5.29.25","cRLDistributionPoints"),s("2.5.29.26","issuingDistributionPoint"),s("2.5.29.27","deltaCRLIndicator"),s("2.5.29.28","issuingDistributionPoint"),s("2.5.29.29","certificateIssuer"),s("2.5.29.30","nameConstraints"),o("2.5.29.31","cRLDistributionPoints"),o("2.5.29.32","certificatePolicies"),s("2.5.29.33","policyMappings"),s("2.5.29.34","policyConstraints"),o("2.5.29.35","authorityKeyIdentifier"),s("2.5.29.36","policyConstraints"),o("2.5.29.37","extKeyUsage"),s("2.5.29.46","freshestCRL"),s("2.5.29.54","inhibitAnyPolicy"),o("1.3.6.1.4.1.11129.2.4.2","timestampList"),o("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),o("1.3.6.1.5.5.7.3.1","serverAuth"),o("1.3.6.1.5.5.7.3.2","clientAuth"),o("1.3.6.1.5.5.7.3.3","codeSigning"),o("1.3.6.1.5.5.7.3.4","emailProtection"),o("1.3.6.1.5.5.7.3.8","timeStamping")},3555:(e,t,r)=>{var n=r(45);if(r(9353),r(5465),r(2986),r(5693),r(3225),r(8009),r(5224),r(2795),r(1577),r(9408),r(3900),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.asn1,s=n.pki=n.pki||{};e.exports=s.pbe=n.pbe=n.pbe||{};var a=s.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},l={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=s.oids[o.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return f(t)}function f(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}s.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,u,l=n.random.getBytesSync(r.saltSize),h=r.count,d=o.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,g,b;switch(r.algorithm){case"aes128":i=16,p=16,g=a["aes128-CBC"],b=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,g=a["aes192-CBC"],b=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,g=a["aes256-CBC"],b=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,g=a.desCBC,b=n.des.createEncryptionCipher;break;default:throw(E=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,E}var y="hmacWith"+r.prfAlgorithm.toUpperCase(),m=f(y),v=n.pkcs5.pbkdf2(t,l,h,i,m),w=n.random.getBytesSync(p);(S=b(v)).start(w),S.update(o.toDer(e)),S.finish(),u=S.output.getBytes();var _=function(e,t,r,i){var a=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.oids[i]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]));return a}(l,d,i,y);c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBKDF2).getBytes()),_]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(g).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,w)])])])}else{var E;if("3des"!==r.algorithm)throw(E=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,E;i=24;var S,A=new n.util.ByteBuffer(l);v=s.pbe.generatePkcs12Key(t,A,1,h,i),w=s.pbe.generatePkcs12Key(t,A,2,h,i);(S=n.des.createEncryptionCipher(v)).start(w),S.update(o.toDer(e)),S.finish(),u=S.output.getBytes(),c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,l),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,d.getBytes())])])}return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[c,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)])},s.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!o.validate(e,c,i,a)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=a,u}var l=o.derToOid(i.encryptionOid),h=s.pbe.getCipher(l,i.encryptionParams,t),d=n.util.createBuffer(i.encryptedData);return h.update(d),h.finish()&&(r=o.fromDer(h.output)),r},s.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},s.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return o.fromDer(t.body)},s.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=s.wrapRsaPrivateKey(s.privateKeyToAsn1(e));return i=s.encryptPrivateKeyInfo(i,t,r),s.encryptedPrivateKeyToPem(i)}var a,c,u,l;switch(r.algorithm){case"aes128":a="AES-128-CBC",u=16,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",u=24,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",u=32,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",u=24,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",u=8,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var d=l(n.pbe.opensslDeriveBytes(t,c.substr(0,8),u));d.start(c),d.update(o.toDer(s.privateKeyToAsn1(e))),d.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:d.output.getBytes()};return n.pem.encode(f)},s.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var l=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,l.substr(0,8),a));if(h.start(l),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?s.decryptPrivateKeyInfo(o.fromDer(r),t):o.fromDer(r))&&(r=s.privateKeyFromAsn1(r)),r},s.pbe.generatePkcs12Key=function(e,t,r,i,o,s){var a,c;if("undefined"===typeof s||null===s){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');s=n.md.sha1.create()}var u=s.digestLength,l=s.blockLength,h=new n.util.ByteBuffer,d=new n.util.ByteBuffer;if(null!==e&&void 0!==e){for(c=0;c<e.length;c++)d.putInt16(e.charCodeAt(c));d.putInt16(0)}var f=d.length(),p=t.length(),g=new n.util.ByteBuffer;g.fillWithByte(r,l);var b=l*Math.ceil(p/l),y=new n.util.ByteBuffer;for(c=0;c<b;c++)y.putByte(t.at(c%p));var m=l*Math.ceil(f/l),v=new n.util.ByteBuffer;for(c=0;c<m;c++)v.putByte(d.at(c%f));var w=y;w.putBuffer(v);for(var _=Math.ceil(o/u),E=1;E<=_;E++){var S=new n.util.ByteBuffer;S.putBytes(g.bytes()),S.putBytes(w.bytes());for(var A=0;A<i;A++)s.start(),s.update(S.getBytes()),S=s.digest();var k=new n.util.ByteBuffer;for(c=0;c<l;c++)k.putByte(S.at(c%u));var x=Math.ceil(p/l)+Math.ceil(f/l),I=new n.util.ByteBuffer;for(a=0;a<x;a++){var C=new n.util.ByteBuffer(w.getBytes(l)),T=511;for(c=k.length()-1;c>=0;c--)T>>=8,T+=k.at(c)+C.at(c),C.setAt(c,255&T);I.putBuffer(C)}w=I,h.putBuffer(S)}return h.truncate(h.length()-o),h},s.pbe.getCipher=function(e,t,r){switch(e){case s.oids.pkcs5PBES2:return s.pbe.getCipherForPBES2(e,t,r);case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case s.oids["pbewithSHAAnd40BitRC2-CBC"]:return s.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},s.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!o.validate(t,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=o.derToOid(a.kdfOid))!==s.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=o.derToOid(a.encOid))!==s.oids["aes128-CBC"]&&e!==s.oids["aes192-CBC"]&&e!==s.oids["aes256-CBC"]&&e!==s.oids["des-EDE3-CBC"]&&e!==s.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var l,h,f=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),s.oids[e]){case"aes128-CBC":l=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,h=n.des.createDecryptionCipher;break;case"desCBC":l=8,h=n.des.createDecryptionCipher}var g=d(a.prfOid),b=n.pkcs5.pbkdf2(r,f,p,l,g),y=a.encIv,m=h(b);return m.start(y),m},s.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!o.validate(t,l,i,a))throw(g=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,g;var c,u,h,f=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,h=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var g;throw(g=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,g}var b=d(i.prfOid),y=s.pbe.generatePkcs12Key(r,f,1,p,c,b);return b.start(),h(y,s.pbe.generatePkcs12Key(r,f,2,p,u,b))},s.pbe.opensslDeriveBytes=function(e,t,r,i){if("undefined"===typeof i||null===i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var o=[h(i,e+t)],s=16,a=1;s<r;++a,s+=16)o.push(h(i,o[a-1]+e+t));return o.join("").substr(0,r)}},8009:(e,t,r)=>{var n=r(45);r(8163),r(5693),r(3900);var i,o=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(i=r(310)),e.exports=n.pbkdf2=o.pbkdf2=function(e,t,r,o,s,a){if("function"===typeof s&&(a=s,s=null),n.util.isNodejs&&!n.options.usePureJavaScript&&i.pbkdf2&&(null===s||"object"!==typeof s)&&(i.pbkdf2Sync.length>4||!s||"sha1"===s))return"string"!==typeof s&&(s="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===i.pbkdf2Sync.length?i.pbkdf2(e,t,r,o,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):i.pbkdf2(e,t,r,o,s,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(e,t,r,o).toString("binary"):i.pbkdf2Sync(e,t,r,o,s).toString("binary");if("undefined"!==typeof s&&null!==s||(s="sha1"),"string"===typeof s){if(!(s in n.md.algorithms))throw new Error("Unknown hash algorithm: "+s);s=n.md[s].create()}var c=s.digestLength;if(o>4294967295*c){var u=new Error("Derived key is too long.");if(a)return a(u);throw u}var l=Math.ceil(o/c),h=o-(l-1)*c,d=n.hmac.create();d.start(s,e);var f,p,g,b="";if(!a){for(var y=1;y<=l;++y){d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(y)),f=g=d.digest().getBytes();for(var m=2;m<=r;++m)d.start(null,null),d.update(g),p=d.digest().getBytes(),f=n.util.xorBytes(f,p,c),g=p;b+=y<l?f:f.substr(0,h)}return b}y=1;function v(){if(y>l)return a(null,b);d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(y)),f=g=d.digest().getBytes(),m=2,w()}function w(){if(m<=r)return d.start(null,null),d.update(g),p=d.digest().getBytes(),f=n.util.xorBytes(f,p,c),g=p,++m,n.util.setImmediate(w);b+=y<l?f:f.substr(0,h),++y,v()}v()}},5224:(e,t,r)=>{var n=r(45);r(3900);var i=e.exports=n.pem=n.pem||{};function o(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var o=0,s=-1;for(i=0;i<t.length;++i,++o)if(o>65&&-1!==s){var a=t[s];","===a?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),o=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function s(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=o(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=o(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=o(r)),e.headers)for(var s=0;s<e.headers.length;++s)i+=o(e.headers[s]);return e.procType&&(i+="\r\n"),i+=n.util.encode64(e.body,t.maxline||64)+"\r\n",i+="-----END "+e.type+"-----\r\n"},i.decode=function(e){for(var t,r=[],i=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,o=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\r?\n/;t=i.exec(e);){var c=t[1];"NEW CERTIFICATE REQUEST"===c&&(c="CERTIFICATE REQUEST");var u={type:c,procType:null,contentDomain:null,dekInfo:null,headers:[],body:n.util.decode64(t[3])};if(r.push(u),t[2]){for(var l=t[2].split(a),h=0;t&&h<l.length;){for(var d=l[h].replace(/\s+$/,""),f=h+1;f<l.length;++f){var p=l[f];if(!/\s/.test(p[0]))break;d+=p,h=f}if(t=d.match(o)){for(var g={name:t[1],values:[]},b=t[2].split(","),y=0;y<b.length;++y)g.values.push(s(b[y]));if(u.procType)if(u.contentDomain||"Content-Domain"!==g.name)if(u.dekInfo||"DEK-Info"!==g.name)u.headers.push(g);else{if(0===g.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');u.dekInfo={algorithm:b[0],parameters:b[1]||null}}else u.contentDomain=b[0]||"";else{if("Proc-Type"!==g.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==g.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');u.procType={version:b[0],type:b[1]}}}++h}if("ENCRYPTED"===u.procType&&!u.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r}},7668:(e,t,r)=>{var n=r(45);r(3900),r(2795),r(3753);var i=e.exports=n.pkcs1=n.pkcs1||{};function o(e,t,r){r||(r=n.md.sha1.create());for(var i="",o=Math.ceil(t/r.digestLength),s=0;s<o;++s){var a=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,255&s);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,s,a,c;"string"===typeof r?(i=r,s=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,s=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),l=u-2*a.digestLength-2;if(t.length>l)throw(b=new Error("RSAES-OAEP input message length is too long.")).length=t.length,b.maxLength=l,b;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",f=l-t.length,p=0;p<f;p++)d+="\0";var g=h.getBytes()+d+"\x01"+t;if(s){if(s.length!==a.digestLength){var b;throw(b=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=s.length,b.digestLength=a.digestLength,b}}else s=n.random.getBytes(a.digestLength);var y=o(s,u-a.digestLength-1,c),m=n.util.xorBytes(g,y,g.length),v=o(m,a.digestLength,c);return"\0"+n.util.xorBytes(s,v,s.length)+m},i.decode_rsa_oaep=function(e,t,r){var i,s,a;"string"===typeof r?(i=r,s=arguments[3]||void 0):r&&(i=r.label||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(a=r.mgf1.md));var c=Math.ceil(e.n.bitLength()/8);if(t.length!==c)throw(y=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,y.expectedLength=c,y;if(void 0===s?s=n.md.sha1.create():s.start(),a||(a=s),c<2*s.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");i||(i=""),s.update(i,"raw");for(var u=s.digest().getBytes(),l=t.charAt(0),h=t.substring(1,s.digestLength+1),d=t.substring(1+s.digestLength),f=o(d,s.digestLength,a),p=o(n.util.xorBytes(h,f,h.length),c-s.digestLength-1,a),g=n.util.xorBytes(d,p,d.length),b=g.substring(0,s.digestLength),y="\0"!==l,m=0;m<s.digestLength;++m)y|=u.charAt(m)!==b.charAt(m);for(var v=1,w=s.digestLength,_=s.digestLength;_<g.length;_++){var E=g.charCodeAt(_);y|=E&(v?65534:0),w+=v&=1&E^1}if(y||1!==g.charCodeAt(w))throw new Error("Invalid RSAES-OAEP padding.");return g.substring(w+1)}},8353:(e,t,r)=>{var n=r(45);r(3900),r(9463),r(2795),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],o=new r(null);o.fromInt(30);var s=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"===typeof t&&(i=t,t={});var o=(t=t||{}).algorithm||"PRIMEINC";"string"===typeof o&&(o={name:o}),o.options=o.options||{};var s=t.prng||n.random,c={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===o.name)return function(e,t,i,o){if("workers"in i)return function(e,t,i,o){if("undefined"===typeof Worker)return a(e,t,i,o);var s=u(e,t),c=i.workers,l=i.workLoad||100,h=30*l/8,d=i.workerScript||"forge/prime.worker.js";if(-1===c)return n.util.estimateCores((function(e,t){e&&(t=2),c=t-1,f()}));function f(){c=Math.max(1,c);for(var n=[],i=0;i<c;++i)n[i]=new Worker(d);for(i=0;i<c;++i)n[i].addEventListener("message",f);var a=!1;function f(i){if(!a){0;var c=i.data;if(c.found){for(var d=0;d<n.length;++d)n[d].terminate();return a=!0,o(null,new r(c.prime,16))}s.bitLength()>e&&(s=u(e,t));var f=s.toString(16);i.target.postMessage({hex:f,workLoad:l}),s.dAddOffset(h,0)}}}f()}(e,t,i,o);return a(e,t,i,o)}(e,c,o.options,i);throw new Error("Invalid prime generation algorithm: "+o.name)}}function a(e,t,r,n){var i=u(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var s=10;"maxBlockTime"in r&&(s=r.maxBlockTime),c(i,e,t,0,o,s,n)}function c(e,t,r,o,s,a,l){var h=+new Date;do{if(e.bitLength()>t&&(e=u(t,r)),e.isProbablePrime(s))return l(null,e);e.dAddOffset(i[o++%8],0)}while(a<0||+new Date-h<a);n.util.setImmediate((function(){c(e,t,r,o,s,a,l)}))}function u(e,t){var n=new r(e,t),i=e-1;return n.testBit(i)||n.bitwiseTo(r.ONE.shiftLeft(i),s,n),n.dAddOffset(31-n.mod(o).byteValue(),0),n}}()},1513:(e,t,r)=>{var n=r(45);r(3900);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||process.versions["node-webkit"]||(i=r(310)),(e.exports=n.prng=n.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,o=new Array(32),s=0;s<32;++s)o[s]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r===0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var o=n.util.createBuffer();if(t)for(;o.length()<e;){var s=Math.max(1,Math.min(e-o.length(),65536)/4),a=new Uint32Array(Math.floor(s));try{t(a);for(var c=0;c<a.length;++c)o.putInt32(a[c])}catch(f){if(!("undefined"!==typeof QuotaExceededError&&f instanceof QuotaExceededError))throw f}}if(o.length()<e)for(var u,l,h,d=Math.floor(65536*Math.random());o.length()<e;){l=16807*(65535&d),l+=(32767&(u=16807*(d>>16)))<<16,d=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)h=d>>>(c<<3),h^=Math.floor(256*Math.random()),o.putByte(255&h)}return o.getBytes(e)}return t.pools=o,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,o=t.plugin.increment,s=t.plugin.formatKey,a=t.plugin.formatSeed,u=n.util.createBuffer();t.key=null,function l(h){if(h)return r(h);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(l)}));var d=i(t.key,t.seed);t.generated+=d.length,u.putBytes(d),t.key=s(i(t.key,o(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,o=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var c=n.util.createBuffer();c.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=o(r(t.key,i(t.seed))),t.seed=s(r(t.key,t.seed))}return c.getBytes(e)},i?(t.seedFile=function(e,t){i.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return i.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(r){t(r)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",i=0;i<r;i+=8)n+=String.fromCharCode(e>>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},2795:(e,t,r)=>{var n=r(45);r(9353),r(3899),r(1513),r(3900),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),o=n.util.createBuffer();function s(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),o.putInt32(i[0]),o.putInt32(i[1]),o.putInt32(i[2]),o.putInt32(i[3]),o.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=s(),c=null,u=n.util.globalScope,l=u.crypto||u.msCrypto;if(l&&l.getRandomValues&&(c=function(e){return l.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"===typeof window||window.document,a.collectInt(+new Date,32),"undefined"!==typeof navigator){var h="";for(var d in navigator)try{"string"==typeof navigator[d]&&(h+=navigator[d])}catch(f){}a.collect(h),h=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(n.random)for(var d in a)n.random[d]=a[d];else n.random=a;n.random.createInstance=s,e.exports=n.random}("undefined"!==typeof jQuery?jQuery:null)},1577:(e,t,r)=>{var n=r(45);r(3900);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],o=[1,2,3,5],s=function(e,t){return e<<t&65535|(65535&e)>>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"===typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,o=e,s=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=s;r<128;r++)o.putByte(i[o.at(r-1)+o.at(r-s)&255]);for(o.setAt(128-c,i[o.at(128-c)&u]),r=127-c;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+c)]);return o};var c=function(e,t,r){var i,c,u,l,h=!1,d=null,f=null,p=null,g=[];for(e=n.rc2.expandKey(e,t),u=0;u<64;u++)g.push(e.getInt16Le());r?(i=function(e){for(u=0;u<4;u++)e[u]+=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=s(e[u],o[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=g[63&e[(u+3)%4]]}):(i=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],o[u]),e[u]-=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=g[63&e[(u+3)%4]]});var b=function(e){var t=[];for(u=0;u<4;u++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}l=r?0:63;for(var i=0;i<e.length;i++)for(var o=0;o<e[i][0];o++)e[i][1](t);for(u=0;u<4;u++)null!==p&&(r?p.putInt16Le(t[u]):t[u]^=p.getInt16Le()),f.putInt16Le(t[u])},y=null;return y={start:function(e,t){e&&"string"===typeof e&&(e=n.util.createBuffer(e)),h=!1,d=n.util.createBuffer(),f=t||new n.util.createBuffer,p=e,y.output=f},update:function(e){for(h||d.putBuffer(e);d.length()>=8;)b([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,d,!r);else{var n=8===d.length()?8:8-d.length();d.fillWithByte(n,n)}if(t&&(h=!0,y.update()),!r&&(t=0===d.length()))if(e)t=e(8,f,!r);else{var i=f.length(),o=f.at(i-1);o>i?t=!1:f.truncate(o)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},9408:(e,t,r)=>{var n=r(45);if(r(5465),r(9463),r(3225),r(7668),r(8353),r(2795),r(3900),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.util.isNodejs?r(310):null,s=n.asn1,a=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},h={name:"RSAPrivateKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},d={name:"RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p={name:"DigestInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:s.Class.UNIVERSAL,type:s.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},g=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var n=s.oidToDer(t).getBytes(),i=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]),o=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]);o.value.push(s.create(s.Class.UNIVERSAL,s.Type.OID,!1,n)),o.value.push(s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,""));var a=s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(a),s.toDer(i).getBytes()},b=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var o;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{o=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(o.compareTo(t.n)>=0||!o.gcd(t.n).equals(i.ONE));for(var s=(e=e.multiply(o.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);s.compareTo(a)<0;)s=s.add(t.p);var c=s.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(o.modInverse(t.n)).mod(t.n)};function y(e,t,r){var i=n.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=o-11,s}i.putByte(0),i.putByte(r);var a,c=o-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u<c;++u)i.putByte(a)}else for(;c>0;){var l=0,h=n.random.getBytes(c);for(u=0;u<c;++u)0===(a=h.charCodeAt(u))?++l:i.putByte(a);c=l}return i.putByte(0),i.putBytes(e),i}function m(e,t,r,i){var o=Math.ceil(t.n.bitLength()/8),s=n.util.createBuffer(e),a=s.getByte(),c=s.getByte();if(0!==a||r&&0!==c&&1!==c||!r&&2!=c||r&&0===c&&"undefined"===typeof i)throw new Error("Encryption block is invalid.");var u=0;if(0===c){u=o-3-i;for(var l=0;l<u;++l)if(0!==s.getByte())throw new Error("Encryption block is invalid.")}else if(1===c)for(u=0;s.length()>1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function v(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0===(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128===(128&r.charCodeAt(1)))?r.substr(1):r}function w(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _(e){return n.util.isNodejs&&"function"===typeof o[e]}function E(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.crypto&&"object"===typeof a.globalScope.crypto.subtle&&"function"===typeof a.globalScope.crypto.subtle[e]}function S(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.msCrypto&&"object"===typeof a.globalScope.msCrypto.subtle&&"function"===typeof a.globalScope.msCrypto.subtle[e]}function A(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i<t.length;++i)r[i]=t.charCodeAt(i);return r}c.rsa.encrypt=function(e,t,r){var o,s=r,a=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(s=2===r,o=y(e,t,r)):(o=n.util.createBuffer()).putBytes(e);for(var c=new i(o.toHex(),16),u=b(c,t,s).toString(16),l=n.util.createBuffer(),h=a-Math.ceil(u.length/2);h>0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,r,o){var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=s,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=b(c,t,r).toString(16),l=n.util.createBuffer(),h=s-Math.ceil(u.length/2);h>0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),!1!==o?m(l.getBytes(),t,r):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"===typeof e&&(e=parseInt(e,10)),e=e||2048;var o,s=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},c=r.algorithm||"PRIMEINC";if("PRIMEINC"!==c)throw new Error("Invalid key generation algorithm: "+c);return(o={algorithm:c,state:0,bits:e,rng:a,eInt:t||65537,e:new i(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(o.eInt),o},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,s=function(e,t){return e|t},a=+new Date,l=0;null===e.keys&&(t<=0||l<t);){if(0===e.state){var h=null===e.p?e.pBits:e.qBits,d=h-1;0===e.pqState?(e.num=new i(h,e.rng),e.num.testBit(d)||e.num.bitwiseTo(i.ONE.shiftLeft(d),s,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),o=0,++e.pqState):1===e.pqState?e.num.bitLength()>h?e.pqState=0:e.num.isProbablePrime(w(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[o++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}l+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,u){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(u=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(u=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,u=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(u=r,r=void 0):(u=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(u){if(_("generateKeyPair"))return o.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return u(e);u(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(E("generateKey")&&E("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:A(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){u(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(e)));u(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(S("generateKey")&&S("exportKey")){var l=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:A(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return l.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(t)));u(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){u(e)}},void(l.onerror=function(e){u(e)})}}else if(_("generateKeyPairSync")){var h=o.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(h.privateKey),publicKey:c.publicKeyFromPem(h.publicKey)}}var d=c.rsa.createKeyPairGenerationState(e,t,r);if(!u)return c.rsa.stepKeyPairGenerationState(d,0),d.keys;!function(e,t,r){"function"===typeof t&&(r=t,t={});t=t||{};var o={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(o.prng=t.prng);function s(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){n.prime.generateProbablePrime(e,o,t)}function u(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void s();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void s();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}s()}(d,r,u)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return y(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"===typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var o=t.encode(e,r,!0);return c.rsa.encrypt(o,r,!0)},verify:function(e,t,i,o){"string"===typeof i?i=i.toUpperCase():void 0===i&&(i="RSASSA-PKCS1-V1_5"),void 0===o&&(o={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in o||(o._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===i?i={verify:function(e,t){t=m(t,r,!0);var i=s.fromDer(t,{parseAllBytes:o._parseAllDigestBytes}),a={},c=[];if(!s.validate(i,p,a,c))throw(u=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=c,u;var u,l=s.derToOid(a.algorithmIdentifier);if(l!==n.oids.md2&&l!==n.oids.md5&&l!==n.oids.sha1&&l!==n.oids.sha224&&l!==n.oids.sha256&&l!==n.oids.sha384&&l!==n.oids.sha512&&l!==n.oids["sha512-224"]&&l!==n.oids["sha512-256"])throw(u=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=l,u;if((l===n.oids.md2||l===n.oids.md5)&&!("parameters"in a))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return e===a.digest}}:"NONE"!==i&&"NULL"!==i&&null!==i||(i={verify:function(e,t){return e===(t=m(t,r,!0))}});var a=c.rsa.decrypt(t,r,!0,!1);return i.verify(e,a,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,o,s,a,u){var l={n:e,e:t,d:r,p:i,q:o,dP:s,dQ:a,qInv:u,decrypt:function(e,t,r){"string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,l,!1)},sign:function(e,t){var r=!1;"string"===typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:g},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,l.n.bitLength());return c.rsa.encrypt(n,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,s.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,o,a,u,d,f,p,g={},b=[];if(s.validate(e,l,g,b)&&(e=s.fromDer(n.util.createBuffer(g.privateKey))),g={},b=[],!s.validate(e,h,g,b)){var y=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw y.errors=b,y}return t=n.util.createBuffer(g.privateKeyModulus).toHex(),r=n.util.createBuffer(g.privateKeyPublicExponent).toHex(),o=n.util.createBuffer(g.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(g.privateKeyPrime1).toHex(),u=n.util.createBuffer(g.privateKeyPrime2).toHex(),d=n.util.createBuffer(g.privateKeyExponent1).toHex(),f=n.util.createBuffer(g.privateKeyExponent2).toHex(),p=n.util.createBuffer(g.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(o,16),new i(a,16),new i(u,16),new i(d,16),new i(f,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.e)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.d)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.p)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.q)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.dP)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.dQ)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(s.validate(e,f,t,r)){var o,a=s.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(o=new Error("Cannot read public key. Unknown OID.")).oid=a,o;e=t.rsaPublicKey}if(r=[],!s.validate(e,d,t,r))throw(o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,o;var u=n.util.createBuffer(t.publicKeyModulus).toHex(),l=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.e))])}},3753:(e,t,r)=>{var n=r(45);r(5693),r(3900);var i=e.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=i,i.create=function(){s||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),s=!0);var e=null,t=n.util.createBuffer(),r=new Array(80),i={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o<r;++o)i.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},i}};return i.start(),i.update=function(o,s){"utf8"===s&&(o=n.util.encodeUtf8(o));var c=o.length;i.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(o),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h<i.fullMessageLength.length-1;++h)l+=(c=8*i.fullMessageLength[h+1])/4294967296>>>0,s.putInt32(l>>>0),l=c>>>0;s.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(d,r,s);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},i};var o=null,s=!1;function a(e,t,r){for(var n,i,o,s,a,c,u,l=r.length();l>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o&s|a&(o^s))+c+2400959708+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+3395469782+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+s|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,l-=64}}},3899:(e,t,r)=>{var n=r(45);r(5693),r(3900);var i=e.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=i,i.create=function(){s||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=!0);var e=null,t=n.util.createBuffer(),r=new Array(64),i={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o<r;++o)i.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},i}};return i.start(),i.update=function(o,s){"utf8"===s&&(o=n.util.encodeUtf8(o));var a=o.length;i.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(o),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h<i.fullMessageLength.length-1;++h)l+=(a=8*i.fullMessageLength[h+1])/4294967296>>>0,s.putInt32(l>>>0),l=a>>>0;s.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(d,r,s);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},i};var o=null,s=!1,a=null;function c(e,t,r){for(var n,i,o,s,c,u,l,h,d,f,p,g,b,y=r.length();y>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,l=e.h1,h=e.h2,d=e.h3,f=e.h4,p=e.h5,g=e.h6,b=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|h&(u^l),n=b+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(g^f&(p^g))+a[c]+t[c],b=g,g=p,p=f,f=d+n>>>0,d=h,h=l,l=u,u=n+(i=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+f|0,e.h5=e.h5+p|0,e.h6=e.h6+g|0,e.h7=e.h7+b|0,y-=64}}},8138:(e,t,r)=>{var n=r(45);r(5693),r(3900);var i=e.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var o=n.sha384=n.sha512.sha384=n.sha512.sha384||{};o.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=o,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(e){if(a||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),"undefined"===typeof e&&(e="SHA-512"),!(e in u))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=u[e],r=null,i=n.util.createBuffer(),o=new Array(80),h=0;h<80;++h)o[h]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,o=0;o<e;++o)f.fullMessageLength.push(0);i=n.util.createBuffer(),r=new Array(t.length);for(o=0;o<t.length;++o)r[o]=t[o].slice(0);return f}};return f.start(),f.update=function(e,t){"utf8"===t&&(e=n.util.encodeUtf8(e));var s=e.length;f.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var a=f.fullMessageLength.length-1;a>=0;--a)f.fullMessageLength[a]+=s[1],s[1]=s[0]+(f.fullMessageLength[a]/4294967296>>>0),f.fullMessageLength[a]=f.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(e),l(r,o,i),(i.read>2048||0===i.length())&&i.compact(),f},f.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(s.substr(0,f.blockLength-c));for(var u=8*f.fullMessageLength[0],h=0;h<f.fullMessageLength.length-1;++h)u+=(a=8*f.fullMessageLength[h+1])/4294967296>>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var d=new Array(r.length);for(h=0;h<r.length;++h)d[h]=r[h].slice(0);l(d,o,t);var p,g=n.util.createBuffer();p="SHA-512"===e?d.length:"SHA-384"===e?d.length-2:d.length-4;for(h=0;h<p;++h)g.putInt32(d[h][0]),h===p-1&&"SHA-512/224"===e||g.putInt32(d[h][1]);return g},f};var s=null,a=!1,c=null,u=null;function l(e,t,r){for(var n,i,o,s,a,u,l,h,d,f,p,g,b,y,m,v,w,_,E,S,A,k,x,I,C,T,R,P,D,N,B,U,L,M=r.length();M>=128;){for(R=0;R<16;++R)t[R][0]=r.getInt32()>>>0,t[R][1]=r.getInt32()>>>0;for(;R<80;++R)n=(((P=(N=t[R-2])[0])>>>19|(D=N[1])<<13)^(D>>>29|P<<3)^P>>>6)>>>0,i=((P<<13|D>>>19)^(D<<3|P>>>29)^(P<<26|D>>>6))>>>0,o=(((P=(U=t[R-15])[0])>>>1|(D=U[1])<<31)^(P>>>8|D<<24)^P>>>7)>>>0,s=((P<<31|D>>>1)^(P<<24|D>>>8)^(P<<25|D>>>7))>>>0,B=t[R-7],L=t[R-16],D=i+B[1]+s+L[1],t[R][0]=n+B[0]+o+L[0]+(D/4294967296>>>0)>>>0,t[R][1]=D>>>0;for(p=e[0][0],g=e[0][1],b=e[1][0],y=e[1][1],m=e[2][0],v=e[2][1],w=e[3][0],_=e[3][1],E=e[4][0],S=e[4][1],A=e[5][0],k=e[5][1],x=e[6][0],I=e[6][1],C=e[7][0],T=e[7][1],R=0;R<80;++R)l=((E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23))>>>0,h=(x^E&(A^x))>>>0,a=((p>>>28|g<<4)^(g>>>2|p<<30)^(g>>>7|p<<25))>>>0,u=((p<<4|g>>>28)^(g<<30|p>>>2)^(g<<25|p>>>7))>>>0,d=(p&b|m&(p^b))>>>0,f=(g&y|v&(g^y))>>>0,D=T+(((E<<18|S>>>14)^(E<<14|S>>>18)^(S<<23|E>>>9))>>>0)+((I^S&(k^I))>>>0)+c[R][1]+t[R][1],n=C+l+h+c[R][0]+t[R][0]+(D/4294967296>>>0)>>>0,i=D>>>0,o=a+d+((D=u+f)/4294967296>>>0)>>>0,s=D>>>0,C=x,T=I,x=A,I=k,A=E,k=S,E=w+n+((D=_+i)/4294967296>>>0)>>>0,S=D>>>0,w=m,_=v,m=b,v=y,b=p,y=g,p=n+o+((D=i+s)/4294967296>>>0)>>>0,g=D>>>0;D=e[0][1]+g,e[0][0]=e[0][0]+p+(D/4294967296>>>0)>>>0,e[0][1]=D>>>0,D=e[1][1]+y,e[1][0]=e[1][0]+b+(D/4294967296>>>0)>>>0,e[1][1]=D>>>0,D=e[2][1]+v,e[2][0]=e[2][0]+m+(D/4294967296>>>0)>>>0,e[2][1]=D>>>0,D=e[3][1]+_,e[3][0]=e[3][0]+w+(D/4294967296>>>0)>>>0,e[3][1]=D>>>0,D=e[4][1]+S,e[4][0]=e[4][0]+E+(D/4294967296>>>0)>>>0,e[4][1]=D>>>0,D=e[5][1]+k,e[5][0]=e[5][0]+A+(D/4294967296>>>0)>>>0,e[5][1]=D>>>0,D=e[6][1]+I,e[6][0]=e[6][0]+x+(D/4294967296>>>0)>>>0,e[6][1]=D>>>0,D=e[7][1]+T,e[7][0]=e[7][0]+C+(D/4294967296>>>0)>>>0,e[7][1]=D>>>0,M-=128}}},3900:(e,t,r)=>{var n=r(45),i=r(6407),o=e.exports=n.util=n.util||{};function s(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function a(e){if(this.data="",this.read=0,"string"===typeof e)this.data=e;else if(o.isArrayBuffer(e)||o.isArrayBufferView(e))if("undefined"!==typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r<t.length;++r)this.putByte(t[r])}}else(e instanceof a||"object"===typeof e&&"string"===typeof e.data&&"number"===typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!==typeof process&&process.nextTick&&!process.browser)return o.nextTick=process.nextTick,void("function"===typeof setImmediate?o.setImmediate=setImmediate:o.setImmediate=o.nextTick);if("function"===typeof setImmediate)return o.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(o.nextTick=function(e){return setImmediate(e)});if(o.setImmediate=function(e){setTimeout(e,0)},"undefined"!==typeof window&&"function"===typeof window.postMessage){var e="forge.setImmediate",t=[];o.setImmediate=function(r){t.push(r),1===t.length&&window.postMessage(e,"*")},window.addEventListener("message",(function(r){if(r.source===window&&r.data===e){r.stopPropagation();var n=t.slice();t.length=0,n.forEach((function(e){e()}))}}),!0)}if("undefined"!==typeof MutationObserver){var r=Date.now(),n=!0,i=document.createElement("div");t=[];new MutationObserver((function(){var e=t.slice();t.length=0,e.forEach((function(e){e()}))})).observe(i,{attributes:!0});var s=o.setImmediate;o.setImmediate=function(e){Date.now()-r>15?(r=Date.now(),s(e)):(t.push(e),1===t.length&&i.setAttribute("a",n=!n))}}o.nextTick=o.setImmediate}(),o.isNodejs="undefined"!==typeof process&&process.versions&&process.versions.node,o.globalScope=o.isNodejs?r.g:"undefined"===typeof self?window:self,o.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isArrayBuffer=function(e){return"undefined"!==typeof ArrayBuffer&&e instanceof ArrayBuffer},o.isArrayBufferView=function(e){return e&&o.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},o.ByteBuffer=a,o.ByteStringBuffer=a;o.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},o.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},o.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},o.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},o.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},o.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},o.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(o.encodeUtf8(e))},o.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},o.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},o.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},o.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},o.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},o.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},o.ByteStringBuffer.prototype.putInt=function(e,t){s(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},o.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},o.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},o.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},o.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},o.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},o.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},o.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},o.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},o.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},o.ByteStringBuffer.prototype.getInt=function(e){s(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},o.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},o.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},o.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},o.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},o.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},o.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},o.ByteStringBuffer.prototype.copy=function(){var e=o.createBuffer(this.data);return e.read=this.read,e},o.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},o.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},o.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},o.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},o.ByteStringBuffer.prototype.toString=function(){return o.decodeUtf8(this.bytes())},o.DataBuffer=function(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var r=o.isArrayBuffer(e),n=o.isArrayBufferView(e);if(r||n)return this.data=r?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in t?t.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!==e&&void 0!==e&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)},o.DataBuffer.prototype.length=function(){return this.write-this.read},o.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},o.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},o.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},o.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},o.DataBuffer.prototype.putBytes=function(e,t){if(o.isArrayBufferView(e)){var r=(n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-n.byteOffset;return this.accommodate(r),new Uint8Array(this.data.buffer,this.write).set(n),this.write+=r,this}if(o.isArrayBuffer(e)){var n=new Uint8Array(e);return this.accommodate(n.byteLength),new Uint8Array(this.data.buffer).set(n,this.write),this.write+=n.byteLength,this}if(e instanceof o.DataBuffer||"object"===typeof e&&"number"===typeof e.read&&"number"===typeof e.write&&o.isArrayBufferView(e.data)){n=new Uint8Array(e.data.byteLength,e.read,e.length());return this.accommodate(n.byteLength),new Uint8Array(e.data.byteLength,this.write).set(n),this.write+=n.byteLength,this}if(e instanceof o.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary","string"===typeof e){var i;if("hex"===t)return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=o.binary.hex.decode(e,i,this.write),this;if("base64"===t)return this.accommodate(3*Math.ceil(e.length/4)),i=new Uint8Array(this.data.buffer,this.write),this.write+=o.binary.base64.decode(e,i,this.write),this;if("utf8"===t&&(e=o.encodeUtf8(e),t="binary"),"binary"===t||"raw"===t)return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=o.binary.raw.decode(i),this;if("utf16"===t)return this.accommodate(2*e.length),i=new Uint16Array(this.data.buffer,this.write),this.write+=o.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},o.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},o.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},o.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},o.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},o.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},o.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},o.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},o.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},o.DataBuffer.prototype.putInt=function(e,t){s(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},o.DataBuffer.prototype.putSignedInt=function(e,t){return s(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},o.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},o.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},o.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},o.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},o.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},o.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},o.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},o.DataBuffer.prototype.getInt=function(e){s(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},o.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},o.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},o.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},o.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},o.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},o.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},o.DataBuffer.prototype.copy=function(){return new o.DataBuffer(this)},o.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},o.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},o.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},o.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},o.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return o.binary.raw.encode(t);if("hex"===e)return o.binary.hex.encode(t);if("base64"===e)return o.binary.base64.encode(t);if("utf8"===e)return o.text.utf8.decode(t);if("utf16"===e)return o.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},o.createBuffer=function(e,t){return t=t||"raw",void 0!==e&&"utf8"===t&&(e=o.encodeUtf8(e)),new o.ByteBuffer(e)},o.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},o.xorBytes=function(e,t,r){for(var n="",i="",o="",s=0,a=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),a>=10&&(n+=o,o="",a=0),o+=String.fromCharCode(i),++a;return n+=o},o.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},o.bytesToHex=function(e){return o.createBuffer(e).toHex()},o.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";o.encode64=function(e,t){for(var r,n,i,o="",s="",a=0;a<e.length;)r=e.charCodeAt(a++),n=e.charCodeAt(a++),i=e.charCodeAt(a++),o+=c.charAt(r>>2),o+=c.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=c.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":c.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},o.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",s=0;s<e.length;)t=u[e.charCodeAt(s++)-43],r=u[e.charCodeAt(s++)-43],n=u[e.charCodeAt(s++)-43],i=u[e.charCodeAt(s++)-43],o+=String.fromCharCode(t<<2|r>>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},o.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},o.decodeUtf8=function(e){return decodeURIComponent(escape(e))},o.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:i.encode,decode:i.decode}},o.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},o.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o);return t?i-r:n},o.binary.hex.encode=o.bytesToHex,o.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,o=r=r||0;for(1&e.length&&(i=1,n[o++]=parseInt(e[0],16));i<e.length;i+=2)n[o++]=parseInt(e.substr(i,2),16);return t?o-r:n},o.binary.base64.encode=function(e,t){for(var r,n,i,o="",s="",a=0;a<e.byteLength;)r=e[a++],n=e[a++],i=e[a++],o+=c.charAt(r>>2),o+=c.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=c.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":c.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},o.binary.base64.decode=function(e,t,r){var n,i,o,s,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,l=r=r||0;c<e.length;)n=u[e.charCodeAt(c++)-43],i=u[e.charCodeAt(c++)-43],o=u[e.charCodeAt(c++)-43],s=u[e.charCodeAt(c++)-43],a[l++]=n<<2|i>>4,64!==o&&(a[l++]=(15&i)<<4|o>>2,64!==s&&(a[l++]=(3&o)<<6|s));return t?l-r:a.subarray(0,l)},o.binary.base58.encode=function(e,t){return o.binary.baseN.encode(e,l,t)},o.binary.base58.decode=function(e,t){return o.binary.baseN.decode(e,l,t)},o.text={utf8:{},utf16:{}},o.text.utf8.encode=function(e,t,r){e=o.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,s=0;s<e.length;++s)n[i++]=e.charCodeAt(s);return t?i-r:n},o.text.utf8.decode=function(e){return o.decodeUtf8(String.fromCharCode.apply(null,e))},o.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),o=r=r||0,s=r,a=0;a<e.length;++a)i[s++]=e.charCodeAt(a),o+=2;return t?o-r:n},o.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},o.deflate=function(e,t,r){if(t=o.decode64(e.deflate(o.encode64(t)).rval),r){var n=2;32&t.charCodeAt(1)&&(n=6),t=t.substring(n,t.length-4)}return t},o.inflate=function(e,t,r){var n=e.inflate(o.encode64(t)).rval;return null===n?null:o.decode64(n)};var h=function(e,t,r){if(!e)throw new Error("WebStorage not available.");var n;if(null===r?n=e.removeItem(t):(r=o.encode64(JSON.stringify(r)),n=e.setItem(t,r)),"undefined"!==typeof n&&!0!==n.rval){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},d=function(e,t){if(!e)throw new Error("WebStorage not available.");var r=e.getItem(t);if(e.init)if(null===r.rval){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return null!==r&&(r=JSON.parse(o.decode64(r))),r},f=function(e,t,r,n){var i=d(e,t);null===i&&(i={}),i[r]=n,h(e,t,i)},p=function(e,t,r){var n=d(e,t);return null!==n&&(n=r in n?n[r]:null),n},g=function(e,t,r){var n=d(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var o in n){i=!1;break}i&&(n=null),h(e,t,n)}},b=function(e,t){h(e,t,null)},y=function(e,t,r){var n,i=null;"undefined"===typeof r&&(r=["web","flash"]);var o=!1,s=null;for(var a in r){n=r[a];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),o="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),o=!0)}catch(c){s=c}if(o)break}if(!o)throw s;return i};o.setItem=function(e,t,r,n,i){y(f,arguments,i)},o.getItem=function(e,t,r,n){return y(p,arguments,n)},o.removeItem=function(e,t,r,n){y(g,arguments,n)},o.clearItems=function(e,t,r){y(b,arguments,r)},o.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},o.format=function(e){for(var t,r,n=/%./g,i=0,o=[],s=0;t=n.exec(e);){(r=e.substring(s,n.lastIndex-2)).length>0&&o.push(r),s=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i<arguments.length?o.push(arguments[1+i++]):o.push("<?>");break;case"%":o.push("%");break;default:o.push("<%"+a+"?>")}}return o.push(e.substring(s)),o.join("")},o.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-u).toFixed(o).slice(2):"")},o.formatSize=function(e){return e=e>=1073741824?o.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?o.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?o.formatNumber(e/1024,0)+" KiB":o.formatNumber(e,0)+" bytes"},o.bytesFromIP=function(e){return-1!==e.indexOf(".")?o.bytesFromIPv4(e):-1!==e.indexOf(":")?o.bytesFromIPv6(e):null},o.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=o.createBuffer(),r=0;r<e.length;++r){var n=parseInt(e[r],10);if(isNaN(n))return null;t.putByte(n)}return t.getBytes()},o.bytesFromIPv6=function(e){for(var t=0,r=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++t,!0}))).length+t),n=o.createBuffer(),i=0;i<8;++i)if(e[i]&&0!==e[i].length){var s=o.hexToBytes(e[i]);s.length<2&&n.putByte(0),n.putBytes(s)}else n.fillWithByte(0,r),r=0;return n.getBytes()},o.bytesToIP=function(e){return 4===e.length?o.bytesToIPv4(e):16===e.length?o.bytesToIPv6(e):null},o.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},o.bytesToIPv6=function(e){if(16!==e.length)return null;for(var t=[],r=[],n=0,i=0;i<e.length;i+=2){for(var s=o.bytesToHex(e[i]+e[i+1]);"0"===s[0]&&"0"!==s;)s=s.substr(1);if("0"===s){var a=r[r.length-1],c=t.length;a&&c===a.end+1?(a.end=c,a.end-a.start>r[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}t.push(s)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},o.estimateCores=function(e,t){if("function"===typeof e&&(t=e,e={}),e=e||{},"cores"in o&&!e.update)return t(null,o.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return o.cores=navigator.hardwareConcurrency,t(null,o.cores);if("undefined"===typeof Worker)return o.cores=1,t(null,o.cores);if("undefined"===typeof Blob)return o.cores=2,t(null,o.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()<r;);self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(n,i,s){if(0===i){var a=Math.floor(n.reduce((function(e,t){return e+t}),0)/n.length);return o.cores=Math.max(1,a),URL.revokeObjectURL(r),t(null,o.cores)}!function(e,t){for(var n=[],i=[],o=0;o<e;++o){var s=new Worker(r);s.addEventListener("message",(function(r){if(i.push(r.data),i.length===e){for(var o=0;o<e;++o)n[o].terminate();t(null,i)}})),n.push(s)}for(o=0;o<e;++o)n[o].postMessage(o)}(s,(function(t,r){n.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],o=r[n]=[],s=0;s<e;++s)if(n!==s){var a=t[s];(i.st>a.st&&i.st<a.et||a.st>i.st&&a.st<i.et)&&o.push(s)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(s,r)),e(n,i-1,s)}))}([],5,16)}},2123:e=>{"use strict";var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(e,i){for(var o,s,a=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),c=1;c<arguments.length;c++){for(var u in o=Object(arguments[c]))r.call(o,u)&&(a[u]=o[u]);if(t){s=t(o);for(var l=0;l<s.length;l++)n.call(o,s[l])&&(a[s[l]]=o[s[l]])}}return a}},3338:(e,t,r)=>{"use strict";e.exports=c;var n,i=r(1509),o=i.LongBits,s=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var u="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},l=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new n(e):u(e)})(e)}:u};function h(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=l(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return e}}(),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,r);if(t===r){var n=i.Buffer;return n?n.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},c.prototype.skip=function(e){if("number"===typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){n=e,c.create=l(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},7707:(e,t,r)=>{"use strict";e.exports=o;var n=r(3338);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(1509);function o(e){n.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},6350:(e,t,r)=>{"use strict";e.exports=i;var n=r(1509);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"===typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===s?o:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},1509:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i<n.length;++i)void 0!==e[n[i]]&&r||(e[n[i]]=t[n[i]]);return e}function o(e){function t(e,r){if(!(this instanceof t))return new t(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&i(this,r)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}n.asPromise=r(4762),n.base64=r(6762),n.EventEmitter=r(7351),n.float=r(217),n.inquire=r(4882),n.utf8=r(8626),n.pool=r(6931),n.LongBits=r(6350),n.isNode=Boolean("undefined"!==typeof r.g&&r.g&&r.g.process&&r.g.process.versions&&r.g.process.versions.node),n.global=n.isNode&&r.g||"undefined"!==typeof window&&window||"undefined"!==typeof self&&self||this,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e},n.isString=function(e){return"string"===typeof e||e instanceof String},n.isObject=function(e){return e&&"object"===typeof e},n.isset=n.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!==typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"===typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var e=n.Buffer;e?(n._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},n._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):n._Buffer_from=n._Buffer_allocUnsafe=null}},5850:(e,t,r)=>{"use strict";e.exports=h;var n,i=r(1509),o=i.LongBits,s=i.base64,a=i.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function h(){this.len=0,this.head=new c(u,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}};function f(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function b(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}h.create=d(),h.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},h.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},h.prototype.int32=function(e){return e<0?this._push(g,10,o.fromNumber(e)):this.uint32(e)},h.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},h.prototype.uint64=function(e){var t=o.from(e);return this._push(g,t.length(),t)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(g,t.length(),t)},h.prototype.bool=function(e){return this._push(f,1,e?1:0)},h.prototype.fixed32=function(e){return this._push(b,4,e>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(e){var t=o.from(e);return this._push(b,4,t.lo)._push(b,4,t.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},h.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var y=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n<e.length;++n)t[r+n]=e[n]};h.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(f,1,0);if(i.isString(e)){var r=h.alloc(t=s.length(e));s.decode(e,r,0),e=r}return this.uint32(t)._push(y,t,e)},h.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},h.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new c(u,0,0),this.len=0,this},h.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 c(u,0,0),this.len=0),this},h.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},h.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},h._configure=function(e){n=e,h.create=d(),n._configure()}},3931:(e,t,r)=>{"use strict";e.exports=o;var n=r(5850);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(1509);function o(){n.call(this)}function s(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n<e.length;)t[r++]=e[n++]}},o.prototype.bytes=function(e){i.isString(e)&&(e=i._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},o._configure()},8275:(e,t)=>{"use strict";class r{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=r.toUint8Array(e),i=r.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}static concat(){let e;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];e=!Array.isArray(r[0])||r[1]instanceof Function?Array.isArray(r[0])&&r[1]instanceof Function?r[0]:r[r.length-1]instanceof Function?r.slice(0,r.length-1):r:r[0];let i=0;for(const a of e)i+=a.byteLength;const o=new Uint8Array(i);let s=0;for(const a of e){const e=this.toUint8Array(a);o.set(e,s),s+=e.length}return r[r.length-1]instanceof Function?this.toView(o,r[r.length-1]):o.buffer}}const n="string",i=/^[0-9a-f]+$/i,o=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,s=/^[a-zA-Z0-9-_]+$/;class a{static fromString(e){const t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r.buffer}static toString(e){const t=r.toUint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return decodeURIComponent(escape(n))}}class c{static toString(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=r.toArrayBuffer(e),i=new DataView(n);let o="";for(let r=0;r<n.byteLength;r+=2){const e=i.getUint16(r,t);o+=String.fromCharCode(e)}return o}static fromString(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=new ArrayBuffer(2*e.length),n=new DataView(r);for(let i=0;i<e.length;i++)n.setUint16(2*i,e.charCodeAt(i),t);return r}}class u{static isHex(e){return typeof e===n&&i.test(e)}static isBase64(e){return typeof e===n&&o.test(e)}static isBase64Url(e){return typeof e===n&&s.test(e)}static ToString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const n=r.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return c.toString(n,!0);case"utf16":case"utf16be":return c.toString(n);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static FromString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return c.fromString(e,!0);case"utf16":case"utf16be":return c.fromString(e);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static ToBase64(e){const t=r.toUint8Array(e);if("undefined"!==typeof btoa){const e=this.ToString(t,"binary");return btoa(e)}return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!u.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!==typeof atob?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!u.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.FromBinary(e);case"utf8":return a.fromString(e);case"utf16":case"utf16be":return c.fromString(e);case"utf16le":case"usc2":return c.fromString(e,!0);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static ToUtf8String(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.ToBinary(e);case"utf8":return a.toString(e);case"utf16":case"utf16be":return c.toString(e);case"utf16le":case"usc2":return c.toString(e,!0);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static FromBinary(e){const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return r.buffer}static ToBinary(e){const t=r.toUint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return n}static ToHex(e){const t=r.toUint8Array(e);let n="";const i=t.length;for(let r=0;r<i;r++){const e=t[r];e<16&&(n+="0"),n+=e.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!u.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t="0".concat(t));const r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2){const e=t.slice(n,n+2);r[n/2]=parseInt(e,16)}return r.buffer}static ToUtf16String(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return c.toString(e,t)}static FromUtf16String(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return c.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return(null===e||void 0===e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}u.DEFAULT_UTF8_ENCODING="utf8",t._H=r,t.U$=u},2730:(e,t,r)=>{"use strict";var n=r(5043),i=r(2123),o=r(8853);function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}if(!n)throw Error(s(227));var a=new Set,c={};function u(e,t){l(e,t),l(e+"Capture",t)}function l(e,t){for(c[e]=t,e=0;e<t.length;e++)a.add(t[e])}var h=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement),d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f=Object.prototype.hasOwnProperty,p={},g={};function b(e,t,r,n,i,o,s){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=s}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){y[e]=new b(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var t=e[0];y[t]=new b(t,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){y[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){y[e]=new b(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){y[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){y[e]=new b(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){y[e]=new b(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){y[e]=new b(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){y[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)}));var m=/[\-:]([a-z])/g;function v(e){return e[1].toUpperCase()}function w(e,t,r,n){var i=y.hasOwnProperty(t)?y[t]:null;(null!==i?0===i.type:!n&&(2<t.length&&("o"===t[0]||"O"===t[0])&&("n"===t[1]||"N"===t[1])))||(function(e,t,r,n){if(null===t||"undefined"===typeof t||function(e,t,r,n){if(null!==r&&0===r.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!n&&(null!==r?!r.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,r,n))return!0;if(n)return!1;if(null!==r)switch(r.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,r,i,n)&&(r=null),n||null===i?function(e){return!!f.call(g,e)||!f.call(p,e)&&(d.test(e)?g[e]=!0:(p[e]=!0,!1))}(t)&&(null===r?e.removeAttribute(t):e.setAttribute(t,""+r)):i.mustUseProperty?e[i.propertyName]=null===r?3!==i.type&&"":r:(t=i.attributeName,n=i.attributeNamespace,null===r?e.removeAttribute(t):(r=3===(i=i.type)||4===i&&!0===r?"":""+r,n?e.setAttributeNS(n,t,r):e.setAttribute(t,r))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach((function(e){var t=e.replace(m,v);y[t]=new b(t,1,!1,e,null,!1,!1)})),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach((function(e){var t=e.replace(m,v);y[t]=new b(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((function(e){var t=e.replace(m,v);y[t]=new b(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){y[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)})),y.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){y[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)}));var _=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=60103,S=60106,A=60107,k=60108,x=60114,I=60109,C=60110,T=60112,R=60113,P=60120,D=60115,N=60116,B=60121,U=60128,L=60129,M=60130,O=60131;if("function"===typeof Symbol&&Symbol.for){var q=Symbol.for;E=q("react.element"),S=q("react.portal"),A=q("react.fragment"),k=q("react.strict_mode"),x=q("react.profiler"),I=q("react.provider"),C=q("react.context"),T=q("react.forward_ref"),R=q("react.suspense"),P=q("react.suspense_list"),D=q("react.memo"),N=q("react.lazy"),B=q("react.block"),q("react.scope"),U=q("react.opaque.id"),L=q("react.debug_trace_mode"),M=q("react.offscreen"),O=q("react.legacy_hidden")}var K,F="function"===typeof Symbol&&Symbol.iterator;function V(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=F&&e[F]||e["@@iterator"])?e:null}function z(e){if(void 0===K)try{throw Error()}catch(r){var t=r.stack.trim().match(/\n( *(at )?)/);K=t&&t[1]||""}return"\n"+K+e}var j=!1;function H(e,t){if(!e||j)return"";j=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var n=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){n=c}e.call(t.prototype)}else{try{throw Error()}catch(c){n=c}e()}}catch(c){if(c&&n&&"string"===typeof c.stack){for(var i=c.stack.split("\n"),o=n.stack.split("\n"),s=i.length-1,a=o.length-1;1<=s&&0<=a&&i[s]!==o[a];)a--;for(;1<=s&&0<=a;s--,a--)if(i[s]!==o[a]){if(1!==s||1!==a)do{if(s--,0>--a||i[s]!==o[a])return"\n"+i[s].replace(" at new "," at ")}while(1<=s&&0<=a);break}}}finally{j=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?z(e):""}function G(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=H(e.type,!1);case 11:return e=H(e.type.render,!1);case 22:return e=H(e.type._render,!1);case 1:return e=H(e.type,!0);default:return""}}function W(e){if(null==e)return null;if("function"===typeof e)return e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case A:return"Fragment";case S:return"Portal";case x:return"Profiler";case k:return"StrictMode";case R:return"Suspense";case P:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case C:return(e.displayName||"Context")+".Consumer";case I:return(e._context.displayName||"Context")+".Provider";case T:var t=e.render;return t=t.displayName||t.name||"",e.displayName||(""!==t?"ForwardRef("+t+")":"ForwardRef");case D:return W(e.type);case B:return W(e._render);case N:t=e._payload,e=e._init;try{return W(e(t))}catch(r){}}return null}function Y(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}function Q(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function J(e){e._valueTracker||(e._valueTracker=function(e){var t=Q(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof r&&"function"===typeof r.get&&"function"===typeof r.set){var i=r.get,o=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function X(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),n="";return e&&(n=Q(e)?e.checked?"true":"false":e.value),(e=n)!==r&&(t.setValue(e),!0)}function Z(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function $(e,t){var r=t.checked;return i({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:e._wrapperState.initialChecked})}function ee(e,t){var r=null==t.defaultValue?"":t.defaultValue,n=null!=t.checked?t.checked:t.defaultChecked;r=Y(null!=t.value?t.value:r),e._wrapperState={initialChecked:n,initialValue:r,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function te(e,t){null!=(t=t.checked)&&w(e,"checked",t,!1)}function re(e,t){te(e,t);var r=Y(t.value),n=t.type;if(null!=r)"number"===n?(0===r&&""===e.value||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if("submit"===n||"reset"===n)return void e.removeAttribute("value");t.hasOwnProperty("value")?ie(e,t.type,r):t.hasOwnProperty("defaultValue")&&ie(e,t.type,Y(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function ne(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!("submit"!==n&&"reset"!==n||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}""!==(r=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==r&&(e.name=r)}function ie(e,t,r){"number"===t&&Z(e.ownerDocument)===e||(null==r?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}function oe(e,t){return e=i({children:void 0},t),(t=function(e){var t="";return n.Children.forEach(e,(function(e){null!=e&&(t+=e)})),t}(t.children))&&(e.children=t),e}function se(e,t,r,n){if(e=e.options,t){t={};for(var i=0;i<r.length;i++)t["$"+r[i]]=!0;for(r=0;r<e.length;r++)i=t.hasOwnProperty("$"+e[r].value),e[r].selected!==i&&(e[r].selected=i),i&&n&&(e[r].defaultSelected=!0)}else{for(r=""+Y(r),t=null,i=0;i<e.length;i++){if(e[i].value===r)return e[i].selected=!0,void(n&&(e[i].defaultSelected=!0));null!==t||e[i].disabled||(t=e[i])}null!==t&&(t.selected=!0)}}function ae(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(s(91));return i({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ce(e,t){var r=t.value;if(null==r){if(r=t.children,t=t.defaultValue,null!=r){if(null!=t)throw Error(s(92));if(Array.isArray(r)){if(!(1>=r.length))throw Error(s(93));r=r[0]}t=r}null==t&&(t=""),r=t}e._wrapperState={initialValue:Y(r)}}function ue(e,t){var r=Y(t.value),n=Y(t.defaultValue);null!=r&&((r=""+r)!==e.value&&(e.value=r),null==t.defaultValue&&e.defaultValue!==r&&(e.defaultValue=r)),null!=n&&(e.defaultValue=""+n)}function le(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}var he={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function de(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function fe(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?de(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var pe,ge,be=(ge=function(e,t){if(e.namespaceURI!==he.svg||"innerHTML"in e)e.innerHTML=t;else{for((pe=pe||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=pe.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,r,n){MSApp.execUnsafeLocalFunction((function(){return ge(e,t)}))}:ge);function ye(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&3===r.nodeType)return void(r.nodeValue=t)}e.textContent=t}var me={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ve=["Webkit","ms","Moz","O"];function we(e,t,r){return null==t||"boolean"===typeof t||""===t?"":r||"number"!==typeof t||0===t||me.hasOwnProperty(e)&&me[e]?(""+t).trim():t+"px"}function _e(e,t){for(var r in e=e.style,t)if(t.hasOwnProperty(r)){var n=0===r.indexOf("--"),i=we(r,t[r],n);"float"===r&&(r="cssFloat"),n?e.setProperty(r,i):e[r]=i}}Object.keys(me).forEach((function(e){ve.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),me[t]=me[e]}))}));var Ee=i({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Se(e,t){if(t){if(Ee[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(s(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(s(60));if("object"!==typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(null!=t.style&&"object"!==typeof t.style)throw Error(s(62))}}function Ae(e,t){if(-1===e.indexOf("-"))return"string"===typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}function ke(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var xe=null,Ie=null,Ce=null;function Te(e){if(e=ri(e)){if("function"!==typeof xe)throw Error(s(280));var t=e.stateNode;t&&(t=ii(t),xe(e.stateNode,e.type,t))}}function Re(e){Ie?Ce?Ce.push(e):Ce=[e]:Ie=e}function Pe(){if(Ie){var e=Ie,t=Ce;if(Ce=Ie=null,Te(e),t)for(e=0;e<t.length;e++)Te(t[e])}}function De(e,t){return e(t)}function Ne(e,t,r,n,i){return e(t,r,n,i)}function Be(){}var Ue=De,Le=!1,Me=!1;function Oe(){null===Ie&&null===Ce||(Be(),Pe())}function qe(e,t){var r=e.stateNode;if(null===r)return null;var n=ii(r);if(null===n)return null;r=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(n=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!n;break e;default:e=!1}if(e)return null;if(r&&"function"!==typeof r)throw Error(s(231,t,typeof r));return r}var Ke=!1;if(h)try{var Fe={};Object.defineProperty(Fe,"passive",{get:function(){Ke=!0}}),window.addEventListener("test",Fe,Fe),window.removeEventListener("test",Fe,Fe)}catch(ge){Ke=!1}function Ve(e,t,r,n,i,o,s,a,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(r,u)}catch(l){this.onError(l)}}var ze=!1,je=null,He=!1,Ge=null,We={onError:function(e){ze=!0,je=e}};function Ye(e,t,r,n,i,o,s,a,c){ze=!1,je=null,Ve.apply(We,arguments)}function Qe(e){var t=e,r=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(1026&(t=e).flags)&&(r=t.return),e=t.return}while(e)}return 3===t.tag?r:null}function Je(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function Xe(e){if(Qe(e)!==e)throw Error(s(188))}function Ze(e){if(e=function(e){var t=e.alternate;if(!t){if(null===(t=Qe(e)))throw Error(s(188));return t!==e?null:e}for(var r=e,n=t;;){var i=r.return;if(null===i)break;var o=i.alternate;if(null===o){if(null!==(n=i.return)){r=n;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===r)return Xe(i),e;if(o===n)return Xe(i),t;o=o.sibling}throw Error(s(188))}if(r.return!==n.return)r=i,n=o;else{for(var a=!1,c=i.child;c;){if(c===r){a=!0,r=i,n=o;break}if(c===n){a=!0,n=i,r=o;break}c=c.sibling}if(!a){for(c=o.child;c;){if(c===r){a=!0,r=o,n=i;break}if(c===n){a=!0,n=o,r=i;break}c=c.sibling}if(!a)throw Error(s(189))}}if(r.alternate!==n)throw Error(s(190))}if(3!==r.tag)throw Error(s(188));return r.stateNode.current===r?e:t}(e),!e)return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function $e(e,t){for(var r=e.alternate;null!==t;){if(t===e||t===r)return!0;t=t.return}return!1}var et,tt,rt,nt,it=!1,ot=[],st=null,at=null,ct=null,ut=new Map,lt=new Map,ht=[],dt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ft(e,t,r,n,i){return{blockedOn:e,domEventName:t,eventSystemFlags:16|r,nativeEvent:i,targetContainers:[n]}}function pt(e,t){switch(e){case"focusin":case"focusout":st=null;break;case"dragenter":case"dragleave":at=null;break;case"mouseover":case"mouseout":ct=null;break;case"pointerover":case"pointerout":ut.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":lt.delete(t.pointerId)}}function gt(e,t,r,n,i,o){return null===e||e.nativeEvent!==o?(e=ft(t,r,n,i,o),null!==t&&(null!==(t=ri(t))&&tt(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,null!==i&&-1===t.indexOf(i)&&t.push(i),e)}function bt(e){var t=ti(e.target);if(null!==t){var r=Qe(t);if(null!==r)if(13===(t=r.tag)){if(null!==(t=Je(r)))return e.blockedOn=t,void nt(e.lanePriority,(function(){o.unstable_runWithPriority(e.priority,(function(){rt(r)}))}))}else if(3===t&&r.stateNode.hydrate)return void(e.blockedOn=3===r.tag?r.stateNode.containerInfo:null)}e.blockedOn=null}function yt(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var r=Zt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==r)return null!==(t=ri(r))&&tt(t),e.blockedOn=r,!1;t.shift()}return!0}function mt(e,t,r){yt(e)&&r.delete(t)}function vt(){for(it=!1;0<ot.length;){var e=ot[0];if(null!==e.blockedOn){null!==(e=ri(e.blockedOn))&&et(e);break}for(var t=e.targetContainers;0<t.length;){var r=Zt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==r){e.blockedOn=r;break}t.shift()}null===e.blockedOn&&ot.shift()}null!==st&&yt(st)&&(st=null),null!==at&&yt(at)&&(at=null),null!==ct&&yt(ct)&&(ct=null),ut.forEach(mt),lt.forEach(mt)}function wt(e,t){e.blockedOn===t&&(e.blockedOn=null,it||(it=!0,o.unstable_scheduleCallback(o.unstable_NormalPriority,vt)))}function _t(e){function t(t){return wt(t,e)}if(0<ot.length){wt(ot[0],e);for(var r=1;r<ot.length;r++){var n=ot[r];n.blockedOn===e&&(n.blockedOn=null)}}for(null!==st&&wt(st,e),null!==at&&wt(at,e),null!==ct&&wt(ct,e),ut.forEach(t),lt.forEach(t),r=0;r<ht.length;r++)(n=ht[r]).blockedOn===e&&(n.blockedOn=null);for(;0<ht.length&&null===(r=ht[0]).blockedOn;)bt(r),null===r.blockedOn&&ht.shift()}function Et(e,t){var r={};return r[e.toLowerCase()]=t.toLowerCase(),r["Webkit"+e]="webkit"+t,r["Moz"+e]="moz"+t,r}var St={animationend:Et("Animation","AnimationEnd"),animationiteration:Et("Animation","AnimationIteration"),animationstart:Et("Animation","AnimationStart"),transitionend:Et("Transition","TransitionEnd")},At={},kt={};function xt(e){if(At[e])return At[e];if(!St[e])return e;var t,r=St[e];for(t in r)if(r.hasOwnProperty(t)&&t in kt)return At[e]=r[t];return e}h&&(kt=document.createElement("div").style,"AnimationEvent"in window||(delete St.animationend.animation,delete St.animationiteration.animation,delete St.animationstart.animation),"TransitionEvent"in window||delete St.transitionend.transition);var It=xt("animationend"),Ct=xt("animationiteration"),Tt=xt("animationstart"),Rt=xt("transitionend"),Pt=new Map,Dt=new Map,Nt=["abort","abort",It,"animationEnd",Ct,"animationIteration",Tt,"animationStart","canplay","canPlay","canplaythrough","canPlayThrough","durationchange","durationChange","emptied","emptied","encrypted","encrypted","ended","ended","error","error","gotpointercapture","gotPointerCapture","load","load","loadeddata","loadedData","loadedmetadata","loadedMetadata","loadstart","loadStart","lostpointercapture","lostPointerCapture","playing","playing","progress","progress","seeking","seeking","stalled","stalled","suspend","suspend","timeupdate","timeUpdate",Rt,"transitionEnd","waiting","waiting"];function Bt(e,t){for(var r=0;r<e.length;r+=2){var n=e[r],i=e[r+1];i="on"+(i[0].toUpperCase()+i.slice(1)),Dt.set(n,t),Pt.set(n,i),u(i,[n])}}(0,o.unstable_now)();var Ut=8;function Lt(e){if(0!==(1&e))return Ut=15,1;if(0!==(2&e))return Ut=14,2;if(0!==(4&e))return Ut=13,4;var t=24&e;return 0!==t?(Ut=12,t):0!==(32&e)?(Ut=11,32):0!==(t=192&e)?(Ut=10,t):0!==(256&e)?(Ut=9,256):0!==(t=3584&e)?(Ut=8,t):0!==(4096&e)?(Ut=7,4096):0!==(t=4186112&e)?(Ut=6,t):0!==(t=62914560&e)?(Ut=5,t):67108864&e?(Ut=4,67108864):0!==(134217728&e)?(Ut=3,134217728):0!==(t=805306368&e)?(Ut=2,t):0!==(1073741824&e)?(Ut=1,1073741824):(Ut=8,e)}function Mt(e,t){var r=e.pendingLanes;if(0===r)return Ut=0;var n=0,i=0,o=e.expiredLanes,s=e.suspendedLanes,a=e.pingedLanes;if(0!==o)n=o,i=Ut=15;else if(0!==(o=134217727&r)){var c=o&~s;0!==c?(n=Lt(c),i=Ut):0!==(a&=o)&&(n=Lt(a),i=Ut)}else 0!==(o=r&~s)?(n=Lt(o),i=Ut):0!==a&&(n=Lt(a),i=Ut);if(0===n)return 0;if(n=r&((0>(n=31-zt(n))?0:1<<n)<<1)-1,0!==t&&t!==n&&0===(t&s)){if(Lt(t),i<=Ut)return t;Ut=i}if(0!==(t=e.entangledLanes))for(e=e.entanglements,t&=n;0<t;)i=1<<(r=31-zt(t)),n|=e[r],t&=~i;return n}function Ot(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function qt(e,t){switch(e){case 15:return 1;case 14:return 2;case 12:return 0===(e=Kt(24&~t))?qt(10,t):e;case 10:return 0===(e=Kt(192&~t))?qt(8,t):e;case 8:return 0===(e=Kt(3584&~t))&&(0===(e=Kt(4186112&~t))&&(e=512)),e;case 2:return 0===(t=Kt(805306368&~t))&&(t=268435456),t}throw Error(s(358,e))}function Kt(e){return e&-e}function Ft(e){for(var t=[],r=0;31>r;r++)t.push(e);return t}function Vt(e,t,r){e.pendingLanes|=t;var n=t-1;e.suspendedLanes&=n,e.pingedLanes&=n,(e=e.eventTimes)[t=31-zt(t)]=r}var zt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-(jt(e)/Ht|0)|0},jt=Math.log,Ht=Math.LN2;var Gt=o.unstable_UserBlockingPriority,Wt=o.unstable_runWithPriority,Yt=!0;function Qt(e,t,r,n){Le||Be();var i=Xt,o=Le;Le=!0;try{Ne(i,e,t,r,n)}finally{(Le=o)||Oe()}}function Jt(e,t,r,n){Wt(Gt,Xt.bind(null,e,t,r,n))}function Xt(e,t,r,n){var i;if(Yt)if((i=0===(4&t))&&0<ot.length&&-1<dt.indexOf(e))e=ft(null,e,t,r,n),ot.push(e);else{var o=Zt(e,t,r,n);if(null===o)i&&pt(e,n);else{if(i){if(-1<dt.indexOf(e))return e=ft(o,e,t,r,n),void ot.push(e);if(function(e,t,r,n,i){switch(t){case"focusin":return st=gt(st,e,t,r,n,i),!0;case"dragenter":return at=gt(at,e,t,r,n,i),!0;case"mouseover":return ct=gt(ct,e,t,r,n,i),!0;case"pointerover":var o=i.pointerId;return ut.set(o,gt(ut.get(o)||null,e,t,r,n,i)),!0;case"gotpointercapture":return o=i.pointerId,lt.set(o,gt(lt.get(o)||null,e,t,r,n,i)),!0}return!1}(o,e,t,r,n))return;pt(e,n)}Bn(e,t,n,null,r)}}}function Zt(e,t,r,n){var i=ke(n);if(null!==(i=ti(i))){var o=Qe(i);if(null===o)i=null;else{var s=o.tag;if(13===s){if(null!==(i=Je(o)))return i;i=null}else if(3===s){if(o.stateNode.hydrate)return 3===o.tag?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null)}}return Bn(e,t,n,i,r),null}var $t=null,er=null,tr=null;function rr(){if(tr)return tr;var e,t,r=er,n=r.length,i="value"in $t?$t.value:$t.textContent,o=i.length;for(e=0;e<n&&r[e]===i[e];e++);var s=n-e;for(t=1;t<=s&&r[n-t]===i[o-t];t++);return tr=i.slice(e,1<t?1-t:void 0)}function nr(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function ir(){return!0}function or(){return!1}function sr(e){function t(t,r,n,i,o){for(var s in this._reactName=t,this._targetInst=n,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null,e)e.hasOwnProperty(s)&&(t=e[s],this[s]=t?t(i):i[s]);return this.isDefaultPrevented=(null!=i.defaultPrevented?i.defaultPrevented:!1===i.returnValue)?ir:or,this.isPropagationStopped=or,this}return i(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!==typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=ir)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!==typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=ir)},persist:function(){},isPersistent:ir}),t}var ar,cr,ur,lr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hr=sr(lr),dr=i({},lr,{view:0,detail:0}),fr=sr(dr),pr=i({},dr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xr,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ur&&(ur&&"mousemove"===e.type?(ar=e.screenX-ur.screenX,cr=e.screenY-ur.screenY):cr=ar=0,ur=e),ar)},movementY:function(e){return"movementY"in e?e.movementY:cr}}),gr=sr(pr),br=sr(i({},pr,{dataTransfer:0})),yr=sr(i({},dr,{relatedTarget:0})),mr=sr(i({},lr,{animationName:0,elapsedTime:0,pseudoElement:0})),vr=i({},lr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),wr=sr(vr),_r=sr(i({},lr,{data:0})),Er={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Sr={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ar={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function xr(){return kr}var Ir=i({},dr,{key:function(e){if(e.key){var t=Er[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=nr(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?Sr[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xr,charCode:function(e){return"keypress"===e.type?nr(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?nr(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Cr=sr(Ir),Tr=sr(i({},pr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Rr=sr(i({},dr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xr})),Pr=sr(i({},lr,{propertyName:0,elapsedTime:0,pseudoElement:0})),Dr=i({},pr,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Nr=sr(Dr),Br=[9,13,27,32],Ur=h&&"CompositionEvent"in window,Lr=null;h&&"documentMode"in document&&(Lr=document.documentMode);var Mr=h&&"TextEvent"in window&&!Lr,Or=h&&(!Ur||Lr&&8<Lr&&11>=Lr),qr=String.fromCharCode(32),Kr=!1;function Fr(e,t){switch(e){case"keyup":return-1!==Br.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vr(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var zr=!1;var jr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!jr[e.type]:"textarea"===t}function Gr(e,t,r,n){Re(n),0<(t=Ln(t,"onChange")).length&&(r=new hr("onChange","change",null,r,n),e.push({event:r,listeners:t}))}var Wr=null,Yr=null;function Qr(e){Cn(e,0)}function Jr(e){if(X(ni(e)))return e}function Xr(e,t){if("change"===e)return t}var Zr=!1;if(h){var $r;if(h){var en="oninput"in document;if(!en){var tn=document.createElement("div");tn.setAttribute("oninput","return;"),en="function"===typeof tn.oninput}$r=en}else $r=!1;Zr=$r&&(!document.documentMode||9<document.documentMode)}function rn(){Wr&&(Wr.detachEvent("onpropertychange",nn),Yr=Wr=null)}function nn(e){if("value"===e.propertyName&&Jr(Yr)){var t=[];if(Gr(t,Yr,e,ke(e)),e=Qr,Le)e(t);else{Le=!0;try{De(e,t)}finally{Le=!1,Oe()}}}}function on(e,t,r){"focusin"===e?(rn(),Yr=r,(Wr=t).attachEvent("onpropertychange",nn)):"focusout"===e&&rn()}function sn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Jr(Yr)}function an(e,t){if("click"===e)return Jr(t)}function cn(e,t){if("input"===e||"change"===e)return Jr(t)}var un="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t},ln=Object.prototype.hasOwnProperty;function hn(e,t){if(un(e,t))return!0;if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++)if(!ln.call(t,r[n])||!un(e[r[n]],t[r[n]]))return!1;return!0}function dn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fn(e,t){var r,n=dn(e);for(e=0;n;){if(3===n.nodeType){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=dn(n)}}function pn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?pn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function gn(){for(var e=window,t=Z();t instanceof e.HTMLIFrameElement;){try{var r="string"===typeof t.contentWindow.location.href}catch(n){r=!1}if(!r)break;t=Z((e=t.contentWindow).document)}return t}function bn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var yn=h&&"documentMode"in document&&11>=document.documentMode,mn=null,vn=null,wn=null,_n=!1;function En(e,t,r){var n=r.window===r?r.document:9===r.nodeType?r:r.ownerDocument;_n||null==mn||mn!==Z(n)||("selectionStart"in(n=mn)&&bn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},wn&&hn(wn,n)||(wn=n,0<(n=Ln(vn,"onSelect")).length&&(t=new hr("onSelect","select",null,t,r),e.push({event:t,listeners:n}),t.target=mn)))}Bt("cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focusin focus focusout blur input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange".split(" "),0),Bt("drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel".split(" "),1),Bt(Nt,2);for(var Sn="change selectionchange textInput compositionstart compositionend compositionupdate".split(" "),An=0;An<Sn.length;An++)Dt.set(Sn[An],0);l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var kn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),xn=new Set("cancel close invalid load scroll toggle".split(" ").concat(kn));function In(e,t,r){var n=e.type||"unknown-event";e.currentTarget=r,function(e,t,r,n,i,o,a,c,u){if(Ye.apply(this,arguments),ze){if(!ze)throw Error(s(198));var l=je;ze=!1,je=null,He||(He=!0,Ge=l)}}(n,t,void 0,e),e.currentTarget=null}function Cn(e,t){t=0!==(4&t);for(var r=0;r<e.length;r++){var n=e[r],i=n.event;n=n.listeners;e:{var o=void 0;if(t)for(var s=n.length-1;0<=s;s--){var a=n[s],c=a.instance,u=a.currentTarget;if(a=a.listener,c!==o&&i.isPropagationStopped())break e;In(i,a,u),o=c}else for(s=0;s<n.length;s++){if(c=(a=n[s]).instance,u=a.currentTarget,a=a.listener,c!==o&&i.isPropagationStopped())break e;In(i,a,u),o=c}}}if(He)throw e=Ge,He=!1,Ge=null,e}function Tn(e,t){var r=oi(t),n=e+"__bubble";r.has(n)||(Nn(t,e,2,!1),r.add(n))}var Rn="_reactListening"+Math.random().toString(36).slice(2);function Pn(e){e[Rn]||(e[Rn]=!0,a.forEach((function(t){xn.has(t)||Dn(t,!1,e,null),Dn(t,!0,e,null)})))}function Dn(e,t,r,n){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=r;if("selectionchange"===e&&9!==r.nodeType&&(o=r.ownerDocument),null!==n&&!t&&xn.has(e)){if("scroll"!==e)return;i|=2,o=n}var s=oi(o),a=e+"__"+(t?"capture":"bubble");s.has(a)||(t&&(i|=4),Nn(o,e,i,t),s.add(a))}function Nn(e,t,r,n){var i=Dt.get(t);switch(void 0===i?2:i){case 0:i=Qt;break;case 1:i=Jt;break;default:i=Xt}r=i.bind(null,t,r,e),i=void 0,!Ke||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(i=!0),n?void 0!==i?e.addEventListener(t,r,{capture:!0,passive:i}):e.addEventListener(t,r,!0):void 0!==i?e.addEventListener(t,r,{passive:i}):e.addEventListener(t,r,!1)}function Bn(e,t,r,n,i){var o=n;if(0===(1&t)&&0===(2&t)&&null!==n)e:for(;;){if(null===n)return;var s=n.tag;if(3===s||4===s){var a=n.stateNode.containerInfo;if(a===i||8===a.nodeType&&a.parentNode===i)break;if(4===s)for(s=n.return;null!==s;){var c=s.tag;if((3===c||4===c)&&((c=s.stateNode.containerInfo)===i||8===c.nodeType&&c.parentNode===i))return;s=s.return}for(;null!==a;){if(null===(s=ti(a)))return;if(5===(c=s.tag)||6===c){n=o=s;continue e}a=a.parentNode}}n=n.return}!function(e,t,r){if(Me)return e(t,r);Me=!0;try{return Ue(e,t,r)}finally{Me=!1,Oe()}}((function(){var n=o,i=ke(r),s=[];e:{var a=Pt.get(e);if(void 0!==a){var c=hr,u=e;switch(e){case"keypress":if(0===nr(r))break e;case"keydown":case"keyup":c=Cr;break;case"focusin":u="focus",c=yr;break;case"focusout":u="blur",c=yr;break;case"beforeblur":case"afterblur":c=yr;break;case"click":if(2===r.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=gr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=br;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Rr;break;case It:case Ct:case Tt:c=mr;break;case Rt:c=Pr;break;case"scroll":c=fr;break;case"wheel":c=Nr;break;case"copy":case"cut":case"paste":c=wr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Tr}var l=0!==(4&t),h=!l&&"scroll"===e,d=l?null!==a?a+"Capture":null:a;l=[];for(var f,p=n;null!==p;){var g=(f=p).stateNode;if(5===f.tag&&null!==g&&(f=g,null!==d&&(null!=(g=qe(p,d))&&l.push(Un(p,g,f)))),h)break;p=p.return}0<l.length&&(a=new c(a,u,null,r,i),s.push({event:a,listeners:l}))}}if(0===(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(a="mouseover"===e||"pointerover"===e)||0!==(16&t)||!(u=r.relatedTarget||r.fromElement)||!ti(u)&&!u[$n])&&(c||a)&&(a=i.window===i?i:(a=i.ownerDocument)?a.defaultView||a.parentWindow:window,c?(c=n,null!==(u=(u=r.relatedTarget||r.toElement)?ti(u):null)&&(u!==(h=Qe(u))||5!==u.tag&&6!==u.tag)&&(u=null)):(c=null,u=n),c!==u)){if(l=gr,g="onMouseLeave",d="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(l=Tr,g="onPointerLeave",d="onPointerEnter",p="pointer"),h=null==c?a:ni(c),f=null==u?a:ni(u),(a=new l(g,p+"leave",c,r,i)).target=h,a.relatedTarget=f,g=null,ti(i)===n&&((l=new l(d,p+"enter",u,r,i)).target=f,l.relatedTarget=h,g=l),h=g,c&&u)e:{for(d=u,p=0,f=l=c;f;f=Mn(f))p++;for(f=0,g=d;g;g=Mn(g))f++;for(;0<p-f;)l=Mn(l),p--;for(;0<f-p;)d=Mn(d),f--;for(;p--;){if(l===d||null!==d&&l===d.alternate)break e;l=Mn(l),d=Mn(d)}l=null}else l=null;null!==c&&On(s,a,c,l,!1),null!==u&&null!==h&&On(s,h,u,l,!0)}if("select"===(c=(a=n?ni(n):window).nodeName&&a.nodeName.toLowerCase())||"input"===c&&"file"===a.type)var b=Xr;else if(Hr(a))if(Zr)b=cn;else{b=sn;var y=on}else(c=a.nodeName)&&"input"===c.toLowerCase()&&("checkbox"===a.type||"radio"===a.type)&&(b=an);switch(b&&(b=b(e,n))?Gr(s,b,r,i):(y&&y(e,a,n),"focusout"===e&&(y=a._wrapperState)&&y.controlled&&"number"===a.type&&ie(a,"number",a.value)),y=n?ni(n):window,e){case"focusin":(Hr(y)||"true"===y.contentEditable)&&(mn=y,vn=n,wn=null);break;case"focusout":wn=vn=mn=null;break;case"mousedown":_n=!0;break;case"contextmenu":case"mouseup":case"dragend":_n=!1,En(s,r,i);break;case"selectionchange":if(yn)break;case"keydown":case"keyup":En(s,r,i)}var m;if(Ur)e:{switch(e){case"compositionstart":var v="onCompositionStart";break e;case"compositionend":v="onCompositionEnd";break e;case"compositionupdate":v="onCompositionUpdate";break e}v=void 0}else zr?Fr(e,r)&&(v="onCompositionEnd"):"keydown"===e&&229===r.keyCode&&(v="onCompositionStart");v&&(Or&&"ko"!==r.locale&&(zr||"onCompositionStart"!==v?"onCompositionEnd"===v&&zr&&(m=rr()):(er="value"in($t=i)?$t.value:$t.textContent,zr=!0)),0<(y=Ln(n,v)).length&&(v=new _r(v,e,null,r,i),s.push({event:v,listeners:y}),m?v.data=m:null!==(m=Vr(r))&&(v.data=m))),(m=Mr?function(e,t){switch(e){case"compositionend":return Vr(t);case"keypress":return 32!==t.which?null:(Kr=!0,qr);case"textInput":return(e=t.data)===qr&&Kr?null:e;default:return null}}(e,r):function(e,t){if(zr)return"compositionend"===e||!Ur&&Fr(e,t)?(e=rr(),tr=er=$t=null,zr=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Or&&"ko"!==t.locale?null:t.data}}(e,r))&&(0<(n=Ln(n,"onBeforeInput")).length&&(i=new _r("onBeforeInput","beforeinput",null,r,i),s.push({event:i,listeners:n}),i.data=m))}Cn(s,t)}))}function Un(e,t,r){return{instance:e,listener:t,currentTarget:r}}function Ln(e,t){for(var r=t+"Capture",n=[];null!==e;){var i=e,o=i.stateNode;5===i.tag&&null!==o&&(i=o,null!=(o=qe(e,r))&&n.unshift(Un(e,o,i)),null!=(o=qe(e,t))&&n.push(Un(e,o,i))),e=e.return}return n}function Mn(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function On(e,t,r,n,i){for(var o=t._reactName,s=[];null!==r&&r!==n;){var a=r,c=a.alternate,u=a.stateNode;if(null!==c&&c===n)break;5===a.tag&&null!==u&&(a=u,i?null!=(c=qe(r,o))&&s.unshift(Un(r,c,a)):i||null!=(c=qe(r,o))&&s.push(Un(r,c,a))),r=r.return}0!==s.length&&e.push({event:t,listeners:s})}function qn(){}var Kn=null,Fn=null;function Vn(e,t){switch(e){case"button":case"input":case"select":case"textarea":return!!t.autoFocus}return!1}function zn(e,t){return"textarea"===e||"option"===e||"noscript"===e||"string"===typeof t.children||"number"===typeof t.children||"object"===typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var jn="function"===typeof setTimeout?setTimeout:void 0,Hn="function"===typeof clearTimeout?clearTimeout:void 0;function Gn(e){1===e.nodeType?e.textContent="":9===e.nodeType&&(null!=(e=e.body)&&(e.textContent=""))}function Wn(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break}return e}function Yn(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var r=e.data;if("$"===r||"$!"===r||"$?"===r){if(0===t)return e;t--}else"/$"===r&&t++}e=e.previousSibling}return null}var Qn=0;var Jn=Math.random().toString(36).slice(2),Xn="__reactFiber$"+Jn,Zn="__reactProps$"+Jn,$n="__reactContainer$"+Jn,ei="__reactEvents$"+Jn;function ti(e){var t=e[Xn];if(t)return t;for(var r=e.parentNode;r;){if(t=r[$n]||r[Xn]){if(r=t.alternate,null!==t.child||null!==r&&null!==r.child)for(e=Yn(e);null!==e;){if(r=e[Xn])return r;e=Yn(e)}return t}r=(e=r).parentNode}return null}function ri(e){return!(e=e[Xn]||e[$n])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function ni(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(s(33))}function ii(e){return e[Zn]||null}function oi(e){var t=e[ei];return void 0===t&&(t=e[ei]=new Set),t}var si=[],ai=-1;function ci(e){return{current:e}}function ui(e){0>ai||(e.current=si[ai],si[ai]=null,ai--)}function li(e,t){ai++,si[ai]=e.current,e.current=t}var hi={},di=ci(hi),fi=ci(!1),pi=hi;function gi(e,t){var r=e.type.contextTypes;if(!r)return hi;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var i,o={};for(i in r)o[i]=t[i];return n&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function bi(e){return null!==(e=e.childContextTypes)&&void 0!==e}function yi(){ui(fi),ui(di)}function mi(e,t,r){if(di.current!==hi)throw Error(s(168));li(di,t),li(fi,r)}function vi(e,t,r){var n=e.stateNode;if(e=t.childContextTypes,"function"!==typeof n.getChildContext)return r;for(var o in n=n.getChildContext())if(!(o in e))throw Error(s(108,W(t)||"Unknown",o));return i({},r,n)}function wi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||hi,pi=di.current,li(di,e),li(fi,fi.current),!0}function _i(e,t,r){var n=e.stateNode;if(!n)throw Error(s(169));r?(e=vi(e,t,pi),n.__reactInternalMemoizedMergedChildContext=e,ui(fi),ui(di),li(di,e)):ui(fi),li(fi,r)}var Ei=null,Si=null,Ai=o.unstable_runWithPriority,ki=o.unstable_scheduleCallback,xi=o.unstable_cancelCallback,Ii=o.unstable_shouldYield,Ci=o.unstable_requestPaint,Ti=o.unstable_now,Ri=o.unstable_getCurrentPriorityLevel,Pi=o.unstable_ImmediatePriority,Di=o.unstable_UserBlockingPriority,Ni=o.unstable_NormalPriority,Bi=o.unstable_LowPriority,Ui=o.unstable_IdlePriority,Li={},Mi=void 0!==Ci?Ci:function(){},Oi=null,qi=null,Ki=!1,Fi=Ti(),Vi=1e4>Fi?Ti:function(){return Ti()-Fi};function zi(){switch(Ri()){case Pi:return 99;case Di:return 98;case Ni:return 97;case Bi:return 96;case Ui:return 95;default:throw Error(s(332))}}function ji(e){switch(e){case 99:return Pi;case 98:return Di;case 97:return Ni;case 96:return Bi;case 95:return Ui;default:throw Error(s(332))}}function Hi(e,t){return e=ji(e),Ai(e,t)}function Gi(e,t,r){return e=ji(e),ki(e,t,r)}function Wi(){if(null!==qi){var e=qi;qi=null,xi(e)}Yi()}function Yi(){if(!Ki&&null!==Oi){Ki=!0;var e=0;try{var t=Oi;Hi(99,(function(){for(;e<t.length;e++){var r=t[e];do{r=r(!0)}while(null!==r)}})),Oi=null}catch(r){throw null!==Oi&&(Oi=Oi.slice(e+1)),ki(Pi,Wi),r}finally{Ki=!1}}}var Qi=_.ReactCurrentBatchConfig;function Ji(e,t){if(e&&e.defaultProps){for(var r in t=i({},t),e=e.defaultProps)void 0===t[r]&&(t[r]=e[r]);return t}return t}var Xi=ci(null),Zi=null,$i=null,eo=null;function to(){eo=$i=Zi=null}function ro(e){var t=Xi.current;ui(Xi),e.type._context._currentValue=t}function no(e,t){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)===t){if(null===r||(r.childLanes&t)===t)break;r.childLanes|=t}else e.childLanes|=t,null!==r&&(r.childLanes|=t);e=e.return}}function io(e,t){Zi=e,eo=$i=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(Ls=!0),e.firstContext=null)}function oo(e,t){if(eo!==e&&!1!==t&&0!==t)if("number"===typeof t&&1073741823!==t||(eo=e,t=1073741823),t={context:e,observedBits:t,next:null},null===$i){if(null===Zi)throw Error(s(308));$i=t,Zi.dependencies={lanes:0,firstContext:t,responders:null}}else $i=$i.next=t;return e._currentValue}var so=!1;function ao(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null},effects:null}}function co(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function uo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function lo(e,t){if(null!==(e=e.updateQueue)){var r=(e=e.shared).pending;null===r?t.next=t:(t.next=r.next,r.next=t),e.pending=t}}function ho(e,t){var r=e.updateQueue,n=e.alternate;if(null!==n&&r===(n=n.updateQueue)){var i=null,o=null;if(null!==(r=r.firstBaseUpdate)){do{var s={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};null===o?i=o=s:o=o.next=s,r=r.next}while(null!==r);null===o?i=o=t:o=o.next=t}else i=o=t;return r={baseState:n.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:n.shared,effects:n.effects},void(e.updateQueue=r)}null===(e=r.lastBaseUpdate)?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function fo(e,t,r,n){var o=e.updateQueue;so=!1;var s=o.firstBaseUpdate,a=o.lastBaseUpdate,c=o.shared.pending;if(null!==c){o.shared.pending=null;var u=c,l=u.next;u.next=null,null===a?s=l:a.next=l,a=u;var h=e.alternate;if(null!==h){var d=(h=h.updateQueue).lastBaseUpdate;d!==a&&(null===d?h.firstBaseUpdate=l:d.next=l,h.lastBaseUpdate=u)}}if(null!==s){for(d=o.baseState,a=0,h=l=u=null;;){c=s.lane;var f=s.eventTime;if((n&c)===c){null!==h&&(h=h.next={eventTime:f,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var p=e,g=s;switch(c=t,f=r,g.tag){case 1:if("function"===typeof(p=g.payload)){d=p.call(f,d,c);break e}d=p;break e;case 3:p.flags=-4097&p.flags|64;case 0:if(null===(c="function"===typeof(p=g.payload)?p.call(f,d,c):p)||void 0===c)break e;d=i({},d,c);break e;case 2:so=!0}}null!==s.callback&&(e.flags|=32,null===(c=o.effects)?o.effects=[s]:c.push(s))}else f={eventTime:f,lane:c,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===h?(l=h=f,u=d):h=h.next=f,a|=c;if(null===(s=s.next)){if(null===(c=o.shared.pending))break;s=c.next,c.next=null,o.lastBaseUpdate=c,o.shared.pending=null}}null===h&&(u=d),o.baseState=u,o.firstBaseUpdate=l,o.lastBaseUpdate=h,Fa|=a,e.lanes=a,e.memoizedState=d}}function po(e,t,r){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var n=e[t],i=n.callback;if(null!==i){if(n.callback=null,n=r,"function"!==typeof i)throw Error(s(191,i));i.call(n)}}}var go=(new n.Component).refs;function bo(e,t,r,n){r=null===(r=r(n,t=e.memoizedState))||void 0===r?t:i({},t,r),e.memoizedState=r,0===e.lanes&&(e.updateQueue.baseState=r)}var yo={isMounted:function(e){return!!(e=e._reactInternals)&&Qe(e)===e},enqueueSetState:function(e,t,r){e=e._reactInternals;var n=dc(),i=fc(e),o=uo(n,i);o.payload=t,void 0!==r&&null!==r&&(o.callback=r),lo(e,o),pc(e,i,n)},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var n=dc(),i=fc(e),o=uo(n,i);o.tag=1,o.payload=t,void 0!==r&&null!==r&&(o.callback=r),lo(e,o),pc(e,i,n)},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=dc(),n=fc(e),i=uo(r,n);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),lo(e,i),pc(e,n,r)}};function mo(e,t,r,n,i,o,s){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(n,o,s):!t.prototype||!t.prototype.isPureReactComponent||(!hn(r,n)||!hn(i,o))}function vo(e,t,r){var n=!1,i=hi,o=t.contextType;return"object"===typeof o&&null!==o?o=oo(o):(i=bi(t)?pi:di.current,o=(n=null!==(n=t.contextTypes)&&void 0!==n)?gi(e,i):hi),t=new t(r,o),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=yo,e.stateNode=t,t._reactInternals=e,n&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function wo(e,t,r,n){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(r,n),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(r,n),t.state!==e&&yo.enqueueReplaceState(t,t.state,null)}function _o(e,t,r,n){var i=e.stateNode;i.props=r,i.state=e.memoizedState,i.refs=go,ao(e);var o=t.contextType;"object"===typeof o&&null!==o?i.context=oo(o):(o=bi(t)?pi:di.current,i.context=gi(e,o)),fo(e,r,i,n),i.state=e.memoizedState,"function"===typeof(o=t.getDerivedStateFromProps)&&(bo(e,t,o,r),i.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof i.getSnapshotBeforeUpdate||"function"!==typeof i.UNSAFE_componentWillMount&&"function"!==typeof i.componentWillMount||(t=i.state,"function"===typeof i.componentWillMount&&i.componentWillMount(),"function"===typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),t!==i.state&&yo.enqueueReplaceState(i,i.state,null),fo(e,r,i,n),i.state=e.memoizedState),"function"===typeof i.componentDidMount&&(e.flags|=4)}var Eo=Array.isArray;function So(e,t,r){if(null!==(e=r.ref)&&"function"!==typeof e&&"object"!==typeof e){if(r._owner){if(r=r._owner){if(1!==r.tag)throw Error(s(309));var n=r.stateNode}if(!n)throw Error(s(147,e));var i=""+e;return null!==t&&null!==t.ref&&"function"===typeof t.ref&&t.ref._stringRef===i?t.ref:(t=function(e){var t=n.refs;t===go&&(t=n.refs={}),null===e?delete t[i]:t[i]=e},t._stringRef=i,t)}if("string"!==typeof e)throw Error(s(284));if(!r._owner)throw Error(s(290,e))}return e}function Ao(e,t){if("textarea"!==e.type)throw Error(s(31,"[object Object]"===Object.prototype.toString.call(t)?"object with keys {"+Object.keys(t).join(", ")+"}":t))}function ko(e){function t(t,r){if(e){var n=t.lastEffect;null!==n?(n.nextEffect=r,t.lastEffect=r):t.firstEffect=t.lastEffect=r,r.nextEffect=null,r.flags=8}}function r(r,n){if(!e)return null;for(;null!==n;)t(r,n),n=n.sibling;return null}function n(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=Gc(e,t)).index=0,e.sibling=null,e}function o(t,r,n){return t.index=n,e?null!==(n=t.alternate)?(n=n.index)<r?(t.flags=2,r):n:(t.flags=2,r):r}function a(t){return e&&null===t.alternate&&(t.flags=2),t}function c(e,t,r,n){return null===t||6!==t.tag?((t=Jc(r,e.mode,n)).return=e,t):((t=i(t,r)).return=e,t)}function u(e,t,r,n){return null!==t&&t.elementType===r.type?((n=i(t,r.props)).ref=So(e,t,r),n.return=e,n):((n=Wc(r.type,r.key,r.props,null,e.mode,n)).ref=So(e,t,r),n.return=e,n)}function l(e,t,r,n){return null===t||4!==t.tag||t.stateNode.containerInfo!==r.containerInfo||t.stateNode.implementation!==r.implementation?((t=Xc(r,e.mode,n)).return=e,t):((t=i(t,r.children||[])).return=e,t)}function h(e,t,r,n,o){return null===t||7!==t.tag?((t=Yc(r,e.mode,n,o)).return=e,t):((t=i(t,r)).return=e,t)}function d(e,t,r){if("string"===typeof t||"number"===typeof t)return(t=Jc(""+t,e.mode,r)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case E:return(r=Wc(t.type,t.key,t.props,null,e.mode,r)).ref=So(e,null,t),r.return=e,r;case S:return(t=Xc(t,e.mode,r)).return=e,t}if(Eo(t)||V(t))return(t=Yc(t,e.mode,r,null)).return=e,t;Ao(e,t)}return null}function f(e,t,r,n){var i=null!==t?t.key:null;if("string"===typeof r||"number"===typeof r)return null!==i?null:c(e,t,""+r,n);if("object"===typeof r&&null!==r){switch(r.$$typeof){case E:return r.key===i?r.type===A?h(e,t,r.props.children,n,i):u(e,t,r,n):null;case S:return r.key===i?l(e,t,r,n):null}if(Eo(r)||V(r))return null!==i?null:h(e,t,r,n,null);Ao(e,r)}return null}function p(e,t,r,n,i){if("string"===typeof n||"number"===typeof n)return c(t,e=e.get(r)||null,""+n,i);if("object"===typeof n&&null!==n){switch(n.$$typeof){case E:return e=e.get(null===n.key?r:n.key)||null,n.type===A?h(t,e,n.props.children,i,n.key):u(t,e,n,i);case S:return l(t,e=e.get(null===n.key?r:n.key)||null,n,i)}if(Eo(n)||V(n))return h(t,e=e.get(r)||null,n,i,null);Ao(t,n)}return null}function g(i,s,a,c){for(var u=null,l=null,h=s,g=s=0,b=null;null!==h&&g<a.length;g++){h.index>g?(b=h,h=null):b=h.sibling;var y=f(i,h,a[g],c);if(null===y){null===h&&(h=b);break}e&&h&&null===y.alternate&&t(i,h),s=o(y,s,g),null===l?u=y:l.sibling=y,l=y,h=b}if(g===a.length)return r(i,h),u;if(null===h){for(;g<a.length;g++)null!==(h=d(i,a[g],c))&&(s=o(h,s,g),null===l?u=h:l.sibling=h,l=h);return u}for(h=n(i,h);g<a.length;g++)null!==(b=p(h,i,g,a[g],c))&&(e&&null!==b.alternate&&h.delete(null===b.key?g:b.key),s=o(b,s,g),null===l?u=b:l.sibling=b,l=b);return e&&h.forEach((function(e){return t(i,e)})),u}function b(i,a,c,u){var l=V(c);if("function"!==typeof l)throw Error(s(150));if(null==(c=l.call(c)))throw Error(s(151));for(var h=l=null,g=a,b=a=0,y=null,m=c.next();null!==g&&!m.done;b++,m=c.next()){g.index>b?(y=g,g=null):y=g.sibling;var v=f(i,g,m.value,u);if(null===v){null===g&&(g=y);break}e&&g&&null===v.alternate&&t(i,g),a=o(v,a,b),null===h?l=v:h.sibling=v,h=v,g=y}if(m.done)return r(i,g),l;if(null===g){for(;!m.done;b++,m=c.next())null!==(m=d(i,m.value,u))&&(a=o(m,a,b),null===h?l=m:h.sibling=m,h=m);return l}for(g=n(i,g);!m.done;b++,m=c.next())null!==(m=p(g,i,b,m.value,u))&&(e&&null!==m.alternate&&g.delete(null===m.key?b:m.key),a=o(m,a,b),null===h?l=m:h.sibling=m,h=m);return e&&g.forEach((function(e){return t(i,e)})),l}return function(e,n,o,c){var u="object"===typeof o&&null!==o&&o.type===A&&null===o.key;u&&(o=o.props.children);var l="object"===typeof o&&null!==o;if(l)switch(o.$$typeof){case E:e:{for(l=o.key,u=n;null!==u;){if(u.key===l){if(7===u.tag){if(o.type===A){r(e,u.sibling),(n=i(u,o.props.children)).return=e,e=n;break e}}else if(u.elementType===o.type){r(e,u.sibling),(n=i(u,o.props)).ref=So(e,u,o),n.return=e,e=n;break e}r(e,u);break}t(e,u),u=u.sibling}o.type===A?((n=Yc(o.props.children,e.mode,c,o.key)).return=e,e=n):((c=Wc(o.type,o.key,o.props,null,e.mode,c)).ref=So(e,n,o),c.return=e,e=c)}return a(e);case S:e:{for(u=o.key;null!==n;){if(n.key===u){if(4===n.tag&&n.stateNode.containerInfo===o.containerInfo&&n.stateNode.implementation===o.implementation){r(e,n.sibling),(n=i(n,o.children||[])).return=e,e=n;break e}r(e,n);break}t(e,n),n=n.sibling}(n=Xc(o,e.mode,c)).return=e,e=n}return a(e)}if("string"===typeof o||"number"===typeof o)return o=""+o,null!==n&&6===n.tag?(r(e,n.sibling),(n=i(n,o)).return=e,e=n):(r(e,n),(n=Jc(o,e.mode,c)).return=e,e=n),a(e);if(Eo(o))return g(e,n,o,c);if(V(o))return b(e,n,o,c);if(l&&Ao(e,o),"undefined"===typeof o&&!u)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error(s(152,W(e.type)||"Component"))}return r(e,n)}}var xo=ko(!0),Io=ko(!1),Co={},To=ci(Co),Ro=ci(Co),Po=ci(Co);function Do(e){if(e===Co)throw Error(s(174));return e}function No(e,t){switch(li(Po,t),li(Ro,e),li(To,Co),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:fe(null,"");break;default:t=fe(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}ui(To),li(To,t)}function Bo(){ui(To),ui(Ro),ui(Po)}function Uo(e){Do(Po.current);var t=Do(To.current),r=fe(t,e.type);t!==r&&(li(Ro,e),li(To,r))}function Lo(e){Ro.current===e&&(ui(To),ui(Ro))}var Mo=ci(0);function Oo(e){for(var t=e;null!==t;){if(13===t.tag){var r=t.memoizedState;if(null!==r&&(null===(r=r.dehydrated)||"$?"===r.data||"$!"===r.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(64&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var qo=null,Ko=null,Fo=!1;function Vo(e,t){var r=jc(5,null,null,0);r.elementType="DELETED",r.type="DELETED",r.stateNode=t,r.return=e,r.flags=8,null!==e.lastEffect?(e.lastEffect.nextEffect=r,e.lastEffect=r):e.firstEffect=e.lastEffect=r}function zo(e,t){switch(e.tag){case 5:var r=e.type;return null!==(t=1!==t.nodeType||r.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);default:return!1}}function jo(e){if(Fo){var t=Ko;if(t){var r=t;if(!zo(e,t)){if(!(t=Wn(r.nextSibling))||!zo(e,t))return e.flags=-1025&e.flags|2,Fo=!1,void(qo=e);Vo(qo,r)}qo=e,Ko=Wn(t.firstChild)}else e.flags=-1025&e.flags|2,Fo=!1,qo=e}}function Ho(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;qo=e}function Go(e){if(e!==qo)return!1;if(!Fo)return Ho(e),Fo=!0,!1;var t=e.type;if(5!==e.tag||"head"!==t&&"body"!==t&&!zn(t,e.memoizedProps))for(t=Ko;t;)Vo(e,t),t=Wn(t.nextSibling);if(Ho(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(s(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var r=e.data;if("/$"===r){if(0===t){Ko=Wn(e.nextSibling);break e}t--}else"$"!==r&&"$!"!==r&&"$?"!==r||t++}e=e.nextSibling}Ko=null}}else Ko=qo?Wn(e.stateNode.nextSibling):null;return!0}function Wo(){Ko=qo=null,Fo=!1}var Yo=[];function Qo(){for(var e=0;e<Yo.length;e++)Yo[e]._workInProgressVersionPrimary=null;Yo.length=0}var Jo=_.ReactCurrentDispatcher,Xo=_.ReactCurrentBatchConfig,Zo=0,$o=null,es=null,ts=null,rs=!1,ns=!1;function is(){throw Error(s(321))}function os(e,t){if(null===t)return!1;for(var r=0;r<t.length&&r<e.length;r++)if(!un(e[r],t[r]))return!1;return!0}function ss(e,t,r,n,i,o){if(Zo=o,$o=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Jo.current=null===e||null===e.memoizedState?Ds:Ns,e=r(n,i),ns){o=0;do{if(ns=!1,!(25>o))throw Error(s(301));o+=1,ts=es=null,t.updateQueue=null,Jo.current=Bs,e=r(n,i)}while(ns)}if(Jo.current=Ps,t=null!==es&&null!==es.next,Zo=0,ts=es=$o=null,rs=!1,t)throw Error(s(300));return e}function as(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===ts?$o.memoizedState=ts=e:ts=ts.next=e,ts}function cs(){if(null===es){var e=$o.alternate;e=null!==e?e.memoizedState:null}else e=es.next;var t=null===ts?$o.memoizedState:ts.next;if(null!==t)ts=t,es=e;else{if(null===e)throw Error(s(310));e={memoizedState:(es=e).memoizedState,baseState:es.baseState,baseQueue:es.baseQueue,queue:es.queue,next:null},null===ts?$o.memoizedState=ts=e:ts=ts.next=e}return ts}function us(e,t){return"function"===typeof t?t(e):t}function ls(e){var t=cs(),r=t.queue;if(null===r)throw Error(s(311));r.lastRenderedReducer=e;var n=es,i=n.baseQueue,o=r.pending;if(null!==o){if(null!==i){var a=i.next;i.next=o.next,o.next=a}n.baseQueue=i=o,r.pending=null}if(null!==i){i=i.next,n=n.baseState;var c=a=o=null,u=i;do{var l=u.lane;if((Zo&l)===l)null!==c&&(c=c.next={lane:0,action:u.action,eagerReducer:u.eagerReducer,eagerState:u.eagerState,next:null}),n=u.eagerReducer===e?u.eagerState:e(n,u.action);else{var h={lane:l,action:u.action,eagerReducer:u.eagerReducer,eagerState:u.eagerState,next:null};null===c?(a=c=h,o=n):c=c.next=h,$o.lanes|=l,Fa|=l}u=u.next}while(null!==u&&u!==i);null===c?o=n:c.next=a,un(n,t.memoizedState)||(Ls=!0),t.memoizedState=n,t.baseState=o,t.baseQueue=c,r.lastRenderedState=n}return[t.memoizedState,r.dispatch]}function hs(e){var t=cs(),r=t.queue;if(null===r)throw Error(s(311));r.lastRenderedReducer=e;var n=r.dispatch,i=r.pending,o=t.memoizedState;if(null!==i){r.pending=null;var a=i=i.next;do{o=e(o,a.action),a=a.next}while(a!==i);un(o,t.memoizedState)||(Ls=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),r.lastRenderedState=o}return[o,n]}function ds(e,t,r){var n=t._getVersion;n=n(t._source);var i=t._workInProgressVersionPrimary;if(null!==i?e=i===n:(e=e.mutableReadLanes,(e=(Zo&e)===e)&&(t._workInProgressVersionPrimary=n,Yo.push(t))),e)return r(t._source);throw Yo.push(t),Error(s(350))}function fs(e,t,r,n){var i=Na;if(null===i)throw Error(s(349));var o=t._getVersion,a=o(t._source),c=Jo.current,u=c.useState((function(){return ds(i,t,r)})),l=u[1],h=u[0];u=ts;var d=e.memoizedState,f=d.refs,p=f.getSnapshot,g=d.source;d=d.subscribe;var b=$o;return e.memoizedState={refs:f,source:t,subscribe:n},c.useEffect((function(){f.getSnapshot=r,f.setSnapshot=l;var e=o(t._source);if(!un(a,e)){e=r(t._source),un(h,e)||(l(e),e=fc(b),i.mutableReadLanes|=e&i.pendingLanes),e=i.mutableReadLanes,i.entangledLanes|=e;for(var n=i.entanglements,s=e;0<s;){var c=31-zt(s),u=1<<c;n[c]|=e,s&=~u}}}),[r,t,n]),c.useEffect((function(){return n(t._source,(function(){var e=f.getSnapshot,r=f.setSnapshot;try{r(e(t._source));var n=fc(b);i.mutableReadLanes|=n&i.pendingLanes}catch(o){r((function(){throw o}))}}))}),[t,n]),un(p,r)&&un(g,t)&&un(d,n)||((e={pending:null,dispatch:null,lastRenderedReducer:us,lastRenderedState:h}).dispatch=l=Rs.bind(null,$o,e),u.queue=e,u.baseQueue=null,h=ds(i,t,r),u.memoizedState=u.baseState=h),h}function ps(e,t,r){return fs(cs(),e,t,r)}function gs(e){var t=as();return"function"===typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={pending:null,dispatch:null,lastRenderedReducer:us,lastRenderedState:e}).dispatch=Rs.bind(null,$o,e),[t.memoizedState,e]}function bs(e,t,r,n){return e={tag:e,create:t,destroy:r,deps:n,next:null},null===(t=$o.updateQueue)?(t={lastEffect:null},$o.updateQueue=t,t.lastEffect=e.next=e):null===(r=t.lastEffect)?t.lastEffect=e.next=e:(n=r.next,r.next=e,e.next=n,t.lastEffect=e),e}function ys(e){return e={current:e},as().memoizedState=e}function ms(){return cs().memoizedState}function vs(e,t,r,n){var i=as();$o.flags|=e,i.memoizedState=bs(1|t,r,void 0,void 0===n?null:n)}function ws(e,t,r,n){var i=cs();n=void 0===n?null:n;var o=void 0;if(null!==es){var s=es.memoizedState;if(o=s.destroy,null!==n&&os(n,s.deps))return void bs(t,r,o,n)}$o.flags|=e,i.memoizedState=bs(1|t,r,o,n)}function _s(e,t){return vs(516,4,e,t)}function Es(e,t){return ws(516,4,e,t)}function Ss(e,t){return ws(4,2,e,t)}function As(e,t){return"function"===typeof t?(e=e(),t(e),function(){t(null)}):null!==t&&void 0!==t?(e=e(),t.current=e,function(){t.current=null}):void 0}function ks(e,t,r){return r=null!==r&&void 0!==r?r.concat([e]):null,ws(4,2,As.bind(null,t,e),r)}function xs(){}function Is(e,t){var r=cs();t=void 0===t?null:t;var n=r.memoizedState;return null!==n&&null!==t&&os(t,n[1])?n[0]:(r.memoizedState=[e,t],e)}function Cs(e,t){var r=cs();t=void 0===t?null:t;var n=r.memoizedState;return null!==n&&null!==t&&os(t,n[1])?n[0]:(e=e(),r.memoizedState=[e,t],e)}function Ts(e,t){var r=zi();Hi(98>r?98:r,(function(){e(!0)})),Hi(97<r?97:r,(function(){var r=Xo.transition;Xo.transition=1;try{e(!1),t()}finally{Xo.transition=r}}))}function Rs(e,t,r){var n=dc(),i=fc(e),o={lane:i,action:r,eagerReducer:null,eagerState:null,next:null},s=t.pending;if(null===s?o.next=o:(o.next=s.next,s.next=o),t.pending=o,s=e.alternate,e===$o||null!==s&&s===$o)ns=rs=!0;else{if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var a=t.lastRenderedState,c=s(a,r);if(o.eagerReducer=s,o.eagerState=c,un(c,a))return}catch(u){}pc(e,i,n)}}var Ps={readContext:oo,useCallback:is,useContext:is,useEffect:is,useImperativeHandle:is,useLayoutEffect:is,useMemo:is,useReducer:is,useRef:is,useState:is,useDebugValue:is,useDeferredValue:is,useTransition:is,useMutableSource:is,useOpaqueIdentifier:is,unstable_isNewReconciler:!1},Ds={readContext:oo,useCallback:function(e,t){return as().memoizedState=[e,void 0===t?null:t],e},useContext:oo,useEffect:_s,useImperativeHandle:function(e,t,r){return r=null!==r&&void 0!==r?r.concat([e]):null,vs(4,2,As.bind(null,t,e),r)},useLayoutEffect:function(e,t){return vs(4,2,e,t)},useMemo:function(e,t){var r=as();return t=void 0===t?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var n=as();return t=void 0!==r?r(t):t,n.memoizedState=n.baseState=t,e=(e=n.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Rs.bind(null,$o,e),[n.memoizedState,e]},useRef:ys,useState:gs,useDebugValue:xs,useDeferredValue:function(e){var t=gs(e),r=t[0],n=t[1];return _s((function(){var t=Xo.transition;Xo.transition=1;try{n(e)}finally{Xo.transition=t}}),[e]),r},useTransition:function(){var e=gs(!1),t=e[0];return ys(e=Ts.bind(null,e[1])),[e,t]},useMutableSource:function(e,t,r){var n=as();return n.memoizedState={refs:{getSnapshot:t,setSnapshot:null},source:e,subscribe:r},fs(n,e,t,r)},useOpaqueIdentifier:function(){if(Fo){var e=!1,t=function(e){return{$$typeof:U,toString:e,valueOf:e}}((function(){throw e||(e=!0,r("r:"+(Qn++).toString(36))),Error(s(355))})),r=gs(t)[1];return 0===(2&$o.mode)&&($o.flags|=516,bs(5,(function(){r("r:"+(Qn++).toString(36))}),void 0,null)),t}return gs(t="r:"+(Qn++).toString(36)),t},unstable_isNewReconciler:!1},Ns={readContext:oo,useCallback:Is,useContext:oo,useEffect:Es,useImperativeHandle:ks,useLayoutEffect:Ss,useMemo:Cs,useReducer:ls,useRef:ms,useState:function(){return ls(us)},useDebugValue:xs,useDeferredValue:function(e){var t=ls(us),r=t[0],n=t[1];return Es((function(){var t=Xo.transition;Xo.transition=1;try{n(e)}finally{Xo.transition=t}}),[e]),r},useTransition:function(){var e=ls(us)[0];return[ms().current,e]},useMutableSource:ps,useOpaqueIdentifier:function(){return ls(us)[0]},unstable_isNewReconciler:!1},Bs={readContext:oo,useCallback:Is,useContext:oo,useEffect:Es,useImperativeHandle:ks,useLayoutEffect:Ss,useMemo:Cs,useReducer:hs,useRef:ms,useState:function(){return hs(us)},useDebugValue:xs,useDeferredValue:function(e){var t=hs(us),r=t[0],n=t[1];return Es((function(){var t=Xo.transition;Xo.transition=1;try{n(e)}finally{Xo.transition=t}}),[e]),r},useTransition:function(){var e=hs(us)[0];return[ms().current,e]},useMutableSource:ps,useOpaqueIdentifier:function(){return hs(us)[0]},unstable_isNewReconciler:!1},Us=_.ReactCurrentOwner,Ls=!1;function Ms(e,t,r,n){t.child=null===e?Io(t,null,r,n):xo(t,e.child,r,n)}function Os(e,t,r,n,i){r=r.render;var o=t.ref;return io(t,i),n=ss(e,t,r,n,o,i),null===e||Ls?(t.flags|=1,Ms(e,t,n,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-517,e.lanes&=~i,oa(e,t,i))}function qs(e,t,r,n,i,o){if(null===e){var s=r.type;return"function"!==typeof s||Hc(s)||void 0!==s.defaultProps||null!==r.compare||void 0!==r.defaultProps?((e=Wc(r.type,null,n,t,t.mode,o)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,Ks(e,t,s,n,i,o))}return s=e.child,0===(i&o)&&(i=s.memoizedProps,(r=null!==(r=r.compare)?r:hn)(i,n)&&e.ref===t.ref)?oa(e,t,o):(t.flags|=1,(e=Gc(s,n)).ref=t.ref,e.return=t,t.child=e)}function Ks(e,t,r,n,i,o){if(null!==e&&hn(e.memoizedProps,n)&&e.ref===t.ref){if(Ls=!1,0===(o&i))return t.lanes=e.lanes,oa(e,t,o);0!==(16384&e.flags)&&(Ls=!0)}return zs(e,t,r,n,o)}function Fs(e,t,r){var n=t.pendingProps,i=n.children,o=null!==e?e.memoizedState:null;if("hidden"===n.mode||"unstable-defer-without-hiding"===n.mode)if(0===(4&t.mode))t.memoizedState={baseLanes:0},Ec(t,r);else{if(0===(1073741824&r))return e=null!==o?o.baseLanes|r:r,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e},Ec(t,e),null;t.memoizedState={baseLanes:0},Ec(t,null!==o?o.baseLanes:r)}else null!==o?(n=o.baseLanes|r,t.memoizedState=null):n=r,Ec(t,n);return Ms(e,t,i,r),t.child}function Vs(e,t){var r=t.ref;(null===e&&null!==r||null!==e&&e.ref!==r)&&(t.flags|=128)}function zs(e,t,r,n,i){var o=bi(r)?pi:di.current;return o=gi(t,o),io(t,i),r=ss(e,t,r,n,o,i),null===e||Ls?(t.flags|=1,Ms(e,t,r,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-517,e.lanes&=~i,oa(e,t,i))}function js(e,t,r,n,i){if(bi(r)){var o=!0;wi(t)}else o=!1;if(io(t,i),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),vo(t,r,n),_o(t,r,n,i),n=!0;else if(null===e){var s=t.stateNode,a=t.memoizedProps;s.props=a;var c=s.context,u=r.contextType;"object"===typeof u&&null!==u?u=oo(u):u=gi(t,u=bi(r)?pi:di.current);var l=r.getDerivedStateFromProps,h="function"===typeof l||"function"===typeof s.getSnapshotBeforeUpdate;h||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(a!==n||c!==u)&&wo(t,s,n,u),so=!1;var d=t.memoizedState;s.state=d,fo(t,n,s,i),c=t.memoizedState,a!==n||d!==c||fi.current||so?("function"===typeof l&&(bo(t,r,l,n),c=t.memoizedState),(a=so||mo(t,r,a,n,d,c,u))?(h||"function"!==typeof s.UNSAFE_componentWillMount&&"function"!==typeof s.componentWillMount||("function"===typeof s.componentWillMount&&s.componentWillMount(),"function"===typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount()),"function"===typeof s.componentDidMount&&(t.flags|=4)):("function"===typeof s.componentDidMount&&(t.flags|=4),t.memoizedProps=n,t.memoizedState=c),s.props=n,s.state=c,s.context=u,n=a):("function"===typeof s.componentDidMount&&(t.flags|=4),n=!1)}else{s=t.stateNode,co(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Ji(t.type,a),s.props=u,h=t.pendingProps,d=s.context,"object"===typeof(c=r.contextType)&&null!==c?c=oo(c):c=gi(t,c=bi(r)?pi:di.current);var f=r.getDerivedStateFromProps;(l="function"===typeof f||"function"===typeof s.getSnapshotBeforeUpdate)||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(a!==h||d!==c)&&wo(t,s,n,c),so=!1,d=t.memoizedState,s.state=d,fo(t,n,s,i);var p=t.memoizedState;a!==h||d!==p||fi.current||so?("function"===typeof f&&(bo(t,r,f,n),p=t.memoizedState),(u=so||mo(t,r,u,n,d,p,c))?(l||"function"!==typeof s.UNSAFE_componentWillUpdate&&"function"!==typeof s.componentWillUpdate||("function"===typeof s.componentWillUpdate&&s.componentWillUpdate(n,p,c),"function"===typeof s.UNSAFE_componentWillUpdate&&s.UNSAFE_componentWillUpdate(n,p,c)),"function"===typeof s.componentDidUpdate&&(t.flags|=4),"function"===typeof s.getSnapshotBeforeUpdate&&(t.flags|=256)):("function"!==typeof s.componentDidUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=256),t.memoizedProps=n,t.memoizedState=p),s.props=n,s.state=p,s.context=c,n=u):("function"!==typeof s.componentDidUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=256),n=!1)}return Hs(e,t,r,n,o,i)}function Hs(e,t,r,n,i,o){Vs(e,t);var s=0!==(64&t.flags);if(!n&&!s)return i&&_i(t,r,!1),oa(e,t,o);n=t.stateNode,Us.current=t;var a=s&&"function"!==typeof r.getDerivedStateFromError?null:n.render();return t.flags|=1,null!==e&&s?(t.child=xo(t,e.child,null,o),t.child=xo(t,null,a,o)):Ms(e,t,a,o),t.memoizedState=n.state,i&&_i(t,r,!0),t.child}function Gs(e){var t=e.stateNode;t.pendingContext?mi(0,t.pendingContext,t.pendingContext!==t.context):t.context&&mi(0,t.context,!1),No(e,t.containerInfo)}var Ws,Ys,Qs,Js,Xs={dehydrated:null,retryLane:0};function Zs(e,t,r){var n,i=t.pendingProps,o=Mo.current,s=!1;return(n=0!==(64&t.flags))||(n=(null===e||null!==e.memoizedState)&&0!==(2&o)),n?(s=!0,t.flags&=-65):null!==e&&null===e.memoizedState||void 0===i.fallback||!0===i.unstable_avoidThisFallback||(o|=1),li(Mo,1&o),null===e?(void 0!==i.fallback&&jo(t),e=i.children,o=i.fallback,s?(e=$s(t,e,o,r),t.child.memoizedState={baseLanes:r},t.memoizedState=Xs,e):"number"===typeof i.unstable_expectedLoadTime?(e=$s(t,e,o,r),t.child.memoizedState={baseLanes:r},t.memoizedState=Xs,t.lanes=33554432,e):((r=Qc({mode:"visible",children:e},t.mode,r,null)).return=t,t.child=r)):(e.memoizedState,s?(i=ta(e,t,i.children,i.fallback,r),s=t.child,o=e.child.memoizedState,s.memoizedState=null===o?{baseLanes:r}:{baseLanes:o.baseLanes|r},s.childLanes=e.childLanes&~r,t.memoizedState=Xs,i):(r=ea(e,t,i.children,r),t.memoizedState=null,r))}function $s(e,t,r,n){var i=e.mode,o=e.child;return t={mode:"hidden",children:t},0===(2&i)&&null!==o?(o.childLanes=0,o.pendingProps=t):o=Qc(t,i,0,null),r=Yc(r,i,n,null),o.return=e,r.return=e,o.sibling=r,e.child=o,r}function ea(e,t,r,n){var i=e.child;return e=i.sibling,r=Gc(i,{mode:"visible",children:r}),0===(2&t.mode)&&(r.lanes=n),r.return=t,r.sibling=null,null!==e&&(e.nextEffect=null,e.flags=8,t.firstEffect=t.lastEffect=e),t.child=r}function ta(e,t,r,n,i){var o=t.mode,s=e.child;e=s.sibling;var a={mode:"hidden",children:r};return 0===(2&o)&&t.child!==s?((r=t.child).childLanes=0,r.pendingProps=a,null!==(s=r.lastEffect)?(t.firstEffect=r.firstEffect,t.lastEffect=s,s.nextEffect=null):t.firstEffect=t.lastEffect=null):r=Gc(s,a),null!==e?n=Gc(e,n):(n=Yc(n,o,i,null)).flags|=2,n.return=t,r.return=t,r.sibling=n,t.child=r,n}function ra(e,t){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),no(e.return,t)}function na(e,t,r,n,i,o){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:i,lastEffect:o}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=n,s.tail=r,s.tailMode=i,s.lastEffect=o)}function ia(e,t,r){var n=t.pendingProps,i=n.revealOrder,o=n.tail;if(Ms(e,t,n.children,r),0!==(2&(n=Mo.current)))n=1&n|2,t.flags|=64;else{if(null!==e&&0!==(64&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ra(e,r);else if(19===e.tag)ra(e,r);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(li(Mo,n),0===(2&t.mode))t.memoizedState=null;else switch(i){case"forwards":for(r=t.child,i=null;null!==r;)null!==(e=r.alternate)&&null===Oo(e)&&(i=r),r=r.sibling;null===(r=i)?(i=t.child,t.child=null):(i=r.sibling,r.sibling=null),na(t,!1,i,r,o,t.lastEffect);break;case"backwards":for(r=null,i=t.child,t.child=null;null!==i;){if(null!==(e=i.alternate)&&null===Oo(e)){t.child=i;break}e=i.sibling,i.sibling=r,r=i,i=e}na(t,!0,r,null,o,t.lastEffect);break;case"together":na(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function oa(e,t,r){if(null!==e&&(t.dependencies=e.dependencies),Fa|=t.lanes,0!==(r&t.childLanes)){if(null!==e&&t.child!==e.child)throw Error(s(153));if(null!==t.child){for(r=Gc(e=t.child,e.pendingProps),t.child=r,r.return=t;null!==e.sibling;)e=e.sibling,(r=r.sibling=Gc(e,e.pendingProps)).return=t;r.sibling=null}return t.child}return null}function sa(e,t){if(!Fo)switch(e.tailMode){case"hidden":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var n=null;null!==r;)null!==r.alternate&&(n=r),r=r.sibling;null===n?t||null===e.tail?e.tail=null:e.tail.sibling=null:n.sibling=null}}function aa(e,t,r){var n=t.pendingProps;switch(t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:case 17:return bi(t.type)&&yi(),null;case 3:return Bo(),ui(fi),ui(di),Qo(),(n=t.stateNode).pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(Go(t)?t.flags|=4:n.hydrate||(t.flags|=256)),Ys(t),null;case 5:Lo(t);var o=Do(Po.current);if(r=t.type,null!==e&&null!=t.stateNode)Qs(e,t,r,n,o),e.ref!==t.ref&&(t.flags|=128);else{if(!n){if(null===t.stateNode)throw Error(s(166));return null}if(e=Do(To.current),Go(t)){n=t.stateNode,r=t.type;var a=t.memoizedProps;switch(n[Xn]=t,n[Zn]=a,r){case"dialog":Tn("cancel",n),Tn("close",n);break;case"iframe":case"object":case"embed":Tn("load",n);break;case"video":case"audio":for(e=0;e<kn.length;e++)Tn(kn[e],n);break;case"source":Tn("error",n);break;case"img":case"image":case"link":Tn("error",n),Tn("load",n);break;case"details":Tn("toggle",n);break;case"input":ee(n,a),Tn("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!a.multiple},Tn("invalid",n);break;case"textarea":ce(n,a),Tn("invalid",n)}for(var u in Se(r,a),e=null,a)a.hasOwnProperty(u)&&(o=a[u],"children"===u?"string"===typeof o?n.textContent!==o&&(e=["children",o]):"number"===typeof o&&n.textContent!==""+o&&(e=["children",""+o]):c.hasOwnProperty(u)&&null!=o&&"onScroll"===u&&Tn("scroll",n));switch(r){case"input":J(n),ne(n,a,!0);break;case"textarea":J(n),le(n);break;case"select":case"option":break;default:"function"===typeof a.onClick&&(n.onclick=qn)}n=e,t.updateQueue=n,null!==n&&(t.flags|=4)}else{switch(u=9===o.nodeType?o:o.ownerDocument,e===he.html&&(e=de(r)),e===he.html?"script"===r?((e=u.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"===typeof n.is?e=u.createElement(r,{is:n.is}):(e=u.createElement(r),"select"===r&&(u=e,n.multiple?u.multiple=!0:n.size&&(u.size=n.size))):e=u.createElementNS(e,r),e[Xn]=t,e[Zn]=n,Ws(e,t,!1,!1),t.stateNode=e,u=Ae(r,n),r){case"dialog":Tn("cancel",e),Tn("close",e),o=n;break;case"iframe":case"object":case"embed":Tn("load",e),o=n;break;case"video":case"audio":for(o=0;o<kn.length;o++)Tn(kn[o],e);o=n;break;case"source":Tn("error",e),o=n;break;case"img":case"image":case"link":Tn("error",e),Tn("load",e),o=n;break;case"details":Tn("toggle",e),o=n;break;case"input":ee(e,n),o=$(e,n),Tn("invalid",e);break;case"option":o=oe(e,n);break;case"select":e._wrapperState={wasMultiple:!!n.multiple},o=i({},n,{value:void 0}),Tn("invalid",e);break;case"textarea":ce(e,n),o=ae(e,n),Tn("invalid",e);break;default:o=n}Se(r,o);var l=o;for(a in l)if(l.hasOwnProperty(a)){var h=l[a];"style"===a?_e(e,h):"dangerouslySetInnerHTML"===a?null!=(h=h?h.__html:void 0)&&be(e,h):"children"===a?"string"===typeof h?("textarea"!==r||""!==h)&&ye(e,h):"number"===typeof h&&ye(e,""+h):"suppressContentEditableWarning"!==a&&"suppressHydrationWarning"!==a&&"autoFocus"!==a&&(c.hasOwnProperty(a)?null!=h&&"onScroll"===a&&Tn("scroll",e):null!=h&&w(e,a,h,u))}switch(r){case"input":J(e),ne(e,n,!1);break;case"textarea":J(e),le(e);break;case"option":null!=n.value&&e.setAttribute("value",""+Y(n.value));break;case"select":e.multiple=!!n.multiple,null!=(a=n.value)?se(e,!!n.multiple,a,!1):null!=n.defaultValue&&se(e,!!n.multiple,n.defaultValue,!0);break;default:"function"===typeof o.onClick&&(e.onclick=qn)}Vn(r,n)&&(t.flags|=4)}null!==t.ref&&(t.flags|=128)}return null;case 6:if(e&&null!=t.stateNode)Js(e,t,e.memoizedProps,n);else{if("string"!==typeof n&&null===t.stateNode)throw Error(s(166));r=Do(Po.current),Do(To.current),Go(t)?(n=t.stateNode,r=t.memoizedProps,n[Xn]=t,n.nodeValue!==r&&(t.flags|=4)):((n=(9===r.nodeType?r:r.ownerDocument).createTextNode(n))[Xn]=t,t.stateNode=n)}return null;case 13:return ui(Mo),n=t.memoizedState,0!==(64&t.flags)?(t.lanes=r,t):(n=null!==n,r=!1,null===e?void 0!==t.memoizedProps.fallback&&Go(t):r=null!==e.memoizedState,n&&!r&&0!==(2&t.mode)&&(null===e&&!0!==t.memoizedProps.unstable_avoidThisFallback||0!==(1&Mo.current)?0===Oa&&(Oa=3):(0!==Oa&&3!==Oa||(Oa=4),null===Na||0===(134217727&Fa)&&0===(134217727&Va)||mc(Na,Ua))),(n||r)&&(t.flags|=4),null);case 4:return Bo(),Ys(t),null===e&&Pn(t.stateNode.containerInfo),null;case 10:return ro(t),null;case 19:if(ui(Mo),null===(n=t.memoizedState))return null;if(a=0!==(64&t.flags),null===(u=n.rendering))if(a)sa(n,!1);else{if(0!==Oa||null!==e&&0!==(64&e.flags))for(e=t.child;null!==e;){if(null!==(u=Oo(e))){for(t.flags|=64,sa(n,!1),null!==(a=u.updateQueue)&&(t.updateQueue=a,t.flags|=4),null===n.lastEffect&&(t.firstEffect=null),t.lastEffect=n.lastEffect,n=r,r=t.child;null!==r;)e=n,(a=r).flags&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,null===(u=a.alternate)?(a.childLanes=0,a.lanes=e,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=u.childLanes,a.lanes=u.lanes,a.child=u.child,a.memoizedProps=u.memoizedProps,a.memoizedState=u.memoizedState,a.updateQueue=u.updateQueue,a.type=u.type,e=u.dependencies,a.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return li(Mo,1&Mo.current|2),t.child}e=e.sibling}null!==n.tail&&Vi()>Ga&&(t.flags|=64,a=!0,sa(n,!1),t.lanes=33554432)}else{if(!a)if(null!==(e=Oo(u))){if(t.flags|=64,a=!0,null!==(r=e.updateQueue)&&(t.updateQueue=r,t.flags|=4),sa(n,!0),null===n.tail&&"hidden"===n.tailMode&&!u.alternate&&!Fo)return null!==(t=t.lastEffect=n.lastEffect)&&(t.nextEffect=null),null}else 2*Vi()-n.renderingStartTime>Ga&&1073741824!==r&&(t.flags|=64,a=!0,sa(n,!1),t.lanes=33554432);n.isBackwards?(u.sibling=t.child,t.child=u):(null!==(r=n.last)?r.sibling=u:t.child=u,n.last=u)}return null!==n.tail?(r=n.tail,n.rendering=r,n.tail=r.sibling,n.lastEffect=t.lastEffect,n.renderingStartTime=Vi(),r.sibling=null,t=Mo.current,li(Mo,a?1&t|2:1&t),r):null;case 23:case 24:return Sc(),null!==e&&null!==e.memoizedState!==(null!==t.memoizedState)&&"unstable-defer-without-hiding"!==n.mode&&(t.flags|=4),null}throw Error(s(156,t.tag))}function ca(e){switch(e.tag){case 1:bi(e.type)&&yi();var t=e.flags;return 4096&t?(e.flags=-4097&t|64,e):null;case 3:if(Bo(),ui(fi),ui(di),Qo(),0!==(64&(t=e.flags)))throw Error(s(285));return e.flags=-4097&t|64,e;case 5:return Lo(e),null;case 13:return ui(Mo),4096&(t=e.flags)?(e.flags=-4097&t|64,e):null;case 19:return ui(Mo),null;case 4:return Bo(),null;case 10:return ro(e),null;case 23:case 24:return Sc(),null;default:return null}}function ua(e,t){try{var r="",n=t;do{r+=G(n),n=n.return}while(n);var i=r}catch(o){i="\nError generating stack: "+o.message+"\n"+o.stack}return{value:e,source:t,stack:i}}function la(e,t){try{console.error(t.value)}catch(r){setTimeout((function(){throw r}))}}Ws=function(e,t){for(var r=t.child;null!==r;){if(5===r.tag||6===r.tag)e.appendChild(r.stateNode);else if(4!==r.tag&&null!==r.child){r.child.return=r,r=r.child;continue}if(r===t)break;for(;null===r.sibling;){if(null===r.return||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}},Ys=function(){},Qs=function(e,t,r,n){var o=e.memoizedProps;if(o!==n){e=t.stateNode,Do(To.current);var s,a=null;switch(r){case"input":o=$(e,o),n=$(e,n),a=[];break;case"option":o=oe(e,o),n=oe(e,n),a=[];break;case"select":o=i({},o,{value:void 0}),n=i({},n,{value:void 0}),a=[];break;case"textarea":o=ae(e,o),n=ae(e,n),a=[];break;default:"function"!==typeof o.onClick&&"function"===typeof n.onClick&&(e.onclick=qn)}for(h in Se(r,n),r=null,o)if(!n.hasOwnProperty(h)&&o.hasOwnProperty(h)&&null!=o[h])if("style"===h){var u=o[h];for(s in u)u.hasOwnProperty(s)&&(r||(r={}),r[s]="")}else"dangerouslySetInnerHTML"!==h&&"children"!==h&&"suppressContentEditableWarning"!==h&&"suppressHydrationWarning"!==h&&"autoFocus"!==h&&(c.hasOwnProperty(h)?a||(a=[]):(a=a||[]).push(h,null));for(h in n){var l=n[h];if(u=null!=o?o[h]:void 0,n.hasOwnProperty(h)&&l!==u&&(null!=l||null!=u))if("style"===h)if(u){for(s in u)!u.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(r||(r={}),r[s]="");for(s in l)l.hasOwnProperty(s)&&u[s]!==l[s]&&(r||(r={}),r[s]=l[s])}else r||(a||(a=[]),a.push(h,r)),r=l;else"dangerouslySetInnerHTML"===h?(l=l?l.__html:void 0,u=u?u.__html:void 0,null!=l&&u!==l&&(a=a||[]).push(h,l)):"children"===h?"string"!==typeof l&&"number"!==typeof l||(a=a||[]).push(h,""+l):"suppressContentEditableWarning"!==h&&"suppressHydrationWarning"!==h&&(c.hasOwnProperty(h)?(null!=l&&"onScroll"===h&&Tn("scroll",e),a||u===l||(a=[])):"object"===typeof l&&null!==l&&l.$$typeof===U?l.toString():(a=a||[]).push(h,l))}r&&(a=a||[]).push("style",r);var h=a;(t.updateQueue=h)&&(t.flags|=4)}},Js=function(e,t,r,n){r!==n&&(t.flags|=4)};var ha="function"===typeof WeakMap?WeakMap:Map;function da(e,t,r){(r=uo(-1,r)).tag=3,r.payload={element:null};var n=t.value;return r.callback=function(){Ja||(Ja=!0,Xa=n),la(0,t)},r}function fa(e,t,r){(r=uo(-1,r)).tag=3;var n=e.type.getDerivedStateFromError;if("function"===typeof n){var i=t.value;r.payload=function(){return la(0,t),n(i)}}var o=e.stateNode;return null!==o&&"function"===typeof o.componentDidCatch&&(r.callback=function(){"function"!==typeof n&&(null===Za?Za=new Set([this]):Za.add(this),la(0,t));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),r}var pa="function"===typeof WeakSet?WeakSet:Set;function ga(e){var t=e.ref;if(null!==t)if("function"===typeof t)try{t(null)}catch(r){Kc(e,r)}else t.current=null}function ba(e,t){switch(t.tag){case 0:case 11:case 15:case 22:case 5:case 6:case 4:case 17:return;case 1:if(256&t.flags&&null!==e){var r=e.memoizedProps,n=e.memoizedState;t=(e=t.stateNode).getSnapshotBeforeUpdate(t.elementType===t.type?r:Ji(t.type,r),n),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:return void(256&t.flags&&Gn(t.stateNode.containerInfo))}throw Error(s(163))}function ya(e,t,r){switch(r.tag){case 0:case 11:case 15:case 22:if(null!==(t=null!==(t=r.updateQueue)?t.lastEffect:null)){e=t=t.next;do{if(3===(3&e.tag)){var n=e.create;e.destroy=n()}e=e.next}while(e!==t)}if(null!==(t=null!==(t=r.updateQueue)?t.lastEffect:null)){e=t=t.next;do{var i=e;n=i.next,0!==(4&(i=i.tag))&&0!==(1&i)&&(Mc(r,e),Lc(r,e)),e=n}while(e!==t)}return;case 1:return e=r.stateNode,4&r.flags&&(null===t?e.componentDidMount():(n=r.elementType===r.type?t.memoizedProps:Ji(r.type,t.memoizedProps),e.componentDidUpdate(n,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),void(null!==(t=r.updateQueue)&&po(r,t,e));case 3:if(null!==(t=r.updateQueue)){if(e=null,null!==r.child)switch(r.child.tag){case 5:case 1:e=r.child.stateNode}po(r,t,e)}return;case 5:return e=r.stateNode,void(null===t&&4&r.flags&&Vn(r.type,r.memoizedProps)&&e.focus());case 6:case 4:case 12:case 19:case 17:case 20:case 21:case 23:case 24:return;case 13:return void(null===r.memoizedState&&(r=r.alternate,null!==r&&(r=r.memoizedState,null!==r&&(r=r.dehydrated,null!==r&&_t(r)))))}throw Error(s(163))}function ma(e,t){for(var r=e;;){if(5===r.tag){var n=r.stateNode;if(t)"function"===typeof(n=n.style).setProperty?n.setProperty("display","none","important"):n.display="none";else{n=r.stateNode;var i=r.memoizedProps.style;i=void 0!==i&&null!==i&&i.hasOwnProperty("display")?i.display:null,n.style.display=we("display",i)}}else if(6===r.tag)r.stateNode.nodeValue=t?"":r.memoizedProps;else if((23!==r.tag&&24!==r.tag||null===r.memoizedState||r===e)&&null!==r.child){r.child.return=r,r=r.child;continue}if(r===e)break;for(;null===r.sibling;){if(null===r.return||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}}function va(e,t){if(Si&&"function"===typeof Si.onCommitFiberUnmount)try{Si.onCommitFiberUnmount(Ei,t)}catch(o){}switch(t.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e=e.next;do{var n=r,i=n.destroy;if(n=n.tag,void 0!==i)if(0!==(4&n))Mc(t,r);else{n=t;try{i()}catch(o){Kc(n,o)}}r=r.next}while(r!==e)}break;case 1:if(ga(t),"function"===typeof(e=t.stateNode).componentWillUnmount)try{e.props=t.memoizedProps,e.state=t.memoizedState,e.componentWillUnmount()}catch(o){Kc(t,o)}break;case 5:ga(t);break;case 4:ka(e,t)}}function wa(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}function _a(e){return 5===e.tag||3===e.tag||4===e.tag}function Ea(e){e:{for(var t=e.return;null!==t;){if(_a(t))break e;t=t.return}throw Error(s(160))}var r=t;switch(t=r.stateNode,r.tag){case 5:var n=!1;break;case 3:case 4:t=t.containerInfo,n=!0;break;default:throw Error(s(161))}16&r.flags&&(ye(t,""),r.flags&=-17);e:t:for(r=e;;){for(;null===r.sibling;){if(null===r.return||_a(r.return)){r=null;break e}r=r.return}for(r.sibling.return=r.return,r=r.sibling;5!==r.tag&&6!==r.tag&&18!==r.tag;){if(2&r.flags)continue t;if(null===r.child||4===r.tag)continue t;r.child.return=r,r=r.child}if(!(2&r.flags)){r=r.stateNode;break e}}n?Sa(e,r,t):Aa(e,r,t)}function Sa(e,t,r){var n=e.tag,i=5===n||6===n;if(i)e=i?e.stateNode:e.stateNode.instance,t?8===r.nodeType?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(8===r.nodeType?(t=r.parentNode).insertBefore(e,r):(t=r).appendChild(e),null!==(r=r._reactRootContainer)&&void 0!==r||null!==t.onclick||(t.onclick=qn));else if(4!==n&&null!==(e=e.child))for(Sa(e,t,r),e=e.sibling;null!==e;)Sa(e,t,r),e=e.sibling}function Aa(e,t,r){var n=e.tag,i=5===n||6===n;if(i)e=i?e.stateNode:e.stateNode.instance,t?r.insertBefore(e,t):r.appendChild(e);else if(4!==n&&null!==(e=e.child))for(Aa(e,t,r),e=e.sibling;null!==e;)Aa(e,t,r),e=e.sibling}function ka(e,t){for(var r,n,i=t,o=!1;;){if(!o){o=i.return;e:for(;;){if(null===o)throw Error(s(160));switch(r=o.stateNode,o.tag){case 5:n=!1;break e;case 3:case 4:r=r.containerInfo,n=!0;break e}o=o.return}o=!0}if(5===i.tag||6===i.tag){e:for(var a=e,c=i,u=c;;)if(va(a,u),null!==u.child&&4!==u.tag)u.child.return=u,u=u.child;else{if(u===c)break e;for(;null===u.sibling;){if(null===u.return||u.return===c)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}n?(a=r,c=i.stateNode,8===a.nodeType?a.parentNode.removeChild(c):a.removeChild(c)):r.removeChild(i.stateNode)}else if(4===i.tag){if(null!==i.child){r=i.stateNode.containerInfo,n=!0,i.child.return=i,i=i.child;continue}}else if(va(e,i),null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break;for(;null===i.sibling;){if(null===i.return||i.return===t)return;4===(i=i.return).tag&&(o=!1)}i.sibling.return=i.return,i=i.sibling}}function xa(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var n=r=r.next;do{3===(3&n.tag)&&(e=n.destroy,n.destroy=void 0,void 0!==e&&e()),n=n.next}while(n!==r)}return;case 1:case 12:case 17:return;case 5:if(null!=(r=t.stateNode)){n=t.memoizedProps;var i=null!==e?e.memoizedProps:n;e=t.type;var o=t.updateQueue;if(t.updateQueue=null,null!==o){for(r[Zn]=n,"input"===e&&"radio"===n.type&&null!=n.name&&te(r,n),Ae(e,i),t=Ae(e,n),i=0;i<o.length;i+=2){var a=o[i],c=o[i+1];"style"===a?_e(r,c):"dangerouslySetInnerHTML"===a?be(r,c):"children"===a?ye(r,c):w(r,a,c,t)}switch(e){case"input":re(r,n);break;case"textarea":ue(r,n);break;case"select":e=r._wrapperState.wasMultiple,r._wrapperState.wasMultiple=!!n.multiple,null!=(o=n.value)?se(r,!!n.multiple,o,!1):e!==!!n.multiple&&(null!=n.defaultValue?se(r,!!n.multiple,n.defaultValue,!0):se(r,!!n.multiple,n.multiple?[]:"",!1))}}}return;case 6:if(null===t.stateNode)throw Error(s(162));return void(t.stateNode.nodeValue=t.memoizedProps);case 3:return void((r=t.stateNode).hydrate&&(r.hydrate=!1,_t(r.containerInfo)));case 13:return null!==t.memoizedState&&(Ha=Vi(),ma(t.child,!0)),void Ia(t);case 19:return void Ia(t);case 23:case 24:return void ma(t,null!==t.memoizedState)}throw Error(s(163))}function Ia(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var r=e.stateNode;null===r&&(r=e.stateNode=new pa),t.forEach((function(t){var n=Vc.bind(null,e,t);r.has(t)||(r.add(t),t.then(n,n))}))}}function Ca(e,t){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(t=t.memoizedState)&&null===t.dehydrated)}var Ta=Math.ceil,Ra=_.ReactCurrentDispatcher,Pa=_.ReactCurrentOwner,Da=0,Na=null,Ba=null,Ua=0,La=0,Ma=ci(0),Oa=0,qa=null,Ka=0,Fa=0,Va=0,za=0,ja=null,Ha=0,Ga=1/0;function Wa(){Ga=Vi()+500}var Ya,Qa=null,Ja=!1,Xa=null,Za=null,$a=!1,ec=null,tc=90,rc=[],nc=[],ic=null,oc=0,sc=null,ac=-1,cc=0,uc=0,lc=null,hc=!1;function dc(){return 0!==(48&Da)?Vi():-1!==ac?ac:ac=Vi()}function fc(e){if(0===(2&(e=e.mode)))return 1;if(0===(4&e))return 99===zi()?1:2;if(0===cc&&(cc=Ka),0!==Qi.transition){0!==uc&&(uc=null!==ja?ja.pendingLanes:0),e=cc;var t=4186112&~uc;return 0===(t&=-t)&&(0===(t=(e=4186112&~e)&-e)&&(t=8192)),t}return e=zi(),0!==(4&Da)&&98===e?e=qt(12,cc):e=qt(e=function(e){switch(e){case 99:return 15;case 98:return 10;case 97:case 96:return 8;case 95:return 2;default:return 0}}(e),cc),e}function pc(e,t,r){if(50<oc)throw oc=0,sc=null,Error(s(185));if(null===(e=gc(e,t)))return null;Vt(e,t,r),e===Na&&(Va|=t,4===Oa&&mc(e,Ua));var n=zi();1===t?0!==(8&Da)&&0===(48&Da)?vc(e):(bc(e,r),0===Da&&(Wa(),Wi())):(0===(4&Da)||98!==n&&99!==n||(null===ic?ic=new Set([e]):ic.add(e)),bc(e,r)),ja=e}function gc(e,t){e.lanes|=t;var r=e.alternate;for(null!==r&&(r.lanes|=t),r=e,e=e.return;null!==e;)e.childLanes|=t,null!==(r=e.alternate)&&(r.childLanes|=t),r=e,e=e.return;return 3===r.tag?r.stateNode:null}function bc(e,t){for(var r=e.callbackNode,n=e.suspendedLanes,i=e.pingedLanes,o=e.expirationTimes,a=e.pendingLanes;0<a;){var c=31-zt(a),u=1<<c,l=o[c];if(-1===l){if(0===(u&n)||0!==(u&i)){l=t,Lt(u);var h=Ut;o[c]=10<=h?l+250:6<=h?l+5e3:-1}}else l<=t&&(e.expiredLanes|=u);a&=~u}if(n=Mt(e,e===Na?Ua:0),t=Ut,0===n)null!==r&&(r!==Li&&xi(r),e.callbackNode=null,e.callbackPriority=0);else{if(null!==r){if(e.callbackPriority===t)return;r!==Li&&xi(r)}15===t?(r=vc.bind(null,e),null===Oi?(Oi=[r],qi=ki(Pi,Yi)):Oi.push(r),r=Li):14===t?r=Gi(99,vc.bind(null,e)):(r=function(e){switch(e){case 15:case 14:return 99;case 13:case 12:case 11:case 10:return 98;case 9:case 8:case 7:case 6:case 4:case 5:return 97;case 3:case 2:case 1:return 95;case 0:return 90;default:throw Error(s(358,e))}}(t),r=Gi(r,yc.bind(null,e))),e.callbackPriority=t,e.callbackNode=r}}function yc(e){if(ac=-1,uc=cc=0,0!==(48&Da))throw Error(s(327));var t=e.callbackNode;if(Uc()&&e.callbackNode!==t)return null;var r=Mt(e,e===Na?Ua:0);if(0===r)return null;var n=r,i=Da;Da|=16;var o=xc();for(Na===e&&Ua===n||(Wa(),Ac(e,n));;)try{Tc();break}catch(c){kc(e,c)}if(to(),Ra.current=o,Da=i,null!==Ba?n=0:(Na=null,Ua=0,n=Oa),0!==(Ka&Va))Ac(e,0);else if(0!==n){if(2===n&&(Da|=64,e.hydrate&&(e.hydrate=!1,Gn(e.containerInfo)),0!==(r=Ot(e))&&(n=Ic(e,r))),1===n)throw t=qa,Ac(e,0),mc(e,r),bc(e,Vi()),t;switch(e.finishedWork=e.current.alternate,e.finishedLanes=r,n){case 0:case 1:throw Error(s(345));case 2:case 5:Dc(e);break;case 3:if(mc(e,r),(62914560&r)===r&&10<(n=Ha+500-Vi())){if(0!==Mt(e,0))break;if(((i=e.suspendedLanes)&r)!==r){dc(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=jn(Dc.bind(null,e),n);break}Dc(e);break;case 4:if(mc(e,r),(4186112&r)===r)break;for(n=e.eventTimes,i=-1;0<r;){var a=31-zt(r);o=1<<a,(a=n[a])>i&&(i=a),r&=~o}if(r=i,10<(r=(120>(r=Vi()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ta(r/1960))-r)){e.timeoutHandle=jn(Dc.bind(null,e),r);break}Dc(e);break;default:throw Error(s(329))}}return bc(e,Vi()),e.callbackNode===t?yc.bind(null,e):null}function mc(e,t){for(t&=~za,t&=~Va,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var r=31-zt(t),n=1<<r;e[r]=-1,t&=~n}}function vc(e){if(0!==(48&Da))throw Error(s(327));if(Uc(),e===Na&&0!==(e.expiredLanes&Ua)){var t=Ua,r=Ic(e,t);0!==(Ka&Va)&&(r=Ic(e,t=Mt(e,t)))}else r=Ic(e,t=Mt(e,0));if(0!==e.tag&&2===r&&(Da|=64,e.hydrate&&(e.hydrate=!1,Gn(e.containerInfo)),0!==(t=Ot(e))&&(r=Ic(e,t))),1===r)throw r=qa,Ac(e,0),mc(e,t),bc(e,Vi()),r;return e.finishedWork=e.current.alternate,e.finishedLanes=t,Dc(e),bc(e,Vi()),null}function wc(e,t){var r=Da;Da|=1;try{return e(t)}finally{0===(Da=r)&&(Wa(),Wi())}}function _c(e,t){var r=Da;Da&=-2,Da|=8;try{return e(t)}finally{0===(Da=r)&&(Wa(),Wi())}}function Ec(e,t){li(Ma,La),La|=t,Ka|=t}function Sc(){La=Ma.current,ui(Ma)}function Ac(e,t){e.finishedWork=null,e.finishedLanes=0;var r=e.timeoutHandle;if(-1!==r&&(e.timeoutHandle=-1,Hn(r)),null!==Ba)for(r=Ba.return;null!==r;){var n=r;switch(n.tag){case 1:null!==(n=n.type.childContextTypes)&&void 0!==n&&yi();break;case 3:Bo(),ui(fi),ui(di),Qo();break;case 5:Lo(n);break;case 4:Bo();break;case 13:case 19:ui(Mo);break;case 10:ro(n);break;case 23:case 24:Sc()}r=r.return}Na=e,Ba=Gc(e.current,null),Ua=La=Ka=t,Oa=0,qa=null,za=Va=Fa=0}function kc(e,t){for(;;){var r=Ba;try{if(to(),Jo.current=Ps,rs){for(var n=$o.memoizedState;null!==n;){var i=n.queue;null!==i&&(i.pending=null),n=n.next}rs=!1}if(Zo=0,ts=es=$o=null,ns=!1,Pa.current=null,null===r||null===r.return){Oa=1,qa=t,Ba=null;break}e:{var o=e,s=r.return,a=r,c=t;if(t=Ua,a.flags|=2048,a.firstEffect=a.lastEffect=null,null!==c&&"object"===typeof c&&"function"===typeof c.then){var u=c;if(0===(2&a.mode)){var l=a.alternate;l?(a.updateQueue=l.updateQueue,a.memoizedState=l.memoizedState,a.lanes=l.lanes):(a.updateQueue=null,a.memoizedState=null)}var h=0!==(1&Mo.current),d=s;do{var f;if(f=13===d.tag){var p=d.memoizedState;if(null!==p)f=null!==p.dehydrated;else{var g=d.memoizedProps;f=void 0!==g.fallback&&(!0!==g.unstable_avoidThisFallback||!h)}}if(f){var b=d.updateQueue;if(null===b){var y=new Set;y.add(u),d.updateQueue=y}else b.add(u);if(0===(2&d.mode)){if(d.flags|=64,a.flags|=16384,a.flags&=-2981,1===a.tag)if(null===a.alternate)a.tag=17;else{var m=uo(-1,1);m.tag=2,lo(a,m)}a.lanes|=1;break e}c=void 0,a=t;var v=o.pingCache;if(null===v?(v=o.pingCache=new ha,c=new Set,v.set(u,c)):void 0===(c=v.get(u))&&(c=new Set,v.set(u,c)),!c.has(a)){c.add(a);var w=Fc.bind(null,o,u,a);u.then(w,w)}d.flags|=4096,d.lanes=t;break e}d=d.return}while(null!==d);c=Error((W(a.type)||"A React component")+" suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.")}5!==Oa&&(Oa=2),c=ua(c,a),d=s;do{switch(d.tag){case 3:o=c,d.flags|=4096,t&=-t,d.lanes|=t,ho(d,da(0,o,t));break e;case 1:o=c;var _=d.type,E=d.stateNode;if(0===(64&d.flags)&&("function"===typeof _.getDerivedStateFromError||null!==E&&"function"===typeof E.componentDidCatch&&(null===Za||!Za.has(E)))){d.flags|=4096,t&=-t,d.lanes|=t,ho(d,fa(d,o,t));break e}}d=d.return}while(null!==d)}Pc(r)}catch(S){t=S,Ba===r&&null!==r&&(Ba=r=r.return);continue}break}}function xc(){var e=Ra.current;return Ra.current=Ps,null===e?Ps:e}function Ic(e,t){var r=Da;Da|=16;var n=xc();for(Na===e&&Ua===t||Ac(e,t);;)try{Cc();break}catch(i){kc(e,i)}if(to(),Da=r,Ra.current=n,null!==Ba)throw Error(s(261));return Na=null,Ua=0,Oa}function Cc(){for(;null!==Ba;)Rc(Ba)}function Tc(){for(;null!==Ba&&!Ii();)Rc(Ba)}function Rc(e){var t=Ya(e.alternate,e,La);e.memoizedProps=e.pendingProps,null===t?Pc(e):Ba=t,Pa.current=null}function Pc(e){var t=e;do{var r=t.alternate;if(e=t.return,0===(2048&t.flags)){if(null!==(r=aa(r,t,La)))return void(Ba=r);if(24!==(r=t).tag&&23!==r.tag||null===r.memoizedState||0!==(1073741824&La)||0===(4&r.mode)){for(var n=0,i=r.child;null!==i;)n|=i.lanes|i.childLanes,i=i.sibling;r.childLanes=n}null!==e&&0===(2048&e.flags)&&(null===e.firstEffect&&(e.firstEffect=t.firstEffect),null!==t.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=t.firstEffect),e.lastEffect=t.lastEffect),1<t.flags&&(null!==e.lastEffect?e.lastEffect.nextEffect=t:e.firstEffect=t,e.lastEffect=t))}else{if(null!==(r=ca(t)))return r.flags&=2047,void(Ba=r);null!==e&&(e.firstEffect=e.lastEffect=null,e.flags|=2048)}if(null!==(t=t.sibling))return void(Ba=t);Ba=t=e}while(null!==t);0===Oa&&(Oa=5)}function Dc(e){var t=zi();return Hi(99,Nc.bind(null,e,t)),null}function Nc(e,t){do{Uc()}while(null!==ec);if(0!==(48&Da))throw Error(s(327));var r=e.finishedWork;if(null===r)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(s(177));e.callbackNode=null;var n=r.lanes|r.childLanes,i=n,o=e.pendingLanes&~i;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=i,e.mutableReadLanes&=i,e.entangledLanes&=i,i=e.entanglements;for(var a=e.eventTimes,c=e.expirationTimes;0<o;){var u=31-zt(o),l=1<<u;i[u]=0,a[u]=-1,c[u]=-1,o&=~l}if(null!==ic&&0===(24&n)&&ic.has(e)&&ic.delete(e),e===Na&&(Ba=Na=null,Ua=0),1<r.flags?null!==r.lastEffect?(r.lastEffect.nextEffect=r,n=r.firstEffect):n=r:n=r.firstEffect,null!==n){if(i=Da,Da|=32,Pa.current=null,Kn=Yt,bn(a=gn())){if("selectionStart"in a)c={start:a.selectionStart,end:a.selectionEnd};else e:if(c=(c=a.ownerDocument)&&c.defaultView||window,(l=c.getSelection&&c.getSelection())&&0!==l.rangeCount){c=l.anchorNode,o=l.anchorOffset,u=l.focusNode,l=l.focusOffset;try{c.nodeType,u.nodeType}catch(x){c=null;break e}var h=0,d=-1,f=-1,p=0,g=0,b=a,y=null;t:for(;;){for(var m;b!==c||0!==o&&3!==b.nodeType||(d=h+o),b!==u||0!==l&&3!==b.nodeType||(f=h+l),3===b.nodeType&&(h+=b.nodeValue.length),null!==(m=b.firstChild);)y=b,b=m;for(;;){if(b===a)break t;if(y===c&&++p===o&&(d=h),y===u&&++g===l&&(f=h),null!==(m=b.nextSibling))break;y=(b=y).parentNode}b=m}c=-1===d||-1===f?null:{start:d,end:f}}else c=null;c=c||{start:0,end:0}}else c=null;Fn={focusedElem:a,selectionRange:c},Yt=!1,lc=null,hc=!1,Qa=n;do{try{Bc()}catch(x){if(null===Qa)throw Error(s(330));Kc(Qa,x),Qa=Qa.nextEffect}}while(null!==Qa);lc=null,Qa=n;do{try{for(a=e;null!==Qa;){var v=Qa.flags;if(16&v&&ye(Qa.stateNode,""),128&v){var w=Qa.alternate;if(null!==w){var _=w.ref;null!==_&&("function"===typeof _?_(null):_.current=null)}}switch(1038&v){case 2:Ea(Qa),Qa.flags&=-3;break;case 6:Ea(Qa),Qa.flags&=-3,xa(Qa.alternate,Qa);break;case 1024:Qa.flags&=-1025;break;case 1028:Qa.flags&=-1025,xa(Qa.alternate,Qa);break;case 4:xa(Qa.alternate,Qa);break;case 8:ka(a,c=Qa);var E=c.alternate;wa(c),null!==E&&wa(E)}Qa=Qa.nextEffect}}catch(x){if(null===Qa)throw Error(s(330));Kc(Qa,x),Qa=Qa.nextEffect}}while(null!==Qa);if(_=Fn,w=gn(),v=_.focusedElem,a=_.selectionRange,w!==v&&v&&v.ownerDocument&&pn(v.ownerDocument.documentElement,v)){null!==a&&bn(v)&&(w=a.start,void 0===(_=a.end)&&(_=w),"selectionStart"in v?(v.selectionStart=w,v.selectionEnd=Math.min(_,v.value.length)):(_=(w=v.ownerDocument||document)&&w.defaultView||window).getSelection&&(_=_.getSelection(),c=v.textContent.length,E=Math.min(a.start,c),a=void 0===a.end?E:Math.min(a.end,c),!_.extend&&E>a&&(c=a,a=E,E=c),c=fn(v,E),o=fn(v,a),c&&o&&(1!==_.rangeCount||_.anchorNode!==c.node||_.anchorOffset!==c.offset||_.focusNode!==o.node||_.focusOffset!==o.offset)&&((w=w.createRange()).setStart(c.node,c.offset),_.removeAllRanges(),E>a?(_.addRange(w),_.extend(o.node,o.offset)):(w.setEnd(o.node,o.offset),_.addRange(w))))),w=[];for(_=v;_=_.parentNode;)1===_.nodeType&&w.push({element:_,left:_.scrollLeft,top:_.scrollTop});for("function"===typeof v.focus&&v.focus(),v=0;v<w.length;v++)(_=w[v]).element.scrollLeft=_.left,_.element.scrollTop=_.top}Yt=!!Kn,Fn=Kn=null,e.current=r,Qa=n;do{try{for(v=e;null!==Qa;){var S=Qa.flags;if(36&S&&ya(v,Qa.alternate,Qa),128&S){w=void 0;var A=Qa.ref;if(null!==A){var k=Qa.stateNode;Qa.tag,w=k,"function"===typeof A?A(w):A.current=w}}Qa=Qa.nextEffect}}catch(x){if(null===Qa)throw Error(s(330));Kc(Qa,x),Qa=Qa.nextEffect}}while(null!==Qa);Qa=null,Mi(),Da=i}else e.current=r;if($a)$a=!1,ec=e,tc=t;else for(Qa=n;null!==Qa;)t=Qa.nextEffect,Qa.nextEffect=null,8&Qa.flags&&((S=Qa).sibling=null,S.stateNode=null),Qa=t;if(0===(n=e.pendingLanes)&&(Za=null),1===n?e===sc?oc++:(oc=0,sc=e):oc=0,r=r.stateNode,Si&&"function"===typeof Si.onCommitFiberRoot)try{Si.onCommitFiberRoot(Ei,r,void 0,64===(64&r.current.flags))}catch(x){}if(bc(e,Vi()),Ja)throw Ja=!1,e=Xa,Xa=null,e;return 0!==(8&Da)||Wi(),null}function Bc(){for(;null!==Qa;){var e=Qa.alternate;hc||null===lc||(0!==(8&Qa.flags)?$e(Qa,lc)&&(hc=!0):13===Qa.tag&&Ca(e,Qa)&&$e(Qa,lc)&&(hc=!0));var t=Qa.flags;0!==(256&t)&&ba(e,Qa),0===(512&t)||$a||($a=!0,Gi(97,(function(){return Uc(),null}))),Qa=Qa.nextEffect}}function Uc(){if(90!==tc){var e=97<tc?97:tc;return tc=90,Hi(e,Oc)}return!1}function Lc(e,t){rc.push(t,e),$a||($a=!0,Gi(97,(function(){return Uc(),null})))}function Mc(e,t){nc.push(t,e),$a||($a=!0,Gi(97,(function(){return Uc(),null})))}function Oc(){if(null===ec)return!1;var e=ec;if(ec=null,0!==(48&Da))throw Error(s(331));var t=Da;Da|=32;var r=nc;nc=[];for(var n=0;n<r.length;n+=2){var i=r[n],o=r[n+1],a=i.destroy;if(i.destroy=void 0,"function"===typeof a)try{a()}catch(u){if(null===o)throw Error(s(330));Kc(o,u)}}for(r=rc,rc=[],n=0;n<r.length;n+=2){i=r[n],o=r[n+1];try{var c=i.create;i.destroy=c()}catch(u){if(null===o)throw Error(s(330));Kc(o,u)}}for(c=e.current.firstEffect;null!==c;)e=c.nextEffect,c.nextEffect=null,8&c.flags&&(c.sibling=null,c.stateNode=null),c=e;return Da=t,Wi(),!0}function qc(e,t,r){lo(e,t=da(0,t=ua(r,t),1)),t=dc(),null!==(e=gc(e,1))&&(Vt(e,1,t),bc(e,t))}function Kc(e,t){if(3===e.tag)qc(e,e,t);else for(var r=e.return;null!==r;){if(3===r.tag){qc(r,e,t);break}if(1===r.tag){var n=r.stateNode;if("function"===typeof r.type.getDerivedStateFromError||"function"===typeof n.componentDidCatch&&(null===Za||!Za.has(n))){var i=fa(r,e=ua(t,e),1);if(lo(r,i),i=dc(),null!==(r=gc(r,1)))Vt(r,1,i),bc(r,i);else if("function"===typeof n.componentDidCatch&&(null===Za||!Za.has(n)))try{n.componentDidCatch(t,e)}catch(o){}break}}r=r.return}}function Fc(e,t,r){var n=e.pingCache;null!==n&&n.delete(t),t=dc(),e.pingedLanes|=e.suspendedLanes&r,Na===e&&(Ua&r)===r&&(4===Oa||3===Oa&&(62914560&Ua)===Ua&&500>Vi()-Ha?Ac(e,0):za|=r),bc(e,t)}function Vc(e,t){var r=e.stateNode;null!==r&&r.delete(t),0===(t=0)&&(0===(2&(t=e.mode))?t=1:0===(4&t)?t=99===zi()?1:2:(0===cc&&(cc=Ka),0===(t=Kt(62914560&~cc))&&(t=4194304))),r=dc(),null!==(e=gc(e,t))&&(Vt(e,t,r),bc(e,r))}function zc(e,t,r,n){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.flags=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childLanes=this.lanes=0,this.alternate=null}function jc(e,t,r,n){return new zc(e,t,r,n)}function Hc(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Gc(e,t){var r=e.alternate;return null===r?((r=jc(e.tag,t,e.key,e.mode)).elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.nextEffect=null,r.firstEffect=null,r.lastEffect=null),r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Wc(e,t,r,n,i,o){var a=2;if(n=e,"function"===typeof e)Hc(e)&&(a=1);else if("string"===typeof e)a=5;else e:switch(e){case A:return Yc(r.children,i,o,t);case L:a=8,i|=16;break;case k:a=8,i|=1;break;case x:return(e=jc(12,r,t,8|i)).elementType=x,e.type=x,e.lanes=o,e;case R:return(e=jc(13,r,t,i)).type=R,e.elementType=R,e.lanes=o,e;case P:return(e=jc(19,r,t,i)).elementType=P,e.lanes=o,e;case M:return Qc(r,i,o,t);case O:return(e=jc(24,r,t,i)).elementType=O,e.lanes=o,e;default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case I:a=10;break e;case C:a=9;break e;case T:a=11;break e;case D:a=14;break e;case N:a=16,n=null;break e;case B:a=22;break e}throw Error(s(130,null==e?e:typeof e,""))}return(t=jc(a,r,t,i)).elementType=e,t.type=n,t.lanes=o,t}function Yc(e,t,r,n){return(e=jc(7,e,n,t)).lanes=r,e}function Qc(e,t,r,n){return(e=jc(23,e,n,t)).elementType=M,e.lanes=r,e}function Jc(e,t,r){return(e=jc(6,e,null,t)).lanes=r,e}function Xc(e,t,r){return(t=jc(4,null!==e.children?e.children:[],e.key,t)).lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Zc(e,t,r){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=r,this.callbackNode=null,this.callbackPriority=0,this.eventTimes=Ft(0),this.expirationTimes=Ft(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ft(0),this.mutableSourceEagerHydrationData=null}function $c(e,t,r,n){var i=t.current,o=dc(),a=fc(i);e:if(r){t:{if(Qe(r=r._reactInternals)!==r||1!==r.tag)throw Error(s(170));var c=r;do{switch(c.tag){case 3:c=c.stateNode.context;break t;case 1:if(bi(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break t}}c=c.return}while(null!==c);throw Error(s(171))}if(1===r.tag){var u=r.type;if(bi(u)){r=vi(r,u,c);break e}}r=c}else r=hi;return null===t.context?t.context=r:t.pendingContext=r,(t=uo(o,a)).payload={element:e},null!==(n=void 0===n?null:n)&&(t.callback=n),lo(i,t),pc(i,a,o),a}function eu(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function tu(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var r=e.retryLane;e.retryLane=0!==r&&r<t?r:t}}function ru(e,t){tu(e,t),(e=e.alternate)&&tu(e,t)}function nu(e,t,r){var n=null!=r&&null!=r.hydrationOptions&&r.hydrationOptions.mutableSources||null;if(r=new Zc(e,t,null!=r&&!0===r.hydrate),t=jc(3,null,null,2===t?7:1===t?3:0),r.current=t,t.stateNode=r,ao(t),e[$n]=r.current,Pn(8===e.nodeType?e.parentNode:e),n)for(e=0;e<n.length;e++){var i=(t=n[e])._getVersion;i=i(t._source),null==r.mutableSourceEagerHydrationData?r.mutableSourceEagerHydrationData=[t,i]:r.mutableSourceEagerHydrationData.push(t,i)}this._internalRoot=r}function iu(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function ou(e,t,r,n,i){var o=r._reactRootContainer;if(o){var s=o._internalRoot;if("function"===typeof i){var a=i;i=function(){var e=eu(s);a.call(e)}}$c(t,s,e,i)}else{if(o=r._reactRootContainer=function(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute("data-reactroot"))),!t)for(var r;r=e.lastChild;)e.removeChild(r);return new nu(e,0,t?{hydrate:!0}:void 0)}(r,n),s=o._internalRoot,"function"===typeof i){var c=i;i=function(){var e=eu(s);c.call(e)}}_c((function(){$c(t,s,e,i)}))}return eu(s)}function su(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!iu(t))throw Error(s(200));return function(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:S,key:null==n?null:""+n,children:e,containerInfo:t,implementation:r}}(e,t,null,r)}Ya=function(e,t,r){var n=t.lanes;if(null!==e)if(e.memoizedProps!==t.pendingProps||fi.current)Ls=!0;else{if(0===(r&n)){switch(Ls=!1,t.tag){case 3:Gs(t),Wo();break;case 5:Uo(t);break;case 1:bi(t.type)&&wi(t);break;case 4:No(t,t.stateNode.containerInfo);break;case 10:n=t.memoizedProps.value;var i=t.type._context;li(Xi,i._currentValue),i._currentValue=n;break;case 13:if(null!==t.memoizedState)return 0!==(r&t.child.childLanes)?Zs(e,t,r):(li(Mo,1&Mo.current),null!==(t=oa(e,t,r))?t.sibling:null);li(Mo,1&Mo.current);break;case 19:if(n=0!==(r&t.childLanes),0!==(64&e.flags)){if(n)return ia(e,t,r);t.flags|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null,i.lastEffect=null),li(Mo,Mo.current),n)break;return null;case 23:case 24:return t.lanes=0,Fs(e,t,r)}return oa(e,t,r)}Ls=0!==(16384&e.flags)}else Ls=!1;switch(t.lanes=0,t.tag){case 2:if(n=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,i=gi(t,di.current),io(t,r),i=ss(null,t,n,e,i,r),t.flags|=1,"object"===typeof i&&null!==i&&"function"===typeof i.render&&void 0===i.$$typeof){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,bi(n)){var o=!0;wi(t)}else o=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,ao(t);var a=n.getDerivedStateFromProps;"function"===typeof a&&bo(t,n,a,e),i.updater=yo,t.stateNode=i,i._reactInternals=t,_o(t,n,e,r),t=Hs(null,t,n,!0,o,r)}else t.tag=0,Ms(null,t,i,r),t=t.child;return t;case 16:i=t.elementType;e:{switch(null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,i=(o=i._init)(i._payload),t.type=i,o=t.tag=function(e){if("function"===typeof e)return Hc(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===T)return 11;if(e===D)return 14}return 2}(i),e=Ji(i,e),o){case 0:t=zs(null,t,i,e,r);break e;case 1:t=js(null,t,i,e,r);break e;case 11:t=Os(null,t,i,e,r);break e;case 14:t=qs(null,t,i,Ji(i.type,e),n,r);break e}throw Error(s(306,i,""))}return t;case 0:return n=t.type,i=t.pendingProps,zs(e,t,n,i=t.elementType===n?i:Ji(n,i),r);case 1:return n=t.type,i=t.pendingProps,js(e,t,n,i=t.elementType===n?i:Ji(n,i),r);case 3:if(Gs(t),n=t.updateQueue,null===e||null===n)throw Error(s(282));if(n=t.pendingProps,i=null!==(i=t.memoizedState)?i.element:null,co(e,t),fo(t,n,null,r),(n=t.memoizedState.element)===i)Wo(),t=oa(e,t,r);else{if((o=(i=t.stateNode).hydrate)&&(Ko=Wn(t.stateNode.containerInfo.firstChild),qo=t,o=Fo=!0),o){if(null!=(e=i.mutableSourceEagerHydrationData))for(i=0;i<e.length;i+=2)(o=e[i])._workInProgressVersionPrimary=e[i+1],Yo.push(o);for(r=Io(t,null,n,r),t.child=r;r;)r.flags=-3&r.flags|1024,r=r.sibling}else Ms(e,t,n,r),Wo();t=t.child}return t;case 5:return Uo(t),null===e&&jo(t),n=t.type,i=t.pendingProps,o=null!==e?e.memoizedProps:null,a=i.children,zn(n,i)?a=null:null!==o&&zn(n,o)&&(t.flags|=16),Vs(e,t),Ms(e,t,a,r),t.child;case 6:return null===e&&jo(t),null;case 13:return Zs(e,t,r);case 4:return No(t,t.stateNode.containerInfo),n=t.pendingProps,null===e?t.child=xo(t,null,n,r):Ms(e,t,n,r),t.child;case 11:return n=t.type,i=t.pendingProps,Os(e,t,n,i=t.elementType===n?i:Ji(n,i),r);case 7:return Ms(e,t,t.pendingProps,r),t.child;case 8:case 12:return Ms(e,t,t.pendingProps.children,r),t.child;case 10:e:{n=t.type._context,i=t.pendingProps,a=t.memoizedProps,o=i.value;var c=t.type._context;if(li(Xi,c._currentValue),c._currentValue=o,null!==a)if(c=a.value,0===(o=un(c,o)?0:0|("function"===typeof n._calculateChangedBits?n._calculateChangedBits(c,o):1073741823))){if(a.children===i.children&&!fi.current){t=oa(e,t,r);break e}}else for(null!==(c=t.child)&&(c.return=t);null!==c;){var u=c.dependencies;if(null!==u){a=c.child;for(var l=u.firstContext;null!==l;){if(l.context===n&&0!==(l.observedBits&o)){1===c.tag&&((l=uo(-1,r&-r)).tag=2,lo(c,l)),c.lanes|=r,null!==(l=c.alternate)&&(l.lanes|=r),no(c.return,r),u.lanes|=r;break}l=l.next}}else a=10===c.tag&&c.type===t.type?null:c.child;if(null!==a)a.return=c;else for(a=c;null!==a;){if(a===t){a=null;break}if(null!==(c=a.sibling)){c.return=a.return,a=c;break}a=a.return}c=a}Ms(e,t,i.children,r),t=t.child}return t;case 9:return i=t.type,n=(o=t.pendingProps).children,io(t,r),n=n(i=oo(i,o.unstable_observedBits)),t.flags|=1,Ms(e,t,n,r),t.child;case 14:return o=Ji(i=t.type,t.pendingProps),qs(e,t,i,o=Ji(i.type,o),n,r);case 15:return Ks(e,t,t.type,t.pendingProps,n,r);case 17:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:Ji(n,i),null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),t.tag=1,bi(n)?(e=!0,wi(t)):e=!1,io(t,r),vo(t,n,i),_o(t,n,i,r),Hs(null,t,n,!0,e,r);case 19:return ia(e,t,r);case 23:case 24:return Fs(e,t,r)}throw Error(s(156,t.tag))},nu.prototype.render=function(e){$c(e,this._internalRoot,null,null)},nu.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;$c(null,e,null,(function(){t[$n]=null}))},et=function(e){13===e.tag&&(pc(e,4,dc()),ru(e,4))},tt=function(e){13===e.tag&&(pc(e,67108864,dc()),ru(e,67108864))},rt=function(e){if(13===e.tag){var t=dc(),r=fc(e);pc(e,r,t),ru(e,r)}},nt=function(e,t){return t()},xe=function(e,t,r){switch(t){case"input":if(re(e,r),t=r.name,"radio"===r.type&&null!=t){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var n=r[t];if(n!==e&&n.form===e.form){var i=ii(n);if(!i)throw Error(s(90));X(n),re(n,i)}}}break;case"textarea":ue(e,r);break;case"select":null!=(t=r.value)&&se(e,!!r.multiple,t,!1)}},De=wc,Ne=function(e,t,r,n,i){var o=Da;Da|=4;try{return Hi(98,e.bind(null,t,r,n,i))}finally{0===(Da=o)&&(Wa(),Wi())}},Be=function(){0===(49&Da)&&(function(){if(null!==ic){var e=ic;ic=null,e.forEach((function(e){e.expiredLanes|=24&e.pendingLanes,bc(e,Vi())}))}Wi()}(),Uc())},Ue=function(e,t){var r=Da;Da|=2;try{return e(t)}finally{0===(Da=r)&&(Wa(),Wi())}};var au={Events:[ri,ni,ii,Re,Pe,Uc,{current:!1}]},cu={findFiberByHostInstance:ti,bundleType:0,version:"17.0.2",rendererPackageName:"react-dom"},uu={bundleType:cu.bundleType,version:cu.version,rendererPackageName:cu.rendererPackageName,rendererConfig:cu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=Ze(e))?null:e.stateNode},findFiberByHostInstance:cu.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var lu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lu.isDisabled&&lu.supportsFiber)try{Ei=lu.inject(uu),Si=lu}catch(ge){}}t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=au,t.createPortal=su,t.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"===typeof e.render)throw Error(s(188));throw Error(s(268,Object.keys(e)))}return e=null===(e=Ze(t))?null:e.stateNode},t.flushSync=function(e,t){var r=Da;if(0!==(48&r))return e(t);Da|=1;try{if(e)return Hi(99,e.bind(null,t))}finally{Da=r,Wi()}},t.hydrate=function(e,t,r){if(!iu(t))throw Error(s(200));return ou(null,e,t,!0,r)},t.render=function(e,t,r){if(!iu(t))throw Error(s(200));return ou(null,e,t,!1,r)},t.unmountComponentAtNode=function(e){if(!iu(e))throw Error(s(40));return!!e._reactRootContainer&&(_c((function(){ou(null,null,e,!1,(function(){e._reactRootContainer=null,e[$n]=null}))})),!0)},t.unstable_batchedUpdates=wc,t.unstable_createPortal=function(e,t){return su(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},t.unstable_renderSubtreeIntoContainer=function(e,t,r,n){if(!iu(r))throw Error(s(200));if(null==e||void 0===e._reactInternals)throw Error(s(38));return ou(e,t,r,!1,n)},t.version="17.0.2"},7950:(e,t,r)=>{"use strict";!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=r(2730)},1153:(e,t,r)=>{"use strict";r(2123);var n=r(5043),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var o=Symbol.for;i=o("react.element"),o("react.fragment")}var s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,c={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var n,o={},u=null,l=null;for(n in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)a.call(t,n)&&!c.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:i,type:e,key:u,ref:l,props:o,_owner:s.current}}t.jsx=u,t.jsxs=u},4202:(e,t,r)=>{"use strict";var n=r(2123),i=60103,o=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var s=60109,a=60110,c=60112;t.Suspense=60113;var u=60115,l=60116;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;i=h("react.element"),o=h("react.portal"),t.Fragment=h("react.fragment"),t.StrictMode=h("react.strict_mode"),t.Profiler=h("react.profiler"),s=h("react.provider"),a=h("react.context"),c=h("react.forward_ref"),t.Suspense=h("react.suspense"),u=h("react.memo"),l=h("react.lazy")}var d="function"===typeof Symbol&&Symbol.iterator;function f(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g={};function b(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||p}function y(){}function m(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||p}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error(f(85));this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=b.prototype;var v=m.prototype=new y;v.constructor=m,n(v,b.prototype),v.isPureReactComponent=!0;var w={current:null},_=Object.prototype.hasOwnProperty,E={key:!0,ref:!0,__self:!0,__source:!0};function S(e,t,r){var n,o={},s=null,a=null;if(null!=t)for(n in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(s=""+t.key),t)_.call(t,n)&&!E.hasOwnProperty(n)&&(o[n]=t[n]);var c=arguments.length-2;if(1===c)o.children=r;else if(1<c){for(var u=Array(c),l=0;l<c;l++)u[l]=arguments[l+2];o.children=u}if(e&&e.defaultProps)for(n in c=e.defaultProps)void 0===o[n]&&(o[n]=c[n]);return{$$typeof:i,type:e,key:s,ref:a,props:o,_owner:w.current}}function A(e){return"object"===typeof e&&null!==e&&e.$$typeof===i}var k=/\/+/g;function x(e,t){return"object"===typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function I(e,t,r,n,s){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case i:case o:c=!0}}if(c)return s=s(c=e),e=""===n?"."+x(c,0):n,Array.isArray(s)?(r="",null!=e&&(r=e.replace(k,"$&/")+"/"),I(s,t,r,"",(function(e){return e}))):null!=s&&(A(s)&&(s=function(e,t){return{$$typeof:i,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(s,r+(!s.key||c&&c.key===s.key?"":(""+s.key).replace(k,"$&/")+"/")+e)),t.push(s)),1;if(c=0,n=""===n?".":n+":",Array.isArray(e))for(var u=0;u<e.length;u++){var l=n+x(a=e[u],u);c+=I(a,t,r,l,s)}else if(l=function(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=d&&e[d]||e["@@iterator"])?e:null}(e),"function"===typeof l)for(e=l.call(e),u=0;!(a=e.next()).done;)c+=I(a=a.value,t,r,l=n+x(a,u++),s);else if("object"===a)throw t=""+e,Error(f(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return c}function C(e,t,r){if(null==e)return e;var n=[],i=0;return I(e,n,"","",(function(e){return t.call(r,e,i++)})),n}function T(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var R={current:null};function P(){var e=R.current;if(null===e)throw Error(f(321));return e}var D={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:w,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:C,forEach:function(e,t,r){C(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return C(e,(function(){t++})),t},toArray:function(e){return C(e,(function(e){return e}))||[]},only:function(e){if(!A(e))throw Error(f(143));return e}},t.Component=b,t.PureComponent=m,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,t.cloneElement=function(e,t,r){if(null===e||void 0===e)throw Error(f(267,e));var o=n({},e.props),s=e.key,a=e.ref,c=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,c=w.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var u=e.type.defaultProps;for(l in t)_.call(t,l)&&!E.hasOwnProperty(l)&&(o[l]=void 0===t[l]&&void 0!==u?u[l]:t[l])}var l=arguments.length-2;if(1===l)o.children=r;else if(1<l){u=Array(l);for(var h=0;h<l;h++)u[h]=arguments[h+2];o.children=u}return{$$typeof:i,type:e.type,key:s,ref:a,props:o,_owner:c}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:a,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},t.createElement=S,t.createFactory=function(e){var t=S.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=A,t.lazy=function(e){return{$$typeof:l,_payload:{_status:-1,_result:e},_init:T}},t.memo=function(e,t){return{$$typeof:u,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return P().useCallback(e,t)},t.useContext=function(e,t){return P().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return P().useEffect(e,t)},t.useImperativeHandle=function(e,t,r){return P().useImperativeHandle(e,t,r)},t.useLayoutEffect=function(e,t){return P().useLayoutEffect(e,t)},t.useMemo=function(e,t){return P().useMemo(e,t)},t.useReducer=function(e,t,r){return P().useReducer(e,t,r)},t.useRef=function(e){return P().useRef(e)},t.useState=function(e){return P().useState(e)},t.version="17.0.2"},5043:(e,t,r)=>{"use strict";e.exports=r(4202)},579:(e,t,r)=>{"use strict";e.exports=r(1153)},7234:(e,t)=>{"use strict";var r,n,i,o;if("object"===typeof performance&&"function"===typeof performance.now){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,c=a.now();t.unstable_now=function(){return a.now()-c}}if("undefined"===typeof window||"function"!==typeof MessageChannel){var u=null,l=null,h=function(){if(null!==u)try{var e=t.unstable_now();u(!0,e),u=null}catch(r){throw setTimeout(h,0),r}};r=function(e){null!==u?setTimeout(r,0,e):(u=e,setTimeout(h,0))},n=function(e,t){l=setTimeout(e,t)},i=function(){clearTimeout(l)},t.unstable_shouldYield=function(){return!1},o=t.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,f=window.clearTimeout;if("undefined"!==typeof console){var p=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!==typeof p&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var g=!1,b=null,y=-1,m=5,v=0;t.unstable_shouldYield=function(){return t.unstable_now()>=v},o=function(){},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):m=0<e?Math.floor(1e3/e):5};var w=new MessageChannel,_=w.port2;w.port1.onmessage=function(){if(null!==b){var e=t.unstable_now();v=e+m;try{b(!0,e)?_.postMessage(null):(g=!1,b=null)}catch(r){throw _.postMessage(null),r}}else g=!1},r=function(e){b=e,g||(g=!0,_.postMessage(null))},n=function(e,r){y=d((function(){e(t.unstable_now())}),r)},i=function(){f(y),y=-1}}function E(e,t){var r=e.length;e.push(t);e:for(;;){var n=r-1>>>1,i=e[n];if(!(void 0!==i&&0<k(i,t)))break e;e[n]=t,e[r]=i,r=n}}function S(e){return void 0===(e=e[0])?null:e}function A(e){var t=e[0];if(void 0!==t){var r=e.pop();if(r!==t){e[0]=r;e:for(var n=0,i=e.length;n<i;){var o=2*(n+1)-1,s=e[o],a=o+1,c=e[a];if(void 0!==s&&0>k(s,r))void 0!==c&&0>k(c,s)?(e[n]=c,e[a]=r,n=a):(e[n]=s,e[o]=r,n=o);else{if(!(void 0!==c&&0>k(c,r)))break e;e[n]=c,e[a]=r,n=a}}}return t}return null}function k(e,t){var r=e.sortIndex-t.sortIndex;return 0!==r?r:e.id-t.id}var x=[],I=[],C=1,T=null,R=3,P=!1,D=!1,N=!1;function B(e){for(var t=S(I);null!==t;){if(null===t.callback)A(I);else{if(!(t.startTime<=e))break;A(I),t.sortIndex=t.expirationTime,E(x,t)}t=S(I)}}function U(e){if(N=!1,B(e),!D)if(null!==S(x))D=!0,r(L);else{var t=S(I);null!==t&&n(U,t.startTime-e)}}function L(e,r){D=!1,N&&(N=!1,i()),P=!0;var o=R;try{for(B(r),T=S(x);null!==T&&(!(T.expirationTime>r)||e&&!t.unstable_shouldYield());){var s=T.callback;if("function"===typeof s){T.callback=null,R=T.priorityLevel;var a=s(T.expirationTime<=r);r=t.unstable_now(),"function"===typeof a?T.callback=a:T===S(x)&&A(x),B(r)}else A(x);T=S(x)}if(null!==T)var c=!0;else{var u=S(I);null!==u&&n(U,u.startTime-r),c=!1}return c}finally{T=null,R=o,P=!1}}var M=o;t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){D||P||(D=!0,r(L))},t.unstable_getCurrentPriorityLevel=function(){return R},t.unstable_getFirstCallbackNode=function(){return S(x)},t.unstable_next=function(e){switch(R){case 1:case 2:case 3:var t=3;break;default:t=R}var r=R;R=t;try{return e()}finally{R=r}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=M,t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var r=R;R=e;try{return t()}finally{R=r}},t.unstable_scheduleCallback=function(e,o,s){var a=t.unstable_now();switch("object"===typeof s&&null!==s?s="number"===typeof(s=s.delay)&&0<s?a+s:a:s=a,e){case 1:var c=-1;break;case 2:c=250;break;case 5:c=1073741823;break;case 4:c=1e4;break;default:c=5e3}return e={id:C++,callback:o,priorityLevel:e,startTime:s,expirationTime:c=s+c,sortIndex:-1},s>a?(e.sortIndex=s,E(I,e),null===S(x)&&e===S(I)&&(N?i():N=!0,n(U,s-a))):(e.sortIndex=c,E(x,e),D||P||(D=!0,r(L))),e},t.unstable_wrapCallback=function(e){var t=R;return function(){var r=R;R=t;try{return e.apply(this,arguments)}finally{R=r}}}},8853:(e,t,r)=>{"use strict";e.exports=r(7234)},5013:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Nouns=t.Adjectives=void 0,t.Adjectives=["Adorable","Adventurous","Agressive","Alert","Alive","Amused","Angry","Annoyed","Annoying","silent","empty","dry","dark","summer","icy","delicate","quiet","white","cool","spring","winter","patient","twilight","dawn","crimson","wispy","weathered","blue","billowing","broken","cold","damp","falling","frosty","green","long","late","lingering","bold","little","morning","muddy","old","red","rough","still","small","sparkling","throbbing","shy","wandering","withered","wild","black","young","holy","solitary","fragrant","aged","snowy","proud","floral","restless","divine","polished","ancient","purple","lively","nameless"],t.Nouns=["waterfall","river","breeze","moon","rain","wind","sea","morning","snow","lake","sunset","pine","shadow","leaf","dawn","glitter","forest","hill","cloud","meadow","sun","glade","bird","brook","butterfly","bush","dew","dust","field","fire","flower","firefly","feather","grass","haze","mountain","night","pond","darkness","snowflake","silence","sound","sky","shape","surf","thunder","violet","water","wildflower","wave","water","resonance","sun","wood","dream","cherry","tree","fog","frost","voice","paper","frog","smoke","star"]},2676:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5013);t.default=()=>n.Adjectives[Math.floor(Math.random()*n.Adjectives.length)]+" "+n.Nouns[Math.floor(Math.random()*n.Nouns.length)]},9233:(e,t,r)=>{"use strict";var n=r(2676);Object.defineProperty(t,"c",{enumerable:!0,get:function(){return n.default}})},1170:e=>{e.exports=function e(n,i){var o,s=0,a=0,c=i=i||0,u=n.length;do{if(c>=u||a>49)throw e.bytes=0,new RangeError("Could not decode varint");o=n[c++],s+=a<28?(o&r)<<a:(o&r)*Math.pow(2,a),a+=7}while(o>=t);return e.bytes=c-i,s};var t=128,r=127},2070:e=>{e.exports=function e(i,o,s){if(Number.MAX_SAFE_INTEGER&&i>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");o=o||[];var a=s=s||0;for(;i>=n;)o[s++]=255&i|t,i/=128;for(;i&r;)o[s++]=255&i|t,i>>>=7;return o[s]=0|i,e.bytes=s-a+1,o};var t=128,r=-128,n=Math.pow(2,31)},1870:(e,t,r)=>{e.exports={encode:r(2070),decode:r(1170),encodingLength:r(940)}},940:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e<t?1:e<r?2:e<n?3:e<i?4:e<o?5:e<s?6:e<a?7:e<c?8:e<u?9:10}},495:()=>{},310:()=>{}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}__webpack_require__.amdO={},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;__webpack_require__.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"===typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"===typeof r.then)return r}var i=Object.create(null);__webpack_require__.r(i);var o={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&r;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>o[e]=()=>r[e]));return o.default=()=>r,__webpack_require__.d(i,o),i}})(),__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";var e={};__webpack_require__.r(e),__webpack_require__.d(e,{base10:()=>Zo});var t={};__webpack_require__.r(t),__webpack_require__.d(t,{base16:()=>$o,base16upper:()=>es});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{base2:()=>ts});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{base256emoji:()=>os});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{base32:()=>ss,base32hex:()=>ls,base32hexpad:()=>ds,base32hexpadupper:()=>fs,base32hexupper:()=>hs,base32pad:()=>cs,base32padupper:()=>us,base32upper:()=>as,base32z:()=>ps});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{base36:()=>gs,base36upper:()=>bs});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{base58btc:()=>ys,base58flickr:()=>ms});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{base64:()=>vs,base64pad:()=>ws,base64url:()=>_s,base64urlpad:()=>Es});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{base8:()=>Ss});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{identity:()=>As});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{code:()=>Cs,decode:()=>Rs,encode:()=>Ts,name:()=>Is});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{code:()=>Ds,decode:()=>Bs,encode:()=>Ns,name:()=>Ps});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{identity:()=>na});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{sha256:()=>aa,sha512:()=>ca});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{base10:()=>iu});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{base16:()=>ou,base16upper:()=>su});var b={};__webpack_require__.r(b),__webpack_require__.d(b,{base2:()=>au});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{base256emoji:()=>hu});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{base32:()=>du,base32hex:()=>bu,base32hexpad:()=>mu,base32hexpadupper:()=>vu,base32hexupper:()=>yu,base32pad:()=>pu,base32padupper:()=>gu,base32upper:()=>fu,base32z:()=>wu});var v={};__webpack_require__.r(v),__webpack_require__.d(v,{base36:()=>_u,base36upper:()=>Eu});var w={};__webpack_require__.r(w),__webpack_require__.d(w,{base58btc:()=>Su,base58flickr:()=>Au});var _={};__webpack_require__.r(_),__webpack_require__.d(_,{base64:()=>ku,base64pad:()=>xu,base64url:()=>Iu,base64urlpad:()=>Cu});var E={};__webpack_require__.r(E),__webpack_require__.d(E,{base8:()=>Tu});var S={};__webpack_require__.r(S),__webpack_require__.d(S,{identity:()=>Ru});var A={};__webpack_require__.r(A),__webpack_require__.d(A,{code:()=>Bu,decode:()=>Lu,encode:()=>Uu,name:()=>Nu});var k={};__webpack_require__.r(k),__webpack_require__.d(k,{code:()=>Ou,decode:()=>Ku,encode:()=>qu,name:()=>Mu});var x={};__webpack_require__.r(x),__webpack_require__.d(x,{identity:()=>ul});var I={};__webpack_require__.r(I),__webpack_require__.d(I,{sha256:()=>fl,sha512:()=>pl});var C={};__webpack_require__.r(C),__webpack_require__.d(C,{DO:()=>Mf,OG:()=>Jf,My:()=>qf,bytesToNumberBE:()=>jf,lX:()=>Hf,Id:()=>Qf,fg:()=>$f,qj:()=>Yf,hexToBytes:()=>zf,aY:()=>Lf,lq:()=>Gf,z:()=>Wf,Q5:()=>tp});var T={};__webpack_require__.r(T),__webpack_require__.d(T,{base10:()=>Ig});var R={};__webpack_require__.r(R),__webpack_require__.d(R,{base16:()=>Cg,base16upper:()=>Tg});var P={};__webpack_require__.r(P),__webpack_require__.d(P,{base2:()=>Rg});var D={};__webpack_require__.r(D),__webpack_require__.d(D,{base256emoji:()=>Bg});var N={};__webpack_require__.r(N),__webpack_require__.d(N,{base32:()=>Ug,base32hex:()=>qg,base32hexpad:()=>Fg,base32hexpadupper:()=>Vg,base32hexupper:()=>Kg,base32pad:()=>Mg,base32padupper:()=>Og,base32upper:()=>Lg,base32z:()=>zg});var B={};__webpack_require__.r(B),__webpack_require__.d(B,{base36:()=>jg,base36upper:()=>Hg});var U={};__webpack_require__.r(U),__webpack_require__.d(U,{base58btc:()=>Gg,base58flickr:()=>Wg});var L={};__webpack_require__.r(L),__webpack_require__.d(L,{base64:()=>Yg,base64pad:()=>Qg,base64url:()=>Jg,base64urlpad:()=>Xg});var M={};__webpack_require__.r(M),__webpack_require__.d(M,{base8:()=>Zg});var O={};__webpack_require__.r(O),__webpack_require__.d(O,{identity:()=>$g});var q={};__webpack_require__.r(q),__webpack_require__.d(q,{code:()=>nb,decode:()=>ob,encode:()=>ib,name:()=>rb});var K={};__webpack_require__.r(K),__webpack_require__.d(K,{code:()=>ab,decode:()=>ub,encode:()=>cb,name:()=>sb});var F={};__webpack_require__.r(F),__webpack_require__.d(F,{identity:()=>Db});var V={};__webpack_require__.r(V),__webpack_require__.d(V,{sha256:()=>Lb,sha512:()=>Mb});var z={};__webpack_require__.r(z),__webpack_require__.d(z,{Ed25519PrivateKey:()=>Vy,Ed25519PublicKey:()=>Fy,generateKeyPair:()=>Hy,generateKeyPairFromSeed:()=>Gy,unmarshalEd25519PrivateKey:()=>zy,unmarshalEd25519PublicKey:()=>jy});var j={};__webpack_require__.r(j),__webpack_require__.d(j,{MAX_KEY_SIZE:()=>tm,RsaPrivateKey:()=>nm,RsaPublicKey:()=>rm,fromJwk:()=>sm,generateKeyPair:()=>am,unmarshalRsaPrivateKey:()=>im,unmarshalRsaPublicKey:()=>om});var H={};__webpack_require__.r(H),__webpack_require__.d(H,{Secp256k1PrivateKey:()=>Im,Secp256k1PublicKey:()=>xm,generateKeyPair:()=>Rm,unmarshalSecp256k1PrivateKey:()=>Cm,unmarshalSecp256k1PublicKey:()=>Tm});var G={};__webpack_require__.r(G),__webpack_require__.d(G,{base58btc:()=>Wm,base58flickr:()=>Ym});var W={};__webpack_require__.r(W),__webpack_require__.d(W,{base10:()=>Qm});var Y={};__webpack_require__.r(Y),__webpack_require__.d(Y,{base16:()=>Jm,base16upper:()=>Xm});var Q={};__webpack_require__.r(Q),__webpack_require__.d(Q,{base2:()=>Zm});var J={};__webpack_require__.r(J),__webpack_require__.d(J,{base256emoji:()=>rv});var X={};__webpack_require__.r(X),__webpack_require__.d(X,{base32:()=>nv,base32hex:()=>av,base32hexpad:()=>uv,base32hexpadupper:()=>lv,base32hexupper:()=>cv,base32pad:()=>ov,base32padupper:()=>sv,base32upper:()=>iv,base32z:()=>hv});var Z={};__webpack_require__.r(Z),__webpack_require__.d(Z,{base36:()=>dv,base36upper:()=>fv});var $={};__webpack_require__.r($),__webpack_require__.d($,{base64:()=>pv,base64pad:()=>gv,base64url:()=>bv,base64urlpad:()=>yv});var ee={};__webpack_require__.r(ee),__webpack_require__.d(ee,{base8:()=>mv});var te={};__webpack_require__.r(te),__webpack_require__.d(te,{identity:()=>vv});var re={};__webpack_require__.r(re),__webpack_require__.d(re,{code:()=>Sv,decode:()=>kv,encode:()=>Av,name:()=>Ev});var ne={};__webpack_require__.r(ne),__webpack_require__.d(ne,{code:()=>Iv,decode:()=>Tv,encode:()=>Cv,name:()=>xv});var ie={};__webpack_require__.r(ie),__webpack_require__.d(ie,{identity:()=>ew});var oe={};__webpack_require__.r(oe),__webpack_require__.d(oe,{sha256:()=>iw,sha512:()=>ow});var se={};__webpack_require__.r(se),__webpack_require__.d(se,{base58btc:()=>O_,base58flickr:()=>q_});var ae={};__webpack_require__.r(ae),__webpack_require__.d(ae,{base10:()=>K_});var ce={};__webpack_require__.r(ce),__webpack_require__.d(ce,{base16:()=>F_,base16upper:()=>V_});var ue={};__webpack_require__.r(ue),__webpack_require__.d(ue,{base2:()=>z_});var le={};__webpack_require__.r(le),__webpack_require__.d(le,{base256emoji:()=>W_});var he={};__webpack_require__.r(he),__webpack_require__.d(he,{base32:()=>Y_,base32hex:()=>Z_,base32hexpad:()=>eE,base32hexpadupper:()=>tE,base32hexupper:()=>$_,base32pad:()=>J_,base32padupper:()=>X_,base32upper:()=>Q_,base32z:()=>rE});var de={};__webpack_require__.r(de),__webpack_require__.d(de,{base36:()=>nE,base36upper:()=>iE});var fe={};__webpack_require__.r(fe),__webpack_require__.d(fe,{base64:()=>oE,base64pad:()=>sE,base64url:()=>aE,base64urlpad:()=>cE});var pe={};__webpack_require__.r(pe),__webpack_require__.d(pe,{base8:()=>uE});var ge={};__webpack_require__.r(ge),__webpack_require__.d(ge,{identity:()=>lE});var be={};__webpack_require__.r(be),__webpack_require__.d(be,{code:()=>pE,decode:()=>bE,encode:()=>gE,name:()=>fE});var ye={};__webpack_require__.r(ye),__webpack_require__.d(ye,{code:()=>mE,decode:()=>wE,encode:()=>vE,name:()=>yE});var me={};__webpack_require__.r(me),__webpack_require__.d(me,{identity:()=>HE});var ve={};__webpack_require__.r(ve),__webpack_require__.d(ve,{sha256:()=>QE,sha512:()=>JE});var we={};__webpack_require__.r(we),__webpack_require__.d(we,{base58btc:()=>PS,base58flickr:()=>DS});var _e={};__webpack_require__.r(_e),__webpack_require__.d(_e,{base32:()=>NS,base32hex:()=>MS,base32hexpad:()=>qS,base32hexpadupper:()=>KS,base32hexupper:()=>OS,base32pad:()=>US,base32padupper:()=>LS,base32upper:()=>BS,base32z:()=>FS});var Ee={};__webpack_require__.r(Ee),__webpack_require__.d(Ee,{base10:()=>NA});var Se={};__webpack_require__.r(Se),__webpack_require__.d(Se,{base16:()=>BA,base16upper:()=>UA});var Ae={};__webpack_require__.r(Ae),__webpack_require__.d(Ae,{base2:()=>LA});var ke={};__webpack_require__.r(ke),__webpack_require__.d(ke,{base256emoji:()=>KA});var xe={};__webpack_require__.r(xe),__webpack_require__.d(xe,{base32:()=>FA,base32hex:()=>HA,base32hexpad:()=>WA,base32hexpadupper:()=>YA,base32hexupper:()=>GA,base32pad:()=>zA,base32padupper:()=>jA,base32upper:()=>VA,base32z:()=>QA});var Ie={};__webpack_require__.r(Ie),__webpack_require__.d(Ie,{base36:()=>JA,base36upper:()=>XA});var Ce={};__webpack_require__.r(Ce),__webpack_require__.d(Ce,{base58btc:()=>ZA,base58flickr:()=>$A});var Te={};__webpack_require__.r(Te),__webpack_require__.d(Te,{base64:()=>ek,base64pad:()=>tk,base64url:()=>rk,base64urlpad:()=>nk});var Re={};__webpack_require__.r(Re),__webpack_require__.d(Re,{base8:()=>ik});var Pe={};__webpack_require__.r(Pe),__webpack_require__.d(Pe,{identity:()=>ok});var De={};__webpack_require__.r(De),__webpack_require__.d(De,{code:()=>uk,decode:()=>hk,encode:()=>lk,name:()=>ck});var Ne={};__webpack_require__.r(Ne),__webpack_require__.d(Ne,{code:()=>fk,decode:()=>gk,encode:()=>pk,name:()=>dk});var Be={};__webpack_require__.r(Be),__webpack_require__.d(Be,{identity:()=>Ok});var Ue={};__webpack_require__.r(Ue),__webpack_require__.d(Ue,{sha256:()=>Vk,sha512:()=>zk});var Le={};__webpack_require__.r(Le),__webpack_require__.d(Le,{base10:()=>nx});var Me={};__webpack_require__.r(Me),__webpack_require__.d(Me,{base16:()=>ix,base16upper:()=>ox});var Oe={};__webpack_require__.r(Oe),__webpack_require__.d(Oe,{base2:()=>sx});var qe={};__webpack_require__.r(qe),__webpack_require__.d(qe,{base256emoji:()=>lx});var Ke={};__webpack_require__.r(Ke),__webpack_require__.d(Ke,{base36:()=>hx,base36upper:()=>dx});var Fe={};__webpack_require__.r(Fe),__webpack_require__.d(Fe,{base64:()=>fx,base64pad:()=>px,base64url:()=>gx,base64urlpad:()=>bx});var Ve={};__webpack_require__.r(Ve),__webpack_require__.d(Ve,{base8:()=>yx});var ze={};__webpack_require__.r(ze),__webpack_require__.d(ze,{identity:()=>mx});var je={};__webpack_require__.r(je),__webpack_require__.d(je,{code:()=>Ex,decode:()=>Ax,encode:()=>Sx,name:()=>_x});var He={};__webpack_require__.r(He),__webpack_require__.d(He,{code:()=>xx,decode:()=>Cx,encode:()=>Ix,name:()=>kx});var Ge={};__webpack_require__.r(Ge),__webpack_require__.d(Ge,{identity:()=>Rx});var We={};__webpack_require__.r(We),__webpack_require__.d(We,{sha256:()=>Bx,sha512:()=>Ux});var Ye={};__webpack_require__.r(Ye),__webpack_require__.d(Ye,{base58btc:()=>rT,base58flickr:()=>nT});var Qe={};__webpack_require__.r(Qe),__webpack_require__.d(Qe,{base10:()=>iT});var Je={};__webpack_require__.r(Je),__webpack_require__.d(Je,{base16:()=>oT,base16upper:()=>sT});var Xe={};__webpack_require__.r(Xe),__webpack_require__.d(Xe,{base2:()=>aT});var Ze={};__webpack_require__.r(Ze),__webpack_require__.d(Ze,{base256emoji:()=>hT});var $e={};__webpack_require__.r($e),__webpack_require__.d($e,{base32:()=>dT,base32hex:()=>bT,base32hexpad:()=>mT,base32hexpadupper:()=>vT,base32hexupper:()=>yT,base32pad:()=>pT,base32padupper:()=>gT,base32upper:()=>fT,base32z:()=>wT});var et={};__webpack_require__.r(et),__webpack_require__.d(et,{base36:()=>_T,base36upper:()=>ET});var tt={};__webpack_require__.r(tt),__webpack_require__.d(tt,{base64:()=>ST,base64pad:()=>AT,base64url:()=>kT,base64urlpad:()=>xT});var rt={};__webpack_require__.r(rt),__webpack_require__.d(rt,{base8:()=>IT});var nt={};__webpack_require__.r(nt),__webpack_require__.d(nt,{identity:()=>CT});var it={};__webpack_require__.r(it),__webpack_require__.d(it,{code:()=>DT,decode:()=>BT,encode:()=>NT,name:()=>PT});var ot={};__webpack_require__.r(ot),__webpack_require__.d(ot,{code:()=>LT,decode:()=>OT,encode:()=>MT,name:()=>UT});var st={};__webpack_require__.r(st),__webpack_require__.d(st,{identity:()=>uR});var at={};__webpack_require__.r(at),__webpack_require__.d(at,{sha256:()=>fR,sha512:()=>pR});var ct={};__webpack_require__.r(ct),__webpack_require__.d(ct,{base58btc:()=>GR,base58flickr:()=>WR});var ut={};__webpack_require__.r(ut),__webpack_require__.d(ut,{base10:()=>YR});var lt={};__webpack_require__.r(lt),__webpack_require__.d(lt,{base16:()=>QR,base16upper:()=>JR});var ht={};__webpack_require__.r(ht),__webpack_require__.d(ht,{base2:()=>XR});var dt={};__webpack_require__.r(dt),__webpack_require__.d(dt,{base256emoji:()=>tP});var ft={};__webpack_require__.r(ft),__webpack_require__.d(ft,{base32:()=>rP,base32hex:()=>sP,base32hexpad:()=>cP,base32hexpadupper:()=>uP,base32hexupper:()=>aP,base32pad:()=>iP,base32padupper:()=>oP,base32upper:()=>nP,base32z:()=>lP});var pt={};__webpack_require__.r(pt),__webpack_require__.d(pt,{base36:()=>hP,base36upper:()=>dP});var gt={};__webpack_require__.r(gt),__webpack_require__.d(gt,{base64:()=>fP,base64pad:()=>pP,base64url:()=>gP,base64urlpad:()=>bP});var bt={};__webpack_require__.r(bt),__webpack_require__.d(bt,{base8:()=>yP});var yt={};__webpack_require__.r(yt),__webpack_require__.d(yt,{identity:()=>mP});var mt={};__webpack_require__.r(mt),__webpack_require__.d(mt,{code:()=>EP,decode:()=>AP,encode:()=>SP,name:()=>_P});var vt={};__webpack_require__.r(vt),__webpack_require__.d(vt,{code:()=>xP,decode:()=>CP,encode:()=>IP,name:()=>kP});var wt={};__webpack_require__.r(wt),__webpack_require__.d(wt,{identity:()=>$P});var _t={};__webpack_require__.r(_t),__webpack_require__.d(_t,{sha256:()=>nD,sha512:()=>iD});var Et={};__webpack_require__.r(Et),__webpack_require__.d(Et,{Ed25519PrivateKey:()=>lB,Ed25519PublicKey:()=>uB,generateKeyPair:()=>fB,generateKeyPairFromSeed:()=>pB,unmarshalEd25519PrivateKey:()=>hB,unmarshalEd25519PublicKey:()=>dB});var St={};__webpack_require__.r(St),__webpack_require__.d(St,{MAX_RSA_KEY_SIZE:()=>BL,RsaPrivateKey:()=>LL,RsaPublicKey:()=>UL,fromJwk:()=>qL,generateKeyPair:()=>KL,unmarshalRsaPrivateKey:()=>ML,unmarshalRsaPublicKey:()=>OL});var At={};__webpack_require__.r(At),__webpack_require__.d(At,{Secp256k1PrivateKey:()=>zL,Secp256k1PublicKey:()=>VL,generateKeyPair:()=>GL,unmarshalSecp256k1PrivateKey:()=>jL,unmarshalSecp256k1PublicKey:()=>HL});var kt={};__webpack_require__.r(kt),__webpack_require__.d(kt,{base10:()=>tK});var xt={};__webpack_require__.r(xt),__webpack_require__.d(xt,{base16:()=>rK,base16upper:()=>nK});var It={};__webpack_require__.r(It),__webpack_require__.d(It,{base2:()=>iK});var Ct={};__webpack_require__.r(Ct),__webpack_require__.d(Ct,{base256emoji:()=>cK});var Tt={};__webpack_require__.r(Tt),__webpack_require__.d(Tt,{base32:()=>uK,base32hex:()=>fK,base32hexpad:()=>gK,base32hexpadupper:()=>bK,base32hexupper:()=>pK,base32pad:()=>hK,base32padupper:()=>dK,base32upper:()=>lK,base32z:()=>yK});var Rt={};__webpack_require__.r(Rt),__webpack_require__.d(Rt,{base36:()=>mK,base36upper:()=>vK});var Pt={};__webpack_require__.r(Pt),__webpack_require__.d(Pt,{base58btc:()=>wK,base58flickr:()=>_K});var Dt={};__webpack_require__.r(Dt),__webpack_require__.d(Dt,{base64:()=>EK,base64pad:()=>SK,base64url:()=>AK,base64urlpad:()=>kK});var Nt={};__webpack_require__.r(Nt),__webpack_require__.d(Nt,{base8:()=>xK});var Bt={};__webpack_require__.r(Bt),__webpack_require__.d(Bt,{identity:()=>IK});var Ut={};__webpack_require__.r(Ut),__webpack_require__.d(Ut,{code:()=>PK,decode:()=>NK,encode:()=>DK,name:()=>RK});var Lt={};__webpack_require__.r(Lt),__webpack_require__.d(Lt,{code:()=>UK,decode:()=>MK,encode:()=>LK,name:()=>BK});var Mt={};__webpack_require__.r(Mt),__webpack_require__.d(Mt,{identity:()=>sF});var Ot={};__webpack_require__.r(Ot),__webpack_require__.d(Ot,{sha256:()=>lF,sha512:()=>hF});var qt={};__webpack_require__.r(qt),__webpack_require__.d(qt,{base10:()=>uV});var Kt={};__webpack_require__.r(Kt),__webpack_require__.d(Kt,{base16:()=>lV,base16upper:()=>hV});var Ft={};__webpack_require__.r(Ft),__webpack_require__.d(Ft,{base2:()=>dV});var Vt={};__webpack_require__.r(Vt),__webpack_require__.d(Vt,{base256emoji:()=>bV});var zt={};__webpack_require__.r(zt),__webpack_require__.d(zt,{base32:()=>yV,base32hex:()=>_V,base32hexpad:()=>SV,base32hexpadupper:()=>AV,base32hexupper:()=>EV,base32pad:()=>vV,base32padupper:()=>wV,base32upper:()=>mV,base32z:()=>kV});var jt={};__webpack_require__.r(jt),__webpack_require__.d(jt,{base36:()=>xV,base36upper:()=>IV});var Ht={};__webpack_require__.r(Ht),__webpack_require__.d(Ht,{base58btc:()=>CV,base58flickr:()=>TV});var Gt={};__webpack_require__.r(Gt),__webpack_require__.d(Gt,{base64:()=>RV,base64pad:()=>PV,base64url:()=>DV,base64urlpad:()=>NV});var Wt={};__webpack_require__.r(Wt),__webpack_require__.d(Wt,{base8:()=>BV});var Yt={};__webpack_require__.r(Yt),__webpack_require__.d(Yt,{identity:()=>UV});var Qt={};__webpack_require__.r(Qt),__webpack_require__.d(Qt,{code:()=>qV,decode:()=>FV,encode:()=>KV,name:()=>OV});var Jt={};__webpack_require__.r(Jt),__webpack_require__.d(Jt,{code:()=>zV,decode:()=>HV,encode:()=>jV,name:()=>VV});var Xt={};__webpack_require__.r(Xt),__webpack_require__.d(Xt,{identity:()=>pz});var Zt={};__webpack_require__.r(Zt),__webpack_require__.d(Zt,{sha256:()=>mz,sha512:()=>vz});var $t={};__webpack_require__.r($t),__webpack_require__.d($t,{base58btc:()=>Qz,base58flickr:()=>Jz});var er={};__webpack_require__.r(er),__webpack_require__.d(er,{base10:()=>Xz});var tr={};__webpack_require__.r(tr),__webpack_require__.d(tr,{base16:()=>Zz,base16upper:()=>$z});var rr={};__webpack_require__.r(rr),__webpack_require__.d(rr,{base2:()=>ej});var nr={};__webpack_require__.r(nr),__webpack_require__.d(nr,{base256emoji:()=>ij});var ir={};__webpack_require__.r(ir),__webpack_require__.d(ir,{base32:()=>oj,base32hex:()=>uj,base32hexpad:()=>hj,base32hexpadupper:()=>dj,base32hexupper:()=>lj,base32pad:()=>aj,base32padupper:()=>cj,base32upper:()=>sj,base32z:()=>fj});var or={};__webpack_require__.r(or),__webpack_require__.d(or,{base36:()=>pj,base36upper:()=>gj});var sr={};__webpack_require__.r(sr),__webpack_require__.d(sr,{base64:()=>bj,base64pad:()=>yj,base64url:()=>mj,base64urlpad:()=>vj});var ar={};__webpack_require__.r(ar),__webpack_require__.d(ar,{base8:()=>wj});var cr={};__webpack_require__.r(cr),__webpack_require__.d(cr,{identity:()=>_j});var ur={};__webpack_require__.r(ur),__webpack_require__.d(ur,{code:()=>kj,decode:()=>Ij,encode:()=>xj,name:()=>Aj});var lr={};__webpack_require__.r(lr),__webpack_require__.d(lr,{code:()=>Tj,decode:()=>Pj,encode:()=>Rj,name:()=>Cj});var hr={};__webpack_require__.r(hr),__webpack_require__.d(hr,{identity:()=>rH});var dr={};__webpack_require__.r(dr),__webpack_require__.d(dr,{sha256:()=>sH,sha512:()=>aH});var fr={};__webpack_require__.r(fr),__webpack_require__.d(fr,{Ed25519PrivateKey:()=>fW,Ed25519PublicKey:()=>dW,generateKeyPair:()=>bW,generateKeyPairFromSeed:()=>yW,unmarshalEd25519PrivateKey:()=>pW,unmarshalEd25519PublicKey:()=>gW});var pr={};__webpack_require__.r(pr),__webpack_require__.d(pr,{MAX_RSA_KEY_SIZE:()=>CW,RsaPrivateKey:()=>RW,RsaPublicKey:()=>TW,fromJwk:()=>NW,generateKeyPair:()=>BW,unmarshalRsaPrivateKey:()=>PW,unmarshalRsaPublicKey:()=>DW});var gr={};__webpack_require__.r(gr),__webpack_require__.d(gr,{Secp256k1PrivateKey:()=>MW,Secp256k1PublicKey:()=>LW,generateKeyPair:()=>KW,unmarshalSecp256k1PrivateKey:()=>OW,unmarshalSecp256k1PublicKey:()=>qW});var br={};__webpack_require__.r(br),__webpack_require__.d(br,{sha256:()=>SY,sha512:()=>AY});var yr={};__webpack_require__.r(yr),__webpack_require__.d(yr,{base10:()=>UY});var mr={};__webpack_require__.r(mr),__webpack_require__.d(mr,{base16:()=>LY,base16upper:()=>MY});var vr={};__webpack_require__.r(vr),__webpack_require__.d(vr,{base2:()=>OY});var wr={};__webpack_require__.r(wr),__webpack_require__.d(wr,{base256emoji:()=>VY});var _r={};__webpack_require__.r(_r),__webpack_require__.d(_r,{base32:()=>zY,base32hex:()=>WY,base32hexpad:()=>QY,base32hexpadupper:()=>JY,base32hexupper:()=>YY,base32pad:()=>HY,base32padupper:()=>GY,base32upper:()=>jY,base32z:()=>XY});var Er={};__webpack_require__.r(Er),__webpack_require__.d(Er,{base36:()=>ZY,base36upper:()=>$Y});var Sr={};__webpack_require__.r(Sr),__webpack_require__.d(Sr,{base58btc:()=>eQ,base58flickr:()=>tQ});var Ar={};__webpack_require__.r(Ar),__webpack_require__.d(Ar,{base64:()=>rQ,base64pad:()=>nQ,base64url:()=>iQ,base64urlpad:()=>oQ});var kr={};__webpack_require__.r(kr),__webpack_require__.d(kr,{base8:()=>sQ});var xr={};__webpack_require__.r(xr),__webpack_require__.d(xr,{identity:()=>aQ});var Ir={};__webpack_require__.r(Ir),__webpack_require__.d(Ir,{code:()=>hQ,decode:()=>fQ,encode:()=>dQ,name:()=>lQ});var Cr={};__webpack_require__.r(Cr),__webpack_require__.d(Cr,{code:()=>gQ,decode:()=>yQ,encode:()=>bQ,name:()=>pQ});var Tr={};__webpack_require__.r(Tr),__webpack_require__.d(Tr,{identity:()=>vQ});var Rr={};__webpack_require__.r(Rr),__webpack_require__.d(Rr,{base58btc:()=>sJ,base58flickr:()=>aJ});var Pr={};__webpack_require__.r(Pr),__webpack_require__.d(Pr,{identity:()=>DJ});var Dr={};__webpack_require__.r(Dr),__webpack_require__.d(Dr,{sha256:()=>LJ,sha512:()=>MJ});var Nr={};__webpack_require__.r(Nr),__webpack_require__.d(Nr,{base10:()=>qJ});var Br={};__webpack_require__.r(Br),__webpack_require__.d(Br,{base16:()=>KJ,base16upper:()=>FJ});var Ur={};__webpack_require__.r(Ur),__webpack_require__.d(Ur,{base2:()=>VJ});var Lr={};__webpack_require__.r(Lr),__webpack_require__.d(Lr,{base256emoji:()=>GJ});var Mr={};__webpack_require__.r(Mr),__webpack_require__.d(Mr,{base32:()=>WJ,base32hex:()=>XJ,base32hexpad:()=>$J,base32hexpadupper:()=>eX,base32hexupper:()=>ZJ,base32pad:()=>QJ,base32padupper:()=>JJ,base32upper:()=>YJ,base32z:()=>tX});var Or={};__webpack_require__.r(Or),__webpack_require__.d(Or,{base36:()=>rX,base36upper:()=>nX});var qr={};__webpack_require__.r(qr),__webpack_require__.d(qr,{base64:()=>iX,base64pad:()=>oX,base64url:()=>sX,base64urlpad:()=>aX});var Kr={};__webpack_require__.r(Kr),__webpack_require__.d(Kr,{base8:()=>cX});var Fr={};__webpack_require__.r(Fr),__webpack_require__.d(Fr,{identity:()=>uX});var Vr={};__webpack_require__.r(Vr),__webpack_require__.d(Vr,{code:()=>fX,decode:()=>gX,encode:()=>pX,name:()=>dX});var zr={};__webpack_require__.r(zr),__webpack_require__.d(zr,{code:()=>yX,decode:()=>vX,encode:()=>mX,name:()=>bX});var jr={};__webpack_require__.r(jr),__webpack_require__.d(jr,{Ed25519PrivateKey:()=>CZ,Ed25519PublicKey:()=>IZ,generateKeyPair:()=>PZ,generateKeyPairFromSeed:()=>DZ,unmarshalEd25519PrivateKey:()=>TZ,unmarshalEd25519PublicKey:()=>RZ});var Hr={};__webpack_require__.r(Hr),__webpack_require__.d(Hr,{MAX_RSA_KEY_SIZE:()=>jZ,RsaPrivateKey:()=>GZ,RsaPublicKey:()=>HZ,fromJwk:()=>QZ,generateKeyPair:()=>JZ,unmarshalRsaPrivateKey:()=>WZ,unmarshalRsaPublicKey:()=>YZ});var Gr={};__webpack_require__.r(Gr),__webpack_require__.d(Gr,{Secp256k1PrivateKey:()=>$Z,Secp256k1PublicKey:()=>ZZ,generateKeyPair:()=>r$,unmarshalSecp256k1PrivateKey:()=>e$,unmarshalSecp256k1PublicKey:()=>t$});var Wr={};__webpack_require__.r(Wr),__webpack_require__.d(Wr,{base58btc:()=>_$,base58flickr:()=>E$});var Yr={};__webpack_require__.r(Yr),__webpack_require__.d(Yr,{base10:()=>S$});var Qr={};__webpack_require__.r(Qr),__webpack_require__.d(Qr,{base16:()=>A$,base16upper:()=>k$});var Jr={};__webpack_require__.r(Jr),__webpack_require__.d(Jr,{base2:()=>x$});var Xr={};__webpack_require__.r(Xr),__webpack_require__.d(Xr,{base256emoji:()=>R$});var Zr={};__webpack_require__.r(Zr),__webpack_require__.d(Zr,{base32:()=>P$,base32hex:()=>U$,base32hexpad:()=>M$,base32hexpadupper:()=>O$,base32hexupper:()=>L$,base32pad:()=>N$,base32padupper:()=>B$,base32upper:()=>D$,base32z:()=>q$});var $r={};__webpack_require__.r($r),__webpack_require__.d($r,{base36:()=>K$,base36upper:()=>F$});var en={};__webpack_require__.r(en),__webpack_require__.d(en,{base64:()=>V$,base64pad:()=>z$,base64url:()=>j$,base64urlpad:()=>H$});var tn={};__webpack_require__.r(tn),__webpack_require__.d(tn,{base8:()=>G$});var rn={};__webpack_require__.r(rn),__webpack_require__.d(rn,{identity:()=>W$});var nn={};__webpack_require__.r(nn),__webpack_require__.d(nn,{code:()=>X$,decode:()=>$$,encode:()=>Z$,name:()=>J$});var on={};__webpack_require__.r(on),__webpack_require__.d(on,{code:()=>t0,decode:()=>n0,encode:()=>r0,name:()=>e0});var sn={};__webpack_require__.r(sn),__webpack_require__.d(sn,{identity:()=>C0});var an={};__webpack_require__.r(an),__webpack_require__.d(an,{sha256:()=>D0,sha512:()=>N0});var cn={};__webpack_require__.r(cn),__webpack_require__.d(cn,{base58btc:()=>S1,base58flickr:()=>A1});var un={};__webpack_require__.r(un),__webpack_require__.d(un,{identity:()=>Q1});var ln={};__webpack_require__.r(ln),__webpack_require__.d(ln,{sha256:()=>$1,sha512:()=>e2});var hn={};__webpack_require__.r(hn),__webpack_require__.d(hn,{base10:()=>r2});var dn={};__webpack_require__.r(dn),__webpack_require__.d(dn,{base16:()=>n2,base16upper:()=>i2});var fn={};__webpack_require__.r(fn),__webpack_require__.d(fn,{base2:()=>o2});var pn={};__webpack_require__.r(pn),__webpack_require__.d(pn,{base256emoji:()=>u2});var gn={};__webpack_require__.r(gn),__webpack_require__.d(gn,{base32:()=>l2,base32hex:()=>p2,base32hexpad:()=>b2,base32hexpadupper:()=>y2,base32hexupper:()=>g2,base32pad:()=>d2,base32padupper:()=>f2,base32upper:()=>h2,base32z:()=>m2});var bn={};__webpack_require__.r(bn),__webpack_require__.d(bn,{base36:()=>v2,base36upper:()=>w2});var yn={};__webpack_require__.r(yn),__webpack_require__.d(yn,{base64:()=>_2,base64pad:()=>E2,base64url:()=>S2,base64urlpad:()=>A2});var mn={};__webpack_require__.r(mn),__webpack_require__.d(mn,{base8:()=>k2});var vn={};__webpack_require__.r(vn),__webpack_require__.d(vn,{identity:()=>x2});var wn={};__webpack_require__.r(wn),__webpack_require__.d(wn,{code:()=>R2,decode:()=>D2,encode:()=>P2,name:()=>T2});var _n={};__webpack_require__.r(_n),__webpack_require__.d(_n,{code:()=>B2,decode:()=>L2,encode:()=>U2,name:()=>N2});var En={};__webpack_require__.r(En),__webpack_require__.d(En,{Ed25519PrivateKey:()=>H3,Ed25519PublicKey:()=>j3,generateKeyPair:()=>Y3,generateKeyPairFromSeed:()=>Q3,unmarshalEd25519PrivateKey:()=>G3,unmarshalEd25519PublicKey:()=>W3});var Sn={};__webpack_require__.r(Sn),__webpack_require__.d(Sn,{MAX_RSA_KEY_SIZE:()=>a6,RsaPrivateKey:()=>u6,RsaPublicKey:()=>c6,fromJwk:()=>d6,generateKeyPair:()=>f6,unmarshalRsaPrivateKey:()=>l6,unmarshalRsaPublicKey:()=>h6});var An={};__webpack_require__.r(An),__webpack_require__.d(An,{Secp256k1PrivateKey:()=>b6,Secp256k1PublicKey:()=>g6,generateKeyPair:()=>v6,unmarshalSecp256k1PrivateKey:()=>y6,unmarshalSecp256k1PublicKey:()=>m6});var kn={};__webpack_require__.r(kn),__webpack_require__.d(kn,{base58btc:()=>Z6,base58flickr:()=>$6});var xn={};__webpack_require__.r(xn),__webpack_require__.d(xn,{base10:()=>e4});var In={};__webpack_require__.r(In),__webpack_require__.d(In,{base16:()=>t4,base16upper:()=>r4});var Cn={};__webpack_require__.r(Cn),__webpack_require__.d(Cn,{base2:()=>n4});var Tn={};__webpack_require__.r(Tn),__webpack_require__.d(Tn,{base256emoji:()=>a4});var Rn={};__webpack_require__.r(Rn),__webpack_require__.d(Rn,{base32:()=>c4,base32hex:()=>d4,base32hexpad:()=>p4,base32hexpadupper:()=>g4,base32hexupper:()=>f4,base32pad:()=>l4,base32padupper:()=>h4,base32upper:()=>u4,base32z:()=>b4});var Pn={};__webpack_require__.r(Pn),__webpack_require__.d(Pn,{base36:()=>y4,base36upper:()=>m4});var Dn={};__webpack_require__.r(Dn),__webpack_require__.d(Dn,{base64:()=>v4,base64pad:()=>w4,base64url:()=>_4,base64urlpad:()=>E4});var Nn={};__webpack_require__.r(Nn),__webpack_require__.d(Nn,{base8:()=>S4});var Bn={};__webpack_require__.r(Bn),__webpack_require__.d(Bn,{identity:()=>A4});var Un={};__webpack_require__.r(Un),__webpack_require__.d(Un,{code:()=>C4,decode:()=>R4,encode:()=>T4,name:()=>I4});var Ln={};__webpack_require__.r(Ln),__webpack_require__.d(Ln,{code:()=>D4,decode:()=>B4,encode:()=>N4,name:()=>P4});var Mn={};__webpack_require__.r(Mn),__webpack_require__.d(Mn,{identity:()=>o5});var On={};__webpack_require__.r(On),__webpack_require__.d(On,{sha256:()=>u5,sha512:()=>l5});var qn={};__webpack_require__.r(qn),__webpack_require__.d(qn,{base10:()=>c9});var Kn={};__webpack_require__.r(Kn),__webpack_require__.d(Kn,{base16:()=>u9,base16upper:()=>l9});var Fn={};__webpack_require__.r(Fn),__webpack_require__.d(Fn,{base2:()=>h9});var Vn={};__webpack_require__.r(Vn),__webpack_require__.d(Vn,{base256emoji:()=>g9});var zn={};__webpack_require__.r(zn),__webpack_require__.d(zn,{base32:()=>b9,base32hex:()=>w9,base32hexpad:()=>E9,base32hexpadupper:()=>S9,base32hexupper:()=>_9,base32pad:()=>m9,base32padupper:()=>v9,base32upper:()=>y9,base32z:()=>A9});var jn={};__webpack_require__.r(jn),__webpack_require__.d(jn,{base36:()=>k9,base36upper:()=>x9});var Hn={};__webpack_require__.r(Hn),__webpack_require__.d(Hn,{base58btc:()=>I9,base58flickr:()=>C9});var Gn={};__webpack_require__.r(Gn),__webpack_require__.d(Gn,{base64:()=>T9,base64pad:()=>R9,base64url:()=>P9,base64urlpad:()=>D9});var Wn={};__webpack_require__.r(Wn),__webpack_require__.d(Wn,{base8:()=>N9});var Yn={};__webpack_require__.r(Yn),__webpack_require__.d(Yn,{identity:()=>B9});var Qn={};__webpack_require__.r(Qn),__webpack_require__.d(Qn,{code:()=>O9,decode:()=>K9,encode:()=>q9,name:()=>M9});var Jn={};__webpack_require__.r(Jn),__webpack_require__.d(Jn,{code:()=>V9,decode:()=>j9,encode:()=>z9,name:()=>F9});var Xn={};__webpack_require__.r(Xn),__webpack_require__.d(Xn,{identity:()=>fee});var Zn={};__webpack_require__.r(Zn),__webpack_require__.d(Zn,{sha256:()=>yee,sha512:()=>mee});var $n={};__webpack_require__.r($n),__webpack_require__.d($n,{base10:()=>ire});var ei={};__webpack_require__.r(ei),__webpack_require__.d(ei,{base16:()=>ore,base16upper:()=>sre});var ti={};__webpack_require__.r(ti),__webpack_require__.d(ti,{base2:()=>are});var ri={};__webpack_require__.r(ri),__webpack_require__.d(ri,{base256emoji:()=>hre});var ni={};__webpack_require__.r(ni),__webpack_require__.d(ni,{base32:()=>dre,base32hex:()=>bre,base32hexpad:()=>mre,base32hexpadupper:()=>vre,base32hexupper:()=>yre,base32pad:()=>pre,base32padupper:()=>gre,base32upper:()=>fre,base32z:()=>wre});var ii={};__webpack_require__.r(ii),__webpack_require__.d(ii,{base36:()=>_re,base36upper:()=>Ere});var oi={};__webpack_require__.r(oi),__webpack_require__.d(oi,{base58btc:()=>Sre,base58flickr:()=>Are});var si={};__webpack_require__.r(si),__webpack_require__.d(si,{base64:()=>kre,base64pad:()=>xre,base64url:()=>Ire,base64urlpad:()=>Cre});var ai={};__webpack_require__.r(ai),__webpack_require__.d(ai,{base8:()=>Tre});var ci={};__webpack_require__.r(ci),__webpack_require__.d(ci,{identity:()=>Rre});var ui={};__webpack_require__.r(ui),__webpack_require__.d(ui,{code:()=>Bre,decode:()=>Lre,encode:()=>Ure,name:()=>Nre});var li={};__webpack_require__.r(li),__webpack_require__.d(li,{code:()=>Ore,decode:()=>Kre,encode:()=>qre,name:()=>Mre});var hi={};__webpack_require__.r(hi),__webpack_require__.d(hi,{identity:()=>une});var di={};__webpack_require__.r(di),__webpack_require__.d(di,{sha256:()=>fne,sha512:()=>pne});var fi={};__webpack_require__.r(fi),__webpack_require__.d(fi,{base10:()=>Eie});var pi={};__webpack_require__.r(pi),__webpack_require__.d(pi,{base16:()=>Sie,base16upper:()=>Aie});var gi={};__webpack_require__.r(gi),__webpack_require__.d(gi,{base2:()=>kie});var bi={};__webpack_require__.r(bi),__webpack_require__.d(bi,{base256emoji:()=>Tie});var yi={};__webpack_require__.r(yi),__webpack_require__.d(yi,{base32:()=>Rie,base32hex:()=>Bie,base32hexpad:()=>Lie,base32hexpadupper:()=>Mie,base32hexupper:()=>Uie,base32pad:()=>Die,base32padupper:()=>Nie,base32upper:()=>Pie,base32z:()=>Oie});var mi={};__webpack_require__.r(mi),__webpack_require__.d(mi,{base36:()=>qie,base36upper:()=>Kie});var vi={};__webpack_require__.r(vi),__webpack_require__.d(vi,{base58btc:()=>Fie,base58flickr:()=>Vie});var wi={};__webpack_require__.r(wi),__webpack_require__.d(wi,{base64:()=>zie,base64pad:()=>jie,base64url:()=>Hie,base64urlpad:()=>Gie});var _i={};__webpack_require__.r(_i),__webpack_require__.d(_i,{base8:()=>Wie});var Ei={};__webpack_require__.r(Ei),__webpack_require__.d(Ei,{identity:()=>Yie});var Si={};__webpack_require__.r(Si),__webpack_require__.d(Si,{code:()=>Zie,decode:()=>eoe,encode:()=>$ie,name:()=>Xie});var Ai={};__webpack_require__.r(Ai),__webpack_require__.d(Ai,{code:()=>roe,decode:()=>ioe,encode:()=>noe,name:()=>toe});var ki={};__webpack_require__.r(ki),__webpack_require__.d(ki,{identity:()=>Ioe});var xi={};__webpack_require__.r(xi),__webpack_require__.d(xi,{sha256:()=>Poe,sha512:()=>Doe});var Ii={};__webpack_require__.r(Ii),__webpack_require__.d(Ii,{base58btc:()=>Uae,base58flickr:()=>Lae});var Ci={};__webpack_require__.r(Ci),__webpack_require__.d(Ci,{identity:()=>ace});var Ti={};__webpack_require__.r(Ti),__webpack_require__.d(Ti,{sha256:()=>hce,sha512:()=>dce});var Ri={};__webpack_require__.r(Ri),__webpack_require__.d(Ri,{base10:()=>pce});var Pi={};__webpack_require__.r(Pi),__webpack_require__.d(Pi,{base16:()=>gce,base16upper:()=>bce});var Di={};__webpack_require__.r(Di),__webpack_require__.d(Di,{base2:()=>yce});var Ni={};__webpack_require__.r(Ni),__webpack_require__.d(Ni,{base256emoji:()=>_ce});var Bi={};__webpack_require__.r(Bi),__webpack_require__.d(Bi,{base32:()=>Ece,base32hex:()=>xce,base32hexpad:()=>Cce,base32hexpadupper:()=>Tce,base32hexupper:()=>Ice,base32pad:()=>Ace,base32padupper:()=>kce,base32upper:()=>Sce,base32z:()=>Rce});var Ui={};__webpack_require__.r(Ui),__webpack_require__.d(Ui,{base36:()=>Pce,base36upper:()=>Dce});var Li={};__webpack_require__.r(Li),__webpack_require__.d(Li,{base64:()=>Nce,base64pad:()=>Bce,base64url:()=>Uce,base64urlpad:()=>Lce});var Mi={};__webpack_require__.r(Mi),__webpack_require__.d(Mi,{base8:()=>Mce});var Oi={};__webpack_require__.r(Oi),__webpack_require__.d(Oi,{identity:()=>Oce});var qi={};__webpack_require__.r(qi),__webpack_require__.d(qi,{code:()=>Vce,decode:()=>jce,encode:()=>zce,name:()=>Fce});var Ki={};__webpack_require__.r(Ki),__webpack_require__.d(Ki,{code:()=>Gce,decode:()=>Yce,encode:()=>Wce,name:()=>Hce});var Fi={};__webpack_require__.r(Fi),__webpack_require__.d(Fi,{Ed25519PrivateKey:()=>nle,Ed25519PublicKey:()=>rle,generateKeyPair:()=>sle,generateKeyPairFromSeed:()=>ale,unmarshalEd25519PrivateKey:()=>ile,unmarshalEd25519PublicKey:()=>ole});var Vi={};__webpack_require__.r(Vi),__webpack_require__.d(Vi,{MAX_RSA_KEY_SIZE:()=>vle,RsaPrivateKey:()=>_le,RsaPublicKey:()=>wle,fromJwk:()=>Ale,generateKeyPair:()=>kle,unmarshalRsaPrivateKey:()=>Ele,unmarshalRsaPublicKey:()=>Sle});var zi={};__webpack_require__.r(zi),__webpack_require__.d(zi,{Secp256k1PrivateKey:()=>Cle,Secp256k1PublicKey:()=>Ile,generateKeyPair:()=>Ple,unmarshalSecp256k1PrivateKey:()=>Tle,unmarshalSecp256k1PublicKey:()=>Rle});var ji={};__webpack_require__.r(ji),__webpack_require__.d(ji,{base10:()=>zfe});var Hi={};__webpack_require__.r(Hi),__webpack_require__.d(Hi,{base16:()=>jfe,base16upper:()=>Hfe});var Gi={};__webpack_require__.r(Gi),__webpack_require__.d(Gi,{base2:()=>Gfe});var Wi={};__webpack_require__.r(Wi),__webpack_require__.d(Wi,{base256emoji:()=>Jfe});var Yi={};__webpack_require__.r(Yi),__webpack_require__.d(Yi,{base32:()=>Xfe,base32hex:()=>tpe,base32hexpad:()=>npe,base32hexpadupper:()=>ipe,base32hexupper:()=>rpe,base32pad:()=>$fe,base32padupper:()=>epe,base32upper:()=>Zfe,base32z:()=>ope});var Qi={};__webpack_require__.r(Qi),__webpack_require__.d(Qi,{base36:()=>spe,base36upper:()=>ape});var Ji={};__webpack_require__.r(Ji),__webpack_require__.d(Ji,{base58btc:()=>cpe,base58flickr:()=>upe});var Xi={};__webpack_require__.r(Xi),__webpack_require__.d(Xi,{base64:()=>lpe,base64pad:()=>hpe,base64url:()=>dpe,base64urlpad:()=>fpe});var Zi={};__webpack_require__.r(Zi),__webpack_require__.d(Zi,{base8:()=>ppe});var $i={};__webpack_require__.r($i),__webpack_require__.d($i,{identity:()=>gpe});var eo={};__webpack_require__.r(eo),__webpack_require__.d(eo,{code:()=>vpe,decode:()=>_pe,encode:()=>wpe,name:()=>mpe});var to={};__webpack_require__.r(to),__webpack_require__.d(to,{code:()=>Spe,decode:()=>kpe,encode:()=>Ape,name:()=>Epe});var ro={};__webpack_require__.r(ro),__webpack_require__.d(ro,{identity:()=>Ype});var no={};__webpack_require__.r(no),__webpack_require__.d(no,{sha256:()=>Zpe,sha512:()=>$pe});var io=__webpack_require__(5043),oo=__webpack_require__(7950);function so(e){return so="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},so(e)}function ao(e){var t=function(e,t){if("object"!=so(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=so(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==so(t)?t:t+""}function co(e,t,r){return(t=ao(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const uo=Math.pow(2,7),lo=Math.pow(2,14),ho=Math.pow(2,21),fo=Math.pow(2,28),po=Math.pow(2,35),go=Math.pow(2,42),bo=Math.pow(2,49),yo=128,mo=127;function vo(e){if(e<uo)return 1;if(e<lo)return 2;if(e<ho)return 3;if(e<fo)return 4;if(e<po)return 5;if(e<go)return 6;if(e<bo)return 7;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function wo(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(vo(e)){case 8:t[r++]=255&e|yo,e/=128;case 7:t[r++]=255&e|yo,e/=128;case 6:t[r++]=255&e|yo,e/=128;case 5:t[r++]=255&e|yo,e/=128;case 4:t[r++]=255&e|yo,e>>>=7;case 3:t[r++]=255&e|yo,e>>>=7;case 2:t[r++]=255&e|yo,e>>>=7;case 1:t[r++]=255&e,e>>>=7;break;default:throw new Error("unreachable")}return t}function _o(e,t){let r=e[t],n=0;if(n+=r&mo,r<yo)return n;if(r=e[t+1],n+=(r&mo)<<7,r<yo)return n;if(r=e[t+2],n+=(r&mo)<<14,r<yo)return n;if(r=e[t+3],n+=(r&mo)<<21,r<yo)return n;if(r=e[t+4],n+=(r&mo)*fo,r<yo)return n;if(r=e[t+5],n+=(r&mo)*po,r<yo)return n;if(r=e[t+6],n+=(r&mo)*go,r<yo)return n;if(r=e[t+7],n+=(r&mo)*bo,r<yo)return n;throw new RangeError("Could not decode varint")}function Eo(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return null==t&&(t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}(vo(e))),t instanceof Uint8Array?wo(e,t,r):function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(vo(e)){case 8:t.set(r++,255&e|yo),e/=128;case 7:t.set(r++,255&e|yo),e/=128;case 6:t.set(r++,255&e|yo),e/=128;case 5:t.set(r++,255&e|yo),e/=128;case 4:t.set(r++,255&e|yo),e>>>=7;case 3:t.set(r++,255&e|yo),e>>>=7;case 2:t.set(r++,255&e|yo),e>>>=7;case 1:t.set(r++,255&e),e>>>=7;break;default:throw new Error("unreachable")}return t}(e,t,r)}function So(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e instanceof Uint8Array?_o(e,t):function(e,t){let r=e.get(t),n=0;if(n+=r&mo,r<yo)return n;if(r=e.get(t+1),n+=(r&mo)<<7,r<yo)return n;if(r=e.get(t+2),n+=(r&mo)<<14,r<yo)return n;if(r=e.get(t+3),n+=(r&mo)<<21,r<yo)return n;if(r=e.get(t+4),n+=(r&mo)*fo,r<yo)return n;if(r=e.get(t+5),n+=(r&mo)*po,r<yo)return n;if(r=e.get(t+6),n+=(r&mo)*go,r<yo)return n;if(r=e.get(t+7),n+=(r&mo)*bo,r<yo)return n;throw new RangeError("Could not decode varint")}(e,t)}const Ao=new Float32Array([-0]),ko=new Uint8Array(Ao.buffer);function xo(e,t,r){Ao[0]=e,t[r]=ko[0],t[r+1]=ko[1],t[r+2]=ko[2],t[r+3]=ko[3]}const Io=new Float64Array([-0]),Co=new Uint8Array(Io.buffer);function To(e,t,r){Io[0]=e,t[r]=Co[0],t[r+1]=Co[1],t[r+2]=Co[2],t[r+3]=Co[3],t[r+4]=Co[4],t[r+5]=Co[5],t[r+6]=Co[6],t[r+7]=Co[7]}const Ro=BigInt(Number.MAX_SAFE_INTEGER),Po=BigInt(Number.MIN_SAFE_INTEGER);class Do{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return No;if(e<Ro&&e>Po)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Bo&&(n=0n,++r>Bo&&(r=0n))),new Do(Number(n),Number(r))}static fromNumber(e){if(0===e)return No;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Do(r,n)}static from(e){return"number"===typeof e?Do.fromNumber(e):"bigint"===typeof e?Do.fromBigInt(e):"string"===typeof e?Do.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Do(e.low>>>0,e.high>>>0):No}}const No=new Do(0,0);No.toBigInt=function(){return 0n},No.zzEncode=No.zzDecode=function(){return this},No.length=function(){return 1};const Bo=4294967296n;function Uo(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function Lo(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function Mo(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Oo{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Lo(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw Lo(this,4);return Mo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lo(this,4);return 0|Mo(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw Lo(this,4);const e=(t=this.buf,r=this.pos,ko[0]=t[r],ko[1]=t[r+1],ko[2]=t[r+2],ko[3]=t[r+3],Ao[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Lo(this,4);const e=(t=this.buf,r=this.pos,Co[0]=t[r],Co[1]=t[r+1],Co[2]=t[r+2],Co[3]=t[r+3],Co[4]=t[r+4],Co[5]=t[r+5],Co[6]=t[r+6],Co[7]=t[r+7],Io[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Lo(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw Lo(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Lo(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new Do(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Lo(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Lo(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Lo(this,8);const e=Mo(this.buf,this.pos+=4),t=Mo(this.buf,this.pos+=4);return new Do(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function qo(e,t,r){const n=function(e){return new Oo(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function Ko(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function Fo(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Vo=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const zo=Vo;class jo{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Ho{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Wo(this,e)}}class Go{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return Wo(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function Wo(e,t){var r,n;return new Go({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Yo{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new jo(e,t,r),this.decoder=new Ho(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Qo(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Yo(t,r,n,i)}function Jo(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=zo(n,t);return Qo({prefix:r,name:t,encode:i,decode:e=>Fo(o(e))})}function Xo(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Qo({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Zo=Jo({prefix:"9",name:"base10",alphabet:"0123456789"}),$o=Xo({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),es=Xo({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ts=Xo({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),rs=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),ns=rs.reduce(((e,t,r)=>(e[r]=t,e)),[]),is=rs.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const os=Qo({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ns[t]),"")},decode:function(e){const t=[];for(const r of e){const e=is[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),ss=Xo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),as=Xo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cs=Xo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),us=Xo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ls=Xo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hs=Xo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ds=Xo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fs=Xo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ps=Xo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),gs=Jo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bs=Jo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ys=Jo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ms=Jo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),vs=Xo({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ws=Xo({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_s=Xo({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Es=Xo({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Ss=Xo({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),As=Qo({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),ks=new TextEncoder,xs=new TextDecoder,Is="json",Cs=512;function Ts(e){return ks.encode(JSON.stringify(e))}function Rs(e){return JSON.parse(xs.decode(e))}const Ps="raw",Ds=85;function Ns(e){return Fo(e)}function Bs(e){return Fo(e)}var Us=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Os;)r[n++]=255&t|Ls,t/=128;for(;t&Ms;)r[n++]=255&t|Ls,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Ls=128,Ms=-128,Os=Math.pow(2,31);var qs=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Fs)<<o:(n&Fs)*Math.pow(2,o),o+=7}while(n>=Ks);return e.bytes=s-r,i},Ks=128,Fs=127;var Vs=Math.pow(2,7),zs=Math.pow(2,14),js=Math.pow(2,21),Hs=Math.pow(2,28),Gs=Math.pow(2,35),Ws=Math.pow(2,42),Ys=Math.pow(2,49),Qs=Math.pow(2,56),Js=Math.pow(2,63);const Xs={encode:Us,decode:qs,encodingLength:function(e){return e<Vs?1:e<zs?2:e<js?3:e<Hs?4:e<Gs?5:e<Ws?6:e<Ys?7:e<Qs?8:e<Js?9:10}};function Zs(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Xs.encode(e,t,r),t}function $s(e){return Xs.encodingLength(e)}function ea(e,t){const r=t.byteLength,n=$s(e),i=n+$s(r),o=new Uint8Array(i+r);return Zs(e,o,0),Zs(r,o,n),o.set(t,i),new ta(e,r,t,o)}class ta{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const ra=Fo;const na={code:0,name:"identity",encode:ra,digest:function(e){return ea(0,ra(e))}};function ia(e){let{name:t,code:r,encode:n}=e;return new oa(t,r,n)}class oa{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ea(this.code,t):t.then((e=>ea(this.code,e)))}throw Error("Unknown type, must be binary type")}}function sa(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const aa=ia({name:"sha2-256",code:18,encode:sa("SHA-256")}),ca=ia({name:"sha2-512",code:19,encode:sa("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const ua={...u,...r,...c,...e,...t,...i,...o,...s,...a,...n};function la(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const ha=la("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),da=la("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Ko((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),fa={utf8:ha,"utf-8":ha,hex:ua.base16,latin1:da,ascii:da,binary:da,...ua};class pa{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function ga(){}class ba{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const ya=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return Ko(e);i+e>t&&(n=Ko(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class ma{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new pa(ga,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new pa(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new _a((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Ea,10,Do.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=Do.fromBigInt(e);return this._push(Ea,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=Do.fromBigInt(e).zzEncode();return this._push(Ea,t.length(),t)}sint64Number(e){const t=Do.fromNumber(e).zzEncode();return this._push(Ea,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(va,1,e?1:0)}fixed32(e){return this._push(Sa,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=Do.fromBigInt(e);return this._push(Sa,4,t.lo)._push(Sa,4,t.hi)}fixed64Number(e){const t=Do.fromNumber(e);return this._push(Sa,4,t.lo)._push(Sa,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(xo,4,e)}double(e){return this._push(To,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(va,1,0):this.uint32(t)._push(Aa,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Uo,t,e):this._push(va,1,0)}fork(){return this.states=new ba(this),this.head=this.tail=new pa(ga,0,0),this.len=0,this}reset(){return null!=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 pa(ga,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?Ko(r):ya(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function va(e,t,r){t[r]=255&e}function wa(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class _a extends pa{constructor(e,t){super(wa,e,t),co(this,"next",void 0),this.next=void 0}}function Ea(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Sa(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Aa(e,t,r){t.set(e,r)}function ka(e,t,r){t.set(e,r)}function xa(e,t,r){e.length<40?Uo(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=fa[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function Ia(e,t){const r=new ma;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Ca,Ta,Ra,Pa,Da,Na,Ba,Ua,La,Ma,Oa,qa,Ka,Fa,Va,za,ja,Ha,Ga,Wa,Ya,Qa,Ja,Xa,Za,$a,ec,tc,rc,nc,ic,oc,sc;function ac(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function cc(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return ac("enum",Ca.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}function uc(e,t){return ac("message",Ca.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(ma.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(ka,t,e),this},ma.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(xa,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(Ca||(Ca={}));Error;function lc(e){return Boolean(e)}function hc(e){const t=new Map;return e.forEach((e=>{let r=t.get(e.contentTopic);r||(t.set(e.contentTopic,[]),r=t.get(e.contentTopic)),r.push(e)})),t}!function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ta||(Ta={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Ta.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Ta.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ra||(Ra={})),function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.contentTopic=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(t=e.ContentFilter||(e.ContentFilter={})),e.codec=()=>(null==r&&(r=uc((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.subscribe&&!1!==t.subscribe&&(r.uint32(8),r.bool(t.subscribe)),null!=t.topic&&""!==t.topic&&(r.uint32(18),r.string(t.topic)),null!=t.contentFilters)for(const i of t.contentFilters)r.uint32(26),e.ContentFilter.codec().encode(i,r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={subscribe:!1,topic:"",contentFilters:[]},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.subscribe=t.bool();break;case 2:n.topic=t.string();break;case 3:n.contentFilters.push(e.ContentFilter.codec().decode(t,t.uint32()));break;default:t.skipType(7&r)}}return n}))),r),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Pa||(Pa={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.messages)for(const n of e.messages)t.uint32(10),Ua.codec().encode(n,t);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={messages:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.messages.push(Ua.codec().decode(e,e.uint32()));else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Da||(Da={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Pa.codec().encode(e.request,t)),null!=e.push&&(t.uint32(26),Da.codec().encode(e.push,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.request=Pa.codec().decode(e,e.uint32());break;case 3:r.push=Da.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Na||(Na={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ba||(Ba={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Ba.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Ba.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ua||(Ua={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===2)r.contentTopic=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(La||(La={})),function(e){let t,r,n;!function(e){e.SUBSCRIBER_PING="SUBSCRIBER_PING",e.SUBSCRIBE="SUBSCRIBE",e.UNSUBSCRIBE="UNSUBSCRIBE",e.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),function(e){e[e.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",e[e.SUBSCRIBE=1]="SUBSCRIBE",e[e.UNSUBSCRIBE=2]="UNSUBSCRIBE",e[e.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"}(r||(r={})),function(e){e.codec=()=>cc(r)}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),e.codec=()=>(null==n&&(n=uc((function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==i.lengthDelimited&&n.fork(),null!=t.requestId&&""!==t.requestId&&(n.uint32(10),n.string(t.requestId)),null!=t.filterSubscribeType&&0!==r[t.filterSubscribeType]&&(n.uint32(16),e.FilterSubscribeType.codec().encode(t.filterSubscribeType,n)),null!=t.pubsubTopic&&(n.uint32(82),n.string(t.pubsubTopic)),null!=t.contentTopics)for(const e of t.contentTopics)n.uint32(90),n.string(e);!1!==i.lengthDelimited&&n.ldelim()}),((r,n)=>{const i={requestId:"",filterSubscribeType:t.SUBSCRIBER_PING,contentTopics:[]},o=null==n?r.len:r.pos+n;for(;r.pos<o;){const t=r.uint32();switch(t>>>3){case 1:i.requestId=r.string();break;case 2:i.filterSubscribeType=e.FilterSubscribeType.codec().decode(r);break;case 10:i.pubsubTopic=r.string();break;case 11:i.contentTopics.push(r.string());break;default:r.skipType(7&t)}}return i}))),n),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ma||(Ma={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.statusCode&&0!==e.statusCode&&(t.uint32(80),t.uint32(e.statusCode)),null!=e.statusDesc&&(t.uint32(90),t.string(e.statusDesc)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:"",statusCode:0},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 10:r.statusCode=e.uint32();break;case 11:r.statusDesc=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Oa||(Oa={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.wakuMessage&&(t.uint32(10),Fa.codec().encode(e.wakuMessage,t)),null!=e.pubsubTopic&&(t.uint32(18),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.wakuMessage=Fa.codec().decode(e,e.uint32());break;case 2:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(qa||(qa={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ka||(Ka={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Ka.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Ka.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Fa||(Fa={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.pubsubTopic&&""!==e.pubsubTopic&&(t.uint32(10),t.string(e.pubsubTopic)),null!=e.message&&(t.uint32(18),Ga.codec().encode(e.message,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={pubsubTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.pubsubTopic=e.string();break;case 2:r.message=Ga.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Va||(Va={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.isSuccess&&!1!==e.isSuccess&&(t.uint32(8),t.bool(e.isSuccess)),null!=e.info&&(t.uint32(18),t.string(e.info)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={isSuccess:!1},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.isSuccess=e.bool();break;case 2:r.info=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(za||(za={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Va.codec().encode(e.request,t)),null!=e.response&&(t.uint32(26),za.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.request=Va.codec().decode(e,e.uint32());break;case 3:r.response=za.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(ja||(ja={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ha||(Ha={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Ha.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Ha.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ga||(Ga={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.digest&&e.digest.byteLength>0&&(t.uint32(10),t.bytes(e.digest)),null!=e.receiverTime&&0n!==e.receiverTime&&(t.uint32(16),t.sint64(e.receiverTime)),null!=e.senderTime&&0n!==e.senderTime&&(t.uint32(24),t.sint64(e.senderTime)),null!=e.pubsubTopic&&""!==e.pubsubTopic&&(t.uint32(34),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={digest:new Uint8Array(0),receiverTime:0n,senderTime:0n,pubsubTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.digest=e.bytes();break;case 2:r.receiverTime=e.sint64();break;case 3:r.senderTime=e.sint64();break;case 4:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Wa||(Wa={})),function(e){let t,r,n;!function(e){e.BACKWARD="BACKWARD",e.FORWARD="FORWARD"}(t=e.Direction||(e.Direction={})),function(e){e[e.BACKWARD=0]="BACKWARD",e[e.FORWARD=1]="FORWARD"}(r||(r={})),function(e){e.codec=()=>cc(r)}(t=e.Direction||(e.Direction={})),e.codec=()=>(null==n&&(n=uc((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.pageSize&&(r.uint32(8),r.uint64(t.pageSize)),null!=t.cursor&&(r.uint32(18),Wa.codec().encode(t.cursor,r)),null!=t.direction&&(r.uint32(24),e.Direction.codec().encode(t.direction,r)),!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.pageSize=t.uint64();break;case 2:n.cursor=Wa.codec().decode(t,t.uint32());break;case 3:n.direction=e.Direction.codec().decode(t);break;default:t.skipType(7&r)}}return n}))),n),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ya||(Ya={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.contentTopic=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Qa||(Qa={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.pubsubTopic&&(t.uint32(18),t.string(e.pubsubTopic)),null!=e.contentFilters)for(const n of e.contentFilters)t.uint32(26),Qa.codec().encode(n,t);null!=e.pagingInfo&&(t.uint32(34),Ya.codec().encode(e.pagingInfo,t)),null!=e.startTime&&(t.uint32(40),t.sint64(e.startTime)),null!=e.endTime&&(t.uint32(48),t.sint64(e.endTime)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentFilters:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 2:r.pubsubTopic=e.string();break;case 3:r.contentFilters.push(Qa.codec().decode(e,e.uint32()));break;case 4:r.pagingInfo=Ya.codec().decode(e,e.uint32());break;case 5:r.startTime=e.sint64();break;case 6:r.endTime=e.sint64();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Ja||(Ja={})),function(e){let t,r,n;!function(e){e.NONE="NONE",e.INVALID_CURSOR="INVALID_CURSOR"}(t=e.HistoryError||(e.HistoryError={})),function(e){e[e.NONE=0]="NONE",e[e.INVALID_CURSOR=1]="INVALID_CURSOR"}(r||(r={})),function(e){e.codec=()=>cc(r)}(t=e.HistoryError||(e.HistoryError={})),e.codec=()=>(null==n&&(n=uc((function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==i.lengthDelimited&&n.fork(),null!=t.messages)for(const e of t.messages)n.uint32(18),ec.codec().encode(e,n);null!=t.pagingInfo&&(n.uint32(26),Ya.codec().encode(t.pagingInfo,n)),null!=t.error&&0!==r[t.error]&&(n.uint32(32),e.HistoryError.codec().encode(t.error,n)),!1!==i.lengthDelimited&&n.ldelim()}),((r,n)=>{const i={messages:[],error:t.NONE},o=null==n?r.len:r.pos+n;for(;r.pos<o;){const t=r.uint32();switch(t>>>3){case 2:i.messages.push(ec.codec().decode(r,r.uint32()));break;case 3:i.pagingInfo=Ya.codec().decode(r,r.uint32());break;case 4:i.error=e.HistoryError.codec().decode(r);break;default:r.skipType(7&t)}}return i}))),n),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Xa||(Xa={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.query&&(t.uint32(18),Ja.codec().encode(e.query,t)),null!=e.response&&(t.uint32(26),Xa.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.query=Ja.codec().decode(e,e.uint32());break;case 3:r.response=Xa.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(Za||(Za={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}($a||($a={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),$a.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=$a.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(ec||(ec={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.enr&&(t.uint32(10),t.bytes(e.enr)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.enr=e.bytes();else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(tc||(tc={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.numPeers&&(t.uint32(8),t.uint64(e.numPeers)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.numPeers=e.uint64();else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(rc||(rc={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.peerInfos)for(const n of e.peerInfos)t.uint32(10),tc.codec().encode(n,t);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={peerInfos:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.peerInfos.push(tc.codec().decode(e,e.uint32()));else e.skipType(7&t)}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(nc||(nc={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.query&&(t.uint32(10),rc.codec().encode(e.query,t)),null!=e.response&&(t.uint32(18),nc.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.query=rc.codec().decode(e,e.uint32());break;case 2:r.response=nc.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(ic||(ic={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const n of e.shards)t.uint32(16),t.uint32(n);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={shards:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.clusterId=e.uint32();break;case 2:r.shards.push(e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(oc||(oc={})),function(e){let t;e.codec=()=>(null==t&&(t=uc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const n of e.shards)t.uint32(16),t.uint32(n);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={shards:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.clusterId=e.uint32();break;case 2:r.shards.push(e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ia(t,e.codec()),e.decode=t=>qo(t,e.codec())}(sc||(sc={}));async function dc(e,t,r){var n,i;const o=null!==(n=null===r||void 0===r?void 0:r.iteratorDelay)&&void 0!==n?n:60,s=[];let a;a=await e.subscribe(t,(e=>{s.push(e)}));const c=Number.isInteger(null===r||void 0===r?void 0:r.timeoutMs),u=null!==(i=null===r||void 0===r?void 0:r.timeoutMs)&&void 0!==i?i:0,l=Date.now();return{iterator:async function*(){for(;;){if(c&&Date.now()-l>=u)return;await fc(o);const e=s.shift();if(!a&&0===s.length)return e;!e&&a||(yield e)}}(),async stop(){a&&(await a(),a=void 0)}}}function fc(e){return new Promise((t=>{setTimeout(t,e)}))}const pc=e=>e.length/1048576<=1;function gc(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, not ".concat(e))}function bc(e){if(!((t=e)instanceof Uint8Array||null!=t&&"object"===typeof t&&"Uint8Array"===t.constructor.name))throw new Error("Uint8Array expected");for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];if(n.length>0&&!n.includes(e.length))throw new Error("Uint8Array expected of length ".concat(n,", not of length=").concat(e.length))}function yc(e){if("function"!==typeof e||"function"!==typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");gc(e.outputLen),gc(e.blockLen)}function mc(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function vc(e,t){bc(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least ".concat(r))}const wc="object"===typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;const _c=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ec=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const Sc=async()=>{};async function Ac(e,t,r){let n=Date.now();for(let i=0;i<e;i++){r(i);const e=Date.now()-n;e>=0&&e<t||(await Sc(),n+=e)}}function kc(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got ".concat(typeof e));return new Uint8Array((new TextEncoder).encode(e))}function xc(e){return"string"===typeof e&&(e=kc(e)),bc(e),e}function Ic(){let e=0;for(let r=0;r<arguments.length;r++){const t=r<0||arguments.length<=r?void 0:arguments[r];bc(t),e+=t.length}const t=new Uint8Array(e);for(let r=0,n=0;r<arguments.length;r++){const e=r<0||arguments.length<=r?void 0:arguments[r];t.set(e,n),n+=e.length}return t}class Cc{clone(){return this._cloneInto()}}const Tc={}.toString;function Rc(e){const t=t=>e().update(xc(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Pc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(wc&&"function"===typeof wc.getRandomValues)return wc.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}const Dc=(e,t,r)=>e&t^e&r^t&r;class Nc extends Cc{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=_c(this.buffer)}update(e){mc(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=xc(e)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0);else{const t=_c(e);for(;n<=i-o;o+=n)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){mc(this),vc(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let l=o;l<n;l++)t[l]=0;!function(e,t,r,n){if("function"===typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=_c(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<c;l++)s.setUint32(4*l,u[l],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}}const Bc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Uc=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Lc=new Uint32Array(64);class Mc extends Nc{constructor(){super(64,32,8,!1),this.A=0|Uc[0],this.B=0|Uc[1],this.C=0|Uc[2],this.D=0|Uc[3],this.E=0|Uc[4],this.F=0|Uc[5],this.G=0|Uc[6],this.H=0|Uc[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let h=0;h<16;h++,t+=4)Lc[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=Lc[h-15],t=Lc[h-2],r=Ec(e,7)^Ec(e,18)^e>>>3,n=Ec(t,17)^Ec(t,19)^t>>>10;Lc[h]=n+Lc[h-7]+r+Lc[h-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let h=0;h<64;h++){const e=u+(Ec(s,6)^Ec(s,11)^Ec(s,25))+((l=s)&a^~l&c)+Bc[h]+Lc[h]|0,t=(Ec(r,2)^Ec(r,13)^Ec(r,22))+Dc(r,n,i)|0;u=c,c=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+t|0}var l;r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){Lc.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Oc=Rc((()=>new Mc));var qc,Kc,Fc,Vc,zc,jc;!function(e){e.Relay="relay",e.Store="store",e.LightPush="lightpush",e.Filter="filter"}(qc||(qc={})),function(e){e.GENERIC_FAIL="Generic error",e.ENCODE_FAILED="Failed to encode",e.DECODE_FAILED="Failed to decode",e.EMPTY_PAYLOAD="Payload is empty",e.SIZE_TOO_BIG="Size is too big",e.TOPIC_NOT_CONFIGURED="Topic not configured",e.NO_PEER_AVAILABLE="No peer available",e.REMOTE_PEER_FAULT="Remote peer fault",e.REMOTE_PEER_REJECTED="Remote peer rejected",e.REQUEST_TIMEOUT="Request timeout"}(Kc||(Kc={})),function(e){e.BACKWARD="backward",e.FORWARD="forward"}(Fc||(Fc={})),function(e){e.BOOTSTRAP="bootstrap",e.PEER_EXCHANGE="peer-exchange",e.LOCAL="local-peer-cache"}(Vc||(Vc={})),function(e){e.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",e.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",e.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",e.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"}(zc||(zc={})),function(e){e.CONNECTION_STATUS="waku:connection"}(jc||(jc={}));const Hc="/waku/2/default-waku/proto",Gc=1;new Uint8Array(0);function Wc(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Yc=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Qc=Yc;class Jc{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Xc{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return $c(this,e)}}class Zc{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return $c(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function $c(e,t){var r,n;return new Zc({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class eu{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Jc(e,t,r),this.decoder=new Xc(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function tu(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new eu(t,r,n,i)}function ru(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Qc(n,t);return tu({prefix:r,name:t,encode:i,decode:e=>Wc(o(e))})}function nu(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return tu({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const iu=ru({prefix:"9",name:"base10",alphabet:"0123456789"}),ou=nu({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),su=nu({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),au=nu({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),cu=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),uu=cu.reduce(((e,t,r)=>(e[r]=t,e)),[]),lu=cu.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const hu=tu({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=uu[t]),"")},decode:function(e){const t=[];for(const r of e){const e=lu[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),du=nu({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fu=nu({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),pu=nu({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gu=nu({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bu=nu({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yu=nu({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mu=nu({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vu=nu({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wu=nu({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),_u=ru({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Eu=ru({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Su=ru({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Au=ru({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),ku=nu({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xu=nu({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Iu=nu({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Cu=nu({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Tu=nu({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Ru=tu({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Pu=new TextEncoder,Du=new TextDecoder,Nu="json",Bu=512;function Uu(e){return Pu.encode(JSON.stringify(e))}function Lu(e){return JSON.parse(Du.decode(e))}const Mu="raw",Ou=85;function qu(e){return Wc(e)}function Ku(e){return Wc(e)}var Fu=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=ju;)r[n++]=255&t|Vu,t/=128;for(;t&zu;)r[n++]=255&t|Vu,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Vu=128,zu=-128,ju=Math.pow(2,31);var Hu=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Wu)<<o:(n&Wu)*Math.pow(2,o),o+=7}while(n>=Gu);return e.bytes=s-r,i},Gu=128,Wu=127;var Yu=Math.pow(2,7),Qu=Math.pow(2,14),Ju=Math.pow(2,21),Xu=Math.pow(2,28),Zu=Math.pow(2,35),$u=Math.pow(2,42),el=Math.pow(2,49),tl=Math.pow(2,56),rl=Math.pow(2,63);const nl={encode:Fu,decode:Hu,encodingLength:function(e){return e<Yu?1:e<Qu?2:e<Ju?3:e<Xu?4:e<Zu?5:e<$u?6:e<el?7:e<tl?8:e<rl?9:10}};function il(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return nl.encode(e,t,r),t}function ol(e){return nl.encodingLength(e)}function sl(e,t){const r=t.byteLength,n=ol(e),i=n+ol(r),o=new Uint8Array(i+r);return il(e,o,0),il(r,o,n),o.set(t,i),new al(e,r,t,o)}class al{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const cl=Wc;const ul={code:0,name:"identity",encode:cl,digest:function(e){return sl(0,cl(e))}};function ll(e){let{name:t,code:r,encode:n}=e;return new hl(t,r,n)}class hl{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?sl(this.code,t):t.then((e=>sl(this.code,e)))}throw Error("Unknown type, must be binary type")}}function dl(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const fl=ll({name:"sha2-256",code:18,encode:dl("SHA-256")}),pl=ll({name:"sha2-512",code:19,encode:dl("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const gl={...S,...b,...E,...p,...g,...m,...v,...w,..._,...y};function bl(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const yl=bl("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ml=bl("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),vl={utf8:yl,"utf-8":yl,hex:gl.base16,latin1:ml,ascii:ml,binary:ml,...gl};function wl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=vl[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function _l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=vl[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}function El(e){if("string"===typeof e){return wl(e.replace(/^0x/i,"").toLowerCase(),"base16")}return e}const Sl=e=>_l(e,"base16"),Al=e=>_l(e,"utf8"),kl=e=>wl(e,"utf8");function xl(e,t){const r=null!==t&&void 0!==t?t:e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(r);let i=0;for(const o of e)n.set(o,i),i+=o.length;return n}const Il=e=>{if(void 0===e.clusterId||void 0===e.shard)throw new Error("Invalid shard");return"/waku/2/rs/".concat(e.clusterId,"/").concat(e.shard)},Cl=e=>{if("contentTopics"in e&&e.contentTopics)return Array.from(new Set(e.contentTopics.map((t=>Dl(t,e.clusterId)))));if("shards"in e){if(void 0===e.shards)throw new Error("Invalid shard");return Array.from(new Set(e.shards.map((t=>{var r;return"/waku/2/rs/".concat(null!==(r=e.clusterId)&&void 0!==r?r:Gc,"/").concat(t)}))))}if("application"in e&&"version"in e)return[Dl("/".concat(e.application,"/").concat(e.version,"/default/default"),e.clusterId)];throw new Error("Missing required configuration in shard parameters")},Tl=e=>{const t=e.split("/");if(6!=t.length||"waku"!==t[1]||"2"!==t[2]||"rs"!==t[3])throw new Error("Invalid pubsub topic");const r=parseInt(t[4]),n=parseInt(t[5]);if(isNaN(r)||isNaN(n))throw new Error("Invalid clusterId or shard");return{clusterId:r,shard:n}};function Rl(e,t){if(!t.includes(e))throw new Error("Pubsub topic ".concat(e," has not been configured on this instance. Configured topics are: ").concat(t,". Please update your configuration by passing in the topic during Waku node instantiation."))}function Pl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const{application:r,version:n}=function(e){const t=e.split("/");if(t.length<5||t.length>6)throw Error("Content topic format is invalid");let r=0;if(6==t.length){if(r=parseInt(t[1]),isNaN(r))throw new Error("Invalid generation field in content topic");if(r>0)throw new Error("Generation greater than 0 is not supported")}const n=t.splice(-4);if(0==n[0].length)throw new Error("Application field cannot be empty");if(0==n[1].length)throw new Error("Version field cannot be empty");if(0==n[2].length)throw new Error("Topic name field cannot be empty");if(0==n[3].length)throw new Error("Encoding field cannot be empty");return{generation:r,application:n[0],version:n[1],topicName:n[2],encoding:n[3]}}(e),i=Oc(xl([kl(r),kl(n)])),o=new DataView(i.buffer.slice(-8));return Number(o.getBigUint64(0,!1)%BigInt(t))}function Dl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gc;const r=Pl(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:8);return"/waku/2/rs/".concat(t,"/").concat(r)}function Nl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hc;return"string"==typeof t?t:t?t.shard?Il(t):Dl(e,t.clusterId):Hc}const Bl=e=>{var t;const r=null!==(t=e.clusterId)&&void 0!==t?t:Gc,n="shards"in e?e.shards:[],i="contentTopics"in e?e.contentTopics:[],[o,s]="application"in e&&"version"in e?[e.application,e.version]:[void 0,void 0],a=n&&n.length>0,c=i&&i.length>0,u=o&&s;if(a)return{shardingParams:{clusterId:r,shards:n},shardInfo:{clusterId:r,shards:n},pubsubTopics:Cl({clusterId:r,shards:n})};if(c){const e=Array.from(new Set(i.map((e=>Dl(e,r))))),t=Array.from(new Set(i.map((e=>Pl(e)))));return{shardingParams:{clusterId:r,contentTopics:i},shardInfo:{clusterId:r,shards:t},pubsubTopics:e}}if(u){const e=Dl("/".concat(o,"/").concat(s,"/default/default"),r);return{shardingParams:{clusterId:r,application:o,version:s},shardInfo:{clusterId:r,shards:[Tl(e).shard]},pubsubTopics:[e]}}throw new Error("Missing minimum required configuration options for static sharding or autosharding.")};function Ul(e,t,r){let n=e.get(t);"undefined"===typeof n&&(e.set(t,new Set),n=e.get(t)),n.add(r)}const Ll=e=>{if((e=new Uint8Array(e)).length<3)throw new Error("Insufficient data");const t=new DataView(e.buffer),r=t.getUint16(0),n=[];if(130===e.length)for(let i=0;i<1024;i++){const e=Math.floor(i/8)+2,r=7-i%8;t.getUint8(e)&1<<r&&n.push(i)}else{const r=t.getUint8(2);for(let i=0,o=3;i<r;i++,o+=2){if(o+1>=e.length)throw new Error("Unexpected end of data");n.push(t.getUint16(o))}}return{clusterId:r,shards:n}},Ml=e=>{const{clusterId:t,shards:r}=e,n=r.length>=64?130:3+2*r.length,i=new ArrayBuffer(n),o=new DataView(i);if(o.setUint16(0,t),r.length>=64)for(const s of r){const e=Math.floor(s/8)+2,t=7-s%8;o.setUint8(e,o.getUint8(e)|1<<t)}else{o.setUint8(2,r.length);for(let e=0,t=3;e<r.length;e++,t+=2)o.setUint16(t,r[e])}return new Uint8Array(i)};var Ol=__webpack_require__(6522);const ql="waku";class Kl{static createDebugNamespace(e,t){return t?"".concat(ql,":").concat(e,":").concat(t):"".concat(ql,":").concat(e)}constructor(e){co(this,"_info",void 0),co(this,"_warn",void 0),co(this,"_error",void 0),this._info=Ol(Kl.createDebugNamespace("info",e)),this._warn=Ol(Kl.createDebugNamespace("warn",e)),this._error=Ol(Kl.createDebugNamespace("error",e))}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(e){const t=this[e];for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];t(...n)}}const Fl=new Kl("message:version-0"),Vl=BigInt(1e6);class zl{constructor(e,t){co(this,"pubsubTopic",void 0),co(this,"proto",void 0),this.pubsubTopic=e,this.proto=t}get ephemeral(){return Boolean(this.proto.ephemeral)}get payload(){return this.proto.payload}get contentTopic(){return this.proto.contentTopic}get _rawTimestamp(){return this.proto.timestamp}get timestamp(){try{if(this.proto.timestamp){const e=this.proto.timestamp/Vl;return new Date(Number(e))}return}catch(e){return}}get meta(){return this.proto.meta}get version(){var e;return null!==(e=this.proto.version)&&void 0!==e?e:0}get rateLimitProof(){return this.proto.rateLimitProof}}class jl{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;if(co(this,"contentTopic",void 0),co(this,"ephemeral",void 0),co(this,"pubsubTopic",void 0),co(this,"metaSetter",void 0),this.contentTopic=e,this.ephemeral=t,this.pubsubTopic=r,this.metaSetter=n,!e||""===e)throw new Error("Content topic must be specified")}async toWire(e){return Ra.encode(await this.toProtoObj(e))}async toProtoObj(e){var t;const r=null!==(t=e.timestamp)&&void 0!==t?t:new Date,n={payload:e.payload,version:0,contentTopic:this.contentTopic,timestamp:BigInt(r.valueOf())*Vl,meta:void 0,rateLimitProof:e.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const e=this.metaSetter(n);return{...n,meta:e}}return n}}function Hl(e){let{pubsubTopic:t,pubsubTopicShardInfo:r,contentTopic:n,ephemeral:i,metaSetter:o}=e;return new jl(n,i,Nl(n,null!==t&&void 0!==t?t:r),o)}class Gl{constructor(e,t){if(co(this,"pubsubTopic",void 0),co(this,"contentTopic",void 0),this.pubsubTopic=e,this.contentTopic=t,!t||""===t)throw new Error("Content topic must be specified")}fromWireToProtoObj(e){var t,r,n,i,o;const s=Ra.decode(e);return Promise.resolve({payload:s.payload,contentTopic:s.contentTopic,version:null!==(t=s.version)&&void 0!==t?t:void 0,timestamp:null!==(r=s.timestamp)&&void 0!==r?r:void 0,meta:null!==(n=s.meta)&&void 0!==n?n:void 0,rateLimitProof:null!==(i=s.rateLimitProof)&&void 0!==i?i:void 0,ephemeral:null!==(o=s.ephemeral)&&void 0!==o&&o})}async fromProtoObj(e,t){var r;return null!==(r=t.version)&&void 0!==r&&r?(Fl.error("Failed to decode due to incorrect version, expected:",0,", actual:",t.version),Promise.resolve(void 0)):new zl(e,t)}}function Wl(e,t){return new Gl(Nl(e,t),e)}function Yl(e,t){const r=function(e,t){const r=kl(e),n=kl(t.contentTopic);let i;return i=t.meta?xl([r,t.payload,n,t.meta]):xl([r,t.payload,n]),Oc(i)}(e,t);return Al(r)}const Ql=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{const t=[];for await(const r of e)t.push(r);return t})();const t=[];for(const r of e)t.push(r);return t};function Jl(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Xl(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Zl(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=Xl(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function $l(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const eh=Symbol.for("@achingbrain/uint8arraylist");function th(e,t){if(null==t||t<0)throw new RangeError("index is out of bounds");let r=0;for(const n of e){const e=r+n.byteLength;if(t<e)return{buf:n,index:t-r};r=e}throw new RangeError("index is out of bounds")}function rh(e){return Boolean(null===e||void 0===e?void 0:e[eh])}class nh{constructor(){co(this,"bufs",void 0),co(this,"length",void 0),co(this,eh,!0),this.bufs=[],this.length=0;for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.appendAll(t)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!rh(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.prependAll(t)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!rh(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=th(this.bufs,e);return t.buf[t.index]}set(e,t){const r=th(this.bufs,e);r.buf[r.index]=t}write(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e instanceof Uint8Array)for(let r=0;r<e.length;r++)this.set(t+r,e[r]);else{if(!rh(e))throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList");for(let r=0;r<e.length;r++)this.set(t+r,e.get(r))}}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength)return this.bufs=[],void(this.length=0);for(;this.bufs.length>0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}}slice(e,t){const{bufs:r,length:n}=this._subList(e,t);return Zl(r,n)}subarray(e,t){const{bufs:r,length:n}=this._subList(e,t);return 1===r.length?r[0]:Zl(r,n)}sublist(e,t){const{bufs:r,length:n}=this._subList(e,t),i=new nh;return i.length=n,i.bufs=[...r],i}_subList(e,t){var r,n;if(e=null!==(r=e)&&void 0!==r?r:0,t=null!==(n=t)&&void 0!==n?n:this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:this.bufs,length:this.length};const i=[];let o=0;for(let s=0;s<this.bufs.length;s++){const r=this.bufs[s],n=o,a=n+r.byteLength;if(o=a,e>=a)continue;const c=e>=n&&e<a,u=t>n&&t<=a;if(c&&u){if(e===n&&t===a){i.push(r);break}const o=e-n;i.push(r.subarray(o,o+(t-e)));break}if(c){if(0===e){i.push(r);continue}i.push(r.subarray(e-n))}else{if(u){if(t===a){i.push(r);break}i.push(r.subarray(0,t-n));break}i.push(r)}}return{bufs:i,length:t-e}}indexOf(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!rh(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const n=e instanceof Uint8Array?e:e.subarray();if(r=Number(null!==(t=r)&&void 0!==t?t:0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),0===e.length)return r>this.length?this.length:r;const i=n.byteLength;if(0===i)throw new TypeError("search must be at least 1 byte long");const o=new Int32Array(256);for(let l=0;l<256;l++)o[l]=-1;for(let l=0;l<i;l++)o[n[l]]=l;const s=o,a=this.byteLength-n.byteLength,c=n.byteLength-1;let u;for(let l=r;l<=a;l+=u){u=0;for(let e=c;e>=0;e--){const t=this.get(l+e);if(n[e]!==t){u=Math.max(1,e-s[t]);break}}if(0===u)return l}return-1}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Xl(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const n=Jl(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt16(0,t,r),this.write(n,e)}getInt32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const n=Jl(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt32(0,t,r),this.write(n,e)}getBigInt64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const n=Jl(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigInt64(0,t,r),this.write(n,e)}getUint8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=Xl(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const n=Jl(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint16(0,t,r),this.write(n,e)}getUint32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const n=Jl(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(0,t,r),this.write(n,e)}getBigUint64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const n=Jl(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigUint64(0,t,r),this.write(n,e)}getFloat32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const n=Jl(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat32(0,t,r),this.write(n,e)}getFloat64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const n=Jl(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat64(0,t,r),this.write(n,e)}equals(e){if(null==e)return!1;if(!(e instanceof nh))return!1;if(e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!$l(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){const r=new nh;return r.bufs=e,null==t&&(t=e.reduce(((e,t)=>e+t.byteLength),0)),r.length=t,r}}function ih(e){return null!=e[Symbol.asyncIterator]}const oh=e=>{const t=vo(e),r=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}(t);return Eo(e,r),oh.bytes=t,r};function sh(e,t){var r,n;const i=null!==(n=(t=null!==(r=t)&&void 0!==r?r:{}).lengthEncoder)&&void 0!==n?n:oh;function*o(e){const t=i(e.byteLength);t instanceof Uint8Array?yield t:yield*t,e instanceof Uint8Array?yield e:yield*e}return ih(e)?async function*(){for await(const t of e)yield*o(t)}():function*(){for(const t of e)yield*o(t)}()}oh.bytes=0,sh.single=(e,t)=>{var r,n;const i=null!==(n=(t=null!==(r=t)&&void 0!==r?r:{}).lengthEncoder)&&void 0!==n?n:oh;return new nh(i(e.byteLength),e)};var ah=__webpack_require__(4823);var ch;!function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"}(ch||(ch={}));const uh=e=>{const t=So(e);return uh.bytes=vo(t),t};function lh(e,t){var r,n,i;const o=new nh;let s=ch.LENGTH,a=-1;const c=null!==(r=null===t||void 0===t?void 0:t.lengthDecoder)&&void 0!==r?r:uh,u=null!==(n=null===t||void 0===t?void 0:t.maxLengthLength)&&void 0!==n?n:8,l=null!==(i=null===t||void 0===t?void 0:t.maxDataLength)&&void 0!==i?i:4194304;function*h(){for(;o.byteLength>0;){if(s===ch.LENGTH)try{if(a=c(o),a<0)throw ah(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(a>l)throw ah(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");const e=c.bytes;o.consume(e),null!=(null===t||void 0===t?void 0:t.onLength)&&t.onLength(a),s=ch.DATA}catch(e){if(e instanceof RangeError){if(o.byteLength>u)throw ah(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw e}if(s===ch.DATA){if(o.byteLength<a)break;const e=o.sublist(0,a);o.consume(a),null!=(null===t||void 0===t?void 0:t.onData)&&t.onData(e),yield e,s=ch.LENGTH}}}return ih(e)?async function*(){for await(const t of e)o.append(t),yield*h();if(o.byteLength>0)throw ah(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(const t of e)o.append(t),yield*h();if(o.byteLength>0)throw ah(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}function hh(){const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}uh.bytes=0,lh.fromReader=(e,t)=>{let r=1;return lh(async function*(){for(;;)try{const{done:t,value:n}=await e.next(r);if(!0===t)return;null!=n&&(yield n)}catch(t){if("ERR_UNDER_READ"===t.code)return{done:!0,value:null};throw t}finally{r=1}}(),{...null!==t&&void 0!==t?t:{},onLength:e=>{r=e}})};class dh{constructor(e){if(co(this,"buffer",void 0),co(this,"mask",void 0),co(this,"top",void 0),co(this,"btm",void 0),co(this,"next",void 0),!(e>0)||0!==(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class fh{constructor(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};co(this,"size",void 0),co(this,"hwm",void 0),co(this,"head",void 0),co(this,"tail",void 0),this.hwm=null!==(e=t.splitLimit)&&void 0!==e?e:16,this.head=new dh(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=(null===e||void 0===e?void 0:e.byteLength)?e.byteLength:1}push(e){if(null!=(null===e||void 0===e?void 0:e.value)&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){const t=this.head;this.head=t.next=new dh(2*this.head.buffer.length),this.head.push(e)}}shift(){var e;let t=this.tail.shift();if(void 0===t&&null!=this.tail.next){const e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return null!=(null===(e=t)||void 0===e?void 0:e.value)&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}}class ph extends Error{constructor(e,t){super(null!==e&&void 0!==e?e:"The operation was aborted"),co(this,"type",void 0),co(this,"code",void 0),this.type="aborted",this.code=null!==t&&void 0!==t?t:"ABORT_ERR"}}function gh(){return bh((e=>{const t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}}),arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}function bh(e,t){var r;let n,i,o,s=(t=null!==(r=t)&&void 0!==r?r:{}).onEnd,a=new fh,c=hh();const u=e=>null!=i?i(e):(a.push(e),n),l=e=>{var r;if(o)return n;if(!0!==(null===(r=t)||void 0===r?void 0:r.objectMode)&&null==(null===e||void 0===e?void 0:e.byteLength))throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:e})},h=e=>o?n:(o=!0,null!=e?(e=>(a=new fh,null!=i?i({error:e}):(a.push({error:e}),n)))(e):u({done:!0}));if(n={[Symbol.asyncIterator](){return this},next:async()=>{try{return a.isEmpty()?o?{done:!0}:await new Promise(((t,r)=>{i=o=>{i=null,a.push(o);try{t(e(a))}catch(s){r(s)}return n}})):e(a)}finally{a.isEmpty()&&queueMicrotask((()=>{c.resolve(),c=hh()}))}},return:()=>(a=new fh,h(),{done:!0}),throw:e=>(h(e),{done:!0}),push:l,end:h,get readableLength(){return a.size},onEmpty:async e=>{const t=null===e||void 0===e?void 0:e.signal;if(null===t||void 0===t||t.throwIfAborted(),a.isEmpty())return;let r,n;null!=t&&(r=new Promise(((e,r)=>{n=()=>{r(new ph)},t.addEventListener("abort",n)})));try{await Promise.race([c.promise,r])}finally{null!=n&&null!=t&&(null===t||void 0===t||t.removeEventListener("abort",n))}}},null==s)return n;const d=n;return n={[Symbol.asyncIterator](){return this},next:()=>d.next(),throw:e=>(d.throw(e),null!=s&&(s(e),s=void 0),{done:!0}),return:()=>(d.return(),null!=s&&(s(),s=void 0),{done:!0}),push:l,end:e=>(d.end(e),null!=s&&(s(e),s=void 0),n),get readableLength(){return d.readableLength},onEmpty:e=>d.onEmpty(e)},n}const yh=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const n=[];for(const i of t)null==i[Symbol.asyncIterator]&&n.push(i);return n.length===t.length?function*(){for(const e of n)yield*e}():async function*(){const e=gh({objectMode:!0});Promise.resolve().then((async()=>{try{await Promise.all(t.map((async t=>{for await(const r of t)e.push(r)}))),e.end()}catch(r){e.end(r)}})),yield*e}()};function mh(e){if(null==e)throw new Error("Empty pipeline");if(Eh(e)){const t=e;e=()=>t.source}else if(_h(e)||wh(e)){const t=e;e=()=>t}for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];const i=[e,...r];if(i.length>1&&Eh(i[i.length-1])&&(i[i.length-1]=i[i.length-1].sink),i.length>2)for(let o=1;o<i.length-1;o++)Eh(i[o])&&(i[o]=Sh(i[o]));return vh(...i)}const vh=function(){let e;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];for(;r.length>0;)e=r.shift()(e);return e},wh=e=>null!=(null===e||void 0===e?void 0:e[Symbol.asyncIterator]),_h=e=>null!=(null===e||void 0===e?void 0:e[Symbol.iterator]),Eh=e=>null!=e&&(null!=e.sink&&null!=e.source),Sh=e=>t=>{const r=e.sink(t);if(null!=(null===r||void 0===r?void 0:r.then)){const t=gh({objectMode:!0});let n;r.then((()=>{t.end()}),(e=>{t.end(e)}));const i=e.source;if(wh(i))n=async function*(){yield*i,t.end()};else{if(!_h(i))throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");n=function*(){yield*i,t.end()}}return yh(t,n())}return e.source};class Ah{constructor(e,t,r){co(this,"multicodec",void 0),co(this,"getConnections",void 0),co(this,"addEventListener",void 0),co(this,"streamPool",void 0),co(this,"log",void 0),co(this,"handlePeerUpdateStreamPool",(e=>{const t=e.detail.peer;t.protocols.includes(this.multicodec)&&(this.log.info("Preemptively opening a stream to ".concat(t.id.toString())),this.prepareNewStream(t))})),this.multicodec=e,this.getConnections=t,this.addEventListener=r,this.log=new Kl("stream-manager:".concat(e)),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool.bind(this)),this.getStream=this.getStream.bind(this),this.streamPool=new Map}async getStream(e){const t=e.id.toString(),r=this.streamPool.get(t);if(!r)return this.newStream(e);this.streamPool.delete(t),this.prepareNewStream(e);const n=await r;return n&&"closed"!==n.status?n:this.newStream(e)}async newStream(e){const t=function(e){if(!e.length)return;if(1===e.length)return e[0];let t;return e.forEach((e=>{"open"===e.status&&(t?e.timeline.open>t.timeline.open&&(t=e):t=e)})),t}(this.getConnections(e.id));if(!t)throw new Error("Failed to get a connection to the peer");return t.newStream(this.multicodec)}prepareNewStream(e){const t=this.newStream(e).catch((()=>{this.log.error("Failed to prepare a new stream for ".concat(e.id.toString()))}));this.streamPool.set(e.id.toString(),t)}}class kh{constructor(e,t,r,n,i){co(this,"multicodec",void 0),co(this,"components",void 0),co(this,"log",void 0),co(this,"pubsubTopics",void 0),co(this,"options",void 0),co(this,"addLibp2pEventListener",void 0),co(this,"removeLibp2pEventListener",void 0),co(this,"streamManager",void 0),this.multicodec=e,this.components=t,this.log=r,this.pubsubTopics=n,this.options=i,this.addLibp2pEventListener=t.events.addEventListener.bind(t.events),this.removeLibp2pEventListener=t.events.removeEventListener.bind(t.events),this.streamManager=new Ah(e,t.connectionManager.getConnections.bind(t.connectionManager),this.addLibp2pEventListener)}async getStream(e){return this.streamManager.getStream(e)}get peerStore(){return this.components.peerStore}async allPeers(){return async function(e,t){const r=[];return await e.forEach((e=>{for(let n=0;n<t.length;n++)if(e.protocols.includes(t[n])){r.push(e);break}})),r}(this.peerStore,[this.multicodec])}async connectedPeers(){return(await this.allPeers()).filter((e=>this.components.connectionManager.getConnections(e.id).length>0))}async getPeers(){var e;let{numPeers:t,maxBootstrapPeers:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{maxBootstrapPeers:1,numPeers:0};const n=await async function(e,t,r,n){const i=e.filter((e=>"open"===e.status)).map((async e=>{const i=await t.get(e.remotePeer);if(r.some((e=>i.protocols.includes(e)))){if(!n)return i;{const e=i.metadata.get("shardInfo"),t=e&&Ll(e);if(t&&n.clusterId===t.clusterId)return i}}return null}));return(await Promise.all(i)).filter((e=>null!==e))}(this.components.connectionManager.getConnections(),this.peerStore,[this.multicodec],null!==(e=this.options)&&void 0!==e&&e.shardInfo?Bl(this.options.shardInfo).shardInfo:void 0),i=function(e,t,r){let n=e.filter((e=>e.tags.has(Vc.BOOTSTRAP))).slice(0,r);t>0&&t<n.length&&(n=n.slice(0,t));const i=e.filter((e=>!e.tags.has(Vc.BOOTSTRAP)));if(0===t)return[...n,...i];const o=[...n];for(;o.length<t&&i.length>0;){const e=Math.floor(Math.random()*i.length),t=i.splice(e,1)[0];o.push(t)}return o}(n,t,r),o=await async function(e,t){return 0===t.length?[]:(await Promise.all(t.map((async t=>{try{const r=(await e.get(t.id)).metadata.get("ping");return r?{peer:t,ping:Number(Al(r))}:{peer:t,ping:1/0}}catch(r){return{peer:t,ping:1/0}}})))).filter((e=>null!==e)).sort(((e,t)=>e.ping-t.ping)).map((e=>e.peer))}(this.peerStore,i);return 0===o.length&&this.log.warn("No peers found. Ensure you have a connection to the network."),o.length<t&&this.log.warn("Only ".concat(o.length," peers found. Requested ").concat(t,".")),o}}const xh={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Ih;const Ch=new Uint8Array(16);function Th(){if(!Ih&&(Ih="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ih))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ih(Ch)}const Rh=[];for(let bbe=0;bbe<256;++bbe)Rh.push((bbe+256).toString(16).slice(1));function Ph(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Rh[e[t+0]]+Rh[e[t+1]]+Rh[e[t+2]]+Rh[e[t+3]]+"-"+Rh[e[t+4]]+Rh[e[t+5]]+"-"+Rh[e[t+6]]+Rh[e[t+7]]+"-"+Rh[e[t+8]]+Rh[e[t+9]]+"-"+Rh[e[t+10]]+Rh[e[t+11]]+Rh[e[t+12]]+Rh[e[t+13]]+Rh[e[t+14]]+Rh[e[t+15]]}const Dh=function(e,t,r){if(xh.randomUUID&&!t&&!e)return xh.randomUUID();const n=(e=e||{}).random||(e.rng||Th)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return Ph(n)};class Nh{constructor(e){co(this,"proto",void 0),this.proto=e}static decode(e){const t=qa.decode(e);return new Nh(t)}encode(){return qa.encode(this.proto)}get wakuMessage(){return this.proto.wakuMessage}get pubsubTopic(){return this.proto.pubsubTopic}}class Bh{constructor(e){co(this,"proto",void 0),this.proto=e}static createSubscribeRequest(e,t){return new Bh({requestId:Dh(),filterSubscribeType:Ma.FilterSubscribeType.SUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeRequest(e,t){return new Bh({requestId:Dh(),filterSubscribeType:Ma.FilterSubscribeType.UNSUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeAllRequest(e){return new Bh({requestId:Dh(),filterSubscribeType:Ma.FilterSubscribeType.UNSUBSCRIBE_ALL,pubsubTopic:e,contentTopics:[]})}static createSubscriberPingRequest(){return new Bh({requestId:Dh(),filterSubscribeType:Ma.FilterSubscribeType.SUBSCRIBER_PING,pubsubTopic:"",contentTopics:[]})}static decode(e){const t=Ma.decode(e);return new Bh(t)}encode(){return Ma.encode(this.proto)}get filterSubscribeType(){return this.proto.filterSubscribeType}get requestId(){return this.proto.requestId}get pubsubTopic(){return this.proto.pubsubTopic}get contentTopics(){return this.proto.contentTopics}}class Uh{constructor(e){co(this,"proto",void 0),this.proto=e}static decode(e){const t=Oa.decode(e);return new Uh(t)}encode(){return Oa.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get requestId(){return this.proto.requestId}}const Lh=new Kl("filter:v2"),Mh="/vac/waku/filter-subscribe/2.0.0-beta1",Oh="/vac/waku/filter-push/2.0.0-beta1";class qh{constructor(e,t,r){co(this,"peers",void 0),co(this,"pubsubTopic",void 0),co(this,"newStream",void 0),co(this,"receivedMessagesHashStr",[]),co(this,"subscriptionCallbacks",void 0),this.peers=t,this.pubsubTopic=e,this.newStream=r,this.subscriptionCallbacks=new Map}async subscribe(e,t){const r=Array.isArray(e)?e:[e];r.forEach((e=>{if(e.pubsubTopic!==this.pubsubTopic)throw new Error("Pubsub topic not configured: decoder is configured for pubsub topic ".concat(e.pubsubTopic," but this subscription is for pubsub topic ").concat(this.pubsubTopic,". Please create a new Subscription for the different pubsub topic."))}));const n=hc(r),i=Array.from(n.keys()),o=this.peers.map((async e=>{const t=await this.newStream(e),r=Bh.createSubscribeRequest(this.pubsubTopic,i);try{const n=await mh([r.encode()],sh,t,lh,(async e=>await Ql(e)));if(!n||!n.length)throw Error("No response received for request ".concat(r.requestId,": ").concat(n));const{statusCode:o,requestId:s,statusDesc:a}=Uh.decode(n[0].slice());if(o<200||o>=300)throw new Error("Filter subscribe request ".concat(s," failed with status code ").concat(o,": ").concat(a));Lh.info("Subscribed to peer ",e.id.toString(),"for content topics",i)}catch(n){throw new Error("Error subscribing to peer: "+e.id.toString()+" for content topics: "+i+": "+n)}})),s=await Promise.allSettled(o);this.handleErrors(s,"subscribe"),n.forEach(((e,r)=>{const n={decoders:e,callback:t};this.subscriptionCallbacks.set(r,n)}))}async unsubscribe(e){const t=this.peers.map((async t=>{const r=await this.newStream(t),n=Bh.createUnsubscribeRequest(this.pubsubTopic,e);try{await mh([n.encode()],sh,r.sink)}catch(i){throw new Error("Error unsubscribing: "+i)}e.forEach((e=>{this.subscriptionCallbacks.delete(e)}))})),r=await Promise.allSettled(t);this.handleErrors(r,"unsubscribe")}async ping(){const e=this.peers.map((async e=>{const t=await this.newStream(e),r=Bh.createSubscriberPingRequest();try{const n=await mh([r.encode()],sh,t,lh,(async e=>await Ql(e)));if(!n||!n.length)throw Error("No response received for request ".concat(r.requestId,": ").concat(n));const{statusCode:i,requestId:o,statusDesc:s}=Uh.decode(n[0].slice());if(i<200||i>=300)throw new Error("Filter ping request ".concat(o," failed with status code ").concat(i,": ").concat(s));Lh.info("Ping successful for peer ".concat(e.id.toString()))}catch(n){throw Lh.error("Error pinging: ",n),n}})),t=await Promise.allSettled(e);this.handleErrors(t,"ping")}async unsubscribeAll(){const e=this.peers.map((async e=>{const t=await this.newStream(e),r=Bh.createUnsubscribeAllRequest(this.pubsubTopic);try{const e=await mh([r.encode()],sh,t,lh,(async e=>await Ql(e)));if(!e||!e.length)throw Error("No response received for request ".concat(r.requestId,": ").concat(e));const{statusCode:n,requestId:i,statusDesc:o}=Uh.decode(e[0].slice());if(n<200||n>=300)throw new Error("Filter unsubscribe all request ".concat(i," failed with status code ").concat(n,": ").concat(o));this.subscriptionCallbacks.clear(),Lh.info("Unsubscribed from all content topics for pubsub topic ".concat(this.pubsubTopic))}catch(n){throw new Error("Error unsubscribing from all content topics: "+n)}})),t=await Promise.allSettled(e);this.handleErrors(t,"unsubscribeAll")}async processMessage(e){const t=Yl(this.pubsubTopic,e);if(this.receivedMessagesHashStr.includes(t))return void Lh.info("Message already received, skipping");this.receivedMessagesHashStr.push(t);const{contentTopic:r}=e,n=this.subscriptionCallbacks.get(r);n?(Lh.info("Processing message with content topic ",r," on pubsub topic ",this.pubsubTopic),await async function(e,t,r){const{decoders:n,callback:i}=e,{contentTopic:o}=r;if(!o)return void Lh.warn("Message has no content topic, skipping");try{const e=n.map((e=>e.fromProtoObj(t,r).then((e=>e||Promise.reject("Decoding failed"))))),o=await Promise.any(e);await i(o)}catch(s){Lh.error("Error decoding message",s)}}(n,this.pubsubTopic,e)):Lh.error("No subscription callback available for ",r)}handleErrors(e,t){const r=e.filter((e=>"rejected"===e.status)).map((e=>e.reason));if(r.length===this.peers.length){const e=new Map;r.forEach((t=>{const r=t instanceof Error?t.message:String(t);e.set(r,(e.get(r)||0)+1)}));const n=Array.from(e,(e=>{let[t,r]=e;return"".concat(t," (occurred ").concat(r," times)")})).join(", ");throw new Error("Error ".concat(t," all peers: ").concat(n))}r.length>0?Lh.warn("Some ".concat(t," failed. These will be refreshed with new peers"),r):Lh.info("".concat(t," successful for all peers"))}}class Kh extends kh{getActiveSubscription(e){return this.activeSubscriptions.get(e)}setActiveSubscription(e,t){return this.activeSubscriptions.set(e,t),t}constructor(e,t){var r;super(Mh,e.components,Lh,t.pubsubTopics,t),co(this,"activeSubscriptions",new Map),co(this,"numPeersToUse",void 0),this.numPeersToUse=null!==(r=null===t||void 0===t?void 0:t.numPeersToUse)&&void 0!==r?r:3,e.handle(Oh,this.onRequest.bind(this)).catch((e=>{Lh.error("Failed to register ",Oh,e)})),this.activeSubscriptions=new Map}async createSubscription(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Hc;const r="string"==typeof t?t:Il(t);Rl(r,this.pubsubTopics);const n=await this.getPeers({maxBootstrapPeers:1,numPeers:this.numPeersToUse});if(0===n.length)throw new Error("No peer found to initiate subscription.");Lh.info("Creating filter subscription with ".concat(n.length," peers: "),n.map((e=>e.id.toString())));return null!==(e=this.getActiveSubscription(r))&&void 0!==e?e:this.setActiveSubscription(r,new qh(r,n,this.getStream.bind(this)))}toSubscriptionIterator(e){return dc(this,e)}async subscribe(e,t){const r=await this.createSubscription();await r.subscribe(e,t);const n=Array.from(hc(Array.isArray(e)?e:[e]).keys());return async()=>{await r.unsubscribe(n)}}onRequest(e){const{connection:t,stream:r}=e,{remotePeer:n}=t;Lh.info("Received message from ".concat(n.toString()));try{mh(r,lh,(async e=>{for await(const t of e){const e=Nh.decode(t.slice()),{pubsubTopic:r,wakuMessage:n}=e;if(!n)return void Lh.error("Received empty message");if(!r)return void Lh.error("Pubsub topic missing from push message");const i=this.getActiveSubscription(r);if(!i)return void Lh.error("No subscription locally registered for topic ".concat(r));await i.processMessage(n)}})).then((()=>{Lh.info("Receiving pipe closed.")}),(e=>{Lh.error("Error with receiving pipe",e)}))}catch(i){Lh.error("Error decoding message",i)}}}class Fh{constructor(e){co(this,"proto",void 0),this.proto=e}static createRequest(e,t){return new Fh({requestId:Dh(),request:{message:e,pubsubTopic:t},response:void 0})}static decode(e){const t=ja.decode(e);return new Fh(t)}encode(){return ja.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const Vh=new Kl("light-push");class zh extends kh{constructor(e,t){super("/vac/waku/lightpush/2.0.0-beta1",e.components,Vh,t.pubsubTopics,t)}async preparePushMessage(e,t){try{if(!t.payload||0===t.payload.length)return Vh.error("Failed to send waku light push: payload is empty"),{query:null,error:Kc.EMPTY_PAYLOAD};if(!await async function(e,t){const r=await e.toWire(t);return!!r&&pc(r)}(e,t))return Vh.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:Kc.SIZE_TOO_BIG};const r=await e.toProtoObj(t);if(!r)return Vh.error("Failed to encode to protoMessage, aborting push"),{query:null,error:Kc.ENCODE_FAILED};return{query:Fh.createRequest(r,e.pubsubTopic),error:null}}catch(r){return Vh.error("Failed to prepare push message",r),{query:null,error:Kc.GENERIC_FAIL}}}async send(e,t,r){const{query:n,error:i}=await this.preparePushMessage(e,t);if(i||!n)return{success:null,failure:{error:i,peerId:r.id}};let o,s;try{o=await this.getStream(r)}catch(u){return Vh.error("Failed to get a stream for remote peer".concat(r.id.toString()),u),{success:null,failure:{error:Kc.REMOTE_PEER_FAULT,peerId:r.id}}}try{s=await mh([n.encode()],sh,o,lh,(async e=>await Ql(e)))}catch(u){return Vh.error("Failed to send waku light push request",u),{success:null,failure:{error:Kc.GENERIC_FAIL,peerId:r.id}}}const a=new nh;let c;s.forEach((e=>{a.append(e)}));try{c=Fh.decode(a).response}catch(u){return Vh.error("Failed to decode push reply",u),{success:null,failure:{error:Kc.DECODE_FAILED,peerId:r.id}}}return c?c.isSuccess?{success:r.id,failure:null}:(Vh.error("Remote peer rejected the message: ",c.info),{success:null,failure:{error:Kc.REMOTE_PEER_REJECTED,peerId:r.id}}):(Vh.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:Kc.REMOTE_PEER_FAULT,peerId:r.id}})}}const jh={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};const Hh=BigInt(1e6);var Gh;!function(e){e.BACKWARD="backward",e.FORWARD="forward"}(Gh||(Gh={}));class Wh{constructor(e){co(this,"proto",void 0),this.proto=e}get query(){return this.proto.query}get response(){return this.proto.response}static createQuery(e){const t=e.contentTopics.map((e=>({contentTopic:e}))),r=function(e){switch(e){case Gh.BACKWARD:return Ya.Direction.BACKWARD;case Gh.FORWARD:return Ya.Direction.FORWARD;default:return Ya.Direction.BACKWARD}}(e.pageDirection),n={pageSize:BigInt(e.pageSize),cursor:e.cursor,direction:r};let i,o;return e.startTime&&(i=BigInt(e.startTime.valueOf())*Hh),e.endTime&&(o=BigInt(e.endTime.valueOf())*Hh),new Wh({requestId:Dh(),query:{pubsubTopic:e.pubsubTopic,contentFilters:t,pagingInfo:n,startTime:i,endTime:o},response:void 0})}decode(e){const t=Za.decode(e);return new Wh(t)}encode(){return Za.encode(this.proto)}}var Yh=Xa.HistoryError;const Qh=new Kl("store");class Jh extends kh{constructor(e,t){super("/vac/waku/store/2.0.0-beta4",e.components,Qh,t.pubsubTopics,t)}async*queryPerPage(e,t,r){if(e.contentTopics.toString()!==Array.from(t.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let n=e.cursor;for(;;){var i,o,s;e.cursor=n;const a=Wh.createQuery(e),c=await this.getStream(r),u=await mh([a.encode()],sh,c,lh,(async e=>await Ql(e))),l=new nh;u.forEach((e=>{l.append(e)}));const h=a.decode(l);if(!h.response){Qh.warn("Stopping pagination due to store `response` field missing");break}const d=h.response;if(d.error&&d.error!==Yh.NONE)throw"History response contains an Error: "+d.error;if(!d.messages||!d.messages.length){Qh.warn("Stopping pagination due to store `response.messages` field missing or empty");break}Qh.error("".concat(d.messages.length," messages retrieved from store")),yield d.messages.map((r=>{const n=r.contentTopic;if("undefined"!==typeof n){const o=t.get(n);if(o)return o.fromProtoObj(e.pubsubTopic,(i=r,{...jh,...i}))}var i;return Promise.resolve(void 0)}));const f=null===(i=d.pagingInfo)||void 0===i?void 0:i.cursor;if("undefined"===typeof f){Qh.warn("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");break}n=f;const p=null===(o=d.pagingInfo)||void 0===o?void 0:o.pageSize,g=null===(s=a.query)||void 0===s||null===(s=s.pagingInfo)||void 0===s?void 0:s.pageSize;if(p&&g&&p<g)break}}}class Xh extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Zh extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const $h=e=>void 0===globalThis.DOMException?new Zh(e):new DOMException(e),ed=e=>{const t=void 0===e.reason?$h("This operation was aborted."):e.reason;return t instanceof Error?t:$h(t)};function td(e,t){const{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout:setTimeout,clearTimeout:clearTimeout}}=t;let s;const a=new Promise(((a,c)=>{if("number"!==typeof r||1!==Math.sign(r))throw new TypeError("Expected `milliseconds` to be a positive number, got `".concat(r,"`"));if(t.signal){const{signal:e}=t;e.aborted&&c(ed(e)),e.addEventListener("abort",(()=>{c(ed(e))}))}if(r===Number.POSITIVE_INFINITY)return void e.then(a,c);const u=new Xh;s=o.setTimeout.call(void 0,(()=>{if(n)try{a(n())}catch(t){c(t)}else"function"===typeof e.cancel&&e.cancel(),!1===i?a():i instanceof Error?c(i):(u.message=null!==i&&void 0!==i?i:"Promise timed out after ".concat(r," milliseconds"),c(u))}),r),(async()=>{try{a(await e)}catch(t){c(t)}})()})).finally((()=>{a.clear()}));return a.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},a}const rd=e=>{const t=e.addEventListener||e.on||e.addListener,r=e.removeEventListener||e.off||e.removeListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function nd(e,t,r){"function"===typeof r&&(r={filter:r});const n=function(e,t,r){let n;const i=new Promise(((i,o)=>{var s;if(!((r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r}).count>=0)||r.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(r.count))throw new TypeError("The `count` option should be at least 0 or more");null===(s=r.signal)||void 0===s||s.throwIfAborted();const a=[t].flat(),c=[],{addListener:u,removeListener:l}=rd(e),h=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];const s=r.multiArgs?t:t[0];r.filter&&!r.filter(s)||(c.push(s),r.count===c.length&&(n(),i(c)))},d=e=>{n(),o(e)};n=()=>{for(const e of a)l(e,h);for(const e of r.rejectionEvents)l(e,d)};for(const e of a)u(e,h);for(const e of r.rejectionEvents)u(e,d);r.signal&&r.signal.addEventListener("abort",(()=>{d(r.signal.reason)}),{once:!0}),r.resolveImmediately&&i(c)}));if(i.cancel=n,"number"===typeof r.timeout){const e=td(i,{milliseconds:r.timeout});return e.cancel=n,e}return i}(e,t,r={...r,count:1,resolveImmediately:!1}),i=n.then((e=>e[0]));return i.cancel=n.cancel,i}const id=new Kl("wait-for-remote-peer");async function od(e,t,r){var n;if(t=null!==(n=t)&&void 0!==n?n:function(e){const t=[];e.relay&&t.push(qc.Relay);e.filter&&t.push(qc.Filter);e.store&&t.push(qc.Store);e.lightPush&&t.push(qc.LightPush);return t}(e),!e.isStarted())return Promise.reject("Waku node is not started");const i=[];if(t.includes(qc.Relay)){if(!e.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");i.push(async function(e){let t=e.getMeshPeers();const r=e.pubsubTopics;for(const n of r)for(;0==t.length;)await nd(e.gossipSub,"gossipsub:heartbeat"),t=e.getMeshPeers(n)}(e.relay))}if(t.includes(qc.Store)){if(!e.store)throw new Error("Cannot wait for Store peer: protocol not mounted");i.push(sd(e.store.protocol,e.libp2p.services.metadata))}if(t.includes(qc.LightPush)){if(!e.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");i.push(sd(e.lightPush.protocol,e.libp2p.services.metadata))}if(t.includes(qc.Filter)){if(!e.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");i.push(sd(e.filter,e.libp2p.services.metadata))}r?await async function(e,t,r){await Promise.race([e,ad(t,r)])}(Promise.all(i),r,"Timed out waiting for a remote peer."):await Promise.all(i)}async function sd(e,t){const r=e.multicodec,n=await e.connectedPeers();if(n.length){if(!t)return void id.info("".concat(r," peer found: "),n[0].id.toString());try{return void await Promise.any(n.map((e=>t.confirmOrAttemptHandshake(e.id))))}catch(i){"ERR_CONNECTION_BEING_CLOSED"===i.code&&id.error("Connection with the peer was closed and possibly because it's on a different shard. Error: ".concat(i)),id.error("Error waiting for handshake confirmation: ".concat(i))}}id.info("Waiting for ".concat(r," peer")),await new Promise((n=>{const i=o=>{var s;null!==(s=o.detail)&&void 0!==s&&null!==(s=s.protocols)&&void 0!==s&&s.includes(r)&&(t?t.confirmOrAttemptHandshake(o.detail.peerId).then((()=>{e.removeLibp2pEventListener("peer:identify",i),n()})).catch((e=>{"ERR_CONNECTION_BEING_CLOSED"===e.code&&id.error("Connection with the peer was closed and possibly because it's on a different shard. Error: ".concat(e)),id.error("Error waiting for handshake confirmation: ".concat(e))})):(e.removeLibp2pEventListener("peer:identify",i),n()))};e.addLibp2pEventListener("peer:identify",i)}))}const ad=(e,t)=>new Promise(((r,n)=>setTimeout((()=>n(t)),e)));function cd(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ud(e,t,r){cd(e,t),t.set(e,r)}function ld(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function hd(e,t){return e.get(ld(e,t))}const dd=function(e){try{for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]}catch{}};var fd,pd=new WeakMap;class gd extends EventTarget{constructor(){super(),ud(this,pd,new Map),dd(1/0,this)}listenerCount(e){const t=hd(pd,this).get(e);return null==t?0:t.length}addEventListener(e,t,r){var n;super.addEventListener(e,t,r);let i=hd(pd,this).get(e);null==i&&(i=[],hd(pd,this).set(e,i)),i.push({callback:t,once:null!==(n=!0!==r&&!1!==r&&(null===r||void 0===r?void 0:r.once))&&void 0!==n&&n})}removeEventListener(e,t,r){super.removeEventListener(e.toString(),null!==t&&void 0!==t?t:null,r);let n=hd(pd,this).get(e);null!=n&&(n=n.filter((e=>{let{callback:r}=e;return r!==t})),hd(pd,this).set(e,n))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=hd(pd,this).get(e.type);return null==r||(r=r.filter((e=>{let{once:t}=e;return!t})),hd(pd,this).set(e.type,r)),t}safeDispatchEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dispatchEvent(new yd(e,t))}}class bd extends Event{constructor(e,t){super(e,t),co(this,"detail",void 0),this.detail=null===t||void 0===t?void 0:t.detail}}const yd=null!==(fd=globalThis.CustomEvent)&&void 0!==fd?fd:bd,md=new Kl("keep-alive");class vd{constructor(e,t){co(this,"pingKeepAliveTimers",void 0),co(this,"relayKeepAliveTimers",void 0),co(this,"options",void 0),co(this,"relay",void 0),this.pingKeepAliveTimers=new Map,this.relayKeepAliveTimers=new Map,this.options=e,this.relay=t}start(e,t,r){this.stop(e);const{pingKeepAlive:n,relayKeepAlive:i}=this.options,o=e.toString();if(0!==n){const i=setInterval((()=>{(async()=>{let i;try{try{i=await t.ping(e),md.info("Ping succeeded (".concat(o,")"),i)}catch(s){return void md.error("Ping failed for peer (".concat(o,").\n Next ping will be attempted in ").concat(n," seconds.\n "))}try{await r.patch(e,{metadata:{ping:kl(i.toString())}})}catch(a){md.error("Failed to update ping",a)}}catch(a){md.error("Ping failed (".concat(o,")"),a)}})()}),1e3*n);this.pingKeepAliveTimers.set(o,i)}const s=this.relay;if(s&&0!==i){const t=this.scheduleRelayPings(s,i,e.toString());this.relayKeepAliveTimers.set(e,t)}}stop(e){const t=e.toString();var r;(this.pingKeepAliveTimers.has(t)&&(clearInterval(this.pingKeepAliveTimers.get(t)),this.pingKeepAliveTimers.delete(t)),this.relayKeepAliveTimers.has(e))&&(null===(r=this.relayKeepAliveTimers.get(e))||void 0===r||r.map(clearInterval),this.relayKeepAliveTimers.delete(e))}stopAll(){for(const e of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(e);this.pingKeepAliveTimers.clear(),this.relayKeepAliveTimers.clear()}connectionsExist(){return this.pingKeepAliveTimers.size>0||this.relayKeepAliveTimers.size>0}scheduleRelayPings(e,t,r){const n=[];for(const i of e.pubsubTopics){if(!e.getMeshPeers(i).includes(r))continue;const o=Hl({pubsubTopicShardInfo:Tl(i),contentTopic:"/relay-ping/1/ping/null",ephemeral:!0}),s=setInterval((()=>{md.info("Sending Waku Relay ping message"),e.send(o,{payload:new Uint8Array([1])}).catch((e=>md.error("Failed to send relay ping",e)))}),1e3*t);n.push(s)}return n}}const wd=new Kl("connection-manager");class _d extends gd{isConnected(){return this.online}toggleOnline(){this.online||(this.online=!0,this.dispatchEvent(new yd(jc.CONNECTION_STATUS,{detail:this.online})))}toggleOffline(){this.online&&0==this.libp2p.getConnections().length&&(this.online=!1,this.dispatchEvent(new yd(jc.CONNECTION_STATUS,{detail:this.online})))}static create(e,t,r,n,i,o){let s=_d.instances.get(e);return s||(s=new _d(t,r,n,i,o),_d.instances.set(e,s)),s}async getPeersByDiscovery(){const e=await this.libp2p.peerStore.all(),t=this.libp2p.getConnections().map((e=>e.remotePeer)),r=[],n=[],i=[],o=[],s=[],a=[];for(const c of e){const e=await this.getTagNamesForPeer(c.id);e.includes(Vc.BOOTSTRAP)?r.push(c):e.includes(Vc.PEER_EXCHANGE)?n.push(c):e.includes(Vc.LOCAL)&&i.push(c)}for(const c of t){const e=await this.libp2p.peerStore.get(c),t=await this.getTagNamesForPeer(c);t.includes(Vc.BOOTSTRAP)?o.push(e):t.includes(Vc.PEER_EXCHANGE)?s.push(e):t.includes(Vc.LOCAL)&&a.push(e)}return{DISCOVERED:{[Vc.BOOTSTRAP]:r,[Vc.PEER_EXCHANGE]:n,[Vc.LOCAL]:i},CONNECTED:{[Vc.BOOTSTRAP]:o,[Vc.PEER_EXCHANGE]:s,[Vc.LOCAL]:a}}}constructor(e,t,r,n,i){super(),co(this,"configuredPubsubTopics",void 0),co(this,"keepAliveManager",void 0),co(this,"options",void 0),co(this,"libp2p",void 0),co(this,"dialAttemptsForPeer",new Map),co(this,"dialErrorsForPeer",new Map),co(this,"currentActiveParallelDialCount",0),co(this,"pendingPeerDialQueue",[]),co(this,"online",!1),co(this,"onEventHandlers",{"peer:discovery":e=>{(async()=>{const{id:t}=e.detail;await this.dispatchDiscoveryEvent(t);try{await this.attemptDial(t)}catch(r){wd.error("Error dialing peer ".concat(t.toString()," : ").concat(r))}})()},"peer:connect":e=>{(async()=>{wd.info("Connected to peer ".concat(e.detail.toString()));const t=e.detail;this.keepAliveManager.start(t,this.libp2p.services.ping,this.libp2p.peerStore);if((await this.getTagNamesForPeer(t)).includes(Vc.BOOTSTRAP)){this.libp2p.getConnections().filter((e=>e.tags.includes(Vc.BOOTSTRAP))).length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(t):this.dispatchEvent(new yd(zc.PEER_CONNECT_BOOTSTRAP,{detail:t}))}else this.dispatchEvent(new yd(zc.PEER_CONNECT_PEER_EXCHANGE,{detail:t}));this.toggleOnline()})()},"peer:disconnect":e=>{(async()=>{this.keepAliveManager.stop(e.detail),this.toggleOffline()})()}}),this.configuredPubsubTopics=r,this.libp2p=e,this.configuredPubsubTopics=r,this.options={maxDialAttemptsForPeer:3,maxBootstrapPeersAllowed:1,maxParallelDials:3,...i},this.keepAliveManager=new vd(t,n),this.run().then((()=>wd.info("Connection Manager is now running"))).catch((e=>wd.error("Unexpected error while running service",e))),this.dialPeerStorePeers().catch((e=>wd.error("Unexpected error while dialing peer store peers",e)))}async dialPeerStorePeers(){const e=await this.libp2p.peerStore.all(),t=[];for(const n of e)this.libp2p.getConnections().find((e=>e.remotePeer===n.id))||t.push(this.attemptDial(n.id));try{await Promise.all(t)}catch(r){wd.error("Unexpected error while dialing peer store peers",r)}}async run(){this.startPeerDiscoveryListener(),this.startPeerConnectionListener(),this.startPeerDisconnectionListener()}stop(){this.keepAliveManager.stopAll(),this.libp2p.removeEventListener("peer:connect",this.onEventHandlers["peer:connect"]),this.libp2p.removeEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"]),this.libp2p.removeEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}async dialPeer(e){this.currentActiveParallelDialCount+=1;let t=0;for(;t<this.options.maxDialAttemptsForPeer;)try{wd.info("Dialing peer ".concat(e.toString()," on attempt ").concat(t+1)),await this.libp2p.dial(e);const r=await this.getTagNamesForPeer(e);this.libp2p.getConnections(e).forEach((e=>{e.tags=Array.from(new Set([...e.tags,...r]))})),this.dialAttemptsForPeer.set(e.toString(),-1);break}catch(r){r instanceof AggregateError?wd.error("Error dialing peer ".concat(e.toString()," - ").concat(r.errors)):wd.error("Error dialing peer ".concat(e.toString()," - ").concat(r.message)),this.dialErrorsForPeer.set(e.toString(),r),t++,this.dialAttemptsForPeer.set(e.toString(),t)}if(this.currentActiveParallelDialCount--,this.processDialQueue(),t===this.options.maxDialAttemptsForPeer)try{const t=this.dialErrorsForPeer.get(e.toString());if(t){let r;t instanceof AggregateError?t.errors?0===t.errors.length?wd.warn("Errors array is empty for AggregateError"):r=JSON.stringify(t.errors[0]):wd.warn("No errors array found for AggregateError"):r=t.message,wd.info("Deleting undialable peer ".concat(e.toString()," from peer store. Reason: ").concat(r))}this.dialErrorsForPeer.delete(e.toString()),await this.libp2p.peerStore.delete(e)}catch(r){throw new Error("Error deleting undialable peer ".concat(e.toString()," from peer store - ").concat(r))}}async dropConnection(e){try{this.keepAliveManager.stop(e),await this.libp2p.hangUp(e),wd.info("Dropped connection with peer ".concat(e.toString()))}catch(t){wd.error("Error dropping connection with peer ".concat(e.toString()," - ").concat(t))}}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveParallelDialCount<this.options.maxParallelDials){const e=this.pendingPeerDialQueue.shift();if(!e)return;this.attemptDial(e).catch((e=>{wd.error(e)}))}}startPeerDiscoveryListener(){this.libp2p.addEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}startPeerConnectionListener(){this.libp2p.addEventListener("peer:connect",this.onEventHandlers["peer:connect"])}startPeerDisconnectionListener(){this.libp2p.addEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"])}async attemptDial(e){await this.shouldDialPeer(e)&&(this.currentActiveParallelDialCount>=this.options.maxParallelDials?this.pendingPeerDialQueue.push(e):this.dialPeer(e).catch((t=>{wd.error("Error dialing peer ".concat(e.toString()," : ").concat(t))})))}async shouldDialPeer(e){if(this.libp2p.getConnections(e).length>0)return wd.warn("Already connected to peer ".concat(e.toString(),". Not dialing.")),!1;if(!await this.isPeerTopicConfigured(e)){const t=await this.getPeerShardInfo(e,this.libp2p.peerStore);return wd.warn("Discovered peer ".concat(e.toString()," with ShardInfo ").concat(t," is not part of any of the configured pubsub topics (").concat(this.configuredPubsubTopics,").\n Not dialing.")),!1}return await this.isPeerDialableBasedOnBootstrapStatus(e)?!this.dialAttemptsForPeer.has(e.toString())||(wd.warn("Peer ".concat(e.toString()," has already been attempted dial before, or already has a dial attempt in progress, skipping dial")),!1):(wd.warn("Peer ".concat(e.toString()," is not dialable based on bootstrap status. Not dialing.")),!1)}async isPeerDialableBasedOnBootstrapStatus(e){if(!(await this.getTagNamesForPeer(e)).some((e=>e===Vc.BOOTSTRAP)))return!0;if(this.libp2p.getConnections().filter((e=>e.tags.find((e=>e===Vc.BOOTSTRAP)))).length<this.options.maxBootstrapPeersAllowed)return!0;return!1}async dispatchDiscoveryEvent(e){const t=(await this.getTagNamesForPeer(e)).includes(Vc.BOOTSTRAP);this.dispatchEvent(new yd(t?zc.PEER_DISCOVERY_BOOTSTRAP:zc.PEER_DISCOVERY_PEER_EXCHANGE,{detail:e}))}async getTagNamesForPeer(e){try{const t=await this.libp2p.peerStore.get(e);return Array.from(t.tags.keys())}catch(t){return wd.error("Failed to get peer ".concat(e,", error: ").concat(t)),[]}}async isPeerTopicConfigured(e){const t=await this.getPeerShardInfo(e,this.libp2p.peerStore);if(!t)return!0;return Cl(t).some((e=>this.configuredPubsubTopics.includes(e)))}async getPeerShardInfo(e,t){const r=(await t.get(e)).metadata.get("shardInfo");if(r)return Ll(r)}}co(_d,"instances",new Map);const Ed=new Kl("metadata"),Sd="/vac/waku/metadata/1.0.0";class Ad extends kh{constructor(e,t){super(Sd,t.components,Ed,Cl(e)),co(this,"shardInfo",void 0),co(this,"libp2pComponents",void 0),co(this,"handshakesConfirmed",new Map),this.shardInfo=e,this.libp2pComponents=t,t.registrar.handle(Sd,(e=>{this.onRequest(e)}))}async onRequest(e){try{const{stream:t,connection:r}=e,n=sc.encode(this.shardInfo),i=await mh([n],sh,t,lh,(async e=>await Ql(e))),{error:o,shardInfo:s}=this.decodeMetadataResponse(i);if(o)return;await this.savePeerShardInfo(r.remotePeer,s)}catch(t){Ed.error("Error handling metadata request",t)}}async query(e){const t=oc.encode(this.shardInfo),r=await this.peerStore.get(e);if(!r)return{shardInfo:null,error:Kc.NO_PEER_AVAILABLE};const n=await this.getStream(r),i=await mh([t],sh,n,lh,(async e=>await Ql(e))),{error:o,shardInfo:s}=this.decodeMetadataResponse(i);return o?{shardInfo:null,error:o}:(await this.savePeerShardInfo(e,s),{shardInfo:s,error:null})}async confirmOrAttemptHandshake(e){const t=this.handshakesConfirmed.get(e.toString());return t?{shardInfo:t,error:null}:await this.query(e)}decodeMetadataResponse(e){const t=new nh;e.forEach((e=>{t.append(e)}));const r=sc.decode(t);return r?{shardInfo:r,error:null}:(Ed.error("Error decoding metadata response"),{shardInfo:null,error:Kc.DECODE_FAILED})}async savePeerShardInfo(e,t){await this.libp2pComponents.peerStore.merge(e,{metadata:{shardInfo:Ml(t)}}),this.handshakesConfirmed.set(e.toString(),t)}}function kd(e){return t=>new Ad(e,t)}class xd extends Error{constructor(e,t){super(null!==e&&void 0!==e?e:"The operation was aborted"),co(this,"type",void 0),co(this,"code",void 0),this.type="aborted",this.name="AbortError",this.code=null!==t&&void 0!==t?t:"ABORT_ERR"}}async function Id(e,t,r){if(null==t)return e;if(t.aborted)return Promise.reject(new xd(null===r||void 0===r?void 0:r.errorMessage,null===r||void 0===r?void 0:r.errorCode));let n;const i=new xd(null===r||void 0===r?void 0:r.errorMessage,null===r||void 0===r?void 0:r.errorCode);try{return await Promise.race([e,new Promise(((e,r)=>{n=()=>{r(i)},t.addEventListener("abort",n)}))])}finally{null!=n&&t.removeEventListener("abort",n)}}class Cd{constructor(){co(this,"readNext",void 0),co(this,"haveNext",void 0),co(this,"ended",void 0),co(this,"nextResult",void 0),this.ended=!1,this.readNext=hh(),this.haveNext=hh()}[Symbol.asyncIterator](){return this}async next(){if(null==this.nextResult&&await this.haveNext.promise,null==this.nextResult)throw new Error("HaveNext promise resolved but nextResult was undefined");const e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=hh(),e}async throw(e){this.ended=!0,null!=e&&this.haveNext.reject(e);return{done:!0,value:void 0}}async return(){const e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){null!=e?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(null!=e&&this.ended)throw new Error("Cannot push value onto an ended pushable");if(null!=this.nextResult&&(await this.readNext.promise,null!=this.nextResult))throw new Error("NeedNext promise resolved but nextResult was not consumed");null!=e?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=hh(),await Id(this.readNext.promise,null===t||void 0===t?void 0:t.signal,t)}}class Td extends Error{constructor(e,t){super(e),co(this,"code",void 0),this.code=t}}class Rd extends Td{constructor(e){super(e,"ABORT_ERR"),co(this,"type",void 0),this.type="aborted"}}function Pd(e,t){const r=new Cd;e.sink(r).catch((async e=>{await r.end(e)})),e.sink=async e=>{for await(const t of e)await r.push(t);await r.end()};let n=e.source;null!=e.source[Symbol.iterator]?n=e.source[Symbol.iterator]():null!=e.source[Symbol.asyncIterator]&&(n=e.source[Symbol.asyncIterator]());const i=new nh,o={read:async(e,t)=>{var r;let o;null===t||void 0===t||null===(r=t.signal)||void 0===r||r.throwIfAborted();const s=new Promise(((e,r)=>{var n;o=()=>{r(new Rd("Read aborted"))},null===t||void 0===t||null===(n=t.signal)||void 0===n||n.addEventListener("abort",o)}));try{if(null==e){const{done:e,value:t}=await Promise.race([n.next(),s]);return!0===e?new nh:t}for(;i.byteLength<e;){const{value:e,done:t}=await Promise.race([n.next(),s]);if(!0===t)throw new Td("unexpected end of input","ERR_UNEXPECTED_EOF");i.append(e)}const t=i.sublist(0,e);return i.consume(e),t}finally{var a;if(null!=o)null===t||void 0===t||null===(a=t.signal)||void 0===a||a.removeEventListener("abort",o)}},write:async(e,t)=>{var n;null===t||void 0===t||null===(n=t.signal)||void 0===n||n.throwIfAborted(),e instanceof Uint8Array?await r.push(e,t):await r.push(e.subarray(),t)},unwrap:()=>{if(i.byteLength>0){const r=e.source;e.source=async function*(){!1===(null===t||void 0===t?void 0:t.yieldBytes)?yield i:yield*i,yield*r}()}return e}};return o}class Dd extends Error{constructor(e,t){super(e),co(this,"code",void 0),this.code=t}}function Nd(e){var t,r;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=Pd(e,n);null!=n.maxDataLength&&null==n.maxLengthLength&&(n.maxLengthLength=vo(n.maxDataLength));const o=null!==(t=null===n||void 0===n?void 0:n.lengthDecoder)&&void 0!==t?t:So,s=null!==(r=null===n||void 0===n?void 0:n.lengthEncoder)&&void 0!==r?r:Eo;return{read:async e=>{let t=-1;const r=new nh;for(;;){r.append(await i.read(1,e));try{t=o(r)}catch(s){if(s instanceof RangeError)continue;throw s}if(null!=(null===n||void 0===n?void 0:n.maxLengthLength)&&r.byteLength>n.maxLengthLength)throw new Dd("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(t>-1)break}if(null!=(null===n||void 0===n?void 0:n.maxDataLength)&&t>n.maxDataLength)throw new Dd("message length too long","ERR_MSG_DATA_TOO_LONG");return i.read(t,e)},write:async(e,t)=>{await i.write(new nh(s(e.byteLength),e),t)},writeV:async(e,t)=>{const r=new nh(...e.flatMap((e=>[s(e.byteLength),e])));await i.write(r,t)},unwrap:()=>i.unwrap()}}function Bd(){const e=hh();let t=!1;return{sink:async r=>{if(t)throw new Error("already piped");t=!0,e.resolve(r)},source:async function*(){const t=await e.promise;yield*t}()}}function Ud(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Ld(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}var Md;const Od=65535,qd=Boolean(null===(Md=globalThis.process)||void 0===Md||null===(Md=Md.env)||void 0===Md?void 0:Md.DUMP_SESSION_KEYS),Kd=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function Fd(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}const Vd=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function zd(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got ".concat(typeof e));return new Uint8Array((new TextEncoder).encode(e))}function jd(e){if("string"===typeof e)e=zd(e);else{if(!Fd(e))throw new Error("expected Uint8Array, got ".concat(typeof e));e=e.slice()}return e}const Hd=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function Gd(e,t){if(!Fd(e))throw new Error("Uint8Array expected");if("number"===typeof t&&e.length!==t)throw new Error("Uint8Array length ".concat(t," expected"))}const Wd=(e,t)=>(Object.assign(t,e),t);function Yd(e,t,r,n){if("function"===typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}function Qd(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("wrong positive integer: ".concat(e))}function Jd(e){if("boolean"!==typeof e)throw new Error("boolean expected, not ".concat(e))}function Xd(e){if(null==(t=e)||"object"!==typeof t||!(t instanceof Uint8Array||"Uint8Array"===t.constructor.name))throw new Error("Uint8Array expected");for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];if(n.length>0&&!n.includes(e.length))throw new Error("Uint8Array expected of length ".concat(n,", not of length=").concat(e.length))}function Zd(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $d(e,t){Xd(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least ".concat(r))}const ef=(e,t)=>255&e[t++]|(255&e[t++])<<8;class tf{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Gd(e=jd(e),32);const t=ef(e,0),r=ef(e,2),n=ef(e,4),i=ef(e,6),o=ef(e,8),s=ef(e,10),a=ef(e,12),c=ef(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|r<<3),this.r[2]=7939&(r>>>10|n<<6),this.r[3]=8191&(n>>>7|i<<9),this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=ef(e,16+2*u)}process(e,t){const r=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?0:2048,{h:n,r:i}=this,o=i[0],s=i[1],a=i[2],c=i[3],u=i[4],l=i[5],h=i[6],d=i[7],f=i[8],p=i[9],g=ef(e,t+0),b=ef(e,t+2),y=ef(e,t+4),m=ef(e,t+6),v=ef(e,t+8),w=ef(e,t+10),_=ef(e,t+12),E=ef(e,t+14);let S=n[0]+(8191&g),A=n[1]+(8191&(g>>>13|b<<3)),k=n[2]+(8191&(b>>>10|y<<6)),x=n[3]+(8191&(y>>>7|m<<9)),I=n[4]+(8191&(m>>>4|v<<12)),C=n[5]+(v>>>1&8191),T=n[6]+(8191&(v>>>14|w<<2)),R=n[7]+(8191&(w>>>11|_<<5)),P=n[8]+(8191&(_>>>8|E<<8)),D=n[9]+(E>>>5|r),N=0,B=N+S*o+A*(5*p)+k*(5*f)+x*(5*d)+I*(5*h);N=B>>>13,B&=8191,B+=C*(5*l)+T*(5*u)+R*(5*c)+P*(5*a)+D*(5*s),N+=B>>>13,B&=8191;let U=N+S*s+A*o+k*(5*p)+x*(5*f)+I*(5*d);N=U>>>13,U&=8191,U+=C*(5*h)+T*(5*l)+R*(5*u)+P*(5*c)+D*(5*a),N+=U>>>13,U&=8191;let L=N+S*a+A*s+k*o+x*(5*p)+I*(5*f);N=L>>>13,L&=8191,L+=C*(5*d)+T*(5*h)+R*(5*l)+P*(5*u)+D*(5*c),N+=L>>>13,L&=8191;let M=N+S*c+A*a+k*s+x*o+I*(5*p);N=M>>>13,M&=8191,M+=C*(5*f)+T*(5*d)+R*(5*h)+P*(5*l)+D*(5*u),N+=M>>>13,M&=8191;let O=N+S*u+A*c+k*a+x*s+I*o;N=O>>>13,O&=8191,O+=C*(5*p)+T*(5*f)+R*(5*d)+P*(5*h)+D*(5*l),N+=O>>>13,O&=8191;let q=N+S*l+A*u+k*c+x*a+I*s;N=q>>>13,q&=8191,q+=C*o+T*(5*p)+R*(5*f)+P*(5*d)+D*(5*h),N+=q>>>13,q&=8191;let K=N+S*h+A*l+k*u+x*c+I*a;N=K>>>13,K&=8191,K+=C*s+T*o+R*(5*p)+P*(5*f)+D*(5*d),N+=K>>>13,K&=8191;let F=N+S*d+A*h+k*l+x*u+I*c;N=F>>>13,F&=8191,F+=C*a+T*s+R*o+P*(5*p)+D*(5*f),N+=F>>>13,F&=8191;let V=N+S*f+A*d+k*h+x*l+I*u;N=V>>>13,V&=8191,V+=C*c+T*a+R*s+P*o+D*(5*p),N+=V>>>13,V&=8191;let z=N+S*p+A*f+k*d+x*h+I*l;N=z>>>13,z&=8191,z+=C*u+T*c+R*a+P*s+D*o,N+=z>>>13,z&=8191,N=(N<<2)+N|0,N=N+B|0,B=8191&N,N>>>=13,U+=N,n[0]=B,n[1]=U,n[2]=L,n[3]=M,n[4]=O,n[5]=q,n[6]=K,n[7]=F,n[8]=V,n[9]=z}finalize(){const{h:e,pad:t}=this,r=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=n,n=e[s]>>>13,e[s]&=8191;e[0]+=5*n,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,r[0]=e[0]+5,n=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+n,n=r[s]>>>13,r[s]&=8191;r[9]-=8192;let i=(1^n)-1;for(let s=0;s<10;s++)r[s]&=i;i=~i;for(let s=0;s<10;s++)e[s]=e[s]&i|r[s];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let o=e[0]+t[0];e[0]=65535&o;for(let s=1;s<8;s++)o=(e[s]+t[s]|0)+(o>>>16)|0,e[s]=65535&o}update(e){Zd(this);const{buffer:t,blockLen:r}=this,n=(e=jd(e)).length;for(let i=0;i<n;){const o=Math.min(r-this.pos,n-i);if(o!==r)t.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===r&&(this.process(t,0,!1),this.pos=0);else for(;r<=n-i;i+=r)this.process(e,i)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){Zd(this),$d(e,this),this.finished=!0;const{buffer:t,h:r}=this;let{pos:n}=this;if(n){for(t[n++]=1;n<16;n++)t[n]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let o=0;o<8;o++)e[i++]=r[o]>>>0,e[i++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}}const rf=function(e){const t=(t,r)=>e(r).update(jd(t)).digest(),r=e(new Uint8Array(32));return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}((e=>new tf(e))),nf=zd("expand 16-byte k"),of=zd("expand 32-byte k"),sf=Kd(nf),af=Kd(of);function cf(e,t){return e<<t|e>>>32-t}function uf(e){return e.byteOffset%4===0}const lf=64,hf=16,df=2**32-1,ff=new Uint32Array;function pf(e,t){const{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=function(e,t){if(void 0!==t&&("object"!==typeof t||!Hd(t)))throw new Error("options must be object or undefined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!==typeof e)throw new Error("core must be a function");return Qd(i),Qd(s),Jd(o),Jd(r),function(t,a,c,u){let l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;Xd(t),Xd(a),Xd(c);const h=c.length;if(u||(u=new Uint8Array(h)),Xd(u),Qd(l),l<0||l>=df)throw new Error("arx: counter overflow");if(u.length<h)throw new Error("arx: output (".concat(u.length,") is shorter than data (").concat(h,")"));const d=[];let f,p,g=t.length;if(32===g)f=t.slice(),d.push(f),p=af;else{if(16!==g||!r)throw new Error("arx: invalid 32-byte key, got length=".concat(g));f=new Uint8Array(32),f.set(t),f.set(t,16),p=sf,d.push(f)}uf(a)||(a=a.slice(),d.push(a));const b=Kd(f);if(n){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");n(p,b,Kd(a.subarray(0,16)),b),a=a.subarray(16)}const y=16-i;if(y!==a.length)throw new Error("arx: nonce must be ".concat(y," or 16 bytes"));if(12!==y){const e=new Uint8Array(12);e.set(a,o?0:12-a.length),a=e,d.push(a)}const m=Kd(a);for(!function(e,t,r,n,i,o,s,a){const c=i.length,u=new Uint8Array(lf),l=Kd(u),h=uf(i)&&uf(o),d=h?Kd(i):ff,f=h?Kd(o):ff;for(let p=0;p<c;s++){if(e(t,r,n,l,s,a),s>=df)throw new Error("arx: counter overflow");const g=Math.min(lf,c-p);if(h&&g===lf){const e=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let t,r=0;r<hf;r++)t=e+r,f[t]=d[t]^l[r];p+=lf}else{for(let e,t=0;t<g;t++)e=p+t,o[e]=i[e]^u[t];p+=g}}}(e,p,b,m,c,u,l,s);d.length>0;)d.pop().fill(0);return u}}function gf(e,t,r,n,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:20,s=e[0],a=e[1],c=e[2],u=e[3],l=t[0],h=t[1],d=t[2],f=t[3],p=t[4],g=t[5],b=t[6],y=t[7],m=i,v=r[0],w=r[1],_=r[2],E=s,S=a,A=c,k=u,x=l,I=h,C=d,T=f,R=p,P=g,D=b,N=y,B=m,U=v,L=w,M=_;for(let q=0;q<o;q+=2)E=E+x|0,B=cf(B^E,16),R=R+B|0,x=cf(x^R,12),E=E+x|0,B=cf(B^E,8),R=R+B|0,x=cf(x^R,7),S=S+I|0,U=cf(U^S,16),P=P+U|0,I=cf(I^P,12),S=S+I|0,U=cf(U^S,8),P=P+U|0,I=cf(I^P,7),A=A+C|0,L=cf(L^A,16),D=D+L|0,C=cf(C^D,12),A=A+C|0,L=cf(L^A,8),D=D+L|0,C=cf(C^D,7),k=k+T|0,M=cf(M^k,16),N=N+M|0,T=cf(T^N,12),k=k+T|0,M=cf(M^k,8),N=N+M|0,T=cf(T^N,7),E=E+I|0,M=cf(M^E,16),D=D+M|0,I=cf(I^D,12),E=E+I|0,M=cf(M^E,8),D=D+M|0,I=cf(I^D,7),S=S+C|0,B=cf(B^S,16),N=N+B|0,C=cf(C^N,12),S=S+C|0,B=cf(B^S,8),N=N+B|0,C=cf(C^N,7),A=A+T|0,U=cf(U^A,16),R=R+U|0,T=cf(T^R,12),A=A+T|0,U=cf(U^A,8),R=R+U|0,T=cf(T^R,7),k=k+x|0,L=cf(L^k,16),P=P+L|0,x=cf(x^P,12),k=k+x|0,L=cf(L^k,8),P=P+L|0,x=cf(x^P,7);let O=0;n[O++]=s+E|0,n[O++]=a+S|0,n[O++]=c+A|0,n[O++]=u+k|0,n[O++]=l+x|0,n[O++]=h+I|0,n[O++]=d+C|0,n[O++]=f+T|0,n[O++]=p+R|0,n[O++]=g+P|0,n[O++]=b+D|0,n[O++]=y+N|0,n[O++]=m+B|0,n[O++]=v+U|0,n[O++]=w+L|0,n[O++]=_+M|0}const bf=pf(gf,{counterRight:!1,counterLength:4,allowShortKeys:!1}),yf=pf(gf,{counterRight:!1,counterLength:8,extendNonceFn:function(e,t,r,n){let i=e[0],o=e[1],s=e[2],a=e[3],c=t[0],u=t[1],l=t[2],h=t[3],d=t[4],f=t[5],p=t[6],g=t[7],b=r[0],y=r[1],m=r[2],v=r[3];for(let _=0;_<20;_+=2)i=i+c|0,b=cf(b^i,16),d=d+b|0,c=cf(c^d,12),i=i+c|0,b=cf(b^i,8),d=d+b|0,c=cf(c^d,7),o=o+u|0,y=cf(y^o,16),f=f+y|0,u=cf(u^f,12),o=o+u|0,y=cf(y^o,8),f=f+y|0,u=cf(u^f,7),s=s+l|0,m=cf(m^s,16),p=p+m|0,l=cf(l^p,12),s=s+l|0,m=cf(m^s,8),p=p+m|0,l=cf(l^p,7),a=a+h|0,v=cf(v^a,16),g=g+v|0,h=cf(h^g,12),a=a+h|0,v=cf(v^a,8),g=g+v|0,h=cf(h^g,7),i=i+u|0,v=cf(v^i,16),p=p+v|0,u=cf(u^p,12),i=i+u|0,v=cf(v^i,8),p=p+v|0,u=cf(u^p,7),o=o+l|0,b=cf(b^o,16),g=g+b|0,l=cf(l^g,12),o=o+l|0,b=cf(b^o,8),g=g+b|0,l=cf(l^g,7),s=s+h|0,y=cf(y^s,16),d=d+y|0,h=cf(h^d,12),s=s+h|0,y=cf(y^s,8),d=d+y|0,h=cf(h^d,7),a=a+c|0,m=cf(m^a,16),f=f+m|0,c=cf(c^f,12),a=a+c|0,m=cf(m^a,8),f=f+m|0,c=cf(c^f,7);let w=0;n[w++]=i,n[w++]=o,n[w++]=s,n[w++]=a,n[w++]=b,n[w++]=y,n[w++]=m,n[w++]=v},allowShortKeys:!1}),mf=new Uint8Array(16),vf=(e,t)=>{e.update(t);const r=t.length%16;r&&e.update(mf.subarray(r))},wf=new Uint8Array(32);function _f(e,t,r,n,i){const o=e(t,r,wf),s=rf.create(o);i&&vf(s,i),vf(s,n);const a=new Uint8Array(16),c=Vd(a);Yd(c,0,BigInt(i?i.length:0),!0),Yd(c,8,BigInt(n.length),!0),s.update(a);const u=s.digest();return o.fill(0),u}const Ef=e=>(t,r,n)=>{const i=16;return Gd(t,32),Gd(r),{encrypt:(o,s)=>{const a=o.length,c=a+i;s?Gd(s,c):s=new Uint8Array(c),e(t,r,o,s,1);const u=_f(e,t,r,s.subarray(0,-16),n);return s.set(u,a),s},decrypt:(o,s)=>{const a=o.length,c=a-i;if(a<i)throw new Error("encrypted data must be at least ".concat(i," bytes"));s?Gd(s,c):s=new Uint8Array(c);const u=o.subarray(0,-16);if(!function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r}(o.subarray(-16),_f(e,t,r,u,n)))throw new Error("invalid tag");return e(t,r,u,s,1),s}}},Sf=Wd({blockSize:64,nonceLength:12,tagLength:16},Ef(bf)),Af=(Ef(yf),BigInt(2**32-1)),kf=BigInt(32);function xf(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&Af),l:Number(e>>kf&Af)}:{h:0|Number(e>>kf&Af),l:0|Number(e&Af)}}const If={fromBig:xf,split:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:o,l:s}=xf(e[i],t);[r[i],n[i]]=[o,s]}return[r,n]},toBig:(e,t)=>BigInt(e>>>0)<<kf|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,n)=>t+r+n+(e/2**32|0)|0,add4L:(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H:(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,add5H:(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0,add5L:(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[Cf,Tf]=(()=>If.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Rf=new Uint32Array(80),Pf=new Uint32Array(80);class Df extends Nc{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:d,Gl:f,Hh:p,Hl:g}=this;return[e,t,r,n,i,o,s,a,c,u,l,h,d,f,p,g]}set(e,t,r,n,i,o,s,a,c,u,l,h,d,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|d,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let m=0;m<16;m++,t+=4)Rf[m]=e.getUint32(t),Pf[m]=e.getUint32(t+=4);for(let m=16;m<80;m++){const e=0|Rf[m-15],t=0|Pf[m-15],r=If.rotrSH(e,t,1)^If.rotrSH(e,t,8)^If.shrSH(e,t,7),n=If.rotrSL(e,t,1)^If.rotrSL(e,t,8)^If.shrSL(e,t,7),i=0|Rf[m-2],o=0|Pf[m-2],s=If.rotrSH(i,o,19)^If.rotrBH(i,o,61)^If.shrSH(i,o,6),a=If.rotrSL(i,o,19)^If.rotrBL(i,o,61)^If.shrSL(i,o,6),c=If.add4L(n,a,Pf[m-7],Pf[m-16]),u=If.add4H(c,r,s,Rf[m-7],Rf[m-16]);Rf[m]=0|u,Pf[m]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:d,Fl:f,Gh:p,Gl:g,Hh:b,Hl:y}=this;for(let m=0;m<80;m++){const e=If.rotrSH(l,h,14)^If.rotrSH(l,h,18)^If.rotrBH(l,h,41),t=If.rotrSL(l,h,14)^If.rotrSL(l,h,18)^If.rotrBL(l,h,41),v=l&d^~l&p,w=h&f^~h&g,_=If.add5L(y,t,w,Tf[m],Pf[m]),E=If.add5H(_,b,e,v,Cf[m],Rf[m]),S=0|_,A=If.rotrSH(r,n,28)^If.rotrBH(r,n,34)^If.rotrBH(r,n,39),k=If.rotrSL(r,n,28)^If.rotrBL(r,n,34)^If.rotrBL(r,n,39),x=r&i^r&s^i&s,I=n&o^n&a^o&a;b=0|p,y=0|g,p=0|d,g=0|f,d=0|l,f=0|h,({h:l,l:h}=If.add(0|c,0|u,0|E,0|S)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const C=If.add3L(S,k,I);r=If.add3H(C,E,A,x),n=0|C}({h:r,l:n}=If.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=If.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=If.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=If.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=If.add(0|this.Eh,0|this.El,0|l,0|h)),({h:d,l:f}=If.add(0|this.Fh,0|this.Fl,0|d,0|f)),({h:p,l:g}=If.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:b,l:y}=If.add(0|this.Hh,0|this.Hl,0|b,0|y)),this.set(r,n,i,o,s,a,c,u,l,h,d,f,p,g,b,y)}roundClean(){Rf.fill(0),Pf.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Nf=Rc((()=>new Df)),Bf=(BigInt(0),BigInt(1)),Uf=BigInt(2);function Lf(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function Mf(e){if(!Lf(e))throw new Error("Uint8Array expected")}const Of=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function qf(e){Mf(e);let t="";for(let r=0;r<e.length;r++)t+=Of[e[r]];return t}function Kf(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":"0x".concat(e))}const Ff={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Vf(e){return e>=Ff._0&&e<=Ff._9?e-Ff._0:e>=Ff._A&&e<=Ff._F?e-(Ff._A-10):e>=Ff._a&&e<=Ff._f?e-(Ff._a-10):void 0}function zf(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){const t=Vf(e.charCodeAt(o)),r=Vf(e.charCodeAt(o+1));if(void 0===t||void 0===r){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}n[i]=16*t+r}return n}function jf(e){return Kf(qf(e))}function Hf(e){return Mf(e),Kf(qf(Uint8Array.from(e).reverse()))}function Gf(e,t){return zf(e.toString(16).padStart(2*t,"0"))}function Wf(e,t){return Gf(e,t).reverse()}function Yf(e,t,r){let n;if("string"===typeof t)try{n=zf(t)}catch(o){throw new Error("".concat(e,' must be valid hex string, got "').concat(t,'". Cause: ').concat(o))}else{if(!Lf(t))throw new Error("".concat(e," must be hex string or Uint8Array"));n=Uint8Array.from(t)}const i=n.length;if("number"===typeof r&&i!==r)throw new Error("".concat(e," expected ").concat(r," bytes, got ").concat(i));return n}function Qf(){let e=0;for(let r=0;r<arguments.length;r++){const t=r<0||arguments.length<=r?void 0:arguments[r];Mf(t),e+=t.length}const t=new Uint8Array(e);for(let r=0,n=0;r<arguments.length;r++){const e=r<0||arguments.length<=r?void 0:arguments[r];t.set(e,n),n+=e.length}return t}const Jf=e=>(Uf<<BigInt(e-1))-Bf,Xf=e=>new Uint8Array(e),Zf=e=>Uint8Array.from(e);function $f(e,t,r){if("number"!==typeof e||e<2)throw new Error("hashLen must be a number");if("number"!==typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!==typeof r)throw new Error("hmacFn must be a function");let n=Xf(e),i=Xf(e),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return r(i,n,...t)},c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xf();i=a(Zf([0]),e),n=a(),0!==e.length&&(i=a(Zf([1]),e),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e<t;){n=a();const t=n.slice();r.push(t),e+=n.length}return Qf(...r)};return(e,t)=>{let r;for(s(),c(e);!(r=t(u()));)c();return s(),r}}const ep={bigint:e=>"bigint"===typeof e,function:e=>"function"===typeof e,boolean:e=>"boolean"===typeof e,string:e=>"string"===typeof e,stringOrUint8Array:e=>"string"===typeof e||Lf(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"===typeof e&&Number.isSafeInteger(e.outputLen)};function tp(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=(t,r,n)=>{const i=ep[r];if("function"!==typeof i)throw new Error('Invalid validator "'.concat(r,'", expected function'));const o=e[t];if((!n||void 0!==o)&&!i(o,e))throw new Error("Invalid param ".concat(String(t),"=").concat(o," (").concat(typeof o,"), expected ").concat(r))};for(const[i,o]of Object.entries(t))n(i,o,!1);for(const[i,o]of Object.entries(r))n(i,o,!0);return e}const rp=BigInt(0),np=BigInt(1),ip=BigInt(2),op=BigInt(3),sp=BigInt(4),ap=BigInt(5),cp=BigInt(8);BigInt(9),BigInt(16);function up(e,t){const r=e%t;return r>=rp?r:t+r}function lp(e,t,r){if(r<=rp||t<rp)throw new Error("Expected power/modulo > 0");if(r===np)return rp;let n=np;for(;t>rp;)t&np&&(n=n*e%r),e=e*e%r,t>>=np;return n}function hp(e,t,r){let n=e;for(;t-- >rp;)n*=n,n%=r;return n}function dp(e,t){if(e===rp||t<=rp)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=up(e,t),n=t,i=rp,o=np,s=np,a=rp;for(;r!==rp;){const e=n/r,t=n%r,c=i-s*e,u=o-a*e;n=r,r=t,i=s,o=a,s=c,a=u}if(n!==np)throw new Error("invert: does not exist");return up(i,t)}function fp(e){if(e%sp===op){const t=(e+np)/sp;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}if(e%cp===ap){const t=(e-ap)/cp;return function(e,r){const n=e.mul(r,ip),i=e.pow(n,t),o=e.mul(r,i),s=e.mul(e.mul(o,ip),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-np)/ip;let r,n,i;for(r=e-np,n=0;r%ip===rp;r/=ip,n++);for(i=ip;i<e&&lp(i,t,e)!==e-np;i++);if(1===n){const t=(e+np)/sp;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}const o=(r+np)/ip;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=n,c=e.pow(e.mul(e.ONE,i),r),u=e.pow(s,o),l=e.pow(s,r);for(;!e.eql(l,e.ONE);){if(e.eql(l,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(l);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const r=e.pow(c,np<<BigInt(a-t-1));c=e.sqr(r),u=e.mul(u,r),l=e.mul(l,c),a=t}return u}}(e)}const pp=(e,t)=>(up(e,t)&np)===np,gp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bp(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function yp(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e<=rp)throw new Error("Expected Field ORDER > 0, got ".concat(e));const{nBitLength:i,nByteLength:o}=bp(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=fp(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:Jf(i),ZERO:rp,ONE:np,create:t=>up(t,e),isValid:t=>{if("bigint"!==typeof t)throw new Error("Invalid field element: expected bigint, got ".concat(typeof t));return rp<=t&&t<e},is0:e=>e===rp,isOdd:e=>(e&np)===np,neg:t=>up(-t,e),eql:(e,t)=>e===t,sqr:t=>up(t*t,e),add:(t,r)=>up(t+r,e),sub:(t,r)=>up(t-r,e),mul:(t,r)=>up(t*r,e),pow:(e,t)=>function(e,t,r){if(r<rp)throw new Error("Expected power > 0");if(r===rp)return e.ONE;if(r===np)return t;let n=e.ONE,i=t;for(;r>rp;)r&np&&(n=e.mul(n,i)),i=e.sqr(i),r>>=np;return n}(a,e,t),div:(t,r)=>up(t*dp(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>dp(t,e),sqrt:n.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const r=new Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Wf(e,o):Gf(e,o),fromBytes:e=>{if(e.length!==o)throw new Error("Fp.fromBytes: expected ".concat(o,", got ").concat(e.length));return r?Hf(e):jf(e)}});return Object.freeze(a)}function mp(e){if("bigint"!==typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function vp(e){const t=mp(e);return t+Math.ceil(t/2)}const wp=BigInt(0),_p=BigInt(1);function Ep(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>wp;)r&_p&&(n=n.add(i)),i=i.double(),r>>=_p;return n},precomputeWindow(e,t){const{windows:r,windowSize:i}=n(t),o=[];let s=e,a=s;for(let n=0;n<r;n++){a=s,o.push(a);for(let e=1;e<i;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,i,o){const{windows:s,windowSize:a}=n(t);let c=e.ZERO,u=e.BASE;const l=BigInt(2**t-1),h=2**t,d=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let n=Number(o&l);o>>=d,n>a&&(n-=h,o+=_p);const s=t,f=t+Math.abs(n)-1,p=e%2!==0,g=n<0;0===n?u=u.add(r(p,i[s])):c=c.add(r(g,i[f]))}return{p:c,f:u}},wNAFCached(e,t,r,n){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,n(o))),this.wNAF(i,o,r)}}}function Sp(e){return function(e){const t=gp.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});tp(e,t)}(e.Fp),tp(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...bp(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const Ap=BigInt(0),kp=BigInt(1),xp=BigInt(2),Ip=BigInt(8),Cp={zip215:!0};function Tp(e){const t=function(e){const t=Sp(e);return tp(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,u=xp<<BigInt(8*a)-kp,l=r.create,h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(n){return{isValid:!1,value:Ap}}}),d=t.adjustScalarBytes||(e=>e),f=t.domain||((e,t,r)=>{if(t.length||r)throw new Error("Contexts/pre-hash are not supported");return e}),p=e=>"bigint"===typeof e&&Ap<e,g=(e,t)=>p(e)&&p(t)&&e<t,b=e=>e===Ap||g(e,u);function y(e,t){if(g(e,t))return e;throw new Error("Expected valid scalar < ".concat(t,", got ").concat(typeof e," ").concat(e))}function m(e){return e===Ap?e:y(e,n)}const v=new Map;function w(e){if(!(e instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(e,t,r,n){if(this.ex=e,this.ey=t,this.ez=r,this.et=n,!b(e))throw new Error("x required");if(!b(t))throw new Error("y required");if(!b(r))throw new Error("z required");if(!b(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof _)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};if(!b(t)||!b(r))throw new Error("invalid affine point");return new _(t,r,kp,l(t*r))}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(_.fromAffine)}_setWindowSize(e){this._WINDOW_SIZE=e,v.delete(this)}assertValidity(){const{a:e,d:r}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:i,ez:o,et:s}=this,a=l(n*n),c=l(i*i),u=l(o*o),h=l(u*u),d=l(a*e);if(l(u*l(d+c))!==l(h+l(r*l(a*c))))throw new Error("bad point: equation left != right (1)");if(l(n*i)!==l(o*s))throw new Error("bad point: equation left != right (2)")}equals(e){w(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=e,a=l(t*s),c=l(i*n),u=l(r*s),h=l(o*n);return a===c&&u===h}is0(){return this.equals(_.ZERO)}negate(){return new _(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:i}=this,o=l(r*r),s=l(n*n),a=l(xp*l(i*i)),c=l(e*o),u=r+n,h=l(l(u*u)-o-s),d=c+s,f=d-a,p=c-s,g=l(h*f),b=l(d*p),y=l(h*p),m=l(f*d);return new _(g,b,m,y)}add(e){w(e);const{a:r,d:n}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:u,ez:h,et:d}=e;if(r===BigInt(-1)){const e=l((o-i)*(u+c)),t=l((o+i)*(u-c)),r=l(t-e);if(r===Ap)return this.double();const n=l(s*xp*d),f=l(a*xp*h),p=f+n,g=t+e,b=f-n,y=l(p*r),m=l(g*b),v=l(p*b),w=l(r*g);return new _(y,m,w,v)}const f=l(i*c),p=l(o*u),g=l(a*n*d),b=l(s*h),y=l((i+o)*(c+u)-f-p),m=b-g,v=b+g,E=l(p-r*f),S=l(y*m),A=l(v*E),k=l(y*E),x=l(m*v);return new _(S,A,x,k)}subtract(e){return this.add(e.negate())}wNAF(e){return A.wNAFCached(this,v,e,_.normalizeZ)}multiply(e){const{p:t,f:r}=this.wNAF(y(e,n));return _.normalizeZ([t,r])[0]}multiplyUnsafe(e){let t=m(e);return t===Ap?S:this.equals(S)||t===kp?this:this.equals(E)?this.wNAF(t).p:A.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return A.unsafeLadder(this,n).is0()}toAffine(e){const{ex:t,ey:n,ez:i}=this,o=this.is0();null==e&&(e=o?Ip:r.inv(i));const s=l(t*e),a=l(n*e),c=l(i*e);if(o)return{x:Ap,y:kp};if(c!==kp)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:e}=t;return e===kp?this:this.multiplyUnsafe(e)}static fromHex(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{d:i,a:o}=t,s=r.BYTES,a=(e=Yf("pointHex",e,s)).slice(),c=e[s-1];a[s-1]=-129&c;const d=Hf(a);d===Ap||y(d,n?u:r.ORDER);const f=l(d*d),p=l(f-kp),g=l(i*f-o);let{isValid:b,value:m}=h(p,g);if(!b)throw new Error("Point.fromHex: invalid y coordinate");const v=(m&kp)===kp,w=0!==(128&c);if(!n&&m===Ap&&w)throw new Error("Point.fromHex: x=0 and x_0=1");return w!==v&&(m=l(-m)),_.fromAffine({x:m,y:d})}static fromPrivateKey(e){return I(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=Wf(t,r.BYTES);return n[n.length-1]|=e&kp?128:0,n}toHex(){return qf(this.toRawBytes())}}_.BASE=new _(t.Gx,t.Gy,kp,l(t.Gx*t.Gy)),_.ZERO=new _(Ap,kp,kp,Ap);const{BASE:E,ZERO:S}=_,A=Ep(_,8*a);function k(e){return up(e,n)}function x(e){return k(Hf(e))}function I(e){const t=a;e=Yf("private key",e,t);const r=Yf("hashed private key",o(e),2*t),n=d(r.slice(0,t)),i=r.slice(t,2*t),s=x(n),c=E.multiply(s),u=c.toRawBytes();return{head:n,prefix:i,scalar:s,point:c,pointBytes:u}}function C(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];const s=Qf(...r);return x(o(f(s,Yf("context",e),!!i)))}const T=Cp;E._setWindowSize(8);const R={getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};return{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=Yf("message",e),i&&(e=i(e));const{prefix:o,scalar:s,pointBytes:c}=I(t),u=C(n.context,o,e),l=E.multiply(u).toRawBytes(),h=k(u+C(n.context,l,c,e)*s);return m(h),Yf("result",Qf(l,Wf(h,r.BYTES)),2*a)},verify:function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T;const{context:s,zip215:a}=o,c=r.BYTES;e=Yf("signature",e,2*c),t=Yf("message",t),i&&(t=i(t));const u=Hf(e.slice(c,2*c));let l,h,d;try{l=_.fromHex(n,a),h=_.fromHex(e.slice(0,c),a),d=E.multiplyUnsafe(u)}catch(p){return!1}if(!a&&l.isSmallOrder())return!1;const f=C(s,h.toRawBytes(),l.toRawBytes(),t);return h.add(l.multiplyUnsafe(f)).subtract(d).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:R}}const Rp=BigInt(0),Pp=BigInt(1);function Dp(e){const t=(tp(r=e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r}));var r;const{P:n}=t,i=e=>up(e,n),o=t.montgomeryBits,s=Math.ceil(o/8),a=t.nByteLength,c=t.adjustScalarBytes||(e=>e),u=t.powPminus2||(e=>lp(e,n-BigInt(2),n));function l(e,t,r){const n=i(e*(t-r));return[t=i(t-n),r=i(r+n)]}function h(e){if("bigint"===typeof e&&Rp<=e&&e<n)return e;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}const d=(t.a-BigInt(2))/BigInt(4);function f(e){return Wf(i(e),s)}function p(e,t){const r=function(e){const t=Yf("u coordinate",e,s);return 32===a&&(t[31]&=127),Hf(t)}(t),n=function(e){const t=Yf("scalar",e),r=t.length;if(r!==s&&r!==a)throw new Error("Expected ".concat(s," or ").concat(a," bytes, got ").concat(r));return Hf(c(t))}(e),p=function(e,t){const r=h(e),n=h(t),s=r;let a,c=Pp,f=Rp,p=r,g=Pp,b=Rp;for(let u=BigInt(o-1);u>=Rp;u--){const e=n>>u&Pp;b^=e,a=l(b,c,p),c=a[0],p=a[1],a=l(b,f,g),f=a[0],g=a[1],b=e;const t=c+f,r=i(t*t),o=c-f,h=i(o*o),y=r-h,m=p+g,v=i((p-g)*t),w=i(m*o),_=v+w,E=v-w;p=i(_*_),g=i(s*i(E*E)),c=i(r*h),f=i(y*(r+i(d*y)))}a=l(b,c,p),c=a[0],p=a[1],a=l(b,f,g),f=a[0],g=a[1];const y=u(f);return i(c*y)}(r,n);if(p===Rp)throw new Error("Invalid private or public key received");return f(p)}const g=f(t.Gu);function b(e){return p(e,g)}return{scalarMult:p,scalarMultBase:b,getSharedSecret:(e,t)=>p(e,t),getPublicKey:e=>b(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:g}}const Np=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Bp=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Up=(BigInt(0),BigInt(1)),Lp=BigInt(2),Mp=BigInt(5),Op=BigInt(10),qp=BigInt(20),Kp=BigInt(40),Fp=BigInt(80);function Vp(e){const t=Np,r=e*e%t*e%t,n=hp(r,Lp,t)*r%t,i=hp(n,Up,t)*e%t,o=hp(i,Mp,t)*i%t,s=hp(o,Op,t)*o%t,a=hp(s,qp,t)*s%t,c=hp(a,Kp,t)*a%t,u=hp(c,Fp,t)*c%t,l=hp(u,Fp,t)*c%t,h=hp(l,Op,t)*o%t;return{pow_p_5_8:hp(h,Lp,t)*e%t,b2:r}}function zp(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function jp(e,t){const r=Np,n=up(t*t*t,r),i=up(n*n*t,r);let o=up(e*n*Vp(e*i).pow_p_5_8,r);const s=up(t*o*o,r),a=o,c=up(o*Bp,r),u=s===e,l=s===up(-e,r),h=s===up(-e*Bp,r);return u&&(o=a),(l||h)&&(o=c),pp(o,r)&&(o=up(-o,r)),{isValid:u||l,value:o}}const Hp=yp(Np,void 0,!0),Gp={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Hp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Nf,randomBytes:Pc,adjustScalarBytes:zp,uvRatio:jp},Wp=Tp(Gp);function Yp(e,t,r){if(t.length>255)throw new Error("Context is too big");return Ic(kc("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}const Qp=(()=>Dp({P:Np,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Np,{pow_p_5_8:r,b2:n}=Vp(e);return up(hp(r,BigInt(3),t)*n,t)},adjustScalarBytes:zp,randomBytes:Pc}))();const Jp=(Hp.ORDER+BigInt(3))/BigInt(8);Hp.pow(Lp,Jp),Hp.sqrt(Hp.neg(Hp.ONE)),Hp.ORDER,BigInt(5),BigInt(8),BigInt(486662);!function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);e.isOdd(r)&&e.neg(r)}(Hp,Hp.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Xp extends Cc{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,yc(e);const r=xc(t);if(this.iHash=e.create(),"function"!==typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return mc(this),this.iHash.update(e),this}digestInto(e){mc(this),bc(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=n,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Zp=(e,t,r)=>new Xp(e,t).update(r).digest();function $p(e,t,r){return yc(e),void 0===r&&(r=new Uint8Array(e.outputLen)),Zp(e,xc(r),xc(t))}Zp.create=(e,t)=>new Xp(e,t);const eg=new Uint8Array([0]),tg=new Uint8Array;function rg(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;if(yc(e),gc(n),n>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(n/e.outputLen);void 0===r&&(r=tg);const o=new Uint8Array(i*e.outputLen),s=Zp.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let u=0;u<i;u++)eg[0]=u+1,a.update(0===u?tg:c).update(r).update(eg).digestInto(c),o.set(c,e.outputLen*u),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),eg.fill(0),o.slice(0,n)}const ng={hashSHA256:e=>Oc(e.subarray()),getHKDF(e,t){const r=$p(Oc,t,e),n=rg(Oc,r,void 0,96);return[n.subarray(0,32),n.subarray(32,64),n.subarray(64,96)]},generateX25519KeyPair(){const e=Qp.utils.randomPrivateKey();return{publicKey:Qp.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed:e=>({publicKey:Qp.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>Qp.getSharedSecret(e.subarray(),t.subarray()),chaCha20Poly1305Encrypt:(e,t,r,n)=>Sf(n,t,r).encrypt(e.subarray()),chaCha20Poly1305Decrypt:(e,t,r,n,i)=>Sf(n,t,r).decrypt(e.subarray(),i)},ig=e=>{const t=Ld(2);return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint16(0,e,!1),t};ig.bytes=2;const og=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");return e instanceof Uint8Array?new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1):e.getUint16(0)};og.bytes=2;class sg extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected Peer"),co(this,"code",void 0),this.code=sg.code}}co(sg,"code","ERR_UNEXPECTED_PEER");class ag extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),co(this,"code",void 0),this.code=ag.code}}co(ag,"code","ERR_INVALID_CRYPTO_EXCHANGE");__webpack_require__(5465),__webpack_require__(3555);class cg extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),co(this,"code",void 0),co(this,"type",void 0),this.name="AbortError",this.code=cg.code,this.type=cg.type}}co(cg,"code","ABORT_ERR"),co(cg,"type","aborted");class ug extends Error{constructor(e,t,r){var n;super(e),co(this,"code",void 0),co(this,"props",void 0),this.code=t,this.name=null!==(n=null===r||void 0===r?void 0:r.name)&&void 0!==n?n:"CodeError",this.props=null!==r&&void 0!==r?r:{}}}class lg extends AggregateError{constructor(e,t,r,n){var i;super(e,t),co(this,"code",void 0),co(this,"props",void 0),this.code=r,this.name=null!==(i=null===n||void 0===n?void 0:n.name)&&void 0!==i?i:"AggregateCodeError",this.props=null!==n&&void 0!==n?n:{}}}class hg extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected Peer"),co(this,"code",void 0),this.name="UnexpectedPeerError",this.code=hg.code}}co(hg,"code","ERR_UNEXPECTED_PEER");class dg extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),co(this,"code",void 0),this.name="InvalidCryptoExchangeError",this.code=dg.code}}co(dg,"code","ERR_INVALID_CRYPTO_EXCHANGE");class fg extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto transmission"),co(this,"code",void 0),this.name="InvalidCryptoTransmissionError",this.code=fg.code}}co(fg,"code","ERR_INVALID_CRYPTO_TRANSMISSION");const pg="ERR_TIMEOUT";var gg=__webpack_require__(45);new Uint8Array(0);function bg(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var yg=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const mg=yg;class vg{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class wg{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Eg(this,e)}}class _g{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return Eg(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function Eg(e,t){var r,n;return new _g({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Sg{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new vg(e,t,r),this.decoder=new wg(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Ag(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Sg(t,r,n,i)}function kg(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=mg(n,t);return Ag({prefix:r,name:t,encode:i,decode:e=>bg(o(e))})}function xg(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Ag({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Ig=kg({prefix:"9",name:"base10",alphabet:"0123456789"}),Cg=xg({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Tg=xg({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Rg=xg({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Pg=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Dg=Pg.reduce(((e,t,r)=>(e[r]=t,e)),[]),Ng=Pg.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Bg=Ag({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Dg[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Ng[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Ug=xg({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Lg=xg({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mg=xg({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Og=xg({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qg=xg({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Kg=xg({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fg=xg({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vg=xg({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zg=xg({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),jg=kg({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Hg=kg({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Gg=kg({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wg=kg({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Yg=xg({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qg=xg({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jg=xg({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xg=xg({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Zg=xg({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),$g=Ag({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),eb=new TextEncoder,tb=new TextDecoder,rb="json",nb=512;function ib(e){return eb.encode(JSON.stringify(e))}function ob(e){return JSON.parse(tb.decode(e))}const sb="raw",ab=85;function cb(e){return bg(e)}function ub(e){return bg(e)}var lb=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=fb;)r[n++]=255&t|hb,t/=128;for(;t&db;)r[n++]=255&t|hb,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},hb=128,db=-128,fb=Math.pow(2,31);var pb=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&bb)<<o:(n&bb)*Math.pow(2,o),o+=7}while(n>=gb);return e.bytes=s-r,i},gb=128,bb=127;var yb=Math.pow(2,7),mb=Math.pow(2,14),vb=Math.pow(2,21),wb=Math.pow(2,28),_b=Math.pow(2,35),Eb=Math.pow(2,42),Sb=Math.pow(2,49),Ab=Math.pow(2,56),kb=Math.pow(2,63);const xb={encode:lb,decode:pb,encodingLength:function(e){return e<yb?1:e<mb?2:e<vb?3:e<wb?4:e<_b?5:e<Eb?6:e<Sb?7:e<Ab?8:e<kb?9:10}};function Ib(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return xb.encode(e,t,r),t}function Cb(e){return xb.encodingLength(e)}function Tb(e,t){const r=t.byteLength,n=Cb(e),i=n+Cb(r),o=new Uint8Array(i+r);return Ib(e,o,0),Ib(r,o,n),o.set(t,i),new Rb(e,r,t,o)}class Rb{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Pb=bg;const Db={code:0,name:"identity",encode:Pb,digest:function(e){return Tb(0,Pb(e))}};function Nb(e){let{name:t,code:r,encode:n}=e;return new Bb(t,r,n)}class Bb{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Tb(this.code,t):t.then((e=>Tb(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Ub(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Lb=Nb({name:"sha2-256",code:18,encode:Ub("SHA-256")}),Mb=Nb({name:"sha2-512",code:19,encode:Ub("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Ob={...O,...P,...M,...T,...R,...N,...B,...U,...L,...D};function qb(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Kb(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Fb=Kb("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Vb=Kb("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=qb((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),zb={utf8:Fb,"utf-8":Fb,hex:Ob.base16,latin1:Vb,ascii:Vb,binary:Vb,...Ob};function jb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=zb[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function Hb(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}__webpack_require__(3900),__webpack_require__(9463);function Gb(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=qb(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Wb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=zb[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}function Yb(e,t){let r=Uint8Array.from(e.abs().toByteArray());if(r=0===r[0]?r.subarray(1):r,null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=Gb([new Uint8Array(t-r.length),r])}return Wb(r,"base64url")}function Qb(e){const t=function(e,t){let r=jb(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=Gb([new Uint8Array(t-r.length),r])}return r}(e);return new gg.jsbn.BigInteger(Wb(t,"base16"),16)}function Jb(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const Xb=32,Zb=64,$b=32;function ey(e,t){const r=new Uint8Array(Zb);for(let n=0;n<$b;n++)r[n]=e[n],r[$b+n]=t[n];return r}const ty={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},ry={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function ny(e,t){const r=function(e){var t,r,n,i,o,s;const a=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM";let c=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16;const u=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",h=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,d=null!==(s=null===e||void 0===e?void 0:e.iterations)&&void 0!==s?s:32767,f=ty.get();return c*=8,{encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(u)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=jb(t)),0===t.length){o=await f.subtle.importKey("jwk",ry,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}catch{o=await f.subtle.importKey("jwk",ry,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}const s=await f.subtle.encrypt(i,o,e);return Gb([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+u),i=e.subarray(h+u),o={name:a,iv:n};let s;if("string"===typeof t&&(t=jb(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}catch{s=await f.subtle.importKey("jwk",ry,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}const p=await f.subtle.decrypt(o,s,i);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return Yg.encode(n)}const iy=new Float32Array([-0]),oy=new Uint8Array(iy.buffer);function sy(e,t,r){iy[0]=e,t[r]=oy[0],t[r+1]=oy[1],t[r+2]=oy[2],t[r+3]=oy[3]}const ay=new Float64Array([-0]),cy=new Uint8Array(ay.buffer);function uy(e,t,r){ay[0]=e,t[r]=cy[0],t[r+1]=cy[1],t[r+2]=cy[2],t[r+3]=cy[3],t[r+4]=cy[4],t[r+5]=cy[5],t[r+6]=cy[6],t[r+7]=cy[7]}const ly=BigInt(Number.MAX_SAFE_INTEGER),hy=BigInt(Number.MIN_SAFE_INTEGER);class dy{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return fy;if(e<ly&&e>hy)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>py&&(n=0n,++r>py&&(r=0n))),new dy(Number(n),Number(r))}static fromNumber(e){if(0===e)return fy;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new dy(r,n)}static from(e){return"number"===typeof e?dy.fromNumber(e):"bigint"===typeof e?dy.fromBigInt(e):"string"===typeof e?dy.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new dy(e.low>>>0,e.high>>>0):fy}}const fy=new dy(0,0);fy.toBigInt=function(){return 0n},fy.zzEncode=fy.zzDecode=function(){return this},fy.length=function(){return 1};const py=4294967296n;function gy(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function by(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function yy(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class my{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,by(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw by(this,4);return yy(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw by(this,4);return 0|yy(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw by(this,4);const e=(t=this.buf,r=this.pos,oy[0]=t[r],oy[1]=t[r+1],oy[2]=t[r+2],oy[3]=t[r+3],iy[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw by(this,4);const e=(t=this.buf,r=this.pos,cy[0]=t[r],cy[1]=t[r+1],cy[2]=t[r+2],cy[3]=t[r+3],cy[4]=t[r+4],cy[5]=t[r+5],cy[6]=t[r+6],cy[7]=t[r+7],ay[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw by(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw by(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw by(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new dy(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw by(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw by(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw by(this,8);const e=yy(this.buf,this.pos+=4),t=yy(this.buf,this.pos+=4);return new dy(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function vy(e,t,r){const n=function(e){return new my(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class wy{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function _y(){}class Ey{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Sy=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return qb(e);i+e>t&&(n=qb(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class Ay{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new wy(_y,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new wy(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Iy((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Cy,10,dy.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=dy.fromBigInt(e);return this._push(Cy,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=dy.fromBigInt(e).zzEncode();return this._push(Cy,t.length(),t)}sint64Number(e){const t=dy.fromNumber(e).zzEncode();return this._push(Cy,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ky,1,e?1:0)}fixed32(e){return this._push(Ty,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=dy.fromBigInt(e);return this._push(Ty,4,t.lo)._push(Ty,4,t.hi)}fixed64Number(e){const t=dy.fromNumber(e);return this._push(Ty,4,t.lo)._push(Ty,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(sy,4,e)}double(e){return this._push(uy,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(ky,1,0):this.uint32(t)._push(Ry,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(gy,t,e):this._push(ky,1,0)}fork(){return this.states=new Ey(this),this.head=this.tail=new wy(_y,0,0),this.len=0,this}reset(){return null!=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 wy(_y,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?qb(r):Sy(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function ky(e,t,r){t[r]=255&e}function xy(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Iy extends wy{constructor(e,t){super(xy,e,t),co(this,"next",void 0),this.next=void 0}}function Cy(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Ty(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Ry(e,t,r){t.set(e,r)}function Py(e,t,r){t.set(e,r)}function Dy(e,t,r){e.length<40?gy(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(jb(e),r)}function Ny(e,t){const r=new Ay;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var By,Uy,Ly,My,Oy;function qy(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Ky(e,t){return qy("message",By.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Ay.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Py,t,e),this},Ay.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Dy,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(By||(By={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(Uy||(Uy={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(Ly||(Ly={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return qy("enum",By.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(Ly)}(Uy||(Uy={})),function(e){let t;e.codec=()=>(null==t&&(t=Ky((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),Uy.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=Uy.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ny(t,e.codec()),e.decode=t=>vy(t,e.codec())}(My||(My={})),function(e){let t;e.codec=()=>(null==t&&(t=Ky((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),Uy.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=Uy.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ny(t,e.codec()),e.decode=t=>vy(t,e.codec())}(Oy||(Oy={}));class Fy{constructor(e){co(this,"_key",void 0),this._key=Wy(e,Xb)}verify(e,t){return function(e,t,r){return Wp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return My.encode({Type:Uy.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Hb(this.bytes,e.bytes)}hash(){const e=Lb.digest(this.bytes);return Jb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Vy{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=Wy(e,Zb),this._publicKey=Wy(t,Xb)}sign(e){return function(e,t){const r=e.subarray(0,$b);return Wp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new Fy(this._publicKey)}marshal(){return this._key}get bytes(){return Oy.encode({Type:Uy.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Hb(this.bytes,e.bytes)}async hash(){const e=Lb.digest(this.bytes);let t;return Jb(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=Db.digest(this.public.bytes);return Gg.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return ny(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function zy(e){if(e.length>Zb){const t=(e=Wy(e,Zb+Xb)).subarray(0,Zb),r=e.subarray(Zb,e.length);return new Vy(t,r)}const t=(e=Wy(e,Zb)).subarray(0,Zb),r=e.subarray(Xb);return new Vy(t,r)}function jy(e){return e=Wy(e,Xb),new Fy(e)}async function Hy(){const{privateKey:e,publicKey:t}=function(){const e=Wp.utils.randomPrivateKey(),t=Wp.getPublicKey(e);return{privateKey:ey(e,t),publicKey:t}}();return new Vy(e,t)}async function Gy(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==$b)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Wp.getPublicKey(t);return{privateKey:ey(t,r),publicKey:r}}(e);return new Vy(t,r)}function Wy(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ug("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}const Yy={"P-256":256,"P-384":384,"P-521":521};Object.keys(Yy).join(" / ");__webpack_require__(8138);__webpack_require__(9408);function Qy(e,t){return t.map((t=>Qb(e[t])))}async function Jy(e){const t=[await ty.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Zy(e)],r=await Xy({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function Xy(e){if(null==e.privateKey||null==e.publicKey)throw new ug("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([ty.get().subtle.exportKey("jwk",e.privateKey),ty.get().subtle.exportKey("jwk",e.publicKey)])}async function Zy(e){return ty.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function $y(e,t,r,n){const i=t?function(e){return gg.pki.setRsaPublicKey(...Qy(e,["n","e"]))}(e):function(e){return gg.pki.setRsaPrivateKey(...Qy(e,["n","e","d","p","q","dp","dq","qi"]))}(e);return jb(n(Wb(r instanceof Uint8Array?r:r.subarray(),"ascii"),i),"ascii")}function em(e){if("RSA"!==e.kty)throw new ug("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ug("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*jb(e.n,"base64url").length}const tm=8192;class rm{constructor(e){co(this,"_key",void 0),this._key=e}verify(e,t){return async function(e,t,r){const n=await ty.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ty.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=gg.pki.publicKeyToAsn1({n:Qb(e.n),e:Qb(e.e)});return jb(gg.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return My.encode({Type:Uy.RSA,Data:this.marshal()}).subarray()}encrypt(e){return $y(this._key,!0,e,((e,t)=>t.encrypt(e)))}equals(e){return Hb(this.bytes,e.bytes)}hash(){const e=Lb.digest(this.bytes);return Jb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class nm{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return function(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}(16)}sign(e){return async function(e,t){const r=await ty.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ty.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ug("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new rm(this._publicKey)}decrypt(e){return $y(this._key,!1,e,((e,t)=>t.decrypt(e)))}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=gg.pki.privateKeyToAsn1({n:Qb(e.n),e:Qb(e.e),d:Qb(e.d),p:Qb(e.p),q:Qb(e.q),dP:Qb(e.dp),dQ:Qb(e.dq),qInv:Qb(e.qi)});return jb(gg.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return Oy.encode({Type:Uy.RSA,Data:this.marshal()}).subarray()}equals(e){return Hb(this.bytes,e.bytes)}hash(){const e=Lb.digest(this.bytes);return Jb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Wb(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t){const t=new gg.util.ByteBuffer(this.marshal()),r=gg.asn1.fromDer(t),n=gg.pki.privateKeyFromAsn1(r),i={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return gg.pki.encryptRsaPrivateKey(n,e,i)}if("libp2p-key"===t)return ny(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function im(e){const t=function(e){const t=gg.asn1.fromDer(Wb(e,"ascii")),r=gg.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:Yb(r.n),e:Yb(r.e),d:Yb(r.d),p:Yb(r.p),q:Yb(r.q),dp:Yb(r.dP),dq:Yb(r.dQ),qi:Yb(r.qInv),alg:"RS256"}}(e);if(em(t)>tm)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await Jy(t);return new nm(r.privateKey,r.publicKey)}function om(e){const t=function(e){const t=gg.asn1.fromDer(Wb(e,"ascii")),r=gg.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:Yb(r.n),e:Yb(r.e)}}(e);if(em(t)>tm)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new rm(t)}async function sm(e){if(em(e)>tm)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await Jy(e);return new nm(t.privateKey,t.publicKey)}async function am(e){if(e>tm)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await ty.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Xy(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new nm(t.privateKey,t.publicKey)}const{bytesToNumberBE:cm,hexToBytes:um}=C,lm={Err:class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}},_parseInt(e){const{Err:t}=lm;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const r=e[1],n=e.subarray(2,r+2);if(!r||n.length!==r)throw new t("Invalid signature integer: wrong length");if(128&n[0])throw new t("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:cm(n),l:e.subarray(r+2)}},toSig(e){const{Err:t}=lm,r="string"===typeof e?um(e):e;Mf(r);let n=r.length;if(n<2||48!=r[0])throw new t("Invalid signature tag");if(r[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:i,l:o}=lm._parseInt(r.subarray(2)),{d:s,l:a}=lm._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,r=e=>{const t=e.toString(16);return 1&t.length?"0".concat(t):t},n=t(r(e.s)),i=t(r(e.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return"30".concat(r(s+o+4),"02").concat(c).concat(i,"02").concat(a).concat(n)}},hm=BigInt(0),dm=BigInt(1),fm=(BigInt(2),BigInt(3));BigInt(4);function pm(e){const t=function(e){const t=Sp(e);tp(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=t;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!==typeof r||"bigint"!==typeof r.beta||"function"!==typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:r}=t,n=t.toBytes||((e,t,n)=>{const i=t.toAffine();return Qf(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function o(e){const{a:n,b:i}=t,o=r.sqr(e),s=r.mul(o,e);return r.add(r.add(s,r.mul(e,n)),i)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"===typeof e&&hm<e&&e<t.n}function a(e){if(!s(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=t;if(r&&"bigint"!==typeof e){if(Lf(e)&&(e=qf(e)),"string"!==typeof e||!r.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*n,"0")}let s;try{s="bigint"===typeof e?e:jf(Yf("private key",e,n))}catch(c){throw new Error("private key must be ".concat(n," bytes, hex or bigint, not ").concat(typeof e))}return i&&(s=up(s,o)),a(s),s}const u=new Map;function l(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const i=e=>r.eql(e,r.ZERO);return i(t)&&i(n)?h.ZERO:new h(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(Yf("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:n}=this.toAffine();if(!r.isValid(e)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(e);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:n,pz:i}=this,{px:o,py:s,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(o,i)),u=r.eql(r.mul(n,a),r.mul(s,i));return c&&u}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,fm),{px:o,py:s,pz:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,d=r.mul(o,o),f=r.mul(s,s),p=r.mul(a,a),g=r.mul(o,s);return g=r.add(g,g),l=r.mul(o,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(i,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),u=r.mul(c,u),c=r.mul(g,c),l=r.mul(i,l),p=r.mul(e,p),g=r.sub(d,p),g=r.mul(e,g),g=r.add(g,l),l=r.add(d,d),d=r.add(l,d),d=r.add(d,p),d=r.mul(d,g),u=r.add(u,d),p=r.mul(s,a),p=r.add(p,p),d=r.mul(p,g),c=r.sub(c,d),l=r.mul(p,f),l=r.add(l,l),l=r.add(l,l),new h(c,u,l)}add(e){l(e);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:c}=e;let u=r.ZERO,d=r.ZERO,f=r.ZERO;const p=t.a,g=r.mul(t.b,fm);let b=r.mul(n,s),y=r.mul(i,a),m=r.mul(o,c),v=r.add(n,i),w=r.add(s,a);v=r.mul(v,w),w=r.add(b,y),v=r.sub(v,w),w=r.add(n,o);let _=r.add(s,c);return w=r.mul(w,_),_=r.add(b,m),w=r.sub(w,_),_=r.add(i,o),u=r.add(a,c),_=r.mul(_,u),u=r.add(y,m),_=r.sub(_,u),f=r.mul(p,w),u=r.mul(g,m),f=r.add(u,f),u=r.sub(y,f),f=r.add(y,f),d=r.mul(u,f),y=r.add(b,b),y=r.add(y,b),m=r.mul(p,m),w=r.mul(g,w),y=r.add(y,m),m=r.sub(b,m),m=r.mul(p,m),w=r.add(w,m),b=r.mul(y,w),d=r.add(d,b),b=r.mul(_,w),u=r.mul(v,u),u=r.sub(u,b),b=r.mul(v,y),f=r.mul(_,f),f=r.add(f,b),new h(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return f.wNAFCached(this,u,e,(e=>{const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}))}multiplyUnsafe(e){const n=h.ZERO;if(e===hm)return n;if(a(e),e===dm)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:c,k2:u}=i.splitScalar(e),l=n,d=n,p=this;for(;s>hm||u>hm;)s&dm&&(l=l.add(p)),u&dm&&(d=d.add(p)),p=p.double(),s>>=dm,u>>=dm;return o&&(l=l.negate()),c&&(d=d.negate()),d=new h(r.mul(d.px,i.beta),d.py,d.pz),l.add(d)}multiply(e){a(e);let n,i,o=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(o);let{p:u,f:l}=this.wNAF(t),{p:d,f:p}=this.wNAF(c);u=f.constTimeNegate(e,u),d=f.constTimeNegate(a,d),d=new h(r.mul(d.px,s.beta),d.py,d.pz),n=u.add(d),i=l.add(p)}else{const{p:e,f:t}=this.wNAF(o);n=e,i=t}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(e,t,r){const n=h.BASE,i=(e,t)=>t!==hm&&t!==dm&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,r));return o.is0()?void 0:o}toAffine(e){const{px:t,py:n,pz:i}=this,o=this.is0();null==e&&(e=o?r.ONE:r.inv(i));const s=r.mul(t,e),a=r.mul(n,e),c=r.mul(i,e);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===dm)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===dm?this:r?r(h,this):this.multiplyUnsafe(t.h)}toRawBytes(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.assertValidity(),n(h,this,e)}toHex(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return qf(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const d=t.nBitLength,f=Ep(h,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function gm(e){const t=function(e){const t=Sp(e);return tp(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n:n}=t,i=r.BYTES+1,o=2*r.BYTES+1;function s(e){return up(e,n)}function a(e){return dp(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=pm({...t,toBytes(e,t,n){const i=t.toAffine(),o=r.toBytes(i.x),s=Qf;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],s=e.subarray(1);if(t!==i||2!==n&&3!==n){if(t===o&&4===n){return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))}}throw new Error("Point of length ".concat(t," was invalid. Expected ").concat(i," compressed bytes or ").concat(o," uncompressed bytes"))}{const e=jf(s);if(!(hm<(a=e)&&a<r.ORDER))throw new Error("Point is not on curve");const t=l(e);let i;try{i=r.sqrt(t)}catch(c){const e=c instanceof Error?": "+c.message:"";throw new Error("Point is not on curve"+e)}return 1===(1&n)!==((i&dm)===dm)&&(i=r.neg(i)),{x:e,y:i}}var a}}),d=e=>qf(Gf(e,t.nByteLength));function f(e){return e>n>>dm}const p=(e,t,r)=>jf(e.slice(t,r));class g{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const r=t.nByteLength;return e=Yf("compactSignature",e,2*r),new g(p(e,0,r),p(e,r,2*r))}static fromDER(e){const{r:t,s:r}=lm.toSig(Yf("DER",e));return new g(t,r)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:i,recovery:o}=this,u=v(Yf("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const l=2===o||3===o?n+t.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=0===(1&o)?"02":"03",f=c.fromHex(h+d(l)),p=a(l),g=s(-u*p),b=s(i*p),y=c.BASE.multiplyAndAddUnsafe(f,g,b);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return zf(this.toDERHex())}toDERHex(){return lm.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zf(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const b={isValidPrivateKey(e){try{return u(e),!0}catch(t){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=vp(t.n);return function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=e.length,i=mp(t),o=vp(t);if(n<16||n<o||n>1024)throw new Error("expected ".concat(o,"-1024 bytes of input, got ").concat(n));const s=up(r?jf(e):Hf(e),t-np)+np;return r?Wf(s,i):Gf(s,i)}(t.randomBytes(e),t.n)},precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e){const t=Lf(e),r="string"===typeof e,n=(t||r)&&e.length;return t?n===i||n===o:r?n===2*i||n===2*o:e instanceof c}const m=t.bits2int||function(e){const r=jf(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},v=t.bits2int_modN||function(e){return s(m(e))},w=Jf(t.nBitLength);function _(e){if("bigint"!==typeof e)throw new Error("bigint expected");if(!(hm<=e&&e<w))throw new Error("bigint expected < 2^".concat(t.nBitLength));return Gf(e,t.nByteLength)}function E(e,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S;if(["recovered","canonical"].some((e=>e in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=t;let{lowS:d,prehash:p,extraEntropy:b}=i;null==d&&(d=!0),e=Yf("msgHash",e),p&&(e=Yf("prehashed msgHash",o(e)));const y=v(e),w=u(n),E=[_(w),_(y)];if(null!=b&&!1!==b){const e=!0===b?l(r.BYTES):b;E.push(Yf("extraEntropy",e))}const A=Qf(...E),k=y;return{seed:A,k2sig:function(e){const t=m(e);if(!h(t))return;const r=a(t),n=c.BASE.multiply(t).toAffine(),i=s(n.x);if(i===hm)return;const o=s(r*s(k+i*w));if(o===hm)return;let u=(n.x===i?0:2)|Number(n.y&dm),l=o;return d&&f(o)&&(l=function(e){return f(e)?s(-e):e}(o),u^=1),new g(i,l,u)}}}const S={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(r)},sign:function(e,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S;const{seed:i,k2sig:o}=E(e,r,n),s=t;return $f(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(e,r,n){var i;let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:A;const u=e;if(r=Yf("msgHash",r),n=Yf("publicKey",n),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:h}=o;let d,f;try{if("string"===typeof u||Lf(u))try{d=g.fromDER(u)}catch(S){if(!(S instanceof lm.Err))throw S;d=g.fromCompact(u)}else{if("object"!==typeof u||"bigint"!==typeof u.r||"bigint"!==typeof u.s)throw new Error("PARSE");{const{r:e,s:t}=u;d=new g(e,t)}}f=c.fromHex(n)}catch(k){if("PARSE"===k.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&d.hasHighS())return!1;h&&(r=t.hash(r));const{r:p,s:b}=d,y=v(r),m=a(b),w=s(y*m),_=s(p*m),E=null===(i=c.BASE.multiplyAndAddUnsafe(f,w,_))||void 0===i?void 0:i.toAffine();return!!E&&s(E.x)===p},ProjectivePoint:c,Signature:g,utils:b}}function bm(e){return{hash:e,hmac:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return Zp(e,t,Ic(...n))},randomBytes:Pc}}const ym=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),mm=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),vm=BigInt(1),wm=BigInt(2),_m=(e,t)=>(e+t/wm)/t;function Em(e){const t=ym,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,h=hp(l,r,t)*l%t,d=hp(h,r,t)*l%t,f=hp(d,wm,t)*u%t,p=hp(f,i,t)*f%t,g=hp(p,o,t)*p%t,b=hp(g,a,t)*g%t,y=hp(b,c,t)*b%t,m=hp(y,a,t)*g%t,v=hp(m,r,t)*l%t,w=hp(v,s,t)*p%t,_=hp(w,n,t)*u%t,E=hp(_,wm,t);if(!Sm.eql(Sm.sqr(E),e))throw new Error("Cannot find square root");return E}const Sm=yp(ym,void 0,void 0,{sqrt:Em}),Am=function(e,t){const r=t=>gm({...e,...bm(t)});return Object.freeze({...r(t),create:r})}({a:BigInt(0),b:BigInt(7),Fp:Sm,n:mm,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=mm,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-vm*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=_m(o*e,t),c=_m(-n*e,t);let u=up(e-a*r-c*i,t),l=up(-a*n-c*o,t);const h=u>s,d=l>s;if(h&&(u=t-u),d&&(l=t-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:u,k2neg:d,k2:l}}}},Oc);BigInt(0);Am.ProjectivePoint;function km(e){try{Am.ProjectivePoint.fromHex(e)}catch(t){throw new ug(String(t),"ERR_INVALID_PUBLIC_KEY")}}class xm{constructor(e){co(this,"_key",void 0),km(e),this._key=e}verify(e,t){return function(e,t,r){const n=Lb.digest(r instanceof Uint8Array?r:r.subarray());if(Jb(n))return n.then((r=>{let{digest:n}=r;return Am.verify(t,n,e)})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.verify(t,n.digest,e)}catch(i){throw new ug(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,Am.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return My.encode({Type:Uy.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Hb(this.bytes,e.bytes)}async hash(){const e=Lb.digest(this.bytes);let t;return Jb(e)?({bytes:t}=await e):t=e.bytes,t}}class Im{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),km(this._publicKey)}sign(e){return function(e,t){const r=Lb.digest(t instanceof Uint8Array?t:t.subarray());if(Jb(r))return r.then((t=>{let{digest:r}=t;return Am.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.sign(r.digest,e).toDERRawBytes()}catch(n){throw new ug(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new xm(this._publicKey)}marshal(){return this._key}get bytes(){return Oy.encode({Type:Uy.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Hb(this.bytes,e.bytes)}hash(){const e=Lb.digest(this.bytes);return Jb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Wb(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return ny(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function Cm(e){return new Im(e)}function Tm(e){return new xm(e)}async function Rm(){const e=Am.utils.randomPrivateKey();return new Im(e)}const Pm={rsa:j,ed25519:z,secp256k1:H};function Dm(e){const t=Object.keys(Pm).join(" / ");return new ug("invalid or unsupported key type ".concat(e,". Must be ").concat(t),"ERR_UNSUPPORTED_KEY_TYPE")}async function Nm(e){var t,r;const n=Oy.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case Uy.RSA:return Pm.rsa.unmarshalRsaPrivateKey(i);case Uy.Ed25519:return Pm.ed25519.unmarshalEd25519PrivateKey(i);case Uy.Secp256k1:return Pm.secp256k1.unmarshalSecp256k1PrivateKey(i);default:throw Dm(null!==(r=n.Type)&&void 0!==r?r:"RSA")}}const Bm=Symbol.for("@libp2p/peer-id");function Um(e){return null!=e&&Boolean(e[Bm])}new Uint8Array(0);function Lm(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Mm=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Om=Mm;class qm{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Km{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Vm(this,e)}}class Fm{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return Vm(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function Vm(e,t){var r,n;return new Fm({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class zm{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new qm(e,t,r),this.decoder=new Km(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function jm(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new zm(t,r,n,i)}function Hm(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Om(n,t);return jm({prefix:r,name:t,encode:i,decode:e=>Lm(o(e))})}function Gm(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return jm({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Wm=Hm({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ym=Hm({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Qm=Hm({prefix:"9",name:"base10",alphabet:"0123456789"}),Jm=Gm({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Xm=Gm({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Zm=Gm({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$m=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),ev=$m.reduce(((e,t,r)=>(e[r]=t,e)),[]),tv=$m.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const rv=jm({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ev[t]),"")},decode:function(e){const t=[];for(const r of e){const e=tv[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),nv=Gm({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),iv=Gm({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ov=Gm({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sv=Gm({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),av=Gm({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cv=Gm({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),uv=Gm({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lv=Gm({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),hv=Gm({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),dv=Hm({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fv=Hm({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),pv=Gm({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gv=Gm({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bv=Gm({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yv=Gm({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),mv=Gm({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),vv=jm({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),wv=new TextEncoder,_v=new TextDecoder,Ev="json",Sv=512;function Av(e){return wv.encode(JSON.stringify(e))}function kv(e){return JSON.parse(_v.decode(e))}const xv="raw",Iv=85;function Cv(e){return Lm(e)}function Tv(e){return Lm(e)}var Rv=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Nv;)r[n++]=255&t|Pv,t/=128;for(;t&Dv;)r[n++]=255&t|Pv,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Pv=128,Dv=-128,Nv=Math.pow(2,31);var Bv=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Lv)<<o:(n&Lv)*Math.pow(2,o),o+=7}while(n>=Uv);return e.bytes=s-r,i},Uv=128,Lv=127;var Mv=Math.pow(2,7),Ov=Math.pow(2,14),qv=Math.pow(2,21),Kv=Math.pow(2,28),Fv=Math.pow(2,35),Vv=Math.pow(2,42),zv=Math.pow(2,49),jv=Math.pow(2,56),Hv=Math.pow(2,63);const Gv={encode:Rv,decode:Bv,encodingLength:function(e){return e<Mv?1:e<Ov?2:e<qv?3:e<Kv?4:e<Fv?5:e<Vv?6:e<zv?7:e<jv?8:e<Hv?9:10}};function Wv(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[Gv.decode(e,t),Gv.decode.bytes]}function Yv(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Gv.encode(e,t,r),t}function Qv(e){return Gv.encodingLength(e)}function Jv(e,t){const r=t.byteLength,n=Qv(e),i=n+Qv(r),o=new Uint8Array(i+r);return Yv(e,o,0),Yv(r,o,n),o.set(t,i),new Zv(e,r,t,o)}function Xv(e){const t=Lm(e),[r,n]=Wv(t),[i,o]=Wv(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Zv(r,i,s,t)}class Zv{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const $v=Lm;const ew={code:0,name:"identity",encode:$v,digest:function(e){return Jv(0,$v(e))}};function tw(e){let{name:t,code:r,encode:n}=e;return new rw(t,r,n)}class rw{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Jv(this.code,t):t.then((e=>Jv(this.code,e)))}throw Error("Unknown type, must be binary type")}}function nw(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const iw=tw({name:"sha2-256",code:18,encode:nw("SHA-256")}),ow=tw({name:"sha2-512",code:19,encode:nw("SHA-512")});function sw(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==Wm.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,cw(e),null!==t&&void 0!==t?t:Wm.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,cw(e),null!==t&&void 0!==t?t:nv.encoder)}const aw=new WeakMap;function cw(e){const t=aw.get(e);if(null==t){const t=new Map;return aw.set(e,t),t}return t}class uw{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==lw)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==hw)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return uw.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Jv(e,t);return uw.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return uw.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return sw(this,e)}toJSON(){return{"/":sw(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof uw)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new uw(e,r,n,null!==i&&void 0!==i?i:dw(e,r,n.bytes))}if(!0===t[fw]){const{version:e,multihash:r,code:n}=t,i=Xv(r);return uw.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==lw)throw new Error("Version 0 CID must use dag-pb (code: ".concat(lw,") block encoding"));return new uw(e,t,r,r.bytes);case 1:{const n=dw(e,t,r.bytes);return new uw(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return uw.create(0,lw,e)}static createV1(e,t){return uw.create(1,e,t)}static decode(e){const[t,r]=uw.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=uw.inspectBytes(e),r=t.size-t.multihashSize,n=Lm(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new Zv(t.multihashCode,t.digestSize,i,n);return[0===t.version?uw.createV0(o):uw.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Wv(e.subarray(t));return t+=n,r};let n=r(),i=lw;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:Wm;return[Wm.prefix,r.decode("".concat(Wm.prefix).concat(e))]}case Wm.prefix:{const r=null!==t&&void 0!==t?t:Wm;return[Wm.prefix,r.decode(e)]}case nv.prefix:{const r=null!==t&&void 0!==t?t:nv;return[nv.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=uw.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return cw(i).set(r,e),i}}const lw=112,hw=18;function dw(e,t,r){const n=Qv(e),i=n+Qv(t),o=new Uint8Array(i+r.byteLength);return Yv(e,o,0),Yv(t,o,n),o.set(r,i),o}const fw=Symbol.for("@ipld/js-cid/CID"),pw={...te,...Q,...ee,...W,...Y,...X,...Z,...G,...$,...J};function gw(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const bw=Symbol.for("nodejs.util.inspect.custom"),yw=Object.values(pw).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),pw.identity.decoder),mw=114,vw=36,ww=37;class _w{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=Wm.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return uw.createV1(mw,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return gw(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:yw,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=Xv(Wm.decode("z".concat(e)));return e.startsWith("12D")?new Sw({multihash:t}):e.startsWith("16U")?new Aw({multihash:t}):new Ew({multihash:t})}return function(e){try{const t=Xv(e);if(t.code===ew.code){if(t.digest.length===vw)return new Sw({multihash:t});if(t.digest.length===ww)return new Aw({multihash:t})}if(t.code===iw.code)return new Ew({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==mw)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===iw.code)return new Ew({multihash:e.multihash});if(t.code===ew.code){if(t.digest.length===vw)return new Sw({multihash:e.multihash});if(t.digest.length===ww)return new Aw({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(uw.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(yw.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return gw(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[bw](){return"PeerId(".concat(this.toString(),")")}}class Ew extends _w{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class Sw extends _w{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class Aw extends _w{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}async function kw(e,t){return e.length===vw?new Sw({multihash:Jv(ew.code,e),privateKey:t}):e.length===ww?new Aw({multihash:Jv(ew.code,e),privateKey:t}):new Ew({multihash:await iw.digest(e),publicKey:e,privateKey:t})}function xw(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Iw=xw("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Cw=xw("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Ld((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Tw={utf8:Iw,"utf-8":Iw,hex:pw.base16,latin1:Cw,ascii:Cw,binary:Cw,...pw};function Rw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Tw[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}const Pw=new Float32Array([-0]),Dw=new Uint8Array(Pw.buffer);function Nw(e,t,r){Pw[0]=e,t[r]=Dw[0],t[r+1]=Dw[1],t[r+2]=Dw[2],t[r+3]=Dw[3]}const Bw=new Float64Array([-0]),Uw=new Uint8Array(Bw.buffer);function Lw(e,t,r){Bw[0]=e,t[r]=Uw[0],t[r+1]=Uw[1],t[r+2]=Uw[2],t[r+3]=Uw[3],t[r+4]=Uw[4],t[r+5]=Uw[5],t[r+6]=Uw[6],t[r+7]=Uw[7]}const Mw=BigInt(Number.MAX_SAFE_INTEGER),Ow=BigInt(Number.MIN_SAFE_INTEGER);class qw{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return Kw;if(e<Mw&&e>Ow)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Fw&&(n=0n,++r>Fw&&(r=0n))),new qw(Number(n),Number(r))}static fromNumber(e){if(0===e)return Kw;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new qw(r,n)}static from(e){return"number"===typeof e?qw.fromNumber(e):"bigint"===typeof e?qw.fromBigInt(e):"string"===typeof e?qw.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new qw(e.low>>>0,e.high>>>0):Kw}}const Kw=new qw(0,0);Kw.toBigInt=function(){return 0n},Kw.zzEncode=Kw.zzDecode=function(){return this},Kw.length=function(){return 1};const Fw=4294967296n;function Vw(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function zw(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function jw(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Hw{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,zw(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw zw(this,4);return jw(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw zw(this,4);return 0|jw(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw zw(this,4);const e=(t=this.buf,r=this.pos,Dw[0]=t[r],Dw[1]=t[r+1],Dw[2]=t[r+2],Dw[3]=t[r+3],Pw[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw zw(this,4);const e=(t=this.buf,r=this.pos,Uw[0]=t[r],Uw[1]=t[r+1],Uw[2]=t[r+2],Uw[3]=t[r+3],Uw[4]=t[r+4],Uw[5]=t[r+5],Uw[6]=t[r+6],Uw[7]=t[r+7],Bw[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw zw(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw zw(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw zw(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new qw(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw zw(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw zw(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw zw(this,8);const e=jw(this.buf,this.pos+=4),t=jw(this.buf,this.pos+=4);return new qw(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function Gw(e,t,r){const n=function(e){return new Hw(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class Ww{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Yw(){}class Qw{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Jw=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return Ld(e);i+e>t&&(n=Ld(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class Xw{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new Ww(Yw,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Ww(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new e_((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(t_,10,qw.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=qw.fromBigInt(e);return this._push(t_,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=qw.fromBigInt(e).zzEncode();return this._push(t_,t.length(),t)}sint64Number(e){const t=qw.fromNumber(e).zzEncode();return this._push(t_,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Zw,1,e?1:0)}fixed32(e){return this._push(r_,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=qw.fromBigInt(e);return this._push(r_,4,t.lo)._push(r_,4,t.hi)}fixed64Number(e){const t=qw.fromNumber(e);return this._push(r_,4,t.lo)._push(r_,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Nw,4,e)}double(e){return this._push(Lw,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Zw,1,0):this.uint32(t)._push(n_,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Vw,t,e):this._push(Zw,1,0)}fork(){return this.states=new Qw(this),this.head=this.tail=new Ww(Yw,0,0),this.len=0,this}reset(){return null!=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 Ww(Yw,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?Ld(r):Jw(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Zw(e,t,r){t[r]=255&e}function $w(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class e_ extends Ww{constructor(e,t){super($w,e,t),co(this,"next",void 0),this.next=void 0}}function t_(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function r_(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n_(e,t,r){t.set(e,r)}function i_(e,t,r){t.set(e,r)}function o_(e,t,r){e.length<40?Vw(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(Rw(e),r)}function s_(e,t){const r=new Xw;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var a_,c_,u_;function l_(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",a_.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Xw.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(i_,t,e),this},Xw.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(o_,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(a_||(a_={}));Error;async function h_(e,t,r){const n=await async function(e,t){if(null==e.privateKey)throw new Error("PrivateKey was missing from PeerId");const r=await Nm(e.privateKey);return r.sign(t)}(e,p_(t));if(null==e.publicKey)throw new Error("PublicKey was missing from local PeerId");return function(e,t,r){return u_.encode({identityKey:e,identitySig:t,extensions:null!==r&&void 0!==r?r:{webtransportCerthashes:[]}}).subarray()}(e.publicKey,n,r)}async function d_(e){return kw(e.identityKey)}function f_(e){return u_.decode(e)}function p_(e){const t=Rw("noise-libp2p-static-key:");return e instanceof Uint8Array?function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=Ld(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}([t,e],t.length+e.length):(e.prepend(t),e)}async function g_(e,t,r){const n=await kw(t.identityKey);if(!n.equals(r))throw new Error("Payload identity key ".concat(n.toString()," does not match expected remote peer ").concat(r.toString()));const i=p_(e);if(null==n.publicKey)throw new Error("PublicKey was missing from PeerId");if(null==t.identitySig)throw new Error("Signature was missing from message");const o=function(e){var t,r;const n=My.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case Uy.RSA:return Pm.rsa.unmarshalRsaPublicKey(i);case Uy.Ed25519:return Pm.ed25519.unmarshalEd25519PublicKey(i);case Uy.Secp256k1:return Pm.secp256k1.unmarshalSecp256k1PublicKey(i);default:throw Dm(null!==(r=n.Type)&&void 0!==r?r:"unknown")}}(n.publicKey);if(!await o.verify(i,t.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return n}function b_(e){return!!(e instanceof Uint8Array||rh(e))&&32===e.byteLength}function y_(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Tw[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}!function(e){let t;e.codec=()=>(null==t&&(t=l_((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.webtransportCerthashes)for(const n of e.webtransportCerthashes)t.uint32(10),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={webtransportCerthashes:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.webtransportCerthashes.push(e.bytes());else e.skipType(7&t)}return r}))),t),e.encode=t=>s_(t,e.codec()),e.decode=t=>Gw(t,e.codec())}(c_||(c_={})),function(e){let t;e.codec=()=>(null==t&&(t=l_((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.identityKey&&e.identityKey.byteLength>0&&(t.uint32(10),t.bytes(e.identityKey)),null!=e.identitySig&&e.identitySig.byteLength>0&&(t.uint32(18),t.bytes(e.identitySig)),null!=e.extensions&&(t.uint32(34),c_.codec().encode(e.extensions,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={identityKey:Ud(0),identitySig:Ud(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.identityKey=e.bytes();break;case 2:r.identitySig=e.bytes();break;case 4:r.extensions=c_.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>s_(t,e.codec()),e.decode=t=>Gw(t,e.codec())}(u_||(u_={}));class m_{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;co(this,"n",void 0),co(this,"bytes",void 0),co(this,"view",void 0),this.n=e,this.bytes=Ud(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}class v_{constructor(e,t){co(this,"crypto",void 0),co(this,"log",void 0),this.log=e.logger.forComponent("libp2p:noise:abstract-handshake"),this.crypto=t}encryptWithAd(e,t,r){const n=this.encrypt(e.k,e.n,t,r);return e.n.increment(),n}decryptWithAd(e,t,r,n){const{plaintext:i,valid:o}=this.decrypt(e.k,e.n,t,r,n);return o&&e.n.increment(),{plaintext:i,valid:o}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return Ud(32)}isEmptyKey(e){return gw(this.createEmptyKey(),e)}encrypt(e,t,r,n){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(n,t.getBytes(),r,e)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,n,i){t.assertValue();const o=this.crypto.chaCha20Poly1305Decrypt(n,t.getBytes(),r,e,i);return o?{plaintext:o,valid:!0}:{plaintext:Ud(0),valid:!1}}decryptAndHash(e,t){let r,n=!0;return this.hasKey(e.cs)?({plaintext:r,valid:n}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:n}}dh(e,t){try{const r=this.crypto.generateX25519SharedKey(e,t);return 32===r.length?r:r.subarray(0,32)}catch(r){const e=r;return this.log.error("error deriving shared key",e),Ud(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(new nh(e,t))}mixKey(e,t){const[r,n]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(n),e.ck=r}initializeKey(e){return{k:e,n:new m_}}initializeSymmetric(e){const t=Rw(e,"utf-8"),r=this.hashProtocolName(t),n=r,i=this.createEmptyKey();return{cs:this.initializeKey(i),ck:n,h:r}}hashProtocolName(e){if(e.length<=32){const t=Ud(32);return t.set(e),t}return this.getHash(e,Ud(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,Ud(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,Ud(0),t);return{ne:this.createEmptyKey(),ns:Ud(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,Ud(0),t.ciphertext)}}class w_ extends v_{initializeInitiator(e,t,r,n){const i=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(i,e);return{ss:i,s:t,rs:r,psk:n,re:Ud(32)}}initializeResponder(e,t,r,n){const i=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(i,e);return{ss:i,s:t,rs:r,psk:n,re:Ud(32)}}writeMessageA(e,t,r){const n=Ud(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const i=e.e.publicKey;this.mixHash(e.ss,i);return{ne:i,ns:n,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const n=e.s.publicKey,i=this.encryptAndHash(e.ss,n);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));return{ne:r,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const r=e.s.publicKey,n=this.encryptAndHash(e.ss,r);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const i=this.encryptAndHash(e.ss,t),o={ne:this.createEmptyKey(),ns:n,ciphertext:i},{cs1:s,cs2:a}=this.split(e.ss);return{h:e.ss.h,messageBuffer:o,cs1:s,cs2:a}}readMessageA(e,t){return b_(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(b_(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:n}=this.decryptAndHash(e.ss,t.ns);n&&b_(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:i,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:i,valid:n&&o}}readMessageC(e,t){const{plaintext:r,valid:n}=this.decryptAndHash(e.ss,t.ns);if(n&&b_(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:i,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:s,cs2:a}=this.split(e.ss);return{h:e.ss.h,plaintext:i,valid:n&&o,cs1:s,cs2:a}}initSession(e,t,r){const n=this.createEmptyKey(),i=Ud(32);let o;return o=e?this.initializeInitiator(t,r,i,n):this.initializeResponder(t,r,i,n),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let n;if(0===e.mc)n=this.writeMessageA(e.hs,t,r);else if(1===e.mc)n=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:r,messageBuffer:i,cs1:o,cs2:s}=this.writeMessageC(e.hs,t);n=i,e.h=r,e.cs1=o,e.cs2=s}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");n=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");n=this.writeMessageRegular(e.cs2,t)}}return e.mc++,n}recvMessage(e,t){let r=Ud(0),n=!1;if(0===e.mc)({plaintext:r,valid:n}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:n}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:i,plaintext:o,valid:s,cs1:a,cs2:c}=this.readMessageC(e.hs,t);r=o,n=s,e.h=i,e.cs1=a,e.cs2=c}return e.mc++,{plaintext:r,valid:n}}}function __(e,t){t.enabled&&qd&&(e?(t("LOCAL_PUBLIC_EPHEMERAL_KEY ".concat(y_(e.publicKey,"hex"))),t("LOCAL_PRIVATE_EPHEMERAL_KEY ".concat(y_(e.privateKey,"hex")))):t("Missing local ephemeral keys."))}function E_(e,t){t.enabled&&qd&&t("REMOTE_EPHEMERAL_PUBLIC_KEY ".concat(y_(e.subarray(),"hex")))}class S_{constructor(e,t,r,n,i,o,s,a,c){co(this,"isInitiator",void 0),co(this,"session",void 0),co(this,"remotePeer",void 0),co(this,"remoteExtensions",{webtransportCerthashes:[]}),co(this,"payload",void 0),co(this,"connection",void 0),co(this,"xx",void 0),co(this,"staticKeypair",void 0),co(this,"prologue",void 0),co(this,"log",void 0),this.log=e.logger.forComponent("libp2p:noise:xxhandshake"),this.isInitiator=t,this.payload=r,this.prologue=n,this.staticKeypair=o,this.connection=s,a&&(this.remotePeer=a),this.xx=null!==c&&void 0!==c?c:new w_(e,i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){var e,t;if(e=this.session.hs.s,(t=this.log).enabled&&qd&&(t("LOCAL_STATIC_PUBLIC_KEY ".concat(y_(e.publicKey,"hex"))),t("LOCAL_STATIC_PRIVATE_KEY ".concat(y_(e.privateKey,"hex")))),this.isInitiator){this.log.trace("Stage 0 - Initiator starting to send first message.");const e=this.xx.sendMessage(this.session,Ud(0));await this.connection.write(function(e){return new nh(e.ne,e.ciphertext)}(e)),this.log.trace("Stage 0 - Initiator finished sending first message."),__(this.session.hs.e,this.log)}else{this.log.trace("Stage 0 - Responder waiting to receive first message...");const e=function(e){if(e.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:e.subarray(0,32),ciphertext:e.subarray(32,e.length),ns:Ud(0)}}((await this.connection.read()).subarray()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new ag("xx handshake stage 0 validation fail");this.log.trace("Stage 0 - Responder received first message."),E_(this.session.hs.re,this.log)}}async exchange(){if(this.isInitiator){this.log.trace("Stage 1 - Initiator waiting to receive first message from responder...");const n=function(e){if(e.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:e.subarray(0,32),ns:e.subarray(32,80),ciphertext:e.subarray(80,e.length)}}((await this.connection.read()).subarray()),{plaintext:i,valid:o}=this.xx.recvMessage(this.session,n);if(!o)throw new ag("xx handshake stage 1 validation fail");this.log.trace("Stage 1 - Initiator received the message."),E_(this.session.hs.re,this.log),e=this.session.hs.rs,(t=this.log).enabled&&qd&&t("REMOTE_STATIC_PUBLIC_KEY ".concat(y_(e.subarray(),"hex"))),this.log.trace("Initiator going to check remote's signature...");try{const e=f_(i);this.remotePeer=this.remotePeer||await d_(e),await g_(this.session.hs.rs,e,this.remotePeer),this.setRemoteNoiseExtension(e.extensions)}catch(r){throw new sg("Error occurred while verifying signed payload: ".concat(r.message))}this.log.trace("All good with the signature!")}else{this.log.trace("Stage 1 - Responder sending out first message with signed payload and static key.");const e=this.xx.sendMessage(this.session,this.payload);await this.connection.write(function(e){return new nh(e.ne,e.ns,e.ciphertext)}(e)),this.log.trace("Stage 1 - Responder sent the second handshake message with signed payload."),__(this.session.hs.e,this.log)}var e,t}async finish(){if(this.isInitiator){this.log.trace("Stage 2 - Initiator sending third handshake message.");const e=this.xx.sendMessage(this.session,this.payload);await this.connection.write(function(e){return new nh(e.ns,e.ciphertext)}(e)),this.log.trace("Stage 2 - Initiator sent message with signed payload.")}else{this.log.trace("Stage 2 - Responder waiting for third handshake message...");const e=function(e){if(e.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:Ud(0),ns:e.subarray(0,48),ciphertext:e.subarray(48,e.length)}}((await this.connection.read()).subarray()),{plaintext:t,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new ag("xx handshake stage 2 validation fail");this.log.trace("Stage 2 - Responder received the message, finished handshake.");try{const e=f_(t);this.remotePeer=this.remotePeer||await d_(e),await g_(this.session.hs.rs,e,this.remotePeer),this.setRemoteNoiseExtension(e.extensions)}catch(r){throw new sg("Error occurred while verifying signed payload: ".concat(r.message))}}var e,t;e=this.session,(t=this.log).enabled&&qd&&(e.cs1&&e.cs2?(t("CIPHER_STATE_1 ".concat(e.cs1.n.getUint64()," ").concat(y_(e.cs1.k,"hex"))),t("CIPHER_STATE_2 ".concat(e.cs2.n.getUint64()," ").concat(y_(e.cs2.k,"hex")))):t("Missing cipher state."))}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,Ud(0),e)}decrypt(e,t,r){const n=this.getCS(t,!1);return this.xx.decryptWithAd(n,Ud(0),e,r)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e.cs1||!e.cs2)throw new ag("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteNoiseExtension(e){e&&(this.remoteExtensions=e)}}class A_{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"protocol","/noise"),co(this,"crypto",void 0),co(this,"prologue",void 0),co(this,"staticKeys",void 0),co(this,"extensions",void 0),co(this,"metrics",void 0),co(this,"components",void 0);const{staticNoiseKey:r,extensions:n,crypto:i,prologueBytes:o}=t,{metrics:s}=e;this.components=e,this.crypto=null!==i&&void 0!==i?i:ng,this.extensions=n,this.metrics=s?function(e){return{xxHandshakeSuccesses:e.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:e.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:e.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:e.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:e.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}(s):void 0,this.staticKeys=r?this.crypto.generateX25519KeyPairFromSeed(r):this.crypto.generateX25519KeyPair(),this.prologue=null!==o&&void 0!==o?o:Ud(0)}async secureOutbound(e,t,r){const n=Nd(t,{lengthEncoder:ig,lengthDecoder:og,maxDataLength:Od}),i=await this.performHandshake({connection:n,isInitiator:!0,localPeer:e,remotePeer:r}),o=await this.createSecureConnection(n,i);return t.source=o.source,t.sink=o.sink,{conn:t,remoteExtensions:i.remoteExtensions,remotePeer:i.remotePeer}}async secureInbound(e,t,r){const n=Nd(t,{lengthEncoder:ig,lengthDecoder:og,maxDataLength:Od}),i=await this.performHandshake({connection:n,isInitiator:!1,localPeer:e,remotePeer:r}),o=await this.createSecureConnection(n,i);return t.source=o.source,t.sink=o.sink,{conn:t,remotePeer:i.remotePeer,remoteExtensions:i.remoteExtensions}}async performHandshake(e){const t=await h_(e.localPeer,this.staticKeys.publicKey,this.extensions);return this.performXXHandshake(e,t)}async performXXHandshake(e,t){const{isInitiator:r,remotePeer:n,connection:i}=e,o=new S_(this.components,r,t,this.prologue,this.crypto,this.staticKeys,i,n);try{var s;await o.propose(),await o.exchange(),await o.finish(),null===(s=this.metrics)||void 0===s||s.xxHandshakeSuccesses.increment()}catch(c){var a;if(null===(a=this.metrics)||void 0===a||a.xxHandshakeErrors.increment(),c instanceof Error)throw c.message="Error occurred during XX handshake: ".concat(c.message),c}return o}async createSecureConnection(e,t){const[r,n]=function(){const e=Bd(),t=Bd();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}(),i=e.unwrap();return await mh(r,function(e,t){return async function*(r){for await(const n of r)for(let r=0;r<n.length;r+=65519){let i,o=r+65519;o>n.length&&(o=n.length),i=n instanceof Uint8Array?e.encrypt(n.subarray(r,o),e.session):e.encrypt(n.sublist(r,o),e.session),null===t||void 0===t||t.encryptedPackets.increment(),yield new nh(ig(i.byteLength),i)}}}(t,this.metrics),i,(e=>lh(e,{lengthDecoder:og})),function(e,t){return async function*(r){for await(const n of r)for(let r=0;r<n.length;r+=Od){let i=r+Od;if(i>n.length&&(i=n.length),i-16<r)throw new Error("Invalid chunk");const o=n.sublist(r,i),s=n.subarray(r,i-16),{plaintext:a,valid:c}=e.decrypt(o,e.session,s);if(!c)throw null===t||void 0===t||t.decryptErrors.increment(),new Error("Failed to validate decrypted chunk");null===t||void 0===t||t.decryptedPackets.increment(),yield a}}}(t,this.metrics),r),n}}function k_(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new A_(t,e)}const x_=Symbol.for("@libp2p/peer-discovery");new Uint8Array(0);function I_(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var C_=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const T_=C_;class R_{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class P_{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return N_(this,e)}}class D_{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return N_(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function N_(e,t){var r,n;return new D_({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class B_{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new R_(e,t,r),this.decoder=new P_(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function U_(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new B_(t,r,n,i)}function L_(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=T_(n,t);return U_({prefix:r,name:t,encode:i,decode:e=>I_(o(e))})}function M_(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return U_({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const O_=L_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),q_=L_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),K_=L_({prefix:"9",name:"base10",alphabet:"0123456789"}),F_=M_({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),V_=M_({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),z_=M_({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),j_=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),H_=j_.reduce(((e,t,r)=>(e[r]=t,e)),[]),G_=j_.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const W_=U_({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=H_[t]),"")},decode:function(e){const t=[];for(const r of e){const e=G_[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Y_=M_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Q_=M_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),J_=M_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),X_=M_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Z_=M_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$_=M_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),eE=M_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tE=M_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rE=M_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),nE=L_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),iE=L_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),oE=M_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sE=M_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),aE=M_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cE=M_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),uE=M_({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),lE=U_({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),hE=new TextEncoder,dE=new TextDecoder,fE="json",pE=512;function gE(e){return hE.encode(JSON.stringify(e))}function bE(e){return JSON.parse(dE.decode(e))}const yE="raw",mE=85;function vE(e){return I_(e)}function wE(e){return I_(e)}var _E=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=AE;)r[n++]=255&t|EE,t/=128;for(;t&SE;)r[n++]=255&t|EE,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},EE=128,SE=-128,AE=Math.pow(2,31);var kE=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&IE)<<o:(n&IE)*Math.pow(2,o),o+=7}while(n>=xE);return e.bytes=s-r,i},xE=128,IE=127;var CE=Math.pow(2,7),TE=Math.pow(2,14),RE=Math.pow(2,21),PE=Math.pow(2,28),DE=Math.pow(2,35),NE=Math.pow(2,42),BE=Math.pow(2,49),UE=Math.pow(2,56),LE=Math.pow(2,63);const ME={encode:_E,decode:kE,encodingLength:function(e){return e<CE?1:e<TE?2:e<RE?3:e<PE?4:e<DE?5:e<NE?6:e<BE?7:e<UE?8:e<LE?9:10}};function OE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[ME.decode(e,t),ME.decode.bytes]}function qE(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return ME.encode(e,t,r),t}function KE(e){return ME.encodingLength(e)}function FE(e,t){const r=t.byteLength,n=KE(e),i=n+KE(r),o=new Uint8Array(i+r);return qE(e,o,0),qE(r,o,n),o.set(t,i),new zE(e,r,t,o)}function VE(e){const t=I_(e),[r,n]=OE(t),[i,o]=OE(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new zE(r,i,s,t)}class zE{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const jE=I_;const HE={code:0,name:"identity",encode:jE,digest:function(e){return FE(0,jE(e))}};function GE(e){let{name:t,code:r,encode:n}=e;return new WE(t,r,n)}class WE{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?FE(this.code,t):t.then((e=>FE(this.code,e)))}throw Error("Unknown type, must be binary type")}}function YE(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const QE=GE({name:"sha2-256",code:18,encode:YE("SHA-256")}),JE=GE({name:"sha2-512",code:19,encode:YE("SHA-512")});function XE(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==O_.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,$E(e),null!==t&&void 0!==t?t:O_.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,$E(e),null!==t&&void 0!==t?t:Y_.encoder)}const ZE=new WeakMap;function $E(e){const t=ZE.get(e);if(null==t){const t=new Map;return ZE.set(e,t),t}return t}class eS{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==tS)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==rS)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return eS.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=FE(e,t);return eS.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return eS.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return XE(this,e)}toJSON(){return{"/":XE(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof eS)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new eS(e,r,n,null!==i&&void 0!==i?i:nS(e,r,n.bytes))}if(!0===t[iS]){const{version:e,multihash:r,code:n}=t,i=VE(r);return eS.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==tS)throw new Error("Version 0 CID must use dag-pb (code: ".concat(tS,") block encoding"));return new eS(e,t,r,r.bytes);case 1:{const n=nS(e,t,r.bytes);return new eS(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return eS.create(0,tS,e)}static createV1(e,t){return eS.create(1,e,t)}static decode(e){const[t,r]=eS.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=eS.inspectBytes(e),r=t.size-t.multihashSize,n=I_(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new zE(t.multihashCode,t.digestSize,i,n);return[0===t.version?eS.createV0(o):eS.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=OE(e.subarray(t));return t+=n,r};let n=r(),i=tS;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:O_;return[O_.prefix,r.decode("".concat(O_.prefix).concat(e))]}case O_.prefix:{const r=null!==t&&void 0!==t?t:O_;return[O_.prefix,r.decode(e)]}case Y_.prefix:{const r=null!==t&&void 0!==t?t:Y_;return[Y_.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=eS.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return $E(i).set(r,e),i}}const tS=112,rS=18;function nS(e,t,r){const n=KE(e),i=n+KE(t),o=new Uint8Array(i+r.byteLength);return qE(e,o,0),qE(t,o,n),o.set(r,i),o}const iS=Symbol.for("@ipld/js-cid/CID"),oS={...ge,...ue,...pe,...ae,...ce,...he,...de,...se,...fe,...le};function sS(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const aS=Symbol.for("nodejs.util.inspect.custom"),cS=Object.values(oS).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),oS.identity.decoder),uS=114,lS=36,hS=37;class dS{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=O_.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return eS.createV1(uS,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return sS(this.multihash.bytes,e);if("string"===typeof e)return bS(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return sS(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[aS](){return"PeerId(".concat(this.toString(),")")}}class fS extends dS{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class pS extends dS{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class gS extends dS{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function bS(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:cS,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=VE(O_.decode("z".concat(e)));return e.startsWith("12D")?new pS({multihash:t}):e.startsWith("16U")?new gS({multihash:t}):new fS({multihash:t})}return function(e){try{const t=VE(e);if(t.code===HE.code){if(t.digest.length===lS)return new pS({multihash:t});if(t.digest.length===hS)return new gS({multihash:t})}if(t.code===QE.code)return new fS({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==uS)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===QE.code)return new fS({multihash:e.multihash});if(t.code===HE.code){if(t.digest.length===lS)return new pS({multihash:e.multihash});if(t.digest.length===hS)return new gS({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(eS.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(cS.decode(e))}function yS(e,t,r){return e.set(ld(e,t),r),r}class mS extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),co(this,"code",void 0),co(this,"type",void 0),this.code=mS.code,this.type=mS.type}}co(mS,"code","ABORT_ERR"),co(mS,"type","aborted");class vS extends Error{constructor(e,t,r){var n;super(e),co(this,"code",void 0),co(this,"props",void 0),this.code=t,this.name=null!==(n=null===r||void 0===r?void 0:r.name)&&void 0!==n?n:"CodeError",this.props=null!==r&&void 0!==r?r:{}}}var wS=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const _S=wS,ES=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")});class SS{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class AS{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return xS(this,e)}}class kS{constructor(e){this.decoders=e}or(e){return xS(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}const xS=(e,t)=>new kS({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class IS{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new SS(e,t,r),this.decoder=new AS(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const CS=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new IS(t,r,n,i)},TS=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=_S(n,r);return CS({prefix:t,name:r,encode:i,decode:e=>ES(o(e))})},RS=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return CS({prefix:r,name:t,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o})(e,i,n),decode:e=>((e,t,r,n)=>{const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},PS=TS({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),DS=TS({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),NS=RS({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),BS=RS({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),US=RS({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),LS=RS({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),MS=RS({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),OS=RS({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qS=RS({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),KS=RS({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),FS=RS({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var VS=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=HS;)r[n++]=255&t|zS,t/=128;for(;t&jS;)r[n++]=255&t|zS,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},zS=128,jS=-128,HS=Math.pow(2,31);var GS=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&YS)<<o:(n&YS)*Math.pow(2,o),o+=7}while(n>=WS);return e.bytes=s-r,i},WS=128,YS=127;var QS=Math.pow(2,7),JS=Math.pow(2,14),XS=Math.pow(2,21),ZS=Math.pow(2,28),$S=Math.pow(2,35),eA=Math.pow(2,42),tA=Math.pow(2,49),rA=Math.pow(2,56),nA=Math.pow(2,63);const iA={encode:VS,decode:GS,encodingLength:function(e){return e<QS?1:e<JS?2:e<XS?3:e<ZS?4:e<$S?5:e<eA?6:e<tA?7:e<rA?8:e<nA?9:10}},oA=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[iA.decode(e,t),iA.decode.bytes]},sA=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return iA.encode(e,t,r),t},aA=e=>iA.encodingLength(e),cA=(e,t)=>{const r=t.byteLength,n=aA(e),i=n+aA(r),o=new Uint8Array(i+r);return sA(e,o,0),sA(r,o,n),o.set(t,i),new lA(e,r,t,o)},uA=e=>{const t=ES(e),[r,n]=oA(t),[i,o]=oA(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new lA(r,i,s,t)};class lA{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const hA=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?bA(r,fA(e),t||PS.encoder):yA(r,fA(e),t||NS.encoder)},dA=new WeakMap,fA=e=>{const t=dA.get(e);if(null==t){const t=new Map;return dA.set(e,t),t}return t};class pA{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==mA)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vA)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return pA.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=cA(e,t);return pA.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return pA.equals(this,e)}static equals(e,t){const r=t;return r&&e.code===r.code&&e.version===r.version&&((e,t)=>{if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0})(e.bytes,r.bytes)}})(e.multihash,r.multihash)}toString(e){return hA(this,e)}toJSON(){return{"/":hA(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof pA)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new pA(e,r,n,i||wA(e,r,n.bytes))}if(!0===t[_A]){const{version:e,multihash:r,code:n}=t,i=uA(r);return pA.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==mA)throw new Error("Version 0 CID must use dag-pb (code: ".concat(mA,") block encoding"));return new pA(e,t,r,r.bytes);case 1:{const n=wA(e,t,r.bytes);return new pA(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return pA.create(0,mA,e)}static createV1(e,t){return pA.create(1,e,t)}static decode(e){const[t,r]=pA.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=pA.inspectBytes(e),r=t.size-t.multihashSize,n=ES(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new lA(t.multihashCode,t.digestSize,i,n);return[0===t.version?pA.createV0(o):pA.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=oA(e.subarray(t));return t+=n,r};let n=r(),i=mA;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=gA(e,t),i=pA.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return fA(i).set(r,e),i}}const gA=(e,t)=>{switch(e[0]){case"Q":{const r=t||PS;return[PS.prefix,r.decode("".concat(PS.prefix).concat(e))]}case PS.prefix:{const r=t||PS;return[PS.prefix,r.decode(e)]}case NS.prefix:{const r=t||NS;return[NS.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},bA=(e,t,r)=>{const{prefix:n}=r;if(n!==PS.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i},yA=(e,t,r)=>{const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i},mA=112,vA=18,wA=(e,t,r)=>{const n=aA(e),i=n+aA(t),o=new Uint8Array(i+r.byteLength);return sA(e,o,0),sA(t,o,n),o.set(r,i),o},_A=Symbol.for("@ipld/js-cid/CID");var EA=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const SA=EA,AA=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")});class kA{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class xA{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return CA(this,e)}}class IA{constructor(e){this.decoders=e}or(e){return CA(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}const CA=(e,t)=>new IA({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class TA{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new kA(e,t,r),this.decoder=new xA(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const RA=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new TA(t,r,n,i)},PA=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=SA(n,r);return RA({prefix:t,name:r,encode:i,decode:e=>AA(o(e))})},DA=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return RA({prefix:r,name:t,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o})(e,i,n),decode:e=>((e,t,r,n)=>{const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},NA=PA({prefix:"9",name:"base10",alphabet:"0123456789"}),BA=DA({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),UA=DA({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),LA=DA({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),MA=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),OA=MA.reduce(((e,t,r)=>(e[r]=t,e)),[]),qA=MA.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const KA=RA({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=OA[t]),"")},decode:function(e){const t=[];for(const r of e){const e=qA[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),FA=DA({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),VA=DA({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zA=DA({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jA=DA({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HA=DA({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),GA=DA({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),WA=DA({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),YA=DA({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),QA=DA({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),JA=PA({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),XA=PA({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ZA=PA({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$A=PA({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),ek=DA({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tk=DA({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rk=DA({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),nk=DA({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),ik=DA({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),ok=RA({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),sk=new TextEncoder,ak=new TextDecoder,ck="json",uk=512,lk=e=>sk.encode(JSON.stringify(e)),hk=e=>JSON.parse(ak.decode(e)),dk="raw",fk=85,pk=e=>AA(e),gk=e=>AA(e);var bk=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=vk;)r[n++]=255&t|yk,t/=128;for(;t&mk;)r[n++]=255&t|yk,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},yk=128,mk=-128,vk=Math.pow(2,31);var wk=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Ek)<<o:(n&Ek)*Math.pow(2,o),o+=7}while(n>=_k);return e.bytes=s-r,i},_k=128,Ek=127;var Sk=Math.pow(2,7),Ak=Math.pow(2,14),kk=Math.pow(2,21),xk=Math.pow(2,28),Ik=Math.pow(2,35),Ck=Math.pow(2,42),Tk=Math.pow(2,49),Rk=Math.pow(2,56),Pk=Math.pow(2,63);const Dk={encode:bk,decode:wk,encodingLength:function(e){return e<Sk?1:e<Ak?2:e<kk?3:e<xk?4:e<Ik?5:e<Ck?6:e<Tk?7:e<Rk?8:e<Pk?9:10}},Nk=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Dk.encode(e,t,r),t},Bk=e=>Dk.encodingLength(e),Uk=(e,t)=>{const r=t.byteLength,n=Bk(e),i=n+Bk(r),o=new Uint8Array(i+r);return Nk(e,o,0),Nk(r,o,n),o.set(t,i),new Lk(e,r,t,o)};class Lk{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Mk=AA,Ok={code:0,name:"identity",encode:Mk,digest:e=>Uk(0,Mk(e))},qk=e=>{let{name:t,code:r,encode:n}=e;return new Kk(t,r,n)};class Kk{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Uk(this.code,t):t.then((e=>Uk(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Fk=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Vk=qk({name:"sha2-256",code:18,encode:Fk("SHA-256")}),zk=qk({name:"sha2-512",code:19,encode:Fk("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const jk={...Pe,...Ae,...Re,...Ee,...Se,...xe,...Ie,...Ce,...Te,...ke};function Hk(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Gk(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return null!=(null===(e=globalThis.Buffer)||void 0===e?void 0:e.allocUnsafe)?Hk(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Wk(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Yk=Wk("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Qk=Wk("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Gk((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Jk={utf8:Yk,"utf-8":Yk,hex:jk.base16,latin1:Qk,ascii:Qk,binary:Qk,...jk};function Xk(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Jk[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}function Zk(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=Gk(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return Hk(r)}var $k=__webpack_require__(1870);const ex=45,tx=15,rx=new class{constructor(){co(this,"index",0),co(this,"input","")}new(e){return this.index=0,this.input=e,this}readAtomically(e){const t=this.index,r=e();return void 0===r&&(this.index=t),r}parseWith(e){const t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically((()=>{const t=this.readChar();if(t===e)return t}))}readSeparator(e,t,r){return this.readAtomically((()=>{if(!(t>0&&void 0===this.readGivenChar(e)))return r()}))}readNumber(e,t,r,n){return this.readAtomically((()=>{let i=0,o=0;const s=this.peekChar();if(void 0===s)return;const a="0"===s,c=2**(8*n)-1;for(;;){const r=this.readAtomically((()=>{const t=this.readChar();if(void 0===t)return;const r=Number.parseInt(t,e);return Number.isNaN(r)?void 0:r}));if(void 0===r)break;if(i*=e,i+=r,i>c)return;if(o+=1,void 0!==t&&o>t)return}return 0===o||!r&&a&&o>1?void 0:i}))}readIPv4Addr(){return this.readAtomically((()=>{const e=new Uint8Array(4);for(let t=0;t<e.length;t++){const r=this.readSeparator(".",t,(()=>this.readNumber(10,3,!1,1)));if(void 0===r)return;e[t]=r}return e}))}readIPv6Addr(){const e=e=>{for(let t=0;t<e.length/2;t++){const r=2*t;if(t<e.length-3){const n=this.readSeparator(":",t,(()=>this.readIPv4Addr()));if(void 0!==n)return e[r]=n[0],e[r+1]=n[1],e[r+2]=n[2],e[r+3]=n[3],[r+4,!0]}const n=this.readSeparator(":",t,(()=>this.readNumber(16,4,!0,2)));if(void 0===n)return[r,!1];e[r]=n>>8,e[r+1]=255&n}return[e.length,!1]};return this.readAtomically((()=>{const t=new Uint8Array(16),[r,n]=e(t);if(16===r)return t;if(n)return;if(void 0===this.readGivenChar(":"))return;if(void 0===this.readGivenChar(":"))return;const i=new Uint8Array(14),o=16-(r+2),[s]=e(i.subarray(0,o));return t.set(i.subarray(0,s),16-s),t}))}readIPAddr(){var e;return null!==(e=this.readIPv4Addr())&&void 0!==e?e:this.readIPv6Addr()}};parseInt("0xFFFF",16),new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);const nx=TS({prefix:"9",name:"base10",alphabet:"0123456789"}),ix=RS({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ox=RS({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),sx=RS({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),ax=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),cx=ax.reduce(((e,t,r)=>(e[r]=t,e)),[]),ux=ax.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const lx=CS({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=cx[t]),"")},decode:function(e){const t=[];for(const r of e){const e=ux[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),hx=TS({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),dx=TS({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),fx=RS({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),px=RS({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gx=RS({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bx=RS({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),yx=RS({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),mx=CS({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),vx=new TextEncoder,wx=new TextDecoder,_x="json",Ex=512,Sx=e=>vx.encode(JSON.stringify(e)),Ax=e=>JSON.parse(wx.decode(e)),kx="raw",xx=85,Ix=e=>ES(e),Cx=e=>ES(e),Tx=ES,Rx={code:0,name:"identity",encode:Tx,digest:e=>cA(0,Tx(e))},Px=e=>{let{name:t,code:r,encode:n}=e;return new Dx(t,r,n)};class Dx{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?cA(this.code,t):t.then((e=>cA(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Nx=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Bx=Px({name:"sha2-256",code:18,encode:Nx("SHA-256")}),Ux=Px({name:"sha2-512",code:19,encode:Nx("SHA-512")}),Lx={...ze,...Oe,...Ve,...Le,...Me,..._e,...Ke,...we,...Fe,...qe};function Mx(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Jk[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode("".concat(r.prefix).concat(e)):Hk(globalThis.Buffer.from(e,"utf-8"))}function Ox(e){return Boolean(function(e){if(!(e.length>tx))return rx.new(e).parseWith((()=>rx.readIPv4Addr()))}(e))}function qx(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>ex))return rx.new(e).parseWith((()=>rx.readIPv6Addr()))}(e))}function Kx(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>ex))return rx.new(e).parseWith((()=>rx.readIPAddr()))}(e))}const Fx=Ox,Vx=qx,zx=function(e){let t=0;if(e=e.toString().trim(),Fx(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(Vx(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;Fx(r[n])&&(e=zx(r[n]),r[n]=Xk(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,Xk(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},jx=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},Hx=-1,Gx={},Wx={};function Yx(e){if("number"===typeof e){if(null!=Wx[e])return Wx[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=Gx[e])return Gx[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,Hx,"ip6zone"],[43,8,"ipcidr"],[53,Hx,"dns",!0],[54,Hx,"dns4",!0],[55,Hx,"dns6",!0],[56,Hx,"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,Hx,"unix",!1,!0],[421,Hx,"ipfs"],[421,Hx,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,Hx,"garlic64"],[448,0,"tls"],[449,Hx,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,Hx,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,Hx,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);Wx[t.code]=t,Gx[t.name]=t}));Yx("ip4"),Yx("ip6"),Yx("ipcidr");function Qx(e,t){switch(Yx(e).code){case 4:case 41:return function(e){const t=jx(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return nI(t);case 6:case 273:case 33:case 132:return tI(t).toString();case 421:return function(e){const t=$k.decode(e),r=e.slice($k.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return Xk(r,"base58btc")}(t);case 444:case 445:return iI(t);case 466:return function(e){const t=$k.decode(e),r=e.slice($k.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return"u"+Xk(r,"base64url")}(t);default:return Xk(t,"base16")}}function Jx(e,t){switch(Yx(e).code){case 4:case 41:return $x(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return rI(t);case 6:case 273:case 33:case 132:return eI(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?uA(PS.decode("z".concat(e))).bytes:pA.parse(e).multihash.bytes;const r=Uint8Array.from($k.encode(t.length));return Zk([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(16!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion address."));const r=NS.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)");const i=eI(n);return Zk([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));const r=NS.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=eI(n);return Zk([r,i],r.length+i.length)}(t);case 466:return function(e){const t=Zx.decode(e),r=Uint8Array.from($k.encode(t.length));return Zk([r,t],r.length+t.length)}(t);default:return Mx(t,"base16")}}const Xx=Object.values(Lx).map((e=>e.decoder)),Zx=function(){let e=Xx[0].or(Xx[1]);return Xx.slice(2).forEach((t=>e=e.or(t))),e}();function $x(e){if(!Kx(e))throw new Error("invalid ip address");return zx(e)}function eI(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function tI(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function rI(e){const t=Mx(e),r=Uint8Array.from($k.encode(t.length));return Zk([r,t],r.length+t.length)}function nI(e){const t=$k.decode(e);if((e=e.slice($k.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return Xk(e)}function iI(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=Xk(t,"base32"),i=tI(r);return"".concat(n,":").concat(i)}function oI(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){var o;const s=$k.decode(e,i),a=null!==(o=$k.decode.bytes)&&void 0!==o?o:0,c=Yx(s),u=cI(c,e.slice(i+a));if(0===u){t.push([s]),r.push([s]),i+=a;continue}const l=e.slice(i+a,i+a+u);if(i+=u+a,i>e.length)throw lI("Invalid address Uint8Array: "+Xk(e,"base16"));t.push([s,l]);const h=Qx(s,l);if(r.push([s,h]),!0===c.path){n=h;break}}return{bytes:Uint8Array.from(e),string:sI(r),tuples:t,stringTuples:r,path:n}}function sI(e){const t=[];return e.map((e=>{const r=Yx(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),uI(t.join("/"))}function aI(e){return Zk(e.map((e=>{const t=Yx(e[0]);let r=Uint8Array.from($k.encode(t.code));return e.length>1&&null!=e[1]&&(r=Zk([r,e[1]])),r})))}function cI(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;var r;return $k.decode(t)+(null!==(r=$k.decode.bytes)&&void 0!==r?r:0)}function uI(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function lI(e){return new Error("Error parsing address: "+e)}const hI=Symbol.for("nodejs.util.inspect.custom"),dI=[Yx("dns").code,Yx("dns4").code,Yx("dns6").code,Yx("dnsaddr").code],fI=new Map,pI=Symbol.for("@multiformats/js-multiaddr/multiaddr");function gI(e){return Boolean(null===e||void 0===e?void 0:e[pI])}var bI=new WeakMap,yI=new WeakMap,mI=new WeakMap,vI=new WeakMap;class wI{constructor(e){let t;if(co(this,"bytes",void 0),ud(this,bI,void 0),ud(this,yI,void 0),ud(this,mI,void 0),ud(this,vI,void 0),co(this,pI,!0),null==e&&(e=""),e instanceof Uint8Array)t=oI(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));t=function(e){const t=[],r=[];let n=null;const i=(e=uI(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){const s=Yx(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw lI("invalid address: "+e);if(!0===s.path){n=uI(i.slice(o).join("/")),t.push([s.code,Jx(s.code,n)]),r.push([s.code,n]);break}const a=Jx(s.code,i[o]);t.push([s.code,a]),r.push([s.code,Qx(s.code,a)])}return{string:sI(r),bytes:aI(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!gI(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=oI(e.bytes)}this.bytes=t.bytes,yS(bI,this,t.string),yS(yI,this,t.tuples),yS(mI,this,t.stringTuples),yS(vI,this,t.path)}toString(){return hd(bI,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=Yx("tcp"),s=Yx("udp"),a=Yx("ip4"),c=Yx("ip6"),u=Yx("dns6"),l=Yx("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),dI.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===u.code?6:4),h!==o.code&&h!==s.code||(t=Yx(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=Yx(h).name,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return hd(yI,this).map((e=>{let[t]=e;return Object.assign({},Yx(t))}))}protoCodes(){return hd(yI,this).map((e=>{let[t]=e;return t}))}protoNames(){return hd(yI,this).map((e=>{let[t]=e;return Yx(t).name}))}tuples(){return hd(yI,this)}stringTuples(){return hd(mI,this)}encapsulate(e){return e=new wI(e),new wI(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address ".concat(this.toString()," does not contain subaddress: ").concat(e.toString()));return new wI(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new wI(aI(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===Gx.p2p.code&&e.push([r,n]),r===Gx["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){const e=t[1];return"Q"===e[0]||"1"===e[0]?Xk(PS.decode("z".concat(e)),"base58btc"):Xk(pA.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return hd(vI,this)}equals(e){return function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=fI.get(t.name);if(null==r)throw new vS("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>new wI(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[hI](){return"Multiaddr(".concat(hd(bI,this),")")}}function _I(e){return new wI(e)}const EI=$I("dns4"),SI=$I("dns6"),AI=$I("dnsaddr"),kI=ZI($I("dns"),AI,EI,SI),xI=ZI($I("ip4"),$I("ip6")),II=ZI(XI(xI,$I("tcp")),XI(kI,$I("tcp"))),CI=XI(xI,$I("udp")),TI=XI(CI,$I("utp")),RI=XI(CI,$I("quic")),PI=XI(CI,$I("quic-v1")),DI=ZI(XI(II,$I("ws")),XI(kI,$I("ws"))),NI=ZI(XI(DI,$I("p2p")),DI),BI=ZI(XI(II,$I("wss")),XI(kI,$I("wss")),XI(II,$I("tls"),$I("ws")),XI(kI,$I("tls"),$I("ws"))),UI=ZI(XI(BI,$I("p2p")),BI),LI=ZI(XI(II,$I("http")),XI(xI,$I("http")),XI(kI,$I("http"))),MI=ZI(XI(II,$I("https")),XI(xI,$I("https")),XI(kI,$I("https"))),OI=XI(CI,$I("webrtc-direct"),$I("certhash")),qI=ZI(XI(OI,$I("p2p")),OI),KI=XI(PI,$I("webtransport"),$I("certhash"),$I("certhash")),FI=ZI(XI(KI,$I("p2p")),KI),VI=ZI(XI(NI,$I("p2p-webrtc-star"),$I("p2p")),XI(UI,$I("p2p-webrtc-star"),$I("p2p")),XI(NI,$I("p2p-webrtc-star")),XI(UI,$I("p2p-webrtc-star"))),zI=(ZI(XI(NI,$I("p2p-websocket-star"),$I("p2p")),XI(UI,$I("p2p-websocket-star"),$I("p2p")),XI(NI,$I("p2p-websocket-star")),XI(UI,$I("p2p-websocket-star"))),ZI(XI(LI,$I("p2p-webrtc-direct"),$I("p2p")),XI(MI,$I("p2p-webrtc-direct"),$I("p2p")),XI(LI,$I("p2p-webrtc-direct")),XI(MI,$I("p2p-webrtc-direct")))),jI=ZI(DI,BI,LI,MI,VI,zI,II,TI,RI,kI,qI,FI),HI=(ZI(XI(jI,$I("p2p-stardust"),$I("p2p")),XI(jI,$I("p2p-stardust"))),ZI(XI(jI,$I("p2p")),VI,zI,qI,FI,$I("p2p"))),GI=ZI(XI(HI,$I("p2p-circuit"),HI),XI(HI,$I("p2p-circuit")),XI($I("p2p-circuit"),HI),XI(jI,$I("p2p-circuit")),XI($I("p2p-circuit"),jI),$I("p2p-circuit")),WI=()=>ZI(XI(GI,WI),GI),YI=WI(),QI=ZI(XI(YI,HI,YI),XI(HI,YI),XI(YI,HI),YI,HI);ZI(XI(YI,$I("webrtc"),$I("p2p")),XI(YI,$I("webrtc")),XI(jI,$I("webrtc"),$I("p2p")),XI(jI,$I("webrtc")),$I("webrtc"));function JI(e){return function(t){let r;try{r=_I(t)}catch(i){return!1}const n=e(r.protoNames());return null!==n&&(!0===n||!1===n?n:0===n.length)}}function XI(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){if(e.length<t.length)return null;let r=e;return t.some((t=>(r="function"===typeof t?t().partialMatch(e):t.partialMatch(e),Array.isArray(r)&&(e=r),null===r))),r}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:JI(n),partialMatch:n}}function ZI(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){let r=null;return t.some((t=>{const n="function"===typeof t?t().partialMatch(e):t.partialMatch(e);return null!=n&&(r=n,!0)})),r}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:JI(n),partialMatch:n}}function $I(e){const t=e;return{toString:function(){return t},matches:function(e){let r;try{r=_I(e)}catch(i){return!1}const n=r.protoNames();return 1===n.length&&n[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}function eC(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function tC(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const rC=tC("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),nC=tC("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=eC((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),iC={utf8:rC,"utf-8":rC,hex:oS.base16,latin1:nC,ascii:nC,binary:nC,...oS};function oC(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=iC[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}function sC(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=eC(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function aC(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=iC[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}const cC=Ox,uC=qx,lC=function(e){let t=0;if(e=e.toString().trim(),cC(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(uC(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;cC(r[n])&&(e=lC(r[n]),r[n]=oC(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,oC(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},hC=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},dC=-1,fC={},pC={};function gC(e){if("number"===typeof e){if(null!=pC[e])return pC[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=fC[e])return fC[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,dC,"ip6zone"],[43,8,"ipcidr"],[53,dC,"dns",!0],[54,dC,"dns4",!0],[55,dC,"dns6",!0],[56,dC,"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,dC,"unix",!1,!0],[421,dC,"ipfs"],[421,dC,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,dC,"garlic64"],[448,0,"tls"],[449,dC,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,dC,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,dC,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);pC[t.code]=t,fC[t.name]=t}));gC("ip4"),gC("ip6"),gC("ipcidr");function bC(e,t){switch(gC(e).code){case 4:case 41:return function(e){const t=hC(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return AC(t);case 6:case 273:case 33:case 132:return EC(t).toString();case 421:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return oC(r,"base58btc")}(t);case 444:case 445:return kC(t);case 466:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+oC(r,"base64url")}(t);default:return oC(t,"base16")}}function yC(e,t){switch(gC(e).code){case 4:case 41:return wC(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return SC(t);case 6:case 273:case 33:case 132:return _C(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?VE(O_.decode("z".concat(e))).bytes:eS.parse(e).multihash.bytes;const r=Uint8Array.from(Eo(t.length));return sC([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(16!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion address."));const r=Y_.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)");const i=_C(n);return sC([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));const r=Y_.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=_C(n);return sC([r,i],r.length+i.length)}(t);case 466:return function(e){const t=vC.decode(e),r=Uint8Array.from(Eo(t.length));return sC([r,t],r.length+t.length)}(t);default:return aC(t,"base16")}}const mC=Object.values(oS).map((e=>e.decoder)),vC=function(){let e=mC[0].or(mC[1]);return mC.slice(2).forEach((t=>e=e.or(t))),e}();function wC(e){if(!Kx(e))throw new Error("invalid ip address");return lC(e)}function _C(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function EC(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function SC(e){const t=aC(e),r=Uint8Array.from(Eo(t.length));return sC([r,t],r.length+t.length)}function AC(e){const t=So(e);if((e=e.slice(vo(t))).length!==t)throw new Error("inconsistent lengths");return oC(e)}function kC(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=oC(t,"base32"),i=EC(r);return"".concat(n,":").concat(i)}function xC(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const o=So(e,i),s=vo(o),a=gC(o),c=TC(a,e.slice(i+s));if(0===c){t.push([o]),r.push([o]),i+=s;continue}const u=e.slice(i+s,i+s+c);if(i+=c+s,i>e.length)throw PC("Invalid address Uint8Array: "+oC(e,"base16"));t.push([o,u]);const l=bC(o,u);if(r.push([o,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:IC(r),tuples:t,stringTuples:r,path:n}}function IC(e){const t=[];return e.map((e=>{const r=gC(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),RC(t.join("/"))}function CC(e){return sC(e.map((e=>{const t=gC(e[0]);let r=Uint8Array.from(Eo(t.code));return e.length>1&&null!=e[1]&&(r=sC([r,e[1]])),r})))}function TC(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=So(t instanceof Uint8Array?t:Uint8Array.from(t));return e+vo(e)}}function RC(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function PC(e){return new Error("Error parsing address: "+e)}const DC=Symbol.for("nodejs.util.inspect.custom"),NC=Symbol.for("@multiformats/js-multiaddr/multiaddr"),BC=[gC("dns").code,gC("dns4").code,gC("dns6").code,gC("dnsaddr").code];var UC=new WeakMap,LC=new WeakMap,MC=new WeakMap,OC=new WeakMap;class qC{constructor(e){let t;if(co(this,"bytes",void 0),ud(this,UC,void 0),ud(this,LC,void 0),ud(this,MC,void 0),ud(this,OC,void 0),co(this,NC,!0),null==e&&(e=""),e instanceof Uint8Array)t=xC(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));t=function(e){const t=[],r=[];let n=null;const i=(e=RC(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){const s=gC(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw PC("invalid address: "+e);if(!0===s.path){n=RC(i.slice(o).join("/")),t.push([s.code,yC(s.code,n)]),r.push([s.code,n]);break}const a=yC(s.code,i[o]);t.push([s.code,a]),r.push([s.code,bC(s.code,a)])}return{string:IC(r),bytes:CC(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!FC(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=xC(e.bytes)}this.bytes=t.bytes,yS(UC,this,t.string),yS(LC,this,t.tuples),yS(MC,this,t.stringTuples),yS(OC,this,t.path)}toString(){return hd(UC,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=gC("tcp"),s=gC("udp"),a=gC("ip4"),c=gC("ip6"),u=gC("dns6"),l=gC("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),BC.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===u.code?6:4),h!==o.code&&h!==s.code||(t=gC(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=gC(h).name,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return hd(LC,this).map((e=>{let[t]=e;return Object.assign({},gC(t))}))}protoCodes(){return hd(LC,this).map((e=>{let[t]=e;return t}))}protoNames(){return hd(LC,this).map((e=>{let[t]=e;return gC(t).name}))}tuples(){return hd(LC,this)}stringTuples(){return hd(MC,this)}encapsulate(e){return e=new qC(e),new qC(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address ".concat(this.toString()," does not contain subaddress: ").concat(e.toString()));return new qC(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new qC(CC(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===fC.p2p.code&&e.push([r,n]),r===fC["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){const e=t[1];return"Q"===e[0]||"1"===e[0]?oC(O_.decode("z".concat(e)),"base58btc"):oC(eS.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return hd(OC,this)}equals(e){return sS(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=KC.get(t.name);if(null==r)throw new ug("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>VC(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[DC](){return"Multiaddr(".concat(hd(UC,this),")")}}const KC=new Map;function FC(e){return Boolean(null===e||void 0===e?void 0:e[NC])}function VC(e){return new qC(e)}class zC extends gd{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{list:[]};if(null==r.list||0===r.list.length)throw new Error("Bootstrap requires a list of peer addresses");super(),co(this,"log",void 0),co(this,"timer",void 0),co(this,"list",void 0),co(this,"timeout",void 0),co(this,"components",void 0),co(this,"_init",void 0),co(this,x_,this),co(this,Symbol.toStringTag,"@libp2p/bootstrap"),this.components=e,this.log=e.logger.forComponent("libp2p:bootstrap"),this.timeout=null!==(t=r.timeout)&&void 0!==t?t:1e3,this.list=[];for(const n of r.list){if(!QI.matches(n)){this.log.error("Invalid multiaddr");continue}const e=VC(n),t=e.getPeerId();if(null==t){this.log.error("Invalid bootstrap multiaddr without peer id");continue}const r={id:bS(t),multiaddrs:[e]};this.list.push(r)}this._init=r}isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout((()=>{this._discoverBootstrapPeers().catch((e=>{this.log.error(e)}))}),this.timeout))}async _discoverBootstrapPeers(){if(null!=this.timer)for(const n of this.list){var e,t,r;if(await this.components.peerStore.merge(n.id,{tags:{[null!==(e=this._init.tagName)&&void 0!==e?e:"bootstrap"]:{value:null!==(t=this._init.tagValue)&&void 0!==t?t:50,ttl:null!==(r=this._init.tagTTL)&&void 0!==r?r:12e4}}}),null==this.timer)return;this.safeDispatchEvent("peer",{detail:n})}}stop(){null!=this.timer&&clearTimeout(this.timer),this.timer=void 0}}co(zC,"tag","bootstrap");function jC(e,t){cd(e,t),t.add(e)}new Uint8Array(0);function HC(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var GC=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const WC=GC;class YC{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class QC{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return XC(this,e)}}class JC{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return XC(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function XC(e,t){var r,n;return new JC({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class ZC{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new YC(e,t,r),this.decoder=new QC(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function $C(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new ZC(t,r,n,i)}function eT(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=WC(n,t);return $C({prefix:r,name:t,encode:i,decode:e=>HC(o(e))})}function tT(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return $C({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const rT=eT({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nT=eT({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),iT=eT({prefix:"9",name:"base10",alphabet:"0123456789"}),oT=tT({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sT=tT({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),aT=tT({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),cT=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),uT=cT.reduce(((e,t,r)=>(e[r]=t,e)),[]),lT=cT.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const hT=$C({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=uT[t]),"")},decode:function(e){const t=[];for(const r of e){const e=lT[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),dT=tT({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fT=tT({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),pT=tT({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gT=tT({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bT=tT({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yT=tT({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mT=tT({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vT=tT({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wT=tT({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),_T=eT({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ET=eT({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ST=tT({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),AT=tT({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),kT=tT({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),xT=tT({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),IT=tT({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),CT=$C({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),TT=new TextEncoder,RT=new TextDecoder,PT="json",DT=512;function NT(e){return TT.encode(JSON.stringify(e))}function BT(e){return JSON.parse(RT.decode(e))}const UT="raw",LT=85;function MT(e){return HC(e)}function OT(e){return HC(e)}var qT=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=VT;)r[n++]=255&t|KT,t/=128;for(;t&FT;)r[n++]=255&t|KT,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},KT=128,FT=-128,VT=Math.pow(2,31);var zT=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&HT)<<o:(n&HT)*Math.pow(2,o),o+=7}while(n>=jT);return e.bytes=s-r,i},jT=128,HT=127;var GT=Math.pow(2,7),WT=Math.pow(2,14),YT=Math.pow(2,21),QT=Math.pow(2,28),JT=Math.pow(2,35),XT=Math.pow(2,42),ZT=Math.pow(2,49),$T=Math.pow(2,56),eR=Math.pow(2,63);const tR={encode:qT,decode:zT,encodingLength:function(e){return e<GT?1:e<WT?2:e<YT?3:e<QT?4:e<JT?5:e<XT?6:e<ZT?7:e<$T?8:e<eR?9:10}};function rR(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[tR.decode(e,t),tR.decode.bytes]}function nR(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return tR.encode(e,t,r),t}function iR(e){return tR.encodingLength(e)}function oR(e,t){const r=t.byteLength,n=iR(e),i=n+iR(r),o=new Uint8Array(i+r);return nR(e,o,0),nR(r,o,n),o.set(t,i),new aR(e,r,t,o)}function sR(e){const t=HC(e),[r,n]=rR(t),[i,o]=rR(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new aR(r,i,s,t)}class aR{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const cR=HC;const uR={code:0,name:"identity",encode:cR,digest:function(e){return oR(0,cR(e))}};function lR(e){let{name:t,code:r,encode:n}=e;return new hR(t,r,n)}class hR{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?oR(this.code,t):t.then((e=>oR(this.code,e)))}throw Error("Unknown type, must be binary type")}}function dR(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const fR=lR({name:"sha2-256",code:18,encode:dR("SHA-256")}),pR=lR({name:"sha2-512",code:19,encode:dR("SHA-512")});function gR(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==rT.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,yR(e),null!==t&&void 0!==t?t:rT.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,yR(e),null!==t&&void 0!==t?t:dT.encoder)}const bR=new WeakMap;function yR(e){const t=bR.get(e);if(null==t){const t=new Map;return bR.set(e,t),t}return t}class mR{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==vR)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==wR)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return mR.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=oR(e,t);return mR.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return mR.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return gR(this,e)}toJSON(){return{"/":gR(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof mR)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new mR(e,r,n,null!==i&&void 0!==i?i:_R(e,r,n.bytes))}if(!0===t[ER]){const{version:e,multihash:r,code:n}=t,i=sR(r);return mR.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==vR)throw new Error("Version 0 CID must use dag-pb (code: ".concat(vR,") block encoding"));return new mR(e,t,r,r.bytes);case 1:{const n=_R(e,t,r.bytes);return new mR(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return mR.create(0,vR,e)}static createV1(e,t){return mR.create(1,e,t)}static decode(e){const[t,r]=mR.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=mR.inspectBytes(e),r=t.size-t.multihashSize,n=HC(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new aR(t.multihashCode,t.digestSize,i,n);return[0===t.version?mR.createV0(o):mR.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=rR(e.subarray(t));return t+=n,r};let n=r(),i=vR;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:rT;return[rT.prefix,r.decode("".concat(rT.prefix).concat(e))]}case rT.prefix:{const r=null!==t&&void 0!==t?t:rT;return[rT.prefix,r.decode(e)]}case dT.prefix:{const r=null!==t&&void 0!==t?t:dT;return[dT.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=mR.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return yR(i).set(r,e),i}}const vR=112,wR=18;function _R(e,t,r){const n=iR(e),i=n+iR(t),o=new Uint8Array(i+r.byteLength);return nR(e,o,0),nR(t,o,n),o.set(r,i),o}const ER=Symbol.for("@ipld/js-cid/CID"),SR={...nt,...Xe,...rt,...Qe,...Je,...$e,...et,...Ye,...tt,...Ze};function AR(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const kR=Symbol.for("nodejs.util.inspect.custom"),xR=Object.values(SR).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),SR.identity.decoder),IR=114,CR=36,TR=37;class RR{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=rT.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return mR.createV1(IR,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return AR(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:xR,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=sR(rT.decode("z".concat(e)));return e.startsWith("12D")?new DR({multihash:t}):e.startsWith("16U")?new NR({multihash:t}):new PR({multihash:t})}return function(e){try{const t=sR(e);if(t.code===uR.code){if(t.digest.length===CR)return new DR({multihash:t});if(t.digest.length===TR)return new NR({multihash:t})}if(t.code===fR.code)return new PR({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==IR)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===fR.code)return new PR({multihash:e.multihash});if(t.code===uR.code){if(t.digest.length===CR)return new DR({multihash:e.multihash});if(t.digest.length===TR)return new NR({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(mR.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(xR.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return AR(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[kR](){return"PeerId(".concat(this.toString(),")")}}class PR extends RR{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class DR extends RR{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class NR extends RR{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}async function BR(e,t){return e.length===CR?new DR({multihash:oR(uR.code,e),privateKey:t}):e.length===TR?new NR({multihash:oR(uR.code,e),privateKey:t}):new PR({multihash:await fR.digest(e),publicKey:e,privateKey:t})}new Uint8Array(0);function UR(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var LR=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const MR=LR;class OR{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class qR{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return FR(this,e)}}class KR{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return FR(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function FR(e,t){var r,n;return new KR({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class VR{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new OR(e,t,r),this.decoder=new qR(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function zR(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new VR(t,r,n,i)}function jR(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=MR(n,t);return zR({prefix:r,name:t,encode:i,decode:e=>UR(o(e))})}function HR(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return zR({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const GR=jR({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),WR=jR({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),YR=jR({prefix:"9",name:"base10",alphabet:"0123456789"}),QR=HR({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),JR=HR({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),XR=HR({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),ZR=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),$R=ZR.reduce(((e,t,r)=>(e[r]=t,e)),[]),eP=ZR.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const tP=zR({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=$R[t]),"")},decode:function(e){const t=[];for(const r of e){const e=eP[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),rP=HR({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),nP=HR({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),iP=HR({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oP=HR({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),sP=HR({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),aP=HR({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),cP=HR({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),uP=HR({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lP=HR({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),hP=jR({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),dP=jR({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),fP=HR({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pP=HR({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gP=HR({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bP=HR({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),yP=HR({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),mP=zR({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),vP=new TextEncoder,wP=new TextDecoder,_P="json",EP=512;function SP(e){return vP.encode(JSON.stringify(e))}function AP(e){return JSON.parse(wP.decode(e))}const kP="raw",xP=85;function IP(e){return UR(e)}function CP(e){return UR(e)}var TP=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=DP;)r[n++]=255&t|RP,t/=128;for(;t&PP;)r[n++]=255&t|RP,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},RP=128,PP=-128,DP=Math.pow(2,31);var NP=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&UP)<<o:(n&UP)*Math.pow(2,o),o+=7}while(n>=BP);return e.bytes=s-r,i},BP=128,UP=127;var LP=Math.pow(2,7),MP=Math.pow(2,14),OP=Math.pow(2,21),qP=Math.pow(2,28),KP=Math.pow(2,35),FP=Math.pow(2,42),VP=Math.pow(2,49),zP=Math.pow(2,56),jP=Math.pow(2,63);const HP={encode:TP,decode:NP,encodingLength:function(e){return e<LP?1:e<MP?2:e<OP?3:e<qP?4:e<KP?5:e<FP?6:e<VP?7:e<zP?8:e<jP?9:10}};function GP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[HP.decode(e,t),HP.decode.bytes]}function WP(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return HP.encode(e,t,r),t}function YP(e){return HP.encodingLength(e)}function QP(e,t){const r=t.byteLength,n=YP(e),i=n+YP(r),o=new Uint8Array(i+r);return WP(e,o,0),WP(r,o,n),o.set(t,i),new XP(e,r,t,o)}function JP(e){const t=UR(e),[r,n]=GP(t),[i,o]=GP(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new XP(r,i,s,t)}class XP{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const ZP=UR;const $P={code:0,name:"identity",encode:ZP,digest:function(e){return QP(0,ZP(e))}};function eD(e){let{name:t,code:r,encode:n}=e;return new tD(t,r,n)}class tD{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?QP(this.code,t):t.then((e=>QP(this.code,e)))}throw Error("Unknown type, must be binary type")}}function rD(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const nD=eD({name:"sha2-256",code:18,encode:rD("SHA-256")}),iD=eD({name:"sha2-512",code:19,encode:rD("SHA-512")});function oD(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==GR.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,aD(e),null!==t&&void 0!==t?t:GR.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,aD(e),null!==t&&void 0!==t?t:rP.encoder)}const sD=new WeakMap;function aD(e){const t=sD.get(e);if(null==t){const t=new Map;return sD.set(e,t),t}return t}class cD{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==uD)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==lD)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return cD.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=QP(e,t);return cD.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return cD.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return oD(this,e)}toJSON(){return{"/":oD(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof cD)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new cD(e,r,n,null!==i&&void 0!==i?i:hD(e,r,n.bytes))}if(!0===t[dD]){const{version:e,multihash:r,code:n}=t,i=JP(r);return cD.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==uD)throw new Error("Version 0 CID must use dag-pb (code: ".concat(uD,") block encoding"));return new cD(e,t,r,r.bytes);case 1:{const n=hD(e,t,r.bytes);return new cD(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return cD.create(0,uD,e)}static createV1(e,t){return cD.create(1,e,t)}static decode(e){const[t,r]=cD.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=cD.inspectBytes(e),r=t.size-t.multihashSize,n=UR(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new XP(t.multihashCode,t.digestSize,i,n);return[0===t.version?cD.createV0(o):cD.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=GP(e.subarray(t));return t+=n,r};let n=r(),i=uD;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:GR;return[GR.prefix,r.decode("".concat(GR.prefix).concat(e))]}case GR.prefix:{const r=null!==t&&void 0!==t?t:GR;return[GR.prefix,r.decode(e)]}case rP.prefix:{const r=null!==t&&void 0!==t?t:rP;return[rP.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=cD.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return aD(i).set(r,e),i}}const uD=112,lD=18;function hD(e,t,r){const n=YP(e),i=n+YP(t),o=new Uint8Array(i+r.byteLength);return WP(e,o,0),WP(t,o,n),o.set(r,i),o}const dD=Symbol.for("@ipld/js-cid/CID"),fD={...yt,...ht,...bt,...ut,...lt,...ft,...pt,...ct,...gt,...dt};function pD(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const gD=Symbol.for("nodejs.util.inspect.custom"),bD=Object.values(fD).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),fD.identity.decoder),yD=114,mD=36,vD=37;class wD{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=GR.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return cD.createV1(yD,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return pD(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:bD,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=JP(GR.decode("z".concat(e)));return e.startsWith("12D")?new ED({multihash:t}):e.startsWith("16U")?new SD({multihash:t}):new _D({multihash:t})}return AD(bD.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return pD(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[gD](){return"PeerId(".concat(this.toString(),")")}}class _D extends wD{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class ED extends wD{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class SD extends wD{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function AD(e){try{const t=JP(e);if(t.code===$P.code){if(t.digest.length===mD)return new ED({multihash:t});if(t.digest.length===vD)return new SD({multihash:t})}if(t.code===nD.code)return new _D({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==yD)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===nD.code)return new _D({multihash:e.multihash});if(t.code===$P.code){if(t.digest.length===mD)return new ED({multihash:e.multihash});if(t.digest.length===vD)return new SD({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(cD.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function kD(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function xD(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const ID=xD("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),CD=xD("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=kD((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),TD={utf8:ID,"utf-8":ID,hex:fD.base16,latin1:CD,ascii:CD,binary:CD,...fD};function RD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=TD[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}function PD(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=kD(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function DD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=TD[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}const ND=Ox,BD=qx,UD=function(e){let t=0;if(e=e.toString().trim(),ND(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(BD(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;ND(r[n])&&(e=UD(r[n]),r[n]=RD(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,RD(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},LD=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},MD=-1,OD={},qD={};function KD(e){if("number"===typeof e){if(null!=qD[e])return qD[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=OD[e])return OD[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,MD,"ip6zone"],[43,8,"ipcidr"],[53,MD,"dns",!0],[54,MD,"dns4",!0],[55,MD,"dns6",!0],[56,MD,"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,MD,"unix",!1,!0],[421,MD,"ipfs"],[421,MD,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,MD,"garlic64"],[448,0,"tls"],[449,MD,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,MD,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,MD,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);qD[t.code]=t,OD[t.name]=t}));KD("ip4"),KD("ip6"),KD("ipcidr");function FD(e,t){switch(KD(e).code){case 4:case 41:return function(e){const t=LD(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return QD(t);case 6:case 273:case 33:case 132:return WD(t).toString();case 421:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return RD(r,"base58btc")}(t);case 444:case 445:return JD(t);case 466:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+RD(r,"base64url")}(t);default:return RD(t,"base16")}}function VD(e,t){switch(KD(e).code){case 4:case 41:return HD(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return YD(t);case 6:case 273:case 33:case 132:return GD(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?JP(GR.decode("z".concat(e))).bytes:cD.parse(e).multihash.bytes;const r=Uint8Array.from(Eo(t.length));return PD([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(16!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion address."));const r=rP.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)");const i=GD(n);return PD([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));const r=rP.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=GD(n);return PD([r,i],r.length+i.length)}(t);case 466:return function(e){const t=jD.decode(e),r=Uint8Array.from(Eo(t.length));return PD([r,t],r.length+t.length)}(t);default:return DD(t,"base16")}}const zD=Object.values(fD).map((e=>e.decoder)),jD=function(){let e=zD[0].or(zD[1]);return zD.slice(2).forEach((t=>e=e.or(t))),e}();function HD(e){if(!Kx(e))throw new Error("invalid ip address");return UD(e)}function GD(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function WD(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function YD(e){const t=DD(e),r=Uint8Array.from(Eo(t.length));return PD([r,t],r.length+t.length)}function QD(e){const t=So(e);if((e=e.slice(vo(t))).length!==t)throw new Error("inconsistent lengths");return RD(e)}function JD(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=RD(t,"base32"),i=WD(r);return"".concat(n,":").concat(i)}function XD(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const o=So(e,i),s=vo(o),a=KD(o),c=eN(a,e.slice(i+s));if(0===c){t.push([o]),r.push([o]),i+=s;continue}const u=e.slice(i+s,i+s+c);if(i+=c+s,i>e.length)throw rN("Invalid address Uint8Array: "+RD(e,"base16"));t.push([o,u]);const l=FD(o,u);if(r.push([o,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:ZD(r),tuples:t,stringTuples:r,path:n}}function ZD(e){const t=[];return e.map((e=>{const r=KD(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),tN(t.join("/"))}function $D(e){return PD(e.map((e=>{const t=KD(e[0]);let r=Uint8Array.from(Eo(t.code));return e.length>1&&null!=e[1]&&(r=PD([r,e[1]])),r})))}function eN(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=So(t instanceof Uint8Array?t:Uint8Array.from(t));return e+vo(e)}}function tN(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function rN(e){return new Error("Error parsing address: "+e)}const nN=Symbol.for("nodejs.util.inspect.custom"),iN=Symbol.for("@multiformats/js-multiaddr/multiaddr"),oN=[KD("dns").code,KD("dns4").code,KD("dns6").code,KD("dnsaddr").code];var sN=new WeakMap,aN=new WeakMap,cN=new WeakMap,uN=new WeakMap;class lN{constructor(e){let t;if(co(this,"bytes",void 0),ud(this,sN,void 0),ud(this,aN,void 0),ud(this,cN,void 0),ud(this,uN,void 0),co(this,iN,!0),null==e&&(e=""),e instanceof Uint8Array)t=XD(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));t=function(e){const t=[],r=[];let n=null;const i=(e=tN(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){const s=KD(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw rN("invalid address: "+e);if(!0===s.path){n=tN(i.slice(o).join("/")),t.push([s.code,VD(s.code,n)]),r.push([s.code,n]);break}const a=VD(s.code,i[o]);t.push([s.code,a]),r.push([s.code,FD(s.code,a)])}return{string:ZD(r),bytes:$D(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!dN(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=XD(e.bytes)}this.bytes=t.bytes,yS(sN,this,t.string),yS(aN,this,t.tuples),yS(cN,this,t.stringTuples),yS(uN,this,t.path)}toString(){return hd(sN,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=KD("tcp"),s=KD("udp"),a=KD("ip4"),c=KD("ip6"),u=KD("dns6"),l=KD("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),oN.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===u.code?6:4),h!==o.code&&h!==s.code||(t=KD(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=KD(h).name,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return hd(aN,this).map((e=>{let[t]=e;return Object.assign({},KD(t))}))}protoCodes(){return hd(aN,this).map((e=>{let[t]=e;return t}))}protoNames(){return hd(aN,this).map((e=>{let[t]=e;return KD(t).name}))}tuples(){return hd(aN,this)}stringTuples(){return hd(cN,this)}encapsulate(e){return e=new lN(e),new lN(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address ".concat(this.toString()," does not contain subaddress: ").concat(e.toString()));return new lN(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new lN($D(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===OD.p2p.code&&e.push([r,n]),r===OD["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){const e=t[1];return"Q"===e[0]||"1"===e[0]?RD(GR.decode("z".concat(e)),"base58btc"):RD(cD.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return hd(uN,this)}equals(e){return pD(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=hN.get(t.name);if(null==r)throw new ug("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>fN(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[nN](){return"Multiaddr(".concat(hd(sN,this),")")}}const hN=new Map;function dN(e){return Boolean(null===e||void 0===e?void 0:e[iN])}function fN(e){return new lN(e)}const pN=Uint8Array.from([3,1]),gN=new Float32Array([-0]),bN=new Uint8Array(gN.buffer);function yN(e,t,r){gN[0]=e,t[r]=bN[0],t[r+1]=bN[1],t[r+2]=bN[2],t[r+3]=bN[3]}const mN=new Float64Array([-0]),vN=new Uint8Array(mN.buffer);function wN(e,t,r){mN[0]=e,t[r]=vN[0],t[r+1]=vN[1],t[r+2]=vN[2],t[r+3]=vN[3],t[r+4]=vN[4],t[r+5]=vN[5],t[r+6]=vN[6],t[r+7]=vN[7]}const _N=BigInt(Number.MAX_SAFE_INTEGER),EN=BigInt(Number.MIN_SAFE_INTEGER);class SN{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return AN;if(e<_N&&e>EN)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>kN&&(n=0n,++r>kN&&(r=0n))),new SN(Number(n),Number(r))}static fromNumber(e){if(0===e)return AN;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new SN(r,n)}static from(e){return"number"===typeof e?SN.fromNumber(e):"bigint"===typeof e?SN.fromBigInt(e):"string"===typeof e?SN.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new SN(e.low>>>0,e.high>>>0):AN}}const AN=new SN(0,0);AN.toBigInt=function(){return 0n},AN.zzEncode=AN.zzDecode=function(){return this},AN.length=function(){return 1};const kN=4294967296n;function xN(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function IN(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function CN(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class TN{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,IN(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw IN(this,4);return CN(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw IN(this,4);return 0|CN(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw IN(this,4);const e=(t=this.buf,r=this.pos,bN[0]=t[r],bN[1]=t[r+1],bN[2]=t[r+2],bN[3]=t[r+3],gN[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw IN(this,4);const e=(t=this.buf,r=this.pos,vN[0]=t[r],vN[1]=t[r+1],vN[2]=t[r+2],vN[3]=t[r+3],vN[4]=t[r+4],vN[5]=t[r+5],vN[6]=t[r+6],vN[7]=t[r+7],mN[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw IN(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw IN(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw IN(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new SN(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw IN(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw IN(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw IN(this,8);const e=CN(this.buf,this.pos+=4),t=CN(this.buf,this.pos+=4);return new SN(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function RN(e,t,r){const n=function(e){return new TN(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class PN{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function DN(){}class NN{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const BN=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return kD(e);i+e>t&&(n=kD(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class UN{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new PN(DN,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new PN(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ON((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(qN,10,SN.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=SN.fromBigInt(e);return this._push(qN,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=SN.fromBigInt(e).zzEncode();return this._push(qN,t.length(),t)}sint64Number(e){const t=SN.fromNumber(e).zzEncode();return this._push(qN,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(LN,1,e?1:0)}fixed32(e){return this._push(KN,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=SN.fromBigInt(e);return this._push(KN,4,t.lo)._push(KN,4,t.hi)}fixed64Number(e){const t=SN.fromNumber(e);return this._push(KN,4,t.lo)._push(KN,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(yN,4,e)}double(e){return this._push(wN,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(LN,1,0):this.uint32(t)._push(FN,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(xN,t,e):this._push(LN,1,0)}fork(){return this.states=new NN(this),this.head=this.tail=new PN(DN,0,0),this.len=0,this}reset(){return null!=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 PN(DN,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?kD(r):BN(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function LN(e,t,r){t[r]=255&e}function MN(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class ON extends PN{constructor(e,t){super(MN,e,t),co(this,"next",void 0),this.next=void 0}}function qN(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function KN(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function FN(e,t,r){t.set(e,r)}function VN(e,t,r){t.set(e,r)}function zN(e,t,r){e.length<40?xN(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(DD(e),r)}function jN(e,t){const r=new UN;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var HN,GN,WN;function YN(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function QN(e,t){return YN("message",HN.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(UN.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(VN,t,e),this},UN.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(zN,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(HN||(HN={}));Error;!function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=QN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={multiaddr:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.multiaddr=e.bytes();else e.skipType(7&t)}return r}))),t),e.encode=t=>jN(t,e.codec()),e.decode=t=>RN(t,e.codec())}(t=e.AddressInfo||(e.AddressInfo={})),e.codec=()=>(null==r&&(r=QN((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.peerId&&t.peerId.byteLength>0&&(r.uint32(10),r.bytes(t.peerId)),null!=t.seq&&0n!==t.seq&&(r.uint32(16),r.uint64(t.seq)),null!=t.addresses)for(const i of t.addresses)r.uint32(26),e.AddressInfo.codec().encode(i,r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={peerId:new Uint8Array(0),seq:0n,addresses:[]},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.peerId=t.bytes();break;case 2:n.seq=t.uint64();break;case 3:n.addresses.push(e.AddressInfo.codec().decode(t,t.uint32()));break;default:t.skipType(7&r)}}return n}))),r),e.encode=t=>jN(t,e.codec()),e.decode=t=>RN(t,e.codec())}(GN||(GN={}));class JN{constructor(e){co(this,"peerId",void 0),co(this,"multiaddrs",void 0),co(this,"seqNumber",void 0),co(this,"domain",JN.DOMAIN),co(this,"codec",JN.CODEC),co(this,"marshaled",void 0);const{peerId:t,multiaddrs:r,seqNumber:n}=e;this.peerId=t,this.multiaddrs=null!==r&&void 0!==r?r:[],this.seqNumber=null!==n&&void 0!==n?n:BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=GN.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof JN&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!function(e,t){const r=(e,t)=>e.toString().localeCompare(t.toString());return e.length===t.length&&(t.sort(r),e.sort(r).every(((e,r)=>t[r].equals(e))))}(this.multiaddrs,e.multiaddrs)))}}function XN(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}WN=JN,co(JN,"createFromProtobuf",(e=>{var t;const r=GN.decode(e),n=AD(r.peerId),i=(null!==(t=r.addresses)&&void 0!==t?t:[]).map((e=>fN(e.multiaddr))),o=r.seq;return new WN({peerId:n,multiaddrs:i,seqNumber:o})})),co(JN,"DOMAIN","libp2p-peer-record"),co(JN,"CODEC",pN);const ZN=32,$N=64,eB=32;function tB(e,t){const r=new Uint8Array($N);for(let n=0;n<eB;n++)r[n]=e[n],r[eB+n]=t[n];return r}const rB={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},nB={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function iB(e,t){const r=function(e){var t,r,n,i,o,s;const a=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM";let c=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16;const u=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",h=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,d=null!==(s=null===e||void 0===e?void 0:e.iterations)&&void 0!==s?s:32767,f=rB.get();return c*=8,{encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(u)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=DD(t)),0===t.length){o=await f.subtle.importKey("jwk",nB,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}catch{o=await f.subtle.importKey("jwk",nB,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}const s=await f.subtle.encrypt(i,o,e);return PD([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+u),i=e.subarray(h+u),o={name:a,iv:n};let s;if("string"===typeof t&&(t=DD(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}catch{s=await f.subtle.importKey("jwk",nB,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}const p=await f.subtle.decrypt(o,s,i);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return fP.encode(n)}var oB,sB,aB,cB;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(oB||(oB={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(sB||(sB={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return YN("enum",HN.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(sB)}(oB||(oB={})),function(e){let t;e.codec=()=>(null==t&&(t=QN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),oB.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=oB.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>jN(t,e.codec()),e.decode=t=>RN(t,e.codec())}(aB||(aB={})),function(e){let t;e.codec=()=>(null==t&&(t=QN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),oB.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=oB.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>jN(t,e.codec()),e.decode=t=>RN(t,e.codec())}(cB||(cB={}));class uB{constructor(e){co(this,"_key",void 0),this._key=gB(e,ZN)}verify(e,t){return function(e,t,r){return Wp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return aB.encode({Type:oB.Ed25519,Data:this.marshal()}).subarray()}equals(e){return pD(this.bytes,e.bytes)}hash(){const e=nD.digest(this.bytes);return XN(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class lB{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=gB(e,$N),this._publicKey=gB(t,ZN)}sign(e){return function(e,t){const r=e.subarray(0,eB);return Wp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new uB(this._publicKey)}marshal(){return this._key}get bytes(){return cB.encode({Type:oB.Ed25519,Data:this.marshal()}).subarray()}equals(e){return pD(this.bytes,e.bytes)}async hash(){const e=nD.digest(this.bytes);let t;return XN(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=$P.digest(this.public.bytes);return GR.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return iB(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function hB(e){if(e.length>$N){const t=(e=gB(e,$N+ZN)).subarray(0,$N),r=e.subarray($N,e.length);return new lB(t,r)}const t=(e=gB(e,$N)).subarray(0,$N),r=e.subarray(ZN);return new lB(t,r)}function dB(e){return e=gB(e,ZN),new uB(e)}async function fB(){const{privateKey:e,publicKey:t}=function(){const e=Wp.utils.randomPrivateKey(),t=Wp.getPublicKey(e);return{privateKey:tB(e,t),publicKey:t}}();return new lB(e,t)}async function pB(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==eB)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Wp.getPublicKey(t);return{privateKey:tB(t,r),publicKey:r}}(e);return new lB(t,r)}function gB(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ug("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}async function bB(e){const t=[await rB.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await mB(e)],r=await yB({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function yB(e){if(null==e.privateKey||null==e.publicKey)throw new ug("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([rB.get().subtle.exportKey("jwk",e.privateKey),rB.get().subtle.exportKey("jwk",e.publicKey)])}async function mB(e){return rB.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function vB(e){if("RSA"!==e.kty)throw new ug("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ug("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*DD(e.n,"base64url").length}function wB(e,t,r,n){yc(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!==Tc.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)}({dkLen:32,asyncTick:10},n),{c:o,dkLen:s,asyncTick:a}=i;if(gc(o),gc(s),gc(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=xc(t),u=xc(r),l=new Uint8Array(s),h=Zp.create(e,c),d=h._cloneInto().update(u);return{c:o,dkLen:s,asyncTick:a,DK:l,PRF:h,PRFSalt:d}}function _B(e,t,r,n,i){return e.destroy(),t.destroy(),n&&n.destroy(),i.fill(0),r}async function EB(e,t,r,n){const{c:i,dkLen:o,asyncTick:s,DK:a,PRF:c,PRFSalt:u}=wB(e,t,r,n);let l;const h=new Uint8Array(4),d=_c(h),f=new Uint8Array(c.outputLen);for(let p=1,g=0;g<o;p++,g+=c.outputLen){const e=a.subarray(g,g+c.outputLen);d.setInt32(0,p,!1),(l=u._cloneInto(l)).update(h).digestInto(f),e.set(f.subarray(0,e.length)),await Ac(i-1,s,(()=>{c._cloneInto(l).update(f).digestInto(f);for(let t=0;t<e.length;t++)e[t]^=f[t]}))}return _B(c,u,a,l,f)}var SB=__webpack_require__(8275);function AB(e,t){let r=0;if(1===e.length)return e[0];for(let n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}function kB(e,t){const r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;let n=e,i=0,o=Math.pow(2,t);for(let s=1;s<8;s++){if(e<o){let e;if(r<0)e=new ArrayBuffer(s),i=s;else{if(r<s)return new ArrayBuffer(0);e=new ArrayBuffer(r),i=r}const o=new Uint8Array(e);for(let r=s-1;r>=0;r--){const e=Math.pow(2,r*t);o[i-r-1]=Math.floor(n/e),n-=o[i-r-1]*e}return e}o*=Math.pow(2,t)}return new ArrayBuffer(0)}function xB(){let e=0,t=0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];for(const a of n)e+=a.length;const o=new ArrayBuffer(e),s=new Uint8Array(o);for(const a of n)s.set(a,t),t+=a.length;return s}function IB(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&0===(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let s=0;s<this.valueHex.byteLength;s++)r[s]=0;r[0]=128&e[0];const n=AB(r,8),i=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(i);for(let s=0;s<this.valueHex.byteLength;s++)o[s]=e[s];o[0]&=127;return AB(o,8)-n}function CB(e,t){const r=e.toString(10);if(t<r.length)return"";const n=t-r.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(r)}Math.log(2);function TB(){if("undefined"===typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function RB(e){let t=0,r=0;for(let i=0;i<e.length;i++){t+=e[i].byteLength}const n=new Uint8Array(t);for(let i=0;i<e.length;i++){const t=e[i];n.set(new Uint8Array(t),r),r+=t.byteLength}return n.buffer}function PB(e,t,r,n){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):n<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-n<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class DB{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return RB(this.items)}}const NB=[new Uint8Array([1])],BB="0123456789",UB="",LB=new ArrayBuffer(0),MB=new Uint8Array(0),OB="EndOfContent",qB="OCTET STRING",KB="BIT STRING";function FB(e){var t;return t=class extends e{constructor(){var e;super(...arguments);const t=(arguments.length<=0?void 0:arguments[0])||{};this.isHexOnly=null!==(e=t.isHexOnly)&&void 0!==e&&e,this.valueHexView=t.valueHex?SB._H.toUint8Array(t.valueHex):MB}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}fromBER(e,t,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!PB(this,n,t,r))return-1;const i=t+r;return this.valueHexView=n.subarray(t,i),this.valueHexView.length?(this.blockLength=r,i):(this.warnings.push("Zero buffer length"),t)}toBER(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isHexOnly?e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",LB)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:SB.U$.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}class VB{constructor(){let{blockLength:e=0,error:t=UB,warnings:r=[],valueBeforeDecode:n=MB}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=SB._H.toUint8Array(n)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:SB.U$.ToHex(this.valueBeforeDecodeView)}}}VB.NAME="baseBlock";class zB extends VB{fromBER(e,t,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}zB.NAME="valueBlock";class jB extends(FB(VB)){constructor(){let{idBlock:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,n,i;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?SB._H.toUint8Array(e.valueHex):MB,this.tagClass=null!==(r=e.tagClass)&&void 0!==r?r:-1,this.tagNumber=null!==(n=e.tagNumber)&&void 0!==n?n:-1,this.isConstructed=null!==(i=e.isConstructed)&&void 0!==i&&i):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",LB}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,r[0]=t}return r.buffer}if(!this.isHexOnly){const r=kB(this.tagNumber,7),n=new Uint8Array(r),i=r.byteLength,o=new Uint8Array(i+1);if(o[0]=31|t,!e){for(let e=0;e<i-1;e++)o[e+1]=128|n[e];o[i]=n[i-1]}return o.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)r[t+1]=128|e[t];r[this.valueHexView.byteLength]=e[e.length-1]}return r.buffer}fromBER(e,t,r){const n=SB._H.toUint8Array(e);if(!PB(this,n,t,r))return-1;const i=n.subarray(t,t+r);if(0===i.length)return this.error="Zero buffer length",-1;switch(192&i[0]){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=32===(32&i[0]),this.isHexOnly=!1;const o=31&i[0];if(31!==o)this.tagNumber=o,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),r=255;for(;128&i[e];){if(t[e-1]=127&i[e],e++,e>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r<t.length;r++)e[r]=t[r];t=this.valueHexView=new Uint8Array(r)}}this.blockLength=e+1,t[e-1]=127&i[e];const n=new Uint8Array(e);for(let i=0;i<e;i++)n[i]=t[i];t=this.valueHexView=new Uint8Array(e),t.set(n),this.blockLength<=9?this.tagNumber=AB(t,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}jB.NAME="identificationBlock";class HB extends VB{constructor(){let{lenBlock:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,n;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(r=e.longFormUsed)&&void 0!==r&&r,this.length=null!==(n=e.length)&&void 0!==n?n:0}fromBER(e,t,r){const n=SB._H.toUint8Array(e);if(!PB(this,n,t,r))return-1;const i=n.subarray(t,t+r);if(0===i.length)return this.error="Zero buffer length",-1;if(255===i[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===i[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&i[0]),!1===this.longFormUsed)return this.length=i[0],this.blockLength=1,t+this.blockLength;const o=127&i[0];if(o>8)return this.error="Too big integer",-1;if(o+1>i.length)return this.error="End of input reached before message was fully decoded",-1;const s=t+1,a=n.subarray(s,s+o);return 0===a[o-1]&&this.warnings.push("Needlessly long encoded length"),this.length=AB(a,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(){let e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),!1===r&&(t=new Uint8Array(e),t[0]=128),e;if(this.longFormUsed){const n=kB(this.length,8);if(n.byteLength>127)return this.error="Too big length",LB;if(e=new ArrayBuffer(n.byteLength+1),r)return e;const i=new Uint8Array(n);t=new Uint8Array(e),t[0]=128|n.byteLength;for(let e=0;e<n.byteLength;e++)t[e+1]=i[e];return e}return e=new ArrayBuffer(1),!1===r&&(t=new Uint8Array(e),t[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}HB.NAME="lengthBlock";const GB={};class WB extends VB{constructor(){let{name:e=UB,optional:t=!1,primitiveSchema:r,...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;super(n),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new jB(n),this.lenBlock=new HB(n),this.valueBlock=i?new i(n):new zB(n)}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}toBER(e,t){const r=t||new DB;t||YB(this);const n=this.idBlock.toBER(e);if(r.write(n),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const n=this.lenBlock.toBER(e);r.write(n),r.write(t)}return t?LB:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(){return"ascii"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ascii")?this.onAsciiEncoding():SB.U$.ToHex(this.toBER())}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(SB.U$.ToHex(this.valueBlock.valueBeforeDecodeView))}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;return function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}(this.toBER(),e.toBER())}}function YB(e){if(e instanceof GB.Constructed)for(const t of e.valueBlock.value)YB(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock.isIndefiniteForm}WB.NAME="BaseBlock";class QB extends WB{constructor(){let{value:e=UB,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t,arguments.length>1?arguments[1]:void 0),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){return"".concat(this.constructor.NAME," : '").concat(this.valueBlock.value,"'")}}QB.NAME="BaseStringBlock";class JB extends(FB(zB)){constructor(){let{isHexOnly:e=!0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isHexOnly=e}}var XB,ZB,$B,eU,tU,rU,nU,iU,oU,sU,aU,cU,uU,lU,hU,dU,fU,pU,gU,bU,yU,mU,vU,wU,_U,EU,SU,AU,kU,xU,IU,CU,TU;JB.NAME="PrimitiveValueBlock";class RU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},JB),this.idBlock.isConstructed=!1}}function PU(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length;const n=t;let i=new WB({},zB);const o=new VB;if(!PB(o,e,t,r))return i.error=o.error,{offset:-1,result:i};if(!e.subarray(t,t+r).length)return i.error="Zero buffer length",{offset:-1,result:i};let s=i.idBlock.fromBER(e,t,r);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),-1===s)return i.error=i.idBlock.error,{offset:-1,result:i};if(t=s,r-=i.idBlock.blockLength,s=i.lenBlock.fromBER(e,t,r),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),-1===s)return i.error=i.lenBlock.error,{offset:-1,result:i};if(t=s,r-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let a=WB;if(1===i.idBlock.tagClass){if(i.idBlock.tagNumber>=37&&!1===i.idBlock.isHexOnly)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};a=GB.EndOfContent;break;case 1:a=GB.Boolean;break;case 2:a=GB.Integer;break;case 3:a=GB.BitString;break;case 4:a=GB.OctetString;break;case 5:a=GB.Null;break;case 6:a=GB.ObjectIdentifier;break;case 10:a=GB.Enumerated;break;case 12:a=GB.Utf8String;break;case 13:a=GB.RelativeObjectIdentifier;break;case 14:a=GB.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:a=GB.Sequence;break;case 17:a=GB.Set;break;case 18:a=GB.NumericString;break;case 19:a=GB.PrintableString;break;case 20:a=GB.TeletexString;break;case 21:a=GB.VideotexString;break;case 22:a=GB.IA5String;break;case 23:a=GB.UTCTime;break;case 24:a=GB.GeneralizedTime;break;case 25:a=GB.GraphicString;break;case 26:a=GB.VisibleString;break;case 27:a=GB.GeneralString;break;case 28:a=GB.UniversalString;break;case 29:a=GB.CharacterString;break;case 30:a=GB.BmpString;break;case 31:a=GB.DATE;break;case 32:a=GB.TimeOfDay;break;case 33:a=GB.DateTime;break;case 34:a=GB.Duration;break;default:{const e=i.idBlock.isConstructed?new GB.Constructed:new GB.Primitive;e.idBlock=i.idBlock,e.lenBlock=i.lenBlock,e.warnings=i.warnings,i=e}}}else a=i.idBlock.isConstructed?GB.Constructed:GB.Primitive;return i=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(i,a),s=i.fromBER(e,t,i.lenBlock.isIndefiniteForm?r:i.lenBlock.length),i.valueBeforeDecodeView=e.subarray(n,n+i.blockLength),{offset:s,result:i}}function DU(e){if(!e.byteLength){const e=new WB({},zB);return e.error="Input buffer has zero length",{offset:-1,result:e}}return PU(SB._H.toUint8Array(e).slice(),0,e.byteLength)}XB=RU,GB.Primitive=XB,RU.NAME="PRIMITIVE";class NU extends zB{constructor(){let{value:e=[],isIndefiniteForm:t=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const n=SB._H.toUint8Array(e);if(!PB(this,n,t,r))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let i=t;for(;o=this.isIndefiniteForm,s=r,(o?1:s)>0;){const e=PU(n,i,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(i=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===OB)break}var o,s;return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===OB?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const r=t||new DB;for(let n=0;n<this.value.length;n++)this.value[n].toBER(e,r);return t?LB:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}NU.NAME="ConstructedValueBlock";class BU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},NU),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split("\n").map((e=>" ".concat(e))).join("\n"));const t=3===this.idBlock.tagClass?"[".concat(this.idBlock.tagNumber,"]"):this.constructor.NAME;return e.length?"".concat(t," :\n").concat(e.join("\n")):"".concat(t," :")}}ZB=BU,GB.Constructed=ZB,BU.NAME="CONSTRUCTED";class UU extends zB{fromBER(e,t,r){return t}toBER(e){return LB}}UU.override="EndOfContentValueBlock";class LU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},UU),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}$B=LU,GB.EndOfContent=$B,LU.NAME=OB;class MU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},zB),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return"".concat(this.constructor.NAME)}}eU=MU,GB.Null=eU,MU.NAME="NULL";class OU extends(FB(zB)){constructor(){let{value:e,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),t.valueHex?this.valueHexView=SB._H.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,r){const n=SB._H.toUint8Array(e);return PB(this,n,t,r)?(this.valueHexView=n.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,IB.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}OU.NAME="BooleanValueBlock";class qU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},OU),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.getValue)}}tU=qU,GB.Boolean=tU,qU.NAME="BOOLEAN";class KU extends(FB(NU)){constructor(){let{isConstructed:e=!1,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isConstructed=e}fromBER(e,t,r){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=NU.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===OB){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==qB)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,n=super.fromBER(e,t,r),this.blockLength=r;return n}toBER(e,t){return this.isConstructed?NU.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}KU.NAME="OctetStringValueBlock";class FU extends WB{constructor(){let{idBlock:e={},lenBlock:t={},...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var n,i;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(i=r.value)||void 0===i?void 0:i.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},KU),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(i.byteLength){const e=PU(i,0,i.byteLength);-1!==e.offset&&e.offset===r&&(this.valueBlock.value=[e.result])}}catch(n){}}return super.fromBER(e,t,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?BU.prototype.onAsciiEncoding.call(this):"".concat(this.constructor.NAME," : ").concat(SB.U$.ToHex(this.valueBlock.valueHexView))}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof FU&&e.push(t.valueBlock.valueHexView);return SB._H.concat(e)}}rU=FU,GB.OctetString=rU,FU.NAME=qB;class VU extends(FB(NU)){constructor(){let{unusedBits:e=0,isConstructed:t=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(r),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;let n=-1;if(this.isConstructed){if(n=NU.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(const e of this.value){const t=e.constructor.NAME;if(t===OB){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==KB)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const r=e.valueBlock;if(this.unusedBits>0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return n}const i=SB._H.toUint8Array(e);if(!PB(this,i,t,r))return-1;const o=i.subarray(t,t+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=o.subarray(1);try{if(e.byteLength){const t=PU(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch(s){}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+r}toBER(e,t){if(this.isConstructed)return NU.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return LB;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}VU.NAME="BitStringValueBlock";class zU extends WB{constructor(){let{idBlock:e={},lenBlock:t={},...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var n,i;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(i=r.value)||void 0===i?void 0:i.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},VU),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return BU.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const n of t)e.push(n.toString(2).padStart(8,"0"));const r=e.join("");return"".concat(this.constructor.NAME," : ").concat(r.substring(0,r.length-this.valueBlock.unusedBits))}}}function jU(e,t){const r=new Uint8Array([0]),n=new Uint8Array(e),i=new Uint8Array(t);let o=n.slice(0);const s=o.length-1,a=i.slice(0),c=a.length-1;let u=0;let l=0;for(let h=c<s?s:c;h>=0;h--,l++){if(!0===l<a.length)u=o[s-l]+a[c-l]+r[0];else u=o[s-l]+r[0];if(r[0]=u/10,!0===l>=o.length)o=xB(new Uint8Array([u%10]),o);else o[s-l]=u%10}return r[0]>0&&(o=xB(r,o)),o}function HU(e){if(e>=NB.length)for(let t=NB.length;t<=e;t++){const e=new Uint8Array([0]);let r=NB[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const n=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=n[0]/10,r[t]=n[0]%10}e[0]>0&&(r=xB(e,r)),NB.push(r)}return NB[e]}function GU(e,t){let r=0;const n=new Uint8Array(e),i=new Uint8Array(t),o=n.slice(0),s=o.length-1,a=i.slice(0),c=a.length-1;let u,l=0;for(let h=c;h>=0;h--,l++)if(u=o[s-l]-a[c-l]-r,!0===u<0)r=1,o[s-l]=u+10;else r=0,o[s-l]=u;if(r>0)for(let h=s-c+1;h>=0;h--,l++){if(u=o[s-l]-r,!(u<0)){r=0,o[s-l]=u;break}r=1,o[s-l]=u+10}return o.slice()}nU=zU,GB.BitString=nU,zU.NAME=KB;class WU extends(FB(zB)){constructor(){let{value:e,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=IB.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let n=1;n<8;n++){if(t<=r){if(e<0){const e=kB(r-t,8,n);return new Uint8Array(e)[0]|=128,e}let i=kB(t,8,n),o=new Uint8Array(i);if(128&o[0]){const e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),o=new Uint8Array(i);for(let r=0;r<e.byteLength;r++)o[r+1]=t[r];o[0]=0}return i}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const i=this.fromBER(e,t,r);if(-1===i)return i;const o=this.valueHexView;return 0===o[0]&&0!==(128&o[1])?this.valueHexView=o.subarray(1):0!==n&&o.length<n&&(n-o.length>1&&(n=o.length+1),this.valueHexView=o.subarray(n-o.length)),i}toDER(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=this.valueHexView;switch(!0){case 0!==(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&0===(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const n=super.fromBER(e,t,r);return-1===n||this.setValueHex(),n}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),n=0;const i=this.valueHexView;let o="",s=!1;for(let a=i.byteLength-1;a>=0;a--){t=i[a];for(let i=0;i<8;i++){if(1===(1&t))if(n===e)r=GU(HU(n),r),o="-";else r=jU(r,HU(n));n++,t>>=1}}for(let a=0;a<r.length;a++)r[a]&&(s=!0),s&&(o+=BB.charAt(r[a]));return!1===s&&(o+=BB.charAt(0)),o}}iU=WU,WU.NAME="IntegerValueBlock",Object.defineProperty(iU.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class YU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},WU),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return TB(),BigInt(this.valueBlock.toString())}static fromBigInt(e){TB();const t=BigInt(e),r=new DB,n=t.toString(16).replace(/^-/,""),i=new Uint8Array(SB.U$.FromHex(n));if(t<0){const e=new Uint8Array(i.length+(128&i[0]?1:0));e[0]|=128;const n=BigInt("0x".concat(SB.U$.ToHex(e)))+t,o=SB._H.toUint8Array(SB.U$.FromHex(n.toString(16)));o[0]|=128,r.write(o)}else 128&i[0]&&r.write(new Uint8Array([0])),r.write(i);return new YU({valueHex:r.final()})}convertToDER(){const e=new YU({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new YU({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString())}}oU=YU,GB.Integer=oU,YU.NAME="INTEGER";class QU extends YU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}sU=QU,GB.Enumerated=sU,QU.NAME="ENUMERATED";class JU extends(FB(zB)){constructor(){let{valueDec:e=-1,isFirstSid:t=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;const n=SB._H.toUint8Array(e);if(!PB(this,n,t,r))return-1;const i=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let s=0;s<r&&(this.valueHexView[s]=127&i[s],this.blockLength++,0!==(128&i[s]));s++);const o=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength;s++)o[s]=this.valueHexView[s];return this.valueHexView=o,0!==(128&i[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=AB(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){TB();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const r=new Uint8Array(t.length/7);for(let n=0;n<r.length;n++)r[n]=parseInt(t.slice(7*n,7*n+7),2)+(n+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=kB(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",LB;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r}toString(){let e="";if(this.isHexOnly)e=SB.U$.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}JU.NAME="sidBlock";class XU extends zB{constructor(){let{value:e=UB,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new JU;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e){const t=[];for(let r=0;r<this.value.length;r++){const n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,LB;t.push(n)}return RB(t)}fromString(e){this.value=[];let t=0,r=0,n="",i=!1;do{if(r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1,i){const e=this.value[0];let t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:return void(this.value=[])}const r=parseInt(n,10);if(isNaN(r))return;e.valueDec=r+t,i=!1}else{const e=new JU;if(n>Number.MAX_SAFE_INTEGER){TB();const t=BigInt(n);e.valueBigInt=t}else if(e.valueDec=parseInt(n,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e="".concat(e,".")),t?(n="{".concat(n,"}"),this.value[r].isFirstSid?e="2.{".concat(n," - 80}"):e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}XU.NAME="ObjectIdentifierValueBlock";class ZU extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},XU),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString()||"empty")}toJSON(){return{...super.toJSON(),value:this.getValue()}}}aU=ZU,GB.ObjectIdentifier=aU,ZU.NAME="OBJECT IDENTIFIER";class $U extends(FB(VB)){constructor(){let{valueDec:e=0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.valueDec=e}fromBER(e,t,r){if(0===r)return t;const n=SB._H.toUint8Array(e);if(!PB(this,n,t,r))return-1;const i=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let s=0;s<r&&(this.valueHexView[s]=127&i[s],this.blockLength++,0!==(128&i[s]));s++);const o=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength;s++)o[s]=this.valueHexView[s];return this.valueHexView=o,0!==(128&i[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=AB(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=kB(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",LB;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r.buffer}toString(){let e="";return e=this.isHexOnly?SB.U$.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}$U.NAME="relativeSidBlock";class eL extends zB{constructor(){let{value:e=UB,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new $U;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e,t){const r=[];for(let n=0;n<this.value.length;n++){const t=this.value[n].toBER(e);if(0===t.byteLength)return this.error=this.value[n].error,LB;r.push(t)}return RB(r)}fromString(e){this.value=[];let t=0,r=0,n="";do{r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1;const i=new $U;if(i.valueDec=parseInt(n,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(-1!==r);return!0}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e="".concat(e,".")),t?(n="{".concat(n,"}"),e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}eL.NAME="RelativeObjectIdentifierValueBlock";class tL extends WB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},eL),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString()||"empty")}toJSON(){return{...super.toJSON(),value:this.getValue()}}}cU=tL,GB.RelativeObjectIdentifier=cU,tL.NAME="RelativeObjectIdentifier";class rL extends BU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}uU=rL,GB.Sequence=uU,rL.NAME="SEQUENCE";class nL extends BU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}lU=nL,GB.Set=lU,nL.NAME="SET";class iL extends(FB(zB)){constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.isHexOnly=!0,this.value=UB}toJSON(){return{...super.toJSON(),value:this.value}}}iL.NAME="StringValueBlock";class oL extends iL{}oL.NAME="SimpleStringValueBlock";class sL extends QB{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e,oL)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,SB._H.toUint8Array(e))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);this.valueBlock.value=e}}sL.NAME="SIMPLE STRING";class aL extends sL{fromBuffer(e){this.valueBlock.valueHexView=SB._H.toUint8Array(e);try{this.valueBlock.value=SB.U$.ToUtf8String(e)}catch(t){this.warnings.push('Error during "decodeURIComponent": '.concat(t,", using raw string")),this.valueBlock.value=SB.U$.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(SB.U$.FromUtf8String(e)),this.valueBlock.value=e}}aL.NAME="Utf8StringValueBlock";class cL extends aL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}hU=cL,GB.Utf8String=hU,cL.NAME="UTF8String";class uL extends sL{fromBuffer(e){this.valueBlock.value=SB.U$.ToUtf16String(e),this.valueBlock.valueHexView=SB._H.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(SB.U$.FromUtf16String(e))}}uL.NAME="BmpStringValueBlock";class lL extends uL{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}dU=lL,GB.BmpString=dU,lL.NAME="BMPString";class hL extends sL{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t);for(let n=0;n<r.length;n+=4)r[n]=r[n+3],r[n+1]=r[n+2],r[n+2]=0,r[n+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let n=0;n<t;n++){const t=kB(e.charCodeAt(n),8),i=new Uint8Array(t);if(i.length>4)continue;const o=4-i.length;for(let e=i.length-1;e>=0;e--)r[4*n+e+o]=i[e]}this.valueBlock.value=e}}hL.NAME="UniversalStringValueBlock";class dL extends hL{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}fU=dL,GB.UniversalString=fU,dL.NAME="UniversalString";class fL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}pU=fL,GB.NumericString=pU,fL.NAME="NumericString";class pL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}gU=pL,GB.PrintableString=gU,pL.NAME="PrintableString";class gL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}bU=gL,GB.TeletexString=bU,gL.NAME="TeletexString";class bL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}yU=bL,GB.VideotexString=yU,bL.NAME="VideotexString";class yL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}mU=yL,GB.IA5String=mU,yL.NAME="IA5String";class mL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}vU=mL,GB.GraphicString=vU,mL.NAME="GraphicString";class vL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}wU=vL,GB.VisibleString=wU,vL.NAME="VisibleString";class wL extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}_U=wL,GB.GeneralString=_U,wL.NAME="GeneralString";class _L extends sL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}EU=_L,GB.CharacterString=EU,_L.NAME="CharacterString";class EL extends vL{constructor(){let{value:e,valueDate:t,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,SB._H.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null===t)return void(this.error="Wrong input string for conversion");const r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"iso";if("iso"===e){const e=new Array(7);return e[0]=CB(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=CB(this.month,2),e[2]=CB(this.day,2),e[3]=CB(this.hour,2),e[4]=CB(this.minute,2),e[5]=CB(this.second,2),e[6]="Z",e.join("")}return super.toString(e)}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.toDate().toISOString())}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}SU=EL,GB.UTCTime=SU,EL.NAME="UTCTime";class SL extends EL{constructor(){var e;super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),null!==(e=this.millisecond)&&void 0!==e||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t,r=!1,n="",i="",o=0,s=0,a=0;if("Z"===e[e.length-1])n=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(-1!==n.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==n.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=n.indexOf("+"),r="";if(-1===t&&(t=n.indexOf("-"),e=-1),-1!==t){if(r=n.substring(t+1),n=n.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw new Error("Wrong input string for conversion");if(s=e*i,4===r.length){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw new Error("Wrong input string for conversion");a=e*i}}}let c=n.indexOf(".");if(-1===c&&(c=n.indexOf(",")),-1!==c){const e=new Number("0".concat(n.substring(c)));if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");o=e.valueOf(),i=n.substring(0,c)}else i=n;switch(!0){case 8===i.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===i.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*o;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===i.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*o;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===i.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*o;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const u=t.exec(i);if(null===u)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+s;break;case 5:this.minute=parseInt(u[l],10)+a;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){const e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"iso";if("iso"===e){const e=[];return e.push(CB(this.year,4)),e.push(CB(this.month,2)),e.push(CB(this.day,2)),e.push(CB(this.hour,2)),e.push(CB(this.minute,2)),e.push(CB(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(CB(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}AU=SL,GB.GeneralizedTime=AU,SL.NAME="GeneralizedTime";class AL extends cL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}kU=AL,GB.DATE=kU,AL.NAME="DATE";class kL extends cL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}xU=kL,GB.TimeOfDay=xU,kL.NAME="TimeOfDay";class xL extends cL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}IU=xL,GB.DateTime=IU,xL.NAME="DateTime";class IL extends cL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}CU=IL,GB.Duration=CU,IL.NAME="Duration";class CL extends cL{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}TU=CL,GB.TIME=TU,CL.NAME="TIME";function TL(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}function RL(e){let t=e.toString(16);t.length%2>0&&(t="0".concat(t));const r=t.length/2,n=new Uint8Array(r);let i=0,o=0;for(;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n}function PL(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r="0".concat(r)),t.push(r)})),BigInt("0x"+t.join(""))}const DL=32,NL=1e4;const BL=8192;class UL{constructor(e){co(this,"_key",void 0),this._key=e}verify(e,t){return async function(e,t,r){const n=await rB.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return rB.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new zU({valueHex:new rL({value:[YU.fromBigInt(PL(DD(e.n,"base64url"))),YU.fromBigInt(PL(DD(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return aB.encode({Type:oB.RSA,Data:this.marshal()}).subarray()}equals(e){return pD(this.bytes,e.bytes)}hash(){const e=nD.digest(this.bytes);return XN(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class LL{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return TL(16)}sign(e){return async function(e,t){const r=await rB.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await rB.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ug("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new UL(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new YU({value:0}),YU.fromBigInt(PL(DD(e.n,"base64url"))),YU.fromBigInt(PL(DD(e.e,"base64url"))),YU.fromBigInt(PL(DD(e.d,"base64url"))),YU.fromBigInt(PL(DD(e.p,"base64url"))),YU.fromBigInt(PL(DD(e.q,"base64url"))),YU.fromBigInt(PL(DD(e.dp,"base64url"))),YU.fromBigInt(PL(DD(e.dq,"base64url"))),YU.fromBigInt(PL(DD(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return cB.encode({Type:oB.RSA,Data:this.marshal()}).subarray()}equals(e){return pD(this.bytes,e.bytes)}hash(){const e=nD.digest(this.bytes);return XN(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return RD(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=rB.get(),n=new rL({value:[new YU({value:0}),new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new FU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),o=TL(16),s=await EB(Nf,t,o,{c:NL,dkLen:DL}),a=TL(16),c=await r.subtle.importKey("raw",s,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new rL({value:[new FU({valueHex:o}),new YU({value:NL}),new YU({value:DL}),new rL({value:[new ZU({value:"1.2.840.113549.2.11"}),new MU]})]}),h=new rL({value:[new ZU({value:"1.2.840.113549.1.5.13"}),new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.5.12"}),l]}),new rL({value:[new ZU({value:"2.16.840.1.101.3.4.1.42"}),new FU({valueHex:a})]})]})]}),d=new rL({value:[h,new FU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...RD(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return iB(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function ML(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value;return{n:RD(RL(r[1].toBigInt()),"base64url"),e:RD(RL(r[2].toBigInt()),"base64url"),d:RD(RL(r[3].toBigInt()),"base64url"),p:RD(RL(r[4].toBigInt()),"base64url"),q:RD(RL(r[5].toBigInt()),"base64url"),dp:RD(RL(r[6].toBigInt()),"base64url"),dq:RD(RL(r[7].toBigInt()),"base64url"),qi:RD(RL(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(vB(t)>BL)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await bB(t);return new LL(r.privateKey,r.publicKey)}function OL(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:RD(RL(r[0].toBigInt()),"base64url"),e:RD(RL(r[1].toBigInt()),"base64url")}}(e);if(vB(t)>BL)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new UL(t)}async function qL(e){if(vB(e)>BL)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await bB(e);return new LL(t.privateKey,t.publicKey)}async function KL(e){if(e>BL)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await rB.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await yB(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new LL(t.privateKey,t.publicKey)}function FL(e){try{Am.ProjectivePoint.fromHex(e)}catch(t){throw new ug(String(t),"ERR_INVALID_PUBLIC_KEY")}}class VL{constructor(e){co(this,"_key",void 0),FL(e),this._key=e}verify(e,t){return function(e,t,r){const n=nD.digest(r instanceof Uint8Array?r:r.subarray());if(XN(n))return n.then((r=>{let{digest:n}=r;return Am.verify(t,n,e)})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.verify(t,n.digest,e)}catch(i){throw new ug(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,Am.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return aB.encode({Type:oB.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return pD(this.bytes,e.bytes)}async hash(){const e=nD.digest(this.bytes);let t;return XN(e)?({bytes:t}=await e):t=e.bytes,t}}class zL{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),FL(this._publicKey)}sign(e){return function(e,t){const r=nD.digest(t instanceof Uint8Array?t:t.subarray());if(XN(r))return r.then((t=>{let{digest:r}=t;return Am.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.sign(r.digest,e).toDERRawBytes()}catch(n){throw new ug(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new VL(this._publicKey)}marshal(){return this._key}get bytes(){return cB.encode({Type:oB.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return pD(this.bytes,e.bytes)}hash(){const e=nD.digest(this.bytes);return XN(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return RD(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return iB(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function jL(e){return new zL(e)}function HL(e){return new VL(e)}async function GL(){const e=Am.utils.randomPrivateKey();return new zL(e)}const WL={rsa:St,ed25519:Et,secp256k1:At};function YL(e){const t=Object.keys(WL).join(" / ");return new ug("invalid or unsupported key type ".concat(e,". Must be ").concat(t),"ERR_UNSUPPORTED_KEY_TYPE")}async function QL(e){var t,r;const n=cB.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case oB.RSA:return WL.rsa.unmarshalRsaPrivateKey(i);case oB.Ed25519:return WL.ed25519.unmarshalEd25519PrivateKey(i);case oB.Secp256k1:return WL.secp256k1.unmarshalSecp256k1PrivateKey(i);default:throw YL(null!==(r=n.Type)&&void 0!==r?r:"RSA")}}const JL="ERR_SIGNATURE_NOT_VALID";var XL,ZL;!function(e){let t;e.codec=()=>(null==t&&(t=QN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.publicKey&&e.publicKey.byteLength>0&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.payloadType&&e.payloadType.byteLength>0&&(t.uint32(18),t.bytes(e.payloadType)),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(26),t.bytes(e.payload)),null!=e.signature&&e.signature.byteLength>0&&(t.uint32(42),t.bytes(e.signature)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.publicKey=e.bytes();break;case 2:r.payloadType=e.bytes();break;case 3:r.payload=e.bytes();break;case 5:r.signature=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>jN(t,e.codec()),e.decode=t=>RN(t,e.codec())}(XL||(XL={}));class $L{constructor(e){co(this,"peerId",void 0),co(this,"payloadType",void 0),co(this,"payload",void 0),co(this,"signature",void 0),co(this,"marshaled",void 0);const{peerId:t,payloadType:r,payload:n,signature:i}=e;this.peerId=t,this.payloadType=r,this.payload=n,this.signature=i}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=XL.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return pD(this.marshal(),e.marshal())}async validate(e){const t=eM(e,this.payloadType,this.payload);if(null==this.peerId.publicKey)throw new Error("Missing public key");return function(e){var t,r;const n=aB.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case oB.RSA:return WL.rsa.unmarshalRsaPublicKey(i);case oB.Ed25519:return WL.ed25519.unmarshalEd25519PublicKey(i);case oB.Secp256k1:return WL.secp256k1.unmarshalSecp256k1PublicKey(i);default:throw YL(null!==(r=n.Type)&&void 0!==r?r:"unknown")}}(this.peerId.publicKey).verify(t.subarray(),this.signature)}}ZL=$L,co($L,"createFromProtobuf",(async e=>{const t=XL.decode(e),r=await async function(e,t){return e.length===mD?new ED({multihash:QP($P.code,e),privateKey:t}):e.length===vD?new SD({multihash:QP($P.code,e),privateKey:t}):new _D({multihash:await nD.digest(e),publicKey:e,privateKey:t})}(t.publicKey);return new ZL({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})})),co($L,"seal",(async(e,t)=>{if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,n=e.codec,i=e.marshal(),o=eM(r,n,i),s=await QL(t.privateKey),a=await s.sign(o.subarray());return new ZL({peerId:t,payloadType:n,payload:i,signature:a})})),co($L,"openAndCertify",(async(e,t)=>{const r=await ZL.createFromProtobuf(e);if(!await r.validate(t))throw new ug("envelope signature is not valid for the given domain",JL);return r}));const eM=(e,t,r)=>{const n=DD(e),i=Eo(n.byteLength),o=Eo(t.length),s=Eo(r.length);return new nh(i,n,o,t,s,r)};function tM(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function rM(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const nM=rM("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),iM=rM("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=tM((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),oM={utf8:nM,"utf-8":nM,hex:SR.base16,latin1:iM,ascii:iM,binary:iM,...SR};function sM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=oM[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}function aM(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=tM(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function cM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=oM[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}const uM=Ox,lM=qx,hM=function(e){let t=0;if(e=e.toString().trim(),uM(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(lM(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;uM(r[n])&&(e=hM(r[n]),r[n]=sM(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,sM(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},dM=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},fM=-1,pM={},gM={};function bM(e){if("number"===typeof e){if(null!=gM[e])return gM[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=pM[e])return pM[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,fM,"ip6zone"],[43,8,"ipcidr"],[53,fM,"dns",!0],[54,fM,"dns4",!0],[55,fM,"dns6",!0],[56,fM,"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,fM,"unix",!1,!0],[421,fM,"ipfs"],[421,fM,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,fM,"garlic64"],[448,0,"tls"],[449,fM,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,fM,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,fM,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);gM[t.code]=t,pM[t.name]=t}));bM("ip4"),bM("ip6"),bM("ipcidr");function yM(e,t){switch(bM(e).code){case 4:case 41:return function(e){const t=dM(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return kM(t);case 6:case 273:case 33:case 132:return SM(t).toString();case 421:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return sM(r,"base58btc")}(t);case 444:case 445:return xM(t);case 466:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+sM(r,"base64url")}(t);default:return sM(t,"base16")}}function mM(e,t){switch(bM(e).code){case 4:case 41:return _M(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return AM(t);case 6:case 273:case 33:case 132:return EM(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?sR(rT.decode("z".concat(e))).bytes:mR.parse(e).multihash.bytes;const r=Uint8Array.from(Eo(t.length));return aM([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(16!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion address."));const r=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)");const i=EM(n);return aM([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));const r=dT.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=EM(n);return aM([r,i],r.length+i.length)}(t);case 466:return function(e){const t=wM.decode(e),r=Uint8Array.from(Eo(t.length));return aM([r,t],r.length+t.length)}(t);default:return cM(t,"base16")}}const vM=Object.values(SR).map((e=>e.decoder)),wM=function(){let e=vM[0].or(vM[1]);return vM.slice(2).forEach((t=>e=e.or(t))),e}();function _M(e){if(!Kx(e))throw new Error("invalid ip address");return hM(e)}function EM(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function SM(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function AM(e){const t=cM(e),r=Uint8Array.from(Eo(t.length));return aM([r,t],r.length+t.length)}function kM(e){const t=So(e);if((e=e.slice(vo(t))).length!==t)throw new Error("inconsistent lengths");return sM(e)}function xM(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=sM(t,"base32"),i=SM(r);return"".concat(n,":").concat(i)}function IM(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const o=So(e,i),s=vo(o),a=bM(o),c=RM(a,e.slice(i+s));if(0===c){t.push([o]),r.push([o]),i+=s;continue}const u=e.slice(i+s,i+s+c);if(i+=c+s,i>e.length)throw DM("Invalid address Uint8Array: "+sM(e,"base16"));t.push([o,u]);const l=yM(o,u);if(r.push([o,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:CM(r),tuples:t,stringTuples:r,path:n}}function CM(e){const t=[];return e.map((e=>{const r=bM(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),PM(t.join("/"))}function TM(e){return aM(e.map((e=>{const t=bM(e[0]);let r=Uint8Array.from(Eo(t.code));return e.length>1&&null!=e[1]&&(r=aM([r,e[1]])),r})))}function RM(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=So(t instanceof Uint8Array?t:Uint8Array.from(t));return e+vo(e)}}function PM(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function DM(e){return new Error("Error parsing address: "+e)}const NM=Symbol.for("nodejs.util.inspect.custom"),BM=Symbol.for("@multiformats/js-multiaddr/multiaddr"),UM=[bM("dns").code,bM("dns4").code,bM("dns6").code,bM("dnsaddr").code];var LM=new WeakMap,MM=new WeakMap,OM=new WeakMap,qM=new WeakMap;class KM{constructor(e){let t;if(co(this,"bytes",void 0),ud(this,LM,void 0),ud(this,MM,void 0),ud(this,OM,void 0),ud(this,qM,void 0),co(this,BM,!0),null==e&&(e=""),e instanceof Uint8Array)t=IM(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));t=function(e){const t=[],r=[];let n=null;const i=(e=PM(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){const s=bM(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw DM("invalid address: "+e);if(!0===s.path){n=PM(i.slice(o).join("/")),t.push([s.code,mM(s.code,n)]),r.push([s.code,n]);break}const a=mM(s.code,i[o]);t.push([s.code,a]),r.push([s.code,yM(s.code,a)])}return{string:CM(r),bytes:TM(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!VM(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=IM(e.bytes)}this.bytes=t.bytes,yS(LM,this,t.string),yS(MM,this,t.tuples),yS(OM,this,t.stringTuples),yS(qM,this,t.path)}toString(){return hd(LM,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=bM("tcp"),s=bM("udp"),a=bM("ip4"),c=bM("ip6"),u=bM("dns6"),l=bM("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),UM.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===u.code?6:4),h!==o.code&&h!==s.code||(t=bM(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=bM(h).name,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return hd(MM,this).map((e=>{let[t]=e;return Object.assign({},bM(t))}))}protoCodes(){return hd(MM,this).map((e=>{let[t]=e;return t}))}protoNames(){return hd(MM,this).map((e=>{let[t]=e;return bM(t).name}))}tuples(){return hd(MM,this)}stringTuples(){return hd(OM,this)}encapsulate(e){return e=new KM(e),new KM(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address ".concat(this.toString()," does not contain subaddress: ").concat(e.toString()));return new KM(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new KM(TM(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===pM.p2p.code&&e.push([r,n]),r===pM["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){const e=t[1];return"Q"===e[0]||"1"===e[0]?sM(rT.decode("z".concat(e)),"base58btc"):sM(mR.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return hd(qM,this)}equals(e){return AR(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=FM.get(t.name);if(null==r)throw new ug("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>zM(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[NM](){return"Multiaddr(".concat(hd(LM,this),")")}}const FM=new Map;function VM(e){return Boolean(null===e||void 0===e?void 0:e[BM])}function zM(e){return new KM(e)}new Uint8Array(0);var jM=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const HM=jM;class GM{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class WM{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return QM(this,e)}}class YM{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return QM(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function QM(e,t){var r,n;return new YM({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class JM{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new GM(e,t,r),this.decoder=new WM(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function XM(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new JM(t,r,n,i)}function ZM(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=HM(n,t);return XM({prefix:r,name:t,encode:i,decode:e=>function(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}(o(e))})}function $M(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return XM({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const eO=ZM({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tO=(ZM({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),$M({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$M({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$M({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6})),rO=($M({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),e=>({match:t=>!(t.length<1)&&(!!e(t[0])&&t.slice(1)),pattern:"fn"})),nO=e=>({match:t=>rO((t=>t===e)).match(t),pattern:e}),iO=()=>({match:e=>rO((e=>"string"===typeof e)).match(e),pattern:"{string}"}),oO=()=>({match:e=>rO((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),sO=()=>({match:e=>{if(e.length<2)return!1;if("p2p"!==e[0]&&"ipfs"!==e[0])return!1;if(!e[1].startsWith("Q")&&!e[1].startsWith("1"))return!1;try{eO.decode("z".concat(e[1]))}catch(t){return!1}return e.slice(2)},pattern:"/p2p/{peerid}"}),aO=()=>({match:e=>{if(e.length<2)return!1;if("certhash"!==e[0])return!1;try{tO.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),cO=e=>({match:t=>{const r=e.match(t);return!1===r?t:r},pattern:"optional(".concat(e.pattern,")")}),uO=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return{match:e=>{let r;for(const n of t){const t=n.match(e);!1!==t&&((null==r||t.length<r.length)&&(r=t))}return null!=r&&r},pattern:"or(".concat(t.map((e=>e.pattern)).join(", "),")")}},lO=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return{match:e=>{for(const r of t){const t=r.match(e);if(!1===t)return!1;e=t}return e},pattern:"and(".concat(t.map((e=>e.pattern)).join(", "),")")}};function hO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){let r=(e=>e.toString().split("/").slice(1))(e);for(const n of t){const e=n.match(r);if(!1===e)return!1;r=e}return r}return{matches:function(e){return!1!==n(e)},exactMatch:function(e){const t=n(e);return!1!==t&&0===t.length}}}const dO=lO(nO("dns4"),iO()),fO=lO(nO("dns6"),iO()),pO=lO(nO("dnsaddr"),iO()),gO=lO(nO("dns"),iO()),bO=(hO(dO),hO(fO),hO(pO),hO(uO(gO,pO,dO,fO)),lO(nO("ip4"),rO(Ox))),yO=lO(nO("ip6"),rO(qx)),mO=uO(bO,yO),vO=uO(mO,gO,dO,fO,pO),wO=hO(vO),_O=(hO(bO),hO(yO),hO(mO),lO(vO,nO("tcp"),oO())),EO=lO(vO,nO("udp"),oO()),SO=uO(_O,EO),AO=(hO(_O),hO(EO),lO(EO,nO("quic"))),kO=lO(EO,nO("quic-v1")),xO=uO(AO,kO),IO=(hO(AO),hO(kO),uO(vO,_O,EO,AO,kO)),CO=uO(lO(IO,nO("ws"),cO(sO()))),TO=(hO(CO),uO(lO(IO,nO("wss"),cO(sO())),lO(IO,nO("tls"),nO("ws"),cO(sO())))),RO=(hO(TO),lO(SO,nO("webrtc-direct"),aO(),cO(aO()),cO(sO()))),PO=(hO(RO),lO(kO,nO("webtransport"),aO(),aO(),cO(sO()))),DO=(hO(PO),uO(CO,TO,lO(_O,cO(sO())),lO(xO,cO(sO())),lO(vO,cO(sO())),RO,PO,sO())),NO=(hO(DO),hO(lO(DO,nO("p2p-circuit"),sO())));hO(uO(lO(DO,nO("p2p-circuit"),nO("webrtc"),sO()),lO(DO,nO("webrtc"),cO(sO())),nO("webrtc"))),hO(uO(lO(vO,nO("tcp"),oO(),nO("http"),cO(sO())),lO(vO,nO("http"),cO(sO())))),hO(uO(lO(vO,nO("tcp"),uO(lO(nO("443"),nO("http")),lO(oO(),nO("https"))),cO(sO())),lO(vO,nO("tls"),nO("http"),cO(sO())),lO(vO,nO("https"),cO(sO()))));function BO(e,t){const r=Nd(e,t),n={read:async(e,t)=>{const n=await r.read(t);return e.decode(n)},write:async(e,t,n)=>{await r.write(t.encode(e),n)},writeV:async(e,t,n)=>{await r.writeV(e.map((e=>t.encode(e))),n)},pb:e=>({read:async t=>n.read(e,t),write:async(t,r)=>n.write(t,e,r),writeV:async(t,r)=>n.writeV(t,e,r),unwrap:()=>n}),unwrap:()=>r.unwrap()};return n}var UO=__webpack_require__(4053);const LO="object"===typeof window&&"object"===typeof document&&9===document.nodeType,MO=UO(),OO=LO&&!MO,qO=MO&&!LO,KO=MO&&LO,FO="undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.release&&"node"===globalThis.process.release.name&&!MO,VO="function"===typeof importScripts&&"undefined"!==typeof self&&"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,zO=("undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.env&&globalThis.process.env.NODE_ENV,"undefined"!==typeof navigator&&"ReactNative"===navigator.product),jO=new Float32Array([-0]),HO=new Uint8Array(jO.buffer);function GO(e,t,r){jO[0]=e,t[r]=HO[0],t[r+1]=HO[1],t[r+2]=HO[2],t[r+3]=HO[3]}const WO=new Float64Array([-0]),YO=new Uint8Array(WO.buffer);function QO(e,t,r){WO[0]=e,t[r]=YO[0],t[r+1]=YO[1],t[r+2]=YO[2],t[r+3]=YO[3],t[r+4]=YO[4],t[r+5]=YO[5],t[r+6]=YO[6],t[r+7]=YO[7]}const JO=BigInt(Number.MAX_SAFE_INTEGER),XO=BigInt(Number.MIN_SAFE_INTEGER);class ZO{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return $O;if(e<JO&&e>XO)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>eq&&(n=0n,++r>eq&&(r=0n))),new ZO(Number(n),Number(r))}static fromNumber(e){if(0===e)return $O;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new ZO(r,n)}static from(e){return"number"===typeof e?ZO.fromNumber(e):"bigint"===typeof e?ZO.fromBigInt(e):"string"===typeof e?ZO.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new ZO(e.low>>>0,e.high>>>0):$O}}const $O=new ZO(0,0);$O.toBigInt=function(){return 0n},$O.zzEncode=$O.zzDecode=function(){return this},$O.length=function(){return 1};const eq=4294967296n;function tq(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function rq(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function nq(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class iq{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,rq(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw rq(this,4);return nq(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw rq(this,4);return 0|nq(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw rq(this,4);const e=(t=this.buf,r=this.pos,HO[0]=t[r],HO[1]=t[r+1],HO[2]=t[r+2],HO[3]=t[r+3],jO[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw rq(this,4);const e=(t=this.buf,r=this.pos,YO[0]=t[r],YO[1]=t[r+1],YO[2]=t[r+2],YO[3]=t[r+3],YO[4]=t[r+4],YO[5]=t[r+5],YO[6]=t[r+6],YO[7]=t[r+7],WO[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw rq(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw rq(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw rq(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new ZO(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw rq(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw rq(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw rq(this,8);const e=nq(this.buf,this.pos+=4),t=nq(this.buf,this.pos+=4);return new ZO(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function oq(e,t,r){const n=function(e){return new iq(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class sq{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function aq(){}class cq{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const uq=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return tM(e);i+e>t&&(n=tM(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class lq{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new sq(aq,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new sq(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new fq((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(pq,10,ZO.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=ZO.fromBigInt(e);return this._push(pq,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=ZO.fromBigInt(e).zzEncode();return this._push(pq,t.length(),t)}sint64Number(e){const t=ZO.fromNumber(e).zzEncode();return this._push(pq,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(hq,1,e?1:0)}fixed32(e){return this._push(gq,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=ZO.fromBigInt(e);return this._push(gq,4,t.lo)._push(gq,4,t.hi)}fixed64Number(e){const t=ZO.fromNumber(e);return this._push(gq,4,t.lo)._push(gq,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(GO,4,e)}double(e){return this._push(QO,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(hq,1,0):this.uint32(t)._push(bq,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(tq,t,e):this._push(hq,1,0)}fork(){return this.states=new cq(this),this.head=this.tail=new sq(aq,0,0),this.len=0,this}reset(){return null!=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 sq(aq,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?tM(r):uq(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function hq(e,t,r){t[r]=255&e}function dq(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class fq extends sq{constructor(e,t){super(dq,e,t),co(this,"next",void 0),this.next=void 0}}function pq(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function gq(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function bq(e,t,r){t.set(e,r)}function yq(e,t,r){t.set(e,r)}function mq(e,t,r){e.length<40?tq(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(cM(e),r)}function vq(e,t){const r=new lq;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var wq,_q;null!=globalThis.Buffer&&(lq.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(yq,t,e),this},lq.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(mq,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(wq||(wq={}));Error;!function(e){let t;e.codec=()=>(null==t&&(t=function(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",wq.LENGTH_DELIMITED,e,t)}((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.protocolVersion&&(t.uint32(42),t.string(e.protocolVersion)),null!=e.agentVersion&&(t.uint32(50),t.string(e.agentVersion)),null!=e.publicKey&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.listenAddrs)for(const n of e.listenAddrs)t.uint32(18),t.bytes(n);if(null!=e.observedAddr&&(t.uint32(34),t.bytes(e.observedAddr)),null!=e.protocols)for(const n of e.protocols)t.uint32(26),t.string(n);null!=e.signedPeerRecord&&(t.uint32(66),t.bytes(e.signedPeerRecord)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={listenAddrs:[],protocols:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 5:r.protocolVersion=e.string();break;case 6:r.agentVersion=e.string();break;case 1:r.publicKey=e.bytes();break;case 2:r.listenAddrs.push(e.bytes());break;case 4:r.observedAddr=e.bytes();break;case 3:r.protocols.push(e.string());break;case 8:r.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>vq(t,e.codec()),e.decode=t=>oq(t,e.codec())}(_q||(_q={}));const Eq=8192,Sq="ipfs",Aq=6e4,kq=1,xq=1,Iq=1,Cq=1,Tq=10,Rq=8192,Pq=!0,Dq=!0;var Nq=new WeakSet;class Bq{constructor(e){var t,r,n,i,o,s,a,c,u,l,h,d,f;let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};jC(this,Nq),co(this,"identifyProtocolStr",void 0),co(this,"identifyPushProtocolStr",void 0),co(this,"host",void 0),co(this,"started",void 0),co(this,"timeout",void 0),co(this,"peerId",void 0),co(this,"peerStore",void 0),co(this,"registrar",void 0),co(this,"connectionManager",void 0),co(this,"addressManager",void 0),co(this,"maxInboundStreams",void 0),co(this,"maxOutboundStreams",void 0),co(this,"maxPushIncomingStreams",void 0),co(this,"maxPushOutgoingStreams",void 0),co(this,"maxIdentifyMessageSize",void 0),co(this,"maxObservedAddresses",void 0),co(this,"events",void 0),co(this,"runOnTransientConnection",void 0),co(this,"log",void 0),this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.events=e.events,this.log=e.logger.forComponent("libp2p:identify"),this.identifyProtocolStr="/".concat(null!==(t=p.protocolPrefix)&&void 0!==t?t:Sq,"/").concat("id","/").concat("1.0.0"),this.identifyPushProtocolStr="/".concat(null!==(r=p.protocolPrefix)&&void 0!==r?r:Sq,"/").concat("id/push","/").concat("1.0.0"),this.timeout=null!==(n=p.timeout)&&void 0!==n?n:Aq,this.maxInboundStreams=null!==(i=p.maxInboundStreams)&&void 0!==i?i:kq,this.maxOutboundStreams=null!==(o=p.maxOutboundStreams)&&void 0!==o?o:xq,this.maxPushIncomingStreams=null!==(s=p.maxPushIncomingStreams)&&void 0!==s?s:Iq,this.maxPushOutgoingStreams=null!==(a=p.maxPushOutgoingStreams)&&void 0!==a?a:Cq,this.maxIdentifyMessageSize=null!==(c=p.maxIdentifyMessageSize)&&void 0!==c?c:Rq,this.maxObservedAddresses=null!==(u=p.maxObservedAddresses)&&void 0!==u?u:Tq,this.runOnTransientConnection=null!==(l=p.runOnTransientConnection)&&void 0!==l?l:Dq,this.host={protocolVersion:"".concat(null!==(h=p.protocolPrefix)&&void 0!==h?h:Sq,"/").concat("0.1.0"),agentVersion:null!==(d=p.agentVersion)&&void 0!==d?d:"".concat(e.nodeInfo.name,"/").concat(e.nodeInfo.version)},(null!==(f=p.runOnConnectionOpen)&&void 0!==f?f:Pq)&&e.events.addEventListener("connection:open",(e=>{const t=e.detail;this.identify(t).catch((e=>{this.log.error("error during identify trigged by connection:open",e)}))})),e.events.addEventListener("self:peer:update",(e=>{this.push().catch((e=>{this.log.error(e)}))})),this.host.agentVersion==="".concat(e.nodeInfo.name,"/").concat(e.nodeInfo.version)&&(FO||qO?this.host.agentVersion+=" UserAgent=".concat(globalThis.process.version):(OO||VO||KO||zO)&&(this.host.agentVersion+=" UserAgent=".concat(globalThis.navigator.userAgent)))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:cM(this.host.agentVersion),ProtocolVersion:cM(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,(e=>{this._handleIdentify(e).catch((e=>{this.log.error(e)}))}),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,(e=>{this._handlePush(e).catch((e=>{this.log.error(e)}))}),{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(e){var t,r;const n=this.addressManager.getAddresses().map((e=>e.decapsulateCode(bM("p2p").code))),i=new JN({peerId:this.peerId,multiaddrs:n}),o=await $L.seal(i,this.peerId),s=this.registrar.getProtocols(),a=await this.peerStore.get(this.peerId),c=sM(null!==(t=a.metadata.get("AgentVersion"))&&void 0!==t?t:cM(this.host.agentVersion)),u=sM(null!==(r=a.metadata.get("ProtocolVersion"))&&void 0!==r?r:cM(this.host.protocolVersion)),l=e.map((async e=>{let t;const r=AbortSignal.timeout(this.timeout);dd(1/0,r);try{var i;t=await e.newStream(this.identifyPushProtocolStr,{signal:r,runOnTransientConnection:this.runOnTransientConnection});const a=BO(t,{maxDataLength:null!==(i=this.maxIdentifyMessageSize)&&void 0!==i?i:Eq}).pb(_q);await a.write({listenAddrs:n.map((e=>e.bytes)),signedPeerRecord:o.marshal(),protocols:s,agentVersion:c,protocolVersion:u},{signal:r}),await t.close({signal:r})}catch(l){var a;this.log.error("could not push identify update to peer",l),null===(a=t)||void 0===a||a.abort(l)}}));await Promise.all(l)}async push(){if(!this.isStarted())return;const e=[];await Promise.all(this.connectionManager.getConnections().map((async t=>{try{if(!(await this.peerStore.get(t.remotePeer)).protocols.includes(this.identifyPushProtocolStr))return;e.push(t)}catch(r){if("ERR_NOT_FOUND"!==r.code)throw r}}))),await this.pushToConnections(e)}async _identify(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==r.signal){const e=AbortSignal.timeout(this.timeout);dd(1/0,e),r={...r,signal:e}}try{var n;t=await e.newStream(this.identifyProtocolStr,{...r,runOnTransientConnection:this.runOnTransientConnection});const i=BO(t,{maxDataLength:null!==(n=this.maxIdentifyMessageSize)&&void 0!==n?n:Eq}).pb(_q),o=await i.read(r);return await t.close(r),o}catch(o){var i;throw this.log.error("error while reading identify message",o),null===(i=t)||void 0===i||i.abort(o),o}}async identify(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await this._identify(e,r),{publicKey:i,protocols:o,observedAddr:s}=n;if(null==i)throw new ug("public key was missing from identify message","ERR_MISSING_PUBLIC_KEY");const a=await BR(i);if(!e.remotePeer.equals(a))throw new ug("identified peer does not match the expected peer","ERR_INVALID_PEER");if(this.peerId.equals(a))throw new ug("identified peer is our own peer id?","ERR_INVALID_PEER");const c=function(e){if(null!=e&&e.length>0)try{return zM(e)}catch{}}(s);return this.log("identify completed for peer %p and protocols %o",a,o),this.log("our observed address is %a",c),null!=c&&this.addressManager.getObservedAddrs().length<(null!==(t=this.maxObservedAddresses)&&void 0!==t?t:1/0)&&(this.log("storing our observed address %a",c),this.addressManager.addObservedAddr(c)),ld(Nq,this,Uq).call(this,e,n)}async _handleIdentify(e){const{connection:t,stream:r}=e,n=AbortSignal.timeout(this.timeout);dd(1/0,n);try{var i;const e=null!==(i=this.peerId.publicKey)&&void 0!==i?i:new Uint8Array(0),o=await this.peerStore.get(this.peerId),s=this.addressManager.getAddresses().map((e=>e.decapsulateCode(bM("p2p").code)));let a=o.peerRecordEnvelope;if(s.length>0&&null==a){const e=new JN({peerId:this.peerId,multiaddrs:s});a=(await $L.seal(e,this.peerId)).marshal().subarray()}let c=t.remoteAddr.bytes;wO.matches(t.remoteAddr)||(c=void 0);const u=BO(r).pb(_q);await u.write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:e,listenAddrs:s.map((e=>e.bytes)),signedPeerRecord:a,observedAddr:c,protocols:o.protocols},{signal:n}),await r.close({signal:n})}catch(o){this.log.error("could not respond to identify request",o),r.abort(o)}}async _handlePush(e){const{connection:t,stream:r}=e;try{var n;if(this.peerId.equals(t.remotePeer))throw new Error("received push from ourselves?");const e={signal:AbortSignal.timeout(this.timeout)},i=BO(r,{maxDataLength:null!==(n=this.maxIdentifyMessageSize)&&void 0!==n?n:Eq}).pb(_q),o=await i.read(e);await r.close(e),await ld(Nq,this,Uq).call(this,t,o)}catch(i){return this.log.error("received invalid message",i),void r.abort(i)}this.log("handled push from %p",t.remotePeer)}}async function Uq(e,t){if(this.log("received identify from %p",e.remotePeer),null==t)throw new ug("message was null or undefined","ERR_INVALID_MESSAGE");const r={};if(t.listenAddrs.length>0&&(r.addresses=t.listenAddrs.map((e=>({isCertified:!1,multiaddr:zM(e)})))),t.protocols.length>0&&(r.protocols=t.protocols),null!=t.publicKey){r.publicKey=t.publicKey;if(!(await BR(t.publicKey)).equals(e.remotePeer))throw new ug("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY")}let n;if(null!=t.signedPeerRecord){this.log("received signedPeerRecord from %p",e.remotePeer);let i=t.signedPeerRecord;const s=await $L.openAndCertify(i,JN.DOMAIN);let a,c=JN.createFromProtobuf(s.payload);if(!c.peerId.equals(s.peerId))throw new ug("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!e.remotePeer.equals(c.peerId))throw new ug("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");try{a=await this.peerStore.get(c.peerId)}catch(o){if("ERR_NOT_FOUND"!==o.code)throw o}if(null!=a&&(r.metadata=a.metadata,null!=a.peerRecordEnvelope)){const e=await $L.createFromProtobuf(a.peerRecordEnvelope),t=JN.createFromProtobuf(e.payload);t.seqNumber>=c.seqNumber&&(this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",t.seqNumber,c.seqNumber),c=t,i=a.peerRecordEnvelope)}r.peerRecordEnvelope=i,r.addresses=c.multiaddrs.map((e=>({isCertified:!0,multiaddr:e}))),n={seq:c.seqNumber,addresses:c.multiaddrs}}else this.log("%p did not send a signed peer record",e.remotePeer);if(this.log("patching %p with",e.remotePeer,r),await this.peerStore.patch(e.remotePeer,r),null!=t.agentVersion||null!=t.protocolVersion){const r={};null!=t.agentVersion&&(r.AgentVersion=cM(t.agentVersion)),null!=t.protocolVersion&&(r.ProtocolVersion=cM(t.protocolVersion)),this.log("merging %p metadata",e.remotePeer,r),await this.peerStore.merge(e.remotePeer,{metadata:r})}const i={peerId:e.remotePeer,protocolVersion:t.protocolVersion,agentVersion:t.agentVersion,publicKey:t.publicKey,listenAddrs:t.listenAddrs.map((e=>zM(e))),observedAddr:null==t.observedAddr?void 0:zM(t.observedAddr),protocols:t.protocols,signedPeerRecord:n,connection:e};return this.events.safeDispatchEvent("peer:identify",{detail:i}),i}function Lq(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Bq(t,e)}function Mq(e,t){var r,n;const i=null===(r=(n=function(e){if(null!=e){if("function"===typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"===typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"===typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}(e)).return)||void 0===r?void 0:r.call(n);var o;null!=(o=i)&&"function"===typeof o.then&&"function"===typeof o.catch&&"function"===typeof o.finally&&i.catch((e=>{t.error("could not cause iterator to return",e)}))}const Oq=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},qq=new WeakMap;const Kq=function(){let{clearTimeout:e,setTimeout:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){let n,i,o,{value:s,signal:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!==a&&void 0!==a&&a.aborted)return Promise.reject(Oq());const c=null!==e&&void 0!==e?e:clearTimeout,u=()=>{c(n),o(Oq())},l=new Promise(((e,c)=>{i=()=>{a&&a.removeEventListener("abort",u),e(s)},o=c,n=(null!==t&&void 0!==t?t:setTimeout)(i,r)}));return a&&a.addEventListener("abort",u,{once:!0}),qq.set(l,(()=>{c(n),n=null,i()})),l}}(),Fq=Kq;class Vq{constructor(){var e,t,r,n,i,o;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};co(this,"memoryStorage",void 0),co(this,"points",void 0),co(this,"duration",void 0),co(this,"blockDuration",void 0),co(this,"execEvenly",void 0),co(this,"execEvenlyMinDelayMs",void 0),co(this,"keyPrefix",void 0),this.points=null!==(e=s.points)&&void 0!==e?e:4,this.duration=null!==(t=s.duration)&&void 0!==t?t:1,this.blockDuration=null!==(r=s.blockDuration)&&void 0!==r?r:0,this.execEvenly=null!==(n=s.execEvenly)&&void 0!==n&&n,this.execEvenlyMinDelayMs=null!==(i=s.execEvenlyMinDelayMs)&&void 0!==i?i:1e3*this.duration/this.points,this.keyPrefix=null!==(o=s.keyPrefix)&&void 0!==o?o:"rlflx",this.memoryStorage=new zq}async consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e),i=this._getKeySecDuration(r);let o=this.memoryStorage.incrby(n,t,i);if(o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.consumedPoints>this.points)throw this.blockDuration>0&&o.consumedPoints<=this.points+t&&(o=this.memoryStorage.set(n,o.consumedPoints,this.blockDuration)),new ug("Rate limit exceeded","ERR_RATE_LIMIT_EXCEEDED",o);if(this.execEvenly&&o.msBeforeNext>0&&!o.isFirstInDuration){let e=Math.ceil(o.msBeforeNext/(o.remainingPoints+2));e<this.execEvenlyMinDelayMs&&(e=o.consumedPoints*this.execEvenlyMinDelayMs),await Fq(e)}return o}penalty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e),i=this._getKeySecDuration(r),o=this.memoryStorage.incrby(n,t,i);return o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e),i=this._getKeySecDuration(r),o=this.memoryStorage.incrby(n,-t,i);return o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o}block(e,t){const r=1e3*t,n=this.points+1;return this.memoryStorage.set(this.getKey(e),n,t),{remainingPoints:0,msBeforeNext:0===r?-1:r,consumedPoints:n,isFirstInDuration:!1}}set(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=1e3*(r>=0?r:this.duration);return this.memoryStorage.set(this.getKey(e),t,r),{remainingPoints:0,msBeforeNext:0===n?-1:n,consumedPoints:t,isFirstInDuration:!1}}get(e){const t=this.memoryStorage.get(this.getKey(e));return null!=t&&(t.remainingPoints=Math.max(this.points-t.consumedPoints,0)),t}delete(e){this.memoryStorage.delete(this.getKey(e))}_getKeySecDuration(e){return null!=(null===e||void 0===e?void 0:e.customDuration)&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?"".concat(this.keyPrefix,":").concat(e):e}parseKey(e){return e.substring(this.keyPrefix.length)}}class zq{constructor(){co(this,"storage",void 0),this.storage=new Map}incrby(e,t,r){const n=this.storage.get(e);if(null!=n){const i=null!=n.expiresAt?n.expiresAt.getTime()-(new Date).getTime():-1;return null==n.expiresAt||i>0?(n.value+=t,{remainingPoints:0,msBeforeNext:i,consumedPoints:n.value,isFirstInDuration:!1}):this.set(e,t,r)}return this.set(e,t,r)}set(e,t,r){const n=1e3*r,i=this.storage.get(e);null!=i&&clearTimeout(i.timeoutId);const o={value:t,expiresAt:n>0?new Date(Date.now()+n):void 0};return this.storage.set(e,o),n>0&&(o.timeoutId=setTimeout((()=>{this.storage.delete(e)}),n),null!=o.timeoutId.unref&&o.timeoutId.unref()),{remainingPoints:0,msBeforeNext:0===n?-1:n,consumedPoints:o.value,isFirstInDuration:!0}}get(e){const t=this.storage.get(e);if(null!=t){return{remainingPoints:0,msBeforeNext:null!=t.expiresAt?t.expiresAt.getTime()-(new Date).getTime():-1,consumedPoints:t.value,isFirstInDuration:!1}}}delete(e){const t=this.storage.get(e);return null!=t&&(null!=t.timeoutId&&clearTimeout(t.timeoutId),this.storage.delete(e),!0)}}new Uint8Array(0);function jq(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Hq=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Gq=Hq;class Wq{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Yq{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Jq(this,e)}}class Qq{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return Jq(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function Jq(e,t){var r,n;return new Qq({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Xq{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Wq(e,t,r),this.decoder=new Yq(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Zq(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Xq(t,r,n,i)}function $q(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Gq(n,t);return Zq({prefix:r,name:t,encode:i,decode:e=>jq(o(e))})}function eK(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Zq({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const tK=$q({prefix:"9",name:"base10",alphabet:"0123456789"}),rK=eK({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),nK=eK({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),iK=eK({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),oK=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),sK=oK.reduce(((e,t,r)=>(e[r]=t,e)),[]),aK=oK.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const cK=Zq({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=sK[t]),"")},decode:function(e){const t=[];for(const r of e){const e=aK[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),uK=eK({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lK=eK({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),hK=eK({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),dK=eK({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fK=eK({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pK=eK({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gK=eK({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bK=eK({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),yK=eK({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),mK=$q({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vK=$q({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),wK=$q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_K=$q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),EK=eK({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),SK=eK({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),AK=eK({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kK=eK({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),xK=eK({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),IK=Zq({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),CK=new TextEncoder,TK=new TextDecoder,RK="json",PK=512;function DK(e){return CK.encode(JSON.stringify(e))}function NK(e){return JSON.parse(TK.decode(e))}const BK="raw",UK=85;function LK(e){return jq(e)}function MK(e){return jq(e)}var OK=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=FK;)r[n++]=255&t|qK,t/=128;for(;t&KK;)r[n++]=255&t|qK,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},qK=128,KK=-128,FK=Math.pow(2,31);var VK=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&jK)<<o:(n&jK)*Math.pow(2,o),o+=7}while(n>=zK);return e.bytes=s-r,i},zK=128,jK=127;var HK=Math.pow(2,7),GK=Math.pow(2,14),WK=Math.pow(2,21),YK=Math.pow(2,28),QK=Math.pow(2,35),JK=Math.pow(2,42),XK=Math.pow(2,49),ZK=Math.pow(2,56),$K=Math.pow(2,63);const eF={encode:OK,decode:VK,encodingLength:function(e){return e<HK?1:e<GK?2:e<WK?3:e<YK?4:e<QK?5:e<JK?6:e<XK?7:e<ZK?8:e<$K?9:10}};function tF(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return eF.encode(e,t,r),t}function rF(e){return eF.encodingLength(e)}function nF(e,t){const r=t.byteLength,n=rF(e),i=n+rF(r),o=new Uint8Array(i+r);return tF(e,o,0),tF(r,o,n),o.set(t,i),new iF(e,r,t,o)}class iF{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const oF=jq;const sF={code:0,name:"identity",encode:oF,digest:function(e){return nF(0,oF(e))}};function aF(e){let{name:t,code:r,encode:n}=e;return new cF(t,r,n)}class cF{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?nF(this.code,t):t.then((e=>nF(this.code,e)))}throw Error("Unknown type, must be binary type")}}function uF(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const lF=aF({name:"sha2-256",code:18,encode:uF("SHA-256")}),hF=aF({name:"sha2-512",code:19,encode:uF("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const dF={...Bt,...It,...Nt,...kt,...xt,...Tt,...Rt,...Pt,...Dt,...Ct};function fF(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function pF(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const gF=pF("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),bF=pF("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=fF((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),yF={utf8:gF,"utf-8":gF,hex:dF.base16,latin1:bF,ascii:bF,binary:bF,...dF};function mF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=yF[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function vF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=yF[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}var wF;!function(e){e[e.NEW_STREAM=0]="NEW_STREAM",e[e.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",e[e.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",e[e.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",e[e.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",e[e.RESET_RECEIVER=5]="RESET_RECEIVER",e[e.RESET_INITIATOR=6]="RESET_INITIATOR"}(wF||(wF={}));const _F=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),EF=Object.freeze({NEW_STREAM:wF.NEW_STREAM,MESSAGE:wF.MESSAGE_INITIATOR,CLOSE:wF.CLOSE_INITIATOR,RESET:wF.RESET_INITIATOR}),SF=Object.freeze({MESSAGE:wF.MESSAGE_RECEIVER,CLOSE:wF.CLOSE_RECEIVER,RESET:wF.RESET_RECEIVER}),AF=1<<20;class kF{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:AF,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4194304;co(this,"_buffer",void 0),co(this,"_headerInfo",void 0),co(this,"_maxMessageSize",void 0),co(this,"_maxUnprocessedMessageQueueSize",void 0),this._buffer=new nh,this._headerInfo=null,this._maxMessageSize=e,this._maxUnprocessedMessageQueueSize=t}write(e){if(null==e||0===e.length)return[];if(this._buffer.append(e),this._buffer.byteLength>this._maxUnprocessedMessageQueueSize)throw Object.assign(new Error("unprocessed message queue size too large!"),{code:"ERR_MSG_QUEUE_TOO_BIG"});const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch(r){if("ERR_MSG_TOO_BIG"===r.code)throw r;break}const{id:e,type:n,length:i,offset:o}=this._headerInfo;if(this._buffer.length-o<i)break;const s={id:e,type:n};n!==wF.NEW_STREAM&&n!==wF.MESSAGE_INITIATOR&&n!==wF.MESSAGE_RECEIVER||(s.data=this._buffer.sublist(o,o+i)),t.push(s),this._buffer.consume(o+i),this._headerInfo=null}return t}_decodeHeader(e){const{value:t,offset:r}=CF(e),{value:n,offset:i}=CF(e,r),o=7&t;if(null==_F[o])throw new Error("Invalid type received: ".concat(o));if(n>this._maxMessageSize)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"});return{id:t>>3,type:o,offset:r+i,length:n}}}const xF=128,IF=127;function CF(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0,i=0,o=r;const s=e.length;do{if(o>=s||i>49)throw r=0,new RangeError("Could not decode varint");t=e.get(o++),n+=i<28?(t&IF)<<i:(t&IF)*Math.pow(2,i),i+=7}while(t>=xF);return r=o-r,{value:n,offset:r}}const TF=10240;const RF=new class{constructor(){co(this,"_pool",void 0),co(this,"_poolOffset",void 0),this._pool=fF(TF),this._poolOffset=0}write(e,t){const r=this._pool;let n=this._poolOffset;Eo(e.id<<3|e.type,r,n),n+=vo(e.id<<3|e.type),e.type!==wF.NEW_STREAM&&e.type!==wF.MESSAGE_INITIATOR&&e.type!==wF.MESSAGE_RECEIVER||null==e.data?(Eo(0,r,n),n+=vo(0)):(Eo(e.data.length,r,n),n+=vo(e.data.length));const i=r.subarray(this._poolOffset,n);TF-n<100?(this._pool=fF(TF),this._poolOffset=0):this._poolOffset=n,t.append(i),e.type!==wF.NEW_STREAM&&e.type!==wF.MESSAGE_INITIATOR&&e.type!==wF.MESSAGE_RECEIVER||null==e.data||t.append(e.data)}};function PF(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}class DF{constructor(e){var t,r;co(this,"id",void 0),co(this,"direction",void 0),co(this,"timeline",void 0),co(this,"protocol",void 0),co(this,"metadata",void 0),co(this,"source",void 0),co(this,"status",void 0),co(this,"readStatus",void 0),co(this,"writeStatus",void 0),co(this,"log",void 0),co(this,"sinkController",void 0),co(this,"sinkEnd",void 0),co(this,"closed",void 0),co(this,"endErr",void 0),co(this,"streamSource",void 0),co(this,"onEnd",void 0),co(this,"onCloseRead",void 0),co(this,"onCloseWrite",void 0),co(this,"onReset",void 0),co(this,"onAbort",void 0),co(this,"sendCloseWriteTimeout",void 0),co(this,"sendingData",void 0),this.sinkController=new AbortController,this.sinkEnd=hh(),this.closed=hh(),this.log=e.log,this.status="open",this.readStatus="ready",this.writeStatus="ready",this.id=e.id,this.metadata=null!==(t=e.metadata)&&void 0!==t?t:{},this.direction=e.direction,this.timeline={open:Date.now()},this.sendCloseWriteTimeout=null!==(r=e.sendCloseWriteTimeout)&&void 0!==r?r:5e3,this.onEnd=e.onEnd,this.onCloseRead=null===e||void 0===e?void 0:e.onCloseRead,this.onCloseWrite=null===e||void 0===e?void 0:e.onCloseWrite,this.onReset=null===e||void 0===e?void 0:e.onReset,this.onAbort=null===e||void 0===e?void 0:e.onAbort,this.source=this.streamSource=gh({onEnd:e=>{null!=e?this.log.trace("source ended with error",e):this.log.trace("source ended"),this.onSourceEnd(e)}}),this.sink=this.sink.bind(this)}async sink(e){if("ready"!==this.writeStatus)throw new ug('writable end state is "'.concat(this.writeStatus,'" not "ready"'),"ERR_SINK_INVALID_STATE");try{this.writeStatus="writing";const t={signal:this.sinkController.signal};if("outbound"===this.direction){const e=this.sendNewStream(t);PF(e)&&await e}const r=()=>{Mq(e,this.log)};try{this.sinkController.signal.addEventListener("abort",r),this.log.trace("sink reading from source");for await(let r of e){r=r instanceof Uint8Array?new nh(r):r;const e=this.sendData(r,t);PF(e)&&(this.sendingData=hh(),await e,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener("abort",r)}this.log.trace('sink finished reading from source, write status is "%s"',this.writeStatus),"writing"===this.writeStatus&&(this.writeStatus="closing",this.log.trace("send close write to remote"),await this.sendCloseWrite({signal:AbortSignal.timeout(this.sendCloseWriteTimeout)}),this.writeStatus="closed"),this.onSinkEnd()}catch(t){throw this.log.trace("sink ended with error, calling abort with error",t),this.abort(t),t}finally{this.log.trace("resolve sink end"),this.sinkEnd.resolve()}}onSourceEnd(e){var t;null==this.timeline.closeRead&&(this.timeline.closeRead=Date.now(),this.readStatus="closed",null!=e&&null==this.endErr&&(this.endErr=e),null===(t=this.onCloseRead)||void 0===t||t.call(this),null!=this.timeline.closeWrite?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(e){var t;null==this.timeline.closeWrite&&(this.timeline.closeWrite=Date.now(),this.writeStatus="closed",null!=e&&null==this.endErr&&(this.endErr=e),null===(t=this.onCloseWrite)||void 0===t||t.call(this),null!=this.timeline.closeRead?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("sink ended, waiting for source to end"))}async close(e){this.log.trace("closing gracefully"),this.status="closing",await Id(Promise.all([this.closeWrite(e),this.closeRead(e),this.closed.promise]),null===e||void 0===e?void 0:e.signal),this.status="closed",this.log.trace("closed gracefully")}async closeRead(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("closing"===this.readStatus||"closed"===this.readStatus)return;this.log.trace('closing readable end of stream with starting read status "%s"',this.readStatus);const t=this.readStatus;this.readStatus="closing","reset"!==this.status&&"aborted"!==this.status&&null==this.timeline.closeRead&&(this.log.trace("send close read to remote"),await this.sendCloseRead(e)),"ready"===t&&(this.log.trace("ending internal source queue with %d queued bytes",this.streamSource.readableLength),this.streamSource.end()),this.log.trace("closed readable end of stream")}async closeWrite(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"closing"!==this.writeStatus&&"closed"!==this.writeStatus&&(this.log.trace('closing writable end of stream with starting write status "%s"',this.writeStatus),"ready"===this.writeStatus&&(this.log.trace("sink was never sunk, sink an empty array"),await Id(this.sink([]),e.signal)),"writing"===this.writeStatus&&(null!=this.sendingData&&await Id(this.sendingData.promise,e.signal),this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),await Id(this.sinkEnd.promise,e.signal)),this.writeStatus="closed",this.log.trace("closed writable end of stream"))}abort(e){var t;if("closed"===this.status||"aborted"===this.status||"reset"===this.status)return;this.log("abort with error",e),this.log("try to send reset to remote");const r=this.sendReset();PF(r)&&r.catch((e=>{this.log.error("error sending reset message",e)})),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(e),null===(t=this.onAbort)||void 0===t||t.call(this,e)}reset(){var e;if("closed"===this.status||"aborted"===this.status||"reset"===this.status)return;const t=new ug("stream reset","ERR_STREAM_RESET");this.status="reset",this.timeline.reset=Date.now(),this._closeSinkAndSource(t),null===(e=this.onReset)||void 0===e||e.call(this)}_closeSinkAndSource(e){this._closeSink(e),this._closeSource(e)}_closeSink(e){"writing"===this.writeStatus&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(e)}_closeSource(e){"closing"!==this.readStatus&&"closed"!==this.readStatus&&(this.log.trace("ending source with %d bytes to be read by consumer",this.streamSource.readableLength),this.readStatus="closing",this.streamSource.end(e))}remoteCloseWrite(){"closing"!==this.readStatus&&"closed"!==this.readStatus?(this.log.trace("remote close write"),this._closeSource()):this.log("received remote close write but local source is already closed")}remoteCloseRead(){"closing"!==this.writeStatus&&"closed"!==this.writeStatus?(this.log.trace("remote close read"),this._closeSink()):this.log("received remote close read but local sink is already closed")}destroy(){"closed"!==this.status&&"aborted"!==this.status&&"reset"!==this.status?(this.log.trace("stream destroyed"),this._closeSinkAndSource()):this.log("received destroy but we are already closed")}sourcePush(e){this.streamSource.push(e)}sourceReadableLength(){return this.streamSource.readableLength}}class NF extends DF{constructor(e){super(e),co(this,"name",void 0),co(this,"streamId",void 0),co(this,"send",void 0),co(this,"types",void 0),co(this,"maxDataSize",void 0),this.types="outbound"===e.direction?EF:SF,this.send=e.send,this.name=e.name,this.streamId=e.streamId,this.maxDataSize=e.maxDataSize}async sendNewStream(){await this.send({id:this.streamId,type:EF.NEW_STREAM,data:new nh(mF(this.name))})}async sendData(e){for(e=e.sublist();e.byteLength>0;){const t=Math.min(e.byteLength,this.maxDataSize);await this.send({id:this.streamId,type:this.types.MESSAGE,data:e.sublist(0,t)}),e.consume(t)}}async sendReset(){await this.send({id:this.streamId,type:this.types.RESET})}async sendCloseWrite(){await this.send({id:this.streamId,type:this.types.CLOSE})}async sendCloseRead(){}}function BF(e){const t={...e,type:"".concat(_F[e.type]," (").concat(e.type,")")};return e.type===wF.NEW_STREAM&&(t.data=vF(e.data instanceof Uint8Array?e.data:e.data.subarray())),e.type!==wF.MESSAGE_INITIATOR&&e.type!==wF.MESSAGE_RECEIVER||(t.data=vF(e.data instanceof Uint8Array?e.data:e.data.subarray(),"base16")),t}class UF{constructor(e,t){var r,n,i;co(this,"protocol","/mplex/6.7.0"),co(this,"sink",void 0),co(this,"source",void 0),co(this,"log",void 0),co(this,"_streamId",void 0),co(this,"_streams",void 0),co(this,"_init",void 0),co(this,"_source",void 0),co(this,"closeController",void 0),co(this,"rateLimiter",void 0),co(this,"closeTimeout",void 0),co(this,"logger",void 0),t=null!==(r=t)&&void 0!==r?r:{},this.log=e.logger.forComponent("libp2p:mplex"),this.logger=e.logger,this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=t,this.closeTimeout=null!==(n=t.closeTimeout)&&void 0!==n?n:500,this.sink=this._createSink(),this._source=gh({objectMode:!0,onEnd:()=>{for(const e of this._streams.initiators.values())e.destroy();for(const e of this._streams.receivers.values())e.destroy()}}),this.source=mh(this._source,(e=>async function*(e){for await(const t of e){const e=new nh;RF.write(t,e),yield e}}(e))),this.closeController=new AbortController,this.rateLimiter=new Vq({points:null!==(i=t.disconnectThreshold)&&void 0!==i?i:5,duration:1})}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;e=null==e?t.toString():e.toString();const r=this._streams.initiators;return this._newStream({id:t,name:e,type:"initiator",registry:r})}async close(e){var t;if(this.closeController.signal.aborted)return;const r=null!==(t=null===e||void 0===e?void 0:e.signal)&&void 0!==t?t:AbortSignal.timeout(this.closeTimeout);try{await Promise.all(this.streams.map((async e=>e.close({signal:r})))),this._source.end(),await this._source.onEmpty({signal:r}),this.closeController.abort()}catch(n){this.abort(n)}}abort(e){this.closeController.signal.aborted||(this.streams.forEach((t=>{t.abort(e)})),this.closeController.abort(e))}_newReceiverStream(e){const{id:t,name:r}=e,n=this._streams.receivers;return this._newStream({id:t,name:r,type:"receiver",registry:n})}_newStream(e){var t;const{id:r,name:n,type:i,registry:o}=e;if(this.log("new %s stream %s",i,r),"initiator"===i&&this._streams.initiators.size===(null!==(t=this._init.maxOutboundStreams)&&void 0!==t?t:1024))throw new ug("Too many outbound streams open","ERR_TOO_MANY_OUTBOUND_STREAMS");if(o.has(r))throw new Error("".concat(i," stream ").concat(r," already exists!"));const s=function(e){const{id:t,name:r,send:n,onEnd:i,type:o="initiator",maxMsgSize:s=AF}=e;return new NF({id:"initiator"===o?"i".concat(t):"r".concat(t),streamId:t,name:"".concat(null==r?t:r),direction:"initiator"===o?"outbound":"inbound",maxDataSize:s,onEnd:i,send:n,log:e.logger.forComponent("libp2p:mplex:stream:".concat(o,":").concat(t))})}({id:r,name:n,send:async e=>{this.log.enabled&&this.log.trace("%s stream %s send",i,r,BF(e)),this._source.push(e)},type:i,onEnd:()=>{this.log("%s stream with id %s and protocol %s ended",i,r,s.protocol),o.delete(r),null!=this._init.onStreamEnd&&this._init.onStreamEnd(s)},maxMsgSize:this._init.maxMsgSize,logger:this.logger});return o.set(r,s),s}_createSink(){return async e=>{const t=()=>{Mq(e,this.log)};this.closeController.signal.addEventListener("abort",t);try{const t=new kF(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(const r of e)for(const e of t.write(r))await this._handleIncoming(e);this._source.end()}catch(r){this.log("error in sink",r),this._source.end(r)}finally{this.closeController.signal.removeEventListener("abort",t)}}}async _handleIncoming(e){var t;const{id:r,type:n}=e;if(this.log.enabled&&this.log.trace("incoming message",BF(e)),e.type===wF.NEW_STREAM){var i;if(this._streams.receivers.size===(null!==(i=this._init.maxInboundStreams)&&void 0!==i?i:1024)){this.log("too many inbound streams open"),this._source.push({id:r,type:wF.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{return this.log("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void this.abort(new Error("Too many open streams"))}return}const t=this._newReceiverStream({id:r,name:vF(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=this._init.onIncomingStream&&this._init.onIncomingStream(t))}const o=(1===(1&n)?this._streams.initiators:this._streams.receivers).get(r);if(null==o){this.log("missing stream %s for message type %s",r,_F[n]);try{await this.rateLimiter.consume("missing-stream",1)}catch{return this.log("rate limit hit when receiving messages for streams that do not exist - closing remote connection"),void this.abort(new Error("Too many messages for missing streams"))}return}const s=null!==(t=this._init.maxStreamBufferSize)&&void 0!==t?t:4194304;try{switch(n){case wF.MESSAGE_INITIATOR:case wF.MESSAGE_RECEIVER:if(o.sourceReadableLength()>s)throw this._source.push({id:e.id,type:n===wF.MESSAGE_INITIATOR?wF.RESET_RECEIVER:wF.RESET_INITIATOR}),new ug("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");o.sourcePush(e.data);break;case wF.CLOSE_INITIATOR:case wF.CLOSE_RECEIVER:o.remoteCloseWrite();break;case wF.RESET_INITIATOR:case wF.RESET_RECEIVER:o.reset();break;default:this.log("unknown message type %s",n)}}catch(a){this.log.error("error while processing message",a),o.abort(a)}}}class LF{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"protocol","/mplex/6.7.0"),co(this,"_init",void 0),co(this,"components",void 0),this.components=e,this._init=t}createStreamMuxer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new UF(this.components,{...e,...this._init})}}function MF(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new LF(t,e)}const OF=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e)return t})();for(const t of e)return t};const qF="ERR_WRONG_PING_ACK";class KF{constructor(e){var t,r,n,i,o;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"protocol",void 0),co(this,"components",void 0),co(this,"started",void 0),co(this,"timeout",void 0),co(this,"maxInboundStreams",void 0),co(this,"maxOutboundStreams",void 0),co(this,"runOnTransientConnection",void 0),co(this,"log",void 0),this.components=e,this.log=e.logger.forComponent("libp2p:ping"),this.started=!1,this.protocol="/".concat(null!==(t=s.protocolPrefix)&&void 0!==t?t:"ipfs","/").concat("ping","/").concat("1.0.0"),this.timeout=null!==(r=s.timeout)&&void 0!==r?r:1e4,this.maxInboundStreams=null!==(n=s.maxInboundStreams)&&void 0!==n?n:2,this.maxOutboundStreams=null!==(i=s.maxOutboundStreams)&&void 0!==i?i:1,this.runOnTransientConnection=null===(o=s.runOnTransientConnection)||void 0===o||o,this.handleMessage=this.handleMessage.bind(this)}async start(){await this.components.registrar.handle(this.protocol,this.handleMessage,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}handleMessage(e){this.log("incoming ping from %p",e.connection.remotePeer);const{stream:t}=e,r=Date.now();mh(t,t).catch((t=>{this.log.error("incoming ping from %p failed with error",e.connection.remotePeer,t)})).finally((()=>{const t=Date.now()-r;this.log("incoming ping from %p complete in %dms",e.connection.remotePeer,t)}))}async ping(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.log("pinging %p",e);const r=Date.now(),n=function(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}(32),i=await this.components.connectionManager.openConnection(e,t);let o,s=()=>{};if(null==t.signal){const e=AbortSignal.timeout(this.timeout);t={...t,signal:e}}try{var a;o=await i.newStream(this.protocol,{...t,runOnTransientConnection:this.runOnTransientConnection}),s=()=>{var e;null===(e=o)||void 0===e||e.abort(new ug("ping timeout",pg))},null===(a=t.signal)||void 0===a||a.addEventListener("abort",s,{once:!0});const e=await mh([n],o,(async e=>OF(e))),c=Date.now()-r;if(null==e)throw new ug("Did not receive a ping ack after ".concat(c,"ms"),qF);if(!function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(n,e.subarray()))throw new ug("Received wrong ping ack after ".concat(c,"ms"),qF);return this.log("ping %p complete in %dms",i.remotePeer,c),c}catch(l){var c;throw this.log.error("error while pinging %p",i.remotePeer,l),null===(c=o)||void 0===c||c.abort(l),l}finally{var u;null===(u=t.signal)||void 0===u||u.removeEventListener("abort",s),null!=o&&await o.close()}}}function FF(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new KF(t,e)}const VF=Symbol.for("@libp2p/transport");var zF;!function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"}(zF||(zF={}));const jF=[Yx("tcp").code,Yx("dns").code,Yx("dnsaddr").code,Yx("dns4").code,Yx("dns6").code];function HF(e){let t;try{t=Yx("sni").code}catch(r){return null}for(const[n,i]of e)if(n===t&&void 0!==i)return i;return null}function GF(e){return e.some((e=>{let[t,r]=e;return t===Yx("tls").code}))}function WF(e,t,r){const n=YF[Yx(e).name];if(void 0===n)throw new Error("Can't interpret protocol ".concat(Yx(e).name));const i=n(t,r);return e===Yx("ip6").code?"[".concat(i,"]"):i}const YF={ip4:(e,t)=>e,ip6:(e,t)=>0===t.length?e:"[".concat(e,"]"),tcp:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"tcp://".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),":").concat(e)},udp:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"udp://".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),":").concat(e)},dnsaddr:(e,t)=>e,dns4:(e,t)=>e,dns6:(e,t)=>e,dns:(e,t)=>e,ipfs:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/ipfs/").concat(e)},p2p:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/p2p/").concat(e)},http:(e,t)=>{var r;const n=GF(t),i=HF(t);if(n&&null!==i)return"https://".concat(i);const o=n?"https://":"http://",s=t.pop();if(void 0===s)throw new Error("Unexpected end of multiaddr");let a=WF(s[0],null!==(r=s[1])&&void 0!==r?r:"",t);return a=a.replace("tcp://",""),"".concat(o).concat(a)},tls:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t)},sni:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t)},https:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");let i=WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t);return i=i.replace("tcp://",""),"https://".concat(i)},ws:(e,t)=>{var r;const n=GF(t),i=HF(t);if(n&&null!==i)return"wss://".concat(i);const o=n?"wss://":"ws://",s=t.pop();if(void 0===s)throw new Error("Unexpected end of multiaddr");let a=WF(s[0],null!==(r=s[1])&&void 0!==r?r:"",t);return a=a.replace("tcp://",""),"".concat(o).concat(a)},wss:(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");let i=WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t);return i=i.replace("tcp://",""),"wss://".concat(i)},"p2p-websocket-star":(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/p2p-websocket-star")},"p2p-webrtc-star":(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/p2p-webrtc-star")},"p2p-webrtc-direct":(e,t)=>{var r;const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return"".concat(WF(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/p2p-webrtc-direct")}};const QF=async e=>{if(e.readyState>=2)throw new Error("socket closed");1!==e.readyState&&await new Promise(((t,r)=>{function n(){e.removeEventListener("open",i),e.removeEventListener("error",o)}function i(){n(),t()}function o(t){var i;n(),r(null!==(i=t.error)&&void 0!==i?i:new Error("connect ECONNREFUSED ".concat(e.url)))}e.addEventListener("open",i),e.addEventListener("error",o)}))},JF=(e,t)=>{var r;(t=null!==(r=t)&&void 0!==r?r:{}).closeOnEnd=!1!==t.closeOnEnd;return async r=>{for await(const t of r){try{await QF(e)}catch(n){if("socket closed"===n.message)break;throw n}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(t)}null!=t.closeOnEnd&&e.readyState<=1&&await new Promise(((t,r)=>{e.addEventListener("close",(e=>{if(e.wasClean||1006===e.code)t();else{const t=Object.assign(new Error("ws error"),{event:e});r(t)}})),setTimeout((()=>{e.close()}))}))}};var XF=__webpack_require__(2605);new Uint8Array(0);function ZF(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var $F=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const eV=$F;class tV{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class rV{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return iV(this,e)}}class nV{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return iV(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function iV(e,t){var r,n;return new nV({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class oV{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new tV(e,t,r),this.decoder=new rV(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function sV(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new oV(t,r,n,i)}function aV(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=eV(n,t);return sV({prefix:r,name:t,encode:i,decode:e=>ZF(o(e))})}function cV(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return sV({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const uV=aV({prefix:"9",name:"base10",alphabet:"0123456789"}),lV=cV({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hV=cV({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),dV=cV({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),fV=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),pV=fV.reduce(((e,t,r)=>(e[r]=t,e)),[]),gV=fV.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const bV=sV({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pV[t]),"")},decode:function(e){const t=[];for(const r of e){const e=gV[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),yV=cV({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mV=cV({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vV=cV({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wV=cV({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_V=cV({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),EV=cV({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SV=cV({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AV=cV({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kV=cV({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),xV=aV({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),IV=aV({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),CV=aV({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),TV=aV({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),RV=cV({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),PV=cV({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),DV=cV({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),NV=cV({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),BV=cV({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),UV=sV({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),LV=new TextEncoder,MV=new TextDecoder,OV="json",qV=512;function KV(e){return LV.encode(JSON.stringify(e))}function FV(e){return JSON.parse(MV.decode(e))}const VV="raw",zV=85;function jV(e){return ZF(e)}function HV(e){return ZF(e)}var GV=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=QV;)r[n++]=255&t|WV,t/=128;for(;t&YV;)r[n++]=255&t|WV,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},WV=128,YV=-128,QV=Math.pow(2,31);var JV=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&ZV)<<o:(n&ZV)*Math.pow(2,o),o+=7}while(n>=XV);return e.bytes=s-r,i},XV=128,ZV=127;var $V=Math.pow(2,7),ez=Math.pow(2,14),tz=Math.pow(2,21),rz=Math.pow(2,28),nz=Math.pow(2,35),iz=Math.pow(2,42),oz=Math.pow(2,49),sz=Math.pow(2,56),az=Math.pow(2,63);const cz={encode:GV,decode:JV,encodingLength:function(e){return e<$V?1:e<ez?2:e<tz?3:e<rz?4:e<nz?5:e<iz?6:e<oz?7:e<sz?8:e<az?9:10}};function uz(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return cz.encode(e,t,r),t}function lz(e){return cz.encodingLength(e)}function hz(e,t){const r=t.byteLength,n=lz(e),i=n+lz(r),o=new Uint8Array(i+r);return uz(e,o,0),uz(r,o,n),o.set(t,i),new dz(e,r,t,o)}class dz{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const fz=ZF;const pz={code:0,name:"identity",encode:fz,digest:function(e){return hz(0,fz(e))}};function gz(e){let{name:t,code:r,encode:n}=e;return new bz(t,r,n)}class bz{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?hz(this.code,t):t.then((e=>hz(this.code,e)))}throw Error("Unknown type, must be binary type")}}function yz(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const mz=gz({name:"sha2-256",code:18,encode:yz("SHA-256")}),vz=gz({name:"sha2-512",code:19,encode:yz("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const wz={...Yt,...Ft,...Wt,...qt,...Kt,...zt,...jt,...Ht,...Gt,...Vt};function _z(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ez=_z("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Sz=_z("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Az={utf8:Ez,"utf-8":Ez,hex:wz.base16,latin1:Sz,ascii:Sz,binary:Sz,...wz};function kz(e){var t;return e instanceof ArrayBuffer||"ArrayBuffer"===(null===e||void 0===e||null===(t=e.constructor)||void 0===t?void 0:t.name)&&"number"===typeof(null===e||void 0===e?void 0:e.byteLength)}const xz=e=>{e.binaryType="arraybuffer";const t=async()=>{await new Promise(((t,r)=>{if(i)return void t();if(null!=n)return void r(n);const o=t=>{e.removeEventListener("open",s),e.removeEventListener("error",a),t()},s=()=>{o(t)},a=t=>{o((()=>{var n;r(null!==(n=t.error)&&void 0!==n?n:new Error("connect ECONNREFUSED ".concat(e.url)))}))};e.addEventListener("open",s),e.addEventListener("error",a)}))},r=async function*(){const r=new XF.PP((t=>{let{push:r,stop:n,fail:i}=t;const o=e=>{let t=null;"string"===typeof e.data&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Az[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e.data)),kz(e.data)&&(t=new Uint8Array(e.data)),e.data instanceof Uint8Array&&(t=e.data),null!=t&&r(t)},s=e=>{var t;i(null!==(t=e.error)&&void 0!==t?t:new Error("Socket error"))};return e.addEventListener("message",o),e.addEventListener("error",s),e.addEventListener("close",n),()=>{e.removeEventListener("message",o),e.removeEventListener("error",s),e.removeEventListener("close",n)}}),{highWaterMark:1/0});await t();for await(const e of r)yield kz(e)?new Uint8Array(e):e}();let n,i=1===e.readyState;return e.addEventListener("open",(()=>{i=!0,n=null})),e.addEventListener("close",(()=>{i=!1,n=null})),e.addEventListener("error",(t=>{var r;i||(n=null!==(r=t.error)&&void 0!==r?r:new Error("connect ECONNREFUSED ".concat(e.url)))})),Object.assign(r,{connected:t})},Iz=WebSocket,Cz={"http:":"ws:","https:":"wss:"};function Tz(e,t){var r;t=null!==(r=t)&&void 0!==r?r:{};const n=((e,t)=>{var r;if(e.startsWith("//")&&(e="".concat(null!==(r=null===t||void 0===t?void 0:t.protocol)&&void 0!==r?r:"ws:").concat(e)),e.startsWith("/")&&null!=t){var n;const r=null!==(n=t.protocol)&&void 0!==n?n:"ws:",i=t.host,o=null!=t.port&&!0!==(null===i||void 0===i?void 0:i.endsWith(":".concat(t.port)))?":".concat(t.port):"";e="".concat(r,"//").concat(i).concat(o).concat(e)}const i=new URL(e);for(const[o,s]of Object.entries(Cz))i.protocol===o&&(i.protocol=s);return i})(e,"undefined"===typeof window?void 0:window.location);return((e,t)=>{var r;t=null!==(r=t)&&void 0!==r?r:{};const n=xz(e);let i=t.remoteAddress,o=t.remotePort;if(null!=e.url)try{const t=new URL(e.url);i=t.hostname,o=parseInt(t.port,10)}catch{}if(null==i||null==o)throw new Error("Remote connection did not have address and/or port");return{sink:JF(e,t),source:n,connected:async()=>{await n.connected()},close:async()=>{e.readyState!==e.CONNECTING&&e.readyState!==e.OPEN||await new Promise((t=>{e.addEventListener("close",(()=>{t()})),e.close()}))},destroy:()=>{null!=e.terminate?e.terminate():e.close()},remoteAddress:i,remotePort:o,socket:e}})(new Iz(n.toString(),t.websocket),t)}const Rz=421,Pz=290;function Dz(e){return e.filter((e=>{if(e.protoCodes().includes(Pz))return!1;const t=e.decapsulateCode(Rz);return NI.matches(t)||UI.matches(t)}))}class Nz{constructor(e,t){co(this,"log",void 0),co(this,"init",void 0),co(this,"logger",void 0),co(this,Symbol.toStringTag,"@libp2p/websockets"),co(this,VF,!0),this.log=e.logger.forComponent("libp2p:websockets"),this.logger=e.logger,this.init=t}async dial(e,t){var r;this.log("dialing %s",e),t=null!==(r=t)&&void 0!==r?r:{};const n=function(e,t,r){const n=r.logger.forComponent("libp2p:websockets:maconn"),i={log:n,async sink(t){try{await e.sink(async function*(){for await(const e of t)e instanceof Uint8Array?yield e:yield e.subarray()}())}catch(r){"aborted"!==r.type&&n.error(r)}},source:e.source,remoteAddr:t,timeline:{open:Date.now()},async close(){var t;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o=Date.now();if(null==r.signal){const e=AbortSignal.timeout(500);r={...r,signal:e}}const s=()=>{const{host:e,port:t}=i.remoteAddr.toOptions();n("timeout closing stream to %s:%s after %dms, destroying it manually",e,t,Date.now()-o),this.abort(new ug("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};null===(t=r.signal)||void 0===t||t.addEventListener("abort",s);try{await e.close()}catch(c){n.error("error closing WebSocket gracefully",c),this.abort(c)}finally{var a;null===(a=r.signal)||void 0===a||a.removeEventListener("abort",s),i.timeline.close=Date.now()}},abort(t){const{host:r,port:o}=i.remoteAddr.toOptions();n("timeout closing stream to %s:%s due to error",r,o,t),e.destroy(),i.timeline.close=Date.now()}};return e.socket.addEventListener("close",(()=>{null==i.timeline.close&&(i.timeline.close=Date.now())}),{once:!0}),i}(await this._connect(e,t),e,{logger:this.logger});this.log("new outbound connection %s",n.remoteAddr);const i=await t.upgrader.upgradeOutbound(n);return this.log("outbound connection %s upgraded",n.remoteAddr),i}async _connect(e,t){var r;if(!0===(null===t||void 0===t||null===(r=t.signal)||void 0===r?void 0:r.aborted))throw new cg;const n=e.toOptions();this.log("dialing %s:%s",n.host,n.port);const i=hh(),o=Tz(function(e,t){var r;const n=_I(e).stringTuples(),i=n.pop();if(void 0===i)throw new Error("Unexpected end of multiaddr");const o=Yx(i[0]),s=YF[o.name];if(null==s)throw new Error("No interpreter found for ".concat(o.name));let a=s(null!==(r=i[1])&&void 0!==r?r:"",n);return!1!==(null===t||void 0===t?void 0:t.assumeHttp)&&jF.includes(i[0])&&(a=a.replace(/^.*:\/\//,""),a="443"===i[1]?"https://".concat(a):"http://".concat(a)),(a.startsWith("http://")||a.startsWith("https://"))&&(a=new URL(a).toString(),a.endsWith("/")&&(a=a.substring(0,a.length-1))),a}(e),this.init);if(o.socket.addEventListener("error",(()=>{const t=new ug("Could not connect to ".concat(e.toString()),"ERR_CONNECTION_FAILED");this.log.error("connection error:",t),i.reject(t)})),null==t.signal)return await Promise.race([o.connected(),i.promise]),this.log("connected %s",e),o;let s;const a=new Promise(((e,r)=>{var n,i;s=()=>{r(new cg),o.close().catch((e=>{this.log.error("error closing raw socket",e)}))},!0!==(null===t||void 0===t||null===(n=t.signal)||void 0===n?void 0:n.aborted)?null===t||void 0===t||null===(i=t.signal)||void 0===i||i.addEventListener("abort",s):s()}));try{await Promise.race([a,i.promise,o.connected()])}finally{var c;if(null!=s)null===t||void 0===t||null===(c=t.signal)||void 0===c||c.removeEventListener("abort",s)}return this.log("connected %s",e),o}createListener(e){return function(){throw new Error("WebSocket Servers can not be created in the browser!")}(this.logger,this.init)}filter(e){var t,r;return e=Array.isArray(e)?e:[e],null!=(null===(t=this.init)||void 0===t?void 0:t.filter)?null===(r=this.init)||void 0===r?void 0:r.filter(e):OO||VO?function(e){return e.filter((e=>{if(e.protoCodes().includes(Pz))return!1;const t=e.decapsulateCode(Rz);return UI.matches(t)}))}(e):Dz(e)}}function Bz(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Nz(t,e)}const Uz="StrictSign",Lz="StrictNoSign";var Mz;!function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"}(Mz||(Mz={}));new Uint8Array(0);function Oz(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var qz=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Kz=qz;class Fz{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Vz{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return jz(this,e)}}class zz{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return jz(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function jz(e,t){var r,n;return new zz({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Hz{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Fz(e,t,r),this.decoder=new Vz(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Gz(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Hz(t,r,n,i)}function Wz(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Kz(n,t);return Gz({prefix:r,name:t,encode:i,decode:e=>Oz(o(e))})}function Yz(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Gz({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Qz=Wz({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jz=Wz({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Xz=Wz({prefix:"9",name:"base10",alphabet:"0123456789"}),Zz=Yz({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$z=Yz({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ej=Yz({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),tj=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),rj=tj.reduce(((e,t,r)=>(e[r]=t,e)),[]),nj=tj.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const ij=Gz({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=rj[t]),"")},decode:function(e){const t=[];for(const r of e){const e=nj[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),oj=Yz({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),sj=Yz({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),aj=Yz({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cj=Yz({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uj=Yz({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lj=Yz({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hj=Yz({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dj=Yz({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),fj=Yz({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),pj=Wz({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gj=Wz({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),bj=Yz({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yj=Yz({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mj=Yz({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vj=Yz({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),wj=Yz({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),_j=Gz({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Ej=new TextEncoder,Sj=new TextDecoder,Aj="json",kj=512;function xj(e){return Ej.encode(JSON.stringify(e))}function Ij(e){return JSON.parse(Sj.decode(e))}const Cj="raw",Tj=85;function Rj(e){return Oz(e)}function Pj(e){return Oz(e)}var Dj=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Uj;)r[n++]=255&t|Nj,t/=128;for(;t&Bj;)r[n++]=255&t|Nj,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Nj=128,Bj=-128,Uj=Math.pow(2,31);var Lj=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Oj)<<o:(n&Oj)*Math.pow(2,o),o+=7}while(n>=Mj);return e.bytes=s-r,i},Mj=128,Oj=127;var qj=Math.pow(2,7),Kj=Math.pow(2,14),Fj=Math.pow(2,21),Vj=Math.pow(2,28),zj=Math.pow(2,35),jj=Math.pow(2,42),Hj=Math.pow(2,49),Gj=Math.pow(2,56),Wj=Math.pow(2,63);const Yj={encode:Dj,decode:Lj,encodingLength:function(e){return e<qj?1:e<Kj?2:e<Fj?3:e<Vj?4:e<zj?5:e<jj?6:e<Hj?7:e<Gj?8:e<Wj?9:10}};function Qj(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[Yj.decode(e,t),Yj.decode.bytes]}function Jj(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Yj.encode(e,t,r),t}function Xj(e){return Yj.encodingLength(e)}function Zj(e,t){const r=t.byteLength,n=Xj(e),i=n+Xj(r),o=new Uint8Array(i+r);return Jj(e,o,0),Jj(r,o,n),o.set(t,i),new eH(e,r,t,o)}function $j(e){const t=Oz(e),[r,n]=Qj(t),[i,o]=Qj(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new eH(r,i,s,t)}class eH{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const tH=Oz;const rH={code:0,name:"identity",encode:tH,digest:function(e){return Zj(0,tH(e))}};function nH(e){let{name:t,code:r,encode:n}=e;return new iH(t,r,n)}class iH{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Zj(this.code,t):t.then((e=>Zj(this.code,e)))}throw Error("Unknown type, must be binary type")}}function oH(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const sH=nH({name:"sha2-256",code:18,encode:oH("SHA-256")}),aH=nH({name:"sha2-512",code:19,encode:oH("SHA-512")});function cH(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==Qz.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,lH(e),null!==t&&void 0!==t?t:Qz.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,lH(e),null!==t&&void 0!==t?t:oj.encoder)}const uH=new WeakMap;function lH(e){const t=uH.get(e);if(null==t){const t=new Map;return uH.set(e,t),t}return t}class hH{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==dH)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==fH)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return hH.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Zj(e,t);return hH.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return hH.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return cH(this,e)}toJSON(){return{"/":cH(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof hH)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new hH(e,r,n,null!==i&&void 0!==i?i:pH(e,r,n.bytes))}if(!0===t[gH]){const{version:e,multihash:r,code:n}=t,i=$j(r);return hH.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==dH)throw new Error("Version 0 CID must use dag-pb (code: ".concat(dH,") block encoding"));return new hH(e,t,r,r.bytes);case 1:{const n=pH(e,t,r.bytes);return new hH(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return hH.create(0,dH,e)}static createV1(e,t){return hH.create(1,e,t)}static decode(e){const[t,r]=hH.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=hH.inspectBytes(e),r=t.size-t.multihashSize,n=Oz(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new eH(t.multihashCode,t.digestSize,i,n);return[0===t.version?hH.createV0(o):hH.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Qj(e.subarray(t));return t+=n,r};let n=r(),i=dH;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:Qz;return[Qz.prefix,r.decode("".concat(Qz.prefix).concat(e))]}case Qz.prefix:{const r=null!==t&&void 0!==t?t:Qz;return[Qz.prefix,r.decode(e)]}case oj.prefix:{const r=null!==t&&void 0!==t?t:oj;return[oj.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=hH.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return lH(i).set(r,e),i}}const dH=112,fH=18;function pH(e,t,r){const n=Xj(e),i=n+Xj(t),o=new Uint8Array(i+r.byteLength);return Jj(e,o,0),Jj(t,o,n),o.set(r,i),o}const gH=Symbol.for("@ipld/js-cid/CID"),bH={...cr,...rr,...ar,...er,...tr,...ir,...or,...$t,...sr,...nr};function yH(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const mH=Symbol.for("nodejs.util.inspect.custom"),vH=Object.values(bH).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),bH.identity.decoder),wH=114,_H=36,EH=37;class SH{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=Qz.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return hH.createV1(wH,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return yH(this.multihash.bytes,e);if("string"===typeof e)return IH(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return yH(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[mH](){return"PeerId(".concat(this.toString(),")")}}class AH extends SH{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class kH extends SH{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class xH extends SH{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function IH(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:vH,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=$j(Qz.decode("z".concat(e)));return e.startsWith("12D")?new kH({multihash:t}):e.startsWith("16U")?new xH({multihash:t}):new AH({multihash:t})}return CH(vH.decode(e))}function CH(e){try{const t=$j(e);if(t.code===rH.code){if(t.digest.length===_H)return new kH({multihash:t});if(t.digest.length===EH)return new xH({multihash:t})}if(t.code===sH.code)return new AH({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==wH)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===sH.code)return new AH({multihash:e.multihash});if(t.code===rH.code){if(t.digest.length===_H)return new kH({multihash:e.multihash});if(t.digest.length===EH)return new xH({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(hH.decode(e))}throw new Error("Supplied PeerID CID is invalid")}const TH="/floodsub/1.0.0",RH="/meshsub/1.0.0",PH="/meshsub/1.1.0",DH=5e3,NH={maxSubscriptions:1/0,maxMessages:1/0,maxIhaveMessageIDs:1/0,maxIwantMessageIDs:1/0,maxControlMessages:1/0,maxPeerInfos:1/0},BH=new Float32Array([-0]),UH=new Uint8Array(BH.buffer);function LH(e,t,r){BH[0]=e,t[r]=UH[0],t[r+1]=UH[1],t[r+2]=UH[2],t[r+3]=UH[3]}const MH=new Float64Array([-0]),OH=new Uint8Array(MH.buffer);function qH(e,t,r){MH[0]=e,t[r]=OH[0],t[r+1]=OH[1],t[r+2]=OH[2],t[r+3]=OH[3],t[r+4]=OH[4],t[r+5]=OH[5],t[r+6]=OH[6],t[r+7]=OH[7]}const KH=BigInt(Number.MAX_SAFE_INTEGER),FH=BigInt(Number.MIN_SAFE_INTEGER);class VH{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return zH;if(e<KH&&e>FH)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>jH&&(n=0n,++r>jH&&(r=0n))),new VH(Number(n),Number(r))}static fromNumber(e){if(0===e)return zH;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new VH(r,n)}static from(e){return"number"===typeof e?VH.fromNumber(e):"bigint"===typeof e?VH.fromBigInt(e):"string"===typeof e?VH.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new VH(e.low>>>0,e.high>>>0):zH}}const zH=new VH(0,0);zH.toBigInt=function(){return 0n},zH.zzEncode=zH.zzDecode=function(){return this},zH.length=function(){return 1};const jH=4294967296n;function HH(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function GH(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function WH(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class YH{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,GH(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw GH(this,4);return WH(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw GH(this,4);return 0|WH(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw GH(this,4);const e=(t=this.buf,r=this.pos,UH[0]=t[r],UH[1]=t[r+1],UH[2]=t[r+2],UH[3]=t[r+3],BH[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw GH(this,4);const e=(t=this.buf,r=this.pos,OH[0]=t[r],OH[1]=t[r+1],OH[2]=t[r+2],OH[3]=t[r+3],OH[4]=t[r+4],OH[5]=t[r+5],OH[6]=t[r+6],OH[7]=t[r+7],MH[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw GH(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw GH(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw GH(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new VH(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw GH(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw GH(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw GH(this,8);const e=WH(this.buf,this.pos+=4),t=WH(this.buf,this.pos+=4);return new VH(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function QH(e,t,r){const n=function(e){return new YH(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function JH(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function XH(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const ZH=XH("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),$H=XH("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=JH((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),eG={utf8:ZH,"utf-8":ZH,hex:bH.base16,latin1:$H,ascii:$H,binary:$H,...bH};function tG(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=eG[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}class rG{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function nG(){}class iG{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const oG=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return JH(e);i+e>t&&(n=JH(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class sG{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new rG(nG,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new rG(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new uG((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(lG,10,VH.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=VH.fromBigInt(e);return this._push(lG,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=VH.fromBigInt(e).zzEncode();return this._push(lG,t.length(),t)}sint64Number(e){const t=VH.fromNumber(e).zzEncode();return this._push(lG,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(aG,1,e?1:0)}fixed32(e){return this._push(hG,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=VH.fromBigInt(e);return this._push(hG,4,t.lo)._push(hG,4,t.hi)}fixed64Number(e){const t=VH.fromNumber(e);return this._push(hG,4,t.lo)._push(hG,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(LH,4,e)}double(e){return this._push(qH,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(aG,1,0):this.uint32(t)._push(dG,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(HH,t,e):this._push(aG,1,0)}fork(){return this.states=new iG(this),this.head=this.tail=new rG(nG,0,0),this.len=0,this}reset(){return null!=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 rG(nG,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?JH(r):oG(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function aG(e,t,r){t[r]=255&e}function cG(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class uG extends rG{constructor(e,t){super(cG,e,t),co(this,"next",void 0),this.next=void 0}}function lG(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function hG(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function dG(e,t,r){t.set(e,r)}function fG(e,t,r){t.set(e,r)}function pG(e,t,r){e.length<40?HH(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(tG(e),r)}function gG(e,t){const r=new sG;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var bG,yG,mG,vG,wG,_G,EG,SG,AG,kG,xG,IG,CG;function TG(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function RG(e,t){return TG("message",bG.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(sG.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(fG,t,e),this},sG.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(pG,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(bG||(bG={}));class PG extends Error{constructor(e,t,r){super(e,r),co(this,"code",void 0),this.code=t}}!function(e){let t,r,n,i,o,s,a,c,u;!function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.subscribe&&(t.uint32(8),t.bool(e.subscribe)),null!=e.topic&&(t.uint32(18),t.string(e.topic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.subscribe=e.bool();break;case 2:r.topic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(t=e.SubOpts||(e.SubOpts={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.from&&(t.uint32(10),t.bytes(e.from)),null!=e.data&&(t.uint32(18),t.bytes(e.data)),null!=e.seqno&&(t.uint32(26),t.bytes(e.seqno)),null!=e.topic&&""!==e.topic&&(t.uint32(34),t.string(e.topic)),null!=e.signature&&(t.uint32(42),t.bytes(e.signature)),null!=e.key&&(t.uint32(50),t.bytes(e.key)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={topic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.from=e.bytes();break;case 2:r.data=e.bytes();break;case 3:r.seqno=e.bytes();break;case 4:r.topic=e.string();break;case 5:r.signature=e.bytes();break;case 6:r.key=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(r=e.Message||(e.Message={})),function(t){let r;t.codec=()=>(null==r&&(r=RG((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.ihave)for(const i of t.ihave)r.uint32(10),e.ControlIHave.codec().encode(i,r);if(null!=t.iwant)for(const i of t.iwant)r.uint32(18),e.ControlIWant.codec().encode(i,r);if(null!=t.graft)for(const i of t.graft)r.uint32(26),e.ControlGraft.codec().encode(i,r);if(null!=t.prune)for(const i of t.prune)r.uint32(34),e.ControlPrune.codec().encode(i,r);!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={ihave:[],iwant:[],graft:[],prune:[]},o=null==r?t.len:t.pos+r;for(;t.pos<o;){const r=t.uint32();switch(r>>>3){case 1:var s;if(null!=(null===(s=n.limits)||void 0===s?void 0:s.ihave)&&i.ihave.length===n.limits.ihave)throw new PG('decode error - map field "ihave" had too many elements',"ERR_MAX_LENGTH");i.ihave.push(e.ControlIHave.codec().decode(t,t.uint32()));break;case 2:var a;if(null!=(null===(a=n.limits)||void 0===a?void 0:a.iwant)&&i.iwant.length===n.limits.iwant)throw new PG('decode error - map field "iwant" had too many elements',"ERR_MAX_LENGTH");i.iwant.push(e.ControlIWant.codec().decode(t,t.uint32()));break;case 3:var c;if(null!=(null===(c=n.limits)||void 0===c?void 0:c.graft)&&i.graft.length===n.limits.graft)throw new PG('decode error - map field "graft" had too many elements',"ERR_MAX_LENGTH");i.graft.push(e.ControlGraft.codec().decode(t,t.uint32()));break;case 4:var u;if(null!=(null===(u=n.limits)||void 0===u?void 0:u.prune)&&i.prune.length===n.limits.prune)throw new PG('decode error - map field "prune" had too many elements',"ERR_MAX_LENGTH");i.prune.push(e.ControlPrune.codec().decode(t,t.uint32()));break;default:t.skipType(7&r)}}return i}))),r),t.encode=e=>gG(e,t.codec()),t.decode=(e,r)=>QH(e,t.codec(),r)}(n=e.ControlMessage||(e.ControlMessage={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.topicID&&(t.uint32(10),t.string(e.topicID)),null!=e.messageIDs)for(const n of e.messageIDs)t.uint32(18),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n={messageIDs:[]},i=null==t?e.len:e.pos+t;for(;e.pos<i;){const t=e.uint32();switch(t>>>3){case 1:n.topicID=e.string();break;case 2:var o;if(null!=(null===(o=r.limits)||void 0===o?void 0:o.messageIDs)&&n.messageIDs.length===r.limits.messageIDs)throw new PG('decode error - map field "messageIDs" had too many elements',"ERR_MAX_LENGTH");n.messageIDs.push(e.bytes());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(i=e.ControlIHave||(e.ControlIHave={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.messageIDs)for(const n of e.messageIDs)t.uint32(10),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n={messageIDs:[]},i=null==t?e.len:e.pos+t;for(;e.pos<i;){const t=e.uint32();if(t>>>3===1){var o;if(null!=(null===(o=r.limits)||void 0===o?void 0:o.messageIDs)&&n.messageIDs.length===r.limits.messageIDs)throw new PG('decode error - map field "messageIDs" had too many elements',"ERR_MAX_LENGTH");n.messageIDs.push(e.bytes())}else e.skipType(7&t)}return n}))),t),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(o=e.ControlIWant||(e.ControlIWant={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.topicID&&(t.uint32(10),t.string(e.topicID)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.topicID=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(s=e.ControlGraft||(e.ControlGraft={})),function(t){let r;t.codec=()=>(null==r&&(r=RG((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.topicID&&(r.uint32(10),r.string(t.topicID)),null!=t.peers)for(const i of t.peers)r.uint32(18),e.PeerInfo.codec().encode(i,r);null!=t.backoff&&(r.uint32(24),r.uint64Number(t.backoff)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={peers:[]},o=null==r?t.len:t.pos+r;for(;t.pos<o;){const r=t.uint32();switch(r>>>3){case 1:i.topicID=t.string();break;case 2:var s;if(null!=(null===(s=n.limits)||void 0===s?void 0:s.peers)&&i.peers.length===n.limits.peers)throw new PG('decode error - map field "peers" had too many elements',"ERR_MAX_LENGTH");i.peers.push(e.PeerInfo.codec().decode(t,t.uint32()));break;case 3:i.backoff=t.uint64Number();break;default:t.skipType(7&r)}}return i}))),r),t.encode=e=>gG(e,t.codec()),t.decode=(e,r)=>QH(e,t.codec(),r)}(a=e.ControlPrune||(e.ControlPrune={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.peerID&&(t.uint32(10),t.bytes(e.peerID)),null!=e.signedPeerRecord&&(t.uint32(18),t.bytes(e.signedPeerRecord)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.peerID=e.bytes();break;case 2:r.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(c=e.PeerInfo||(e.PeerInfo={})),e.codec=()=>(null==u&&(u=RG((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.subscriptions)for(const i of t.subscriptions)r.uint32(10),e.SubOpts.codec().encode(i,r);if(null!=t.messages)for(const i of t.messages)r.uint32(18),e.Message.codec().encode(i,r);null!=t.control&&(r.uint32(26),e.ControlMessage.codec().encode(t.control,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={subscriptions:[],messages:[]},o=null==r?t.len:t.pos+r;for(;t.pos<o;){const r=t.uint32();switch(r>>>3){case 1:var s;if(null!=(null===(s=n.limits)||void 0===s?void 0:s.subscriptions)&&i.subscriptions.length===n.limits.subscriptions)throw new PG('decode error - map field "subscriptions" had too many elements',"ERR_MAX_LENGTH");i.subscriptions.push(e.SubOpts.codec().decode(t,t.uint32()));break;case 2:var a;if(null!=(null===(a=n.limits)||void 0===a?void 0:a.messages)&&i.messages.length===n.limits.messages)throw new PG('decode error - map field "messages" had too many elements',"ERR_MAX_LENGTH");i.messages.push(e.Message.codec().decode(t,t.uint32()));break;case 3:i.control=e.ControlMessage.codec().decode(t,t.uint32());break;default:t.skipType(7&r)}}return i}))),u),e.encode=t=>gG(t,e.codec()),e.decode=(t,r)=>QH(t,e.codec(),r)}(yG||(yG={}));class DG{constructor(e,t,r){co(this,"gossip",void 0),co(this,"msgs",new Map),co(this,"msgIdToStrFn",void 0),co(this,"history",[]),co(this,"notValidatedCount",0),this.gossip=e,this.msgIdToStrFn=r;for(let n=0;n<t;n++)this.history[n]=[]}get size(){return this.msgs.size}put(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{msgIdStr:n}=e;return!this.msgs.has(n)&&(this.msgs.set(n,{message:t,validated:r,originatingPeers:new Set,iwantCounts:new Map}),this.history[0].push({...e,topic:t.topic}),r||this.notValidatedCount++,!0)}observeDuplicate(e,t){const r=this.msgs.get(e);null==r||r.validated||r.originatingPeers.add(t)}get(e){var t;return null===(t=this.msgs.get(this.msgIdToStrFn(e)))||void 0===t?void 0:t.message}getWithIWantCount(e,t){var r;const n=this.msgs.get(e);if(null==n)return null;const i=(null!==(r=n.iwantCounts.get(t))&&void 0!==r?r:0)+1;return n.iwantCounts.set(t,i),{msg:n.message,count:i}}getGossipIDs(e){const t=new Map;for(let r=0;r<this.gossip;r++)this.history[r].forEach((r=>{var n;const i=this.msgs.get(r.msgIdStr);if(null!==(n=null===i||void 0===i?void 0:i.validated)&&void 0!==n&&n&&e.has(r.topic)){let e=t.get(r.topic);null==e&&(e=[],t.set(r.topic,e)),e.push(r.msgId)}}));return t}validate(e){const t=this.msgs.get(e);if(null==t)return null;t.validated||this.notValidatedCount--;const{message:r,originatingPeers:n}=t;return t.validated=!0,t.originatingPeers=new Set,{message:r,originatingPeers:n}}shift(){this.history[this.history.length-1].forEach((e=>{const t=this.msgs.get(e.msgIdStr);null!=t&&(this.msgs.delete(e.msgIdStr),t.validated||this.notValidatedCount--)})),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return null==t?null:(this.msgs.delete(e),t)}}function NG(e){switch(e){case Mz.Ignore:return wG.Ignore;case Mz.Reject:return wG.Reject;default:throw new Error("Unreachable")}}!function(e){e.StrictSign="StrictSign",e.StrictNoSign="StrictNoSign"}(mG||(mG={})),function(e){e[e.Signing=0]="Signing",e[e.Anonymous=1]="Anonymous"}(vG||(vG={})),function(e){e.Error="error",e.Ignore="ignore",e.Reject="reject",e.Blacklisted="blacklisted"}(wG||(wG={})),function(e){e.InvalidSignature="invalid_signature",e.InvalidSeqno="invalid_seqno",e.InvalidPeerId="invalid_peerid",e.SignaturePresent="signature_present",e.SeqnoPresent="seqno_present",e.FromPresent="from_present",e.TransformFailed="transform_failed"}(_G||(_G={})),function(e){e.duplicate="duplicate",e.invalid="invalid",e.valid="valid"}(EG||(EG={})),function(e){e.forward="forward",e.publish="publish"}(SG||(SG={})),function(e){e.Fanout="fanout",e.Random="random",e.Subscribed="subscribed",e.Outbound="outbound",e.NotEnough="not_enough",e.Opportunistic="opportunistic"}(AG||(AG={})),function(e){e.Dc="disconnected",e.BadScore="bad_score",e.Prune="prune",e.Excess="excess"}(kG||(kG={})),function(e){e.GraftBackoff="graft_backoff",e.BrokenPromise="broken_promise",e.MessageDeficit="message_deficit",e.IPColocation="IP_colocation"}(xG||(xG={})),function(e){e.LowScore="low_score",e.MaxIhave="max_ihave",e.MaxIasked="max_iasked"}(IG||(IG={})),function(e){e.graylist="graylist",e.publish="publish",e.gossip="gossip",e.mesh="mesh"}(CG||(CG={}));const BG="ERR_INVALID_PEER_SCORE_PARAMS",UG={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},LG={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3};function MG(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{...UG,...e,topics:null!=e.topics?Object.entries(e.topics).reduce(((e,t)=>{let[r,n]=t;return e[r]=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{...LG,...e}}(n),e}),{}):{}}}function OG(e){if(e.topicWeight<0)throw new ug("invalid topic weight; must be >= 0",BG);if(0===e.timeInMeshQuantum)throw new ug("invalid TimeInMeshQuantum; must be non zero",BG);if(e.timeInMeshWeight<0)throw new ug("invalid TimeInMeshWeight; must be positive (or 0 to disable)",BG);if(0!==e.timeInMeshWeight&&e.timeInMeshQuantum<=0)throw new ug("invalid TimeInMeshQuantum; must be positive",BG);if(0!==e.timeInMeshWeight&&e.timeInMeshCap<=0)throw new ug("invalid TimeInMeshCap; must be positive",BG);if(e.firstMessageDeliveriesWeight<0)throw new ug("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)",BG);if(0!==e.firstMessageDeliveriesWeight&&(e.firstMessageDeliveriesDecay<=0||e.firstMessageDeliveriesDecay>=1))throw new ug("invalid FirstMessageDeliveriesDecay; must be between 0 and 1",BG);if(0!==e.firstMessageDeliveriesWeight&&e.firstMessageDeliveriesCap<=0)throw new ug("invalid FirstMessageDeliveriesCap; must be positive",BG);if(e.meshMessageDeliveriesWeight>0)throw new ug("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)",BG);if(0!==e.meshMessageDeliveriesWeight&&(e.meshMessageDeliveriesDecay<=0||e.meshMessageDeliveriesDecay>=1))throw new ug("invalid MeshMessageDeliveriesDecay; must be between 0 and 1",BG);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesCap<=0)throw new ug("invalid MeshMessageDeliveriesCap; must be positive",BG);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesThreshold<=0)throw new ug("invalid MeshMessageDeliveriesThreshold; must be positive",BG);if(e.meshMessageDeliveriesWindow<0)throw new ug("invalid MeshMessageDeliveriesWindow; must be non-negative",BG);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesActivation<1e3)throw new ug("invalid MeshMessageDeliveriesActivation; must be at least 1s",BG);if(e.meshFailurePenaltyWeight>0)throw new ug("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)",BG);if(0!==e.meshFailurePenaltyWeight&&(e.meshFailurePenaltyDecay<=0||e.meshFailurePenaltyDecay>=1))throw new ug("invalid MeshFailurePenaltyDecay; must be between 0 and 1",BG);if(e.invalidMessageDeliveriesWeight>0)throw new ug("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)",BG);if(e.invalidMessageDeliveriesDecay<=0||e.invalidMessageDeliveriesDecay>=1)throw new ug("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1",BG)}const qG={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function KG(){return{...qG,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}function FG(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0;const n=new Set;if(t<=0)return n;for(const i of e){if(n.size>=t)break;r(i)&&(n.add(i),e.delete(i))}return n}class VG extends Map{constructor(e){super(),co(this,"getDefault",void 0),this.getDefault=e}getOrDefault(e){let t=super.get(e);return void 0===t&&(t=this.getDefault(),this.set(e,t)),t}}function zG(e,t,r,n){let i=0;Object.entries(t.topics).forEach((e=>{let[t,n]=e;const o=r.topics[t];if(void 0===o)return;let s=0;if(n.inMesh){let e=n.meshTime/o.timeInMeshQuantum;e>o.timeInMeshCap&&(e=o.timeInMeshCap),s+=e*o.timeInMeshWeight}let a=n.firstMessageDeliveries;if(a>o.firstMessageDeliveriesCap&&(a=o.firstMessageDeliveriesCap),s+=a*o.firstMessageDeliveriesWeight,n.meshMessageDeliveriesActive&&n.meshMessageDeliveries<o.meshMessageDeliveriesThreshold){const e=o.meshMessageDeliveriesThreshold-n.meshMessageDeliveries;s+=e*e*o.meshMessageDeliveriesWeight}s+=n.meshFailurePenalty*o.meshFailurePenaltyWeight;s+=n.invalidMessageDeliveries*n.invalidMessageDeliveries*o.invalidMessageDeliveriesWeight,i+=s*o.topicWeight})),r.topicScoreCap>0&&i>r.topicScoreCap&&(i=r.topicScoreCap);const o=r.appSpecificScore(e);if(i+=o*r.appSpecificWeight,t.knownIPs.forEach((e=>{if(r.IPColocationFactorWhitelist.has(e))return;const t=n.get(e),o=null!=t?t.size:0;if(o>r.IPColocationFactorThreshold){const e=o-r.IPColocationFactorThreshold;i+=e*e*r.IPColocationFactorWeight}})),t.behaviourPenalty>r.behaviourPenaltyThreshold){const e=t.behaviourPenalty-r.behaviourPenaltyThreshold;i+=e*e*r.behaviourPenaltyWeight}return i}var jG,HG=__webpack_require__(80);!function(e){e[e.unknown=0]="unknown",e[e.valid=1]="valid",e[e.invalid=2]="invalid",e[e.ignored=3]="ignored"}(jG||(jG={}));class GG{constructor(){co(this,"records",void 0),co(this,"queue",void 0),this.records=new Map,this.queue=new HG}getRecord(e){return this.records.get(e)}ensureRecord(e){let t=this.records.get(e);if(null!=t)return t;t={status:jG.unknown,firstSeenTsMs:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;null!=t&&t.expire<e;)this.records.delete(t.msgId),this.queue.shift(),t=this.queue.peekFront()}clear(){this.records.clear(),this.queue.clear()}}class WG{constructor(e,t,r,n){var i;co(this,"params",void 0),co(this,"metrics",void 0),co(this,"peerStats",new Map),co(this,"peerIPs",new VG((()=>new Set))),co(this,"scoreCache",new Map),co(this,"deliveryRecords",new GG),co(this,"_backgroundInterval",void 0),co(this,"scoreCacheValidityMs",void 0),co(this,"computeScore",void 0),co(this,"log",void 0),this.params=e,this.metrics=t,function(e){for(const[r,n]of Object.entries(e.topics))try{OG(n)}catch(t){throw new ug("invalid score parameters for topic ".concat(r,": ").concat(t.message),BG)}if(e.topicScoreCap<0)throw new ug("invalid topic score cap; must be positive (or 0 for no cap)",BG);if(null===e.appSpecificScore||void 0===e.appSpecificScore)throw new ug("missing application specific score function",BG);if(e.IPColocationFactorWeight>0)throw new ug("invalid IPColocationFactorWeight; must be negative (or 0 to disable)",BG);if(0!==e.IPColocationFactorWeight&&e.IPColocationFactorThreshold<1)throw new ug("invalid IPColocationFactorThreshold; must be at least 1",BG);if(e.behaviourPenaltyWeight>0)throw new ug("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)",BG);if(0!==e.behaviourPenaltyWeight&&(e.behaviourPenaltyDecay<=0||e.behaviourPenaltyDecay>=1))throw new ug("invalid BehaviourPenaltyDecay; must be between 0 and 1",BG);if(e.decayInterval<1e3)throw new ug("invalid DecayInterval; must be at least 1s",BG);if(e.decayToZero<=0||e.decayToZero>=1)throw new ug("invalid DecayToZero; must be between 0 and 1",BG)}(e),this.scoreCacheValidityMs=n.scoreCacheValidityMs,this.computeScore=null!==(i=n.computeScore)&&void 0!==i?i:zG,this.log=r.forComponent("libp2p:gossipsub:score")}get size(){return this.peerStats.size}start(){null==this._backgroundInterval?(this._backgroundInterval=setInterval((()=>{this.background()}),this.params.decayInterval),this.log("started")):this.log("Peer score already running")}stop(){null!=this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),this.log("stopped")):this.log("Peer score already stopped")}background(){this.refreshScores(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map((e=>{let[t,r]=e;return[t,r]})))}messageFirstSeenTimestampMs(e){const t=this.deliveryRecords.getRecord(e);return null!=t?t.firstSeenTsMs:null}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach(((r,n)=>{r.connected?(Object.entries(r.topics).forEach((r=>{let[n,i]=r;const o=this.params.topics[n];void 0!==o&&(i.firstMessageDeliveries*=o.firstMessageDeliveriesDecay,i.firstMessageDeliveries<t&&(i.firstMessageDeliveries=0),i.meshMessageDeliveries*=o.meshMessageDeliveriesDecay,i.meshMessageDeliveries<t&&(i.meshMessageDeliveries=0),i.meshFailurePenalty*=o.meshFailurePenaltyDecay,i.meshFailurePenalty<t&&(i.meshFailurePenalty=0),i.invalidMessageDeliveries*=o.invalidMessageDeliveriesDecay,i.invalidMessageDeliveries<t&&(i.invalidMessageDeliveries=0),i.inMesh&&(i.meshTime=e-i.graftTime,i.meshTime>o.meshMessageDeliveriesActivation&&(i.meshMessageDeliveriesActive=!0)))})),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenalty<t&&(r.behaviourPenalty=0)):e>r.expire&&(this.removeIPsForPeer(n,r.knownIPs),this.peerStats.delete(n),this.scoreCache.delete(n))}))}score(e){var t,r;null===(t=this.metrics)||void 0===t||t.scoreFnCalls.inc();const n=this.peerStats.get(e);if(null==n)return 0;const i=Date.now(),o=this.scoreCache.get(e);if(null!=o&&o.cacheUntil>i)return o.score;null===(r=this.metrics)||void 0===r||r.scoreFnRuns.inc();const s=this.computeScore(e,n,this.params,this.peerIPs),a=i+this.scoreCacheValidityMs;var c;null!=o?(null===(c=this.metrics)||void 0===c||c.scoreCachedDelta.observe(Math.abs(s-o.score)),o.score=s,o.cacheUntil=a):this.scoreCache.set(e,{score:s,cacheUntil:a});return s}addPenalty(e,t,r){const n=this.peerStats.get(e);var i;null!=n&&(n.behaviourPenalty+=t,null===(i=this.metrics)||void 0===i||i.onScorePenalty(r))}addPeer(e){const t={connected:!0,expire:0,topics:{},knownIPs:new Set,behaviourPenalty:0};this.peerStats.set(e,t)}addIP(e,t){const r=this.peerStats.get(e);null!=r&&r.knownIPs.add(t),this.peerIPs.getOrDefault(t).add(e)}removeIP(e,t){const r=this.peerStats.get(e);null!=r&&r.knownIPs.delete(t);const n=this.peerIPs.get(t);null!=n&&(n.delete(e),0===n.size&&this.peerIPs.delete(t))}removePeer(e){const t=this.peerStats.get(e);if(null!=t){if(this.score(e)>0)return this.removeIPsForPeer(e,t.knownIPs),void this.peerStats.delete(e);Object.entries(t.topics).forEach((e=>{let[t,r]=e;r.firstMessageDeliveries=0;const n=this.params.topics[t].meshMessageDeliveriesThreshold;if(r.inMesh&&r.meshMessageDeliveriesActive&&r.meshMessageDeliveries<n){const e=n-r.meshMessageDeliveries;r.meshFailurePenalty+=e*e}r.inMesh=!1,r.meshMessageDeliveriesActive=!1})),t.connected=!1,t.expire=Date.now()+this.params.retainScore}}graft(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);null!=e&&(e.inMesh=!0,e.graftTime=Date.now(),e.meshTime=0,e.meshMessageDeliveriesActive=!1)}}prune(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);if(null!=e){const r=this.params.topics[t].meshMessageDeliveriesThreshold;if(e.meshMessageDeliveriesActive&&e.meshMessageDeliveries<r){const t=r-e.meshMessageDeliveries;e.meshFailurePenalty+=t*t}e.meshMessageDeliveriesActive=!1,e.inMesh=!1}}}validateMessage(e){this.deliveryRecords.ensureRecord(e)}deliverMessage(e,t,r){this.markFirstMessageDelivery(e,r);const n=this.deliveryRecords.ensureRecord(t),i=Date.now();n.status===jG.unknown?(n.status=jG.valid,n.validated=i,n.peers.forEach((t=>{t!==e.toString()&&this.markDuplicateMessageDelivery(t,r)}))):this.log("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,i-n.firstSeenTsMs,jG[n.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,n){switch(n){case wG.Error:return void this.markInvalidMessageDelivery(e,r);case wG.Blacklisted:return}const i=this.deliveryRecords.ensureRecord(t);if(i.status===jG.unknown){if(n===wG.Ignore)return i.status=jG.ignored,void i.peers.clear();i.status=jG.invalid,this.markInvalidMessageDelivery(e,r),i.peers.forEach((e=>{this.markInvalidMessageDelivery(e,r)})),i.peers.clear()}else this.log("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-i.firstSeenTsMs,jG[i.status])}duplicateMessage(e,t,r){const n=this.deliveryRecords.ensureRecord(t);if(!n.peers.has(e))switch(n.status){case jG.unknown:n.peers.add(e);break;case jG.valid:n.peers.add(e),this.markDuplicateMessageDelivery(e,r,n.validated);break;case jG.invalid:this.markInvalidMessageDelivery(e,r);case jG.ignored:}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);null!=e&&(e.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);if(null!=e){let r=this.params.topics[t].firstMessageDeliveriesCap;e.firstMessageDeliveries=Math.min(r,e.firstMessageDeliveries+1),e.inMesh&&(r=this.params.topics[t].meshMessageDeliveriesCap,e.meshMessageDeliveries=Math.min(r,e.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const n=this.peerStats.get(e);if(null!=n){const e=void 0!==r?Date.now():0,o=this.getPtopicStats(n,t);if(null!=o&&o.inMesh){const n=this.params.topics[t];if(void 0!==r){var i;const o=e-r,s=o>n.meshMessageDeliveriesWindow;if(null===(i=this.metrics)||void 0===i||i.onDuplicateMsgDelivery(t,o,s),s)return}const s=n.meshMessageDeliveriesCap;o.meshMessageDeliveries=Math.min(s,o.meshMessageDeliveries+1)}}}removeIPsForPeer(e,t){for(const r of t){const t=this.peerIPs.get(r);null!=t&&(t.delete(e),0===t.size&&this.peerIPs.delete(r))}}getPtopicStats(e,t){let r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}function YG(e,t,r,n,i){let o=0;const s=new Map;if(Object.entries(t.topics).forEach((e=>{var t;let[n,a]=e;const c=null!==(t=i.get(n))&&void 0!==t?t:"unknown",u=r.topics[n];if(void 0===u)return;let l=s.get(c);null==l&&(l={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},s.set(c,l));let h=0,d=0,f=0,p=0,g=0;if(a.inMesh){h+=Math.max(a.meshTime/u.timeInMeshQuantum,u.timeInMeshCap)*u.timeInMeshWeight}let b=a.firstMessageDeliveries;if(b>u.firstMessageDeliveriesCap&&(b=u.firstMessageDeliveriesCap),d+=b*u.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries<u.meshMessageDeliveriesThreshold){const e=u.meshMessageDeliveriesThreshold-a.meshMessageDeliveries;f+=e*e*u.meshMessageDeliveriesWeight}p+=a.meshFailurePenalty*u.meshFailurePenaltyWeight;g+=a.invalidMessageDeliveries*a.invalidMessageDeliveries*u.invalidMessageDeliveriesWeight,o+=(h+d+f+p+g)*u.topicWeight,l.p1w+=h,l.p2w+=d,l.p3w+=f,l.p3bw+=p,l.p4w+=g})),r.topicScoreCap>0&&o>r.topicScoreCap){o=r.topicScoreCap;const e=r.topicScoreCap/o;for(const t of s.values())t.p1w*=e,t.p2w*=e,t.p3w*=e,t.p3bw*=e,t.p4w*=e}let a=0,c=0,u=0;a+=r.appSpecificScore(e)*r.appSpecificWeight,t.knownIPs.forEach((e=>{if(r.IPColocationFactorWhitelist.has(e))return;const t=n.get(e),i=null!=t?t.size:0;if(i>r.IPColocationFactorThreshold){const e=i-r.IPColocationFactorThreshold;c+=e*e*r.IPColocationFactorWeight}}));return u+=t.behaviourPenalty*t.behaviourPenalty*r.behaviourPenaltyWeight,o+=a+c+u,{byTopic:s,p5w:a,p6w:c,p7w:u,score:o}}class QG{constructor(e,t,r){var n;co(this,"rawStream",void 0),co(this,"pushable",void 0),co(this,"closeController",void 0),co(this,"maxBufferSize",void 0),this.rawStream=e,this.pushable=gh(),this.closeController=new AbortController,this.maxBufferSize=null!==(n=r.maxBufferSize)&&void 0!==n?n:1/0,this.closeController.signal.addEventListener("abort",(()=>{e.close().catch((t=>{e.abort(t)}))})),mh(this.pushable,this.rawStream).catch(t)}get protocol(){return this.rawStream.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error("OutboundStream buffer full, size > ".concat(this.maxBufferSize));this.pushable.push(sh.single(e))}pushPrefixed(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error("OutboundStream buffer full, size > ".concat(this.maxBufferSize));this.pushable.push(e)}async close(){this.closeController.abort(),await this.pushable.return()}}class JG{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"source",void 0),co(this,"rawStream",void 0),co(this,"closeController",void 0),this.rawStream=e,this.closeController=new AbortController,this.closeController.signal.addEventListener("abort",(()=>{e.close().catch((t=>{e.abort(t)}))})),this.source=mh(this.rawStream,(e=>lh(e,t)))}async close(){this.closeController.abort()}}class XG{constructor(e,t,r){co(this,"gossipsubIWantFollowupMs",void 0),co(this,"msgIdToStrFn",void 0),co(this,"metrics",void 0),co(this,"promises",new Map),co(this,"requestMsByMsg",new Map),co(this,"requestMsByMsgExpire",void 0),this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=t[Math.floor(Math.random()*t.length)],n=this.msgIdToStrFn(r);let i=this.promises.get(n);null==i&&(i=new Map,this.promises.set(n,i));const o=Date.now();i.has(e)||(i.set(e,o+this.gossipsubIWantFollowupMs),null!=this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(n)||this.requestMsByMsg.set(n,o)))}getBrokenPromises(){var e;const t=Date.now(),r=new Map;let n=0;return this.promises.forEach(((e,i)=>{e.forEach(((i,o)=>{var s;i<t&&(r.set(o,(null!==(s=r.get(o))&&void 0!==s?s:0)+1),e.delete(o),n++)})),0===e.size&&this.promises.delete(i)})),null===(e=this.metrics)||void 0===e||e.iwantPromiseBroken.inc(n),r}deliverMessage(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.trackMessage(e);const r=this.promises.get(e);null!=r&&(this.promises.delete(e),null!=this.metrics&&(this.metrics.iwantPromiseResolved.inc(1),t&&this.metrics.iwantPromiseResolvedFromDuplicate.inc(1),this.metrics.iwantPromiseResolvedPeers.inc(r.size)))}rejectMessage(e,t){this.trackMessage(e),t!==wG.Error&&this.promises.delete(e)}clear(){this.promises.clear()}prune(){var e;const t=Date.now()-this.requestMsByMsgExpire;let r=0;for(const[n,i]of this.requestMsByMsg.entries()){if(!(i<t))break;this.requestMsByMsg.delete(n),r++}null===(e=this.metrics)||void 0===e||e.iwantMessagePruned.inc(r)}trackMessage(e){if(null!=this.metrics){const t=this.requestMsByMsg.get(e);void 0!==t&&(this.metrics.iwantPromiseDeliveryTime.observe((Date.now()-t)/1e3),this.requestMsByMsg.delete(e))}}}function ZG(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}function $G(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const eW=32,tW=64,rW=32;function nW(e,t){const r=new Uint8Array(tW);for(let n=0;n<rW;n++)r[n]=e[n],r[rW+n]=t[n];return r}function iW(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=JH(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}const oW={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},sW={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function aW(e,t){const r=function(e){var t,r,n,i,o,s;const a=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM";let c=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16;const u=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",h=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,d=null!==(s=null===e||void 0===e?void 0:e.iterations)&&void 0!==s?s:32767,f=oW.get();return c*=8,{encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(u)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=tG(t)),0===t.length){o=await f.subtle.importKey("jwk",sW,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}catch{o=await f.subtle.importKey("jwk",sW,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}const s=await f.subtle.encrypt(i,o,e);return iW([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+u),i=e.subarray(h+u),o={name:a,iv:n};let s;if("string"===typeof t&&(t=tG(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}catch{s=await f.subtle.importKey("jwk",sW,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}const p=await f.subtle.decrypt(o,s,i);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return bj.encode(n)}var cW,uW,lW,hW;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(cW||(cW={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(uW||(uW={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return TG("enum",bG.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(uW)}(cW||(cW={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),cW.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=cW.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gG(t,e.codec()),e.decode=t=>QH(t,e.codec())}(lW||(lW={})),function(e){let t;e.codec=()=>(null==t&&(t=RG((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),cW.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=cW.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gG(t,e.codec()),e.decode=t=>QH(t,e.codec())}(hW||(hW={}));class dW{constructor(e){co(this,"_key",void 0),this._key=mW(e,eW)}verify(e,t){return function(e,t,r){return Wp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return lW.encode({Type:cW.Ed25519,Data:this.marshal()}).subarray()}equals(e){return yH(this.bytes,e.bytes)}hash(){const e=sH.digest(this.bytes);return $G(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class fW{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=mW(e,tW),this._publicKey=mW(t,eW)}sign(e){return function(e,t){const r=e.subarray(0,rW);return Wp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new dW(this._publicKey)}marshal(){return this._key}get bytes(){return hW.encode({Type:cW.Ed25519,Data:this.marshal()}).subarray()}equals(e){return yH(this.bytes,e.bytes)}async hash(){const e=sH.digest(this.bytes);let t;return $G(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=rH.digest(this.public.bytes);return Qz.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return aW(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function pW(e){if(e.length>tW){const t=(e=mW(e,tW+eW)).subarray(0,tW),r=e.subarray(tW,e.length);return new fW(t,r)}const t=(e=mW(e,tW)).subarray(0,tW),r=e.subarray(eW);return new fW(t,r)}function gW(e){return e=mW(e,eW),new dW(e)}async function bW(){const{privateKey:e,publicKey:t}=function(){const e=Wp.utils.randomPrivateKey(),t=Wp.getPublicKey(e);return{privateKey:nW(e,t),publicKey:t}}();return new fW(e,t)}async function yW(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==rW)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Wp.getPublicKey(t);return{privateKey:nW(t,r),publicKey:r}}(e);return new fW(t,r)}function mW(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ug("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}function vW(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=eG[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}async function wW(e){const t=[await oW.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await EW(e)],r=await _W({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function _W(e){if(null==e.privateKey||null==e.publicKey)throw new ug("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([oW.get().subtle.exportKey("jwk",e.privateKey),oW.get().subtle.exportKey("jwk",e.publicKey)])}async function EW(e){return oW.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function SW(e){if("RSA"!==e.kty)throw new ug("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ug("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*tG(e.n,"base64url").length}function AW(e){let t=e.toString(16);t.length%2>0&&(t="0".concat(t));const r=t.length/2,n=new Uint8Array(r);let i=0,o=0;for(;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n}function kW(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r="0".concat(r)),t.push(r)})),BigInt("0x"+t.join(""))}const xW=32,IW=1e4;const CW=8192;class TW{constructor(e){co(this,"_key",void 0),this._key=e}verify(e,t){return async function(e,t,r){const n=await oW.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return oW.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new zU({valueHex:new rL({value:[YU.fromBigInt(kW(tG(e.n,"base64url"))),YU.fromBigInt(kW(tG(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return lW.encode({Type:cW.RSA,Data:this.marshal()}).subarray()}equals(e){return yH(this.bytes,e.bytes)}hash(){const e=sH.digest(this.bytes);return $G(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class RW{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return ZG(16)}sign(e){return async function(e,t){const r=await oW.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await oW.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ug("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new TW(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new YU({value:0}),YU.fromBigInt(kW(tG(e.n,"base64url"))),YU.fromBigInt(kW(tG(e.e,"base64url"))),YU.fromBigInt(kW(tG(e.d,"base64url"))),YU.fromBigInt(kW(tG(e.p,"base64url"))),YU.fromBigInt(kW(tG(e.q,"base64url"))),YU.fromBigInt(kW(tG(e.dp,"base64url"))),YU.fromBigInt(kW(tG(e.dq,"base64url"))),YU.fromBigInt(kW(tG(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return hW.encode({Type:cW.RSA,Data:this.marshal()}).subarray()}equals(e){return yH(this.bytes,e.bytes)}hash(){const e=sH.digest(this.bytes);return $G(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return vW(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=oW.get(),n=new rL({value:[new YU({value:0}),new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new FU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),o=ZG(16),s=await EB(Nf,t,o,{c:IW,dkLen:xW}),a=ZG(16),c=await r.subtle.importKey("raw",s,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new rL({value:[new FU({valueHex:o}),new YU({value:IW}),new YU({value:xW}),new rL({value:[new ZU({value:"1.2.840.113549.2.11"}),new MU]})]}),h=new rL({value:[new ZU({value:"1.2.840.113549.1.5.13"}),new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.5.12"}),l]}),new rL({value:[new ZU({value:"2.16.840.1.101.3.4.1.42"}),new FU({valueHex:a})]})]})]}),d=new rL({value:[h,new FU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...vW(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return aW(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function PW(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value;return{n:vW(AW(r[1].toBigInt()),"base64url"),e:vW(AW(r[2].toBigInt()),"base64url"),d:vW(AW(r[3].toBigInt()),"base64url"),p:vW(AW(r[4].toBigInt()),"base64url"),q:vW(AW(r[5].toBigInt()),"base64url"),dp:vW(AW(r[6].toBigInt()),"base64url"),dq:vW(AW(r[7].toBigInt()),"base64url"),qi:vW(AW(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(SW(t)>CW)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await wW(t);return new RW(r.privateKey,r.publicKey)}function DW(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:vW(AW(r[0].toBigInt()),"base64url"),e:vW(AW(r[1].toBigInt()),"base64url")}}(e);if(SW(t)>CW)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new TW(t)}async function NW(e){if(SW(e)>CW)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await wW(e);return new RW(t.privateKey,t.publicKey)}async function BW(e){if(e>CW)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await oW.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await _W(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new RW(t.privateKey,t.publicKey)}function UW(e){try{Am.ProjectivePoint.fromHex(e)}catch(t){throw new ug(String(t),"ERR_INVALID_PUBLIC_KEY")}}class LW{constructor(e){co(this,"_key",void 0),UW(e),this._key=e}verify(e,t){return function(e,t,r){const n=sH.digest(r instanceof Uint8Array?r:r.subarray());if($G(n))return n.then((r=>{let{digest:n}=r;return Am.verify(t,n,e)})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.verify(t,n.digest,e)}catch(i){throw new ug(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,Am.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return lW.encode({Type:cW.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return yH(this.bytes,e.bytes)}async hash(){const e=sH.digest(this.bytes);let t;return $G(e)?({bytes:t}=await e):t=e.bytes,t}}class MW{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),UW(this._publicKey)}sign(e){return function(e,t){const r=sH.digest(t instanceof Uint8Array?t:t.subarray());if($G(r))return r.then((t=>{let{digest:r}=t;return Am.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.sign(r.digest,e).toDERRawBytes()}catch(n){throw new ug(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new LW(this._publicKey)}marshal(){return this._key}get bytes(){return hW.encode({Type:cW.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return yH(this.bytes,e.bytes)}hash(){const e=sH.digest(this.bytes);return $G(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return vW(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return aW(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function OW(e){return new MW(e)}function qW(e){return new LW(e)}async function KW(){const e=Am.utils.randomPrivateKey();return new MW(e)}const FW={rsa:pr,ed25519:fr,secp256k1:gr};function VW(e){const t=Object.keys(FW).join(" / ");return new ug("invalid or unsupported key type ".concat(e,". Must be ").concat(t),"ERR_UNSUPPORTED_KEY_TYPE")}function zW(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return FW[e];throw VW(e)}function jW(e){var t,r;const n=lW.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case cW.RSA:return FW.rsa.unmarshalRsaPublicKey(i);case cW.Ed25519:return FW.ed25519.unmarshalEd25519PublicKey(i);case cW.Secp256k1:return FW.secp256k1.unmarshalSecp256k1PublicKey(i);default:throw VW(null!==(r=n.Type)&&void 0!==r?r:"unknown")}}function HW(e,t){var r;return zW(t=(null!==(r=t)&&void 0!==r?r:"rsa").toLowerCase()),e.bytes}async function GW(e){var t,r;const n=hW.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case cW.RSA:return FW.rsa.unmarshalRsaPrivateKey(i);case cW.Ed25519:return FW.ed25519.unmarshalEd25519PrivateKey(i);case cW.Secp256k1:return FW.secp256k1.unmarshalSecp256k1PrivateKey(i);default:throw VW(null!==(r=n.Type)&&void 0!==r?r:"RSA")}}const WW=tG("libp2p-pubsub:");function YW(){var e,t,r,n;let i=arguments.length>1?arguments[1]:void 0;return{subscriptions:[],messages:arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],control:void 0!==i?{graft:null!==(e=i.graft)&&void 0!==e?e:[],prune:null!==(t=i.prune)&&void 0!==t?t:[],ihave:null!==(r=i.ihave)&&void 0!==r?r:[],iwant:null!==(n=i.iwant)&&void 0!==n?n:[]}:void 0}}function QW(e){return void 0===e.control&&(e.control={graft:[],prune:[],ihave:[],iwant:[]}),e}function JW(e){return vW(e,"base64")}function XW(e){if(e.length<=1)return e;for(let t=0;t<e.length;t++){const r=Math.floor(Math.random()*Math.floor(e.length)),n=e[t];e[t]=e[r],e[r]=n}return e}new Uint8Array(0);function ZW(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var $W=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=rY;)r[n++]=255&t|eY,t/=128;for(;t&tY;)r[n++]=255&t|eY,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},eY=128,tY=-128,rY=Math.pow(2,31);var nY=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&oY)<<o:(n&oY)*Math.pow(2,o),o+=7}while(n>=iY);return e.bytes=s-r,i},iY=128,oY=127;var sY=Math.pow(2,7),aY=Math.pow(2,14),cY=Math.pow(2,21),uY=Math.pow(2,28),lY=Math.pow(2,35),hY=Math.pow(2,42),dY=Math.pow(2,49),fY=Math.pow(2,56),pY=Math.pow(2,63);const gY={encode:$W,decode:nY,encodingLength:function(e){return e<sY?1:e<aY?2:e<cY?3:e<uY?4:e<lY?5:e<hY?6:e<dY?7:e<fY?8:e<pY?9:10}};function bY(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return gY.encode(e,t,r),t}function yY(e){return gY.encodingLength(e)}function mY(e,t){const r=t.byteLength,n=yY(e),i=n+yY(r),o=new Uint8Array(i+r);return bY(e,o,0),bY(r,o,n),o.set(t,i),new vY(e,r,t,o)}class vY{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}function wY(e){let{name:t,code:r,encode:n}=e;return new _Y(t,r,n)}class _Y{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?mY(this.code,t):t.then((e=>mY(this.code,e)))}throw Error("Unknown type, must be binary type")}}function EY(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const SY=wY({name:"sha2-256",code:18,encode:EY("SHA-256")}),AY=wY({name:"sha2-512",code:19,encode:EY("SHA-512")});var kY=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const xY=kY;class IY{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class CY{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return RY(this,e)}}class TY{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return RY(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function RY(e,t){var r,n;return new TY({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class PY{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new IY(e,t,r),this.decoder=new CY(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function DY(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new PY(t,r,n,i)}function NY(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=xY(n,t);return DY({prefix:r,name:t,encode:i,decode:e=>ZW(o(e))})}function BY(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return DY({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const UY=NY({prefix:"9",name:"base10",alphabet:"0123456789"}),LY=BY({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),MY=BY({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),OY=BY({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),qY=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),KY=qY.reduce(((e,t,r)=>(e[r]=t,e)),[]),FY=qY.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const VY=DY({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=KY[t]),"")},decode:function(e){const t=[];for(const r of e){const e=FY[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),zY=BY({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jY=BY({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),HY=BY({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),GY=BY({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),WY=BY({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),YY=BY({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),QY=BY({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),JY=BY({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),XY=BY({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ZY=NY({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$Y=NY({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),eQ=NY({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tQ=NY({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),rQ=BY({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nQ=BY({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),iQ=BY({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),oQ=BY({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),sQ=BY({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),aQ=DY({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),cQ=new TextEncoder,uQ=new TextDecoder,lQ="json",hQ=512;function dQ(e){return cQ.encode(JSON.stringify(e))}function fQ(e){return JSON.parse(uQ.decode(e))}const pQ="raw",gQ=85;function bQ(e){return ZW(e)}function yQ(e){return ZW(e)}const mQ=ZW;const vQ={code:0,name:"identity",encode:mQ,digest:function(e){return mY(0,mQ(e))}};new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const wQ={...xr,...vr,...kr,...yr,...mr,..._r,...Er,...Sr,...Ar,...wr};function _Q(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const EQ=_Q("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),SQ=_Q("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),AQ={utf8:EQ,"utf-8":EQ,hex:wQ.base16,latin1:SQ,ascii:SQ,binary:SQ,...wQ};const kQ=(e,t)=>{const r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=AQ[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(t.toString(16).padStart(16,"0"),"base16"),n=new Uint8Array(e.length+r.length);return n.set(e,0),n.set(r,e.length),n};function xQ(e){if("signed"!==e.type)throw new Error("expected signed message type");if(null==e.sequenceNumber)throw Error("missing seqno field");return kQ(e.from.toBytes(),e.sequenceNumber)}async function IQ(e){return sH.encode(e.data)}const CQ=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},TQ=-1,RQ={},PQ={};function DQ(e){if("number"===typeof e){if(null!=PQ[e])return PQ[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=RQ[e])return RQ[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,TQ,"ip6zone"],[43,8,"ipcidr"],[53,TQ,"dns",!0],[54,TQ,"dns4",!0],[55,TQ,"dns6",!0],[56,TQ,"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,TQ,"unix",!1,!0],[421,TQ,"ipfs"],[421,TQ,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,TQ,"garlic64"],[448,0,"tls"],[449,TQ,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,TQ,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,TQ,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);PQ[t.code]=t,RQ[t.name]=t}));DQ("ip4"),DQ("ip6"),DQ("ipcidr");function NQ(e,t){switch(DQ(e).code){case 4:case 41:return function(e){const t=CQ(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return LQ(t);case 6:case 273:case 33:case 132:return UQ(t).toString();case 421:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return vW(r,"base58btc")}(t);case 444:case 445:return MQ(t);case 466:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+vW(r,"base64url")}(t);default:return vW(t,"base16")}}const BQ=Object.values(bH).map((e=>e.decoder));!function(){let e=BQ[0].or(BQ[1]);BQ.slice(2).forEach((t=>e=e.or(t)))}();function UQ(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function LQ(e){const t=So(e);if((e=e.slice(vo(t))).length!==t)throw new Error("inconsistent lengths");return vW(e)}function MQ(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=vW(t,"base32"),i=UQ(r);return"".concat(n,":").concat(i)}var OQ;!function(e){e[e.ip4=4]="ip4",e[e.ip6=41]="ip6"}(OQ||(OQ={}));class qQ{constructor(e){co(this,"entries",new Map),co(this,"validityMs",void 0),this.validityMs=e.validityMs}get size(){return this.entries.size}put(e,t){return!!this.entries.has(e)||(this.entries.set(e,{value:t,validUntilMs:Date.now()+this.validityMs}),!1)}prune(){const e=Date.now();for(const[t,r]of this.entries.entries()){if(!(r.validUntilMs<e))break;this.entries.delete(t)}}has(e){return this.entries.has(e)}get(e){const t=this.entries.get(e);return null!=t&&t.validUntilMs>=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var KQ;!function(e){e[e.started=0]="started",e[e.stopped=1]="stopped"}(KQ||(KQ={}));class FQ extends gd{constructor(e){var t,r,n,i,o;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),co(this,"globalSignaturePolicy",void 0),co(this,"multicodecs",[PH,RH]),co(this,"publishConfig",void 0),co(this,"dataTransform",void 0),co(this,"peers",new Set),co(this,"streamsInbound",new Map),co(this,"streamsOutbound",new Map),co(this,"outboundInflightQueue",gh({objectMode:!0})),co(this,"direct",new Set),co(this,"floodsubPeers",new Set),co(this,"seenCache",void 0),co(this,"acceptFromWhitelist",new Map),co(this,"topics",new Map),co(this,"subscriptions",new Set),co(this,"mesh",new Map),co(this,"fanout",new Map),co(this,"fanoutLastpub",new Map),co(this,"gossip",new Map),co(this,"control",new Map),co(this,"peerhave",new Map),co(this,"iasked",new Map),co(this,"backoff",new Map),co(this,"outbound",new Map),co(this,"msgIdFn",void 0),co(this,"fastMsgIdFn",void 0),co(this,"msgIdToStrFn",void 0),co(this,"fastMsgIdCache",void 0),co(this,"publishedMessageIds",void 0),co(this,"mcache",void 0),co(this,"score",void 0),co(this,"topicValidators",new Map),co(this,"log",void 0),co(this,"heartbeatTicks",0),co(this,"gossipTracer",void 0),co(this,"components",void 0),co(this,"directPeerInitial",null),co(this,"opts",void 0),co(this,"decodeRpcLimits",void 0),co(this,"metrics",void 0),co(this,"status",{code:KQ.stopped}),co(this,"maxInboundStreams",void 0),co(this,"maxOutboundStreams",void 0),co(this,"runOnTransientConnection",void 0),co(this,"allowedTopics",void 0),co(this,"heartbeatTimer",null),co(this,"runHeartbeat",(()=>{var e;const t=null===(e=this.metrics)||void 0===e?void 0:e.heartbeatDuration.startTimer();this.heartbeat().catch((e=>{this.log("Error running heartbeat",e)})).finally((()=>{if(null!=t&&t(),this.status.code===KQ.started){clearTimeout(this.status.heartbeatTimeout);let t=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;var e;if(t<.25*this.opts.heartbeatInterval)t+=this.opts.heartbeatInterval,null===(e=this.metrics)||void 0===e||e.heartbeatSkipped.inc();this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,t)}}))}));const a={fallbackToFloodsub:!0,floodPublish:!0,batchPublish:!1,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,unsubcribeBackoff:1e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...s,scoreParams:MG(s.scoreParams),scoreThresholds:KG(s.scoreThresholds)};if(this.components=e,this.decodeRpcLimits=null!==(t=a.decodeRpcLimits)&&void 0!==t?t:NH,this.globalSignaturePolicy=null!==(r=a.globalSignaturePolicy)&&void 0!==r?r:Uz,a.fallbackToFloodsub&&this.multicodecs.push(TH),this.log=e.logger.forComponent(null!==(n=a.debugName)&&void 0!==n?n:"libp2p:gossipsub"),this.opts=a,this.direct=new Set(a.directPeers.map((e=>e.id.toString()))),this.seenCache=new qQ({validityMs:a.seenTTL}),this.publishedMessageIds=new qQ({validityMs:a.seenTTL}),null!=s.msgIdFn)this.msgIdFn=s.msgIdFn;else switch(this.globalSignaturePolicy){case Uz:this.msgIdFn=xQ;break;case Lz:this.msgIdFn=IQ;break;default:throw new Error("Invalid globalSignaturePolicy: ".concat(this.globalSignaturePolicy))}if(null!=s.fastMsgIdFn&&(this.fastMsgIdFn=s.fastMsgIdFn,this.fastMsgIdCache=new qQ({validityMs:a.seenTTL})),this.msgIdToStrFn=null!==(i=s.msgIdToStrFn)&&void 0!==i?i:JW,this.mcache=null!==(o=s.messageCache)&&void 0!==o?o:new DG(a.mcacheGossip,a.mcacheLength,this.msgIdToStrFn),null!=s.dataTransform&&(this.dataTransform=s.dataTransform),null!=s.metricsRegister){if(null==s.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const e=Math.max(...Object.values(a.scoreParams.topics).map((e=>e.meshMessageDeliveriesWindow)),1e3),t=function(e,t,r){return{protocolsEnabled:e.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:e.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:e.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:e.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEventsFanout:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_fanout_total",help:"Number of times we include peers in a topic mesh for fanout reasons",labelNames:["topic"]}),meshPeerInclusionEventsRandom:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_random_total",help:"Number of times we include peers in a topic mesh for random reasons",labelNames:["topic"]}),meshPeerInclusionEventsSubscribed:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_subscribed_total",help:"Number of times we include peers in a topic mesh for subscribed reasons",labelNames:["topic"]}),meshPeerInclusionEventsOutbound:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_outbound_total",help:"Number of times we include peers in a topic mesh for outbound reasons",labelNames:["topic"]}),meshPeerInclusionEventsNotEnough:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_not_enough_total",help:"Number of times we include peers in a topic mesh for not_enough reasons",labelNames:["topic"]}),meshPeerInclusionEventsOpportunistic:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_opportunistic_total",help:"Number of times we include peers in a topic mesh for opportunistic reasons",labelNames:["topic"]}),meshPeerInclusionEventsUnknown:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_unknown_total",help:"Number of times we include peers in a topic mesh for unknown reasons",labelNames:["topic"]}),meshPeerChurnEventsDisconnected:e.gauge({name:"gossipsub_peer_churn_events_disconnected_total",help:"Number of times we remove peers in a topic mesh for disconnected reasons",labelNames:["topic"]}),meshPeerChurnEventsBadScore:e.gauge({name:"gossipsub_peer_churn_events_bad_score_total",help:"Number of times we remove peers in a topic mesh for bad_score reasons",labelNames:["topic"]}),meshPeerChurnEventsPrune:e.gauge({name:"gossipsub_peer_churn_events_prune_total",help:"Number of times we remove peers in a topic mesh for prune reasons",labelNames:["topic"]}),meshPeerChurnEventsExcess:e.gauge({name:"gossipsub_peer_churn_events_excess_total",help:"Number of times we remove peers in a topic mesh for excess reasons",labelNames:["topic"]}),meshPeerChurnEventsUnknown:e.gauge({name:"gossipsub_peer_churn_events_unknown_total",help:"Number of times we remove peers in a topic mesh for unknown reasons",labelNames:["topic"]}),peersPerProtocol:e.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:e.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:e.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),acceptedMessagesTotal:e.gauge({name:"gossipsub_accepted_messages_total",help:"Total accepted messages for each topic",labelNames:["topic"]}),ignoredMessagesTotal:e.gauge({name:"gossipsub_ignored_messages_total",help:"Total ignored messages for each topic",labelNames:["topic"]}),rejectedMessagesTotal:e.gauge({name:"gossipsub_rejected_messages_total",help:"Total rejected messages for each topic",labelNames:["topic"]}),unknownValidationResultsTotal:e.gauge({name:"gossipsub_unknown_validation_results_total",help:"Total unknown validation results for each topic",labelNames:["topic"]}),asyncValidationMcacheHit:e.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),asyncValidationDelayFromFirstSeenSec:e.histogram({name:"gossipsub_async_validation_delay_from_first_seen",help:"Async validation report delay from first seen in second",buckets:[.01,.03,.1,.3,1,3,10]}),asyncValidationUnknownFirstSeen:e.gauge({name:"gossipsub_async_validation_unknown_first_seen_count_total",help:"Async validation report unknown first seen value for message"}),peerReadStreamError:e.gauge({name:"gossipsub_peer_read_stream_err_count_total",help:"Peer read stream error"}),rpcRecvBytes:e.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:e.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:e.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:e.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:e.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:e.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:e.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:e.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:e.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcDataError:e.gauge({name:"gossipsub_rpc_data_err_count_total",help:"RPC data error"}),rpcRecvError:e.gauge({name:"gossipsub_rpc_recv_err_count_total",help:"RPC recv error"}),rpcRecvNotAccepted:e.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:e.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:e.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:e.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:e.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:e.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:e.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:e.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:e.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:e.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:e.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeersByTopic:e.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),directPeersPublishedTotal:e.gauge({name:"gossipsub_direct_peers_published_total",help:"Total direct peers that we publish a msg to",labelNames:["topic"]}),floodsubPeersPublishedTotal:e.gauge({name:"gossipsub_floodsub_peers_published_total",help:"Total floodsub peers that we publish a msg to",labelNames:["topic"]}),meshPeersPublishedTotal:e.gauge({name:"gossipsub_mesh_peers_published_total",help:"Total mesh peers that we publish a msg to",labelNames:["topic"]}),fanoutPeersPublishedTotal:e.gauge({name:"gossipsub_fanout_peers_published_total",help:"Total fanout peers that we publish a msg to",labelNames:["topic"]}),msgPublishBytes:e.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgPublishTime:e.histogram({name:"gossipsub_msg_publish_seconds",help:"Total time in seconds to publish a message",buckets:[.001,.002,.005,.01,.1,.5,1],labelNames:["topic"]}),msgForwardCount:e.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:e.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:e.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedError:e.gauge({name:"gossipsub_msg_received_error_total",help:"Total count of recv msgs error",labelNames:["topic"]}),prevalidationInvalidTotal:e.gauge({name:"gossipsub_pre_validation_invalid_total",help:"Total count of invalid messages received",labelNames:["topic"]}),prevalidationValidTotal:e.gauge({name:"gossipsub_pre_validation_valid_total",help:"Total count of valid messages received",labelNames:["topic"]}),prevalidationDuplicateTotal:e.gauge({name:"gossipsub_pre_validation_duplicate_total",help:"Total count of duplicate messages received",labelNames:["topic"]}),prevalidationUnknownTotal:e.gauge({name:"gossipsub_pre_validation_unknown_status_total",help:"Total count of unknown_status messages received",labelNames:["topic"]}),msgReceivedInvalid:e.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["error"]}),msgReceivedInvalidByTopic:e.gauge({name:"gossipsub_msg_received_invalid_by_topic_total",help:"Tracks specific invalid message by topic",labelNames:["topic"]}),duplicateMsgDeliveryDelay:e.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*r.maxMeshMessageDeliveriesWindowSec,.5*r.maxMeshMessageDeliveriesWindowSec,Number(r.maxMeshMessageDeliveriesWindowSec),2*r.maxMeshMessageDeliveriesWindowSec,4*r.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:e.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),duplicateMsgIgnored:e.gauge({name:"gossisub_ignored_published_duplicate_msgs_total",help:"Total count of published duplicate message ignored by topic",labelNames:["topic"]}),scoreFnCalls:e.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:e.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:e.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:e.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:e.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores"}),scoreWeights:e.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:e.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:e.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:e.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*r.behaviourPenaltyThreshold,.5*r.behaviourPenaltyThreshold,Number(r.behaviourPenaltyThreshold),2*r.behaviourPenaltyThreshold,4*r.behaviourPenaltyThreshold]}),ihaveRcvIgnored:e.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:e.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:e.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:e.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:e.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:e.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:e.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedFromDuplicate:e.gauge({name:"gossipsub_iwant_promise_resolved_from_duplicate_total",help:"Total count of resolved IWANT promises from duplicate messages"}),iwantPromiseResolvedPeers:e.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:e.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantMessagePruned:e.gauge({name:"gossipsub_iwant_message_pruned",help:"Total count of pruned IWANT messages"}),iwantPromiseDeliveryTime:e.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*r.gossipPromiseExpireSec,Number(r.gossipPromiseExpireSec),2*r.gossipPromiseExpireSec,4*r.gossipPromiseExpireSec]}),iwantPromiseUntracked:e.gauge({name:"gossip_iwant_promise_untracked",help:"Total count of untracked IWANT promise"}),connectedPeersBackoffSec:e.histogram({name:"gossipsub_connected_peers_backoff_seconds",help:"Backoff time in seconds",buckets:[1,2,4,10,20,60,120]}),cacheSize:e.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:e.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),mcacheNotValidatedCount:e.gauge({name:"gossipsub_mcache_not_validated_count",help:"Current mcache msg count not validated"}),fastMsgIdCacheCollision:e.gauge({name:"gossipsub_fastmsgid_cache_collision_total",help:"Total count of key collisions on fastmsgid cache put"}),newConnectionCount:e.gauge({name:"gossipsub_new_connection_total",help:"Total new connection by status",labelNames:["status"]}),topicStrToLabel:t,toTopic(e){var t;return null!==(t=this.topicStrToLabel.get(e))&&void 0!==t?t:e},onJoin(e){this.topicSubscriptionStatus.set({topicStr:e},1),this.meshPeerCounts.set({topicStr:e},0)},onLeave(e){this.topicSubscriptionStatus.set({topicStr:e},0),this.meshPeerCounts.set({topicStr:e},0)},onAddToMesh(e,t,r){const n=this.toTopic(e);switch(t){case AG.Fanout:this.meshPeerInclusionEventsFanout.inc({topic:n},r);break;case AG.Random:this.meshPeerInclusionEventsRandom.inc({topic:n},r);break;case AG.Subscribed:this.meshPeerInclusionEventsSubscribed.inc({topic:n},r);break;case AG.Outbound:this.meshPeerInclusionEventsOutbound.inc({topic:n},r);break;case AG.NotEnough:this.meshPeerInclusionEventsNotEnough.inc({topic:n},r);break;case AG.Opportunistic:this.meshPeerInclusionEventsOpportunistic.inc({topic:n},r);break;default:this.meshPeerInclusionEventsUnknown.inc({topic:n},r)}},onRemoveFromMesh(e,t,r){const n=this.toTopic(e);switch(t){case kG.Dc:this.meshPeerChurnEventsDisconnected.inc({topic:n},r);break;case kG.BadScore:this.meshPeerChurnEventsBadScore.inc({topic:n},r);break;case kG.Prune:this.meshPeerChurnEventsPrune.inc({topic:n},r);break;case kG.Excess:this.meshPeerChurnEventsExcess.inc({topic:n},r);break;default:this.meshPeerChurnEventsUnknown.inc({topic:n},r)}},onReportValidation(e,t,r){if(this.asyncValidationMcacheHit.inc({hit:null!=e?"hit":"miss"}),null!=e){const r=this.toTopic(e.message.topic);switch(t){case Mz.Accept:this.acceptedMessagesTotal.inc({topic:r});break;case Mz.Ignore:this.ignoredMessagesTotal.inc({topic:r});break;case Mz.Reject:this.rejectedMessagesTotal.inc({topic:r});break;default:this.unknownValidationResultsTotal.inc({topic:r})}}null!=r?this.asyncValidationDelayFromFirstSeenSec.observe((Date.now()-r)/1e3):this.asyncValidationUnknownFirstSeen.inc()},onScorePenalty(e){this.scoringPenalties.inc({penalty:e},1)},onIhaveRcv(e,t,r){const n=this.toTopic(e);this.ihaveRcvMsgids.inc({topic:n},t),this.ihaveRcvNotSeenMsgids.inc({topic:n},r)},onIwantRcv(e,t){for(const[r,n]of e){const e=this.toTopic(r);this.iwantRcvMsgids.inc({topic:e},n)}this.iwantRcvDonthaveMsgids.inc(t)},onForwardMsg(e,t){const r=this.toTopic(e);this.msgForwardCount.inc({topic:r},1),this.msgForwardPeers.inc({topic:r},t)},onPublishMsg(e,t,r,n,i){const o=this.toTopic(e);this.msgPublishCount.inc({topic:o},1),this.msgPublishBytes.inc({topic:o},r*n),this.msgPublishPeersByTopic.inc({topic:o},r),this.directPeersPublishedTotal.inc({topic:o},t.direct),this.floodsubPeersPublishedTotal.inc({topic:o},t.floodsub),this.meshPeersPublishedTotal.inc({topic:o},t.mesh),this.fanoutPeersPublishedTotal.inc({topic:o},t.fanout),this.msgPublishTime.observe({topic:o},i/1e3)},onMsgRecvPreValidation(e){const t=this.toTopic(e);this.msgReceivedPreValidation.inc({topic:t},1)},onMsgRecvError(e){const t=this.toTopic(e);this.msgReceivedError.inc({topic:t},1)},onPrevalidationResult(e,t){const r=this.toTopic(e);switch(t){case EG.duplicate:this.prevalidationDuplicateTotal.inc({topic:r});break;case EG.invalid:this.prevalidationInvalidTotal.inc({topic:r});break;case EG.valid:this.prevalidationValidTotal.inc({topic:r});break;default:this.prevalidationUnknownTotal.inc({topic:r})}},onMsgRecvInvalid(e,t){const r=this.toTopic(e),n=t.reason===wG.Error?t.error:t.reason;this.msgReceivedInvalid.inc({error:n},1),this.msgReceivedInvalidByTopic.inc({topic:r},1)},onDuplicateMsgDelivery(e,t,r){const n=this.toTopic(e);this.duplicateMsgDeliveryDelay.observe({topic:n},t/1e3),r&&this.duplicateMsgLateDelivery.inc({topic:n},1)},onPublishDuplicateMsg(e){const t=this.toTopic(e);this.duplicateMsgIgnored.inc({topic:t},1)},onPeerReadStreamError(){this.peerReadStreamError.inc(1)},onRpcRecvError(){this.rpcRecvError.inc(1)},onRpcDataError(){this.rpcDataError.inc(1)},onRpcRecv(e,t){this.rpcRecvBytes.inc(t),this.rpcRecvCount.inc(1),null!=e.subscriptions&&this.rpcRecvSubscription.inc(e.subscriptions.length),null!=e.messages&&this.rpcRecvMessage.inc(e.messages.length),null!=e.control&&(this.rpcRecvControl.inc(1),null!=e.control.ihave&&this.rpcRecvIHave.inc(e.control.ihave.length),null!=e.control.iwant&&this.rpcRecvIWant.inc(e.control.iwant.length),null!=e.control.graft&&this.rpcRecvGraft.inc(e.control.graft.length),null!=e.control.prune&&this.rpcRecvPrune.inc(e.control.prune.length))},onRpcSent(e,t){if(this.rpcSentBytes.inc(t),this.rpcSentCount.inc(1),null!=e.subscriptions&&this.rpcSentSubscription.inc(e.subscriptions.length),null!=e.messages&&this.rpcSentMessage.inc(e.messages.length),null!=e.control){var r,n,i,o,s,a,c,u;const t=null!==(r=null===(n=e.control.ihave)||void 0===n?void 0:n.length)&&void 0!==r?r:0,l=null!==(i=null===(o=e.control.iwant)||void 0===o?void 0:o.length)&&void 0!==i?i:0,h=null!==(s=null===(a=e.control.graft)||void 0===a?void 0:a.length)&&void 0!==s?s:0,d=null!==(c=null===(u=e.control.prune)||void 0===u?void 0:u.length)&&void 0!==c?c:0;t>0&&this.rpcSentIHave.inc(t),l>0&&this.rpcSentIWant.inc(l),h>0&&this.rpcSentGraft.inc(h),d>0&&this.rpcSentPrune.inc(d),(t>0||l>0||h>0||d>0)&&this.rpcSentControl.inc(1)}},registerScores(e,t){let r=0,n=0,i=0,o=0;for(const s of e)s>=t.graylistThreshold&&r++,s>=t.publishThreshold&&n++,s>=t.gossipThreshold&&i++,s>=0&&o++;this.peersByScoreThreshold.set({threshold:CG.graylist},r),this.peersByScoreThreshold.set({threshold:CG.publish},n),this.peersByScoreThreshold.set({threshold:CG.gossip},i),this.peersByScoreThreshold.set({threshold:CG.mesh},o),this.score.set(e)},registerScoreWeights(e){for(const[t,r]of e.byTopic)this.scoreWeights.set({topic:t,p:"p1"},r.p1w),this.scoreWeights.set({topic:t,p:"p2"},r.p2w),this.scoreWeights.set({topic:t,p:"p3"},r.p3w),this.scoreWeights.set({topic:t,p:"p3b"},r.p3bw),this.scoreWeights.set({topic:t,p:"p4"},r.p4w);this.scoreWeights.set({p:"p5"},e.p5w),this.scoreWeights.set({p:"p6"},e.p6w),this.scoreWeights.set({p:"p7"},e.p7w)},registerScorePerMesh(e,t){const r=new Map;e.forEach(((e,t)=>{var n;const i=null!==(n=this.topicStrToLabel.get(t))&&void 0!==n?n:"unknown";let o=r.get(i);null==o&&(o=new Set,r.set(i,o)),e.forEach((e=>{var t;return null===(t=o)||void 0===t?void 0:t.add(e)}))}));for(const[n,i]of r){const e=[];i.forEach((r=>{var n;e.push(null!==(n=t.get(r))&&void 0!==n?n:0)})),this.scorePerMesh.set({topic:n},e)}}}}(s.metricsRegister,s.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:a.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:e/1e3});t.mcacheSize.addCollect((()=>{this.onScrapeMetrics(t)}));for(const r of this.multicodecs)t.protocolsEnabled.set({protocol:r},1);this.metrics=t}else this.metrics=null;this.gossipTracer=new XG(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new WG(this.opts.scoreParams,this.metrics,this.components.logger,{scoreCacheValidityMs:a.heartbeatInterval}),this.maxInboundStreams=s.maxInboundStreams,this.maxOutboundStreams=s.maxOutboundStreams,this.runOnTransientConnection=s.runOnTransientConnection,this.allowedTopics=null!=a.allowedTopics?new Set(a.allowedTopics):null}getPeers(){return[...this.peers.keys()].map((e=>IH(e)))}isStarted(){return this.status.code===KQ.started}async start(){if(this.isStarted())return;this.log("starting"),this.publishConfig=await async function(e,t){switch(e){case Uz:{if(null==t)throw Error("Must provide PeerId");if(null==t.privateKey)throw Error("Cannot sign message, no private key present");if(null==t.publicKey)throw Error("Cannot sign message, no public key present");const e=await GW(t.privateKey);return{type:vG.Signing,author:t,key:t.publicKey,privateKey:e}}case Lz:return{type:vG.Anonymous};default:throw new Error('Unknown signature policy "'.concat(e,'"'))}}(this.globalSignaturePolicy,this.components.peerId),this.outboundInflightQueue=gh({objectMode:!0}),mh(this.outboundInflightQueue,(async e=>{for await(const{peerId:t,connection:r}of e)await this.createOutboundStream(t,r)})).catch((e=>{this.log.error("outbound inflight queue error",e)})),await Promise.all(this.opts.directPeers.map((async e=>{await this.components.peerStore.merge(e.id,{multiaddrs:e.addrs})})));const e=this.components.registrar;await Promise.all(this.multicodecs.map((async t=>e.handle(t,this.onIncomingStream.bind(this),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}))));const t={onConnect:this.onPeerConnected.bind(this),onDisconnect:this.onPeerDisconnected.bind(this),notifyOnTransient:this.runOnTransientConnection},r=await Promise.all(this.multicodecs.map((async r=>e.register(r,t)))),n=setTimeout(this.runHeartbeat,100);this.status={code:KQ.started,registrarTopologyIds:r,heartbeatTimeout:n,hearbeatStartMs:Date.now()+100},this.score.start(),this.directPeerInitial=setTimeout((()=>{Promise.resolve().then((async()=>{await Promise.all(Array.from(this.direct).map((async e=>this.connect(e))))})).catch((e=>{this.log(e)}))}),1e3),this.log("started")}async stop(){if(this.log("stopping"),this.status.code!==KQ.started)return;const{registrarTopologyIds:e}=this.status;this.status={code:KQ.stopped};const t=this.components.registrar;await Promise.all(this.multicodecs.map((async e=>t.unhandle(e)))),e.forEach((e=>{t.unregister(e)})),this.outboundInflightQueue.end();const r=[];for(const n of this.streamsOutbound.values())r.push(n.close());this.streamsOutbound.clear();for(const n of this.streamsInbound.values())r.push(n.close());this.streamsInbound.clear(),await Promise.all(r),this.peers.clear(),this.subscriptions.clear(),null!=this.heartbeatTimer&&(this.heartbeatTimer.cancel(),this.heartbeatTimer=null),this.score.stop(),this.mesh.clear(),this.fanout.clear(),this.fanoutLastpub.clear(),this.gossip.clear(),this.control.clear(),this.peerhave.clear(),this.iasked.clear(),this.backoff.clear(),this.outbound.clear(),this.gossipTracer.clear(),this.seenCache.clear(),null!=this.fastMsgIdCache&&this.fastMsgIdCache.clear(),null!=this.directPeerInitial&&clearTimeout(this.directPeerInitial),this.log("stopped")}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream(e){let{stream:t,connection:r}=e;if(!this.isStarted())return;const n=r.remotePeer;this.addPeer(n,r.direction,r.remoteAddr),this.createInboundStream(n,t),this.outboundInflightQueue.push({peerId:n,connection:r})}onPeerConnected(e,t){var r;null===(r=this.metrics)||void 0===r||r.newConnectionCount.inc({status:t.status}),this.isStarted()&&"open"===t.status&&(this.addPeer(e,t.direction,t.remoteAddr),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}async createOutboundStream(e,t){if(!this.isStarted())return;const r=e.toString();if(this.peers.has(r)&&!this.streamsOutbound.has(r))try{var n;const i=new QG(await t.newStream(this.multicodecs,{runOnTransientConnection:this.runOnTransientConnection}),(e=>{this.log.error("outbound pipe error",e)}),{maxBufferSize:this.opts.maxOutboundBufferSize});this.log("create outbound stream %p",e),this.streamsOutbound.set(r,i);const o=i.protocol;o===TH&&this.floodsubPeers.add(r),null===(n=this.metrics)||void 0===n||n.peersPerProtocol.inc({protocol:o},1),this.subscriptions.size>0&&(this.log("send subscriptions to",r),this.sendSubscriptions(r,Array.from(this.subscriptions),!0))}catch(i){this.log.error("createOutboundStream error",i)}}createInboundStream(e,t){if(!this.isStarted())return;const r=e.toString();if(!this.peers.has(r))return;const n=this.streamsInbound.get(r);void 0!==n&&(this.log("replacing existing inbound steam %s",r),n.close().catch((e=>{this.log.error(e)}))),this.log("create inbound stream %s",r);const i=new JG(t,{maxDataLength:this.opts.maxInboundDataLength});this.streamsInbound.set(r,i),this.pipePeerReadStream(e,i.source).catch((e=>{this.log(e)}))}addPeer(e,t,r){const n=e.toString();if(!this.peers.has(n)){this.log("new peer %p",e),this.peers.add(n),this.score.addPeer(n);const i=function(e){for(const t of e.tuples())switch(t[0]){case OQ.ip4:case OQ.ip6:return NQ(t[0],t[1])}return null}(r);null!==i?this.score.addIP(n,i):this.log("Added peer has no IP in current address %s %s",n,r.toString()),this.outbound.has(n)||this.outbound.set(n,"outbound"===t)}}removePeer(e){const t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);const r=this.streamsOutbound.get(t),n=this.streamsInbound.get(t);var i;null!=r&&(null===(i=this.metrics)||void 0===i||i.peersPerProtocol.inc({protocol:r.protocol},-1));null===r||void 0===r||r.close().catch((e=>{this.log.error(e)})),null===n||void 0===n||n.close().catch((e=>{this.log.error(e)})),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(const s of this.topics.values())s.delete(t);for(const[s,a]of this.mesh){var o;if(a.delete(t))null===(o=this.metrics)||void 0===o||o.onRemoveFromMesh(s,kG.Dc,1)}for(const s of this.fanout.values())s.delete(t);this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}get started(){return this.status.code===KQ.started}getMeshPeers(e){const t=this.mesh.get(e);return null!=t?Array.from(t):[]}getSubscribers(e){const t=this.topics.get(e);return(null!=t?Array.from(t):[]).map((e=>IH(e)))}getTopics(){return Array.from(this.subscriptions)}async pipePeerReadStream(e,t){try{await mh(t,(async t=>{for await(const a of t)try{var r;const t=a.subarray(),i=yG.decode(t,{limits:{subscriptions:this.decodeRpcLimits.maxSubscriptions,messages:this.decodeRpcLimits.maxMessages,control$:{ihave:this.decodeRpcLimits.maxIhaveMessageIDs,iwant:this.decodeRpcLimits.maxIwantMessageIDs,graft:this.decodeRpcLimits.maxControlMessages,prune:this.decodeRpcLimits.maxControlMessages,prune$:{peers:this.decodeRpcLimits.maxPeerInfos}}}});if(null===(r=this.metrics)||void 0===r||r.onRpcRecv(i,t.length),this.opts.awaitRpcHandler)try{await this.handleReceivedRpc(e,i)}catch(o){var n;null===(n=this.metrics)||void 0===n||n.onRpcRecvError(),this.log(o)}else this.handleReceivedRpc(e,i).catch((e=>{var t;null===(t=this.metrics)||void 0===t||t.onRpcRecvError(),this.log(e)}))}catch(s){var i;null===(i=this.metrics)||void 0===i||i.onRpcDataError(),this.log(s)}}))}catch(n){var r;null===(r=this.metrics)||void 0===r||r.onPeerReadStreamError(),this.handlePeerReadStreamError(n,e)}}handlePeerReadStreamError(e,t){this.log.error(e),this.onPeerDisconnected(t)}async handleReceivedRpc(e,t){var r;if(!this.acceptFrom(e.toString()))return this.log("received message from unacceptable peer %p",e),void(null===(r=this.metrics)||void 0===r||r.rpcRecvNotAccepted.inc());const n=null!=t.subscriptions?t.subscriptions.length:0,i=null!=t.messages?t.messages.length:0;let o=0,s=0,a=0,c=0;if(null!=t.control&&(null!=t.control.ihave&&(o=t.control.ihave.length),null!=t.control.iwant&&(s=t.control.iwant.length),null!=t.control.graft&&(a=t.control.graft.length),null!=t.control.prune&&(c=t.control.prune.length)),this.log("rpc.from ".concat(e.toString()," subscriptions ").concat(n," messages ").concat(i," ihave ").concat(o," iwant ").concat(s," graft ").concat(a," prune ").concat(c)),null!=t.subscriptions&&t.subscriptions.length>0){const r=[];t.subscriptions.forEach((t=>{const n=t.topic,i=!0===t.subscribe;if(null!=n){if(null!=this.allowedTopics&&!this.allowedTopics.has(n))return;this.handleReceivedSubscription(e,n,i),r.push({topic:n,subscribe:i})}})),this.safeDispatchEvent("subscription-change",{detail:{peerId:e,subscriptions:r}})}for(const u of t.messages){if(null!=this.allowedTopics&&!this.allowedTopics.has(u.topic))continue;const t=this.handleReceivedMessage(e,u).catch((e=>{var t;null===(t=this.metrics)||void 0===t||t.onMsgRecvError(u.topic),this.log(e)}));this.opts.awaitRpcMessageHandler&&await t}null!=t.control&&await this.handleControlMessage(e.toString(),t.control)}handleReceivedSubscription(e,t,r){this.log("subscription update from %p topic %s",e,t);let n=this.topics.get(t);null==n&&(n=new Set,this.topics.set(t,n)),r?n.add(e.toString()):n.delete(e.toString())}async handleReceivedMessage(e,t){var r,n,i;null===(r=this.metrics)||void 0===r||r.onMsgRecvPreValidation(t.topic);const o=await this.validateReceivedMessage(e,t);null===(n=this.metrics)||void 0===n||n.onPrevalidationResult(t.topic,o.code);const s=o.code;switch(s){case EG.duplicate:return this.score.duplicateMessage(e.toString(),o.msgIdStr,t.topic),this.gossipTracer.deliverMessage(o.msgIdStr,!0),void this.mcache.observeDuplicate(o.msgIdStr,e.toString());case EG.invalid:if(null!=o.msgIdStr){const r=o.msgIdStr;this.score.rejectMessage(e.toString(),r,t.topic,o.reason),this.gossipTracer.rejectMessage(r,o.reason)}else this.score.rejectInvalidMessage(e.toString(),t.topic);return void(null===(i=this.metrics)||void 0===i||i.onMsgRecvInvalid(t.topic,o));case EG.valid:if(this.score.validateMessage(o.messageId.msgIdStr),this.gossipTracer.deliverMessage(o.messageId.msgIdStr),this.mcache.put(o.messageId,t,!this.opts.asyncValidation),this.subscriptions.has(t.topic)){this.components.peerId.equals(e)&&!this.opts.emitSelf||(super.dispatchEvent(new yd("gossipsub:message",{detail:{propagationSource:e,msgId:o.messageId.msgIdStr,msg:o.msg}})),super.dispatchEvent(new yd("message",{detail:o.msg})))}this.opts.asyncValidation||this.forwardMessage(o.messageId.msgIdStr,t,e.toString());break;default:throw new Error("Invalid validation result: ".concat(s))}}async validateReceivedMessage(e,t){var r,n;const i=null===(r=this.fastMsgIdFn)||void 0===r?void 0:r.call(this,t),o=void 0!==i?null===(n=this.fastMsgIdCache)||void 0===n?void 0:n.get(i):void 0;if(null!=o)return{code:EG.duplicate,msgIdStr:o};const s=await async function(e,t){var r;switch(e){case Lz:return null!=t.signature?{valid:!1,error:_G.SignaturePresent}:null!=t.seqno?{valid:!1,error:_G.SeqnoPresent}:null!=t.key?{valid:!1,error:_G.FromPresent}:{valid:!0,message:{type:"unsigned",topic:t.topic,data:null!==(r=t.data)&&void 0!==r?r:new Uint8Array(0)}};case Uz:{var n,i;if(null==t.seqno)return{valid:!1,error:_G.InvalidSeqno};if(8!==t.seqno.length)return{valid:!1,error:_G.InvalidSeqno};if(null==t.signature)return{valid:!1,error:_G.InvalidSignature};if(null==t.from)return{valid:!1,error:_G.InvalidPeerId};let e,r;try{e=CH(t.from)}catch(o){return{valid:!1,error:_G.InvalidPeerId}}if(null!=t.key){if(r=jW(t.key),void 0!==e.publicKey&&!yH(r.bytes,e.publicKey))return{valid:!1,error:_G.InvalidPeerId}}else{if(null==e.publicKey)return{valid:!1,error:_G.InvalidPeerId};r=jW(e.publicKey)}const s={from:t.from,data:t.data,seqno:t.seqno,topic:t.topic,signature:void 0,key:void 0},a=iW([WW,yG.Message.encode(s)]);return await r.verify(a,t.signature)?{valid:!0,message:{type:"signed",from:e,data:null!==(n=t.data)&&void 0!==n?n:new Uint8Array(0),sequenceNumber:BigInt("0x".concat(vW(t.seqno,"base16"))),topic:t.topic,signature:t.signature,key:null!==(i=t.key)&&void 0!==i?i:HW(r)}}:{valid:!1,error:_G.InvalidSignature}}default:throw new Error("Unreachable")}}(this.globalSignaturePolicy,t);if(!s.valid)return{code:EG.invalid,reason:wG.Error,error:s.error};const a=s.message;try{null!=this.dataTransform&&(a.data=this.dataTransform.inboundTransform(t.topic,a.data))}catch(f){return this.log("Invalid message, transform failed",f),{code:EG.invalid,reason:wG.Error,error:_G.TransformFailed}}const c=await this.msgIdFn(a),u=this.msgIdToStrFn(c),l={msgId:c,msgIdStr:u};if(void 0!==i&&null!=this.fastMsgIdCache){var h;if(this.fastMsgIdCache.put(i,u))null===(h=this.metrics)||void 0===h||h.fastMsgIdCacheCollision.inc()}if(this.seenCache.has(u))return{code:EG.duplicate,msgIdStr:u};this.seenCache.put(u);const d=this.topicValidators.get(t.topic);if(null!=d){let t;try{t=await d(e,a)}catch(f){const e=f.code;"ERR_TOPIC_VALIDATOR_IGNORE"===e&&(t=Mz.Ignore),t="ERR_TOPIC_VALIDATOR_REJECT"===e?Mz.Reject:Mz.Ignore}if(t!==Mz.Accept)return{code:EG.invalid,reason:NG(t),msgIdStr:u}}return{code:EG.valid,messageId:l,msg:a}}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map((e=>({topic:e,subscribe:r}))),messages:[]})}async handleControlMessage(e,t){var r;if(void 0===t)return;const n=null!=t.ihave?this.handleIHave(e,t.ihave):[],i=null!=t.iwant?this.handleIWant(e,t.iwant):[],o=null!=t.graft?await this.handleGraft(e,t.graft):[];if(null!=t.prune&&await this.handlePrune(e,t.prune),0===n.length&&0===i.length&&0===o.length)return;const s=this.sendRpc(e,YW(i,{iwant:n,prune:o})),a=null===(r=n[0])||void 0===r?void 0:r.messageIDs;var c;null!=a&&(s?this.gossipTracer.addPromise(e,a):null===(c=this.metrics)||void 0===c||c.iwantPromiseUntracked.inc(1))}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(null!=r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const n=this.score.score(e);return n>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),n>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){var r,n;if(0===t.length)return[];const i=this.score.score(e);var o;if(i<this.opts.scoreThresholds.gossipThreshold)return this.log("IHAVE: ignoring peer %s with score below threshold [ score = %d ]",e,i),null===(o=this.metrics)||void 0===o||o.ihaveRcvIgnored.inc({reason:IG.LowScore}),[];const s=(null!==(r=this.peerhave.get(e))&&void 0!==r?r:0)+1;var a;if(this.peerhave.set(e,s),s>10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,s),null===(a=this.metrics)||void 0===a||a.ihaveRcvIgnored.inc({reason:IG.MaxIhave}),[];const c=null!==(n=this.iasked.get(e))&&void 0!==n?n:0;var u;if(c>=DH)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,c),null===(u=this.metrics)||void 0===u||u.ihaveRcvIgnored.inc({reason:IG.MaxIasked}),[];const l=new Map;if(t.forEach((e=>{var t;let{topicID:r,messageIDs:n}=e;if(null==r||null==n||!this.mesh.has(r))return;let i=0;n.forEach((e=>{const t=this.msgIdToStrFn(e);this.seenCache.has(t)||(l.set(t,e),i++)})),null===(t=this.metrics)||void 0===t||t.onIhaveRcv(r,n.length,i)})),0===l.size)return[];let h=l.size;h+c>DH&&(h=DH-c),this.log("IHAVE: Asking for %d out of %d messages from %s",h,l.size,e);let d=Array.from(l.values());return XW(d),d=d.slice(0,h),this.iasked.set(e,c+h),[{messageIDs:d}]}handleIWant(e,t){var r;if(0===t.length)return[];const n=this.score.score(e);if(n<this.opts.scoreThresholds.gossipThreshold)return this.log("IWANT: ignoring peer %s with score below threshold [score = %d]",e,n),[];const i=new Map,o=new Map;let s=0;return t.forEach((t=>{let{messageIDs:r}=t;null===r||void 0===r||r.forEach((t=>{var r;const n=this.msgIdToStrFn(t),a=this.mcache.getWithIWantCount(n,e);null!=a?(o.set(a.msg.topic,1+(null!==(r=o.get(a.msg.topic))&&void 0!==r?r:0)),a.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,t):i.set(n,a.msg)):s++}))})),null===(r=this.metrics)||void 0===r||r.onIwantRcv(o,s),0===i.size?(this.log("IWANT: Could not provide any wanted messages to %s",e),[]):(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values()))}async handleGraft(e,t){const r=[],n=this.score.score(e),i=Date.now();let o=this.opts.doPX;if(t.forEach((t=>{var s,a,c;let{topicID:u}=t;if(null==u)return;const l=this.mesh.get(u);if(null==l)return void(o=!1);if(l.has(e))return;if(this.direct.has(e))return this.log("GRAFT: ignoring request from direct peer %s",e),r.push(u),void(o=!1);const h=null===(s=this.backoff.get(u))||void 0===s?void 0:s.get(e);if("number"===typeof h&&i<h){this.log("GRAFT: ignoring backed off peer %s",e),this.score.addPenalty(e,1,xG.GraftBackoff),o=!1;const t=h+this.opts.graftFloodThreshold-this.opts.pruneBackoff;return i<t&&this.score.addPenalty(e,1,xG.GraftBackoff),this.addBackoff(e,u),void r.push(u)}return n<0?(this.log("GRAFT: ignoring peer %s with negative score: score=%d, topic=%s",e,n,u),r.push(u),o=!1,void this.addBackoff(e,u)):l.size>=this.opts.Dhi&&(null===(a=this.outbound.get(e))||void 0===a||!a)?(r.push(u),void this.addBackoff(e,u)):(this.log("GRAFT: Add mesh link from %s in %s",e,u),this.score.graft(e,u),l.add(e),void(null===(c=this.metrics)||void 0===c||c.onAddToMesh(u,AG.Subscribed,1)))})),0===r.length)return[];return Promise.all(r.map((async t=>this.makePrune(e,t,o,false))))}async handlePrune(e,t){const r=this.score.score(e);for(const{topicID:i,backoff:o,peers:s}of t){if(null==i)continue;const t=this.mesh.get(i);if(null==t)return;var n;if(this.log("PRUNE: Remove mesh link to %s in %s",e,i),this.score.prune(e,i),t.has(e))t.delete(e),null===(n=this.metrics)||void 0===n||n.onRemoveFromMesh(i,kG.Prune,1);if("number"===typeof o&&o>0?this.doAddBackoff(e,i,1e3*o):this.addBackoff(e,i),null!=s&&s.length>0){if(r<this.opts.scoreThresholds.acceptPXThreshold){this.log("PRUNE: ignoring PX from peer %s with insufficient score [score = %d, topic = %s]",e,r,i);continue}await this.pxConnect(s)}}}addBackoff(e,t){this.doAddBackoff(e,t,this.opts.pruneBackoff)}doAddBackoff(e,t,r){var n;let i=this.backoff.get(t);null==i&&(i=new Map,this.backoff.set(t,i));const o=Date.now()+r;(null!==(n=i.get(e))&&void 0!==n?n:0)<o&&i.set(e,o)}applyIwantPenalties(){this.gossipTracer.getBrokenPromises().forEach(((e,t)=>{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,xG.BrokenPromise)}))}clearBackoff(){if(this.heartbeatTicks%15!==0)return;const e=Date.now();this.backoff.forEach(((t,r)=>{t.forEach(((r,n)=>{r+1*this.opts.heartbeatInterval<e&&t.delete(n)})),0===t.size&&this.backoff.delete(r)}))}async directConnect(){const e=[];this.direct.forEach((t=>{this.streamsOutbound.has(t)||e.push(t)})),await Promise.all(e.map((async e=>this.connect(e))))}async pxConnect(e){e.length>this.opts.prunePeers&&(XW(e),e=e.slice(0,this.opts.prunePeers));const t=[];await Promise.all(e.map((async e=>{if(null==e.peerID)return;const r=CH(e.peerID),n=r.toString();if(!this.peers.has(n))if(null!=e.signedPeerRecord)try{if(!await this.components.peerStore.consumePeerRecord(e.signedPeerRecord,r))return void this.log("bogus peer record obtained through px: could not add peer record to address book");t.push(n)}catch(i){this.log("bogus peer record obtained through px: invalid signature or not a peer record")}else t.push(n)}))),0!==t.length&&await Promise.all(t.map((async e=>this.connect(e))))}async connect(e){this.log("Initiating connection with %s",e);const t=IH(e),r=await this.components.connectionManager.openConnection(t);for(const i of this.multicodecs)for(const e of this.components.registrar.getTopologies(i)){var n;null===(n=e.onConnect)||void 0===n||n.call(e,t,r)}}subscribe(e){if(this.status.code!==KQ.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(const t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==KQ.started)throw new Error("Pubsub is not started");const t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(const r of this.peers.keys())this.sendSubscriptions(r,[e],!1);this.leave(e)}join(e){var t;if(this.status.code!==KQ.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),null===(t=this.metrics)||void 0===t||t.onJoin(e);const r=new Set,n=this.backoff.get(e),i=this.fanout.get(e);var o;null!=i&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),i.forEach((e=>{this.direct.has(e)||!(this.score.score(e)>=0)||null!=n&&n.has(e)||r.add(e)})),null===(o=this.metrics)||void 0===o||o.onAddToMesh(e,AG.Fanout,r.size));if(r.size<this.opts.D){var s;const t=r.size;this.getRandomGossipPeers(e,this.opts.D,(e=>!r.has(e)&&!this.direct.has(e)&&this.score.score(e)>=0&&(null==n||!n.has(e)))).forEach((e=>{r.add(e)})),null===(s=this.metrics)||void 0===s||s.onAddToMesh(e,AG.Random,r.size-t)}this.mesh.set(e,r),r.forEach((t=>{this.log("JOIN: Add mesh link to %s in %s",t,e),this.sendGraft(t,e)}))}leave(e){var t;if(this.status.code!==KQ.started)throw new Error("Gossipsub has not started");this.log("LEAVE %s",e),null===(t=this.metrics)||void 0===t||t.onLeave(e);const r=this.mesh.get(e);null!=r&&(Promise.all(Array.from(r).map((async t=>{this.log("LEAVE: Remove mesh link to %s in %s",t,e),await this.sendPrune(t,e)}))).catch((e=>{this.log("Error sending prunes to mesh peers",e)})),this.mesh.delete(e))}selectPeersToForward(e,t,r){const n=new Set,i=this.topics.get(e);null!=i&&(this.direct.forEach((e=>{var o;!i.has(e)||t===e||null!==(o=null===r||void 0===r?void 0:r.has(e))&&void 0!==o&&o||n.add(e)})),this.floodsubPeers.forEach((e=>{var o;i.has(e)&&t!==e&&(null===(o=null===r||void 0===r?void 0:r.has(e))||void 0===o||!o)&&this.score.score(e)>=this.opts.scoreThresholds.publishThreshold&&n.add(e)})));const o=this.mesh.get(e);return null!=o&&o.size>0&&o.forEach((e=>{var i;t===e||null!==(i=null===r||void 0===r?void 0:r.has(e))&&void 0!==i&&i||n.add(e)})),n}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},n=this.topics.get(e);if(null!=n)if(this.opts.floodPublish)n.forEach((e=>{this.direct.has(e)?(t.add(e),r.direct++):this.score.score(e)>=this.opts.scoreThresholds.publishThreshold&&(t.add(e),r.floodsub++)}));else{this.direct.forEach((e=>{n.has(e)&&(t.add(e),r.direct++)})),this.floodsubPeers.forEach((e=>{n.has(e)&&this.score.score(e)>=this.opts.scoreThresholds.publishThreshold&&(t.add(e),r.floodsub++)}));const i=this.mesh.get(e);if(null!=i&&i.size>0)i.forEach((e=>{t.add(e),r.mesh++}));else{const n=this.fanout.get(e);if(null!=n&&n.size>0)n.forEach((e=>{t.add(e),r.fanout++}));else{const n=this.getRandomGossipPeers(e,this.opts.D,(e=>this.score.score(e)>=this.opts.scoreThresholds.publishThreshold));n.size>0&&(this.fanout.set(e,n),n.forEach((e=>{t.add(e),r.fanout++})))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,n){var i;null!=r&&this.score.deliverMessage(r,e,t.topic);const o=this.selectPeersToForward(t.topic,r,n);o.forEach((e=>{this.sendRpc(e,YW([t]))})),null===(i=this.metrics)||void 0===i||i.onForwardMsg(t.topic,o.size)}async publish(e,t,r){var n,i,o,s;const a=Date.now(),c=null!=this.dataTransform?this.dataTransform.outboundTransform(e,t):t;if(null==this.publishConfig)throw Error("PublishError.Uninitialized");const{raw:u,msg:l}=await async function(e,t,r,n){switch(e.type){case vG.Signing:{const i={from:e.author.toBytes(),data:n,seqno:ZG(8),topic:t,signature:void 0,key:void 0},o=iW([WW,yG.Message.encode(i)]);return i.signature=await e.privateKey.sign(o),i.key=e.key,{raw:i,msg:{type:"signed",from:e.author,data:r,sequenceNumber:BigInt("0x".concat(vW(i.seqno,"base16"))),topic:t,signature:i.signature,key:i.key}}}case vG.Anonymous:return{raw:{from:void 0,data:n,seqno:void 0,topic:t,signature:void 0,key:void 0},msg:{type:"unsigned",data:r,topic:t}};default:throw new Error("Unreachable")}}(this.publishConfig,e,t,c),h=await this.msgIdFn(l),d=this.msgIdToStrFn(h),f=null!==(n=null===r||void 0===r?void 0:r.ignoreDuplicatePublishError)&&void 0!==n?n:this.opts.ignoreDuplicatePublishError;if(this.seenCache.has(d)){var p;if(f)return null===(p=this.metrics)||void 0===p||p.onPublishDuplicateMsg(e),{recipients:[]};throw Error("PublishError.Duplicate")}const{tosend:g,tosendCount:b}=this.selectPeersToPublish(e),y=this.opts.emitSelf&&this.subscriptions.has(e),m=null!==(i=null===r||void 0===r?void 0:r.allowPublishToZeroPeers)&&void 0!==i?i:this.opts.allowPublishToZeroPeers;if(0===g.size&&!m&&!y)throw Error("PublishError.InsufficientPeers");this.seenCache.put(d),this.mcache.put({msgId:h,msgIdStr:d},u,!0),this.publishedMessageIds.put(d);const v=null!==(o=null===r||void 0===r?void 0:r.batchPublish)&&void 0!==o?o:this.opts.batchPublish,w=YW([u]);if(v)this.sendRpcInBatch(g,w);else for(const E of g){this.sendRpc(E,w)||g.delete(E)}const _=Date.now()-a;return null===(s=this.metrics)||void 0===s||s.onPublishMsg(e,b,g.size,null!=u.data?u.data.length:0,_),y&&(g.add(this.components.peerId.toString()),super.dispatchEvent(new yd("gossipsub:message",{detail:{propagationSource:this.components.peerId,msgId:d,msg:l}})),super.dispatchEvent(new yd("message",{detail:l}))),{recipients:Array.from(g.values()).map((e=>IH(e)))}}sendRpcInBatch(e,t){const r=yG.encode(t),n=sh.single(r);for(const s of e){var i;const a=this.streamsOutbound.get(s);if(null!=a){try{a.pushPrefixed(n)}catch(o){e.delete(s),this.log.error("Cannot send rpc to ".concat(s),o)}null===(i=this.metrics)||void 0===i||i.onRpcSent(t,r.length)}else this.log("Cannot send RPC to ".concat(s," as there is no open stream to it available")),e.delete(s)}}reportMessageValidationResult(e,t,r){var n;let i;if(r===Mz.Accept){if(i=this.mcache.validate(e),null!=i){const{message:r,originatingPeers:n}=i;this.score.deliverMessage(t,e,r.topic),this.forwardMessage(e,i.message,t,n)}}else if(i=this.mcache.remove(e),null!=i){const n=NG(r),{message:o,originatingPeers:s}=i;this.score.rejectMessage(t,e,o.topic,n);for(const t of s)this.score.rejectMessage(t,e,o.topic,n)}const o=this.score.messageFirstSeenTimestampMs(e);null===(n=this.metrics)||void 0===n||n.onReportValidation(i,r,o)}sendGraft(e,t){const r=YW([],{graft:[{topicID:t}]});this.sendRpc(e,r)}async sendPrune(e,t){const r=YW([],{prune:[await this.makePrune(e,t,this.opts.doPX,!0)]});this.sendRpc(e,r)}sendRpc(e,t){var r;const n=this.streamsOutbound.get(e);if(null==n)return this.log("Cannot send RPC to ".concat(e," as there is no open stream to it available")),!1;const i=this.control.get(e);null!=i&&(this.piggybackControl(e,t,i),this.control.delete(e));const o=this.gossip.get(e);null!=o&&(this.piggybackGossip(e,t,o),this.gossip.delete(e));const s=yG.encode(t);try{n.push(s)}catch(a){return this.log.error("Cannot send rpc to ".concat(e),a),null!=i&&this.control.set(e,i),null!=o&&this.gossip.set(e,o),!1}return null===(r=this.metrics)||void 0===r||r.onRpcSent(t,s.length),!0}piggybackControl(e,t,r){const n=QW(t);for(const c of r.graft){var i,o;null!=c.topicID&&null!==(i=null===(o=this.mesh.get(c.topicID))||void 0===o?void 0:o.has(e))&&void 0!==i&&i&&n.control.graft.push(c)}for(const c of r.prune){var s,a;null==c.topicID||null!==(s=null===(a=this.mesh.get(c.topicID))||void 0===a?void 0:a.has(e))&&void 0!==s&&s||n.control.prune.push(c)}}piggybackGossip(e,t,r){QW(t).control.ihave=r}async sendGraftPrune(e,t,r){const n=this.opts.doPX,i=!1;for(const[o,s]of e){const e=s.map((e=>({topicID:e})));let a=[];const c=t.get(o);null!=c&&(a=await Promise.all(c.map((async e=>{var t;return this.makePrune(o,e,n&&!(null!==(t=r.get(o))&&void 0!==t&&t),i)}))),t.delete(o)),this.sendRpc(o,YW([],{graft:e,prune:a}))}for(const[o,s]of t){const e=await Promise.all(s.map((async e=>{var t;return this.makePrune(o,e,n&&!(null!==(t=r.get(o))&&void 0!==t&&t),i)})));this.sendRpc(o,YW([],{prune:e}))}}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[n,i]of e){var r;this.doEmitGossip(n,i,null!==(r=t.get(n))&&void 0!==r?r:[])}}doEmitGossip(e,t,r){if(0===r.length)return;if(XW(r),r.length>DH&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),0===t.size)return;let n=this.opts.Dlazy;const i=.25*t.size;let o=t;i>n&&(n=i),n>o.size?n=o.size:o=XW(Array.from(o)).slice(0,n),o.forEach((t=>{let n=r;r.length>DH&&(n=XW(n.slice()).slice(0,DH)),this.pushGossip(t,{topicID:e,messageIDs:n})}))}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,YW([],{ihave:t}));for(const[e,t]of this.control.entries()){this.control.delete(e);const r=YW([],{graft:t.graft,prune:t.prune});this.sendRpc(e,r)}}pushGossip(e,t){var r;this.log("Add gossip to %s",e);const n=null!==(r=this.gossip.get(e))&&void 0!==r?r:[];this.gossip.set(e,n.concat(t))}async makePrune(e,t,r,n){var i;if(this.score.prune(e,t),(null===(i=this.streamsOutbound.get(e))||void 0===i?void 0:i.protocol)===RH)return{topicID:t,peers:[]};const o=n?this.opts.unsubcribeBackoff:this.opts.pruneBackoff,s=o/1e3;if(this.doAddBackoff(e,t,o),!r)return{topicID:t,peers:[],backoff:s};const a=this.getRandomGossipPeers(t,this.opts.prunePeers,(t=>t!==e&&this.score.score(t)>=0)),c=await Promise.all(Array.from(a).map((async e=>{var t;const r=IH(e);let n;try{n=await this.components.peerStore.get(r)}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}return{peerID:r.toBytes(),signedPeerRecord:null===(t=n)||void 0===t?void 0:t.peerRecordEnvelope}})));return{topicID:t,peers:c,backoff:s}}async heartbeat(){var e,t;const{D:r,Dlo:n,Dhi:i,Dscore:o,Dout:s,fanoutTTL:a}=this.opts;this.heartbeatTicks++;const c=new Map,u=e=>{let t=c.get(e);return void 0===t&&(t=this.score.score(e),c.set(e,t)),t},l=new Map,h=new Map,d=new Map;this.clearBackoff(),this.peerhave.clear(),null===(e=this.metrics)||void 0===e||e.cacheSize.set({cache:"iasked"},this.iasked.size),this.iasked.clear(),this.applyIwantPenalties(),this.heartbeatTicks%this.opts.directConnectTicks===0&&await this.directConnect(),null===(t=this.fastMsgIdCache)||void 0===t||t.prune(),this.seenCache.prune(),this.gossipTracer.prune(),this.publishedMessageIds.prune();const f=new Map;this.mesh.forEach(((e,t)=>{const a=this.topics.get(t),c=new Set,p=new Set;if(f.set(t,p),null!=a){const r=XW(Array.from(a)),n=this.backoff.get(t);for(const t of r){const r=this.streamsOutbound.get(t);if(null!=r&&this.multicodecs.includes(r.protocol)&&!e.has(t)&&!this.direct.has(t)){const e=u(t);(null==n||!n.has(t))&&e>=0&&c.add(t),e>=this.opts.scoreThresholds.gossipThreshold&&p.add(t)}}}const g=(r,n)=>{var i;this.log("HEARTBEAT: Remove mesh link to %s in %s",r,t),this.addBackoff(r,t),e.delete(r),u(r)>=this.opts.scoreThresholds.gossipThreshold&&p.add(r),null===(i=this.metrics)||void 0===i||i.onRemoveFromMesh(t,n,1);const o=h.get(r);null==o?h.set(r,[t]):o.push(t)},b=(r,n)=>{var i;this.log("HEARTBEAT: Add mesh link to %s in %s",r,t),this.score.graft(r,t),e.add(r),p.delete(r),null===(i=this.metrics)||void 0===i||i.onAddToMesh(t,n,1);const o=l.get(r);null==o?l.set(r,[t]):o.push(t)};if(e.forEach((e=>{const r=u(e);r<0&&(this.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,r,t),g(e,kG.BadScore),d.set(e,!0))})),e.size<n){const t=function(e,t){return FG(e,t,(()=>!0))}(c,r-e.size);t.forEach((e=>{b(e,AG.NotEnough)}))}if(e.size>i){let t=Array.from(e);t.sort(((e,t)=>u(t)-u(e))),t=t.slice(0,o).concat(XW(t.slice(o)));let n=0;if(t.slice(0,r).forEach((e=>{var t;null!==(t=this.outbound.get(e))&&void 0!==t&&t&&n++})),n<s){const e=e=>{const r=t[e];for(let n=e;n>0;n--)t[n]=t[n-1];t[0]=r};if(n>0){let i=n;for(let n=1;n<r&&i>0;n++){var y;null!==(y=this.outbound.get(t[n]))&&void 0!==y&&y&&(e(n),i--)}}let i=r-n;for(let n=r;n<t.length&&i>0;n++){var m;null!==(m=this.outbound.get(t[n]))&&void 0!==m&&m&&(e(n),i--)}}t.slice(r).forEach((e=>{g(e,kG.Excess)}))}if(e.size>=n){let t=0;if(e.forEach((e=>{var r;null!==(r=this.outbound.get(e))&&void 0!==r&&r&&t++})),t<s){FG(c,s-t,(e=>!0===this.outbound.get(e))).forEach((e=>{b(e,AG.Outbound)}))}}if(this.heartbeatTicks%this.opts.opportunisticGraftTicks===0&&e.size>1){const r=Array.from(e).sort(((e,t)=>u(e)-u(t))),n=Math.floor(e.size/2),i=u(r[n]);if(i<this.opts.scoreThresholds.opportunisticGraftThreshold){const e=FG(c,this.opts.opportunisticGraftPeers,(e=>u(e)>i));for(const r of e)this.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",r,t),b(r,AG.Opportunistic)}}}));const p=Date.now();this.fanoutLastpub.forEach(((e,t)=>{e+a<p&&(this.fanout.delete(t),this.fanoutLastpub.delete(t))})),this.fanout.forEach(((e,t)=>{const n=this.topics.get(t);e.forEach((t=>{var r;(null===(r=null===n||void 0===n?void 0:n.has(t))||void 0===r||!r||u(t)<this.opts.scoreThresholds.publishThreshold)&&e.delete(t)}));const i=this.topics.get(t),o=[],s=new Set;if(f.set(t,s),null!=i){const t=XW(Array.from(i));for(const r of t){const t=this.streamsOutbound.get(r);if(null!=t&&this.multicodecs.includes(t.protocol)&&!e.has(r)&&!this.direct.has(r)){const e=u(r);e>=this.opts.scoreThresholds.publishThreshold&&o.push(r),e>=this.opts.scoreThresholds.gossipThreshold&&s.add(r)}}}if(e.size<r){const t=r-e.size;o.slice(0,t).forEach((t=>{e.add(t),null===s||void 0===s||s.delete(t)}))}})),this.emitGossip(f),await this.sendGraftPrune(l,h,d),this.flush(),this.mcache.shift(),this.dispatchEvent(new yd("gossipsub:heartbeat"))}getRandomGossipPeers(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0;const n=this.topics.get(e);if(null==n)return new Set;let i=[];return n.forEach((e=>{const t=this.streamsOutbound.get(e);null!=t&&this.multicodecs.includes(t.protocol)&&r(e)&&i.push(e)})),i=XW(i),t>0&&i.length>t&&(i=i.slice(0,t)),new Set(i)}onScrapeMetrics(e){var t,r;e.mcacheSize.set(this.mcache.size),e.mcacheNotValidatedCount.set(this.mcache.notValidatedCount),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},null!==(t=null===(r=this.fastMsgIdCache)||void 0===r?void 0:r.size)&&void 0!==t?t:0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);let n=0;const i=Date.now();e.connectedPeersBackoffSec.reset();for(const l of this.backoff.values()){n+=l.size;for(const[t,r]of l.entries())this.peers.has(t)&&e.connectedPeersBackoffSec.observe(Math.max(0,r-i)/1e3)}e.cacheSize.set({cache:"backoff"},n);for(const[l,h]of this.topics)e.topicPeersCount.set({topicStr:l},h.size);for(const[l,h]of this.mesh)e.meshPeerCounts.set({topicStr:l},h.size);const o=[],s=new Map;e.behaviourPenalty.reset();for(const l of this.peers.keys()){var a,c;const t=this.score.score(l);o.push(t),s.set(l,t),e.behaviourPenalty.observe(null!==(a=null===(c=this.score.peerStats.get(l))||void 0===c?void 0:c.behaviourPenalty)&&void 0!==a?a:0)}e.registerScores(o,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,s);const u=function(e,t,r,n,i){const o={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const s of e){const e=t.get(s);if(null!=e){const t=YG(s,e,r,n,i);for(const[e,r]of t.byTopic){let t=o.byTopic.get(e);null==t&&(t={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},o.byTopic.set(e,t)),t.p1w.push(r.p1w),t.p2w.push(r.p2w),t.p3w.push(r.p3w),t.p3bw.push(r.p3bw),t.p4w.push(r.p4w)}o.p5w.push(t.p5w),o.p6w.push(t.p6w),o.p7w.push(t.p7w),o.score.push(t.score)}else o.p5w.push(0),o.p6w.push(0),o.p7w.push(0),o.score.push(0)}return o}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(u)}}co(FQ,"multicodec",PH);const VQ=["/vac/waku/relay/2.0.0"],zQ=new Kl("relay");function jQ(e,t){const r=performance.now();zQ.info("validating message from ".concat(e," received on ").concat(t.topic));let n=Mz.Accept;try{const e=Ra.decode(t.data);e.contentTopic&&e.contentTopic.length&&e.payload&&e.payload.length||(n=Mz.Reject)}catch(o){n=Mz.Reject}const i=performance.now()-r;return i>100?zQ.warn("message validation took ".concat(i,"ms for peer ").concat(e," on topic ").concat(t.topic,". This should be less than 100ms.")):zQ.info("message validation took ".concat(i,"ms for peer ").concat(e," on topic ").concat(t.topic)),n}class HQ{constructor(e,t){co(this,"pubsubTopic",void 0),co(this,"proto",void 0),co(this,"payload",new Uint8Array),co(this,"rateLimitProof",void 0),co(this,"timestamp",void 0),co(this,"meta",void 0),co(this,"ephemeral",void 0),this.pubsubTopic=e,this.proto=t}get contentTopic(){return this.proto.contentTopic}}class GQ{constructor(){co(this,"pubsubTopic",Hc),co(this,"contentTopic","")}fromWireToProtoObj(e){const t=La.decode(e);return Promise.resolve({contentTopic:t.contentTopic,payload:new Uint8Array,rateLimitProof:void 0,timestamp:void 0,meta:void 0,version:void 0,ephemeral:void 0})}async fromProtoObj(e,t){return new HQ(e,t)}}const WQ=new Kl("relay");class YQ{constructor(e,t){if(co(this,"pubsubTopics",void 0),co(this,"defaultDecoder",void 0),co(this,"gossipSub",void 0),co(this,"observers",void 0),!this.isRelayPubsub(e.services.pubsub))throw Error("Failed to initialize Relay. libp2p.pubsub does not support ".concat(YQ.multicodec));this.gossipSub=e.services.pubsub,this.pubsubTopics=new Set(t),this.gossipSub.isStarted()&&this.subscribeToAllTopics(),this.observers=new Map,this.defaultDecoder=new GQ}async start(){if(this.gossipSub.isStarted())throw Error("GossipSub already started.");await this.gossipSub.start(),this.subscribeToAllTopics()}async send(e,t){const r=[],{pubsubTopic:n}=e;if(!this.pubsubTopics.has(n))return WQ.error("Failed to send waku relay: topic not configured"),{successes:r,failures:[{error:Kc.TOPIC_NOT_CONFIGURED}]};const i=await e.toWire(t);if(!i)return WQ.error("Failed to encode message, aborting publish"),{successes:r,failures:[{error:Kc.ENCODE_FAILED}]};if(!pc(i))return WQ.error("Failed to send waku relay: message is bigger that 1MB"),{successes:r,failures:[{error:Kc.SIZE_TOO_BIG}]};const{recipients:o}=await this.gossipSub.publish(n,i);return{successes:o}}subscribe(e,t){const r=[];for(const i of Array.isArray(e)?e:[e]){var n;const{pubsubTopic:e}=i,o=null!==(n=this.observers.get(e))&&void 0!==n?n:new Map,s={pubsubTopic:e,decoder:i,callback:t};Ul(o,i.contentTopic,s),this.observers.set(e,o),r.push([e,s])}return()=>{this.removeObservers(r)}}removeObservers(e){for(const[t,r]of e){const e=this.observers.get(t);if(!e)continue;const n=r.decoder.contentTopic,i=e.get(n);i&&(i.delete(r),e.set(n,i),this.observers.set(t,e))}}toSubscriptionIterator(e){return dc(this,e)}getActiveSubscriptions(){const e=new Map;for(const t of this.pubsubTopics)e.set(t,Array.from(this.observers.keys()));return e}getMeshPeers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Hc;return this.gossipSub.getMeshPeers(e)}subscribeToAllTopics(){for(const e of this.pubsubTopics)this.gossipSubSubscribe(e)}async processIncomingMessage(e,t){const r=await this.defaultDecoder.fromWireToProtoObj(t);if(!r||!r.contentTopic)return void WQ.warn("Message does not have a content topic, skipping");const n=this.observers.get(e);if(!n)return;const i=n.get(r.contentTopic);i&&await Promise.all(Array.from(i).map((n=>{let{decoder:i,callback:o}=n;return(async()=>{try{const n=await i.fromWireToProtoObj(t);if(!n)return void WQ.error("Internal error: message previously decoded failed on 2nd pass.");const s=await i.fromProtoObj(e,n);s?await o(s):WQ.error("Failed to decode messages on",r.contentTopic)}catch(n){WQ.error("Error while decoding message:",n)}})()})))}gossipSubSubscribe(e){this.gossipSub.addEventListener("gossipsub:message",(t=>{t.detail.msg.topic===e&&this.processIncomingMessage(t.detail.msg.topic,t.detail.msg.data).catch((e=>WQ.error("Failed to process incoming message",e)))})),this.gossipSub.topicValidators.set(e,jQ),this.gossipSub.subscribe(e)}isRelayPubsub(e){var t,r;return null!==(t=null===e||void 0===e||null===(r=e.multicodecs)||void 0===r?void 0:r.includes(YQ.multicodec))&&void 0!==t&&t}}co(YQ,"multicodec",VQ[0]);new Uint8Array(0);function QQ(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var JQ=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const XQ=JQ;class ZQ{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class $Q{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return tJ(this,e)}}class eJ{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return tJ(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function tJ(e,t){var r,n;return new eJ({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class rJ{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new ZQ(e,t,r),this.decoder=new $Q(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function nJ(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new rJ(t,r,n,i)}function iJ(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=XQ(n,t);return nJ({prefix:r,name:t,encode:i,decode:e=>QQ(o(e))})}function oJ(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return nJ({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const sJ=iJ({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),aJ=iJ({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var cJ=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=hJ;)r[n++]=255&t|uJ,t/=128;for(;t&lJ;)r[n++]=255&t|uJ,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},uJ=128,lJ=-128,hJ=Math.pow(2,31);var dJ=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&pJ)<<o:(n&pJ)*Math.pow(2,o),o+=7}while(n>=fJ);return e.bytes=s-r,i},fJ=128,pJ=127;var gJ=Math.pow(2,7),bJ=Math.pow(2,14),yJ=Math.pow(2,21),mJ=Math.pow(2,28),vJ=Math.pow(2,35),wJ=Math.pow(2,42),_J=Math.pow(2,49),EJ=Math.pow(2,56),SJ=Math.pow(2,63);const AJ={encode:cJ,decode:dJ,encodingLength:function(e){return e<gJ?1:e<bJ?2:e<yJ?3:e<mJ?4:e<vJ?5:e<wJ?6:e<_J?7:e<EJ?8:e<SJ?9:10}};function kJ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[AJ.decode(e,t),AJ.decode.bytes]}function xJ(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return AJ.encode(e,t,r),t}function IJ(e){return AJ.encodingLength(e)}function CJ(e,t){const r=t.byteLength,n=IJ(e),i=n+IJ(r),o=new Uint8Array(i+r);return xJ(e,o,0),xJ(r,o,n),o.set(t,i),new RJ(e,r,t,o)}function TJ(e){const t=QQ(e),[r,n]=kJ(t),[i,o]=kJ(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new RJ(r,i,s,t)}class RJ{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const PJ=QQ;const DJ={code:0,name:"identity",encode:PJ,digest:function(e){return CJ(0,PJ(e))}};function NJ(e){let{name:t,code:r,encode:n}=e;return new BJ(t,r,n)}class BJ{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?CJ(this.code,t):t.then((e=>CJ(this.code,e)))}throw Error("Unknown type, must be binary type")}}function UJ(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const LJ=NJ({name:"sha2-256",code:18,encode:UJ("SHA-256")}),MJ=NJ({name:"sha2-512",code:19,encode:UJ("SHA-512")});function OJ(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const qJ=iJ({prefix:"9",name:"base10",alphabet:"0123456789"}),KJ=oJ({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),FJ=oJ({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),VJ=oJ({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),zJ=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),jJ=zJ.reduce(((e,t,r)=>(e[r]=t,e)),[]),HJ=zJ.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const GJ=nJ({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=jJ[t]),"")},decode:function(e){const t=[];for(const r of e){const e=HJ[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),WJ=oJ({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),YJ=oJ({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),QJ=oJ({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),JJ=oJ({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),XJ=oJ({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ZJ=oJ({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$J=oJ({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),eX=oJ({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tX=oJ({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),rX=iJ({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nX=iJ({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),iX=oJ({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),oX=oJ({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sX=oJ({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),aX=oJ({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),cX=oJ({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),uX=nJ({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),lX=new TextEncoder,hX=new TextDecoder,dX="json",fX=512;function pX(e){return lX.encode(JSON.stringify(e))}function gX(e){return JSON.parse(hX.decode(e))}const bX="raw",yX=85;function mX(e){return QQ(e)}function vX(e){return QQ(e)}function wX(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==sJ.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,EX(e),null!==t&&void 0!==t?t:sJ.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,EX(e),null!==t&&void 0!==t?t:WJ.encoder)}const _X=new WeakMap;function EX(e){const t=_X.get(e);if(null==t){const t=new Map;return _X.set(e,t),t}return t}class SX{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==AX)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==kX)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return SX.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=CJ(e,t);return SX.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return SX.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return wX(this,e)}toJSON(){return{"/":wX(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof SX)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new SX(e,r,n,null!==i&&void 0!==i?i:xX(e,r,n.bytes))}if(!0===t[IX]){const{version:e,multihash:r,code:n}=t,i=TJ(r);return SX.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==AX)throw new Error("Version 0 CID must use dag-pb (code: ".concat(AX,") block encoding"));return new SX(e,t,r,r.bytes);case 1:{const n=xX(e,t,r.bytes);return new SX(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return SX.create(0,AX,e)}static createV1(e,t){return SX.create(1,e,t)}static decode(e){const[t,r]=SX.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=SX.inspectBytes(e),r=t.size-t.multihashSize,n=QQ(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new RJ(t.multihashCode,t.digestSize,i,n);return[0===t.version?SX.createV0(o):SX.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=kJ(e.subarray(t));return t+=n,r};let n=r(),i=AX;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:sJ;return[sJ.prefix,r.decode("".concat(sJ.prefix).concat(e))]}case sJ.prefix:{const r=null!==t&&void 0!==t?t:sJ;return[sJ.prefix,r.decode(e)]}case WJ.prefix:{const r=null!==t&&void 0!==t?t:WJ;return[WJ.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=SX.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return EX(i).set(r,e),i}}const AX=112,kX=18;function xX(e,t,r){const n=IJ(e),i=n+IJ(t),o=new Uint8Array(i+r.byteLength);return xJ(e,o,0),xJ(t,o,n),o.set(r,i),o}const IX=Symbol.for("@ipld/js-cid/CID"),CX={...Fr,...Ur,...Kr,...Nr,...Br,...Mr,...Or,...Rr,...qr,...Lr};function TX(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function RX(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const PX=RX("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),DX=RX("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=TX((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),NX={utf8:PX,"utf-8":PX,hex:CX.base16,latin1:DX,ascii:DX,binary:DX,...CX};function BX(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=NX[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function UX(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const LX=32,MX=64,OX=32;function qX(e,t){const r=new Uint8Array(MX);for(let n=0;n<OX;n++)r[n]=e[n],r[OX+n]=t[n];return r}function KX(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=TX(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}const FX={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},VX={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function zX(e,t){const r=function(e){var t,r,n,i,o,s;const a=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM";let c=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16;const u=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",h=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,d=null!==(s=null===e||void 0===e?void 0:e.iterations)&&void 0!==s?s:32767,f=FX.get();return c*=8,{encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(u)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=BX(t)),0===t.length){o=await f.subtle.importKey("jwk",VX,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}catch{o=await f.subtle.importKey("jwk",VX,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}const s=await f.subtle.encrypt(i,o,e);return KX([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+u),i=e.subarray(h+u),o={name:a,iv:n};let s;if("string"===typeof t&&(t=BX(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}catch{s=await f.subtle.importKey("jwk",VX,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}const p=await f.subtle.decrypt(o,s,i);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return iX.encode(n)}const jX=new Float32Array([-0]),HX=new Uint8Array(jX.buffer);function GX(e,t,r){jX[0]=e,t[r]=HX[0],t[r+1]=HX[1],t[r+2]=HX[2],t[r+3]=HX[3]}const WX=new Float64Array([-0]),YX=new Uint8Array(WX.buffer);function QX(e,t,r){WX[0]=e,t[r]=YX[0],t[r+1]=YX[1],t[r+2]=YX[2],t[r+3]=YX[3],t[r+4]=YX[4],t[r+5]=YX[5],t[r+6]=YX[6],t[r+7]=YX[7]}const JX=BigInt(Number.MAX_SAFE_INTEGER),XX=BigInt(Number.MIN_SAFE_INTEGER);class ZX{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return $X;if(e<JX&&e>XX)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>eZ&&(n=0n,++r>eZ&&(r=0n))),new ZX(Number(n),Number(r))}static fromNumber(e){if(0===e)return $X;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new ZX(r,n)}static from(e){return"number"===typeof e?ZX.fromNumber(e):"bigint"===typeof e?ZX.fromBigInt(e):"string"===typeof e?ZX.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new ZX(e.low>>>0,e.high>>>0):$X}}const $X=new ZX(0,0);$X.toBigInt=function(){return 0n},$X.zzEncode=$X.zzDecode=function(){return this},$X.length=function(){return 1};const eZ=4294967296n;function tZ(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function rZ(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function nZ(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class iZ{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,rZ(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw rZ(this,4);return nZ(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw rZ(this,4);return 0|nZ(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw rZ(this,4);const e=(t=this.buf,r=this.pos,HX[0]=t[r],HX[1]=t[r+1],HX[2]=t[r+2],HX[3]=t[r+3],jX[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw rZ(this,4);const e=(t=this.buf,r=this.pos,YX[0]=t[r],YX[1]=t[r+1],YX[2]=t[r+2],YX[3]=t[r+3],YX[4]=t[r+4],YX[5]=t[r+5],YX[6]=t[r+6],YX[7]=t[r+7],WX[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw rZ(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw rZ(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw rZ(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new ZX(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw rZ(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw rZ(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw rZ(this,8);const e=nZ(this.buf,this.pos+=4),t=nZ(this.buf,this.pos+=4);return new ZX(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function oZ(e,t,r){const n=function(e){return new iZ(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class sZ{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function aZ(){}class cZ{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const uZ=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return TX(e);i+e>t&&(n=TX(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class lZ{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new sZ(aZ,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new sZ(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new fZ((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(pZ,10,ZX.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=ZX.fromBigInt(e);return this._push(pZ,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=ZX.fromBigInt(e).zzEncode();return this._push(pZ,t.length(),t)}sint64Number(e){const t=ZX.fromNumber(e).zzEncode();return this._push(pZ,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(hZ,1,e?1:0)}fixed32(e){return this._push(gZ,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=ZX.fromBigInt(e);return this._push(gZ,4,t.lo)._push(gZ,4,t.hi)}fixed64Number(e){const t=ZX.fromNumber(e);return this._push(gZ,4,t.lo)._push(gZ,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(GX,4,e)}double(e){return this._push(QX,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(hZ,1,0):this.uint32(t)._push(bZ,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(tZ,t,e):this._push(hZ,1,0)}fork(){return this.states=new cZ(this),this.head=this.tail=new sZ(aZ,0,0),this.len=0,this}reset(){return null!=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 sZ(aZ,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?TX(r):uZ(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function hZ(e,t,r){t[r]=255&e}function dZ(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class fZ extends sZ{constructor(e,t){super(dZ,e,t),co(this,"next",void 0),this.next=void 0}}function pZ(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function gZ(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function bZ(e,t,r){t.set(e,r)}function yZ(e,t,r){t.set(e,r)}function mZ(e,t,r){e.length<40?tZ(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(BX(e),r)}function vZ(e,t){const r=new lZ;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var wZ,_Z,EZ,SZ,AZ;function kZ(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function xZ(e,t){return kZ("message",wZ.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(lZ.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(yZ,t,e),this},lZ.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(mZ,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(wZ||(wZ={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(_Z||(_Z={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(EZ||(EZ={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return kZ("enum",wZ.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(EZ)}(_Z||(_Z={})),function(e){let t;e.codec=()=>(null==t&&(t=xZ((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),_Z.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=_Z.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>vZ(t,e.codec()),e.decode=t=>oZ(t,e.codec())}(SZ||(SZ={})),function(e){let t;e.codec=()=>(null==t&&(t=xZ((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),_Z.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=_Z.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>vZ(t,e.codec()),e.decode=t=>oZ(t,e.codec())}(AZ||(AZ={}));class IZ{constructor(e){co(this,"_key",void 0),this._key=NZ(e,LX)}verify(e,t){return function(e,t,r){return Wp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return SZ.encode({Type:_Z.Ed25519,Data:this.marshal()}).subarray()}equals(e){return OJ(this.bytes,e.bytes)}hash(){const e=LJ.digest(this.bytes);return UX(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class CZ{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=NZ(e,MX),this._publicKey=NZ(t,LX)}sign(e){return function(e,t){const r=e.subarray(0,OX);return Wp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new IZ(this._publicKey)}marshal(){return this._key}get bytes(){return AZ.encode({Type:_Z.Ed25519,Data:this.marshal()}).subarray()}equals(e){return OJ(this.bytes,e.bytes)}async hash(){const e=LJ.digest(this.bytes);let t;return UX(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=DJ.digest(this.public.bytes);return sJ.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return zX(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function TZ(e){if(e.length>MX){const t=(e=NZ(e,MX+LX)).subarray(0,MX),r=e.subarray(MX,e.length);return new CZ(t,r)}const t=(e=NZ(e,MX)).subarray(0,MX),r=e.subarray(LX);return new CZ(t,r)}function RZ(e){return e=NZ(e,LX),new IZ(e)}async function PZ(){const{privateKey:e,publicKey:t}=function(){const e=Wp.utils.randomPrivateKey(),t=Wp.getPublicKey(e);return{privateKey:qX(e,t),publicKey:t}}();return new CZ(e,t)}async function DZ(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==OX)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Wp.getPublicKey(t);return{privateKey:qX(t,r),publicKey:r}}(e);return new CZ(t,r)}function NZ(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ug("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}function BZ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=NX[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}async function UZ(e){const t=[await FX.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await MZ(e)],r=await LZ({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function LZ(e){if(null==e.privateKey||null==e.publicKey)throw new ug("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([FX.get().subtle.exportKey("jwk",e.privateKey),FX.get().subtle.exportKey("jwk",e.publicKey)])}async function MZ(e){return FX.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function OZ(e){if("RSA"!==e.kty)throw new ug("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ug("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*BX(e.n,"base64url").length}function qZ(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}function KZ(e){let t=e.toString(16);t.length%2>0&&(t="0".concat(t));const r=t.length/2,n=new Uint8Array(r);let i=0,o=0;for(;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n}function FZ(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r="0".concat(r)),t.push(r)})),BigInt("0x"+t.join(""))}const VZ=32,zZ=1e4;const jZ=8192;class HZ{constructor(e){co(this,"_key",void 0),this._key=e}verify(e,t){return async function(e,t,r){const n=await FX.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return FX.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new zU({valueHex:new rL({value:[YU.fromBigInt(FZ(BX(e.n,"base64url"))),YU.fromBigInt(FZ(BX(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return SZ.encode({Type:_Z.RSA,Data:this.marshal()}).subarray()}equals(e){return OJ(this.bytes,e.bytes)}hash(){const e=LJ.digest(this.bytes);return UX(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class GZ{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return qZ(16)}sign(e){return async function(e,t){const r=await FX.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await FX.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ug("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new HZ(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new YU({value:0}),YU.fromBigInt(FZ(BX(e.n,"base64url"))),YU.fromBigInt(FZ(BX(e.e,"base64url"))),YU.fromBigInt(FZ(BX(e.d,"base64url"))),YU.fromBigInt(FZ(BX(e.p,"base64url"))),YU.fromBigInt(FZ(BX(e.q,"base64url"))),YU.fromBigInt(FZ(BX(e.dp,"base64url"))),YU.fromBigInt(FZ(BX(e.dq,"base64url"))),YU.fromBigInt(FZ(BX(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return AZ.encode({Type:_Z.RSA,Data:this.marshal()}).subarray()}equals(e){return OJ(this.bytes,e.bytes)}hash(){const e=LJ.digest(this.bytes);return UX(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return BZ(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=FX.get(),n=new rL({value:[new YU({value:0}),new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new FU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),o=qZ(16),s=await EB(Nf,t,o,{c:zZ,dkLen:VZ}),a=qZ(16),c=await r.subtle.importKey("raw",s,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new rL({value:[new FU({valueHex:o}),new YU({value:zZ}),new YU({value:VZ}),new rL({value:[new ZU({value:"1.2.840.113549.2.11"}),new MU]})]}),h=new rL({value:[new ZU({value:"1.2.840.113549.1.5.13"}),new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.5.12"}),l]}),new rL({value:[new ZU({value:"2.16.840.1.101.3.4.1.42"}),new FU({valueHex:a})]})]})]}),d=new rL({value:[h,new FU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...BZ(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return zX(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function WZ(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value;return{n:BZ(KZ(r[1].toBigInt()),"base64url"),e:BZ(KZ(r[2].toBigInt()),"base64url"),d:BZ(KZ(r[3].toBigInt()),"base64url"),p:BZ(KZ(r[4].toBigInt()),"base64url"),q:BZ(KZ(r[5].toBigInt()),"base64url"),dp:BZ(KZ(r[6].toBigInt()),"base64url"),dq:BZ(KZ(r[7].toBigInt()),"base64url"),qi:BZ(KZ(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(OZ(t)>jZ)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await UZ(t);return new GZ(r.privateKey,r.publicKey)}function YZ(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:BZ(KZ(r[0].toBigInt()),"base64url"),e:BZ(KZ(r[1].toBigInt()),"base64url")}}(e);if(OZ(t)>jZ)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new HZ(t)}async function QZ(e){if(OZ(e)>jZ)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await UZ(e);return new GZ(t.privateKey,t.publicKey)}async function JZ(e){if(e>jZ)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await FX.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await LZ(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new GZ(t.privateKey,t.publicKey)}function XZ(e){try{Am.ProjectivePoint.fromHex(e)}catch(t){throw new ug(String(t),"ERR_INVALID_PUBLIC_KEY")}}class ZZ{constructor(e){co(this,"_key",void 0),XZ(e),this._key=e}verify(e,t){return function(e,t,r){const n=LJ.digest(r instanceof Uint8Array?r:r.subarray());if(UX(n))return n.then((r=>{let{digest:n}=r;return Am.verify(t,n,e)})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.verify(t,n.digest,e)}catch(i){throw new ug(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,Am.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return SZ.encode({Type:_Z.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return OJ(this.bytes,e.bytes)}async hash(){const e=LJ.digest(this.bytes);let t;return UX(e)?({bytes:t}=await e):t=e.bytes,t}}class $Z{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),XZ(this._publicKey)}sign(e){return function(e,t){const r=LJ.digest(t instanceof Uint8Array?t:t.subarray());if(UX(r))return r.then((t=>{let{digest:r}=t;return Am.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.sign(r.digest,e).toDERRawBytes()}catch(n){throw new ug(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new ZZ(this._publicKey)}marshal(){return this._key}get bytes(){return AZ.encode({Type:_Z.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return OJ(this.bytes,e.bytes)}hash(){const e=LJ.digest(this.bytes);return UX(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return BZ(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return zX(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function e$(e){return new $Z(e)}function t$(e){return new ZZ(e)}async function r$(){const e=Am.utils.randomPrivateKey();return new $Z(e)}const n$={rsa:Hr,ed25519:jr,secp256k1:Gr};function i$(e){const t=Object.keys(n$).join(" / ");return new ug("invalid or unsupported key type ".concat(e,". Must be ").concat(t),"ERR_UNSUPPORTED_KEY_TYPE")}async function o$(e){var t,r;const n=AZ.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case _Z.RSA:return n$.rsa.unmarshalRsaPrivateKey(i);case _Z.Ed25519:return n$.ed25519.unmarshalEd25519PrivateKey(i);case _Z.Secp256k1:return n$.secp256k1.unmarshalSecp256k1PrivateKey(i);default:throw i$(null!==(r=n.Type)&&void 0!==r?r:"RSA")}}const s$=Symbol.for("@libp2p/content-routing"),a$=Symbol.for("@libp2p/peer-routing");function c$(){return{forComponent:e=>u$(e)}}function u$(e){let t=function(e){const t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}("".concat(e,":trace"));return Ol.enabled("".concat(e,":trace"))&&null!=Ol.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=Ol("".concat(e,":trace"))),Object.assign(Ol(e),{error:Ol("".concat(e,":error")),trace:t})}Ol.formatters.b=e=>null==e?"undefined":sJ.baseEncode(e),Ol.formatters.t=e=>null==e?"undefined":WJ.baseEncode(e),Ol.formatters.m=e=>null==e?"undefined":iX.baseEncode(e),Ol.formatters.p=e=>null==e?"undefined":e.toString(),Ol.formatters.c=e=>null==e?"undefined":e.toString(),Ol.formatters.k=e=>null==e?"undefined":e.toString(),Ol.formatters.a=e=>null==e?"undefined":e.toString();new Uint8Array(0);function l$(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var h$=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const d$=h$;class f${constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class p${constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return b$(this,e)}}class g${constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return b$(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function b$(e,t){var r,n;return new g$({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class y${constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new f$(e,t,r),this.decoder=new p$(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function m$(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new y$(t,r,n,i)}function v$(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=d$(n,t);return m$({prefix:r,name:t,encode:i,decode:e=>l$(o(e))})}function w$(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return m$({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const _$=v$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),E$=v$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),S$=v$({prefix:"9",name:"base10",alphabet:"0123456789"}),A$=w$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),k$=w$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),x$=w$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),I$=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),C$=I$.reduce(((e,t,r)=>(e[r]=t,e)),[]),T$=I$.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const R$=m$({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=C$[t]),"")},decode:function(e){const t=[];for(const r of e){const e=T$[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),P$=w$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),D$=w$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),N$=w$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),B$=w$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),U$=w$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),L$=w$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),M$=w$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),O$=w$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),q$=w$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),K$=v$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),F$=v$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),V$=w$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),z$=w$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),j$=w$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),H$=w$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),G$=w$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),W$=m$({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Y$=new TextEncoder,Q$=new TextDecoder,J$="json",X$=512;function Z$(e){return Y$.encode(JSON.stringify(e))}function $$(e){return JSON.parse(Q$.decode(e))}const e0="raw",t0=85;function r0(e){return l$(e)}function n0(e){return l$(e)}var i0=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=a0;)r[n++]=255&t|o0,t/=128;for(;t&s0;)r[n++]=255&t|o0,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},o0=128,s0=-128,a0=Math.pow(2,31);var c0=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&l0)<<o:(n&l0)*Math.pow(2,o),o+=7}while(n>=u0);return e.bytes=s-r,i},u0=128,l0=127;var h0=Math.pow(2,7),d0=Math.pow(2,14),f0=Math.pow(2,21),p0=Math.pow(2,28),g0=Math.pow(2,35),b0=Math.pow(2,42),y0=Math.pow(2,49),m0=Math.pow(2,56),v0=Math.pow(2,63);const w0={encode:i0,decode:c0,encodingLength:function(e){return e<h0?1:e<d0?2:e<f0?3:e<p0?4:e<g0?5:e<b0?6:e<y0?7:e<m0?8:e<v0?9:10}};function _0(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[w0.decode(e,t),w0.decode.bytes]}function E0(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return w0.encode(e,t,r),t}function S0(e){return w0.encodingLength(e)}function A0(e,t){const r=t.byteLength,n=S0(e),i=n+S0(r),o=new Uint8Array(i+r);return E0(e,o,0),E0(r,o,n),o.set(t,i),new x0(e,r,t,o)}function k0(e){const t=l$(e),[r,n]=_0(t),[i,o]=_0(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new x0(r,i,s,t)}class x0{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const I0=l$;const C0={code:0,name:"identity",encode:I0,digest:function(e){return A0(0,I0(e))}};function T0(e){let{name:t,code:r,encode:n}=e;return new R0(t,r,n)}class R0{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?A0(this.code,t):t.then((e=>A0(this.code,e)))}throw Error("Unknown type, must be binary type")}}function P0(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const D0=T0({name:"sha2-256",code:18,encode:P0("SHA-256")}),N0=T0({name:"sha2-512",code:19,encode:P0("SHA-512")});function B0(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==_$.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,L0(e),null!==t&&void 0!==t?t:_$.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,L0(e),null!==t&&void 0!==t?t:P$.encoder)}const U0=new WeakMap;function L0(e){const t=U0.get(e);if(null==t){const t=new Map;return U0.set(e,t),t}return t}class M0{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==O0)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==q0)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return M0.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=A0(e,t);return M0.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return M0.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return B0(this,e)}toJSON(){return{"/":B0(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof M0)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new M0(e,r,n,null!==i&&void 0!==i?i:K0(e,r,n.bytes))}if(!0===t[F0]){const{version:e,multihash:r,code:n}=t,i=k0(r);return M0.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==O0)throw new Error("Version 0 CID must use dag-pb (code: ".concat(O0,") block encoding"));return new M0(e,t,r,r.bytes);case 1:{const n=K0(e,t,r.bytes);return new M0(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return M0.create(0,O0,e)}static createV1(e,t){return M0.create(1,e,t)}static decode(e){const[t,r]=M0.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=M0.inspectBytes(e),r=t.size-t.multihashSize,n=l$(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new x0(t.multihashCode,t.digestSize,i,n);return[0===t.version?M0.createV0(o):M0.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=_0(e.subarray(t));return t+=n,r};let n=r(),i=O0;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:_$;return[_$.prefix,r.decode("".concat(_$.prefix).concat(e))]}case _$.prefix:{const r=null!==t&&void 0!==t?t:_$;return[_$.prefix,r.decode(e)]}case P$.prefix:{const r=null!==t&&void 0!==t?t:P$;return[P$.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=M0.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return L0(i).set(r,e),i}}const O0=112,q0=18;function K0(e,t,r){const n=S0(e),i=n+S0(t),o=new Uint8Array(i+r.byteLength);return E0(e,o,0),E0(t,o,n),o.set(r,i),o}const F0=Symbol.for("@ipld/js-cid/CID"),V0={...rn,...Jr,...tn,...Yr,...Qr,...Zr,...$r,...Wr,...en,...Xr};function z0(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const j0=Symbol.for("nodejs.util.inspect.custom"),H0=Object.values(V0).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),V0.identity.decoder),G0=114,W0=36,Y0=37;class Q0{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=_$.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return M0.createV1(G0,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return z0(this.multihash.bytes,e);if("string"===typeof e)return $0(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return z0(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[j0](){return"PeerId(".concat(this.toString(),")")}}class J0 extends Q0{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class X0 extends Q0{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class Z0 extends Q0{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function $0(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:H0,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=k0(_$.decode("z".concat(e)));return e.startsWith("12D")?new X0({multihash:t}):e.startsWith("16U")?new Z0({multihash:t}):new J0({multihash:t})}return function(e){try{const t=k0(e);if(t.code===C0.code){if(t.digest.length===W0)return new X0({multihash:t});if(t.digest.length===Y0)return new Z0({multihash:t})}if(t.code===D0.code)return new J0({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==G0)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===D0.code)return new J0({multihash:e.multihash});if(t.code===C0.code){if(t.digest.length===W0)return new X0({multihash:e.multihash});if(t.digest.length===Y0)return new Z0({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(M0.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(H0.decode(e))}function e1(e,t){const r={[Symbol.iterator]:()=>r,next:()=>{const r=e.next(),n=r.value;if(!0===r.done||null==n){return{done:!0,value:void 0}}return{done:!1,value:t(n)}}};return r}class t1{constructor(e){if(co(this,"set",void 0),this.set=new Set,null!=e)for(const t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return e1(this.set.entries(),(e=>{const t=$0(e[0]);return[t,t]}))}forEach(e){this.set.forEach((t=>{const r=$0(t);e(r,r,this)}))}has(e){return this.set.has(e.toString())}values(){return e1(this.set.values(),(e=>$0(e)))}intersection(e){const t=new t1;for(const r of e)this.has(r)&&t.add(r);return t}difference(e){const t=new t1;for(const r of this)e.has(r)||t.add(r);return t}union(e){const t=new t1;for(const r of e)t.add(r);for(const r of this)t.add(r);return t}}const r1=Symbol.for("nodejs.util.inspect.custom"),n1=Object.values(CX).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),CX.identity.decoder),i1=114,o1=36,s1=37;class a1{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=sJ.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return SX.createV1(i1,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return OJ(this.multihash.bytes,e);if("string"===typeof e)return h1(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return OJ(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[r1](){return"PeerId(".concat(this.toString(),")")}}class c1 extends a1{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class u1 extends a1{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class l1 extends a1{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function h1(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:n1,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=TJ(sJ.decode("z".concat(e)));return e.startsWith("12D")?new u1({multihash:t}):e.startsWith("16U")?new l1({multihash:t}):new c1({multihash:t})}return function(e){try{const t=TJ(e);if(t.code===DJ.code){if(t.digest.length===o1)return new u1({multihash:t});if(t.digest.length===s1)return new l1({multihash:t})}if(t.code===LJ.code)return new c1({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==i1)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===LJ.code)return new c1({multihash:e.multihash});if(t.code===DJ.code){if(t.digest.length===o1)return new u1({multihash:e.multihash});if(t.digest.length===s1)return new l1({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(SX.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(n1.decode(e))}new Uint8Array(0);function d1(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var f1=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const p1=f1;class g1{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class b1{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return m1(this,e)}}class y1{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return m1(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function m1(e,t){var r,n;return new y1({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class v1{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new g1(e,t,r),this.decoder=new b1(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function w1(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new v1(t,r,n,i)}function _1(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=p1(n,t);return w1({prefix:r,name:t,encode:i,decode:e=>d1(o(e))})}function E1(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return w1({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const S1=_1({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),A1=_1({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var k1=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=C1;)r[n++]=255&t|x1,t/=128;for(;t&I1;)r[n++]=255&t|x1,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},x1=128,I1=-128,C1=Math.pow(2,31);var T1=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&P1)<<o:(n&P1)*Math.pow(2,o),o+=7}while(n>=R1);return e.bytes=s-r,i},R1=128,P1=127;var D1=Math.pow(2,7),N1=Math.pow(2,14),B1=Math.pow(2,21),U1=Math.pow(2,28),L1=Math.pow(2,35),M1=Math.pow(2,42),O1=Math.pow(2,49),q1=Math.pow(2,56),K1=Math.pow(2,63);const F1={encode:k1,decode:T1,encodingLength:function(e){return e<D1?1:e<N1?2:e<B1?3:e<U1?4:e<L1?5:e<M1?6:e<O1?7:e<q1?8:e<K1?9:10}};function V1(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[F1.decode(e,t),F1.decode.bytes]}function z1(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return F1.encode(e,t,r),t}function j1(e){return F1.encodingLength(e)}function H1(e,t){const r=t.byteLength,n=j1(e),i=n+j1(r),o=new Uint8Array(i+r);return z1(e,o,0),z1(r,o,n),o.set(t,i),new W1(e,r,t,o)}function G1(e){const t=d1(e),[r,n]=V1(t),[i,o]=V1(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new W1(r,i,s,t)}class W1{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Y1=d1;const Q1={code:0,name:"identity",encode:Y1,digest:function(e){return H1(0,Y1(e))}};function J1(e){let{name:t,code:r,encode:n}=e;return new X1(t,r,n)}class X1{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?H1(this.code,t):t.then((e=>H1(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Z1(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const $1=J1({name:"sha2-256",code:18,encode:Z1("SHA-256")}),e2=J1({name:"sha2-512",code:19,encode:Z1("SHA-512")});function t2(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const r2=_1({prefix:"9",name:"base10",alphabet:"0123456789"}),n2=E1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),i2=E1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),o2=E1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),s2=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),a2=s2.reduce(((e,t,r)=>(e[r]=t,e)),[]),c2=s2.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const u2=w1({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=a2[t]),"")},decode:function(e){const t=[];for(const r of e){const e=c2[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),l2=E1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),h2=E1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),d2=E1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),f2=E1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),p2=E1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),g2=E1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),b2=E1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),y2=E1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),m2=E1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),v2=_1({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),w2=_1({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),_2=E1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),E2=E1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),S2=E1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),A2=E1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),k2=E1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),x2=w1({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),I2=new TextEncoder,C2=new TextDecoder,T2="json",R2=512;function P2(e){return I2.encode(JSON.stringify(e))}function D2(e){return JSON.parse(C2.decode(e))}const N2="raw",B2=85;function U2(e){return d1(e)}function L2(e){return d1(e)}function M2(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==S1.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,q2(e),null!==t&&void 0!==t?t:S1.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,q2(e),null!==t&&void 0!==t?t:l2.encoder)}const O2=new WeakMap;function q2(e){const t=O2.get(e);if(null==t){const t=new Map;return O2.set(e,t),t}return t}class K2{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==F2)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==V2)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return K2.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=H1(e,t);return K2.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return K2.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return M2(this,e)}toJSON(){return{"/":M2(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof K2)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new K2(e,r,n,null!==i&&void 0!==i?i:z2(e,r,n.bytes))}if(!0===t[j2]){const{version:e,multihash:r,code:n}=t,i=G1(r);return K2.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==F2)throw new Error("Version 0 CID must use dag-pb (code: ".concat(F2,") block encoding"));return new K2(e,t,r,r.bytes);case 1:{const n=z2(e,t,r.bytes);return new K2(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return K2.create(0,F2,e)}static createV1(e,t){return K2.create(1,e,t)}static decode(e){const[t,r]=K2.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=K2.inspectBytes(e),r=t.size-t.multihashSize,n=d1(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new W1(t.multihashCode,t.digestSize,i,n);return[0===t.version?K2.createV0(o):K2.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=V1(e.subarray(t));return t+=n,r};let n=r(),i=F2;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:S1;return[S1.prefix,r.decode("".concat(S1.prefix).concat(e))]}case S1.prefix:{const r=null!==t&&void 0!==t?t:S1;return[S1.prefix,r.decode(e)]}case l2.prefix:{const r=null!==t&&void 0!==t?t:l2;return[l2.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=K2.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return q2(i).set(r,e),i}}const F2=112,V2=18;function z2(e,t,r){const n=j1(e),i=n+j1(t),o=new Uint8Array(i+r.byteLength);return z1(e,o,0),z1(t,o,n),o.set(r,i),o}const j2=Symbol.for("@ipld/js-cid/CID"),H2={...vn,...fn,...mn,...hn,...dn,...gn,...bn,...cn,...yn,...pn};function G2(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function W2(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Y2=W2("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Q2=W2("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=G2((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),J2={utf8:Y2,"utf-8":Y2,hex:H2.base16,latin1:Q2,ascii:Q2,binary:Q2,...H2};function X2(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=J2[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function Z2(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const $2=32,e3=64,t3=32;function r3(e,t){const r=new Uint8Array(e3);for(let n=0;n<t3;n++)r[n]=e[n],r[t3+n]=t[n];return r}const n3={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},i3={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function o3(e){var t,r,n,i,o,s;const a=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM";let c=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16;const u=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",h=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,d=null!==(s=null===e||void 0===e?void 0:e.iterations)&&void 0!==s?s:32767,f=n3.get();c*=8;const p={encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(u)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=X2(t)),0===t.length){o=await f.subtle.importKey("jwk",i3,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}catch{o=await f.subtle.importKey("jwk",i3,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}const s=await f.subtle.encrypt(i,o,e);return function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=G2(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+u),i=e.subarray(h+u),o={name:a,iv:n};let s;if("string"===typeof t&&(t=X2(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}catch{s=await f.subtle.importKey("jwk",i3,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}const p=await f.subtle.decrypt(o,s,i);return new Uint8Array(p)}};return p}async function s3(e,t){const r=o3(),n=await r.encrypt(e,t);return _2.encode(n)}const a3=new Float32Array([-0]),c3=new Uint8Array(a3.buffer);function u3(e,t,r){a3[0]=e,t[r]=c3[0],t[r+1]=c3[1],t[r+2]=c3[2],t[r+3]=c3[3]}const l3=new Float64Array([-0]),h3=new Uint8Array(l3.buffer);function d3(e,t,r){l3[0]=e,t[r]=h3[0],t[r+1]=h3[1],t[r+2]=h3[2],t[r+3]=h3[3],t[r+4]=h3[4],t[r+5]=h3[5],t[r+6]=h3[6],t[r+7]=h3[7]}const f3=BigInt(Number.MAX_SAFE_INTEGER),p3=BigInt(Number.MIN_SAFE_INTEGER);class g3{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return b3;if(e<f3&&e>p3)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>y3&&(n=0n,++r>y3&&(r=0n))),new g3(Number(n),Number(r))}static fromNumber(e){if(0===e)return b3;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new g3(r,n)}static from(e){return"number"===typeof e?g3.fromNumber(e):"bigint"===typeof e?g3.fromBigInt(e):"string"===typeof e?g3.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new g3(e.low>>>0,e.high>>>0):b3}}const b3=new g3(0,0);b3.toBigInt=function(){return 0n},b3.zzEncode=b3.zzDecode=function(){return this},b3.length=function(){return 1};const y3=4294967296n;function m3(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function v3(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function w3(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class _3{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,v3(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw v3(this,4);return w3(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw v3(this,4);return 0|w3(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw v3(this,4);const e=(t=this.buf,r=this.pos,c3[0]=t[r],c3[1]=t[r+1],c3[2]=t[r+2],c3[3]=t[r+3],a3[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw v3(this,4);const e=(t=this.buf,r=this.pos,h3[0]=t[r],h3[1]=t[r+1],h3[2]=t[r+2],h3[3]=t[r+3],h3[4]=t[r+4],h3[5]=t[r+5],h3[6]=t[r+6],h3[7]=t[r+7],l3[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw v3(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw v3(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw v3(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new g3(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw v3(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw v3(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw v3(this,8);const e=w3(this.buf,this.pos+=4),t=w3(this.buf,this.pos+=4);return new g3(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function E3(e,t,r){const n=function(e){return new _3(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class S3{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function A3(){}class k3{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const x3=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return G2(e);i+e>t&&(n=G2(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class I3{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new S3(A3,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new S3(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new R3((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(P3,10,g3.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=g3.fromBigInt(e);return this._push(P3,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=g3.fromBigInt(e).zzEncode();return this._push(P3,t.length(),t)}sint64Number(e){const t=g3.fromNumber(e).zzEncode();return this._push(P3,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(C3,1,e?1:0)}fixed32(e){return this._push(D3,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=g3.fromBigInt(e);return this._push(D3,4,t.lo)._push(D3,4,t.hi)}fixed64Number(e){const t=g3.fromNumber(e);return this._push(D3,4,t.lo)._push(D3,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(u3,4,e)}double(e){return this._push(d3,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(C3,1,0):this.uint32(t)._push(N3,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(m3,t,e):this._push(C3,1,0)}fork(){return this.states=new k3(this),this.head=this.tail=new S3(A3,0,0),this.len=0,this}reset(){return null!=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 S3(A3,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?G2(r):x3(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function C3(e,t,r){t[r]=255&e}function T3(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class R3 extends S3{constructor(e,t){super(T3,e,t),co(this,"next",void 0),this.next=void 0}}function P3(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function D3(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function N3(e,t,r){t.set(e,r)}function B3(e,t,r){t.set(e,r)}function U3(e,t,r){e.length<40?m3(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(X2(e),r)}function L3(e,t){const r=new I3;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var M3,O3,q3,K3,F3;function V3(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function z3(e,t){return V3("message",M3.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(I3.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(B3,t,e),this},I3.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(U3,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(M3||(M3={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(O3||(O3={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(q3||(q3={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return V3("enum",M3.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(q3)}(O3||(O3={})),function(e){let t;e.codec=()=>(null==t&&(t=z3((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),O3.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=O3.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>L3(t,e.codec()),e.decode=t=>E3(t,e.codec())}(K3||(K3={})),function(e){let t;e.codec=()=>(null==t&&(t=z3((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),O3.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=O3.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>L3(t,e.codec()),e.decode=t=>E3(t,e.codec())}(F3||(F3={}));class j3{constructor(e){co(this,"_key",void 0),this._key=J3(e,$2)}verify(e,t){return function(e,t,r){return Wp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return K3.encode({Type:O3.Ed25519,Data:this.marshal()}).subarray()}equals(e){return t2(this.bytes,e.bytes)}hash(){const e=$1.digest(this.bytes);return Z2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class H3{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=J3(e,e3),this._publicKey=J3(t,$2)}sign(e){return function(e,t){const r=e.subarray(0,t3);return Wp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new j3(this._publicKey)}marshal(){return this._key}get bytes(){return F3.encode({Type:O3.Ed25519,Data:this.marshal()}).subarray()}equals(e){return t2(this.bytes,e.bytes)}async hash(){const e=$1.digest(this.bytes);let t;return Z2(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=Q1.digest(this.public.bytes);return S1.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return s3(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function G3(e){if(e.length>e3){const t=(e=J3(e,e3+$2)).subarray(0,e3),r=e.subarray(e3,e.length);return new H3(t,r)}const t=(e=J3(e,e3)).subarray(0,e3),r=e.subarray($2);return new H3(t,r)}function W3(e){return e=J3(e,$2),new j3(e)}async function Y3(){const{privateKey:e,publicKey:t}=function(){const e=Wp.utils.randomPrivateKey(),t=Wp.getPublicKey(e);return{privateKey:r3(e,t),publicKey:t}}();return new H3(e,t)}async function Q3(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==t3)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Wp.getPublicKey(t);return{privateKey:r3(t,r),publicKey:r}}(e);return new H3(t,r)}function J3(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ug("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}function X3(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=J2[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}async function Z3(e){const t=[await n3.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await e6(e)],r=await $3({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function $3(e){if(null==e.privateKey||null==e.publicKey)throw new ug("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([n3.get().subtle.exportKey("jwk",e.privateKey),n3.get().subtle.exportKey("jwk",e.publicKey)])}async function e6(e){return n3.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function t6(e){if("RSA"!==e.kty)throw new ug("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ug("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*X2(e.n,"base64url").length}function r6(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}function n6(e){let t=e.toString(16);t.length%2>0&&(t="0".concat(t));const r=t.length/2,n=new Uint8Array(r);let i=0,o=0;for(;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n}function i6(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r="0".concat(r)),t.push(r)})),BigInt("0x"+t.join(""))}const o6=32,s6=1e4;const a6=8192;class c6{constructor(e){co(this,"_key",void 0),this._key=e}verify(e,t){return async function(e,t,r){const n=await n3.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return n3.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new zU({valueHex:new rL({value:[YU.fromBigInt(i6(X2(e.n,"base64url"))),YU.fromBigInt(i6(X2(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return K3.encode({Type:O3.RSA,Data:this.marshal()}).subarray()}equals(e){return t2(this.bytes,e.bytes)}hash(){const e=$1.digest(this.bytes);return Z2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class u6{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return r6(16)}sign(e){return async function(e,t){const r=await n3.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await n3.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ug("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new c6(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new YU({value:0}),YU.fromBigInt(i6(X2(e.n,"base64url"))),YU.fromBigInt(i6(X2(e.e,"base64url"))),YU.fromBigInt(i6(X2(e.d,"base64url"))),YU.fromBigInt(i6(X2(e.p,"base64url"))),YU.fromBigInt(i6(X2(e.q,"base64url"))),YU.fromBigInt(i6(X2(e.dp,"base64url"))),YU.fromBigInt(i6(X2(e.dq,"base64url"))),YU.fromBigInt(i6(X2(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return F3.encode({Type:O3.RSA,Data:this.marshal()}).subarray()}equals(e){return t2(this.bytes,e.bytes)}hash(){const e=$1.digest(this.bytes);return Z2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return X3(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=n3.get(),n=new rL({value:[new YU({value:0}),new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new FU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),o=r6(16),s=await EB(Nf,t,o,{c:s6,dkLen:o6}),a=r6(16),c=await r.subtle.importKey("raw",s,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new rL({value:[new FU({valueHex:o}),new YU({value:s6}),new YU({value:o6}),new rL({value:[new ZU({value:"1.2.840.113549.2.11"}),new MU]})]}),h=new rL({value:[new ZU({value:"1.2.840.113549.1.5.13"}),new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.5.12"}),l]}),new rL({value:[new ZU({value:"2.16.840.1.101.3.4.1.42"}),new FU({valueHex:a})]})]})]}),d=new rL({value:[h,new FU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...X3(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return s3(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function l6(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value;return{n:X3(n6(r[1].toBigInt()),"base64url"),e:X3(n6(r[2].toBigInt()),"base64url"),d:X3(n6(r[3].toBigInt()),"base64url"),p:X3(n6(r[4].toBigInt()),"base64url"),q:X3(n6(r[5].toBigInt()),"base64url"),dp:X3(n6(r[6].toBigInt()),"base64url"),dq:X3(n6(r[7].toBigInt()),"base64url"),qi:X3(n6(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(t6(t)>a6)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await Z3(t);return new u6(r.privateKey,r.publicKey)}function h6(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:X3(n6(r[0].toBigInt()),"base64url"),e:X3(n6(r[1].toBigInt()),"base64url")}}(e);if(t6(t)>a6)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new c6(t)}async function d6(e){if(t6(e)>a6)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await Z3(e);return new u6(t.privateKey,t.publicKey)}async function f6(e){if(e>a6)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await n3.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await $3(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new u6(t.privateKey,t.publicKey)}function p6(e){try{Am.ProjectivePoint.fromHex(e)}catch(t){throw new ug(String(t),"ERR_INVALID_PUBLIC_KEY")}}class g6{constructor(e){co(this,"_key",void 0),p6(e),this._key=e}verify(e,t){return function(e,t,r){const n=$1.digest(r instanceof Uint8Array?r:r.subarray());if(Z2(n))return n.then((r=>{let{digest:n}=r;return Am.verify(t,n,e)})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.verify(t,n.digest,e)}catch(i){throw new ug(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,Am.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return K3.encode({Type:O3.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return t2(this.bytes,e.bytes)}async hash(){const e=$1.digest(this.bytes);let t;return Z2(e)?({bytes:t}=await e):t=e.bytes,t}}class b6{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),p6(this._publicKey)}sign(e){return function(e,t){const r=$1.digest(t instanceof Uint8Array?t:t.subarray());if(Z2(r))return r.then((t=>{let{digest:r}=t;return Am.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.sign(r.digest,e).toDERRawBytes()}catch(n){throw new ug(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new g6(this._publicKey)}marshal(){return this._key}get bytes(){return F3.encode({Type:O3.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return t2(this.bytes,e.bytes)}hash(){const e=$1.digest(this.bytes);return Z2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return X3(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return s3(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function y6(e){return new b6(e)}function m6(e){return new g6(e)}async function v6(){const e=Am.utils.randomPrivateKey();return new b6(e)}const w6={rsa:Sn,ed25519:En,secp256k1:An};function _6(e){const t=Object.keys(w6).join(" / ");return new ug("invalid or unsupported key type ".concat(e,". Must be ").concat(t),"ERR_UNSUPPORTED_KEY_TYPE")}function E6(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return w6[e];throw _6(e)}function S6(e,t){var r;return E6(t=(null!==(r=t)&&void 0!==r?r:"rsa").toLowerCase()),e.bytes}async function A6(e){var t,r;const n=F3.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case O3.RSA:return w6.rsa.unmarshalRsaPrivateKey(i);case O3.Ed25519:return w6.ed25519.unmarshalEd25519PrivateKey(i);case O3.Secp256k1:return w6.secp256k1.unmarshalSecp256k1PrivateKey(i);default:throw _6(null!==(r=n.Type)&&void 0!==r?r:"RSA")}}const k6=Symbol.for("nodejs.util.inspect.custom"),x6=Object.values(H2).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),H2.identity.decoder),I6=114,C6=36,T6=37;class R6{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=S1.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return K2.createV1(I6,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return t2(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:x6,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=G1(S1.decode("z".concat(e)));return e.startsWith("12D")?new D6({multihash:t}):e.startsWith("16U")?new N6({multihash:t}):new P6({multihash:t})}return B6(x6.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return t2(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[k6](){return"PeerId(".concat(this.toString(),")")}}class P6 extends R6{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class D6 extends R6{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class N6 extends R6{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function B6(e){try{const t=G1(e);if(t.code===Q1.code){if(t.digest.length===C6)return new D6({multihash:t});if(t.digest.length===T6)return new N6({multihash:t})}if(t.code===$1.code)return new P6({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==I6)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===$1.code)return new P6({multihash:e.multihash});if(t.code===Q1.code){if(t.digest.length===C6)return new D6({multihash:e.multihash});if(t.digest.length===T6)return new N6({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(K2.decode(e))}throw new Error("Supplied PeerID CID is invalid")}async function U6(e,t){return e.length===C6?new D6({multihash:H1(Q1.code,e),privateKey:t}):e.length===T6?new N6({multihash:H1(Q1.code,e),privateKey:t}):new P6({multihash:await $1.digest(e),publicKey:e,privateKey:t})}const L6=async()=>{const e=await async function(e,t){return E6(e).generateKeyPair(null!==t&&void 0!==t?t:2048)}("Ed25519"),t=await M6(e);if("Ed25519"===t.type)return t;throw new Error('Generated unexpected PeerId type "'.concat(t.type,'"'))};async function M6(e){return U6(S6(e.public),function(e,t){var r;return E6(t=(null!==(r=t)&&void 0!==r?r:"rsa").toLowerCase()),e.bytes}(e))}async function O6(e){return q6(X2(e.id,"base58btc"),null!=e.privKey?X2(e.privKey,"base64pad"):void 0,null!=e.pubKey?X2(e.pubKey,"base64pad"):void 0)}async function q6(e,t,r){if(null!=t){return M6(await A6(t))}if(null!=r){return async function(e){return U6(S6(e))}(function(e){var t,r;const n=K3.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case O3.RSA:return w6.rsa.unmarshalRsaPublicKey(i);case O3.Ed25519:return w6.ed25519.unmarshalEd25519PublicKey(i);case O3.Secp256k1:return w6.secp256k1.unmarshalSecp256k1PublicKey(i);default:throw _6(null!==(r=n.Type)&&void 0!==r?r:"unknown")}}(r))}return B6(e)}class K6{constructor(e){if(co(this,"map",void 0),this.map=new Map,null!=e)for(const[t,r]of e.entries())this.map.set(t.toString(),r)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){return this.map.delete(e.toString())}entries(){return e1(this.map.entries(),(e=>[$0(e[0]),e[1]]))}forEach(e){this.map.forEach(((t,r)=>{e(t,$0(r),this)}))}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return e1(this.map.keys(),(e=>$0(e)))}values(){return this.map.values()}get size(){return this.map.size}}new Uint8Array(0);function F6(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var V6=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const z6=V6;class j6{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class H6{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return W6(this,e)}}class G6{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return W6(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function W6(e,t){var r,n;return new G6({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Y6{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new j6(e,t,r),this.decoder=new H6(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Q6(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Y6(t,r,n,i)}function J6(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=z6(n,t);return Q6({prefix:r,name:t,encode:i,decode:e=>F6(o(e))})}function X6(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Q6({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Z6=J6({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$6=J6({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),e4=J6({prefix:"9",name:"base10",alphabet:"0123456789"}),t4=X6({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),r4=X6({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),n4=X6({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),i4=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),o4=i4.reduce(((e,t,r)=>(e[r]=t,e)),[]),s4=i4.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const a4=Q6({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=o4[t]),"")},decode:function(e){const t=[];for(const r of e){const e=s4[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),c4=X6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),u4=X6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),l4=X6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),h4=X6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),d4=X6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),f4=X6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),p4=X6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),g4=X6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),b4=X6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),y4=J6({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),m4=J6({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),v4=X6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),w4=X6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_4=X6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),E4=X6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),S4=X6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),A4=Q6({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),k4=new TextEncoder,x4=new TextDecoder,I4="json",C4=512;function T4(e){return k4.encode(JSON.stringify(e))}function R4(e){return JSON.parse(x4.decode(e))}const P4="raw",D4=85;function N4(e){return F6(e)}function B4(e){return F6(e)}var U4=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=O4;)r[n++]=255&t|L4,t/=128;for(;t&M4;)r[n++]=255&t|L4,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},L4=128,M4=-128,O4=Math.pow(2,31);var q4=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&F4)<<o:(n&F4)*Math.pow(2,o),o+=7}while(n>=K4);return e.bytes=s-r,i},K4=128,F4=127;var V4=Math.pow(2,7),z4=Math.pow(2,14),j4=Math.pow(2,21),H4=Math.pow(2,28),G4=Math.pow(2,35),W4=Math.pow(2,42),Y4=Math.pow(2,49),Q4=Math.pow(2,56),J4=Math.pow(2,63);const X4={encode:U4,decode:q4,encodingLength:function(e){return e<V4?1:e<z4?2:e<j4?3:e<H4?4:e<G4?5:e<W4?6:e<Y4?7:e<Q4?8:e<J4?9:10}};function Z4(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[X4.decode(e,t),X4.decode.bytes]}function $4(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return X4.encode(e,t,r),t}function e5(e){return X4.encodingLength(e)}function t5(e,t){const r=t.byteLength,n=e5(e),i=n+e5(r),o=new Uint8Array(i+r);return $4(e,o,0),$4(r,o,n),o.set(t,i),new n5(e,r,t,o)}function r5(e){const t=F6(e),[r,n]=Z4(t),[i,o]=Z4(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new n5(r,i,s,t)}class n5{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const i5=F6;const o5={code:0,name:"identity",encode:i5,digest:function(e){return t5(0,i5(e))}};function s5(e){let{name:t,code:r,encode:n}=e;return new a5(t,r,n)}class a5{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?t5(this.code,t):t.then((e=>t5(this.code,e)))}throw Error("Unknown type, must be binary type")}}function c5(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const u5=s5({name:"sha2-256",code:18,encode:c5("SHA-256")}),l5=s5({name:"sha2-512",code:19,encode:c5("SHA-512")});function h5(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==Z6.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,f5(e),null!==t&&void 0!==t?t:Z6.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,f5(e),null!==t&&void 0!==t?t:c4.encoder)}const d5=new WeakMap;function f5(e){const t=d5.get(e);if(null==t){const t=new Map;return d5.set(e,t),t}return t}class p5{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==g5)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==b5)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return p5.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=t5(e,t);return p5.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return p5.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return h5(this,e)}toJSON(){return{"/":h5(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof p5)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new p5(e,r,n,null!==i&&void 0!==i?i:y5(e,r,n.bytes))}if(!0===t[m5]){const{version:e,multihash:r,code:n}=t,i=r5(r);return p5.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==g5)throw new Error("Version 0 CID must use dag-pb (code: ".concat(g5,") block encoding"));return new p5(e,t,r,r.bytes);case 1:{const n=y5(e,t,r.bytes);return new p5(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return p5.create(0,g5,e)}static createV1(e,t){return p5.create(1,e,t)}static decode(e){const[t,r]=p5.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=p5.inspectBytes(e),r=t.size-t.multihashSize,n=F6(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new n5(t.multihashCode,t.digestSize,i,n);return[0===t.version?p5.createV0(o):p5.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Z4(e.subarray(t));return t+=n,r};let n=r(),i=g5;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:Z6;return[Z6.prefix,r.decode("".concat(Z6.prefix).concat(e))]}case Z6.prefix:{const r=null!==t&&void 0!==t?t:Z6;return[Z6.prefix,r.decode(e)]}case c4.prefix:{const r=null!==t&&void 0!==t?t:c4;return[c4.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=p5.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return f5(i).set(r,e),i}}const g5=112,b5=18;function y5(e,t,r){const n=e5(e),i=n+e5(t),o=new Uint8Array(i+r.byteLength);return $4(e,o,0),$4(t,o,n),o.set(r,i),o}const m5=Symbol.for("@ipld/js-cid/CID"),v5={...Bn,...Cn,...Nn,...xn,...In,...Rn,...Pn,...kn,...Dn,...Tn};function w5(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const _5=Symbol.for("nodejs.util.inspect.custom"),E5=Object.values(v5).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),v5.identity.decoder),S5=114,A5=36,k5=37;class x5{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=Z6.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return p5.createV1(S5,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return w5(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:E5,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=r5(Z6.decode("z".concat(e)));return e.startsWith("12D")?new C5({multihash:t}):e.startsWith("16U")?new T5({multihash:t}):new I5({multihash:t})}return R5(E5.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return w5(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[_5](){return"PeerId(".concat(this.toString(),")")}}class I5 extends x5{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class C5 extends x5{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class T5 extends x5{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function R5(e){try{const t=r5(e);if(t.code===o5.code){if(t.digest.length===A5)return new C5({multihash:t});if(t.digest.length===k5)return new T5({multihash:t})}if(t.code===u5.code)return new I5({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==S5)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===u5.code)return new I5({multihash:e.multihash});if(t.code===o5.code){if(t.digest.length===A5)return new C5({multihash:e.multihash});if(t.digest.length===k5)return new T5({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(p5.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function P5(e,t,r){return r(ld(e,t))}var D5=__webpack_require__(7283);var N5=new WeakMap;class B5{constructor(){ud(this,N5,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&hd(N5,this)[this.size-1].priority>=t.priority)return void hd(N5,this).push(r);const n=function(e,t,r){let n=0,i=e.length;for(;i>0;){const o=Math.trunc(i/2);let s=n+o;r(e[s],t)<=0?(n=++s,i-=o+1):i=o}return n}(hd(N5,this),r,((e,t)=>t.priority-e.priority));hd(N5,this).splice(n,0,r)}dequeue(){const e=hd(N5,this).shift();return null===e||void 0===e?void 0:e.run}filter(e){return hd(N5,this).filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return hd(N5,this).length}}var U5=new WeakMap,L5=new WeakMap,M5=new WeakMap,O5=new WeakMap,q5=new WeakMap,K5=new WeakMap,F5=new WeakMap,V5=new WeakMap,z5=new WeakMap,j5=new WeakMap,H5=new WeakMap,G5=new WeakMap,W5=new WeakMap,Y5=new WeakMap,Q5=new WeakSet;class J5 extends D5{constructor(e){var t,r,n,i;if(super(),jC(this,Q5),ud(this,U5,void 0),ud(this,L5,void 0),ud(this,M5,0),ud(this,O5,void 0),ud(this,q5,void 0),ud(this,K5,0),ud(this,F5,void 0),ud(this,V5,void 0),ud(this,z5,void 0),ud(this,j5,void 0),ud(this,H5,0),ud(this,G5,void 0),ud(this,W5,void 0),ud(this,Y5,void 0),co(this,"timeout",void 0),!("number"===typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:B5,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError("Expected `intervalCap` to be a number from 1 and up, got `".concat(null!==(t=null===(r=e.intervalCap)||void 0===r?void 0:r.toString())&&void 0!==t?t:"","` (").concat(typeof e.intervalCap,")"));if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError("Expected `interval` to be a finite number >= 0, got `".concat(null!==(n=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==n?n:"","` (").concat(typeof e.interval,")"));yS(U5,this,e.carryoverConcurrencyCount),yS(L5,this,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval),yS(O5,this,e.intervalCap),yS(q5,this,e.interval),yS(z5,this,new e.queueClass),yS(j5,this,e.queueClass),this.concurrency=e.concurrency,this.timeout=e.timeout,yS(Y5,this,!0===e.throwOnTimeout),yS(W5,this,!1===e.autoStart)}get concurrency(){return hd(G5,this)}set concurrency(e){if(!("number"===typeof e&&e>=1))throw new TypeError("Expected `concurrency` to be a number from 1 and up, got `".concat(e,"` (").concat(typeof e,")"));yS(G5,this,e),ld(Q5,this,o8).call(this)}async add(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t={timeout:this.timeout,throwOnTimeout:hd(Y5,this),...t},new Promise(((r,n)=>{hd(z5,this).enqueue((async()=>{var i,o;yS(H5,this,(i=hd(H5,this),i++,i)),yS(M5,this,(o=hd(M5,this),o++,o));try{var s;null===(s=t.signal)||void 0===s||s.throwIfAborted();let n=e({signal:t.signal});t.timeout&&(n=td(Promise.resolve(n),{milliseconds:t.timeout})),t.signal&&(n=Promise.race([n,ld(Q5,this,s8).call(this,t.signal)]));const i=await n;r(i),this.emit("completed",i)}catch(a){if(a instanceof Xh&&!t.throwOnTimeout)return void r();n(a),this.emit("error",a)}finally{ld(Q5,this,$5).call(this)}}),t),this.emit("add"),ld(Q5,this,r8).call(this)}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return hd(W5,this)?(yS(W5,this,!1),ld(Q5,this,o8).call(this),this):this}pause(){yS(W5,this,!0)}clear(){yS(z5,this,new(hd(j5,this)))}async onEmpty(){0!==hd(z5,this).size&&await ld(Q5,this,a8).call(this,"empty")}async onSizeLessThan(e){hd(z5,this).size<e||await ld(Q5,this,a8).call(this,"next",(()=>hd(z5,this).size<e))}async onIdle(){0===hd(H5,this)&&0===hd(z5,this).size||await ld(Q5,this,a8).call(this,"idle")}get size(){return hd(z5,this).size}sizeBy(e){return hd(z5,this).filter(e).length}get pending(){return hd(H5,this)}get isPaused(){return hd(W5,this)}}function X5(e){return hd(L5,e)||hd(M5,e)<hd(O5,e)}function Z5(e){return hd(H5,e)<hd(G5,e)}function $5(){var e;yS(H5,this,(e=hd(H5,this),e--,e)),ld(Q5,this,r8).call(this),this.emit("next")}function e8(){ld(Q5,this,i8).call(this),ld(Q5,this,n8).call(this),yS(V5,this,void 0)}function t8(e){const t=Date.now();if(void 0===hd(F5,e)){const r=hd(K5,e)-t;if(!(r<0))return void 0===hd(V5,e)&&yS(V5,e,setTimeout((()=>{ld(Q5,e,e8).call(e)}),r)),!0;yS(M5,e,hd(U5,e)?hd(H5,e):0)}return!1}function r8(){if(0===hd(z5,this).size)return hd(F5,this)&&clearInterval(hd(F5,this)),yS(F5,this,void 0),this.emit("empty"),0===hd(H5,this)&&this.emit("idle"),!1;if(!hd(W5,this)){const e=!P5(Q5,this,t8);if(P5(Q5,this,X5)&&P5(Q5,this,Z5)){const t=hd(z5,this).dequeue();return!!t&&(this.emit("active"),t(),e&&ld(Q5,this,n8).call(this),!0)}}return!1}function n8(){hd(L5,this)||void 0!==hd(F5,this)||(yS(F5,this,setInterval((()=>{ld(Q5,this,i8).call(this)}),hd(q5,this))),yS(K5,this,Date.now()+hd(q5,this)))}function i8(){0===hd(M5,this)&&0===hd(H5,this)&&hd(F5,this)&&(clearInterval(hd(F5,this)),yS(F5,this,void 0)),yS(M5,this,hd(U5,this)?hd(H5,this):0),ld(Q5,this,o8).call(this)}function o8(){for(;ld(Q5,this,r8).call(this););}async function s8(e){return new Promise(((t,r)=>{e.addEventListener("abort",(()=>{r(e.reason)}),{once:!0})}))}async function a8(e,t){return new Promise((r=>{const n=()=>{t&&!t()||(this.off(e,n),r())};this.on(e,n)}))}const c8={},u8=e=>{e.addEventListener("message",(t=>{u8.dispatchEvent("message",e,t)})),null!=e.port&&e.port.addEventListener("message",(t=>{u8.dispatchEvent("message",e,t)}))};u8.addEventListener=(e,t)=>{null==c8[e]&&(c8[e]=[]),c8[e].push(t)},u8.removeEventListener=(e,t)=>{null!=c8[e]&&(c8[e]=c8[e].filter((e=>e===t)))},u8.dispatchEvent=function(e,t,r){null!=c8[e]&&c8[e].forEach((e=>e(t,r)))};const l8=u8,h8="lock:worker:request-read",d8="lock:worker:release-read",f8="lock:master:grant-read",p8="lock:worker:request-write",g8="lock:worker:release-write",b8="lock:master:grant-write",y8=(e,t,r,n,i)=>(o,s)=>{if(s.data.type!==r)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.dispatchEvent(new MessageEvent(t,{data:{name:a.name,handler:async()=>{o.postMessage({type:i,name:a.name,identifier:a.identifier}),await new Promise((e=>{const t=r=>{if(null==r||null==r.data)return;const i=r.data.type,s=(r.data.name,r.data.identifier);i===n&&s===a.identifier&&(o.removeEventListener("message",t),e())};o.addEventListener("message",t)}))}}}))},m8=(e,t,r,n)=>async()=>{const i=Math.random().toString().substring(2);return globalThis.postMessage({type:t,identifier:i,name:e}),new Promise((t=>{const o=s=>{if(null==s||null==s.data)return;const a=s.data.type,c=s.data.identifier;a===r&&c===i&&(globalThis.removeEventListener("message",o),t((()=>{globalThis.postMessage({type:n,identifier:i,name:e})})))};globalThis.addEventListener("message",o)}))},v8={singleProcess:!1},w8={};let _8;async function E8(e,t){let r;const n=new Promise((e=>{r=e}));return e.add((async()=>td((async()=>{await new Promise((e=>{r((()=>{e()}))}))})(),{milliseconds:t.timeout}))),n}const S8={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function A8(e){const t=Object.assign({},S8,e);return null==_8&&(_8=(e=>{if(e=Object.assign({},v8,e),Boolean(globalThis.document)||e.singleProcess){const e=new EventTarget;return l8.addEventListener("message",y8(e,"requestReadLock",h8,d8,f8)),l8.addEventListener("message",y8(e,"requestWriteLock",p8,g8,b8)),e}return{isWorker:!0,readLock:e=>m8(e,h8,f8,d8),writeLock:e=>m8(e,p8,b8,g8)}})(t),!0!==_8.isWorker&&(_8.addEventListener("requestReadLock",(e=>{null!=w8[e.data.name]&&w8[e.data.name].readLock().then((async t=>e.data.handler().finally((()=>{t()}))))})),_8.addEventListener("requestWriteLock",(async e=>{null!=w8[e.data.name]&&w8[e.data.name].writeLock().then((async t=>e.data.handler().finally((()=>{t()}))))})))),null==w8[t.name]&&(w8[t.name]=((e,t)=>{if(!0===_8.isWorker)return{readLock:_8.readLock(e,t),writeLock:_8.writeLock(e,t)};const r=new J5({concurrency:1});let n;return{async readLock(){if(null!=n)return E8(n,t);n=new J5({concurrency:t.concurrency,autoStart:!1});const e=n,i=E8(n,t);return r.add((async()=>{e.start(),await e.onIdle().then((()=>{n===e&&(n=null)}))})),i},writeLock:async()=>(n=null,E8(r,t))}})(t.name,t)),w8[t.name]}const k8={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS"},x8=new Float32Array([-0]),I8=new Uint8Array(x8.buffer);function C8(e,t,r){x8[0]=e,t[r]=I8[0],t[r+1]=I8[1],t[r+2]=I8[2],t[r+3]=I8[3]}const T8=new Float64Array([-0]),R8=new Uint8Array(T8.buffer);function P8(e,t,r){T8[0]=e,t[r]=R8[0],t[r+1]=R8[1],t[r+2]=R8[2],t[r+3]=R8[3],t[r+4]=R8[4],t[r+5]=R8[5],t[r+6]=R8[6],t[r+7]=R8[7]}const D8=BigInt(Number.MAX_SAFE_INTEGER),N8=BigInt(Number.MIN_SAFE_INTEGER);class B8{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return U8;if(e<D8&&e>N8)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>L8&&(n=0n,++r>L8&&(r=0n))),new B8(Number(n),Number(r))}static fromNumber(e){if(0===e)return U8;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new B8(r,n)}static from(e){return"number"===typeof e?B8.fromNumber(e):"bigint"===typeof e?B8.fromBigInt(e):"string"===typeof e?B8.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new B8(e.low>>>0,e.high>>>0):U8}}const U8=new B8(0,0);U8.toBigInt=function(){return 0n},U8.zzEncode=U8.zzDecode=function(){return this},U8.length=function(){return 1};const L8=4294967296n;function M8(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function O8(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function q8(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class K8{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,O8(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw O8(this,4);return q8(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw O8(this,4);return 0|q8(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw O8(this,4);const e=(t=this.buf,r=this.pos,I8[0]=t[r],I8[1]=t[r+1],I8[2]=t[r+2],I8[3]=t[r+3],x8[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw O8(this,4);const e=(t=this.buf,r=this.pos,R8[0]=t[r],R8[1]=t[r+1],R8[2]=t[r+2],R8[3]=t[r+3],R8[4]=t[r+4],R8[5]=t[r+5],R8[6]=t[r+6],R8[7]=t[r+7],T8[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw O8(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw O8(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw O8(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new B8(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw O8(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw O8(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw O8(this,8);const e=q8(this.buf,this.pos+=4),t=q8(this.buf,this.pos+=4);return new B8(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function F8(e,t,r){const n=function(e){return new K8(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function V8(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function z8(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const j8=z8("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),H8=z8("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=V8((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),G8={utf8:j8,"utf-8":j8,hex:v5.base16,latin1:H8,ascii:H8,binary:H8,...v5};function W8(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=G8[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}class Y8{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Q8(){}class J8{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const X8=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return V8(e);i+e>t&&(n=V8(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class Z8{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new Y8(Q8,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Y8(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new t7((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(r7,10,B8.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=B8.fromBigInt(e);return this._push(r7,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=B8.fromBigInt(e).zzEncode();return this._push(r7,t.length(),t)}sint64Number(e){const t=B8.fromNumber(e).zzEncode();return this._push(r7,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push($8,1,e?1:0)}fixed32(e){return this._push(n7,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=B8.fromBigInt(e);return this._push(n7,4,t.lo)._push(n7,4,t.hi)}fixed64Number(e){const t=B8.fromNumber(e);return this._push(n7,4,t.lo)._push(n7,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(C8,4,e)}double(e){return this._push(P8,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push($8,1,0):this.uint32(t)._push(i7,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(M8,t,e):this._push($8,1,0)}fork(){return this.states=new J8(this),this.head=this.tail=new Y8(Q8,0,0),this.len=0,this}reset(){return null!=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 Y8(Q8,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?V8(r):X8(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function $8(e,t,r){t[r]=255&e}function e7(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class t7 extends Y8{constructor(e,t){super(e7,e,t),co(this,"next",void 0),this.next=void 0}}function r7(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function n7(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function i7(e,t,r){t.set(e,r)}function o7(e,t,r){t.set(e,r)}function s7(e,t,r){e.length<40?M8(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(W8(e),r)}function a7(e,t){const r=new Z8;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var c7,u7,l7,h7;function d7(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",c7.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Z8.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(o7,t,e),this},Z8.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(s7,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(c7||(c7={}));Error;function f7(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=G8[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}function p7(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=V8(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}!function(e){let t,r,n;!function(e){let t;e.codec=()=>(null==t&&(t=d7((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.key&&""!==e.key&&(t.uint32(10),t.string(e.key)),null!=e.value&&e.value.byteLength>0&&(t.uint32(18),t.bytes(e.value)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={key:"",value:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.key=e.string();break;case 2:r.value=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>a7(t,e.codec()),e.decode=t=>F8(t,e.codec())}(t=e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(e){let t;e.codec=()=>(null==t&&(t=d7((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.key&&""!==e.key&&(t.uint32(10),t.string(e.key)),null!=e.value&&(t.uint32(18),h7.codec().encode(e.value,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={key:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.key=e.string();break;case 2:r.value=h7.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>a7(t,e.codec()),e.decode=t=>F8(t,e.codec())}(r=e.Peer$tagsEntry||(e.Peer$tagsEntry={})),e.codec=()=>(null==n&&(n=d7((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.addresses)for(const e of t.addresses)r.uint32(10),l7.codec().encode(e,r);if(null!=t.protocols)for(const e of t.protocols)r.uint32(18),r.string(e);if(null!=t.publicKey&&(r.uint32(34),r.bytes(t.publicKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),null!=t.metadata&&0!==t.metadata.size)for(const[i,o]of t.metadata.entries())r.uint32(50),e.Peer$metadataEntry.codec().encode({key:i,value:o},r);if(null!=t.tags&&0!==t.tags.size)for(const[i,o]of t.tags.entries())r.uint32(58),e.Peer$tagsEntry.codec().encode({key:i,value:o},r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={addresses:[],protocols:[],metadata:new Map,tags:new Map},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.addresses.push(l7.codec().decode(t,t.uint32()));break;case 2:n.protocols.push(t.string());break;case 4:n.publicKey=t.bytes();break;case 5:n.peerRecordEnvelope=t.bytes();break;case 6:{const r=e.Peer$metadataEntry.codec().decode(t,t.uint32());n.metadata.set(r.key,r.value);break}case 7:{const r=e.Peer$tagsEntry.codec().decode(t,t.uint32());n.tags.set(r.key,r.value);break}default:t.skipType(7&r)}}return n}))),n),e.encode=t=>a7(t,e.codec()),e.decode=t=>F8(t,e.codec())}(u7||(u7={})),function(e){let t;e.codec=()=>(null==t&&(t=d7((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),null!=e.isCertified&&(t.uint32(16),t.bool(e.isCertified)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={multiaddr:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.multiaddr=e.bytes();break;case 2:r.isCertified=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>a7(t,e.codec()),e.decode=t=>F8(t,e.codec())}(l7||(l7={})),function(e){let t;e.codec=()=>(null==t&&(t=d7((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.value&&0!==e.value&&(t.uint32(8),t.uint32(e.value)),null!=e.expiry&&(t.uint32(16),t.uint64(e.expiry)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={value:0},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.value=e.uint32();break;case 2:r.expiry=e.uint64();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>a7(t,e.codec()),e.decode=t=>F8(t,e.codec())}(h7||(h7={}));const g7=Ox,b7=qx,y7=function(e){let t=0;if(e=e.toString().trim(),g7(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(b7(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;g7(r[n])&&(e=y7(r[n]),r[n]=f7(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,f7(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},m7=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},v7=-1,w7={},_7={};function E7(e){if("number"===typeof e){if(null!=_7[e])return _7[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=w7[e])return w7[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,v7,"ip6zone"],[43,8,"ipcidr"],[53,v7,"dns",!0],[54,v7,"dns4",!0],[55,v7,"dns6",!0],[56,v7,"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,v7,"unix",!1,!0],[421,v7,"ipfs"],[421,v7,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,v7,"garlic64"],[448,0,"tls"],[449,v7,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,v7,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,v7,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);_7[t.code]=t,w7[t.name]=t}));E7("ip4"),E7("ip6"),E7("ipcidr");function S7(e,t){switch(E7(e).code){case 4:case 41:return function(e){const t=m7(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return P7(t);case 6:case 273:case 33:case 132:return T7(t).toString();case 421:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return f7(r,"base58btc")}(t);case 444:case 445:return D7(t);case 466:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+f7(r,"base64url")}(t);default:return f7(t,"base16")}}function A7(e,t){switch(E7(e).code){case 4:case 41:return I7(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return R7(t);case 6:case 273:case 33:case 132:return C7(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?r5(Z6.decode("z".concat(e))).bytes:p5.parse(e).multihash.bytes;const r=Uint8Array.from(Eo(t.length));return p7([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(16!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion address."));const r=c4.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)");const i=C7(n);return p7([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));const r=c4.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=C7(n);return p7([r,i],r.length+i.length)}(t);case 466:return function(e){const t=x7.decode(e),r=Uint8Array.from(Eo(t.length));return p7([r,t],r.length+t.length)}(t);default:return W8(t,"base16")}}const k7=Object.values(v5).map((e=>e.decoder)),x7=function(){let e=k7[0].or(k7[1]);return k7.slice(2).forEach((t=>e=e.or(t))),e}();function I7(e){if(!Kx(e))throw new Error("invalid ip address");return y7(e)}function C7(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function T7(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function R7(e){const t=W8(e),r=Uint8Array.from(Eo(t.length));return p7([r,t],r.length+t.length)}function P7(e){const t=So(e);if((e=e.slice(vo(t))).length!==t)throw new Error("inconsistent lengths");return f7(e)}function D7(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=f7(t,"base32"),i=T7(r);return"".concat(n,":").concat(i)}function N7(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const o=So(e,i),s=vo(o),a=E7(o),c=L7(a,e.slice(i+s));if(0===c){t.push([o]),r.push([o]),i+=s;continue}const u=e.slice(i+s,i+s+c);if(i+=c+s,i>e.length)throw O7("Invalid address Uint8Array: "+f7(e,"base16"));t.push([o,u]);const l=S7(o,u);if(r.push([o,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:B7(r),tuples:t,stringTuples:r,path:n}}function B7(e){const t=[];return e.map((e=>{const r=E7(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),M7(t.join("/"))}function U7(e){return p7(e.map((e=>{const t=E7(e[0]);let r=Uint8Array.from(Eo(t.code));return e.length>1&&null!=e[1]&&(r=p7([r,e[1]])),r})))}function L7(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=So(t instanceof Uint8Array?t:Uint8Array.from(t));return e+vo(e)}}function M7(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function O7(e){return new Error("Error parsing address: "+e)}const q7=Symbol.for("nodejs.util.inspect.custom"),K7=Symbol.for("@multiformats/js-multiaddr/multiaddr"),F7=[E7("dns").code,E7("dns4").code,E7("dns6").code,E7("dnsaddr").code];var V7=new WeakMap,z7=new WeakMap,j7=new WeakMap,H7=new WeakMap;class G7{constructor(e){let t;if(co(this,"bytes",void 0),ud(this,V7,void 0),ud(this,z7,void 0),ud(this,j7,void 0),ud(this,H7,void 0),co(this,K7,!0),null==e&&(e=""),e instanceof Uint8Array)t=N7(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));t=function(e){const t=[],r=[];let n=null;const i=(e=M7(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){const s=E7(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw O7("invalid address: "+e);if(!0===s.path){n=M7(i.slice(o).join("/")),t.push([s.code,A7(s.code,n)]),r.push([s.code,n]);break}const a=A7(s.code,i[o]);t.push([s.code,a]),r.push([s.code,S7(s.code,a)])}return{string:B7(r),bytes:U7(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!Y7(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=N7(e.bytes)}this.bytes=t.bytes,yS(V7,this,t.string),yS(z7,this,t.tuples),yS(j7,this,t.stringTuples),yS(H7,this,t.path)}toString(){return hd(V7,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=E7("tcp"),s=E7("udp"),a=E7("ip4"),c=E7("ip6"),u=E7("dns6"),l=E7("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),F7.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===u.code?6:4),h!==o.code&&h!==s.code||(t=E7(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=E7(h).name,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return hd(z7,this).map((e=>{let[t]=e;return Object.assign({},E7(t))}))}protoCodes(){return hd(z7,this).map((e=>{let[t]=e;return t}))}protoNames(){return hd(z7,this).map((e=>{let[t]=e;return E7(t).name}))}tuples(){return hd(z7,this)}stringTuples(){return hd(j7,this)}encapsulate(e){return e=new G7(e),new G7(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address ".concat(this.toString()," does not contain subaddress: ").concat(e.toString()));return new G7(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new G7(U7(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===w7.p2p.code&&e.push([r,n]),r===w7["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){const e=t[1];return"Q"===e[0]||"1"===e[0]?f7(Z6.decode("z".concat(e)),"base58btc"):f7(p5.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return hd(H7,this)}equals(e){return w5(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=W7.get(t.name);if(null==r)throw new ug("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>Q7(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[q7](){return"Multiaddr(".concat(hd(V7,this),")")}}const W7=new Map;function Y7(e){return Boolean(null===e||void 0===e?void 0:e[K7])}function Q7(e){return new G7(e)}function J7(e,t){var r;const n=u7.decode(t);null!=n.publicKey&&null==e.publicKey&&(e=function(e){if("RSA"===e.type)return new I5(e);if("Ed25519"===e.type)return new C5(e);if("secp256k1"===e.type)return new T5(e);throw new ug("Not a PeerId","ERR_INVALID_PARAMETERS")}({...e,publicKey:e.publicKey}));const i=new Map,o=BigInt(Date.now());for(const[s,a]of n.tags.entries())null!=a.expiry&&a.expiry<o||i.set(s,a);return{...n,id:e,addresses:n.addresses.map((e=>{let{multiaddr:t,isCertified:r}=e;return{multiaddr:Q7(t),isCertified:null!==r&&void 0!==r&&r}})),metadata:n.metadata,peerRecordEnvelope:null!==(r=n.peerRecordEnvelope)&&void 0!==r?r:void 0,tags:i}}new Uint8Array(0);function X7(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Z7=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const $7=Z7;class e9{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class t9{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return n9(this,e)}}class r9{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return n9(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function n9(e,t){var r,n;return new r9({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class i9{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new e9(e,t,r),this.decoder=new t9(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function o9(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new i9(t,r,n,i)}function s9(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=$7(n,t);return o9({prefix:r,name:t,encode:i,decode:e=>X7(o(e))})}function a9(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return o9({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const c9=s9({prefix:"9",name:"base10",alphabet:"0123456789"}),u9=a9({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),l9=a9({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),h9=a9({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),d9=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),f9=d9.reduce(((e,t,r)=>(e[r]=t,e)),[]),p9=d9.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const g9=o9({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=f9[t]),"")},decode:function(e){const t=[];for(const r of e){const e=p9[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),b9=a9({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),y9=a9({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),m9=a9({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),v9=a9({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),w9=a9({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_9=a9({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),E9=a9({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),S9=a9({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),A9=a9({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),k9=s9({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),x9=s9({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),I9=s9({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),C9=s9({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),T9=a9({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),R9=a9({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),P9=a9({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),D9=a9({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),N9=a9({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),B9=o9({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),U9=new TextEncoder,L9=new TextDecoder,M9="json",O9=512;function q9(e){return U9.encode(JSON.stringify(e))}function K9(e){return JSON.parse(L9.decode(e))}const F9="raw",V9=85;function z9(e){return X7(e)}function j9(e){return X7(e)}var H9=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Y9;)r[n++]=255&t|G9,t/=128;for(;t&W9;)r[n++]=255&t|G9,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},G9=128,W9=-128,Y9=Math.pow(2,31);var Q9=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&X9)<<o:(n&X9)*Math.pow(2,o),o+=7}while(n>=J9);return e.bytes=s-r,i},J9=128,X9=127;var Z9=Math.pow(2,7),$9=Math.pow(2,14),eee=Math.pow(2,21),tee=Math.pow(2,28),ree=Math.pow(2,35),nee=Math.pow(2,42),iee=Math.pow(2,49),oee=Math.pow(2,56),see=Math.pow(2,63);const aee={encode:H9,decode:Q9,encodingLength:function(e){return e<Z9?1:e<$9?2:e<eee?3:e<tee?4:e<ree?5:e<nee?6:e<iee?7:e<oee?8:e<see?9:10}};function cee(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return aee.encode(e,t,r),t}function uee(e){return aee.encodingLength(e)}function lee(e,t){const r=t.byteLength,n=uee(e),i=n+uee(r),o=new Uint8Array(i+r);return cee(e,o,0),cee(r,o,n),o.set(t,i),new hee(e,r,t,o)}class hee{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const dee=X7;const fee={code:0,name:"identity",encode:dee,digest:function(e){return lee(0,dee(e))}};function pee(e){let{name:t,code:r,encode:n}=e;return new gee(t,r,n)}class gee{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?lee(this.code,t):t.then((e=>lee(this.code,e)))}throw Error("Unknown type, must be binary type")}}function bee(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const yee=pee({name:"sha2-256",code:18,encode:bee("SHA-256")}),mee=pee({name:"sha2-512",code:19,encode:bee("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const vee={...Yn,...Fn,...Wn,...qn,...Kn,...zn,...jn,...Hn,...Gn,...Vn};function wee(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const _ee=wee("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Eee=wee("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),See={utf8:_ee,"utf-8":_ee,hex:vee.base16,latin1:Eee,ascii:Eee,binary:Eee,...vee};const Aee="/",kee=(new TextEncoder).encode(Aee),xee=kee[0];class Iee{constructor(e,t){if(co(this,"_buf",void 0),"string"===typeof e)this._buf=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=See[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==xee)throw new Error("Invalid key")}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf8";return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=See[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return"Key(".concat(this.toString(),")")}static withNamespaces(e){return new Iee(e.join(Aee))}static random(){return new Iee(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"===typeof e?new Iee(e):"function"===typeof e.uint8Array?new Iee(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=kee),this._buf[0]!==xee){const e=new Uint8Array(this._buf.byteLength+1);e.fill(xee,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===xee;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let n=0;n<t.length;n++){if(r.length<n+1)return!1;const e=t[n],i=r[n];if(e<i)return!0;if(e>i)return!1}return t.length<r.length}reverse(){return Iee.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Aee).slice(1)}type(){return function(e){const t=e.split(":");if(t.length<2)return"";return t.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(e){const t=e.split(":");return t[t.length-1]}(this.baseNamespace())}instance(e){return new Iee(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Aee)||(e+=Aee),e+=this.type(),new Iee(e)}parent(){const e=this.list();return 1===e.length?new Iee(Aee):new Iee(e.slice(0,-1).join(Aee))}child(e){return this.toString()===Aee?e:e.toString()===Aee?this:new Iee(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()!==this.toString()&&e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()!==this.toString()&&this.toString().startsWith(e.toString())}isTopLevel(){return 1===this.list().length}concat(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Iee.withNamespaces([...this.namespaces(),...(n=t.map((e=>e.namespaces())),[].concat(...n))]);var n}}const Cee="/peers/";function Tee(e){if(!Um(e)||null==e.type)throw new ug("Invalid PeerId",k8.ERR_INVALID_PARAMETERS);const t=e.toCID().toString();return new Iee("".concat(Cee).concat(t))}async function Ree(e,t,r){const n=new Map;for(const o of r){var i;if(null==o)continue;if(o.multiaddr instanceof Uint8Array&&(o.multiaddr=Q7(o.multiaddr)),!Y7(o.multiaddr))throw new ug("Multiaddr was invalid",k8.ERR_INVALID_PARAMETERS);if(!await t(e,o.multiaddr))continue;const r=null!==(i=o.isCertified)&&void 0!==i&&i,s=o.multiaddr.toString(),a=n.get(s);null!=a?o.isCertified=a.isCertified||r:n.set(s,{multiaddr:o.multiaddr,isCertified:r})}return[...n.values()].sort(((e,t)=>e.multiaddr.toString().localeCompare(t.multiaddr.toString()))).map((e=>{let{isCertified:t,multiaddr:r}=e;return{isCertified:t,multiaddr:r.bytes}}))}async function Pee(e,t,r,n){var i,o,s,a,c,u,l;if(null==t)throw new ug("Invalid PeerData",k8.ERR_INVALID_PARAMETERS);if(null!=t.publicKey&&null!=e.publicKey&&!w5(t.publicKey,e.publicKey))throw new ug("publicKey bytes do not match peer id publicKey bytes",k8.ERR_INVALID_PARAMETERS);const h=n.existingPeer;if(null!=h&&!e.equals(h.id))throw new ug("peer id did not match existing peer id",k8.ERR_INVALID_PARAMETERS);let d=null!==(i=null===h||void 0===h?void 0:h.addresses)&&void 0!==i?i:[],f=new Set(null!==(o=null===h||void 0===h?void 0:h.protocols)&&void 0!==o?o:[]),p=null!==(s=null===h||void 0===h?void 0:h.metadata)&&void 0!==s?s:new Map,g=null!==(a=null===h||void 0===h?void 0:h.tags)&&void 0!==a?a:new Map,b=null===h||void 0===h?void 0:h.peerRecordEnvelope;if("patch"===r){if(null==t.multiaddrs&&null==t.addresses||(d=[],null!=t.multiaddrs&&d.push(...t.multiaddrs.map((e=>({isCertified:!1,multiaddr:e})))),null!=t.addresses&&d.push(...t.addresses)),null!=t.protocols&&(f=new Set(t.protocols)),null!=t.metadata){p=Dee(t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata),{validate:Nee})}if(null!=t.tags){g=Dee(t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),{validate:Bee,map:Uee})}null!=t.peerRecordEnvelope&&(b=t.peerRecordEnvelope)}if("merge"===r){if(null!=t.multiaddrs&&d.push(...t.multiaddrs.map((e=>({isCertified:!1,multiaddr:e})))),null!=t.addresses&&d.push(...t.addresses),null!=t.protocols&&(f=new Set([...f,...t.protocols])),null!=t.metadata){const e=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);for(const[t,r]of e)null==r?p.delete(t):p.set(t,r);p=Dee([...p.entries()],{validate:Nee})}if(null!=t.tags){const e=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),r=new Map(g);for(const[t,n]of e)null==n?r.delete(t):r.set(t,n);g=Dee([...r.entries()],{validate:Bee,map:Uee})}null!=t.peerRecordEnvelope&&(b=t.peerRecordEnvelope)}const y={addresses:await Ree(e,null!==(c=n.addressFilter)&&void 0!==c?c:async()=>!0,d),protocols:[...f.values()].sort(((e,t)=>e.localeCompare(t))),metadata:p,tags:g,publicKey:null!==(u=null!==(l=null===h||void 0===h?void 0:h.id.publicKey)&&void 0!==l?l:t.publicKey)&&void 0!==u?u:e.publicKey,peerRecordEnvelope:b};return"RSA"!==e.type&&delete y.publicKey,y}function Dee(e,t){const r=new Map;for(const[o,s]of e)null!=s&&t.validate(o,s);for(const[o,s]of e.sort(((e,t)=>{let[r]=e,[n]=t;return r.localeCompare(n)}))){var n,i;if(null!=s)r.set(o,null!==(n=null===(i=t.map)||void 0===i?void 0:i.call(t,o,s))&&void 0!==n?n:s)}return r}function Nee(e,t){if("string"!==typeof e)throw new ug("Metadata key must be a string",k8.ERR_INVALID_PARAMETERS);if(!(t instanceof Uint8Array))throw new ug("Metadata value must be a Uint8Array",k8.ERR_INVALID_PARAMETERS)}function Bee(e,t){if("string"!==typeof e)throw new ug("Tag name must be a string",k8.ERR_INVALID_PARAMETERS);if(null!=t.value){if(parseInt("".concat(t.value),10)!==t.value)throw new ug("Tag value must be an integer",k8.ERR_INVALID_PARAMETERS);if(t.value<0||t.value>100)throw new ug("Tag value must be between 0-100",k8.ERR_INVALID_PARAMETERS)}if(null!=t.ttl){if(parseInt("".concat(t.ttl),10)!==t.ttl)throw new ug("Tag ttl must be an integer",k8.ERR_INVALID_PARAMETERS);if(t.ttl<0)throw new ug("Tag ttl must be between greater than 0",k8.ERR_INVALID_PARAMETERS)}}function Uee(e,t){var r;let n;return null!=t.expiry&&(n=t.expiry),null!=t.ttl&&(n=BigInt(Date.now()+Number(t.ttl))),{value:null!==(r=t.value)&&void 0!==r?r:0,expiry:n}}function Lee(e,t,r){const n=e.toString().split("/")[2],i=R5(c4.decode(n)),o=r.get(i);if(null!=o)return o;const s=J7(i,t);return r.set(i,s),s}var Mee=new WeakSet;class Oee{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};jC(this,Mee),co(this,"peerId",void 0),co(this,"datastore",void 0),co(this,"lock",void 0),co(this,"addressFilter",void 0),this.peerId=e.peerId,this.datastore=e.datastore,this.addressFilter=t.addressFilter,this.lock=A8({name:"peer-store",singleProcess:!0})}async has(e){return this.datastore.has(Tee(e))}async delete(e){if(this.peerId.equals(e))throw new ug("Cannot delete self peer",k8.ERR_INVALID_PARAMETERS);await this.datastore.delete(Tee(e))}async load(e){return J7(e,await this.datastore.get(Tee(e)))}async save(e,t){const{existingBuf:r,existingPeer:n}=await ld(Mee,this,qee).call(this,e),i=await Pee(e,t,"patch",{addressFilter:this.addressFilter});return ld(Mee,this,Kee).call(this,e,i,r,n)}async patch(e,t){const{existingBuf:r,existingPeer:n}=await ld(Mee,this,qee).call(this,e),i=await Pee(e,t,"patch",{addressFilter:this.addressFilter,existingPeer:n});return ld(Mee,this,Kee).call(this,e,i,r,n)}async merge(e,t){const{existingBuf:r,existingPeer:n}=await ld(Mee,this,qee).call(this,e),i=await Pee(e,t,"merge",{addressFilter:this.addressFilter,existingPeer:n});return ld(Mee,this,Kee).call(this,e,i,r,n)}async*all(e){const t=new K6;for await(const{key:r,value:n}of this.datastore.query(function(e,t){var r,n;return null==e?{}:{prefix:Cee,filters:(null!==(r=e.filters)&&void 0!==r?r:[]).map((e=>r=>{let{key:n,value:i}=r;return e(Lee(n,i,t))})),orders:(null!==(n=e.orders)&&void 0!==n?n:[]).map((e=>(r,n)=>e(Lee(r.key,r.value,t),Lee(n.key,n.value,t))))}}(null!==e&&void 0!==e?e:{},t))){const e=Lee(r,n,t);e.id.equals(this.peerId)||(yield e)}}}async function qee(e){try{const t=await this.datastore.get(Tee(e));return{existingBuf:t,existingPeer:J7(e,t)}}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t}return{}}async function Kee(e,t,r,n){const i=u7.encode(t);return null!=r&&w5(i,r)?{peer:J7(e,i),previous:n,updated:!1}:(await this.datastore.put(Tee(e),i),{peer:J7(e,i),previous:n,updated:!0})}var Fee=new WeakSet;class Vee{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};jC(this,Fee),co(this,"store",void 0),co(this,"events",void 0),co(this,"peerId",void 0),co(this,"log",void 0),this.log=e.logger.forComponent("libp2p:peer-store"),this.events=e.events,this.peerId=e.peerId,this.store=new Oee(e,t)}async forEach(e,t){this.log.trace("forEach await read lock");const r=await this.store.lock.readLock();this.log.trace("forEach got read lock");try{for await(const r of this.store.all(t))e(r)}finally{this.log.trace("forEach release read lock"),r()}}async all(e){this.log.trace("all await read lock");const t=await this.store.lock.readLock();this.log.trace("all got read lock");try{return await Ql(this.store.all(e))}finally{this.log.trace("all release read lock"),t()}}async delete(e){this.log.trace("delete await write lock");const t=await this.store.lock.writeLock();this.log.trace("delete got write lock");try{await this.store.delete(e)}finally{this.log.trace("delete release write lock"),t()}}async has(e){this.log.trace("has await read lock");const t=await this.store.lock.readLock();this.log.trace("has got read lock");try{return await this.store.has(e)}finally{this.log.trace("has release read lock"),t()}}async get(e){this.log.trace("get await read lock");const t=await this.store.lock.readLock();this.log.trace("get got read lock");try{return await this.store.load(e)}finally{this.log.trace("get release read lock"),t()}}async save(e,t){this.log.trace("save await write lock");const r=await this.store.lock.writeLock();this.log.trace("save got write lock");try{const r=await this.store.save(e,t);return ld(Fee,this,zee).call(this,e,r),r.peer}finally{this.log.trace("save release write lock"),r()}}async patch(e,t){this.log.trace("patch await write lock");const r=await this.store.lock.writeLock();this.log.trace("patch got write lock");try{const r=await this.store.patch(e,t);return ld(Fee,this,zee).call(this,e,r),r.peer}finally{this.log.trace("patch release write lock"),r()}}async merge(e,t){this.log.trace("merge await write lock");const r=await this.store.lock.writeLock();this.log.trace("merge got write lock");try{const r=await this.store.merge(e,t);return ld(Fee,this,zee).call(this,e,r),r.peer}finally{this.log.trace("merge release write lock"),r()}}async consumePeerRecord(e,t){var r;const n=await $L.openAndCertify(e,JN.DOMAIN);if(!1===(null===t||void 0===t?void 0:t.equals(n.peerId)))return this.log("envelope peer id was not the expected peer id - expected: %p received: %p",t,n.peerId),!1;const i=JN.createFromProtobuf(n.payload);let o;try{o=await this.get(n.peerId)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}if(null!=(null===(r=o)||void 0===r?void 0:r.peerRecordEnvelope)){const e=await $L.createFromProtobuf(o.peerRecordEnvelope),t=JN.createFromProtobuf(e.payload);if(t.seqNumber>=i.seqNumber)return this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",t.seqNumber,i.seqNumber),!1}return await this.patch(i.peerId,{peerRecordEnvelope:e,addresses:i.multiaddrs.map((e=>({isCertified:!0,multiaddr:e})))}),!0}}function zee(e,t){t.updated&&(this.peerId.equals(e)?this.events.safeDispatchEvent("self:peer:update",{detail:t}):this.events.safeDispatchEvent("peer:update",{detail:t}))}const jee=Ox,Hee=qx,Gee=function(e){let t=0;if(e=e.toString().trim(),jee(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(Hee(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;jee(r[n])&&(e=Gee(r[n]),r[n]=BZ(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,BZ(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},Wee=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;const i=new DataView(e.buffer);if(4===n){const t=[];for(let i=0;i<n;i++)t.push(e[r+i]);return t.join(".")}if(16===n){const e=[];for(let t=0;t<n;t+=2)e.push(i.getUint16(r+t).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},Yee=-1,Qee={},Jee={};function Xee(e){if("number"===typeof e){if(null!=Jee[e])return Jee[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=Qee[e])return Qee[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,Yee,"ip6zone"],[43,8,"ipcidr"],[53,Yee,"dns",!0],[54,Yee,"dns4",!0],[55,Yee,"dns6",!0],[56,Yee,"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,Yee,"unix",!1,!0],[421,Yee,"ipfs"],[421,Yee,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,Yee,"garlic64"],[448,0,"tls"],[449,Yee,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,Yee,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,Yee,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);Jee[t.code]=t,Qee[t.name]=t}));Xee("ip4"),Xee("ip6"),Xee("ipcidr");function Zee(e,t){switch(Xee(e).code){case 4:case 41:return function(e){const t=Wee(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Kx(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ste(t);case 6:case 273:case 33:case 132:return ite(t).toString();case 421:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return BZ(r,"base58btc")}(t);case 444:case 445:return ate(t);case 466:return function(e){const t=So(e),r=e.slice(vo(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+BZ(r,"base64url")}(t);default:return BZ(t,"base16")}}function $ee(e,t){switch(Xee(e).code){case 4:case 41:return rte(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ote(t);case 6:case 273:case 33:case 132:return nte(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?TJ(sJ.decode("z".concat(e))).bytes:SX.parse(e).multihash.bytes;const r=Uint8Array.from(Eo(t.length));return KX([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(16!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion address."));const r=WJ.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)");const i=nte(n);return KX([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));const r=WJ.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=nte(n);return KX([r,i],r.length+i.length)}(t);case 466:return function(e){const t=tte.decode(e),r=Uint8Array.from(Eo(t.length));return KX([r,t],r.length+t.length)}(t);default:return BX(t,"base16")}}const ete=Object.values(CX).map((e=>e.decoder)),tte=function(){let e=ete[0].or(ete[1]);return ete.slice(2).forEach((t=>e=e.or(t))),e}();function rte(e){if(!Kx(e))throw new Error("invalid ip address");return Gee(e)}function nte(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function ite(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function ote(e){const t=BX(e),r=Uint8Array.from(Eo(t.length));return KX([r,t],r.length+t.length)}function ste(e){const t=So(e);if((e=e.slice(vo(t))).length!==t)throw new Error("inconsistent lengths");return BZ(e)}function ate(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=BZ(t,"base32"),i=ite(r);return"".concat(n,":").concat(i)}function cte(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const o=So(e,i),s=vo(o),a=Xee(o),c=hte(a,e.slice(i+s));if(0===c){t.push([o]),r.push([o]),i+=s;continue}const u=e.slice(i+s,i+s+c);if(i+=c+s,i>e.length)throw fte("Invalid address Uint8Array: "+BZ(e,"base16"));t.push([o,u]);const l=Zee(o,u);if(r.push([o,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:ute(r),tuples:t,stringTuples:r,path:n}}function ute(e){const t=[];return e.map((e=>{const r=Xee(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),dte(t.join("/"))}function lte(e){return KX(e.map((e=>{const t=Xee(e[0]);let r=Uint8Array.from(Eo(t.code));return e.length>1&&null!=e[1]&&(r=KX([r,e[1]])),r})))}function hte(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=So(t instanceof Uint8Array?t:Uint8Array.from(t));return e+vo(e)}}function dte(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function fte(e){return new Error("Error parsing address: "+e)}const pte=Symbol.for("nodejs.util.inspect.custom"),gte=Symbol.for("@multiformats/js-multiaddr/multiaddr"),bte=[Xee("dns").code,Xee("dns4").code,Xee("dns6").code,Xee("dnsaddr").code];var yte=new WeakMap,mte=new WeakMap,vte=new WeakMap,wte=new WeakMap;class _te{constructor(e){let t;if(co(this,"bytes",void 0),ud(this,yte,void 0),ud(this,mte,void 0),ud(this,vte,void 0),ud(this,wte,void 0),co(this,gte,!0),null==e&&(e=""),e instanceof Uint8Array)t=cte(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));t=function(e){const t=[],r=[];let n=null;const i=(e=dte(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){const s=Xee(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw fte("invalid address: "+e);if(!0===s.path){n=dte(i.slice(o).join("/")),t.push([s.code,$ee(s.code,n)]),r.push([s.code,n]);break}const a=$ee(s.code,i[o]);t.push([s.code,a]),r.push([s.code,Zee(s.code,a)])}return{string:ute(r),bytes:lte(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!Ste(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=cte(e.bytes)}this.bytes=t.bytes,yS(yte,this,t.string),yS(mte,this,t.tuples),yS(vte,this,t.stringTuples),yS(wte,this,t.path)}toString(){return hd(yte,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=Xee("tcp"),s=Xee("udp"),a=Xee("ip4"),c=Xee("ip6"),u=Xee("dns6"),l=Xee("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),bte.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===u.code?6:4),h!==o.code&&h!==s.code||(t=Xee(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=Xee(h).name,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return hd(mte,this).map((e=>{let[t]=e;return Object.assign({},Xee(t))}))}protoCodes(){return hd(mte,this).map((e=>{let[t]=e;return t}))}protoNames(){return hd(mte,this).map((e=>{let[t]=e;return Xee(t).name}))}tuples(){return hd(mte,this)}stringTuples(){return hd(vte,this)}encapsulate(e){return e=new _te(e),new _te(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address ".concat(this.toString()," does not contain subaddress: ").concat(e.toString()));return new _te(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new _te(lte(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===Qee.p2p.code&&e.push([r,n]),r===Qee["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){const e=t[1];return"Q"===e[0]||"1"===e[0]?BZ(sJ.decode("z".concat(e)),"base58btc"):BZ(SX.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return hd(wte,this)}equals(e){return OJ(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=Ete.get(t.name);if(null==r)throw new ug("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>Ate(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[pte](){return"Multiaddr(".concat(hd(yte,this),")")}}const Ete=new Map;function Ste(e){return Boolean(null===e||void 0===e?void 0:e[gte])}function Ate(e){return new _te(e)}const kte=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e);})();for(const t of e);};const xte=function(e){const[t,r]=null!=e[Symbol.asyncIterator]?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:e=>{n.push(e)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}};const Ite=function(e,t){if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)await t(r)&&(yield r)}();const r=xte(e),{value:n,done:i}=r.next();if(!0===i)return function*(){}();const o=t(n);if("function"===typeof o.then)return async function*(){await o&&(yield n);for await(const e of r)await t(e)&&(yield e)}();const s=t;return function*(){!0===o&&(yield n);for(const e of r)s(e)&&(yield e)}()};const Cte=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){const r=await Ql(e);yield*r.sort(t)}():function*(){const r=Ql(e);yield*r.sort(t)}()};const Tte=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){let r=0;if(!(t<1))for await(const n of e)if(yield n,r++,r===t)return}():function*(){let r=0;if(!(t<1))for(const n of e)if(yield n,r++,r===t)return}()};class Rte{put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const{key:n,value:i}of e)await t.put(n,i,r),yield n}()}catch(r){return Promise.reject(r)}}getMany(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const n of e)yield{key:n,value:await t.get(n,r)}}()}catch(r){return Promise.reject(r)}}deleteMany(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const n of e)await t.delete(n,r),yield n}()}catch(r){return Promise.reject(r)}}batch(){let e=[],t=[];return{put(t,r){e.push({key:t,value:r})},delete(e){t.push(e)},commit:async r=>{await kte(this.putMany(e,r)),e=[],await kte(this.deleteMany(t,r)),t=[]}}}async*_all(e,t){throw new Error("._all is not implemented")}async*_allKeys(e,t){throw new Error("._allKeys is not implemented")}query(e,t){let r=this._all(e,t);if(null!=e.prefix){const t=e.prefix;r=Ite(r,(e=>e.key.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>Ite(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>Cte(e,t)),r)),null!=e.offset){let t=0;const n=e.offset;r=Ite(r,(()=>t++>=n))}return null!=e.limit&&(r=Tte(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix){const t=e.prefix;r=Ite(r,(e=>e.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>Ite(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>Cte(e,t)),r)),null!=e.offset){const t=e.offset;let n=0;r=Ite(r,(()=>n++>=t))}return null!=e.limit&&(r=Tte(r,e.limit)),r}}class Pte extends Rte{constructor(){super(),co(this,"data",void 0),this.data=new Map}put(e,t){return this.data.set(e.toString(),t),e}get(e){const t=this.data.get(e.toString());if(null==t)throw function(e){var t;return e=null!==(t=e)&&void 0!==t?t:new Error("Not Found"),ah(e,"ERR_NOT_FOUND")}();return t}has(e){return this.data.has(e.toString())}delete(e){this.data.delete(e.toString())}*_all(){for(const[e,t]of this.data.entries())yield{key:new Iee(e),value:t}}*_allKeys(){for(const e of this.data.keys())yield new Iee(e)}}const Dte=e=>e;function Nte(e,t){const r=e.getPeerId();if(null!=r){h1(r).equals(t)&&(e=e.decapsulate(Ate("/p2p/".concat(t.toString()))))}return e}class Bte{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"log",void 0),co(this,"components",void 0),co(this,"listen",void 0),co(this,"announce",void 0),co(this,"observed",void 0),co(this,"announceFilter",void 0);const{listen:n=[],announce:i=[]}=r;this.components=e,this.log=e.logger.forComponent("libp2p:address-manager"),this.listen=n.map((e=>e.toString())),this.announce=new Set(i.map((e=>e.toString()))),this.observed=new Map,this.announceFilter=null!==(t=r.announceFilter)&&void 0!==t?t:Dte,this._updatePeerStoreAddresses=function(e,t){let r;return function(){clearTimeout(r),r=setTimeout((function(){r=void 0,e()}),t)}}(this._updatePeerStoreAddresses.bind(this),1e3),e.events.addEventListener("transport:listening",(()=>{this._updatePeerStoreAddresses()})),e.events.addEventListener("transport:close",(()=>{this._updatePeerStoreAddresses()}))}_updatePeerStoreAddresses(){const e=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter((e=>{let[t,r]=e;return r.confident})).map((e=>{let[t]=e;return Ate(t)}))).map((e=>e.getPeerId()===this.components.peerId.toString()?e.decapsulate("/p2p/".concat(this.components.peerId.toString())):e));this.components.peerStore.patch(this.components.peerId,{multiaddrs:e}).catch((e=>{this.log.error("error updating addresses",e)}))}getListenAddrs(){return Array.from(this.listen).map((e=>Ate(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>Ate(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>{let[t]=e;return Ate(t)}))}addObservedAddr(e){const t=(e=Nte(e,this.components.peerId)).toString();this.observed.has(t)||this.observed.set(t,{confident:!1})}confirmObservedAddr(e){var t;const r=(e=Nte(e,this.components.peerId)).toString(),n=(null!==(t=this.observed.get(r))&&void 0!==t?t:{confident:!1}).confident;this.observed.set(r,{confident:!0}),n||this._updatePeerStoreAddresses()}removeObservedAddr(e){const t=(e=Nte(e,this.components.peerId)).toString();this.observed.delete(t)}getAddresses(){let e=this.getAnnounceAddrs().map((e=>e.toString()));0===e.length&&(e=this.components.transportManager.getAddrs().map((e=>e.toString()))),e=e.concat(Array.from(this.observed).filter((e=>{let[t,r]=e;return r.confident})).map((e=>{let[t]=e;return t})));const t=new Set(e);return this.announceFilter(Array.from(t).map((e=>Ate(e)))).map((e=>{var t;return!0===(null===(t=e.protos().pop())||void 0===t?void 0:t.path)||e.getPeerId()===this.components.peerId.toString()?e:e.encapsulate("/p2p/".concat(this.components.peerId.toString()))}))}}function Ute(e){return null!=e&&"function"===typeof e.start&&"function"===typeof e.stop}class Lte{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};co(this,"components",{}),co(this,"_started",!1),this.components={};for(const[t,r]of Object.entries(e))this.components[t]=r;null==this.components.logger&&(this.components.logger=c$())}isStarted(){return this._started}async _invokeStartableMethod(e){await Promise.all(Object.values(this.components).filter((e=>Ute(e))).map((async t=>{var r;await(null===(r=t[e])||void 0===r?void 0:r.call(t))})))}async beforeStart(){await this._invokeStartableMethod("beforeStart")}async start(){await this._invokeStartableMethod("start"),this._started=!0}async afterStart(){await this._invokeStartableMethod("afterStart")}async beforeStop(){await this._invokeStartableMethod("beforeStop")}async stop(){await this._invokeStartableMethod("stop"),this._started=!1}async afterStop(){await this._invokeStartableMethod("afterStop")}}const Mte=["metrics","connectionProtector","dns"],Ote=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];var qte=__webpack_require__(7364);const Kte=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new qte.Netmask(e)));function Fte(e){return Ox(e)?function(e){for(const t of Kte)if(t.contains(e))return!0;return!1}(e):qx(e)?/^::$/.test(t=e)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t):void 0;var t}function Vte(){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{const t=e.stringTuples();return(4===t[0][0]||41===t[0][0])&&Boolean(Fte("".concat(t[0][1])))},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}function zte(e){try{const{address:t}=e.nodeAddress();return Boolean(Fte(t))}catch{return!0}}function jte(e,t){const r=function(e,t){const r=zte(e.multiaddr),n=zte(t.multiaddr);return r&&!n?1:!r&&n?-1:0}(e,t);if(0!==r)return r;const n=function(e,t){const r=NO.exactMatch(e.multiaddr),n=NO.exactMatch(t.multiaddr);return r&&!n?1:!r&&n?-1:0}(e,t);if(0!==n)return n;const i=function(e,t){return e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}(e,t);return i}class Hte extends Event{constructor(e,t){super(e),this.detail=t}}function Gte(e){const t=[Cne.A];return null==e?t:Array.isArray(e)?0===e.length?t:e:[e]}new Uint8Array(0);function Wte(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Yte=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Qte=Yte;class Jte{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Xte{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return $te(this,e)}}class Zte{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return $te(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function $te(e,t){var r,n;return new Zte({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class ere{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Jte(e,t,r),this.decoder=new Xte(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function tre(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new ere(t,r,n,i)}function rre(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Qte(n,t);return tre({prefix:r,name:t,encode:i,decode:e=>Wte(o(e))})}function nre(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return tre({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const ire=rre({prefix:"9",name:"base10",alphabet:"0123456789"}),ore=nre({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sre=nre({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),are=nre({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),cre=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),ure=cre.reduce(((e,t,r)=>(e[r]=t,e)),[]),lre=cre.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const hre=tre({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ure[t]),"")},decode:function(e){const t=[];for(const r of e){const e=lre[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),dre=nre({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fre=nre({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),pre=nre({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gre=nre({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bre=nre({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yre=nre({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mre=nre({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vre=nre({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wre=nre({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),_re=rre({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ere=rre({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Sre=rre({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Are=rre({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),kre=nre({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xre=nre({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ire=nre({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Cre=nre({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Tre=nre({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Rre=tre({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Pre=new TextEncoder,Dre=new TextDecoder,Nre="json",Bre=512;function Ure(e){return Pre.encode(JSON.stringify(e))}function Lre(e){return JSON.parse(Dre.decode(e))}const Mre="raw",Ore=85;function qre(e){return Wte(e)}function Kre(e){return Wte(e)}var Fre=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=jre;)r[n++]=255&t|Vre,t/=128;for(;t&zre;)r[n++]=255&t|Vre,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Vre=128,zre=-128,jre=Math.pow(2,31);var Hre=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Wre)<<o:(n&Wre)*Math.pow(2,o),o+=7}while(n>=Gre);return e.bytes=s-r,i},Gre=128,Wre=127;var Yre=Math.pow(2,7),Qre=Math.pow(2,14),Jre=Math.pow(2,21),Xre=Math.pow(2,28),Zre=Math.pow(2,35),$re=Math.pow(2,42),ene=Math.pow(2,49),tne=Math.pow(2,56),rne=Math.pow(2,63);const nne={encode:Fre,decode:Hre,encodingLength:function(e){return e<Yre?1:e<Qre?2:e<Jre?3:e<Xre?4:e<Zre?5:e<$re?6:e<ene?7:e<tne?8:e<rne?9:10}};function ine(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return nne.encode(e,t,r),t}function one(e){return nne.encodingLength(e)}function sne(e,t){const r=t.byteLength,n=one(e),i=n+one(r),o=new Uint8Array(i+r);return ine(e,o,0),ine(r,o,n),o.set(t,i),new ane(e,r,t,o)}class ane{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const cne=Wte;const une={code:0,name:"identity",encode:cne,digest:function(e){return sne(0,cne(e))}};function lne(e){let{name:t,code:r,encode:n}=e;return new hne(t,r,n)}class hne{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?sne(this.code,t):t.then((e=>sne(this.code,e)))}throw Error("Unknown type, must be binary type")}}function dne(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const fne=lne({name:"sha2-256",code:18,encode:dne("SHA-256")}),pne=lne({name:"sha2-512",code:19,encode:dne("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const gne={...ci,...ti,...ai,...$n,...ei,...ni,...ii,...oi,...si,...ri};function bne(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const yne=bne("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),mne=bne("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),vne={utf8:yne,"utf-8":yne,hex:gne.base16,latin1:mne,ascii:mne,binary:mne,...gne};function wne(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=vne[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}const _ne=60;function Ene(e){var t,r,n,i,o,s,a,c,u,l,h,d,f,p,g;return{Status:null!==(t=e.Status)&&void 0!==t?t:0,TC:null!==(r=null!==(n=e.TC)&&void 0!==n?n:e.flag_tc)&&void 0!==r&&r,RD:null!==(i=null!==(o=e.RD)&&void 0!==o?o:e.flag_rd)&&void 0!==i&&i,RA:null!==(s=null!==(a=e.RA)&&void 0!==a?a:e.flag_ra)&&void 0!==s&&s,AD:null!==(c=null!==(u=e.AD)&&void 0!==u?u:e.flag_ad)&&void 0!==c&&c,CD:null!==(l=null!==(h=e.CD)&&void 0!==h?h:e.flag_cd)&&void 0!==l&&l,Question:(null!==(d=null!==(f=e.Question)&&void 0!==f?f:e.questions)&&void 0!==d?d:[]).map((e=>({name:e.name,type:Cne[e.type]}))),Answer:(null!==(p=null!==(g=e.Answer)&&void 0!==g?g:e.answers)&&void 0!==p?p:[]).map((e=>{var t,r;return{name:e.name,type:Cne[e.type],TTL:null!==(t=null!==(r=e.TTL)&&void 0!==r?r:e.ttl)&&void 0!==t?t:_ne,data:e.data instanceof Uint8Array?wne(e.data):e.data}}))}}const Sne=4;function Ane(e){var t;const r=new J5({concurrency:null!==(t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).queryConcurrency)&&void 0!==t?t:Sne});return async function(t){var n;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=new URLSearchParams;o.set("name",t),Gte(i.types).forEach((e=>{o.append("type",Cne[e])})),null===(n=i.onProgress)||void 0===n||n.call(i,new Hte("dns:query",{detail:t}));const s=await r.add((async()=>{var t;const r=await fetch("".concat(e,"?").concat(o),{headers:{accept:"application/dns-json"},signal:null===i||void 0===i?void 0:i.signal});if(200!==r.status)throw new Error("Unexpected HTTP status: ".concat(r.status," - ").concat(r.statusText));const n=Ene(await r.json());return null===(t=i.onProgress)||void 0===t||t.call(i,new Hte("dns:response",{detail:n})),n}),{signal:i.signal});if(null==s)throw new Error("No DNS response received");return s}}var kne=__webpack_require__(101);class xne{constructor(e){co(this,"lru",void 0),this.lru=kne(e)}get(e,t){let r=!0;const n=[];for(const i of t){const t=this.getAnswers(e,i);if(0===t.length){r=!1;break}n.push(...t)}if(r)return Ene({answers:n})}getAnswers(e,t){const r="".concat(e.toLowerCase(),"-").concat(t),n=this.lru.get(r);if(null!=n){const e=n.filter((e=>e.expires>Date.now())).map((e=>{let{expires:t,value:r}=e;return{...r,TTL:Math.round((t-Date.now())/1e3),type:Cne[r.type]}}));return 0===e.length&&this.lru.remove(r),e}return[]}add(e,t){var r,n;const i="".concat(e.toLowerCase(),"-").concat(t.type),o=null!==(r=this.lru.get(i))&&void 0!==r?r:[];o.push({expires:Date.now()+1e3*(null!==(n=t.TTL)&&void 0!==n?n:_ne),value:t}),this.lru.set(i,o)}remove(e,t){const r="".concat(e.toLowerCase(),"-").concat(t);this.lru.remove(r)}clear(){this.lru.clear()}}class Ine{constructor(e){var t,r,n;co(this,"resolvers",void 0),co(this,"cache",void 0),this.resolvers={},this.cache=(n=null!==(t=e.cacheSize)&&void 0!==t?t:1e3,new xne(n)),Object.entries(null!==(r=e.resolvers)&&void 0!==r?r:{}).forEach((e=>{let[t,r]=e;Array.isArray(r)||(r=[r]),t.endsWith(".")||(t="".concat(t,".")),this.resolvers[t]=r})),null==this.resolvers["."]&&(this.resolvers["."]=[Ane("https://cloudflare-dns.com/dns-query"),Ane("https://dns.google/resolve")])}async query(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=Gte(r.types),i=!1!==r.cached?this.cache.get(e,n):void 0;var o;if(null!=i)return null===(o=r.onProgress)||void 0===o||o.call(r,new Hte("dns:cache",{detail:i})),i;const s="".concat(e.split(".").pop(),"."),a=(null!==(t=this.resolvers[s])&&void 0!==t?t:this.resolvers["."]).sort((()=>Math.random()>.5?-1:1)),c=[];for(const d of a){var u;if(!0===(null===(u=r.signal)||void 0===u?void 0:u.aborted))break;try{const t=await d(e,{...r,types:n});for(const r of t.Answer)this.cache.add(e,r);return t}catch(h){var l;c.push(h),null===(l=r.onProgress)||void 0===l||l.call(r,new Hte("dns:error",{detail:h}))}}if(1===c.length)throw c[0];throw new AggregateError(c,"DNS lookup of ".concat(e," ").concat(n," failed"))}}var Cne;!function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"}(Cne||(Cne={}));const{code:Tne}=Xee("dnsaddr"),Rne=async function(e){var t,r,n;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=null!==(t=i.maxRecursiveDepth)&&void 0!==t?t:32;if(0===o)throw new ug("Max recursive depth reached","ERR_MAX_RECURSIVE_DEPTH_REACHED");const[,s]=null!==(r=e.stringTuples().find((e=>{let[t]=e;return t===Tne})))&&void 0!==r?r:[],a=null!==(n=null===i||void 0===i?void 0:i.dns)&&void 0!==n?n:function(){return new Ine(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}(),c=await a.query("_dnsaddr.".concat(s),{signal:null===i||void 0===i?void 0:i.signal,types:[Cne.TXT]}),u=e.getPeerId(),l=[];for(const h of c.Answer){const e=h.data.split("=")[1];if(null==e)continue;if(null!=u&&!e.includes(u))continue;const t=Ate(e);if(e.startsWith("/dnsaddr")){const e=await t.resolve({...i,maxRecursiveDepth:o-1});l.push(...e.map((e=>e.toString())))}else l.push(t.toString())}return l};const Pne=__webpack_require__(8355);var Dne,Nne;!function(e){e.NOT_STARTED_YET="The libp2p node is not started yet",e.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",e.NOT_FOUND="Not found"}(Dne||(Dne={})),function(e){e.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",e.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",e.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",e.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",e.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",e.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",e.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",e.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",e.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",e.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",e.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",e.ERR_DIALED_SELF="ERR_DIALED_SELF",e.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",e.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",e.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",e.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",e.ERR_INVALID_KEY="ERR_INVALID_KEY",e.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_INVALID_PEER="ERR_INVALID_PEER",e.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",e.ERR_NOT_FOUND="ERR_NOT_FOUND",e.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",e.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",e.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",e.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",e.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",e.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",e.ERR_FIND_SELF="ERR_FIND_SELF",e.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",e.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",e.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",e.ERR_INVALID_CMS="ERR_INVALID_CMS",e.ERR_MISSING_KEYS="ERR_MISSING_KEYS",e.ERR_NO_KEY="ERR_NO_KEY",e.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",e.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",e.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",e.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",e.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",e.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",e.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",e.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",e.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",e.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",e.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",e.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",e.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",e.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",e.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",e.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",e.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",e.ERR_INVALID_RECORD="ERR_INVALID_RECORD",e.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",e.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",e.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",e.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",e.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",e.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"}(Nne||(Nne={}));const Bne={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:Rne},addressSorter:jte},transportManager:{faultTolerance:zF.FATAL_ALL}};async function Une(e){var t;const r=Pne(Bne,e);if(null===r.connectionProtector&&null!=(null===(t=globalThis.process)||void 0===t||null===(t=t.env)||void 0===t?void 0:t.LIBP2P_FORCE_PNET))throw new ug(Dne.ERR_PROTECTOR_REQUIRED,Nne.ERR_PROTECTOR_REQUIRED);if(!(await async function(e,t){return e.length===o1?new u1({multihash:CJ(DJ.code,e),privateKey:t}):e.length===s1?new l1({multihash:CJ(DJ.code,e),privateKey:t}):new c1({multihash:await LJ.digest(e),publicKey:e,privateKey:t})}(r.privateKey.public.bytes,r.privateKey.bytes)).equals(r.peerId))throw new ug("Private key doesn't match peer id",Nne.ERR_INVALID_KEY);return r}function Lne(e){if(Um(e))return{peerId:e,multiaddrs:[]};let t;if(Array.isArray(e)||(e=[e]),e.length>0){const r=e[0].getPeerId();t=null==r?void 0:h1(r),e.forEach((e=>{if(!Ste(e))throw new ug("Invalid Multiaddr",Nne.ERR_INVALID_MULTIADDR);const r=e.getPeerId();if(null==r){if(null!=t)throw new ug("Multiaddrs must all have the same peer id or have no peer id",Nne.ERR_INVALID_PARAMETERS)}else{const e=h1(r);if(null==t||!t.equals(e))throw new ug("Multiaddrs must all have the same peer id or have no peer id",Nne.ERR_INVALID_PARAMETERS)}}))}return{peerId:t,multiaddrs:e}}class Mne extends Error{constructor(e,t){super(null!==e&&void 0!==e?e:"The operation was aborted"),co(this,"type",void 0),co(this,"code",void 0),this.type="aborted",this.name="AbortError",this.code=null!==t&&void 0!==t?t:"ABORT_ERR"}}async function One(e,t,r,n){const i=new Mne(null===n||void 0===n?void 0:n.errorMessage,null===n||void 0===n?void 0:n.errorCode);return!0===(null===r||void 0===r?void 0:r.aborted)?Promise.reject(i):new Promise(((o,s)=>{const a=i=>{try{var u;if(!1===(null===n||void 0===n||null===(u=n.filter)||void 0===u?void 0:u.call(n,i)))return}catch(l){return e.removeEventListener(t,a),null===r||void 0===r||r.removeEventListener("abort",c),void s(l)}e.removeEventListener(t,a),null===r||void 0===r||r.removeEventListener("abort",c),o(i)},c=()=>{e.removeEventListener(t,a),null===r||void 0===r||r.removeEventListener("abort",c),s(i)};e.addEventListener(t,a),null===r||void 0===r||r.addEventListener("abort",c)}))}class qne{constructor(e,t){var r;co(this,"deferred",void 0),co(this,"signal",void 0),co(this,"where",void 0),this.signal=t,this.deferred=hh(),this.where=e,this.onAbort=this.onAbort.bind(this),null===(r=this.signal)||void 0===r||r.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(new cg)}cleanup(){var e;null===(e=this.signal)||void 0===e||e.removeEventListener("abort",this.onAbort)}}class Kne{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;co(this,"id",void 0),co(this,"fn",void 0),co(this,"options",void 0),co(this,"priority",void 0),co(this,"recipients",void 0),co(this,"status",void 0),co(this,"timeline",void 0),co(this,"controller",void 0),this.id="".concat(parseInt(String(1e9*Math.random()),10).toString()).concat(Date.now()),this.status="queued",this.fn=e,this.priority=r,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,dd(1/0,this.controller.signal),this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce(((e,t)=>{var r;return e&&!0===(null===(r=t.signal)||void 0===r?void 0:r.aborted)}),!0)&&this.controller.abort(new cg)}async join(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=new qne(new Error("where").stack,t.signal);return this.recipients.push(r),null===(e=t.signal)||void 0===e||e.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{var e;this.controller.signal.throwIfAborted();const t=await Id(this.fn({...null!==(e=this.options)&&void 0!==e?e:{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach((e=>{e.deferred.resolve(t)})),this.status="complete"}catch(t){this.recipients.forEach((e=>{e.deferred.reject(t)})),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach((e=>{var t;null===(t=e.signal)||void 0===t||t.removeEventListener("abort",this.onAbort)}))}}class Fne extends gd{constructor(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var r;(super(),co(this,"concurrency",void 0),co(this,"queue",void 0),co(this,"pending",void 0),this.concurrency=null!==(e=t.concurrency)&&void 0!==e?e:Number.POSITIVE_INFINITY,this.pending=0,null!=t.metricName)&&(null===(r=t.metrics)||void 0===r||r.registerMetricGroup(t.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}));this.queue=[]}tryToStartAnother(){if(0===this.size)return queueMicrotask((()=>{this.safeDispatchEvent("empty")})),0===this.running&&queueMicrotask((()=>{this.safeDispatchEvent("idle")})),!1;if(this.pending<this.concurrency){let e;for(const t of this.queue)if("queued"===t.status){e=t;break}return null!=e&&(this.safeDispatchEvent("active"),this.pending++,e.run().finally((()=>{for(let t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")})),!0)}return!1}enqueue(e){var t;if((null===(t=this.queue[this.size-1])||void 0===t?void 0:t.priority)>=e.priority)return void this.queue.push(e);const r=function(e,t,r){let n=0,i=e.length;for(;i>0;){const o=Math.trunc(i/2);let s=n+o;r(e[s],t)<=0?(n=++s,i-=o+1):i=o}return n}(this.queue,e,((e,t)=>t.priority-e.priority));this.queue.splice(r,0,e)}async add(e,t){var r;null===t||void 0===t||null===(r=t.signal)||void 0===r||r.throwIfAborted();const n=new Kne(e,t,null===t||void 0===t?void 0:t.priority),i=n.join(t).then((e=>(this.safeDispatchEvent("completed",{detail:e}),e))).catch((e=>{throw this.safeDispatchEvent("error",{detail:e}),e}));return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),i}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach((e=>{e.abort(new cg)})),this.clear()}async onEmpty(e){0!==this.size&&await One(this,"empty",null===e||void 0===e?void 0:e.signal)}async onSizeLessThan(e,t){this.size<e||await One(this,"next",null===t||void 0===t?void 0:t.signal,{filter:()=>this.size<e})}async onIdle(e){0===this.pending&&0===this.size||await One(this,"idle",null===e||void 0===e?void 0:e.signal)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){var t,r;null===e||void 0===e||null===(t=e.signal)||void 0===t||t.throwIfAborted();const n=gh({objectMode:!0}),i=e=>{null!=e?this.abort():this.clear(),n.end(e)},o=e=>{null!=e.detail&&n.push(e.detail)},s=e=>{i(e.detail)},a=()=>{i()},c=()=>{i(new ug("Queue aborted","ERR_QUEUE_ABORTED"))};this.addEventListener("completed",o),this.addEventListener("error",s),this.addEventListener("idle",a),null===e||void 0===e||null===(r=e.signal)||void 0===r||r.addEventListener("abort",c);try{yield*n}finally{var u;this.removeEventListener("completed",o),this.removeEventListener("error",s),this.removeEventListener("idle",a),null===e||void 0===e||null===(u=e.signal)||void 0===u||u.removeEventListener("abort",c),i()}}}class Vne extends Fne{has(e){return null!=this.find(e)}find(e){return this.queue.find((t=>e.equals(t.options.peerId)))}}const zne="last-dial-failure",jne={minConnections:5,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3,autoDialPeerRetryThreshold:42e4,autoDialDiscoveredPeersDebounce:10};class Hne{constructor(e,t){var r,n,i,o,s,a,c;let u;co(this,"connectionManager",void 0),co(this,"peerStore",void 0),co(this,"queue",void 0),co(this,"minConnections",void 0),co(this,"autoDialPriority",void 0),co(this,"autoDialIntervalMs",void 0),co(this,"autoDialMaxQueueLength",void 0),co(this,"autoDialPeerRetryThresholdMs",void 0),co(this,"autoDialDiscoveredPeersDebounce",void 0),co(this,"autoDialInterval",void 0),co(this,"started",void 0),co(this,"running",void 0),co(this,"log",void 0),this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.minConnections=null!==(r=t.minConnections)&&void 0!==r?r:jne.minConnections,this.autoDialPriority=null!==(n=t.autoDialPriority)&&void 0!==n?n:jne.autoDialPriority,this.autoDialIntervalMs=null!==(i=t.autoDialInterval)&&void 0!==i?i:jne.autoDialInterval,this.autoDialMaxQueueLength=null!==(o=t.maxQueueLength)&&void 0!==o?o:jne.maxQueueLength,this.autoDialPeerRetryThresholdMs=null!==(s=t.autoDialPeerRetryThreshold)&&void 0!==s?s:jne.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=null!==(a=t.autoDialDiscoveredPeersDebounce)&&void 0!==a?a:jne.autoDialDiscoveredPeersDebounce,this.log=e.logger.forComponent("libp2p:connection-manager:auto-dial"),this.started=!1,this.running=!1,this.queue=new Vne({concurrency:null!==(c=t.autoDialConcurrency)&&void 0!==c?c:jne.autoDialConcurrency,metricName:"libp2p_autodial_queue",metrics:e.metrics}),this.queue.addEventListener("error",(e=>{this.log.error("error during auto-dial",e.detail)})),e.events.addEventListener("connection:close",(()=>{this.autoDial().catch((e=>{this.log.error(e)}))})),e.events.addEventListener("peer:discovery",(()=>{clearTimeout(u),u=setTimeout((()=>{this.autoDial().catch((e=>{this.log.error(e)}))}),this.autoDialDiscoveredPeersDebounce)}))}isStarted(){return this.started}start(){this.started=!0}afterStart(){this.autoDial().catch((e=>{this.log.error("error while autodialing",e)}))}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started||this.running)return;const e=this.connectionManager.getConnectionsMap(),t=e.size;if(t>=this.minConnections)return void(this.minConnections>0&&this.log.trace("have enough connections %d/%d",t,this.minConnections));if(this.queue.size>this.autoDialMaxQueueLength)return this.log("not enough connections %d/%d but auto dial queue is full",t,this.minConnections),void this.sheduleNextAutodial();this.running=!0,this.log("not enough connections %d/%d - will dial peers to increase the number of connections",t,this.minConnections);const r=new t1(this.connectionManager.getDialQueue().map((e=>e.peerId)).filter(Boolean)),n=await this.peerStore.all({filters:[t=>0===t.addresses.length?(this.log.trace("not autodialing %p because they have no addresses",t.id),!1):e.has(t.id)?(this.log.trace("not autodialing %p because they are already connected",t.id),!1):r.has(t.id)?(this.log.trace("not autodialing %p because they are already being dialed",t.id),!1):!this.queue.has(t.id)||(this.log.trace("not autodialing %p because they are already being autodialed",t.id),!1)]}),i=n.sort((()=>Math.random()>.5?1:-1)),o=new K6;for(const a of i)o.has(a.id)||o.set(a.id,[...a.tags.values()].reduce(((e,t)=>e+t.value),0));const s=i.sort(((e,t)=>{var r,n;const i=null!==(r=o.get(e.id))&&void 0!==r?r:0,s=null!==(n=o.get(t.id))&&void 0!==n?n:0;return i>s?-1:i<s?1:0})).filter((e=>{const t=e.metadata.get(zne);if(null==t)return!0;const r=parseInt(BZ(t));return!!isNaN(r)||Date.now()-r>this.autoDialPeerRetryThresholdMs}));this.log("selected %d/%d peers to dial",s.length,n.length);for(const a of s)this.queue.add((async()=>{const e=this.connectionManager.getConnectionsMap().size;if(e>=this.minConnections)return this.log("got enough connections now %d/%d",e,this.minConnections),void this.queue.clear();this.log("connecting to a peerStore stored peer %p",a.id),await this.connectionManager.openConnection(a.id,{priority:this.autoDialPriority})}),{peerId:a.id}).catch((e=>{this.log.error("could not connect to peerStore stored peer",e)}));this.running=!1,this.sheduleNextAutodial()}sheduleNextAutodial(){this.started&&(this.autoDialInterval=setTimeout((()=>{this.autoDial().catch((e=>{this.log.error("error while autodialing",e)}))}),this.autoDialIntervalMs))}}const Gne={maxConnections:100,allow:[]};class Wne{constructor(e){var t,r;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"maxConnections",void 0),co(this,"connectionManager",void 0),co(this,"peerStore",void 0),co(this,"allow",void 0),co(this,"events",void 0),co(this,"log",void 0),this.maxConnections=null!==(t=n.maxConnections)&&void 0!==t?t:Gne.maxConnections,this.allow=null!==(r=n.allow)&&void 0!==r?r:Gne.allow,this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.events=e.events,this.log=e.logger.forComponent("libp2p:connection-manager:connection-pruner"),e.events.addEventListener("connection:open",(()=>{this.maybePruneConnections().catch((e=>{this.log.error(e)}))}))}async maybePruneConnections(){const e=this.connectionManager.getConnections(),t=e.length,r=Math.max(t-this.maxConnections,0);if(this.log("checking max connections limit %d/%d",t,this.maxConnections),t<=this.maxConnections)return;this.log("max connections limit exceeded %d/%d, pruning %d connection(s)",t,this.maxConnections,r);const n=new K6;for(const a of e){const e=a.remotePeer;if(!n.has(e)){n.set(e,0);try{const t=await this.peerStore.get(e);n.set(e,[...t.tags.values()].reduce(((e,t)=>e+t.value),0))}catch(s){"ERR_NOT_FOUND"!==s.code&&this.log.error("error loading peer tags",s)}}}const i=e.sort(((e,t)=>{var r,i;const o=null!==(r=n.get(e.remotePeer))&&void 0!==r?r:0,s=null!==(i=n.get(t.remotePeer))&&void 0!==i?i:0;if(o>s)return 1;if(o<s)return-1;const a=e.timeline.open,c=t.timeline.open;return a<c?1:a>c?-1:0})),o=[];for(const a of i){this.log("too many connections open - closing a connection to %p",a.remotePeer);if(this.allow.some((e=>a.remoteAddr.toString().startsWith(e.toString())))||o.push(a),o.length===r)break}await Promise.all(o.map((async e=>{try{await e.close()}catch(s){this.log.error(s)}}))),this.events.safeDispatchEvent("connection:prune",{detail:o})}}const Yne={addressSorter:jte,maxParallelDials:50,maxDialQueueLength:500,maxPeerAddrsToDial:25,dialTimeout:5e3,resolvers:{dnsaddr:Rne}};class Qne{constructor(e){var t,r,n,i,o,s;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"queue",void 0),co(this,"components",void 0),co(this,"addressSorter",void 0),co(this,"maxPeerAddrsToDial",void 0),co(this,"maxDialQueueLength",void 0),co(this,"dialTimeout",void 0),co(this,"shutDownController",void 0),co(this,"connections",void 0),co(this,"log",void 0),this.addressSorter=null!==(t=a.addressSorter)&&void 0!==t?t:Yne.addressSorter,this.maxPeerAddrsToDial=null!==(r=a.maxPeerAddrsToDial)&&void 0!==r?r:Yne.maxPeerAddrsToDial,this.maxDialQueueLength=null!==(n=a.maxDialQueueLength)&&void 0!==n?n:Yne.maxDialQueueLength,this.dialTimeout=null!==(i=a.dialTimeout)&&void 0!==i?i:Yne.dialTimeout,this.connections=null!==(o=a.connections)&&void 0!==o?o:new K6,this.log=e.logger.forComponent("libp2p:connection-manager:dial-queue"),this.components=e,this.shutDownController=new AbortController,dd(1/0,this.shutDownController.signal);for(const[u,l]of Object.entries(null!==(c=a.resolvers)&&void 0!==c?c:{})){var c;Ete.set(u,l)}this.queue=new Fne({concurrency:null!==(s=a.maxParallelDials)&&void 0!==s?s:Yne.maxParallelDials,metricName:"libp2p_dial_queue",metrics:e.metrics}),this.queue.addEventListener("error",(e=>{this.log.error("error in dial queue",e.detail)}))}start(){this.shutDownController=new AbortController,dd(1/0,this.shutDownController.signal)}stop(){this.shutDownController.abort(),this.queue.abort()}async dial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{peerId:r,multiaddrs:n}=Lne(e),i=Array.from(this.connections.values()).flat().find((e=>!0!==t.force&&(!!e.remotePeer.equals(r)||n.find((t=>t.equals(e.remoteAddr))))));if(null!=i)return this.log("already connected to %a",i.remoteAddr),i;const o=this.queue.queue.find((e=>{if(!0===(null===r||void 0===r?void 0:r.equals(e.options.peerId)))return!0;const t=e.options.multiaddrs;if(null==t)return!1;for(const r of n)if(t.has(r.toString()))return!0;return!1}));if(null!=o){this.log("joining existing dial target for %p",r);for(const e of n)o.options.multiaddrs.add(e.toString());return o.join(t)}if(this.queue.size>=this.maxDialQueueLength)throw new ug("Dial queue is full","ERR_DIAL_QUEUE_FULL");return this.log("creating dial target for %p",r,n.map((e=>e.toString()))),this.queue.add((async e=>{const t=this.createDialAbortController(null===e||void 0===e?void 0:e.signal);let n;try{n=await this.calculateMultiaddrs(r,null===e||void 0===e?void 0:e.multiaddrs,{...e,signal:t}),n.map((e=>{let{multiaddr:t}=e;return t.toString()})).forEach((t=>{null===e||void 0===e||e.multiaddrs.add(t)}))}catch(i){throw t.clear(),i}try{let o=0;const s=[];for(const a of n){if(o===this.maxPeerAddrsToDial)throw this.log("dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others",o,r),new ug("Peer had more than maxPeerAddrsToDial",Nne.ERR_TOO_MANY_ADDRESSES);o++;try{const r=await this.components.transportManager.dial(a.multiaddr,{...e,signal:t});return this.log("dial to %a succeeded",a.multiaddr),r}catch(i){if(this.log.error("dial failed to %a",a.multiaddr,i),null!=r)try{await this.components.peerStore.patch(r,{metadata:{[zne]:BX(Date.now().toString())}})}catch(i){this.log.error("could not update last dial failure key for %p",r,i)}if(t.aborted)throw new ug(i.message,pg);s.push(i)}}if(1===s.length)throw s[0];throw new lg(s,"All multiaddr dials failed",Nne.ERR_TRANSPORT_DIAL_FAILED)}finally{t.clear()}}),{peerId:r,priority:t.priority,multiaddrs:new Set(n.map((e=>e.toString()))),signal:t.signal})}createDialAbortController(e){const t=function(e){const t=new globalThis.AbortController;function r(){t.abort();for(const t of e)null!=(null===t||void 0===t?void 0:t.removeEventListener)&&t.removeEventListener("abort",r)}for(const i of e){if(!0===(null===i||void 0===i?void 0:i.aborted)){r();break}null!=(null===i||void 0===i?void 0:i.addEventListener)&&i.addEventListener("abort",r)}const n=t.signal;return n.clear=function(){for(const t of e)null!=(null===t||void 0===t?void 0:t.removeEventListener)&&t.removeEventListener("abort",r)},n}([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);return dd(1/0,t),t}async calculateMultiaddrs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=[...t].map((e=>({multiaddr:Ate(e),isCertified:!1})));if(null!=e){var i,o;if(this.components.peerId.equals(e))throw new ug("Tried to dial self",Nne.ERR_DIALED_SELF);if(!0===await(null===(i=(o=this.components.connectionGater).denyDialPeer)||void 0===i?void 0:i.call(o,e)))throw new ug("The dial request is blocked by gater.allowDialPeer",Nne.ERR_PEER_DIAL_INTERCEPTED);if(0===n.length){this.log("loading multiaddrs for %p",e);try{const t=await this.components.peerStore.get(e);n.push(...t.addresses),this.log("loaded multiaddrs for %p",e,n.map((e=>{let{multiaddr:t}=e;return t.toString()})))}catch(d){if(d.code!==Nne.ERR_NOT_FOUND)throw d}}if(0===n.length){this.log("looking up multiaddrs for %p in the peer routing",e);try{const t=await this.components.peerRouting.findPeer(e);this.log("found multiaddrs for %p in the peer routing",e,n.map((e=>{let{multiaddr:t}=e;return t.toString()}))),n.push(...t.multiaddrs.map((e=>({multiaddr:e,isCertified:!1}))))}catch(d){d.code!==Nne.ERR_NO_ROUTERS_AVAILABLE&&this.log.error("looking up multiaddrs for %p in the peer routing failed",e,d)}}}let s=(await Promise.all(n.map((async e=>{const t=await async function(e,t){let r=!1;for(const i of Ete.keys())if(r=e.protoNames().includes(i),r)break;if(!r)return[e];const n=await e.resolve(t);return t.log("resolved %s to",e,n.map((e=>e.toString()))),n}(e.multiaddr,{dns:this.components.dns,...r,log:this.log});return 1===t.length&&t[0].equals(e.multiaddr)?e:t.map((e=>({multiaddr:e,isCertified:!1})))})))).flat();if(null!=e){const t="/p2p/".concat(e.toString());s=s.map((e=>{const r=e.multiaddr.protos().pop();return!0===(null===r||void 0===r?void 0:r.path)?e:null==e.multiaddr.getPeerId()?{multiaddr:e.multiaddr.encapsulate(t),isCertified:e.isCertified}:e}))}const a=s.filter((t=>{if(null==this.components.transportManager.transportForMultiaddr(t.multiaddr))return!1;const r=t.multiaddr.getPeerId();return null==e||null==r||e.equals(r)})),c=new Map;for(const f of a){const e=f.multiaddr.toString(),t=c.get(e);null==t?c.set(e,f):t.isCertified=t.isCertified||f.isCertified||!1}const u=[...c.values()];if(0===u.length)throw new ug("The dial request has no valid addresses",Nne.ERR_NO_VALID_ADDRESSES);const l=[];for(const f of u)null!=this.components.connectionGater.denyDialMultiaddr&&await this.components.connectionGater.denyDialMultiaddr(f.multiaddr)||l.push(f);const h=l.sort(this.addressSorter);if(0===h.length)throw new ug("The connection gater denied all addresses in the dial request",Nne.ERR_NO_VALID_ADDRESSES);return this.log.trace("addresses for %p before filtering",null!==e&&void 0!==e?e:"unknown peer",s.map((e=>{let{multiaddr:t}=e;return t.toString()}))),this.log.trace("addresses for %p after filtering",null!==e&&void 0!==e?e:"unknown peer",h.map((e=>{let{multiaddr:t}=e;return t.toString()}))),h}}const Jne=5,Xne=100,Zne=5,$ne=10,eie=25,tie=0,rie=100;class nie{constructor(e){var t,r,n,i,o,s,a,c,u,l,h,d,f,p,g;let b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"started",void 0),co(this,"connections",void 0),co(this,"allow",void 0),co(this,"deny",void 0),co(this,"maxIncomingPendingConnections",void 0),co(this,"incomingPendingConnections",void 0),co(this,"maxConnections",void 0),co(this,"dialQueue",void 0),co(this,"autoDial",void 0),co(this,"connectionPruner",void 0),co(this,"inboundConnectionRateLimiter",void 0),co(this,"peerStore",void 0),co(this,"metrics",void 0),co(this,"events",void 0),co(this,"log",void 0),this.maxConnections=null!==(t=b.maxConnections)&&void 0!==t?t:Xne;const y=null!==(r=b.minConnections)&&void 0!==r?r:Jne;if(this.maxConnections<y)throw new ug("Connection Manager maxConnections must be greater than minConnections",Nne.ERR_INVALID_PARAMETERS);this.connections=new K6,this.started=!1,this.peerStore=e.peerStore,this.metrics=e.metrics,this.events=e.events,this.log=e.logger.forComponent("libp2p:connection-manager"),this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),this.allow=(null!==(n=b.allow)&&void 0!==n?n:[]).map((e=>Ate(e))),this.deny=(null!==(i=b.deny)&&void 0!==i?i:[]).map((e=>Ate(e))),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=null!==(o=b.maxIncomingPendingConnections)&&void 0!==o?o:$ne,this.inboundConnectionRateLimiter=new Vq({points:null!==(s=b.inboundConnectionThreshold)&&void 0!==s?s:Zne,duration:1}),this.autoDial=new Hne({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{minConnections:y,autoDialConcurrency:null!==(a=b.autoDialConcurrency)&&void 0!==a?a:eie,autoDialPriority:null!==(c=b.autoDialPriority)&&void 0!==c?c:tie,maxQueueLength:null!==(u=b.autoDialMaxQueueLength)&&void 0!==u?u:rie}),this.connectionPruner=new Wne({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new Qne(e,{addressSorter:null!==(l=b.addressSorter)&&void 0!==l?l:jte,maxParallelDials:null!==(h=b.maxParallelDials)&&void 0!==h?h:50,maxDialQueueLength:null!==(d=b.maxDialQueueLength)&&void 0!==d?d:500,maxPeerAddrsToDial:null!==(f=b.maxPeerAddrsToDial)&&void 0!==f?f:25,dialTimeout:null!==(p=b.dialTimeout)&&void 0!==p?p:5e3,resolvers:null!==(g=b.resolvers)&&void 0!==g?g:{dnsaddr:Rne},connections:this.connections})}isStarted(){return this.started}async start(){var e,t,r;null===(e=this.metrics)||void 0===e||e.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{const e={inbound:0,outbound:0};for(const t of this.connections.values())for(const r of t)"inbound"===r.direction?e.inbound++:e.outbound++;return e}}),null===(t=this.metrics)||void 0===t||t.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{const e={};for(const n of this.connections.values())for(const i of n)for(const n of i.streams){var t,r;const i="".concat(n.direction," ").concat(null!==(t=n.protocol)&&void 0!==t?t:"unnegotiated");e[i]=(null!==(r=e[i])&&void 0!==r?r:0)+1}return e}}),null===(r=this.metrics)||void 0===r||r.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const e={};for(const o of this.connections.values())for(const i of o){const o={};for(const e of i.streams){var t,r;const n="".concat(e.direction," ").concat(null!==(t=e.protocol)&&void 0!==t?t:"unnegotiated");o[n]=(null!==(r=o[n])&&void 0!==r?r:0)+1}for(const[t,r]of Object.entries(o)){var n;e[t]=null!==(n=e[t])&&void 0!==n?n:[],e[t].push(r)}}const i={};for(let[o,s]of Object.entries(e)){s=s.sort(((e,t)=>e-t));const e=Math.floor(.9*s.length);i[o]=s[e]}return i}}),this.dialQueue.start(),this.autoDial.start(),this.started=!0,this.log("started")}async afterStart(){Promise.resolve().then((async()=>{const e=await this.peerStore.all({filters:[e=>e.tags.has("keep-alive")]});await Promise.all(e.map((async e=>{await this.openConnection(e.id).catch((e=>{this.log.error(e)}))})))})).catch((e=>{this.log.error(e)})),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();const e=[];for(const t of this.connections.values())for(const r of t)e.push((async()=>{try{await r.close()}catch(e){this.log.error(e)}})());this.log("closing %d connections",e.length),await Promise.all(e),this.connections.clear(),this.log("stopped")}onConnect(e){this._onConnect(e).catch((e=>{this.log.error(e)}))}async _onConnect(e){const{detail:t}=e;if(!this.started)return void await t.close();const r=t.remotePeer,n=this.connections.get(r);let i=!1;null!=n?n.push(t):(i=!0,this.connections.set(r,[t])),null!=r.publicKey&&"RSA"===r.type&&await this.peerStore.patch(r,{publicKey:r.publicKey}),i&&this.events.safeDispatchEvent("peer:connect",{detail:t.remotePeer})}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const r=t.remotePeer;let n=this.connections.get(r);null!=n&&n.length>1?(n=n.filter((e=>e.id!==t.id)),this.connections.set(r,n)):null!=n&&(this.connections.delete(r),this.events.safeDispatchEvent("peer:disconnect",{detail:t.remotePeer}))}getConnections(e){var t;if(null!=e)return null!==(t=this.connections.get(e))&&void 0!==t?t:[];let r=[];for(const n of this.connections.values())r=r.concat(n);return r}getConnectionsMap(){return this.connections}async openConnection(e){var t,r;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isStarted())throw new ug("Not started",Nne.ERR_NODE_NOT_STARTED);null===(t=n.signal)||void 0===t||t.throwIfAborted();const{peerId:i}=Lne(e);if(null!=i&&!0!==n.force){this.log("dial %p",i);const e=this.getConnections(i).find((e=>!e.transient));if(null!=e)return this.log("had an existing non-transient connection to %p",i),e}const o=await this.dialQueue.dial(e,{...n,priority:null!==(r=n.priority)&&void 0!==r?r:50});let s=this.connections.get(o.remotePeer);null==s&&(s=[],this.connections.set(o.remotePeer,s));let a=!1;for(const c of s)c.id===o.id&&(a=!0);return a||s.push(o),o}async closeConnections(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=null!==(t=this.connections.get(e))&&void 0!==t?t:[];await Promise.all(n.map((async e=>{try{await e.close(r)}catch(t){e.abort(t)}})))}async acceptIncomingConnection(e){if(this.deny.some((t=>e.remoteAddr.toString().startsWith(t.toString()))))return this.log("connection from %a refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some((t=>e.remoteAddr.toString().startsWith(t.toString()))))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return this.log("connection from %a refused - incomingPendingConnections exceeded by host",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){const t=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(t,1)}catch{return this.log("connection from %a refused - inboundConnectionThreshold exceeded by host %s",e.remoteAddr,t),!1}}return this.getConnections().length<this.maxConnections?(this.incomingPendingConnections++,!0):(this.log("connection from %a refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}getDialQueue(){const e={queued:"queued",running:"active",errored:"error",complete:"success"};return this.dialQueue.queue.queue.map((t=>({id:t.id,status:e[t.status],peerId:t.options.peerId,multiaddrs:[...t.options.multiaddrs].map((e=>Ate(e)))})))}}class iie{constructor(e,t){var r;co(this,"routers",void 0),co(this,"started",void 0),co(this,"components",void 0),this.routers=null!==(r=t.routers)&&void 0!==r?r:[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}findProviders(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){if(0===t.routers.length)throw new ug("No content routers available",Nne.ERR_NO_ROUTERS_AVAILABLE);const n=t,i=new t1;for await(const o of yh(...n.routers.map((t=>t.findProviders(e,r)))))null!=o&&(o.multiaddrs.length>0&&await t.components.peerStore.merge(o.id,{multiaddrs:o.multiaddrs}),i.has(o.id)||(i.add(o.id),yield o))}()}catch(r){return Promise.reject(r)}}async provide(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(0===this.routers.length)throw new ug("No content routers available",Nne.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map((async r=>{await r.provide(e,t)})))}async put(e,t,r){if(!this.isStarted())throw new ug(Dne.NOT_STARTED_YET,Nne.ERR_NODE_NOT_STARTED);await Promise.all(this.routers.map((async n=>{await n.put(e,t,r)})))}async get(e,t){if(!this.isStarted())throw new ug(Dne.NOT_STARTED_YET,Nne.ERR_NODE_NOT_STARTED);return Promise.any(this.routers.map((async r=>r.get(e,t))))}}var oie;const sie=null!==(oie=globalThis.CustomEvent)&&void 0!==oie?oie:Event;class aie{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"log",void 0),co(this,"peerId",void 0),co(this,"peerStore",void 0),co(this,"routers",void 0),this.log=e.logger.forComponent("libp2p:peer-routing"),this.peerId=e.peerId,this.peerStore=e.peerStore,this.routers=null!==(t=r.routers)&&void 0!==t?t:[]}async findPeer(e,t){if(0===this.routers.length)throw new ug("No peer routers available",Nne.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.peerId.toString())throw new ug("Should not try to find self",Nne.ERR_FIND_SELF);const r=this,n=yh(...this.routers.map((n=>async function*(){try{yield await n.findPeer(e,t)}catch(i){r.log.error(i)}}())));for await(const i of n)if(null!=i)return i.multiaddrs.length>0&&await this.peerStore.merge(i.id,{multiaddrs:i.multiaddrs}),i;throw new ug(Dne.NOT_FOUND,Nne.ERR_NOT_FOUND)}getClosestPeers(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){if(0===t.routers.length)throw new ug("No peer routers available",Nne.ERR_NO_ROUTERS_AVAILABLE);const n=t,i=new t1;for await(const o of function(e){try{let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(r){let n=null!==(r=t.concurrency)&&void 0!==r?r:1/0;n<1&&(n=1/0);const i=null!=t.ordered&&t.ordered,o=new EventTarget,s=[];let a,c=hh(),u=hh(),l=!1,h=!1;function d(){var e;return i?null===(e=s[0])||void 0===e?void 0:e.done:Boolean(s.find((e=>e.done)))}function*f(){for(;s.length>0&&s[0].done;){const e=s[0];if(s.shift(),!e.ok)throw h=!0,c.resolve(),e.err;yield e.value,c.resolve()}}function*p(){for(;d();)for(let e=0;e<s.length;e++)if(s[e].done){const t=s[e];if(s.splice(e,1),e--,!t.ok)throw h=!0,c.resolve(),t.err;yield t.value,c.resolve()}}for(o.addEventListener("task-complete",(()=>{u.resolve()})),Promise.resolve().then((async()=>{try{for await(const t of e){if(s.length===n&&(c=hh(),await c.promise),h)break;const e={done:!1};s.push(e),t().then((t=>{e.done=!0,e.ok=!0,e.value=t,o.dispatchEvent(new sie("task-complete"))}),(t=>{e.done=!0,e.err=t,o.dispatchEvent(new sie("task-complete"))}))}l=!0,o.dispatchEvent(new sie("task-complete"))}catch(t){a=t,o.dispatchEvent(new sie("task-complete"))}}));;){if(d()||(u=hh(),await u.promise),null!=a)throw a;if(i?yield*f():yield*p(),l&&0===s.length)break}}()}catch(t){return Promise.reject(t)}}(async function*(){const t=yh(...n.routers.map((t=>t.getClosestPeers(e,r))));for await(let e of t)yield async()=>{if(0===e.multiaddrs.length)try{e=await n.findPeer(e.id,{...r,useCache:!1})}catch(t){return void n.log.error("could not find peer multiaddrs",t)}return e}}()))null!=o&&(o.multiaddrs.length>0&&await t.peerStore.merge(o.id,{multiaddrs:o.multiaddrs}),i.has(o.id)||(i.add(o.id),yield o))}()}catch(r){return Promise.reject(r)}}}class cie{constructor(e){co(this,"log",void 0),co(this,"topologies",void 0),co(this,"handlers",void 0),co(this,"components",void 0),this.log=e.logger.forComponent("libp2p:registrar"),this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onPeerIdentify=this._onPeerIdentify.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate),this.components.events.addEventListener("peer:identify",this._onPeerIdentify)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw new ug("No handler registered for protocol ".concat(e),Nne.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}async handle(e,t,r){if(this.handlers.has(e))throw new ug("Handler already registered for protocol ".concat(e),Nne.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const n=Pne.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);this.handlers.set(e,{handler:t,options:n}),await this.components.peerStore.merge(this.components.peerId,{protocols:[e]})}async unhandle(e){(Array.isArray(e)?e:[e]).forEach((e=>{this.handlers.delete(e)})),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(e,t){if(null==t)throw new ug("invalid topology",Nne.ERR_INVALID_PARAMETERS);const r="".concat((1e9*Math.random()).toString(36)).concat(Date.now());let n=this.topologies.get(e);return null==n&&(n=new Map,this.topologies.set(e,n)),n.set(r,t),r}unregister(e){for(const[t,r]of this.topologies.entries())r.has(e)&&(r.delete(e),0===r.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.peerStore.get(t).then((e=>{for(const n of e.protocols){const e=this.topologies.get(n);if(null!=e)for(const n of e.values()){var r;null===(r=n.onDisconnect)||void 0===r||r.call(n,t)}}})).catch((e=>{e.code!==Nne.ERR_NOT_FOUND&&this.log.error("could not inform topologies of disconnecting peer %p",t,e)}))}_onPeerUpdate(e){var t;const{peer:r,previous:n}=e.detail,i=(null!==(t=null===n||void 0===n?void 0:n.protocols)&&void 0!==t?t:[]).filter((e=>!r.protocols.includes(e)));for(const s of i){const e=this.topologies.get(s);if(null!=e)for(const t of e.values()){var o;null===(o=t.onDisconnect)||void 0===o||o.call(t,r.id)}}}_onPeerIdentify(e){const t=e.detail.protocols,r=e.detail.connection,n=e.detail.peerId;for(const o of t){const e=this.topologies.get(o);if(null!=e)for(const t of e.values()){var i;r.transient&&!0!==t.notifyOnTransient||(null===(i=t.onConnect)||void 0===i||i.call(t,n,r))}}}}class uie extends Map{constructor(e){super(),co(this,"metric",void 0);const{name:t,metrics:r}=e;this.metric=r.registerMetric(t),this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){const t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}}class lie{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};co(this,"log",void 0),co(this,"components",void 0),co(this,"transports",void 0),co(this,"listeners",void 0),co(this,"faultTolerance",void 0),co(this,"started",void 0),this.log=e.logger.forComponent("libp2p:transports"),this.components=e,this.started=!1,this.transports=new Map,this.listeners=function(e){const{name:t,metrics:r}=e;let n;return n=null!=r?new uie({name:t,metrics:r}):new Map,n}({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=null!==(t=r.faultTolerance)&&void 0!==t?t:zF.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw new ug("Transport must have a valid tag",Nne.ERR_INVALID_KEY);if(this.transports.has(t))throw new ug("There is already a transport with the tag ".concat(t),Nne.ERR_DUPLICATE_TRANSPORT);this.log("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){const e=this.components.addressManager.getListenAddrs();await this.listen(e)}async stop(){const e=[];for(const[t,r]of this.listeners)for(this.log("closing listeners for %s",t);r.length>0;){const t=r.pop();null!=t&&e.push(t.close())}await Promise.all(e),this.log("all listeners closed");for(const t of this.listeners.keys())this.listeners.set(t,[]);this.started=!1}async dial(e,t){const r=this.transportForMultiaddr(e);if(null==r)throw new ug("No transport available for address ".concat(String(e)),Nne.ERR_TRANSPORT_UNAVAILABLE);try{return await r.dial(e,{...t,upgrader:this.components.upgrader})}catch(n){throw null==n.code&&(n.code=Nne.ERR_TRANSPORT_DIAL_FAILED),n}}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(e){for(const t of this.transports.values()){if(t.filter([e]).length>0)return t}}async listen(e){if(!this.isStarted())throw new ug("Not started",Nne.ERR_NODE_NOT_STARTED);if(null==e||0===e.length)return void this.log("no addresses were provided for listening, this node is dial only");const t=[];for(const[n,i]of this.transports.entries()){const o=i.filter(e),s=[];for(const e of o){var r;this.log("creating listener for %s on %a",n,e);const t=i.createListener({upgrader:this.components.upgrader});let o=null!==(r=this.listeners.get(n))&&void 0!==r?r:[];null==o&&(o=[],this.listeners.set(n,o)),o.push(t),t.addEventListener("listening",(()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:t})})),t.addEventListener("close",(()=>{const e=o.findIndex((e=>e===t));o.splice(e,1),this.components.events.safeDispatchEvent("transport:close",{detail:t})})),s.push(t.listen(e))}if(0===s.length){t.push(n);continue}if(null==(await Promise.allSettled(s)).find((e=>"fulfilled"===e.status))&&this.faultTolerance!==zF.NO_FATAL)throw new ug("Transport (".concat(n,") could not listen on any available address"),Nne.ERR_NO_VALID_ADDRESSES)}if(t.length===this.transports.size){const e="no valid addresses were provided for transports [".concat(t.join(", "),"]");if(this.faultTolerance===zF.FATAL_ALL)throw new ug(e,Nne.ERR_NO_VALID_ADDRESSES);this.log("libp2p in dial mode only: ".concat(e))}}async remove(e){var t;const r=null!==(t=this.listeners.get(e))&&void 0!==t?t:[];this.log.trace("removing transport %s",e);const n=[];for(this.log.trace("closing listeners for %s",e);r.length>0;){const e=r.pop();null!=e&&n.push(e.close())}await Promise.all(n),this.transports.delete(e),this.listeners.delete(e)}async removeAll(){const e=[];for(const t of this.transports.keys())e.push(this.remove(t));await Promise.all(e)}}new Uint8Array(0);function hie(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var die=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const fie=die;class pie{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class gie{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return yie(this,e)}}class bie{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return yie(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function yie(e,t){var r,n;return new bie({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class mie{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new pie(e,t,r),this.decoder=new gie(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function vie(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new mie(t,r,n,i)}function wie(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=fie(n,t);return vie({prefix:r,name:t,encode:i,decode:e=>hie(o(e))})}function _ie(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return vie({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Eie=wie({prefix:"9",name:"base10",alphabet:"0123456789"}),Sie=_ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Aie=_ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),kie=_ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),xie=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Iie=xie.reduce(((e,t,r)=>(e[r]=t,e)),[]),Cie=xie.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Tie=vie({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Iie[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Cie[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Rie=_ie({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Pie=_ie({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Die=_ie({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Nie=_ie({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bie=_ie({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uie=_ie({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lie=_ie({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mie=_ie({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Oie=_ie({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),qie=wie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Kie=wie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Fie=wie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vie=wie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),zie=_ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jie=_ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hie=_ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gie=_ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Wie=_ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Yie=vie({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Qie=new TextEncoder,Jie=new TextDecoder,Xie="json",Zie=512;function $ie(e){return Qie.encode(JSON.stringify(e))}function eoe(e){return JSON.parse(Jie.decode(e))}const toe="raw",roe=85;function noe(e){return hie(e)}function ioe(e){return hie(e)}var ooe=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=coe;)r[n++]=255&t|soe,t/=128;for(;t&aoe;)r[n++]=255&t|soe,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},soe=128,aoe=-128,coe=Math.pow(2,31);var uoe=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&hoe)<<o:(n&hoe)*Math.pow(2,o),o+=7}while(n>=loe);return e.bytes=s-r,i},loe=128,hoe=127;var doe=Math.pow(2,7),foe=Math.pow(2,14),poe=Math.pow(2,21),goe=Math.pow(2,28),boe=Math.pow(2,35),yoe=Math.pow(2,42),moe=Math.pow(2,49),voe=Math.pow(2,56),woe=Math.pow(2,63);const _oe={encode:ooe,decode:uoe,encodingLength:function(e){return e<doe?1:e<foe?2:e<poe?3:e<goe?4:e<boe?5:e<yoe?6:e<moe?7:e<voe?8:e<woe?9:10}};function Eoe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return _oe.encode(e,t,r),t}function Soe(e){return _oe.encodingLength(e)}function Aoe(e,t){const r=t.byteLength,n=Soe(e),i=n+Soe(r),o=new Uint8Array(i+r);return Eoe(e,o,0),Eoe(r,o,n),o.set(t,i),new koe(e,r,t,o)}class koe{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const xoe=hie;const Ioe={code:0,name:"identity",encode:xoe,digest:function(e){return Aoe(0,xoe(e))}};function Coe(e){let{name:t,code:r,encode:n}=e;return new Toe(t,r,n)}class Toe{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Aoe(this.code,t):t.then((e=>Aoe(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Roe(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Poe=Coe({name:"sha2-256",code:18,encode:Roe("SHA-256")}),Doe=Coe({name:"sha2-512",code:19,encode:Roe("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Noe={...Ei,...gi,..._i,...fi,...pi,...yi,...mi,...vi,...wi,...bi};function Boe(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Uoe=Boe("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Loe=Boe("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Moe={utf8:Uoe,"utf-8":Uoe,hex:Noe.base16,latin1:Loe,ascii:Loe,binary:Loe,...Noe};function Ooe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Moe[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}const qoe="/multistream/1.0.0",Koe=1024;const Foe=Ooe("\n");async function Voe(e,t,r){await e.write(t,r)}async function zoe(e,t){const r=await async function(e,t){const r=await e.read(t);if(0===r.byteLength||r.get(r.byteLength-1)!==Foe[0])throw t.log.error("Invalid mss message - missing newline",r),new ug("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return r.sublist(0,-1)}(e,t);return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Moe[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}(r.subarray())}async function joe(e,t,r){t=Array.isArray(t)?t:[t],r.log.trace("handle: available protocols %s",t);const n=Nd(e,{...r,maxDataLength:Koe,maxLengthLength:2});for(;;){r.log.trace("handle: reading incoming string");const e=await zoe(n,r);if(r.log.trace('handle: read "%s"',e),e!==qoe){if(t.includes(e))return r.log.trace('handle: respond with "%s" for "%s"',e,e),await Voe(n,Ooe("".concat(e,"\n")),r),r.log.trace('handle: responded with "%s" for "%s"',e,e),{stream:n.unwrap(),protocol:e};if("ls"!==e)r.log('handle: respond with "na" for "%s"',e),await Voe(n,Ooe("na\n"),r),r.log('handle: responded with "na" for "%s"',e);else{const i=new nh(...t.map((e=>sh.single(Ooe("".concat(e,"\n"))))),Ooe("\n"));r.log.trace('handle: respond with "%s" for %s',t,e),await Voe(n,i,r),r.log.trace('handle: responded with "%s" for %s',t,e)}}else r.log.trace('handle: respond with "%s" for "%s"',qoe,e),await Voe(n,Ooe("".concat(qoe,"\n")),r),r.log.trace('handle: responded with "%s" for "%s"',qoe,e)}}async function Hoe(e,t,r){if(1===(t=Array.isArray(t)?[...t]:[t]).length&&!1===r.negotiateFully)return function(e,t,r){const n=e.sink.bind(e),i=e.source;let o=!1,s=!1;const a=hh();let c=!1,u=!1;const l=hh();let h=!1,d=!1;const f=hh(),p=Nd({sink:n,source:i},{...r,maxDataLength:Koe});async function g(){if(s)return r.log.trace("optimistic: already negotiating %s stream",t),void await a.promise;s=!0;try{c||(r.log.trace("optimistic: doing send protocol for %s stream",t),await b()),h||(r.log.trace("optimistic: doing read protocol for %s stream",t),await y())}finally{s=!1,o=!0,a.resolve()}}async function b(){if(u)await l.promise;else{u=!0;try{r.log.trace('optimistic: write ["%s", "%s", data] in source',qoe,t),await p.writeV([Ooe("".concat(qoe,"\n")),Ooe("".concat(t,"\n"))]),r.log.trace('optimistic: wrote ["%s", "%s", data] in source',qoe,t)}finally{c=!0,u=!1,l.resolve()}}}async function y(){if(d)await f.promise;else{d=!0;try{r.log.trace("optimistic: reading multistream select header");let e=await zoe(p,r);if(r.log.trace('optimistic: read multistream select header "%s"',e),e===qoe&&(e=await zoe(p,r)),r.log.trace('optimistic: read protocol "%s", expecting "%s"',e,t),e!==t)throw new ug("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}finally{h=!0,d=!1,f.resolve()}}}if(e.sink=async e=>{const{sink:n}=p.unwrap();await n(async function*(){let n=!1;for await(const i of e){if(u&&await l.promise,c)yield i;else{u=!0,r.log.trace('optimistic: write ["%s", "%s", data(%d)] in sink',qoe,t,i.byteLength);const e="".concat(t,"\n");yield new nh(Uint8Array.from([19]),Ooe("".concat(qoe,"\n")),Eo(e.length),Ooe(e),i).subarray(),r.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',qoe,t,i.byteLength),c=!0,u=!1,l.resolve(),g().catch((e=>{r.log.error("could not finish optimistic protocol negotiation of %s",t,e)}))}n=!0}n||await g()}())},e.source=async function*(){await g(),r.log.trace('optimistic: reading data from "%s" stream',t),yield*p.unwrap().source}(),null!=e.closeRead){const t=e.closeRead.bind(e);e.closeRead=async e=>{o||await g().catch((e=>{r.log.error("could not negotiate protocol before close read",e)})),await t(e)}}if(null!=e.closeWrite){const t=e.closeWrite.bind(e);e.closeWrite=async e=>{o||await g().catch((e=>{r.log.error("could not negotiate protocol before close write",e)})),await t(e)}}if(null!=e.close){const t=e.close.bind(e);e.close=async e=>{const r=[];u&&r.push(l.promise),d&&r.push(f.promise),r.length>0?await Id(Promise.all(r),null===e||void 0===e?void 0:e.signal):(o=!0,s=!1,a.resolve()),await t(e)}}return{stream:e,protocol:t}}(e,t[0],r);const n=Nd(e,{...r,maxDataLength:Koe}),i=t.shift();if(null==i)throw new Error("At least one protocol must be specified");r.log.trace('select: write ["%s", "%s"]',qoe,i);const o=Ooe("".concat(qoe,"\n")),s=Ooe("".concat(i,"\n"));await async function(e,t,r){await e.writeV(t,r)}(n,[o,s],r),r.log.trace("select: reading multistream-select header");let a=await zoe(n,r);if(r.log.trace('select: read "%s"',a),a===qoe&&(r.log.trace("select: reading protocol response"),a=await zoe(n,r),r.log.trace('select: read "%s"',a)),a===i)return{stream:n.unwrap(),protocol:i};for(const c of t){r.log.trace('select: write "%s"',c),await Voe(n,Ooe("".concat(c,"\n")),r),r.log.trace("select: reading protocol response");const e=await zoe(n,r);if(r.log.trace('select: read "%s" for "%s"',e,c),e===c)return{stream:n.unwrap(),protocol:c}}throw new ug("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const Goe=Symbol.for("@libp2p/connection");class Woe{constructor(e){var t;co(this,"id",void 0),co(this,"remoteAddr",void 0),co(this,"remotePeer",void 0),co(this,"direction",void 0),co(this,"timeline",void 0),co(this,"multiplexer",void 0),co(this,"encryption",void 0),co(this,"status",void 0),co(this,"transient",void 0),co(this,"log",void 0),co(this,"tags",void 0),co(this,"_newStream",void 0),co(this,"_close",void 0),co(this,"_abort",void 0),co(this,"_getStreams",void 0),co(this,Symbol.toStringTag,"Connection"),co(this,Goe,!0);const{remoteAddr:r,remotePeer:n,newStream:i,close:o,abort:s,getStreams:a}=e;this.id="".concat(parseInt(String(1e9*Math.random())).toString(36)).concat(Date.now()),this.remoteAddr=r,this.remotePeer=n,this.direction=e.direction,this.status="open",this.timeline=e.timeline,this.multiplexer=e.multiplexer,this.encryption=e.encryption,this.transient=null!==(t=e.transient)&&void 0!==t&&t,this.log=e.logger.forComponent("libp2p:connection:".concat(this.direction,":").concat(this.id)),null==this.remoteAddr.getPeerId()&&(this.remoteAddr=this.remoteAddr.encapsulate("/p2p/".concat(this.remotePeer))),this._newStream=i,this._close=o,this._abort=s,this._getStreams=a,this.tags=[]}get streams(){return this._getStreams()}async newStream(e,t){if("closing"===this.status)throw new ug("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if("closed"===this.status)throw new ug("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&!0!==(null===t||void 0===t?void 0:t.runOnTransientConnection))throw new ug("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");const r=await this._newStream(e,t);return r.direction="outbound",r}async close(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("closed"!==this.status&&"closing"!==this.status){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",null==e.signal){const t=AbortSignal.timeout(500);dd(1/0,t),e={...e,signal:t}}try{this.log.trace("closing all streams"),await Promise.all(this.streams.map((async t=>t.close(e)))),this.log.trace("closing underlying transport"),await this._close(e),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(t){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,t),this.abort(t)}}}abort(e){this.log.error("aborting connection to %a due to error",this.remoteAddr,e),this.status="closing",this.streams.forEach((t=>{t.abort(e)})),this.log.error("all streams aborted",this.streams.length),this._abort(e),this.timeline.close=Date.now(),this.status="closed"}}function Yoe(e,t,r){let n=0;return r.streams.forEach((r=>{r.direction===t&&r.protocol===e&&n++})),n}class Qoe{constructor(e,t){var r;co(this,"components",void 0),co(this,"connectionEncryption",void 0),co(this,"muxers",void 0),co(this,"inboundUpgradeTimeout",void 0),co(this,"events",void 0),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach((e=>{this.connectionEncryption.set(e.protocol,e)})),this.muxers=new Map,t.muxers.forEach((e=>{this.muxers.set(e.protocol,e)})),this.inboundUpgradeTimeout=null!==(r=t.inboundUpgradeTimeout)&&void 0!==r?r:2e3,this.events=e.events}async shouldBlockConnection(e,t,r){const n=this.components.connectionGater[r];if(void 0!==n&&await n(e,t))throw new ug("The multiaddr connection is blocked by gater.".concat(r),Nne.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new ug("connection denied",Nne.ERR_CONNECTION_DENIED);let r,n,i,o,s;const a=AbortSignal.timeout(this.inboundUpgradeTimeout),c=()=>{e.abort(new ug("inbound upgrade timeout",pg))};a.addEventListener("abort",c,{once:!0}),dd(1/0,a);try{var u,l,h;if(!0===await(null===(u=(l=this.components.connectionGater).denyInboundConnection)||void 0===u?void 0:u.call(l,e)))throw new ug("The multiaddr connection is blocked by gater.acceptConnection",Nne.ERR_CONNECTION_INTERCEPTED);null===(h=this.components.metrics)||void 0===h||h.trackMultiaddrConnection(e),e.log("starting the inbound connection upgrade");let a=e;if(!0!==(null===t||void 0===t?void 0:t.skipProtection)){const t=this.components.connectionProtector;null!=t&&(e.log("protecting the inbound connection"),a=await t.protect(e))}try{if(r=a,!0!==(null===t||void 0===t?void 0:t.skipEncryption)){({conn:r,remotePeer:n,protocol:s}=await this._encryptInbound(a));const e={...a,...r};await this.shouldBlockConnection(n,e,"denyInboundEncryptedConnection")}else{const t=e.remoteAddr.getPeerId();if(null==t)throw new ug("inbound connection that skipped encryption must have a peer id",Nne.ERR_INVALID_MULTIADDR);const r=h1(t);s="native",n=r}if(i=r,null!=(null===t||void 0===t?void 0:t.muxerFactory))o=t.muxerFactory;else if(this.muxers.size>0){const e=await this._multiplexInbound({...a,...r},this.muxers);o=e.muxerFactory,i=e.stream}}catch(d){throw e.log.error("failed to upgrade inbound connection",d),d}return await this.shouldBlockConnection(n,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:s,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:o,remotePeer:n,transient:null===t||void 0===t?void 0:t.transient})}finally{a.removeEventListener("abort",c),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){var r;const n=e.remoteAddr.getPeerId();let i,o,s,a,c,u;null!=n&&(i=h1(n),await this.shouldBlockConnection(i,e,"denyOutboundConnection")),null===(r=this.components.metrics)||void 0===r||r.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let l=e;if(!0!==(null===t||void 0===t?void 0:t.skipProtection)){const t=this.components.connectionProtector;null!=t&&(l=await t.protect(e))}try{if(o=l,!0!==(null===t||void 0===t?void 0:t.skipEncryption)){({conn:o,remotePeer:s,protocol:c}=await this._encryptOutbound(l,i));const e={...l,...o};await this.shouldBlockConnection(s,e,"denyOutboundEncryptedConnection")}else{if(null==i)throw new ug("Encryption was skipped but no peer id was passed",Nne.ERR_INVALID_PEER);c="native",s=i}if(a=o,null!=(null===t||void 0===t?void 0:t.muxerFactory))u=t.muxerFactory;else if(this.muxers.size>0){const e=await this._multiplexOutbound({...l,...o},this.muxers);u=e.muxerFactory,a=e.stream}}catch(h){throw e.log.error("failed to upgrade outbound connection",h),await e.close(h),h}return await this.shouldBlockConnection(s,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:u,remotePeer:s,transient:null===t||void 0===t?void 0:t.transient})}_createConnection(e){var t,r,n=this;const{cryptoProtocol:i,direction:o,maConn:s,upgradedConn:a,remotePeer:c,muxerFactory:u,transient:l}=e;let h,d,f;null!=u&&(h=u.createStreamMuxer({direction:o,onIncomingStream:e=>{null!=f&&Promise.resolve().then((async()=>{var t;const r=this.components.registrar.getProtocols(),{stream:n,protocol:i}=await joe(e,r,{log:e.log,yieldBytes:!1});if(null==f)return;f.log("incoming stream opened on %s",i);const o=function(e,t){try{const{options:r}=t.getHandler(e);return r.maxInboundStreams}catch(r){if(r.code!==Nne.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return 32}(i,this.components.registrar);if(Yoe(i,"inbound",f)===o){const t=new ug('Too many inbound protocol streams for protocol "'.concat(i,'" - limit ').concat(o),Nne.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw e.abort(t),t}e.source=n.source,e.sink=n.sink,e.protocol=i,null!=n.closeWrite&&(e.closeWrite=n.closeWrite),null!=n.closeRead&&(e.closeRead=n.closeRead),null!=n.close&&(e.close=n.close),await this.components.peerStore.merge(c,{protocols:[i]}),null===(t=this.components.metrics)||void 0===t||t.trackProtocolStream(e,f),this._onStream({connection:f,stream:e,protocol:i})})).catch((async t=>{f.log.error("error handling incoming stream id %s",e.id,t.message,t.code,t.stack),null==e.timeline.close&&await e.close()}))}}),d=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==h)throw new ug("Stream is not multiplexed",Nne.ERR_MUXER_UNAVAILABLE);f.log("starting new stream for protocols %s",e);const r=await h.newStream();f.log.trace("started new stream %s for protocols %s",r.id,e);try{var i;if(null==t.signal){r.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",e);const n=AbortSignal.timeout(3e4);dd(1/0,n),t={...t,signal:n}}r.log.trace("selecting protocol from protocols %s",e);const{stream:o,protocol:s}=await Hoe(r,e,{...t,log:r.log,yieldBytes:!0});r.log("selected protocol %s",s);const a=function(e,t){var r;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{const{options:r}=t.getHandler(e);if(null!=r.maxOutboundStreams)return r.maxOutboundStreams}catch(i){if(i.code!==Nne.ERR_NO_HANDLER_FOR_PROTOCOL)throw i}return null!==(r=n.maxOutboundStreams)&&void 0!==r?r:64}(s,n.components.registrar,t);if(Yoe(s,"outbound",f)>=a){const e=new ug('Too many outbound protocol streams for protocol "'.concat(s,'" - limit ').concat(a),Nne.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw r.abort(e),e}return await n.components.peerStore.merge(c,{protocols:[s]}),r.source=o.source,r.sink=o.sink,r.protocol=s,null!=o.closeWrite&&(r.closeWrite=o.closeWrite),null!=o.closeRead&&(r.closeRead=o.closeRead),null!=o.close&&(r.close=o.close),null===(i=n.components.metrics)||void 0===i||i.trackProtocolStream(r,f),r}catch(o){if(f.log.error("could not create new stream for protocols %s",e,o),null==r.timeline.close&&r.abort(o),null!=o.code)throw o;throw new ug(String(o),Nne.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([h.sink(a.source),a.sink(h.source)]).catch((e=>{f.log.error("error piping data through muxer",e)})));const p=s.timeline;s.timeline=new Proxy(p,{set:function(){return null!=f&&"close"===(arguments.length<=1?void 0:arguments[1])&&null!=(arguments.length<=2?void 0:arguments[2])&&null==p.close&&(async()=>{try{"open"===f.status&&await f.close()}catch(e){f.log.error("error closing connection after timeline close",e)}finally{n.events.safeDispatchEvent("connection:close",{detail:f})}})().catch((e=>{f.log.error("error thrown while dispatching connection:close event",e)})),Reflect.set(...arguments)}}),s.timeline.upgraded=Date.now();var g;return g={remoteAddr:s.remoteAddr,remotePeer:c,status:"open",direction:o,timeline:s.timeline,multiplexer:null===(t=h)||void 0===t?void 0:t.protocol,encryption:i,transient:l,logger:this.components.logger,newStream:null!==(r=d)&&void 0!==r?r:()=>{throw new ug("connection is not multiplexed",Nne.ERR_CONNECTION_NOT_MULTIPLEXED)},getStreams:()=>null!=h?h.streams:[],close:async e=>{null!=h&&(f.log.trace("close muxer"),await h.close(e)),f.log.trace("close maconn"),await s.close(e),f.log.trace("closed maconn")},abort:e=>{s.abort(e),null!=h&&h.abort(e)}},f=new Woe(g),this.events.safeDispatchEvent("connection:open",{detail:f}),f}_onStream(e){const{connection:t,stream:r,protocol:n}=e,{handler:i,options:o}=this.components.registrar.getHandler(n);if(t.transient&&!0!==o.runOnTransientConnection)throw new ug("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");i({connection:t,stream:r})}async _encryptInbound(e){const t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{const{stream:r,protocol:n}=await joe(e,t,{log:e.log}),i=this.connectionEncryption.get(n);if(null==i)throw new Error("no crypto module found for ".concat(n));return e.log("encrypting inbound connection using",n),{...await i.secureInbound(this.components.peerId,r),protocol:n}}catch(r){throw e.log.error("encrypting inbound connection to %p failed",r),new ug(r.message,Nne.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){const r=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",r);try{e.log.trace("selecting encrypter from %s",r);const{stream:n,protocol:i}=await Hoe(e,r,{log:e.log,yieldBytes:!0}),o=this.connectionEncryption.get(i);if(null==o)throw new Error("no crypto module found for ".concat(i));return e.log("encrypting outbound connection to %p using %s",t,o),{...await o.secureOutbound(this.components.peerId,n,t),protocol:i}}catch(n){throw e.log.error("encrypting outbound connection to %p failed",n),new ug(n.message,Nne.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const r=Array.from(t.keys());e.log("outbound selecting muxer %s",r);try{e.log.trace("selecting stream muxer from %s",r);const{stream:n,protocol:i}=await Hoe(e,r,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",i);return{stream:n,muxerFactory:t.get(i)}}catch(n){throw e.log.error("error multiplexing outbound connection",n),new ug(String(n),Nne.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const r=Array.from(t.keys());e.log("inbound handling muxers %s",r);try{const{stream:n,protocol:i}=await joe(e,r,{log:e.log});return{stream:n,muxerFactory:t.get(i)}}catch(n){throw e.log.error("error multiplexing inbound connection",n),new ug(String(n),Nne.ERR_MUXER_UNAVAILABLE)}}}var Joe=new WeakSet;class Xoe extends gd{constructor(e){var t,r,n,i,o,s,a,c,u;super(),jC(this,Joe),co(this,"peerId",void 0),co(this,"peerStore",void 0),co(this,"contentRouting",void 0),co(this,"peerRouting",void 0),co(this,"metrics",void 0),co(this,"services",void 0),co(this,"logger",void 0),co(this,"status",void 0),co(this,"components",void 0),co(this,"log",void 0),this.status="stopped";const l=new gd,h=l.dispatchEvent.bind(l);l.dispatchEvent=e=>{const t=h(e),r=this.dispatchEvent(new yd(e.type,{detail:e.detail}));return t||r},dd(1/0,l),this.peerId=e.peerId,this.logger=null!==(t=e.logger)&&void 0!==t?t:c$(),this.log=this.logger.forComponent("libp2p"),this.services={};const d=this.components=function(){const e=new Lte(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return new Proxy(e,{get(t,r,n){if("string"===typeof r&&!Ote.includes(r)){const t=e.components[r];if(null==t&&!Mte.includes(r))throw new ug("".concat(r," not set"),"ERR_SERVICE_MISSING");return t}return Reflect.get(t,r,n)},set:(t,r,n)=>("string"===typeof r?e.components[r]=n:Reflect.set(t,r,n),!0)})}({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:null!==(r=e.nodeInfo)&&void 0!==r?r:{name:"libp2p",version:"1.3.3"},logger:this.logger,events:l,datastore:null!==(n=e.datastore)&&void 0!==n?n:new Pte,connectionGater:Vte(e.connectionGater),dns:e.dns});this.peerStore=this.configureComponent("peerStore",new Vee(d,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),null!=e.metrics&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),d.events.addEventListener("peer:update",(e=>{if(null==e.detail.previous){const t={id:e.detail.peer.id,multiaddrs:e.detail.peer.addresses.map((e=>e.multiaddr))};d.events.safeDispatchEvent("peer:discovery",{detail:t})}})),null!=e.connectionProtector&&this.configureComponent("connectionProtector",e.connectionProtector(d)),this.components.upgrader=new Qoe(this.components,{connectionEncryption:(null!==(i=e.connectionEncryption)&&void 0!==i?i:[]).map(((e,t)=>this.configureComponent("connection-encryption-".concat(t),e(this.components)))),muxers:(null!==(o=e.streamMuxers)&&void 0!==o?o:[]).map(((e,t)=>this.configureComponent("stream-muxers-".concat(t),e(this.components)))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new lie(this.components,e.transportManager)),this.configureComponent("connectionManager",new nie(this.components,e.connectionManager)),this.configureComponent("registrar",new cie(this.components)),this.configureComponent("addressManager",new Bte(this.components,e.addresses));const f=(null!==(s=e.peerRouters)&&void 0!==s?s:[]).map(((e,t)=>this.configureComponent("peer-router-".concat(t),e(this.components))));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new aie(this.components,{routers:f}));const p=(null!==(a=e.contentRouters)&&void 0!==a?a:[]).map(((e,t)=>this.configureComponent("content-router-".concat(t),e(this.components))));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new iie(this.components,{routers:p})),(null!==(c=e.peerDiscovery)&&void 0!==c?c:[]).forEach(((e,t)=>{this.configureComponent("peer-discovery-".concat(t),e(this.components)).addEventListener("peer",(e=>{ld(Joe,this,Zoe).call(this,e)}))})),null===(u=e.transports)||void 0===u||u.forEach(((e,t)=>{this.components.transportManager.add(this.configureComponent("transport-".concat(t),e(this.components)))})),null!=e.services)for(const y of Object.keys(e.services)){const t=(0,e.services[y])(this.components);var g,b;if(null!=t){if(this.services[y]=t,this.configureComponent(y,t),null!=t[s$]&&(this.log("registering service %s for content routing",y),p.push(t[s$])),null!=t[a$]&&(this.log("registering service %s for peer routing",y),f.push(t[a$])),null!=t[x_])this.log("registering service %s for peer discovery",y),null===(g=(b=t[x_]).addEventListener)||void 0===g||g.call(b,"peer",(e=>{ld(Joe,this,Zoe).call(this,e)}))}else this.log.error("service factory %s returned null or undefined instance",y)}}configureComponent(e,t){return null==t&&this.log.error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if("stopped"===this.status){this.status="starting",this.log("libp2p is starting");try{var e,t,r,n;await(null===(e=(t=this.components).beforeStart)||void 0===e?void 0:e.call(t)),await this.components.start(),await(null===(r=(n=this.components).afterStart)||void 0===r?void 0:r.call(n)),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(i){throw this.log.error("An error occurred starting libp2p",i),this.status="started",await this.stop(),i}}}async stop(){var e,t,r,n;"started"===this.status&&(this.log("libp2p is stopping"),this.status="stopping",await(null===(e=(t=this.components).beforeStop)||void 0===e?void 0:e.call(t)),await this.components.stop(),await(null===(r=(n=this.components).afterStop)||void 0===r?void 0:r.call(n)),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){const e=new t1;for(const t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.components.connectionManager.openConnection(e,{priority:75,...t})}async dialProtocol(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==t)throw new ug("no protocols were provided to open a stream",Nne.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw new ug("no protocols were provided to open a stream",Nne.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,r)).newStream(t,r)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var r;Ste(e)&&(e=h1(null!==(r=e.getPeerId())&&void 0!==r?r:""));await this.components.connectionManager.closeConnections(e,t)}async getPublicKey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.log("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;try{const t=await this.peerStore.get(e);if(null!=t.id.publicKey)return t.id.publicKey}catch(i){if(i.code!==Nne.ERR_NOT_FOUND)throw i}const r=KX([BX("/pk/"),e.multihash.digest]),n=await this.contentRouting.get(r,t);return function(e){var t,r;const n=SZ.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case _Z.RSA:return n$.rsa.unmarshalRsaPublicKey(i);case _Z.Ed25519:return n$.ed25519.unmarshalEd25519PublicKey(i);case _Z.Secp256k1:return n$.secp256k1.unmarshalSecp256k1PublicKey(i);default:throw i$(null!==(r=n.Type)&&void 0!==r?r:"unknown")}}(n),await this.peerStore.patch(e,{publicKey:n}),n}async handle(e,t,r){Array.isArray(e)||(e=[e]),await Promise.all(e.map((async e=>{await this.components.registrar.handle(e,t,r)})))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map((async e=>{await this.components.registrar.unhandle(e)})))}async register(e,t){return this.components.registrar.register(e,t)}unregister(e){this.components.registrar.unregister(e)}}function Zoe(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs}).catch((e=>{this.log.error(e)})):this.log.error(new Error(Nne.ERR_DISCOVERED_SELF))}async function $oe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await async function(){var e,t;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=null!==(e=r.peerId)&&void 0!==e?e:r.peerId=await L6();if(null==n.privateKey)throw new ug("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return null!==(t=r.privateKey)&&void 0!==t||(r.privateKey=await o$(n.privateKey)),new Xoe(await Une(r))}(e);return!1!==e.start&&await t.start(),t}class ese{constructor(e){var t;co(this,"numPeers",void 0),this.numPeers=null!==(t=null===e||void 0===e?void 0:e.numPeersToUse)&&void 0!==t?t:3}}const tse=new Kl("sdk:light-push");class rse extends ese{constructor(e,t){var r;super({numPeersToUse:null!==(r=null===t||void 0===t?void 0:t.numPeersToUse)&&void 0!==r?r:3}),co(this,"protocol",void 0),this.protocol=new zh(e,t)}async send(e,t){const r=[],n=[],{pubsubTopic:i}=e;try{Rl(i,this.protocol.pubsubTopics)}catch(c){return tse.error("Failed to send waku light push: pubsub topic not configured"),{failures:[{error:Kc.TOPIC_NOT_CONFIGURED}],successes:[]}}const o=await this.protocol.getPeers();if(!o.length)return{successes:r,failures:[{error:Kc.NO_PEER_AVAILABLE}]};const s=o.map((r=>this.protocol.send(e,t,r))),a=await Promise.allSettled(s);for(const u of a)if("fulfilled"===u.status){const{failure:e,success:t}=u.value;t&&r.push(t),e&&n.push(e)}else tse.error("Failed to send message to peer",u.reason),n.push({error:Kc.GENERIC_FAIL});return{successes:r,failures:n}}}const nse=new Kl("waku:store:protocol");class ise extends ese{constructor(e,t){super({numPeersToUse:1}),co(this,"protocol",void 0),this.protocol=new Jh(e,t)}async*queryGenerator(e,t){const{pubsubTopic:r,contentTopics:n,decodersAsMap:i}=this.validateDecodersAndPubsubTopic(e,t),o=this.constructOptions(r,n,t),s=(await this.protocol.getPeers({numPeers:this.numPeers,maxBootstrapPeers:1}))[0];if(!s)throw new Error("No peers available to query");const a=this.protocol.queryPerPage(o,i,s);for await(const c of a)yield c}async queryWithOrderedCallback(e,t,r){for await(const n of this.queryGenerator(e,r))if(await this.processMessages(n,t,r))break}async queryWithPromiseCallback(e,t,r){let n=!1;for await(const i of this.queryGenerator(e,r)){const e=i.map((async e=>{n||(n=Boolean(await t(e)))}));if(await Promise.all(e),n)break}}createCursor(e){if(!e||!e.timestamp||!e.payload||!e.contentTopic)throw new Error("Message is missing required fields");const t=kl(e.contentTopic),r=Oc(xl([t,e.payload])),n=BigInt(e.timestamp.getTime())*BigInt(1e6);return{digest:r,pubsubTopic:e.pubsubTopic,senderTime:n,receiverTime:n}}validateDecodersAndPubsubTopic(e,t){var r;if(0===e.length)throw new Error("No decoders provided");const n=Array.from(new Set(e.map((e=>e.pubsubTopic))));if(n.length>1)throw new Error("API does not support querying multiple pubsub topics at once");const i=n[0];var o;if(Rl(i,this.protocol.pubsubTopics),null!==t&&void 0!==t&&null!==(r=t.cursor)&&void 0!==r&&r.pubsubTopic&&t.cursor.pubsubTopic!==i)throw new Error("Cursor pubsub topic (".concat(null===t||void 0===t||null===(o=t.cursor)||void 0===o?void 0:o.pubsubTopic,") does not match decoder pubsub topic (").concat(i,")"));const s=new Map;e.forEach((e=>{if(s.has(e.contentTopic))throw new Error("API does not support different decoder per content topic");s.set(e.contentTopic,e)}));const a=e.filter((e=>e.pubsubTopic===i)).map((e=>e.contentTopic));if(0===a.length)throw new Error("No decoders found for topic "+i);return{pubsubTopic:i,contentTopics:a,decodersAsMap:s}}constructOptions(e,t){let r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};null!==i&&void 0!==i&&i.timeFilter&&(r=i.timeFilter.startTime,n=i.timeFilter.endTime),r||nse.warn("No start time provided"),n||nse.warn("No end time provided");return Object.assign({pubsubTopic:e,pageDirection:Fc.BACKWARD,pageSize:10},i,{contentTopics:t,startTime:r,endTime:n})}async processMessages(e,t,r){let n=!1;let i=(await Promise.all(e)).filter(lc);return this.shouldReverseOrder(r)&&(i=i.reverse()),await Promise.all(i.map((async e=>{e&&!n&&(n=Boolean(await t(e)))}))),n}shouldReverseOrder(e){return"undefined"===typeof(null===e||void 0===e?void 0:e.pageDirection)||(null===e||void 0===e?void 0:e.pageDirection)===Fc.BACKWARD}}async function ose(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await async function(e){var t,r,n,i;const o=e.shardInfo?Bl(e.shardInfo):void 0;e.pubsubTopics=null!==(t=null!==(r=null===o||void 0===o?void 0:o.pubsubTopics)&&void 0!==r?r:e.pubsubTopics)&&void 0!==t?t:[Hc];const s=null!==(n=null===e||void 0===e?void 0:e.libp2p)&&void 0!==n?n:{},a=null!==(i=s.peerDiscovery)&&void 0!==i?i:[];null!==e&&void 0!==e&&e.defaultBootstrap&&a.push(...(c=e.pubsubTopics,[gge([lse.SANDBOX],Pge),Rge(),kge(c)]));var c;null!==e&&void 0!==e&&e.bootstrapPeers&&a.push((u={list:e.bootstrapPeers},e=>new zC(e,u)));var u;s.peerDiscovery=a;const l=await async function(e,t,r,n){var i;null!==r&&void 0!==r&&r.hideWebSocketInfo||"test"===(null===(i=process)||void 0===i||null===(i={NODE_ENV:"production",PUBLIC_URL:"/web-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0})||void 0===i?void 0:i.NODE_ENV)||(console.info("%cIgnore WebSocket connection failures","background: gray; color: white; font-size: x-large"),console.info("%cWaku tries to discover peers and some of them are expected to fail","background: gray; color: white; font-size: x-large"));const o=t?{pubsub:t}:{},s=e?{metadata:kd(e)}:{};return $oe({connectionManager:{minConnections:1},transports:[Bz({filter:Dz})],streamMuxers:[MF()],connectionEncryption:[k_()],...r,services:{identify:Lq({agentVersion:null!==n&&void 0!==n?n:ase}),ping:FF(),...s,...o,...null===r||void 0===r?void 0:r.services}})}(null===o||void 0===o?void 0:o.shardInfo,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>{e={...e,msgIdFn:e=>{let{data:t}=e;return Oc(t)},globalSignaturePolicy:mG.StrictNoSign,fallbackToFloodsub:!1};const r=new FQ(t,e);return r.multicodecs=VQ,r}}(e),s,null===e||void 0===e?void 0:e.userAgent);return l}(e),r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new ise(t,e)}(e),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new rse(t,e)}(e),i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{pubsubTopics:[]};return t=>new Kh(t,e)}(e);return new use(e,t,r,n,i)}async function sse(e,t,r){var n;if(!e.filter)throw new Error("Filter protocol missing from Waku node");const{shardInfo:i}=e.libp2p.components.metadata;if(!i)throw new Error("Shard info missing from Waku node.");const o=Cl(i),s=Dl(t);if(!o.includes(s))throw new Error("Content topic does not match any pubsub topic in shard info.");await e.dial(r),await od(e,[qc.Filter]);let a=Wl(t,s);a&&(a=null!==(n=a)&&void 0!==n?n:a);return{decoder:a,subscription:await e.filter.createSubscription(s)}}const ase="js-waku",cse=new Kl("waku");class use{constructor(e,t,r,n,i,o){if(co(this,"libp2p",void 0),co(this,"relay",void 0),co(this,"store",void 0),co(this,"filter",void 0),co(this,"lightPush",void 0),co(this,"connectionManager",void 0),co(this,"pubsubTopics",void 0),0==e.pubsubTopics.length)throw new Error("At least one pubsub topic must be provided");this.pubsubTopics=e.pubsubTopics,this.libp2p=t,r&&(this.store=r(t)),i&&(this.filter=i(t)),n&&(this.lightPush=n(t)),o&&(this.relay=o(t));const s=e.pingKeepAlive||300,a=this.relay?e.relayKeepAlive||300:0,c=this.libp2p.peerId.toString();this.connectionManager=_d.create(c,t,{pingKeepAlive:s,relayKeepAlive:a},this.pubsubTopics,this.relay),cse.info("Waku node created",c,"relay: ".concat(!!this.relay,", store: ").concat(!!this.store,", light push: ").concat(!!this.lightPush,", filter: ").concat(!!this.filter))}async dial(e,t){const r=null!==t&&void 0!==t?t:[],n=function(e){return Um(e)?e:VC(e)}(e);"undefined"===typeof t&&(this.relay&&r.push(qc.Relay),this.store&&r.push(qc.Store),this.filter&&r.push(qc.Filter),this.lightPush&&r.push(qc.LightPush));const i=[];return r.includes(qc.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach((e=>i.push(e))):cse.error("Relay codec not included in dial codec: protocol not mounted locally")),r.includes(qc.Store)&&(this.store?i.push(this.store.protocol.multicodec):cse.error("Store codec not included in dial codec: protocol not mounted locally")),r.includes(qc.LightPush)&&(this.lightPush?i.push(this.lightPush.protocol.multicodec):cse.error("Light Push codec not included in dial codec: protocol not mounted locally")),r.includes(qc.Filter)&&(this.filter?i.push(this.filter.multicodec):cse.error("Filter codec not included in dial codec: protocol not mounted locally")),cse.info("Dialing to ".concat(n.toString()," with protocols ").concat(r)),this.libp2p.dialProtocol(n,i)}async start(){await this.libp2p.start()}async stop(){this.connectionManager.stop(),await this.libp2p.stop()}async subscribeToContentTopic(e,t,r){return(await async function(e,t,r){var n;r.waku=null!==(n=r.waku)&&void 0!==n?n:await ose({shardInfo:{contentTopics:[e]}});const{decoder:i,subscription:o}=await sse(r.waku,e,r.peer);return await o.subscribe(i,t),{subscription:o,waku:r.waku}}(e,r,{waku:this,peer:t})).subscription}isStarted(){return"started"==this.libp2p.status}isConnected(){return this.connectionManager.isConnected()}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find((e=>e.toString().match(/127\.0\.0\.1/)));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}}const lse={TEST:"enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im",SANDBOX:"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im"},hse="bootstrap",dse={store:2,filter:1,lightPush:1};var fse=__webpack_require__(495),pse=__webpack_require__.t(fse,2);const gse=BigInt(0),bse=BigInt(1),yse=BigInt(2),mse=BigInt(3),vse=BigInt(8),wse=Object.freeze({a:gse,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:bse,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),_se=(e,t)=>(e+t/yse)/t,Ese={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=wse,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-bse*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=_se(o*e,t),c=_se(-n*e,t);let u=Xse(e-a*r-c*i,t),l=Xse(-a*n-c*o,t);const h=u>s,d=l>s;if(h&&(u=t-u),d&&(l=t-l),u>s||l>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:h,k1:u,k2neg:d,k2:l}}},Sse=32,Ase=32,kse=32,xse=Sse+1,Ise=2*Sse+1;function Cse(e){const{a:t,b:r}=wse,n=Xse(e*e),i=Xse(n*e);return Xse(i+t*e+r)}const Tse=wse.a===gse;class Rse extends Error{constructor(e){super(e)}}function Pse(e){if(!(e instanceof Dse))throw new TypeError("JacobianPoint expected")}class Dse{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof Use))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Use.ZERO)?Dse.ZERO:new Dse(e.x,e.y,bse)}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wse.P;const r=new Array(e.length),n=$se(e.reduce(((e,n,i)=>n===gse?e:(r[i]=e,Xse(e*n,t))),bse),t);return e.reduceRight(((e,n,i)=>n===gse?e:(r[i]=Xse(e*r[i],t),Xse(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return Dse.toAffineBatch(e).map(Dse.fromAffine)}equals(e){Pse(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e,a=Xse(n*n),c=Xse(s*s),u=Xse(t*c),l=Xse(i*a),h=Xse(Xse(r*s)*c),d=Xse(Xse(o*n)*a);return u===l&&h===d}negate(){return new Dse(this.x,Xse(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=Xse(e*e),i=Xse(t*t),o=Xse(i*i),s=e+i,a=Xse(yse*(Xse(s*s)-n-o)),c=Xse(mse*n),u=Xse(c*c),l=Xse(u-yse*a),h=Xse(c*(a-l)-vse*o),d=Xse(yse*t*r);return new Dse(l,h,d)}add(e){Pse(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e;if(i===gse||o===gse)return this;if(t===gse||r===gse)return e;const a=Xse(n*n),c=Xse(s*s),u=Xse(t*c),l=Xse(i*a),h=Xse(Xse(r*s)*c),d=Xse(Xse(o*n)*a),f=Xse(l-u),p=Xse(d-h);if(f===gse)return p===gse?this.double():Dse.ZERO;const g=Xse(f*f),b=Xse(f*g),y=Xse(u*g),m=Xse(p*p-b-yse*y),v=Xse(p*(y-m)-h*b),w=Xse(n*s*f);return new Dse(m,v,w)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Dse.ZERO;if("bigint"===typeof e&&e===gse)return t;let r=Jse(e);if(r===bse)return this;if(!Tse){let e=t,n=this;for(;r>gse;)r&bse&&(e=e.add(n)),n=n.double(),r>>=bse;return e}let{k1neg:n,k1:i,k2neg:o,k2:s}=Ese.splitScalar(r),a=t,c=t,u=this;for(;i>gse||s>gse;)i&bse&&(a=a.add(u)),s&bse&&(c=c.add(u)),u=u.double(),i>>=bse,s>>=bse;return n&&(a=a.negate()),o&&(c=c.negate()),c=new Dse(Xse(c.x*Ese.beta),c.y,c.z),a.add(c)}precomputeWindow(e){const t=Tse?128/e+1:256/e+1,r=[];let n=this,i=n;for(let o=0;o<t;o++){i=n,r.push(i);for(let t=1;t<2**(e-1);t++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(e,t){!t&&this.equals(Dse.BASE)&&(t=Use.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=t&&Bse.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=Dse.normalizeZ(n),Bse.set(t,n)));let i=Dse.ZERO,o=Dse.BASE;const s=1+(Tse?128/r:256/r),a=2**(r-1),c=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let h=0;h<s;h++){const t=h*a;let r=Number(e&c);e>>=l,r>a&&(r-=u,e+=bse);const s=t,d=t+Math.abs(r)-1,f=h%2!==0,p=r<0;0===r?o=o.add(Nse(f,n[s])):i=i.add(Nse(p,n[d]))}return{p:i,f:o}}multiply(e,t){let r,n,i=Jse(e);if(Tse){const{k1neg:e,k1:o,k2neg:s,k2:a}=Ese.splitScalar(i);let{p:c,f:u}=this.wNAF(o,t),{p:l,f:h}=this.wNAF(a,t);c=Nse(e,c),l=Nse(s,l),l=new Dse(Xse(l.x*Ese.beta),l.y,l.z),r=c.add(l),n=u.add(h)}else{const{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return Dse.normalizeZ([r,n])[0]}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(Dse.ZERO);null==e&&(e=i?vse:$se(n));const o=e,s=Xse(o*o),a=Xse(s*o),c=Xse(t*s),u=Xse(r*a),l=Xse(n*o);if(i)return Use.ZERO;if(l!==bse)throw new Error("invZ was invalid");return new Use(c,u)}}function Nse(e,t){const r=t.negate();return e?r:t}Dse.BASE=new Dse(wse.Gx,wse.Gy,bse),Dse.ZERO=new Dse(gse,bse,gse);const Bse=new WeakMap;class Use{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Bse.delete(this)}hasEvenY(){return this.y%yse===gse}static fromCompressedHex(e){const t=32===e.length,r=Yse(t?e:e.subarray(1));if(!oae(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=wse,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),c=e*e*e%t,u=c*c*e%t,l=Zse(u,mse)*u%t,h=Zse(l,mse)*u%t,d=Zse(h,yse)*c%t,f=Zse(d,n)*d%t,p=Zse(f,i)*f%t,g=Zse(p,s)*p%t,b=Zse(g,a)*g%t,y=Zse(b,s)*p%t,m=Zse(y,mse)*u%t,v=Zse(m,o)*f%t,w=Zse(v,r)*c%t,_=Zse(w,yse);if(_*_%t!==e)throw new Error("Cannot find square root");return _}(Cse(r));const i=(n&bse)===bse;if(t)i&&(n=Xse(-n));else{1===(1&e[0])!==i&&(n=Xse(-n))}const o=new Use(r,n);return o.assertValidity(),o}static fromUncompressedHex(e){const t=Yse(e.subarray(1,Sse+1)),r=Yse(e.subarray(Sse+1,2*Sse+1)),n=new Use(t,r);return n.assertValidity(),n}static fromHex(e){const t=Qse(e),r=t.length,n=t[0];if(r===Sse)return this.fromCompressedHex(t);if(r===xse&&(2===n||3===n))return this.fromCompressedHex(t);if(r===Ise&&4===n)return this.fromUncompressedHex(t);throw new Error("Point.fromHex: received invalid point. Expected 32-".concat(xse," compressed bytes or ").concat(Ise," uncompressed bytes, not ").concat(r))}static fromPrivateKey(e){return Use.BASE.multiply(aae(e))}static fromSignature(e,t,r){const{r:n,s:i}=uae(t);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=eae(Qse(e)),{n:s}=wse,a=2===r||3===r?n+s:n,c=$se(a,s),u=Xse(-o*c,s),l=Xse(i*c,s),h=1&r?"03":"02",d=Use.fromHex(h+zse(a)),f=Use.BASE.multiplyAndAddUnsafe(d,u,l);if(!f)throw new Error("Cannot recover signature: point at infinify");return f.assertValidity(),f}toRawBytes(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Wse(this.toHex(e))}toHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=zse(this.x);if(e){const e=this.hasEvenY()?"02":"03";return"".concat(e).concat(t)}return"04".concat(t).concat(zse(this.y))}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!oae(t)||!oae(r))throw new Error(e);const n=Xse(r*r);if(Xse(n-Cse(t))!==gse)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Use(this.x,Xse(-this.y))}double(){return Dse.fromAffine(this).double().toAffine()}add(e){return Dse.fromAffine(this).add(Dse.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Dse.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const n=Dse.fromAffine(this),i=t===gse||t===bse||this!==Use.BASE?n.multiplyUnsafe(t):n.multiply(t),o=Dse.fromAffine(e).multiplyUnsafe(r),s=i.add(o);return s.equals(Dse.ZERO)?void 0:s.toAffine()}}function Lse(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Mse(e){if(e.length<2||2!==e[0])throw new Error("Invalid signature integer tag: ".concat(Fse(e)));const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Yse(r),left:e.subarray(t+2)}}Use.BASE=new Use(wse.Gx,wse.Gy),Use.ZERO=new Use(gse,gse);class Ose{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!==typeof e&&!t)throw new TypeError("".concat(r,": Expected string or Uint8Array"));const n=t?Fse(e):e;if(128!==n.length)throw new Error("".concat(r,": Expected 64-byte hex"));return new Ose(Gse(n.slice(0,64)),Gse(n.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!==typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error("Invalid signature tag: ".concat(Fse(e)));if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=Mse(e.subarray(2)),{data:n,left:i}=Mse(r);if(i.length)throw new Error("Invalid signature: left bytes after parsing: ".concat(Fse(i)));return{r:t,s:n}}(t?e:Wse(e));return new Ose(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!iae(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!iae(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=wse.n>>bse;return this.s>e}normalizeS(){return this.hasHighS()?new Ose(this.r,Xse(-this.s,wse.n)):this}toDERRawBytes(){return Wse(this.toDERHex())}toDERHex(){const e=Lse(Hse(this.s)),t=Lse(Hse(this.r)),r=e.length/2,n=t.length/2,i=Hse(r),o=Hse(n),s=Hse(n+r+4);return"30".concat(s,"02").concat(o).concat(t,"02").concat(i).concat(e)}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Wse(this.toCompactHex())}toCompactHex(){return zse(this.r)+zse(this.s)}}function qse(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(!t.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const n=t.reduce(((e,t)=>e+t.length),0),i=new Uint8Array(n);for(let o=0,s=0;o<t.length;o++){const e=t[o];i.set(e,s),s+=e.length}return i}const Kse=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Fse(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r<e.length;r++)t+=Kse[e[r]];return t}const Vse=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function zse(e){if("bigint"!==typeof e)throw new Error("Expected bigint");if(!(gse<=e&&e<Vse))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function jse(e){const t=Wse(zse(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function Hse(e){const t=e.toString(16);return 1&t.length?"0".concat(t):t}function Gse(e){if("string"!==typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt("0x".concat(e))}function Wse(e){if("string"!==typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+e.length);const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Yse(e){return Gse(Fse(e))}function Qse(e){return e instanceof Uint8Array?Uint8Array.from(e):Wse(e)}function Jse(e){if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"===typeof e&&iae(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Xse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wse.P;const r=e%t;return r>=gse?r:t+r}function Zse(e,t){const{P:r}=wse;let n=e;for(;t-- >gse;)n*=n,n%=r;return n}function $se(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wse.P;if(e===gse||t<=gse)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=Xse(e,t),n=t,i=gse,o=bse,s=bse,a=gse;for(;r!==gse;){const e=n/r,t=n%r,c=i-s*e,u=o-a*e;n=r,r=t,i=s,o=a,s=c,a=u}if(n!==bse)throw new Error("invert: does not exist");return Xse(i,t)}function eae(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=function(e){const t=8*e.length-8*Ase,r=Yse(e);return t>0?r>>BigInt(t):r}(e);if(t)return r;const{n:n}=wse;return r>=n?r-n:r}let tae,rae;class nae{constructor(e,t){if(this.hashLen=e,this.qByteLen=t,"number"!==typeof e||e<2)throw new Error("hashLen must be a number");if("number"!==typeof t||t<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return mae.hmacSha256(this.k,...t)}hmacSync(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return rae(this.k,...t)}checkSync(){if("function"!==typeof rae)throw new Rse("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return qse(...t)}generateSync(){this.checkSync(),this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return qse(...t)}}function iae(e){return gse<e&&e<wse.n}function oae(e){return gse<e&&e<wse.P}function sae(e,t,r){let n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const{n:i}=wse,o=eae(e,!0);if(!iae(o))return;const s=$se(o,i),a=Use.BASE.multiply(o),c=Xse(a.x,i);if(c===gse)return;const u=Xse(s*Xse(t+r*c,i),i);if(u===gse)return;let l=new Ose(c,u),h=(a.x===l.r?0:2)|Number(a.y&bse);return n&&l.hasHighS()&&(l=l.normalizeS(),h^=1),{sig:l,recovery:h}}function aae(e){let t;if("bigint"===typeof e)t=e;else if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"===typeof e){if(e.length!==2*Ase)throw new Error("Expected 32 bytes of private key");t=Gse(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(e.length!==Ase)throw new Error("Expected 32 bytes of private key");t=Yse(e)}if(!iae(t))throw new Error("Expected private key: 0 < key < n");return t}function cae(e){return e instanceof Use?(e.assertValidity(),e):Use.fromHex(e)}function uae(e){if(e instanceof Ose)return e.assertValidity(),e;try{return Ose.fromDER(e)}catch(t){return Ose.fromCompact(e)}}function lae(e){return Yse(e.length>Sse?e.slice(0,Sse):e)}function hae(e){const t=lae(e),r=Xse(t,wse.n);return dae(r<gse?t:r)}function dae(e){return jse(e)}function fae(e,t,r){if(null==e)throw new Error('sign: expected valid message hash, not "'.concat(e,'"'));const n=Qse(e),i=aae(t),o=[dae(i),hae(n)];if(null!=r){!0===r&&(r=mae.randomBytes(Sse));const e=Qse(r);if(e.length!==Sse)throw new Error("sign: Expected ".concat(Sse," bytes of extra data"));o.push(e)}return{seed:qse(...o),m:lae(n),d:i}}function pae(e,t){const{sig:r,recovery:n}=e,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},t),s=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[s,n]:s}const gae={strict:!0};Use.BASE._setWindowSize(8);const bae={node:pse,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},yae={},mae={bytesToHex:Fse,hexToBytes:Wse,concatBytes:qse,mod:Xse,invert:$se,isValidPrivateKey(e){try{return aae(e),!0}catch(t){return!1}},_bigintTo32Bytes:jse,_normalizePrivateKey:aae,hashToPrivateKey:e=>{e=Qse(e);const t=Ase+8;if(e.length<t||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return jse(Xse(Yse(e),wse.n-bse)+bse)},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(bae.web)return bae.web.getRandomValues(new Uint8Array(e));if(bae.node){const{randomBytes:t}=bae.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>mae.hashToPrivateKey(mae.randomBytes(Ase+8)),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Use.BASE;const r=t===Use.BASE?t:new Use(t.x,t.y);return r._setWindowSize(e),r.multiply(mse),r},sha256:async function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(bae.web){const e=await bae.web.subtle.digest("SHA-256",qse(...t));return new Uint8Array(e)}if(bae.node){const{createHash:e}=bae.node,r=e("sha256");return t.forEach((e=>r.update(e))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(bae.web){const t=await bae.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=qse(...r),i=await bae.web.subtle.sign("HMAC",t,n);return new Uint8Array(i)}if(bae.node){const{createHmac:t}=bae.node,n=t("sha256",e);return r.forEach((e=>n.update(e))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async function(e){let t=yae[e];if(void 0===t){const r=await mae.sha256(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=qse(r,r),yae[e]=t}for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return mae.sha256(t,...n)},taggedHashSync:function(e){if("function"!==typeof tae)throw new Rse("sha256Sync is undefined, you need to set it");let t=yae[e];if(void 0===t){const r=tae(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=qse(r,r),yae[e]=t}for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return tae(t,...n)},_JacobianPoint:Dse};Object.defineProperties(mae,{sha256Sync:{configurable:!1,get:()=>tae,set(e){tae||(tae=e)}},hmacSha256Sync:{configurable:!1,get:()=>rae,set(e){rae||(rae=e)}}});var vae=__webpack_require__(2161);function wae(e){return new Uint8Array(vae.keccak256.arrayBuffer(e))}function _ae(e,t,r){try{return function(e,t,r){let n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:gae;try{n=uae(e),t=Qse(t)}catch(p){return!1}const{r:o,s:s}=n;if(i.strict&&n.hasHighS())return!1;const a=eae(t);let c;try{c=cae(r)}catch(p){return!1}const{n:u}=wse,l=$se(s,u),h=Xse(a*l,u),d=Xse(o*l,u),f=Use.BASE.multiplyAndAddUnsafe(c,h,d);return!!f&&Xse(f.x,u)===o}(Ose.fromCompact(e.slice(0,64)),t,r)}catch{return!1}}const Eae="Invalid record id";function Sae(e,t){switch(t){case"udp":return Sae(e,"udp4")||Sae(e,"udp6");case"tcp":return Sae(e,"tcp4")||Sae(e,"tcp6")}const r=t.endsWith("6"),n=e.get(r?"ip6":"ip");if(!n)return;const i=t.slice(0,3);let o;switch(i){case"udp":o=r?e.get("udp6"):e.get("udp");break;case"tcp":o=r?e.get("tcp6"):e.get("tcp");break;default:return}return o?function(e,t,r,n){let i=_I("/"+e+"/"+Qx(e,r));return i=i.encapsulate(_I("/"+t+"/"+Qx(t,n))),i}(r?"ip6":"ip4",i,n,o):void 0}new Uint8Array(0);function Aae(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var kae=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const xae=kae;class Iae{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Cae{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Rae(this,e)}}class Tae{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return Rae(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function Rae(e,t){var r,n;return new Tae({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Pae{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Iae(e,t,r),this.decoder=new Cae(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Dae(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Pae(t,r,n,i)}function Nae(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=xae(n,t);return Dae({prefix:r,name:t,encode:i,decode:e=>Aae(o(e))})}function Bae(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Dae({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const Uae=Nae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lae=Nae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mae=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Kae;)r[n++]=255&t|Oae,t/=128;for(;t&qae;)r[n++]=255&t|Oae,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Oae=128,qae=-128,Kae=Math.pow(2,31);var Fae=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&zae)<<o:(n&zae)*Math.pow(2,o),o+=7}while(n>=Vae);return e.bytes=s-r,i},Vae=128,zae=127;var jae=Math.pow(2,7),Hae=Math.pow(2,14),Gae=Math.pow(2,21),Wae=Math.pow(2,28),Yae=Math.pow(2,35),Qae=Math.pow(2,42),Jae=Math.pow(2,49),Xae=Math.pow(2,56),Zae=Math.pow(2,63);const $ae={encode:Mae,decode:Fae,encodingLength:function(e){return e<jae?1:e<Hae?2:e<Gae?3:e<Wae?4:e<Yae?5:e<Qae?6:e<Jae?7:e<Xae?8:e<Zae?9:10}};function ece(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[$ae.decode(e,t),$ae.decode.bytes]}function tce(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return $ae.encode(e,t,r),t}function rce(e){return $ae.encodingLength(e)}function nce(e,t){const r=t.byteLength,n=rce(e),i=n+rce(r),o=new Uint8Array(i+r);return tce(e,o,0),tce(r,o,n),o.set(t,i),new oce(e,r,t,o)}function ice(e){const t=Aae(e),[r,n]=ece(t),[i,o]=ece(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new oce(r,i,s,t)}class oce{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const sce=Aae;const ace={code:0,name:"identity",encode:sce,digest:function(e){return nce(0,sce(e))}};function cce(e){let{name:t,code:r,encode:n}=e;return new uce(t,r,n)}class uce{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?nce(this.code,t):t.then((e=>nce(this.code,e)))}throw Error("Unknown type, must be binary type")}}function lce(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const hce=cce({name:"sha2-256",code:18,encode:lce("SHA-256")}),dce=cce({name:"sha2-512",code:19,encode:lce("SHA-512")});function fce(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const pce=Nae({prefix:"9",name:"base10",alphabet:"0123456789"}),gce=Bae({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bce=Bae({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),yce=Bae({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),mce=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),vce=mce.reduce(((e,t,r)=>(e[r]=t,e)),[]),wce=mce.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const _ce=Dae({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=vce[t]),"")},decode:function(e){const t=[];for(const r of e){const e=wce[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Ece=Bae({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sce=Bae({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ace=Bae({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),kce=Bae({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xce=Bae({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ice=Bae({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cce=Bae({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tce=Bae({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rce=Bae({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Pce=Nae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Dce=Nae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Nce=Bae({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bce=Bae({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Uce=Bae({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lce=Bae({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Mce=Bae({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Oce=Dae({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),qce=new TextEncoder,Kce=new TextDecoder,Fce="json",Vce=512;function zce(e){return qce.encode(JSON.stringify(e))}function jce(e){return JSON.parse(Kce.decode(e))}const Hce="raw",Gce=85;function Wce(e){return Aae(e)}function Yce(e){return Aae(e)}function Qce(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==Uae.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,Xce(e),null!==t&&void 0!==t?t:Uae.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,Xce(e),null!==t&&void 0!==t?t:Ece.encoder)}const Jce=new WeakMap;function Xce(e){const t=Jce.get(e);if(null==t){const t=new Map;return Jce.set(e,t),t}return t}class Zce{constructor(e,t,r,n){co(this,"code",void 0),co(this,"version",void 0),co(this,"multihash",void 0),co(this,"bytes",void 0),co(this,"/",void 0),co(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==$ce)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==eue)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Zce.createV0(t)}default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=nce(e,t);return Zce.createV1(this.code,r)}case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return Zce.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return Qce(this,e)}toJSON(){return{"/":Qce(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;const t=e;if(t instanceof Zce)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new Zce(e,r,n,null!==i&&void 0!==i?i:tue(e,r,n.bytes))}if(!0===t[rue]){const{version:e,multihash:r,code:n}=t,i=ice(r);return Zce.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==$ce)throw new Error("Version 0 CID must use dag-pb (code: ".concat($ce,") block encoding"));return new Zce(e,t,r,r.bytes);case 1:{const n=tue(e,t,r.bytes);return new Zce(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return Zce.create(0,$ce,e)}static createV1(e,t){return Zce.create(1,e,t)}static decode(e){const[t,r]=Zce.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=Zce.inspectBytes(e),r=t.size-t.multihashSize,n=Aae(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),o=new oce(t.multihashCode,t.digestSize,i,n);return[0===t.version?Zce.createV0(o):Zce.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=ece(e.subarray(t));return t+=n,r};let n=r(),i=$ce;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));const o=t,s=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:s,digestSize:a,multihashSize:c-o,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=null!==t&&void 0!==t?t:Uae;return[Uae.prefix,r.decode("".concat(Uae.prefix).concat(e))]}case Uae.prefix:{const r=null!==t&&void 0!==t?t:Uae;return[Uae.prefix,r.decode(e)]}case Ece.prefix:{const r=null!==t&&void 0!==t?t:Ece;return[Ece.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=Zce.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return Xce(i).set(r,e),i}}const $ce=112,eue=18;function tue(e,t,r){const n=rce(e),i=n+rce(t),o=new Uint8Array(i+r.byteLength);return tce(e,o,0),tce(t,o,n),o.set(r,i),o}const rue=Symbol.for("@ipld/js-cid/CID"),nue={...Oi,...Di,...Mi,...Ri,...Pi,...Bi,...Ui,...Ii,...Li,...Ni};function iue(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function oue(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const sue=oue("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),aue=oue("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=iue((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),cue={utf8:sue,"utf-8":sue,hex:nue.base16,latin1:aue,ascii:aue,binary:aue,...nue};function uue(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=cue[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function lue(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const hue=32,due=64,fue=32;function pue(e,t){const r=new Uint8Array(due);for(let n=0;n<fue;n++)r[n]=e[n],r[fue+n]=t[n];return r}const gue={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},bue={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function yue(e){var t,r,n,i,o,s;const a=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM";let c=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16;const u=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",h=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,d=null!==(s=null===e||void 0===e?void 0:e.iterations)&&void 0!==s?s:32767,f=gue.get();c*=8;const p={encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(u)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=uue(t)),0===t.length){o=await f.subtle.importKey("jwk",bue,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}catch{o=await f.subtle.importKey("jwk",bue,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);o=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["encrypt"])}const s=await f.subtle.encrypt(i,o,e);return function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=iue(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+u),i=e.subarray(h+u),o={name:a,iv:n};let s;if("string"===typeof t&&(t=uue(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}catch{s=await f.subtle.importKey("jwk",bue,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:l}},n=await f.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveKey"]);s=await f.subtle.deriveKey(e,n,{name:a,length:c},!0,["decrypt"])}const p=await f.subtle.decrypt(o,s,i);return new Uint8Array(p)}};return p}async function mue(e,t){const r=yue(),n=await r.encrypt(e,t);return Nce.encode(n)}const vue=new Float32Array([-0]),wue=new Uint8Array(vue.buffer);function _ue(e,t,r){vue[0]=e,t[r]=wue[0],t[r+1]=wue[1],t[r+2]=wue[2],t[r+3]=wue[3]}const Eue=new Float64Array([-0]),Sue=new Uint8Array(Eue.buffer);function Aue(e,t,r){Eue[0]=e,t[r]=Sue[0],t[r+1]=Sue[1],t[r+2]=Sue[2],t[r+3]=Sue[3],t[r+4]=Sue[4],t[r+5]=Sue[5],t[r+6]=Sue[6],t[r+7]=Sue[7]}const kue=BigInt(Number.MAX_SAFE_INTEGER),xue=BigInt(Number.MIN_SAFE_INTEGER);class Iue{constructor(e,t){co(this,"lo",void 0),co(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return Cue;if(e<kue&&e>xue)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Tue&&(n=0n,++r>Tue&&(r=0n))),new Iue(Number(n),Number(r))}static fromNumber(e){if(0===e)return Cue;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Iue(r,n)}static from(e){return"number"===typeof e?Iue.fromNumber(e):"bigint"===typeof e?Iue.fromBigInt(e):"string"===typeof e?Iue.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Iue(e.low>>>0,e.high>>>0):Cue}}const Cue=new Iue(0,0);Cue.toBigInt=function(){return 0n},Cue.zzEncode=Cue.zzDecode=function(){return this},Cue.length=function(){return 1};const Tue=4294967296n;function Rue(e,t,r){const n=r;let i,o;for(let s=0;s<e.length;++s)i=e.charCodeAt(s),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(o=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&o),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function Pue(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function Due(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Nue{constructor(e){co(this,"buf",void 0),co(this,"pos",void 0),co(this,"len",void 0),co(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Pue(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw Pue(this,4);return Due(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Pue(this,4);return 0|Due(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw Pue(this,4);const e=(t=this.buf,r=this.pos,wue[0]=t[r],wue[1]=t[r+1],wue[2]=t[r+2],wue[3]=t[r+3],vue[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Pue(this,4);const e=(t=this.buf,r=this.pos,Sue[0]=t[r],Sue[1]=t[r+1],Sue[2]=t[r+2],Sue[3]=t[r+3],Sue[4]=t[r+4],Sue[5]=t[r+5],Sue[6]=t[r+6],Sue[7]=t[r+7],Eue[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Pue(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let o,s=0;for(;t<r;){var a;o=e[t++],o<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!==(a=n)&&void 0!==a?a:n=[]).push(String.fromCharCode.apply(String,i)),s=0)}return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw Pue(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Pue(this)}while(0!==(128&this.buf[this.pos++]));return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){const e=new Iue(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Pue(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Pue(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Pue(this,8);const e=Due(this.buf,this.pos+=4),t=Due(this.buf,this.pos+=4);return new Iue(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=_o(this.buf,this.pos);return this.pos+=vo(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function Bue(e,t,r){const n=function(e){return new Nue(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class Uue{constructor(e,t,r){co(this,"fn",void 0),co(this,"len",void 0),co(this,"next",void 0),co(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Lue(){}class Mue{constructor(e){co(this,"head",void 0),co(this,"tail",void 0),co(this,"len",void 0),co(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Oue=function(e){const t=null!==e&&void 0!==e?e:8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return iue(e);i+e>t&&(n=iue(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class que{constructor(){co(this,"len",void 0),co(this,"head",void 0),co(this,"tail",void 0),co(this,"states",void 0),this.len=0,this.head=new Uue(Lue,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Uue(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Vue((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(zue,10,Iue.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=Iue.fromBigInt(e);return this._push(zue,t.length(),t)}uint64Number(e){return this._push(wo,vo(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){const t=Iue.fromBigInt(e).zzEncode();return this._push(zue,t.length(),t)}sint64Number(e){const t=Iue.fromNumber(e).zzEncode();return this._push(zue,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Kue,1,e?1:0)}fixed32(e){return this._push(jue,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=Iue.fromBigInt(e);return this._push(jue,4,t.lo)._push(jue,4,t.hi)}fixed64Number(e){const t=Iue.fromNumber(e);return this._push(jue,4,t.lo)._push(jue,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(_ue,4,e)}double(e){return this._push(Aue,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Kue,1,0):this.uint32(t)._push(Hue,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Rue,t,e):this._push(Kue,1,0)}fork(){return this.states=new Mue(this),this.head=this.tail=new Uue(Lue,0,0),this.len=0,this}reset(){return null!=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 Uue(Lue,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?iue(r):Oue(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Kue(e,t,r){t[r]=255&e}function Fue(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Vue extends Uue{constructor(e,t){super(Fue,e,t),co(this,"next",void 0),this.next=void 0}}function zue(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function jue(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Hue(e,t,r){t.set(e,r)}function Gue(e,t,r){t.set(e,r)}function Wue(e,t,r){e.length<40?Rue(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(uue(e),r)}function Yue(e,t){const r=new que;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Que,Jue,Xue,Zue,$ue;function ele(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function tle(e,t){return ele("message",Que.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(que.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Gue,t,e),this},que.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Wue,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(Que||(Que={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(Jue||(Jue={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(Xue||(Xue={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return ele("enum",Que.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(Xue)}(Jue||(Jue={})),function(e){let t;e.codec=()=>(null==t&&(t=tle((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),Jue.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=Jue.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yue(t,e.codec()),e.decode=t=>Bue(t,e.codec())}(Zue||(Zue={})),function(e){let t;e.codec=()=>(null==t&&(t=tle((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),Jue.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=Jue.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yue(t,e.codec()),e.decode=t=>Bue(t,e.codec())}($ue||($ue={}));class rle{constructor(e){co(this,"_key",void 0),this._key=cle(e,hue)}verify(e,t){return function(e,t,r){return Wp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return Zue.encode({Type:Jue.Ed25519,Data:this.marshal()}).subarray()}equals(e){return fce(this.bytes,e.bytes)}hash(){const e=hce.digest(this.bytes);return lue(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class nle{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=cle(e,due),this._publicKey=cle(t,hue)}sign(e){return function(e,t){const r=e.subarray(0,fue);return Wp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new rle(this._publicKey)}marshal(){return this._key}get bytes(){return $ue.encode({Type:Jue.Ed25519,Data:this.marshal()}).subarray()}equals(e){return fce(this.bytes,e.bytes)}async hash(){const e=hce.digest(this.bytes);let t;return lue(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=ace.digest(this.public.bytes);return Uae.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return mue(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function ile(e){if(e.length>due){const t=(e=cle(e,due+hue)).subarray(0,due),r=e.subarray(due,e.length);return new nle(t,r)}const t=(e=cle(e,due)).subarray(0,due),r=e.subarray(hue);return new nle(t,r)}function ole(e){return e=cle(e,hue),new rle(e)}async function sle(){const{privateKey:e,publicKey:t}=function(){const e=Wp.utils.randomPrivateKey(),t=Wp.getPublicKey(e);return{privateKey:pue(e,t),publicKey:t}}();return new nle(e,t)}async function ale(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==fue)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Wp.getPublicKey(t);return{privateKey:pue(t,r),publicKey:r}}(e);return new nle(t,r)}function cle(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ug("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}function ule(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=cue[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}async function lle(e){const t=[await gue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await dle(e)],r=await hle({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function hle(e){if(null==e.privateKey||null==e.publicKey)throw new ug("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([gue.get().subtle.exportKey("jwk",e.privateKey),gue.get().subtle.exportKey("jwk",e.publicKey)])}async function dle(e){return gue.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function fle(e){if("RSA"!==e.kty)throw new ug("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ug("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*uue(e.n,"base64url").length}function ple(e){if(isNaN(e)||e<=0)throw new ug("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pc(e)}function gle(e){let t=e.toString(16);t.length%2>0&&(t="0".concat(t));const r=t.length/2,n=new Uint8Array(r);let i=0,o=0;for(;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n}function ble(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r="0".concat(r)),t.push(r)})),BigInt("0x"+t.join(""))}const yle=32,mle=1e4;const vle=8192;class wle{constructor(e){co(this,"_key",void 0),this._key=e}verify(e,t){return async function(e,t,r){const n=await gue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return gue.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new zU({valueHex:new rL({value:[YU.fromBigInt(ble(uue(e.n,"base64url"))),YU.fromBigInt(ble(uue(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return Zue.encode({Type:Jue.RSA,Data:this.marshal()}).subarray()}equals(e){return fce(this.bytes,e.bytes)}hash(){const e=hce.digest(this.bytes);return lue(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class _le{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return ple(16)}sign(e){return async function(e,t){const r=await gue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await gue.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ug("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new wle(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ug("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new rL({value:[new YU({value:0}),YU.fromBigInt(ble(uue(e.n,"base64url"))),YU.fromBigInt(ble(uue(e.e,"base64url"))),YU.fromBigInt(ble(uue(e.d,"base64url"))),YU.fromBigInt(ble(uue(e.p,"base64url"))),YU.fromBigInt(ble(uue(e.q,"base64url"))),YU.fromBigInt(ble(uue(e.dp,"base64url"))),YU.fromBigInt(ble(uue(e.dq,"base64url"))),YU.fromBigInt(ble(uue(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return $ue.encode({Type:Jue.RSA,Data:this.marshal()}).subarray()}equals(e){return fce(this.bytes,e.bytes)}hash(){const e=hce.digest(this.bytes);return lue(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return ule(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=gue.get(),n=new rL({value:[new YU({value:0}),new rL({value:[new ZU({value:"1.2.840.113549.1.1.1"}),new MU]}),new FU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),o=ple(16),s=await EB(Nf,t,o,{c:mle,dkLen:yle}),a=ple(16),c=await r.subtle.importKey("raw",s,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new rL({value:[new FU({valueHex:o}),new YU({value:mle}),new YU({value:yle}),new rL({value:[new ZU({value:"1.2.840.113549.2.11"}),new MU]})]}),h=new rL({value:[new ZU({value:"1.2.840.113549.1.5.13"}),new rL({value:[new rL({value:[new ZU({value:"1.2.840.113549.1.5.12"}),l]}),new rL({value:[new ZU({value:"2.16.840.1.101.3.4.1.42"}),new FU({valueHex:a})]})]})]}),d=new rL({value:[h,new FU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...ule(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return mue(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function Ele(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value;return{n:ule(gle(r[1].toBigInt()),"base64url"),e:ule(gle(r[2].toBigInt()),"base64url"),d:ule(gle(r[3].toBigInt()),"base64url"),p:ule(gle(r[4].toBigInt()),"base64url"),q:ule(gle(r[5].toBigInt()),"base64url"),dp:ule(gle(r[6].toBigInt()),"base64url"),dq:ule(gle(r[7].toBigInt()),"base64url"),qi:ule(gle(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(fle(t)>vle)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await lle(t);return new _le(r.privateKey,r.publicKey)}function Sle(e){const t=function(e){const{result:t}=DU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ule(gle(r[0].toBigInt()),"base64url"),e:ule(gle(r[1].toBigInt()),"base64url")}}(e);if(fle(t)>vle)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new wle(t)}async function Ale(e){if(fle(e)>vle)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await lle(e);return new _le(t.privateKey,t.publicKey)}async function kle(e){if(e>vle)throw new ug("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await gue.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await hle(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new _le(t.privateKey,t.publicKey)}function xle(e){try{Am.ProjectivePoint.fromHex(e)}catch(t){throw new ug(String(t),"ERR_INVALID_PUBLIC_KEY")}}class Ile{constructor(e){co(this,"_key",void 0),xle(e),this._key=e}verify(e,t){return function(e,t,r){const n=hce.digest(r instanceof Uint8Array?r:r.subarray());if(lue(n))return n.then((r=>{let{digest:n}=r;return Am.verify(t,n,e)})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.verify(t,n.digest,e)}catch(i){throw new ug(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,Am.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return Zue.encode({Type:Jue.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return fce(this.bytes,e.bytes)}async hash(){const e=hce.digest(this.bytes);let t;return lue(e)?({bytes:t}=await e):t=e.bytes,t}}class Cle{constructor(e,t){co(this,"_key",void 0),co(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{Am.getPublicKey(e,!0)}catch(t){throw new ug(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),xle(this._publicKey)}sign(e){return function(e,t){const r=hce.digest(t instanceof Uint8Array?t:t.subarray());if(lue(r))return r.then((t=>{let{digest:r}=t;return Am.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ug(String(e),"ERR_INVALID_INPUT")}));try{return Am.sign(r.digest,e).toDERRawBytes()}catch(n){throw new ug(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new Ile(this._publicKey)}marshal(){return this._key}get bytes(){return $ue.encode({Type:Jue.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return fce(this.bytes,e.bytes)}hash(){const e=hce.digest(this.bytes);return lue(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return ule(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return mue(this.bytes,e);throw new ug("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function Tle(e){return new Cle(e)}function Rle(e){return new Ile(e)}async function Ple(){const e=Am.utils.randomPrivateKey();return new Cle(e)}const Dle={rsa:Vi,ed25519:Fi,secp256k1:zi};const Nle=Symbol.for("nodejs.util.inspect.custom"),Ble=Object.values(nue).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),nue.identity.decoder),Ule=114,Lle=36,Mle=37;class Ole{constructor(e){co(this,"type",void 0),co(this,"multihash",void 0),co(this,"privateKey",void 0),co(this,"publicKey",void 0),co(this,"string",void 0),co(this,Bm,!0),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return"PeerId(".concat(this.toString(),")")}toString(){return null==this.string&&(this.string=Uae.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Zce.createV1(Ule,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(null==e)return!1;if(e instanceof Uint8Array)return fce(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:Ble,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=ice(Uae.decode("z".concat(e)));return e.startsWith("12D")?new Kle({multihash:t}):e.startsWith("16U")?new Fle({multihash:t}):new qle({multihash:t})}return function(e){try{const t=ice(e);if(t.code===ace.code){if(t.digest.length===Lle)return new Kle({multihash:t});if(t.digest.length===Mle)return new Fle({multihash:t})}if(t.code===hce.code)return new qle({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==Ule)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===hce.code)return new qle({multihash:e.multihash});if(t.code===ace.code){if(t.digest.length===Lle)return new Kle({multihash:e.multihash});if(t.digest.length===Mle)return new Fle({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(Zce.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(Ble.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return fce(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Nle](){return"PeerId(".concat(this.toString(),")")}}class qle extends Ole{constructor(e){super({...e,type:"RSA"}),co(this,"type","RSA"),co(this,"publicKey",void 0),this.publicKey=e.publicKey}}class Kle extends Ole{constructor(e){super({...e,type:"Ed25519"}),co(this,"type","Ed25519"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class Fle extends Ole{constructor(e){super({...e,type:"secp256k1"}),co(this,"type","secp256k1"),co(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function Vle(e){return async function(e,t){return e.length===Lle?new Kle({multihash:nce(ace.code,e),privateKey:t}):e.length===Mle?new Fle({multihash:nce(ace.code,e),privateKey:t}):new qle({multihash:await hce.digest(e),publicKey:e,privateKey:t})}(new Dle.secp256k1.Secp256k1PublicKey(e).bytes,void 0)}function zle(e){const t=e.reduce(((e,t)=>e+2+t.bytes.length),0),r=new Uint8Array(t),n=new DataView(r.buffer);let i=0;return e.forEach((e=>{if(e.getPeerId())throw new Error("`multiaddr` field MUST not contain peer id");n.setUint16(i,e.bytes.length),i+=2,r.set(e.bytes,i),i+=e.bytes.length})),r}function jle(e){let t=0;return e.lightPush&&(t+=1),t<<=1,e.filter&&(t+=1),t<<=1,e.store&&(t+=1),t<<=1,e.relay&&(t+=1),t}class Hle extends Map{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BigInt(1),r=arguments.length>2?arguments[2]:void 0;super(Object.entries(e)),co(this,"seq",void 0),co(this,"signature",void 0),this.seq=t,this.signature=r}set(e,t){return this.signature=void 0,this.seq++,super.set(e,t)}get id(){const e=this.get("id");if(!e)throw new Error("id not found.");return Al(e)}get publicKey(){if("v4"===this.id)return this.get("secp256k1");throw new Error(Eae)}get rs(){const e=this.get("rs");if(e)return Ll(e)}get rsv(){const e=this.get("rsv");if(e)return Ll(e)}get ip(){return Gle(this,"ip","ip4")}set ip(e){Yle(this,"ip","ip4",e)}get tcp(){return Wle(this,"tcp","tcp")}set tcp(e){Qle(this,"tcp","tcp",e)}get udp(){return Wle(this,"udp","udp")}set udp(e){Qle(this,"udp","udp",e)}get ip6(){return Gle(this,"ip6","ip6")}set ip6(e){Yle(this,"ip6","ip6",e)}get tcp6(){return Wle(this,"tcp6","tcp")}set tcp6(e){Qle(this,"tcp6","tcp",e)}get udp6(){return Wle(this,"udp6","udp")}set udp6(e){Qle(this,"udp6","udp",e)}get multiaddrs(){const e=this.get("multiaddrs");if(e)return function(e){const t=[];let r=0;for(;r<e.length;){const n=new DataView(e.buffer,r,2).getUint16(0);r+=2;const i=e.slice(r,r+n);r+=n,t.push(_I(i))}return t}(e)}set multiaddrs(e){Jle(this,"multiaddrs",e,zle)}get waku2(){const e=this.get("waku2");if(e)return function(e){const t={relay:!1,store:!1,filter:!1,lightPush:!1};return e%2&&(t.relay=!0),(e>>=1)%2&&(t.store=!0),(e>>=1)%2&&(t.filter=!0),(e>>=1)%2&&(t.lightPush=!0),t}(e[0])}set waku2(e){Jle(this,"waku2",e,(e=>new Uint8Array([jle(e)])))}}function Gle(e,t,r){const n=e.get(t);if(n)return Qx(r,n)}function Wle(e,t,r){const n=e.get(t);if(n)return Number(Qx(r,n))}function Yle(e,t,r,n){Jle(e,t,n,Jx.bind({},r))}function Qle(e,t,r,n){Yle(e,t,r,null===n||void 0===n?void 0:n.toString(10))}function Jle(e,t,r,n){void 0!==r?e.set(t,n(r)):e.delete(t)}async function Xle(e,t){return async function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{seed:n,m:i,d:o}=fae(e,t,r.extraEntropy),s=new nae(kse,Ase);let a;for(await s.reseed(n);!(a=sae(await s.generate(),i,o,r.canonical));)await s.reseed();return pae(a,r)}(wae(t),e,{der:!1})}const Zle=new Kl("enr");var $le,ehe;!function(e){e.TCP="tcp",e.UDP="udp"}($le||($le={})),function(e){e.TCP4="tcp4",e.UDP4="udp4",e.TCP6="tcp6",e.UDP6="udp6"}(ehe||(ehe={}));class the extends Hle{constructor(){super(...arguments),co(this,"peerId",void 0),co(this,"getLocationMultiaddr",Sae.bind({},this))}static async create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BigInt(1);const r=new the(e,t,arguments.length>2?arguments[2]:void 0);try{const e=r.publicKey;e&&(r.peerId=await Vle(e))}catch(n){Zle.error("Could not calculate peer id for ENR",n)}return r}get nodeId(){if("v4"===this.id)return this.publicKey?function(e){const t=Use.fromHex(e).toRawBytes(!1);return Sl(wae(t.slice(1)))}(this.publicKey):void 0;throw new Error(Eae)}get shardInfo(){return this.rs&&this.rsv&&Zle.warn("ENR contains both `rs` and `rsv` fields."),this.rs||this.rsv}setLocationMultiaddr(e){const t=e.protoNames();if(2!==t.length&&"udp"!==t[1]&&"tcp"!==t[1])throw new Error("Invalid multiaddr");const r=e.tuples();if(!r[0][1]||!r[1][1])throw new Error("Invalid multiaddr");4===r[0][0]?(this.set("ip",r[0][1]),this.set(t[1],r[1][1])):(this.set("ip6",r[0][1]),this.set(t[1]+"6",r[1][1]))}getAllLocationMultiaddrs(){var e;const t=[];for(const n of Object.values(ehe)){const e=this.getLocationMultiaddr(n);e&&t.push(e)}const r=null!==(e=this.multiaddrs)&&void 0!==e?e:[];return t.concat(r).map((e=>this.peerId?e.encapsulate("/p2p/".concat(this.peerId.toString())):e))}get peerInfo(){const e=this.peerId;if(e)return{id:e,multiaddrs:this.getAllLocationMultiaddrs()}}getFullMultiaddr(e){if(this.peerId){const t=this.getLocationMultiaddr(e);if(t)return t.encapsulate("/p2p/".concat(this.peerId.toString()))}}getFullMultiaddrs(){if(this.peerId&&this.multiaddrs){const e=this.peerId;return this.multiaddrs.map((t=>t.encapsulate("/p2p/".concat(e.toString()))))}return[]}verify(e,t){if(!this.get("id")||"v4"!==this.id)throw new Error(Eae);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return _ae(t,wae(e),this.publicKey)}async sign(e,t){if("v4"!==this.id)throw new Error(Eae);return this.signature=await Xle(t,e),this.signature}}co(the,"RECORD_PREFIX","enr:");let rhe=!1,nhe=!1;const ihe={debug:1,default:2,info:2,warning:3,error:4,off:5};let ohe=ihe.default,she=null;const ahe=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var che,uhe;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(che||(che={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(uhe||(uhe={}));const lhe="0123456789abcdef";class hhe{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==ihe[r]&&this.throwArgumentError("invalid log level name","logLevel",e),ohe>ihe[r]||console.log.apply(console,t)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(hhe.levels.DEBUG,t)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(hhe.levels.INFO,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(hhe.levels.WARNING,t)}makeError(e,t,r){if(nhe)return this.makeError("censored error",t,{});t||(t=hhe.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach((e=>{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=lhe[t[e]>>4],r+=lhe[15&t[e]];n.push(e+"=Uint8Array(0x"+r+")")}else n.push(e+"="+JSON.stringify(t))}catch(s){n.push(e+"="+JSON.stringify(r[e].toString()))}})),n.push("code=".concat(t)),n.push("version=".concat(this.version));const i=e;let o="";switch(t){case uhe.NUMERIC_FAULT:{o="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":o+="-"+t;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case uhe.CALL_EXCEPTION:case uhe.INSUFFICIENT_FUNDS:case uhe.MISSING_NEW:case uhe.NONCE_EXPIRED:case uhe.REPLACEMENT_UNDERPRICED:case uhe.TRANSACTION_REPLACED:case uhe.UNPREDICTABLE_GAS_LIMIT:o=t}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const s=new Error(e);return s.reason=i,s.code=t,Object.keys(r).forEach((function(e){s[e]=r[e]})),s}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,hhe.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),ahe&&this.throwError("platform missing String.prototype.normalize",hhe.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ahe})}checkSafeUint53(e,t){"number"===typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,hhe.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,hhe.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",e<t&&this.throwError("missing argument"+r,hhe.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+r,hhe.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",hhe.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",hhe.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",hhe.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return she||(she=new hhe("logger/5.7.0")),she}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",hhe.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),rhe){if(!e)return;this.globalLogger().throwError("error censorship permanent",hhe.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}nhe=!!e,rhe=!!t}static setLogLevel(e){const t=ihe[e.toLowerCase()];null!=t?ohe=t:hhe.globalLogger().warn("invalid log level - "+e)}static from(e){return new hhe(e)}}hhe.errors=uhe,hhe.levels=che;const dhe=new hhe("bytes/5.7.0");function fhe(e){return!!e.toHexString}function phe(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return phe(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function ghe(e){return vhe(e)&&!(e.length%2)||yhe(e)}function bhe(e){return"number"===typeof e&&e==e&&e%1===0}function yhe(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!bhe(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!bhe(r)||r<0||r>=256)return!1}return!0}function mhe(e,t){if(t||(t={}),"number"===typeof e){dhe.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),phe(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),fhe(e)&&(e=e.toHexString()),vhe(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0"+r:"right"===t.hexPad?r+="0":dhe.throwArgumentError("hex data is odd-length","value",e));const n=[];for(let e=0;e<r.length;e+=2)n.push(parseInt(r.substring(e,e+2),16));return phe(new Uint8Array(n))}return yhe(e)?phe(new Uint8Array(e)):dhe.throwArgumentError("invalid arrayify value","value",e)}function vhe(e,t){return!("string"!==typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}const whe="0123456789abcdef";function _he(e,t){if(t||(t={}),"number"===typeof e){dhe.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=whe[15&e]+t,e=Math.floor(e/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if("bigint"===typeof e)return(e=e.toString(16)).length%2?"0x0"+e:"0x"+e;if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),fhe(e))return e.toHexString();if(vhe(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":dhe.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(yhe(e)){let t="0x";for(let r=0;r<e.length;r++){let n=e[r];t+=whe[(240&n)>>4]+whe[15&n]}return t}return dhe.throwArgumentError("invalid hexlify value","value",e)}const Ehe=new hhe("rlp/5.7.0");function She(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function Ahe(e,t,r){let n=0;for(let i=0;i<r;i++)n=256*n+e[t+i];return n}function khe(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat(khe(e))})),t.length<=55)return t.unshift(192+t.length),t;const r=She(t.length);return r.unshift(247+r.length),r.concat(t)}ghe(e)||Ehe.throwArgumentError("RLP object must be BytesLike","object",e);const t=Array.prototype.slice.call(mhe(e));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const r=She(t.length);return r.unshift(183+r.length),r.concat(t)}function xhe(e){return _he(khe(e))}function Ihe(e,t,r,n){const i=[];for(;r<t+1+n;){const o=Che(e,r);i.push(o.result),(r+=o.consumed)>t+1+n&&Ehe.throwError("child data too short",hhe.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:i}}function Che(e,t){if(0===e.length&&Ehe.throwError("data too short",hhe.errors.BUFFER_OVERRUN,{}),e[t]>=248){const r=e[t]-247;t+1+r>e.length&&Ehe.throwError("data short segment too short",hhe.errors.BUFFER_OVERRUN,{});const n=Ahe(e,t+1,r);return t+1+r+n>e.length&&Ehe.throwError("data long segment too short",hhe.errors.BUFFER_OVERRUN,{}),Ihe(e,t,t+1+r,r+n)}if(e[t]>=192){const r=e[t]-192;return t+1+r>e.length&&Ehe.throwError("data array too short",hhe.errors.BUFFER_OVERRUN,{}),Ihe(e,t,t+1,r)}if(e[t]>=184){const r=e[t]-183;t+1+r>e.length&&Ehe.throwError("data array too short",hhe.errors.BUFFER_OVERRUN,{});const n=Ahe(e,t+1,r);t+1+r+n>e.length&&Ehe.throwError("data array too short",hhe.errors.BUFFER_OVERRUN,{});return{consumed:1+r+n,result:_he(e.slice(t+1+r,t+1+r+n))}}if(e[t]>=128){const r=e[t]-128;t+1+r>e.length&&Ehe.throwError("data too short",hhe.errors.BUFFER_OVERRUN,{});return{consumed:1+r,result:_he(e.slice(t+1,t+1+r))}}return{consumed:1,result:_he(e[t])}}const The=new Kl("enr:decoder");class Rhe{static fromString(e){if(!e.startsWith(the.RECORD_PREFIX))throw new Error("\"string encoded ENR must start with '".concat(the.RECORD_PREFIX,"'"));return Rhe.fromRLP(uue(e.slice(4),"base64url"))}static fromRLP(e){const t=function(e){const t=mhe(e),r=Che(t,0);return r.consumed!==t.length&&Ehe.throwArgumentError("invalid rlp data","data",e),r.result}(e).map(El);return async function(e){const{signature:t,seq:r,kvs:n}=function(e){if(!Array.isArray(e))throw new Error("Decoded ENR must be an array");if(e.length%2!==0)throw new Error("Decoded ENR must have an even number of elements");const[t,r,...n]=e;if(!t||Array.isArray(t))throw new Error("Decoded ENR invalid signature: must be a byte array");if(!r||Array.isArray(r))throw new Error("Decoded ENR invalid sequence number: must be a byte array");return{signature:t,seq:r,kvs:n}}(e),i={};for(let c=0;c<n.length;c+=2)try{i[Al(n[c])]=n[c+1]}catch(a){The.error("Failed to decode ENR key to UTF-8, skipping it",n[c],a)}const o=function(e){return e.length?BigInt("0x"+Sl(e)):BigInt(0)}(r),s=await the.create(i,o,t);return function(e,t,r,n){const i=El(xhe([e,...t]));if(!r.verify(i,n))throw new Error("Unable to verify ENR signature")}(r,n,s,t),s}(t)}}const Phe=/^(\d{1,3}\.){3,3}\d{1,3}$/,Dhe=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,Nhe={name:"v4",size:4,isFormat:e=>Phe.test(e),encode(e,t,r){r=~~r,t=t||new Uint8Array(r+4);const n=e.length;let i=0;for(let o=0;o<n;){const n=e.charCodeAt(o++);46===n?(t[r++]=i,i=0):i=10*i+(n-48)}return t[r]=i,t},decode:(e,t)=>(t=~~t,"".concat(e[t++],".").concat(e[t++],".").concat(e[t++],".").concat(e[t]))},Bhe={name:"v6",size:16,isFormat:e=>e.length>0&&Dhe.test(e),encode(e,t,r){let n=(r=~~r)+16,i=-1,o=0,s=0,a=!0,c=!1;t=t||new Uint8Array(r+16);for(let u=0;u<e.length;u++){let l=e.charCodeAt(u);58===l?(a?-1!==i?(r<n&&(t[r]=0),r<n-1&&(t[r+1]=0),r+=2):r<n&&(i=r):(!0===c?(r<n&&(t[r]=s),r++):(r<n&&(t[r]=o>>8),r<n-1&&(t[r+1]=255&o),r+=2),o=0,s=0),a=!0,c=!1):46===l?(r<n&&(t[r]=s),r++,s=0,o=0,a=!1,c=!0):(a=!1,l>=97?l-=87:l>=65?l-=55:(l-=48,s=10*s+l),o=(o<<4)+l)}if(!1===a)!0===c?(r<n&&(t[r]=s),r++):(r<n&&(t[r]=o>>8),r<n-1&&(t[r+1]=255&o),r+=2);else if(0===i)r<n&&(t[r]=0),r<n-1&&(t[r+1]=0),r+=2;else if(-1!==i){r+=2;for(let e=Math.min(r-1,n-1);e>=i+2;e--)t[e]=t[e-2];t[i]=0,t[i+1]=0,i=r}if(i!==r&&-1!==i)for(r>n-2&&(r=n-2);n>i;)t[--n]=r<n&&r>i?t[--r]:0;else for(;r<n;)t[r++]=0;return t},decode(e,t){t=~~t;let r="";for(let n=0;n<16;n+=2)0!==n&&(r+=":"),r+=(e[t+n]<<8|e[t+n+1]).toString(16);return r.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};function Uhe(e){if(Nhe.isFormat(e))return Nhe.size;if(Bhe.isFormat(e))return Bhe.size;throw Error("Invalid ip address: ".concat(e))}function Lhe(e){switch(e){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+e}function Mhe(e){switch(e.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":case"*":return 255}return e.toUpperCase().startsWith("UNKNOWN_")?parseInt(e.slice(8)):0}function Ohe(e){switch(e){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+e}function qhe(e){switch(e){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+e}function Khe(e){switch(e){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+e}function Fhe(e){switch(e.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}function Vhe(e){if("number"===typeof e)return e;if(!e)return-1;switch(e.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}const t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}const zhe=55296,jhe=56320;function Hhe(e){let t=0;const r=e.length;for(let n=0;n<r;n+=1){const i=e.charCodeAt(n);if(i<=127)t+=1;else if(i<=2047)t+=2;else if((63488&i)!==zhe)t+=3;else{const o=n+1;if(o===r||i>=jhe)t+=3;else{(64512&e.charCodeAt(o))!==jhe?t+=3:(n=o,t+=4)}}}return t}function Ghe(e,t,r){const n=e.length;void 0!==r&&null!==r||(r=0),void 0===t&&(t=new Uint8Array(Hhe(e)+r));let i=r;for(let o=0;o<n;o+=1){let r=e.charCodeAt(o);if(r<=127)t[i++]=r;else if(r<=2047)t[i++]=192|(1984&r)>>6,t[i++]=128|63&r;else if((63488&r)!==zhe)t[i++]=224|(61440&r)>>12,t[i++]=128|(4032&r)>>6,t[i++]=128|63&r;else{const s=o+1;if(s===n||r>=jhe)t[i++]=239,t[i++]=191,t[i++]=189;else{const n=e.charCodeAt(s);(64512&n)!==jhe?(t[i++]=239,t[i++]=191,t[i++]=189):(o=s,r=65536|(1023&r)<<10|1023&n,t[i++]=240|(1835008&r)>>18,t[i++]=128|(258048&r)>>12,t[i++]=128|(4032&r)>>6,t[i++]=128|63&r)}}}return Ghe.bytes=i-r,t}function Whe(e,t,r){let n="";void 0!==t&&null!==t||(t=0),void 0!==r&&null!==r||(r=e.length);for(let i=t;i<r;){const t=e[i++];let r;if(t<=128)r=t;else if(t>191&&t<224)r=(31&t)<<6|63&e[i++];else if(t>239&&t<365){r=((7&t)<<18|(63&e[i++])<<12|(63&e[i++])<<6|63&e[i++])-65536;const o=zhe|r>>10&1023;n+=String.fromCharCode(o),r=jhe|1023&r}else r=(15&t)<<12|(63&e[i++])<<6|63&e[i++];n+=String.fromCharCode(r)}return Whe.bytes=r-t,n}Ghe.bytes=0,Whe.bytes=0;const Yhe=e=>e instanceof Uint8Array;function Qhe(e){return"string"===typeof e?Hhe(e):e.byteLength}function Jhe(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):Ghe(e)}function Xhe(e,t,r){if("string"!==typeof t)throw new Error("unknown input type");return Ghe(t,e,r),Ghe.bytes}const Zhe=Math.pow(2,24),$he=Math.pow(2,16),ede=Math.pow(2,8),tde=(e,t)=>e[t]*Zhe+e[t+1]*$he+e[t+2]*ede+e[t+3],rde=(e,t)=>e[t]<<8|e[t+1],nde=(e,t,r)=>(t=+t,e[r+3]=t,t>>>=8,e[r+2]=t,t>>>=8,e[r+1]=t,t>>>=8,e[r]=t,r+4),ide=(e,t,r)=>(e[r]=t>>8,e[r+1]=255&t,r+2);function ode(e,t,r,n,i){return r<0&&(n-=r,r=0),n<0&&(n=0),i<0?new Uint8Array(0):r>=t.length||n>=i?0:function(e,t,r,n,i){i-n>t.length-r&&(i=n+t.length-r);let o=i-n;const s=e.length-n;o>s&&(o=s);(0!==n||i<e.length)&&(e=new Uint8Array(e.buffer,e.byteOffset+n,o));return t.set(e,r),o}(e,t,r,n,i)}const sde=32768;function ade(e){let{bytes:t=0,encode:r,decode:n,encodingLength:i}=e;return r.bytes=t,n.bytes=t,{encode:r,decode:n,encodingLength:i||(()=>t)}}const cde=ade({encode(e,t,r){t||(t=new Uint8Array(cde.encodingLength(e))),r||(r=0);const n=r,i=e.replace(/^\.|\.$/gm,"");if(i.length){const e=i.split(".");for(let n=0;n<e.length;n++){const i=Xhe(t,e[n],r+1);t[r]=i,r+=i+1}}return t[r++]=0,cde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=[];let n=t,i=0,o=0,s=!1;for(;;){if(t>=e.length)throw new Error("Cannot decode name (buffer overflow)");const a=e[t++];if(o+=s?0:1,0===a)break;if(0===(192&a)){if(t+a>e.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(Whe(e,t,t+a)),t+=a,o+=s?0:a}else{if(192!==(192&a))throw new Error("Cannot decode name (bad label)");{if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");const r=rde(e,t-1)-49152;if(r>=n)throw new Error("Cannot decode name (bad pointer)");t=r,n=r,o+=s?0:1,s=!0}}}return cde.decode.bytes=o,0===r.length?".":r.join(".")},encodingLength:e=>"."===e||".."===e?1:Qhe(e.replace(/^\.|\.$/gm,""))+2}),ude=ade({encode(e,t,r){t||(t=new Uint8Array(ude.encodingLength(e))),r||(r=0);const n=Xhe(t,e,r+1);return t[r]=n,ude.encode.bytes=n+1,t},decode(e,t){t||(t=0);const r=e[t],n=Whe(e,t+1,t+1+r);return ude.decode.bytes=r+1,n},encodingLength:e=>Qhe(e)+1}),lde=ade({bytes:12,encode(e,t,r){t||(t=new Uint8Array(lde.encodingLength(e))),r||(r=0);const n=32767&(e.flags||0),i="response"===e.type?32768:0;return ide(t,e.id||0,r),ide(t,n|i,r+2),ide(t,e.questions.length,r+4),ide(t,e.answers.length,r+6),ide(t,e.authorities.length,r+8),ide(t,e.additionals.length,r+10),t},decode(e,t){if(t||(t=0),e.length<12)throw new Error("Header must be 12 bytes");const r=rde(e,t+2);return{id:rde(e,t),type:32768&r?"response":"query",flags:32767&r,flag_qr:1===(r>>15&1),opcode:qhe(r>>11&15),flag_aa:1===(r>>10&1),flag_tc:1===(r>>9&1),flag_rd:1===(r>>8&1),flag_ra:1===(r>>7&1),flag_z:1===(r>>6&1),flag_ad:1===(r>>5&1),flag_cd:1===(r>>4&1),rcode:Ohe(15&r),questions:new Array(rde(e,t+4)),answers:new Array(rde(e,t+6)),authorities:new Array(rde(e,t+8)),additionals:new Array(rde(e,t+10))}},encodingLength:()=>12}),hde=ade({encode(e,t,r){t||(t=new Uint8Array(hde.encodingLength(e))),r||(r=0);const n=e.length;return ide(t,n,r),ode(e,t,r+2,0,n),hde.encode.bytes=n+2,t},decode(e,t){t||(t=0);const r=rde(e,t),n=e.slice(t+2,t+2+r);return hde.decode.bytes=r+2,n},encodingLength:e=>e.length+2}),dde=ade({encode:(e,t,r)=>(t||(t=new Uint8Array(dde.encodingLength(e))),r||(r=0),cde.encode(e,t,r+2),ide(t,cde.encode.bytes,r),dde.encode.bytes=cde.encode.bytes+2,t),decode(e,t){t||(t=0);const r=rde(e,t),n=cde.decode(e,t+2);return dde.decode.bytes=r+2,n},encodingLength:e=>cde.encodingLength(e)+2}),fde=ade({encode(e,t,r){t||(t=new Uint8Array(fde.encodingLength(e))),r||(r=0);const n=r;return r+=2,cde.encode(e.mname,t,r),r+=cde.encode.bytes,cde.encode(e.rname,t,r),r+=cde.encode.bytes,nde(t,e.serial||0,r),r+=4,nde(t,e.refresh||0,r),r+=4,nde(t,e.retry||0,r),r+=4,nde(t,e.expire||0,r),r+=4,nde(t,e.minimum||0,r),ide(t,(r+=4)-n-2,n),fde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.mname=cde.decode(e,t),t+=cde.decode.bytes,n.rname=cde.decode(e,t),t+=cde.decode.bytes,n.serial=tde(e,t),t+=4,n.refresh=tde(e,t),t+=4,n.retry=tde(e,t),t+=4,n.expire=tde(e,t),t+=4,n.minimum=tde(e,t),t+=4,fde.decode.bytes=t-r,n},encodingLength:e=>22+cde.encodingLength(e.mname)+cde.encodingLength(e.rname)}),pde=ade({encode(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)if("string"===typeof e[i]&&(e[i]=Jhe(e[i])),!Yhe(e[i]))throw new Error("Must be a Buffer");t||(t=new Uint8Array(pde.encodingLength(e))),r||(r=0);const n=r;return r+=2,e.forEach((function(e){t[r++]=e.length,ode(e,t,r,0,e.length),r+=e.length})),ide(t,r-n-2,n),pde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t;let n=rde(e,t);t+=2;const i=[];for(;n>0;){const r=e[t++];if(--n,n<r)throw new Error("Buffer overflow");i.push(e.slice(t,t+r)),t+=r,n-=r}return pde.decode.bytes=t-r,i},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach((function(e){t+="string"===typeof e?Qhe(e)+1:e.length+1})),t}}),gde=ade({encode(e,t,r){t||(t=new Uint8Array(gde.encodingLength(e))),r||(r=0),"string"===typeof e&&(e=Jhe(e)),e||(e=new Uint8Array(0));const n=r;r+=2;const i=e.length;return ode(e,t,r,0,i),ide(t,(r+=i)-n-2,n),gde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n=rde(e,t);t+=2;const i=e.slice(t,t+n);return t+=n,gde.decode.bytes=t-r,i},encodingLength:e=>e?(Yhe(e)?e.length:Qhe(e))+2:2}),bde=ade({encode(e,t,r){t||(t=new Uint8Array(bde.encodingLength(e))),r||(r=0);const n=r;return r+=2,ude.encode(e.cpu,t,r),r+=ude.encode.bytes,ude.encode(e.os,t,r),r+=ude.encode.bytes,ide(t,r-n-2,n),bde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.cpu=ude.decode(e,t),t+=ude.decode.bytes,n.os=ude.decode(e,t),t+=ude.decode.bytes,bde.decode.bytes=t-r,n},encodingLength:e=>ude.encodingLength(e.cpu)+ude.encodingLength(e.os)+2}),yde=ade({encode:(e,t,r)=>(t||(t=new Uint8Array(yde.encodingLength(e))),r||(r=0),cde.encode(e,t,r+2),ide(t,cde.encode.bytes,r),yde.encode.bytes=cde.encode.bytes+2,t),decode(e,t){t||(t=0);const r=cde.decode(e,t+2);return yde.decode.bytes=cde.decode.bytes+2,r},encodingLength:e=>cde.encodingLength(e)+2}),mde=ade({encode(e,t,r){t||(t=new Uint8Array(mde.encodingLength(e))),r||(r=0),ide(t,e.priority||0,r+2),ide(t,e.weight||0,r+4),ide(t,e.port||0,r+6),cde.encode(e.target,t,r+8);const n=cde.encode.bytes+6;return ide(t,n,r),mde.encode.bytes=n+2,t},decode(e,t){t||(t=0);const r=rde(e,t),n={};return n.priority=rde(e,t+2),n.weight=rde(e,t+4),n.port=rde(e,t+6),n.target=cde.decode(e,t+8),mde.decode.bytes=r+2,n},encodingLength:e=>8+cde.encodingLength(e.target)}),vde=ade({encode(e,t,r){const n=vde.encodingLength(e);return t||(t=new Uint8Array(vde.encodingLength(e))),r||(r=0),e.issuerCritical&&(e.flags=vde.ISSUER_CRITICAL),ide(t,n-2,r),t[r+=2]=e.flags||0,r+=1,ude.encode(e.tag,t,r),r+=ude.encode.bytes,Xhe(t,e.value,r),r+=Qhe(e.value),vde.encode.bytes=n,t},decode(e,t){t||(t=0);const r=rde(e,t),n=t+=2,i={};return i.flags=e[t],t+=1,i.tag=ude.decode(e,t),t+=ude.decode.bytes,i.value=Whe(e,t,n+r),i.issuerCritical=!!(i.flags&vde.ISSUER_CRITICAL),vde.decode.bytes=r+2,i},encodingLength:e=>ude.encodingLength(e.tag)+ude.encodingLength(e.value)+2});vde.ISSUER_CRITICAL=128;const wde=ade({encode(e,t,r){t||(t=new Uint8Array(wde.encodingLength(e))),r||(r=0);const n=r;return r+=2,ide(t,e.preference||0,r),r+=2,cde.encode(e.exchange,t,r),r+=cde.encode.bytes,ide(t,r-n-2,n),wde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.preference=rde(e,t),t+=2,n.exchange=cde.decode(e,t),t+=cde.decode.bytes,wde.decode.bytes=t-r,n},encodingLength:e=>4+cde.encodingLength(e.exchange)}),_de=ade({encode:(e,t,r)=>(t||(t=new Uint8Array(_de.encodingLength(e))),r||(r=0),ide(t,4,r),r+=2,Nhe.encode(e,t,r),t),decode(e,t){t||(t=0),t+=2;return Nhe.decode(e,t)},bytes:6}),Ede=ade({encode:(e,t,r)=>(t||(t=new Uint8Array(Ede.encodingLength(e))),r||(r=0),ide(t,16,r),r+=2,Bhe.encode(e,t,r),Ede.encode.bytes=18,t),decode(e,t){t||(t=0),t+=2;const r=Bhe.decode(e,t);return Ede.decode.bytes=18,r},bytes:18}),Sde=e=>new Uint8Array(e),Ade=ade({encode(e,t,r){t||(t=new Uint8Array(Ade.encodingLength(e))),r||(r=0);const n=r,i=Vhe(e.code);if(ide(t,i,r),r+=2,e.data)ide(t,e.data.length,r),r+=2,ode(e.data,t,r),r+=e.data.length;else switch(i){case 8:{const n=e.sourcePrefixLength||0,i=e.family||function(e){return Uhe(e)===Nhe.size?1:2}(e.ip),o=function(e,t,r){r=~~r;const n=Uhe(e);return"function"===typeof t&&(t=t(r+n)),n===Nhe.size?Nhe.encode(e,t,r):Bhe.encode(e,t,r)}(e.ip,Sde),s=Math.ceil(n/8);ide(t,s+4,r),ide(t,i,r+=2),r+=2,t[r++]=n,t[r++]=e.scopePrefixLength||0,ode(o,t,r,0,s),r+=s}break;case 11:e.timeout?(ide(t,2,r),r+=2,ide(t,e.timeout,r),r+=2):(ide(t,0,r),r+=2);break;case 12:{const n=e.length||0;ide(t,n,r),r+=2,t.fill(0,r,r+n),r+=n}break;case 14:{const n=2*e.tags.length;ide(t,n,r),r+=2;for(const i of e.tags)ide(t,i,r),r+=2}break;default:throw new Error("Unknown roption code: ".concat(e.code))}return Ade.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r={};r.code=rde(e,t),r.type=function(e){switch(e){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return e<0?null:"OPTION_".concat(e)}(r.code);const n=rde(e,t+=2);switch(t+=2,r.data=e.slice(t,t+n),r.code){case 8:r.family=rde(e,t),t+=2,r.sourcePrefixLength=e[t++],r.scopePrefixLength=e[t++];{const i=new Uint8Array(1===r.family?4:16);ode(e,i,0,t,t+n-4),r.ip=function(e,t,r){if(t=~~t,(r=r||e.length-t)===Nhe.size)return Nhe.decode(e,t,r);if(r===Bhe.size)return Bhe.decode(e,t,r);throw Error("Invalid buffer size needs to be ".concat(Nhe.size," for v4 or ").concat(Bhe.size," for v6."))}(i)}break;case 11:n>0&&(r.timeout=rde(e,t),t+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(rde(e,t)),t+=2}return Ade.decode.bytes=n+4,r},encodingLength(e){if(e.data)return e.data.length+4;switch(Vhe(e.code)){case 8:{const t=e.sourcePrefixLength||0;return Math.ceil(t/8)+8}case 11:return"number"===typeof e.timeout?6:4;case 12:return e.length+4;case 14:return 4+2*e.tags.length}throw new Error("Unknown roption code: ".concat(e.code))}}),kde=ade({encode(e,t,r){t||(t=new Uint8Array(kde.encodingLength(e))),r||(r=0);const n=r,i=jde(e,Ade);return ide(t,i,r),r=Hde(e,Ade,t,r+2),kde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n=[];let i=rde(e,t);t+=2;let o=0;for(;i>0;)n[o++]=Ade.decode(e,t),t+=Ade.decode.bytes,i-=Ade.decode.bytes;return kde.decode.bytes=t-r,n},encodingLength:e=>2+jde(e||[],Ade)}),xde=ade({encode(e,t,r){t||(t=new Uint8Array(xde.encodingLength(e))),r||(r=0);const n=r,i=e.key;if(!Yhe(i))throw new Error("Key must be a Buffer");return r+=2,ide(t,e.flags,r),t[r+=2]=xde.PROTOCOL_DNSSEC,t[r+=1]=e.algorithm,ode(i,t,r+=1,0,i.length),r+=i.length,xde.encode.bytes=r-n,ide(t,xde.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=rde(e,t);if(t+=2,n.flags=rde(e,t),e[t+=2]!==xde.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return t+=1,n.algorithm=e[t],t+=1,n.key=e.slice(t,r+i+2),t+=n.key.length,xde.decode.bytes=t-r,n},encodingLength:e=>6+Qhe(e.key)});xde.PROTOCOL_DNSSEC=3,xde.ZONE_KEY=128,xde.SECURE_ENTRYPOINT=32768;const Ide=ade({encode(e,t,r){t||(t=new Uint8Array(Ide.encodingLength(e))),r||(r=0);const n=r,i=e.signature;if(!Yhe(i))throw new Error("Signature must be a Buffer");return r+=2,ide(t,Mhe(e.typeCovered),r),t[r+=2]=e.algorithm,t[r+=1]=e.labels,r+=1,nde(t,e.originalTTL,r),r+=4,nde(t,e.expiration,r),r+=4,nde(t,e.inception,r),r+=4,ide(t,e.keyTag,r),r+=2,cde.encode(e.signersName,t,r),ode(i,t,r+=cde.encode.bytes,0,i.length),r+=i.length,Ide.encode.bytes=r-n,ide(t,Ide.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=rde(e,t);return t+=2,n.typeCovered=Lhe(rde(e,t)),t+=2,n.algorithm=e[t],t+=1,n.labels=e[t],t+=1,n.originalTTL=tde(e,t),t+=4,n.expiration=tde(e,t),t+=4,n.inception=tde(e,t),t+=4,n.keyTag=rde(e,t),t+=2,n.signersName=cde.decode(e,t),t+=cde.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,Ide.decode.bytes=t-r,n},encodingLength:e=>20+cde.encodingLength(e.signersName)+Qhe(e.signature)}),Cde=ade({encode(e,t,r){t||(t=new Uint8Array(Cde.encodingLength(e))),r||(r=0);const n=r;return r+=2,cde.encode(e.mbox||".",t,r),r+=cde.encode.bytes,cde.encode(e.txt||".",t,r),r+=cde.encode.bytes,Cde.encode.bytes=r-n,ide(t,Cde.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.mbox=cde.decode(e,t)||".",t+=cde.decode.bytes,n.txt=cde.decode(e,t)||".",t+=cde.decode.bytes,Cde.decode.bytes=t-r,n},encodingLength:e=>2+cde.encodingLength(e.mbox||".")+cde.encodingLength(e.txt||".")}),Tde=ade({encode(e,t,r){t||(t=new Uint8Array(Tde.encodingLength(e))),r||(r=0);const n=r,i=[];for(let o=0;o<e.length;o++){const t=Mhe(e[o]);void 0===i[t>>8]&&(i[t>>8]=[]),i[t>>8][t>>3&31]|=1<<7-(7&t)}for(let o=0;o<i.length;o++)if(void 0!==i[o]){const e=Jhe(i[o]);t[r]=o,t[r+=1]=e.length,ode(e,t,r+=1,0,e.length),r+=e.length}return Tde.encode.bytes=r-n,t},decode(e,t,r){t||(t=0);const n=t,i=[];for(;t-n<r;){const r=e[t],n=e[t+=1];t+=1;for(let o=0;o<n;o++){const n=e[t+o];for(let e=0;e<8;e++)if(n&1<<7-e){const t=Lhe(r<<8|o<<3|e);i.push(t)}}t+=n}return Tde.decode.bytes=t-n,i},encodingLength(e){const t=[];for(let n=0;n<e.length;n++){const r=Mhe(e[n]);t[r>>8]=Math.max(t[r>>8]||0,255&r)}let r=0;for(let n=0;n<t.length;n++)void 0!==t[n]&&(r+=2+Math.ceil((t[n]+1)/8));return r}}),Rde=ade({encode(e,t,r){t||(t=new Uint8Array(Rde.encodingLength(e))),r||(r=0);const n=r;return r+=2,cde.encode(e.nextDomain,t,r),r+=cde.encode.bytes,Tde.encode(e.rrtypes,t,r),r+=Tde.encode.bytes,Rde.encode.bytes=r-n,ide(t,Rde.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=rde(e,t);return t+=2,n.nextDomain=cde.decode(e,t),t+=cde.decode.bytes,n.rrtypes=Tde.decode(e,t,i-(t-r)),t+=Tde.decode.bytes,Rde.decode.bytes=t-r,n},encodingLength:e=>2+cde.encodingLength(e.nextDomain)+Tde.encodingLength(e.rrtypes)}),Pde=ade({encode(e,t,r){t||(t=new Uint8Array(Pde.encodingLength(e))),r||(r=0);const n=r,i=e.salt;if(!Yhe(i))throw new Error("salt must be a Buffer");const o=e.nextDomain;if(!Yhe(o))throw new Error("nextDomain must be a Buffer");return t[r+=2]=e.algorithm,t[r+=1]=e.flags,r+=1,ide(t,e.iterations,r),t[r+=2]=i.length,ode(i,t,r+=1,0,i.length),t[r+=i.length]=o.length,ode(o,t,r+=1,0,o.length),r+=o.length,Tde.encode(e.rrtypes,t,r),r+=Tde.encode.bytes,Pde.encode.bytes=r-n,ide(t,Pde.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=rde(e,t);t+=2,n.algorithm=e[t],t+=1,n.flags=e[t],t+=1,n.iterations=rde(e,t);const o=e[t+=2];t+=1,n.salt=e.slice(t,t+o);const s=e[t+=o];return t+=1,n.nextDomain=e.slice(t,t+s),t+=s,n.rrtypes=Tde.decode(e,t,i-(t-r)),t+=Tde.decode.bytes,Pde.decode.bytes=t-r,n},encodingLength:e=>8+e.salt.length+e.nextDomain.length+Tde.encodingLength(e.rrtypes)}),Dde=ade({encode(e,t,r){t||(t=new Uint8Array(Dde.encodingLength(e))),r||(r=0);const n=r,i=e.digest;if(!Yhe(i))throw new Error("Digest must be a Buffer");return r+=2,ide(t,e.keyTag,r),t[r+=2]=e.algorithm,t[r+=1]=e.digestType,ode(i,t,r+=1,0,i.length),r+=i.length,Dde.encode.bytes=r-n,ide(t,Dde.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=rde(e,t);return t+=2,n.keyTag=rde(e,t),t+=2,n.algorithm=e[t],t+=1,n.digestType=e[t],t+=1,n.digest=e.slice(t,r+i+2),t+=n.digest.length,Dde.decode.bytes=t-r,n},encodingLength:e=>6+Qhe(e.digest)});function Nde(e){switch(e.toUpperCase()){case"A":return _de;case"PTR":case"CNAME":case"DNAME":return yde;case"TXT":return pde;case"NULL":return gde;case"AAAA":return Ede;case"SRV":return mde;case"HINFO":return bde;case"CAA":return vde;case"NS":return dde;case"SOA":return fde;case"MX":return wde;case"OPT":return kde;case"DNSKEY":return xde;case"RRSIG":return Ide;case"RP":return Cde;case"NSEC":return Rde;case"NSEC3":return Pde;case"DS":return Dde}return hde}const Bde=ade({encode(e,t,r){t||(t=new Uint8Array(Bde.encodingLength(e))),r||(r=0);const n=r;if(cde.encode(e.name,t,r),r+=cde.encode.bytes,ide(t,Mhe(e.type),r),"OPT"===e.type.toUpperCase()){if("."!==e.name)throw new Error("OPT name must be root.");ide(t,e.udpPayloadSize||4096,r+2),t[r+4]=e.extendedRcode||0,t[r+5]=e.ednsVersion||0,ide(t,e.flags||0,r+6),r+=8,kde.encode(e.options||[],t,r),r+=kde.encode.bytes}else{let n=Fhe(void 0===e.class?"IN":e.class);e.flush&&(n|=sde),ide(t,n,r+2),nde(t,e.ttl||0,r+4),r+=8;const i=Nde(e.type);i.encode(e.data,t,r),r+=i.encode.bytes}return Bde.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r={},n=t;if(r.name=cde.decode(e,t),t+=cde.decode.bytes,r.type=Lhe(rde(e,t)),"OPT"===r.type)r.udpPayloadSize=rde(e,t+2),r.extendedRcode=e[t+4],r.ednsVersion=e[t+5],r.flags=rde(e,t+6),r.flag_do=1===(r.flags>>15&1),r.options=kde.decode(e,t+8),t+=8+kde.decode.bytes;else{const n=rde(e,t+2);r.ttl=tde(e,t+4),r.class=Khe(-32769&n),r.flush=!!(n&sde);const i=Nde(r.type);r.data=i.decode(e,t+8),t+=8+i.decode.bytes}return Bde.decode.bytes=t-n,r},encodingLength(e){const t=null!==e.data&&void 0!==e.data?e.data:e.options;return cde.encodingLength(e.name)+8+Nde(e.type).encodingLength(t)}}),Ude=ade({encode(e,t,r){t||(t=new Uint8Array(Ude.encodingLength(e))),r||(r=0);const n=r;return cde.encode(e.name,t,r),r+=cde.encode.bytes,ide(t,Mhe(e.type),r),r+=2,ide(t,Fhe(void 0===e.class?"IN":e.class),r),r+=2,Ude.encode.bytes=r-n,e},decode(e,t){t||(t=0);const r=t,n={};n.name=cde.decode(e,t),t+=cde.decode.bytes,n.type=Lhe(rde(e,t)),t+=2,n.class=Khe(rde(e,t)),t+=2;return!!(32768&n.class)&&(n.class&=-32769),Ude.decode.bytes=t-r,n},encodingLength:e=>cde.encodingLength(e.name)+4}),Lde=256,Mde={encode:function(e,t,r){const n=!t;n&&(t=new Uint8Array(zde(e))),r||(r=0);const i=r;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),lde.encode(e,t,r),r+=lde.encode.bytes,r=Hde(e.questions,Ude,t,r),r=Hde(e.answers,Bde,t,r),r=Hde(e.authorities,Bde,t,r),r=Hde(e.additionals,Bde,t,r),Mde.encode.bytes=r-i,n&&Fde.bytes!==t.length?t.slice(0,Fde.bytes):t},decode:function(e,t){t||(t=0);const r=t,n=lde.decode(e,t);return t+=lde.decode.bytes,t=Gde(n.questions,Ude,e,t),t=Gde(n.answers,Bde,e,t),t=Gde(n.authorities,Bde,e,t),t=Gde(n.additionals,Bde,e,t),Mde.decode.bytes=t-r,n},encodingLength:function(e){return lde.encodingLength(e)+jde(e.questions||[],Ude)+jde(e.answers||[],Bde)+jde(e.authorities||[],Bde)+jde(e.additionals||[],Bde)}};function Ode(e,t){if(e.questions)throw new Error("Only one .question object expected instead of a .questions array!");const r=Object.assign({type:t},e);return r.question&&(r.questions=[r.question],delete r.question),r}Mde.encode.bytes=0,Mde.decode.bytes=0;const qde={encode:function(e,t,r){return t=Mde.encode(Ode(e,"query"),t,r),qde.encode.bytes=Mde.encode.bytes,t},decode:function(e,t){const r=Mde.decode(e,t);return qde.decode.bytes=Mde.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(e){return Mde.encodingLength(Ode(e,"query"))}};qde.encode.bytes=0,qde.decode.bytes=0;const Kde={encode:function(e,t,r){return t=Mde.encode(Ode(e,"response"),t,r),Kde.encode.bytes=Mde.encode.bytes,t},decode:function(e,t){const r=Mde.decode(e,t);return Kde.decode.bytes=Mde.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(e){return Mde.encodingLength(Ode(e,"response"))}};Kde.encode.bytes=0,Kde.decode.bytes=0;const Fde=Mde.encode,Vde=Mde.decode,zde=Mde.encodingLength;function jde(e,t){let r=0;for(let n=0;n<e.length;n++)r+=t.encodingLength(e[n]);return r}function Hde(e,t,r,n){for(let i=0;i<e.length;i++)t.encode(e[i],r,n),n+=t.encode.bytes;return n}function Gde(e,t,r,n){for(let i=0;i<e.length;i++)e[i]=t.decode(r,n),n+=t.decode.bytes;return n}function Wde(e,t,r,n){if(64!==t.length)throw new Error("Charset needs to be 64 characters long! (".concat(t.length,")"));const i=new Uint8Array(256),o=new Uint8Array(64);for(let c=0;c<64;c+=1){const e=t.charCodeAt(c);if(e>255)throw new Error("Character #".concat(c," in charset [code=").concat(e,", char=").concat(t.charAt(c),"] is too high! (max=255)"));if(0!==i[e])throw new Error("Character [code=".concat(e,", char=").concat(t.charAt(c),"] is more than once in the charset!"));i[e]=c,o[c]=e}const s=r.charCodeAt(0),a={name:e,encodingLength(e){const t=e.length,r=.75*t|0;return e.charCodeAt(t-1)===s?e.charCodeAt(t-2)===s?r-2:r-1:r},encode(e,t,r){null!==t&&void 0!==t||(t=new Uint8Array(a.encodingLength(e))),null!==r&&void 0!==r||(r=0);let n=e.length;e.charCodeAt(n-1)===s&&(e.charCodeAt(n-2)===s?n-=2:n-=1);const o=n%4,c=n-o;let u=r,l=0;for(;l<c;){const r=i[e.charCodeAt(l)]<<18|i[e.charCodeAt(l+1)]<<12|i[e.charCodeAt(l+2)]<<6|i[e.charCodeAt(l+3)];t[u++]=r>>16,t[u++]=r>>8,t[u++]=r,l+=4}if(3===o){const r=i[e.charCodeAt(l)]<<10|i[e.charCodeAt(l+1)]<<4|i[e.charCodeAt(l+2)]>>2;t[u++]=r>>8,t[u++]=r}else 2===o&&(t[u++]=i[e.charCodeAt(l)]<<2|i[e.charCodeAt(l+1)]>>4);return a.encode.bytes=u-r,t},decode(e,t,r){null!==t&&void 0!==t||(t=0),null!==r&&void 0!==r||(r=e.length);const i=r-t,c=i%3,u=t+i-c,l=[];for(let n=t;n<u;n+=3){const t=e[n]<<16|e[n+1]<<8|e[n+2];l.push(o[t>>18&63],o[t>>12&63],o[t>>6&63],o[63&t])}if(2===c){const t=(e[r-2]<<8)+e[r-1];l.push(o[t>>10],o[t>>4&63],o[t<<2&63]),1===n&&l.push(s)}else if(1===c){const t=e[r-1];l.push(o[t>>2],o[t<<4&63]),1===n&&l.push(s,s)}return a.decode.bytes=i,String.fromCharCode.apply(String,l)}};return a}Wde("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",1);const Yde=Wde("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",2);let Qde="undefined"!==typeof global?global.AbortError:"undefined"!==typeof window?window.AbortError:null;Qde||(Qde=class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Request aborted.")}}),Qde.prototype.name="AbortError",Qde.prototype.code="ABORT_ERR";const Jde="undefined"!==typeof globalThis&&globalThis.URL||require("url").URL;class Xde extends Error{constructor(e,t,r){super("status="+t+" while requesting "+e+" ["+r+"]"),this.uri=e,this.status=t,this.method=r}toJSON(){return{code:this.code,uri:this.uri,status:this.status,method:this.method,endpoint:this.endpoint}}}Xde.prototype.name="HTTPStatusError",Xde.prototype.code="HTTP_STATUS";class Zde extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:rfe(this.cause)}}}Zde.prototype.name="ResponseError",Zde.prototype.code="RESPONSE_ERR";class $de extends Error{constructor(e){super("Timeout (t="+e+")."),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}$de.prototype.name="TimeoutError",$de.prototype.code="ETIMEOUT";const efe=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,tfe=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function rfe(e){if("string"===typeof e)return{message:e};try{const t=JSON.stringify(e);if("{}"!==t)return JSON.parse(t)}catch(r){}const t={message:String(e.message||e)};return void 0!==e.code&&(t.code=String(e.code)),t}const nfe=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,ife=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,ofe=/\[(((pk|name)=([^\]]+)))\]/gi;function sfe(e,t){t.lastIndex=0;const r={};for(;;){const n=t.exec(e);if(!n)break;n[2]?r[n[3].toLowerCase()]=n[4]:r[n[1].toLowerCase()]=!0}return r}class afe extends Error{constructor(e,t){super('Invalid Endpoint: unsupported protocol "'.concat(e,'" for endpoint: ').concat(t,", supported protocols: ").concat(cfe.join(", "))),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}afe.prototype.name="InvalidProtocolError",afe.prototype.code="EPROTOCOL";const cfe=["http:","https:","udp4:","udp6:"];class ufe{constructor(e,t){this.name=e.name||null,this.protocol=e.protocol;const r="string"===typeof e.port?e.port=parseInt(e.port,10):e.port;if(void 0===r||null===r)this.port=t?"https:"===this.protocol?443:80:e.pk?443:53;else{if("number"!==typeof r&&!isNaN(r))throw new Error('Invalid Endpoint: port "'.concat(e.port,'" needs to be a number: ').concat(JSON.stringify(e)));this.port=r}}toJSON(){return this.toString()}}class lfe extends ufe{constructor(e){super(e,!1),this.pk=e.pk||null}toString(){const e=this.port!==(this.pk?443:53)?":".concat(this.port):"",t=this.pk?" [pk=".concat(this.pk,"]"):"",r=this.name?" [name=".concat(this.name,"]"):"";return"udp://".concat(this.ipv4||"[".concat(this.ipv6,"]")).concat(e).concat(t).concat(r)}}class hfe extends lfe{constructor(e){if(super(Object.assign({protocol:"udp4:"},e)),!e.ipv4||"string"!==typeof e.ipv4)throw new Error('Invalid Endpoint: .ipv4 "'.concat(e.ipv4,'" needs to be set: ').concat(JSON.stringify(e)));this.ipv4=e.ipv4}}class dfe extends lfe{constructor(e){if(super(Object.assign({protocol:"udp6:"},e)),!e.ipv6||"string"!==typeof e.ipv6)throw new Error('Invalid Endpoint: .ipv6 "'.concat(e.ipv6,'" needs to be set: ').concat(JSON.stringify(e)));this.ipv6=e.ipv6}}function ffe(e){return tfe.test(e)&&!efe.test(e)?"[".concat(e,"]"):e}class pfe extends ufe{constructor(e){if(super(Object.assign({protocol:"https:"},e),!0),e.host||(e.ipv4&&(e.host=e.ipv4),e.ipv6&&(e.host="[".concat(e.ipv6,"]"))),!e.host||"string"!==typeof e.host)throw new Error('Invalid Endpoint: host "'.concat(e.path,'" needs to be set: ').concat(JSON.stringify(e)));if(this.host=e.host,this.path=e.path||"/dns-query",this.method=/^post$/i.test(e.method)?"POST":"GET",this.ipv4=e.ipv4,this.ipv6=e.ipv6,!this.ipv6){const e=tfe.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||efe.test(this.host)&&(this.ipv4=this.host);const t="".concat(this.protocol,"//").concat(ffe(this.host),":").concat(this.port).concat(this.path);try{this.url=new Jde(t)}catch(r){throw new Error(r.message+" [".concat(t,"]"))}}toString(){const e="https:"===this.protocol?"":"http://",t=this.port!==("https:"===this.protocol?443:80)?":".concat(this.port):"",r="GET"!==this.method?" [post]":"",n="/dns-query"===this.path?"":this.path,i=this.name?" [name=".concat(this.name,"]"):"",o=this.ipv4&&this.ipv4!==this.host?" [ipv4=".concat(this.ipv4,"]"):"",s=this.ipv6&&this.ipv6!==this.host?" [ipv6=".concat(this.ipv6,"]"):"";return"".concat(e).concat(ffe(this.host)).concat(t).concat(n).concat(r).concat(o).concat(s).concat(i)}}function gfe(e){let t;if("string"===typeof e)t=function(e){const t=nfe.exec(e),r=t[2]||"https:",n=t[3],i=t[5],o=t[6],s=t[7];if("https:"===r||"http:"===r){const e=sfe(s,ife);return{name:e.name,protocol:r,ipv4:e.ipv4,ipv6:e.ipv6,host:n,port:i,path:o,method:e.post?"POST":"GET"}}if("udp:"===r||"udp4:"===r||"udp6:"===r){const t=sfe(s,ofe),o=/^\[(.*)\]$/.exec(n);if(o&&"udp4:"===r)throw new Error("Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=".concat(e,")"));if(!o&&"udp6:"===r)throw new Error("Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=".concat(e,")"));return o?new dfe({protocol:"udp6:",ipv6:o[1],port:i,pk:t.pk,name:t.name}):new hfe({protocol:"udp4:",ipv4:n,port:i,pk:t.pk,name:t.name})}throw new afe(r,e)}(e);else{if("object"!==typeof e||null===e||Array.isArray(e))throw new Error("Can not convert ".concat(e," to an endpoint"));if(e instanceof ufe)return e;t=e}null!==t.protocol&&void 0!==t.protocol||(t.protocol="https:");const r=t.protocol;if("udp4:"===r)return new hfe(t);if("udp6:"===r)return new dfe(t);if("https:"===r||"http:"===r)return new pfe(t);throw new afe(r,JSON.stringify(t))}const bfe="application/dns-message";function yfe(){}function mfe(e,t,r,n,i){return new Promise(((o,s)=>{const a=new Jde(e);"GET"===t&&r&&(a.search="?dns="+Yde.decode(r));const c=a.toString(),u=new XMLHttpRequest;u.open(t,c,!0),u.setRequestHeader("Accept",bfe),"POST"===t&&u.setRequestHeader("Content-Type",bfe),u.responseType="arraybuffer",u.timeout=n,u.ontimeout=function(){l(new $de(n));try{u.abort()}catch(e){}},u.onreadystatechange=function(){if(u.readyState>1&&200!==u.status&&0!==u.status){l(new Xde(c,u.status,t));try{u.abort()}catch(e){}}},u.onerror=function(){l(200===u.status?new Error("Inexplicable XHR Error"):new Xde(c,u.status,t))},u.onload=function(){if(200!==u.status)l(new Xde(c,u.status,t));else{let e;if("string"===typeof u.response)e=Ghe(u.response);else if(u.response instanceof Uint8Array)e=u.response;else{if(!(Array.isArray(u.response)||u.response instanceof ArrayBuffer))throw new Error("Unprocessable response "+u.response);e=new Uint8Array(u.response)}l(null,e)}},"POST"===t?u.send(r):u.send(),i&&i.addEventListener("abort",h);let l=function(e,t){l=yfe,i&&i.removeEventListener("abort",h),o(e?{error:e,response:u}:{data:t,response:u})};function h(){l(new Qde);try{u.abort()}catch(e){}}}))}Error;function vfe(e){const t=null===e.time||void 0===e.time?Date.now():e.time,r=function(e){return e.filter((e=>e.cors||e.endpoint.cors))}(e.data.map((e=>(e.endpoint=gfe(Object.assign({name:e.name},e.endpoint)),e)))),n=r.map((e=>e.endpoint));return{data:{resolvers:r,resolverByName:r.reduce(((e,t)=>(e[t.name]=t,e)),{}),endpoints:n,endpointByName:n.reduce(((e,t)=>(e[t.name]=t,e)),{})},time:t}}const wfe=vfe({data:[{name:"adfree.usableprivacy.net",endpoint:{protocol:"https:",host:"adfree.usableprivacy.net"},description:"Public updns DoH service with advertising, tracker and malware filters.\nHosted in Europe by @usableprivacy, details see: https://docs.usableprivacy.com",country:"Germany",location:{lat:51.2993,long:9.491},filter:!0},{name:"adguard-dns-doh",endpoint:{protocol:"https:",host:"dns.adguard.com",ipv4:"94.140.15.15"},description:"Remove ads and protect your computer from malware (over DoH)",country:"France",location:{lat:48.8582,long:2.3387},filter:!0},{name:"adguard-dns-family-doh",endpoint:{protocol:"https:",host:"dns-family.adguard.com",ipv4:"94.140.15.16"},description:"Adguard DNS with safesearch and adult content blocking (over DoH)",country:"France",location:{lat:48.8582,long:2.3387},filter:!0},{name:"adguard-dns-unfiltered-doh",endpoint:{protocol:"https:",host:"dns-unfiltered.adguard.com",ipv4:"94.140.14.140"},description:"AdGuard public DNS servers without filters (over DoH)",country:"France",location:{lat:48.8582,long:2.3387}},{name:"ahadns-doh-chi",endpoint:{protocol:"https:",host:"doh.chi.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Chicago, USA. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=chi",country:"United States",location:{lat:41.8483,long:-87.6517},filter:!0,cors:!0},{name:"ahadns-doh-in",endpoint:{protocol:"https:",host:"doh.in.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Mumbai, India. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=in",country:"India",location:{lat:19.0748,long:72.8856},filter:!0,cors:!0},{name:"ahadns-doh-la",endpoint:{protocol:"https:",host:"doh.la.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Los Angeles, USA. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=la",country:"United States",location:{lat:34.0549,long:-118.2578},filter:!0,cors:!0},{name:"ahadns-doh-nl",endpoint:{protocol:"https:",host:"doh.nl.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Amsterdam, Netherlands. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=nl",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"ahadns-doh-ny",endpoint:{protocol:"https:",host:"doh.ny.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in New York. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=ny",country:"United States",location:{lat:40.7308,long:-73.9975},filter:!0,cors:!0},{name:"ahadns-doh-pl",endpoint:{protocol:"https:",host:"doh.pl.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Poland. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=pl",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"alidns-doh",endpoint:{protocol:"https:",host:"dns.alidns.com",ipv4:"223.5.5.5",cors:!0},description:"A public DNS resolver that supports DoH/DoT in mainland China, provided by Alibaba-Cloud.\nWarning: GFW filtering rules are applied by that resolver.\nHomepage: https://alidns.com/",country:"China",location:{lat:34.7725,long:113.7266},filter:!0,log:!0,cors:!0},{name:"ams-ads-doh-nl",endpoint:{protocol:"https:",host:"dnsnl-noads.alekberg.net"},description:"Resolver in Amsterdam. DoH protocol. Non-logging. Blocks ads, malware and trackers. DNSSEC enabled.",country:"Romania",location:{lat:45.9968,long:24.997},filter:!0},{name:"ams-doh-nl",endpoint:{protocol:"https:",host:"dnsnl.alekberg.net"},description:"Resolver in Amsterdam. DoH protocol. Non-logging, non-filtering, DNSSEC.",country:"Romania",location:{lat:45.9968,long:24.997}},{name:"att",endpoint:{protocol:"https:",host:"dohtrial.att.net"},description:"AT&T test DoH server.",log:!0},{name:"bcn-ads-doh",endpoint:{protocol:"https:",host:"dnses-noads.alekberg.net"},description:"Resolver in Spain. DoH protocol. Non-logging, remove ads and malware, DNSSEC.",country:"Spain",location:{lat:41.3891,long:2.1611},filter:!0},{name:"bcn-doh",endpoint:{protocol:"https:",host:"dnses.alekberg.net"},description:"Resolver in Spain. DoH protocol. Non-logging, non-filtering, DNSSEC.",country:"Spain",location:{lat:41.3891,long:2.1611}},{name:"brahma-world",endpoint:{protocol:"https:",host:"dns.brahma.world"},description:"DNS-over-HTTPS server. Non Logging, filters ads, trackers and malware. DNSSEC ready, QNAME Minimization, No EDNS Client-Subnet.\nHosted in Stockholm, Sweden. (https://dns.brahma.world)",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"cisco-doh",endpoint:{protocol:"https:",host:"doh.opendns.com",ipv4:"146.112.41.2"},description:"Remove your DNS blind spot (DoH protocol)\nWarning: modifies your queries to include a copy of your network\naddress when forwarding them to a selection of companies and organizations.",country:"United States",location:{lat:37.751,long:-97.822},filter:!0,log:!0},{name:"cloudflare",endpoint:{protocol:"https:",host:"dns.cloudflare.com",ipv4:"1.0.0.1",cors:!0},description:"Cloudflare DNS (anycast) - aka 1.1.1.1 / 1.0.0.1",country:"Australia",location:{lat:-33.494,long:143.2104},cors:!0},{name:"cloudflare-family",endpoint:{protocol:"https:",host:"family.cloudflare-dns.com",ipv4:"1.0.0.3",cors:!0},description:"Cloudflare DNS (anycast) with malware protection and parental control - aka 1.1.1.3 / 1.0.0.3",country:"Australia",location:{lat:-33.494,long:143.2104},filter:!0,cors:!0},{name:"cloudflare-ipv6",endpoint:{protocol:"https:",host:"1dot1dot1dot1.cloudflare-dns.com",cors:!0},description:"Cloudflare DNS over IPv6 (anycast)",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"cloudflare-security",endpoint:{protocol:"https:",host:"security.cloudflare-dns.com",ipv4:"1.0.0.2",cors:!0},description:"Cloudflare DNS (anycast) with malware blocking - aka 1.1.1.2 / 1.0.0.2",country:"Australia",location:{lat:-33.494,long:143.2104},filter:!0,cors:!0},{name:"controld-block-malware",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p1"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-block-malware-ad",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p2"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-block-malware-ad-social",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p3"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking and Social Networks domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-family-friendly",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/family"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking, Adult Content and Drugs domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-uncensored",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/uncensored"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS unblocks censored domains from various countries.",country:"Canada",location:{lat:43.6319,long:-79.3716}},{name:"controld-unfiltered",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p0"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis is a Unfiltered DNS, no DNS record blocking or manipulation here, if you want to block Malware, Ads & Tracking or Social Network domains, use the other ControlD DNS configs.",country:"Canada",location:{lat:43.6319,long:-79.3716}},{name:"dns.digitale-gesellschaft.ch",endpoint:{protocol:"https:",host:"dns.digitale-gesellschaft.ch"},description:"Public DoH resolver operated by the Digital Society (https://www.digitale-gesellschaft.ch).\nHosted in Zurich, Switzerland.\nNon-logging, non-filtering, supports DNSSEC.",country:"Switzerland",location:{lat:47.1449,long:8.1551}},{name:"dns.ryan-palmer",endpoint:{protocol:"https:",host:"dns1.ryan-palmer.com"},description:"Non-logging, non-filtering, DNSSEC DoH Server. Hosted in the UK.",country:"United Kingdom",location:{lat:51.5164,long:-.093}},{name:"dns.sb",endpoint:{protocol:"https:",host:"doh.sb",ipv4:"185.222.222.222",cors:!0},description:"DNSSEC-enabled DoH server by https://xtom.com/\nhttps://dns.sb/doh/",country:"Unknown",location:{lat:47,long:8},cors:!0},{name:"dns.therifleman.name",endpoint:{protocol:"https:",host:"dns.therifleman.name"},description:"DNS-over-HTTPS DNS forwarder from Mumbai, India. Blocks web and Android trackers and ads.\nIP addresses are not logged, but queries are logged for 24 hours for debugging.\nReport issues, send suggestions @ joker349 at protonmail.com.\nAlso supports DoT (for android) @ dns.therifleman.name and plain DNS @ 172.104.206.174",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"dnsforfamily-doh",endpoint:{protocol:"https:",host:"dns-doh.dnsforfamily.com"},description:"(DoH Protocol) (Now supports DNSSEC). Block adult websites, gambling websites, malwares and advertisements.\nIt also enforces safe search in: Google, YouTube, Bing, DuckDuckGo and Yandex.\nSocial websites like Facebook and Instagram are not blocked. No DNS queries are logged.\nAs of 26-May-2022 5.9 million websites are blocked and new websites are added to blacklist daily.\nCompletely free, no ads or any commercial motive. Operating for 4 years now.\nProvided by: https://dnsforfamily.com",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0},{name:"dnsforfamily-doh-no-safe-search",endpoint:{protocol:"https:",host:"dns-doh-no-safe-search.dnsforfamily.com"},description:"(DoH Protocol) (Now supports DNSSEC) Block adult websites, gambling websites, malwares and advertisements.\nUnlike other dnsforfamily servers, this one does not enforces safe search. So Google, YouTube, Bing, DuckDuckGo and Yandex are completely accessible without any restriction.\nSocial websites like Facebook and Instagram are not blocked. No DNS queries are logged.\nAs of 26-May-2022 5.9 million websites are blocked and new websites are added to blacklist daily.\nCompletely free, no ads or any commercial motive. Operating for 4 years now.\nWarning: This server is incompatible with anonymization.\nProvided by: https://dnsforfamily.com",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0},{name:"dnsforge.de",endpoint:{protocol:"https:",host:"dnsforge.de",cors:!0},description:"Public DoH resolver running with Pihole for Adblocking (https://dnsforge.de).\nNon-logging, AD-filtering, supports DNSSEC. Hosted in Germany.",country:"Germany",location:{lat:52.2998,long:9.447},filter:!0,cors:!0},{name:"dnshome-doh",endpoint:{protocol:"https:",host:"dns.dnshome.de"},description:"https://www.dnshome.de/ public resolver in Germany"},{name:"dnspod-doh",endpoint:{protocol:"https:",host:"doh.pub",cors:!0},description:"A public DNS resolver in mainland China provided by DNSPod (Tencent Cloud).\nhttps://www.dnspod.cn/Products/Public.DNS?lang=en",filter:!0,log:!0,cors:!0},{name:"dnswarden-asia-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/adblock"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"dnswarden-asia-adultfilter-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/adultfilter"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"dnswarden-asia-uncensor-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/uncensored"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547}},{name:"dnswarden-eu-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.eu.dnswarden.com"},description:"Hosted in Germany. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Germany",location:{lat:50.1103,long:8.7147},filter:!0},{name:"dnswarden-us-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.us.dnswarden.com"},description:"Hosted in USA (Dallas) . For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"United States",location:{lat:32.7889,long:-96.8021},filter:!0},{name:"doh-ch-blahdns",endpoint:{protocol:"https:",host:"doh-ch.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Switzerland. By https://blahdns.com/",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"doh-cleanbrowsing-adult",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/adult-filter/",cors:!0},description:"Blocks access to all adult, pornographic and explicit sites. It does\nnot block proxy or VPNs, nor mixed-content sites. Sites like Reddit\nare allowed. Google and Bing are set to the Safe Mode.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-cleanbrowsing-family",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/family-filter/",cors:!0},description:"Blocks access to all adult, pornographic and explicit sites. It also\nblocks proxy and VPN domains that are used to bypass the filters.\nMixed content sites (like Reddit) are also blocked. Google, Bing and\nYoutube are set to the Safe Mode.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-cleanbrowsing-security",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/security-filter/",cors:!0},description:"Block access to phishing, malware and malicious domains. It does not block adult content.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-crypto-sx",endpoint:{protocol:"https:",host:"doh.crypto.sx",cors:!0},description:"DNS-over-HTTPS server. Anycast, no logs, no censorship, DNSSEC.\nBackend hosted by Scaleway, globally cached via Cloudflare.\nMaintained by Frank Denis.",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"doh-crypto-sx-ipv6",endpoint:{protocol:"https:",host:"doh-ipv6.crypto.sx",cors:!0},description:"DNS-over-HTTPS server accessible over IPv6. Anycast, no logs, no censorship, DNSSEC.\nBackend hosted by Scaleway, globally cached via Cloudflare.\nMaintained by Frank Denis.",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"doh-de-blahdns",endpoint:{protocol:"https:",host:"doh-de.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Germany. By https://blahdns.com/",country:"Germany",location:{lat:51.2993,long:9.491},filter:!0,cors:!0},{name:"doh-fi-blahdns",endpoint:{protocol:"https:",host:"doh-fi.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Finland. By https://blahdns.com/",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0,cors:!0},{name:"doh-ibksturm",endpoint:{protocol:"https:",host:"ibksturm.synology.me"},description:"DoH & DoT Server, No Logging, No Filters, DNSSEC\nRunning privately by ibksturm in Thurgau, Switzerland"},{name:"doh-jp-blahdns",endpoint:{protocol:"https:",host:"doh-jp.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Japan. By https://blahdns.com/",country:"Japan",location:{lat:35.6882,long:139.7532},filter:!0,cors:!0},{name:"doh.ffmuc.net",endpoint:{protocol:"https:",host:"doh.ffmuc.net"},description:"An open (non-logging, non-filtering, non-censoring) DoH resolver operated by Freifunk Munich with nodes in DE.\nhttps://ffmuc.net/",country:"Germany",location:{lat:51.2993,long:9.491}},{name:"doh.tiarap.org",endpoint:{protocol:"https:",host:"doh.tiarap.org"},description:"Non-Logging DNS-over-HTTPS server, cached via Cloudflare.\nFilters out ads, trackers and malware, NO ECS, supports DNSSEC.",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"google",endpoint:{protocol:"https:",host:"dns.google",ipv4:"8.8.8.8",cors:!0},description:"Google DNS (anycast)",country:"United States",location:{lat:37.751,long:-97.822},log:!0,cors:!0},{name:"hdns",endpoint:{protocol:"https:",host:"query.hdns.io",cors:!0},description:"HDNS is a public DNS resolver that supports Handshake domains.\nhttps://www.hdns.io",country:"United States",location:{lat:37.7771,long:-122.406},cors:!0},{name:"he",endpoint:{protocol:"https:",host:"ordns.he.net"},description:"Hurricane Electric DoH server (anycast)\nUnknown logging policy.",country:"United States",location:{lat:37.751,long:-97.822},log:!0},{name:"id-gmail-doh",endpoint:{protocol:"https:",host:"doh.tiar.app"},description:"Non-Logging DNS-over-HTTPS server located in Singapore.\nFilters out ads, trackers and malware, supports DNSSEC, provided by id-gmail.",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"iij",endpoint:{protocol:"https:",host:"public.dns.iij.jp"},description:"DoH server operated by Internet Initiative Japan in Tokyo.\nhttps://www.iij.ad.jp/",country:"Japan",location:{lat:35.69,long:139.69},log:!0},{name:"iqdns-doh",endpoint:{protocol:"https:",host:"a.passcloud.xyz"},description:'Non-logging DoH service runned by V2EX.com user johnsonwil.\nReturns "no such domain" for anti-Chinese government websites. Supports DNSSEC.\nFor more information: https://www.v2ex.com/t/785666',filter:!0},{name:"jp.tiar.app-doh",endpoint:{protocol:"https:",host:"jp.tiar.app"},description:"Non-Logging, Non-Filtering DNS-over-HTTPS server in Japan.\nNo ECS, Support DNSSEC",country:"Japan",location:{lat:35.6882,long:139.7532}},{name:"jp.tiarap.org",endpoint:{protocol:"https:",host:"jp.tiarap.org"},description:"DNS-over-HTTPS Server. Non-Logging, Non-Filtering, No ECS, Support DNSSEC.\nCached via Cloudflare."},{name:"libredns",endpoint:{protocol:"https:",host:"doh.libredns.gr"},description:"DoH server in Germany. No logging, but no DNS padding and no DNSSEC support.\nhttps://libredns.gr/",country:"Germany",location:{lat:51.2993,long:9.491}},{name:"nextdns",endpoint:{protocol:"https:",host:"anycsast.dns.nextdns.io"},description:"NextDNS is a cloud-based private DNS service that gives you full control\nover what is allowed and what is blocked on the Internet.\nDNSSEC, Anycast, Non-logging, NoFilters\nhttps://www.nextdns.io/",country:"Netherlands",location:{lat:52.3891,long:4.6563}},{name:"nextdns-ultralow",endpoint:{protocol:"https:",host:"dns.nextdns.io",path:"/dnscrypt-proxy"},description:'NextDNS is a cloud-based private DNS service that gives you full control\nover what is allowed and what is blocked on the Internet.\nhttps://www.nextdns.io/\nTo select the server location, the "-ultralow" variant relies on bootstrap servers\ninstead of anycast.'},{name:"njalla-doh",endpoint:{protocol:"https:",host:"dns.njal.la",cors:!0},description:"Non-logging DoH server in Sweden operated by Njalla.\nhttps://dns.njal.la/",country:"Sweden",location:{lat:59.3247,long:18.056},cors:!0},{name:"odoh-cloudflare",endpoint:{protocol:"https:",host:"odoh.cloudflare-dns.com",cors:!0},description:"Cloudflare ODoH server.\nhttps://cloudflare.com",cors:!0},{name:"odoh-crypto-sx",endpoint:{protocol:"https:",host:"odoh.crypto.sx",cors:!0},description:"ODoH target server. Anycast, no logs.\nBackend hosted by Scaleway. Maintained by Frank Denis.",cors:!0},{name:"odoh-id-gmail",endpoint:{protocol:"https:",host:"doh.tiar.app",path:"/odoh"},description:"ODoH target server. Based in Singapore, no logs.\nFilter ads, trackers and malware.",filter:!0},{name:"odoh-jp.tiar.app",endpoint:{protocol:"https:",host:"jp.tiar.app",path:"/odoh"},description:"ODoH target server. no logs."},{name:"odoh-jp.tiarap.org",endpoint:{protocol:"https:",host:"jp.tiarap.org",path:"/odoh"},description:"ODoH target server via Cloudflare, no logs."},{name:"odoh-resolver4.dns.openinternet.io",endpoint:{protocol:"https:",host:"resolver4.dns.openinternet.io"},description:"ODoH target server. no logs, no filter, DNSSEC.\nRunning on dedicated hardware colocated at Sonic.net in Santa Rosa, CA in the United States.\nUses Sonic's recusrive DNS servers as upstream resolvers (but is not affiliated with Sonic\nin any way). Provided by https://openinternet.io"},{name:"odoh-tiarap.org",endpoint:{protocol:"https:",host:"doh.tiarap.org",path:"/odoh"},description:"ODoH target server via Cloudflare, no logs.\nFilter ads, trackers and malware.",filter:!0},{name:"publicarray-au2-doh",endpoint:{protocol:"https:",host:"doh-2.seby.io",cors:!0},description:"DNSSEC \u2022 OpenNIC \u2022 Non-logging \u2022 Uncensored - hosted on ovh.com.au\nMaintained by publicarray - https://dns.seby.io",country:"Australia",location:{lat:-33.8591,long:151.2002},cors:!0},{name:"puredns-doh",endpoint:{protocol:"https:",host:"puredns.org",ipv4:"146.190.6.13",cors:!0},description:"Public uncensored DNS resolver in Singapore - https://puredns.org\n** Only available in Indonesia and Singapore **",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"quad101",endpoint:{protocol:"https:",host:"dns.twnic.tw",cors:!0},description:"DNSSEC-aware public resolver by the Taiwan Network Information Center (TWNIC)\nhttps://101.101.101.101/index_en.html",cors:!0},{name:"quad9-doh-ip4-port443-filter-ecs-pri",endpoint:{protocol:"https:",host:"dns11.quad9.net",ipv4:"149.112.112.11"},description:"Quad9 (anycast) dnssec/no-log/filter/ecs 9.9.9.11 - 149.112.112.11",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"quad9-doh-ip4-port443-filter-pri",endpoint:{protocol:"https:",host:"dns.quad9.net",ipv4:"149.112.112.112"},description:"Quad9 (anycast) dnssec/no-log/filter 9.9.9.9 - 149.112.112.9 - 149.112.112.112",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"quad9-doh-ip4-port443-nofilter-ecs-pri",endpoint:{protocol:"https:",host:"dns12.quad9.net",ipv4:"9.9.9.12"},description:"Quad9 (anycast) no-dnssec/no-log/no-filter/ecs 9.9.9.12 - 149.112.112.12",country:"United States",location:{lat:37.751,long:-97.822}},{name:"quad9-doh-ip4-port443-nofilter-pri",endpoint:{protocol:"https:",host:"dns10.quad9.net",ipv4:"149.112.112.10"},description:"Quad9 (anycast) no-dnssec/no-log/no-filter 9.9.9.10 - 149.112.112.10",country:"United States",location:{lat:37.751,long:-97.822}},{name:"quad9-doh-ip6-port5053-filter-pri",endpoint:{protocol:"https:",host:"dns9.quad9.net"},description:"Quad9 (anycast) dnssec/no-log/filter 2620:fe::fe - 2620:fe::9 - 2620:fe::fe:9",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"safesurfer-doh",endpoint:{protocol:"https:",host:"doh.safesurfer.io"},description:"Family safety focused blocklist for over 2 million adult sites, as well as phishing and malware and more.\nFree to use, paid for customizing blocking for more categories+sites and viewing usage at my.safesurfer.io. Logs taken for viewing\nusage, data never sold - https://safesurfer.io",filter:!0,log:!0},{name:"sth-ads-doh-se",endpoint:{protocol:"https:",host:"dnsse-noads.alekberg.net"},description:"Resolver in Stockholm, Sweden. DoH server. Non-logging, remove ads and malware, DNSSEC.",country:"Bulgaria",location:{lat:42.696,long:23.332},filter:!0},{name:"sth-doh-se",endpoint:{protocol:"https:",host:"dnsse.alekberg.net"},description:"Resolver in Stockholm, Sweden. DoH server. Non-logging, non-filtering, DNSSEC.",country:"Bulgaria",location:{lat:42.696,long:23.332}},{name:"switch",endpoint:{protocol:"https:",host:"dns.switch.ch"},description:"Public DoH service provided by SWITCH in Switzerland\nhttps://www.switch.ch\nProvides protection against malware, but does not block ads.",filter:!0},{name:"uncensoreddns-dk-ipv4",endpoint:{protocol:"https:",host:"unicast.uncensoreddns.org"},description:"Also known as censurfridns.\nDoH, no logs, no filter, DNSSEC, unicast hosted in Denmark - https://blog.uncensoreddns.org",country:"Denmark",location:{lat:55.7123,long:12.0564}},{name:"uncensoreddns-ipv4",endpoint:{protocol:"https:",host:"anycast.uncensoreddns.org"},description:"Also known as censurfridns.\nDoH, no logs, no filter, DNSSEC, anycast - https://blog.uncensoreddns.org",country:"Denmark",location:{lat:55.7123,long:12.0564}},{name:"v.dnscrypt.uk-doh-ipv4",endpoint:{protocol:"https:",host:"v.dnscrypt.uk"},description:"DoH, no logs, uncensored, DNSSEC. Hosted in London UK on Digital Ocean\nhttps://www.dnscrypt.uk",country:"United Kingdom",location:{lat:51.4964,long:-.1224}}],time:1654187067783});function _fe(e,t,r,n){return n&&n.aborted?Promise.reject(new Qde):"udp4:"===e.protocol||"udp6:"===e.protocol?function(){throw new Error('Only "doh" endpoints are supported in the browser')}():function(e,t,r,n){return function(e,t,r,n,i){return mfe(e,t,r,n,i)}(e.url,e.method,Fde(Object.assign({flags:Lde},t)),r,n).then((function(e){const t=e.data,r=e.response;let n=e.error;if(void 0===n)if(0===t.length)n=new Zde("Empty.");else try{const e=Vde(t);return e.response=r,e}catch(i){n=new Zde("Invalid packet (cause="+i.message+")",i)}throw Object.assign(n,{response:r})}))}(e,t,r,n)}const Efe=new Jde("https://martinheidegger.github.io/dns-query/resolvers.json");function Sfe(e){return/^@/.test(e)}const Afe=new class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:Efe,persist:!1,localStoragePrefix:"dnsquery_",maxAge:3e5},e),this._dataP=null}_data(e,t){return e||null===this._dataP?(this._dataP=this.opts.update?async function(e,t,r,n){const i=t?t.localStoragePrefix+t.name:null;if(i)try{const e=JSON.parse(localStorage.getItem(i));if(e&&e.time>t.maxTime)return e}catch(a){}const{data:o}=await mfe(e,"GET",null,r,n),s={time:Date.now(),data:JSON.parse(Whe(o))};if(i)try{localStorage.setItem(i,JSON.stringify(s))}catch(a){s.time=null}return s}(this.opts.updateURL,this.opts.persist?{name:"resolvers.json",localStoragePrefix:this.opts.localStoragePrefix,maxTime:Date.now()-this.opts.maxAge}:null,this.opts.timeout).then((e=>vfe({data:e.data.resolvers,time:e.time}))).catch((()=>t||wfe)):Promise.resolve(wfe),this._dataP):this._dataP.then((e=>e.time<Date.now()-this.opts.maxAge?this._data(!0,e):e))}data(){return this._data(!1).then((e=>e.data))}endpoints(e){if(null===e||void 0===e)return this.data().then((e=>e.endpoints));if("doh"===e&&(e=Ife),"dns"===e&&(e=Cfe),"function"===typeof e)return this.data().then((t=>t.endpoints.filter(e)));if("string"===typeof e||"function"!==typeof e[Symbol.iterator])return Promise.reject(new Error("Endpoints (".concat(e,") needs to be iterable (array).")));if(-1===(e=Array.from(e).filter(Boolean)).findIndex(Sfe))try{return Promise.resolve(e.map(gfe))}catch(t){return Promise.reject(t)}return this.data().then((t=>e.map((e=>{if(Sfe(e)){const r=t.endpointByName[e.substring(1)];if(!r)throw new Error("Endpoint ".concat(e," is not known."));return r}return gfe(e)}))))}};function kfe(e,t){return t=Object.assign({retries:5,timeout:3e4},t),e.question?(r=t.endpoints,function(e){return null!==e&&"object"===typeof e&&"function"===typeof e.then}(r)?r:Promise.resolve(r)).then((r=>{if(!Array.isArray(r)||0===r.length)throw new Error("No endpoints defined to lookup dns records.");return xfe(r.map(gfe),function(e){const t=Object.assign({type:"query"},e);return delete t.question,t.questions=[],e.question&&t.questions.push(e.question),t}(e),t)})).then((e=>(e.question=e.questions[0],delete e.questions,e))):Promise.reject(new Error("To request data you need to specify a .question!"));var r}function xfe(e,t,r){const n=1===e.length?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return _fe(n,t,r.timeout,r.signal).then((e=>(e.endpoint=n.toString(),e)),(i=>{if("AbortError"===i.name||0===r.retries)throw i.endpoint=n.toString(),i;return r.retries>0&&(r.retries-=1),xfe(e,t,r)}))}function Ife(e){return"https:"===e.protocol||"http:"===e.protocol}function Cfe(e){return"udp4:"===e.protocol||"udp6:"===e.protocol}const Tfe=new Kl("dns-over-https");class Rfe{static async create(e,t){const r=null!==e&&void 0!==e?e:await Afe.endpoints("doh");return new Rfe(r,t)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;co(this,"endpoints",void 0),co(this,"retries",void 0),this.endpoints=e,this.retries=t}async resolveTXT(e){let t;try{t=(await kfe({question:{type:"TXT",name:e}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(i){throw Tfe.error("query failed: ",i),new Error("DNS query failed")}if(!t)throw new Error("Could not resolve ".concat(e));const r=t.map((e=>e.data)),n=[];return r.forEach((e=>{"string"===typeof e?n.push(e):Array.isArray(e)?e.forEach((e=>{"string"===typeof e?n.push(e):n.push(Al(e))})):n.push(Al(e))})),n}}var Pfe=__webpack_require__(5411);new Uint8Array(0);function Dfe(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Nfe=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var o=(e.length-t)*u+1>>>0,s=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*s[d]>>>0,s[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=o-i;f!==o&&0===s[f];)f++;for(var p=new Uint8Array(n+(o-f)),g=n;f!==o;)p[g++]=s[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*l+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],d=0,f=s-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Bfe=Nfe;class Ufe{constructor(e,t,r){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class Lfe{constructor(e,t,r){if(co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseDecode",void 0),co(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Ofe(this,e)}}class Mfe{constructor(e){co(this,"decoders",void 0),this.decoders=e}or(e){return Ofe(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function Ofe(e,t){var r,n;return new Mfe({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class qfe{constructor(e,t,r,n){co(this,"name",void 0),co(this,"prefix",void 0),co(this,"baseEncode",void 0),co(this,"baseDecode",void 0),co(this,"encoder",void 0),co(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Ufe(e,t,r),this.decoder=new Lfe(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Kfe(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new qfe(t,r,n,i)}function Ffe(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Bfe(n,t);return Kfe({prefix:r,name:t,encode:i,decode:e=>Dfe(o(e))})}function Vfe(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Kfe({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let o="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(0!==s&&(o+=t[i&a<<r-s]),n)for(;0!==(o.length*r&7);)o+="=";return o}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,u=0;for(let l=0;l<o;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)})}const zfe=Ffe({prefix:"9",name:"base10",alphabet:"0123456789"}),jfe=Vfe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hfe=Vfe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Gfe=Vfe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Wfe=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Yfe=Wfe.reduce(((e,t,r)=>(e[r]=t,e)),[]),Qfe=Wfe.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Jfe=Kfe({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Yfe[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Qfe[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Xfe=Vfe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zfe=Vfe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$fe=Vfe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),epe=Vfe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tpe=Vfe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rpe=Vfe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),npe=Vfe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ipe=Vfe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ope=Vfe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),spe=Ffe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ape=Ffe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),cpe=Ffe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),upe=Ffe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),lpe=Vfe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hpe=Vfe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dpe=Vfe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fpe=Vfe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),ppe=Vfe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),gpe=Kfe({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),bpe=new TextEncoder,ype=new TextDecoder,mpe="json",vpe=512;function wpe(e){return bpe.encode(JSON.stringify(e))}function _pe(e){return JSON.parse(ype.decode(e))}const Epe="raw",Spe=85;function Ape(e){return Dfe(e)}function kpe(e){return Dfe(e)}var xpe=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Tpe;)r[n++]=255&t|Ipe,t/=128;for(;t&Cpe;)r[n++]=255&t|Ipe,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Ipe=128,Cpe=-128,Tpe=Math.pow(2,31);var Rpe=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(n&Dpe)<<o:(n&Dpe)*Math.pow(2,o),o+=7}while(n>=Ppe);return e.bytes=s-r,i},Ppe=128,Dpe=127;var Npe=Math.pow(2,7),Bpe=Math.pow(2,14),Upe=Math.pow(2,21),Lpe=Math.pow(2,28),Mpe=Math.pow(2,35),Ope=Math.pow(2,42),qpe=Math.pow(2,49),Kpe=Math.pow(2,56),Fpe=Math.pow(2,63);const Vpe={encode:xpe,decode:Rpe,encodingLength:function(e){return e<Npe?1:e<Bpe?2:e<Upe?3:e<Lpe?4:e<Mpe?5:e<Ope?6:e<qpe?7:e<Kpe?8:e<Fpe?9:10}};function zpe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Vpe.encode(e,t,r),t}function jpe(e){return Vpe.encodingLength(e)}function Hpe(e,t){const r=t.byteLength,n=jpe(e),i=n+jpe(r),o=new Uint8Array(i+r);return zpe(e,o,0),zpe(r,o,n),o.set(t,i),new Gpe(e,r,t,o)}class Gpe{constructor(e,t,r,n){co(this,"code",void 0),co(this,"size",void 0),co(this,"digest",void 0),co(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Wpe=Dfe;const Ype={code:0,name:"identity",encode:Wpe,digest:function(e){return Hpe(0,Wpe(e))}};function Qpe(e){let{name:t,code:r,encode:n}=e;return new Jpe(t,r,n)}class Jpe{constructor(e,t,r){co(this,"name",void 0),co(this,"code",void 0),co(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Hpe(this.code,t):t.then((e=>Hpe(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Xpe(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Zpe=Qpe({name:"sha2-256",code:18,encode:Xpe("SHA-256")}),$pe=Qpe({name:"sha2-512",code:19,encode:Xpe("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const ege={...$i,...Gi,...Zi,...ji,...Hi,...Yi,...Qi,...Ji,...Xi,...Wi};function tge(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const rge=tge("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),nge=tge("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),ige={utf8:rge,"utf-8":rge,hex:ege.base16,latin1:nge,ascii:nge,binary:nge,...ege};class oge{static parseAndVerifyRoot(e,t){if(!e.startsWith(this.ROOT_PREFIX))throw new Error("ENRTree root entry must start with '".concat(this.ROOT_PREFIX,"'"));const r=oge.parseRootValues(e),n=Pfe.decode.asBytes(t),i=e.split(" sig")[0],o=kl(i),s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=ige[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(r.signature,"base64url").slice(0,64);if(!_ae(s,wae(o),new Uint8Array(n)))throw new Error("Unable to verify ENRTree root signature");return r.eRoot}static parseRootValues(e){const t=e.match(/^enrtree-root:v1 e=([^ ]+) l=([^ ]+) seq=(\d+) sig=([^ ]+)$/);if(!Array.isArray(t))throw new Error("Could not parse ENRTree root entry");t.shift();const[r,n,i,o]=t;if(!r)throw new Error("Could not parse 'e' value from ENRTree root entry");if(!n)throw new Error("Could not parse 'l' value from ENRTree root entry");if(!i)throw new Error("Could not parse 'seq' value from ENRTree root entry");if(!o)throw new Error("Could not parse 'sig' value from ENRTree root entry");return{eRoot:r,lRoot:n,seq:Number(i),signature:o}}static parseTree(e){if(!e.startsWith(this.TREE_PREFIX))throw new Error("ENRTree tree entry must start with '".concat(this.TREE_PREFIX,"'"));const t=e.match(/^enrtree:\/\/([^@]+)@(.+)$/);if(!Array.isArray(t))throw new Error("Could not parse ENRTree tree entry");t.shift();const[r,n]=t;if(!r)throw new Error("Could not parse public key from ENRTree tree entry");if(!n)throw new Error("Could not parse domain from ENRTree tree entry");return{publicKey:r,domain:n}}static parseBranch(e){if(!e.startsWith(this.BRANCH_PREFIX))throw new Error("ENRTree branch entry must start with '".concat(this.BRANCH_PREFIX,"'"));return e.split(this.BRANCH_PREFIX)[1].split(",")}}co(oge,"RECORD_PREFIX",the.RECORD_PREFIX),co(oge,"TREE_PREFIX","enrtree:"),co(oge,"BRANCH_PREFIX","enrtree-branch:"),co(oge,"ROOT_PREFIX","enrtree-root:");const sge=new Kl("discovery:fetch_nodes");function age(e,t){return t.relay>=e.relay&&t.store>=e.store&&t.filter>=e.filter&&t.lightPush>=e.lightPush}function cge(e,t){if(!e.nodeId)return!1;for(const r of t)if(e.nodeId===r.nodeId)return!1;return!0}function uge(e,t){e.relay&&(t.relay+=1),e.store&&(t.store+=1),e.filter&&(t.filter+=1),e.lightPush&&(t.lightPush+=1)}function lge(e,t,r){if(age(t,r))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";const n=function(e,t){return{relay:t.relay<e.relay,store:t.store<e.store,filter:t.filter<e.filter,lightPush:t.lightPush<e.lightPush}}(t,r);return n.relay&&e.relay||n.store&&e.store||n.filter&&e.filter||n.lightPush&&e.lightPush}const hge=new Kl("discovery:dns");class dge{static async dnsOverHttp(e){return e||(e=await Rfe.create()),new dge(e)}async getPeers(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=oge.parseTree(e[r]),o={domain:i,publicKey:n,visits:{}},s=await async function(e,t,r){var n,i,o,s;const a={relay:null!==(n=e.relay)&&void 0!==n?n:0,store:null!==(i=e.store)&&void 0!==i?i:0,filter:null!==(o=e.filter)&&void 0!==o?o:0,lightPush:null!==(s=e.lightPush)&&void 0!==s?s:0},c=a.relay+a.store+a.filter+a.lightPush,u={relay:0,store:0,filter:0,lightPush:0};let l=0;const h=[];for(;!age(a,u)&&l<c+t;){const e=await r();e&&cge(e,h)&&(e.waku2&&lge(e.waku2,a,u)&&(uge(e.waku2,u),h.push(e)),sge.info("got new peer candidate from DNS address=".concat(e.nodeId,"@").concat(e.ip))),l++}return h}(t,this._errorTolerance,(()=>this._search(i,o)));return hge.info("retrieved peers: ",s.map((e=>{var t,r;return{id:null===(t=e.peerId)||void 0===t?void 0:t.toString(),multiaddrs:null===(r=e.multiaddrs)||void 0===r?void 0:r.map((e=>e.toString()))}}))),s}constructor(e){co(this,"dns",void 0),co(this,"_DNSTreeCache",void 0),co(this,"_errorTolerance",10),this._DNSTreeCache={},this.dns=e}async*getNextPeer(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=oge.parseTree(e[r]),o={domain:i,publicKey:n,visits:{}};for await(const s of async function*(e,t,r){var n,i,o,s;const a={relay:null!==(n=e.relay)&&void 0!==n?n:0,store:null!==(i=e.store)&&void 0!==i?i:0,filter:null!==(o=e.filter)&&void 0!==o?o:0,lightPush:null!==(s=e.lightPush)&&void 0!==s?s:0},c=a.relay+a.store+a.filter+a.lightPush,u={relay:0,store:0,filter:0,lightPush:0};let l=0;const h=new Set;for(;!age(a,u)&&l<c+t;){const e=await r();e&&e.nodeId&&!h.has(e.nodeId)&&(h.add(e.nodeId),e.waku2&&lge(e.waku2,a,u)&&(uge(e.waku2,u),yield e),sge.info("got new peer candidate from DNS address=".concat(e.nodeId,"@").concat(e.ip))),l++}}(t,this._errorTolerance,(()=>this._search(i,o))))yield s}async _search(e,t){try{const n=await this._getTXTRecord(e,t);let i,o;t.visits[e]=!0;const s=function(e){return e.startsWith(oge.ROOT_PREFIX)?oge.ROOT_PREFIX:e.startsWith(oge.BRANCH_PREFIX)?oge.BRANCH_PREFIX:e.startsWith(oge.RECORD_PREFIX)?oge.RECORD_PREFIX:""}(n);try{switch(s){case oge.ROOT_PREFIX:return i=oge.parseAndVerifyRoot(n,t.publicKey),await this._search(i,t);case oge.BRANCH_PREFIX:return o=oge.parseBranch(n),i=function(e,t){const r={};for(const[i,o]of e.entries())t.visits[o]&&(r[i]=!0);if(Object.keys(r).length===e.length)throw new Error("Unresolvable circular path detected");let n;do{n=Math.floor(Math.random()*e.length)}while(r[n]);return e[n]}(o,t),await this._search(i,t);case oge.RECORD_PREFIX:return Rhe.fromString(n);default:return null}}catch(r){return hge.error("Failed to search DNS tree ".concat(s," at subdomain ").concat(e,": ").concat(r)),null}}catch(r){return hge.error("Failed to retrieve TXT record at subdomain ".concat(e,": ").concat(r)),null}}async _getTXTRecord(e,t){if(this._DNSTreeCache[e])return this._DNSTreeCache[e];const r=e!==t.domain?"".concat(e,".").concat(t.domain):t.domain,n=await this.dns.resolveTXT(r);if(!n.length)throw new Error("Received empty result array while fetching TXT record");if(!n[0].length)throw new Error("Received empty TXT record");const i=n.join("");return this._DNSTreeCache[e]=i,i}}const fge=new Kl("peer-discovery-dns");class pge extends gd{constructor(e,t){super(),co(this,"nextPeer",void 0),co(this,"_started",void 0),co(this,"_components",void 0),co(this,"_options",void 0),this._started=!1,this._components=e,this._options=t;const{enrUrls:r}=t;fge.info("Use following EIP-1459 ENR Tree URLs: ",r)}async start(){if(fge.info("Starting peer discovery via dns"),this._started=!0,void 0===this.nextPeer){let{enrUrls:e}=this._options;Array.isArray(e)||(e=[e]);const{wantedNodeCapabilityCount:t}=this._options,r=await dge.dnsOverHttp();this.nextPeer=r.getNextPeer.bind(r,e,t)}for await(const r of this.nextPeer()){var e,t;if(!this._started)return;const{peerInfo:n,shardInfo:i}=r;if(!n)continue;const o={[hse]:{value:null!==(e=this._options.tagValue)&&void 0!==e?e:50,ttl:null!==(t=this._options.tagTTL)&&void 0!==t?t:1e8}};let s=!1;if(await this._components.peerStore.has(n.id)){(await this._components.peerStore.get(n.id)).tags.has(hse)||(s=!0,await this._components.peerStore.merge(n.id,{tags:o}))}else s=!0,await this._components.peerStore.save(n.id,{tags:o,...i&&{metadata:{shardInfo:Ml(i)}}});s&&this.dispatchEvent(new yd("peer",{detail:n}))}}stop(){this._started=!1}get[x_](){return!0}get[Symbol.toStringTag](){return"@waku/bootstrap"}}function gge(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dse;return r=>new pge(r,{enrUrls:e,wantedNodeCapabilityCount:t})}class bge{constructor(e){co(this,"proto",void 0),this.proto=e}static createRequest(e){const{numPeers:t}=e;return new bge({query:{numPeers:t},response:void 0})}encode(){return ic.encode(this.proto)}static decode(e){const t=ic.decode(e);return new bge(t)}get query(){return this.proto.query}get response(){return this.proto.response}}const yge="/vac/waku/peer-exchange/2.0.0-alpha1",mge=new Kl("peer-exchange");class vge extends kh{constructor(e,t){super(yge,e,mge,t)}async query(e){const{numPeers:t}=e,r=bge.createRequest({numPeers:BigInt(t)}),n=await this.peerStore.get(e.peerId);if(!n)return{peerInfos:null,error:Kc.NO_PEER_AVAILABLE};const i=await this.getStream(n),o=await mh([r.encode()],sh,i,lh,(async e=>await Ql(e)));try{const e=new nh;o.forEach((t=>{e.append(t)}));const{response:t}=bge.decode(e);if(!t)return mge.error("PeerExchangeRPC message did not contains a `response` field"),{peerInfos:null,error:Kc.EMPTY_PAYLOAD};return{peerInfos:await Promise.all(t.peerInfos.map((e=>e.enr)).filter(lc).map((async e=>({ENR:await Rhe.fromRLP(e)})))),error:null}}catch(s){return mge.error("Failed to decode push reply",s),{peerInfos:null,error:Kc.DECODE_FAILED}}}}const wge=new Kl("peer-exchange-discovery"),_ge=1e4,Ege=3,Sge=Vc.PEER_EXCHANGE;class Age extends gd{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),co(this,"components",void 0),co(this,"peerExchange",void 0),co(this,"options",void 0),co(this,"isStarted",void 0),co(this,"queryingPeers",new Set),co(this,"queryAttempts",new Map),co(this,"handleDiscoveredPeer",(e=>{const{protocols:t,peerId:r}=e.detail;t.includes(yge)&&!this.queryingPeers.has(r.toString())&&(this.queryingPeers.add(r.toString()),this.startRecurringQueries(r).catch((e=>wge.error("Error querying peer ".concat(e)))))})),co(this,"startRecurringQueries",(async e=>{var t,r;const n=e.toString(),{queryInterval:i=_ge,maxRetries:o=Ege}=this.options;wge.info("Querying peer: ".concat(n," (attempt ").concat(null!==(t=this.queryAttempts.get(n))&&void 0!==t?t:1,")")),await this.query(e);const s=null!==(r=this.queryAttempts.get(n))&&void 0!==r?r:1;s>o?this.abortQueriesForPeer(n):setTimeout((()=>{this.queryAttempts.set(n,s+1),this.startRecurringQueries(e).catch((e=>{wge.error("Error in startRecurringQueries: ".concat(e))}))}),i*s)})),this.components=e,this.peerExchange=new vge(e,t),this.options=r,this.isStarted=!1}start(){this.isStarted||(wge.info("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(wge.info("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[x_](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}async query(e){const{error:t,peerInfos:r}=await this.peerExchange.query({numPeers:10,peerId:e});if(t)return wge.error("Peer exchange query failed",t),{error:t,peerInfos:null};for(const o of r){var n,i;const{ENR:e}=o;if(!e){wge.warn("No ENR in peerInfo object, skipping");continue}const{peerId:t,peerInfo:r,shardInfo:s}=e;if(!t||!r)continue;await this.components.peerStore.has(t)||(await this.components.peerStore.save(t,{tags:{[Sge]:{value:null!==(n=this.options.tagValue)&&void 0!==n?n:50,ttl:null!==(i=this.options.tagTTL)&&void 0!==i?i:1e8}},...s&&{metadata:{shardInfo:Ml(s)}}}),wge.info("Discovered peer: ".concat(t.toString())),this.dispatchEvent(new yd("peer",{detail:{id:t,multiaddrs:r.multiaddrs}})))}return{error:null,peerInfos:r}}abortQueriesForPeer(e){wge.info("Aborting queries for peer: ".concat(e)),this.queryingPeers.delete(e),this.queryAttempts.delete(e)}}function kge(e){return t=>new Age(t,e)}const xge=new Kl("peer-exchange-discovery"),Ige=Vc.LOCAL;class Cge extends gd{constructor(e,t){super(),co(this,"components",void 0),co(this,"options",void 0),co(this,"isStarted",void 0),co(this,"peers",[]),co(this,"handleNewPeers",(e=>{const{peerId:t,listenAddrs:r}=e.detail,n=function(e){const t=e.find((e=>e.toString().includes("ws")||e.toString().includes("wss")));if(!t)throw new Error("No ws multiaddr found in the given addresses");return t}(r),i=this.getPeersFromLocalStorage(),o=i.findIndex((e=>e.id===t.toString()));o>=0?i[o].address=n.toString():i.push({id:t.toString(),address:n.toString()}),this.peers=i,this.savePeersToLocalStorage()})),this.components=e,this.options=t,this.isStarted=!1,this.peers=this.getPeersFromLocalStorage()}get[Symbol.toStringTag](){return"@waku/local-peer-cache-discovery"}async start(){if(!this.isStarted){xge.info("Starting Local Storage Discovery"),this.components.events.addEventListener("peer:identify",this.handleNewPeers);for(const{id:s,address:a}of this.peers){var e,t,r,n,i,o;const c=await O6({id:s});await this.components.peerStore.has(c)||(await this.components.peerStore.save(c,{multiaddrs:[_I(a)],tags:{[null!==(e=null===(t=this.options)||void 0===t?void 0:t.tagName)&&void 0!==e?e:Ige]:{value:null!==(r=null===(n=this.options)||void 0===n?void 0:n.tagValue)&&void 0!==r?r:50,ttl:null!==(i=null===(o=this.options)||void 0===o?void 0:o.tagTTL)&&void 0!==i?i:1e8}}}),this.dispatchEvent(new yd("peer",{detail:{id:c,multiaddrs:[_I(a)]}})))}xge.info("Discovered ".concat(this.peers.length," peers")),this.isStarted=!0}}stop(){this.isStarted&&(xge.info("Stopping Local Storage Discovery"),this.components.events.removeEventListener("peer:identify",this.handleNewPeers),this.isStarted=!1,this.savePeersToLocalStorage())}getPeersFromLocalStorage(){try{const e=localStorage.getItem("waku:peers");if(!e)return[];return JSON.parse(e).filter(Tge)}catch(e){return xge.error("Error parsing peers from local storage:",e),[]}}savePeersToLocalStorage(){localStorage.setItem("waku:peers",JSON.stringify(this.peers))}}function Tge(e){return e&&"object"===typeof e&&"string"===typeof e.id&&"string"===typeof e.address}function Rge(){return(e,t)=>new Cge(e,t)}const Pge={lightPush:1,filter:1,store:1};const Dge=io.createContext({decoder:void 0,encoder:void 0}),Nge=()=>io.useContext(Dge),Bge=e=>{const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const[r,n]=io.useState(Hl({contentTopic:e,ephemeral:t})),[i,o]=io.useState(Wl(e));return io.useEffect((()=>{n(Hl({contentTopic:e,ephemeral:t})),o(Wl(e))}),[e,t]),{encoder:r,decoder:i}}(e.contentTopic,e.ephemeral);return io.createElement(Dge.Provider,{value:t},e.children)},Uge=e=>(e=>{const{factory:t,options:r,protocols:n=[]}=e,[i,o]=io.useState(void 0),[s,a]=io.useState(!0),[c,u]=io.useState(void 0);return io.useEffect((()=>{let e=!1;return a(!0),t(r).then((async t=>{e||(await t.start(),await od(t,n),o(t),a(!1))})).catch((e=>{a(!1),u("Failed at creating node: ".concat((null===e||void 0===e?void 0:e.message)||"no message"))})),()=>{e=!0}}),[]),{node:i,error:c,isLoading:s}})({...e,factory:ose}),Lge=e=>{const{node:t,encoder:r}=e,n=io.useCallback((e=>t.lightPush.send(r,e)),[t,r]);return t||r?{push:n}:{}},Mge=io.createContext({node:void 0,isLoading:!1,error:void 0}),Oge=()=>io.useContext(Mge),qge=e=>{const t=Uge({options:e.options,protocols:e.protocols});return io.createElement(Mge.Provider,{value:t},e.children)};async function Kge(e,t,r){let n=[];const i=function(e){const t=e.trim().replaceAll(/\s\s+/g," ");return t.split(" ")}(e),o=i.shift();switch(o){case"/help":["/nick <nickname>: set a new nickname","/info: some information about the node","/connect <Multiaddr>: connect to the given peer","/help: Display this help"].map((e=>n.push(e)));break;case"/nick":(function(e,t){return e?(t(e),["New nick: ".concat(e)]):["No nick provided"]})(i.shift(),r).map((e=>n.push(e)));break;case"/info":(function(e){return e?["PeerId: ".concat(e.libp2p.peerId.toString())]:["Waku node is starting"]})(t).map((e=>n.push(e)));break;case"/connect":(function(e,t){if(!t)return["Waku node is starting"];if(!e)return["No peer provided"];try{const r=_I(e),n=r.getPeerId();return n?(t.dial(r).catch((e=>console.error("Failed to dial ".concat(r),e))),["".concat(n,": ").concat(r.toString()," added to address book, autodial in progress")]):["Peer Id needed to dial"]}catch(r){return["Invalid multiaddr: "+r]}})(i.shift(),t).map((e=>n.push(e)));break;case"/peers":(await async function(e){if(!e)return["Waku node is starting"];let t=[];const r=await e.libp2p.peerStore.all();return Array.from(r).forEach((e=>{t.push(e.id.toString()+":");let r=" addresses: [";e.addresses.forEach((e=>{let{multiaddr:t}=e;r+=" "+t.toString()+","})),r=r.replace(/,$/,""),r+="]",t.push(r);let n=" protocols: [";n+=e.protocols,n+="]",t.push(n)})),0===t.length&&t.push("Not connected to any peer."),t}(t)).map((e=>n.push(e)));break;case"/connections":(function(e){if(!e)return["Waku node is starting"];let t=[],r=" connections: \n";return e.libp2p.getConnections().forEach((e=>{r+=e.remotePeer.toString()+", ",r+=JSON.stringify({direction:e.direction,timeline:e.timeline,multiplexer:e.multiplexer,encryption:e.encryption,status:e.status}),r+="; "+JSON.stringify(e.streams),r+="\n"})),t.push(r),0===t.length&&t.push("Not connected to any peer."),t})(t).map((e=>n.push(e)));break;default:n.push("Unknown Command '".concat(o,"'"))}return{command:o,response:n}}var Fge=__webpack_require__(579);function Vge(e){const t=e.messages.array.map((e=>{var t;return(0,Fge.jsxs)("div",{className:"flex flex-col p-2 border-b border-gray-200",children:[(0,Fge.jsx)("span",{className:"text-sm text-gray-500",children:e.nick}),(0,Fge.jsx)("span",{className:"text-sm text-gray-500",children:zge(e)}),(0,Fge.jsx)("p",{className:"text-gray-700",children:e.payloadAsUtf8})]},e.nick+e.payloadAsUtf8+e.timestamp.valueOf()+(null===(t=e.sentTimestamp)||void 0===t?void 0:t.valueOf()))}));return(0,Fge.jsxs)("div",{className:"overflow-y-auto h-full",children:[t,(0,Fge.jsx)(jge,{messages:e.messages.array})]})}function zge(e){return e.timestamp.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!1})}const jge=e=>{const t=(0,io.useRef)(null);return(0,io.useEffect)((()=>{t.current&&t.current.scrollIntoView()}),[e.messages]),(0,Fge.jsx)("div",{ref:t})};function Hge(e){const{hasLightPushPeers:t}=e,{node:r}=Oge(),[n,i]=(0,io.useState)(""),[o,s]=(0,io.useState)(!1),a=async()=>{if(e.sendMessage&&n){try{await e.sendMessage(n)}catch(t){console.error("Failed to send message: ".concat(t))}i("")}};return(0,io.useEffect)((()=>{n.startsWith("/")||t?s(!0):r&&s(!1)}),[r,n,t]),(0,Fge.jsxs)("div",{className:"flex p-2",children:[(0,Fge.jsx)("input",{type:"text",value:n,onChange:e=>{e.preventDefault(),i(e.target.value)},onKeyDown:async e=>{!o||"Enter"!==e.key||e.altKey||e.ctrlKey||e.shiftKey||await a()},className:"flex-grow p-2 border border-gray-300 rounded-l-md",placeholder:"Type your message..."}),(0,Fge.jsx)("button",{onClick:a,className:"flex-none px-4 py-2 text-white ".concat(o?"bg-blue-500":"bg-blue-300 cursor-not-allowed"," rounded-r-md"),disabled:!o,children:"Send"})]})}var Gge=__webpack_require__(3338),Wge=__webpack_require__(7707),Yge=__webpack_require__(5850),Qge=__webpack_require__(3931);__webpack_require__(1509)._configure(),Gge._configure(Wge),Yge._configure(Qge);const Jge=["uint64","int64","sint64","fixed64","sfixed64"];function Xge(e){return function(e){for(const t of Jge){if(null==e[t])continue;const r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}(new Gge(e))}function Zge(){return function(e){for(const t of Jge){if(null==e[t])continue;const r=e[t];e[t]=function(e){return r.call(this,e.toString())}}return e}(Yge.create())}var $ge;let ebe;!function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}($ge||($ge={})),function(e){let t;e.codec=()=>(null==t&&(t=function(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",$ge.LENGTH_DELIMITED,e,t)}((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.timestamp)throw new Error('Protocol error: required field "timestamp" was not found in object');if(t.uint32(8),t.uint64(e.timestamp),null==e.nick)throw new Error('Protocol error: required field "nick" was not found in object');if(t.uint32(18),t.string(e.nick),null==e.payload)throw new Error('Protocol error: required field "payload" was not found in object');t.uint32(26),t.bytes(e.payload),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={timestamp:0n,nick:"",payload:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.timestamp=e.uint64();break;case 2:r.nick=e.string();break;case 3:r.payload=e.bytes();break;default:e.skipType(7&t)}}if(null==r.timestamp)throw new Error('Protocol error: value for required field "timestamp" was not found in protobuf');if(null==r.nick)throw new Error('Protocol error: value for required field "nick" was not found in protobuf');if(null==r.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');return r}))),t),e.encode=e=>function(e,t){const r=Zge();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}(e,ebe.codec()),e.decode=e=>function(e,t){const r=Xge(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}(e,ebe.codec())}(ebe||(ebe={}));class tbe{constructor(e){this.proto=e}static fromUtf8String(e,t,r){const n=BigInt(Math.floor(e.valueOf()/1e3)),i=kl(r);return new tbe({timestamp:n,nick:t,payload:i})}static decode(e){const t=ebe.decode(e);return new tbe(t)}encode(){return ebe.encode(this.proto)}get timestamp(){return new Date(Number(BigInt(this.proto.timestamp)*BigInt(1e3)))}get nick(){return this.proto.nick}get payloadAsUtf8(){return this.proto.payload?Al(this.proto.payload):""}}var rbe=__webpack_require__(9233);class nbe{constructor(e,t){this.chatMessage=void 0,this.sentTimestamp=void 0,this.chatMessage=e,this.sentTimestamp=t}static cmp(e,t){return e.timestamp.getTime()<t.timestamp.getTime()}static isEqual(e,t){return e.timestamp.valueOf()===t.timestamp.valueOf()&&e.chatMessage.nick===t.chatMessage.nick&&e.chatMessage.payloadAsUtf8===t.chatMessage.payloadAsUtf8}static fromWakuMessage(e){if(e.payload)try{const t=tbe.decode(e.payload);if(t)return new nbe(t,e.timestamp)}catch(t){console.error("Failed to decode chat message",t)}}static fromUtf8String(e,t){const r=new Date;return new nbe(tbe.fromUtf8String(r,e,t),r)}get nick(){return this.chatMessage.nick}get timestamp(){return this.chatMessage.timestamp}get payloadAsUtf8(){return this.chatMessage.payloadAsUtf8}}class ibe{constructor(e,t){this.orderCmp=e,this.isEqual=t,this.array=void 0,this.array=[]}push(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(const n of t)this.insertInOrder(this.array,n)}insertInOrder(e,t){let r=0;for(;r<e.length;)if(!this.isEqual(t,e[r])){if(this.orderCmp(t,e[r]))break;r++}return e.splice(r,0,t),e}}function obe(e,t){if(!e)return[];const r="multicodec"in e?e.multicodec:e.protocol.multicodec;return t.filter((e=>e.protocols.includes(r))).map((e=>e.id))}const sbe=e=>{const{messages:t}=(e=>{const{node:t,decoder:r}=e,[n,i]=io.useState(void 0),[o,s]=io.useState(!1),[a,c]=io.useState([]),u=io.useCallback((e=>{e&&c((t=>[...t,e]))}),[c]);return io.useEffect((()=>{if(!t||!r)return;let e=null;return s(!0),t.filter.subscribe([r],u).then((t=>{s(!1),e=t})).catch((e=>{s(!1),i("Failed to subscribe to filer: ".concat((null===e||void 0===e?void 0:e.message)||"no message"))})),()=>{null===e||void 0===e||e()}}),[t,r,u,i,s]),{error:n,messages:a,isLoading:o}})(e),{messages:r}=(e=>{const{node:t,decoder:r,options:n}=e,[i,o]=io.useState(void 0),[s,a]=io.useState(!1),[c,u]=io.useState([]),l=io.useCallback((e=>{e&&e.length&&u((t=>[...t,...e]))}),[u]);return io.useEffect((()=>{if(!t||!r)return;let e=!1;return a(!0),Promise.resolve().then((async()=>{for await(const i of t.store.queryGenerator([r],n)){if(e)return;const t=(await Promise.all(i)).filter((e=>!!e));l(t)}a(!1)})).catch((e=>{a(!1),o("Failed to query messages from store: ".concat((null===e||void 0===e?void 0:e.message)||"no message"))})),()=>{e=!0}}),[t,r,l,o,a]),{error:i,isLoading:s,messages:c}})(e),[n,i]=(0,io.useState)([]);return[io.useMemo((()=>{const e=new ibe(nbe.cmp,nbe.isEqual),i=new Date;i.setDate(i.getDate()+1);const o=[...r,...t].map(nbe.fromWakuMessage).filter((e=>!!e)).filter((e=>""!==e.payloadAsUtf8)).filter((e=>e.timestamp.valueOf()<i.valueOf()));return e.push(...o),e.push(...n),e}),[r,t,n]),e=>{e&&e.length&&i((t=>[...t,...e]))}]},abe=e=>{const[t,r]=(0,io.useState)(new Set),[n,i]=(0,io.useState)(new Set),[o,s]=(0,io.useState)(new Set),[a,c]=(0,io.useState)(new Set);return(0,io.useEffect)((()=>{if(!e)return;const t=async t=>{(async()=>{await ube(t.detail,e)&&r((e=>new Set([...e,t.detail])))})().catch((e=>console.error(e)))},n=e=>{i((t=>new Set([...t,e.detail])))},o=t=>{(async()=>{await ube(t.detail,e)&&s((e=>new Set([...e,t.detail])))})().catch((e=>console.error(e)))},a=e=>{c((t=>new Set([...t,e.detail])))};return(async()=>{const{CONNECTED:u,DISCOVERED:l}=await e.connectionManager.getPeersByDiscovery();i(new Set(u[Vc.BOOTSTRAP].map((e=>e.id)))),c(new Set(u[Vc.PEER_EXCHANGE].map((e=>e.id)))),r(new Set(l[Vc.BOOTSTRAP].map((e=>e.id)))),s(new Set(l[Vc.PEER_EXCHANGE].map((e=>e.id)))),e.libp2p.addEventListener("peer:disconnect",(e=>{const t=e.detail;i((e=>(e.delete(t),e)))})),e.connectionManager.addEventListener(zc.PEER_DISCOVERY_BOOTSTRAP,t),e.connectionManager.addEventListener(zc.PEER_CONNECT_BOOTSTRAP,n),e.connectionManager.addEventListener(zc.PEER_DISCOVERY_PEER_EXCHANGE,o),e.connectionManager.addEventListener(zc.PEER_CONNECT_PEER_EXCHANGE,a)})(),()=>{e.connectionManager.removeEventListener(zc.PEER_DISCOVERY_BOOTSTRAP,t),e.connectionManager.removeEventListener(zc.PEER_CONNECT_BOOTSTRAP,n),e.connectionManager.removeEventListener(zc.PEER_DISCOVERY_PEER_EXCHANGE,o),e.connectionManager.removeEventListener(zc.PEER_CONNECT_PEER_EXCHANGE,a)}}),[e]),{discoveredBootstrapPeers:t,connectedBootstrapPeers:n,discoveredPeerExchangePeers:o,connectedPeerExchangePeers:a}},cbe=e=>{const{node:t}=e,[r,n]=io.useState({});return(0,io.useEffect)((()=>{if(!t)return;const e=async()=>{const e=t.libp2p.getPeers(),r=await Promise.all(e.map((e=>t.libp2p.peerStore.get(e))));n({allConnected:r.map((e=>e.id)),storePeers:obe(t.store,r),filterPeers:obe(t.filter,r),lightPushPeers:obe(t.lightPush,r)})};return e(),t.libp2p.addEventListener("peer:identify",e),()=>{t.libp2p.removeEventListener("peer:identify",e)}}),[t,n]),r},ube=async(e,t)=>{const r=await t.libp2p.peerStore.get(e);if(!r)return!1;if(0===r.addresses.length)return!1;return 0!==r.addresses.filter((e=>{let{multiaddr:t}=e;return lbe(t.toString())})).length},lbe=e=>e.includes("wss")||e.includes("/tls/ws");function hbe(e){const{node:t}=Oge(),{encoder:r}=Nge(),{push:n}=Lge({node:t,encoder:r}),{connectedBootstrapPeers:i,connectedPeerExchangePeers:o,discoveredBootstrapPeers:s,discoveredPeerExchangePeers:a}=abe(t),{allConnected:c,storePeers:u,filterPeers:l,lightPushPeers:h}=cbe({node:t}),d=dbe(null===c||void 0===c?void 0:c.length),f=dbe(null===h||void 0===h?void 0:h.length),p=dbe(null===l||void 0===l?void 0:l.length),g=dbe(null===u||void 0===u?void 0:u.length);return(0,Fge.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,Fge.jsxs)("div",{className:"flex justify-between items-center bg-gray-800 text-white p-4",children:[(0,Fge.jsxs)("div",{children:[(0,Fge.jsxs)("div",{children:["Peers Connected: ",d]}),(0,Fge.jsxs)("div",{className:"mt-2",children:["Store: ",g]}),(0,Fge.jsxs)("div",{children:["Filter: ",p]}),(0,Fge.jsxs)("div",{children:["Light Push: ",f]})]}),(0,Fge.jsx)("div",{children:"Waku v2 Web Chat"}),(0,Fge.jsxs)("div",{children:[(0,Fge.jsxs)("div",{className:"mt-2",children:["Peers Discovered:"," ",s.size+a.size]}),(0,Fge.jsxs)("div",{children:["Bootstrap: ",s.size," Peer Exchange:"," ",a.size]}),(0,Fge.jsxs)("div",{className:"mt-2",children:["Peers Connected:"," ",i.size+o.size]}),(0,Fge.jsxs)("div",{children:["Bootstrap: ",i.size," Peer Exchange:"," ",o.size]})]})]}),(0,Fge.jsx)(Vge,{messages:e.messages}),(0,Fge.jsx)(Hge,{hasLightPushPeers:!!h,sendMessage:async t=>{if(n&&t)if(t.startsWith("/"))e.commandHandler(t);else{const r=new Date,i=tbe.fromUtf8String(r,e.nick,t).encode();await n({payload:i,timestamp:r})}}})]})}function dbe(e){return e||0}const fbe=new Date;fbe.setTime(Date.now()-6048e5);const pbe=new Date;function gbe(){const{node:e}=Oge(),{decoder:t}=Nge(),[r,n]=sbe({node:e,decoder:t,options:{pageSize:5,pageDirection:Fc.FORWARD,timeFilter:{startTime:fbe,endTime:pbe}}}),[i,o]=(()=>{const[e,t]=(0,io.useState)((()=>{const e=window.localStorage.getItem("nick");return null!==e?e:(0,rbe.c)()}));return(0,io.useEffect)((()=>{localStorage.setItem("nick",e)}),[e]),[e,t]})();return(0,Fge.jsx)("div",{className:"chat-app",style:{height:"100vh",width:"100vw",overflow:"hidden"},children:(0,Fge.jsx)(hbe,{nick:i,messages:r,commandHandler:t=>{Kge(t,e,o).then((e=>{let{command:t,response:r}=e;const i=r.map((e=>nbe.fromUtf8String(t,e)));n(i)}))}})})}oo.render((0,Fge.jsx)(io.StrictMode,{children:(0,Fge.jsx)(qge,{options:{defaultBootstrap:!0},protocols:[qc.Store,qc.Filter,qc.LightPush],children:(0,Fge.jsx)(Bge,{contentTopic:"/toy-chat/2/huilong/proto",children:(0,Fge.jsx)(gbe,{})})})}),document.getElementById("root"))})()})();
|
|
//# sourceMappingURL=main.547d0ff0.js.map |