lab.waku.org/web-chat/static/js/main.e1d0037a.js
status-im-auto 3f372cd065 Updates
2024-04-02 14:30:09 +00:00

3 lines
1.5 MiB

/*! For license information please see main.e1d0037a.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 l=e[t++];switch(c){case 0:s[a++]=n[l>>2],i=(3&l)<<4,c=1;break;case 1:s[a++]=n[i|l>>4],i=(15&l)<<2,c=2;break;case 2:s[a++]=n[i|l>>6],s[a++]=n[63&l],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 l=e.charCodeAt(c++);if(61===l&&a>1)break;if(void 0===(l=i[l]))throw Error(s);switch(a){case 0:n=l,a=1;break;case 1:t[r++]=n<<2|(48&l)>>4,n=l,a=2;break;case 2:t[r++]=(15&n)<<4|(60&l)>>2,n=l,a=3;break;case 3:t[r++]=(3&n)<<6|l,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,l=4294967296*(1048575&s)+o;return 2047===c?l?NaN:a*(1/0):0===c?5e-324*a*l:a*Math.pow(2,c-1075)*(l+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 l=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if("%%"===e)return"%";l++;const i=t.formatters[r];if("function"===typeof i){const t=n[l];e=i.call(o,t),n.splice(l,1),l--}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,l=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>l;)this.unshift(arguments[--a]);for(i=r;i>0;i--)this.unshift(o[i-1])}else{var u=(o=new Array(n-(r+t))).length;for(i=0;i<u;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-u+c&this._capacityMask);l<a;)this.push(arguments[l++]);for(i=0;i<u;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,l,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,o),!0;case 6:return u.fn.call(u.context,t,n,i,o,s),!0}for(l=1,c=new Array(h-1);l<h;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var d,f=u.length;for(l=0;l<f;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,n);break;case 4:u[l].fn.call(u[l].context,t,n,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];u[l].fn.apply(u[l].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,l=[],u=a.length;c<u;c++)(a[c].fn!==t||i&&!a[c].once||n&&a[c].context!==n)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l: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},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],l=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},u=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,l,u=[],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++)],l=a[e.charAt(f++)],u[h++]=255&(t<<3|r>>>2),u[h++]=255&(r<<6|n<<1|i>>>4),u[h++]=255&(i<<4|o>>>1),u[h++]=255&(o<<7|s<<2|c>>>3),u[h++]=255&(c<<5|l);var g=d-p;return 2===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],u[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++)],u[h++]=255&(t<<3|r>>>2),u[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++)],u[h++]=255&(t<<3|r>>>2),u[h++]=255&(r<<6|n<<1|i>>>4),u[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++)],u[h++]=255&(t<<3|r>>>2),u[h++]=255&(r<<6|n<<1|i>>>4),u[h++]=255&(i<<4|o>>>1),u[h++]=255&(o<<7|s<<2|c>>>3)),u},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):l(o,n);for(var a=0;a<s;++a)((t=e[o++])<128||t>191)&&l(o,n),r<<=6,r+=63&t;r>=55296&&r<=57343&&l(o,n),r>1114111&&l(o,n),r<=65535?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode(55296+(r>>10)),n+=String.fromCharCode(56320+(1023&r)))}return n}(u(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,l=0,u=5*parseInt(c/5);l<u;)t=e[l++],r=e[l++],n=e[l++],i=e[l++],o=e[l++],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-u;return 1===h?(t=e[l],a+=s[t>>>3]+s[t<<2&31]+"======"):2===h?(t=e[l++],r=e[l],a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[r<<4&31]+"===="):3===h?(t=e[l++],r=e[l++],n=e[l],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[l++],r=e[l++],n=e[l++],i=e[l],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,l=0,u=5*parseInt(c/5);l<u;)t=e.charCodeAt(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l++),i=e.charCodeAt(l++),o=e.charCodeAt(l++),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-u;return 1===h?(t=e.charCodeAt(l),a+=s[t>>>3]+s[t<<2&31]+"======"):2===h?(t=e.charCodeAt(l++),r=e.charCodeAt(l),a+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[r<<4&31]+"===="):3===h?(t=e.charCodeAt(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l),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(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l++),i=e.charCodeAt(l),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,l,u=!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],l=f;d<p&&l<5;++d)(a=e.charCodeAt(d))<128?c[l++]=a:a<2048?(c[l++]=192|a>>6,c[l++]=128|63&a):a<55296||a>=57344?(c[l++]=224|a>>12,c[l++]=128|a>>6&63,c[l++]=128|63&a):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++d)),c[l++]=240|a>>18,c[l++]=128|a>>12&63,c[l++]=128|a>>6&63,c[l++]=128|63&a);f=l-5,d===p&&++d,d>p&&l<6&&(u=!0),t=c[0],l>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===l?h+=s[t>>>3]+s[t<<2&31]+"======":2===l?(r=c[1],h+=s[t>>>3]+s[31&(t<<2|r>>>6)]+s[r>>>1&31]+s[r<<4&31]+"===="):3===l?(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(!u);return h}(e)},decode:h};h.asBytes=u,i?e.exports=d:(t.base32=d,o&&(void 0===(n=function(){return d}.call(d,r,d,e))||(e.exports=n)))}()},4201:function(e){!function(t){"use strict";const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp("^".concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"$"),"i"),threeOctet:new RegExp("^".concat(r,"\\.").concat(r,"\\.").concat(r,"$"),"i"),twoOctet:new RegExp("^".concat(r,"\\.").concat(r,"$"),"i"),longValue:new RegExp("^".concat(r,"$"),"i")},i=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(s,"i"),native:new RegExp("^(::)?(".concat(a,")?([0-9a-f]+)?(::)?(").concat(s,")?$"),"i"),deprecatedTransitional:new RegExp("^(?:::)(".concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"(").concat(s,")?)$"),"i"),transitional:new RegExp("^((?:".concat(a,")|(?:::)(?:").concat(a,")?)").concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"(").concat(s,")?$"),"i")};function l(e,t){if(e.indexOf("::")!==e.lastIndexOf("::"))return null;let r,n,i=0,o=-1,s=(e.match(c.zoneIndex)||[])[0];for(s&&(s=s.substring(1),e=e.replace(/%.+$/,""));(o=e.indexOf(":",o+1))>=0;)i++;if("::"===e.substr(0,2)&&i--,"::"===e.substr(-2,2)&&i--,i>t)return null;for(n=t-i,r=":";n--;)r+="0:";return":"===(e=e.replace("::",r))[0]&&(e=e.slice(1)),":"===e[e.length-1]&&(e=e.slice(0,-1)),{parts:t=function(){const t=e.split(":"),r=[];for(let e=0;e<t.length;e++)r.push(parseInt(t[e],16));return r}(),zoneId:s}}function u(e,t,r,n){if(e.length!==t.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let i,o=0;for(;n>0;){if(i=r-n,i<0&&(i=0),e[o]>>i!==t[o]>>i)return!1;n-=r,o+=1}return!0}function h(e){if(o.test(e))return parseInt(e,16);if("0"===e[0]&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw new Error("ipaddr: cannot parse ".concat(e," as octal"))}return parseInt(e,10)}function d(e,t){for(;e.length<t;)e="0".concat(e);return e}const f={};f.IPv4=function(){function e(e){if(4!==e.length)throw new Error("ipaddr: ipv4 octet count should be 4");let t,r;for(t=0;t<e.length;t++)if(r=e[t],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]]},e.prototype.kind=function(){return"ipv4"},e.prototype.match=function(e,t){let r;if(void 0===t&&(r=e,e=r[0],t=r[1]),"ipv4"!==e.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let n,i,o;for(n=3;n>=0;n-=1){if(i=this.octets[n],!(i in r))return null;if(o=r[i],t&&0!==o)return null;8!==o&&(t=!0),e+=o}return 32-e},e.prototype.range=function(){return f.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return f.IPv6.parse("::ffff:".concat(this.toString()))},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(".")},e}(),f.IPv4.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[];let o=0;for(;o<4;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},f.IPv4.isIPv4=function(e){return null!==this.parser(e)},f.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch(t){return!1}},f.IPv4.isValidFourPartDecimal=function(e){return!(!f.IPv4.isValid(e)||!e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},f.IPv4.networkAddressFromCIDR=function(e){let t,r,n,i,o;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],r=0;r<4;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(s){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},f.IPv4.parse=function(e){const t=this.parser(e);if(null===t)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(t)},f.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){const e=parseInt(t[2]);if(e>=0&&e<=32){const r=[this.parse(t[1]),e];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},f.IPv4.parser=function(e){let t,r,i;if(t=e.match(n.fourOctet))return function(){const e=t.slice(1,6),n=[];for(let t=0;t<e.length;t++)r=e[t],n.push(h(r));return n}();if(t=e.match(n.longValue)){if(i=h(t[1]),i>4294967295||i<0)throw new Error("ipaddr: address outside defined range");return function(){const e=[];let t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e}().reverse()}return(t=e.match(n.twoOctet))?function(){const e=t.slice(1,4),r=[];if(i=h(e[1]),i>16777215||i<0)throw new Error("ipaddr: address outside defined range");return r.push(h(e[0])),r.push(i>>16&255),r.push(i>>8&255),r.push(255&i),r}():(t=e.match(n.threeOctet))?function(){const e=t.slice(1,5),r=[];if(i=h(e[2]),i>65535||i<0)throw new Error("ipaddr: address outside defined range");return r.push(h(e[0])),r.push(h(e[1])),r.push(i>>8&255),r.push(255&i),r}():null},f.IPv4.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>32)throw new Error("ipaddr: invalid IPv4 prefix length");const t=[0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r<n;)t[r]=255,r++;return n<4&&(t[n]=Math.pow(2,e%8)-1<<8-e%8),new this(t)},f.IPv6=function(){function e(e,t){let r,n;if(16===e.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(e[r]<<8|e[r+1]);else{if(8!==e.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=e}for(r=0;r<this.parts.length;r++)if(n=this.parts[r],!(0<=n&&n<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[new e([100,65435,0,0,0,0,0,0]),96],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],reserved:[[new e([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[new e([8193,4,274,0,0,0,0,0]),48],deprecated:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28]},e.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},e.prototype.kind=function(){return"ipv6"},e.prototype.match=function(e,t){let r;if(void 0===t&&(r=e,e=r[0],t=r[1]),"ipv6"!==e.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1;const r={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let n,i;for(let o=7;o>=0;o-=1){if(n=this.parts[o],!(n in r))return null;if(i=r[n],t&&0!==i)return null;16!==i&&(t=!0),e+=i}return 128-e},e.prototype.range=function(){return f.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e;const t=[],r=this.parts;for(let n=0;n<r.length;n++)e=r[n],t.push(e>>8),t.push(255&e);return t},e.prototype.toFixedLengthString=function(){const e=function(){const e=[];for(let t=0;t<this.parts.length;t++)e.push(d(this.parts[t].toString(16),4));return e}.call(this).join(":");let t="";return this.zoneId&&(t="%".concat(this.zoneId)),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const e=this.parts.slice(-2),t=e[0],r=e[1];return new f.IPv4([t>>8,255&t,r>>8,255&r])},e.prototype.toNormalizedString=function(){const e=function(){const e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}.call(this).join(":");let t="";return this.zoneId&&(t="%".concat(this.zoneId)),e+t},e.prototype.toRFC5952String=function(){const e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString();let r,n=0,i=-1;for(;r=e.exec(t);)r[0].length>i&&(n=r.index,i=r[0].length);return i<0?t:"".concat(t.substring(0,n),"::").concat(t.substring(n+i))},e.prototype.toString=function(){return this.toRFC5952String()},e}(),f.IPv6.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[];let o=0;for(;o<16;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv6 CIDR format (".concat(t,")"))}},f.IPv6.isIPv6=function(e){return null!==this.parser(e)},f.IPv6.isValid=function(e){if("string"===typeof e&&-1===e.indexOf(":"))return!1;try{const t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch(t){return!1}},f.IPv6.networkAddressFromCIDR=function(e){let t,r,n,i,o;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],r=0;r<16;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(s){throw new Error("ipaddr: the address does not have IPv6 CIDR format (".concat(s,")"))}},f.IPv6.parse=function(e){const t=this.parser(e);if(null===t.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(t.parts,t.zoneId)},f.IPv6.parseCIDR=function(e){let t,r,n;if((r=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(r[2]),t>=0&&t<=128))return n=[this.parse(r[1]),t],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},f.IPv6.parser=function(e){let t,r,n,i,o,s;if(n=e.match(c.deprecatedTransitional))return this.parser("::ffff:".concat(n[1]));if(c.native.test(e))return l(e,8);if((n=e.match(c.transitional))&&(s=n[6]||"",t=l(n[1].slice(0,-1)+s,6),t.parts)){for(o=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r<o.length;r++)if(i=o[r],!(0<=i&&i<=255))return null;return t.parts.push(o[0]<<8|o[1]),t.parts.push(o[2]<<8|o[3]),{parts:t.parts,zoneId:t.zoneId}}return null},f.IPv6.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>128)throw new Error("ipaddr: invalid IPv6 prefix length");const t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r<n;)t[r]=255,r++;return n<16&&(t[n]=Math.pow(2,e%8)-1<<8-e%8),new this(t)},f.fromByteArray=function(e){const t=e.length;if(4===t)return new f.IPv4(e);if(16===t)return new f.IPv6(e);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},f.isValid=function(e){return f.IPv6.isValid(e)||f.IPv4.isValid(e)},f.parse=function(e){if(f.IPv6.isValid(e))return f.IPv6.parse(e);if(f.IPv4.isValid(e))return f.IPv4.parse(e);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},f.parseCIDR=function(e){try{return f.IPv6.parseCIDR(e)}catch(t){try{return f.IPv4.parseCIDR(e)}catch(r){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},f.process=function(e){const t=this.parse(e);return"ipv6"===t.kind()&&t.isIPv4MappedAddress()?t.toIPv4Address():t},f.subnetMatch=function(e,t,r){let n,i,o,s;for(i in void 0!==r&&null!==r||(r="unicast"),t)if(Object.prototype.hasOwnProperty.call(t,i))for(o=t[i],!o[0]||o[0]instanceof Array||(o=[o]),n=0;n<o.length;n++)if(s=o[n],e.kind()===s[0].kind()&&e.match.apply(e,s))return i;return r},e.exports?e.exports=f:t.ipaddr=f}(this)},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);var c=!s.JS_SHA3_NO_COMMON_JS&&e.exports,l=r.amdO,u=!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};!s.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var w=function(e,t,r){return function(n){return new B(e,t,e).update(n)[r]()}},v=function(e,t,r){return function(n,i){return new B(e,t,i).update(n)[r]()}},_=function(e,t,r){return function(t,n,i,o){return k["cshake"+e].update(t,n,i,o)[r]()}},E=function(e,t,r){return function(t,n,i,o){return k["kmac"+e].update(t,n,i,o)[r]()}},S=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},A=function(e,t){var r=w(e,t,"hex");return r.create=function(){return new B(e,t,e)},r.update=function(e){return r.create().update(e)},S(r,w,e,t)},x=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:A},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:A},{name:"shake",padding:[31,7936,2031616,520093696],bits:b,createMethod:function(e,t){var r=v(e,t,"hex");return r.create=function(r){return new B(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},S(r,v,e,t)}},{name:"cshake",padding:d,bits:b,createMethod:function(e,t){var r=m[e],n=_(e,0,"hex");return n.create=function(n,i,o){return i||o?new B(e,t,n).bytepad([i,o],r):k["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},S(n,_,e,t)}},{name:"kmac",padding:d,bits:b,createMethod:function(e,t){var r=m[e],n=E(e,0,"hex");return n.create=function(n,i,o){return new L(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)},S(n,E,e,t)}}],k={},C=[],I=0;I<x.length;++I)for(var T=x[I],P=T.bits,R=0;R<P.length;++R){var D=T.name+"_"+P[R];if(C.push(D),k[D]=T.createMethod(P[R],T.padding),"sha3"!==T.name){var N=T.name+P[R];C.push(N),k[N]=k[D]}}function B(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 L(e,t,r){B.call(this,e,t,r)}B.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!u||!ArrayBuffer.isView(e)))throw new Error(i);t=!0}for(var n,o,s=this.blocks,a=this.byteCount,c=e.length,l=this.blockCount,h=0,d=this.s;h<c;){if(this.reset)for(this.reset=!1,s[0]=this.block,n=1;n<l+1;++n)s[n]=0;if(t)for(n=this.start;h<c&&n<a;++h)s[n>>2]|=e[h]<<f[3&n++];else for(n=this.start;h<c&&n<a;++h)(o=e.charCodeAt(h))<128?s[n>>2]|=o<<f[3&n++]:o<2048?(s[n>>2]|=(192|o>>6)<<f[3&n++],s[n>>2]|=(128|63&o)<<f[3&n++]):o<55296||o>=57344?(s[n>>2]|=(224|o>>12)<<f[3&n++],s[n>>2]|=(128|o>>6&63)<<f[3&n++],s[n>>2]|=(128|63&o)<<f[3&n++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++h)),s[n>>2]|=(240|o>>18)<<f[3&n++],s[n>>2]|=(128|o>>12&63)<<f[3&n++],s[n>>2]|=(128|o>>6&63)<<f[3&n++],s[n>>2]|=(128|63&o)<<f[3&n++]);if(this.lastByteIndex=n,n>=a){for(this.start=n-a,this.block=s[l],n=0;n<l;++n)d[n]^=s[n];U(d),this.reset=!0}else this.start=n}return this},B.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},B.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!u||!ArrayBuffer.isView(e)))throw new Error(i);t=!0}var n=0,o=e.length;if(t)n=o;else for(var s=0;s<e.length;++s){var a=e.charCodeAt(s);a<128?n+=1:a<2048?n+=2:a<55296||a>=57344?n+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++s)),n+=4)}return n+=this.encode(8*n),this.update(e),n},B.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,o=[];return o.length=i,this.update(o),this},B.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];U(n)}},B.prototype.toString=B.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&&(U(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},B.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&&U(r)}return i&&(c[o]=r[o],e=e.slice(0,a)),e},B.prototype.buffer=B.prototype.arrayBuffer,B.prototype.digest=B.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&&U(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},L.prototype=new B,L.prototype.finalize=function(){return this.encode(this.outputBits,!0),B.prototype.finalize.call(this)};var U=function(e){var t,r,n,i,o,s,a,c,l,u,h,d,f,g,b,y,m,w,v,_,E,S,A,x,k,C,I,T,P,R,D,N,B,L,U,M,O,q,z,F,K,V,j,H,W,G,Y,Q,J,X,Z,$,ee,te,re,ne,ie,oe,se,ae,ce,le,ue;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],l=e[5]^e[15]^e[25]^e[35]^e[45],u=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|l>>>31),r=o^(l<<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^(u<<1|h>>>31),r=a^(h<<1|u>>>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=l^(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=u^(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],G=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,P=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,V=e[40]<<18|e[41]>>>14,j=e[41]<<18|e[40]>>>14,L=e[2]<<1|e[3]>>>31,U=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,R=e[33]<<13|e[32]>>>19,D=e[32]<<13|e[33]>>>19,le=e[42]<<2|e[43]>>>30,ue=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,w=e[25]<<11|e[24]>>>21,v=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,x=e[6]<<28|e[7]>>>4,k=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,z=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,W=e[9]<<27|e[8]>>>5,C=e[18]<<20|e[19]>>>12,I=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,K=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=g^~y&w,e[1]=b^~m&v,e[10]=x^~C&T,e[11]=k^~I&P,e[20]=L^~M&q,e[21]=U^~O&z,e[30]=H^~G&Q,e[31]=W^~Y&J,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=y^~w&_,e[3]=m^~v&E,e[12]=C^~T&R,e[13]=I^~P&D,e[22]=M^~q&F,e[23]=O^~z&K,e[32]=G^~Q&X,e[33]=Y^~J&Z,e[42]=ne^~oe&ae,e[43]=ie^~se&ce,e[4]=w^~_&S,e[5]=v^~E&A,e[14]=T^~R&N,e[15]=P^~D&B,e[24]=q^~F&V,e[25]=z^~K&j,e[34]=Q^~X&$,e[35]=J^~Z&ee,e[44]=oe^~ae&le,e[45]=se^~ce&ue,e[6]=_^~S&g,e[7]=E^~A&b,e[16]=R^~N&x,e[17]=D^~B&k,e[26]=F^~V&L,e[27]=K^~j&U,e[36]=X^~$&H,e[37]=Z^~ee&W,e[46]=ae^~le&te,e[47]=ce^~ue&re,e[8]=S^~g&y,e[9]=A^~b&m,e[18]=N^~x&C,e[19]=B^~k&I,e[28]=V^~L&M,e[29]=j^~U&O,e[38]=$^~H&G,e[39]=ee^~W&Y,e[48]=le^~te&ne,e[49]=ue^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(c)e.exports=k;else{for(I=0;I<C.length;++I)s[C[I]]=k[C[I]];l&&(void 0===(n=function(){return k}.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},l=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 u(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return l(e).forEach((r=>{s(t,r,u(e[r]))})),t}(e):n(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return l(e).forEach((r=>{s(t,r,u(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,u(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]:u(t[r])));n=h(n,t,l(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,l(t),r):u(t)}e.exports=function(){const e=f(u(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 l=typeof e;if("string"===l&&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"===l&&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,l;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")),l=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===l)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){u||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 u||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,l,u=!1,h=4;function d(){u=!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),l=new Array(4);for(t=0;t<4;++t)c[t]=new Array(256),l[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,l[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),u=s;u<c;++u)r=n[u-1],u%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&&u%s===4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[255&r]),n[u]=n[u-s]^r;if(t){for(var d,f=l[0],p=l[1],g=l[2],b=l[3],y=n.slice(0),m=(u=0,(c=n.length)-h);u<c;u+=h,m-=h)if(0===u||u===c-h)y[u]=n[m],y[u+1]=n[m+3],y[u+2]=n[m+2],y[u+3]=n[m+1];else for(var w=0;w<h;++w)d=n[m+w],y[u+(3&-w)]=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,u,h,d,f,p,g,b,y,m,w,v=e.length/4-1;n?(i=l[0],a=l[1],u=l[2],h=l[3],d=s):(i=c[0],a=c[1],u=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<v;++E)y=i[f>>>24]^a[p>>>16&255]^u[g>>>8&255]^h[255&b]^e[++_],m=i[p>>>24]^a[g>>>16&255]^u[b>>>8&255]^h[255&f]^e[++_],w=i[g>>>24]^a[b>>>16&255]^u[f>>>8&255]^h[255&p]^e[++_],b=i[b>>>24]^a[f>>>16&255]^u[p>>>8&255]^h[255&g]^e[++_],f=y,p=m,g=w;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 l={tagClass:e,type:t,constructed:r,composed:r||n.util.isArray(o),value:o};return s&&"bitStringContents"in s&&(l.bitStringContents=s.bitStringContents,l.original=i.copy(l)),l},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 l=192&c,u=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&&l===i.Class.UNIVERSAL&&u===i.Type.BITSTRING&&(d=e.bytes(f)),void 0===h&&n.decodeBitStrings&&l===i.Class.UNIVERSAL&&u===i.Type.BITSTRING&&f>1){var b=e.read,y=t,m=0;if(u===i.Type.BITSTRING&&(o(e,t,1),m=e.getByte(),t--),0===m)try{a=e.length();var w=s(e,t,r+1,{strict:!0,decodeBitStrings:!0}),v=a-e.length();t-=v,u==i.Type.BITSTRING&&v++;var _=w.tagClass;v!==f||_!==i.Class.UNIVERSAL&&_!==i.Class.CONTEXT_SPECIFIC||(h=[w])}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(u===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(l,u,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(),l="";do{l+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|l.length);for(a=l.length-1;a>=0;--a)t.putByte(l.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 l=r.length-1;l>=0;--l)a.putByte(r[l])}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),l=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),l&&("+"===(c=e.charAt(l))||"-"===c)){var u=60*parseInt(e.substr(l+1,2),10)+parseInt(e.substr(l+4,2),10);u*=6e4,"+"===c?t.setTime(+t-u):t.setTime(+t+u)}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,l=0,u=!1;"Z"===e.charAt(e.length-1)&&(u=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(l=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),l*=6e4,"+"===d&&(l*=-1),u=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),u?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,c),t.setTime(+t+l)):(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 l=0,u="";for(c=0;c<e.value.length;++c)void 0!==e.value[c]&&(l+=1,u+=i.prettyPrint(e.value[c],t+1,r),c+1<e.value.length&&(u+=","));o+=s+"Sub values: "+l+u}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,l=e[i];c<a.length;++c)l+=a[c]<<8,a[c]=l%o,l=l/o|0;for(;l>0;)a.push(l%o),l=l/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 u=new RegExp(".{1,"+r+"}","g");n=n.match(u).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 l=0,u=c;l<a.length;++l)u+=a[l]*o,a[l]=255&u,u>>=8;for(;u>0;)a.push(255&u),u>>=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 l=i[o^n];i[o]=[e[0]^l[0],e[1]^l[1],e[2]^l[2],e[3]^l[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],l=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[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],w=0,v=0;v<b;v++){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],x=l[E>>>28]|u[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&(x>>>16^A),y[w++]=A^t,y[w++]=x^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],l=[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],u=[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],w=i[y+2],v=i[y];v!=m;v+=w){var _=b^e[v],E=(b>>>4|b<<28)^e[v+1];f=g,g=b,b=f^(s[_>>>24&63]|c[_>>>16&63]|u[_>>>8&63]|d[63&_]|o[E>>>24&63]|a[E>>>16&63]|l[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 l=s.length();l>t.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),l=s.length();for(c=0;c<l;++c){a=s.at(c);r.putByte(54^a),i.putByte(92^a)}if(l<t.blockLength)for(a=t.blockLength-l,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],l=this.data[e++]>>14,u=a*c+l*s;i=((c=s*c+((16383&u)<<14)+r.data[n]+i)>>28)+(u>>14)+a*l,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],l=this.data[e++]>>15,u=a*c+l*s;i=((c=s*c+((32767&u)<<15)+r.data[n]+(1073741823&i))>>>30)+(u>>>15)+a*l+(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,l,u="0123456789abcdefghijklmnopqrstuvwxyz",h=new Array;for(c="0".charCodeAt(0),l=0;l<=9;++l)h[c++]=l;for(c="a".charCodeAt(0),l=10;l<36;++l)h[c++]=l;for(c="A".charCodeAt(0),l=10;l<36;++l)h[c++]=l;function d(e){return u.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 w(e,t){return e|t}function v(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 x(e){return e}function k(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,l=e.s,u=this.DB-g(n.data[n.t-1]);u>0?(n.lShiftTo(u,a),i.lShiftTo(u,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,w=m-h,v=null==t?s():t;for(a.dlShiftTo(w,v),r.compareTo(v)>=0&&(r.data[r.t++]=1,r.subTo(v,r)),o.ONE.dlShiftTo(h,v),v.subTo(a,a);a.t<h;)a.data[a.t++]=0;for(;--w>=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,w,0,h))<_)for(a.dlShiftTo(w,v),r.subTo(v,r);r.data[m]<--_;)r.subTo(v,r)}null!=t&&(r.drShiftTo(h,t),c!=l&&o.ZERO.subTo(t,t)),r.t=h,r.clamp(),u>0&&r.rShiftTo(u,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=x,A.prototype.revert=x,A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},A.prototype.sqrTo=function(e,t){e.squareTo(t)},k.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},k.prototype.revert=function(e){return e},k.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)},k.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},k.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var C=[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],I=(1<<26)/C[C.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 l=f(e,c);l<0?"-"==e.charAt(c)&&0==this.signum()&&(i=!0):(a=t*a+l,++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),w,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 l=1;l++<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,w,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,v,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,w)},o.prototype.clearBit=function(e){return this.changeBit(e,_)},o.prototype.flipBit=function(e){return this.changeBit(e,v)},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 k(t):new y(t);var a=new Array,c=3,l=r-1,u=(1<<r)-1;if(a[1]=n.convert(this),r>1){var h=s();for(n.sqrTo(a[1],h);c<=u;)a[c]=s(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,f,m=e.t-1,w=!0,v=s();for(i=g(e.data[m])-1;m>=0;){for(i>=l?d=e.data[m]>>i-l&u:(d=(e.data[m]&(1<<i+1)-1)<<l-i,m>0&&(d|=e.data[m-1]>>this.DB+i-l)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),w)a[d].copyTo(o),w=!1;else{for(;c>1;)n.sqrTo(o,v),n.sqrTo(v,o),c-=2;c>0?n.sqrTo(o,v):(f=o,o=v,v=f),n.mulTo(v,a[d],o)}for(;m>=0&&0==(e.data[m]&1<<i);)n.sqrTo(o,v),f=o,o=v,v=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]<=C[C.length-1]){for(t=0;t<C.length;++t)if(r.data[0]==C[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<C.length;){for(var n=C[t],i=t+1;i<C.length&&n<I;)n*=C[i++];for(n=r.modInt(n);t<i;)if(n%C[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"}]},l={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"}]}]},u={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,l,u=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),w=n.pkcs5.pbkdf2(t,u,h,i,m),v=n.random.getBytesSync(p);(S=b(w)).start(v),S.update(o.toDer(e)),S.finish(),l=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}(u,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,v)])])])}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(u);w=s.pbe.generatePkcs12Key(t,A,1,h,i),v=s.pbe.generatePkcs12Key(t,A,2,h,i);(S=n.des.createEncryptionCipher(w)).start(v),S.update(o.toDer(e)),S.finish(),l=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,u),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,l)])},s.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!o.validate(e,c,i,a)){var l=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw l.errors=a,l}var u=o.derToOid(i.encryptionOid),h=s.pbe.getCipher(u,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,l,u;switch(r.algorithm){case"aes128":a="AES-128-CBC",l=16,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",l=24,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",l=32,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",l=24,c=n.random.getBytesSync(8),u=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",l=8,c=n.random.getBytesSync(8),u=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=u(n.pbe.opensslDeriveBytes(t,c.substr(0,8),l));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(l=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=l,l;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 l;throw(l=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,l}var u=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,u.substr(0,8),a));if(h.start(u),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 l=s.digestLength,u=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,u);var b=u*Math.ceil(p/u),y=new n.util.ByteBuffer;for(c=0;c<b;c++)y.putByte(t.at(c%p));var m=u*Math.ceil(f/u),w=new n.util.ByteBuffer;for(c=0;c<m;c++)w.putByte(d.at(c%f));var v=y;v.putBuffer(w);for(var _=Math.ceil(o/l),E=1;E<=_;E++){var S=new n.util.ByteBuffer;S.putBytes(g.bytes()),S.putBytes(v.bytes());for(var A=0;A<i;A++)s.start(),s.update(S.getBytes()),S=s.digest();var x=new n.util.ByteBuffer;for(c=0;c<u;c++)x.putByte(S.at(c%l));var k=Math.ceil(p/u)+Math.ceil(f/u),C=new n.util.ByteBuffer;for(a=0;a<k;a++){var I=new n.util.ByteBuffer(v.getBytes(u)),T=511;for(c=x.length()-1;c>=0;c--)T>>=8,T+=x.at(c)+I.at(c),I.setAt(c,255&T);C.putBuffer(I)}v=C,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,l,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 u,h,f=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),s.oids[e]){case"aes128-CBC":u=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,h=n.des.createDecryptionCipher;break;case"desCBC":u=8,h=n.des.createDecryptionCipher}var g=d(a.prfOid),b=n.pkcs5.pbkdf2(r,f,p,u,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,u,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,l,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,l=8,h=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,l=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,l,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 l=new Error("Derived key is too long.");if(a)return a(l);throw l}var u=Math.ceil(o/c),h=o-(u-1)*c,d=n.hmac.create();d.start(s,e);var f,p,g,b="";if(!a){for(var y=1;y<=u;++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<u?f:f.substr(0,h)}return b}y=1;function w(){if(y>u)return a(null,b);d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(y)),f=g=d.digest().getBytes(),m=2,v()}function v(){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(v);b+=y<u?f:f.substr(0,h),++y,w()}w()}},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 l={type:c,procType:null,contentDomain:null,dekInfo:null,headers:[],body:n.util.decode64(t[3])};if(r.push(l),t[2]){for(var u=t[2].split(a),h=0;t&&h<u.length;){for(var d=u[h].replace(/\s+$/,""),f=h+1;f<u.length;++f){var p=u[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(l.procType)if(l.contentDomain||"Content-Domain"!==g.name)if(l.dekInfo||"DEK-Info"!==g.name)l.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.');l.dekInfo={algorithm:b[0],parameters:b[1]||null}}else l.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.');l.procType={version:b[0],type:b[1]}}}++h}if("ENCRYPTED"===l.procType&&!l.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 l=Math.ceil(e.n.bitLength()/8),u=l-2*a.digestLength-2;if(t.length>u)throw(b=new Error("RSAES-OAEP input message length is too long.")).length=t.length,b.maxLength=u,b;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",f=u-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,l-a.digestLength-1,c),m=n.util.xorBytes(g,y,g.length),w=o(m,a.digestLength,c);return"\0"+n.util.xorBytes(s,w,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 l=s.digest().getBytes(),u=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"!==u,m=0;m<s.digestLength;++m)y|=l.charAt(m)!==b.charAt(m);for(var w=1,v=s.digestLength,_=s.digestLength;_<g.length;_++){var E=g.charCodeAt(_);y|=E&(w?65534:0),v+=w&=1&E^1}if(y||1!==g.charCodeAt(v))throw new Error("Invalid RSAES-OAEP padding.");return g.substring(v+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=l(e,t),c=i.workers,u=i.workLoad||100,h=30*u/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=l(e,t));var f=s.toString(16);i.target.postMessage({hex:f,workLoad:u}),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=l(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,u){var h=+new Date;do{if(e.bitLength()>t&&(e=l(t,r)),e.isProbablePrime(s))return u(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,u)}))}function l(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 l(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 l,u,h,d=Math.floor(65536*Math.random());o.length()<e;){u=16807*(65535&d),u+=(32767&(l=16807*(d>>16)))<<16,d=4294967295&(u=(2147483647&(u+=l>>15))+(u>>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,l=n.util.createBuffer();t.key=null,function u(h){if(h)return r(h);if(l.length()>=e)return r(null,l.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()}))}(u)}));var d=i(t.key,t.seed);t.generated+=d.length,l.putBytes(d),t.key=s(i(t.key,o(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(u)}()},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 l=r(t.key,t.seed);t.generated+=l.length,c.putBytes(l),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,l(e))}catch(r){t(r)}},t.seedFileSync=l),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,l=n.util.globalScope,u=l.crypto||l.msCrypto;if(u&&u.getRandomValues&&(c=function(e){return u.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),l=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)&l]),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,l,u,h=!1,d=null,f=null,p=null,g=[];for(e=n.rc2.expandKey(e,t),l=0;l<64;l++)g.push(e.getInt16Le());r?(i=function(e){for(l=0;l<4;l++)e[l]+=g[u]+(e[(l+3)%4]&e[(l+2)%4])+(~e[(l+3)%4]&e[(l+1)%4]),e[l]=s(e[l],o[l]),u++},c=function(e){for(l=0;l<4;l++)e[l]+=g[63&e[(l+3)%4]]}):(i=function(e){for(l=3;l>=0;l--)e[l]=a(e[l],o[l]),e[l]-=g[u]+(e[(l+3)%4]&e[(l+2)%4])+(~e[(l+3)%4]&e[(l+1)%4]),u--},c=function(e){for(l=3;l>=0;l--)e[l]-=g[63&e[(l+3)%4]]});var b=function(e){var t=[];for(l=0;l<4;l++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}u=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(l=0;l<4;l++)null!==p&&(r?p.putInt16Le(t[l]):t[l]^=p.getInt16Le()),f.putInt16Le(t[l])},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,l=[6,4,2,4,2,4,6,2],u={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 l=0;l<c;++l)i.putByte(a)}else for(;c>0;){var u=0,h=n.random.getBytes(c);for(l=0;l<c;++l)0===(a=h.charCodeAt(l))?++u:i.putByte(a);c=u}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 l=0;if(0===c){l=o-3-i;for(var u=0;u<l;++u)if(0!==s.getByte())throw new Error("Encryption block is invalid.")}else if(1===c)for(l=0;s.length()>1;){if(255!==s.getByte()){--s.read;break}++l}else if(2===c)for(l=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++l}if(0!==s.getByte()||l!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function w(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 v(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),l=b(c,t,s).toString(16),u=n.util.createBuffer(),h=a-Math.ceil(l.length/2);h>0;)u.putByte(0),--h;return u.putBytes(n.util.hexToBytes(l)),u.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 l=b(c,t,r).toString(16),u=n.util.createBuffer(),h=s-Math.ceil(l.length/2);h>0;)u.putByte(0),--h;return u.putBytes(n.util.hexToBytes(l)),!1!==o?m(u.getBytes(),t,r):u.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,u=0;null===e.keys&&(t<=0||u<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(v(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(l[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)}}u+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,l){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(l=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(l=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,l=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(l=r,r=void 0):(l=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(l){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 l(e);l(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){l(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(e)));l(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(S("generateKey")&&S("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:A(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.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)));l(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){l(e)}},void(u.onerror=function(e){l(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(!l)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?l(t,e.q):void a(e.qBits,l))}))}function a(e,t){n.prime.generateProbablePrime(e,o,t)}function l(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,l);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,l);var u=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,u,e.p,e.q,u.mod(e.p1),u.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}s()}(d,r,l)},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(l=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=c,l;var l,u=s.derToOid(a.algorithmIdentifier);if(u!==n.oids.md2&&u!==n.oids.md5&&u!==n.oids.sha1&&u!==n.oids.sha224&&u!==n.oids.sha256&&u!==n.oids.sha384&&u!==n.oids.sha512&&u!==n.oids["sha512-224"]&&u!==n.oids["sha512-256"])throw(l=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=u,l;if((u===n.oids.md2||u===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,l){var u={n:e,e:t,d:r,p:i,q:o,dP:s,dQ:a,qInv:l,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,u,!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,u,!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,u.n.bitLength());return c.rsa.encrypt(n,u,r)}};return u},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,l,d,f,p,g={},b=[];if(s.validate(e,u,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(),l=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(l,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,w(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(e.e)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(e.d)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(e.p)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(e.q)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(e.dP)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(e.dQ)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(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 l=n.util.createBuffer(t.publicKeyModulus).toHex(),u=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(l,16),new i(u,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,w(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,w(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 l=i.fullMessageLength.length-1;l>=0;--l)i.fullMessageLength[l]+=c[1],c[1]=c[0]+(i.fullMessageLength[l]/4294967296>>>0),i.fullMessageLength[l]=i.fullMessageLength[l]>>>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,l=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-l));for(var u=8*i.fullMessageLength[0],h=0;h<i.fullMessageLength.length-1;++h)u+=(c=8*i.fullMessageLength[h+1])/4294967296>>>0,s.putInt32(u>>>0),u=c>>>0;s.putInt32(u);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,l,u=r.length();u>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,c=e.h4,l=0;l<16;++l)n=r.getInt32(),t[l]=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(;l<20;++l)n=(n=t[l-3]^t[l-8]^t[l-14]^t[l-16])<<1|n>>>31,t[l]=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(;l<32;++l)n=(n=t[l-3]^t[l-8]^t[l-14]^t[l-16])<<1|n>>>31,t[l]=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(;l<40;++l)n=(n=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|n>>>30,t[l]=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(;l<60;++l)n=(n=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|n>>>30,t[l]=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(;l<80;++l)n=(n=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|n>>>30,t[l]=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,u-=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 l=i.fullMessageLength.length-1;l>=0;--l)i.fullMessageLength[l]+=a[1],a[1]=a[0]+(i.fullMessageLength[l]/4294967296>>>0),i.fullMessageLength[l]=i.fullMessageLength[l]>>>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,l=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-l));for(var u=8*i.fullMessageLength[0],h=0;h<i.fullMessageLength.length-1;++h)u+=(a=8*i.fullMessageLength[h+1])/4294967296>>>0,s.putInt32(u>>>0),u=a>>>0;s.putInt32(u);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,l,u,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(l=e.h0,u=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=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),s=l&u|h&(l^u),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=u,u=l,l=n+(i=o+s)>>>0;e.h0=e.h0+l|0,e.h1=e.h1+u|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]],(l={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],l["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],l["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],l["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 l))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=l[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),u(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 l=8*f.fullMessageLength[0],h=0;h<f.fullMessageLength.length-1;++h)l+=(a=8*f.fullMessageLength[h+1])/4294967296>>>0,t.putInt32(l>>>0),l=a>>>0;t.putInt32(l);var d=new Array(r.length);for(h=0;h<r.length;++h)d[h]=r[h].slice(0);u(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,l=null;function u(e,t,r){for(var n,i,o,s,a,l,u,h,d,f,p,g,b,y,m,w,v,_,E,S,A,x,k,C,I,T,P,R,D,N,B,L,U,M=r.length();M>=128;){for(P=0;P<16;++P)t[P][0]=r.getInt32()>>>0,t[P][1]=r.getInt32()>>>0;for(;P<80;++P)n=(((R=(N=t[P-2])[0])>>>19|(D=N[1])<<13)^(D>>>29|R<<3)^R>>>6)>>>0,i=((R<<13|D>>>19)^(D<<3|R>>>29)^(R<<26|D>>>6))>>>0,o=(((R=(L=t[P-15])[0])>>>1|(D=L[1])<<31)^(R>>>8|D<<24)^R>>>7)>>>0,s=((R<<31|D>>>1)^(R<<24|D>>>8)^(R<<25|D>>>7))>>>0,B=t[P-7],U=t[P-16],D=i+B[1]+s+U[1],t[P][0]=n+B[0]+o+U[0]+(D/4294967296>>>0)>>>0,t[P][1]=D>>>0;for(p=e[0][0],g=e[0][1],b=e[1][0],y=e[1][1],m=e[2][0],w=e[2][1],v=e[3][0],_=e[3][1],E=e[4][0],S=e[4][1],A=e[5][0],x=e[5][1],k=e[6][0],C=e[6][1],I=e[7][0],T=e[7][1],P=0;P<80;++P)u=((E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23))>>>0,h=(k^E&(A^k))>>>0,a=((p>>>28|g<<4)^(g>>>2|p<<30)^(g>>>7|p<<25))>>>0,l=((p<<4|g>>>28)^(g<<30|p>>>2)^(g<<25|p>>>7))>>>0,d=(p&b|m&(p^b))>>>0,f=(g&y|w&(g^y))>>>0,D=T+(((E<<18|S>>>14)^(E<<14|S>>>18)^(S<<23|E>>>9))>>>0)+((C^S&(x^C))>>>0)+c[P][1]+t[P][1],n=I+u+h+c[P][0]+t[P][0]+(D/4294967296>>>0)>>>0,i=D>>>0,o=a+d+((D=l+f)/4294967296>>>0)>>>0,s=D>>>0,I=k,T=C,k=A,C=x,A=E,x=S,E=v+n+((D=_+i)/4294967296>>>0)>>>0,S=D>>>0,v=m,_=w,m=b,w=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]+w,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]+v+(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]+x,e[5][0]=e[5][0]+A+(D/4294967296>>>0)>>>0,e[5][1]=D>>>0,D=e[6][1]+C,e[6][0]=e[6][0]+k+(D/4294967296>>>0)>>>0,e[6][1]=D>>>0,D=e[7][1]+T,e[7][0]=e[7][0]+I+(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+/=",l=[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],u="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=l[e.charCodeAt(s++)-43],r=l[e.charCodeAt(s++)-43],n=l[e.charCodeAt(s++)-43],i=l[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,u=r=r||0;c<e.length;)n=l[e.charCodeAt(c++)-43],i=l[e.charCodeAt(c++)-43],o=l[e.charCodeAt(c++)-43],s=l[e.charCodeAt(c++)-43],a[u++]=n<<2|i>>4,64!==o&&(a[u++]=(15&i)<<4|o>>2,64!==s&&(a[u++]=(3&o)<<6|s));return t?u-r:a.subarray(0,u)},o.binary.base58.encode=function(e,t){return o.binary.baseN.encode(e,u,t)},o.binary.base58.decode=function(e,t){return o.binary.baseN.decode(e,u,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?"-":"",l=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",u=l.length>3?l.length%3:0;return c+(u?l.substr(0,u)+a:"")+l.substr(u).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-l).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 l=r[n];l.end-l.start>0&&(t.splice(l.start,l.end-l.start+1,""),0===l.start&&t.unshift(""),7===l.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 l in o=Object(arguments[c]))r.call(o,l)&&(a[l]=o[l]);if(t){s=t(o);for(var u=0;u<s.length;u++)n.call(o,s[u])&&(a[s[u]]=o[s[u]])}}return a}},1099:(e,t,r)=>{"use strict";e.exports=r(9191)},9191:(e,t,r)=>{"use strict";var n=t;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=r(5850),n.BufferWriter=r(3931),n.Reader=r(3338),n.BufferReader=r(7707),n.util=r(1509),n.rpc=r(8094),n.roots=r(1368),n.configure=i,i()},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 l="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")},u=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new n(e):l(e)})(e)}:l};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=u(),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=u(),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()},1368:e=>{"use strict";e.exports={}},8094:(e,t,r)=>{"use strict";t.Service=r(3694)},3694:(e,t,r)=>{"use strict";e.exports=i;var n=r(1509);function i(e,t,r){if("function"!==typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(i.prototype=Object.create(n.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,r,i,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return n.asPromise(e,a,t,r,i,o);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,r){if(e)return a.emit("error",e,t),s(e);if(null!==r){if(!(r instanceof i))try{r=i[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",r,t),s(null,r)}a.end(!0)}))}catch(c){return a.emit("error",c,t),void setTimeout((function(){s(c)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},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 l(){}function u(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(l,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 u(this),this.head=this.tail=new c(l,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(l,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()},9413:(e,t,r)=>{const n=r(428),i=r(619),o=r(3181),s=r(176),{RateLimiterClusterMaster:a,RateLimiterClusterMasterPM2:c,RateLimiterCluster:l}=r(1873),u=r(1636),h=r(8662),d=r(7771),f=r(8400),p=r(4120),g=r(6360),b=r(5925);e.exports={RateLimiterRedis:n,RateLimiterMongo:i,RateLimiterMySQL:o,RateLimiterPostgres:s,RateLimiterMemory:u,RateLimiterMemcache:h,RateLimiterClusterMaster:a,RateLimiterClusterMasterPM2:c,RateLimiterCluster:l,RLWrapperBlackAndWhite:d,RateLimiterUnion:f,RateLimiterQueue:p,BurstyRateLimiter:g,RateLimiterRes:b}},6360:(e,t,r)=>{const n=r(5925);e.exports=class{constructor(e,t){this._rateLimiter=e,this._burstLimiter=t}_combineRes(e,t){return e?new n(e.remainingPoints,Math.min(e.msBeforeNext,t?t.msBeforeNext:0),e.consumedPoints,e.isFirstInDuration):null}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._rateLimiter.consume(e,t,r).catch((i=>i instanceof n?this._burstLimiter.consume(e,t,r).then((e=>Promise.resolve(this._combineRes(i,e)))).catch((e=>e instanceof n?Promise.reject(this._combineRes(i,e)):Promise.reject(e))):Promise.reject(i)))}get(e){return Promise.all([this._rateLimiter.get(e),this._burstLimiter.get(e)]).then((e=>{let[t,r]=e;return this._combineRes(t,r)}))}get points(){return this._rateLimiter.points}}},7771:(e,t,r)=>{const n=r(5925);e.exports=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.limiter=e.limiter,this.blackList=e.blackList,this.whiteList=e.whiteList,this.isBlackListed=e.isBlackListed,this.isWhiteListed=e.isWhiteListed,this.runActionAnyway=e.runActionAnyway}get limiter(){return this._limiter}set limiter(e){if("undefined"===typeof e)throw new Error("limiter is not set");this._limiter=e}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(e){this._runActionAnyway="undefined"!==typeof e&&e}get blackList(){return this._blackList}set blackList(e){this._blackList=Array.isArray(e)?e:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(e){if("undefined"===typeof e&&(e=()=>!1),"function"!==typeof e)throw new Error("isBlackListed must be function");this._isBlackListed=e}get whiteList(){return this._whiteList}set whiteList(e){this._whiteList=Array.isArray(e)?e:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(e){if("undefined"===typeof e&&(e=()=>!1),"function"!==typeof e)throw new Error("isWhiteListed must be function");this._isWhiteListed=e}isBlackListedSomewhere(e){return this.blackList.indexOf(e)>=0||this.isBlackListed(e)}isWhiteListedSomewhere(e){return this.whiteList.indexOf(e)>=0||this.isWhiteListed(e)}getBlackRes(){return new n(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new n(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.isWhiteListedSomewhere(e)?t=this.resolveWhite():this.isBlackListedSomewhere(e)&&(t=this.rejectBlack()),"undefined"===typeof t?this.limiter.consume(e,r):(this.runActionAnyway&&this.limiter.consume(e,r).catch((()=>{})),t)}block(e,t){let r;return this.isWhiteListedSomewhere(e)?r=this.resolveWhite():this.isBlackListedSomewhere(e)&&(r=this.resolveBlack()),"undefined"===typeof r?this.limiter.block(e,t):(this.runActionAnyway&&this.limiter.block(e,t).catch((()=>{})),r)}penalty(e,t){let r;return this.isWhiteListedSomewhere(e)?r=this.resolveWhite():this.isBlackListedSomewhere(e)&&(r=this.resolveBlack()),"undefined"===typeof r?this.limiter.penalty(e,t):(this.runActionAnyway&&this.limiter.penalty(e,t).catch((()=>{})),r)}reward(e,t){let r;return this.isWhiteListedSomewhere(e)?r=this.resolveWhite():this.isBlackListedSomewhere(e)&&(r=this.resolveBlack()),"undefined"===typeof r?this.limiter.reward(e,t):(this.runActionAnyway&&this.limiter.reward(e,t).catch((()=>{})),r)}get(e){let t;return this.isWhiteListedSomewhere(e)?t=this.resolveWhite():this.isBlackListedSomewhere(e)&&(t=this.resolveBlack()),"undefined"===typeof t||this.runActionAnyway?this.limiter.get(e):t}delete(e){return this.limiter.delete(e)}}},8205:e=>{e.exports=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.points=e.points,this.duration=e.duration,this.blockDuration=e.blockDuration,this.execEvenly=e.execEvenly,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs,this.keyPrefix=e.keyPrefix}get points(){return this._points}set points(e){this._points=e>=0?e:4}get duration(){return this._duration}set duration(e){this._duration="undefined"===typeof e?1:e}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration="undefined"===typeof e?0:e}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly="undefined"!==typeof e&&Boolean(e)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs="undefined"===typeof e?Math.ceil(this.msDuration/this.points):e}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if("undefined"===typeof e&&(e="rlflx"),"string"!==typeof e)throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e&&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)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},1873:(e,t,r)=>{const n=r(4658),i=r(7287),o=r(8205),s=r(1636),a=r(5925),c="rate_limiter_flexible";let l=null;const u=function(e,t,r,n){let i;i=null===n||!0===n||!1===n?n:{remainingPoints:n.remainingPoints,msBeforeNext:n.msBeforeNext,consumedPoints:n.consumedPoints,isFirstInDuration:n.isFirstInDuration},e.send({channel:c,keyPrefix:t.keyPrefix,promiseId:t.promiseId,type:r,data:i})},h=function(e){setTimeout((()=>{this._initiated?process.send(e):"undefined"!==typeof this._promises[e.promiseId]&&h.call(this,e)}),30)},d=function(e,t,r,n,i){const o={channel:c,keyPrefix:this.keyPrefix,func:e,promiseId:t,data:{key:r,arg:n,opts:i}};this._initiated?process.send(o):h.call(this,o)},f=function(e,t){if(!t||t.channel!==c||"undefined"===typeof this._rateLimiters[t.keyPrefix])return!1;let r;switch(t.func){case"consume":r=this._rateLimiters[t.keyPrefix].consume(t.data.key,t.data.arg,t.data.opts);break;case"penalty":r=this._rateLimiters[t.keyPrefix].penalty(t.data.key,t.data.arg,t.data.opts);break;case"reward":r=this._rateLimiters[t.keyPrefix].reward(t.data.key,t.data.arg,t.data.opts);break;case"block":r=this._rateLimiters[t.keyPrefix].block(t.data.key,t.data.arg,t.data.opts);break;case"get":r=this._rateLimiters[t.keyPrefix].get(t.data.key,t.data.opts);break;case"delete":r=this._rateLimiters[t.keyPrefix].delete(t.data.key,t.data.opts);break;default:return!1}r&&r.then((r=>{u(e,t,"resolve",r)})).catch((r=>{u(e,t,"reject",r)}))},p=function(e){if(!e||e.channel!==c||e.keyPrefix!==this.keyPrefix)return!1;if(this._promises[e.promiseId]){let t;switch(clearTimeout(this._promises[e.promiseId].timeoutId),t=null===e.data||!0===e.data||!1===e.data?e.data:new a(e.data.remainingPoints,e.data.msBeforeNext,e.data.consumedPoints,e.data.isFirstInDuration),e.type){case"resolve":this._promises[e.promiseId].resolve(t);break;case"reject":this._promises[e.promiseId].reject(t);break;default:throw new Error("RateLimiterCluster: no such message type '".concat(e.type,"'"))}delete this._promises[e.promiseId]}},g=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},b=function(e,t){const r=process.hrtime();let n=r[0].toString()+r[1].toString();return"undefined"!==typeof this._promises[n]&&(n+=i.randomBytes(12).toString("base64")),this._promises[n]={resolve:e,reject:t,timeoutId:setTimeout((()=>{delete this._promises[n],t(new Error("RateLimiterCluster timeout: no answer from master in time"))}),this.timeoutMs)},n};e.exports={RateLimiterClusterMaster:class{constructor(){if(l)return l;this._rateLimiters={},n.setMaxListeners(0),n.on("message",((e,t)=>{t&&t.channel===c&&"init"===t.type?("undefined"===typeof this._rateLimiters[t.opts.keyPrefix]&&(this._rateLimiters[t.opts.keyPrefix]=new s(t.opts)),e.send({channel:c,type:"init",keyPrefix:t.opts.keyPrefix})):f.call(this,e,t)})),l=this}},RateLimiterClusterMasterPM2:class{constructor(e){if(l)return l;this._rateLimiters={},e.launchBus(((t,r)=>{r.on("process:msg",(t=>{const r=t.raw;if(r&&r.channel===c&&"init"===r.type)"undefined"===typeof this._rateLimiters[r.opts.keyPrefix]&&(this._rateLimiters[r.opts.keyPrefix]=new s(r.opts)),e.sendDataToProcessId(t.process.pm_id,{data:{},topic:c,channel:c,type:"init",keyPrefix:r.opts.keyPrefix},((e,t)=>{e&&console.log(e,t)}));else{f.call(this,{send:r=>{const n=r;n.topic=c,"undefined"===typeof n.data&&(n.data={}),e.sendDataToProcessId(t.process.pm_id,n,((e,t)=>{e&&console.log(e,t)}))}},r)}}))})),l=this}},RateLimiterCluster:class extends o{get timeoutMs(){return this._timeoutMs}set timeoutMs(e){this._timeoutMs="undefined"===typeof e?5e3:Math.abs(parseInt(e))}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),process.setMaxListeners(0),this.timeoutMs=e.timeoutMs,this._initiated=!1,process.on("message",(e=>{e&&e.channel===c&&"init"===e.type&&e.keyPrefix===this.keyPrefix?this._initiated=!0:p.call(this,e)})),process.send({channel:c,type:"init",opts:g.call(this)}),this._promises={}}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const o=b.call(this,n,i);d.call(this,"consume",o,e,t,r)}))}penalty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const o=b.call(this,n,i);d.call(this,"penalty",o,e,t,r)}))}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const o=b.call(this,n,i);d.call(this,"reward",o,e,t,r)}))}block(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const o=b.call(this,n,i);d.call(this,"block",o,e,t,r)}))}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((r,n)=>{const i=b.call(this,r,n);d.call(this,"get",i,e,t)}))}delete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((r,n)=>{const i=b.call(this,r,n);d.call(this,"delete",i,e,t)}))}}}},8662:(e,t,r)=>{const n=r(3384),i=r(5925);e.exports=class extends n{constructor(e){super(e),this.client=e.storeClient}_getRateLimiterRes(e,t,r){const n=new i;return n.consumedPoints=parseInt(r.consumedPoints),n.isFirstInDuration=r.consumedPoints===t,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=r.msBeforeNext,n}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return new Promise(((o,s)=>{const a=Date.now(),c=Math.floor(r/1e3);n?this.client.set(e,t,c,(r=>{r?s(r):this.client.set("".concat(e,"_expire"),c>0?a+1e3*c:-1,c,(()=>{o({consumedPoints:t,msBeforeNext:c>0?1e3*c:-1})}))})):this.client.incr(e,t,((l,u)=>{l||!1===u?this.client.add(e,t,c,((l,u)=>{if(l||!u)if("undefined"===typeof i.attemptNumber||i.attemptNumber<3){const a=Object.assign({},i);a.attemptNumber=a.attemptNumber?a.attemptNumber+1:1,this._upsert(e,t,r,n,a).then((e=>o(e))).catch((e=>s(e)))}else s(new Error("Can not add key"));else this.client.add("".concat(e,"_expire"),c>0?a+1e3*c:-1,c,(()=>{o({consumedPoints:t,msBeforeNext:c>0?1e3*c:-1})}))})):this.client.get("".concat(e,"_expire"),((e,t)=>{if(e)s(e);else{const e=!1===t?0:t,r={consumedPoints:u,msBeforeNext:e>=0?Math.max(e-a,0):-1};o(r)}}))}))}))}_get(e){return new Promise(((t,r)=>{const n=Date.now();this.client.get(e,((i,o)=>{o?this.client.get("".concat(e,"_expire"),((e,i)=>{if(e)r(e);else{const e=!1===i?0:i,r={consumedPoints:o,msBeforeNext:e>=0?Math.max(e-n,0):-1};t(r)}})):t(null)}))}))}_delete(e){return new Promise(((t,r)=>{this.client.del(e,((n,i)=>{n?r(n):!1===i?t(i):this.client.del("".concat(e,"_expire"),(e=>{e?r(e):t(i)}))}))}))}}},1636:(e,t,r)=>{const n=r(8205),i=r(1994),o=r(5925);e.exports=class extends n{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this._memoryStorage=new i}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const o=this.getKey(e),s=this._getKeySecDuration(r);let a=this._memoryStorage.incrby(o,t,s);if(a.remainingPoints=Math.max(this.points-a.consumedPoints,0),a.consumedPoints>this.points)this.blockDuration>0&&a.consumedPoints<=this.points+t&&(a=this._memoryStorage.set(o,a.consumedPoints,this.blockDuration)),i(a);else if(this.execEvenly&&a.msBeforeNext>0&&!a.isFirstInDuration){let e=Math.ceil(a.msBeforeNext/(a.remainingPoints+2));e<this.execEvenlyMinDelayMs&&(e=a.consumedPoints*this.execEvenlyMinDelayMs),setTimeout(n,e,a)}else n(a)}))}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);return new Promise((e=>{const i=this._getKeySecDuration(r),o=this._memoryStorage.incrby(n,t,i);o.remainingPoints=Math.max(this.points-o.consumedPoints,0),e(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);return new Promise((e=>{const i=this._getKeySecDuration(r),o=this._memoryStorage.incrby(n,-t,i);o.remainingPoints=Math.max(this.points-o.consumedPoints,0),e(o)}))}block(e,t){const r=1e3*t,n=this.points+1;return this._memoryStorage.set(this.getKey(e),n,t),Promise.resolve(new o(0,0===r?-1:r,n))}set(e,t,r){const n=1e3*(r>=0?r:this.duration);return this._memoryStorage.set(this.getKey(e),t,r),Promise.resolve(new o(0,0===n?-1:n,t))}get(e){const t=this._memoryStorage.get(this.getKey(e));return null!==t&&(t.remainingPoints=Math.max(this.points-t.consumedPoints,0)),Promise.resolve(t)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}}},619:(e,t,r)=>{const n=r(3384),i=r(5925);function o(e){try{const t=e.client?e.client:e,{version:r}=t.topology.s.options.metadata.driver,n=r.split(".").map((e=>parseInt(e)));return{major:n[0],feature:n[1],patch:n[2]}}catch(t){return{major:0,feature:0,patch:0}}}class s extends n{constructor(e){super(e),this.dbName=e.dbName,this.tableName=e.tableName,this.indexKeyPrefix=e.indexKeyPrefix,e.mongo?this.client=e.mongo:this.client=e.storeClient,"function"===typeof this.client.then?this.client.then((e=>{this.client=e,this._initCollection(),this._driverVersion=o(this.client)})):(this._initCollection(),this._driverVersion=o(this.client))}get dbName(){return this._dbName}set dbName(e){this._dbName="undefined"===typeof e?s.getDbName():e}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(e){this._tableName="undefined"===typeof e?this.keyPrefix:e}get client(){return this._client}set client(e){if("undefined"===typeof e)throw new Error("mongo is not set");this._client=e}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(e){this._indexKeyPrefix=e||{}}_initCollection(){const e=("function"===typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);e.createIndex({expire:-1},{expireAfterSeconds:0}),e.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=e}_getRateLimiterRes(e,t,r){const n=new i;let o;return o="undefined"===typeof r.value?r:r.value,n.isFirstInDuration=o.points===t,n.consumedPoints=o.points,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=null!==o.expire?Math.max(new Date(o.expire).getTime()-Date.now(),0):-1,n}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const o=i.attrs||{};let s,a;n?(s={key:e},s=Object.assign(s,o),a={$set:{key:e,points:t,expire:r>0?new Date(Date.now()+r):null}},a.$set=Object.assign(a.$set,o)):(s={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:e},s=Object.assign(s,o),a={$setOnInsert:{key:e,expire:r>0?new Date(Date.now()+r):null},$inc:{points:t}},a.$setOnInsert=Object.assign(a.$setOnInsert,o));const c={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?c.returnDocument="after":c.returnOriginal=!1,new Promise(((i,l)=>{this._collection.findOneAndUpdate(s,a,c).then((e=>{i(e)})).catch((s=>{if(s&&11e3===s.code){const s=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:e},o),a={$set:Object.assign({key:e,points:t,expire:r>0?new Date(Date.now()+r):null},o)};this._collection.findOneAndUpdate(s,a,c).then((e=>{i(e)})).catch((o=>{o&&11e3===o.code?this._upsert(e,t,r,n).then((e=>i(e))).catch((e=>l(e))):l(o)}))}else l(s)}))}))}_get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const r=t.attrs||{},n=Object.assign({key:e,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},r);return this._collection.findOne(n)}_delete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const r=t.attrs||{},n=Object.assign({key:e},r);return this._collection.deleteOne(n).then((e=>e.deletedCount>0))}}e.exports=s},3181:(e,t,r)=>{const n=r(3384),i=r(5925);e.exports=class extends n{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e),this.client=e.storeClient,this.clientType=e.storeType,this.dbName=e.dbName,this.tableName=e.tableName,this.clearExpiredByTimeout=e.clearExpiredByTimeout,this.tableCreated=e.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()):this._createDbAndTable().then((()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()})).catch((e=>{if("function"!==typeof t)throw e;t(e)}))}clearExpired(e){return new Promise((t=>{this._getConnection().then((r=>{r.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,e],(()=>{this._releaseConnection(r),t()}))})).catch((()=>{t()}))}))}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout((()=>{this.clearExpired(Date.now()-36e5).then((()=>{this._clearExpiredHourAgo()}))}),3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise(((e,t)=>{this.client.getConnection(((r,n)=>{if(r)return t(r);e(n)}))}));case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(e){switch(this.clientType){case"pool":return e.release();case"sequelize":return this.client.connectionManager.releaseConnection(e);case"knex":return this.client.client.releaseConnection(e);default:return!0}}_createDbAndTable(){return new Promise(((e,t)=>{this._getConnection().then((r=>{r.query("CREATE DATABASE IF NOT EXISTS `".concat(this.dbName,"`;"),(n=>{if(n)return this._releaseConnection(r),t(n);r.query(this._getCreateTableStmt(),(n=>{if(n)return this._releaseConnection(r),t(n);this._releaseConnection(r),e()}))}))})).catch((e=>{t(e)}))}))}_getCreateTableStmt(){return"CREATE TABLE IF NOT EXISTS `".concat(this.dbName,"`.`").concat(this.tableName,"` (")+"`key` VARCHAR(255) CHARACTER SET utf8 NOT NULL,`points` INT(9) NOT NULL default 0,`expire` BIGINT UNSIGNED,PRIMARY KEY (`key`)) ENGINE = INNODB;"}get clientType(){return this._clientType}set clientType(e){if("undefined"===typeof e)if("Connection"===this.client.constructor.name)e="connection";else if("Pool"===this.client.constructor.name)e="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");e="sequelize"}this._clientType=e.toLowerCase()}get dbName(){return this._dbName}set dbName(e){this._dbName="undefined"===typeof e?"rtlmtrflx":e}get tableName(){return this._tableName}set tableName(e){this._tableName="undefined"===typeof e?this.keyPrefix:e}get tableCreated(){return this._tableCreated}set tableCreated(e){this._tableCreated="undefined"!==typeof e&&!!e}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(e){this._clearExpiredByTimeout="undefined"===typeof e||Boolean(e)}_getRateLimiterRes(e,t,r){const n=new i,[o]=r;return n.isFirstInDuration=t===o.points,n.consumedPoints=n.isFirstInDuration?t:o.points,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=o.expire?Math.max(o.expire-Date.now(),0):-1,n}_upsertTransaction(e,t,r,n,i){return new Promise(((o,s)=>{e.query("BEGIN",(a=>{if(a)return e.rollback(),s(a);const c=Date.now(),l=n>0?c+n:null;let u,h;i?(u="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",h=[this.dbName,this.tableName,t,r,l,r,l]):(u="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",h=[this.dbName,this.tableName,t,r,l,c,r,r,c,l]),e.query(u,h,(r=>{if(r)return e.rollback(),s(r);e.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,t],((t,r)=>{if(t)return e.rollback(),s(t);e.query("COMMIT",(t=>{if(t)return e.rollback(),s(t);o(r)}))}))}))}))}))}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.tableCreated?new Promise(((i,o)=>{this._getConnection().then((s=>{this._upsertTransaction(s,e,t,r,n).then((e=>{i(e),this._releaseConnection(s)})).catch((e=>{o(e),this._releaseConnection(s)}))})).catch((e=>{o(e)}))})):Promise.reject(Error("Table is not created yet"))}_get(e){return this.tableCreated?new Promise(((t,r)=>{this._getConnection().then((n=>{n.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,e,Date.now()],((e,i)=>{e?r(e):0===i.length?t(null):t(i),this._releaseConnection(n)}))})).catch((e=>{r(e)}))})):Promise.reject(Error("Table is not created yet"))}_delete(e){return this.tableCreated?new Promise(((t,r)=>{this._getConnection().then((n=>{n.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,e],((e,i)=>{e?r(e):t(i.affectedRows>0),this._releaseConnection(n)}))})).catch((e=>{r(e)}))})):Promise.reject(Error("Table is not created yet"))}}},176:(e,t,r)=>{const n=r(3384),i=r(5925);e.exports=class extends n{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e),this.client=e.storeClient,this.clientType=e.storeType,this.tableName=e.tableName,this.schemaName=e.schemaName,this.clearExpiredByTimeout=e.clearExpiredByTimeout,this.tableCreated=e.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()):this._createTable().then((()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()})).catch((e=>{if("function"!==typeof t)throw e;t(e)}))}_getTableIdentifier(){return this.schemaName?'"'.concat(this.schemaName,'"."').concat(this.tableName,'"'):'"'.concat(this.tableName,'"')}clearExpired(e){return new Promise((t=>{const r={name:"rlflx-clear-expired",text:"DELETE FROM ".concat(this._getTableIdentifier()," WHERE expire < $1"),values:[e]};this._query(r).then((()=>{t()})).catch((()=>{t()}))}))}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout((()=>{this.clearExpired(Date.now()-36e5).then((()=>{this._clearExpiredHourAgo()}))}),3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(e){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(e);case"knex":return this.client.client.releaseConnection(e)}}_createTable(){return new Promise(((e,t)=>{this._query({text:this._getCreateTableStmt()}).then((()=>{e()})).catch((r=>{"23505"===r.code?e():t(r)}))}))}_getCreateTableStmt(){return"CREATE TABLE IF NOT EXISTS ".concat(this._getTableIdentifier()," (\n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );")}get clientType(){return this._clientType}set clientType(e){const t=this.client.constructor.name;if("undefined"===typeof e)if("Client"===t)e="client";else if("Pool"===t||"BoundPool"===t)e="pool";else{if("Sequelize"!==t)throw new Error("storeType is not defined");e="sequelize"}this._clientType=e.toLowerCase()}get tableName(){return this._tableName}set tableName(e){this._tableName="undefined"===typeof e?this.keyPrefix:e}get schemaName(){return this._schemaName}set schemaName(e){this._schemaName=e}get tableCreated(){return this._tableCreated}set tableCreated(e){this._tableCreated="undefined"!==typeof e&&!!e}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(e){this._clearExpiredByTimeout="undefined"===typeof e||Boolean(e)}_getRateLimiterRes(e,t,r){const n=new i,o=r.rows[0];return n.isFirstInDuration=t===o.points,n.consumedPoints=n.isFirstInDuration?t:o.points,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=o.expire?Math.max(o.expire-Date.now(),0):-1,n}_query(e){const t=this.tableName.toLowerCase(),r={name:"".concat(t,":").concat(e.name),text:e.text,values:e.values};return new Promise(((e,t)=>{this._getConnection().then((n=>{n.query(r).then((t=>{e(t),this._releaseConnection(n)})).catch((e=>{t(e),this._releaseConnection(n)}))})).catch((e=>{t(e)}))}))}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const i=r>0?Date.now()+r:null,o=n?" $3 ":" CASE\n WHEN ".concat(this._getTableIdentifier(),".expire <= $4 THEN $3\n ELSE ").concat(this._getTableIdentifier(),".expire\n END ");return this._query({name:n?"rlflx-upsert-force":"rlflx-upsert",text:"\n INSERT INTO ".concat(this._getTableIdentifier()," VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (").concat(this._getTableIdentifier(),".expire <= $4 OR 1=").concat(n?1:0,") THEN $2\n ELSE ").concat(this._getTableIdentifier(),".points + ($2)\n END,\n expire = ").concat(o,"\n RETURNING points, expire;"),values:[e,t,i,Date.now()]})}_get(e){return this.tableCreated?new Promise(((t,r)=>{this._query({name:"rlflx-get",text:"\n SELECT points, expire FROM ".concat(this._getTableIdentifier()," WHERE key = $1 AND (expire > $2 OR expire IS NULL);"),values:[e,Date.now()]}).then((e=>{0===e.rowCount&&(e=null),t(e)})).catch((e=>{r(e)}))})):Promise.reject(Error("Table is not created yet"))}_delete(e){return this.tableCreated?this._query({name:"rlflx-delete",text:"DELETE FROM ".concat(this._getTableIdentifier()," WHERE key = $1"),values:[e]}).then((e=>e.rowCount>0)):Promise.reject(Error("Table is not created yet"))}}},4120:(e,t,r)=>{const n=r(1168),i=4294967295,o="limiter";e.exports=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{maxQueueSize:i};this._queueLimiters={KEY_DEFAULT:new s(e,t)},this._limiterFlexible=e,this._maxQueueSize=t.maxQueueSize}getTokensRemaining(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o;return this._queueLimiters[e]?this._queueLimiters[e].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;return this._queueLimiters[t]||(this._queueLimiters[t]=new s(this._limiterFlexible,{key:t,maxQueueSize:this._maxQueueSize})),this._queueLimiters[t].removeTokens(e)}};class s{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{maxQueueSize:i,key:o};this._key=t.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=e,this._maxQueueSize=t.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then((e=>null!==e?e.remainingPoints:this._limiterFlexible.points))}removeTokens(e){const t=this;return new Promise(((r,i)=>{e>t._limiterFlexible.points?i(new n("Requested tokens ".concat(e," exceeds maximum ").concat(t._limiterFlexible.points," tokens per interval"))):t._queue.length>0?t._queueRequest.call(t,r,i,e):t._limiterFlexible.consume(t._key,e).then((e=>{r(e.remainingPoints)})).catch((n=>{n instanceof Error?i(n):(t._queueRequest.call(t,r,i,e),null===t._waitTimeout&&(t._waitTimeout=setTimeout(t._processFIFO.bind(t),n.msBeforeNext)))}))}))}_queueRequest(e,t,r){const i=this;i._queue.length<i._maxQueueSize?i._queue.push({resolve:e,reject:t,tokens:r}):t(new n("Number of requests reached it's maximum ".concat(i._maxQueueSize)))}_processFIFO(){const e=this;if(null!==e._waitTimeout&&(clearTimeout(e._waitTimeout),e._waitTimeout=null),0===e._queue.length)return;const t=e._queue.shift();e._limiterFlexible.consume(e._key,t.tokens).then((r=>{t.resolve(r.remainingPoints),e._processFIFO.call(e)})).catch((r=>{r instanceof Error?(t.reject(r),e._processFIFO.call(e)):(e._queue.unshift(t),null===e._waitTimeout&&(e._waitTimeout=setTimeout(e._processFIFO.bind(e),r.msBeforeNext)))}))}}},428:(e,t,r)=>{const n=r(3384),i=r(5925),o="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";e.exports=class extends n{constructor(e){super(e),this.client=e.storeClient,this._rejectIfRedisNotReady=!!e.rejectIfRedisNotReady,this.useRedisPackage=e.useRedisPackage||"Commander"===this.client.constructor.name||!1,this.useRedis3AndLowerPackage=e.useRedis3AndLowerPackage,"function"===typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:o})}_isRedisReady(){return!this._rejectIfRedisNotReady||(!this.client.status||"ready"===this.client.status)&&!("function"===typeof this.client.isReady&&!this.client.isReady())}_getRateLimiterRes(e,t,r){let[n,o]=r;Array.isArray(n)&&([,n]=n,[,o]=o);const s=new i;return s.consumedPoints=parseInt(n),s.isFirstInDuration=s.consumedPoints===t,s.remainingPoints=Math.max(this.points-s.consumedPoints,0),s.msBeforeNext=o,s}async _upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!this._isRedisReady())throw new Error("Redis connection is not ready");const i=Math.floor(r/1e3),s=this.client.multi();return n?(i>0?this.useRedisPackage||this.useRedis3AndLowerPackage?s.set(e,t,{EX:i}):s.set(e,t,"EX",i):s.set(e,t),this.useRedisPackage||this.useRedis3AndLowerPackage?s.pTTL(e).exec(!0):s.pttl(e).exec(!0)):i>0?this.useRedisPackage||this.useRedis3AndLowerPackage?this.useRedis3AndLowerPackage?new Promise(((r,n)=>{const s=function(e,t){return e?n(e):r(t)};"function"===typeof this.client.rlflxIncr?this.client.rlflxIncr(e,t,i,s):this.client.eval(o,1,e,t,i,s)})):this.client.eval(o,{keys:[e],arguments:[String(t),String(i)]}):this.client.rlflxIncr([e].concat([String(t),String(i)])):this.useRedisPackage||this.useRedis3AndLowerPackage?s.incrBy(e,t).pTTL(e).exec(!0):s.incrby(e,t).pttl(e).exec(!0)}async _get(e){if(!this._isRedisReady())throw new Error("Redis connection is not ready");return this.useRedisPackage||this.useRedis3AndLowerPackage?this.client.multi().get(e).pTTL(e).exec(!0).then((e=>{const[t]=e;return null===t?null:e})):this.client.multi().get(e).pttl(e).exec().then((e=>{const[[,t]]=e;return null===t?null:e}))}_delete(e){return this.client.del(e).then((e=>e>0))}}},5925:e=>{e.exports=class{constructor(e,t,r,n){this.remainingPoints="undefined"===typeof e?0:e,this.msBeforeNext="undefined"===typeof t?0:t,this.consumedPoints="undefined"===typeof r?0:r,this.isFirstInDuration="undefined"!==typeof n&&n}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(e){return this._msBeforeNext=e,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(e){return this._remainingPoints=e,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(e){return this._consumedPoints=e,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(e){this._isFirstInDuration=Boolean(e)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},3384:(e,t,r)=>{const n=r(8205),i=r(5754),o=r(5925);e.exports=class extends n{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.inMemoryBlockOnConsumed=e.inMemoryBlockOnConsumed,this.inMemoryBlockDuration=e.inMemoryBlockDuration,this.insuranceLimiter=e.insuranceLimiter,this._inMemoryBlockedKeys=new i}get client(){return this._client}set client(e){if("undefined"===typeof e)throw new Error("storeClient is not set");this._client=e}_afterConsume(e,t,r,n,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const s=this._getRateLimiterRes(r,n,i);if(this.inMemoryBlockOnConsumed>0&&!(this.inMemoryBlockDuration>0)&&s.consumedPoints>=this.inMemoryBlockOnConsumed)return this._inMemoryBlockedKeys.addMs(r,s.msBeforeNext),s.consumedPoints>this.points?t(s):e(s);if(s.consumedPoints>this.points){let e=Promise.resolve();this.blockDuration>0&&s.consumedPoints<=this.points+n&&(s.msBeforeNext=this.msBlockDuration,e=this._block(r,s.consumedPoints,this.msBlockDuration,o)),this.inMemoryBlockOnConsumed>0&&s.consumedPoints>=this.inMemoryBlockOnConsumed&&(this._inMemoryBlockedKeys.add(r,this.inMemoryBlockDuration),s.msBeforeNext=this.msInMemoryBlockDuration),e.then((()=>{t(s)})).catch((e=>{t(e)}))}else if(this.execEvenly&&s.msBeforeNext>0&&!s.isFirstInDuration){let t=Math.ceil(s.msBeforeNext/(s.remainingPoints+2));t<this.execEvenlyMinDelayMs&&(t=s.consumedPoints*this.execEvenlyMinDelayMs),setTimeout(e,t,s)}else e(s)}_handleError(e,t,r,i,o){let s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{};this.insuranceLimiter instanceof n?this.insuranceLimiter[t](o,s,a).then((e=>{r(e)})).catch((e=>{i(e)})):i(e)}getInMemoryBlockMsBeforeExpire(e){return this.inMemoryBlockOnConsumed>0?this._inMemoryBlockedKeys.msBeforeExpire(e):0}get inMemoryBlockOnConsumed(){return this._inMemoryBlockOnConsumed}set inMemoryBlockOnConsumed(e){if(this._inMemoryBlockOnConsumed=e?parseInt(e):0,this.inMemoryBlockOnConsumed>0&&this.points>this.inMemoryBlockOnConsumed)throw new Error('inMemoryBlockOnConsumed option must be greater or equal "points" option')}get inMemoryBlockDuration(){return this._inMemoryBlockDuration}set inMemoryBlockDuration(e){if(this._inMemoryBlockDuration=e?parseInt(e):0,this.inMemoryBlockDuration>0&&0===this.inMemoryBlockOnConsumed)throw new Error("inMemoryBlockOnConsumed option must be set up")}get msInMemoryBlockDuration(){return 1e3*this._inMemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(e){if("undefined"!==typeof e&&!(e instanceof n))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=e,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=1e3*t;return this._block(this.getKey(e),this.points+1,n,r)}set(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=1e3*(r>=0?r:this.duration);return this._block(this.getKey(e),t,i,n)}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const s=this.getKey(e),a=this.getInMemoryBlockMsBeforeExpire(s);if(a>0)return i(new o(0,a));this._upsert(s,t,1e3*this._getKeySecDuration(r),!1,r).then((e=>{this._afterConsume(n,i,s,t,e)})).catch((o=>{this._handleError(o,"consume",n,i,e,t,r)}))}))}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);return new Promise(((i,o)=>{this._upsert(n,t,1e3*this._getKeySecDuration(r),!1,r).then((e=>{i(this._getRateLimiterRes(n,t,e))})).catch((n=>{this._handleError(n,"penalty",i,o,e,t,r)}))}))}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);return new Promise(((i,o)=>{this._upsert(n,-t,1e3*this._getKeySecDuration(r),!1,r).then((e=>{i(this._getRateLimiterRes(n,-t,e))})).catch((n=>{this._handleError(n,"reward",i,o,e,t,r)}))}))}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=this.getKey(e);return new Promise(((n,i)=>{this._get(r,t).then((e=>{n(null===e||"undefined"===typeof e?null:this._getRateLimiterRes(r,0,e))})).catch((r=>{this._handleError(r,"get",n,i,e,t)}))}))}delete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=this.getKey(e);return new Promise(((n,i)=>{this._delete(r,t).then((e=>{this._inMemoryBlockedKeys.delete(r),n(e)})).catch((r=>{this._handleError(r,"delete",n,i,e,t)}))}))}deleteInMemoryBlockedAll(){this._inMemoryBlockedKeys.delete()}_getRateLimiterRes(e,t,r){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise(((i,s)=>{this._upsert(e,t,r,!0,n).then((()=>{i(new o(0,r>0?r:-1,t))})).catch((t=>{this._handleError(t,"block",i,s,this.parseKey(e),r/1e3,n)}))}))}_get(e){throw new Error("You have to implement the method '_get'!")}_delete(e){throw new Error("You have to implement the method '_delete'!")}_upsert(e,t,r){throw new Error("You have to implement the method '_upsert'!")}}},8400:(e,t,r)=>{const n=r(8205);e.exports=class{constructor(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(t.length<1)throw new Error("RateLimiterUnion: at least one limiter have to be passed");t.forEach((e=>{if(!(e instanceof n))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")})),this._limiters=t}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new Promise(((r,n)=>{const i=[];this._limiters.forEach((r=>{i.push(r.consume(e,t).catch((e=>({rejected:!0,rej:e}))))})),Promise.all(i).then((e=>{const t={};let i=!1;e.forEach((e=>{!0===e.rejected&&(i=!0)}));for(let r=0;r<e.length;r++)i&&!0===e[r].rejected?t[this._limiters[r].keyPrefix]=e[r].rej:i||(t[this._limiters[r].keyPrefix]=e[r]);i?n(t):r(t)}))}))}}},9822:e=>{e.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const e=Date.now();Object.keys(this._keys).forEach((t=>{this._keys[t]<=e&&delete this._keys[t]})),this._addedKeysAmount=Object.keys(this._keys).length}add(e,t){this.addMs(e,1e3*t)}addMs(e,t){this._keys[e]=Date.now()+t,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(e){const t=this._keys[e];if(t&&t>=Date.now()){this.collectExpired();const e=Date.now();return t>=e?t-e:0}return 0}delete(e){e?delete this._keys[e]:Object.keys(this._keys).forEach((e=>{delete this._keys[e]}))}}},5754:(e,t,r)=>{const n=r(9822);e.exports=n},1994:(e,t,r)=>{const n=r(1673),i=r(5925);e.exports=class{constructor(){this._storage={}}incrby(e,t,r){if(this._storage[e]){const n=this._storage[e].expiresAt?this._storage[e].expiresAt.getTime()-(new Date).getTime():-1;return!this._storage[e].expiresAt||n>0?(this._storage[e].value=this._storage[e].value+t,new i(0,n,this._storage[e].value,!1)):this.set(e,t,r)}return this.set(e,t,r)}set(e,t,r){const o=1e3*r;return this._storage[e]&&this._storage[e].timeoutId&&clearTimeout(this._storage[e].timeoutId),this._storage[e]=new n(t,o>0?new Date(Date.now()+o):null),o>0&&(this._storage[e].timeoutId=setTimeout((()=>{delete this._storage[e]}),o),this._storage[e].timeoutId.unref&&this._storage[e].timeoutId.unref()),new i(0,0===o?-1:o,this._storage[e].value,!0)}get(e){if(this._storage[e]){const t=this._storage[e].expiresAt?this._storage[e].expiresAt.getTime()-(new Date).getTime():-1;return new i(0,t,this._storage[e].value,!1)}return null}delete(e){return!!this._storage[e]&&(this._storage[e].timeoutId&&clearTimeout(this._storage[e].timeoutId),delete this._storage[e],!0)}}},1673:e=>{e.exports=class{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.value=e,this.expiresAt=t,this.timeoutId=r}get value(){return this._value}set value(e){this._value=parseInt(e)}get expiresAt(){return this._expiresAt}set expiresAt(e){e instanceof Date||!Number.isInteger(e)||(e=new Date(e)),this._expiresAt=e}get timeoutId(){return this._timeoutId}set timeoutId(e){this._timeoutId=e}}},1168:e=>{e.exports=class extends Error{constructor(e,t){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=e,t&&(this.extra=t)}}},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 l(e,t){u(e,t),u(e+"Capture",t)}function u(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 w(e){return e[1].toUpperCase()}function v(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,w);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,w);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,w);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,x=60108,k=60114,C=60109,I=60110,T=60112,P=60113,R=60120,D=60115,N=60116,B=60121,L=60128,U=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"),x=q("react.strict_mode"),k=q("react.profiler"),C=q("react.provider"),I=q("react.context"),T=q("react.forward_ref"),P=q("react.suspense"),R=q("react.suspense_list"),D=q("react.memo"),N=q("react.lazy"),B=q("react.block"),q("react.scope"),L=q("react.opaque.id"),U=q("react.debug_trace_mode"),M=q("react.offscreen"),O=q("react.legacy_hidden")}var z,F="function"===typeof Symbol&&Symbol.iterator;function K(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=F&&e[F]||e["@@iterator"])?e:null}function V(e){if(void 0===z)try{throw Error()}catch(r){var t=r.stack.trim().match(/\n( *(at )?)/);z=t&&t[1]||""}return"\n"+z+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:"")?V(e):""}function W(e){switch(e.tag){case 5:return V(e.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("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 G(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 k:return"Profiler";case x:return"StrictMode";case P:return"Suspense";case R:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case I:return(e.displayName||"Context")+".Consumer";case C: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 G(e.type);case B:return G(e._render);case N:t=e._payload,e=e._init;try{return G(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)&&v(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 le(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 ue(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},we=["Webkit","ms","Moz","O"];function ve(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=ve(r,t[r],n);"float"===r&&(r="cssFloat"),n?e.setProperty(r,i):e[r]=i}}Object.keys(me).forEach((function(e){we.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 xe(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var ke=null,Ce=null,Ie=null;function Te(e){if(e=ri(e)){if("function"!==typeof ke)throw Error(s(280));var t=e.stateNode;t&&(t=ii(t),ke(e.stateNode,e.type,t))}}function Pe(e){Ce?Ie?Ie.push(e):Ie=[e]:Ce=e}function Re(){if(Ce){var e=Ce,t=Ie;if(Ie=Ce=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 Le=De,Ue=!1,Me=!1;function Oe(){null===Ce&&null===Ie||(Be(),Re())}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 ze=!1;if(h)try{var Fe={};Object.defineProperty(Fe,"passive",{get:function(){ze=!0}}),window.addEventListener("test",Fe,Fe),window.removeEventListener("test",Fe,Fe)}catch(ge){ze=!1}function Ke(e,t,r,n,i,o,s,a,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(r,l)}catch(u){this.onError(u)}}var Ve=!1,je=null,He=!1,We=null,Ge={onError:function(e){Ve=!0,je=e}};function Ye(e,t,r,n,i,o,s,a,c){Ve=!1,je=null,Ke.apply(Ge,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,lt=new Map,ut=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":lt.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ut.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 wt(){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),lt.forEach(mt),ut.forEach(mt)}function vt(e,t){e.blockedOn===t&&(e.blockedOn=null,it||(it=!0,o.unstable_scheduleCallback(o.unstable_NormalPriority,wt)))}function _t(e){function t(t){return vt(t,e)}if(0<ot.length){vt(ot[0],e);for(var r=1;r<ot.length;r++){var n=ot[r];n.blockedOn===e&&(n.blockedOn=null)}}for(null!==st&&vt(st,e),null!==at&&vt(at,e),null!==ct&&vt(ct,e),lt.forEach(t),ut.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={},xt={};function kt(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 xt)return At[e]=r[t];return e}h&&(xt=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 Ct=kt("animationend"),It=kt("animationiteration"),Tt=kt("animationstart"),Pt=kt("transitionend"),Rt=new Map,Dt=new Map,Nt=["abort","abort",Ct,"animationEnd",It,"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",Pt,"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),Rt.set(n,i),l(i,[n])}}(0,o.unstable_now)();var Lt=8;function Ut(e){if(0!==(1&e))return Lt=15,1;if(0!==(2&e))return Lt=14,2;if(0!==(4&e))return Lt=13,4;var t=24&e;return 0!==t?(Lt=12,t):0!==(32&e)?(Lt=11,32):0!==(t=192&e)?(Lt=10,t):0!==(256&e)?(Lt=9,256):0!==(t=3584&e)?(Lt=8,t):0!==(4096&e)?(Lt=7,4096):0!==(t=4186112&e)?(Lt=6,t):0!==(t=62914560&e)?(Lt=5,t):67108864&e?(Lt=4,67108864):0!==(134217728&e)?(Lt=3,134217728):0!==(t=805306368&e)?(Lt=2,t):0!==(1073741824&e)?(Lt=1,1073741824):(Lt=8,e)}function Mt(e,t){var r=e.pendingLanes;if(0===r)return Lt=0;var n=0,i=0,o=e.expiredLanes,s=e.suspendedLanes,a=e.pingedLanes;if(0!==o)n=o,i=Lt=15;else if(0!==(o=134217727&r)){var c=o&~s;0!==c?(n=Ut(c),i=Lt):0!==(a&=o)&&(n=Ut(a),i=Lt)}else 0!==(o=r&~s)?(n=Ut(o),i=Lt):0!==a&&(n=Ut(a),i=Lt);if(0===n)return 0;if(n=r&((0>(n=31-Vt(n))?0:1<<n)<<1)-1,0!==t&&t!==n&&0===(t&s)){if(Ut(t),i<=Lt)return t;Lt=i}if(0!==(t=e.entangledLanes))for(e=e.entanglements,t&=n;0<t;)i=1<<(r=31-Vt(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=zt(24&~t))?qt(10,t):e;case 10:return 0===(e=zt(192&~t))?qt(8,t):e;case 8:return 0===(e=zt(3584&~t))&&(0===(e=zt(4186112&~t))&&(e=512)),e;case 2:return 0===(t=zt(805306368&~t))&&(t=268435456),t}throw Error(s(358,e))}function zt(e){return e&-e}function Ft(e){for(var t=[],r=0;31>r;r++)t.push(e);return t}function Kt(e,t,r){e.pendingLanes|=t;var n=t-1;e.suspendedLanes&=n,e.pingedLanes&=n,(e=e.eventTimes)[t=31-Vt(t)]=r}var Vt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-(jt(e)/Ht|0)|0},jt=Math.log,Ht=Math.LN2;var Wt=o.unstable_UserBlockingPriority,Gt=o.unstable_runWithPriority,Yt=!0;function Qt(e,t,r,n){Ue||Be();var i=Xt,o=Ue;Ue=!0;try{Ne(i,e,t,r,n)}finally{(Ue=o)||Oe()}}function Jt(e,t,r,n){Gt(Wt,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 lt.set(o,gt(lt.get(o)||null,e,t,r,n,i)),!0;case"gotpointercapture":return o=i.pointerId,ut.set(o,gt(ut.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=xe(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,lr,ur={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hr=sr(ur),dr=i({},ur,{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:kr,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!==lr&&(lr&&"mousemove"===e.type?(ar=e.screenX-lr.screenX,cr=e.screenY-lr.screenY):cr=ar=0,lr=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({},ur,{animationName:0,elapsedTime:0,pseudoElement:0})),wr=i({},ur,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),vr=sr(wr),_r=sr(i({},ur,{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 xr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function kr(){return xr}var Cr=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:kr,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}}),Ir=sr(Cr),Tr=sr(i({},pr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Pr=sr(i({},dr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kr})),Rr=sr(i({},ur,{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],Lr=h&&"CompositionEvent"in window,Ur=null;h&&"documentMode"in document&&(Ur=document.documentMode);var Mr=h&&"TextEvent"in window&&!Ur,Or=h&&(!Lr||Ur&&8<Ur&&11>=Ur),qr=String.fromCharCode(32),zr=!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 Kr(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var Vr=!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 Wr(e,t,r,n){Pe(n),0<(t=Un(t,"onChange")).length&&(r=new hr("onChange","change",null,r,n),e.push({event:r,listeners:t}))}var Gr=null,Yr=null;function Qr(e){In(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(){Gr&&(Gr.detachEvent("onpropertychange",nn),Yr=Gr=null)}function nn(e){if("value"===e.propertyName&&Jr(Yr)){var t=[];if(Wr(t,Yr,e,xe(e)),e=Qr,Ue)e(t);else{Ue=!0;try{De(e,t)}finally{Ue=!1,Oe()}}}}function on(e,t,r){"focusin"===e?(rn(),Yr=r,(Gr=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 ln="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t},un=Object.prototype.hasOwnProperty;function hn(e,t){if(ln(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(!un.call(t,r[n])||!ln(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,wn=null,vn=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},vn&&hn(vn,n)||(vn=n,0<(n=Un(wn,"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);u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),kn=new Set("cancel close invalid load scroll toggle".split(" ").concat(xn));function Cn(e,t,r){var n=e.type||"unknown-event";e.currentTarget=r,function(e,t,r,n,i,o,a,c,l){if(Ye.apply(this,arguments),Ve){if(!Ve)throw Error(s(198));var u=je;Ve=!1,je=null,He||(He=!0,We=u)}}(n,t,void 0,e),e.currentTarget=null}function In(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,l=a.currentTarget;if(a=a.listener,c!==o&&i.isPropagationStopped())break e;Cn(i,a,l),o=c}else for(s=0;s<n.length;s++){if(c=(a=n[s]).instance,l=a.currentTarget,a=a.listener,c!==o&&i.isPropagationStopped())break e;Cn(i,a,l),o=c}}}if(He)throw e=We,He=!1,We=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 Pn="_reactListening"+Math.random().toString(36).slice(2);function Rn(e){e[Pn]||(e[Pn]=!0,a.forEach((function(t){kn.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&&kn.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,!ze||"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 Le(e,t,r)}finally{Me=!1,Oe()}}((function(){var n=o,i=xe(r),s=[];e:{var a=Rt.get(e);if(void 0!==a){var c=hr,l=e;switch(e){case"keypress":if(0===nr(r))break e;case"keydown":case"keyup":c=Ir;break;case"focusin":l="focus",c=yr;break;case"focusout":l="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=Pr;break;case Ct:case It:case Tt:c=mr;break;case Pt:c=Rr;break;case"scroll":c=fr;break;case"wheel":c=Nr;break;case"copy":case"cut":case"paste":c=vr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Tr}var u=0!==(4&t),h=!u&&"scroll"===e,d=u?null!==a?a+"Capture":null:a;u=[];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))&&u.push(Ln(p,g,f)))),h)break;p=p.return}0<u.length&&(a=new c(a,l,null,r,i),s.push({event:a,listeners:u}))}}if(0===(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(a="mouseover"===e||"pointerover"===e)||0!==(16&t)||!(l=r.relatedTarget||r.fromElement)||!ti(l)&&!l[$n])&&(c||a)&&(a=i.window===i?i:(a=i.ownerDocument)?a.defaultView||a.parentWindow:window,c?(c=n,null!==(l=(l=r.relatedTarget||r.toElement)?ti(l):null)&&(l!==(h=Qe(l))||5!==l.tag&&6!==l.tag)&&(l=null)):(c=null,l=n),c!==l)){if(u=gr,g="onMouseLeave",d="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(u=Tr,g="onPointerLeave",d="onPointerEnter",p="pointer"),h=null==c?a:ni(c),f=null==l?a:ni(l),(a=new u(g,p+"leave",c,r,i)).target=h,a.relatedTarget=f,g=null,ti(i)===n&&((u=new u(d,p+"enter",l,r,i)).target=f,u.relatedTarget=h,g=u),h=g,c&&l)e:{for(d=l,p=0,f=u=c;f;f=Mn(f))p++;for(f=0,g=d;g;g=Mn(g))f++;for(;0<p-f;)u=Mn(u),p--;for(;0<f-p;)d=Mn(d),f--;for(;p--;){if(u===d||null!==d&&u===d.alternate)break e;u=Mn(u),d=Mn(d)}u=null}else u=null;null!==c&&On(s,a,c,u,!1),null!==l&&null!==h&&On(s,h,l,u,!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))?Wr(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,wn=n,vn=null);break;case"focusout":vn=wn=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(Lr)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Vr?Fr(e,r)&&(w="onCompositionEnd"):"keydown"===e&&229===r.keyCode&&(w="onCompositionStart");w&&(Or&&"ko"!==r.locale&&(Vr||"onCompositionStart"!==w?"onCompositionEnd"===w&&Vr&&(m=rr()):(er="value"in($t=i)?$t.value:$t.textContent,Vr=!0)),0<(y=Un(n,w)).length&&(w=new _r(w,e,null,r,i),s.push({event:w,listeners:y}),m?w.data=m:null!==(m=Kr(r))&&(w.data=m))),(m=Mr?function(e,t){switch(e){case"compositionend":return Kr(t);case"keypress":return 32!==t.which?null:(zr=!0,qr);case"textInput":return(e=t.data)===qr&&zr?null:e;default:return null}}(e,r):function(e,t){if(Vr)return"compositionend"===e||!Lr&&Fr(e,t)?(e=rr(),tr=er=$t=null,Vr=!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=Un(n,"onBeforeInput")).length&&(i=new _r("onBeforeInput","beforeinput",null,r,i),s.push({event:i,listeners:n}),i.data=m))}In(s,t)}))}function Ln(e,t,r){return{instance:e,listener:t,currentTarget:r}}function Un(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(Ln(e,o,i)),null!=(o=qe(e,t))&&n.push(Ln(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,l=a.stateNode;if(null!==c&&c===n)break;5===a.tag&&null!==l&&(a=l,i?null!=(c=qe(r,o))&&s.unshift(Ln(r,c,a)):i||null!=(c=qe(r,o))&&s.push(Ln(r,c,a))),r=r.return}0!==s.length&&e.push({event:t,listeners:s})}function qn(){}var zn=null,Fn=null;function Kn(e,t){switch(e){case"button":case"input":case"select":case"textarea":return!!t.autoFocus}return!1}function Vn(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 Wn(e){1===e.nodeType?e.textContent="":9===e.nodeType&&(null!=(e=e.body)&&(e.textContent=""))}function Gn(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 li(e){0>ai||(e.current=si[ai],si[ai]=null,ai--)}function ui(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(){li(fi),li(di)}function mi(e,t,r){if(di.current!==hi)throw Error(s(168));ui(di,t),ui(fi,r)}function wi(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,G(t)||"Unknown",o));return i({},r,n)}function vi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||hi,pi=di.current,ui(di,e),ui(fi,fi.current),!0}function _i(e,t,r){var n=e.stateNode;if(!n)throw Error(s(169));r?(e=wi(e,t,pi),n.__reactInternalMemoizedMergedChildContext=e,li(fi),li(di),ui(di,e)):li(fi),ui(fi,r)}var Ei=null,Si=null,Ai=o.unstable_runWithPriority,xi=o.unstable_scheduleCallback,ki=o.unstable_cancelCallback,Ci=o.unstable_shouldYield,Ii=o.unstable_requestPaint,Ti=o.unstable_now,Pi=o.unstable_getCurrentPriorityLevel,Ri=o.unstable_ImmediatePriority,Di=o.unstable_UserBlockingPriority,Ni=o.unstable_NormalPriority,Bi=o.unstable_LowPriority,Li=o.unstable_IdlePriority,Ui={},Mi=void 0!==Ii?Ii:function(){},Oi=null,qi=null,zi=!1,Fi=Ti(),Ki=1e4>Fi?Ti:function(){return Ti()-Fi};function Vi(){switch(Pi()){case Ri:return 99;case Di:return 98;case Ni:return 97;case Bi:return 96;case Li:return 95;default:throw Error(s(332))}}function ji(e){switch(e){case 99:return Ri;case 98:return Di;case 97:return Ni;case 96:return Bi;case 95:return Li;default:throw Error(s(332))}}function Hi(e,t){return e=ji(e),Ai(e,t)}function Wi(e,t,r){return e=ji(e),xi(e,t,r)}function Gi(){if(null!==qi){var e=qi;qi=null,ki(e)}Yi()}function Yi(){if(!zi&&null!==Oi){zi=!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)),xi(Ri,Gi),r}finally{zi=!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;li(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)&&(Us=!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 lo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function uo(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 l=c,u=l.next;l.next=null,null===a?s=u:a.next=u,a=l;var h=e.alternate;if(null!==h){var d=(h=h.updateQueue).lastBaseUpdate;d!==a&&(null===d?h.firstBaseUpdate=u:d.next=u,h.lastBaseUpdate=l)}}if(null!==s){for(d=o.baseState,a=0,h=u=l=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?(u=h=f,l=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&&(l=d),o.baseState=l,o.firstBaseUpdate=u,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=lo(n,i);o.payload=t,void 0!==r&&null!==r&&(o.callback=r),uo(e,o),pc(e,i,n)},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var n=dc(),i=fc(e),o=lo(n,i);o.tag=1,o.payload=t,void 0!==r&&null!==r&&(o.callback=r),uo(e,o),pc(e,i,n)},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=dc(),n=fc(e),i=lo(r,n);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),uo(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 wo(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 vo(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 xo(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=Wc(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 l(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=Gc(r.type,r.key,r.props,null,e.mode,n)).ref=So(e,t,r),n.return=e,n)}function u(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=Gc(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)||K(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):l(e,t,r,n):null;case S:return r.key===i?u(e,t,r,n):null}if(Eo(r)||K(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):l(t,e,n,i);case S:return u(t,e=e.get(null===n.key?r:n.key)||null,n,i)}if(Eo(n)||K(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 l=null,u=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===u?l=y:u.sibling=y,u=y,h=b}if(g===a.length)return r(i,h),l;if(null===h){for(;g<a.length;g++)null!==(h=d(i,a[g],c))&&(s=o(h,s,g),null===u?l=h:u.sibling=h,u=h);return l}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===u?l=b:u.sibling=b,u=b);return e&&h.forEach((function(e){return t(i,e)})),l}function b(i,a,c,l){var u=K(c);if("function"!==typeof u)throw Error(s(150));if(null==(c=u.call(c)))throw Error(s(151));for(var h=u=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 w=f(i,g,m.value,l);if(null===w){null===g&&(g=y);break}e&&g&&null===w.alternate&&t(i,g),a=o(w,a,b),null===h?u=w:h.sibling=w,h=w,g=y}if(m.done)return r(i,g),u;if(null===g){for(;!m.done;b++,m=c.next())null!==(m=d(i,m.value,l))&&(a=o(m,a,b),null===h?u=m:h.sibling=m,h=m);return u}for(g=n(i,g);!m.done;b++,m=c.next())null!==(m=p(g,i,b,m.value,l))&&(e&&null!==m.alternate&&g.delete(null===m.key?b:m.key),a=o(m,a,b),null===h?u=m:h.sibling=m,h=m);return e&&g.forEach((function(e){return t(i,e)})),u}return function(e,n,o,c){var l="object"===typeof o&&null!==o&&o.type===A&&null===o.key;l&&(o=o.props.children);var u="object"===typeof o&&null!==o;if(u)switch(o.$$typeof){case E:e:{for(u=o.key,l=n;null!==l;){if(l.key===u){if(7===l.tag){if(o.type===A){r(e,l.sibling),(n=i(l,o.props.children)).return=e,e=n;break e}}else if(l.elementType===o.type){r(e,l.sibling),(n=i(l,o.props)).ref=So(e,l,o),n.return=e,e=n;break e}r(e,l);break}t(e,l),l=l.sibling}o.type===A?((n=Yc(o.props.children,e.mode,c,o.key)).return=e,e=n):((c=Gc(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(l=o.key;null!==n;){if(n.key===l){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(K(o))return b(e,n,o,c);if(u&&Ao(e,o),"undefined"===typeof o&&!l)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error(s(152,G(e.type)||"Component"))}return r(e,n)}}var ko=xo(!0),Co=xo(!1),Io={},To=ci(Io),Po=ci(Io),Ro=ci(Io);function Do(e){if(e===Io)throw Error(s(174));return e}function No(e,t){switch(ui(Ro,t),ui(Po,e),ui(To,Io),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)}li(To),ui(To,t)}function Bo(){li(To),li(Po),li(Ro)}function Lo(e){Do(Ro.current);var t=Do(To.current),r=fe(t,e.type);t!==r&&(ui(Po,e),ui(To,r))}function Uo(e){Po.current===e&&(li(To),li(Po))}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,zo=null,Fo=!1;function Ko(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 Vo(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=zo;if(t){var r=t;if(!Vo(e,t)){if(!(t=Gn(r.nextSibling))||!Vo(e,t))return e.flags=-1025&e.flags|2,Fo=!1,void(qo=e);Ko(qo,r)}qo=e,zo=Gn(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 Wo(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&&!Vn(t,e.memoizedProps))for(t=zo;t;)Ko(e,t),t=Gn(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){zo=Gn(e.nextSibling);break e}t--}else"$"!==r&&"$!"!==r&&"$?"!==r||t++}e=e.nextSibling}zo=null}}else zo=qo?Gn(e.stateNode.nextSibling):null;return!0}function Go(){zo=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(!ln(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=Rs,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 ls(e,t){return"function"===typeof t?t(e):t}function us(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,l=i;do{var u=l.lane;if((Zo&u)===u)null!==c&&(c=c.next={lane:0,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null}),n=l.eagerReducer===e?l.eagerState:e(n,l.action);else{var h={lane:u,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null};null===c?(a=c=h,o=n):c=c.next=h,$o.lanes|=u,Fa|=u}l=l.next}while(null!==l&&l!==i);null===c?o=n:c.next=a,ln(n,t.memoizedState)||(Us=!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);ln(o,t.memoizedState)||(Us=!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,l=c.useState((function(){return ds(i,t,r)})),u=l[1],h=l[0];l=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=u;var e=o(t._source);if(!ln(a,e)){e=r(t._source),ln(h,e)||(u(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-Vt(s),l=1<<c;n[c]|=e,s&=~l}}}),[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]),ln(p,r)&&ln(g,t)&&ln(d,n)||((e={pending:null,dispatch:null,lastRenderedReducer:ls,lastRenderedState:h}).dispatch=u=Ps.bind(null,$o,e),l.queue=e,l.baseQueue=null,h=ds(i,t,r),l.memoizedState=l.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:ls,lastRenderedState:e}).dispatch=Ps.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 ws(e,t,r,n){var i=as();$o.flags|=e,i.memoizedState=bs(1|t,r,void 0,void 0===n?null:n)}function vs(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 ws(516,4,e,t)}function Es(e,t){return vs(516,4,e,t)}function Ss(e,t){return vs(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 xs(e,t,r){return r=null!==r&&void 0!==r?r.concat([e]):null,vs(4,2,As.bind(null,t,e),r)}function ks(){}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]:(r.memoizedState=[e,t],e)}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]:(e=e(),r.memoizedState=[e,t],e)}function Ts(e,t){var r=Vi();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 Ps(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,ln(c,a))return}catch(l){}pc(e,i,n)}}var Rs={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,ws(4,2,As.bind(null,t,e),r)},useLayoutEffect:function(e,t){return ws(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=Ps.bind(null,$o,e),[n.memoizedState,e]},useRef:ys,useState:gs,useDebugValue:ks,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:L,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:Cs,useContext:oo,useEffect:Es,useImperativeHandle:xs,useLayoutEffect:Ss,useMemo:Is,useReducer:us,useRef:ms,useState:function(){return us(ls)},useDebugValue:ks,useDeferredValue:function(e){var t=us(ls),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=us(ls)[0];return[ms().current,e]},useMutableSource:ps,useOpaqueIdentifier:function(){return us(ls)[0]},unstable_isNewReconciler:!1},Bs={readContext:oo,useCallback:Cs,useContext:oo,useEffect:Es,useImperativeHandle:xs,useLayoutEffect:Ss,useMemo:Is,useReducer:hs,useRef:ms,useState:function(){return hs(ls)},useDebugValue:ks,useDeferredValue:function(e){var t=hs(ls),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(ls)[0];return[ms().current,e]},useMutableSource:ps,useOpaqueIdentifier:function(){return hs(ls)[0]},unstable_isNewReconciler:!1},Ls=_.ReactCurrentOwner,Us=!1;function Ms(e,t,r,n){t.child=null===e?Co(t,null,r,n):ko(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||Us?(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=Gc(r.type,null,n,t,t.mode,o)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,zs(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=Wc(s,n)).ref=t.ref,e.return=t,t.child=e)}function zs(e,t,r,n,i,o){if(null!==e&&hn(e.memoizedProps,n)&&e.ref===t.ref){if(Us=!1,0===(o&i))return t.lanes=e.lanes,oa(e,t,o);0!==(16384&e.flags)&&(Us=!0)}return Vs(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 Ks(e,t){var r=t.ref;(null===e&&null!==r||null!==e&&e.ref!==r)&&(t.flags|=128)}function Vs(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||Us?(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;vi(t)}else o=!1;if(io(t,i),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),wo(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,l=r.contextType;"object"===typeof l&&null!==l?l=oo(l):l=gi(t,l=bi(r)?pi:di.current);var u=r.getDerivedStateFromProps,h="function"===typeof u||"function"===typeof s.getSnapshotBeforeUpdate;h||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(a!==n||c!==l)&&vo(t,s,n,l),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 u&&(bo(t,r,u,n),c=t.memoizedState),(a=so||mo(t,r,a,n,d,c,l))?(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=l,n=a):("function"===typeof s.componentDidMount&&(t.flags|=4),n=!1)}else{s=t.stateNode,co(e,t),a=t.memoizedProps,l=t.type===t.elementType?a:Ji(t.type,a),s.props=l,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;(u="function"===typeof f||"function"===typeof s.getSnapshotBeforeUpdate)||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(a!==h||d!==c)&&vo(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),(l=so||mo(t,r,l,n,d,p,c))?(u||"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=l):("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){Ks(e,t);var s=0!==(64&t.flags);if(!n&&!s)return i&&_i(t,r,!1),oa(e,t,o);n=t.stateNode,Ls.current=t;var a=s&&"function"!==typeof r.getDerivedStateFromError?null:n.render();return t.flags|=1,null!==e&&s?(t.child=ko(t,e.child,null,o),t.child=ko(t,null,a,o)):Ms(e,t,a,o),t.memoizedState=n.state,i&&_i(t,r,!0),t.child}function Ws(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 Gs,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),ui(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=Wc(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=Wc(s,a),null!==e?n=Wc(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(ui(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=Wc(e=t.child,e.pendingProps),t.child=r,r.return=t;null!==e.sibling;)e=e.sibling,(r=r.sibling=Wc(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(),li(fi),li(di),Qo(),(n=t.stateNode).pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(Wo(t)?t.flags|=4:n.hydrate||(t.flags|=256)),Ys(t),null;case 5:Uo(t);var o=Do(Ro.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),Wo(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<xn.length;e++)Tn(xn[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 l in Se(r,a),e=null,a)a.hasOwnProperty(l)&&(o=a[l],"children"===l?"string"===typeof o?n.textContent!==o&&(e=["children",o]):"number"===typeof o&&n.textContent!==""+o&&(e=["children",""+o]):c.hasOwnProperty(l)&&null!=o&&"onScroll"===l&&Tn("scroll",n));switch(r){case"input":J(n),ne(n,a,!0);break;case"textarea":J(n),ue(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(l=9===o.nodeType?o:o.ownerDocument,e===he.html&&(e=de(r)),e===he.html?"script"===r?((e=l.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"===typeof n.is?e=l.createElement(r,{is:n.is}):(e=l.createElement(r),"select"===r&&(l=e,n.multiple?l.multiple=!0:n.size&&(l.size=n.size))):e=l.createElementNS(e,r),e[Xn]=t,e[Zn]=n,Gs(e,t,!1,!1),t.stateNode=e,l=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<xn.length;o++)Tn(xn[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 u=o;for(a in u)if(u.hasOwnProperty(a)){var h=u[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&&v(e,a,h,l))}switch(r){case"input":J(e),ne(e,n,!1);break;case"textarea":J(e),ue(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)}Kn(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(Ro.current),Do(To.current),Wo(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 li(Mo),n=t.memoizedState,0!==(64&t.flags)?(t.lanes=r,t):(n=null!==n,r=!1,null===e?void 0!==t.memoizedProps.fallback&&Wo(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&Ka)||mc(Na,La))),(n||r)&&(t.flags|=4),null);case 4:return Bo(),Ys(t),null===e&&Rn(t.stateNode.containerInfo),null;case 10:return ro(t),null;case 19:if(li(Mo),null===(n=t.memoizedState))return null;if(a=0!==(64&t.flags),null===(l=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!==(l=Oo(e))){for(t.flags|=64,sa(n,!1),null!==(a=l.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===(l=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=l.childLanes,a.lanes=l.lanes,a.child=l.child,a.memoizedProps=l.memoizedProps,a.memoizedState=l.memoizedState,a.updateQueue=l.updateQueue,a.type=l.type,e=l.dependencies,a.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return ui(Mo,1&Mo.current|2),t.child}e=e.sibling}null!==n.tail&&Ki()>Wa&&(t.flags|=64,a=!0,sa(n,!1),t.lanes=33554432)}else{if(!a)if(null!==(e=Oo(l))){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&&!l.alternate&&!Fo)return null!==(t=t.lastEffect=n.lastEffect)&&(t.nextEffect=null),null}else 2*Ki()-n.renderingStartTime>Wa&&1073741824!==r&&(t.flags|=64,a=!0,sa(n,!1),t.lanes=33554432);n.isBackwards?(l.sibling=t.child,t.child=l):(null!==(r=n.last)?r.sibling=l:t.child=l,n.last=l)}return null!==n.tail?(r=n.tail,n.rendering=r,n.tail=r.sibling,n.lastEffect=t.lastEffect,n.renderingStartTime=Ki(),r.sibling=null,t=Mo.current,ui(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(),li(fi),li(di),Qo(),0!==(64&(t=e.flags)))throw Error(s(285));return e.flags=-4097&t|64,e;case 5:return Uo(e),null;case 13:return li(Mo),4096&(t=e.flags)?(e.flags=-4097&t|64,e):null;case 19:return li(Mo),null;case 4:return Bo(),null;case 10:return ro(e),null;case 23:case 24:return Sc(),null;default:return null}}function la(e,t){try{var r="",n=t;do{r+=W(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 ua(e,t){try{console.error(t.value)}catch(r){setTimeout((function(){throw r}))}}Gs=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 l=o[h];for(s in l)l.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 u=n[h];if(l=null!=o?o[h]:void 0,n.hasOwnProperty(h)&&u!==l&&(null!=u||null!=l))if("style"===h)if(l){for(s in l)!l.hasOwnProperty(s)||u&&u.hasOwnProperty(s)||(r||(r={}),r[s]="");for(s in u)u.hasOwnProperty(s)&&l[s]!==u[s]&&(r||(r={}),r[s]=u[s])}else r||(a||(a=[]),a.push(h,r)),r=u;else"dangerouslySetInnerHTML"===h?(u=u?u.__html:void 0,l=l?l.__html:void 0,null!=u&&l!==u&&(a=a||[]).push(h,u)):"children"===h?"string"!==typeof u&&"number"!==typeof u||(a=a||[]).push(h,""+u):"suppressContentEditableWarning"!==h&&"suppressHydrationWarning"!==h&&(c.hasOwnProperty(h)?(null!=u&&"onScroll"===h&&Tn("scroll",e),a||l===u||(a=[])):"object"===typeof u&&null!==u&&u.$$typeof===L?u.toString():(a=a||[]).push(h,u))}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=lo(-1,r)).tag=3,r.payload={element:null};var n=t.value;return r.callback=function(){Ja||(Ja=!0,Xa=n),ua(0,t)},r}function fa(e,t,r){(r=lo(-1,r)).tag=3;var n=e.type.getDerivedStateFromError;if("function"===typeof n){var i=t.value;r.payload=function(){return ua(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),ua(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){zc(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&&Wn(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),Uc(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&&Kn(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=ve("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 wa(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){zc(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){zc(t,o)}break;case 5:ga(t);break;case 4:xa(e,t)}}function va(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 xa(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,l=c;;)if(wa(a,l),null!==l.child&&4!==l.tag)l.child.return=l,l=l.child;else{if(l===c)break e;for(;null===l.sibling;){if(null===l.return||l.return===c)break e;l=l.return}l.sibling.return=l.return,l=l.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(wa(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 ka(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):v(r,a,c,t)}switch(e){case"input":re(r,n);break;case"textarea":le(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=Ki(),ma(t.child,!0)),void Ca(t);case 19:return void Ca(t);case 23:case 24:return void ma(t,null!==t.memoizedState)}throw Error(s(163))}function Ca(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=Kc.bind(null,e,t);r.has(t)||(r.add(t),t.then(n,n))}))}}function Ia(e,t){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(t=t.memoizedState)&&null===t.dehydrated)}var Ta=Math.ceil,Pa=_.ReactCurrentDispatcher,Ra=_.ReactCurrentOwner,Da=0,Na=null,Ba=null,La=0,Ua=0,Ma=ci(0),Oa=0,qa=null,za=0,Fa=0,Ka=0,Va=0,ja=null,Ha=0,Wa=1/0;function Ga(){Wa=Ki()+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,lc=0,uc=null,hc=!1;function dc(){return 0!==(48&Da)?Ki():-1!==ac?ac:ac=Ki()}function fc(e){if(0===(2&(e=e.mode)))return 1;if(0===(4&e))return 99===Vi()?1:2;if(0===cc&&(cc=za),0!==Qi.transition){0!==lc&&(lc=null!==ja?ja.pendingLanes:0),e=cc;var t=4186112&~lc;return 0===(t&=-t)&&(0===(t=(e=4186112&~e)&-e)&&(t=8192)),t}return e=Vi(),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;Kt(e,t,r),e===Na&&(Ka|=t,4===Oa&&mc(e,La));var n=Vi();1===t?0!==(8&Da)&&0===(48&Da)?wc(e):(bc(e,r),0===Da&&(Ga(),Gi())):(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-Vt(a),l=1<<c,u=o[c];if(-1===u){if(0===(l&n)||0!==(l&i)){u=t,Ut(l);var h=Lt;o[c]=10<=h?u+250:6<=h?u+5e3:-1}}else u<=t&&(e.expiredLanes|=l);a&=~l}if(n=Mt(e,e===Na?La:0),t=Lt,0===n)null!==r&&(r!==Ui&&ki(r),e.callbackNode=null,e.callbackPriority=0);else{if(null!==r){if(e.callbackPriority===t)return;r!==Ui&&ki(r)}15===t?(r=wc.bind(null,e),null===Oi?(Oi=[r],qi=xi(Ri,Yi)):Oi.push(r),r=Ui):14===t?r=Wi(99,wc.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=Wi(r,yc.bind(null,e))),e.callbackPriority=t,e.callbackNode=r}}function yc(e){if(ac=-1,lc=cc=0,0!==(48&Da))throw Error(s(327));var t=e.callbackNode;if(Lc()&&e.callbackNode!==t)return null;var r=Mt(e,e===Na?La:0);if(0===r)return null;var n=r,i=Da;Da|=16;var o=kc();for(Na===e&&La===n||(Ga(),Ac(e,n));;)try{Tc();break}catch(c){xc(e,c)}if(to(),Pa.current=o,Da=i,null!==Ba?n=0:(Na=null,La=0,n=Oa),0!==(za&Ka))Ac(e,0);else if(0!==n){if(2===n&&(Da|=64,e.hydrate&&(e.hydrate=!1,Wn(e.containerInfo)),0!==(r=Ot(e))&&(n=Cc(e,r))),1===n)throw t=qa,Ac(e,0),mc(e,r),bc(e,Ki()),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-Ki())){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-Vt(r);o=1<<a,(a=n[a])>i&&(i=a),r&=~o}if(r=i,10<(r=(120>(r=Ki()-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,Ki()),e.callbackNode===t?yc.bind(null,e):null}function mc(e,t){for(t&=~Va,t&=~Ka,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var r=31-Vt(t),n=1<<r;e[r]=-1,t&=~n}}function wc(e){if(0!==(48&Da))throw Error(s(327));if(Lc(),e===Na&&0!==(e.expiredLanes&La)){var t=La,r=Cc(e,t);0!==(za&Ka)&&(r=Cc(e,t=Mt(e,t)))}else r=Cc(e,t=Mt(e,0));if(0!==e.tag&&2===r&&(Da|=64,e.hydrate&&(e.hydrate=!1,Wn(e.containerInfo)),0!==(t=Ot(e))&&(r=Cc(e,t))),1===r)throw r=qa,Ac(e,0),mc(e,t),bc(e,Ki()),r;return e.finishedWork=e.current.alternate,e.finishedLanes=t,Dc(e),bc(e,Ki()),null}function vc(e,t){var r=Da;Da|=1;try{return e(t)}finally{0===(Da=r)&&(Ga(),Gi())}}function _c(e,t){var r=Da;Da&=-2,Da|=8;try{return e(t)}finally{0===(Da=r)&&(Ga(),Gi())}}function Ec(e,t){ui(Ma,Ua),Ua|=t,za|=t}function Sc(){Ua=Ma.current,li(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(),li(fi),li(di),Qo();break;case 5:Uo(n);break;case 4:Bo();break;case 13:case 19:li(Mo);break;case 10:ro(n);break;case 23:case 24:Sc()}r=r.return}Na=e,Ba=Wc(e.current,null),La=Ua=za=t,Oa=0,qa=null,Va=Ka=Fa=0}function xc(e,t){for(;;){var r=Ba;try{if(to(),Jo.current=Rs,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,Ra.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=La,a.flags|=2048,a.firstEffect=a.lastEffect=null,null!==c&&"object"===typeof c&&"function"===typeof c.then){var l=c;if(0===(2&a.mode)){var u=a.alternate;u?(a.updateQueue=u.updateQueue,a.memoizedState=u.memoizedState,a.lanes=u.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(l),d.updateQueue=y}else b.add(l);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=lo(-1,1);m.tag=2,uo(a,m)}a.lanes|=1;break e}c=void 0,a=t;var w=o.pingCache;if(null===w?(w=o.pingCache=new ha,c=new Set,w.set(l,c)):void 0===(c=w.get(l))&&(c=new Set,w.set(l,c)),!c.has(a)){c.add(a);var v=Fc.bind(null,o,l,a);l.then(v,v)}d.flags|=4096,d.lanes=t;break e}d=d.return}while(null!==d);c=Error((G(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=la(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)}Rc(r)}catch(S){t=S,Ba===r&&null!==r&&(Ba=r=r.return);continue}break}}function kc(){var e=Pa.current;return Pa.current=Rs,null===e?Rs:e}function Cc(e,t){var r=Da;Da|=16;var n=kc();for(Na===e&&La===t||Ac(e,t);;)try{Ic();break}catch(i){xc(e,i)}if(to(),Da=r,Pa.current=n,null!==Ba)throw Error(s(261));return Na=null,La=0,Oa}function Ic(){for(;null!==Ba;)Pc(Ba)}function Tc(){for(;null!==Ba&&!Ci();)Pc(Ba)}function Pc(e){var t=Ya(e.alternate,e,Ua);e.memoizedProps=e.pendingProps,null===t?Rc(e):Ba=t,Ra.current=null}function Rc(e){var t=e;do{var r=t.alternate;if(e=t.return,0===(2048&t.flags)){if(null!==(r=aa(r,t,Ua)))return void(Ba=r);if(24!==(r=t).tag&&23!==r.tag||null===r.memoizedState||0!==(1073741824&Ua)||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=Vi();return Hi(99,Nc.bind(null,e,t)),null}function Nc(e,t){do{Lc()}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 l=31-Vt(o),u=1<<l;i[l]=0,a[l]=-1,c[l]=-1,o&=~u}if(null!==ic&&0===(24&n)&&ic.has(e)&&ic.delete(e),e===Na&&(Ba=Na=null,La=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,Ra.current=null,zn=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,(u=c.getSelection&&c.getSelection())&&0!==u.rangeCount){c=u.anchorNode,o=u.anchorOffset,l=u.focusNode,u=u.focusOffset;try{c.nodeType,l.nodeType}catch(k){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!==l||0!==u&&3!==b.nodeType||(f=h+u),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===l&&++g===u&&(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,uc=null,hc=!1,Qa=n;do{try{Bc()}catch(k){if(null===Qa)throw Error(s(330));zc(Qa,k),Qa=Qa.nextEffect}}while(null!==Qa);uc=null,Qa=n;do{try{for(a=e;null!==Qa;){var w=Qa.flags;if(16&w&&ye(Qa.stateNode,""),128&w){var v=Qa.alternate;if(null!==v){var _=v.ref;null!==_&&("function"===typeof _?_(null):_.current=null)}}switch(1038&w){case 2:Ea(Qa),Qa.flags&=-3;break;case 6:Ea(Qa),Qa.flags&=-3,ka(Qa.alternate,Qa);break;case 1024:Qa.flags&=-1025;break;case 1028:Qa.flags&=-1025,ka(Qa.alternate,Qa);break;case 4:ka(Qa.alternate,Qa);break;case 8:xa(a,c=Qa);var E=c.alternate;va(c),null!==E&&va(E)}Qa=Qa.nextEffect}}catch(k){if(null===Qa)throw Error(s(330));zc(Qa,k),Qa=Qa.nextEffect}}while(null!==Qa);if(_=Fn,v=gn(),w=_.focusedElem,a=_.selectionRange,v!==w&&w&&w.ownerDocument&&pn(w.ownerDocument.documentElement,w)){null!==a&&bn(w)&&(v=a.start,void 0===(_=a.end)&&(_=v),"selectionStart"in w?(w.selectionStart=v,w.selectionEnd=Math.min(_,w.value.length)):(_=(v=w.ownerDocument||document)&&v.defaultView||window).getSelection&&(_=_.getSelection(),c=w.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(w,E),o=fn(w,a),c&&o&&(1!==_.rangeCount||_.anchorNode!==c.node||_.anchorOffset!==c.offset||_.focusNode!==o.node||_.focusOffset!==o.offset)&&((v=v.createRange()).setStart(c.node,c.offset),_.removeAllRanges(),E>a?(_.addRange(v),_.extend(o.node,o.offset)):(v.setEnd(o.node,o.offset),_.addRange(v))))),v=[];for(_=w;_=_.parentNode;)1===_.nodeType&&v.push({element:_,left:_.scrollLeft,top:_.scrollTop});for("function"===typeof w.focus&&w.focus(),w=0;w<v.length;w++)(_=v[w]).element.scrollLeft=_.left,_.element.scrollTop=_.top}Yt=!!zn,Fn=zn=null,e.current=r,Qa=n;do{try{for(w=e;null!==Qa;){var S=Qa.flags;if(36&S&&ya(w,Qa.alternate,Qa),128&S){v=void 0;var A=Qa.ref;if(null!==A){var x=Qa.stateNode;Qa.tag,v=x,"function"===typeof A?A(v):A.current=v}}Qa=Qa.nextEffect}}catch(k){if(null===Qa)throw Error(s(330));zc(Qa,k),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(k){}if(bc(e,Ki()),Ja)throw Ja=!1,e=Xa,Xa=null,e;return 0!==(8&Da)||Gi(),null}function Bc(){for(;null!==Qa;){var e=Qa.alternate;hc||null===uc||(0!==(8&Qa.flags)?$e(Qa,uc)&&(hc=!0):13===Qa.tag&&Ia(e,Qa)&&$e(Qa,uc)&&(hc=!0));var t=Qa.flags;0!==(256&t)&&ba(e,Qa),0===(512&t)||$a||($a=!0,Wi(97,(function(){return Lc(),null}))),Qa=Qa.nextEffect}}function Lc(){if(90!==tc){var e=97<tc?97:tc;return tc=90,Hi(e,Oc)}return!1}function Uc(e,t){rc.push(t,e),$a||($a=!0,Wi(97,(function(){return Lc(),null})))}function Mc(e,t){nc.push(t,e),$a||($a=!0,Wi(97,(function(){return Lc(),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(l){if(null===o)throw Error(s(330));zc(o,l)}}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(l){if(null===o)throw Error(s(330));zc(o,l)}}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,Gi(),!0}function qc(e,t,r){uo(e,t=da(0,t=la(r,t),1)),t=dc(),null!==(e=gc(e,1))&&(Kt(e,1,t),bc(e,t))}function zc(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=la(t,e),1);if(uo(r,i),i=dc(),null!==(r=gc(r,1)))Kt(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&&(La&r)===r&&(4===Oa||3===Oa&&(62914560&La)===La&&500>Ki()-Ha?Ac(e,0):Va|=r),bc(e,t)}function Kc(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===Vi()?1:2:(0===cc&&(cc=za),0===(t=zt(62914560&~cc))&&(t=4194304))),r=dc(),null!==(e=gc(e,t))&&(Kt(e,t,r),bc(e,r))}function Vc(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 Vc(e,t,r,n)}function Hc(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Wc(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 Gc(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 U:a=8,i|=16;break;case x:a=8,i|=1;break;case k:return(e=jc(12,r,t,8|i)).elementType=k,e.type=k,e.lanes=o,e;case P:return(e=jc(13,r,t,i)).type=P,e.elementType=P,e.lanes=o,e;case R:return(e=jc(19,r,t,i)).elementType=R,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 C:a=10;break e;case I: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 l=r.type;if(bi(l)){r=wi(r,l,c);break e}}r=c}else r=hi;return null===t.context?t.context=r:t.pendingContext=r,(t=lo(o,a)).payload={element:e},null!==(n=void 0===n?null:n)&&(t.callback=n),uo(i,t),pc(i,a,o),a}function el(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function tl(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var r=e.retryLane;e.retryLane=0!==r&&r<t?r:t}}function rl(e,t){tl(e,t),(e=e.alternate)&&tl(e,t)}function nl(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,Rn(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 il(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function ol(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=el(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 nl(e,0,t?{hydrate:!0}:void 0)}(r,n),s=o._internalRoot,"function"===typeof i){var c=i;i=function(){var e=el(s);c.call(e)}}_c((function(){$c(t,s,e,i)}))}return el(s)}function sl(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!il(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)Us=!0;else{if(0===(r&n)){switch(Us=!1,t.tag){case 3:Ws(t),Go();break;case 5:Lo(t);break;case 1:bi(t.type)&&vi(t);break;case 4:No(t,t.stateNode.containerInfo);break;case 10:n=t.memoizedProps.value;var i=t.type._context;ui(Xi,i._currentValue),i._currentValue=n;break;case 13:if(null!==t.memoizedState)return 0!==(r&t.child.childLanes)?Zs(e,t,r):(ui(Mo,1&Mo.current),null!==(t=oa(e,t,r))?t.sibling:null);ui(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),ui(Mo,Mo.current),n)break;return null;case 23:case 24:return t.lanes=0,Fs(e,t,r)}return oa(e,t,r)}Us=0!==(16384&e.flags)}else Us=!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;vi(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=Vs(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,Vs(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(Ws(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)Go(),t=oa(e,t,r);else{if((o=(i=t.stateNode).hydrate)&&(zo=Gn(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=Co(t,null,n,r),t.child=r;r;)r.flags=-3&r.flags|1024,r=r.sibling}else Ms(e,t,n,r),Go();t=t.child}return t;case 5:return Lo(t),null===e&&jo(t),n=t.type,i=t.pendingProps,o=null!==e?e.memoizedProps:null,a=i.children,Vn(n,i)?a=null:null!==o&&Vn(n,o)&&(t.flags|=16),Ks(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=ko(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(ui(Xi,c._currentValue),c._currentValue=o,null!==a)if(c=a.value,0===(o=ln(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 l=c.dependencies;if(null!==l){a=c.child;for(var u=l.firstContext;null!==u;){if(u.context===n&&0!==(u.observedBits&o)){1===c.tag&&((u=lo(-1,r&-r)).tag=2,uo(c,u)),c.lanes|=r,null!==(u=c.alternate)&&(u.lanes|=r),no(c.return,r),l.lanes|=r;break}u=u.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 zs(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,vi(t)):e=!1,io(t,r),wo(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))},nl.prototype.render=function(e){$c(e,this._internalRoot,null,null)},nl.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()),rl(e,4))},tt=function(e){13===e.tag&&(pc(e,67108864,dc()),rl(e,67108864))},rt=function(e){if(13===e.tag){var t=dc(),r=fc(e);pc(e,r,t),rl(e,r)}},nt=function(e,t){return t()},ke=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":le(e,r);break;case"select":null!=(t=r.value)&&se(e,!!r.multiple,t,!1)}},De=vc,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)&&(Ga(),Gi())}},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,Ki())}))}Gi()}(),Lc())},Le=function(e,t){var r=Da;Da|=2;try{return e(t)}finally{0===(Da=r)&&(Ga(),Gi())}};var al={Events:[ri,ni,ii,Pe,Re,Lc,{current:!1}]},cl={findFiberByHostInstance:ti,bundleType:0,version:"17.0.2",rendererPackageName:"react-dom"},ll={bundleType:cl.bundleType,version:cl.version,rendererPackageName:cl.rendererPackageName,rendererConfig:cl.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:cl.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var ul=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ul.isDisabled&&ul.supportsFiber)try{Ei=ul.inject(ll),Si=ul}catch(ge){}}t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=al,t.createPortal=sl,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,Gi()}},t.hydrate=function(e,t,r){if(!il(t))throw Error(s(200));return ol(null,e,t,!0,r)},t.render=function(e,t,r){if(!il(t))throw Error(s(200));return ol(null,e,t,!1,r)},t.unmountComponentAtNode=function(e){if(!il(e))throw Error(s(40));return!!e._reactRootContainer&&(_c((function(){ol(null,null,e,!1,(function(){e._reactRootContainer=null,e[$n]=null}))})),!0)},t.unstable_batchedUpdates=vc,t.unstable_createPortal=function(e,t){return sl(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},t.unstable_renderSubtreeIntoContainer=function(e,t,r,n){if(!il(r))throw Error(s(200));if(null==e||void 0===e._reactInternals)throw Error(s(38));return ol(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 l(e,t,r){var n,o={},l=null,u=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(u=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:l,ref:u,props:o,_owner:s.current}}t.jsx=l,t.jsxs=l},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 l=60115,u=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"),l=h("react.memo"),u=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 w=m.prototype=new y;w.constructor=m,n(w,b.prototype),w.isPureReactComponent=!0;var v={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 l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];o.children=l}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:v.current}}function A(e){return"object"===typeof e&&null!==e&&e.$$typeof===i}var x=/\/+/g;function k(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 C(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?"."+k(c,0):n,Array.isArray(s)?(r="",null!=e&&(r=e.replace(x,"$&/")+"/"),C(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(x,"$&/")+"/")+e)),t.push(s)),1;if(c=0,n=""===n?".":n+":",Array.isArray(e))for(var l=0;l<e.length;l++){var u=n+k(a=e[l],l);c+=C(a,t,r,u,s)}else if(u=function(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=d&&e[d]||e["@@iterator"])?e:null}(e),"function"===typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=C(a=a.value,t,r,u=n+k(a,l++),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 I(e,t,r){if(null==e)return e;var n=[],i=0;return C(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 P={current:null};function R(){var e=P.current;if(null===e)throw Error(f(321));return e}var D={ReactCurrentDispatcher:P,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:v,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:I,forEach:function(e,t,r){I(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return I(e,(function(){t++})),t},toArray:function(e){return I(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=v.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(u in t)_.call(t,u)&&!E.hasOwnProperty(u)&&(o[u]=void 0===t[u]&&void 0!==l?l[u]:t[u])}var u=arguments.length-2;if(1===u)o.children=r;else if(1<u){l=Array(u);for(var h=0;h<u;h++)l[h]=arguments[h+2];o.children=l}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:u,_payload:{_status:-1,_result:e},_init:T}},t.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return R().useCallback(e,t)},t.useContext=function(e,t){return R().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return R().useEffect(e,t)},t.useImperativeHandle=function(e,t,r){return R().useImperativeHandle(e,t,r)},t.useLayoutEffect=function(e,t){return R().useLayoutEffect(e,t)},t.useMemo=function(e,t){return R().useMemo(e,t)},t.useReducer=function(e,t,r){return R().useReducer(e,t,r)},t.useRef=function(e){return R().useRef(e)},t.useState=function(e){return R().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)},8846:(e,t,r)=>{"use strict";e.exports=s;var n=r(7340),i=s.prototype,o=new Date%1e9;function s(e){e=e||{},this.id=e.id||(1e9*Math.random()>>>0)+o++,this.max=e.max||1/0,this.items=e.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(e.lastModified||new Date);for(var t,r,n=this.items.length;n--;)t=this.items[n],r=new Date(t.expires)-new Date,this._lookup[t.key]=t,r>0?this.expire(t.key,r):r<=0&&this.delete(t.key)}i.has=function(e){return e in this._lookup},i.get=function(e){if(!this.has(e))return null;var t=this._lookup[e];return t.refresh&&this.expire(e,t.refresh),this.items.splice(this.items.indexOf(t),1),this.items.push(t),t.value},i.meta=function(e){if(!this.has(e))return null;var t=this._lookup[e];return"meta"in t?t.meta:null},i.set=function(e,t,r){var n=this._lookup[e],i=this._lookup[e]={key:e,value:t};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,i)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(i),this.size++),r&&("ttl"in r&&this.expire(e,r.ttl),"meta"in r&&(i.meta=r.meta),r.refresh&&(i.refresh=r.ttl)),this},i.delete=function(e){var t=this._lookup[e];return!!t&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(t),1),clearTimeout(t.timeout),delete this._lookup[e],this.size--,this)},i.expire=function(e,t){var r=t||0,i=this._lookup[e];if(!i)return this;if("string"===typeof r&&(r=n(t)),"number"!==typeof r)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(i.timeout),i.timeout=setTimeout(this.delete.bind(this,i.key),r),i.expires=Number(new Date)+r,this},i.clear=function(){for(var e=this.items.length;e--;)this.delete(this.items[e].key);return this},i.toJSON=function(){for(var e,t=new Array(this.items.length),r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}},1287:(e,t,r)=>{"use strict";var n=r(3688),i=/[\/\?<>\\:\*\|"]/g,o=/[\x00-\x1f\x80-\x9f]/g,s=/^\.+$/,a=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,c=/[\. ]+$/;function l(e,t){if("string"!==typeof e)throw new Error("Input must be string");var r=e.replace(i,t).replace(o,t).replace(s,t).replace(a,t).replace(c,t);return n(r,255)}e.exports=function(e,t){var r=t&&t.replacement||"",n=l(e,r);return""===r?n:l(n,"")}},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 l=null,u=null,h=function(){if(null!==l)try{var e=t.unstable_now();l(!0,e),l=null}catch(r){throw setTimeout(h,0),r}};r=function(e){null!==l?setTimeout(r,0,e):(l=e,setTimeout(h,0))},n=function(e,t){u=setTimeout(e,t)},i=function(){clearTimeout(u)},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,w=0;t.unstable_shouldYield=function(){return t.unstable_now()>=w},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 v=new MessageChannel,_=v.port2;v.port1.onmessage=function(){if(null!==b){var e=t.unstable_now();w=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<x(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>x(s,r))void 0!==c&&0>x(c,s)?(e[n]=c,e[a]=r,n=a):(e[n]=s,e[o]=r,n=o);else{if(!(void 0!==c&&0>x(c,r)))break e;e[n]=c,e[a]=r,n=a}}}return t}return null}function x(e,t){var r=e.sortIndex-t.sortIndex;return 0!==r?r:e.id-t.id}var k=[],C=[],I=1,T=null,P=3,R=!1,D=!1,N=!1;function B(e){for(var t=S(C);null!==t;){if(null===t.callback)A(C);else{if(!(t.startTime<=e))break;A(C),t.sortIndex=t.expirationTime,E(k,t)}t=S(C)}}function L(e){if(N=!1,B(e),!D)if(null!==S(k))D=!0,r(U);else{var t=S(C);null!==t&&n(L,t.startTime-e)}}function U(e,r){D=!1,N&&(N=!1,i()),R=!0;var o=P;try{for(B(r),T=S(k);null!==T&&(!(T.expirationTime>r)||e&&!t.unstable_shouldYield());){var s=T.callback;if("function"===typeof s){T.callback=null,P=T.priorityLevel;var a=s(T.expirationTime<=r);r=t.unstable_now(),"function"===typeof a?T.callback=a:T===S(k)&&A(k),B(r)}else A(k);T=S(k)}if(null!==T)var c=!0;else{var l=S(C);null!==l&&n(L,l.startTime-r),c=!1}return c}finally{T=null,P=o,R=!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||R||(D=!0,r(U))},t.unstable_getCurrentPriorityLevel=function(){return P},t.unstable_getFirstCallbackNode=function(){return S(k)},t.unstable_next=function(e){switch(P){case 1:case 2:case 3:var t=3;break;default:t=P}var r=P;P=t;try{return e()}finally{P=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=P;P=e;try{return t()}finally{P=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:I++,callback:o,priorityLevel:e,startTime:s,expirationTime:c=s+c,sortIndex:-1},s>a?(e.sortIndex=s,E(C,e),null===S(k)&&e===S(C)&&(N?i():N=!0,n(L,s-a))):(e.sortIndex=c,E(k,e),D||R||(D=!0,r(U))),e},t.unstable_wrapCallback=function(e){var t=P;return function(){var r=P;P=t;try{return e.apply(this,arguments)}finally{P=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}})},3688:(e,t,r)=>{"use strict";var n=r(3748),i=r(6651);e.exports=n.bind(null,i)},3748:e=>{"use strict";function t(e){return e>=55296&&e<=56319}function r(e){return e>=56320&&e<=57343}e.exports=function(e,n,i){if("string"!==typeof n)throw new Error("Input must be string");for(var o,s,a=n.length,c=0,l=0;l<a;l+=1){if(o=n.charCodeAt(l),s=n[l],t(o)&&r(n.charCodeAt(l+1))&&(s+=n[l+=1]),(c+=e(s))===i)return n.slice(0,l+1);if(c>i)return n.slice(0,l-s.length+1)}return n}},6651:e=>{"use strict";function t(e){return e>=55296&&e<=56319}function r(e){return e>=56320&&e<=57343}e.exports=function(e){if("string"!==typeof e)throw new Error("Input must be string");for(var n=e.length,i=0,o=null,s=null,a=0;a<n;a++)r(o=e.charCodeAt(a))?null!=s&&t(s)?i+=1:i+=3:o<=127?i+=1:o>=128&&o<=2047?i+=2:o>=2048&&o<=65535&&(i+=3),s=o;return i}},1170:e=>{e.exports=function e(n,i){var o,s=0,a=0,c=i=i||0,l=n.length;do{if(c>=l||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),l=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<l?9:10}},9122:()=>{},495:()=>{},310:()=>{},4658:()=>{},7287:()=>{}},__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})},__webpack_require__.p="/web-chat/";var __webpack_exports__={};(()=>{"use strict";var e={};__webpack_require__.r(e),__webpack_require__.d(e,{base58btc:()=>mo,base58flickr:()=>wo});var t={};__webpack_require__.r(t),__webpack_require__.d(t,{base32:()=>vo,base32hex:()=>Ao,base32hexpad:()=>ko,base32hexpadupper:()=>Co,base32hexupper:()=>xo,base32pad:()=>Eo,base32padupper:()=>So,base32upper:()=>_o,base32z:()=>Io});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{base10:()=>_s});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{base16:()=>Es,base16upper:()=>Ss});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{base2:()=>As});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{base256emoji:()=>Is});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{base32:()=>Ts,base32hex:()=>Ns,base32hexpad:()=>Ls,base32hexpadupper:()=>Us,base32hexupper:()=>Bs,base32pad:()=>Rs,base32padupper:()=>Ds,base32upper:()=>Ps,base32z:()=>Ms});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{base36:()=>Os,base36upper:()=>qs});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{base58btc:()=>zs,base58flickr:()=>Fs});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{base64:()=>Ks,base64pad:()=>Vs,base64url:()=>js,base64urlpad:()=>Hs});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{base8:()=>Ws});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{identity:()=>Gs});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{code:()=>Xs,decode:()=>$s,encode:()=>Zs,name:()=>Js});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{code:()=>ta,decode:()=>na,encode:()=>ra,name:()=>ea});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{identity:()=>ka});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{sha256:()=>Pa,sha512:()=>Ra});var b={};__webpack_require__.r(b),__webpack_require__.d(b,{base10:()=>Wa});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{base16:()=>Ga,base16upper:()=>Ya});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{base2:()=>Qa});var w={};__webpack_require__.r(w),__webpack_require__.d(w,{base256emoji:()=>$a});var v={};__webpack_require__.r(v),__webpack_require__.d(v,{base36:()=>ec,base36upper:()=>tc});var _={};__webpack_require__.r(_),__webpack_require__.d(_,{base64:()=>rc,base64pad:()=>nc,base64url:()=>ic,base64urlpad:()=>oc});var E={};__webpack_require__.r(E),__webpack_require__.d(E,{base8:()=>sc});var S={};__webpack_require__.r(S),__webpack_require__.d(S,{identity:()=>ac});var A={};__webpack_require__.r(A),__webpack_require__.d(A,{code:()=>hc,decode:()=>fc,encode:()=>dc,name:()=>uc});var x={};__webpack_require__.r(x),__webpack_require__.d(x,{code:()=>gc,decode:()=>yc,encode:()=>bc,name:()=>pc});var k={};__webpack_require__.r(k),__webpack_require__.d(k,{identity:()=>wc});var C={};__webpack_require__.r(C),__webpack_require__.d(C,{sha256:()=>Sc,sha512:()=>Ac});var I={};__webpack_require__.r(I),__webpack_require__.d(I,{base10:()=>pu});var T={};__webpack_require__.r(T),__webpack_require__.d(T,{base16:()=>gu,base16upper:()=>bu});var P={};__webpack_require__.r(P),__webpack_require__.d(P,{base2:()=>yu});var R={};__webpack_require__.r(R),__webpack_require__.d(R,{base256emoji:()=>_u});var D={};__webpack_require__.r(D),__webpack_require__.d(D,{base32:()=>Eu,base32hex:()=>ku,base32hexpad:()=>Iu,base32hexpadupper:()=>Tu,base32hexupper:()=>Cu,base32pad:()=>Au,base32padupper:()=>xu,base32upper:()=>Su,base32z:()=>Pu});var N={};__webpack_require__.r(N),__webpack_require__.d(N,{base36:()=>Ru,base36upper:()=>Du});var B={};__webpack_require__.r(B),__webpack_require__.d(B,{base58btc:()=>Nu,base58flickr:()=>Bu});var L={};__webpack_require__.r(L),__webpack_require__.d(L,{base64:()=>Lu,base64pad:()=>Uu,base64url:()=>Mu,base64urlpad:()=>Ou});var U={};__webpack_require__.r(U),__webpack_require__.d(U,{base8:()=>qu});var M={};__webpack_require__.r(M),__webpack_require__.d(M,{identity:()=>zu});var O={};__webpack_require__.r(O),__webpack_require__.d(O,{code:()=>ju,decode:()=>Wu,encode:()=>Hu,name:()=>Vu});var q={};__webpack_require__.r(q),__webpack_require__.d(q,{code:()=>Yu,decode:()=>Ju,encode:()=>Qu,name:()=>Gu});var z={};__webpack_require__.r(z),__webpack_require__.d(z,{identity:()=>wh});var F={};__webpack_require__.r(F),__webpack_require__.d(F,{sha256:()=>Sh,sha512:()=>Ah});var K={};__webpack_require__.r(K),__webpack_require__.d(K,{DO:()=>Bg,OG:()=>Gg,My:()=>Ug,bytesToNumberBE:()=>Fg,lX:()=>Kg,Id:()=>Wg,fg:()=>Jg,qj:()=>Hg,hexToBytes:()=>zg,aY:()=>Ng,lq:()=>Vg,z:()=>jg,Q5:()=>Zg});var V={};__webpack_require__.r(V),__webpack_require__.d(V,{base10:()=>Um});var j={};__webpack_require__.r(j),__webpack_require__.d(j,{base16:()=>Mm,base16upper:()=>Om});var H={};__webpack_require__.r(H),__webpack_require__.d(H,{base2:()=>qm});var W={};__webpack_require__.r(W),__webpack_require__.d(W,{base256emoji:()=>Vm});var G={};__webpack_require__.r(G),__webpack_require__.d(G,{base32:()=>jm,base32hex:()=>Ym,base32hexpad:()=>Jm,base32hexpadupper:()=>Xm,base32hexupper:()=>Qm,base32pad:()=>Wm,base32padupper:()=>Gm,base32upper:()=>Hm,base32z:()=>Zm});var Y={};__webpack_require__.r(Y),__webpack_require__.d(Y,{base36:()=>$m,base36upper:()=>ew});var Q={};__webpack_require__.r(Q),__webpack_require__.d(Q,{base58btc:()=>tw,base58flickr:()=>rw});var J={};__webpack_require__.r(J),__webpack_require__.d(J,{base64:()=>nw,base64pad:()=>iw,base64url:()=>ow,base64urlpad:()=>sw});var X={};__webpack_require__.r(X),__webpack_require__.d(X,{base8:()=>aw});var Z={};__webpack_require__.r(Z),__webpack_require__.d(Z,{identity:()=>cw});var $={};__webpack_require__.r($),__webpack_require__.d($,{code:()=>dw,decode:()=>pw,encode:()=>fw,name:()=>hw});var ee={};__webpack_require__.r(ee),__webpack_require__.d(ee,{code:()=>bw,decode:()=>mw,encode:()=>yw,name:()=>gw});var te={};__webpack_require__.r(te),__webpack_require__.d(te,{identity:()=>Fw});var re={};__webpack_require__.r(re),__webpack_require__.d(re,{sha256:()=>Hw,sha512:()=>Ww});var ne={};__webpack_require__.r(ne),__webpack_require__.d(ne,{Ed25519PrivateKey:()=>vv,Ed25519PublicKey:()=>wv,generateKeyPair:()=>Sv,generateKeyPairFromSeed:()=>Av,unmarshalEd25519PrivateKey:()=>_v,unmarshalEd25519PublicKey:()=>Ev});var ie={};__webpack_require__.r(ie),__webpack_require__.d(ie,{MAX_KEY_SIZE:()=>Mv,RsaPrivateKey:()=>qv,RsaPublicKey:()=>Ov,fromJwk:()=>Kv,generateKeyPair:()=>Vv,unmarshalRsaPrivateKey:()=>zv,unmarshalRsaPublicKey:()=>Fv});var oe={};__webpack_require__.r(oe),__webpack_require__.d(oe,{Secp256k1PrivateKey:()=>l_,Secp256k1PublicKey:()=>c_,generateKeyPair:()=>d_,unmarshalSecp256k1PrivateKey:()=>u_,unmarshalSecp256k1PublicKey:()=>h_});var se={};__webpack_require__.r(se),__webpack_require__.d(se,{base58btc:()=>D_,base58flickr:()=>N_});var ae={};__webpack_require__.r(ae),__webpack_require__.d(ae,{base10:()=>B_});var ce={};__webpack_require__.r(ce),__webpack_require__.d(ce,{base16:()=>L_,base16upper:()=>U_});var le={};__webpack_require__.r(le),__webpack_require__.d(le,{base2:()=>M_});var ue={};__webpack_require__.r(ue),__webpack_require__.d(ue,{base256emoji:()=>F_});var he={};__webpack_require__.r(he),__webpack_require__.d(he,{base32:()=>K_,base32hex:()=>W_,base32hexpad:()=>Y_,base32hexpadupper:()=>Q_,base32hexupper:()=>G_,base32pad:()=>j_,base32padupper:()=>H_,base32upper:()=>V_,base32z:()=>J_});var de={};__webpack_require__.r(de),__webpack_require__.d(de,{base36:()=>X_,base36upper:()=>Z_});var fe={};__webpack_require__.r(fe),__webpack_require__.d(fe,{base64:()=>$_,base64pad:()=>eE,base64url:()=>tE,base64urlpad:()=>rE});var pe={};__webpack_require__.r(pe),__webpack_require__.d(pe,{base8:()=>nE});var ge={};__webpack_require__.r(ge),__webpack_require__.d(ge,{identity:()=>iE});var be={};__webpack_require__.r(be),__webpack_require__.d(be,{code:()=>cE,decode:()=>uE,encode:()=>lE,name:()=>aE});var ye={};__webpack_require__.r(ye),__webpack_require__.d(ye,{code:()=>dE,decode:()=>pE,encode:()=>fE,name:()=>hE});var me={};__webpack_require__.r(me),__webpack_require__.d(me,{identity:()=>qE});var we={};__webpack_require__.r(we),__webpack_require__.d(we,{sha256:()=>VE,sha512:()=>jE});var ve={};__webpack_require__.r(ve),__webpack_require__.d(ve,{base10:()=>FS});var _e={};__webpack_require__.r(_e),__webpack_require__.d(_e,{base16:()=>KS,base16upper:()=>VS});var Ee={};__webpack_require__.r(Ee),__webpack_require__.d(Ee,{base2:()=>jS});var Se={};__webpack_require__.r(Se),__webpack_require__.d(Se,{base256emoji:()=>YS});var Ae={};__webpack_require__.r(Ae),__webpack_require__.d(Ae,{base32:()=>QS,base32hex:()=>$S,base32hexpad:()=>tA,base32hexpadupper:()=>rA,base32hexupper:()=>eA,base32pad:()=>XS,base32padupper:()=>ZS,base32upper:()=>JS,base32z:()=>nA});var xe={};__webpack_require__.r(xe),__webpack_require__.d(xe,{base36:()=>iA,base36upper:()=>oA});var ke={};__webpack_require__.r(ke),__webpack_require__.d(ke,{base58btc:()=>sA,base58flickr:()=>aA});var Ce={};__webpack_require__.r(Ce),__webpack_require__.d(Ce,{base64:()=>cA,base64pad:()=>lA,base64url:()=>uA,base64urlpad:()=>hA});var Ie={};__webpack_require__.r(Ie),__webpack_require__.d(Ie,{base8:()=>dA});var Te={};__webpack_require__.r(Te),__webpack_require__.d(Te,{identity:()=>fA});var Pe={};__webpack_require__.r(Pe),__webpack_require__.d(Pe,{code:()=>yA,decode:()=>wA,encode:()=>mA,name:()=>bA});var Re={};__webpack_require__.r(Re),__webpack_require__.d(Re,{code:()=>_A,decode:()=>SA,encode:()=>EA,name:()=>vA});var De={};__webpack_require__.r(De),__webpack_require__.d(De,{identity:()=>WA});var Ne={};__webpack_require__.r(Ne),__webpack_require__.d(Ne,{sha256:()=>JA,sha512:()=>XA});var Be={};__webpack_require__.r(Be),__webpack_require__.d(Be,{base10:()=>iC});var Le={};__webpack_require__.r(Le),__webpack_require__.d(Le,{base16:()=>oC,base16upper:()=>sC});var Ue={};__webpack_require__.r(Ue),__webpack_require__.d(Ue,{base2:()=>aC});var Me={};__webpack_require__.r(Me),__webpack_require__.d(Me,{base256emoji:()=>hC});var Oe={};__webpack_require__.r(Oe),__webpack_require__.d(Oe,{base32:()=>dC,base32hex:()=>bC,base32hexpad:()=>mC,base32hexpadupper:()=>wC,base32hexupper:()=>yC,base32pad:()=>pC,base32padupper:()=>gC,base32upper:()=>fC,base32z:()=>vC});var qe={};__webpack_require__.r(qe),__webpack_require__.d(qe,{base36:()=>_C,base36upper:()=>EC});var ze={};__webpack_require__.r(ze),__webpack_require__.d(ze,{base58btc:()=>SC,base58flickr:()=>AC});var Fe={};__webpack_require__.r(Fe),__webpack_require__.d(Fe,{base64:()=>xC,base64pad:()=>kC,base64url:()=>CC,base64urlpad:()=>IC});var Ke={};__webpack_require__.r(Ke),__webpack_require__.d(Ke,{base8:()=>TC});var Ve={};__webpack_require__.r(Ve),__webpack_require__.d(Ve,{identity:()=>PC});var je={};__webpack_require__.r(je),__webpack_require__.d(je,{code:()=>BC,decode:()=>UC,encode:()=>LC,name:()=>NC});var He={};__webpack_require__.r(He),__webpack_require__.d(He,{code:()=>OC,decode:()=>zC,encode:()=>qC,name:()=>MC});var We={};__webpack_require__.r(We),__webpack_require__.d(We,{identity:()=>lI});var Ge={};__webpack_require__.r(Ge),__webpack_require__.d(Ge,{sha256:()=>fI,sha512:()=>pI});var Ye={};__webpack_require__.r(Ye),__webpack_require__.d(Ye,{base10:()=>lN});var Qe={};__webpack_require__.r(Qe),__webpack_require__.d(Qe,{base16:()=>uN,base16upper:()=>hN});var Je={};__webpack_require__.r(Je),__webpack_require__.d(Je,{base2:()=>dN});var Xe={};__webpack_require__.r(Xe),__webpack_require__.d(Xe,{base256emoji:()=>bN});var Ze={};__webpack_require__.r(Ze),__webpack_require__.d(Ze,{base32:()=>yN,base32hex:()=>_N,base32hexpad:()=>SN,base32hexpadupper:()=>AN,base32hexupper:()=>EN,base32pad:()=>wN,base32padupper:()=>vN,base32upper:()=>mN,base32z:()=>xN});var $e={};__webpack_require__.r($e),__webpack_require__.d($e,{base36:()=>kN,base36upper:()=>CN});var et={};__webpack_require__.r(et),__webpack_require__.d(et,{base58btc:()=>IN,base58flickr:()=>TN});var tt={};__webpack_require__.r(tt),__webpack_require__.d(tt,{base64:()=>PN,base64pad:()=>RN,base64url:()=>DN,base64urlpad:()=>NN});var rt={};__webpack_require__.r(rt),__webpack_require__.d(rt,{base8:()=>BN});var nt={};__webpack_require__.r(nt),__webpack_require__.d(nt,{identity:()=>LN});var it={};__webpack_require__.r(it),__webpack_require__.d(it,{code:()=>qN,decode:()=>FN,encode:()=>zN,name:()=>ON});var ot={};__webpack_require__.r(ot),__webpack_require__.d(ot,{code:()=>VN,decode:()=>HN,encode:()=>jN,name:()=>KN});var st={};__webpack_require__.r(st),__webpack_require__.d(st,{identity:()=>pB});var at={};__webpack_require__.r(at),__webpack_require__.d(at,{sha256:()=>mB,sha512:()=>wB});var ct={};__webpack_require__.r(ct),__webpack_require__.d(ct,{Ed25519PrivateKey:()=>GB,Ed25519PublicKey:()=>WB,generateKeyPair:()=>JB,generateKeyPairFromSeed:()=>XB,unmarshalEd25519PrivateKey:()=>YB,unmarshalEd25519PublicKey:()=>QB});var lt={};__webpack_require__.r(lt),__webpack_require__.d(lt,{RsaPrivateKey:()=>cL,RsaPublicKey:()=>aL,fromJwk:()=>hL,generateKeyPair:()=>dL,unmarshalRsaPrivateKey:()=>lL,unmarshalRsaPublicKey:()=>uL});var ut={};__webpack_require__.r(ut),__webpack_require__.d(ut,{Secp256k1PrivateKey:()=>gL,Secp256k1PublicKey:()=>pL,generateKeyPair:()=>mL,unmarshalSecp256k1PrivateKey:()=>bL,unmarshalSecp256k1PublicKey:()=>yL});var ht={};__webpack_require__.r(ht),__webpack_require__.d(ht,{base58btc:()=>RL,base58flickr:()=>DL});var dt={};__webpack_require__.r(dt),__webpack_require__.d(dt,{base10:()=>NL});var ft={};__webpack_require__.r(ft),__webpack_require__.d(ft,{base16:()=>BL,base16upper:()=>LL});var pt={};__webpack_require__.r(pt),__webpack_require__.d(pt,{base2:()=>UL});var gt={};__webpack_require__.r(gt),__webpack_require__.d(gt,{base256emoji:()=>zL});var bt={};__webpack_require__.r(bt),__webpack_require__.d(bt,{base32:()=>FL,base32hex:()=>HL,base32hexpad:()=>GL,base32hexpadupper:()=>YL,base32hexupper:()=>WL,base32pad:()=>VL,base32padupper:()=>jL,base32upper:()=>KL,base32z:()=>QL});var yt={};__webpack_require__.r(yt),__webpack_require__.d(yt,{base36:()=>JL,base36upper:()=>XL});var mt={};__webpack_require__.r(mt),__webpack_require__.d(mt,{base64:()=>ZL,base64pad:()=>$L,base64url:()=>eU,base64urlpad:()=>tU});var wt={};__webpack_require__.r(wt),__webpack_require__.d(wt,{base8:()=>rU});var vt={};__webpack_require__.r(vt),__webpack_require__.d(vt,{identity:()=>nU});var _t={};__webpack_require__.r(_t),__webpack_require__.d(_t,{code:()=>aU,decode:()=>lU,encode:()=>cU,name:()=>sU});var Et={};__webpack_require__.r(Et),__webpack_require__.d(Et,{code:()=>hU,decode:()=>fU,encode:()=>dU,name:()=>uU});var St={};__webpack_require__.r(St),__webpack_require__.d(St,{identity:()=>OU});var At={};__webpack_require__.r(At),__webpack_require__.d(At,{sha256:()=>KU,sha512:()=>VU});var xt={};__webpack_require__.r(xt),__webpack_require__.d(xt,{base32:()=>Nz,base32hex:()=>Mz,base32hexpad:()=>qz,base32hexpadupper:()=>zz,base32hexupper:()=>Oz,base32pad:()=>Lz,base32padupper:()=>Uz,base32upper:()=>Bz,base32z:()=>Fz});var kt={};__webpack_require__.r(kt),__webpack_require__.d(kt,{base58btc:()=>Kz,base58flickr:()=>Vz});var Ct={};__webpack_require__.r(Ct),__webpack_require__.d(Ct,{base64:()=>jz,base64pad:()=>Hz,base64url:()=>Wz,base64urlpad:()=>Gz});var It={};__webpack_require__.r(It),__webpack_require__.d(It,{base10:()=>Qz});var Tt={};__webpack_require__.r(Tt),__webpack_require__.d(Tt,{base16:()=>Jz,base16upper:()=>Xz});var Pt={};__webpack_require__.r(Pt),__webpack_require__.d(Pt,{base2:()=>Zz});var Rt={};__webpack_require__.r(Rt),__webpack_require__.d(Rt,{base256emoji:()=>rF});var Dt={};__webpack_require__.r(Dt),__webpack_require__.d(Dt,{base36:()=>nF,base36upper:()=>iF});var Nt={};__webpack_require__.r(Nt),__webpack_require__.d(Nt,{base8:()=>oF});var Bt={};__webpack_require__.r(Bt),__webpack_require__.d(Bt,{identity:()=>sF});var Lt={};__webpack_require__.r(Lt),__webpack_require__.d(Lt,{code:()=>uF,decode:()=>dF,encode:()=>hF,name:()=>lF});var Ut={};__webpack_require__.r(Ut),__webpack_require__.d(Ut,{code:()=>pF,decode:()=>bF,encode:()=>gF,name:()=>fF});var Mt={};__webpack_require__.r(Mt),__webpack_require__.d(Mt,{identity:()=>FF});var Ot={};__webpack_require__.r(Ot),__webpack_require__.d(Ot,{sha256:()=>HF,sha512:()=>WF});var qt={};__webpack_require__.r(qt),__webpack_require__.d(qt,{base58btc:()=>IV,base58flickr:()=>TV});var zt={};__webpack_require__.r(zt),__webpack_require__.d(zt,{base10:()=>PV});var Ft={};__webpack_require__.r(Ft),__webpack_require__.d(Ft,{base16:()=>RV,base16upper:()=>DV});var Kt={};__webpack_require__.r(Kt),__webpack_require__.d(Kt,{base2:()=>NV});var Vt={};__webpack_require__.r(Vt),__webpack_require__.d(Vt,{base256emoji:()=>MV});var jt={};__webpack_require__.r(jt),__webpack_require__.d(jt,{base32:()=>OV,base32hex:()=>KV,base32hexpad:()=>jV,base32hexpadupper:()=>HV,base32hexupper:()=>VV,base32pad:()=>zV,base32padupper:()=>FV,base32upper:()=>qV,base32z:()=>WV});var Ht={};__webpack_require__.r(Ht),__webpack_require__.d(Ht,{base36:()=>GV,base36upper:()=>YV});var Wt={};__webpack_require__.r(Wt),__webpack_require__.d(Wt,{base64:()=>QV,base64pad:()=>JV,base64url:()=>XV,base64urlpad:()=>ZV});var Gt={};__webpack_require__.r(Gt),__webpack_require__.d(Gt,{base8:()=>$V});var Yt={};__webpack_require__.r(Yt),__webpack_require__.d(Yt,{identity:()=>ej});var Qt={};__webpack_require__.r(Qt),__webpack_require__.d(Qt,{code:()=>ij,decode:()=>sj,encode:()=>oj,name:()=>nj});var Jt={};__webpack_require__.r(Jt),__webpack_require__.d(Jt,{code:()=>cj,decode:()=>uj,encode:()=>lj,name:()=>aj});var Xt={};__webpack_require__.r(Xt),__webpack_require__.d(Xt,{identity:()=>Nj});var Zt={};__webpack_require__.r(Zt),__webpack_require__.d(Zt,{sha256:()=>Mj,sha512:()=>Oj});var $t={};__webpack_require__.r($t),__webpack_require__.d($t,{base32:()=>yH,base32hex:()=>_H,base32hexpad:()=>SH,base32hexpadupper:()=>AH,base32hexupper:()=>EH,base32pad:()=>wH,base32padupper:()=>vH,base32upper:()=>mH,base32z:()=>xH});var er={};__webpack_require__.r(er),__webpack_require__.d(er,{base58btc:()=>kH,base58flickr:()=>CH});var tr={};__webpack_require__.r(tr),__webpack_require__.d(tr,{base64:()=>IH,base64pad:()=>TH,base64url:()=>PH,base64urlpad:()=>RH});var rr={};__webpack_require__.r(rr),__webpack_require__.d(rr,{base10:()=>NH});var nr={};__webpack_require__.r(nr),__webpack_require__.d(nr,{base16:()=>BH,base16upper:()=>LH});var ir={};__webpack_require__.r(ir),__webpack_require__.d(ir,{base2:()=>UH});var or={};__webpack_require__.r(or),__webpack_require__.d(or,{base256emoji:()=>zH});var sr={};__webpack_require__.r(sr),__webpack_require__.d(sr,{base36:()=>FH,base36upper:()=>KH});var ar={};__webpack_require__.r(ar),__webpack_require__.d(ar,{base8:()=>VH});var cr={};__webpack_require__.r(cr),__webpack_require__.d(cr,{identity:()=>jH});var lr={};__webpack_require__.r(lr),__webpack_require__.d(lr,{code:()=>YH,decode:()=>JH,encode:()=>QH,name:()=>GH});var ur={};__webpack_require__.r(ur),__webpack_require__.d(ur,{code:()=>ZH,decode:()=>eW,encode:()=>$H,name:()=>XH});var hr={};__webpack_require__.r(hr),__webpack_require__.d(hr,{identity:()=>xW});var dr={};__webpack_require__.r(dr),__webpack_require__.d(dr,{sha256:()=>TW,sha512:()=>PW});var fr={};__webpack_require__.r(fr),__webpack_require__.d(fr,{base10:()=>lG});var pr={};__webpack_require__.r(pr),__webpack_require__.d(pr,{base16:()=>uG,base16upper:()=>hG});var gr={};__webpack_require__.r(gr),__webpack_require__.d(gr,{base2:()=>dG});var br={};__webpack_require__.r(br),__webpack_require__.d(br,{base256emoji:()=>bG});var yr={};__webpack_require__.r(yr),__webpack_require__.d(yr,{base32:()=>yG,base32hex:()=>_G,base32hexpad:()=>SG,base32hexpadupper:()=>AG,base32hexupper:()=>EG,base32pad:()=>wG,base32padupper:()=>vG,base32upper:()=>mG,base32z:()=>xG});var mr={};__webpack_require__.r(mr),__webpack_require__.d(mr,{base36:()=>kG,base36upper:()=>CG});var wr={};__webpack_require__.r(wr),__webpack_require__.d(wr,{base58btc:()=>IG,base58flickr:()=>TG});var vr={};__webpack_require__.r(vr),__webpack_require__.d(vr,{base64:()=>PG,base64pad:()=>RG,base64url:()=>DG,base64urlpad:()=>NG});var _r={};__webpack_require__.r(_r),__webpack_require__.d(_r,{base8:()=>BG});var Er={};__webpack_require__.r(Er),__webpack_require__.d(Er,{identity:()=>LG});var Sr={};__webpack_require__.r(Sr),__webpack_require__.d(Sr,{code:()=>qG,decode:()=>FG,encode:()=>zG,name:()=>OG});var Ar={};__webpack_require__.r(Ar),__webpack_require__.d(Ar,{code:()=>VG,decode:()=>HG,encode:()=>jG,name:()=>KG});var xr={};__webpack_require__.r(xr),__webpack_require__.d(xr,{identity:()=>pY});var kr={};__webpack_require__.r(kr),__webpack_require__.d(kr,{sha256:()=>mY,sha512:()=>wY});var Cr={};__webpack_require__.r(Cr),__webpack_require__.d(Cr,{base32:()=>tQ,base32hex:()=>oQ,base32hexpad:()=>aQ,base32hexpadupper:()=>cQ,base32hexupper:()=>sQ,base32pad:()=>nQ,base32padupper:()=>iQ,base32upper:()=>rQ,base32z:()=>lQ});var Ir={};__webpack_require__.r(Ir),__webpack_require__.d(Ir,{base58btc:()=>uQ,base58flickr:()=>hQ});var Tr={};__webpack_require__.r(Tr),__webpack_require__.d(Tr,{base64:()=>dQ,base64pad:()=>fQ,base64url:()=>pQ,base64urlpad:()=>gQ});var Pr={};__webpack_require__.r(Pr),__webpack_require__.d(Pr,{base58btc:()=>TQ,base58flickr:()=>PQ});var Rr={};__webpack_require__.r(Rr),__webpack_require__.d(Rr,{base10:()=>RQ});var Dr={};__webpack_require__.r(Dr),__webpack_require__.d(Dr,{base16:()=>DQ,base16upper:()=>NQ});var Nr={};__webpack_require__.r(Nr),__webpack_require__.d(Nr,{base2:()=>BQ});var Br={};__webpack_require__.r(Br),__webpack_require__.d(Br,{base256emoji:()=>OQ});var Lr={};__webpack_require__.r(Lr),__webpack_require__.d(Lr,{base32:()=>qQ,base32hex:()=>VQ,base32hexpad:()=>HQ,base32hexpadupper:()=>WQ,base32hexupper:()=>jQ,base32pad:()=>FQ,base32padupper:()=>KQ,base32upper:()=>zQ,base32z:()=>GQ});var Ur={};__webpack_require__.r(Ur),__webpack_require__.d(Ur,{base36:()=>YQ,base36upper:()=>QQ});var Mr={};__webpack_require__.r(Mr),__webpack_require__.d(Mr,{base64:()=>JQ,base64pad:()=>XQ,base64url:()=>ZQ,base64urlpad:()=>$Q});var Or={};__webpack_require__.r(Or),__webpack_require__.d(Or,{base8:()=>eJ});var qr={};__webpack_require__.r(qr),__webpack_require__.d(qr,{identity:()=>tJ});var zr={};__webpack_require__.r(zr),__webpack_require__.d(zr,{code:()=>oJ,decode:()=>aJ,encode:()=>sJ,name:()=>iJ});var Fr={};__webpack_require__.r(Fr),__webpack_require__.d(Fr,{code:()=>lJ,decode:()=>hJ,encode:()=>uJ,name:()=>cJ});var Kr={};__webpack_require__.r(Kr),__webpack_require__.d(Kr,{identity:()=>UJ});var Vr={};__webpack_require__.r(Vr),__webpack_require__.d(Vr,{sha256:()=>zJ,sha512:()=>FJ});var jr={};__webpack_require__.r(jr),__webpack_require__.d(jr,{base10:()=>fX});var Hr={};__webpack_require__.r(Hr),__webpack_require__.d(Hr,{base16:()=>pX,base16upper:()=>gX});var Wr={};__webpack_require__.r(Wr),__webpack_require__.d(Wr,{base2:()=>bX});var Gr={};__webpack_require__.r(Gr),__webpack_require__.d(Gr,{base256emoji:()=>vX});var Yr={};__webpack_require__.r(Yr),__webpack_require__.d(Yr,{base36:()=>_X,base36upper:()=>EX});var Qr={};__webpack_require__.r(Qr),__webpack_require__.d(Qr,{base8:()=>SX});var Jr={};__webpack_require__.r(Jr),__webpack_require__.d(Jr,{identity:()=>AX});var Xr={};__webpack_require__.r(Xr),__webpack_require__.d(Xr,{code:()=>IX,decode:()=>PX,encode:()=>TX,name:()=>CX});var Zr={};__webpack_require__.r(Zr),__webpack_require__.d(Zr,{code:()=>DX,decode:()=>BX,encode:()=>NX,name:()=>RX});var $r={};__webpack_require__.r($r),__webpack_require__.d($r,{identity:()=>oZ});var en={};__webpack_require__.r(en),__webpack_require__.d(en,{sha256:()=>lZ,sha512:()=>uZ});var tn={};__webpack_require__.r(tn),__webpack_require__.d(tn,{base58btc:()=>HZ,base58flickr:()=>WZ});var rn={};__webpack_require__.r(rn),__webpack_require__.d(rn,{base10:()=>GZ});var nn={};__webpack_require__.r(nn),__webpack_require__.d(nn,{base16:()=>YZ,base16upper:()=>QZ});var on={};__webpack_require__.r(on),__webpack_require__.d(on,{base2:()=>JZ});var sn={};__webpack_require__.r(sn),__webpack_require__.d(sn,{base256emoji:()=>e$});var an={};__webpack_require__.r(an),__webpack_require__.d(an,{base32:()=>t$,base32hex:()=>o$,base32hexpad:()=>a$,base32hexpadupper:()=>c$,base32hexupper:()=>s$,base32pad:()=>n$,base32padupper:()=>i$,base32upper:()=>r$,base32z:()=>l$});var cn={};__webpack_require__.r(cn),__webpack_require__.d(cn,{base36:()=>u$,base36upper:()=>h$});var ln={};__webpack_require__.r(ln),__webpack_require__.d(ln,{base64:()=>d$,base64pad:()=>f$,base64url:()=>p$,base64urlpad:()=>g$});var un={};__webpack_require__.r(un),__webpack_require__.d(un,{base8:()=>b$});var hn={};__webpack_require__.r(hn),__webpack_require__.d(hn,{identity:()=>y$});var dn={};__webpack_require__.r(dn),__webpack_require__.d(dn,{code:()=>_$,decode:()=>S$,encode:()=>E$,name:()=>v$});var fn={};__webpack_require__.r(fn),__webpack_require__.d(fn,{code:()=>x$,decode:()=>C$,encode:()=>k$,name:()=>A$});var pn={};__webpack_require__.r(pn),__webpack_require__.d(pn,{identity:()=>Z$});var gn={};__webpack_require__.r(gn),__webpack_require__.d(gn,{sha256:()=>r0,sha512:()=>n0});var bn={};__webpack_require__.r(bn),__webpack_require__.d(bn,{base10:()=>$0});var yn={};__webpack_require__.r(yn),__webpack_require__.d(yn,{base16:()=>e1,base16upper:()=>t1});var mn={};__webpack_require__.r(mn),__webpack_require__.d(mn,{base2:()=>r1});var wn={};__webpack_require__.r(wn),__webpack_require__.d(wn,{base256emoji:()=>s1});var vn={};__webpack_require__.r(vn),__webpack_require__.d(vn,{base32:()=>a1,base32hex:()=>h1,base32hexpad:()=>f1,base32hexpadupper:()=>p1,base32hexupper:()=>d1,base32pad:()=>l1,base32padupper:()=>u1,base32upper:()=>c1,base32z:()=>g1});var _n={};__webpack_require__.r(_n),__webpack_require__.d(_n,{base36:()=>b1,base36upper:()=>y1});var En={};__webpack_require__.r(En),__webpack_require__.d(En,{base58btc:()=>m1,base58flickr:()=>w1});var Sn={};__webpack_require__.r(Sn),__webpack_require__.d(Sn,{base64:()=>v1,base64pad:()=>_1,base64url:()=>E1,base64urlpad:()=>S1});var An={};__webpack_require__.r(An),__webpack_require__.d(An,{base8:()=>A1});var xn={};__webpack_require__.r(xn),__webpack_require__.d(xn,{identity:()=>x1});var kn={};__webpack_require__.r(kn),__webpack_require__.d(kn,{code:()=>T1,decode:()=>R1,encode:()=>P1,name:()=>I1});var Cn={};__webpack_require__.r(Cn),__webpack_require__.d(Cn,{code:()=>N1,decode:()=>L1,encode:()=>B1,name:()=>D1});var In={};__webpack_require__.r(In),__webpack_require__.d(In,{identity:()=>i2});var Tn={};__webpack_require__.r(Tn),__webpack_require__.d(Tn,{sha256:()=>c2,sha512:()=>l2});var Pn={};__webpack_require__.r(Pn),__webpack_require__.d(Pn,{base32:()=>j2,base32hex:()=>Y2,base32hexpad:()=>J2,base32hexpadupper:()=>X2,base32hexupper:()=>Q2,base32pad:()=>W2,base32padupper:()=>G2,base32upper:()=>H2,base32z:()=>Z2});var Rn={};__webpack_require__.r(Rn),__webpack_require__.d(Rn,{base58btc:()=>$2,base58flickr:()=>e3});var Dn={};__webpack_require__.r(Dn),__webpack_require__.d(Dn,{base64:()=>t3,base64pad:()=>r3,base64url:()=>n3,base64urlpad:()=>i3});var Nn={};__webpack_require__.r(Nn),__webpack_require__.d(Nn,{base58btc:()=>y3,base58flickr:()=>m3});var Bn={};__webpack_require__.r(Bn),__webpack_require__.d(Bn,{base10:()=>w3});var Ln={};__webpack_require__.r(Ln),__webpack_require__.d(Ln,{base16:()=>v3,base16upper:()=>_3});var Un={};__webpack_require__.r(Un),__webpack_require__.d(Un,{base2:()=>E3});var Mn={};__webpack_require__.r(Mn),__webpack_require__.d(Mn,{base256emoji:()=>k3});var On={};__webpack_require__.r(On),__webpack_require__.d(On,{base32:()=>C3,base32hex:()=>R3,base32hexpad:()=>N3,base32hexpadupper:()=>B3,base32hexupper:()=>D3,base32pad:()=>T3,base32padupper:()=>P3,base32upper:()=>I3,base32z:()=>L3});var qn={};__webpack_require__.r(qn),__webpack_require__.d(qn,{base36:()=>U3,base36upper:()=>M3});var zn={};__webpack_require__.r(zn),__webpack_require__.d(zn,{base64:()=>O3,base64pad:()=>q3,base64url:()=>z3,base64urlpad:()=>F3});var Fn={};__webpack_require__.r(Fn),__webpack_require__.d(Fn,{base8:()=>K3});var Kn={};__webpack_require__.r(Kn),__webpack_require__.d(Kn,{identity:()=>V3});var Vn={};__webpack_require__.r(Vn),__webpack_require__.d(Vn,{code:()=>G3,decode:()=>Q3,encode:()=>Y3,name:()=>W3});var jn={};__webpack_require__.r(jn),__webpack_require__.d(jn,{code:()=>X3,decode:()=>$3,encode:()=>Z3,name:()=>J3});var Hn={};__webpack_require__.r(Hn),__webpack_require__.d(Hn,{identity:()=>A6});var Wn={};__webpack_require__.r(Wn),__webpack_require__.d(Wn,{sha256:()=>I6,sha512:()=>T6});var Gn={};__webpack_require__.r(Gn),__webpack_require__.d(Gn,{base10:()=>C5});var Yn={};__webpack_require__.r(Yn),__webpack_require__.d(Yn,{base16:()=>I5,base16upper:()=>T5});var Qn={};__webpack_require__.r(Qn),__webpack_require__.d(Qn,{base2:()=>P5});var Jn={};__webpack_require__.r(Jn),__webpack_require__.d(Jn,{base256emoji:()=>B5});var Xn={};__webpack_require__.r(Xn),__webpack_require__.d(Xn,{base32:()=>L5,base32hex:()=>q5,base32hexpad:()=>F5,base32hexpadupper:()=>K5,base32hexupper:()=>z5,base32pad:()=>M5,base32padupper:()=>O5,base32upper:()=>U5,base32z:()=>V5});var Zn={};__webpack_require__.r(Zn),__webpack_require__.d(Zn,{base36:()=>j5,base36upper:()=>H5});var $n={};__webpack_require__.r($n),__webpack_require__.d($n,{base58btc:()=>W5,base58flickr:()=>G5});var ei={};__webpack_require__.r(ei),__webpack_require__.d(ei,{base64:()=>Y5,base64pad:()=>Q5,base64url:()=>J5,base64urlpad:()=>X5});var ti={};__webpack_require__.r(ti),__webpack_require__.d(ti,{base8:()=>Z5});var ri={};__webpack_require__.r(ri),__webpack_require__.d(ri,{identity:()=>$5});var ni={};__webpack_require__.r(ni),__webpack_require__.d(ni,{code:()=>n4,decode:()=>o4,encode:()=>i4,name:()=>r4});var ii={};__webpack_require__.r(ii),__webpack_require__.d(ii,{code:()=>a4,decode:()=>l4,encode:()=>c4,name:()=>s4});var oi={};__webpack_require__.r(oi),__webpack_require__.d(oi,{identity:()=>D4});var si={};__webpack_require__.r(si),__webpack_require__.d(si,{sha256:()=>U4,sha512:()=>M4});var ai={};__webpack_require__.r(ai),__webpack_require__.d(ai,{base10:()=>f8});var ci={};__webpack_require__.r(ci),__webpack_require__.d(ci,{base16:()=>p8,base16upper:()=>g8});var li={};__webpack_require__.r(li),__webpack_require__.d(li,{base2:()=>b8});var ui={};__webpack_require__.r(ui),__webpack_require__.d(ui,{base256emoji:()=>v8});var hi={};__webpack_require__.r(hi),__webpack_require__.d(hi,{base36:()=>_8,base36upper:()=>E8});var di={};__webpack_require__.r(di),__webpack_require__.d(di,{base8:()=>S8});var fi={};__webpack_require__.r(fi),__webpack_require__.d(fi,{identity:()=>A8});var pi={};__webpack_require__.r(pi),__webpack_require__.d(pi,{code:()=>I8,decode:()=>P8,encode:()=>T8,name:()=>C8});var gi={};__webpack_require__.r(gi),__webpack_require__.d(gi,{code:()=>D8,decode:()=>B8,encode:()=>N8,name:()=>R8});var bi={};__webpack_require__.r(bi),__webpack_require__.d(bi,{identity:()=>o7});var yi={};__webpack_require__.r(yi),__webpack_require__.d(yi,{sha256:()=>l7,sha512:()=>u7});var mi={};__webpack_require__.r(mi),__webpack_require__.d(mi,{base10:()=>aee});var wi={};__webpack_require__.r(wi),__webpack_require__.d(wi,{base16:()=>cee,base16upper:()=>lee});var vi={};__webpack_require__.r(vi),__webpack_require__.d(vi,{base2:()=>uee});var _i={};__webpack_require__.r(_i),__webpack_require__.d(_i,{base256emoji:()=>pee});var Ei={};__webpack_require__.r(Ei),__webpack_require__.d(Ei,{base32:()=>gee,base32hex:()=>wee,base32hexpad:()=>_ee,base32hexpadupper:()=>Eee,base32hexupper:()=>vee,base32pad:()=>yee,base32padupper:()=>mee,base32upper:()=>bee,base32z:()=>See});var Si={};__webpack_require__.r(Si),__webpack_require__.d(Si,{base36:()=>Aee,base36upper:()=>xee});var Ai={};__webpack_require__.r(Ai),__webpack_require__.d(Ai,{base58btc:()=>kee,base58flickr:()=>Cee});var xi={};__webpack_require__.r(xi),__webpack_require__.d(xi,{base64:()=>Iee,base64pad:()=>Tee,base64url:()=>Pee,base64urlpad:()=>Ree});var ki={};__webpack_require__.r(ki),__webpack_require__.d(ki,{base8:()=>Dee});var Ci={};__webpack_require__.r(Ci),__webpack_require__.d(Ci,{identity:()=>Nee});var Ii={};__webpack_require__.r(Ii),__webpack_require__.d(Ii,{code:()=>Mee,decode:()=>qee,encode:()=>Oee,name:()=>Uee});var Ti={};__webpack_require__.r(Ti),__webpack_require__.d(Ti,{code:()=>Fee,decode:()=>Vee,encode:()=>Kee,name:()=>zee});var Pi={};__webpack_require__.r(Pi),__webpack_require__.d(Pi,{identity:()=>dte});var Ri={};__webpack_require__.r(Ri),__webpack_require__.d(Ri,{sha256:()=>bte,sha512:()=>yte});var Di={};__webpack_require__.r(Di),__webpack_require__.d(Di,{base10:()=>Cse});var Ni={};__webpack_require__.r(Ni),__webpack_require__.d(Ni,{base16:()=>Ise,base16upper:()=>Tse});var Bi={};__webpack_require__.r(Bi),__webpack_require__.d(Bi,{base2:()=>Pse});var Li={};__webpack_require__.r(Li),__webpack_require__.d(Li,{base256emoji:()=>Bse});var Ui={};__webpack_require__.r(Ui),__webpack_require__.d(Ui,{base32:()=>Lse,base32hex:()=>qse,base32hexpad:()=>Fse,base32hexpadupper:()=>Kse,base32hexupper:()=>zse,base32pad:()=>Mse,base32padupper:()=>Ose,base32upper:()=>Use,base32z:()=>Vse});var Mi={};__webpack_require__.r(Mi),__webpack_require__.d(Mi,{base36:()=>jse,base36upper:()=>Hse});var Oi={};__webpack_require__.r(Oi),__webpack_require__.d(Oi,{base58btc:()=>Wse,base58flickr:()=>Gse});var qi={};__webpack_require__.r(qi),__webpack_require__.d(qi,{base64:()=>Yse,base64pad:()=>Qse,base64url:()=>Jse,base64urlpad:()=>Xse});var zi={};__webpack_require__.r(zi),__webpack_require__.d(zi,{base8:()=>Zse});var Fi={};__webpack_require__.r(Fi),__webpack_require__.d(Fi,{identity:()=>$se});var Ki={};__webpack_require__.r(Ki),__webpack_require__.d(Ki,{code:()=>nae,decode:()=>oae,encode:()=>iae,name:()=>rae});var Vi={};__webpack_require__.r(Vi),__webpack_require__.d(Vi,{code:()=>aae,decode:()=>lae,encode:()=>cae,name:()=>sae});var ji={};__webpack_require__.r(ji),__webpack_require__.d(ji,{identity:()=>Dae});var Hi={};__webpack_require__.r(Hi),__webpack_require__.d(Hi,{sha256:()=>Uae,sha512:()=>Mae});var Wi=__webpack_require__(5043),Gi=__webpack_require__(7950);function Yi(e){return Yi="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},Yi(e)}function Qi(e){var t=function(e,t){if("object"!=Yi(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Yi(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Yi(t)?t:t+""}function Ji(e,t,r){return(t=Qi(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Xi=Symbol.for("@libp2p/peer-id");function Zi(e){return null!=e&&Boolean(e[Xi])}function $i(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function eo(e,t,r){$i(e,t),t.set(e,r)}function to(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 ro(e,t){return e.get(to(e,t))}function no(e,t,r){return e.set(to(e,t),r),r}class io extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),Ji(this,"code",void 0),Ji(this,"type",void 0),this.code=io.code,this.type=io.type}}Ji(io,"code","ABORT_ERR"),Ji(io,"type","aborted");class oo extends Error{constructor(e,t,r){var n;super(e),Ji(this,"code",void 0),Ji(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 so=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const ao=so,co=(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 lo{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 uo{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 fo(this,e)}}class ho{constructor(e){this.decoders=e}or(e){return fo(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 fo=(e,t)=>new ho({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class po{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new lo(e,t,r),this.decoder=new uo(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const go=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new po(t,r,n,i)},bo=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=ao(n,r);return go({prefix:t,name:r,encode:i,decode:e=>co(o(e))})},yo=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return go({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},mo=bo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wo=bo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),vo=yo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_o=yo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Eo=yo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),So=yo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ao=yo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xo=yo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ko=yo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Co=yo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Io=yo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var To=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Do;)r[n++]=255&t|Po,t/=128;for(;t&Ro;)r[n++]=255&t|Po,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Po=128,Ro=-128,Do=Math.pow(2,31);var No=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&Lo)<<o:(n&Lo)*Math.pow(2,o),o+=7}while(n>=Bo);return e.bytes=s-r,i},Bo=128,Lo=127;var Uo=Math.pow(2,7),Mo=Math.pow(2,14),Oo=Math.pow(2,21),qo=Math.pow(2,28),zo=Math.pow(2,35),Fo=Math.pow(2,42),Ko=Math.pow(2,49),Vo=Math.pow(2,56),jo=Math.pow(2,63);const Ho={encode:To,decode:No,encodingLength:function(e){return e<Uo?1:e<Mo?2:e<Oo?3:e<qo?4:e<zo?5:e<Fo?6:e<Ko?7:e<Vo?8:e<jo?9:10}},Wo=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[Ho.decode(e,t),Ho.decode.bytes]},Go=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ho.encode(e,t,r),t},Yo=e=>Ho.encodingLength(e),Qo=(e,t)=>{const r=t.byteLength,n=Yo(e),i=n+Yo(r),o=new Uint8Array(i+r);return Go(e,o,0),Go(r,o,n),o.set(t,i),new Xo(e,r,t,o)},Jo=e=>{const t=co(e),[r,n]=Wo(t),[i,o]=Wo(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Xo(r,i,s,t)};class Xo{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Zo=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?ns(r,es(e),t||mo.encoder):is(r,es(e),t||vo.encoder)},$o=new WeakMap,es=e=>{const t=$o.get(e);if(null==t){const t=new Map;return $o.set(e,t),t}return t};class ts{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!==os)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ss)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return ts.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=Qo(e,t);return ts.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 ts.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 Zo(this,e)}toJSON(){return{"/":Zo(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 ts)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new ts(e,r,n,i||as(e,r,n.bytes))}if(!0===t[cs]){const{version:e,multihash:r,code:n}=t,i=Jo(r);return ts.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!==os)throw new Error("Version 0 CID must use dag-pb (code: ".concat(os,") block encoding"));return new ts(e,t,r,r.bytes);case 1:{const n=as(e,t,r.bytes);return new ts(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return ts.create(0,os,e)}static createV1(e,t){return ts.create(1,e,t)}static decode(e){const[t,r]=ts.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=ts.inspectBytes(e),r=t.size-t.multihashSize,n=co(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 Xo(t.multihashCode,t.digestSize,i,n);return[0===t.version?ts.createV0(o):ts.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Wo(e.subarray(t));return t+=n,r};let n=r(),i=os;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]=rs(e,t),i=ts.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return es(i).set(r,e),i}}const rs=(e,t)=>{switch(e[0]){case"Q":{const r=t||mo;return[mo.prefix,r.decode("".concat(mo.prefix).concat(e))]}case mo.prefix:{const r=t||mo;return[mo.prefix,r.decode(e)]}case vo.prefix:{const r=t||vo;return[vo.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)]}},ns=(e,t,r)=>{const{prefix:n}=r;if(n!==mo.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},is=(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},os=112,ss=18,as=(e,t,r)=>{const n=Yo(e),i=n+Yo(t),o=new Uint8Array(i+r.byteLength);return Go(e,o,0),Go(t,o,n),o.set(r,i),o},cs=Symbol.for("@ipld/js-cid/CID");function ls(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}var us=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const hs=us,ds=(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 fs{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 ps{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 bs(this,e)}}class gs{constructor(e){this.decoders=e}or(e){return bs(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 bs=(e,t)=>new gs({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ys{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new fs(e,t,r),this.decoder=new ps(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ms=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new ys(t,r,n,i)},ws=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=hs(n,r);return ms({prefix:t,name:r,encode:i,decode:e=>ds(o(e))})},vs=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return ms({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},_s=ws({prefix:"9",name:"base10",alphabet:"0123456789"}),Es=vs({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ss=vs({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),As=vs({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),xs=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"),ks=xs.reduce(((e,t,r)=>(e[r]=t,e)),[]),Cs=xs.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Is=ms({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ks[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Cs[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Ts=vs({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ps=vs({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Rs=vs({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ds=vs({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ns=vs({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Bs=vs({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ls=vs({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Us=vs({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ms=vs({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Os=ws({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qs=ws({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),zs=ws({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fs=ws({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Ks=vs({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vs=vs({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),js=vs({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Hs=vs({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Ws=vs({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Gs=ms({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),Ys=new TextEncoder,Qs=new TextDecoder,Js="json",Xs=512,Zs=e=>Ys.encode(JSON.stringify(e)),$s=e=>JSON.parse(Qs.decode(e)),ea="raw",ta=85,ra=e=>ds(e),na=e=>ds(e);var ia=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=aa;)r[n++]=255&t|oa,t/=128;for(;t&sa;)r[n++]=255&t|oa,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},oa=128,sa=-128,aa=Math.pow(2,31);var ca=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&ua)<<o:(n&ua)*Math.pow(2,o),o+=7}while(n>=la);return e.bytes=s-r,i},la=128,ua=127;var ha=Math.pow(2,7),da=Math.pow(2,14),fa=Math.pow(2,21),pa=Math.pow(2,28),ga=Math.pow(2,35),ba=Math.pow(2,42),ya=Math.pow(2,49),ma=Math.pow(2,56),wa=Math.pow(2,63);const va={encode:ia,decode:ca,encodingLength:function(e){return e<ha?1:e<da?2:e<fa?3:e<pa?4:e<ga?5:e<ba?6:e<ya?7:e<ma?8:e<wa?9:10}},_a=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return va.encode(e,t,r),t},Ea=e=>va.encodingLength(e),Sa=(e,t)=>{const r=t.byteLength,n=Ea(e),i=n+Ea(r),o=new Uint8Array(i+r);return _a(e,o,0),_a(r,o,n),o.set(t,i),new Aa(e,r,t,o)};class Aa{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const xa=ds,ka={code:0,name:"identity",encode:xa,digest:e=>Sa(0,xa(e))},Ca=e=>{let{name:t,code:r,encode:n}=e;return new Ia(t,r,n)};class Ia{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?Sa(this.code,t):t.then((e=>Sa(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Ta=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Pa=Ca({name:"sha2-256",code:18,encode:Ta("SHA-256")}),Ra=Ca({name:"sha2-512",code:19,encode:Ta("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Da={...h,...i,...u,...r,...n,...s,...a,...c,...l,...o};function Na(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Ba(){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.alloc)?Na(globalThis.Buffer.alloc(t)):new Uint8Array(t)}function La(){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)?Na(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Ua(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ma=Ua("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Oa=Ua("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=La((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),qa={utf8:Ma,"utf-8":Ma,hex:Da.base16,latin1:Oa,ascii:Oa,binary:Oa,...Da};function za(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=qa[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 Fa(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=La(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return Na(r)}var Ka=__webpack_require__(1870);const Va=45,ja=15,Ha=new class{constructor(){Ji(this,"index",0),Ji(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 Wa=bo({prefix:"9",name:"base10",alphabet:"0123456789"}),Ga=yo({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ya=yo({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Qa=yo({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Ja=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"),Xa=Ja.reduce(((e,t,r)=>(e[r]=t,e)),[]),Za=Ja.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const $a=go({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Xa[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Za[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),ec=bo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tc=bo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),rc=yo({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nc=yo({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ic=yo({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),oc=yo({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),sc=yo({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),ac=go({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),cc=new TextEncoder,lc=new TextDecoder,uc="json",hc=512,dc=e=>cc.encode(JSON.stringify(e)),fc=e=>JSON.parse(lc.decode(e)),pc="raw",gc=85,bc=e=>co(e),yc=e=>co(e),mc=co,wc={code:0,name:"identity",encode:mc,digest:e=>Qo(0,mc(e))},vc=e=>{let{name:t,code:r,encode:n}=e;return new _c(t,r,n)};class _c{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?Qo(this.code,t):t.then((e=>Qo(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Ec=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Sc=vc({name:"sha2-256",code:18,encode:Ec("SHA-256")}),Ac=vc({name:"sha2-512",code:19,encode:Ec("SHA-512")}),xc={...S,...m,...E,...b,...y,...t,...v,...e,..._,...w};function kc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=qa[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)):Na(globalThis.Buffer.from(e,"utf-8"))}function Cc(e){return Boolean(function(e){if(!(e.length>ja))return Ha.new(e).parseWith((()=>Ha.readIPv4Addr()))}(e))}function Ic(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Va))return Ha.new(e).parseWith((()=>Ha.readIPv6Addr()))}(e))}function Tc(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Va))return Ha.new(e).parseWith((()=>Ha.readIPAddr()))}(e))}const Pc=Cc,Rc=Ic,Dc=function(e){let t=0;if(e=e.toString().trim(),Pc(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(Rc(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;Pc(r[n])&&(e=Dc(r[n]),r[n]=za(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,za(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")},Nc=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""},Bc=-1,Lc={},Uc={};function Mc(e){if("number"===typeof e){if(null!=Uc[e])return Uc[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=Lc[e])return Lc[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,Bc,"ip6zone"],[43,8,"ipcidr"],[53,Bc,"dns",!0],[54,Bc,"dns4",!0],[55,Bc,"dns6",!0],[56,Bc,"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,Bc,"unix",!1,!0],[421,Bc,"ipfs"],[421,Bc,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,Bc,"garlic64"],[448,0,"tls"],[449,Bc,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,Bc,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,Bc,"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);Uc[t.code]=t,Lc[t.name]=t}));Mc("ip4"),Mc("ip6"),Mc("ipcidr");function Oc(e,t){switch(Mc(e).code){case 4:case 41:return function(e){const t=Nc(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Tc(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 Wc(t);case 6:case 273:case 33:case 132:return jc(t).toString();case 421:return function(e){const t=Ka.decode(e),r=e.slice(Ka.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return za(r,"base58btc")}(t);case 444:case 445:return Gc(t);case 466:return function(e){const t=Ka.decode(e),r=e.slice(Ka.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return"u"+za(r,"base64url")}(t);default:return za(t,"base16")}}function qc(e,t){switch(Mc(e).code){case 4:case 41:return Kc(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Hc(t);case 6:case 273:case 33:case 132:return Vc(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?Jo(mo.decode("z".concat(e))).bytes:ts.parse(e).multihash.bytes;const r=Uint8Array.from(Ka.encode(t.length));return Fa([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=vo.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=Vc(n);return Fa([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=vo.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=Vc(n);return Fa([r,i],r.length+i.length)}(t);case 466:return function(e){const t=Fc.decode(e),r=Uint8Array.from(Ka.encode(t.length));return Fa([r,t],r.length+t.length)}(t);default:return kc(t,"base16")}}const zc=Object.values(xc).map((e=>e.decoder)),Fc=function(){let e=zc[0].or(zc[1]);return zc.slice(2).forEach((t=>e=e.or(t))),e}();function Kc(e){if(!Tc(e))throw new Error("invalid ip address");return Dc(e)}function Vc(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function jc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Hc(e){const t=kc(e),r=Uint8Array.from(Ka.encode(t.length));return Fa([r,t],r.length+t.length)}function Wc(e){const t=Ka.decode(e);if((e=e.slice(Ka.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return za(e)}function Gc(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=za(t,"base32"),i=jc(r);return"".concat(n,":").concat(i)}function Yc(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){var o;const s=Ka.decode(e,i),a=null!==(o=Ka.decode.bytes)&&void 0!==o?o:0,c=Mc(s),l=Xc(c,e.slice(i+a));if(0===l){t.push([s]),r.push([s]),i+=a;continue}const u=e.slice(i+a,i+a+l);if(i+=l+a,i>e.length)throw $c("Invalid address Uint8Array: "+za(e,"base16"));t.push([s,u]);const h=Oc(s,u);if(r.push([s,h]),!0===c.path){n=h;break}}return{bytes:Uint8Array.from(e),string:Qc(r),tuples:t,stringTuples:r,path:n}}function Qc(e){const t=[];return e.map((e=>{const r=Mc(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),Zc(t.join("/"))}function Jc(e){return Fa(e.map((e=>{const t=Mc(e[0]);let r=Uint8Array.from(Ka.encode(t.code));return e.length>1&&null!=e[1]&&(r=Fa([r,e[1]])),r})))}function Xc(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;var r;return Ka.decode(t)+(null!==(r=Ka.decode.bytes)&&void 0!==r?r:0)}function Zc(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function $c(e){return new Error("Error parsing address: "+e)}const el=Symbol.for("nodejs.util.inspect.custom"),tl=[Mc("dns").code,Mc("dns4").code,Mc("dns6").code,Mc("dnsaddr").code],rl=new Map,nl=Symbol.for("@multiformats/js-multiaddr/multiaddr");function il(e){return Boolean(null===e||void 0===e?void 0:e[nl])}var ol,sl,al,cl,ll,ul=new WeakMap,hl=new WeakMap,dl=new WeakMap,fl=new WeakMap;class pl{constructor(e){let t;if(Ji(this,"bytes",void 0),eo(this,ul,void 0),eo(this,hl,void 0),eo(this,dl,void 0),eo(this,fl,void 0),Ji(this,nl,!0),null==e&&(e=""),e instanceof Uint8Array)t=Yc(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=Zc(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=Mc(i[o]);if(0===s.size){t.push([s.code]),r.push([s.code]);continue}if(o++,o>=i.length)throw $c("invalid address: "+e);if(!0===s.path){n=Zc(i.slice(o).join("/")),t.push([s.code,qc(s.code,n)]),r.push([s.code,n]);break}const a=qc(s.code,i[o]);t.push([s.code,a]),r.push([s.code,Oc(s.code,a)])}return{string:Qc(r),bytes:Jc(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!il(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=Yc(e.bytes)}this.bytes=t.bytes,no(ul,this,t.string),no(hl,this,t.tuples),no(dl,this,t.stringTuples),no(fl,this,t.path)}toString(){return ro(ul,this)}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const o=Mc("tcp"),s=Mc("udp"),a=Mc("ip4"),c=Mc("ip6"),l=Mc("dns6"),u=Mc("ip6zone");for(const[h,d]of this.stringTuples())h===u.code&&(i="%".concat(null!==d&&void 0!==d?d:"")),tl.includes(h)&&(t=o.name,n=443,r="".concat(null!==d&&void 0!==d?d:"").concat(i),e=h===l.code?6:4),h!==o.code&&h!==s.code||(t=Mc(h).name,n=parseInt(null!==d&&void 0!==d?d:"")),h!==a.code&&h!==c.code||(t=Mc(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 ro(hl,this).map((e=>{let[t]=e;return Object.assign({},Mc(t))}))}protoCodes(){return ro(hl,this).map((e=>{let[t]=e;return t}))}protoNames(){return ro(hl,this).map((e=>{let[t]=e;return Mc(t).name}))}tuples(){return ro(hl,this)}stringTuples(){return ro(dl,this)}encapsulate(e){return e=new pl(e),new pl(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 pl(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 pl(Jc(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===Lc.p2p.code&&e.push([r,n]),r===Lc["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]?za(mo.decode("z".concat(e)),"base58btc"):za(ts.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return ro(fl,this)}equals(e){return ls(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=rl.get(t.name);if(null==r)throw new oo("no available resolver for ".concat(t.name),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>new pl(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))}[el](){return"Multiaddr(".concat(ro(ul,this),")")}}function gl(e){return new pl(e)}!function(e){e.Relay="relay",e.Store="store",e.LightPush="lightpush",e.Filter="filter"}(ol||(ol={})),function(e){e.GENERIC_FAIL="Generic error",e.ENCODE_FAILED="Failed to encode",e.DECODE_FAILED="Failed to decode",e.SIZE_TOO_BIG="Size is too big",e.NO_RPC_RESPONSE="No RPC response"}(sl||(sl={})),function(e){e.BACKWARD="backward",e.FORWARD="forward"}(al||(al={})),function(e){e.BOOTSTRAP="bootstrap",e.PEER_EXCHANGE="peer-exchange"}(cl||(cl={})),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"}(ll||(ll={}));var bl,yl=__webpack_require__(6522),ml=new WeakMap;class wl extends EventTarget{constructor(){super(...arguments),eo(this,ml,new Map)}listenerCount(e){const t=ro(ml,this).get(e);return null==t?0:t.length}addEventListener(e,t,r){var n;super.addEventListener(e,t,r);let i=ro(ml,this).get(e);null==i&&(i=[],ro(ml,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=ro(ml,this).get(e);null!=n&&(n=n.filter((e=>{let{callback:r}=e;return r!==t})),ro(ml,this).set(e,n))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=ro(ml,this).get(e.type);return null==r||(r=r.filter((e=>{let{once:t}=e;return!t})),ro(ml,this).set(e.type,r)),t}safeDispatchEvent(e,t){return this.dispatchEvent(new _l(e,t))}}class vl extends Event{constructor(e,t){super(e,t),Ji(this,"detail",void 0),this.detail=null===t||void 0===t?void 0:t.detail}}const _l=null!==(bl=globalThis.CustomEvent)&&void 0!==bl?bl:vl;function El(e){if("string"===typeof e){return kc(e.replace(/^0x/i,"").toLowerCase(),"base16")}return e}const Sl=e=>za(e,"base16"),Al=e=>za(e,"utf8"),xl=e=>kc(e,"utf8");const kl=Math.pow(2,7),Cl=Math.pow(2,14),Il=Math.pow(2,21),Tl=Math.pow(2,28),Pl=Math.pow(2,35),Rl=Math.pow(2,42),Dl=Math.pow(2,49),Nl=128,Bl=127;function Ll(e){if(e<kl)return 1;if(e<Cl)return 2;if(e<Il)return 3;if(e<Tl)return 4;if(e<Pl)return 5;if(e<Rl)return 6;if(e<Dl)return 7;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ul(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(Ll(e)){case 8:t[r++]=255&e|Nl,e/=128;case 7:t[r++]=255&e|Nl,e/=128;case 6:t[r++]=255&e|Nl,e/=128;case 5:t[r++]=255&e|Nl,e/=128;case 4:t[r++]=255&e|Nl,e>>>=7;case 3:t[r++]=255&e|Nl,e>>>=7;case 2:t[r++]=255&e|Nl,e>>>=7;case 1:t[r++]=255&e,e>>>=7;break;default:throw new Error("unreachable")}return t}function Ml(e,t){let r=e[t],n=0;if(n+=r&Bl,r<Nl)return n;if(r=e[t+1],n+=(r&Bl)<<7,r<Nl)return n;if(r=e[t+2],n+=(r&Bl)<<14,r<Nl)return n;if(r=e[t+3],n+=(r&Bl)<<21,r<Nl)return n;if(r=e[t+4],n+=(r&Bl)*Tl,r<Nl)return n;if(r=e[t+5],n+=(r&Bl)*Pl,r<Nl)return n;if(r=e[t+6],n+=(r&Bl)*Rl,r<Nl)return n;if(r=e[t+7],n+=(r&Bl)*Dl,r<Nl)return n;throw new RangeError("Could not decode varint")}function Ol(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)}(Ll(e))),t instanceof Uint8Array?Ul(e,t,r):function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(Ll(e)){case 8:t.set(r++,255&e|Nl),e/=128;case 7:t.set(r++,255&e|Nl),e/=128;case 6:t.set(r++,255&e|Nl),e/=128;case 5:t.set(r++,255&e|Nl),e/=128;case 4:t.set(r++,255&e|Nl),e>>>=7;case 3:t.set(r++,255&e|Nl),e>>>=7;case 2:t.set(r++,255&e|Nl),e>>>=7;case 1:t.set(r++,255&e),e>>>=7;break;default:throw new Error("unreachable")}return t}(e,t,r)}function ql(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e instanceof Uint8Array?Ml(e,t):function(e,t){let r=e.get(t),n=0;if(n+=r&Bl,r<Nl)return n;if(r=e.get(t+1),n+=(r&Bl)<<7,r<Nl)return n;if(r=e.get(t+2),n+=(r&Bl)<<14,r<Nl)return n;if(r=e.get(t+3),n+=(r&Bl)<<21,r<Nl)return n;if(r=e.get(t+4),n+=(r&Bl)*Tl,r<Nl)return n;if(r=e.get(t+5),n+=(r&Bl)*Pl,r<Nl)return n;if(r=e.get(t+6),n+=(r&Bl)*Rl,r<Nl)return n;if(r=e.get(t+7),n+=(r&Bl)*Dl,r<Nl)return n;throw new RangeError("Could not decode varint")}(e,t)}const zl=new Float32Array([-0]),Fl=new Uint8Array(zl.buffer);function Kl(e,t,r){zl[0]=e,t[r]=Fl[0],t[r+1]=Fl[1],t[r+2]=Fl[2],t[r+3]=Fl[3]}const Vl=new Float64Array([-0]),jl=new Uint8Array(Vl.buffer);function Hl(e,t,r){Vl[0]=e,t[r]=jl[0],t[r+1]=jl[1],t[r+2]=jl[2],t[r+3]=jl[3],t[r+4]=jl[4],t[r+5]=jl[5],t[r+6]=jl[6],t[r+7]=jl[7]}const Wl=BigInt(Number.MAX_SAFE_INTEGER),Gl=BigInt(Number.MIN_SAFE_INTEGER);class Yl{constructor(e,t){Ji(this,"lo",void 0),Ji(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 Ql;if(e<Wl&&e>Gl)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>Jl&&(n=0n,++r>Jl&&(r=0n))),new Yl(Number(n),Number(r))}static fromNumber(e){if(0===e)return Ql;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 Yl(r,n)}static from(e){return"number"===typeof e?Yl.fromNumber(e):"bigint"===typeof e?Yl.fromBigInt(e):"string"===typeof e?Yl.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Yl(e.low>>>0,e.high>>>0):Ql}}const Ql=new Yl(0,0);Ql.toBigInt=function(){return 0n},Ql.zzEncode=Ql.zzDecode=function(){return this},Ql.length=function(){return 1};const Jl=4294967296n;function Xl(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 Zl(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function $l(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class eu{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,Zl(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 Zl(this,4);return $l(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Zl(this,4);return 0|$l(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw Zl(this,4);const e=(t=this.buf,r=this.pos,Fl[0]=t[r],Fl[1]=t[r+1],Fl[2]=t[r+2],Fl[3]=t[r+3],zl[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Zl(this,4);const e=(t=this.buf,r=this.pos,jl[0]=t[r],jl[1]=t[r+1],jl[2]=t[r+2],jl[3]=t[r+3],jl[4]=t[r+4],jl[5]=t[r+5],jl[6]=t[r+6],jl[7]=t[r+7],Vl[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 Zl(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 Zl(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Zl(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 Yl(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Zl(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 Zl(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 Zl(this,8);const e=$l(this.buf,this.pos+=4),t=$l(this.buf,this.pos+=4);return new Yl(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 tu(e,t,r){const n=function(e){return new eu(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function ru(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function nu(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 iu=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const ou=iu;class su{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 au{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 lu(this,e)}}class cu{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return lu(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 lu(e,t){var r,n;return new cu({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class uu{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new su(e,t,r),this.decoder=new au(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function hu(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new uu(t,r,n,i)}function du(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=ou(n,t);return hu({prefix:r,name:t,encode:i,decode:e=>nu(o(e))})}function fu(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return hu({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 pu=du({prefix:"9",name:"base10",alphabet:"0123456789"}),gu=fu({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bu=fu({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),yu=fu({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),mu=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"),wu=mu.reduce(((e,t,r)=>(e[r]=t,e)),[]),vu=mu.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const _u=hu({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=wu[t]),"")},decode:function(e){const t=[];for(const r of e){const e=vu[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Eu=fu({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Su=fu({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Au=fu({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xu=fu({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ku=fu({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Cu=fu({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Iu=fu({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tu=fu({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pu=fu({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Ru=du({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Du=du({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Nu=du({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bu=du({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Lu=fu({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Uu=fu({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Mu=fu({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ou=fu({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),qu=fu({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),zu=hu({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)}),Fu=new TextEncoder,Ku=new TextDecoder,Vu="json",ju=512;function Hu(e){return Fu.encode(JSON.stringify(e))}function Wu(e){return JSON.parse(Ku.decode(e))}const Gu="raw",Yu=85;function Qu(e){return nu(e)}function Ju(e){return nu(e)}var Xu=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=eh;)r[n++]=255&t|Zu,t/=128;for(;t&$u;)r[n++]=255&t|Zu,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Zu=128,$u=-128,eh=Math.pow(2,31);var th=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&nh)<<o:(n&nh)*Math.pow(2,o),o+=7}while(n>=rh);return e.bytes=s-r,i},rh=128,nh=127;var ih=Math.pow(2,7),oh=Math.pow(2,14),sh=Math.pow(2,21),ah=Math.pow(2,28),ch=Math.pow(2,35),lh=Math.pow(2,42),uh=Math.pow(2,49),hh=Math.pow(2,56),dh=Math.pow(2,63);const fh={encode:Xu,decode:th,encodingLength:function(e){return e<ih?1:e<oh?2:e<sh?3:e<ah?4:e<ch?5:e<lh?6:e<uh?7:e<hh?8:e<dh?9:10}};function ph(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return fh.encode(e,t,r),t}function gh(e){return fh.encodingLength(e)}function bh(e,t){const r=t.byteLength,n=gh(e),i=n+gh(r),o=new Uint8Array(i+r);return ph(e,o,0),ph(r,o,n),o.set(t,i),new yh(e,r,t,o)}class yh{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const mh=nu;const wh={code:0,name:"identity",encode:mh,digest:function(e){return bh(0,mh(e))}};function vh(e){let{name:t,code:r,encode:n}=e;return new _h(t,r,n)}class _h{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?bh(this.code,t):t.then((e=>bh(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Eh(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Sh=vh({name:"sha2-256",code:18,encode:Eh("SHA-256")}),Ah=vh({name:"sha2-512",code:19,encode:Eh("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const xh={...M,...P,...U,...I,...T,...D,...N,...B,...L,...R};function kh(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ch=kh("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Ih=kh("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=ru((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Th={utf8:Ch,"utf-8":Ch,hex:xh.base16,latin1:Ih,ascii:Ih,binary:Ih,...xh};class Ph{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Rh(){}class Dh{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Nh=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 ru(e);i+e>t&&(n=ru(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class Bh{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new Ph(Rh,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Ph(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Mh((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Oh,10,Yl.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=Yl.fromBigInt(e);return this._push(Oh,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=Yl.fromBigInt(e).zzEncode();return this._push(Oh,t.length(),t)}sint64Number(e){const t=Yl.fromNumber(e).zzEncode();return this._push(Oh,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Lh,1,e?1:0)}fixed32(e){return this._push(qh,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=Yl.fromBigInt(e);return this._push(qh,4,t.lo)._push(qh,4,t.hi)}fixed64Number(e){const t=Yl.fromNumber(e);return this._push(qh,4,t.lo)._push(qh,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(Kl,4,e)}double(e){return this._push(Hl,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Lh,1,0):this.uint32(t)._push(zh,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(Xl,t,e):this._push(Lh,1,0)}fork(){return this.states=new Dh(this),this.head=this.tail=new Ph(Rh,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 Ph(Rh,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?ru(r):Nh(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Lh(e,t,r){t[r]=255&e}function Uh(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Mh extends Ph{constructor(e,t){super(Uh,e,t),Ji(this,"next",void 0),this.next=void 0}}function Oh(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 qh(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 zh(e,t,r){t.set(e,r)}function Fh(e,t,r){t.set(e,r)}function Kh(e,t,r){e.length<40?Xl(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=Th[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function Vh(e,t){const r=new Bh;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var jh,Hh,Wh,Gh,Yh,Qh,Jh,Xh,Zh,$h,ed,td,rd,nd,id,od,sd,ad,cd,ld,ud,hd,dd,fd,pd,gd,bd,yd,md,wd,vd;function _d(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Ed(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return _d("enum",jh.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}function Sd(e,t){return _d("message",jh.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Bh.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Fh,t,e),this},Bh.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Kh,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"}(jh||(jh={}));Error;!function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Hh||(Hh={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),Hh.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=Hh.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Wh||(Wh={})),function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(t=e.ContentFilter||(e.ContentFilter={})),e.codec=()=>(null==r&&(r=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Gh||(Gh={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),Xh.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(Xh.codec().decode(e,e.uint32()));else e.skipType(7&t)}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Yh||(Yh={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),Gh.codec().encode(e.request,t)),null!=e.push&&(t.uint32(26),Yh.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=Gh.codec().decode(e,e.uint32());break;case 3:r.push=Yh.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Qh||(Qh={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Jh||(Jh={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),Jh.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=Jh.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Xh||(Xh={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(Zh||(Zh={})),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=()=>Ed(r)}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),e.codec=()=>(null==n&&(n=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}($h||($h={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(ed||(ed={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),nd.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=nd.codec().decode(e,e.uint32());break;case 2:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(td||(td={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(rd||(rd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),rd.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=rd.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(nd||(nd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),cd.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=cd.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(id||(id={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(od||(od={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),id.codec().encode(e.request,t)),null!=e.response&&(t.uint32(26),od.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=id.codec().decode(e,e.uint32());break;case 3:r.response=od.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(sd||(sd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(ad||(ad={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),ad.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=ad.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(cd||(cd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(ld||(ld={})),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=()=>Ed(r)}(t=e.Direction||(e.Direction={})),e.codec=()=>(null==n&&(n=Sd((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),ld.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=ld.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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(ud||(ud={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(hd||(hd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),hd.codec().encode(n,t);null!=e.pagingInfo&&(t.uint32(34),ud.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(hd.codec().decode(e,e.uint32()));break;case 4:r.pagingInfo=ud.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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(dd||(dd={})),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=()=>Ed(r)}(t=e.HistoryError||(e.HistoryError={})),e.codec=()=>(null==n&&(n=Sd((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),bd.codec().encode(e,n);null!=t.pagingInfo&&(n.uint32(26),ud.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(bd.codec().decode(r,r.uint32()));break;case 3:i.pagingInfo=ud.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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(fd||(fd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),dd.codec().encode(e.query,t)),null!=e.response&&(t.uint32(26),fd.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=dd.codec().decode(e,e.uint32());break;case 3:r.response=fd.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(pd||(pd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(gd||(gd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),gd.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=gd.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(bd||(bd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(yd||(yd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(md||(md={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),yd.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(yd.codec().decode(e,e.uint32()));else e.skipType(7&t)}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(wd||(wd={})),function(e){let t;e.codec=()=>(null==t&&(t=Sd((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),md.codec().encode(e.query,t)),null!=e.response&&(t.uint32(18),wd.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=md.codec().decode(e,e.uint32());break;case 2:r.response=wd.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Vh(t,e.codec()),e.decode=t=>tu(t,e.codec())}(vd||(vd={}));const Ad=yl("waku:message:version-0"),xd=BigInt(1e6);class kd{constructor(e,t){Ji(this,"pubSubTopic",void 0),Ji(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/xd;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 Cd{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0;if(Ji(this,"contentTopic",void 0),Ji(this,"ephemeral",void 0),Ji(this,"metaSetter",void 0),this.contentTopic=e,this.ephemeral=t,this.metaSetter=r,!e||""===e)throw new Error("Content topic must be specified")}async toWire(e){return Wh.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())*xd,meta:void 0,rateLimitProof:e.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const e=this.metaSetter(n);return{...n,meta:e}}return n}}function Id(e){let{contentTopic:t,ephemeral:r,metaSetter:n}=e;return new Cd(t,r,n)}class Td{constructor(e){if(Ji(this,"contentTopic",void 0),this.contentTopic=e,!e||""===e)throw new Error("Content topic must be specified")}fromWireToProtoObj(e){var t,r,n,i,o;const s=Wh.decode(e);return Ad("Message decoded",s),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?(Ad("Failed to decode due to incorrect version, expected:",0,", actual:",t.version),Promise.resolve(void 0)):new kd(e,t)}}function Pd(e){return new Td(e)}const Rd=yl("waku:keep-alive");class Dd{constructor(e,t){Ji(this,"pingKeepAliveTimers",void 0),Ji(this,"relayKeepAliveTimers",void 0),Ji(this,"options",void 0),Ji(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()=>{try{const i=await t.ping(e);Rd("Ping succeeded (".concat(o,")"),i);try{await r.patch(e,{metadata:{ping:xl(i.toString())}})}catch(n){Rd("Failed to update ping",n)}}catch(n){Rd("Ping failed (".concat(o,")"),n)}})()}),1e3*n);this.pingKeepAliveTimers.set(o,i)}const s=this.relay;if(s&&0!==i){const t=Id({contentTopic:"/relay-ping/1/ping/null",ephemeral:!0}),r=setInterval((()=>{Rd("Sending Waku Relay ping message"),s.send(t,{payload:new Uint8Array([1])}).catch((e=>Rd("Failed to send relay ping",e)))}),1e3*i);this.relayKeepAliveTimers.set(e,r)}}stop(e){const t=e.toString();this.pingKeepAliveTimers.has(t)&&(clearInterval(this.pingKeepAliveTimers.get(t)),this.pingKeepAliveTimers.delete(t)),this.relayKeepAliveTimers.has(e)&&(clearInterval(this.relayKeepAliveTimers.get(e)),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()}}const Nd=yl("waku:connection-manager");class Bd extends wl{static create(e,t,r,n,i){let o=Bd.instances.get(e);return o||(o=new Bd(t,r,n,i),Bd.instances.set(e,o)),o}async getPeersByDiscovery(){const e=await this.libp2p.peerStore.all(),t=this.libp2p.getConnections().map((e=>e.remotePeer)),r=[],n=[],i=[],o=[];for(const s of e){const e=await this.getTagNamesForPeer(s.id);e.includes(cl.BOOTSTRAP)?r.push(s):e.includes(cl.PEER_EXCHANGE)&&n.push(s)}for(const s of t){const e=await this.libp2p.peerStore.get(s),t=await this.getTagNamesForPeer(s);t.includes(cl.BOOTSTRAP)?i.push(e):t.includes(cl.PEER_EXCHANGE)&&o.push(e)}return{DISCOVERED:{[cl.BOOTSTRAP]:r,[cl.PEER_EXCHANGE]:n},CONNECTED:{[cl.BOOTSTRAP]:i,[cl.PEER_EXCHANGE]:o}}}constructor(e,t,r,n){super(),Ji(this,"keepAliveManager",void 0),Ji(this,"options",void 0),Ji(this,"libp2p",void 0),Ji(this,"dialAttemptsForPeer",new Map),Ji(this,"dialErrorsForPeer",new Map),Ji(this,"currentActiveDialCount",0),Ji(this,"pendingPeerDialQueue",[]),Ji(this,"onEventHandlers",{"peer:discovery":e=>{(async()=>{const{id:t}=e.detail,r=(await this.getTagNamesForPeer(t)).includes(cl.BOOTSTRAP);this.dispatchEvent(new _l(r?ll.PEER_DISCOVERY_BOOTSTRAP:ll.PEER_DISCOVERY_PEER_EXCHANGE,{detail:t}));try{await this.attemptDial(t)}catch(n){Nd("Error dialing peer ".concat(t.toString()," : ").concat(n))}})()},"peer:connect":e=>{(async()=>{const t=e.detail;this.keepAliveManager.start(t,this.libp2p.services.ping,this.libp2p.peerStore);if((await this.getTagNamesForPeer(t)).includes(cl.BOOTSTRAP)){this.libp2p.getConnections().filter((e=>e.tags.includes(cl.BOOTSTRAP))).length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(t):this.dispatchEvent(new _l(ll.PEER_CONNECT_BOOTSTRAP,{detail:t}))}else this.dispatchEvent(new _l(ll.PEER_CONNECT_PEER_EXCHANGE,{detail:t}))})()},"peer:disconnect":()=>e=>{this.keepAliveManager.stop(e.detail)}}),this.libp2p=e,this.options={maxDialAttemptsForPeer:3,maxBootstrapPeersAllowed:1,maxParallelDials:3,...n},this.keepAliveManager=new Dd(t,r),this.run().then((()=>Nd("Connection Manager is now running"))).catch((e=>Nd("Unexpected error while running service",e))),this.dialPeerStorePeers().catch((e=>Nd("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){Nd("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.currentActiveDialCount+=1;let t=0;for(;t<this.options.maxDialAttemptsForPeer;)try{Nd("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.delete(e.toString());break}catch(r){r instanceof AggregateError?Nd("Error dialing peer ".concat(e.toString()," - ").concat(r.errors)):Nd("Error dialing peer ".concat(e.toString()," - ").concat(r.message)),this.dialErrorsForPeer.set(e.toString(),r),t++,this.dialAttemptsForPeer.set(e.toString(),t)}if(this.currentActiveDialCount--,this.processDialQueue(),t===this.options.maxDialAttemptsForPeer)try{const t=this.dialErrorsForPeer.get(e.toString());let r;r=t instanceof AggregateError?JSON.stringify(t.errors[0]):t.message,Nd("Deleting undialable peer ".concat(e.toString()," from peer store. Error: ").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),Nd("Dropped connection with peer ".concat(e.toString()))}catch(t){Nd("Error dropping connection with peer ".concat(e.toString()," - ").concat(t))}}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveDialCount<this.options.maxParallelDials){const e=this.pendingPeerDialQueue.shift();if(!e)return;this.attemptDial(e).catch((e=>{Nd(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){this.currentActiveDialCount>=this.options.maxParallelDials?this.pendingPeerDialQueue.push(e):await this.shouldDialPeer(e)&&this.dialPeer(e).catch((t=>{throw"Error dialing peer ".concat(e.toString()," : ").concat(t)}))}async shouldDialPeer(e){if(this.libp2p.getConnections(e).length>0)return!1;if(!(await this.getTagNamesForPeer(e)).some((e=>e===cl.BOOTSTRAP)))return!0;if(this.libp2p.getConnections().filter((e=>e.tags.find((e=>e===cl.BOOTSTRAP)))).length<this.options.maxBootstrapPeersAllowed)return!0;return!1}async getTagNamesForPeer(e){try{const t=await this.libp2p.peerStore.get(e);return Array.from(t.tags.keys())}catch(t){return Nd("Failed to get peer ".concat(e,", error: ").concat(t)),[]}}}Ji(Bd,"instances",new Map);const Ld="js-waku",Ud=yl("waku:waku");class Md{constructor(e,t,r,n,i,o){Ji(this,"libp2p",void 0),Ji(this,"relay",void 0),Ji(this,"store",void 0),Ji(this,"filter",void 0),Ji(this,"lightPush",void 0),Ji(this,"connectionManager",void 0),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||0,a=this.relay?e.relayKeepAlive||300:0,c=this.libp2p.peerId.toString();this.connectionManager=Bd.create(c,t,{pingKeepAlive:s,relayKeepAlive:a},this.relay),Ud("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 Zi(e)?e:gl(e)}(e);"undefined"===typeof t&&(this.relay&&r.push(ol.Relay),this.store&&r.push(ol.Store),this.filter&&r.push(ol.Filter),this.lightPush&&r.push(ol.LightPush));const i=[];return r.includes(ol.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach((e=>i.push(e))):Ud("Relay codec not included in dial codec: protocol not mounted locally")),r.includes(ol.Store)&&(this.store?i.push(this.store.multicodec):Ud("Store codec not included in dial codec: protocol not mounted locally")),r.includes(ol.LightPush)&&(this.lightPush?i.push(this.lightPush.multicodec):Ud("Light Push codec not included in dial codec: protocol not mounted locally")),r.includes(ol.Filter)&&(this.filter?i.push(this.filter.multicodec):Ud("Filter codec not included in dial codec: protocol not mounted locally")),Ud("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()}isStarted(){return this.libp2p.isStarted()}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 Od="/waku/2/default-waku/proto";function qd(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}async function zd(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),l=null!==(i=null===r||void 0===r?void 0:r.timeoutMs)&&void 0!==i?i:0,u=Date.now();return{iterator:async function*(){for(;;){if(c&&Date.now()-u>=l)return;await Fd(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 Fd(e){return new Promise((t=>{setTimeout(t,e)}))}const Kd=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 Vd(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function jd(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Hd(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=jd(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Wd(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("@achingbrain/uint8arraylist");function Yd(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 Qd(e){return Boolean(null===e||void 0===e?void 0:e[Gd])}class Jd{constructor(){Ji(this,"bufs",void 0),Ji(this,"length",void 0),Ji(this,Gd,!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(!Qd(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(!Qd(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=Yd(this.bufs,e);return t.buf[t.index]}set(e,t){const r=Yd(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(!Qd(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 Hd(r,n)}subarray(e,t){const{bufs:r,length:n}=this._subList(e,t);return 1===r.length?r[0]:Hd(r,n)}sublist(e,t){const{bufs:r,length:n}=this._subList(e,t),i=new Jd;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,l=t>n&&t<=a;if(c&&l){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(l){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(!Qd(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 u=0;u<256;u++)o[u]=-1;for(let u=0;u<i;u++)o[n[u]]=u;const s=o,a=this.byteLength-n.byteLength,c=n.byteLength-1;let l;for(let u=r;u<=a;u+=l){l=0;for(let e=c;e>=0;e--){const t=this.get(u+e);if(n[e]!==t){l=Math.max(1,e-s[t]);break}}if(0===l)return u}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=jd(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=Vd(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=Vd(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=Vd(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=jd(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=Vd(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=Vd(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=Vd(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=Vd(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=Vd(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 Jd))return!1;if(e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Wd(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){const r=new Jd;return r.bufs=e,null==t&&(t=e.reduce(((e,t)=>e+t.byteLength),0)),r.length=t,r}}function Xd(e){return null!=e[Symbol.asyncIterator]}const Zd=e=>{const t=Ll(e),r=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}(t);return Ol(e,r),Zd.bytes=t,r};function $d(e,t){var r,n;const i=null!==(n=(t=null!==(r=t)&&void 0!==r?r:{}).lengthEncoder)&&void 0!==n?n:Zd;function*o(e){const t=i(e.byteLength);t instanceof Uint8Array?yield t:yield*t,e instanceof Uint8Array?yield e:yield*e}return Xd(e)?async function*(){for await(const t of e)yield*o(t)}():function*(){for(const t of e)yield*o(t)}()}Zd.bytes=0,$d.single=(e,t)=>{var r,n;const i=null!==(n=(t=null!==(r=t)&&void 0!==r?r:{}).lengthEncoder)&&void 0!==n?n:Zd;return new Jd(i(e.byteLength),e)};var ef=__webpack_require__(4823);const tf=8,rf=4194304;var nf;!function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"}(nf||(nf={}));const of=e=>{const t=ql(e);return of.bytes=Ll(t),t};function sf(e,t){var r,n,i;const o=new Jd;let s=nf.LENGTH,a=-1;const c=null!==(r=null===t||void 0===t?void 0:t.lengthDecoder)&&void 0!==r?r:of,l=null!==(n=null===t||void 0===t?void 0:t.maxLengthLength)&&void 0!==n?n:tf,u=null!==(i=null===t||void 0===t?void 0:t.maxDataLength)&&void 0!==i?i:rf;function*h(){for(;o.byteLength>0;){if(s===nf.LENGTH)try{if(a=c(o),a<0)throw ef(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(a>u)throw ef(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=nf.DATA}catch(e){if(e instanceof RangeError){if(o.byteLength>l)throw ef(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw e}if(s===nf.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=nf.LENGTH}}}return Xd(e)?async function*(){for await(const t of e)o.append(t),yield*h();if(o.byteLength>0)throw ef(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 ef(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}function af(){const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}of.bytes=0,sf.fromReader=(e,t)=>{let r=1;return sf(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 cf{constructor(e){if(Ji(this,"buffer",void 0),Ji(this,"mask",void 0),Ji(this,"top",void 0),Ji(this,"btm",void 0),Ji(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 lf{constructor(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ji(this,"size",void 0),Ji(this,"hwm",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),this.hwm=null!==(e=t.splitLimit)&&void 0!==e?e:16,this.head=new cf(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 cf(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 uf extends Error{constructor(e,t){super(null!==e&&void 0!==e?e:"The operation was aborted"),Ji(this,"type",void 0),Ji(this,"code",void 0),this.type="aborted",this.code=null!==t&&void 0!==t?t:"ABORT_ERR"}}function hf(){return df((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 df(e,t){var r;let n,i,o,s=(t=null!==(r=t)&&void 0!==r?r:{}).onEnd,a=new lf,c=af();const l=e=>null!=i?i(e):(a.push(e),n),u=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 l({done:!1,value:e})},h=e=>o?n:(o=!0,null!=e?(e=>(a=new lf,null!=i?i({error:e}):(a.push({error:e}),n)))(e):l({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=af()}))}},return:()=>(a=new lf,h(),{done:!0}),throw:e=>(h(e),{done:!0}),push:u,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 uf)},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:u,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 ff=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=hf({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 pf(e){if(null==e)throw new Error("Empty pipeline");if(mf(e)){const t=e;e=()=>t.source}else if(yf(e)||bf(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&&mf(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++)mf(i[o])&&(i[o]=wf(i[o]));return gf(...i)}const gf=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},bf=e=>null!=(null===e||void 0===e?void 0:e[Symbol.asyncIterator]),yf=e=>null!=(null===e||void 0===e?void 0:e[Symbol.iterator]),mf=e=>null!=e&&(null!=e.sink&&null!=e.source),wf=e=>t=>{const r=e.sink(t);if(null!=(null===r||void 0===r?void 0:r.then)){const t=hf({objectMode:!0});let n;r.then((()=>{t.end()}),(e=>{t.end(e)}));const i=e.source;if(bf(i))n=async function*(){yield*i,t.end()};else{if(!yf(i))throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");n=function*(){yield*i,t.end()}}return ff(t,n())}return e.source},vf=yl("waku:libp2p-utils");async function _f(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}async function Ef(e,t,r){let n,i;if(r){if(n=await e.get(r),!n)throw new Error("Failed to retrieve connection details for provided peer in peer store: ".concat(r.toString()))}else{const r=await _f(e,t);if(n=await async function(e,t){if(0===t.length)return;const r=(await Promise.all(t.map((async t=>{var r;const n=(await e.get(t.id)).metadata.get("ping");return n?{peer:t,ping:null!==(r=Number(Al(n)))&&void 0!==r?r:1/0}:{peer:t,ping:1/0}})))).sort(((e,t)=>e.ping-t.ping))[0];return r&&r.ping!==1/0?r.peer:void 0}(e,r),!n&&(n=function(e){if(0===e.length)return;return e[Math.round(Math.random()*(e.length-1))]}(r),!n))throw new Error("Failed to find known peer that registers protocols: ".concat(t))}for(const o of t)n.protocols.includes(o)&&(i=o);if(vf("Using codec ".concat(i)),!i)throw new Error("Peer does not register required protocols (".concat(n.id.toString(),"): ").concat(t));return{peer:n,protocol:i}}class Sf{constructor(e,t,r){Ji(this,"multicodec",void 0),Ji(this,"getConnections",void 0),Ji(this,"addEventListener",void 0),Ji(this,"streamPool",void 0),Ji(this,"log",void 0),Ji(this,"handlePeerUpdateStreamPool",(e=>{const t=e.detail.peer;t.protocols.includes(this.multicodec)&&(this.log("Preemptively opening a stream to ".concat(t.id.toString())),this.prepareNewStream(t))})),this.multicodec=e,this.getConnections=t,this.addEventListener=r,this.log=yl("waku: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"closed"===n.status?this.newStream(e):n}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);this.streamPool.set(e.id.toString(),t)}}class Af{constructor(e,t){Ji(this,"multicodec",void 0),Ji(this,"components",void 0),Ji(this,"addLibp2pEventListener",void 0),Ji(this,"removeLibp2pEventListener",void 0),Ji(this,"streamManager",void 0),this.multicodec=e,this.components=t,this.addLibp2pEventListener=t.events.addEventListener.bind(t.events),this.removeLibp2pEventListener=t.events.removeEventListener.bind(t.events),this.streamManager=new Sf(e,t.connectionManager.getConnections.bind(t.connectionManager),this.addLibp2pEventListener)}async getStream(e){return this.streamManager.getStream(e)}get peerStore(){return this.components.peerStore}async peers(){return _f(this.peerStore,[this.multicodec])}async getPeer(e){const{peer:t}=await Ef(this.peerStore,[this.multicodec],e);return t}async getPeers(){let{numPeers:e,maxBootstrapPeers:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{maxBootstrapPeers:1,numPeers:0};return async function(e,t,r){const n=e.filter((e=>e.tags.has(cl.BOOTSTRAP))).slice(0,r),i=e.filter((e=>!e.tags.has(cl.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}(await _f(this.peerStore,[this.multicodec]),e,t)}}const xf={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let kf;const Cf=new Uint8Array(16);function If(){if(!kf&&(kf="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!kf))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return kf(Cf)}const Tf=[];for(let nle=0;nle<256;++nle)Tf.push((nle+256).toString(16).slice(1));function Pf(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Tf[e[t+0]]+Tf[e[t+1]]+Tf[e[t+2]]+Tf[e[t+3]]+"-"+Tf[e[t+4]]+Tf[e[t+5]]+"-"+Tf[e[t+6]]+Tf[e[t+7]]+"-"+Tf[e[t+8]]+Tf[e[t+9]]+"-"+Tf[e[t+10]]+Tf[e[t+11]]+Tf[e[t+12]]+Tf[e[t+13]]+Tf[e[t+14]]+Tf[e[t+15]]}const Rf=function(e,t,r){if(xf.randomUUID&&!t&&!e)return xf.randomUUID();const n=(e=e||{}).random||(e.rng||If)();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 Pf(n)};class Df{constructor(e){Ji(this,"proto",void 0),this.proto=e}static decode(e){const t=td.decode(e);return new Df(t)}encode(){return td.encode(this.proto)}get wakuMessage(){return this.proto.wakuMessage}get pubsubTopic(){return this.proto.pubsubTopic}}class Nf{constructor(e){Ji(this,"proto",void 0),this.proto=e}static createSubscribeRequest(e,t){return new Nf({requestId:Rf(),filterSubscribeType:$h.FilterSubscribeType.SUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeRequest(e,t){return new Nf({requestId:Rf(),filterSubscribeType:$h.FilterSubscribeType.UNSUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeAllRequest(e){return new Nf({requestId:Rf(),filterSubscribeType:$h.FilterSubscribeType.UNSUBSCRIBE_ALL,pubsubTopic:e,contentTopics:[]})}static createSubscriberPingRequest(){return new Nf({requestId:Rf(),filterSubscribeType:$h.FilterSubscribeType.SUBSCRIBER_PING,pubsubTopic:"",contentTopics:[]})}static decode(e){const t=$h.decode(e);return new Nf(t)}encode(){return $h.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 Bf{constructor(e){Ji(this,"proto",void 0),this.proto=e}static decode(e){const t=ed.decode(e);return new Bf(t)}encode(){return ed.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get requestId(){return this.proto.requestId}}const Lf=yl("waku:filter:v2"),Uf="/vac/waku/filter-subscribe/2.0.0-beta1",Mf="/vac/waku/filter-push/2.0.0-beta1";class Of{constructor(e,t,r){Ji(this,"peer",void 0),Ji(this,"pubSubTopic",void 0),Ji(this,"newStream",void 0),Ji(this,"subscriptionCallbacks",void 0),this.peer=t,this.pubSubTopic=e,this.newStream=r,this.subscriptionCallbacks=new Map}async subscribe(e,t){const r=qd(Array.isArray(e)?e:[e]),n=Array.from(r.keys()),i=await this.newStream(this.peer),o=Nf.createSubscribeRequest(this.pubSubTopic,n);try{const e=await pf([o.encode()],$d,i,sf,(async e=>await Kd(e))),{statusCode:t,requestId:r,statusDesc:s}=Bf.decode(e[0].slice());if(t<200||t>=300)throw new Error("Filter subscribe request ".concat(r," failed with status code ").concat(t,": ").concat(s));Lf("Subscribed to peer ",this.peer.id.toString(),"for content topics",n)}catch(s){throw new Error("Error subscribing to peer: "+this.peer.id.toString()+" for content topics: "+n+": "+s)}r.forEach(((e,r)=>{const n={decoders:e,callback:t};this.subscriptionCallbacks.set(r,n)}))}async unsubscribe(e){const t=await this.newStream(this.peer),r=Nf.createUnsubscribeRequest(this.pubSubTopic,e);try{await pf([r.encode()],$d,t.sink)}catch(n){throw new Error("Error subscribing: "+n)}e.forEach((e=>{this.subscriptionCallbacks.delete(e)}))}async ping(){const e=await this.newStream(this.peer),t=Nf.createSubscriberPingRequest();try{const r=await pf([t.encode()],$d,e,sf,(async e=>await Kd(e))),{statusCode:n,requestId:i,statusDesc:o}=Bf.decode(r[0].slice());if(n<200||n>=300)throw new Error("Filter ping request ".concat(i," failed with status code ").concat(n,": ").concat(o));Lf("Ping successful")}catch(r){throw Lf("Error pinging: ",r),new Error("Error pinging: "+r)}}async unsubscribeAll(){const e=await this.newStream(this.peer),t=Nf.createUnsubscribeAllRequest(this.pubSubTopic);try{const r=await pf([t.encode()],$d,e,sf,(async e=>await Kd(e))),{statusCode:n,requestId:i,statusDesc:o}=Bf.decode(r[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(),Lf("Unsubscribed from all content topics")}catch(r){throw new Error("Error unsubscribing from all content topics: "+r)}}async processMessage(e){const t=e.contentTopic,r=this.subscriptionCallbacks.get(t);r?await async function(e,t,r){const{decoders:n,callback:i}=e,{contentTopic:o}=r;if(!o)return void Lf("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){Lf("Error decoding message",s)}}(r,this.pubSubTopic,e):Lf("No subscription callback available for ",t)}}class qf extends Af{getActiveSubscription(e,t){return this.activeSubscriptions.get("".concat(e,"_").concat(t))}setActiveSubscription(e,t,r){return this.activeSubscriptions.set("".concat(e,"_").concat(t),r),r}constructor(e,t){super(Uf,e.components),Ji(this,"options",void 0),Ji(this,"activeSubscriptions",new Map),Ji(this,"NUM_PEERS_PROTOCOL",1),e.handle(Mf,this.onRequest.bind(this)).catch((e=>{Lf("Failed to register ",Mf,e)})),this.activeSubscriptions=new Map,this.options=null!==t&&void 0!==t?t:{}}async createSubscription(e){var t,r;const n=null!==(t=null!==e&&void 0!==e?e:this.options.pubSubTopic)&&void 0!==t?t:Od,i=(await this.getPeers({maxBootstrapPeers:1,numPeers:this.NUM_PEERS_PROTOCOL}))[0];return null!==(r=this.getActiveSubscription(n,i.id.toString()))&&void 0!==r?r:this.setActiveSubscription(n,i.id.toString(),new Of(n,i,this.getStream.bind(this,i)))}toSubscriptionIterator(e){return zd(this,e)}async subscribe(e,t){const r=await this.createSubscription();await r.subscribe(e,t);const n=Array.from(qd(Array.isArray(e)?e:[e]).keys());return async()=>{await r.unsubscribe(n)}}onRequest(e){Lf("Receiving message push");try{pf(e.stream,sf,(async t=>{for await(const r of t){const t=Df.decode(r.slice()),{pubsubTopic:n,wakuMessage:i}=t;if(!i)return void Lf("Received empty message");if(!n)return void Lf("PubSub topic missing from push message");const o=e.connection.remotePeer.toString(),s=this.getActiveSubscription(n,o);if(!s)return void Lf("No subscription locally registered for topic ".concat(n));await s.processMessage(i)}})).then((()=>{Lf("Receiving pipe closed.")}),(e=>{Lf("Error with receiving pipe",e)}))}catch(t){Lf("Error decoding message",t)}}}const zf=e=>!(e.length/1048576>1);class Ff{constructor(e){Ji(this,"proto",void 0),this.proto=e}static createRequest(e,t){return new Ff({requestId:Rf(),request:{message:e,pubsubTopic:t},response:void 0})}static decode(e){const t=sd.decode(e);return new Ff(t)}encode(){return sd.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const Kf=yl("waku:light-push");class Vf extends Af{constructor(e,t){super("/vac/waku/lightpush/2.0.0-beta1",e.components),Ji(this,"options",void 0),Ji(this,"NUM_PEERS_PROTOCOL",1),this.options=t||{}}async preparePushMessage(e,t,r){try{if(!zf(t.payload))return Kf("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:sl.SIZE_TOO_BIG};const n=await e.toProtoObj(t);if(!n)return Kf("Failed to encode to protoMessage, aborting push"),{query:null,error:sl.ENCODE_FAILED};return{query:Ff.createRequest(n,r),error:null}}catch(n){return Kf("Failed to prepare push message",n),{query:null,error:sl.GENERIC_FAIL}}}async send(e,t){const{pubSubTopic:r=Od}=this.options,n=[],{query:i,error:o}=await this.preparePushMessage(e,t,r);if(o||!i)return{recipients:n,errors:[o]};const s=(await this.getPeers({maxBootstrapPeers:1,numPeers:this.NUM_PEERS_PROTOCOL})).map((async e=>{let t;const r=await this.getStream(e);try{const s=await pf([i.encode()],$d,r,sf,(async e=>await Kd(e)));try{const r=new Jd;s.forEach((e=>{r.append(e)}));const i=Ff.decode(r).response;null!==i&&void 0!==i&&i.isSuccess?n.some((t=>t.equals(e.id)))||n.push(e.id):(Kf("No response in PushRPC"),t=sl.NO_RPC_RESPONSE)}catch(o){Kf("Failed to decode push reply",o),t=sl.DECODE_FAILED}}catch(o){Kf("Failed to send waku light push request",o),t=sl.GENERIC_FAIL}return{recipients:n,error:t}})),a=(await Promise.allSettled(s)).filter((e=>"fulfilled"===e.status)).map((e=>e.value.error)).filter((e=>void 0!==e));return{recipients:n,errors:a}}}function jf(e){return Boolean(e)}const Hf={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};function Wf(e){return{...Hf,...e}}const Gf=BigInt(1e6);var Yf;!function(e){e.BACKWARD="backward",e.FORWARD="forward"}(Yf||(Yf={}));class Qf{constructor(e){Ji(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 Yf.BACKWARD:return ud.Direction.BACKWARD;case Yf.FORWARD:return ud.Direction.FORWARD;default:return ud.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())*Gf),e.endTime&&(o=BigInt(e.endTime.valueOf())*Gf),new Qf({requestId:Rf(),query:{pubsubTopic:e.pubSubTopic,contentFilters:t,pagingInfo:n,startTime:i,endTime:o},response:void 0})}decode(e){const t=pd.decode(e);return new Qf(t)}encode(){return pd.encode(this.proto)}}var Jf=fd.HistoryError;const Xf=yl("waku:store");class Zf extends Af{constructor(e,t){super("/vac/waku/store/2.0.0-beta4",e.components),Ji(this,"options",void 0),Ji(this,"NUM_PEERS_PROTOCOL",1),Ji(this,"queryOrderedCallback",this.queryWithOrderedCallback),this.options=null!==t&&void 0!==t?t:{}}async processMessages(e,t,r){let n=!1;let i=(await Promise.all(e)).filter(jf);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)===Yf.BACKWARD}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}}async*queryGenerator(e,t){const{pubSubTopic:r=Od}=this.options;let n,i;null!==t&&void 0!==t&&t.timeFilter&&(n=t.timeFilter.startTime,i=t.timeFilter.endTime);const o=new Map;e.forEach((e=>{if(o.has(e.contentTopic))throw new Error("API does not support different decoder per content topic");o.set(e.contentTopic,e)}));const s=e.map((e=>e.contentTopic)),a=Object.assign({pubSubTopic:r,pageDirection:Yf.BACKWARD,pageSize:10},t,{contentTopics:s,startTime:n,endTime:i});Xf("Querying history with the following options",t);const c=(await this.getPeers({numPeers:this.NUM_PEERS_PROTOCOL,maxBootstrapPeers:1}))[0];for await(const l of async function*(e,t,r,n){if(t.contentTopics.toString()!==Array.from(r.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let i=n;for(;;){var o,s,a;t.cursor=i;const n=Qf.createQuery(t);Xf("Querying store peer","for (".concat(t.pubSubTopic,")"),t.contentTopics);const c=await e(),l=await pf([n.encode()],$d,c,sf,(async e=>await Kd(e))),u=new Jd;l.forEach((e=>{u.append(e)}));const h=n.decode(u);if(!h.response){Xf("Stopping pagination due to store `response` field missing");break}const d=h.response;if(d.error&&d.error!==Jf.NONE)throw"History response contains an Error: "+d.error;if(!d.messages||!d.messages.length){Xf("Stopping pagination due to store `response.messages` field missing or empty");break}Xf("".concat(d.messages.length," messages retrieved from store")),yield d.messages.map((e=>{const n=e.contentTopic;if("undefined"!==typeof n){const i=r.get(n);if(i)return i.fromProtoObj(t.pubSubTopic,Wf(e))}return Promise.resolve(void 0)}));const f=null===(o=d.pagingInfo)||void 0===o?void 0:o.cursor;if("undefined"===typeof f){Xf("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");break}i=f;const p=null===(s=d.pagingInfo)||void 0===s?void 0:s.pageSize,g=null===(a=n.query)||void 0===a||null===(a=a.pagingInfo)||void 0===a?void 0:a.pageSize;if(p&&g&&p<g)break}}(this.getStream.bind(this,c),a,o,null===t||void 0===t?void 0:t.cursor))yield l}}class $f extends Error{constructor(e){super(e),this.name="TimeoutError"}}class ep extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const tp=e=>void 0===globalThis.DOMException?new ep(e):new DOMException(e),rp=e=>{const t=void 0===e.reason?tp("This operation was aborted."):e.reason;return t instanceof Error?t:tp(t)};const np=e=>{const t=e.on||e.addListener||e.addEventListener,r=e.off||e.removeListener||e.removeEventListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function ip(e,t,r){let n;const i=new Promise(((i,o)=>{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");const s=[t].flat(),a=[],{addListener:c,removeListener:l}=np(e),u=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)||(a.push(s),r.count===a.length&&(n(),i(a)))},h=e=>{n(),o(e)};n=()=>{for(const e of s)l(e,u);for(const e of r.rejectionEvents)l(e,h)};for(const e of s)c(e,u);for(const e of r.rejectionEvents)c(e,h);r.resolveImmediately&&i(a)}));if(i.cancel=n,"number"===typeof r.timeout){const e=function(e,t,r,n){let i;const o=new Promise(((o,s)=>{if("number"!==typeof t||1!==Math.sign(t))throw new TypeError("Expected `milliseconds` to be a positive number, got `".concat(t,"`"));if(t!==Number.POSITIVE_INFINITY){if((n={customTimers:{setTimeout:setTimeout,clearTimeout:clearTimeout},...n}).signal){const{signal:e}=n;e.aborted&&s(rp(e)),e.addEventListener("abort",(()=>{s(rp(e))}))}i=n.customTimers.setTimeout.call(void 0,(()=>{if("function"===typeof r){try{o(r())}catch(a){s(a)}return}const n="string"===typeof r?r:"Promise timed out after ".concat(t," milliseconds"),i=r instanceof Error?r:new $f(n);"function"===typeof e.cancel&&e.cancel(),s(i)}),t),(async()=>{try{o(await e)}catch(t){s(t)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()}else o(e)}));return o.clear=()=>{clearTimeout(i),i=void 0},o}(i,r.timeout);return e.cancel=n,e}return i}function op(e,t,r){"function"===typeof r&&(r={filter:r});const n=ip(e,t,r={...r,count:1,resolveImmediately:!1}),i=n.then((e=>e[0]));return i.cancel=n.cancel,i}const sp=yl("waku:wait-for-remote-peer");async function ap(e,t,r){var n;if(t=null!==(n=t)&&void 0!==n?n:function(e){const t=[];e.relay&&t.push(ol.Relay);e.filter&&t.push(ol.Filter);e.store&&t.push(ol.Store);e.lightPush&&t.push(ol.LightPush);return t}(e),!e.isStarted())return Promise.reject("Waku node is not started");const i=[];if(t.includes(ol.Relay)){if(!e.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");i.push(async function(e){let t=e.getMeshPeers();for(;0==t.length;)await op(e.gossipSub,"gossipsub:heartbeat"),t=e.getMeshPeers()}(e.relay))}if(t.includes(ol.Store)){if(!e.store)throw new Error("Cannot wait for Store peer: protocol not mounted");i.push(cp(e.store))}if(t.includes(ol.LightPush)){if(!e.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");i.push(cp(e.lightPush))}if(t.includes(ol.Filter)){if(!e.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");i.push(cp(e.filter))}r?await async function(e,t,r){await Promise.race([e,lp(t,r)])}(Promise.all(i),r,"Timed out waiting for a remote peer."):await Promise.all(i)}async function cp(e){const t=e.multicodec,r=await e.peers();r.length?sp("".concat(t," peer found: "),r[0].id.toString()):await new Promise((r=>{const n=i=>{var o;null!==(o=i.detail)&&void 0!==o&&null!==(o=o.protocols)&&void 0!==o&&o.includes(t)&&(sp("Resolving for",t,i.detail.protocols),e.removeLibp2pEventListener("peer:identify",n),r())};e.addLibp2pEventListener("peer:identify",n)}))}const lp=(e,t)=>new Promise(((r,n)=>setTimeout((()=>n(t)),e)));class up extends Error{constructor(e,t){super(null!==e&&void 0!==e?e:"The operation was aborted"),Ji(this,"type",void 0),Ji(this,"code",void 0),this.type="aborted",this.name="AbortError",this.code=null!==t&&void 0!==t?t:"ABORT_ERR"}}async function hp(e,t,r){if(null==t)return e;if(t.aborted)return Promise.reject(new up(null===r||void 0===r?void 0:r.errorMessage,null===r||void 0===r?void 0:r.errorCode));let n;const i=new up(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 dp{constructor(){Ji(this,"readNext",void 0),Ji(this,"haveNext",void 0),Ji(this,"ended",void 0),Ji(this,"nextResult",void 0),this.ended=!1,this.readNext=af(),this.haveNext=af()}[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=af(),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=af(),await hp(this.readNext.promise,null===t||void 0===t?void 0:t.signal,t)}}class fp extends Error{constructor(e,t){super(e),Ji(this,"code",void 0),this.code=t}}class pp extends fp{constructor(e){super(e,"ABORT_ERR"),Ji(this,"type",void 0),this.type="aborted"}}function gp(e,t){const r=new dp;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 Jd,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 pp("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 Jd:t}for(;i.byteLength<e;){const{value:e,done:t}=await Promise.race([n.next(),s]);if(!0===t)throw new fp("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 bp extends Error{constructor(e,t){super(e),Ji(this,"code",void 0),this.code=t}}function yp(e){var t,r;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=gp(e,n);null!=n.maxDataLength&&null==n.maxLengthLength&&(n.maxLengthLength=Ll(n.maxDataLength));const o=null!==(t=null===n||void 0===n?void 0:n.lengthDecoder)&&void 0!==t?t:ql,s=null!==(r=null===n||void 0===n?void 0:n.lengthEncoder)&&void 0!==r?r:Ol;return{read:async e=>{let t=-1;const r=new Jd;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 bp("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 bp("message length too long","ERR_MSG_DATA_TOO_LONG");return i.read(t,e)},write:async(e,t)=>{await i.write(new Jd(s(e.byteLength),e),t)},writeV:async(e,t)=>{const r=new Jd(...e.flatMap((e=>[s(e.byteLength),e])));await i.write(r,t)},unwrap:()=>i.unwrap()}}function mp(){const e=af();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}()}}var wp;const vp=65535,_p=Boolean(null===(wp=globalThis.process)||void 0===wp||null===(wp=wp.env)||void 0===wp?void 0:wp.DUMP_SESSION_KEYS),Ep=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function Sp(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}const Ap=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 xp(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got ".concat(typeof e));return new Uint8Array((new TextEncoder).encode(e))}function kp(e){if("string"===typeof e)e=xp(e);else{if(!Sp(e))throw new Error("expected Uint8Array, got ".concat(typeof e));e=e.slice()}return e}const Cp=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function Ip(e,t){if(!Sp(e))throw new Error("Uint8Array expected");if("number"===typeof t&&e.length!==t)throw new Error("Uint8Array length ".concat(t," expected"))}const Tp=(e,t)=>(Object.assign(t,e),t);function Pp(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,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function Rp(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("wrong positive integer: ".concat(e))}function Dp(e){if("boolean"!==typeof e)throw new Error("boolean expected, not ".concat(e))}function Np(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 Bp(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 Lp(e,t){Np(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least ".concat(r))}const Up=(e,t)=>255&e[t++]|(255&e[t++])<<8;class Mp{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,Ip(e=kp(e),32);const t=Up(e,0),r=Up(e,2),n=Up(e,4),i=Up(e,6),o=Up(e,8),s=Up(e,10),a=Up(e,12),c=Up(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 l=0;l<8;l++)this.pad[l]=Up(e,16+2*l)}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],l=i[4],u=i[5],h=i[6],d=i[7],f=i[8],p=i[9],g=Up(e,t+0),b=Up(e,t+2),y=Up(e,t+4),m=Up(e,t+6),w=Up(e,t+8),v=Up(e,t+10),_=Up(e,t+12),E=Up(e,t+14);let S=n[0]+(8191&g),A=n[1]+(8191&(g>>>13|b<<3)),x=n[2]+(8191&(b>>>10|y<<6)),k=n[3]+(8191&(y>>>7|m<<9)),C=n[4]+(8191&(m>>>4|w<<12)),I=n[5]+(w>>>1&8191),T=n[6]+(8191&(w>>>14|v<<2)),P=n[7]+(8191&(v>>>11|_<<5)),R=n[8]+(8191&(_>>>8|E<<8)),D=n[9]+(E>>>5|r),N=0,B=N+S*o+A*(5*p)+x*(5*f)+k*(5*d)+C*(5*h);N=B>>>13,B&=8191,B+=I*(5*u)+T*(5*l)+P*(5*c)+R*(5*a)+D*(5*s),N+=B>>>13,B&=8191;let L=N+S*s+A*o+x*(5*p)+k*(5*f)+C*(5*d);N=L>>>13,L&=8191,L+=I*(5*h)+T*(5*u)+P*(5*l)+R*(5*c)+D*(5*a),N+=L>>>13,L&=8191;let U=N+S*a+A*s+x*o+k*(5*p)+C*(5*f);N=U>>>13,U&=8191,U+=I*(5*d)+T*(5*h)+P*(5*u)+R*(5*l)+D*(5*c),N+=U>>>13,U&=8191;let M=N+S*c+A*a+x*s+k*o+C*(5*p);N=M>>>13,M&=8191,M+=I*(5*f)+T*(5*d)+P*(5*h)+R*(5*u)+D*(5*l),N+=M>>>13,M&=8191;let O=N+S*l+A*c+x*a+k*s+C*o;N=O>>>13,O&=8191,O+=I*(5*p)+T*(5*f)+P*(5*d)+R*(5*h)+D*(5*u),N+=O>>>13,O&=8191;let q=N+S*u+A*l+x*c+k*a+C*s;N=q>>>13,q&=8191,q+=I*o+T*(5*p)+P*(5*f)+R*(5*d)+D*(5*h),N+=q>>>13,q&=8191;let z=N+S*h+A*u+x*l+k*c+C*a;N=z>>>13,z&=8191,z+=I*s+T*o+P*(5*p)+R*(5*f)+D*(5*d),N+=z>>>13,z&=8191;let F=N+S*d+A*h+x*u+k*l+C*c;N=F>>>13,F&=8191,F+=I*a+T*s+P*o+R*(5*p)+D*(5*f),N+=F>>>13,F&=8191;let K=N+S*f+A*d+x*h+k*u+C*l;N=K>>>13,K&=8191,K+=I*c+T*a+P*s+R*o+D*(5*p),N+=K>>>13,K&=8191;let V=N+S*p+A*f+x*d+k*h+C*u;N=V>>>13,V&=8191,V+=I*l+T*c+P*a+R*s+D*o,N+=V>>>13,V&=8191,N=(N<<2)+N|0,N=N+B|0,B=8191&N,N>>>=13,L+=N,n[0]=B,n[1]=L,n[2]=U,n[3]=M,n[4]=O,n[5]=q,n[6]=z,n[7]=F,n[8]=K,n[9]=V}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){Bp(this);const{buffer:t,blockLen:r}=this,n=(e=kp(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){Bp(this),Lp(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 Op=function(e){const t=(t,r)=>e(r).update(kp(t)).digest(),r=e(new Uint8Array(32));return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}((e=>new Mp(e))),qp=xp("expand 16-byte k"),zp=xp("expand 32-byte k"),Fp=Ep(qp),Kp=Ep(zp);function Vp(e,t){return e<<t|e>>>32-t}function jp(e){return e.byteOffset%4===0}const Hp=64,Wp=16,Gp=2**32-1,Yp=new Uint32Array;function Qp(e,t){const{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=function(e,t){if(void 0!==t&&("object"!==typeof t||!Cp(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 Rp(i),Rp(s),Dp(o),Dp(r),function(t,a,c,l){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;Np(t),Np(a),Np(c);const h=c.length;if(l||(l=new Uint8Array(h)),Np(l),Rp(u),u<0||u>=Gp)throw new Error("arx: counter overflow");if(l.length<h)throw new Error("arx: output (".concat(l.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=Kp;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=Fp,d.push(f)}jp(a)||(a=a.slice(),d.push(a));const b=Ep(f);if(n){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");n(p,b,Ep(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=Ep(a);for(!function(e,t,r,n,i,o,s,a){const c=i.length,l=new Uint8Array(Hp),u=Ep(l),h=jp(i)&&jp(o),d=h?Ep(i):Yp,f=h?Ep(o):Yp;for(let p=0;p<c;s++){if(e(t,r,n,u,s,a),s>=Gp)throw new Error("arx: counter overflow");const g=Math.min(Hp,c-p);if(h&&g===Hp){const e=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let t,r=0;r<Wp;r++)t=e+r,f[t]=d[t]^u[r];p+=Hp}else{for(let e,t=0;t<g;t++)e=p+t,o[e]=i[e]^l[t];p+=g}}}(e,p,b,m,c,l,u,s);d.length>0;)d.pop().fill(0);return l}}function Jp(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],l=e[3],u=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,w=r[0],v=r[1],_=r[2],E=s,S=a,A=c,x=l,k=u,C=h,I=d,T=f,P=p,R=g,D=b,N=y,B=m,L=w,U=v,M=_;for(let q=0;q<o;q+=2)E=E+k|0,B=Vp(B^E,16),P=P+B|0,k=Vp(k^P,12),E=E+k|0,B=Vp(B^E,8),P=P+B|0,k=Vp(k^P,7),S=S+C|0,L=Vp(L^S,16),R=R+L|0,C=Vp(C^R,12),S=S+C|0,L=Vp(L^S,8),R=R+L|0,C=Vp(C^R,7),A=A+I|0,U=Vp(U^A,16),D=D+U|0,I=Vp(I^D,12),A=A+I|0,U=Vp(U^A,8),D=D+U|0,I=Vp(I^D,7),x=x+T|0,M=Vp(M^x,16),N=N+M|0,T=Vp(T^N,12),x=x+T|0,M=Vp(M^x,8),N=N+M|0,T=Vp(T^N,7),E=E+C|0,M=Vp(M^E,16),D=D+M|0,C=Vp(C^D,12),E=E+C|0,M=Vp(M^E,8),D=D+M|0,C=Vp(C^D,7),S=S+I|0,B=Vp(B^S,16),N=N+B|0,I=Vp(I^N,12),S=S+I|0,B=Vp(B^S,8),N=N+B|0,I=Vp(I^N,7),A=A+T|0,L=Vp(L^A,16),P=P+L|0,T=Vp(T^P,12),A=A+T|0,L=Vp(L^A,8),P=P+L|0,T=Vp(T^P,7),x=x+k|0,U=Vp(U^x,16),R=R+U|0,k=Vp(k^R,12),x=x+k|0,U=Vp(U^x,8),R=R+U|0,k=Vp(k^R,7);let O=0;n[O++]=s+E|0,n[O++]=a+S|0,n[O++]=c+A|0,n[O++]=l+x|0,n[O++]=u+k|0,n[O++]=h+C|0,n[O++]=d+I|0,n[O++]=f+T|0,n[O++]=p+P|0,n[O++]=g+R|0,n[O++]=b+D|0,n[O++]=y+N|0,n[O++]=m+B|0,n[O++]=w+L|0,n[O++]=v+U|0,n[O++]=_+M|0}const Xp=Qp(Jp,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Zp=Qp(Jp,{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],l=t[1],u=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],w=r[3];for(let _=0;_<20;_+=2)i=i+c|0,b=Vp(b^i,16),d=d+b|0,c=Vp(c^d,12),i=i+c|0,b=Vp(b^i,8),d=d+b|0,c=Vp(c^d,7),o=o+l|0,y=Vp(y^o,16),f=f+y|0,l=Vp(l^f,12),o=o+l|0,y=Vp(y^o,8),f=f+y|0,l=Vp(l^f,7),s=s+u|0,m=Vp(m^s,16),p=p+m|0,u=Vp(u^p,12),s=s+u|0,m=Vp(m^s,8),p=p+m|0,u=Vp(u^p,7),a=a+h|0,w=Vp(w^a,16),g=g+w|0,h=Vp(h^g,12),a=a+h|0,w=Vp(w^a,8),g=g+w|0,h=Vp(h^g,7),i=i+l|0,w=Vp(w^i,16),p=p+w|0,l=Vp(l^p,12),i=i+l|0,w=Vp(w^i,8),p=p+w|0,l=Vp(l^p,7),o=o+u|0,b=Vp(b^o,16),g=g+b|0,u=Vp(u^g,12),o=o+u|0,b=Vp(b^o,8),g=g+b|0,u=Vp(u^g,7),s=s+h|0,y=Vp(y^s,16),d=d+y|0,h=Vp(h^d,12),s=s+h|0,y=Vp(y^s,8),d=d+y|0,h=Vp(h^d,7),a=a+c|0,m=Vp(m^a,16),f=f+m|0,c=Vp(c^f,12),a=a+c|0,m=Vp(m^a,8),f=f+m|0,c=Vp(c^f,7);let v=0;n[v++]=i,n[v++]=o,n[v++]=s,n[v++]=a,n[v++]=b,n[v++]=y,n[v++]=m,n[v++]=w},allowShortKeys:!1}),$p=new Uint8Array(16),eg=(e,t)=>{e.update(t);const r=t.length%16;r&&e.update($p.subarray(r))},tg=new Uint8Array(32);function rg(e,t,r,n,i){const o=e(t,r,tg),s=Op.create(o);i&&eg(s,i),eg(s,n);const a=new Uint8Array(16),c=Ap(a);Pp(c,0,BigInt(i?i.length:0),!0),Pp(c,8,BigInt(n.length),!0),s.update(a);const l=s.digest();return o.fill(0),l}const ng=e=>(t,r,n)=>{const i=16;return Ip(t,32),Ip(r),{encrypt:(o,s)=>{const a=o.length,c=a+i;s?Ip(s,c):s=new Uint8Array(c),e(t,r,o,s,1);const l=rg(e,t,r,s.subarray(0,-16),n);return s.set(l,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?Ip(s,c):s=new Uint8Array(c);const l=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),rg(e,t,r,l,n)))throw new Error("invalid tag");return e(t,r,l,s,1),s}}},ig=Tp({blockSize:64,nonceLength:12,tagLength:16},ng(Xp));ng(Zp);function og(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, not ".concat(e))}function sg(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 ag(e){if("function"!==typeof e||"function"!==typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");og(e.outputLen),og(e.blockLen)}function cg(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 lg(e,t){sg(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least ".concat(r))}const ug="object"===typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;const hg=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),dg=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function fg(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got ".concat(typeof e));return new Uint8Array((new TextEncoder).encode(e))}function pg(e){return"string"===typeof e&&(e=fg(e)),sg(e),e}function gg(){let e=0;for(let r=0;r<arguments.length;r++){const t=r<0||arguments.length<=r?void 0:arguments[r];sg(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 bg{clone(){return this._cloneInto()}}function yg(e){const t=t=>e().update(pg(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function mg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(ug&&"function"===typeof ug.getRandomValues)return ug.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}const wg=(e,t,r)=>e&t^e&r^t&r;class vg extends bg{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=hg(this.buffer)}update(e){cg(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=pg(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=hg(e);for(;n<=i-o;o+=n)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){cg(this),lg(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 u=o;u<n;u++)t[u]=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,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=hg(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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 _g=BigInt(2**32-1),Eg=BigInt(32);function Sg(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&_g),l:Number(e>>Eg&_g)}:{h:0|Number(e>>Eg&_g),l:0|Number(e&_g)}}const Ag={fromBig:Sg,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}=Sg(e[i],t);[r[i],n[i]]=[o,s]}return[r,n]},toBig:(e,t)=>BigInt(e>>>0)<<Eg|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)},[xg,kg]=(()=>Ag.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)))))(),Cg=new Uint32Array(80),Ig=new Uint32Array(80);class Tg extends vg{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:l,Fh:u,Fl:h,Gh:d,Gl:f,Hh:p,Hl:g}=this;return[e,t,r,n,i,o,s,a,c,l,u,h,d,f,p,g]}set(e,t,r,n,i,o,s,a,c,l,u,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|l,this.Fh=0|u,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)Cg[m]=e.getUint32(t),Ig[m]=e.getUint32(t+=4);for(let m=16;m<80;m++){const e=0|Cg[m-15],t=0|Ig[m-15],r=Ag.rotrSH(e,t,1)^Ag.rotrSH(e,t,8)^Ag.shrSH(e,t,7),n=Ag.rotrSL(e,t,1)^Ag.rotrSL(e,t,8)^Ag.shrSL(e,t,7),i=0|Cg[m-2],o=0|Ig[m-2],s=Ag.rotrSH(i,o,19)^Ag.rotrBH(i,o,61)^Ag.shrSH(i,o,6),a=Ag.rotrSL(i,o,19)^Ag.rotrBL(i,o,61)^Ag.shrSL(i,o,6),c=Ag.add4L(n,a,Ig[m-7],Ig[m-16]),l=Ag.add4H(c,r,s,Cg[m-7],Cg[m-16]);Cg[m]=0|l,Ig[m]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:h,Fh:d,Fl:f,Gh:p,Gl:g,Hh:b,Hl:y}=this;for(let m=0;m<80;m++){const e=Ag.rotrSH(u,h,14)^Ag.rotrSH(u,h,18)^Ag.rotrBH(u,h,41),t=Ag.rotrSL(u,h,14)^Ag.rotrSL(u,h,18)^Ag.rotrBL(u,h,41),w=u&d^~u&p,v=h&f^~h&g,_=Ag.add5L(y,t,v,kg[m],Ig[m]),E=Ag.add5H(_,b,e,w,xg[m],Cg[m]),S=0|_,A=Ag.rotrSH(r,n,28)^Ag.rotrBH(r,n,34)^Ag.rotrBH(r,n,39),x=Ag.rotrSL(r,n,28)^Ag.rotrBL(r,n,34)^Ag.rotrBL(r,n,39),k=r&i^r&s^i&s,C=n&o^n&a^o&a;b=0|p,y=0|g,p=0|d,g=0|f,d=0|u,f=0|h,({h:u,l:h}=Ag.add(0|c,0|l,0|E,0|S)),c=0|s,l=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const I=Ag.add3L(S,x,C);r=Ag.add3H(I,E,A,k),n=0|I}({h:r,l:n}=Ag.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=Ag.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Ag.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:l}=Ag.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:u,l:h}=Ag.add(0|this.Eh,0|this.El,0|u,0|h)),({h:d,l:f}=Ag.add(0|this.Fh,0|this.Fl,0|d,0|f)),({h:p,l:g}=Ag.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:b,l:y}=Ag.add(0|this.Hh,0|this.Hl,0|b,0|y)),this.set(r,n,i,o,s,a,c,l,u,h,d,f,p,g,b,y)}roundClean(){Cg.fill(0),Ig.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 Pg=yg((()=>new Tg)),Rg=(BigInt(0),BigInt(1)),Dg=BigInt(2);function Ng(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function Bg(e){if(!Ng(e))throw new Error("Uint8Array expected")}const Lg=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Ug(e){Bg(e);let t="";for(let r=0;r<e.length;r++)t+=Lg[e[r]];return t}function Mg(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":"0x".concat(e))}const Og={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qg(e){return e>=Og._0&&e<=Og._9?e-Og._0:e>=Og._A&&e<=Og._F?e-(Og._A-10):e>=Og._a&&e<=Og._f?e-(Og._a-10):void 0}function zg(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=qg(e.charCodeAt(o)),r=qg(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 Fg(e){return Mg(Ug(e))}function Kg(e){return Bg(e),Mg(Ug(Uint8Array.from(e).reverse()))}function Vg(e,t){return zg(e.toString(16).padStart(2*t,"0"))}function jg(e,t){return Vg(e,t).reverse()}function Hg(e,t,r){let n;if("string"===typeof t)try{n=zg(t)}catch(o){throw new Error("".concat(e,' must be valid hex string, got "').concat(t,'". Cause: ').concat(o))}else{if(!Ng(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 Wg(){let e=0;for(let r=0;r<arguments.length;r++){const t=r<0||arguments.length<=r?void 0:arguments[r];Bg(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 Gg=e=>(Dg<<BigInt(e-1))-Rg,Yg=e=>new Uint8Array(e),Qg=e=>Uint8Array.from(e);function Jg(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=Yg(e),i=Yg(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]:Yg();i=a(Qg([0]),e),n=a(),0!==e.length&&(i=a(Qg([1]),e),n=a())},l=()=>{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 Wg(...r)};return(e,t)=>{let r;for(s(),c(e);!(r=t(l()));)c();return s(),r}}const Xg={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||Ng(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 Zg(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=(t,r,n)=>{const i=Xg[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 $g=BigInt(0),eb=BigInt(1),tb=BigInt(2),rb=BigInt(3),nb=BigInt(4),ib=BigInt(5),ob=BigInt(8);BigInt(9),BigInt(16);function sb(e,t){const r=e%t;return r>=$g?r:t+r}function ab(e,t,r){if(r<=$g||t<$g)throw new Error("Expected power/modulo > 0");if(r===eb)return $g;let n=eb;for(;t>$g;)t&eb&&(n=n*e%r),e=e*e%r,t>>=eb;return n}function cb(e,t,r){let n=e;for(;t-- >$g;)n*=n,n%=r;return n}function lb(e,t){if(e===$g||t<=$g)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=sb(e,t),n=t,i=$g,o=eb,s=eb,a=$g;for(;r!==$g;){const e=n/r,t=n%r,c=i-s*e,l=o-a*e;n=r,r=t,i=s,o=a,s=c,a=l}if(n!==eb)throw new Error("invert: does not exist");return sb(i,t)}function ub(e){if(e%nb===rb){const t=(e+eb)/nb;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%ob===ib){const t=(e-ib)/ob;return function(e,r){const n=e.mul(r,tb),i=e.pow(n,t),o=e.mul(r,i),s=e.mul(e.mul(o,tb),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-eb)/tb;let r,n,i;for(r=e-eb,n=0;r%tb===$g;r/=tb,n++);for(i=tb;i<e&&ab(i,t,e)!==e-eb;i++);if(1===n){const t=(e+eb)/nb;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+eb)/tb;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),l=e.pow(s,o),u=e.pow(s,r);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const r=e.pow(c,eb<<BigInt(a-t-1));c=e.sqr(r),l=e.mul(l,r),u=e.mul(u,c),a=t}return l}}(e)}const hb=(e,t)=>(sb(e,t)&eb)===eb,db=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fb(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function pb(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<=$g)throw new Error("Expected Field ORDER > 0, got ".concat(e));const{nBitLength:i,nByteLength:o}=fb(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=ub(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:Gg(i),ZERO:$g,ONE:eb,create:t=>sb(t,e),isValid:t=>{if("bigint"!==typeof t)throw new Error("Invalid field element: expected bigint, got ".concat(typeof t));return $g<=t&&t<e},is0:e=>e===$g,isOdd:e=>(e&eb)===eb,neg:t=>sb(-t,e),eql:(e,t)=>e===t,sqr:t=>sb(t*t,e),add:(t,r)=>sb(t+r,e),sub:(t,r)=>sb(t-r,e),mul:(t,r)=>sb(t*r,e),pow:(e,t)=>function(e,t,r){if(r<$g)throw new Error("Expected power > 0");if(r===$g)return e.ONE;if(r===eb)return t;let n=e.ONE,i=t;for(;r>$g;)r&eb&&(n=e.mul(n,i)),i=e.sqr(i),r>>=eb;return n}(a,e,t),div:(t,r)=>sb(t*lb(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>lb(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?jg(e,o):Vg(e,o),fromBytes:e=>{if(e.length!==o)throw new Error("Fp.fromBytes: expected ".concat(o,", got ").concat(e.length));return r?Kg(e):Fg(e)}});return Object.freeze(a)}function gb(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 bb(e){const t=gb(e);return t+Math.ceil(t/2)}const yb=BigInt(0),mb=BigInt(1);function wb(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>yb;)r&mb&&(n=n.add(i)),i=i.double(),r>>=mb;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,l=e.BASE;const u=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&u);o>>=d,n>a&&(n-=h,o+=mb);const s=t,f=t+Math.abs(n)-1,p=e%2!==0,g=n<0;0===n?l=l.add(r(p,i[s])):c=c.add(r(g,i[f]))}return{p:c,f:l}},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 vb(e){return function(e){const t=db.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Zg(e,t)}(e.Fp),Zg(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...fb(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const _b=BigInt(0),Eb=BigInt(1),Sb=BigInt(2),Ab=BigInt(8),xb={zip215:!0};function kb(e){const t=function(e){const t=vb(e);return Zg(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,l=Sb<<BigInt(8*a)-Eb,u=r.create,h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(n){return{isValid:!1,value:_b}}}),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&&_b<e,g=(e,t)=>p(e)&&p(t)&&e<t,b=e=>e===_b||g(e,l);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===_b?e:y(e,n)}const w=new Map;function v(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,Eb,u(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,w.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=u(n*n),c=u(i*i),l=u(o*o),h=u(l*l),d=u(a*e);if(u(l*u(d+c))!==u(h+u(r*u(a*c))))throw new Error("bad point: equation left != right (1)");if(u(n*i)!==u(o*s))throw new Error("bad point: equation left != right (2)")}equals(e){v(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=e,a=u(t*s),c=u(i*n),l=u(r*s),h=u(o*n);return a===c&&l===h}is0(){return this.equals(_.ZERO)}negate(){return new _(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:i}=this,o=u(r*r),s=u(n*n),a=u(Sb*u(i*i)),c=u(e*o),l=r+n,h=u(u(l*l)-o-s),d=c+s,f=d-a,p=c-s,g=u(h*f),b=u(d*p),y=u(h*p),m=u(f*d);return new _(g,b,m,y)}add(e){v(e);const{a:r,d:n}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:l,ez:h,et:d}=e;if(r===BigInt(-1)){const e=u((o-i)*(l+c)),t=u((o+i)*(l-c)),r=u(t-e);if(r===_b)return this.double();const n=u(s*Sb*d),f=u(a*Sb*h),p=f+n,g=t+e,b=f-n,y=u(p*r),m=u(g*b),w=u(p*b),v=u(r*g);return new _(y,m,v,w)}const f=u(i*c),p=u(o*l),g=u(a*n*d),b=u(s*h),y=u((i+o)*(c+l)-f-p),m=b-g,w=b+g,E=u(p-r*f),S=u(y*m),A=u(w*E),x=u(y*E),k=u(m*w);return new _(S,A,k,x)}subtract(e){return this.add(e.negate())}wNAF(e){return A.wNAFCached(this,w,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===_b?S:this.equals(S)||t===Eb?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?Ab:r.inv(i));const s=u(t*e),a=u(n*e),c=u(i*e);if(o)return{x:_b,y:Eb};if(c!==Eb)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:e}=t;return e===Eb?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=Hg("pointHex",e,s)).slice(),c=e[s-1];a[s-1]=-129&c;const d=Kg(a);d===_b||y(d,n?l:r.ORDER);const f=u(d*d),p=u(f-Eb),g=u(i*f-o);let{isValid:b,value:m}=h(p,g);if(!b)throw new Error("Point.fromHex: invalid y coordinate");const w=(m&Eb)===Eb,v=0!==(128&c);if(!n&&m===_b&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==w&&(m=u(-m)),_.fromAffine({x:m,y:d})}static fromPrivateKey(e){return C(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=jg(t,r.BYTES);return n[n.length-1]|=e&Eb?128:0,n}toHex(){return Ug(this.toRawBytes())}}_.BASE=new _(t.Gx,t.Gy,Eb,u(t.Gx*t.Gy)),_.ZERO=new _(_b,Eb,Eb,_b);const{BASE:E,ZERO:S}=_,A=wb(_,8*a);function x(e){return sb(e,n)}function k(e){return x(Kg(e))}function C(e){const t=a;e=Hg("private key",e,t);const r=Hg("hashed private key",o(e),2*t),n=d(r.slice(0,t)),i=r.slice(t,2*t),s=k(n),c=E.multiply(s),l=c.toRawBytes();return{head:n,prefix:i,scalar:s,point:c,pointBytes:l}}function I(){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=Wg(...r);return k(o(f(s,Hg("context",e),!!i)))}const T=xb;E._setWindowSize(8);const P={getExtendedPublicKey:C,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 C(e).pointBytes},sign:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=Hg("message",e),i&&(e=i(e));const{prefix:o,scalar:s,pointBytes:c}=C(t),l=I(n.context,o,e),u=E.multiply(l).toRawBytes(),h=x(l+I(n.context,u,c,e)*s);return m(h),Hg("result",Wg(u,jg(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=Hg("signature",e,2*c),t=Hg("message",t),i&&(t=i(t));const l=Kg(e.slice(c,2*c));let u,h,d;try{u=_.fromHex(n,a),h=_.fromHex(e.slice(0,c),a),d=E.multiplyUnsafe(l)}catch(p){return!1}if(!a&&u.isSmallOrder())return!1;const f=I(s,h.toRawBytes(),u.toRawBytes(),t);return h.add(u.multiplyUnsafe(f)).subtract(d).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:P}}const Cb=BigInt(0),Ib=BigInt(1);function Tb(e){const t=(Zg(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=>sb(e,n),o=t.montgomeryBits,s=Math.ceil(o/8),a=t.nByteLength,c=t.adjustScalarBytes||(e=>e),l=t.powPminus2||(e=>ab(e,n-BigInt(2),n));function u(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&&Cb<=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 jg(i(e),s)}function p(e,t){const r=function(e){const t=Hg("u coordinate",e,s);return 32===a&&(t[31]&=127),Kg(t)}(t),n=function(e){const t=Hg("scalar",e),r=t.length;if(r!==s&&r!==a)throw new Error("Expected ".concat(s," or ").concat(a," bytes, got ").concat(r));return Kg(c(t))}(e),p=function(e,t){const r=h(e),n=h(t),s=r;let a,c=Ib,f=Cb,p=r,g=Ib,b=Cb;for(let l=BigInt(o-1);l>=Cb;l--){const e=n>>l&Ib;b^=e,a=u(b,c,p),c=a[0],p=a[1],a=u(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,w=i((p-g)*t),v=i(m*o),_=w+v,E=w-v;p=i(_*_),g=i(s*i(E*E)),c=i(r*h),f=i(y*(r+i(d*y)))}a=u(b,c,p),c=a[0],p=a[1],a=u(b,f,g),f=a[0],g=a[1];const y=l(f);return i(c*y)}(r,n);if(p===Cb)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 Pb=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Rb=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Db=(BigInt(0),BigInt(1)),Nb=BigInt(2),Bb=BigInt(5),Lb=BigInt(10),Ub=BigInt(20),Mb=BigInt(40),Ob=BigInt(80);function qb(e){const t=Pb,r=e*e%t*e%t,n=cb(r,Nb,t)*r%t,i=cb(n,Db,t)*e%t,o=cb(i,Bb,t)*i%t,s=cb(o,Lb,t)*o%t,a=cb(s,Ub,t)*s%t,c=cb(a,Mb,t)*a%t,l=cb(c,Ob,t)*c%t,u=cb(l,Ob,t)*c%t,h=cb(u,Lb,t)*o%t;return{pow_p_5_8:cb(h,Nb,t)*e%t,b2:r}}function zb(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Fb(e,t){const r=Pb,n=sb(t*t*t,r),i=sb(n*n*t,r);let o=sb(e*n*qb(e*i).pow_p_5_8,r);const s=sb(t*o*o,r),a=o,c=sb(o*Rb,r),l=s===e,u=s===sb(-e,r),h=s===sb(-e*Rb,r);return l&&(o=a),(u||h)&&(o=c),hb(o,r)&&(o=sb(-o,r)),{isValid:l||u,value:o}}const Kb=pb(Pb,void 0,!0),Vb={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Kb,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Pg,randomBytes:mg,adjustScalarBytes:zb,uvRatio:Fb},jb=kb(Vb);function Hb(e,t,r){if(t.length>255)throw new Error("Context is too big");return gg(fg("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}const Wb=(()=>Tb({P:Pb,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Pb,{pow_p_5_8:r,b2:n}=qb(e);return sb(cb(r,BigInt(3),t)*n,t)},adjustScalarBytes:zb,randomBytes:mg}))();const Gb=(Kb.ORDER+BigInt(3))/BigInt(8);Kb.pow(Nb,Gb),Kb.sqrt(Kb.neg(Kb.ONE)),Kb.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)}(Kb,Kb.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Yb extends bg{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ag(e);const r=pg(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 cg(this),this.iHash.update(e),this}digestInto(e){cg(this),sg(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 Qb=(e,t,r)=>new Yb(e,t).update(r).digest();function Jb(e,t,r){return ag(e),void 0===r&&(r=new Uint8Array(e.outputLen)),Qb(e,pg(r),pg(t))}Qb.create=(e,t)=>new Yb(e,t);const Xb=new Uint8Array([0]),Zb=new Uint8Array;function $b(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;if(ag(e),og(n),n>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(n/e.outputLen);void 0===r&&(r=Zb);const o=new Uint8Array(i*e.outputLen),s=Qb.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let l=0;l<i;l++)Xb[0]=l+1,a.update(0===l?Zb:c).update(r).update(Xb).digestInto(c),o.set(c,e.outputLen*l),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),Xb.fill(0),o.slice(0,n)}const ey=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]),ty=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ry=new Uint32Array(64);class ny extends vg{constructor(){super(64,32,8,!1),this.A=0|ty[0],this.B=0|ty[1],this.C=0|ty[2],this.D=0|ty[3],this.E=0|ty[4],this.F=0|ty[5],this.G=0|ty[6],this.H=0|ty[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)ry[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=ry[h-15],t=ry[h-2],r=dg(e,7)^dg(e,18)^e>>>3,n=dg(t,17)^dg(t,19)^t>>>10;ry[h]=n+ry[h-7]+r+ry[h-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let h=0;h<64;h++){const e=l+(dg(s,6)^dg(s,11)^dg(s,25))+((u=s)&a^~u&c)+ey[h]+ry[h]|0,t=(dg(r,2)^dg(r,13)^dg(r,22))+wg(r,n,i)|0;l=c,c=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+t|0}var u;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,l=l+this.H|0,this.set(r,n,i,o,s,a,c,l)}roundClean(){ry.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const iy=yg((()=>new ny)),oy={hashSHA256:e=>iy(e),getHKDF(e,t){const r=Jb(iy,t,e),n=$b(iy,r,void 0,96);return[n.subarray(0,32),n.subarray(32,64),n.subarray(64,96)]},generateX25519KeyPair(){const e=Wb.utils.randomPrivateKey();return{publicKey:Wb.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed:e=>({publicKey:Wb.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>Wb.getSharedSecret(e,t),chaCha20Poly1305Encrypt:(e,t,r,n)=>ig(n,t,r).encrypt(e),chaCha20Poly1305Decrypt:(e,t,r,n,i)=>ig(n,t,r).decrypt(e,i)},sy=e=>{const t=La(2);return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint16(0,e,!1),t};sy.bytes=2;const ay=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)};ay.bytes=2;class cy extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),Ji(this,"code",void 0),Ji(this,"type",void 0),this.code=cy.code,this.type=cy.type}}Ji(cy,"code","ABORT_ERR"),Ji(cy,"type","aborted");class ly extends Error{constructor(e,t,r){var n;super(e),Ji(this,"code",void 0),Ji(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 uy extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected Peer"),Ji(this,"code",void 0),this.code=uy.code}}Ji(uy,"code","ERR_UNEXPECTED_PEER");class hy extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),Ji(this,"code",void 0),this.code=hy.code}}Ji(hy,"code","ERR_INVALID_CRYPTO_EXCHANGE");class dy extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto transmission"),Ji(this,"code",void 0),this.code=dy.code}}Ji(dy,"code","ERR_INVALID_CRYPTO_TRANSMISSION");__webpack_require__(5465),__webpack_require__(3555);var fy=__webpack_require__(45);var py=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const gy=py,by=(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 yy{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 my{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 vy(this,e)}}class wy{constructor(e){this.decoders=e}or(e){return vy(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 vy=(e,t)=>new wy({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class _y{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new yy(e,t,r),this.decoder=new my(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ey=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new _y(t,r,n,i)},Sy=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=gy(n,r);return Ey({prefix:t,name:r,encode:i,decode:e=>by(o(e))})},Ay=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Ey({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},xy=Sy({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"});Sy({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ky=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Ty;)r[n++]=255&t|Cy,t/=128;for(;t&Iy;)r[n++]=255&t|Cy,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Cy=128,Iy=-128,Ty=Math.pow(2,31);var Py=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&Dy)<<o:(n&Dy)*Math.pow(2,o),o+=7}while(n>=Ry);return e.bytes=s-r,i},Ry=128,Dy=127;var Ny=Math.pow(2,7),By=Math.pow(2,14),Ly=Math.pow(2,21),Uy=Math.pow(2,28),My=Math.pow(2,35),Oy=Math.pow(2,42),qy=Math.pow(2,49),zy=Math.pow(2,56),Fy=Math.pow(2,63);const Ky={encode:ky,decode:Py,encodingLength:function(e){return e<Ny?1:e<By?2:e<Ly?3:e<Uy?4:e<My?5:e<Oy?6:e<qy?7:e<zy?8:e<Fy?9:10}},Vy=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ky.encode(e,t,r),t},jy=e=>Ky.encodingLength(e),Hy=(e,t)=>{const r=t.byteLength,n=jy(e),i=n+jy(r),o=new Uint8Array(i+r);return Vy(e,o,0),Vy(r,o,n),o.set(t,i),new Wy(e,r,t,o)};class Wy{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Gy=by,Yy=e=>Hy(0,Gy(e)),Qy=e=>{let{name:t,code:r,encode:n}=e;return new Jy(t,r,n)};class Jy{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?Hy(this.code,t):t.then((e=>Hy(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Xy=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Zy=Qy({name:"sha2-256",code:18,encode:Xy("SHA-256")}),$y=(Qy({name:"sha2-512",code:19,encode:Xy("SHA-512")}),32),em=64,tm=32;function rm(e,t){const r=new Uint8Array(em);for(let n=0;n<tm;n++)r[n]=e[n],r[tm+n]=t[n];return r}const nm=Ay({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),im=(Ay({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ay({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ay({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),{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-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}}),om={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function sm(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 l=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,u=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=im.get();c*=8;return{encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(l)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=kc(t)),0===t.length){o=await f.subtle.importKey("jwk",om,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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",om,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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 Fa([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+l),i=e.subarray(h+l),o={name:a,iv:n};let s;if("string"===typeof t&&(t=kc(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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",om,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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)}}}async function am(e,t){const r=sm(),n=await r.encrypt(e,t);return nm.encode(n)}const cm=new Float32Array([-0]),lm=new Uint8Array(cm.buffer);function um(e,t,r){cm[0]=e,t[r]=lm[0],t[r+1]=lm[1],t[r+2]=lm[2],t[r+3]=lm[3]}const hm=new Float64Array([-0]),dm=new Uint8Array(hm.buffer);function fm(e,t,r){hm[0]=e,t[r]=dm[0],t[r+1]=dm[1],t[r+2]=dm[2],t[r+3]=dm[3],t[r+4]=dm[4],t[r+5]=dm[5],t[r+6]=dm[6],t[r+7]=dm[7]}const pm=BigInt(Number.MAX_SAFE_INTEGER),gm=BigInt(Number.MIN_SAFE_INTEGER);class bm{constructor(e,t){Ji(this,"lo",void 0),Ji(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 ym;if(e<pm&&e>gm)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>mm&&(n=0n,++r>mm&&(r=0n))),new bm(Number(n),Number(r))}static fromNumber(e){if(0===e)return ym;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 bm(r,n)}static from(e){return"number"===typeof e?bm.fromNumber(e):"bigint"===typeof e?bm.fromBigInt(e):"string"===typeof e?bm.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new bm(e.low>>>0,e.high>>>0):ym}}const ym=new bm(0,0);ym.toBigInt=function(){return 0n},ym.zzEncode=ym.zzDecode=function(){return this},ym.length=function(){return 1};const mm=4294967296n;function wm(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 vm(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function _m(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Em{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,vm(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 vm(this,4);return _m(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw vm(this,4);return 0|_m(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw vm(this,4);const e=(t=this.buf,r=this.pos,lm[0]=t[r],lm[1]=t[r+1],lm[2]=t[r+2],lm[3]=t[r+3],cm[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw vm(this,4);const e=(t=this.buf,r=this.pos,dm[0]=t[r],dm[1]=t[r+1],dm[2]=t[r+2],dm[3]=t[r+3],dm[4]=t[r+4],dm[5]=t[r+5],dm[6]=t[r+6],dm[7]=t[r+7],hm[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 vm(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 vm(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw vm(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 bm(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw vm(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 vm(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 vm(this,8);const e=_m(this.buf,this.pos+=4),t=_m(this.buf,this.pos+=4);return new bm(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 Sm(e,t,r){const n=function(e){return new Em(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function Am(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function xm(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 km=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Cm=km;class Im{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 Tm{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 Rm(this,e)}}class Pm{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return Rm(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 Rm(e,t){var r,n;return new Pm({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Dm{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Im(e,t,r),this.decoder=new Tm(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Nm(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Dm(t,r,n,i)}function Bm(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Cm(n,t);return Nm({prefix:r,name:t,encode:i,decode:e=>xm(o(e))})}function Lm(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Nm({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 Um=Bm({prefix:"9",name:"base10",alphabet:"0123456789"}),Mm=Lm({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Om=Lm({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),qm=Lm({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),zm=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"),Fm=zm.reduce(((e,t,r)=>(e[r]=t,e)),[]),Km=zm.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Vm=Nm({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Fm[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Km[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),jm=Lm({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hm=Lm({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wm=Lm({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gm=Lm({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ym=Lm({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qm=Lm({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jm=Lm({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xm=Lm({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zm=Lm({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),$m=Bm({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ew=Bm({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),tw=Bm({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rw=Bm({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),nw=Lm({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),iw=Lm({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ow=Lm({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sw=Lm({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),aw=Lm({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),cw=Nm({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)}),lw=new TextEncoder,uw=new TextDecoder,hw="json",dw=512;function fw(e){return lw.encode(JSON.stringify(e))}function pw(e){return JSON.parse(uw.decode(e))}const gw="raw",bw=85;function yw(e){return xm(e)}function mw(e){return xm(e)}var ww=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Ew;)r[n++]=255&t|vw,t/=128;for(;t&_w;)r[n++]=255&t|vw,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},vw=128,_w=-128,Ew=Math.pow(2,31);var Sw=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&xw)<<o:(n&xw)*Math.pow(2,o),o+=7}while(n>=Aw);return e.bytes=s-r,i},Aw=128,xw=127;var kw=Math.pow(2,7),Cw=Math.pow(2,14),Iw=Math.pow(2,21),Tw=Math.pow(2,28),Pw=Math.pow(2,35),Rw=Math.pow(2,42),Dw=Math.pow(2,49),Nw=Math.pow(2,56),Bw=Math.pow(2,63);const Lw={encode:ww,decode:Sw,encodingLength:function(e){return e<kw?1:e<Cw?2:e<Iw?3:e<Tw?4:e<Pw?5:e<Rw?6:e<Dw?7:e<Nw?8:e<Bw?9:10}};function Uw(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Lw.encode(e,t,r),t}function Mw(e){return Lw.encodingLength(e)}function Ow(e,t){const r=t.byteLength,n=Mw(e),i=n+Mw(r),o=new Uint8Array(i+r);return Uw(e,o,0),Uw(r,o,n),o.set(t,i),new qw(e,r,t,o)}class qw{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const zw=xm;const Fw={code:0,name:"identity",encode:zw,digest:function(e){return Ow(0,zw(e))}};function Kw(e){let{name:t,code:r,encode:n}=e;return new Vw(t,r,n)}class Vw{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?Ow(this.code,t):t.then((e=>Ow(this.code,e)))}throw Error("Unknown type, must be binary type")}}function jw(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Hw=Kw({name:"sha2-256",code:18,encode:jw("SHA-256")}),Ww=Kw({name:"sha2-512",code:19,encode:jw("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Gw={...Z,...H,...X,...V,...j,...G,...Y,...Q,...J,...W};function Yw(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Qw=Yw("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Jw=Yw("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Am((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Xw={utf8:Qw,"utf-8":Qw,hex:Gw.base16,latin1:Jw,ascii:Jw,binary:Jw,...Gw};class Zw{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function $w(){}class ev{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const tv=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 Am(e);i+e>t&&(n=Am(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class rv{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new Zw($w,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Zw(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ov((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(sv,10,bm.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=bm.fromBigInt(e);return this._push(sv,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=bm.fromBigInt(e).zzEncode();return this._push(sv,t.length(),t)}sint64Number(e){const t=bm.fromNumber(e).zzEncode();return this._push(sv,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(nv,1,e?1:0)}fixed32(e){return this._push(av,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=bm.fromBigInt(e);return this._push(av,4,t.lo)._push(av,4,t.hi)}fixed64Number(e){const t=bm.fromNumber(e);return this._push(av,4,t.lo)._push(av,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(um,4,e)}double(e){return this._push(fm,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(nv,1,0):this.uint32(t)._push(cv,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(wm,t,e):this._push(nv,1,0)}fork(){return this.states=new ev(this),this.head=this.tail=new Zw($w,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 Zw($w,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?Am(r):tv(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function nv(e,t,r){t[r]=255&e}function iv(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class ov extends Zw{constructor(e,t){super(iv,e,t),Ji(this,"next",void 0),this.next=void 0}}function sv(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 av(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 cv(e,t,r){t.set(e,r)}function lv(e,t,r){t.set(e,r)}function uv(e,t,r){e.length<40?wm(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=Xw[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function hv(e,t){const r=new rv;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var dv,fv,pv,gv,bv;function yv(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function mv(e,t){return yv("message",dv.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(rv.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(lv,t,e),this},rv.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(uv,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"}(dv||(dv={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(fv||(fv={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(pv||(pv={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return yv("enum",dv.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(pv)}(fv||(fv={})),function(e){let t;e.codec=()=>(null==t&&(t=mv((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),fv.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=fv.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>hv(t,e.codec()),e.decode=t=>Sm(t,e.codec())}(gv||(gv={})),function(e){let t;e.codec=()=>(null==t&&(t=mv((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),fv.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=fv.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>hv(t,e.codec()),e.decode=t=>Sm(t,e.codec())}(bv||(bv={}));class wv{constructor(e){Ji(this,"_key",void 0),this._key=xv(e,$y)}async verify(e,t){return async function(e,t,r){return jb.verify(t,r,e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return gv.encode({Type:fv.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await Zy.digest(this.bytes);return e}}class vv{constructor(e,t){Ji(this,"_key",void 0),Ji(this,"_publicKey",void 0),this._key=xv(e,em),this._publicKey=xv(t,$y)}async sign(e){return async function(e,t){const r=e.subarray(0,tm);return jb.sign(t,r)}(this._key,e)}get public(){return new wv(this._publicKey)}marshal(){return this._key}get bytes(){return bv.encode({Type:fv.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await Zy.digest(this.bytes);return e}async id(){const e=Yy(this.public.bytes);return xy.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 am(this.bytes,e);throw new ly("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function _v(e){if(e.length>em){const t=(e=xv(e,em+$y)).subarray(0,em),r=e.subarray(em,e.length);return new vv(t,r)}const t=(e=xv(e,em)).subarray(0,em),r=e.subarray($y);return new vv(t,r)}function Ev(e){return e=xv(e,$y),new wv(e)}async function Sv(){const{privateKey:e,publicKey:t}=await async function(){const e=jb.utils.randomPrivateKey(),t=jb.getPublicKey(e);return{privateKey:rm(e,t),publicKey:t}}();return new vv(e,t)}async function Av(e){const{privateKey:t,publicKey:r}=await async function(e){if(e.length!==tm)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=jb.getPublicKey(t);return{privateKey:rm(t,r),publicKey:r}}(e);return new vv(t,r)}function xv(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new ly("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}var kv=__webpack_require__(3900);__webpack_require__(9463);function Cv(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=Fa([new Uint8Array(t-r.length),r])}return za(r,"base64url")}function Iv(e){const t=function(e,t){let r=kc(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=Fa([new Uint8Array(t-r.length),r])}return r}(e);return new fy.jsbn.BigInteger(za(t,"base16"),16)}const Tv={"P-256":256,"P-384":384,"P-521":521};Object.keys(Tv).join(" / ");__webpack_require__(8138);function Pv(e){if(isNaN(e)||e<=0)throw new ly("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return mg(e)}__webpack_require__(9408);function Rv(e,t){return t.map((t=>Iv(e[t])))}async function Dv(e){const t=[await im.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Bv(e)],r=await Nv({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function Nv(e){if(null==e.privateKey||null==e.publicKey)throw new ly("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([im.get().subtle.exportKey("jwk",e.privateKey),im.get().subtle.exportKey("jwk",e.publicKey)])}async function Bv(e){return im.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 Lv(e,t,r,n){const i=t?function(e){return fy.pki.setRsaPublicKey(...Rv(e,["n","e"]))}(e):function(e){return fy.pki.setRsaPrivateKey(...Rv(e,["n","e","d","p","q","dp","dq","qi"]))}(e);return kc(n(za(Uint8Array.from(r),"ascii"),i),"ascii")}function Uv(e){if("RSA"!==e.kty)throw new ly("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ly("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*kc(e.n,"base64url").length}const Mv=8192;class Ov{constructor(e){Ji(this,"_key",void 0),this._key=e}async verify(e,t){return async function(e,t,r){const n=await im.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return im.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r)}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ly("JWK was missing components","ERR_INVALID_PARAMETERS");const t=fy.pki.publicKeyToAsn1({n:Iv(e.n),e:Iv(e.e)});return kc(fy.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return gv.encode({Type:fv.RSA,Data:this.marshal()}).subarray()}encrypt(e){return Lv(this._key,!0,e,((e,t)=>t.encrypt(e)))}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await Zy.digest(this.bytes);return e}}class qv{constructor(e,t){Ji(this,"_key",void 0),Ji(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return Pv(16)}async sign(e){return async function(e,t){const r=await im.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await im.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(t));return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ly("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Ov(this._publicKey)}decrypt(e){return Lv(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 ly("JWK was missing components","ERR_INVALID_PARAMETERS");const t=fy.pki.privateKeyToAsn1({n:Iv(e.n),e:Iv(e.e),d:Iv(e.d),p:Iv(e.p),q:Iv(e.q),dP:Iv(e.dp),dQ:Iv(e.dq),qInv:Iv(e.qi)});return kc(fy.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return bv.encode({Type:fv.RSA,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await Zy.digest(this.bytes);return e}async id(){return za(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 fy.util.ByteBuffer(this.marshal()),r=fy.asn1.fromDer(t),n=fy.pki.privateKeyFromAsn1(r),i={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return fy.pki.encryptRsaPrivateKey(n,e,i)}if("libp2p-key"===t)return am(this.bytes,e);throw new ly("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function zv(e){const t=function(e){const t=fy.asn1.fromDer(za(e,"ascii")),r=fy.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:Cv(r.n),e:Cv(r.e),d:Cv(r.d),p:Cv(r.p),q:Cv(r.q),dp:Cv(r.dP),dq:Cv(r.dQ),qi:Cv(r.qInv),alg:"RS256"}}(e);if(Uv(t)>Mv)throw new ly("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await Dv(t);return new qv(r.privateKey,r.publicKey)}function Fv(e){const t=function(e){const t=fy.asn1.fromDer(za(e,"ascii")),r=fy.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:Cv(r.n),e:Cv(r.e)}}(e);if(Uv(t)>Mv)throw new ly("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Ov(t)}async function Kv(e){if(Uv(e)>Mv)throw new ly("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await Dv(e);return new qv(t.privateKey,t.publicKey)}async function Vv(e){if(e>Mv)throw new ly("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await im.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 Nv(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new qv(t.privateKey,t.publicKey)}const{bytesToNumberBE:jv,hexToBytes:Hv}=K,Wv={Err:class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}},_parseInt(e){const{Err:t}=Wv;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:jv(n),l:e.subarray(r+2)}},toSig(e){const{Err:t}=Wv,r="string"===typeof e?Hv(e):e;Bg(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}=Wv._parseInt(r.subarray(2)),{d:s,l:a}=Wv._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)}},Gv=BigInt(0),Yv=BigInt(1),Qv=(BigInt(2),BigInt(3));BigInt(4);function Jv(e){const t=function(e){const t=vb(e);Zg(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 Wg(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&&Gv<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(Ng(e)&&(e=Ug(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:Fg(Hg("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=sb(s,o)),a(s),s}const l=new Map;function u(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(Hg("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.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){u(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)),l=r.eql(r.mul(n,a),r.mul(s,i));return c&&l}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,Qv),{px:o,py:s,pz:a}=this;let c=r.ZERO,l=r.ZERO,u=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),u=r.mul(o,a),u=r.add(u,u),c=r.mul(e,u),l=r.mul(i,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(g,c),u=r.mul(i,u),p=r.mul(e,p),g=r.sub(d,p),g=r.mul(e,g),g=r.add(g,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,g),l=r.add(l,d),p=r.mul(s,a),p=r.add(p,p),d=r.mul(p,g),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new h(c,l,u)}add(e){u(e);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:c}=e;let l=r.ZERO,d=r.ZERO,f=r.ZERO;const p=t.a,g=r.mul(t.b,Qv);let b=r.mul(n,s),y=r.mul(i,a),m=r.mul(o,c),w=r.add(n,i),v=r.add(s,a);w=r.mul(w,v),v=r.add(b,y),w=r.sub(w,v),v=r.add(n,o);let _=r.add(s,c);return v=r.mul(v,_),_=r.add(b,m),v=r.sub(v,_),_=r.add(i,o),l=r.add(a,c),_=r.mul(_,l),l=r.add(y,m),_=r.sub(_,l),f=r.mul(p,v),l=r.mul(g,m),f=r.add(l,f),l=r.sub(y,f),f=r.add(y,f),d=r.mul(l,f),y=r.add(b,b),y=r.add(y,b),m=r.mul(p,m),v=r.mul(g,v),y=r.add(y,m),m=r.sub(b,m),m=r.mul(p,m),v=r.add(v,m),b=r.mul(y,v),d=r.add(d,b),b=r.mul(_,v),l=r.mul(w,l),l=r.sub(l,b),b=r.mul(w,y),f=r.mul(_,f),f=r.add(f,b),new h(l,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return f.wNAFCached(this,l,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===Gv)return n;if(a(e),e===Yv)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:c,k2:l}=i.splitScalar(e),u=n,d=n,p=this;for(;s>Gv||l>Gv;)s&Yv&&(u=u.add(p)),l&Yv&&(d=d.add(p)),p=p.double(),s>>=Yv,l>>=Yv;return o&&(u=u.negate()),c&&(d=d.negate()),d=new h(r.mul(d.px,i.beta),d.py,d.pz),u.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:l,f:u}=this.wNAF(t),{p:d,f:p}=this.wNAF(c);l=f.constTimeNegate(e,l),d=f.constTimeNegate(a,d),d=new h(r.mul(d.px,s.beta),d.py,d.pz),n=l.add(d),i=u.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!==Gv&&t!==Yv&&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===Yv)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===Yv?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 Ug(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=wb(h,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function Xv(e){const t=function(e){const t=vb(e);return Zg(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 sb(e,n)}function a(e){return lb(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=Jv({...t,toBytes(e,t,n){const i=t.toAffine(),o=r.toBytes(i.x),s=Wg;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=Fg(s);if(!(Gv<(a=e)&&a<r.ORDER))throw new Error("Point is not on curve");const t=u(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&Yv)===Yv)&&(i=r.neg(i)),{x:e,y:i}}var a}}),d=e=>Ug(Vg(e,t.nByteLength));function f(e){return e>n>>Yv}const p=(e,t,r)=>Fg(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=Hg("compactSignature",e,2*r),new g(p(e,0,r),p(e,r,2*r))}static fromDER(e){const{r:t,s:r}=Wv.toSig(Hg("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,l=w(Hg("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const u=2===o||3===o?n+t.n:n;if(u>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=0===(1&o)?"02":"03",f=c.fromHex(h+d(u)),p=a(u),g=s(-l*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 zg(this.toDERHex())}toDERHex(){return Wv.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zg(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const b={isValidPrivateKey(e){try{return l(e),!0}catch(t){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=bb(t.n);return function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=e.length,i=gb(t),o=bb(t);if(n<16||n<o||n>1024)throw new Error("expected ".concat(o,"-1024 bytes of input, got ").concat(n));const s=sb(r?Fg(e):Kg(e),t-eb)+eb;return r?jg(s,i):Vg(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=Ng(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=Fg(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},w=t.bits2int_modN||function(e){return s(m(e))},v=Gg(t.nBitLength);function _(e){if("bigint"!==typeof e)throw new Error("bigint expected");if(!(Gv<=e&&e<v))throw new Error("bigint expected < 2^".concat(t.nBitLength));return Vg(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:u}=t;let{lowS:d,prehash:p,extraEntropy:b}=i;null==d&&(d=!0),e=Hg("msgHash",e),p&&(e=Hg("prehashed msgHash",o(e)));const y=w(e),v=l(n),E=[_(v),_(y)];if(null!=b&&!1!==b){const e=!0===b?u(r.BYTES):b;E.push(Hg("extraEntropy",e))}const A=Wg(...E),x=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===Gv)return;const o=s(r*s(x+i*v));if(o===Gv)return;let l=(n.x===i?0:2)|Number(n.y&Yv),u=o;return d&&f(o)&&(u=function(e){return f(e)?s(-e):e}(o),l^=1),new g(i,u,l)}}}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(l(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 Jg(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 l=e;if(r=Hg("msgHash",r),n=Hg("publicKey",n),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=o;let d,f;try{if("string"===typeof l||Ng(l))try{d=g.fromDER(l)}catch(S){if(!(S instanceof Wv.Err))throw S;d=g.fromCompact(l)}else{if("object"!==typeof l||"bigint"!==typeof l.r||"bigint"!==typeof l.s)throw new Error("PARSE");{const{r:e,s:t}=l;d=new g(e,t)}}f=c.fromHex(n)}catch(x){if("PARSE"===x.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&d.hasHighS())return!1;h&&(r=t.hash(r));const{r:p,s:b}=d,y=w(r),m=a(b),v=s(y*m),_=s(p*m),E=null===(i=c.BASE.multiplyAndAddUnsafe(f,v,_))||void 0===i?void 0:i.toAffine();return!!E&&s(E.x)===p},ProjectivePoint:c,Signature:g,utils:b}}function Zv(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 Qb(e,t,gg(...n))},randomBytes:mg}}const $v=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),e_=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),t_=BigInt(1),r_=BigInt(2),n_=(e,t)=>(e+t/r_)/t;function i_(e){const t=$v,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,h=cb(u,r,t)*u%t,d=cb(h,r,t)*u%t,f=cb(d,r_,t)*l%t,p=cb(f,i,t)*f%t,g=cb(p,o,t)*p%t,b=cb(g,a,t)*g%t,y=cb(b,c,t)*b%t,m=cb(y,a,t)*g%t,w=cb(m,r,t)*u%t,v=cb(w,s,t)*p%t,_=cb(v,n,t)*l%t,E=cb(_,r_,t);if(!o_.eql(o_.sqr(E),e))throw new Error("Cannot find square root");return E}const o_=pb($v,void 0,void 0,{sqrt:i_}),s_=function(e,t){const r=t=>Xv({...e,...Zv(t)});return Object.freeze({...r(t),create:r})}({a:BigInt(0),b:BigInt(7),Fp:o_,n:e_,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=e_,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-t_*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=n_(o*e,t),c=n_(-n*e,t);let l=sb(e-a*r-c*i,t),u=sb(-a*n-c*o,t);const h=l>s,d=u>s;if(h&&(l=t-l),d&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:l,k2neg:d,k2:u}}}},iy);BigInt(0);s_.ProjectivePoint;function a_(e){try{s_.ProjectivePoint.fromHex(e)}catch(t){throw new ly(String(t),"ERR_INVALID_PUBLIC_KEY")}}class c_{constructor(e){Ji(this,"_key",void 0),a_(e),this._key=e}async verify(e,t){return async function(e,t,r){try{const{digest:n}=await Zy.digest(r);return s_.verify(t,n,e)}catch(n){throw new ly(String(n),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,s_.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return gv.encode({Type:fv.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await Zy.digest(this.bytes);return e}}class l_{constructor(e,t){Ji(this,"_key",void 0),Ji(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return s_.getPublicKey(e,!0)}catch(t){throw new ly(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{s_.getPublicKey(e,!0)}catch(t){throw new ly(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),a_(this._publicKey)}async sign(e){return async function(e,t){const{digest:r}=await Zy.digest(t);try{return s_.sign(r,e).toDERRawBytes()}catch(n){throw new ly(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new c_(this._publicKey)}marshal(){return this._key}get bytes(){return bv.encode({Type:fv.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await Zy.digest(this.bytes);return e}async id(){return za(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 am(this.bytes,e);throw new ly("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function u_(e){return new l_(e)}function h_(e){return new c_(e)}async function d_(){const e=s_.utils.randomPrivateKey();return new l_(e)}const f_={rsa:ie,ed25519:ne,secp256k1:oe};function p_(e){const t=Object.keys(f_).join(" / ");return new ly("invalid or unsupported key type ".concat(e,". Must be ").concat(t),"ERR_UNSUPPORTED_KEY_TYPE")}function g_(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return f_[e];throw p_(e)}async function b_(e,t){return g_(e).generateKeyPair(null!==t&&void 0!==t?t:2048)}function y_(e){var t,r;const n=gv.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case fv.RSA:return f_.rsa.unmarshalRsaPublicKey(i);case fv.Ed25519:return f_.ed25519.unmarshalEd25519PublicKey(i);case fv.Secp256k1:return f_.secp256k1.unmarshalSecp256k1PublicKey(i);default:throw p_(null!==(r=n.Type)&&void 0!==r?r:"unknown")}}function m_(e,t){var r;return g_(t=(null!==(r=t)&&void 0!==r?r:"rsa").toLowerCase()),e.bytes}async function w_(e){var t,r;const n=bv.decode(e),i=null!==(t=n.Data)&&void 0!==t?t:new Uint8Array;switch(n.Type){case fv.RSA:return f_.rsa.unmarshalRsaPrivateKey(i);case fv.Ed25519:return f_.ed25519.unmarshalEd25519PrivateKey(i);case fv.Secp256k1:return f_.secp256k1.unmarshalSecp256k1PrivateKey(i);default:throw p_(null!==(r=n.Type)&&void 0!==r?r:"RSA")}}async function v_(e,t){try{const r=await async function(e,t){const r=nm.decode(e);return sm().decrypt(r,t)}(e,t);return await w_(r)}catch(i){}const r=fy.pki.decryptRsaPrivateKey(e,t);if(null===r)throw new ly("Cannot read the key, most likely the password is wrong or not a RSA key","ERR_CANNOT_DECRYPT_PEM");let n=fy.asn1.toDer(fy.pki.privateKeyToAsn1(r));return n=kc(n.getBytes(),"ascii"),f_.rsa.unmarshalRsaPrivateKey(n)}var __=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const E_=__,S_=(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 A_{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 x_{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 C_(this,e)}}class k_{constructor(e){this.decoders=e}or(e){return C_(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 C_=(e,t)=>new k_({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class I_{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new A_(e,t,r),this.decoder=new x_(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const T_=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new I_(t,r,n,i)},P_=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=E_(n,r);return T_({prefix:t,name:r,encode:i,decode:e=>S_(o(e))})},R_=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return T_({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},D_=P_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),N_=P_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),B_=P_({prefix:"9",name:"base10",alphabet:"0123456789"}),L_=R_({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),U_=R_({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),M_=R_({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),O_=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"),q_=O_.reduce(((e,t,r)=>(e[r]=t,e)),[]),z_=O_.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const F_=T_({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=q_[t]),"")},decode:function(e){const t=[];for(const r of e){const e=z_[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),K_=R_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),V_=R_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),j_=R_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),H_=R_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),W_=R_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),G_=R_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Y_=R_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Q_=R_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),J_=R_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),X_=P_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Z_=P_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),$_=R_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),eE=R_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tE=R_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rE=R_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),nE=R_({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),iE=T_({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),oE=new TextEncoder,sE=new TextDecoder,aE="json",cE=512,lE=e=>oE.encode(JSON.stringify(e)),uE=e=>JSON.parse(sE.decode(e)),hE="raw",dE=85,fE=e=>S_(e),pE=e=>S_(e);var gE=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=mE;)r[n++]=255&t|bE,t/=128;for(;t&yE;)r[n++]=255&t|bE,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},bE=128,yE=-128,mE=Math.pow(2,31);var wE=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&_E)<<o:(n&_E)*Math.pow(2,o),o+=7}while(n>=vE);return e.bytes=s-r,i},vE=128,_E=127;var EE=Math.pow(2,7),SE=Math.pow(2,14),AE=Math.pow(2,21),xE=Math.pow(2,28),kE=Math.pow(2,35),CE=Math.pow(2,42),IE=Math.pow(2,49),TE=Math.pow(2,56),PE=Math.pow(2,63);const RE={encode:gE,decode:wE,encodingLength:function(e){return e<EE?1:e<SE?2:e<AE?3:e<xE?4:e<kE?5:e<CE?6:e<IE?7:e<TE?8:e<PE?9:10}},DE=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[RE.decode(e,t),RE.decode.bytes]},NE=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return RE.encode(e,t,r),t},BE=e=>RE.encodingLength(e),LE=(e,t)=>{const r=t.byteLength,n=BE(e),i=n+BE(r),o=new Uint8Array(i+r);return NE(e,o,0),NE(r,o,n),o.set(t,i),new ME(e,r,t,o)},UE=e=>{const t=S_(e),[r,n]=DE(t),[i,o]=DE(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new ME(r,i,s,t)};class ME{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const OE=S_,qE={code:0,name:"identity",encode:OE,digest:e=>LE(0,OE(e))},zE=e=>{let{name:t,code:r,encode:n}=e;return new FE(t,r,n)};class FE{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?LE(this.code,t):t.then((e=>LE(this.code,e)))}throw Error("Unknown type, must be binary type")}}const KE=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),VE=zE({name:"sha2-256",code:18,encode:KE("SHA-256")}),jE=zE({name:"sha2-512",code:19,encode:KE("SHA-512")}),HE=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?JE(r,GE(e),t||D_.encoder):XE(r,GE(e),t||K_.encoder)},WE=new WeakMap,GE=e=>{const t=WE.get(e);if(null==t){const t=new Map;return WE.set(e,t),t}return t};class YE{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!==ZE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$E)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return YE.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=LE(e,t);return YE.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 YE.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 HE(this,e)}toJSON(){return{"/":HE(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 YE)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new YE(e,r,n,i||eS(e,r,n.bytes))}if(!0===t[tS]){const{version:e,multihash:r,code:n}=t,i=UE(r);return YE.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!==ZE)throw new Error("Version 0 CID must use dag-pb (code: ".concat(ZE,") block encoding"));return new YE(e,t,r,r.bytes);case 1:{const n=eS(e,t,r.bytes);return new YE(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return YE.create(0,ZE,e)}static createV1(e,t){return YE.create(1,e,t)}static decode(e){const[t,r]=YE.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=YE.inspectBytes(e),r=t.size-t.multihashSize,n=S_(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 ME(t.multihashCode,t.digestSize,i,n);return[0===t.version?YE.createV0(o):YE.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=DE(e.subarray(t));return t+=n,r};let n=r(),i=ZE;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]=QE(e,t),i=YE.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return GE(i).set(r,e),i}}const QE=(e,t)=>{switch(e[0]){case"Q":{const r=t||D_;return[D_.prefix,r.decode("".concat(D_.prefix).concat(e))]}case D_.prefix:{const r=t||D_;return[D_.prefix,r.decode(e)]}case K_.prefix:{const r=t||K_;return[K_.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)]}},JE=(e,t,r)=>{const{prefix:n}=r;if(n!==D_.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},XE=(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},ZE=112,$E=18,eS=(e,t,r)=>{const n=BE(e),i=n+BE(t),o=new Uint8Array(i+r.byteLength);return NE(e,o,0),NE(t,o,n),o.set(r,i),o},tS=Symbol.for("@ipld/js-cid/CID"),rS={...ge,...le,...pe,...ae,...ce,...he,...de,...se,...fe,...ue},nS=Symbol.for("nodejs.util.inspect.custom"),iS=Object.values(rS).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),rS.identity.decoder),oS=114,sS=36,aS=37;class cS{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=D_.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return YE.createV1(oS,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:iS,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=UE(D_.decode("z".concat(e)));return e.startsWith("12D")?new uS({multihash:t}):e.startsWith("16U")?new hS({multihash:t}):new lS({multihash:t})}return function(e){try{const t=UE(e);if(t.code===qE.code){if(t.digest.length===sS)return new uS({multihash:t});if(t.digest.length===aS)return new hS({multihash:t})}if(t.code===VE.code)return new lS({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==oS)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===VE.code)return new lS({multihash:e.multihash});if(t.code===qE.code){if(t.digest.length===sS)return new uS({multihash:e.multihash});if(t.digest.length===aS)return new hS({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(YE.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(iS.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[nS](){return"PeerId(".concat(this.toString(),")")}}class lS extends cS{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class uS extends cS{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class hS extends cS{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}async function dS(e,t){return e.length===sS?new uS({multihash:LE(qE.code,e),privateKey:t}):e.length===aS?new hS({multihash:LE(qE.code,e),privateKey:t}):new lS({multihash:await VE.digest(e),publicKey:e,privateKey:t})}const fS=new Float32Array([-0]),pS=new Uint8Array(fS.buffer);function gS(e,t,r){fS[0]=e,t[r]=pS[0],t[r+1]=pS[1],t[r+2]=pS[2],t[r+3]=pS[3]}const bS=new Float64Array([-0]),yS=new Uint8Array(bS.buffer);function mS(e,t,r){bS[0]=e,t[r]=yS[0],t[r+1]=yS[1],t[r+2]=yS[2],t[r+3]=yS[3],t[r+4]=yS[4],t[r+5]=yS[5],t[r+6]=yS[6],t[r+7]=yS[7]}const wS=BigInt(Number.MAX_SAFE_INTEGER),vS=BigInt(Number.MIN_SAFE_INTEGER);class _S{constructor(e,t){Ji(this,"lo",void 0),Ji(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 ES;if(e<wS&&e>vS)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>SS&&(n=0n,++r>SS&&(r=0n))),new _S(Number(n),Number(r))}static fromNumber(e){if(0===e)return ES;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 _S(r,n)}static from(e){return"number"===typeof e?_S.fromNumber(e):"bigint"===typeof e?_S.fromBigInt(e):"string"===typeof e?_S.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new _S(e.low>>>0,e.high>>>0):ES}}const ES=new _S(0,0);ES.toBigInt=function(){return 0n},ES.zzEncode=ES.zzDecode=function(){return this},ES.length=function(){return 1};const SS=4294967296n;function AS(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 xS(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function kS(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class CS{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,xS(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 xS(this,4);return kS(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xS(this,4);return 0|kS(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw xS(this,4);const e=(t=this.buf,r=this.pos,pS[0]=t[r],pS[1]=t[r+1],pS[2]=t[r+2],pS[3]=t[r+3],fS[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw xS(this,4);const e=(t=this.buf,r=this.pos,yS[0]=t[r],yS[1]=t[r+1],yS[2]=t[r+2],yS[3]=t[r+3],yS[4]=t[r+4],yS[5]=t[r+5],yS[6]=t[r+6],yS[7]=t[r+7],bS[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 xS(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 xS(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw xS(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 _S(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw xS(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 xS(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 xS(this,8);const e=kS(this.buf,this.pos+=4),t=kS(this.buf,this.pos+=4);return new _S(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 IS(e,t,r){const n=function(e){return new CS(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function TS(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function PS(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 RS=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const DS=RS;class NS{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 BS{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 US(this,e)}}class LS{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return US(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 US(e,t){var r,n;return new LS({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class MS{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new NS(e,t,r),this.decoder=new BS(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function OS(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new MS(t,r,n,i)}function qS(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=DS(n,t);return OS({prefix:r,name:t,encode:i,decode:e=>PS(o(e))})}function zS(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return OS({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 FS=qS({prefix:"9",name:"base10",alphabet:"0123456789"}),KS=zS({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),VS=zS({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),jS=zS({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),HS=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"),WS=HS.reduce(((e,t,r)=>(e[r]=t,e)),[]),GS=HS.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const YS=OS({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=WS[t]),"")},decode:function(e){const t=[];for(const r of e){const e=GS[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),QS=zS({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),JS=zS({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),XS=zS({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ZS=zS({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$S=zS({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),eA=zS({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tA=zS({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rA=zS({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nA=zS({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),iA=qS({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),oA=qS({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),sA=qS({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),aA=qS({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),cA=zS({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),lA=zS({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),uA=zS({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hA=zS({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),dA=zS({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),fA=OS({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)}),pA=new TextEncoder,gA=new TextDecoder,bA="json",yA=512;function mA(e){return pA.encode(JSON.stringify(e))}function wA(e){return JSON.parse(gA.decode(e))}const vA="raw",_A=85;function EA(e){return PS(e)}function SA(e){return PS(e)}var AA=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=CA;)r[n++]=255&t|xA,t/=128;for(;t&kA;)r[n++]=255&t|xA,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},xA=128,kA=-128,CA=Math.pow(2,31);var IA=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&PA)<<o:(n&PA)*Math.pow(2,o),o+=7}while(n>=TA);return e.bytes=s-r,i},TA=128,PA=127;var RA=Math.pow(2,7),DA=Math.pow(2,14),NA=Math.pow(2,21),BA=Math.pow(2,28),LA=Math.pow(2,35),UA=Math.pow(2,42),MA=Math.pow(2,49),OA=Math.pow(2,56),qA=Math.pow(2,63);const zA={encode:AA,decode:IA,encodingLength:function(e){return e<RA?1:e<DA?2:e<NA?3:e<BA?4:e<LA?5:e<UA?6:e<MA?7:e<OA?8:e<qA?9:10}};function FA(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return zA.encode(e,t,r),t}function KA(e){return zA.encodingLength(e)}function VA(e,t){const r=t.byteLength,n=KA(e),i=n+KA(r),o=new Uint8Array(i+r);return FA(e,o,0),FA(r,o,n),o.set(t,i),new jA(e,r,t,o)}class jA{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const HA=PS;const WA={code:0,name:"identity",encode:HA,digest:function(e){return VA(0,HA(e))}};function GA(e){let{name:t,code:r,encode:n}=e;return new YA(t,r,n)}class YA{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?VA(this.code,t):t.then((e=>VA(this.code,e)))}throw Error("Unknown type, must be binary type")}}function QA(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const JA=GA({name:"sha2-256",code:18,encode:QA("SHA-256")}),XA=GA({name:"sha2-512",code:19,encode:QA("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const ZA={...Te,...Ee,...Ie,...ve,..._e,...Ae,...xe,...ke,...Ce,...Se};function $A(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const ex=$A("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),tx=$A("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=TS((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),rx={utf8:ex,"utf-8":ex,hex:ZA.base16,latin1:tx,ascii:tx,binary:tx,...ZA};class nx{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function ix(){}class ox{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const sx=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 TS(e);i+e>t&&(n=TS(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class ax{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new nx(ix,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new nx(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ux((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(hx,10,_S.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=_S.fromBigInt(e);return this._push(hx,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=_S.fromBigInt(e).zzEncode();return this._push(hx,t.length(),t)}sint64Number(e){const t=_S.fromNumber(e).zzEncode();return this._push(hx,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(cx,1,e?1:0)}fixed32(e){return this._push(dx,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=_S.fromBigInt(e);return this._push(dx,4,t.lo)._push(dx,4,t.hi)}fixed64Number(e){const t=_S.fromNumber(e);return this._push(dx,4,t.lo)._push(dx,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(gS,4,e)}double(e){return this._push(mS,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(cx,1,0):this.uint32(t)._push(fx,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(AS,t,e):this._push(cx,1,0)}fork(){return this.states=new ox(this),this.head=this.tail=new nx(ix,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 nx(ix,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?TS(r):sx(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function cx(e,t,r){t[r]=255&e}function lx(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class ux extends nx{constructor(e,t){super(lx,e,t),Ji(this,"next",void 0),this.next=void 0}}function hx(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 dx(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 fx(e,t,r){t.set(e,r)}function px(e,t,r){t.set(e,r)}function gx(e,t,r){e.length<40?AS(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=rx[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function bx(e,t){const r=new ax;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var yx,mx,wx;function vx(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",yx.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(ax.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(px,t,e),this},ax.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(gx,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"}(yx||(yx={}));Error;async function _x(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 w_(e.privateKey);return r.sign(t)}(e,Ax(t));if(null==e.publicKey)throw new Error("PublicKey was missing from local PeerId");return function(e,t,r){return wx.encode({identityKey:e,identitySig:t,extensions:null!==r&&void 0!==r?r:{webtransportCerthashes:[]}}).subarray()}(e.publicKey,n,r)}async function Ex(e){return dS(e.identityKey)}function Sx(e){return wx.decode(e)}function Ax(e){const t=kc("noise-libp2p-static-key:");return Fa([t,e],t.length+e.length)}async function xx(e,t,r){const n=await dS(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=Ax(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=y_(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 kx(e){return e instanceof Uint8Array&&32===e.length}function Cx(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}!function(e){let t;e.codec=()=>(null==t&&(t=vx((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=>bx(t,e.codec()),e.decode=t=>IS(t,e.codec())}(mx||(mx={})),function(e){let t;e.codec=()=>(null==t&&(t=vx((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),mx.codec().encode(e.extensions,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={identityKey:Ba(0),identitySig:Ba(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=mx.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>bx(t,e.codec()),e.decode=t=>IS(t,e.codec())}(wx||(wx={})),yl.formatters.b=e=>null==e?"undefined":D_.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":K_.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":$_.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();const Ix=Cx("libp2p:noise");let Tx;function Px(e){e?(Tx("LOCAL_PUBLIC_EPHEMERAL_KEY ".concat(za(e.publicKey,"hex"))),Tx("LOCAL_PRIVATE_EPHEMERAL_KEY ".concat(za(e.privateKey,"hex")))):Tx("Missing local ephemeral keys.")}function Rx(e){Tx("REMOTE_EPHEMERAL_PUBLIC_KEY ".concat(za(e,"hex")))}Tx=_p?Ix:Object.assign((()=>{}),{enabled:!1,trace:()=>{},error:()=>{}});class Dx{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;Ji(this,"n",void 0),Ji(this,"bytes",void 0),Ji(this,"view",void 0),this.n=e,this.bytes=Ba(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 Nx{constructor(e){Ji(this,"crypto",void 0),this.crypto=e}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 Ba(32)}isEmptyKey(e){return ls(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:Ba(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 Ix.error(e),Ba(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(Fa([e,t],e.length+t.length))}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 Dx}}initializeSymmetric(e){const t=kc(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=Ba(32);return t.set(e),t}return this.getHash(e,Ba(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,Ba(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,Ba(0),t);return{ne:this.createEmptyKey(),ns:Ba(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,Ba(0),t.ciphertext)}}class Bx extends Nx{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:Ba(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:Ba(32)}}writeMessageA(e,t,r){const n=Ba(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 kx(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(kx(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&&kx(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&&kx(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=Ba(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=Ba(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}}}class Lx{constructor(e,t,r,n,i,o,s,a){Ji(this,"isInitiator",void 0),Ji(this,"session",void 0),Ji(this,"remotePeer",void 0),Ji(this,"remoteExtensions",{webtransportCerthashes:[]}),Ji(this,"payload",void 0),Ji(this,"connection",void 0),Ji(this,"xx",void 0),Ji(this,"staticKeypair",void 0),Ji(this,"prologue",void 0),this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=i,this.connection=o,s&&(this.remotePeer=s),this.xx=null!==a&&void 0!==a?a:new Bx(n),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){var e;if(e=this.session.hs.s,Tx("LOCAL_STATIC_PUBLIC_KEY ".concat(za(e.publicKey,"hex"))),Tx("LOCAL_STATIC_PRIVATE_KEY ".concat(za(e.privateKey,"hex"))),this.isInitiator){Ix.trace("Stage 0 - Initiator starting to send first message.");const e=this.xx.sendMessage(this.session,Ba(0));await this.connection.write(function(e){return Fa([e.ne,e.ciphertext],e.ne.length+e.ciphertext.length)}(e)),Ix.trace("Stage 0 - Initiator finished sending first message."),Px(this.session.hs.e)}else{Ix.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:Ba(0)}}((await this.connection.read()).subarray()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new hy("xx handshake stage 0 validation fail");Ix.trace("Stage 0 - Responder received first message."),Rx(this.session.hs.re)}}async exchange(){if(this.isInitiator){Ix.trace("Stage 1 - Initiator waiting to receive first message from responder...");const r=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:n,valid:i}=this.xx.recvMessage(this.session,r);if(!i)throw new hy("xx handshake stage 1 validation fail");Ix.trace("Stage 1 - Initiator received the message."),Rx(this.session.hs.re),e=this.session.hs.rs,Tx("REMOTE_STATIC_PUBLIC_KEY ".concat(za(e,"hex"))),Ix.trace("Initiator going to check remote's signature...");try{const e=Sx(n);this.remotePeer=this.remotePeer||await Ex(e),await xx(this.session.hs.rs,e,this.remotePeer),this.setRemoteNoiseExtension(e.extensions)}catch(t){throw new uy("Error occurred while verifying signed payload: ".concat(t.message))}Ix.trace("All good with the signature!")}else{Ix.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 Fa([e.ne,e.ns,e.ciphertext],e.ne.length+e.ns.length+e.ciphertext.length)}(e)),Ix.trace("Stage 1 - Responder sent the second handshake message with signed payload."),Px(this.session.hs.e)}var e}async finish(){if(this.isInitiator){Ix.trace("Stage 2 - Initiator sending third handshake message.");const e=this.xx.sendMessage(this.session,this.payload);await this.connection.write(function(e){return Fa([e.ns,e.ciphertext],e.ns.length+e.ciphertext.length)}(e)),Ix.trace("Stage 2 - Initiator sent message with signed payload.")}else{Ix.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:Ba(0),ns:e.subarray(0,48),ciphertext:e.subarray(48,e.length)}}((await this.connection.read()).subarray()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new hy("xx handshake stage 2 validation fail");Ix.trace("Stage 2 - Responder received the message, finished handshake.");try{const e=Sx(r);this.remotePeer=this.remotePeer||await Ex(e),await xx(this.session.hs.rs,e,this.remotePeer),this.setRemoteNoiseExtension(e.extensions)}catch(t){throw new uy("Error occurred while verifying signed payload: ".concat(t.message))}}var e;(e=this.session).cs1&&e.cs2?(Tx("CIPHER_STATE_1 ".concat(e.cs1.n.getUint64()," ").concat(za(e.cs1.k,"hex"))),Tx("CIPHER_STATE_2 ".concat(e.cs2.n.getUint64()," ").concat(za(e.cs2.k,"hex")))):Tx("Missing cipher state.")}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,Ba(0),e)}decrypt(e,t,r){const n=this.getCS(t,!1);return this.xx.decryptWithAd(n,Ba(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 hy("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 Ux{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ji(this,"protocol","/noise"),Ji(this,"crypto",void 0),Ji(this,"prologue",void 0),Ji(this,"staticKeys",void 0),Ji(this,"extensions",void 0),Ji(this,"metrics",void 0);const{staticNoiseKey:t,extensions:r,crypto:n,prologueBytes:i,metrics:o}=e;this.crypto=null!==n&&void 0!==n?n:oy,this.extensions=r,this.metrics=o?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"})}}(o):void 0,this.staticKeys=t?this.crypto.generateX25519KeyPairFromSeed(t):this.crypto.generateX25519KeyPair(),this.prologue=null!==i&&void 0!==i?i:Ba(0)}async secureOutbound(e,t,r){const n=yp(t,{lengthEncoder:sy,lengthDecoder:ay,maxDataLength:vp}),i=await this.performHandshake({connection:n,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:await this.createSecureConnection(n,i),remoteExtensions:i.remoteExtensions,remotePeer:i.remotePeer}}async secureInbound(e,t,r){const n=yp(t,{lengthEncoder:sy,lengthDecoder:ay,maxDataLength:vp}),i=await this.performHandshake({connection:n,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:await this.createSecureConnection(n,i),remotePeer:i.remotePeer,remoteExtensions:i.remoteExtensions}}async performHandshake(e){const t=await _x(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 Lx(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=mp(),t=mp();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}(),i=e.unwrap();return await pf(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=r+65519;i>n.length&&(i=n.length);const o=e.encrypt(n.subarray(r,i),e.session);null===t||void 0===t||t.encryptedPackets.increment(),yield Fa([sy(o.byteLength),o],2+o.byteLength)}}}(t,this.metrics),i,(e=>sf(e,{lengthDecoder:ay})),function(e,t){return async function*(r){for await(const n of r)for(let r=0;r<n.length;r+=vp){let i=r+vp;if(i>n.length&&(i=n.length),i-16<r)throw new Error("Invalid chunk");const o=n.subarray(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 Mx(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return()=>new Ux(e)}var Ox=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const qx=Ox;new Uint8Array(0);class zx{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 Fx{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 Vx(this,e)}}class Kx{constructor(e){this.decoders=e}or(e){return Vx(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 Vx=(e,t)=>new Kx({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class jx{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new zx(e,t,r),this.decoder=new Fx(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Hx=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new jx(t,r,n,i)},Wx=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=qx(n,r);return Hx({prefix:t,name:r,encode:i,decode:e=>(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))})},Gx=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Hx({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},Yx=Gx({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qx=(Gx({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gx({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gx({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gx({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gx({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gx({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Gx({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gx({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Wx({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"})),Jx=(Wx({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Gx({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}));Gx({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Gx({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gx({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Xx(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}yl.formatters.b=e=>null==e?"undefined":Qx.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":Yx.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":Jx.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();class Zx extends Error{constructor(e,t){super(null!==e&&void 0!==e?e:"The operation was aborted"),this.type="aborted",this.code=null!==t&&void 0!==t?t:"ABORT_ERR"}}function $x(e,t,r){const n=null!==r&&void 0!==r?r:{},i=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 async function*(){let r;const o=()=>{null!=r&&r()};for(t.addEventListener("abort",o);;){let a;try{if(t.aborted){const{abortMessage:e,abortCode:t}=n;throw new Zx(e,t)}const e=new Promise(((e,t)=>{r=()=>{const{abortMessage:e,abortCode:r}=n;t(new Zx(e,r))}}));a=await Promise.race([e,i.next()]),r=null}catch(s){t.removeEventListener("abort",o);const r="aborted"===s.type&&t.aborted;if(r&&null!=n.onAbort&&n.onAbort(e),"function"===typeof i.return)try{const e=i.return();e instanceof Promise&&e.catch((e=>{null!=n.onReturnError&&n.onReturnError(e)}))}catch(s){null!=n.onReturnError&&n.onReturnError(s)}if(r&&!0===n.returnOnAbort)return;throw s}if(!0===a.done)break;yield a.value}t.removeEventListener("abort",o)}()}var ek,tk=__webpack_require__(9413);!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"}(ek||(ek={}));const rk=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),nk=Object.freeze({NEW_STREAM:ek.NEW_STREAM,MESSAGE:ek.MESSAGE_INITIATOR,CLOSE:ek.CLOSE_INITIATOR,RESET:ek.RESET_INITIATOR}),ik=Object.freeze({MESSAGE:ek.MESSAGE_RECEIVER,CLOSE:ek.CLOSE_RECEIVER,RESET:ek.RESET_RECEIVER}),ok=1<<20;class sk{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ok,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4194304;Ji(this,"_buffer",void 0),Ji(this,"_headerInfo",void 0),Ji(this,"_maxMessageSize",void 0),Ji(this,"_maxUnprocessedMessageQueueSize",void 0),this._buffer=new Jd,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!==ek.NEW_STREAM&&n!==ek.MESSAGE_INITIATOR&&n!==ek.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}=lk(e),{value:n,offset:i}=lk(e,r),o=7&t;if(null==rk[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 ak=128,ck=127;function lk(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&ck)<<i:(t&ck)*Math.pow(2,i),i+=7}while(t>=ak);return r=o-r,{value:n,offset:r}}const uk=1048576,hk=(e,t)=>{t.append(e)};const dk=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(r,n,i){let o=new Jd,s=!1,a=af(),c=Number(null!==(r=null===t||void 0===t?void 0:t.size)&&void 0!==r?r:uk);if((isNaN(c)||0===c||c<0)&&(c=uk),c!==Math.round(c))throw new Error("Batch size must be an integer");const l=null!==(n=null===t||void 0===t?void 0:t.yieldAfter)&&void 0!==n?n:0,u=null!==(i=null===t||void 0===t?void 0:t.serialize)&&void 0!==i?i:hk;for(Promise.resolve().then((async()=>{try{let t;for await(const r of e)u(r,o),o.byteLength>=c?(clearTimeout(t),a.resolve()):t=setTimeout((()=>{a.resolve()}),l);clearTimeout(t),a.resolve()}catch(t){a.reject(t)}finally{s=!0}}));!s;)if(await a.promise,a=af(),o.byteLength>0){const e=o;o=new Jd,yield e.subarray()}}():function*(r,n){const i=new Jd;let o=Number(null!==(r=null===t||void 0===t?void 0:t.size)&&void 0!==r?r:uk);if((isNaN(o)||0===o||o<0)&&(o=uk),o!==Math.round(o))throw new Error("Batch size must be an integer");const s=null!==(n=null===t||void 0===t?void 0:t.serialize)&&void 0!==n?n:hk;for(const t of e)s(t,i),i.byteLength>=o&&(yield i.subarray(0,o),i.consume(o));i.byteLength>0&&(yield i.subarray())}()};function fk(e){return new Uint8Array(e)}const pk=10240;const gk=new class{constructor(){Ji(this,"_pool",void 0),Ji(this,"_poolOffset",void 0),this._pool=fk(pk),this._poolOffset=0}write(e,t){const r=this._pool;let n=this._poolOffset;Ol(e.id<<3|e.type,r,n),n+=Ll(e.id<<3|e.type),e.type!==ek.NEW_STREAM&&e.type!==ek.MESSAGE_INITIATOR&&e.type!==ek.MESSAGE_RECEIVER||null==e.data?(Ol(0,r,n),n+=Ll(0)):(Ol(e.data.length,r,n),n+=Ll(e.data.length));const i=r.subarray(this._poolOffset,n);pk-n<100?(this._pool=fk(pk),this._poolOffset=0):this._poolOffset=n,t.append(i),e.type!==ek.NEW_STREAM&&e.type!==ek.MESSAGE_INITIATOR&&e.type!==ek.MESSAGE_RECEIVER||null==e.data||t.append(e.data)}};function bk(e){return null!=e&&"function"===typeof e.then}class yk{constructor(e){var t,r;Ji(this,"id",void 0),Ji(this,"direction",void 0),Ji(this,"timeline",void 0),Ji(this,"protocol",void 0),Ji(this,"metadata",void 0),Ji(this,"source",void 0),Ji(this,"status",void 0),Ji(this,"readStatus",void 0),Ji(this,"writeStatus",void 0),Ji(this,"sinkController",void 0),Ji(this,"sinkEnd",void 0),Ji(this,"endErr",void 0),Ji(this,"streamSource",void 0),Ji(this,"onEnd",void 0),Ji(this,"onCloseRead",void 0),Ji(this,"onCloseWrite",void 0),Ji(this,"onReset",void 0),Ji(this,"onAbort",void 0),Ji(this,"sendCloseWriteTimeout",void 0),Ji(this,"log",void 0),this.sinkController=new AbortController,this.sinkEnd=af(),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=hf({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 ly('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);bk(e)&&await e}e=$x(e,this.sinkController.signal,{returnOnAbort:!0}),this.log.trace("sink reading from source");for await(let r of e){r=r instanceof Uint8Array?new Jd(r):r;const e=this.sendData(r,t);bk(e)&&await e}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.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.log.trace("sink ended, waiting for source to end"))}async close(e){this.log.trace("closing gracefully"),this.status="closing",await Promise.all([this.closeRead(e),this.closeWrite(e)]),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"),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 hp(this.sink([]),e.signal)),"writing"===this.writeStatus&&await new Promise(((t,r)=>{queueMicrotask((()=>{this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),hp(this.sinkEnd.promise,e.signal).then(t,r)}))})),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();bk(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 ly("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 mk extends yk{constructor(e){super(e),Ji(this,"name",void 0),Ji(this,"streamId",void 0),Ji(this,"send",void 0),Ji(this,"types",void 0),Ji(this,"maxDataSize",void 0),this.types="outbound"===e.direction?nk:ik,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:nk.NEW_STREAM,data:new Jd(kc(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(){}}const wk=Xx("libp2p:mplex");function vk(e){const t={...e,type:"".concat(rk[e.type]," (").concat(e.type,")")};return e.type===ek.NEW_STREAM&&(t.data=za(e.data instanceof Uint8Array?e.data:e.data.subarray())),e.type!==ek.MESSAGE_INITIATOR&&e.type!==ek.MESSAGE_RECEIVER||(t.data=za(e.data instanceof Uint8Array?e.data:e.data.subarray(),"base16")),t}class _k{constructor(e){var t,r,n;Ji(this,"protocol","/mplex/6.7.0"),Ji(this,"sink",void 0),Ji(this,"source",void 0),Ji(this,"_streamId",void 0),Ji(this,"_streams",void 0),Ji(this,"_init",void 0),Ji(this,"_source",void 0),Ji(this,"closeController",void 0),Ji(this,"rateLimiter",void 0),Ji(this,"closeTimeout",void 0),e=null!==(t=e)&&void 0!==t?t:{},this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=e,this.closeTimeout=null!==(r=e.closeTimeout)&&void 0!==r?r:500,this.sink=this._createSink(),this._source=function(){return df((e=>{let t;const r=[];for(;!e.isEmpty()&&(t=e.shift(),null!=t);){if(null!=t.error)throw t.error;!1===t.done&&r.push(t.value)}return null==t?{done:!0}:{done:!0===t.done,value:r}}),arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}({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=pf(this._source,(e=>function(e){try{let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return async function*(){if(null!=t&&0!==t)yield*dk(e,{size:t,serialize:(e,t)=>{for(const r of e)gk.write(r,t)}});else for await(const t of e){const e=new Jd;for(const r of t)gk.write(r,e);yield e.subarray()}}()}catch(t){return Promise.reject(t)}}(e,this._init.minSendBytes))),this.closeController=new AbortController,this.rateLimiter=new tk.RateLimiterMemory({points:null!==(n=e.disconnectThreshold)&&void 0!==n?n: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(wk("new %s stream %s",i,r),"initiator"===i&&this._streams.initiators.size===(null!==(t=this._init.maxOutboundStreams)&&void 0!==t?t:1024))throw new ly("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=ok}=e;return new mk({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:Xx("libp2p:mplex:stream:".concat(o,":").concat(t))})}({id:r,name:n,send:async e=>{wk.enabled&&wk.trace("%s stream %s send",i,r,vk(e)),this._source.push(e)},type:i,onEnd:()=>{wk("%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});return o.set(r,s),s}_createSink(){return async e=>{try{e=$x(e,this.closeController.signal,{returnOnAbort:!0});const t=new sk(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(t){wk("error in sink",t),this._source.end(t)}}}async _handleIncoming(e){var t;const{id:r,type:n}=e;if(wk.enabled&&wk.trace("incoming message",vk(e)),e.type===ek.NEW_STREAM){var i;if(this._streams.receivers.size===(null!==(i=this._init.maxInboundStreams)&&void 0!==i?i:1024)){wk("too many inbound streams open"),this._source.push({id:r,type:ek.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{return wk("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:za(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){wk("missing stream %s for message type %s",r,rk[n]);try{await this.rateLimiter.consume("missing-stream",1)}catch{return wk("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 ek.MESSAGE_INITIATOR:case ek.MESSAGE_RECEIVER:if(o.sourceReadableLength()>s)throw this._source.push({id:e.id,type:n===ek.MESSAGE_INITIATOR?ek.RESET_RECEIVER:ek.RESET_INITIATOR}),new ly("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");o.sourcePush(e.data);break;case ek.CLOSE_INITIATOR:case ek.CLOSE_RECEIVER:o.remoteCloseWrite();break;case ek.RESET_INITIATOR:case ek.RESET_RECEIVER:o.reset();break;default:wk("unknown message type %s",n)}}catch(a){wk.error("error while processing message",a),o.abort(a)}}}class Ek{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ji(this,"protocol","/mplex/6.7.0"),Ji(this,"_init",void 0),this._init=e}createStreamMuxer(){return new _k({...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},...this._init})}}function Sk(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return()=>new Ek(e)}const Ak=Symbol.for("@libp2p/transport");var xk;!function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"}(xk||(xk={}));var kk=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Ck=kk;new Uint8Array(0);class Ik{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 Tk{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 Rk(this,e)}}class Pk{constructor(e){this.decoders=e}or(e){return Rk(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 Rk=(e,t)=>new Pk({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Dk{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Ik(e,t,r),this.decoder=new Tk(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Nk=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new Dk(t,r,n,i)},Bk=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=Ck(n,r);return Nk({prefix:t,name:r,encode:i,decode:e=>(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))})},Lk=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Nk({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},Uk=Lk({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mk=(Lk({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lk({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Lk({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lk({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lk({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lk({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Lk({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Lk({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Bk({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"})),Ok=(Bk({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Lk({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}));Lk({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lk({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lk({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function qk(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}function zk(e){let t;try{t=Mc("sni").code}catch(r){return null}for(const[n,i]of e)if(n===t&&void 0!==i)return i;return null}function Fk(e){return e.some((e=>{let[t,r]=e;return t===Mc("tls").code}))}function Kk(e,t,r){const n=Vk[Mc(e).name];if(void 0===n)throw new Error("Can't interpret protocol ".concat(Mc(e).name));const i=n(t,r);return e===Mc("ip6").code?"[".concat(i,"]"):i}yl.formatters.b=e=>null==e?"undefined":Mk.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":Uk.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":Ok.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();const Vk={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(Kk(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(Kk(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(Kk(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(Kk(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/p2p/").concat(e)},http:(e,t)=>{var r;const n=Fk(t),i=zk(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=Kk(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 Kk(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 Kk(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=Kk(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=Fk(t),i=zk(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=Kk(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=Kk(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(Kk(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(Kk(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(Kk(n[0],null!==(r=n[1])&&void 0!==r?r:"",t),"/p2p-webrtc-direct")}};const jk=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)}))},Hk=(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 jk(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 Wk=__webpack_require__(2605);new Uint8Array(0);function Gk(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 Yk=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Qk=Yk;class Jk{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 Xk{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 $k(this,e)}}class Zk{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return $k(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 $k(e,t){var r,n;return new Zk({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class eC{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Jk(e,t,r),this.decoder=new Xk(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function tC(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new eC(t,r,n,i)}function rC(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Qk(n,t);return tC({prefix:r,name:t,encode:i,decode:e=>Gk(o(e))})}function nC(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return tC({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 iC=rC({prefix:"9",name:"base10",alphabet:"0123456789"}),oC=nC({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sC=nC({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),aC=nC({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),cC=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"),lC=cC.reduce(((e,t,r)=>(e[r]=t,e)),[]),uC=cC.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const hC=tC({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=lC[t]),"")},decode:function(e){const t=[];for(const r of e){const e=uC[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),dC=nC({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fC=nC({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),pC=nC({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gC=nC({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bC=nC({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yC=nC({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mC=nC({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wC=nC({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vC=nC({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),_C=rC({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),EC=rC({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),SC=rC({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),AC=rC({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),xC=nC({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),kC=nC({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),CC=nC({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),IC=nC({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),TC=nC({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),PC=tC({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)}),RC=new TextEncoder,DC=new TextDecoder,NC="json",BC=512;function LC(e){return RC.encode(JSON.stringify(e))}function UC(e){return JSON.parse(DC.decode(e))}const MC="raw",OC=85;function qC(e){return Gk(e)}function zC(e){return Gk(e)}var FC=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=jC;)r[n++]=255&t|KC,t/=128;for(;t&VC;)r[n++]=255&t|KC,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},KC=128,VC=-128,jC=Math.pow(2,31);var HC=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&GC)<<o:(n&GC)*Math.pow(2,o),o+=7}while(n>=WC);return e.bytes=s-r,i},WC=128,GC=127;var YC=Math.pow(2,7),QC=Math.pow(2,14),JC=Math.pow(2,21),XC=Math.pow(2,28),ZC=Math.pow(2,35),$C=Math.pow(2,42),eI=Math.pow(2,49),tI=Math.pow(2,56),rI=Math.pow(2,63);const nI={encode:FC,decode:HC,encodingLength:function(e){return e<YC?1:e<QC?2:e<JC?3:e<XC?4:e<ZC?5:e<$C?6:e<eI?7:e<tI?8:e<rI?9:10}};function iI(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return nI.encode(e,t,r),t}function oI(e){return nI.encodingLength(e)}function sI(e,t){const r=t.byteLength,n=oI(e),i=n+oI(r),o=new Uint8Array(i+r);return iI(e,o,0),iI(r,o,n),o.set(t,i),new aI(e,r,t,o)}class aI{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const cI=Gk;const lI={code:0,name:"identity",encode:cI,digest:function(e){return sI(0,cI(e))}};function uI(e){let{name:t,code:r,encode:n}=e;return new hI(t,r,n)}class hI{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?sI(this.code,t):t.then((e=>sI(this.code,e)))}throw Error("Unknown type, must be binary type")}}function dI(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const fI=uI({name:"sha2-256",code:18,encode:dI("SHA-256")}),pI=uI({name:"sha2-512",code:19,encode:dI("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const gI={...Ve,...Ue,...Ke,...Be,...Le,...Oe,...qe,...ze,...Fe,...Me};function bI(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const yI=bI("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),mI=bI("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})),wI={utf8:yI,"utf-8":yI,hex:gI.base16,latin1:mI,ascii:mI,binary:mI,...gI};function vI(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 _I=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 Wk.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=wI[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e.data)),vI(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 vI(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})},EI=WebSocket,SI={"http:":"ws:","https:":"wss:"};function AI(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(SI))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=_I(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:Hk(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 EI(n.toString(),t.websocket),t)}var xI=__webpack_require__(4053);const kI="object"===typeof window&&"object"===typeof document&&9===document.nodeType,CI=xI(),II=kI&&!CI,TI=CI&&!kI,PI=CI&&kI,RI="undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.release&&"node"===globalThis.process.release.name&&!CI,DI="function"===typeof importScripts&&"undefined"!==typeof self&&"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,NI=("undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.env&&globalThis.process.env.NODE_ENV,"undefined"!==typeof navigator&&"ReactNative"===navigator.product),BI=uT("dns4"),LI=uT("dns6"),UI=uT("dnsaddr"),MI=lT(uT("dns"),UI,BI,LI),OI=lT(uT("ip4"),uT("ip6")),qI=lT(cT(OI,uT("tcp")),cT(MI,uT("tcp"))),zI=cT(OI,uT("udp")),FI=cT(zI,uT("utp")),KI=cT(zI,uT("quic")),VI=cT(zI,uT("quic-v1")),jI=lT(cT(qI,uT("ws")),cT(MI,uT("ws"))),HI=lT(cT(jI,uT("p2p")),jI),WI=lT(cT(qI,uT("wss")),cT(MI,uT("wss")),cT(qI,uT("tls"),uT("ws")),cT(MI,uT("tls"),uT("ws"))),GI=lT(cT(WI,uT("p2p")),WI),YI=lT(cT(qI,uT("http")),cT(OI,uT("http")),cT(MI,uT("http"))),QI=lT(cT(qI,uT("https")),cT(OI,uT("https")),cT(MI,uT("https"))),JI=cT(zI,uT("webrtc-direct"),uT("certhash")),XI=lT(cT(JI,uT("p2p")),JI),ZI=cT(VI,uT("webtransport"),uT("certhash"),uT("certhash")),$I=lT(cT(ZI,uT("p2p")),ZI),eT=lT(cT(HI,uT("p2p-webrtc-star"),uT("p2p")),cT(GI,uT("p2p-webrtc-star"),uT("p2p")),cT(HI,uT("p2p-webrtc-star")),cT(GI,uT("p2p-webrtc-star"))),tT=(lT(cT(HI,uT("p2p-websocket-star"),uT("p2p")),cT(GI,uT("p2p-websocket-star"),uT("p2p")),cT(HI,uT("p2p-websocket-star")),cT(GI,uT("p2p-websocket-star"))),lT(cT(YI,uT("p2p-webrtc-direct"),uT("p2p")),cT(QI,uT("p2p-webrtc-direct"),uT("p2p")),cT(YI,uT("p2p-webrtc-direct")),cT(QI,uT("p2p-webrtc-direct")))),rT=lT(jI,WI,YI,QI,eT,tT,qI,FI,KI,MI,XI,$I),nT=(lT(cT(rT,uT("p2p-stardust"),uT("p2p")),cT(rT,uT("p2p-stardust"))),lT(cT(rT,uT("p2p")),eT,tT,XI,$I,uT("p2p"))),iT=lT(cT(nT,uT("p2p-circuit"),nT),cT(nT,uT("p2p-circuit")),cT(uT("p2p-circuit"),nT),cT(rT,uT("p2p-circuit")),cT(uT("p2p-circuit"),rT),uT("p2p-circuit")),oT=()=>lT(cT(iT,oT),iT),sT=oT();lT(cT(sT,nT,sT),cT(nT,sT),cT(sT,nT),sT,nT),lT(cT(sT,uT("webrtc"),uT("p2p")),cT(sT,uT("webrtc")),cT(rT,uT("webrtc"),uT("p2p")),cT(rT,uT("webrtc")),uT("webrtc"));function aT(e){return function(t){let r;try{r=gl(t)}catch(i){return!1}const n=e(r.protoNames());return null!==n&&(!0===n||!1===n?n:0===n.length)}}function cT(){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:aT(n),partialMatch:n}}function lT(){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:aT(n),partialMatch:n}}function uT(e){const t=e;return{toString:function(){return t},matches:function(e){let r;try{r=gl(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}}}const hT=421,dT=290;function fT(e){return e.filter((e=>{if(e.protoCodes().includes(dT))return!1;const t=e.decapsulateCode(hT);return HI.matches(t)||GI.matches(t)}))}const pT=qk("libp2p:websockets:socket");const gT=qk("libp2p:websockets");class bT{constructor(e){Ji(this,"init",void 0),Ji(this,Symbol.toStringTag,"@libp2p/websockets"),Ji(this,Ak,!0),this.init=e}async dial(e,t){var r;gT("dialing %s",e),t=null!==(r=t)&&void 0!==r?r:{};const n=function(e,t,r){var n;const i={async sink(t){var n;null!=(null===(n=r)||void 0===n?void 0:n.signal)&&(t=$x(t,r.signal));try{await e.sink(t)}catch(i){"aborted"!==i.type&&pT.error(i)}},source:null!=(r=null!==(n=r)&&void 0!==n?n:{}).signal?$x(e.source,r.signal):e.source,remoteAddr:t,timeline:{open:Date.now()},async close(){var t;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=Date.now();if(null==r.signal){const e=AbortSignal.timeout(500);r={...r,signal:e}}const o=()=>{const{host:e,port:t}=i.remoteAddr.toOptions();pT("timeout closing stream to %s:%s after %dms, destroying it manually",e,t,Date.now()-n),this.abort(new ly("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};null===(t=r.signal)||void 0===t||t.addEventListener("abort",o);try{await e.close()}catch(a){pT.error("error closing WebSocket gracefully",a),this.abort(a)}finally{var s;null===(s=r.signal)||void 0===s||s.removeEventListener("abort",o),i.timeline.close=Date.now()}},abort(t){const{host:r,port:n}=i.remoteAddr.toOptions();pT("timeout closing stream to %s:%s due to error",r,n,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);gT("new outbound connection %s",n.remoteAddr);const i=await t.upgrader.upgradeOutbound(n);return gT("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 cy;const n=e.toOptions();gT("dialing %s:%s",n.host,n.port);const i=af(),o=AI(function(e,t){var r;const n=gl(e).stringTuples(),i=n.pop();if(void 0===i)throw new Error("Unexpected end of multiaddr");const o=Mc(i[0]),s=Vk[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)&&i[0]===Mc("tcp").code&&(a=a.replace("tcp://","http://"),"443"!==i[1]&&"80"!==i[1]||("443"===i[1]&&(a=a.replace("http://","https://")),a=a.substring(0,a.lastIndexOf(":")))),a}(e),this.init);if(o.socket.addEventListener("error",(()=>{const t=new ly("Could not connect to ".concat(e.toString()),"ERR_CONNECTION_FAILED");gT.error("connection error:",t),i.reject(t)})),null==t.signal)return await Promise.race([o.connected(),i.promise]),gT("connected %s",e),o;let s;const a=new Promise(((e,r)=>{var n,i;s=()=>{r(new cy),o.close().catch((e=>{gT.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 gT("connected %s",e),o}createListener(e){return function(){throw new Error("WebSocket Servers can not be created in the browser!")}(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):II||DI?function(e){return e.filter((e=>{if(e.protoCodes().includes(dT))return!1;const t=e.decapsulateCode(hT);return GI.matches(t)}))}(e):fT(e)}}function yT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return()=>new bT(e)}var mT,wT=new WeakMap;class vT extends EventTarget{constructor(){super(...arguments),eo(this,wT,new Map)}listenerCount(e){const t=ro(wT,this).get(e);return null==t?0:t.length}addEventListener(e,t,r){var n;super.addEventListener(e,t,r);let i=ro(wT,this).get(e);null==i&&(i=[],ro(wT,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=ro(wT,this).get(e);null!=n&&(n=n.filter((e=>{let{callback:r}=e;return r!==t})),ro(wT,this).set(e,n))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=ro(wT,this).get(e.type);return null==r||(r=r.filter((e=>{let{once:t}=e;return!t})),ro(wT,this).set(e.type,r)),t}safeDispatchEvent(e,t){return this.dispatchEvent(new ET(e,t))}}class _T extends Event{constructor(e,t){super(e,t),Ji(this,"detail",void 0),this.detail=null===t||void 0===t?void 0:t.detail}}const ET=null!==(mT=globalThis.CustomEvent)&&void 0!==mT?mT:_T,ST=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{}},AT=Symbol.for("@libp2p/peer-discovery"),xT={TEST:"enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@test.waku.nodes.status.im",PROD:"enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@prod.waku.nodes.status.im"},kT="bootstrap",CT={store:2,filter:1,lightPush:1};var IT=__webpack_require__(495),TT=__webpack_require__.t(IT,2);const PT=BigInt(0),RT=BigInt(1),DT=BigInt(2),NT=BigInt(3),BT=BigInt(8),LT=Object.freeze({a:PT,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:RT,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),UT=(e,t)=>(e+t/DT)/t,MT={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=LT,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-RT*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=UT(o*e,t),c=UT(-n*e,t);let l=dP(e-a*r-c*i,t),u=dP(-a*n-c*o,t);const h=l>s,d=u>s;if(h&&(l=t-l),d&&(u=t-u),l>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:h,k1:l,k2neg:d,k2:u}}},OT=32,qT=32,zT=32,FT=OT+1,KT=2*OT+1;function VT(e){const{a:t,b:r}=LT,n=dP(e*e),i=dP(n*e);return dP(i+t*e+r)}const jT=LT.a===PT;class HT extends Error{constructor(e){super(e)}}function WT(e){if(!(e instanceof GT))throw new TypeError("JacobianPoint expected")}class GT{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof JT))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(JT.ZERO)?GT.ZERO:new GT(e.x,e.y,RT)}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LT.P;const r=new Array(e.length),n=pP(e.reduce(((e,n,i)=>n===PT?e:(r[i]=e,dP(e*n,t))),RT),t);return e.reduceRight(((e,n,i)=>n===PT?e:(r[i]=dP(e*r[i],t),dP(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return GT.toAffineBatch(e).map(GT.fromAffine)}equals(e){WT(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e,a=dP(n*n),c=dP(s*s),l=dP(t*c),u=dP(i*a),h=dP(dP(r*s)*c),d=dP(dP(o*n)*a);return l===u&&h===d}negate(){return new GT(this.x,dP(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=dP(e*e),i=dP(t*t),o=dP(i*i),s=e+i,a=dP(DT*(dP(s*s)-n-o)),c=dP(NT*n),l=dP(c*c),u=dP(l-DT*a),h=dP(c*(a-u)-BT*o),d=dP(DT*t*r);return new GT(u,h,d)}add(e){WT(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e;if(i===PT||o===PT)return this;if(t===PT||r===PT)return e;const a=dP(n*n),c=dP(s*s),l=dP(t*c),u=dP(i*a),h=dP(dP(r*s)*c),d=dP(dP(o*n)*a),f=dP(u-l),p=dP(d-h);if(f===PT)return p===PT?this.double():GT.ZERO;const g=dP(f*f),b=dP(f*g),y=dP(l*g),m=dP(p*p-b-DT*y),w=dP(p*(y-m)-h*b),v=dP(n*s*f);return new GT(m,w,v)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=GT.ZERO;if("bigint"===typeof e&&e===PT)return t;let r=hP(e);if(r===RT)return this;if(!jT){let e=t,n=this;for(;r>PT;)r&RT&&(e=e.add(n)),n=n.double(),r>>=RT;return e}let{k1neg:n,k1:i,k2neg:o,k2:s}=MT.splitScalar(r),a=t,c=t,l=this;for(;i>PT||s>PT;)i&RT&&(a=a.add(l)),s&RT&&(c=c.add(l)),l=l.double(),i>>=RT,s>>=RT;return n&&(a=a.negate()),o&&(c=c.negate()),c=new GT(dP(c.x*MT.beta),c.y,c.z),a.add(c)}precomputeWindow(e){const t=jT?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(GT.BASE)&&(t=JT.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&&QT.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=GT.normalizeZ(n),QT.set(t,n)));let i=GT.ZERO,o=GT.BASE;const s=1+(jT?128/r:256/r),a=2**(r-1),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let h=0;h<s;h++){const t=h*a;let r=Number(e&c);e>>=u,r>a&&(r-=l,e+=RT);const s=t,d=t+Math.abs(r)-1,f=h%2!==0,p=r<0;0===r?o=o.add(YT(f,n[s])):i=i.add(YT(p,n[d]))}return{p:i,f:o}}multiply(e,t){let r,n,i=hP(e);if(jT){const{k1neg:e,k1:o,k2neg:s,k2:a}=MT.splitScalar(i);let{p:c,f:l}=this.wNAF(o,t),{p:u,f:h}=this.wNAF(a,t);c=YT(e,c),u=YT(s,u),u=new GT(dP(u.x*MT.beta),u.y,u.z),r=c.add(u),n=l.add(h)}else{const{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return GT.normalizeZ([r,n])[0]}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(GT.ZERO);null==e&&(e=i?BT:pP(n));const o=e,s=dP(o*o),a=dP(s*o),c=dP(t*s),l=dP(r*a),u=dP(n*o);if(i)return JT.ZERO;if(u!==RT)throw new Error("invZ was invalid");return new JT(c,l)}}function YT(e,t){const r=t.negate();return e?r:t}GT.BASE=new GT(LT.Gx,LT.Gy,RT),GT.ZERO=new GT(PT,RT,PT);const QT=new WeakMap;class JT{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,QT.delete(this)}hasEvenY(){return this.y%DT===PT}static fromCompressedHex(e){const t=32===e.length,r=lP(t?e:e.subarray(1));if(!vP(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=LT,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),c=e*e*e%t,l=c*c*e%t,u=fP(l,NT)*l%t,h=fP(u,NT)*l%t,d=fP(h,DT)*c%t,f=fP(d,n)*d%t,p=fP(f,i)*f%t,g=fP(p,s)*p%t,b=fP(g,a)*g%t,y=fP(b,s)*p%t,m=fP(y,NT)*l%t,w=fP(m,o)*f%t,v=fP(w,r)*c%t,_=fP(v,DT);if(_*_%t!==e)throw new Error("Cannot find square root");return _}(VT(r));const i=(n&RT)===RT;if(t)i&&(n=dP(-n));else{1===(1&e[0])!==i&&(n=dP(-n))}const o=new JT(r,n);return o.assertValidity(),o}static fromUncompressedHex(e){const t=lP(e.subarray(1,OT+1)),r=lP(e.subarray(OT+1,2*OT+1)),n=new JT(t,r);return n.assertValidity(),n}static fromHex(e){const t=uP(e),r=t.length,n=t[0];if(r===OT)return this.fromCompressedHex(t);if(r===FT&&(2===n||3===n))return this.fromCompressedHex(t);if(r===KT&&4===n)return this.fromUncompressedHex(t);throw new Error("Point.fromHex: received invalid point. Expected 32-".concat(FT," compressed bytes or ").concat(KT," uncompressed bytes, not ").concat(r))}static fromPrivateKey(e){return JT.BASE.multiply(EP(e))}static fromSignature(e,t,r){const{r:n,s:i}=AP(t);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=gP(uP(e)),{n:s}=LT,a=2===r||3===r?n+s:n,c=pP(a,s),l=dP(-o*c,s),u=dP(i*c,s),h=1&r?"03":"02",d=JT.fromHex(h+iP(a)),f=JT.BASE.multiplyAndAddUnsafe(d,l,u);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 cP(this.toHex(e))}toHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=iP(this.x);if(e){const e=this.hasEvenY()?"02":"03";return"".concat(e).concat(t)}return"04".concat(t).concat(iP(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(!vP(t)||!vP(r))throw new Error(e);const n=dP(r*r);if(dP(n-VT(t))!==PT)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new JT(this.x,dP(-this.y))}double(){return GT.fromAffine(this).double().toAffine()}add(e){return GT.fromAffine(this).add(GT.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return GT.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const n=GT.fromAffine(this),i=t===PT||t===RT||this!==JT.BASE?n.multiplyUnsafe(t):n.multiply(t),o=GT.fromAffine(e).multiplyUnsafe(r),s=i.add(o);return s.equals(GT.ZERO)?void 0:s.toAffine()}}function XT(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function ZT(e){if(e.length<2||2!==e[0])throw new Error("Invalid signature integer tag: ".concat(rP(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:lP(r),left:e.subarray(t+2)}}JT.BASE=new JT(LT.Gx,LT.Gy),JT.ZERO=new JT(PT,PT);class $T{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?rP(e):e;if(128!==n.length)throw new Error("".concat(r,": Expected 64-byte hex"));return new $T(aP(n.slice(0,64)),aP(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(rP(e)));if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=ZT(e.subarray(2)),{data:n,left:i}=ZT(r);if(i.length)throw new Error("Invalid signature: left bytes after parsing: ".concat(rP(i)));return{r:t,s:n}}(t?e:cP(e));return new $T(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!wP(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!wP(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=LT.n>>RT;return this.s>e}normalizeS(){return this.hasHighS()?new $T(this.r,dP(-this.s,LT.n)):this}toDERRawBytes(){return cP(this.toDERHex())}toDERHex(){const e=XT(sP(this.s)),t=XT(sP(this.r)),r=e.length/2,n=t.length/2,i=sP(r),o=sP(n),s=sP(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 cP(this.toCompactHex())}toCompactHex(){return iP(this.r)+iP(this.s)}}function eP(){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 tP=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function rP(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r<e.length;r++)t+=tP[e[r]];return t}const nP=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function iP(e){if("bigint"!==typeof e)throw new Error("Expected bigint");if(!(PT<=e&&e<nP))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function oP(e){const t=cP(iP(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function sP(e){const t=e.toString(16);return 1&t.length?"0".concat(t):t}function aP(e){if("string"!==typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt("0x".concat(e))}function cP(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 lP(e){return aP(rP(e))}function uP(e){return e instanceof Uint8Array?Uint8Array.from(e):cP(e)}function hP(e){if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"===typeof e&&wP(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function dP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LT.P;const r=e%t;return r>=PT?r:t+r}function fP(e,t){const{P:r}=LT;let n=e;for(;t-- >PT;)n*=n,n%=r;return n}function pP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LT.P;if(e===PT||t<=PT)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=dP(e,t),n=t,i=PT,o=RT,s=RT,a=PT;for(;r!==PT;){const e=n/r,t=n%r,c=i-s*e,l=o-a*e;n=r,r=t,i=s,o=a,s=c,a=l}if(n!==RT)throw new Error("invert: does not exist");return dP(i,t)}function gP(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=function(e){const t=8*e.length-8*qT,r=lP(e);return t>0?r>>BigInt(t):r}(e);if(t)return r;const{n:n}=LT;return r>=n?r-n:r}let bP,yP;class mP{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 UP.hmacSha256(this.k,...t)}hmacSync(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return yP(this.k,...t)}checkSync(){if("function"!==typeof yP)throw new HT("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 eP(...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 eP(...t)}}function wP(e){return PT<e&&e<LT.n}function vP(e){return PT<e&&e<LT.P}function _P(e,t,r){let n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const{n:i}=LT,o=gP(e,!0);if(!wP(o))return;const s=pP(o,i),a=JT.BASE.multiply(o),c=dP(a.x,i);if(c===PT)return;const l=dP(s*dP(t+r*c,i),i);if(l===PT)return;let u=new $T(c,l),h=(a.x===u.r?0:2)|Number(a.y&RT);return n&&u.hasHighS()&&(u=u.normalizeS(),h^=1),{sig:u,recovery:h}}function EP(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*qT)throw new Error("Expected 32 bytes of private key");t=aP(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(e.length!==qT)throw new Error("Expected 32 bytes of private key");t=lP(e)}if(!wP(t))throw new Error("Expected private key: 0 < key < n");return t}function SP(e){return e instanceof JT?(e.assertValidity(),e):JT.fromHex(e)}function AP(e){if(e instanceof $T)return e.assertValidity(),e;try{return $T.fromDER(e)}catch(t){return $T.fromCompact(e)}}function xP(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return JT.fromPrivateKey(e).toRawBytes(t)}function kP(e){return lP(e.length>OT?e.slice(0,OT):e)}function CP(e){const t=kP(e),r=dP(t,LT.n);return IP(r<PT?t:r)}function IP(e){return oP(e)}function TP(e,t,r){if(null==e)throw new Error('sign: expected valid message hash, not "'.concat(e,'"'));const n=uP(e),i=EP(t),o=[IP(i),CP(n)];if(null!=r){!0===r&&(r=UP.randomBytes(OT));const e=uP(r);if(e.length!==OT)throw new Error("sign: Expected ".concat(OT," bytes of extra data"));o.push(e)}return{seed:eP(...o),m:kP(n),d:i}}function PP(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}async function RP(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{seed:n,m:i,d:o}=TP(e,t,r.extraEntropy),s=new mP(zT,qT);let a;for(await s.reseed(n);!(a=_P(await s.generate(),i,o,r.canonical));)await s.reseed();return PP(a,r)}const DP={strict:!0};function NP(e,t,r){let n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:DP;try{n=AP(e),t=uP(t)}catch(p){return!1}const{r:o,s:s}=n;if(i.strict&&n.hasHighS())return!1;const a=gP(t);let c;try{c=SP(r)}catch(p){return!1}const{n:l}=LT,u=pP(s,l),h=dP(a*u,l),d=dP(o*u,l),f=JT.BASE.multiplyAndAddUnsafe(c,h,d);if(!f)return!1;return dP(f.x,l)===o}JT.BASE._setWindowSize(8);const BP={node:TT,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},LP={},UP={bytesToHex:rP,hexToBytes:cP,concatBytes:eP,mod:dP,invert:pP,isValidPrivateKey(e){try{return EP(e),!0}catch(t){return!1}},_bigintTo32Bytes:oP,_normalizePrivateKey:EP,hashToPrivateKey:e=>{e=uP(e);const t=qT+8;if(e.length<t||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return oP(dP(lP(e),LT.n-RT)+RT)},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(BP.web)return BP.web.getRandomValues(new Uint8Array(e));if(BP.node){const{randomBytes:t}=BP.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>UP.hashToPrivateKey(UP.randomBytes(qT+8)),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JT.BASE;const r=t===JT.BASE?t:new JT(t.x,t.y);return r._setWindowSize(e),r.multiply(NT),r},sha256:async function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(BP.web){const e=await BP.web.subtle.digest("SHA-256",eP(...t));return new Uint8Array(e)}if(BP.node){const{createHash:e}=BP.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(BP.web){const t=await BP.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=eP(...r),i=await BP.web.subtle.sign("HMAC",t,n);return new Uint8Array(i)}if(BP.node){const{createHmac:t}=BP.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=LP[e];if(void 0===t){const r=await UP.sha256(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=eP(r,r),LP[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 UP.sha256(t,...n)},taggedHashSync:function(e){if("function"!==typeof bP)throw new HT("sha256Sync is undefined, you need to set it");let t=LP[e];if(void 0===t){const r=bP(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=eP(r,r),LP[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 bP(t,...n)},_JacobianPoint:GT};Object.defineProperties(UP,{sha256Sync:{configurable:!1,get:()=>bP,set(e){bP||(bP=e)}},hmacSha256Sync:{configurable:!1,get:()=>yP,set(e){yP||(yP=e)}}});var MP=__webpack_require__(2161);function OP(e){return new Uint8Array(MP.keccak256.arrayBuffer(e))}function qP(e,t,r){try{return NP($T.fromCompact(e.slice(0,64)),t,r)}catch{return!1}}const zP="Invalid record id";function FP(e,t){switch(t){case"udp":return FP(e,"udp4")||FP(e,"udp6");case"tcp":return FP(e,"tcp4")||FP(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=gl("/"+e+"/"+Oc(e,r));return i=i.encapsulate(gl("/"+t+"/"+Oc(t,n))),i}(r?"ip6":"ip4",i,n,o):void 0}var KP=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const VP=KP,jP=(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 HP{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 WP{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 YP(this,e)}}class GP{constructor(e){this.decoders=e}or(e){return YP(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 YP=(e,t)=>new GP({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class QP{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new HP(e,t,r),this.decoder=new WP(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const JP=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new QP(t,r,n,i)},XP=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=VP(n,r);return JP({prefix:t,name:r,encode:i,decode:e=>jP(o(e))})},ZP=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return JP({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},$P=XP({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"});XP({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var eR=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=nR;)r[n++]=255&t|tR,t/=128;for(;t&rR;)r[n++]=255&t|tR,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},tR=128,rR=-128,nR=Math.pow(2,31);var iR=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&sR)<<o:(n&sR)*Math.pow(2,o),o+=7}while(n>=oR);return e.bytes=s-r,i},oR=128,sR=127;var aR=Math.pow(2,7),cR=Math.pow(2,14),lR=Math.pow(2,21),uR=Math.pow(2,28),hR=Math.pow(2,35),dR=Math.pow(2,42),fR=Math.pow(2,49),pR=Math.pow(2,56),gR=Math.pow(2,63);const bR={encode:eR,decode:iR,encodingLength:function(e){return e<aR?1:e<cR?2:e<lR?3:e<uR?4:e<hR?5:e<dR?6:e<fR?7:e<pR?8:e<gR?9:10}},yR=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return bR.encode(e,t,r),t},mR=e=>bR.encodingLength(e),wR=(e,t)=>{const r=t.byteLength,n=mR(e),i=n+mR(r),o=new Uint8Array(i+r);return yR(e,o,0),yR(r,o,n),o.set(t,i),new vR(e,r,t,o)};class vR{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const _R=jP,ER=e=>wR(0,_R(e)),SR=e=>{let{name:t,code:r,encode:n}=e;return new AR(t,r,n)};class AR{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?wR(this.code,t):t.then((e=>wR(this.code,e)))}throw Error("Unknown type, must be binary type")}}const xR=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),kR=SR({name:"sha2-256",code:18,encode:xR("SHA-256")});SR({name:"sha2-512",code:19,encode:xR("SHA-512")});var CR=__webpack_require__(9122),IR=__webpack_require__.t(CR,2);const TR=BigInt(0),PR=BigInt(1),RR=BigInt(2),DR=BigInt(8),NR=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),BR=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:NR,n:NR,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),LR=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),UR=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),MR=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),OR=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),qR=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),zR=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class FR{constructor(e,t,r,n){this.x=e,this.y=t,this.z=r,this.t=n}static fromAffine(e){if(!(e instanceof YR))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(YR.ZERO)?FR.ZERO:new FR(e.x,e.y,PR,sD(e.x*e.y))}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BR.P;const r=new Array(e.length),n=aD(e.reduce(((e,n,i)=>n===TR?e:(r[i]=e,sD(e*n,t))),PR),t);return e.reduceRight(((e,n,i)=>n===TR?e:(r[i]=sD(e*r[i],t),sD(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){VR(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e,a=sD(t*s),c=sD(i*n),l=sD(r*s),u=sD(o*n);return a===c&&l===u}negate(){return new FR(sD(-this.x),this.y,this.z,sD(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:n}=BR,i=sD(e*e),o=sD(t*t),s=sD(RR*sD(r*r)),a=sD(n*i),c=e+t,l=sD(sD(c*c)-i-o),u=a+o,h=u-s,d=a-o,f=sD(l*h),p=sD(u*d),g=sD(l*d),b=sD(h*u);return new FR(f,p,b,g)}add(e){VR(e);const{x:t,y:r,z:n,t:i}=this,{x:o,y:s,z:a,t:c}=e,l=sD((r-t)*(s+o)),u=sD((r+t)*(s-o)),h=sD(u-l);if(h===TR)return this.double();const d=sD(n*RR*c),f=sD(i*RR*a),p=f+d,g=u+l,b=f-d,y=sD(p*h),m=sD(g*b),w=sD(p*b),v=sD(h*g);return new FR(y,m,v,w)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,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(FR.BASE)&&(t=YR.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&&GR.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=FR.normalizeZ(n),GR.set(t,n)));let i=FR.ZERO,o=FR.BASE;const s=1+256/r,a=2**(r-1),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let h=0;h<s;h++){const t=h*a;let r=Number(e&c);e>>=u,r>a&&(r-=l,e+=PR);const s=t,d=t+Math.abs(r)-1,f=h%2!==0,p=r<0;0===r?o=o.add(KR(f,n[s])):i=i.add(KR(p,n[d]))}return FR.normalizeZ([i,o])[0]}multiply(e,t){return this.wNAF(pD(e,BR.l),t)}multiplyUnsafe(e){let t=pD(e,BR.l,!1);const r=FR.BASE,n=FR.ZERO;if(t===TR)return n;if(this.equals(n)||t===PR)return this;if(this.equals(r))return this.wNAF(t);let i=n,o=this;for(;t>TR;)t&PR&&(i=i.add(o)),o=o.double(),t>>=PR;return i}isSmallOrder(){return this.multiplyUnsafe(BR.h).equals(FR.ZERO)}isTorsionFree(){let e=this.multiplyUnsafe(BR.l/RR).double();return BR.l%RR&&(e=e.add(this)),e.equals(FR.ZERO)}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(FR.ZERO);null==e&&(e=i?DR:aD(n));const o=sD(t*e),s=sD(r*e),a=sD(n*e);if(i)return YR.ZERO;if(a!==PR)throw new Error("invZ was invalid");return new YR(o,s)}fromRistrettoBytes(){HR()}toRistrettoBytes(){HR()}fromRistrettoHash(){HR()}}function KR(e,t){const r=t.negate();return e?r:t}function VR(e){if(!(e instanceof FR))throw new TypeError("ExtendedPoint expected")}function jR(e){if(!(e instanceof WR))throw new TypeError("RistrettoPoint expected")}function HR(){throw new Error("Legacy method: switch to RistrettoPoint")}FR.BASE=new FR(BR.Gx,BR.Gy,PR,sD(BR.Gx*BR.Gy)),FR.ZERO=new FR(TR,PR,PR,TR);class WR{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=BR,r=sD(UR*e*e),n=sD((r+PR)*qR);let i=BigInt(-1);const o=sD((i-t*r)*sD(r+t));let{isValid:s,value:a}=uD(n,o),c=sD(a*e);rD(c)||(c=sD(-c)),s||(a=c),s||(i=r);const l=sD(i*(r-PR)*zR-o),u=a*a,h=sD((a+a)*o),d=sD(l*MR),f=sD(PR-u),p=sD(PR+u);return new FR(sD(h*p),sD(f*d),sD(d*p),sD(h*f))}static hashToCurve(e){const t=oD((e=fD(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),n=oD(e.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new WR(r.add(i))}static fromHex(e){e=fD(e,32);const{a:t,d:r}=BR,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=oD(e);if(!function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(tD(i),e)||rD(i))throw new Error(n);const o=sD(i*i),s=sD(PR+t*o),a=sD(PR-t*o),c=sD(s*s),l=sD(a*a),u=sD(t*r*c-l),{isValid:h,value:d}=hD(sD(u*l)),f=sD(d*a),p=sD(d*f*u);let g=sD((i+i)*f);rD(g)&&(g=sD(-g));const b=sD(s*p),y=sD(g*b);if(!h||rD(y)||b===TR)throw new Error(n);return new WR(new FR(g,b,PR,y))}toRawBytes(){let{x:e,y:t,z:r,t:n}=this.ep;const i=sD(sD(r+t)*sD(r-t)),o=sD(e*t),s=sD(o*o),{value:a}=hD(sD(i*s)),c=sD(a*i),l=sD(a*o),u=sD(c*l*n);let h;if(rD(n*u)){let r=sD(t*UR),n=sD(e*UR);e=r,t=n,h=sD(c*OR)}else h=l;rD(e*u)&&(t=sD(-t));let d=sD((r-t)*h);return rD(d)&&(d=sD(-d)),tD(d)}toHex(){return ZR(this.toRawBytes())}toString(){return this.toHex()}equals(e){jR(e);const t=this.ep,r=e.ep,n=sD(t.x*r.y)===sD(t.y*r.x),i=sD(t.y*r.y)===sD(t.x*r.x);return n||i}add(e){return jR(e),new WR(this.ep.add(e.ep))}subtract(e){return jR(e),new WR(this.ep.subtract(e.ep))}multiply(e){return new WR(this.ep.multiply(e))}multiplyUnsafe(e){return new WR(this.ep.multiplyUnsafe(e))}}WR.BASE=new WR(FR.BASE),WR.ZERO=new WR(FR.ZERO);const GR=new WeakMap;class YR{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,GR.delete(this)}static fromHex(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{d:r,P:n}=BR,i=(e=fD(e,32)).slice();i[31]=-129&e[31];const o=nD(i);if(t&&o>=n)throw new Error("Expected 0 < hex < P");if(!t&&o>=LR)throw new Error("Expected 0 < hex < 2**256");const s=sD(o*o),a=sD(s-PR),c=sD(r*s+PR);let{isValid:l,value:u}=uD(a,c);if(!l)throw new Error("Point.fromHex: invalid y coordinate");const h=(u&PR)===PR;return 0!==(128&e[31])!==h&&(u=sD(-u)),new YR(u,o)}static async fromPrivateKey(e){return(await wD(e)).point}toRawBytes(){const e=tD(this.y);return e[31]|=this.x&PR?128:0,e}toHex(){return ZR(this.toRawBytes())}toX25519(){const{y:e}=this;return tD(sD((PR+e)*aD(PR-e)))}isTorsionFree(){return FR.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new YR(sD(-this.x),this.y)}add(e){return FR.fromAffine(this).add(FR.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return FR.fromAffine(this).multiply(e,this).toAffine()}}YR.BASE=new YR(BR.Gx,BR.Gy),YR.ZERO=new YR(TR,PR);class QR{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=fD(e,64),r=YR.fromHex(t.slice(0,32),!1),n=nD(t.slice(32,64));return new QR(r,n)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof YR))throw new Error("Expected Point instance");return pD(t,BR.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(tD(this.s),32),e}toHex(){return ZR(this.toRawBytes())}}function JR(){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("Expected Uint8Array list");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 XR=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function ZR(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(let r=0;r<e.length;r++)t+=XR[e[r]];return t}function $R(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");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 eD(e){return $R(e.toString(16).padStart(64,"0"))}function tD(e){return eD(e).reverse()}function rD(e){return(sD(e)&PR)===PR}function nD(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+ZR(Uint8Array.from(e).reverse()))}const iD=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function oD(e){return sD(nD(e)&iD)}function sD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BR.P;const r=e%t;return r>=TR?r:t+r}function aD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BR.P;if(e===TR||t<=TR)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=sD(e,t),n=t,i=TR,o=PR,s=PR,a=TR;for(;r!==TR;){const e=n/r,t=n%r,c=i-s*e,l=o-a*e;n=r,r=t,i=s,o=a,s=c,a=l}if(n!==PR)throw new Error("invert: does not exist");return sD(i,t)}function cD(e,t){const{P:r}=BR;let n=e;for(;t-- >TR;)n*=n,n%=r;return n}function lD(e){const{P:t}=BR,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),s=BigInt(80),a=e*e%t*e%t,c=cD(a,RR)*a%t,l=cD(c,PR)*e%t,u=cD(l,r)*l%t,h=cD(u,n)*u%t,d=cD(h,i)*h%t,f=cD(d,o)*d%t,p=cD(f,s)*f%t,g=cD(p,s)*f%t,b=cD(g,n)*u%t;return{pow_p_5_8:cD(b,RR)*e%t,b2:a}}function uD(e,t){const r=sD(t*t*t),n=sD(r*r*t);let i=sD(e*r*lD(e*n).pow_p_5_8);const o=sD(t*i*i),s=i,a=sD(i*UR),c=o===e,l=o===sD(-e),u=o===sD(-e*UR);return c&&(i=s),(l||u)&&(i=a),rD(i)&&(i=sD(-i)),{isValid:c||l,value:i}}function hD(e){return uD(PR,e)}function dD(e){return sD(nD(e),BR.l)}function fD(e,t){const r=e instanceof Uint8Array?Uint8Array.from(e):$R(e);if("number"===typeof t&&r.length!==t)throw new Error("Expected ".concat(t," bytes"));return r}function pD(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t)throw new TypeError("Specify max value");if("number"===typeof e&&Number.isSafeInteger(e)&&(e=BigInt(e)),"bigint"===typeof e&&e<t)if(r){if(TR<e)return e}else if(TR<=e)return e;throw new TypeError("Expected valid scalar: 0 < scalar < max")}function gD(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function bD(e){if(32!==(e="bigint"===typeof e||"number"===typeof e?eD(pD(e,LR)):fD(e)).length)throw new Error("Expected 32 bytes");return e}function yD(e){const t=gD(e.slice(0,32)),r=e.slice(32,64),n=dD(t),i=YR.BASE.multiply(n),o=i.toRawBytes();return{head:t,prefix:r,scalar:n,point:i,pointBytes:o}}let mD;async function wD(e){return yD(await AD.sha512(bD(e)))}async function vD(e){return(await wD(e)).pointBytes}function _D(e,t,r){t=fD(t),r instanceof YR||(r=YR.fromHex(r,!1));const{r:n,s:i}=e instanceof QR?e.assertValidity():QR.fromHex(e);return{r:n,s:i,SB:FR.BASE.multiplyUnsafe(i),pub:r,msg:t}}function ED(e,t,r,n){const i=dD(n),o=FR.fromAffine(e).multiplyUnsafe(i);return FR.fromAffine(t).add(o).subtract(r).multiplyUnsafe(BR.h).equals(FR.ZERO)}YR.BASE._setWindowSize(8);const SD={node:IR,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},AD={bytesToHex:ZR,hexToBytes:$R,concatBytes:JR,getExtendedPublicKey:wD,mod:sD,invert:aD,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:e=>{if((e=fD(e)).length<40||e.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return sD(nD(e),BR.l-PR)+PR},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(SD.web)return SD.web.getRandomValues(new Uint8Array(e));if(SD.node){const{randomBytes:t}=SD.node;return new Uint8Array(t(e).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>AD.randomBytes(32),sha512:async function(){const e=JR(...arguments);if(SD.web){const t=await SD.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(SD.node)return Uint8Array.from(SD.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:YR.BASE;const r=t.equals(YR.BASE)?t:new YR(t.x,t.y);return r._setWindowSize(e),r.multiply(RR),r},sha512Sync:void 0};Object.defineProperties(AD,{sha512Sync:{configurable:!1,get:()=>mD,set(e){mD||(mD=e)}}});const xD=32,kD=64,CD=32;async function ID(e,t){return async function(e,t){e=fD(e);const{prefix:r,scalar:n,pointBytes:i}=await wD(t),o=dD(await AD.sha512(r,e)),s=YR.BASE.multiply(o),a=sD(o+dD(await AD.sha512(s.toRawBytes(),i,e))*n,BR.l);return new QR(s,a).toRawBytes()}(t,e.subarray(0,CD))}async function TD(e,t,r){return async function(e,t,r){const{r:n,SB:i,msg:o,pub:s}=_D(e,t,r),a=await AD.sha512(n.toRawBytes(),s.toRawBytes(),o);return ED(s,n,i,a)}(t,r,e)}function PD(e,t){const r=new Uint8Array(kD);for(let n=0;n<CD;n++)r[n]=e[n],r[CD+n]=t[n];return r}const RD=ZP({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),DD=(ZP({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ZP({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ZP({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),{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-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}}),ND={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function BD(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 l=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,u=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=DD.get();return c*=8,{encrypt:async function(e,t){const r=f.getRandomValues(new Uint8Array(h)),n=f.getRandomValues(new Uint8Array(l)),i={name:a,iv:n};let o;if("string"===typeof t&&(t=kc(t)),0===t.length){o=await f.subtle.importKey("jwk",ND,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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",ND,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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 Fa([r,i.iv,new Uint8Array(s)])},decrypt:async function(e,t){const r=e.subarray(0,h),n=e.subarray(h,h+l),i=e.subarray(h+l),o={name:a,iv:n};let s;if("string"===typeof t&&(t=kc(t)),0===t.length)try{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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",ND,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:r,iterations:d,hash:{name:u}},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 RD.encode(n)}const LD=new Float32Array([-0]),UD=new Uint8Array(LD.buffer);function MD(e,t,r){LD[0]=e,t[r]=UD[0],t[r+1]=UD[1],t[r+2]=UD[2],t[r+3]=UD[3]}const OD=new Float64Array([-0]),qD=new Uint8Array(OD.buffer);function zD(e,t,r){OD[0]=e,t[r]=qD[0],t[r+1]=qD[1],t[r+2]=qD[2],t[r+3]=qD[3],t[r+4]=qD[4],t[r+5]=qD[5],t[r+6]=qD[6],t[r+7]=qD[7]}const FD=BigInt(Number.MAX_SAFE_INTEGER),KD=BigInt(Number.MIN_SAFE_INTEGER);class VD{constructor(e,t){Ji(this,"lo",void 0),Ji(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 jD;if(e<FD&&e>KD)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>HD&&(n=0n,++r>HD&&(r=0n))),new VD(Number(n),Number(r))}static fromNumber(e){if(0===e)return jD;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 VD(r,n)}static from(e){return"number"===typeof e?VD.fromNumber(e):"bigint"===typeof e?VD.fromBigInt(e):"string"===typeof e?VD.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new VD(e.low>>>0,e.high>>>0):jD}}const jD=new VD(0,0);jD.toBigInt=function(){return 0n},jD.zzEncode=jD.zzDecode=function(){return this},jD.length=function(){return 1};const HD=4294967296n;function WD(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 GD(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function YD(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class QD{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,GD(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 GD(this,4);return YD(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw GD(this,4);return 0|YD(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw GD(this,4);const e=(t=this.buf,r=this.pos,UD[0]=t[r],UD[1]=t[r+1],UD[2]=t[r+2],UD[3]=t[r+3],LD[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw GD(this,4);const e=(t=this.buf,r=this.pos,qD[0]=t[r],qD[1]=t[r+1],qD[2]=t[r+2],qD[3]=t[r+3],qD[4]=t[r+4],qD[5]=t[r+5],qD[6]=t[r+6],qD[7]=t[r+7],OD[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 GD(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 GD(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw GD(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 VD(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw GD(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 GD(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 GD(this,8);const e=YD(this.buf,this.pos+=4),t=YD(this.buf,this.pos+=4);return new VD(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 JD(e,t,r){const n=function(e){return new QD(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function XD(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function ZD(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 $D=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const eN=$D;class tN{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 rN{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 iN(this,e)}}class nN{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return iN(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 iN(e,t){var r,n;return new nN({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class oN{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new tN(e,t,r),this.decoder=new rN(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function sN(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new oN(t,r,n,i)}function aN(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=eN(n,t);return sN({prefix:r,name:t,encode:i,decode:e=>ZD(o(e))})}function cN(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return sN({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 lN=aN({prefix:"9",name:"base10",alphabet:"0123456789"}),uN=cN({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hN=cN({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),dN=cN({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),fN=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"),pN=fN.reduce(((e,t,r)=>(e[r]=t,e)),[]),gN=fN.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const bN=sN({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pN[t]),"")},decode:function(e){const t=[];for(const r of e){const e=gN[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),yN=cN({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mN=cN({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wN=cN({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vN=cN({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_N=cN({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),EN=cN({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SN=cN({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AN=cN({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xN=cN({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),kN=aN({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),CN=aN({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),IN=aN({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),TN=aN({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),PN=cN({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),RN=cN({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),DN=cN({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),NN=cN({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),BN=cN({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),LN=sN({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)}),UN=new TextEncoder,MN=new TextDecoder,ON="json",qN=512;function zN(e){return UN.encode(JSON.stringify(e))}function FN(e){return JSON.parse(MN.decode(e))}const KN="raw",VN=85;function jN(e){return ZD(e)}function HN(e){return ZD(e)}var WN=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=QN;)r[n++]=255&t|GN,t/=128;for(;t&YN;)r[n++]=255&t|GN,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},GN=128,YN=-128,QN=Math.pow(2,31);var JN=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&ZN)<<o:(n&ZN)*Math.pow(2,o),o+=7}while(n>=XN);return e.bytes=s-r,i},XN=128,ZN=127;var $N=Math.pow(2,7),eB=Math.pow(2,14),tB=Math.pow(2,21),rB=Math.pow(2,28),nB=Math.pow(2,35),iB=Math.pow(2,42),oB=Math.pow(2,49),sB=Math.pow(2,56),aB=Math.pow(2,63);const cB={encode:WN,decode:JN,encodingLength:function(e){return e<$N?1:e<eB?2:e<tB?3:e<rB?4:e<nB?5:e<iB?6:e<oB?7:e<sB?8:e<aB?9:10}};function lB(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return cB.encode(e,t,r),t}function uB(e){return cB.encodingLength(e)}function hB(e,t){const r=t.byteLength,n=uB(e),i=n+uB(r),o=new Uint8Array(i+r);return lB(e,o,0),lB(r,o,n),o.set(t,i),new dB(e,r,t,o)}class dB{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const fB=ZD;const pB={code:0,name:"identity",encode:fB,digest:function(e){return hB(0,fB(e))}};function gB(e){let{name:t,code:r,encode:n}=e;return new bB(t,r,n)}class bB{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?hB(this.code,t):t.then((e=>hB(this.code,e)))}throw Error("Unknown type, must be binary type")}}function yB(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const mB=gB({name:"sha2-256",code:18,encode:yB("SHA-256")}),wB=gB({name:"sha2-512",code:19,encode:yB("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const vB={...nt,...Je,...rt,...Ye,...Qe,...Ze,...$e,...et,...tt,...Xe};function _B(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const EB=_B("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),SB=_B("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=XD((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),AB={utf8:EB,"utf-8":EB,hex:vB.base16,latin1:SB,ascii:SB,binary:SB,...vB};class xB{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function kB(){}class CB{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const IB=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 XD(e);i+e>t&&(n=XD(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class TB{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new xB(kB,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new xB(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new DB((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(NB,10,VD.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=VD.fromBigInt(e);return this._push(NB,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=VD.fromBigInt(e).zzEncode();return this._push(NB,t.length(),t)}sint64Number(e){const t=VD.fromNumber(e).zzEncode();return this._push(NB,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(PB,1,e?1:0)}fixed32(e){return this._push(BB,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=VD.fromBigInt(e);return this._push(BB,4,t.lo)._push(BB,4,t.hi)}fixed64Number(e){const t=VD.fromNumber(e);return this._push(BB,4,t.lo)._push(BB,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(MD,4,e)}double(e){return this._push(zD,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(PB,1,0):this.uint32(t)._push(LB,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(WD,t,e):this._push(PB,1,0)}fork(){return this.states=new CB(this),this.head=this.tail=new xB(kB,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 xB(kB,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?XD(r):IB(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function PB(e,t,r){t[r]=255&e}function RB(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class DB extends xB{constructor(e,t){super(RB,e,t),Ji(this,"next",void 0),this.next=void 0}}function NB(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 BB(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 LB(e,t,r){t.set(e,r)}function UB(e,t,r){t.set(e,r)}function MB(e,t,r){e.length<40?WD(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=AB[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function OB(e,t){const r=new TB;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var qB,zB,FB,KB,VB;function jB(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function HB(e,t){return jB("message",qB.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(TB.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(UB,t,e),this},TB.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(MB,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"}(qB||(qB={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(zB||(zB={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(FB||(FB={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return jB("enum",qB.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(FB)}(zB||(zB={})),function(e){let t;e.codec=()=>(null==t&&(t=HB((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),zB.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=zB.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>OB(t,e.codec()),e.decode=t=>JD(t,e.codec())}(KB||(KB={})),function(e){let t;e.codec=()=>(null==t&&(t=HB((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),zB.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=zB.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>OB(t,e.codec()),e.decode=t=>JD(t,e.codec())}(VB||(VB={}));class WB{constructor(e){Ji(this,"_key",void 0),this._key=ZB(e,xD)}async verify(e,t){return TD(this._key,t,e)}marshal(){return this._key}get bytes(){return KB.encode({Type:zB.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await kR.digest(this.bytes);return e}}class GB{constructor(e,t){Ji(this,"_key",void 0),Ji(this,"_publicKey",void 0),this._key=ZB(e,kD),this._publicKey=ZB(t,xD)}async sign(e){return ID(this._key,e)}get public(){return new WB(this._publicKey)}marshal(){return this._key}get bytes(){return VB.encode({Type:zB.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await kR.digest(this.bytes);return e}async id(){const e=ER(this.public.bytes);return $P.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 BD(this.bytes,e);throw new oo("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function YB(e){if(e.length>kD){const t=(e=ZB(e,kD+xD)).subarray(0,kD),r=e.subarray(kD,e.length);return new GB(t,r)}const t=(e=ZB(e,kD)).subarray(0,kD),r=e.subarray(xD);return new GB(t,r)}function QB(e){return e=ZB(e,xD),new WB(e)}async function JB(){const{privateKey:e,publicKey:t}=await async function(){const e=AD.randomPrivateKey(),t=await vD(e);return{privateKey:PD(e,t),publicKey:t}}();return new GB(e,t)}async function XB(e){const{privateKey:t,publicKey:r}=await async function(e){if(e.length!==CD)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=await vD(t);return{privateKey:PD(t,r),publicKey:r}}(e);return new GB(t,r)}function ZB(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw new oo("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length),"ERR_INVALID_KEY_TYPE");return e}function $B(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=Fa([new Uint8Array(t-r.length),r])}return za(r,"base64url")}function eL(e){const t=function(e,t){let r=kc(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=Fa([new Uint8Array(t-r.length),r])}return r}(e);return new fy.jsbn.BigInteger(za(t,"base16"),16)}const tL={"P-256":256,"P-384":384,"P-521":521};Object.keys(tL).join(" / ");function rL(e,t){return t.map((t=>eL(e[t])))}async function nL(e){const t=[await DD.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await oL(e)],r=await iL({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function iL(e){if(null==e.privateKey||null==e.publicKey)throw new oo("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([DD.get().subtle.exportKey("jwk",e.privateKey),DD.get().subtle.exportKey("jwk",e.publicKey)])}async function oL(e){return DD.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 sL(e,t,r,n){const i=t?function(e){return fy.pki.setRsaPublicKey(...rL(e,["n","e"]))}(e):function(e){return fy.pki.setRsaPrivateKey(...rL(e,["n","e","d","p","q","dp","dq","qi"]))}(e);return kc(n(za(Uint8Array.from(r),"ascii"),i),"ascii")}class aL{constructor(e){Ji(this,"_key",void 0),this._key=e}async verify(e,t){return async function(e,t,r){const n=await DD.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return DD.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r)}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new oo("JWK was missing components","ERR_INVALID_PARAMETERS");const t=fy.pki.publicKeyToAsn1({n:eL(e.n),e:eL(e.e)});return kc(fy.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return KB.encode({Type:zB.RSA,Data:this.marshal()}).subarray()}encrypt(e){return sL(this._key,!0,e,((e,t)=>t.encrypt(e)))}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await kR.digest(this.bytes);return e}}class cL{constructor(e,t){Ji(this,"_key",void 0),Ji(this,"_publicKey",void 0),this._key=e,this._publicKey=t}genSecret(){return function(e){if(isNaN(e)||e<=0)throw new oo("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return UP.randomBytes(e)}(16)}async sign(e){return async function(e,t){const r=await DD.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await DD.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(t));return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new oo("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new aL(this._publicKey)}decrypt(e){return sL(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 oo("JWK was missing components","ERR_INVALID_PARAMETERS");const t=fy.pki.privateKeyToAsn1({n:eL(e.n),e:eL(e.e),d:eL(e.d),p:eL(e.p),q:eL(e.q),dP:eL(e.dp),dQ:eL(e.dq),qInv:eL(e.qi)});return kc(fy.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return VB.encode({Type:zB.RSA,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await kR.digest(this.bytes);return e}async id(){return za(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 fy.util.ByteBuffer(this.marshal()),r=fy.asn1.fromDer(t),n=fy.pki.privateKeyFromAsn1(r),i={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return fy.pki.encryptRsaPrivateKey(n,e,i)}if("libp2p-key"===t)return BD(this.bytes,e);throw new oo("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}async function lL(e){const t=function(e){const t=fy.asn1.fromDer(za(e,"ascii")),r=fy.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:$B(r.n),e:$B(r.e),d:$B(r.d),p:$B(r.p),q:$B(r.q),dp:$B(r.dP),dq:$B(r.dQ),qi:$B(r.qInv),alg:"RS256"}}(e),r=await nL(t);return new cL(r.privateKey,r.publicKey)}function uL(e){const t=function(e){const t=fy.asn1.fromDer(za(e,"ascii")),r=fy.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:$B(r.n),e:$B(r.e)}}(e);return new aL(t)}async function hL(e){const t=await nL(e);return new cL(t.privateKey,t.publicKey)}async function dL(e){const t=await async function(e){const t=await DD.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 iL(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new cL(t.privateKey,t.publicKey)}function fL(e){try{JT.fromHex(e)}catch(t){throw new oo(String(t),"ERR_INVALID_PUBLIC_KEY")}}class pL{constructor(e){Ji(this,"_key",void 0),fL(e),this._key=e}async verify(e,t){return async function(e,t,r){try{const{digest:n}=await kR.digest(r);return NP(t,n,e)}catch(n){throw new oo(String(n),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,JT.fromHex(e).toRawBytes(!0);var e}get bytes(){return KB.encode({Type:zB.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await kR.digest(this.bytes);return e}}class gL{constructor(e,t){Ji(this,"_key",void 0),Ji(this,"_publicKey",void 0),this._key=e,this._publicKey=null!==t&&void 0!==t?t:function(e){try{return xP(e,!0)}catch(t){throw new oo(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{xP(e,!0)}catch(t){throw new oo(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),fL(this._publicKey)}async sign(e){return async function(e,t){const{digest:r}=await kR.digest(t);try{return await RP(r,e)}catch(n){throw new oo(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new pL(this._publicKey)}marshal(){return this._key}get bytes(){return VB.encode({Type:zB.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ls(this.bytes,e.bytes)}async hash(){const{bytes:e}=await kR.digest(this.bytes);return e}async id(){return za(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 BD(this.bytes,e);throw new oo("export format '".concat(t,"' is not supported"),"ERR_INVALID_EXPORT_FORMAT")}}function bL(e){return new gL(e)}function yL(e){return new pL(e)}async function mL(){const e=UP.randomPrivateKey();return new gL(e)}const wL={rsa:lt,ed25519:ct,secp256k1:ut};var vL=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const _L=vL,EL=(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 SL{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 AL{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 kL(this,e)}}class xL{constructor(e){this.decoders=e}or(e){return kL(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 kL=(e,t)=>new xL({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class CL{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new SL(e,t,r),this.decoder=new AL(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const IL=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new CL(t,r,n,i)},TL=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=_L(n,r);return IL({prefix:t,name:r,encode:i,decode:e=>EL(o(e))})},PL=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return IL({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},RL=TL({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),DL=TL({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),NL=TL({prefix:"9",name:"base10",alphabet:"0123456789"}),BL=PL({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),LL=PL({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),UL=PL({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),ML=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"),OL=ML.reduce(((e,t,r)=>(e[r]=t,e)),[]),qL=ML.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const zL=IL({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=OL[t]),"")},decode:function(e){const t=[];for(const r of e){const e=qL[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),FL=PL({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),KL=PL({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),VL=PL({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jL=PL({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HL=PL({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),WL=PL({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),GL=PL({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),YL=PL({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),QL=PL({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),JL=TL({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),XL=TL({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ZL=PL({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$L=PL({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),eU=PL({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tU=PL({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),rU=PL({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),nU=IL({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),iU=new TextEncoder,oU=new TextDecoder,sU="json",aU=512,cU=e=>iU.encode(JSON.stringify(e)),lU=e=>JSON.parse(oU.decode(e)),uU="raw",hU=85,dU=e=>EL(e),fU=e=>EL(e);var pU=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=yU;)r[n++]=255&t|gU,t/=128;for(;t&bU;)r[n++]=255&t|gU,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},gU=128,bU=-128,yU=Math.pow(2,31);var mU=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&vU)<<o:(n&vU)*Math.pow(2,o),o+=7}while(n>=wU);return e.bytes=s-r,i},wU=128,vU=127;var _U=Math.pow(2,7),EU=Math.pow(2,14),SU=Math.pow(2,21),AU=Math.pow(2,28),xU=Math.pow(2,35),kU=Math.pow(2,42),CU=Math.pow(2,49),IU=Math.pow(2,56),TU=Math.pow(2,63);const PU={encode:pU,decode:mU,encodingLength:function(e){return e<_U?1:e<EU?2:e<SU?3:e<AU?4:e<xU?5:e<kU?6:e<CU?7:e<IU?8:e<TU?9:10}},RU=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[PU.decode(e,t),PU.decode.bytes]},DU=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return PU.encode(e,t,r),t},NU=e=>PU.encodingLength(e),BU=(e,t)=>{const r=t.byteLength,n=NU(e),i=n+NU(r),o=new Uint8Array(i+r);return DU(e,o,0),DU(r,o,n),o.set(t,i),new UU(e,r,t,o)},LU=e=>{const t=EL(e),[r,n]=RU(t),[i,o]=RU(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new UU(r,i,s,t)};class UU{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const MU=EL,OU={code:0,name:"identity",encode:MU,digest:e=>BU(0,MU(e))},qU=e=>{let{name:t,code:r,encode:n}=e;return new zU(t,r,n)};class zU{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?BU(this.code,t):t.then((e=>BU(this.code,e)))}throw Error("Unknown type, must be binary type")}}const FU=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),KU=qU({name:"sha2-256",code:18,encode:FU("SHA-256")}),VU=qU({name:"sha2-512",code:19,encode:FU("SHA-512")}),jU=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?QU(r,WU(e),t||RL.encoder):JU(r,WU(e),t||FL.encoder)},HU=new WeakMap,WU=e=>{const t=HU.get(e);if(null==t){const t=new Map;return HU.set(e,t),t}return t};class GU{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!==XU)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ZU)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return GU.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=BU(e,t);return GU.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 GU.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 jU(this,e)}toJSON(){return{"/":jU(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 GU)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new GU(e,r,n,i||$U(e,r,n.bytes))}if(!0===t[eM]){const{version:e,multihash:r,code:n}=t,i=LU(r);return GU.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!==XU)throw new Error("Version 0 CID must use dag-pb (code: ".concat(XU,") block encoding"));return new GU(e,t,r,r.bytes);case 1:{const n=$U(e,t,r.bytes);return new GU(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return GU.create(0,XU,e)}static createV1(e,t){return GU.create(1,e,t)}static decode(e){const[t,r]=GU.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=GU.inspectBytes(e),r=t.size-t.multihashSize,n=EL(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 UU(t.multihashCode,t.digestSize,i,n);return[0===t.version?GU.createV0(o):GU.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=RU(e.subarray(t));return t+=n,r};let n=r(),i=XU;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]=YU(e,t),i=GU.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return WU(i).set(r,e),i}}const YU=(e,t)=>{switch(e[0]){case"Q":{const r=t||RL;return[RL.prefix,r.decode("".concat(RL.prefix).concat(e))]}case RL.prefix:{const r=t||RL;return[RL.prefix,r.decode(e)]}case FL.prefix:{const r=t||FL;return[FL.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)]}},QU=(e,t,r)=>{const{prefix:n}=r;if(n!==RL.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},JU=(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},XU=112,ZU=18,$U=(e,t,r)=>{const n=NU(e),i=n+NU(t),o=new Uint8Array(i+r.byteLength);return DU(e,o,0),DU(t,o,n),o.set(r,i),o},eM=Symbol.for("@ipld/js-cid/CID"),tM={...vt,...pt,...wt,...dt,...ft,...bt,...yt,...ht,...mt,...gt},rM=Symbol.for("nodejs.util.inspect.custom"),nM=Object.values(tM).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),tM.identity.decoder),iM=114,oM=36,sM=37;class aM{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=RL.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return GU.createV1(iM,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:nM,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=LU(RL.decode("z".concat(e)));return e.startsWith("12D")?new lM({multihash:t}):e.startsWith("16U")?new uM({multihash:t}):new cM({multihash:t})}return function(e){try{const t=LU(e);if(t.code===OU.code){if(t.digest.length===oM)return new lM({multihash:t});if(t.digest.length===sM)return new uM({multihash:t})}if(t.code===KU.code)return new cM({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==iM)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===KU.code)return new cM({multihash:e.multihash});if(t.code===OU.code){if(t.digest.length===oM)return new lM({multihash:e.multihash});if(t.digest.length===sM)return new uM({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(GU.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(nM.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[rM](){return"PeerId(".concat(this.toString(),")")}}class cM extends aM{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class lM extends aM{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class uM extends aM{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function hM(e){return async function(e,t){return e.length===oM?new lM({multihash:BU(OU.code,e),privateKey:t}):e.length===sM?new uM({multihash:BU(OU.code,e),privateKey:t}):new cM({multihash:await KU.digest(e),publicKey:e,privateKey:t})}(new wL.secp256k1.Secp256k1PublicKey(e).bytes,void 0)}function dM(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 fM(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 pM 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)),Ji(this,"seq",void 0),Ji(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(zP)}get ip(){return gM(this,"ip","ip4")}set ip(e){yM(this,"ip","ip4",e)}get tcp(){return bM(this,"tcp","tcp")}set tcp(e){mM(this,"tcp","tcp",e)}get udp(){return bM(this,"udp","udp")}set udp(e){mM(this,"udp","udp",e)}get ip6(){return gM(this,"ip6","ip6")}set ip6(e){yM(this,"ip6","ip6",e)}get tcp6(){return bM(this,"tcp6","tcp")}set tcp6(e){mM(this,"tcp6","tcp",e)}get udp6(){return bM(this,"udp6","udp")}set udp6(e){mM(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(gl(i))}return t}(e)}set multiaddrs(e){wM(this,"multiaddrs",e,dM)}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){wM(this,"waku2",e,(e=>new Uint8Array([fM(e)])))}}function gM(e,t,r){const n=e.get(t);if(n)return Oc(r,n)}function bM(e,t,r){const n=e.get(t);if(n)return Number(Oc(r,n))}function yM(e,t,r,n){wM(e,t,n,qc.bind({},r))}function mM(e,t,r,n){yM(e,t,r,null===n||void 0===n?void 0:n.toString(10))}function wM(e,t,r,n){void 0!==r?e.set(t,n(r)):e.delete(t)}const vM=yl("waku:enr");var _M,EM;!function(e){e.TCP="tcp",e.UDP="udp"}(_M||(_M={})),function(e){e.TCP4="tcp4",e.UDP4="udp4",e.TCP6="tcp6",e.UDP6="udp6"}(EM||(EM={}));class SM extends pM{constructor(){super(...arguments),Ji(this,"peerId",void 0),Ji(this,"getLocationMultiaddr",FP.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 SM(e,t,arguments.length>2?arguments[2]:void 0);try{const e=r.publicKey;e&&(r.peerId=await hM(e))}catch(n){vM("Could not calculate peer id for ENR",n)}return r}get nodeId(){if("v4"===this.id)return this.publicKey?function(e){const t=JT.fromHex(e).toRawBytes(!1);return Sl(OP(t.slice(1)))}(this.publicKey):void 0;throw new Error(zP)}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(EM)){const e=this.getLocationMultiaddr(n);e&&t.push(e)}const r=null!==(e=this.multiaddrs)&&void 0!==e?e:[];return t.concat(r)}get peerInfo(){const e=this.peerId;if(e)return{id:e,multiaddrs:this.getAllLocationMultiaddrs(),protocols:[]}}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(zP);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return qP(t,OP(e),this.publicKey)}async sign(e,t){if("v4"!==this.id)throw new Error(zP);return this.signature=await async function(e,t){return RP(OP(t),e,{der:!1})}(t,e),this.signature}}Ji(SM,"RECORD_PREFIX","enr:");let AM=!1,xM=!1;const kM={debug:1,default:2,info:2,warning:3,error:4,off:5};let CM=kM.default,IM=null;const TM=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 PM,RM;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(PM||(PM={})),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"}(RM||(RM={}));const DM="0123456789abcdef";class NM{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==kM[r]&&this.throwArgumentError("invalid log level name","logLevel",e),CM>kM[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(NM.levels.DEBUG,t)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(NM.levels.INFO,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(NM.levels.WARNING,t)}makeError(e,t,r){if(xM)return this.makeError("censored error",t,{});t||(t=NM.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+=DM[t[e]>>4],r+=DM[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 RM.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 RM.CALL_EXCEPTION:case RM.INSUFFICIENT_FUNDS:case RM.MISSING_NEW:case RM.NONCE_EXPIRED:case RM.REPLACEMENT_UNDERPRICED:case RM.TRANSACTION_REPLACED:case RM.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,NM.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"),TM&&this.throwError("platform missing String.prototype.normalize",NM.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:TM})}checkSafeUint53(e,t){"number"===typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,NM.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,NM.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",e<t&&this.throwError("missing argument"+r,NM.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+r,NM.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",NM.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",NM.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",NM.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return IM||(IM=new NM("logger/5.7.0")),IM}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",NM.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),AM){if(!e)return;this.globalLogger().throwError("error censorship permanent",NM.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}xM=!!e,AM=!!t}static setLogLevel(e){const t=kM[e.toLowerCase()];null!=t?CM=t:NM.globalLogger().warn("invalid log level - "+e)}static from(e){return new NM(e)}}NM.errors=RM,NM.levels=PM;const BM=new NM("bytes/5.7.0");function LM(e){return!!e.toHexString}function UM(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return UM(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function MM(e){return FM(e)&&!(e.length%2)||qM(e)}function OM(e){return"number"===typeof e&&e==e&&e%1===0}function qM(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!OM(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!OM(r)||r<0||r>=256)return!1}return!0}function zM(e,t){if(t||(t={}),"number"===typeof e){BM.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),UM(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),LM(e)&&(e=e.toHexString()),FM(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0"+r:"right"===t.hexPad?r+="0":BM.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 UM(new Uint8Array(n))}return qM(e)?UM(new Uint8Array(e)):BM.throwArgumentError("invalid arrayify value","value",e)}function FM(e,t){return!("string"!==typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}const KM="0123456789abcdef";function VM(e,t){if(t||(t={}),"number"===typeof e){BM.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=KM[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),LM(e))return e.toHexString();if(FM(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":BM.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(qM(e)){let t="0x";for(let r=0;r<e.length;r++){let n=e[r];t+=KM[(240&n)>>4]+KM[15&n]}return t}return BM.throwArgumentError("invalid hexlify value","value",e)}const jM=new NM("rlp/5.7.0");function HM(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function WM(e,t,r){let n=0;for(let i=0;i<r;i++)n=256*n+e[t+i];return n}function GM(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat(GM(e))})),t.length<=55)return t.unshift(192+t.length),t;const r=HM(t.length);return r.unshift(247+r.length),r.concat(t)}MM(e)||jM.throwArgumentError("RLP object must be BytesLike","object",e);const t=Array.prototype.slice.call(zM(e));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const r=HM(t.length);return r.unshift(183+r.length),r.concat(t)}function YM(e){return VM(GM(e))}function QM(e,t,r,n){const i=[];for(;r<t+1+n;){const o=JM(e,r);i.push(o.result),(r+=o.consumed)>t+1+n&&jM.throwError("child data too short",NM.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:i}}function JM(e,t){if(0===e.length&&jM.throwError("data too short",NM.errors.BUFFER_OVERRUN,{}),e[t]>=248){const r=e[t]-247;t+1+r>e.length&&jM.throwError("data short segment too short",NM.errors.BUFFER_OVERRUN,{});const n=WM(e,t+1,r);return t+1+r+n>e.length&&jM.throwError("data long segment too short",NM.errors.BUFFER_OVERRUN,{}),QM(e,t,t+1+r,r+n)}if(e[t]>=192){const r=e[t]-192;return t+1+r>e.length&&jM.throwError("data array too short",NM.errors.BUFFER_OVERRUN,{}),QM(e,t,t+1,r)}if(e[t]>=184){const r=e[t]-183;t+1+r>e.length&&jM.throwError("data array too short",NM.errors.BUFFER_OVERRUN,{});const n=WM(e,t+1,r);t+1+r+n>e.length&&jM.throwError("data array too short",NM.errors.BUFFER_OVERRUN,{});return{consumed:1+r+n,result:VM(e.slice(t+1+r,t+1+r+n))}}if(e[t]>=128){const r=e[t]-128;t+1+r>e.length&&jM.throwError("data too short",NM.errors.BUFFER_OVERRUN,{});return{consumed:1+r,result:VM(e.slice(t+1,t+1+r))}}return{consumed:1,result:VM(e[t])}}class XM{static fromString(e){if(!e.startsWith(SM.RECORD_PREFIX))throw new Error("\"string encoded ENR must start with '".concat(SM.RECORD_PREFIX,"'"));return XM.fromRLP(kc(e.slice(4),"base64url"))}static fromRLP(e){const t=function(e){const t=zM(e),r=JM(t,0);return r.consumed!==t.length&&jM.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){(0,yl.log)("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 SM.create(i,o,t);return function(e,t,r,n){const i=El(YM([e,...t]));if(!r.verify(i,n))throw new Error("Unable to verify ENR signature")}(r,n,s,t),s}(t)}}const ZM=/^(\d{1,3}\.){3,3}\d{1,3}$/,$M=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,eO={name:"v4",size:4,isFormat:e=>ZM.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]))},tO={name:"v6",size:16,isFormat:e=>e.length>0&&$M.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 l=0;l<e.length;l++){let u=e.charCodeAt(l);58===u?(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===u?(r<n&&(t[r]=s),r++,s=0,o=0,a=!1,c=!0):(a=!1,u>=97?u-=87:u>=65?u-=55:(u-=48,s=10*s+u),o=(o<<4)+u)}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 rO(e){if(eO.isFormat(e))return eO.size;if(tO.isFormat(e))return tO.size;throw Error("Invalid ip address: ".concat(e))}function nO(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 iO(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 oO(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 sO(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 aO(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 cO(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 lO(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 uO=55296,hO=56320;function dO(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)!==uO)t+=3;else{const o=n+1;if(o===r||i>=hO)t+=3;else{(64512&e.charCodeAt(o))!==hO?t+=3:(n=o,t+=4)}}}return t}function fO(e,t,r){const n=e.length;void 0!==r&&null!==r||(r=0),void 0===t&&(t=new Uint8Array(dO(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)!==uO)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>=hO)t[i++]=239,t[i++]=191,t[i++]=189;else{const n=e.charCodeAt(s);(64512&n)!==hO?(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 fO.bytes=i-r,t}function pO(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=uO|r>>10&1023;n+=String.fromCharCode(o),r=hO|1023&r}else r=(15&t)<<12|(63&e[i++])<<6|63&e[i++];n+=String.fromCharCode(r)}return pO.bytes=r-t,n}fO.bytes=0,pO.bytes=0;const gO=e=>e instanceof Uint8Array;function bO(e){return"string"===typeof e?dO(e):e.byteLength}function yO(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):fO(e)}function mO(e,t,r){if("string"!==typeof t)throw new Error("unknown input type");return fO(t,e,r),fO.bytes}const wO=Math.pow(2,24),vO=Math.pow(2,16),_O=Math.pow(2,8),EO=(e,t)=>e[t]*wO+e[t+1]*vO+e[t+2]*_O+e[t+3],SO=(e,t)=>e[t]<<8|e[t+1],AO=(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),xO=(e,t,r)=>(e[r]=t>>8,e[r+1]=255&t,r+2);function kO(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 CO=32768;function IO(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 TO=IO({encode(e,t,r){t||(t=new Uint8Array(TO.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=mO(t,e[n],r+1);t[r]=i,r+=i+1}}return t[r++]=0,TO.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(pO(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=SO(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 TO.decode.bytes=o,0===r.length?".":r.join(".")},encodingLength:e=>"."===e||".."===e?1:bO(e.replace(/^\.|\.$/gm,""))+2}),PO=IO({encode(e,t,r){t||(t=new Uint8Array(PO.encodingLength(e))),r||(r=0);const n=mO(t,e,r+1);return t[r]=n,PO.encode.bytes=n+1,t},decode(e,t){t||(t=0);const r=e[t],n=pO(e,t+1,t+1+r);return PO.decode.bytes=r+1,n},encodingLength:e=>bO(e)+1}),RO=IO({bytes:12,encode(e,t,r){t||(t=new Uint8Array(RO.encodingLength(e))),r||(r=0);const n=32767&(e.flags||0),i="response"===e.type?32768:0;return xO(t,e.id||0,r),xO(t,n|i,r+2),xO(t,e.questions.length,r+4),xO(t,e.answers.length,r+6),xO(t,e.authorities.length,r+8),xO(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=SO(e,t+2);return{id:SO(e,t),type:32768&r?"response":"query",flags:32767&r,flag_qr:1===(r>>15&1),opcode:sO(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:oO(15&r),questions:new Array(SO(e,t+4)),answers:new Array(SO(e,t+6)),authorities:new Array(SO(e,t+8)),additionals:new Array(SO(e,t+10))}},encodingLength:()=>12}),DO=IO({encode(e,t,r){t||(t=new Uint8Array(DO.encodingLength(e))),r||(r=0);const n=e.length;return xO(t,n,r),kO(e,t,r+2,0,n),DO.encode.bytes=n+2,t},decode(e,t){t||(t=0);const r=SO(e,t),n=e.slice(t+2,t+2+r);return DO.decode.bytes=r+2,n},encodingLength:e=>e.length+2}),NO=IO({encode:(e,t,r)=>(t||(t=new Uint8Array(NO.encodingLength(e))),r||(r=0),TO.encode(e,t,r+2),xO(t,TO.encode.bytes,r),NO.encode.bytes=TO.encode.bytes+2,t),decode(e,t){t||(t=0);const r=SO(e,t),n=TO.decode(e,t+2);return NO.decode.bytes=r+2,n},encodingLength:e=>TO.encodingLength(e)+2}),BO=IO({encode(e,t,r){t||(t=new Uint8Array(BO.encodingLength(e))),r||(r=0);const n=r;return r+=2,TO.encode(e.mname,t,r),r+=TO.encode.bytes,TO.encode(e.rname,t,r),r+=TO.encode.bytes,AO(t,e.serial||0,r),r+=4,AO(t,e.refresh||0,r),r+=4,AO(t,e.retry||0,r),r+=4,AO(t,e.expire||0,r),r+=4,AO(t,e.minimum||0,r),xO(t,(r+=4)-n-2,n),BO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.mname=TO.decode(e,t),t+=TO.decode.bytes,n.rname=TO.decode(e,t),t+=TO.decode.bytes,n.serial=EO(e,t),t+=4,n.refresh=EO(e,t),t+=4,n.retry=EO(e,t),t+=4,n.expire=EO(e,t),t+=4,n.minimum=EO(e,t),t+=4,BO.decode.bytes=t-r,n},encodingLength:e=>22+TO.encodingLength(e.mname)+TO.encodingLength(e.rname)}),LO=IO({encode(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)if("string"===typeof e[i]&&(e[i]=yO(e[i])),!gO(e[i]))throw new Error("Must be a Buffer");t||(t=new Uint8Array(LO.encodingLength(e))),r||(r=0);const n=r;return r+=2,e.forEach((function(e){t[r++]=e.length,kO(e,t,r,0,e.length),r+=e.length})),xO(t,r-n-2,n),LO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t;let n=SO(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 LO.decode.bytes=t-r,i},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach((function(e){t+="string"===typeof e?bO(e)+1:e.length+1})),t}}),UO=IO({encode(e,t,r){t||(t=new Uint8Array(UO.encodingLength(e))),r||(r=0),"string"===typeof e&&(e=yO(e)),e||(e=new Uint8Array(0));const n=r;r+=2;const i=e.length;return kO(e,t,r,0,i),xO(t,(r+=i)-n-2,n),UO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n=SO(e,t);t+=2;const i=e.slice(t,t+n);return t+=n,UO.decode.bytes=t-r,i},encodingLength:e=>e?(gO(e)?e.length:bO(e))+2:2}),MO=IO({encode(e,t,r){t||(t=new Uint8Array(MO.encodingLength(e))),r||(r=0);const n=r;return r+=2,PO.encode(e.cpu,t,r),r+=PO.encode.bytes,PO.encode(e.os,t,r),r+=PO.encode.bytes,xO(t,r-n-2,n),MO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.cpu=PO.decode(e,t),t+=PO.decode.bytes,n.os=PO.decode(e,t),t+=PO.decode.bytes,MO.decode.bytes=t-r,n},encodingLength:e=>PO.encodingLength(e.cpu)+PO.encodingLength(e.os)+2}),OO=IO({encode:(e,t,r)=>(t||(t=new Uint8Array(OO.encodingLength(e))),r||(r=0),TO.encode(e,t,r+2),xO(t,TO.encode.bytes,r),OO.encode.bytes=TO.encode.bytes+2,t),decode(e,t){t||(t=0);const r=TO.decode(e,t+2);return OO.decode.bytes=TO.decode.bytes+2,r},encodingLength:e=>TO.encodingLength(e)+2}),qO=IO({encode(e,t,r){t||(t=new Uint8Array(qO.encodingLength(e))),r||(r=0),xO(t,e.priority||0,r+2),xO(t,e.weight||0,r+4),xO(t,e.port||0,r+6),TO.encode(e.target,t,r+8);const n=TO.encode.bytes+6;return xO(t,n,r),qO.encode.bytes=n+2,t},decode(e,t){t||(t=0);const r=SO(e,t),n={};return n.priority=SO(e,t+2),n.weight=SO(e,t+4),n.port=SO(e,t+6),n.target=TO.decode(e,t+8),qO.decode.bytes=r+2,n},encodingLength:e=>8+TO.encodingLength(e.target)}),zO=IO({encode(e,t,r){const n=zO.encodingLength(e);return t||(t=new Uint8Array(zO.encodingLength(e))),r||(r=0),e.issuerCritical&&(e.flags=zO.ISSUER_CRITICAL),xO(t,n-2,r),t[r+=2]=e.flags||0,r+=1,PO.encode(e.tag,t,r),r+=PO.encode.bytes,mO(t,e.value,r),r+=bO(e.value),zO.encode.bytes=n,t},decode(e,t){t||(t=0);const r=SO(e,t),n=t+=2,i={};return i.flags=e[t],t+=1,i.tag=PO.decode(e,t),t+=PO.decode.bytes,i.value=pO(e,t,n+r),i.issuerCritical=!!(i.flags&zO.ISSUER_CRITICAL),zO.decode.bytes=r+2,i},encodingLength:e=>PO.encodingLength(e.tag)+PO.encodingLength(e.value)+2});zO.ISSUER_CRITICAL=128;const FO=IO({encode(e,t,r){t||(t=new Uint8Array(FO.encodingLength(e))),r||(r=0);const n=r;return r+=2,xO(t,e.preference||0,r),r+=2,TO.encode(e.exchange,t,r),r+=TO.encode.bytes,xO(t,r-n-2,n),FO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.preference=SO(e,t),t+=2,n.exchange=TO.decode(e,t),t+=TO.decode.bytes,FO.decode.bytes=t-r,n},encodingLength:e=>4+TO.encodingLength(e.exchange)}),KO=IO({encode:(e,t,r)=>(t||(t=new Uint8Array(KO.encodingLength(e))),r||(r=0),xO(t,4,r),r+=2,eO.encode(e,t,r),t),decode(e,t){t||(t=0),t+=2;return eO.decode(e,t)},bytes:6}),VO=IO({encode:(e,t,r)=>(t||(t=new Uint8Array(VO.encodingLength(e))),r||(r=0),xO(t,16,r),r+=2,tO.encode(e,t,r),VO.encode.bytes=18,t),decode(e,t){t||(t=0),t+=2;const r=tO.decode(e,t);return VO.decode.bytes=18,r},bytes:18}),jO=e=>new Uint8Array(e),HO=IO({encode(e,t,r){t||(t=new Uint8Array(HO.encodingLength(e))),r||(r=0);const n=r,i=lO(e.code);if(xO(t,i,r),r+=2,e.data)xO(t,e.data.length,r),r+=2,kO(e.data,t,r),r+=e.data.length;else switch(i){case 8:{const n=e.sourcePrefixLength||0,i=e.family||function(e){return rO(e)===eO.size?1:2}(e.ip),o=function(e,t,r){r=~~r;const n=rO(e);return"function"===typeof t&&(t=t(r+n)),n===eO.size?eO.encode(e,t,r):tO.encode(e,t,r)}(e.ip,jO),s=Math.ceil(n/8);xO(t,s+4,r),xO(t,i,r+=2),r+=2,t[r++]=n,t[r++]=e.scopePrefixLength||0,kO(o,t,r,0,s),r+=s}break;case 11:e.timeout?(xO(t,2,r),r+=2,xO(t,e.timeout,r),r+=2):(xO(t,0,r),r+=2);break;case 12:{const n=e.length||0;xO(t,n,r),r+=2,t.fill(0,r,r+n),r+=n}break;case 14:{const n=2*e.tags.length;xO(t,n,r),r+=2;for(const i of e.tags)xO(t,i,r),r+=2}break;default:throw new Error("Unknown roption code: ".concat(e.code))}return HO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r={};r.code=SO(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=SO(e,t+=2);switch(t+=2,r.data=e.slice(t,t+n),r.code){case 8:r.family=SO(e,t),t+=2,r.sourcePrefixLength=e[t++],r.scopePrefixLength=e[t++];{const i=new Uint8Array(1===r.family?4:16);kO(e,i,0,t,t+n-4),r.ip=function(e,t,r){if(t=~~t,(r=r||e.length-t)===eO.size)return eO.decode(e,t,r);if(r===tO.size)return tO.decode(e,t,r);throw Error("Invalid buffer size needs to be ".concat(eO.size," for v4 or ").concat(tO.size," for v6."))}(i)}break;case 11:n>0&&(r.timeout=SO(e,t),t+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(SO(e,t)),t+=2}return HO.decode.bytes=n+4,r},encodingLength(e){if(e.data)return e.data.length+4;switch(lO(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))}}),WO=IO({encode(e,t,r){t||(t=new Uint8Array(WO.encodingLength(e))),r||(r=0);const n=r,i=hq(e,HO);return xO(t,i,r),r=dq(e,HO,t,r+2),WO.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n=[];let i=SO(e,t);t+=2;let o=0;for(;i>0;)n[o++]=HO.decode(e,t),t+=HO.decode.bytes,i-=HO.decode.bytes;return WO.decode.bytes=t-r,n},encodingLength:e=>2+hq(e||[],HO)}),GO=IO({encode(e,t,r){t||(t=new Uint8Array(GO.encodingLength(e))),r||(r=0);const n=r,i=e.key;if(!gO(i))throw new Error("Key must be a Buffer");return r+=2,xO(t,e.flags,r),t[r+=2]=GO.PROTOCOL_DNSSEC,t[r+=1]=e.algorithm,kO(i,t,r+=1,0,i.length),r+=i.length,GO.encode.bytes=r-n,xO(t,GO.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=SO(e,t);if(t+=2,n.flags=SO(e,t),e[t+=2]!==GO.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,GO.decode.bytes=t-r,n},encodingLength:e=>6+bO(e.key)});GO.PROTOCOL_DNSSEC=3,GO.ZONE_KEY=128,GO.SECURE_ENTRYPOINT=32768;const YO=IO({encode(e,t,r){t||(t=new Uint8Array(YO.encodingLength(e))),r||(r=0);const n=r,i=e.signature;if(!gO(i))throw new Error("Signature must be a Buffer");return r+=2,xO(t,iO(e.typeCovered),r),t[r+=2]=e.algorithm,t[r+=1]=e.labels,r+=1,AO(t,e.originalTTL,r),r+=4,AO(t,e.expiration,r),r+=4,AO(t,e.inception,r),r+=4,xO(t,e.keyTag,r),r+=2,TO.encode(e.signersName,t,r),kO(i,t,r+=TO.encode.bytes,0,i.length),r+=i.length,YO.encode.bytes=r-n,xO(t,YO.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=SO(e,t);return t+=2,n.typeCovered=nO(SO(e,t)),t+=2,n.algorithm=e[t],t+=1,n.labels=e[t],t+=1,n.originalTTL=EO(e,t),t+=4,n.expiration=EO(e,t),t+=4,n.inception=EO(e,t),t+=4,n.keyTag=SO(e,t),t+=2,n.signersName=TO.decode(e,t),t+=TO.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,YO.decode.bytes=t-r,n},encodingLength:e=>20+TO.encodingLength(e.signersName)+bO(e.signature)}),QO=IO({encode(e,t,r){t||(t=new Uint8Array(QO.encodingLength(e))),r||(r=0);const n=r;return r+=2,TO.encode(e.mbox||".",t,r),r+=TO.encode.bytes,TO.encode(e.txt||".",t,r),r+=TO.encode.bytes,QO.encode.bytes=r-n,xO(t,QO.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.mbox=TO.decode(e,t)||".",t+=TO.decode.bytes,n.txt=TO.decode(e,t)||".",t+=TO.decode.bytes,QO.decode.bytes=t-r,n},encodingLength:e=>2+TO.encodingLength(e.mbox||".")+TO.encodingLength(e.txt||".")}),JO=IO({encode(e,t,r){t||(t=new Uint8Array(JO.encodingLength(e))),r||(r=0);const n=r,i=[];for(let o=0;o<e.length;o++){const t=iO(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=yO(i[o]);t[r]=o,t[r+=1]=e.length,kO(e,t,r+=1,0,e.length),r+=e.length}return JO.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=nO(r<<8|o<<3|e);i.push(t)}}t+=n}return JO.decode.bytes=t-n,i},encodingLength(e){const t=[];for(let n=0;n<e.length;n++){const r=iO(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}}),XO=IO({encode(e,t,r){t||(t=new Uint8Array(XO.encodingLength(e))),r||(r=0);const n=r;return r+=2,TO.encode(e.nextDomain,t,r),r+=TO.encode.bytes,JO.encode(e.rrtypes,t,r),r+=JO.encode.bytes,XO.encode.bytes=r-n,xO(t,XO.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=SO(e,t);return t+=2,n.nextDomain=TO.decode(e,t),t+=TO.decode.bytes,n.rrtypes=JO.decode(e,t,i-(t-r)),t+=JO.decode.bytes,XO.decode.bytes=t-r,n},encodingLength:e=>2+TO.encodingLength(e.nextDomain)+JO.encodingLength(e.rrtypes)}),ZO=IO({encode(e,t,r){t||(t=new Uint8Array(ZO.encodingLength(e))),r||(r=0);const n=r,i=e.salt;if(!gO(i))throw new Error("salt must be a Buffer");const o=e.nextDomain;if(!gO(o))throw new Error("nextDomain must be a Buffer");return t[r+=2]=e.algorithm,t[r+=1]=e.flags,r+=1,xO(t,e.iterations,r),t[r+=2]=i.length,kO(i,t,r+=1,0,i.length),t[r+=i.length]=o.length,kO(o,t,r+=1,0,o.length),r+=o.length,JO.encode(e.rrtypes,t,r),r+=JO.encode.bytes,ZO.encode.bytes=r-n,xO(t,ZO.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=SO(e,t);t+=2,n.algorithm=e[t],t+=1,n.flags=e[t],t+=1,n.iterations=SO(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=JO.decode(e,t,i-(t-r)),t+=JO.decode.bytes,ZO.decode.bytes=t-r,n},encodingLength:e=>8+e.salt.length+e.nextDomain.length+JO.encodingLength(e.rrtypes)}),$O=IO({encode(e,t,r){t||(t=new Uint8Array($O.encodingLength(e))),r||(r=0);const n=r,i=e.digest;if(!gO(i))throw new Error("Digest must be a Buffer");return r+=2,xO(t,e.keyTag,r),t[r+=2]=e.algorithm,t[r+=1]=e.digestType,kO(i,t,r+=1,0,i.length),r+=i.length,$O.encode.bytes=r-n,xO(t,$O.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=SO(e,t);return t+=2,n.keyTag=SO(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,$O.decode.bytes=t-r,n},encodingLength:e=>6+bO(e.digest)});function eq(e){switch(e.toUpperCase()){case"A":return KO;case"PTR":case"CNAME":case"DNAME":return OO;case"TXT":return LO;case"NULL":return UO;case"AAAA":return VO;case"SRV":return qO;case"HINFO":return MO;case"CAA":return zO;case"NS":return NO;case"SOA":return BO;case"MX":return FO;case"OPT":return WO;case"DNSKEY":return GO;case"RRSIG":return YO;case"RP":return QO;case"NSEC":return XO;case"NSEC3":return ZO;case"DS":return $O}return DO}const tq=IO({encode(e,t,r){t||(t=new Uint8Array(tq.encodingLength(e))),r||(r=0);const n=r;if(TO.encode(e.name,t,r),r+=TO.encode.bytes,xO(t,iO(e.type),r),"OPT"===e.type.toUpperCase()){if("."!==e.name)throw new Error("OPT name must be root.");xO(t,e.udpPayloadSize||4096,r+2),t[r+4]=e.extendedRcode||0,t[r+5]=e.ednsVersion||0,xO(t,e.flags||0,r+6),r+=8,WO.encode(e.options||[],t,r),r+=WO.encode.bytes}else{let n=cO(void 0===e.class?"IN":e.class);e.flush&&(n|=CO),xO(t,n,r+2),AO(t,e.ttl||0,r+4),r+=8;const i=eq(e.type);i.encode(e.data,t,r),r+=i.encode.bytes}return tq.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r={},n=t;if(r.name=TO.decode(e,t),t+=TO.decode.bytes,r.type=nO(SO(e,t)),"OPT"===r.type)r.udpPayloadSize=SO(e,t+2),r.extendedRcode=e[t+4],r.ednsVersion=e[t+5],r.flags=SO(e,t+6),r.flag_do=1===(r.flags>>15&1),r.options=WO.decode(e,t+8),t+=8+WO.decode.bytes;else{const n=SO(e,t+2);r.ttl=EO(e,t+4),r.class=aO(-32769&n),r.flush=!!(n&CO);const i=eq(r.type);r.data=i.decode(e,t+8),t+=8+i.decode.bytes}return tq.decode.bytes=t-n,r},encodingLength(e){const t=null!==e.data&&void 0!==e.data?e.data:e.options;return TO.encodingLength(e.name)+8+eq(e.type).encodingLength(t)}}),rq=IO({encode(e,t,r){t||(t=new Uint8Array(rq.encodingLength(e))),r||(r=0);const n=r;return TO.encode(e.name,t,r),r+=TO.encode.bytes,xO(t,iO(e.type),r),r+=2,xO(t,cO(void 0===e.class?"IN":e.class),r),r+=2,rq.encode.bytes=r-n,e},decode(e,t){t||(t=0);const r=t,n={};n.name=TO.decode(e,t),t+=TO.decode.bytes,n.type=nO(SO(e,t)),t+=2,n.class=aO(SO(e,t)),t+=2;return!!(32768&n.class)&&(n.class&=-32769),rq.decode.bytes=t-r,n},encodingLength:e=>TO.encodingLength(e.name)+4}),nq=256,iq={encode:function(e,t,r){const n=!t;n&&(t=new Uint8Array(uq(e))),r||(r=0);const i=r;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),RO.encode(e,t,r),r+=RO.encode.bytes,r=dq(e.questions,rq,t,r),r=dq(e.answers,tq,t,r),r=dq(e.authorities,tq,t,r),r=dq(e.additionals,tq,t,r),iq.encode.bytes=r-i,n&&cq.bytes!==t.length?t.slice(0,cq.bytes):t},decode:function(e,t){t||(t=0);const r=t,n=RO.decode(e,t);return t+=RO.decode.bytes,t=fq(n.questions,rq,e,t),t=fq(n.answers,tq,e,t),t=fq(n.authorities,tq,e,t),t=fq(n.additionals,tq,e,t),iq.decode.bytes=t-r,n},encodingLength:function(e){return RO.encodingLength(e)+hq(e.questions||[],rq)+hq(e.answers||[],tq)+hq(e.authorities||[],tq)+hq(e.additionals||[],tq)}};function oq(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}iq.encode.bytes=0,iq.decode.bytes=0;const sq={encode:function(e,t,r){return t=iq.encode(oq(e,"query"),t,r),sq.encode.bytes=iq.encode.bytes,t},decode:function(e,t){const r=iq.decode(e,t);return sq.decode.bytes=iq.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(e){return iq.encodingLength(oq(e,"query"))}};sq.encode.bytes=0,sq.decode.bytes=0;const aq={encode:function(e,t,r){return t=iq.encode(oq(e,"response"),t,r),aq.encode.bytes=iq.encode.bytes,t},decode:function(e,t){const r=iq.decode(e,t);return aq.decode.bytes=iq.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(e){return iq.encodingLength(oq(e,"response"))}};aq.encode.bytes=0,aq.decode.bytes=0;const cq=iq.encode,lq=iq.decode,uq=iq.encodingLength;function hq(e,t){let r=0;for(let n=0;n<e.length;n++)r+=t.encodingLength(e[n]);return r}function dq(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 fq(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 pq(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 l=r,u=0;for(;u<c;){const r=i[e.charCodeAt(u)]<<18|i[e.charCodeAt(u+1)]<<12|i[e.charCodeAt(u+2)]<<6|i[e.charCodeAt(u+3)];t[l++]=r>>16,t[l++]=r>>8,t[l++]=r,u+=4}if(3===o){const r=i[e.charCodeAt(u)]<<10|i[e.charCodeAt(u+1)]<<4|i[e.charCodeAt(u+2)]>>2;t[l++]=r>>8,t[l++]=r}else 2===o&&(t[l++]=i[e.charCodeAt(u)]<<2|i[e.charCodeAt(u+1)]>>4);return a.encode.bytes=l-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,l=t+i-c,u=[];for(let n=t;n<l;n+=3){const t=e[n]<<16|e[n+1]<<8|e[n+2];u.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];u.push(o[t>>10],o[t>>4&63],o[t<<2&63]),1===n&&u.push(s)}else if(1===c){const t=e[r-1];u.push(o[t>>2],o[t<<4&63]),1===n&&u.push(s,s)}return a.decode.bytes=i,String.fromCharCode.apply(String,u)}};return a}pq("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",1);const gq=pq("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",2);let bq="undefined"!==typeof global?global.AbortError:"undefined"!==typeof window?window.AbortError:null;bq||(bq=class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Request aborted.")}}),bq.prototype.name="AbortError",bq.prototype.code="ABORT_ERR";const yq="undefined"!==typeof globalThis&&globalThis.URL||require("url").URL;class mq 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}}}mq.prototype.name="HTTPStatusError",mq.prototype.code="HTTP_STATUS";class wq extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:Sq(this.cause)}}}wq.prototype.name="ResponseError",wq.prototype.code="RESPONSE_ERR";class vq extends Error{constructor(e){super("Timeout (t="+e+")."),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}vq.prototype.name="TimeoutError",vq.prototype.code="ETIMEOUT";const _q=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,Eq=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function Sq(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 Aq=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,xq=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,kq=/\[(((pk|name)=([^\]]+)))\]/gi;function Cq(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 Iq extends Error{constructor(e,t){super('Invalid Endpoint: unsupported protocol "'.concat(e,'" for endpoint: ').concat(t,", supported protocols: ").concat(Tq.join(", "))),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}Iq.prototype.name="InvalidProtocolError",Iq.prototype.code="EPROTOCOL";const Tq=["http:","https:","udp4:","udp6:"];class Pq{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 Rq extends Pq{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 Dq extends Rq{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 Nq extends Rq{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 Bq(e){return Eq.test(e)&&!_q.test(e)?"[".concat(e,"]"):e}class Lq extends Pq{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=Eq.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||_q.test(this.host)&&(this.ipv4=this.host);const t="".concat(this.protocol,"//").concat(Bq(this.host),":").concat(this.port).concat(this.path);try{this.url=new yq(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(Bq(this.host)).concat(t).concat(n).concat(r).concat(o).concat(s).concat(i)}}function Uq(e){let t;if("string"===typeof e)t=function(e){const t=Aq.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=Cq(s,xq);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=Cq(s,kq),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 Nq({protocol:"udp6:",ipv6:o[1],port:i,pk:t.pk,name:t.name}):new Dq({protocol:"udp4:",ipv4:n,port:i,pk:t.pk,name:t.name})}throw new Iq(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 Pq)return e;t=e}null!==t.protocol&&void 0!==t.protocol||(t.protocol="https:");const r=t.protocol;if("udp4:"===r)return new Dq(t);if("udp6:"===r)return new Nq(t);if("https:"===r||"http:"===r)return new Lq(t);throw new Iq(r,JSON.stringify(t))}const Mq="application/dns-message";function Oq(){}function qq(e,t,r,n,i){return new Promise(((o,s)=>{const a=new yq(e);"GET"===t&&r&&(a.search="?dns="+gq.decode(r));const c=a.toString(),l=new XMLHttpRequest;l.open(t,c,!0),l.setRequestHeader("Accept",Mq),"POST"===t&&l.setRequestHeader("Content-Type",Mq),l.responseType="arraybuffer",l.timeout=n,l.ontimeout=function(){u(new vq(n));try{l.abort()}catch(e){}},l.onreadystatechange=function(){if(l.readyState>1&&200!==l.status&&0!==l.status){u(new mq(c,l.status,t));try{l.abort()}catch(e){}}},l.onerror=function(){u(200===l.status?new Error("Inexplicable XHR Error"):new mq(c,l.status,t))},l.onload=function(){if(200!==l.status)u(new mq(c,l.status,t));else{let e;if("string"===typeof l.response)e=fO(l.response);else if(l.response instanceof Uint8Array)e=l.response;else{if(!(Array.isArray(l.response)||l.response instanceof ArrayBuffer))throw new Error("Unprocessable response "+l.response);e=new Uint8Array(l.response)}u(null,e)}},"POST"===t?l.send(r):l.send(),i&&i.addEventListener("abort",h);let u=function(e,t){u=Oq,i&&i.removeEventListener("abort",h),o(e?{error:e,response:l}:{data:t,response:l})};function h(){u(new bq);try{l.abort()}catch(e){}}}))}Error;function zq(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=Uq(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 Fq=zq({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 Kq(e,t,r,n){return n&&n.aborted?Promise.reject(new bq):"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 qq(e,t,r,n,i)}(e.url,e.method,cq(Object.assign({flags:nq},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 wq("Empty.");else try{const e=lq(t);return e.response=r,e}catch(i){n=new wq("Invalid packet (cause="+i.message+")",i)}throw Object.assign(n,{response:r})}))}(e,t,r,n)}const Vq=new yq("https://martinheidegger.github.io/dns-query/resolvers.json");function jq(e){return/^@/.test(e)}const Hq=new class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:Vq,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 qq(e,"GET",null,r,n),s={time:Date.now(),data:JSON.parse(pO(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=>zq({data:e.data.resolvers,time:e.time}))).catch((()=>t||Fq)):Promise.resolve(Fq),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=Yq),"dns"===e&&(e=Qq),"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(jq))try{return Promise.resolve(e.map(Uq))}catch(t){return Promise.reject(t)}return this.data().then((t=>e.map((e=>{if(jq(e)){const r=t.endpointByName[e.substring(1)];if(!r)throw new Error("Endpoint ".concat(e," is not known."));return r}return Uq(e)}))))}};function Wq(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 Gq(r.map(Uq),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 Gq(e,t,r){const n=1===e.length?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return Kq(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),Gq(e,t,r)}))}function Yq(e){return"https:"===e.protocol||"http:"===e.protocol}function Qq(e){return"udp4:"===e.protocol||"udp6:"===e.protocol}const Jq=yl("waku:dns-over-https");class Xq{static async create(e,t){const r=null!==e&&void 0!==e?e:await Hq.endpoints("doh");return new Xq(r,t)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;Ji(this,"endpoints",void 0),Ji(this,"retries",void 0),this.endpoints=e,this.retries=t}async resolveTXT(e){let t;try{t=(await Wq({question:{type:"TXT",name:e}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(i){throw Jq("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 Zq=__webpack_require__(5411);class $q{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=$q.parseRootValues(e),n=Zq.decode.asBytes(t),i=e.split(" sig")[0],o=xl(i);if(!qP(kc(r.signature,"base64url").slice(0,64),OP(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(",")}}Ji($q,"RECORD_PREFIX",SM.RECORD_PREFIX),Ji($q,"TREE_PREFIX","enrtree:"),Ji($q,"BRANCH_PREFIX","enrtree-branch:"),Ji($q,"ROOT_PREFIX","enrtree-root:");const ez=yl("waku:discovery:fetch_nodes");function tz(e,t){return t.relay>=e.relay&&t.store>=e.store&&t.filter>=e.filter&&t.lightPush>=e.lightPush}function rz(e,t){if(!e.nodeId)return!1;for(const r of t)if(e.nodeId===r.nodeId)return!1;return!0}function nz(e,t){e.relay&&(t.relay+=1),e.store&&(t.store+=1),e.filter&&(t.filter+=1),e.lightPush&&(t.lightPush+=1)}function iz(e,t,r){if(tz(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 oz=yl("waku:discovery:dns");class sz{static async dnsOverHttp(e){return e||(e=await Xq.create()),new sz(e)}async getPeers(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=$q.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,l={relay:0,store:0,filter:0,lightPush:0};let u=0;const h=[];for(;!tz(a,l)&&u<c+t;){const e=await r();e&&rz(e,h)&&(e.waku2&&iz(e.waku2,a,l)&&(nz(e.waku2,l),h.push(e)),ez("got new peer candidate from DNS address=".concat(e.nodeId,"@").concat(e.ip))),u++}return h}(t,this._errorTolerance,(()=>this._search(i,o)));return oz("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){Ji(this,"dns",void 0),Ji(this,"_DNSTreeCache",void 0),Ji(this,"_errorTolerance",10),this._DNSTreeCache={},this.dns=e}async*getNextPeer(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=$q.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,l={relay:0,store:0,filter:0,lightPush:0};let u=0;const h=new Set;for(;!tz(a,l)&&u<c+t;){const e=await r();e&&e.nodeId&&!h.has(e.nodeId)&&(h.add(e.nodeId),e.waku2&&iz(e.waku2,a,l)&&(nz(e.waku2,l),yield e),ez("got new peer candidate from DNS address=".concat(e.nodeId,"@").concat(e.ip))),u++}}(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($q.ROOT_PREFIX)?$q.ROOT_PREFIX:e.startsWith($q.BRANCH_PREFIX)?$q.BRANCH_PREFIX:e.startsWith($q.RECORD_PREFIX)?$q.RECORD_PREFIX:""}(n);try{switch(s){case $q.ROOT_PREFIX:return i=$q.parseAndVerifyRoot(n,t.publicKey),await this._search(i,t);case $q.BRANCH_PREFIX:return o=$q.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 $q.RECORD_PREFIX:return XM.fromString(n);default:return null}}catch(r){return oz("Failed to search DNS tree ".concat(s," at subdomain ").concat(e,": ").concat(r)),null}}catch(r){return oz("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 az=yl("waku:peer-discovery-dns");class cz extends vT{constructor(e,t){super(),Ji(this,"nextPeer",void 0),Ji(this,"_started",void 0),Ji(this,"_components",void 0),Ji(this,"_options",void 0),this._started=!1,this._components=e,this._options=t;const{enrUrls:r}=t;az("Use following EIP-1459 ENR Tree URLs: ",r)}async start(){if(az("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 sz.dnsOverHttp();this.nextPeer=r.getNextPeer.bind(r,e,t)}for await(const r of this.nextPeer()){var e,t;if(!this._started)return;const n=r.peerInfo;if(!n)continue;const i={tags:{[kT]:{value:null!==(e=this._options.tagValue)&&void 0!==e?e:50,ttl:null!==(t=this._options.tagTTL)&&void 0!==t?t:1e8}}};let o=!1;if(await this._components.peerStore.has(n.id)){(await this._components.peerStore.get(n.id)).tags.has(kT)||(o=!0,await this._components.peerStore.merge(n.id,i))}else o=!0,await this._components.peerStore.save(n.id,i);o&&this.dispatchEvent(new ET("peer",{detail:n}))}}stop(){this._started=!1}get[AT](){return!0}get[Symbol.toStringTag](){return"@waku/bootstrap"}}function lz(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:CT;return r=>new cz(r,{enrUrls:e,wantedNodeCapabilityCount:t})}class uz{constructor(e){Ji(this,"proto",void 0),this.proto=e}static createRequest(e){const{numPeers:t}=e;return new uz({query:{numPeers:t},response:void 0})}encode(){return vd.encode(this.proto)}static decode(e){const t=vd.decode(e);return new uz(t)}get query(){return this.proto.query}get response(){return this.proto.response}}const hz="/vac/waku/peer-exchange/2.0.0-alpha1",dz=yl("waku:peer-exchange");class fz extends Af{constructor(e){super(hz,e)}async query(e){const{numPeers:t}=e,r=uz.createRequest({numPeers:BigInt(t)}),n=await this.getPeer(e.peerId),i=await this.getStream(n),o=await pf([r.encode()],$d,i,sf,(async e=>await Kd(e)));try{const e=new Jd;o.forEach((t=>{e.append(t)}));const{response:t}=uz.decode(e);return t?Promise.all(t.peerInfos.map((e=>e.enr)).filter(jf).map((async e=>({ENR:await XM.fromRLP(e)})))):void dz("PeerExchangeRPC message did not contains a `response` field")}catch(s){return void dz("Failed to decode push reply",s)}}}const pz=yl("waku:peer-exchange-discovery"),gz=1e4,bz=3,yz=cl.PEER_EXCHANGE;class mz extends vT{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Ji(this,"components",void 0),Ji(this,"peerExchange",void 0),Ji(this,"options",void 0),Ji(this,"isStarted",void 0),Ji(this,"queryingPeers",new Set),Ji(this,"queryAttempts",new Map),Ji(this,"handleDiscoveredPeer",(e=>{const{protocols:t,peerId:r}=e.detail;t.includes(hz)&&!this.queryingPeers.has(r.toString())&&(this.queryingPeers.add(r.toString()),this.startRecurringQueries(r).catch((e=>pz("Error querying peer ".concat(e)))))})),Ji(this,"startRecurringQueries",(async e=>{var t,r;const n=e.toString(),{queryInterval:i=gz,maxRetries:o=bz}=this.options;pz("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=>{pz("Error in startRecurringQueries: ".concat(e))}))}),i*s)})),this.components=e,this.peerExchange=new fz(e),this.options=t,this.isStarted=!1}start(){this.isStarted||(pz("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(pz("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[AT](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}async query(e){const t=await this.peerExchange.query({numPeers:10,peerId:e});if(t)for(const i of t){var r,n;const{ENR:e}=i;if(!e){pz("No ENR in peerInfo object, skipping");continue}const{peerId:t,peerInfo:o}=e;if(!t||!o)continue;await this.components.peerStore.has(t)||(await this.components.peerStore.save(t,{tags:{[yz]:{value:null!==(r=this.options.tagValue)&&void 0!==r?r:50,ttl:null!==(n=this.options.tagTTL)&&void 0!==n?n:1e8}}}),pz("Discovered peer: ".concat(t.toString())),this.dispatchEvent(new ET("peer",{detail:{id:t,protocols:[],multiaddrs:o.multiaddrs}})))}else pz("Peer exchange query failed, no peer info returned")}abortQueriesForPeer(e){pz("Aborting queries for peer: ".concat(e)),this.queryingPeers.delete(e),this.queryAttempts.delete(e)}}const wz="StrictSign",vz="StrictNoSign";var _z;!function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"}(_z||(_z={}));var Ez=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Sz=Ez,Az=(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 xz{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 kz{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 Iz(this,e)}}class Cz{constructor(e){this.decoders=e}or(e){return Iz(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 Iz=(e,t)=>new Cz({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Tz{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new xz(e,t,r),this.decoder=new kz(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Pz=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new Tz(t,r,n,i)},Rz=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=Sz(n,r);return Pz({prefix:t,name:r,encode:i,decode:e=>Az(o(e))})},Dz=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Pz({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},Nz=Dz({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Bz=Dz({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lz=Dz({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Uz=Dz({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Mz=Dz({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Oz=Dz({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qz=Dz({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zz=Dz({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Fz=Dz({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Kz=Rz({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vz=Rz({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),jz=Dz({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Hz=Dz({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Wz=Dz({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gz=Dz({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Yz(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}yl.formatters.b=e=>null==e?"undefined":Kz.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":Nz.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":jz.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();const Qz=Rz({prefix:"9",name:"base10",alphabet:"0123456789"}),Jz=Dz({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Xz=Dz({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Zz=Dz({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$z=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"),eF=$z.reduce(((e,t,r)=>(e[r]=t,e)),[]),tF=$z.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const rF=Pz({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=eF[t]),"")},decode:function(e){const t=[];for(const r of e){const e=tF[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),nF=Rz({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),iF=Rz({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),oF=Dz({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),sF=Pz({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),aF=new TextEncoder,cF=new TextDecoder,lF="json",uF=512,hF=e=>aF.encode(JSON.stringify(e)),dF=e=>JSON.parse(cF.decode(e)),fF="raw",pF=85,gF=e=>Az(e),bF=e=>Az(e);var yF=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=vF;)r[n++]=255&t|mF,t/=128;for(;t&wF;)r[n++]=255&t|mF,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},mF=128,wF=-128,vF=Math.pow(2,31);var _F=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&SF)<<o:(n&SF)*Math.pow(2,o),o+=7}while(n>=EF);return e.bytes=s-r,i},EF=128,SF=127;var AF=Math.pow(2,7),xF=Math.pow(2,14),kF=Math.pow(2,21),CF=Math.pow(2,28),IF=Math.pow(2,35),TF=Math.pow(2,42),PF=Math.pow(2,49),RF=Math.pow(2,56),DF=Math.pow(2,63);const NF={encode:yF,decode:_F,encodingLength:function(e){return e<AF?1:e<xF?2:e<kF?3:e<CF?4:e<IF?5:e<TF?6:e<PF?7:e<RF?8:e<DF?9:10}},BF=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[NF.decode(e,t),NF.decode.bytes]},LF=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return NF.encode(e,t,r),t},UF=e=>NF.encodingLength(e),MF=(e,t)=>{const r=t.byteLength,n=UF(e),i=n+UF(r),o=new Uint8Array(i+r);return LF(e,o,0),LF(r,o,n),o.set(t,i),new qF(e,r,t,o)},OF=e=>{const t=Az(e),[r,n]=BF(t),[i,o]=BF(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new qF(r,i,s,t)};class qF{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const zF=Az,FF={code:0,name:"identity",encode:zF,digest:e=>MF(0,zF(e))},KF=e=>{let{name:t,code:r,encode:n}=e;return new VF(t,r,n)};class VF{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?MF(this.code,t):t.then((e=>MF(this.code,e)))}throw Error("Unknown type, must be binary type")}}const jF=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),HF=KF({name:"sha2-256",code:18,encode:jF("SHA-256")}),WF=KF({name:"sha2-512",code:19,encode:jF("SHA-512")}),GF=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?ZF(r,QF(e),t||Kz.encoder):$F(r,QF(e),t||Nz.encoder)},YF=new WeakMap,QF=e=>{const t=YF.get(e);if(null==t){const t=new Map;return YF.set(e,t),t}return t};class JF{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!==eK)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==tK)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return JF.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=MF(e,t);return JF.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 JF.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 GF(this,e)}toJSON(){return{"/":GF(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 JF)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new JF(e,r,n,i||rK(e,r,n.bytes))}if(!0===t[nK]){const{version:e,multihash:r,code:n}=t,i=OF(r);return JF.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!==eK)throw new Error("Version 0 CID must use dag-pb (code: ".concat(eK,") block encoding"));return new JF(e,t,r,r.bytes);case 1:{const n=rK(e,t,r.bytes);return new JF(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return JF.create(0,eK,e)}static createV1(e,t){return JF.create(1,e,t)}static decode(e){const[t,r]=JF.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=JF.inspectBytes(e),r=t.size-t.multihashSize,n=Az(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 qF(t.multihashCode,t.digestSize,i,n);return[0===t.version?JF.createV0(o):JF.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=BF(e.subarray(t));return t+=n,r};let n=r(),i=eK;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]=XF(e,t),i=JF.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return QF(i).set(r,e),i}}const XF=(e,t)=>{switch(e[0]){case"Q":{const r=t||Kz;return[Kz.prefix,r.decode("".concat(Kz.prefix).concat(e))]}case Kz.prefix:{const r=t||Kz;return[Kz.prefix,r.decode(e)]}case Nz.prefix:{const r=t||Nz;return[Nz.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)]}},ZF=(e,t,r)=>{const{prefix:n}=r;if(n!==Kz.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},$F=(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},eK=112,tK=18,rK=(e,t,r)=>{const n=UF(e),i=n+UF(t),o=new Uint8Array(i+r.byteLength);return LF(e,o,0),LF(t,o,n),o.set(r,i),o},nK=Symbol.for("@ipld/js-cid/CID"),iK={...Bt,...Pt,...Nt,...It,...Tt,...xt,...Dt,...kt,...Ct,...Rt},oK=Symbol.for("nodejs.util.inspect.custom"),sK=Object.values(iK).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),iK.identity.decoder),aK=114,cK=36,lK=37;class uK{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=Kz.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return JF.createV1(aK,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return pK(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[oK](){return"PeerId(".concat(this.toString(),")")}}class hK extends uK{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class dK extends uK{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class fK extends uK{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function pK(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:sK,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=OF(Kz.decode("z".concat(e)));return e.startsWith("12D")?new dK({multihash:t}):e.startsWith("16U")?new fK({multihash:t}):new hK({multihash:t})}return gK(sK.decode(e))}function gK(e){try{const t=OF(e);if(t.code===FF.code){if(t.digest.length===cK)return new dK({multihash:t});if(t.digest.length===lK)return new fK({multihash:t})}if(t.code===HF.code)return new hK({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==aK)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===HF.code)return new hK({multihash:e.multihash});if(t.code===FF.code){if(t.digest.length===cK)return new dK({multihash:e.multihash});if(t.digest.length===lK)return new fK({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(JF.decode(e))}throw new Error("Supplied PeerID CID is invalid")}const bK="/floodsub/1.0.0",yK="/meshsub/1.0.0",mK="/meshsub/1.1.0",wK=5e3;var vK=__webpack_require__(1099);const _K={maxSubscriptions:1/0,maxMessages:1/0,maxIhaveMessageIDs:1/0,maxIwantMessageIDs:1/0,maxControlMessages:1/0,maxPeerInfos:1/0};function EK(e,t){t={...t};const r=vK.Reader.create(e),n=e.length,i=void 0===n?r.len:r.pos+n,o={};for(;r.pos<i;){const e=r.uint32();switch(e>>>3){case 1:null!=o.subscriptions&&o.subscriptions.length>0||(o.subscriptions=[]),o.subscriptions.length<t.maxSubscriptions?o.subscriptions.push(SK(r,r.uint32())):r.skipType(7&e);break;case 2:null!=o.messages&&o.messages.length>0||(o.messages=[]),o.messages.length<t.maxMessages?o.messages.push(AK(r,r.uint32())):r.skipType(7&e);break;case 3:o.control=xK(r,r.uint32(),t);break;default:r.skipType(7&e)}}return o}function SK(e,t){const r=void 0===t?e.len:e.pos+t,n={};for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.subscribe=e.bool();break;case 2:n.topic=e.string();break;default:e.skipType(7&t)}}return n}function AK(e,t){const r=void 0===t?e.len:e.pos+t,n={};for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.from=e.bytes();break;case 2:n.data=e.bytes();break;case 3:n.seqno=e.bytes();break;case 4:n.topic=e.string();break;case 5:n.signature=e.bytes();break;case 6:n.key=e.bytes();break;default:e.skipType(7&t)}}if(!n.topic)throw Error("missing required 'topic'");return n}function xK(e,t,r){const n=void 0===t?e.len:e.pos+t,i={};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:null!=i.ihave&&i.ihave.length>0||(i.ihave=[]),i.ihave.length<r.maxControlMessages?i.ihave.push(kK(e,e.uint32(),r)):e.skipType(7&t);break;case 2:null!=i.iwant&&i.iwant.length>0||(i.iwant=[]),i.iwant.length<r.maxControlMessages?i.iwant.push(CK(e,e.uint32(),r)):e.skipType(7&t);break;case 3:null!=i.graft&&i.graft.length>0||(i.graft=[]),i.graft.length<r.maxControlMessages?i.graft.push(IK(e,e.uint32())):e.skipType(7&t);break;case 4:null!=i.prune&&i.prune.length>0||(i.prune=[]),i.prune.length<r.maxControlMessages?i.prune.push(TK(e,e.uint32(),r)):e.skipType(7&t);break;default:e.skipType(7&t)}}return i}function kK(e,t,r){const n=void 0===t?e.len:e.pos+t,i={};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:i.topicID=e.string();break;case 2:null!=i.messageIDs&&i.messageIDs.length>0||(i.messageIDs=[]),r.maxIhaveMessageIDs-- >0?i.messageIDs.push(e.bytes()):e.skipType(7&t);break;default:e.skipType(7&t)}}return i}function CK(e,t,r){const n=void 0===t?e.len:e.pos+t,i={};for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)null!=i.messageIDs&&i.messageIDs.length>0||(i.messageIDs=[]),r.maxIwantMessageIDs-- >0?i.messageIDs.push(e.bytes()):e.skipType(7&t);else e.skipType(7&t)}return i}function IK(e,t){const r=void 0===t?e.len:e.pos+t,n={};for(;e.pos<r;){const t=e.uint32();if(t>>>3===1)n.topicID=e.string();else e.skipType(7&t)}return n}function TK(e,t,r){const n=void 0===t?e.len:e.pos+t,i={};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:i.topicID=e.string();break;case 2:null!=i.peers&&i.peers.length>0||(i.peers=[]),r.maxPeerInfos-- >0?i.peers.push(PK(e,e.uint32())):e.skipType(7&t);break;case 3:i.backoff=e.uint64();break;default:e.skipType(7&t)}}return i}function PK(e,t){const r=void 0===t?e.len:e.pos+t,n={};for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.peerID=e.bytes();break;case 2:n.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return n}const RK=__webpack_require__.p+"static/media/rpc.3ba5ca7bdb004060d5e2.cjs",{RPC:DK}=RK;class NK{constructor(e,t,r){Ji(this,"gossip",void 0),Ji(this,"msgs",new Map),Ji(this,"msgIdToStrFn",void 0),Ji(this,"history",[]),Ji(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)}}var BK,LK,UK,MK,OK,qK,zK,FK,KK,VK,jK;function HK(e){switch(e){case _z.Ignore:return UK.Ignore;case _z.Reject:return UK.Reject;default:throw new Error("Unreachable")}}!function(e){e.StrictSign="StrictSign",e.StrictNoSign="StrictNoSign"}(BK||(BK={})),function(e){e[e.Signing=0]="Signing",e[e.Anonymous=1]="Anonymous"}(LK||(LK={})),function(e){e.Error="error",e.Ignore="ignore",e.Reject="reject",e.Blacklisted="blacklisted"}(UK||(UK={})),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"}(MK||(MK={})),function(e){e.duplicate="duplicate",e.invalid="invalid",e.valid="valid"}(OK||(OK={})),function(e){e.forward="forward",e.publish="publish"}(qK||(qK={})),function(e){e.Fanout="fanout",e.Random="random",e.Subscribed="subscribed",e.Outbound="outbound",e.NotEnough="not_enough",e.Opportunistic="opportunistic"}(zK||(zK={})),function(e){e.Dc="disconnected",e.BadScore="bad_score",e.Prune="prune",e.Excess="excess"}(FK||(FK={})),function(e){e.GraftBackoff="graft_backoff",e.BrokenPromise="broken_promise",e.MessageDeficit="message_deficit",e.IPColocation="IP_colocation"}(KK||(KK={})),function(e){e.LowScore="low_score",e.MaxIhave="max_ihave",e.MaxIasked="max_iasked"}(VK||(VK={})),function(e){e.graylist="graylist",e.publish="publish",e.gossip="gossip",e.mesh="mesh"}(jK||(jK={}));const WK="ERR_INVALID_PEER_SCORE_PARAMS",GK={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},YK={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 QK(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{...GK,...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{...YK,...e}}(n),e}),{}):{}}}function JK(e){if(e.topicWeight<0)throw new ly("invalid topic weight; must be >= 0",WK);if(0===e.timeInMeshQuantum)throw new ly("invalid TimeInMeshQuantum; must be non zero",WK);if(e.timeInMeshWeight<0)throw new ly("invalid TimeInMeshWeight; must be positive (or 0 to disable)",WK);if(0!==e.timeInMeshWeight&&e.timeInMeshQuantum<=0)throw new ly("invalid TimeInMeshQuantum; must be positive",WK);if(0!==e.timeInMeshWeight&&e.timeInMeshCap<=0)throw new ly("invalid TimeInMeshCap; must be positive",WK);if(e.firstMessageDeliveriesWeight<0)throw new ly("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)",WK);if(0!==e.firstMessageDeliveriesWeight&&(e.firstMessageDeliveriesDecay<=0||e.firstMessageDeliveriesDecay>=1))throw new ly("invalid FirstMessageDeliveriesDecay; must be between 0 and 1",WK);if(0!==e.firstMessageDeliveriesWeight&&e.firstMessageDeliveriesCap<=0)throw new ly("invalid FirstMessageDeliveriesCap; must be positive",WK);if(e.meshMessageDeliveriesWeight>0)throw new ly("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)",WK);if(0!==e.meshMessageDeliveriesWeight&&(e.meshMessageDeliveriesDecay<=0||e.meshMessageDeliveriesDecay>=1))throw new ly("invalid MeshMessageDeliveriesDecay; must be between 0 and 1",WK);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesCap<=0)throw new ly("invalid MeshMessageDeliveriesCap; must be positive",WK);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesThreshold<=0)throw new ly("invalid MeshMessageDeliveriesThreshold; must be positive",WK);if(e.meshMessageDeliveriesWindow<0)throw new ly("invalid MeshMessageDeliveriesWindow; must be non-negative",WK);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesActivation<1e3)throw new ly("invalid MeshMessageDeliveriesActivation; must be at least 1s",WK);if(e.meshFailurePenaltyWeight>0)throw new ly("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)",WK);if(0!==e.meshFailurePenaltyWeight&&(e.meshFailurePenaltyDecay<=0||e.meshFailurePenaltyDecay>=1))throw new ly("invalid MeshFailurePenaltyDecay; must be between 0 and 1",WK);if(e.invalidMessageDeliveriesWeight>0)throw new ly("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)",WK);if(e.invalidMessageDeliveriesDecay<=0||e.invalidMessageDeliveriesDecay>=1)throw new ly("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1",WK)}const XK={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function ZK(){return{...XK,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}function $K(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 eV extends Map{constructor(e){super(),Ji(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 tV(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 rV,nV=__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"}(rV||(rV={}));class iV{constructor(){Ji(this,"records",void 0),Ji(this,"queue",void 0),this.records=new Map,this.queue=new nV}getRecord(e){return this.records.get(e)}ensureRecord(e){let t=this.records.get(e);if(null!=t)return t;t={status:rV.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()}}const oV=Yz("libp2p:gossipsub:score");class sV{constructor(e,t,r){var n;Ji(this,"params",void 0),Ji(this,"metrics",void 0),Ji(this,"peerStats",new Map),Ji(this,"peerIPs",new eV((()=>new Set))),Ji(this,"scoreCache",new Map),Ji(this,"deliveryRecords",new iV),Ji(this,"_backgroundInterval",void 0),Ji(this,"scoreCacheValidityMs",void 0),Ji(this,"computeScore",void 0),this.params=e,this.metrics=t,function(e){for(const[r,n]of Object.entries(e.topics))try{JK(n)}catch(t){throw new ly("invalid score parameters for topic ".concat(r,": ").concat(t.message),WK)}if(e.topicScoreCap<0)throw new ly("invalid topic score cap; must be positive (or 0 for no cap)",WK);if(null===e.appSpecificScore||void 0===e.appSpecificScore)throw new ly("missing application specific score function",WK);if(e.IPColocationFactorWeight>0)throw new ly("invalid IPColocationFactorWeight; must be negative (or 0 to disable)",WK);if(0!==e.IPColocationFactorWeight&&e.IPColocationFactorThreshold<1)throw new ly("invalid IPColocationFactorThreshold; must be at least 1",WK);if(e.behaviourPenaltyWeight>0)throw new ly("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)",WK);if(0!==e.behaviourPenaltyWeight&&(e.behaviourPenaltyDecay<=0||e.behaviourPenaltyDecay>=1))throw new ly("invalid BehaviourPenaltyDecay; must be between 0 and 1",WK);if(e.decayInterval<1e3)throw new ly("invalid DecayInterval; must be at least 1s",WK);if(e.decayToZero<=0||e.decayToZero>=1)throw new ly("invalid DecayToZero; must be between 0 and 1",WK)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=null!==(n=r.computeScore)&&void 0!==n?n:tV}get size(){return this.peerStats.size}start(){null==this._backgroundInterval?(this._backgroundInterval=setInterval((()=>{this.background()}),this.params.decayInterval),oV("started")):oV("Peer score already running")}stop(){null!=this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),oV("stopped")):oV("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===rV.unknown?(n.status=rV.valid,n.validated=i,n.peers.forEach((t=>{t!==e.toString()&&this.markDuplicateMessageDelivery(t,r)}))):oV("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,i-n.firstSeenTsMs,rV[n.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,n){switch(n){case UK.Error:return void this.markInvalidMessageDelivery(e,r);case UK.Blacklisted:return}const i=this.deliveryRecords.ensureRecord(t);if(i.status===rV.unknown){if(n===UK.Ignore)return i.status=rV.ignored,void i.peers.clear();i.status=rV.invalid,this.markInvalidMessageDelivery(e,r),i.peers.forEach((e=>{this.markInvalidMessageDelivery(e,r)})),i.peers.clear()}else oV("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-i.firstSeenTsMs,rV[i.status])}duplicateMessage(e,t,r){const n=this.deliveryRecords.ensureRecord(t);if(!n.peers.has(e))switch(n.status){case rV.unknown:n.peers.add(e);break;case rV.valid:n.peers.add(e),this.markDuplicateMessageDelivery(e,r,n.validated);break;case rV.invalid:this.markInvalidMessageDelivery(e,r);case rV.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 aV(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",l=r.topics[n];if(void 0===l)return;let u=s.get(c);null==u&&(u={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},s.set(c,u));let h=0,d=0,f=0,p=0,g=0;if(a.inMesh){h+=Math.max(a.meshTime/l.timeInMeshQuantum,l.timeInMeshCap)*l.timeInMeshWeight}let b=a.firstMessageDeliveries;if(b>l.firstMessageDeliveriesCap&&(b=l.firstMessageDeliveriesCap),d+=b*l.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries<l.meshMessageDeliveriesThreshold){const e=l.meshMessageDeliveriesThreshold-a.meshMessageDeliveries;f+=e*e*l.meshMessageDeliveriesWeight}p+=a.meshFailurePenalty*l.meshFailurePenaltyWeight;g+=a.invalidMessageDeliveries*a.invalidMessageDeliveries*l.invalidMessageDeliveriesWeight,o+=(h+d+f+p+g)*l.topicWeight,u.p1w+=h,u.p2w+=d,u.p3w+=f,u.p3bw+=p,u.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,l=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 l+=t.behaviourPenalty*t.behaviourPenalty*r.behaviourPenaltyWeight,o+=a+c+l,{byTopic:s,p5w:a,p6w:c,p7w:l,score:o}}class cV{constructor(e,t,r){var n;Ji(this,"rawStream",void 0),Ji(this,"pushable",void 0),Ji(this,"closeController",void 0),Ji(this,"maxBufferSize",void 0),this.rawStream=e,this.pushable=hf({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=null!==(n=r.maxBufferSize)&&void 0!==n?n:1/0,pf($x(this.pushable,this.closeController.signal,{returnOnAbort:!0}),(e=>$d(e)),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(e)}async close(){this.closeController.abort(),await this.pushable.return(),await this.rawStream.close()}}class lV{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ji(this,"source",void 0),Ji(this,"rawStream",void 0),Ji(this,"closeController",void 0),this.rawStream=e,this.closeController=new AbortController,this.source=$x(pf(this.rawStream,(e=>sf(e,t))),this.closeController.signal,{returnOnAbort:!0})}async close(){this.closeController.abort(),await this.rawStream.close()}}class uV{constructor(e,t,r){Ji(this,"gossipsubIWantFollowupMs",void 0),Ji(this,"msgIdToStrFn",void 0),Ji(this,"metrics",void 0),Ji(this,"promises",new Map),Ji(this,"requestMsByMsg",new Map),Ji(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!==UK.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))}}}__webpack_require__(9353);var hV=__webpack_require__(8009);const dV={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function fV(e,t,r,n,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const e=Object.keys(dV).join(" / ");throw new ly("Hash '".concat(i,"' is unknown or not supported. Must be ").concat(e),"ERR_UNSUPPORTED_HASH_TYPE")}const o=hV(e,t,r,n,dV[i]);return kv.encode64(o,null)}const pV=kc("libp2p-pubsub:");function gV(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}function bV(e){return za(e,"base64")}var yV=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const mV=yV,wV=(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 vV{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 _V{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 SV(this,e)}}class EV{constructor(e){this.decoders=e}or(e){return SV(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 SV=(e,t)=>new EV({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class AV{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new vV(e,t,r),this.decoder=new _V(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const xV=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new AV(t,r,n,i)},kV=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=mV(n,r);return xV({prefix:t,name:r,encode:i,decode:e=>wV(o(e))})},CV=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return xV({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},IV=kV({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),TV=kV({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),PV=kV({prefix:"9",name:"base10",alphabet:"0123456789"}),RV=CV({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),DV=CV({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),NV=CV({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),BV=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"),LV=BV.reduce(((e,t,r)=>(e[r]=t,e)),[]),UV=BV.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const MV=xV({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=LV[t]),"")},decode:function(e){const t=[];for(const r of e){const e=UV[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),OV=CV({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qV=CV({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zV=CV({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),FV=CV({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),KV=CV({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),VV=CV({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),jV=CV({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),HV=CV({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),WV=CV({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),GV=kV({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),YV=kV({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),QV=CV({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),JV=CV({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),XV=CV({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ZV=CV({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),$V=CV({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),ej=xV({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),tj=new TextEncoder,rj=new TextDecoder,nj="json",ij=512,oj=e=>tj.encode(JSON.stringify(e)),sj=e=>JSON.parse(rj.decode(e)),aj="raw",cj=85,lj=e=>wV(e),uj=e=>wV(e);var hj=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=pj;)r[n++]=255&t|dj,t/=128;for(;t&fj;)r[n++]=255&t|dj,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},dj=128,fj=-128,pj=Math.pow(2,31);var gj=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&yj)<<o:(n&yj)*Math.pow(2,o),o+=7}while(n>=bj);return e.bytes=s-r,i},bj=128,yj=127;var mj=Math.pow(2,7),wj=Math.pow(2,14),vj=Math.pow(2,21),_j=Math.pow(2,28),Ej=Math.pow(2,35),Sj=Math.pow(2,42),Aj=Math.pow(2,49),xj=Math.pow(2,56),kj=Math.pow(2,63);const Cj={encode:hj,decode:gj,encodingLength:function(e){return e<mj?1:e<wj?2:e<vj?3:e<_j?4:e<Ej?5:e<Sj?6:e<Aj?7:e<xj?8:e<kj?9:10}},Ij=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Cj.encode(e,t,r),t},Tj=e=>Cj.encodingLength(e),Pj=(e,t)=>{const r=t.byteLength,n=Tj(e),i=n+Tj(r),o=new Uint8Array(i+r);return Ij(e,o,0),Ij(r,o,n),o.set(t,i),new Rj(e,r,t,o)};class Rj{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Dj=wV,Nj={code:0,name:"identity",encode:Dj,digest:e=>Pj(0,Dj(e))},Bj=e=>{let{name:t,code:r,encode:n}=e;return new Lj(t,r,n)};class Lj{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?Pj(this.code,t):t.then((e=>Pj(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Uj=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Mj=Bj({name:"sha2-256",code:18,encode:Uj("SHA-256")}),Oj=Bj({name:"sha2-512",code:19,encode:Uj("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const qj={...Yt,...Kt,...Gt,...zt,...Ft,...jt,...Ht,...qt,...Wt,...Vt},zj=Symbol.for("nodejs.util.inspect.custom");Object.values(qj).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),qj.identity.decoder);Symbol.toStringTag;function Fj(e){if("signed"!==e.type)throw new Error("expected signed message type");if(null==e.sequenceNumber)throw Error("missing seqno field");return((e,t)=>{const r=kc(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})(e.from.toBytes(),e.sequenceNumber)}async function Kj(e){return HF.encode(e.data)}var Vj;!function(e){e[e.ip4=4]="ip4",e[e.ip6=41]="ip6"}(Vj||(Vj={}));class jj{constructor(e){Ji(this,"entries",new Map),Ji(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 Hj;!function(e){e[e.started=0]="started",e[e.stopped=1]="stopped"}(Hj||(Hj={}));class Wj extends vT{constructor(e){var t,r,n,i,o;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Ji(this,"globalSignaturePolicy",void 0),Ji(this,"multicodecs",[mK,yK]),Ji(this,"publishConfig",void 0),Ji(this,"dataTransform",void 0),Ji(this,"peers",new Set),Ji(this,"streamsInbound",new Map),Ji(this,"streamsOutbound",new Map),Ji(this,"outboundInflightQueue",hf({objectMode:!0})),Ji(this,"direct",new Set),Ji(this,"floodsubPeers",new Set),Ji(this,"seenCache",void 0),Ji(this,"acceptFromWhitelist",new Map),Ji(this,"topics",new Map),Ji(this,"subscriptions",new Set),Ji(this,"mesh",new Map),Ji(this,"fanout",new Map),Ji(this,"fanoutLastpub",new Map),Ji(this,"gossip",new Map),Ji(this,"control",new Map),Ji(this,"peerhave",new Map),Ji(this,"iasked",new Map),Ji(this,"backoff",new Map),Ji(this,"outbound",new Map),Ji(this,"msgIdFn",void 0),Ji(this,"fastMsgIdFn",void 0),Ji(this,"msgIdToStrFn",void 0),Ji(this,"fastMsgIdCache",void 0),Ji(this,"publishedMessageIds",void 0),Ji(this,"mcache",void 0),Ji(this,"score",void 0),Ji(this,"topicValidators",new Map),Ji(this,"log",void 0),Ji(this,"heartbeatTicks",0),Ji(this,"gossipTracer",void 0),Ji(this,"components",void 0),Ji(this,"directPeerInitial",null),Ji(this,"opts",void 0),Ji(this,"decodeRpcLimits",void 0),Ji(this,"metrics",void 0),Ji(this,"status",{code:Hj.stopped}),Ji(this,"maxInboundStreams",void 0),Ji(this,"maxOutboundStreams",void 0),Ji(this,"allowedTopics",void 0),Ji(this,"heartbeatTimer",null),Ji(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===Hj.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,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:QK(s.scoreParams),scoreThresholds:ZK(s.scoreThresholds)};if(this.components=e,this.decodeRpcLimits=null!==(t=a.decodeRpcLimits)&&void 0!==t?t:_K,this.globalSignaturePolicy=null!==(r=a.globalSignaturePolicy)&&void 0!==r?r:wz,a.fallbackToFloodsub&&this.multicodecs.push(bK),this.log=Yz(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 jj({validityMs:a.seenTTL}),this.publishedMessageIds=new jj({validityMs:a.seenTTL}),null!=s.msgIdFn)this.msgIdFn=s.msgIdFn;else switch(this.globalSignaturePolicy){case wz:this.msgIdFn=Fj;break;case vz:this.msgIdFn=Kj;break;default:throw new Error("Invalid globalSignaturePolicy: ".concat(this.globalSignaturePolicy))}if(null!=s.fastMsgIdFn&&(this.fastMsgIdFn=s.fastMsgIdFn,this.fastMsgIdCache=new jj({validityMs:a.seenTTL})),this.msgIdToStrFn=null!==(i=s.msgIdToStrFn)&&void 0!==i?i:bV,this.mcache=null!==(o=s.messageCache)&&void 0!==o?o:new NK(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",labelNames:["topic"],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 zK.Fanout:this.meshPeerInclusionEventsFanout.inc({topic:n},r);break;case zK.Random:this.meshPeerInclusionEventsRandom.inc({topic:n},r);break;case zK.Subscribed:this.meshPeerInclusionEventsSubscribed.inc({topic:n},r);break;case zK.Outbound:this.meshPeerInclusionEventsOutbound.inc({topic:n},r);break;case zK.NotEnough:this.meshPeerInclusionEventsNotEnough.inc({topic:n},r);break;case zK.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 FK.Dc:this.meshPeerChurnEventsDisconnected.inc({topic:n},r);break;case FK.BadScore:this.meshPeerChurnEventsBadScore.inc({topic:n},r);break;case FK.Prune:this.meshPeerChurnEventsPrune.inc({topic:n},r);break;case FK.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 _z.Accept:this.acceptedMessagesTotal.inc({topic:r});break;case _z.Ignore:this.ignoredMessagesTotal.inc({topic:r});break;case _z.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 OK.duplicate:this.prevalidationDuplicateTotal.inc({topic:r});break;case OK.invalid:this.prevalidationInvalidTotal.inc({topic:r});break;case OK.valid:this.prevalidationValidTotal.inc({topic:r});break;default:this.prevalidationUnknownTotal.inc({topic:r})}},onMsgRecvInvalid(e,t){const r=this.toTopic(e),n=t.reason===UK.Error?t.error:t.reason;this.msgReceivedInvalid.inc({error:n},1),this.msgReceivedInvalidByTopic.inc({topic:r},1)},onDuplicateMsgDelivery(e,t,r){if(this.duplicateMsgDeliveryDelay.observe(t/1e3),r){const t=this.toTopic(e);this.duplicateMsgLateDelivery.inc({topic:t},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,l;const t=null!==(r=null===(n=e.control.ihave)||void 0===n?void 0:n.length)&&void 0!==r?r:0,u=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===(l=e.control.prune)||void 0===l?void 0:l.length)&&void 0!==c?c:0;t>0&&this.rpcSentIHave.inc(t),u>0&&this.rpcSentIWant.inc(u),h>0&&this.rpcSentGraft.inc(h),d>0&&this.rpcSentPrune.inc(d),(t>0||u>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:jK.graylist},r),this.peersByScoreThreshold.set({threshold:jK.publish},n),this.peersByScoreThreshold.set({threshold:jK.gossip},i),this.peersByScoreThreshold.set({threshold:jK.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 uV(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new sV(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:a.heartbeatInterval}),this.maxInboundStreams=s.maxInboundStreams,this.maxOutboundStreams=s.maxOutboundStreams,this.allowedTopics=null!=a.allowedTopics?new Set(a.allowedTopics):null}getPeers(){return[...this.peers.keys()].map((e=>pK(e)))}isStarted(){return this.status.code===Hj.started}async start(){if(this.isStarted())return;this.log("starting"),this.publishConfig=await async function(e,t){switch(e){case wz:{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 w_(t.privateKey);return{type:LK.Signing,author:t,key:t.publicKey,privateKey:e}}case vz:return{type:LK.Anonymous};default:throw new Error('Unknown signature policy "'.concat(e,'"'))}}(this.globalSignaturePolicy,this.components.peerId),this.outboundInflightQueue=hf({objectMode:!0}),pf(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}))));const t={onConnect:this.onPeerConnected.bind(this),onDisconnect:this.onPeerDisconnected.bind(this)},r=await Promise.all(this.multicodecs.map((async r=>e.register(r,t)))),n=setTimeout(this.runHeartbeat,100);this.status={code:Hj.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!==Hj.started)return;const{registrarTopologyIds:e}=this.status;this.status={code:Hj.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 cV(await t.newStream(this.multicodecs),(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===bK&&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 lV(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 Vj.ip4:case Vj.ip6:return Oc(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,FK.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===Hj.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=>pK(e)))}getTopics(){return Array.from(this.subscriptions)}async pipePeerReadStream(e,t){try{await pf(t,(async t=>{for await(const a of t)try{var r;const t=a.subarray(),i=EK(t,this.decodeRpcLimits);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}})}if(null!=t.messages)for(const l of t.messages){if(null!=this.allowedTopics&&!this.allowedTopics.has(l.topic))continue;const t=this.handleReceivedMessage(e,l).catch((e=>{var t;null===(t=this.metrics)||void 0===t||t.onMsgRecvError(l.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 OK.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 OK.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 OK.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 ET("gossipsub:message",{detail:{propagationSource:e,msgId:o.messageId.msgIdStr,msg:o.msg}})),super.dispatchEvent(new ET("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:OK.duplicate,msgIdStr:o};const s=await async function(e,t){var r;switch(e){case vz:return null!=t.signature?{valid:!1,error:MK.SignaturePresent}:null!=t.seqno?{valid:!1,error:MK.SeqnoPresent}:null!=t.key?{valid:!1,error:MK.FromPresent}:{valid:!0,message:{type:"unsigned",topic:t.topic,data:null!==(r=t.data)&&void 0!==r?r:new Uint8Array(0)}};case wz:{var n,i;if(null==t.seqno)return{valid:!1,error:MK.InvalidSeqno};if(8!==t.seqno.length)return{valid:!1,error:MK.InvalidSeqno};if(null==t.signature)return{valid:!1,error:MK.InvalidSignature};if(null==t.from)return{valid:!1,error:MK.InvalidPeerId};let e,r;try{e=gK(t.from)}catch(o){return{valid:!1,error:MK.InvalidPeerId}}if(null!=t.key){if(r=y_(t.key),void 0!==e.publicKey&&!ls(r.bytes,e.publicKey))return{valid:!1,error:MK.InvalidPeerId}}else{if(null==e.publicKey)return{valid:!1,error:MK.InvalidPeerId};r=y_(e.publicKey)}const s={from:t.from,data:t.data,seqno:t.seqno,topic:t.topic,signature:void 0,key:void 0},a=Fa([pV,DK.Message.encode(s).finish()]);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(za(t.seqno,"base16"))),topic:t.topic,signature:t.signature,key:null!==(i=t.key)&&void 0!==i?i:m_(r)}}:{valid:!1,error:MK.InvalidSignature}}default:throw new Error("Unreachable")}}(this.globalSignaturePolicy,t);if(!s.valid)return{code:OK.invalid,reason:UK.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:OK.invalid,reason:UK.Error,error:MK.TransformFailed}}const c=await this.msgIdFn(a),l=this.msgIdToStrFn(c),u={msgId:c,msgIdStr:l};if(void 0!==i&&null!=this.fastMsgIdCache){var h;if(this.fastMsgIdCache.put(i,l))null===(h=this.metrics)||void 0===h||h.fastMsgIdCacheCollision.inc()}if(this.seenCache.has(l))return{code:OK.duplicate,msgIdStr:l};this.seenCache.put(l);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=_z.Ignore),t="ERR_TOPIC_VALIDATOR_REJECT"===e?_z.Reject:_z.Ignore}if(t!==_z.Accept)return{code:OK.invalid,reason:HK(t),msgIdStr:l}}return{code:OK.valid,messageId:u,msg:a}}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map((e=>({topic:e,subscribe:r})))})}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,{messages:i,control:{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:VK.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:VK.MaxIhave}),[];const c=null!==(n=this.iasked.get(e))&&void 0!==n?n:0;var l;if(c>=wK)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,c),null===(l=this.metrics)||void 0===l||l.ihaveRcvIgnored.inc({reason:VK.MaxIasked}),[];const u=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)||(u.set(t,e),i++)})),null===(t=this.metrics)||void 0===t||t.onIhaveRcv(r,n.length,i)})),0===u.size)return[];let h=u.size;h+c>wK&&(h=wK-c),this.log("IHAVE: Asking for %d out of %d messages from %s",h,u.size,e);let d=Array.from(u.values());return gV(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:l}=t;if(null==l)return;const u=this.mesh.get(l);if(null==u)return void(o=!1);if(u.has(e))return;if(this.direct.has(e))return this.log("GRAFT: ignoring request from direct peer %s",e),r.push(l),void(o=!1);const h=null===(s=this.backoff.get(l))||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,KK.GraftBackoff),o=!1;const t=h+this.opts.graftFloodThreshold-this.opts.pruneBackoff;return i<t&&this.score.addPenalty(e,1,KK.GraftBackoff),this.addBackoff(e,l),void r.push(l)}return n<0?(this.log("GRAFT: ignoring peer %s with negative score: score=%d, topic=%s",e,n,l),r.push(l),o=!1,void this.addBackoff(e,l)):u.size>=this.opts.Dhi&&(null===(a=this.outbound.get(e))||void 0===a||!a)?(r.push(l),void this.addBackoff(e,l)):(this.log("GRAFT: Add mesh link from %s in %s",e,l),this.score.graft(e,l),u.add(e),void(null===(c=this.metrics)||void 0===c||c.onAddToMesh(l,zK.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,FK.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,KK.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&&(gV(e),e=e.slice(0,this.opts.prunePeers));const t=[];await Promise.all(e.map((async e=>{if(null==e.peerID)return;const r=gK(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=pK(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!==Hj.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!==Hj.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!==Hj.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,zK.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,zK.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!==Hj.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,{messages:[t]})})),null===(i=this.metrics)||void 0===i||i.onForwardMsg(t.topic,o.size)}async publish(e,t,r){var n,i,o;const s=Date.now(),a=null!=this.dataTransform?this.dataTransform.outboundTransform(e,t):t;if(null==this.publishConfig)throw Error("PublishError.Uninitialized");const{raw:c,msg:l}=await async function(e,t,r,n){switch(e.type){case LK.Signing:{const i={from:e.author.toBytes(),data:n,seqno:Pv(8),topic:t,signature:void 0,key:void 0},o=Fa([pV,DK.Message.encode(i).finish()]);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(za(i.seqno,"base16"))),topic:t,signature:i.signature,key:i.key}}}case LK.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,a),u=await this.msgIdFn(l),h=this.msgIdToStrFn(u),d=null!==(n=null===r||void 0===r?void 0:r.ignoreDuplicatePublishError)&&void 0!==n?n:this.opts.ignoreDuplicatePublishError;if(this.seenCache.has(h)){var f;if(d)return null===(f=this.metrics)||void 0===f||f.onPublishDuplicateMsg(e),{recipients:[]};throw Error("PublishError.Duplicate")}const{tosend:p,tosendCount:g}=this.selectPeersToPublish(e),b=this.opts.emitSelf&&this.subscriptions.has(e),y=null!==(i=null===r||void 0===r?void 0:r.allowPublishToZeroPeers)&&void 0!==i?i:this.opts.allowPublishToZeroPeers;if(0===p.size&&!y&&!b)throw Error("PublishError.InsufficientPeers");this.seenCache.put(h),this.mcache.put({msgId:u,msgIdStr:h},c,!0),this.publishedMessageIds.put(h);for(const w of p){this.sendRpc(w,{messages:[c]})||p.delete(w)}const m=Date.now()-s;return null===(o=this.metrics)||void 0===o||o.onPublishMsg(e,g,p.size,null!=c.data?c.data.length:0,m),b&&(p.add(this.components.peerId.toString()),super.dispatchEvent(new ET("gossipsub:message",{detail:{propagationSource:this.components.peerId,msgId:h,msg:l}})),super.dispatchEvent(new ET("message",{detail:l}))),{recipients:Array.from(p.values()).map((e=>pK(e)))}}reportMessageValidationResult(e,t,r){var n;let i;if(r===_z.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=HK(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=[{topicID:t}];this.sendRpc(e,{control:{graft:r}})}async sendPrune(e,t){const r=[await this.makePrune(e,t,this.opts.doPX,!0)];this.sendRpc(e,{control:{prune: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=DK.encode(t).finish();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){if(null!=r.graft){null==t.control&&(t.control={}),null==t.control.graft&&(t.control.graft=[]);for(const o of r.graft){var n,i;null!=o.topicID&&null!==(n=null===(i=this.mesh.get(o.topicID))||void 0===i?void 0:i.has(e))&&void 0!==n&&n&&t.control.graft.push(o)}}if(null!=r.prune){null==t.control&&(t.control={}),null==t.control.prune&&(t.control.prune=[]);for(const n of r.prune){var o,s;null==n.topicID||null!==(o=null===(s=this.mesh.get(n.topicID))||void 0===s?void 0:s.has(e))&&void 0!==o&&o||t.control.prune.push(n)}}}piggybackGossip(e,t,r){null==t.control&&(t.control={}),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,{control:{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,{control:{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(gV(r),r.length>wK&&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=gV(Array.from(o)).slice(0,n),o.forEach((t=>{let n=r;r.length>wK&&(n=gV(n.slice()).slice(0,wK)),this.pushGossip(t,{topicID:e,messageIDs:n})}))}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,{control:{ihave:t}});for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,{control:{graft:t.graft,prune:t.prune}})}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)===yK)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=pK(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,l=e=>{let t=c.get(e);return void 0===t&&(t=this.score.score(e),c.set(e,t)),t},u=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=gV(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=l(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),l(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=u.get(r);null==o?u.set(r,[t]):o.push(t)};if(e.forEach((e=>{const r=l(e);r<0&&(this.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,r,t),g(e,FK.BadScore),d.set(e,!0))})),e.size<n){const t=function(e,t){return $K(e,t,(()=>!0))}(c,r-e.size);t.forEach((e=>{b(e,zK.NotEnough)}))}if(e.size>i){let t=Array.from(e);t.sort(((e,t)=>l(t)-l(e))),t=t.slice(0,o).concat(gV(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,FK.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){$K(c,s-t,(e=>!0===this.outbound.get(e))).forEach((e=>{b(e,zK.Outbound)}))}}if(this.heartbeatTicks%this.opts.opportunisticGraftTicks===0&&e.size>1){const r=Array.from(e).sort(((e,t)=>l(e)-l(t))),n=Math.floor(e.size/2),i=l(r[n]);if(i<this.opts.scoreThresholds.opportunisticGraftThreshold){const e=$K(c,this.opts.opportunisticGraftPeers,(e=>l(e)>i));for(const r of e)this.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",r,t),b(r,zK.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||l(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=gV(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=l(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(u,h,d),this.flush(),this.mcache.shift(),this.dispatchEvent(new ET("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=gV(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 u of this.backoff.values()){n+=u.size;for(const[t,r]of u.entries())this.peers.has(t)&&e.connectedPeersBackoffSec.observe(Math.max(0,r-i)/1e3)}e.cacheSize.set({cache:"backoff"},n);for(const[u,h]of this.topics)e.topicPeersCount.set({topicStr:u},h.size);for(const[u,h]of this.mesh)e.meshPeerCounts.set({topicStr:u},h.size);const o=[],s=new Map;e.behaviourPenalty.reset();for(const u of this.peers.keys()){var a,c;const t=this.score.score(u);o.push(t),s.set(u,t),e.behaviourPenalty.observe(null!==(a=null===(c=this.score.peerStats.get(u))||void 0===c?void 0:c.behaviourPenalty)&&void 0!==a?a:0)}e.registerScores(o,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,s);const l=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=aV(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(l)}}Ji(Wj,"multicodec",mK);const Gj=yl("waku:relay");function Yj(e,t){const r=performance.now();Gj("validating message from ".concat(e," received on ").concat(t.topic));let n=_z.Accept;try{const e=Wh.decode(t.data);e.contentTopic&&e.contentTopic.length&&e.payload&&e.payload.length||(n=_z.Reject)}catch(o){n=_z.Reject}const i=performance.now();return Gj("Validation time (must be <100ms): ".concat(i-r,"ms")),n}const Qj=yl("waku:message:topic-only");class Jj{constructor(e,t){Ji(this,"pubSubTopic",void 0),Ji(this,"proto",void 0),Ji(this,"payload",new Uint8Array),Ji(this,"rateLimitProof",void 0),Ji(this,"timestamp",void 0),Ji(this,"meta",void 0),Ji(this,"ephemeral",void 0),this.pubSubTopic=e,this.proto=t}get contentTopic(){return this.proto.contentTopic}}class Xj{constructor(){Ji(this,"contentTopic","")}fromWireToProtoObj(e){const t=Zh.decode(e);return Qj("Message decoded",t),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 Jj(e,t)}}const Zj=yl("waku:relay");class $j{constructor(e,t){var r;if(Ji(this,"pubSubTopic",void 0),Ji(this,"defaultDecoder",void 0),Ji(this,"gossipSub",void 0),Ji(this,"observers",void 0),!this.isRelayPubSub(e.services.pubsub))throw Error("Failed to initialize Relay. libp2p.pubsub does not support ".concat($j.multicodec));this.gossipSub=e.services.pubsub,this.pubSubTopic=null!==(r=null===t||void 0===t?void 0:t.pubSubTopic)&&void 0!==r?r:Od,this.gossipSub.isStarted()&&this.gossipSubSubscribe(this.pubSubTopic),this.observers=new Map,this.defaultDecoder=new Xj}async start(){if(this.gossipSub.isStarted())throw Error("GossipSub already started.");await this.gossipSub.start(),this.gossipSubSubscribe(this.pubSubTopic)}async send(e,t){const r=[];if(!zf(t.payload))return Zj("Failed to send waku relay: message is bigger that 1MB"),{recipients:r,errors:[sl.SIZE_TOO_BIG]};const n=await e.toWire(t);return n?this.gossipSub.publish(this.pubSubTopic,n):(Zj("Failed to encode message, aborting publish"),{recipients:r,errors:[sl.ENCODE_FAILED]})}subscribe(e,t){const r=Array.isArray(e)?eH(e,t):eH([e],t);for(const n of r.keys()){const e=this.observers.get(n)||new Set,t=r.get(n)||new Set;this.observers.set(n,tH(e,t))}return()=>{for(const e of r.keys()){const t=rH(this.observers.get(e)||new Set,r.get(e)||new Set);t.size?this.observers.set(e,t):this.observers.delete(e)}}}toSubscriptionIterator(e){return zd(this,e)}getActiveSubscriptions(){const e=new Map;return e.set(this.pubSubTopic,this.observers.keys()),e}getMeshPeers(e){return this.gossipSub.getMeshPeers(null!==e&&void 0!==e?e:this.pubSubTopic)}async processIncomingMessage(e,t){const r=await this.defaultDecoder.fromWireToProtoObj(t);if(!r||!r.contentTopic)return void Zj("Message does not have a content topic, skipping");const n=this.observers.get(r.contentTopic);n&&await Promise.all(Array.from(n).map((n=>{let{decoder:i,callback:o}=n;return(async()=>{try{const n=await i.fromWireToProtoObj(t);if(!n)return void Zj("Internal error: message previously decoded failed on 2nd pass.");const s=await i.fromProtoObj(e,n);s?await o(s):Zj("Failed to decode messages on",r.contentTopic)}catch(n){Zj("Error while decoding message:",n)}})()})))}gossipSubSubscribe(e){this.gossipSub.addEventListener("gossipsub:message",(t=>{t.detail.msg.topic===e&&(Zj("Message received on ".concat(e)),this.processIncomingMessage(t.detail.msg.topic,t.detail.msg.data).catch((e=>Zj("Failed to process incoming message",e))))})),this.gossipSub.topicValidators.set(e,Yj),this.gossipSub.subscribe(e)}isRelayPubSub(e){var t;return(null===e||void 0===e||null===(t=e.multicodecs)||void 0===t?void 0:t.includes($j.multicodec))||!1}}function eH(e,t){const r=Array.from(qd(e).entries()).map((e=>{let[r,n]=e;return[r,new Set(n.map((e=>({decoder:e,callback:t}))))]}));return new Map(r)}function tH(e,t){for(const r of t.values())e.add(r);return e}function rH(e,t){for(const r of t.values())e.has(r)&&e.delete(r);return e}function nH(e,t){$i(e,t),t.add(e)}Ji($j,"multicodec","/vac/waku/relay/2.0.0");const iH=Symbol.for("@libp2p/content-routing"),oH=Symbol.for("@libp2p/peer-routing");var sH=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const aH=sH,cH=(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 lH{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 uH{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 dH(this,e)}}class hH{constructor(e){this.decoders=e}or(e){return dH(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 dH=(e,t)=>new hH({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class fH{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new lH(e,t,r),this.decoder=new uH(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pH=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new fH(t,r,n,i)},gH=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=aH(n,r);return pH({prefix:t,name:r,encode:i,decode:e=>cH(o(e))})},bH=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return pH({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},yH=bH({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mH=bH({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wH=bH({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vH=bH({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_H=bH({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),EH=bH({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SH=bH({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AH=bH({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xH=bH({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),kH=gH({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),CH=gH({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),IH=bH({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),TH=bH({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),PH=bH({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),RH=bH({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function DH(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}yl.formatters.b=e=>null==e?"undefined":kH.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":yH.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":IH.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();const NH=gH({prefix:"9",name:"base10",alphabet:"0123456789"}),BH=bH({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),LH=bH({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),UH=bH({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),MH=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"),OH=MH.reduce(((e,t,r)=>(e[r]=t,e)),[]),qH=MH.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const zH=pH({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=OH[t]),"")},decode:function(e){const t=[];for(const r of e){const e=qH[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),FH=gH({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),KH=gH({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),VH=bH({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),jH=pH({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),HH=new TextEncoder,WH=new TextDecoder,GH="json",YH=512,QH=e=>HH.encode(JSON.stringify(e)),JH=e=>JSON.parse(WH.decode(e)),XH="raw",ZH=85,$H=e=>cH(e),eW=e=>cH(e);var tW=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=iW;)r[n++]=255&t|rW,t/=128;for(;t&nW;)r[n++]=255&t|rW,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},rW=128,nW=-128,iW=Math.pow(2,31);var oW=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&aW)<<o:(n&aW)*Math.pow(2,o),o+=7}while(n>=sW);return e.bytes=s-r,i},sW=128,aW=127;var cW=Math.pow(2,7),lW=Math.pow(2,14),uW=Math.pow(2,21),hW=Math.pow(2,28),dW=Math.pow(2,35),fW=Math.pow(2,42),pW=Math.pow(2,49),gW=Math.pow(2,56),bW=Math.pow(2,63);const yW={encode:tW,decode:oW,encodingLength:function(e){return e<cW?1:e<lW?2:e<uW?3:e<hW?4:e<dW?5:e<fW?6:e<pW?7:e<gW?8:e<bW?9:10}},mW=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[yW.decode(e,t),yW.decode.bytes]},wW=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return yW.encode(e,t,r),t},vW=e=>yW.encodingLength(e),_W=(e,t)=>{const r=t.byteLength,n=vW(e),i=n+vW(r),o=new Uint8Array(i+r);return wW(e,o,0),wW(r,o,n),o.set(t,i),new SW(e,r,t,o)},EW=e=>{const t=cH(e),[r,n]=mW(t),[i,o]=mW(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new SW(r,i,s,t)};class SW{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const AW=cH,xW={code:0,name:"identity",encode:AW,digest:e=>_W(0,AW(e))},kW=e=>{let{name:t,code:r,encode:n}=e;return new CW(t,r,n)};class CW{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?_W(this.code,t):t.then((e=>_W(this.code,e)))}throw Error("Unknown type, must be binary type")}}const IW=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),TW=kW({name:"sha2-256",code:18,encode:IW("SHA-256")}),PW=kW({name:"sha2-512",code:19,encode:IW("SHA-512")}),RW=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?UW(r,NW(e),t||kH.encoder):MW(r,NW(e),t||yH.encoder)},DW=new WeakMap,NW=e=>{const t=DW.get(e);if(null==t){const t=new Map;return DW.set(e,t),t}return t};class BW{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!==OW)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==qW)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return BW.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=_W(e,t);return BW.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 BW.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 RW(this,e)}toJSON(){return{"/":RW(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 BW)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new BW(e,r,n,i||zW(e,r,n.bytes))}if(!0===t[FW]){const{version:e,multihash:r,code:n}=t,i=EW(r);return BW.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!==OW)throw new Error("Version 0 CID must use dag-pb (code: ".concat(OW,") block encoding"));return new BW(e,t,r,r.bytes);case 1:{const n=zW(e,t,r.bytes);return new BW(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return BW.create(0,OW,e)}static createV1(e,t){return BW.create(1,e,t)}static decode(e){const[t,r]=BW.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=BW.inspectBytes(e),r=t.size-t.multihashSize,n=cH(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 SW(t.multihashCode,t.digestSize,i,n);return[0===t.version?BW.createV0(o):BW.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=mW(e.subarray(t));return t+=n,r};let n=r(),i=OW;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]=LW(e,t),i=BW.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return NW(i).set(r,e),i}}const LW=(e,t)=>{switch(e[0]){case"Q":{const r=t||kH;return[kH.prefix,r.decode("".concat(kH.prefix).concat(e))]}case kH.prefix:{const r=t||kH;return[kH.prefix,r.decode(e)]}case yH.prefix:{const r=t||yH;return[yH.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)]}},UW=(e,t,r)=>{const{prefix:n}=r;if(n!==kH.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},MW=(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},OW=112,qW=18,zW=(e,t,r)=>{const n=vW(e),i=n+vW(t),o=new Uint8Array(i+r.byteLength);return wW(e,o,0),wW(t,o,n),o.set(r,i),o},FW=Symbol.for("@ipld/js-cid/CID"),KW={...cr,...ir,...ar,...rr,...nr,...$t,...sr,...er,...tr,...or},VW=Symbol.for("nodejs.util.inspect.custom"),jW=Object.values(KW).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),KW.identity.decoder),HW=114,WW=36,GW=37;class YW{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=kH.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return BW.createV1(HW,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:jW,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=EW(kH.decode("z".concat(e)));return e.startsWith("12D")?new JW({multihash:t}):e.startsWith("16U")?new XW({multihash:t}):new QW({multihash:t})}return function(e){try{const t=EW(e);if(t.code===xW.code){if(t.digest.length===WW)return new JW({multihash:t});if(t.digest.length===GW)return new XW({multihash:t})}if(t.code===TW.code)return new QW({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==HW)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===TW.code)return new QW({multihash:e.multihash});if(t.code===xW.code){if(t.digest.length===WW)return new JW({multihash:e.multihash});if(t.digest.length===GW)return new XW({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(BW.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(jW.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[VW](){return"PeerId(".concat(this.toString(),")")}}class QW extends YW{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class JW extends YW{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class XW extends YW{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}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){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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const eG=$W;class tG{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 rG{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 iG(this,e)}}class nG{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return iG(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 iG(e,t){var r,n;return new nG({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class oG{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new tG(e,t,r),this.decoder=new rG(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function sG(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new oG(t,r,n,i)}function aG(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=eG(n,t);return sG({prefix:r,name:t,encode:i,decode:e=>ZW(o(e))})}function cG(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return sG({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 lG=aG({prefix:"9",name:"base10",alphabet:"0123456789"}),uG=cG({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hG=cG({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),dG=cG({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),fG=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"),pG=fG.reduce(((e,t,r)=>(e[r]=t,e)),[]),gG=fG.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const bG=sG({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pG[t]),"")},decode:function(e){const t=[];for(const r of e){const e=gG[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),yG=cG({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mG=cG({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wG=cG({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vG=cG({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_G=cG({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),EG=cG({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SG=cG({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AG=cG({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xG=cG({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),kG=aG({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),CG=aG({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),IG=aG({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),TG=aG({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),PG=cG({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),RG=cG({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),DG=cG({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),NG=cG({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),BG=cG({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),LG=sG({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)}),UG=new TextEncoder,MG=new TextDecoder,OG="json",qG=512;function zG(e){return UG.encode(JSON.stringify(e))}function FG(e){return JSON.parse(MG.decode(e))}const KG="raw",VG=85;function jG(e){return ZW(e)}function HG(e){return ZW(e)}var WG=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=QG;)r[n++]=255&t|GG,t/=128;for(;t&YG;)r[n++]=255&t|GG,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},GG=128,YG=-128,QG=Math.pow(2,31);var JG=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&ZG)<<o:(n&ZG)*Math.pow(2,o),o+=7}while(n>=XG);return e.bytes=s-r,i},XG=128,ZG=127;var $G=Math.pow(2,7),eY=Math.pow(2,14),tY=Math.pow(2,21),rY=Math.pow(2,28),nY=Math.pow(2,35),iY=Math.pow(2,42),oY=Math.pow(2,49),sY=Math.pow(2,56),aY=Math.pow(2,63);const cY={encode:WG,decode:JG,encodingLength:function(e){return e<$G?1:e<eY?2:e<tY?3:e<rY?4:e<nY?5:e<iY?6:e<oY?7:e<sY?8:e<aY?9:10}};function lY(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return cY.encode(e,t,r),t}function uY(e){return cY.encodingLength(e)}function hY(e,t){const r=t.byteLength,n=uY(e),i=n+uY(r),o=new Uint8Array(i+r);return lY(e,o,0),lY(r,o,n),o.set(t,i),new dY(e,r,t,o)}class dY{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const fY=ZW;const pY={code:0,name:"identity",encode:fY,digest:function(e){return hY(0,fY(e))}};function gY(e){let{name:t,code:r,encode:n}=e;return new bY(t,r,n)}class bY{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?hY(this.code,t):t.then((e=>hY(this.code,e)))}throw Error("Unknown type, must be binary type")}}function yY(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const mY=gY({name:"sha2-256",code:18,encode:yY("SHA-256")}),wY=gY({name:"sha2-512",code:19,encode:yY("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const vY={...Er,...gr,..._r,...fr,...pr,...yr,...mr,...wr,...vr,...br};function _Y(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const EY=_Y("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),SY=_Y("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})),AY={utf8:EY,"utf-8":EY,hex:vY.base16,latin1:SY,ascii:SY,binary:SY,...vY};const xY="/",kY=(new TextEncoder).encode(xY),CY=kY[0];class IY{constructor(e,t){if(Ji(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=AY[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]!==CY)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=AY[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 IY(e.join(xY))}static random(){return new IY(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"===typeof e?new IY(e):"function"===typeof e.uint8Array?new IY(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=kY),this._buf[0]!==CY){const e=new Uint8Array(this._buf.byteLength+1);e.fill(CY,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===CY;)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 IY.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(xY).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 IY(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(xY)||(e+=xY),e+=this.type(),new IY(e)}parent(){const e=this.list();return 1===e.length?new IY(xY):new IY(e.slice(0,-1).join(xY))}child(e){return this.toString()===xY?e:e.toString()===xY?this:new IY(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 IY.withNamespaces([...this.namespaces(),...(n=t.map((e=>e.namespaces())),[].concat(...n))]);var n}}const TY=__webpack_require__(8355);var PY,RY=__webpack_require__(1287);!function(e){e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",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_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"}(PY||(PY={}));const DY=DH("libp2p:keychain"),NY="/info/",BY=new WeakMap,LY=14,UY=16,MY=1e3,OY={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function qY(e){return null!=e&&("string"===typeof e&&(e===RY(e.trim())&&e.length>0))}async function zY(){const e=800*Math.random()+200;await new Promise((t=>setTimeout(t,e)))}function FY(e){return new IY("/pkcs8/"+e)}function KY(e){return new IY(NY+e)}class VY{constructor(e,t){var r,n,i,o,s,a,c,l,u;if(Ji(this,"components",void 0),Ji(this,"init",void 0),this.components=e,this.init=TY(OY,t),null!=this.init.pass&&(null===(r=this.init.pass)||void 0===r?void 0:r.length)<20)throw new Error("pass must be least 20 characters");if(null!=(null===(n=this.init.dek)||void 0===n?void 0:n.keyLength)&&this.init.dek.keyLength<LY)throw new Error("dek.keyLength must be least ".concat(LY," bytes"));if(null!=(null===(i=this.init.dek)||void 0===i||null===(i=i.salt)||void 0===i?void 0:i.length)&&this.init.dek.salt.length<UY)throw new Error("dek.saltLength must be least ".concat(UY," bytes"));if(null!=(null===(o=this.init.dek)||void 0===o?void 0:o.iterationCount)&&this.init.dek.iterationCount<MY)throw new Error("dek.iterationCount must be least ".concat(MY));const h=null!=this.init.pass&&null!=(null===(s=this.init.dek)||void 0===s?void 0:s.salt)?fV(this.init.pass,null===(a=this.init.dek)||void 0===a?void 0:a.salt,null===(c=this.init.dek)||void 0===c?void 0:c.iterationCount,null===(l=this.init.dek)||void 0===l?void 0:l.keyLength,null===(u=this.init.dek)||void 0===u?void 0:u.hash):"";BY.set(this,{dek:h})}static generateOptions(){const e=Object.assign({},OY),t=3*Math.ceil(UY/3);return e.dek.salt=za(Pv(t),"base64"),e}static get options(){return OY}async createKey(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2048;if(!qY(e)||"self"===e)throw await zY(),new ly("Invalid key name",PY.ERR_INVALID_KEY_NAME);if("string"!==typeof t)throw await zY(),new ly("Invalid key type",PY.ERR_INVALID_KEY_TYPE);const n=FY(e);if(await this.components.datastore.has(n))throw await zY(),new ly("Key name already exists",PY.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase())if(!Number.isSafeInteger(r)||r<2048)throw await zY(),new ly("Invalid RSA key size",PY.ERR_INVALID_KEY_SIZE);let i;try{const o=await b_(t,r),s=await o.id(),a=BY.get(this);if(null==a)throw new ly("dek missing",PY.ERR_INVALID_PARAMETERS);const c=a.dek,l=await o.export(c);i={name:e,id:s};const u=this.components.datastore.batch();u.put(n,kc(l)),u.put(KY(e),kc(JSON.stringify(i))),await u.commit()}catch(o){throw await zY(),o}return i}async listKeys(){const e={prefix:NY},t=[];for await(const r of this.components.datastore.query(e))t.push(JSON.parse(za(r.value)));return t}async findKeyById(e){try{const t=(await this.listKeys()).find((t=>t.id===e));if(null==t)throw new ly("Key with id '".concat(e,"' does not exist."),PY.ERR_KEY_NOT_FOUND);return t}catch(t){throw await zY(),t}}async findKeyByName(e){if(!qY(e))throw await zY(),new ly("Invalid key name '".concat(e,"'"),PY.ERR_INVALID_KEY_NAME);const t=KY(e);try{const e=await this.components.datastore.get(t);return JSON.parse(za(e))}catch(r){throw await zY(),DY.error(r),new ly("Key '".concat(e,"' does not exist."),PY.ERR_KEY_NOT_FOUND)}}async removeKey(e){if(!qY(e)||"self"===e)throw await zY(),new ly("Invalid key name '".concat(e,"'"),PY.ERR_INVALID_KEY_NAME);const t=FY(e),r=await this.findKeyByName(e),n=this.components.datastore.batch();return n.delete(t),n.delete(KY(e)),await n.commit(),r}async renameKey(e,t){if(!qY(e)||"self"===e)throw await zY(),new ly("Invalid old key name '".concat(e,"'"),PY.ERR_OLD_KEY_NAME_INVALID);if(!qY(t)||"self"===t)throw await zY(),new ly("Invalid new key name '".concat(t,"'"),PY.ERR_NEW_KEY_NAME_INVALID);const r=FY(e),n=FY(t),i=KY(e),o=KY(t);if(await this.components.datastore.has(n))throw await zY(),new ly("Key '".concat(t,"' already exists"),PY.ERR_KEY_ALREADY_EXISTS);try{const e=await this.components.datastore.get(r),s=await this.components.datastore.get(i),a=JSON.parse(za(s));a.name=t;const c=this.components.datastore.batch();return c.put(n,e),c.put(o,kc(JSON.stringify(a))),c.delete(r),c.delete(i),await c.commit(),a}catch(s){throw await zY(),s}}async exportKey(e,t){if(!qY(e))throw await zY(),new ly("Invalid key name '".concat(e,"'"),PY.ERR_INVALID_KEY_NAME);if(null==t)throw await zY(),new ly("Password is required",PY.ERR_PASSWORD_REQUIRED);const r=FY(e);try{const e=za(await this.components.datastore.get(r)),n=BY.get(this);if(null==n)throw new ly("dek missing",PY.ERR_INVALID_PARAMETERS);const i=n.dek,o=await v_(e,i);return await o.export(t)}catch(n){throw await zY(),n}}async exportPeerId(e){const t="temporary-password",r=await this.exportKey(e,t),n=await v_(r,t);return async function(e,t){return e.length===WW?new JW({multihash:_W(xW.code,e),privateKey:t}):e.length===GW?new XW({multihash:_W(xW.code,e),privateKey:t}):new QW({multihash:await TW.digest(e),publicKey:e,privateKey:t})}(n.public.bytes,n.bytes)}async importKey(e,t,r){if(!qY(e)||"self"===e)throw await zY(),new ly("Invalid key name '".concat(e,"'"),PY.ERR_INVALID_KEY_NAME);if(null==t)throw await zY(),new ly("PEM encoded key is required",PY.ERR_PEM_REQUIRED);const n=FY(e);if(await this.components.datastore.has(n))throw await zY(),new ly("Key '".concat(e,"' already exists"),PY.ERR_KEY_ALREADY_EXISTS);let i,o;try{i=await v_(t,r)}catch(c){throw await zY(),new ly("Cannot read the key, most likely the password is wrong",PY.ERR_CANNOT_READ_KEY)}try{o=await i.id();const e=BY.get(this);if(null==e)throw new ly("dek missing",PY.ERR_INVALID_PARAMETERS);const r=e.dek;t=await i.export(r)}catch(c){throw await zY(),c}const s={name:e,id:o},a=this.components.datastore.batch();return a.put(n,kc(t)),a.put(KY(e),kc(JSON.stringify(s))),await a.commit(),s}async importPeer(e,t){try{if(!qY(e))throw new ly("Invalid key name '".concat(e,"'"),PY.ERR_INVALID_KEY_NAME);if(null==t)throw new ly("PeerId is required",PY.ERR_MISSING_PRIVATE_KEY);if(null==t.privateKey)throw new ly("PeerId.privKey is required",PY.ERR_MISSING_PRIVATE_KEY);const r=await w_(t.privateKey),n=FY(e);if(await this.components.datastore.has(n))throw await zY(),new ly("Key '".concat(e,"' already exists"),PY.ERR_KEY_ALREADY_EXISTS);const i=BY.get(this);if(null==i)throw new ly("dek missing",PY.ERR_INVALID_PARAMETERS);const o=i.dek,s=await r.export(o),a={name:e,id:t.toString()},c=this.components.datastore.batch();return c.put(n,kc(s)),c.put(KY(e),kc(JSON.stringify(a))),await c.commit(),a}catch(r){throw await zY(),r}}async getPrivateKey(e){if(!qY(e))throw await zY(),new ly("Invalid key name '".concat(e,"'"),PY.ERR_INVALID_KEY_NAME);try{const t=FY(e);return za(await this.components.datastore.get(t))}catch(t){throw await zY(),DY.error(t),new ly("Key '".concat(e,"' does not exist."),PY.ERR_KEY_NOT_FOUND)}}async rotateKeychainPass(e,t){var r,n,i,o;if("string"!==typeof e)throw await zY(),new ly("Invalid old pass type '".concat(typeof e,"'"),PY.ERR_INVALID_OLD_PASS_TYPE);if("string"!==typeof t)throw await zY(),new ly("Invalid new pass type '".concat(typeof t,"'"),PY.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw await zY(),new ly("Invalid pass length ".concat(t.length),PY.ERR_INVALID_PASS_LENGTH);DY("recreating keychain");const s=BY.get(this);if(null==s)throw new ly("dek missing",PY.ERR_INVALID_PARAMETERS);const a=s.dek;this.init.pass=t;const c=null!=t&&null!=(null===(r=this.init.dek)||void 0===r?void 0:r.salt)?fV(t,this.init.dek.salt,null===(n=this.init.dek)||void 0===n?void 0:n.iterationCount,null===(i=this.init.dek)||void 0===i?void 0:i.keyLength,null===(o=this.init.dek)||void 0===o?void 0:o.hash):"";BY.set(this,{dek:c});const l=await this.listKeys();for(const u of l){const e=za(await this.components.datastore.get(FY(u.name))),t=await v_(e,a),r=c.toString(),n=await t.export(r),i=this.components.datastore.batch(),o={name:u.name,id:u.id};i.put(FY(u.name),kc(n)),i.put(KY(u.name),kc(JSON.stringify(o))),await i.commit()}DY("keychain reconstructed")}}var jY=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const HY=jY,WY=(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 GY{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 YY{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 JY(this,e)}}class QY{constructor(e){this.decoders=e}or(e){return JY(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 JY=(e,t)=>new QY({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class XY{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new GY(e,t,r),this.decoder=new YY(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ZY=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new XY(t,r,n,i)},$Y=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=HY(n,r);return ZY({prefix:t,name:r,encode:i,decode:e=>WY(o(e))})},eQ=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return ZY({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},tQ=eQ({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rQ=eQ({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),nQ=eQ({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),iQ=eQ({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oQ=eQ({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sQ=eQ({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),aQ=eQ({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),cQ=eQ({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lQ=eQ({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),uQ=$Y({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hQ=$Y({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),dQ=eQ({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fQ=eQ({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pQ=eQ({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),gQ=eQ({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function bQ(){return{forComponent:e=>yQ(e)}}function yQ(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}yl.formatters.b=e=>null==e?"undefined":uQ.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":tQ.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":dQ.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();var mQ=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const wQ=mQ,vQ=(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 _Q{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 EQ{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 AQ(this,e)}}class SQ{constructor(e){this.decoders=e}or(e){return AQ(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 AQ=(e,t)=>new SQ({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class xQ{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new _Q(e,t,r),this.decoder=new EQ(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const kQ=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new xQ(t,r,n,i)},CQ=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=wQ(n,r);return kQ({prefix:t,name:r,encode:i,decode:e=>vQ(o(e))})},IQ=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return kQ({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},TQ=CQ({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),PQ=CQ({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),RQ=CQ({prefix:"9",name:"base10",alphabet:"0123456789"}),DQ=IQ({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),NQ=IQ({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),BQ=IQ({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),LQ=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"),UQ=LQ.reduce(((e,t,r)=>(e[r]=t,e)),[]),MQ=LQ.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const OQ=kQ({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=UQ[t]),"")},decode:function(e){const t=[];for(const r of e){const e=MQ[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),qQ=IQ({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zQ=IQ({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),FQ=IQ({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),KQ=IQ({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),VQ=IQ({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jQ=IQ({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),HQ=IQ({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WQ=IQ({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),GQ=IQ({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),YQ=CQ({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),QQ=CQ({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),JQ=IQ({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),XQ=IQ({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ZQ=IQ({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$Q=IQ({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),eJ=IQ({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),tJ=kQ({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),rJ=new TextEncoder,nJ=new TextDecoder,iJ="json",oJ=512,sJ=e=>rJ.encode(JSON.stringify(e)),aJ=e=>JSON.parse(nJ.decode(e)),cJ="raw",lJ=85,uJ=e=>vQ(e),hJ=e=>vQ(e);var dJ=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=gJ;)r[n++]=255&t|fJ,t/=128;for(;t&pJ;)r[n++]=255&t|fJ,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},fJ=128,pJ=-128,gJ=Math.pow(2,31);var bJ=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&mJ)<<o:(n&mJ)*Math.pow(2,o),o+=7}while(n>=yJ);return e.bytes=s-r,i},yJ=128,mJ=127;var wJ=Math.pow(2,7),vJ=Math.pow(2,14),_J=Math.pow(2,21),EJ=Math.pow(2,28),SJ=Math.pow(2,35),AJ=Math.pow(2,42),xJ=Math.pow(2,49),kJ=Math.pow(2,56),CJ=Math.pow(2,63);const IJ={encode:dJ,decode:bJ,encodingLength:function(e){return e<wJ?1:e<vJ?2:e<_J?3:e<EJ?4:e<SJ?5:e<AJ?6:e<xJ?7:e<kJ?8:e<CJ?9:10}},TJ=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[IJ.decode(e,t),IJ.decode.bytes]},PJ=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return IJ.encode(e,t,r),t},RJ=e=>IJ.encodingLength(e),DJ=(e,t)=>{const r=t.byteLength,n=RJ(e),i=n+RJ(r),o=new Uint8Array(i+r);return PJ(e,o,0),PJ(r,o,n),o.set(t,i),new BJ(e,r,t,o)},NJ=e=>{const t=vQ(e),[r,n]=TJ(t),[i,o]=TJ(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new BJ(r,i,s,t)};class BJ{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const LJ=vQ,UJ={code:0,name:"identity",encode:LJ,digest:e=>DJ(0,LJ(e))},MJ=e=>{let{name:t,code:r,encode:n}=e;return new OJ(t,r,n)};class OJ{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?DJ(this.code,t):t.then((e=>DJ(this.code,e)))}throw Error("Unknown type, must be binary type")}}const qJ=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),zJ=MJ({name:"sha2-256",code:18,encode:qJ("SHA-256")}),FJ=MJ({name:"sha2-512",code:19,encode:qJ("SHA-512")}),KJ=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?GJ(r,jJ(e),t||TQ.encoder):YJ(r,jJ(e),t||qQ.encoder)},VJ=new WeakMap,jJ=e=>{const t=VJ.get(e);if(null==t){const t=new Map;return VJ.set(e,t),t}return t};class HJ{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!==QJ)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==JJ)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return HJ.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=DJ(e,t);return HJ.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 HJ.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 KJ(this,e)}toJSON(){return{"/":KJ(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 HJ)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new HJ(e,r,n,i||XJ(e,r,n.bytes))}if(!0===t[ZJ]){const{version:e,multihash:r,code:n}=t,i=NJ(r);return HJ.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!==QJ)throw new Error("Version 0 CID must use dag-pb (code: ".concat(QJ,") block encoding"));return new HJ(e,t,r,r.bytes);case 1:{const n=XJ(e,t,r.bytes);return new HJ(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return HJ.create(0,QJ,e)}static createV1(e,t){return HJ.create(1,e,t)}static decode(e){const[t,r]=HJ.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=HJ.inspectBytes(e),r=t.size-t.multihashSize,n=vQ(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 BJ(t.multihashCode,t.digestSize,i,n);return[0===t.version?HJ.createV0(o):HJ.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=TJ(e.subarray(t));return t+=n,r};let n=r(),i=QJ;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]=WJ(e,t),i=HJ.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return jJ(i).set(r,e),i}}const WJ=(e,t)=>{switch(e[0]){case"Q":{const r=t||TQ;return[TQ.prefix,r.decode("".concat(TQ.prefix).concat(e))]}case TQ.prefix:{const r=t||TQ;return[TQ.prefix,r.decode(e)]}case qQ.prefix:{const r=t||qQ;return[qQ.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)]}},GJ=(e,t,r)=>{const{prefix:n}=r;if(n!==TQ.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},YJ=(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},QJ=112,JJ=18,XJ=(e,t,r)=>{const n=RJ(e),i=n+RJ(t),o=new Uint8Array(i+r.byteLength);return PJ(e,o,0),PJ(t,o,n),o.set(r,i),o},ZJ=Symbol.for("@ipld/js-cid/CID"),$J={...qr,...Nr,...Or,...Rr,...Dr,...Lr,...Ur,...Pr,...Mr,...Br},eX=Symbol.for("nodejs.util.inspect.custom"),tX=Object.values($J).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),$J.identity.decoder),rX=114,nX=36,iX=37;class oX{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=TQ.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return HJ.createV1(rX,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return lX(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[eX](){return"PeerId(".concat(this.toString(),")")}}class sX extends oX{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class aX extends oX{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class cX extends oX{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function lX(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:tX,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=NJ(TQ.decode("z".concat(e)));return e.startsWith("12D")?new aX({multihash:t}):e.startsWith("16U")?new cX({multihash:t}):new sX({multihash:t})}return function(e){try{const t=NJ(e);if(t.code===UJ.code){if(t.digest.length===nX)return new aX({multihash:t});if(t.digest.length===iX)return new cX({multihash:t})}if(t.code===zJ.code)return new sX({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==rX)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===zJ.code)return new sX({multihash:e.multihash});if(t.code===UJ.code){if(t.digest.length===nX)return new aX({multihash:e.multihash});if(t.digest.length===iX)return new cX({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(HJ.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(tX.decode(e))}function uX(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 hX{constructor(e){if(Ji(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){this.map.delete(e.toString())}entries(){return uX(this.map.entries(),(e=>[lX(e[0]),e[1]]))}forEach(e){this.map.forEach(((t,r)=>{e(t,lX(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 uX(this.map.keys(),(e=>lX(e)))}values(){return this.map.values()}get size(){return this.map.size}}class dX{constructor(e){if(Ji(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 uX(this.set.entries(),(e=>{const t=lX(e[0]);return[t,t]}))}forEach(e){this.set.forEach((t=>{const r=lX(t);e(r,r,this)}))}has(e){return this.set.has(e.toString())}values(){return uX(this.set.values(),(e=>lX(e)))}intersection(e){const t=new dX;for(const r of e)this.has(r)&&t.add(r);return t}difference(e){const t=new dX;for(const r of this)e.has(r)||t.add(r);return t}union(e){const t=new dX;for(const r of e)t.add(r);for(const r of this)t.add(r);return t}}Symbol.iterator;const fX=$Y({prefix:"9",name:"base10",alphabet:"0123456789"}),pX=eQ({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gX=eQ({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),bX=eQ({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),yX=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"),mX=yX.reduce(((e,t,r)=>(e[r]=t,e)),[]),wX=yX.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const vX=ZY({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=mX[t]),"")},decode:function(e){const t=[];for(const r of e){const e=wX[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),_X=$Y({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),EX=$Y({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),SX=eQ({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),AX=ZY({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),xX=new TextEncoder,kX=new TextDecoder,CX="json",IX=512,TX=e=>xX.encode(JSON.stringify(e)),PX=e=>JSON.parse(kX.decode(e)),RX="raw",DX=85,NX=e=>WY(e),BX=e=>WY(e);var LX=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=OX;)r[n++]=255&t|UX,t/=128;for(;t&MX;)r[n++]=255&t|UX,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},UX=128,MX=-128,OX=Math.pow(2,31);var qX=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&FX)<<o:(n&FX)*Math.pow(2,o),o+=7}while(n>=zX);return e.bytes=s-r,i},zX=128,FX=127;var KX=Math.pow(2,7),VX=Math.pow(2,14),jX=Math.pow(2,21),HX=Math.pow(2,28),WX=Math.pow(2,35),GX=Math.pow(2,42),YX=Math.pow(2,49),QX=Math.pow(2,56),JX=Math.pow(2,63);const XX={encode:LX,decode:qX,encodingLength:function(e){return e<KX?1:e<VX?2:e<jX?3:e<HX?4:e<WX?5:e<GX?6:e<YX?7:e<QX?8:e<JX?9:10}},ZX=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[XX.decode(e,t),XX.decode.bytes]},$X=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return XX.encode(e,t,r),t},eZ=e=>XX.encodingLength(e),tZ=(e,t)=>{const r=t.byteLength,n=eZ(e),i=n+eZ(r),o=new Uint8Array(i+r);return $X(e,o,0),$X(r,o,n),o.set(t,i),new nZ(e,r,t,o)},rZ=e=>{const t=WY(e),[r,n]=ZX(t),[i,o]=ZX(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new nZ(r,i,s,t)};class nZ{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const iZ=WY,oZ={code:0,name:"identity",encode:iZ,digest:e=>tZ(0,iZ(e))},sZ=e=>{let{name:t,code:r,encode:n}=e;return new aZ(t,r,n)};class aZ{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?tZ(this.code,t):t.then((e=>tZ(this.code,e)))}throw Error("Unknown type, must be binary type")}}const cZ=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),lZ=sZ({name:"sha2-256",code:18,encode:cZ("SHA-256")}),uZ=sZ({name:"sha2-512",code:19,encode:cZ("SHA-512")}),hZ=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?bZ(r,fZ(e),t||uQ.encoder):yZ(r,fZ(e),t||tQ.encoder)},dZ=new WeakMap,fZ=e=>{const t=dZ.get(e);if(null==t){const t=new Map;return dZ.set(e,t),t}return t};class pZ{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!==mZ)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==wZ)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return pZ.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=tZ(e,t);return pZ.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 pZ.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 hZ(this,e)}toJSON(){return{"/":hZ(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 pZ)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new pZ(e,r,n,i||vZ(e,r,n.bytes))}if(!0===t[_Z]){const{version:e,multihash:r,code:n}=t,i=rZ(r);return pZ.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!==mZ)throw new Error("Version 0 CID must use dag-pb (code: ".concat(mZ,") block encoding"));return new pZ(e,t,r,r.bytes);case 1:{const n=vZ(e,t,r.bytes);return new pZ(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return pZ.create(0,mZ,e)}static createV1(e,t){return pZ.create(1,e,t)}static decode(e){const[t,r]=pZ.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=pZ.inspectBytes(e),r=t.size-t.multihashSize,n=WY(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 nZ(t.multihashCode,t.digestSize,i,n);return[0===t.version?pZ.createV0(o):pZ.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=ZX(e.subarray(t));return t+=n,r};let n=r(),i=mZ;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]=gZ(e,t),i=pZ.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return fZ(i).set(r,e),i}}const gZ=(e,t)=>{switch(e[0]){case"Q":{const r=t||uQ;return[uQ.prefix,r.decode("".concat(uQ.prefix).concat(e))]}case uQ.prefix:{const r=t||uQ;return[uQ.prefix,r.decode(e)]}case tQ.prefix:{const r=t||tQ;return[tQ.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)]}},bZ=(e,t,r)=>{const{prefix:n}=r;if(n!==uQ.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},yZ=(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},mZ=112,wZ=18,vZ=(e,t,r)=>{const n=eZ(e),i=n+eZ(t),o=new Uint8Array(i+r.byteLength);return $X(e,o,0),$X(t,o,n),o.set(r,i),o},_Z=Symbol.for("@ipld/js-cid/CID"),EZ={...Jr,...Wr,...Qr,...jr,...Hr,...Cr,...Yr,...Ir,...Tr,...Gr},SZ=Symbol.for("nodejs.util.inspect.custom"),AZ=Object.values(EZ).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),EZ.identity.decoder),xZ=114,kZ=36,CZ=37;class IZ{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=uQ.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return pZ.createV1(xZ,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return DZ(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[SZ](){return"PeerId(".concat(this.toString(),")")}}class TZ extends IZ{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class PZ extends IZ{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class RZ extends IZ{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function DZ(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:AZ,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=rZ(uQ.decode("z".concat(e)));return e.startsWith("12D")?new PZ({multihash:t}):e.startsWith("16U")?new RZ({multihash:t}):new TZ({multihash:t})}return function(e){try{const t=rZ(e);if(t.code===oZ.code){if(t.digest.length===kZ)return new PZ({multihash:t});if(t.digest.length===CZ)return new RZ({multihash:t})}if(t.code===lZ.code)return new TZ({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==xZ)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===lZ.code)return new TZ({multihash:e.multihash});if(t.code===oZ.code){if(t.digest.length===kZ)return new PZ({multihash:e.multihash});if(t.digest.length===CZ)return new RZ({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(pZ.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(AZ.decode(e))}async function NZ(e,t){return e.length===kZ?new PZ({multihash:tZ(oZ.code,e),privateKey:t}):e.length===CZ?new RZ({multihash:tZ(oZ.code,e),privateKey:t}):new TZ({multihash:await lZ.digest(e),publicKey:e,privateKey:t})}var BZ=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const LZ=BZ,UZ=(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 MZ{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 OZ{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 zZ(this,e)}}class qZ{constructor(e){this.decoders=e}or(e){return zZ(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 zZ=(e,t)=>new qZ({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class FZ{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new MZ(e,t,r),this.decoder=new OZ(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const KZ=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new FZ(t,r,n,i)},VZ=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=LZ(n,r);return KZ({prefix:t,name:r,encode:i,decode:e=>UZ(o(e))})},jZ=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return KZ({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},HZ=VZ({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),WZ=VZ({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),GZ=VZ({prefix:"9",name:"base10",alphabet:"0123456789"}),YZ=jZ({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),QZ=jZ({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),JZ=jZ({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),XZ=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"),ZZ=XZ.reduce(((e,t,r)=>(e[r]=t,e)),[]),$Z=XZ.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const e$=KZ({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ZZ[t]),"")},decode:function(e){const t=[];for(const r of e){const e=$Z[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),t$=jZ({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),r$=jZ({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),n$=jZ({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),i$=jZ({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),o$=jZ({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),s$=jZ({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),a$=jZ({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),c$=jZ({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),l$=jZ({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),u$=VZ({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),h$=VZ({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),d$=jZ({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),f$=jZ({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),p$=jZ({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),g$=jZ({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),b$=jZ({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),y$=KZ({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),m$=new TextEncoder,w$=new TextDecoder,v$="json",_$=512,E$=e=>m$.encode(JSON.stringify(e)),S$=e=>JSON.parse(w$.decode(e)),A$="raw",x$=85,k$=e=>UZ(e),C$=e=>UZ(e);var I$=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=R$;)r[n++]=255&t|T$,t/=128;for(;t&P$;)r[n++]=255&t|T$,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},T$=128,P$=-128,R$=Math.pow(2,31);var D$=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&B$)<<o:(n&B$)*Math.pow(2,o),o+=7}while(n>=N$);return e.bytes=s-r,i},N$=128,B$=127;var L$=Math.pow(2,7),U$=Math.pow(2,14),M$=Math.pow(2,21),O$=Math.pow(2,28),q$=Math.pow(2,35),z$=Math.pow(2,42),F$=Math.pow(2,49),K$=Math.pow(2,56),V$=Math.pow(2,63);const j$={encode:I$,decode:D$,encodingLength:function(e){return e<L$?1:e<U$?2:e<M$?3:e<O$?4:e<q$?5:e<z$?6:e<F$?7:e<K$?8:e<V$?9:10}},H$=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[j$.decode(e,t),j$.decode.bytes]},W$=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return j$.encode(e,t,r),t},G$=e=>j$.encodingLength(e),Y$=(e,t)=>{const r=t.byteLength,n=G$(e),i=n+G$(r),o=new Uint8Array(i+r);return W$(e,o,0),W$(r,o,n),o.set(t,i),new J$(e,r,t,o)},Q$=e=>{const t=UZ(e),[r,n]=H$(t),[i,o]=H$(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new J$(r,i,s,t)};class J${constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const X$=UZ,Z$={code:0,name:"identity",encode:X$,digest:e=>Y$(0,X$(e))},$$=e=>{let{name:t,code:r,encode:n}=e;return new e0(t,r,n)};class e0{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?Y$(this.code,t):t.then((e=>Y$(this.code,e)))}throw Error("Unknown type, must be binary type")}}const t0=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),r0=$$({name:"sha2-256",code:18,encode:t0("SHA-256")}),n0=$$({name:"sha2-512",code:19,encode:t0("SHA-512")}),i0=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?l0(r,s0(e),t||HZ.encoder):u0(r,s0(e),t||t$.encoder)},o0=new WeakMap,s0=e=>{const t=o0.get(e);if(null==t){const t=new Map;return o0.set(e,t),t}return t};class a0{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!==h0)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==d0)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return a0.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=Y$(e,t);return a0.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 a0.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 i0(this,e)}toJSON(){return{"/":i0(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 a0)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new a0(e,r,n,i||f0(e,r,n.bytes))}if(!0===t[p0]){const{version:e,multihash:r,code:n}=t,i=Q$(r);return a0.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!==h0)throw new Error("Version 0 CID must use dag-pb (code: ".concat(h0,") block encoding"));return new a0(e,t,r,r.bytes);case 1:{const n=f0(e,t,r.bytes);return new a0(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return a0.create(0,h0,e)}static createV1(e,t){return a0.create(1,e,t)}static decode(e){const[t,r]=a0.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=a0.inspectBytes(e),r=t.size-t.multihashSize,n=UZ(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 J$(t.multihashCode,t.digestSize,i,n);return[0===t.version?a0.createV0(o):a0.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=H$(e.subarray(t));return t+=n,r};let n=r(),i=h0;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]=c0(e,t),i=a0.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return s0(i).set(r,e),i}}const c0=(e,t)=>{switch(e[0]){case"Q":{const r=t||HZ;return[HZ.prefix,r.decode("".concat(HZ.prefix).concat(e))]}case HZ.prefix:{const r=t||HZ;return[HZ.prefix,r.decode(e)]}case t$.prefix:{const r=t||t$;return[t$.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)]}},l0=(e,t,r)=>{const{prefix:n}=r;if(n!==HZ.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},u0=(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},h0=112,d0=18,f0=(e,t,r)=>{const n=G$(e),i=n+G$(t),o=new Uint8Array(i+r.byteLength);return W$(e,o,0),W$(t,o,n),o.set(r,i),o},p0=Symbol.for("@ipld/js-cid/CID"),g0={...hn,...on,...un,...rn,...nn,...an,...cn,...tn,...ln,...sn},b0=Symbol.for("nodejs.util.inspect.custom"),y0=Object.values(g0).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),g0.identity.decoder),m0=114,w0=36,v0=37;class _0{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=HZ.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return a0.createV1(m0,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:y0,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=Q$(HZ.decode("z".concat(e)));return e.startsWith("12D")?new S0({multihash:t}):e.startsWith("16U")?new A0({multihash:t}):new E0({multihash:t})}return function(e){try{const t=Q$(e);if(t.code===Z$.code){if(t.digest.length===w0)return new S0({multihash:t});if(t.digest.length===v0)return new A0({multihash:t})}if(t.code===r0.code)return new E0({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==m0)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===r0.code)return new E0({multihash:e.multihash});if(t.code===Z$.code){if(t.digest.length===w0)return new S0({multihash:e.multihash});if(t.digest.length===v0)return new A0({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(a0.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(y0.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[b0](){return"PeerId(".concat(this.toString(),")")}}class E0 extends _0{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class S0 extends _0{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class A0 extends _0{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}const x0=new Float32Array([-0]),k0=new Uint8Array(x0.buffer);function C0(e,t,r){x0[0]=e,t[r]=k0[0],t[r+1]=k0[1],t[r+2]=k0[2],t[r+3]=k0[3]}const I0=new Float64Array([-0]),T0=new Uint8Array(I0.buffer);function P0(e,t,r){I0[0]=e,t[r]=T0[0],t[r+1]=T0[1],t[r+2]=T0[2],t[r+3]=T0[3],t[r+4]=T0[4],t[r+5]=T0[5],t[r+6]=T0[6],t[r+7]=T0[7]}const R0=BigInt(Number.MAX_SAFE_INTEGER),D0=BigInt(Number.MIN_SAFE_INTEGER);class N0{constructor(e,t){Ji(this,"lo",void 0),Ji(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 B0;if(e<R0&&e>D0)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>L0&&(n=0n,++r>L0&&(r=0n))),new N0(Number(n),Number(r))}static fromNumber(e){if(0===e)return B0;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 N0(r,n)}static from(e){return"number"===typeof e?N0.fromNumber(e):"bigint"===typeof e?N0.fromBigInt(e):"string"===typeof e?N0.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new N0(e.low>>>0,e.high>>>0):B0}}const B0=new N0(0,0);B0.toBigInt=function(){return 0n},B0.zzEncode=B0.zzDecode=function(){return this},B0.length=function(){return 1};const L0=4294967296n;function U0(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 M0(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function O0(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class q0{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,M0(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 M0(this,4);return O0(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw M0(this,4);return 0|O0(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw M0(this,4);const e=(t=this.buf,r=this.pos,k0[0]=t[r],k0[1]=t[r+1],k0[2]=t[r+2],k0[3]=t[r+3],x0[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw M0(this,4);const e=(t=this.buf,r=this.pos,T0[0]=t[r],T0[1]=t[r+1],T0[2]=t[r+2],T0[3]=t[r+3],T0[4]=t[r+4],T0[5]=t[r+5],T0[6]=t[r+6],T0[7]=t[r+7],I0[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 M0(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 M0(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw M0(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 N0(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw M0(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 M0(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 M0(this,8);const e=O0(this.buf,this.pos+=4),t=O0(this.buf,this.pos+=4);return new N0(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 z0(e,t,r){const n=function(e){return new q0(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function F0(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function K0(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 V0=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const j0=V0;class H0{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 W0{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 Y0(this,e)}}class G0{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return Y0(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 Y0(e,t){var r,n;return new G0({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Q0{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new H0(e,t,r),this.decoder=new W0(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function J0(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Q0(t,r,n,i)}function X0(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=j0(n,t);return J0({prefix:r,name:t,encode:i,decode:e=>K0(o(e))})}function Z0(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return J0({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 $0=X0({prefix:"9",name:"base10",alphabet:"0123456789"}),e1=Z0({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),t1=Z0({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),r1=Z0({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),n1=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"),i1=n1.reduce(((e,t,r)=>(e[r]=t,e)),[]),o1=n1.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const s1=J0({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=i1[t]),"")},decode:function(e){const t=[];for(const r of e){const e=o1[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),a1=Z0({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),c1=Z0({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),l1=Z0({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),u1=Z0({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),h1=Z0({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),d1=Z0({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),f1=Z0({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),p1=Z0({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),g1=Z0({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),b1=X0({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),y1=X0({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),m1=X0({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),w1=X0({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),v1=Z0({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),_1=Z0({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),E1=Z0({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),S1=Z0({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),A1=Z0({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),x1=J0({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)}),k1=new TextEncoder,C1=new TextDecoder,I1="json",T1=512;function P1(e){return k1.encode(JSON.stringify(e))}function R1(e){return JSON.parse(C1.decode(e))}const D1="raw",N1=85;function B1(e){return K0(e)}function L1(e){return K0(e)}var U1=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=q1;)r[n++]=255&t|M1,t/=128;for(;t&O1;)r[n++]=255&t|M1,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},M1=128,O1=-128,q1=Math.pow(2,31);var z1=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&K1)<<o:(n&K1)*Math.pow(2,o),o+=7}while(n>=F1);return e.bytes=s-r,i},F1=128,K1=127;var V1=Math.pow(2,7),j1=Math.pow(2,14),H1=Math.pow(2,21),W1=Math.pow(2,28),G1=Math.pow(2,35),Y1=Math.pow(2,42),Q1=Math.pow(2,49),J1=Math.pow(2,56),X1=Math.pow(2,63);const Z1={encode:U1,decode:z1,encodingLength:function(e){return e<V1?1:e<j1?2:e<H1?3:e<W1?4:e<G1?5:e<Y1?6:e<Q1?7:e<J1?8:e<X1?9:10}};function $1(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Z1.encode(e,t,r),t}function e2(e){return Z1.encodingLength(e)}function t2(e,t){const r=t.byteLength,n=e2(e),i=n+e2(r),o=new Uint8Array(i+r);return $1(e,o,0),$1(r,o,n),o.set(t,i),new r2(e,r,t,o)}class r2{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const n2=K0;const i2={code:0,name:"identity",encode:n2,digest:function(e){return t2(0,n2(e))}};function o2(e){let{name:t,code:r,encode:n}=e;return new s2(t,r,n)}class s2{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?t2(this.code,t):t.then((e=>t2(this.code,e)))}throw Error("Unknown type, must be binary type")}}function a2(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const c2=o2({name:"sha2-256",code:18,encode:a2("SHA-256")}),l2=o2({name:"sha2-512",code:19,encode:a2("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const u2={...xn,...mn,...An,...bn,...yn,...vn,..._n,...En,...Sn,...wn};function h2(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const d2=h2("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),f2=h2("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=F0((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),p2={utf8:d2,"utf-8":d2,hex:u2.base16,latin1:f2,ascii:f2,binary:f2,...u2};class g2{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function b2(){}class y2{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const m2=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 F0(e);i+e>t&&(n=F0(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class w2{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new g2(b2,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new g2(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new E2((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(S2,10,N0.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=N0.fromBigInt(e);return this._push(S2,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=N0.fromBigInt(e).zzEncode();return this._push(S2,t.length(),t)}sint64Number(e){const t=N0.fromNumber(e).zzEncode();return this._push(S2,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(v2,1,e?1:0)}fixed32(e){return this._push(A2,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=N0.fromBigInt(e);return this._push(A2,4,t.lo)._push(A2,4,t.hi)}fixed64Number(e){const t=N0.fromNumber(e);return this._push(A2,4,t.lo)._push(A2,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(C0,4,e)}double(e){return this._push(P0,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(v2,1,0):this.uint32(t)._push(x2,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(U0,t,e):this._push(v2,1,0)}fork(){return this.states=new y2(this),this.head=this.tail=new g2(b2,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 g2(b2,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?F0(r):m2(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function v2(e,t,r){t[r]=255&e}function _2(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class E2 extends g2{constructor(e,t){super(_2,e,t),Ji(this,"next",void 0),this.next=void 0}}function S2(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 A2(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 x2(e,t,r){t.set(e,r)}function k2(e,t,r){t.set(e,r)}function C2(e,t,r){e.length<40?U0(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=p2[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function I2(e,t){const r=new w2;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var T2,P2;null!=globalThis.Buffer&&(w2.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(k2,t,e),this},w2.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(C2,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"}(T2||(T2={}));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",T2.LENGTH_DELIMITED,e,t)}((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.id&&(t.uint32(10),t.bytes(e.id)),null!=e.pubKey&&(t.uint32(18),t.bytes(e.pubKey)),null!=e.privKey&&(t.uint32(26),t.bytes(e.privKey)),!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.id=e.bytes();break;case 2:r.pubKey=e.bytes();break;case 3:r.privKey=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>I2(t,e.codec()),e.decode=t=>z0(t,e.codec())}(P2||(P2={}));const R2=async()=>{const e=await b_("Ed25519"),t=await D2(e);if("Ed25519"===t.type)return t;throw new Error('Generated unexpected PeerId type "'.concat(t.type,'"'))};async function D2(e){return async function(e,t){return e.length===w0?new S0({multihash:Y$(Z$.code,e),privateKey:t}):e.length===v0?new A0({multihash:Y$(Z$.code,e),privateKey:t}):new E0({multihash:await r0.digest(e),publicKey:e,privateKey:t})}(m_(e.public),function(e,t){var r;return g_(t=(null!==(r=t)&&void 0!==r?r:"rsa").toLowerCase()),e.bytes}(e))}var N2=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const B2=N2,L2=(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 U2{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 M2{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 q2(this,e)}}class O2{constructor(e){this.decoders=e}or(e){return q2(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 q2=(e,t)=>new O2({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class z2{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new U2(e,t,r),this.decoder=new M2(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const F2=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new z2(t,r,n,i)},K2=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=B2(n,r);return F2({prefix:t,name:r,encode:i,decode:e=>L2(o(e))})},V2=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return F2({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},j2=V2({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),H2=V2({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),W2=V2({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),G2=V2({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Y2=V2({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Q2=V2({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),J2=V2({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),X2=V2({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Z2=V2({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),$2=K2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),e3=K2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),t3=V2({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),r3=V2({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),n3=V2({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),i3=V2({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function o3(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}yl.formatters.b=e=>null==e?"undefined":$2.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":j2.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":t3.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();var s3=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const a3=s3,c3=(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 l3{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 u3{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 d3(this,e)}}class h3{constructor(e){this.decoders=e}or(e){return d3(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 d3=(e,t)=>new h3({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class f3{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new l3(e,t,r),this.decoder=new u3(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const p3=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new f3(t,r,n,i)},g3=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=a3(n,r);return p3({prefix:t,name:r,encode:i,decode:e=>c3(o(e))})},b3=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return p3({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},y3=g3({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),m3=g3({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),w3=g3({prefix:"9",name:"base10",alphabet:"0123456789"}),v3=b3({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_3=b3({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),E3=b3({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),S3=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"),A3=S3.reduce(((e,t,r)=>(e[r]=t,e)),[]),x3=S3.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const k3=p3({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=A3[t]),"")},decode:function(e){const t=[];for(const r of e){const e=x3[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),C3=b3({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),I3=b3({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),T3=b3({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),P3=b3({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),R3=b3({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),D3=b3({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),N3=b3({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),B3=b3({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),L3=b3({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),U3=g3({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),M3=g3({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),O3=b3({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),q3=b3({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),z3=b3({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),F3=b3({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),K3=b3({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),V3=p3({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),j3=new TextEncoder,H3=new TextDecoder,W3="json",G3=512,Y3=e=>j3.encode(JSON.stringify(e)),Q3=e=>JSON.parse(H3.decode(e)),J3="raw",X3=85,Z3=e=>c3(e),$3=e=>c3(e);var e6=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=n6;)r[n++]=255&t|t6,t/=128;for(;t&r6;)r[n++]=255&t|t6,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},t6=128,r6=-128,n6=Math.pow(2,31);var i6=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&s6)<<o:(n&s6)*Math.pow(2,o),o+=7}while(n>=o6);return e.bytes=s-r,i},o6=128,s6=127;var a6=Math.pow(2,7),c6=Math.pow(2,14),l6=Math.pow(2,21),u6=Math.pow(2,28),h6=Math.pow(2,35),d6=Math.pow(2,42),f6=Math.pow(2,49),p6=Math.pow(2,56),g6=Math.pow(2,63);const b6={encode:e6,decode:i6,encodingLength:function(e){return e<a6?1:e<c6?2:e<l6?3:e<u6?4:e<h6?5:e<d6?6:e<f6?7:e<p6?8:e<g6?9:10}},y6=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[b6.decode(e,t),b6.decode.bytes]},m6=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b6.encode(e,t,r),t},w6=e=>b6.encodingLength(e),v6=(e,t)=>{const r=t.byteLength,n=w6(e),i=n+w6(r),o=new Uint8Array(i+r);return m6(e,o,0),m6(r,o,n),o.set(t,i),new E6(e,r,t,o)},_6=e=>{const t=c3(e),[r,n]=y6(t),[i,o]=y6(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new E6(r,i,s,t)};class E6{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const S6=c3,A6={code:0,name:"identity",encode:S6,digest:e=>v6(0,S6(e))},x6=e=>{let{name:t,code:r,encode:n}=e;return new k6(t,r,n)};class k6{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?v6(this.code,t):t.then((e=>v6(this.code,e)))}throw Error("Unknown type, must be binary type")}}const C6=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),I6=x6({name:"sha2-256",code:18,encode:C6("SHA-256")}),T6=x6({name:"sha2-512",code:19,encode:C6("SHA-512")}),P6=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?L6(r,D6(e),t||y3.encoder):U6(r,D6(e),t||C3.encoder)},R6=new WeakMap,D6=e=>{const t=R6.get(e);if(null==t){const t=new Map;return R6.set(e,t),t}return t};class N6{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!==M6)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==O6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return N6.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=v6(e,t);return N6.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 N6.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 P6(this,e)}toJSON(){return{"/":P6(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 N6)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new N6(e,r,n,i||q6(e,r,n.bytes))}if(!0===t[z6]){const{version:e,multihash:r,code:n}=t,i=_6(r);return N6.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!==M6)throw new Error("Version 0 CID must use dag-pb (code: ".concat(M6,") block encoding"));return new N6(e,t,r,r.bytes);case 1:{const n=q6(e,t,r.bytes);return new N6(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return N6.create(0,M6,e)}static createV1(e,t){return N6.create(1,e,t)}static decode(e){const[t,r]=N6.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=N6.inspectBytes(e),r=t.size-t.multihashSize,n=c3(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 E6(t.multihashCode,t.digestSize,i,n);return[0===t.version?N6.createV0(o):N6.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=y6(e.subarray(t));return t+=n,r};let n=r(),i=M6;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]=B6(e,t),i=N6.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return D6(i).set(r,e),i}}const B6=(e,t)=>{switch(e[0]){case"Q":{const r=t||y3;return[y3.prefix,r.decode("".concat(y3.prefix).concat(e))]}case y3.prefix:{const r=t||y3;return[y3.prefix,r.decode(e)]}case C3.prefix:{const r=t||C3;return[C3.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)]}},L6=(e,t,r)=>{const{prefix:n}=r;if(n!==y3.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},U6=(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},M6=112,O6=18,q6=(e,t,r)=>{const n=w6(e),i=n+w6(t),o=new Uint8Array(i+r.byteLength);return m6(e,o,0),m6(t,o,n),o.set(r,i),o},z6=Symbol.for("@ipld/js-cid/CID"),F6={...Kn,...Un,...Fn,...Bn,...Ln,...On,...qn,...Nn,...zn,...Mn},K6=Symbol.for("nodejs.util.inspect.custom"),V6=Object.values(F6).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),F6.identity.decoder),j6=114,H6=36,W6=37;class G6{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=y3.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return N6.createV1(j6,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:V6,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=_6(y3.decode("z".concat(e)));return e.startsWith("12D")?new Q6({multihash:t}):e.startsWith("16U")?new J6({multihash:t}):new Y6({multihash:t})}return X6(V6.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[K6](){return"PeerId(".concat(this.toString(),")")}}class Y6 extends G6{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class Q6 extends G6{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class J6 extends G6{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function X6(e){try{const t=_6(e);if(t.code===A6.code){if(t.digest.length===H6)return new Q6({multihash:t});if(t.digest.length===W6)return new J6({multihash:t})}if(t.code===I6.code)return new Y6({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==j6)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===I6.code)return new Y6({multihash:e.multihash});if(t.code===A6.code){if(t.digest.length===H6)return new Q6({multihash:e.multihash});if(t.digest.length===W6)return new J6({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(N6.decode(e))}throw new Error("Supplied PeerID CID is invalid")}const Z6="ERR_SIGNATURE_NOT_VALID",$6=new Float32Array([-0]),e5=new Uint8Array($6.buffer);function t5(e,t,r){$6[0]=e,t[r]=e5[0],t[r+1]=e5[1],t[r+2]=e5[2],t[r+3]=e5[3]}const r5=new Float64Array([-0]),n5=new Uint8Array(r5.buffer);function i5(e,t,r){r5[0]=e,t[r]=n5[0],t[r+1]=n5[1],t[r+2]=n5[2],t[r+3]=n5[3],t[r+4]=n5[4],t[r+5]=n5[5],t[r+6]=n5[6],t[r+7]=n5[7]}const o5=BigInt(Number.MAX_SAFE_INTEGER),s5=BigInt(Number.MIN_SAFE_INTEGER);class a5{constructor(e,t){Ji(this,"lo",void 0),Ji(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 c5;if(e<o5&&e>s5)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>l5&&(n=0n,++r>l5&&(r=0n))),new a5(Number(n),Number(r))}static fromNumber(e){if(0===e)return c5;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 a5(r,n)}static from(e){return"number"===typeof e?a5.fromNumber(e):"bigint"===typeof e?a5.fromBigInt(e):"string"===typeof e?a5.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new a5(e.low>>>0,e.high>>>0):c5}}const c5=new a5(0,0);c5.toBigInt=function(){return 0n},c5.zzEncode=c5.zzDecode=function(){return this},c5.length=function(){return 1};const l5=4294967296n;function u5(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 h5(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function d5(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class f5{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,h5(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 h5(this,4);return d5(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw h5(this,4);return 0|d5(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw h5(this,4);const e=(t=this.buf,r=this.pos,e5[0]=t[r],e5[1]=t[r+1],e5[2]=t[r+2],e5[3]=t[r+3],$6[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw h5(this,4);const e=(t=this.buf,r=this.pos,n5[0]=t[r],n5[1]=t[r+1],n5[2]=t[r+2],n5[3]=t[r+3],n5[4]=t[r+4],n5[5]=t[r+5],n5[6]=t[r+6],n5[7]=t[r+7],r5[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 h5(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 h5(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw h5(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 a5(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw h5(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 h5(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 h5(this,8);const e=d5(this.buf,this.pos+=4),t=d5(this.buf,this.pos+=4);return new a5(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 p5(e,t,r){const n=function(e){return new f5(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function g5(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function b5(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 y5=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const m5=y5;class w5{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 v5{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 E5(this,e)}}class _5{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return E5(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 E5(e,t){var r,n;return new _5({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class S5{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new w5(e,t,r),this.decoder=new v5(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function A5(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new S5(t,r,n,i)}function x5(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=m5(n,t);return A5({prefix:r,name:t,encode:i,decode:e=>b5(o(e))})}function k5(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return A5({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 C5=x5({prefix:"9",name:"base10",alphabet:"0123456789"}),I5=k5({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),T5=k5({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),P5=k5({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),R5=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"),D5=R5.reduce(((e,t,r)=>(e[r]=t,e)),[]),N5=R5.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const B5=A5({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=D5[t]),"")},decode:function(e){const t=[];for(const r of e){const e=N5[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),L5=k5({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U5=k5({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),M5=k5({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),O5=k5({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),q5=k5({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),z5=k5({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),F5=k5({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),K5=k5({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),V5=k5({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),j5=x5({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),H5=x5({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),W5=x5({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),G5=x5({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Y5=k5({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Q5=k5({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),J5=k5({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),X5=k5({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Z5=k5({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),$5=A5({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)}),e4=new TextEncoder,t4=new TextDecoder,r4="json",n4=512;function i4(e){return e4.encode(JSON.stringify(e))}function o4(e){return JSON.parse(t4.decode(e))}const s4="raw",a4=85;function c4(e){return b5(e)}function l4(e){return b5(e)}var u4=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=f4;)r[n++]=255&t|h4,t/=128;for(;t&d4;)r[n++]=255&t|h4,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},h4=128,d4=-128,f4=Math.pow(2,31);var p4=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&b4)<<o:(n&b4)*Math.pow(2,o),o+=7}while(n>=g4);return e.bytes=s-r,i},g4=128,b4=127;var y4=Math.pow(2,7),m4=Math.pow(2,14),w4=Math.pow(2,21),v4=Math.pow(2,28),_4=Math.pow(2,35),E4=Math.pow(2,42),S4=Math.pow(2,49),A4=Math.pow(2,56),x4=Math.pow(2,63);const k4={encode:u4,decode:p4,encodingLength:function(e){return e<y4?1:e<m4?2:e<w4?3:e<v4?4:e<_4?5:e<E4?6:e<S4?7:e<A4?8:e<x4?9:10}};function C4(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return k4.encode(e,t,r),t}function I4(e){return k4.encodingLength(e)}function T4(e,t){const r=t.byteLength,n=I4(e),i=n+I4(r),o=new Uint8Array(i+r);return C4(e,o,0),C4(r,o,n),o.set(t,i),new P4(e,r,t,o)}class P4{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const R4=b5;const D4={code:0,name:"identity",encode:R4,digest:function(e){return T4(0,R4(e))}};function N4(e){let{name:t,code:r,encode:n}=e;return new B4(t,r,n)}class B4{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?T4(this.code,t):t.then((e=>T4(this.code,e)))}throw Error("Unknown type, must be binary type")}}function L4(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const U4=N4({name:"sha2-256",code:18,encode:L4("SHA-256")}),M4=N4({name:"sha2-512",code:19,encode:L4("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const O4={...ri,...Qn,...ti,...Gn,...Yn,...Xn,...Zn,...$n,...ei,...Jn};function q4(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const z4=q4("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),F4=q4("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=g5((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),K4={utf8:z4,"utf-8":z4,hex:O4.base16,latin1:F4,ascii:F4,binary:F4,...O4};class V4{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function j4(){}class H4{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const W4=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 g5(e);i+e>t&&(n=g5(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class G4{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new V4(j4,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new V4(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new J4((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(X4,10,a5.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=a5.fromBigInt(e);return this._push(X4,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=a5.fromBigInt(e).zzEncode();return this._push(X4,t.length(),t)}sint64Number(e){const t=a5.fromNumber(e).zzEncode();return this._push(X4,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Y4,1,e?1:0)}fixed32(e){return this._push(Z4,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=a5.fromBigInt(e);return this._push(Z4,4,t.lo)._push(Z4,4,t.hi)}fixed64Number(e){const t=a5.fromNumber(e);return this._push(Z4,4,t.lo)._push(Z4,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(t5,4,e)}double(e){return this._push(i5,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Y4,1,0):this.uint32(t)._push($4,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(u5,t,e):this._push(Y4,1,0)}fork(){return this.states=new H4(this),this.head=this.tail=new V4(j4,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 V4(j4,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?g5(r):W4(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Y4(e,t,r){t[r]=255&e}function Q4(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class J4 extends V4{constructor(e,t){super(Q4,e,t),Ji(this,"next",void 0),this.next=void 0}}function X4(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 Z4(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 $4(e,t,r){t.set(e,r)}function e8(e,t,r){t.set(e,r)}function t8(e,t,r){e.length<40?u5(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=K4[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function r8(e,t){const r=new G4;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var n8,i8,o8;function s8(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",n8.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(G4.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(e8,t,e),this},G4.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(t8,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"}(n8||(n8={}));Error;!function(e){let t;e.codec=()=>(null==t&&(t=s8((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=>r8(t,e.codec()),e.decode=t=>p5(t,e.codec())}(i8||(i8={}));class a8{constructor(e){Ji(this,"peerId",void 0),Ji(this,"payloadType",void 0),Ji(this,"payload",void 0),Ji(this,"signature",void 0),Ji(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=i8.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return ls(this.marshal(),e.marshal())}async validate(e){const t=c8(e,this.payloadType,this.payload);if(null==this.peerId.publicKey)throw new Error("Missing public key");return y_(this.peerId.publicKey).verify(t.subarray(),this.signature)}}o8=a8,Ji(a8,"createFromProtobuf",(async e=>{const t=i8.decode(e),r=await async function(e,t){return e.length===H6?new Q6({multihash:v6(A6.code,e),privateKey:t}):e.length===W6?new J6({multihash:v6(A6.code,e),privateKey:t}):new Y6({multihash:await I6.digest(e),publicKey:e,privateKey:t})}(t.publicKey);return new o8({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})})),Ji(a8,"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=c8(r,n,i),s=await w_(t.privateKey),a=await s.sign(o.subarray());return new o8({peerId:t,payloadType:n,payload:i,signature:a})})),Ji(a8,"openAndCertify",(async(e,t)=>{const r=await o8.createFromProtobuf(e);if(!await r.validate(t))throw new ly("envelope signature is not valid for the given domain",Z6);return r}));const c8=(e,t,r)=>{const n=kc(e),i=Ol(n.byteLength),o=Ol(t.length),s=Ol(r.length);return new Jd(i,n,o,t,s,r)};const l8=Uint8Array.from([3,1]);var u8,h8;!function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=s8((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=>r8(t,e.codec()),e.decode=t=>p5(t,e.codec())}(t=e.AddressInfo||(e.AddressInfo={})),e.codec=()=>(null==r&&(r=s8((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=>r8(t,e.codec()),e.decode=t=>p5(t,e.codec())}(u8||(u8={}));class d8{constructor(e){Ji(this,"peerId",void 0),Ji(this,"multiaddrs",void 0),Ji(this,"seqNumber",void 0),Ji(this,"domain",d8.DOMAIN),Ji(this,"codec",d8.CODEC),Ji(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=u8.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof d8&&(!!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)))}}h8=d8,Ji(d8,"createFromProtobuf",(e=>{var t;const r=u8.decode(e),n=X6(r.peerId),i=(null!==(t=r.addresses)&&void 0!==t?t:[]).map((e=>gl(e.multiaddr))),o=r.seq;return new h8({peerId:n,multiaddrs:i,seqNumber:o})})),Ji(d8,"DOMAIN","libp2p-peer-record"),Ji(d8,"CODEC",l8);const f8=K2({prefix:"9",name:"base10",alphabet:"0123456789"}),p8=V2({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),g8=V2({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),b8=V2({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),y8=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"),m8=y8.reduce(((e,t,r)=>(e[r]=t,e)),[]),w8=y8.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const v8=F2({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=m8[t]),"")},decode:function(e){const t=[];for(const r of e){const e=w8[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),_8=K2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),E8=K2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),S8=V2({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),A8=F2({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),x8=new TextEncoder,k8=new TextDecoder,C8="json",I8=512,T8=e=>x8.encode(JSON.stringify(e)),P8=e=>JSON.parse(k8.decode(e)),R8="raw",D8=85,N8=e=>L2(e),B8=e=>L2(e);var L8=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=O8;)r[n++]=255&t|U8,t/=128;for(;t&M8;)r[n++]=255&t|U8,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},U8=128,M8=-128,O8=Math.pow(2,31);var q8=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&F8)<<o:(n&F8)*Math.pow(2,o),o+=7}while(n>=z8);return e.bytes=s-r,i},z8=128,F8=127;var K8=Math.pow(2,7),V8=Math.pow(2,14),j8=Math.pow(2,21),H8=Math.pow(2,28),W8=Math.pow(2,35),G8=Math.pow(2,42),Y8=Math.pow(2,49),Q8=Math.pow(2,56),J8=Math.pow(2,63);const X8={encode:L8,decode:q8,encodingLength:function(e){return e<K8?1:e<V8?2:e<j8?3:e<H8?4:e<W8?5:e<G8?6:e<Y8?7:e<Q8?8:e<J8?9:10}},Z8=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[X8.decode(e,t),X8.decode.bytes]},$8=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return X8.encode(e,t,r),t},e7=e=>X8.encodingLength(e),t7=(e,t)=>{const r=t.byteLength,n=e7(e),i=n+e7(r),o=new Uint8Array(i+r);return $8(e,o,0),$8(r,o,n),o.set(t,i),new n7(e,r,t,o)},r7=e=>{const t=L2(e),[r,n]=Z8(t),[i,o]=Z8(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new n7(r,i,s,t)};class n7{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const i7=L2,o7={code:0,name:"identity",encode:i7,digest:e=>t7(0,i7(e))},s7=e=>{let{name:t,code:r,encode:n}=e;return new a7(t,r,n)};class a7{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?t7(this.code,t):t.then((e=>t7(this.code,e)))}throw Error("Unknown type, must be binary type")}}const c7=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),l7=s7({name:"sha2-256",code:18,encode:c7("SHA-256")}),u7=s7({name:"sha2-512",code:19,encode:c7("SHA-512")}),h7=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?b7(r,f7(e),t||$2.encoder):y7(r,f7(e),t||j2.encoder)},d7=new WeakMap,f7=e=>{const t=d7.get(e);if(null==t){const t=new Map;return d7.set(e,t),t}return t};class p7{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!==m7)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==w7)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return p7.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=t7(e,t);return p7.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 p7.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 h7(this,e)}toJSON(){return{"/":h7(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 p7)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new p7(e,r,n,i||v7(e,r,n.bytes))}if(!0===t[_7]){const{version:e,multihash:r,code:n}=t,i=r7(r);return p7.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!==m7)throw new Error("Version 0 CID must use dag-pb (code: ".concat(m7,") block encoding"));return new p7(e,t,r,r.bytes);case 1:{const n=v7(e,t,r.bytes);return new p7(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return p7.create(0,m7,e)}static createV1(e,t){return p7.create(1,e,t)}static decode(e){const[t,r]=p7.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=p7.inspectBytes(e),r=t.size-t.multihashSize,n=L2(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 n7(t.multihashCode,t.digestSize,i,n);return[0===t.version?p7.createV0(o):p7.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Z8(e.subarray(t));return t+=n,r};let n=r(),i=m7;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]=g7(e,t),i=p7.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return f7(i).set(r,e),i}}const g7=(e,t)=>{switch(e[0]){case"Q":{const r=t||$2;return[$2.prefix,r.decode("".concat($2.prefix).concat(e))]}case $2.prefix:{const r=t||$2;return[$2.prefix,r.decode(e)]}case j2.prefix:{const r=t||j2;return[j2.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)]}},b7=(e,t,r)=>{const{prefix:n}=r;if(n!==$2.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},y7=(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},m7=112,w7=18,v7=(e,t,r)=>{const n=e7(e),i=n+e7(t),o=new Uint8Array(i+r.byteLength);return $8(e,o,0),$8(t,o,n),o.set(r,i),o},_7=Symbol.for("@ipld/js-cid/CID"),E7={...fi,...li,...di,...ai,...ci,...Pn,...hi,...Rn,...Dn,...ui},S7=Symbol.for("nodejs.util.inspect.custom"),A7=Object.values(E7).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),E7.identity.decoder),x7=114,k7=36,C7=37;class I7{constructor(e){Ji(this,"type",void 0),Ji(this,"multihash",void 0),Ji(this,"privateKey",void 0),Ji(this,"publicKey",void 0),Ji(this,"string",void 0),Ji(this,Xi,!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=$2.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return p7.createV1(x7,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){var t;if(e instanceof Uint8Array)return ls(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:A7,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=r7($2.decode("z".concat(e)));return e.startsWith("12D")?new P7({multihash:t}):e.startsWith("16U")?new R7({multihash:t}):new T7({multihash:t})}return D7(A7.decode(e))}(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return ls(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[S7](){return"PeerId(".concat(this.toString(),")")}}class T7 extends I7{constructor(e){super({...e,type:"RSA"}),Ji(this,"type","RSA"),Ji(this,"publicKey",void 0),this.publicKey=e.publicKey}}class P7 extends I7{constructor(e){super({...e,type:"Ed25519"}),Ji(this,"type","Ed25519"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}class R7 extends I7{constructor(e){super({...e,type:"secp256k1"}),Ji(this,"type","secp256k1"),Ji(this,"publicKey",void 0),this.publicKey=e.multihash.digest}}function D7(e){try{const t=r7(e);if(t.code===o7.code){if(t.digest.length===k7)return new P7({multihash:t});if(t.digest.length===C7)return new R7({multihash:t})}if(t.code===l7.code)return new T7({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==x7)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===l7.code)return new T7({multihash:e.multihash});if(t.code===o7.code){if(t.digest.length===k7)return new P7({multihash:e.multihash});if(t.digest.length===C7)return new R7({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(p7.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function N7(e,t,r){return r(to(e,t))}var B7=__webpack_require__(7283);class L7 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class U7 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const M7=e=>void 0===globalThis.DOMException?new U7(e):new DOMException(e),O7=e=>{const t=void 0===e.reason?M7("This operation was aborted."):e.reason;return t instanceof Error?t:M7(t)};function q7(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(O7(e)),e.addEventListener("abort",(()=>{c(O7(e))}))}if(r===Number.POSITIVE_INFINITY)return void e.then(a,c);const l=new L7;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):(l.message=null!==i&&void 0!==i?i:"Promise timed out after ".concat(r," milliseconds"),c(l))}),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}var z7=new WeakMap;class F7{constructor(){eo(this,z7,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&ro(z7,this)[this.size-1].priority>=t.priority)return void ro(z7,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}(ro(z7,this),r,((e,t)=>t.priority-e.priority));ro(z7,this).splice(n,0,r)}dequeue(){const e=ro(z7,this).shift();return null===e||void 0===e?void 0:e.run}filter(e){return ro(z7,this).filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return ro(z7,this).length}}var K7=new WeakMap,V7=new WeakMap,j7=new WeakMap,H7=new WeakMap,W7=new WeakMap,G7=new WeakMap,Y7=new WeakMap,Q7=new WeakMap,J7=new WeakMap,X7=new WeakMap,Z7=new WeakMap,$7=new WeakMap,e9=new WeakMap,t9=new WeakMap,r9=new WeakSet;class n9 extends B7{constructor(e){var t,r,n,i;if(super(),nH(this,r9),eo(this,K7,void 0),eo(this,V7,void 0),eo(this,j7,0),eo(this,H7,void 0),eo(this,W7,void 0),eo(this,G7,0),eo(this,Y7,void 0),eo(this,Q7,void 0),eo(this,J7,void 0),eo(this,X7,void 0),eo(this,Z7,0),eo(this,$7,void 0),eo(this,e9,void 0),eo(this,t9,void 0),Ji(this,"timeout",void 0),!("number"===typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:F7,...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,")"));no(K7,this,e.carryoverConcurrencyCount),no(V7,this,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval),no(H7,this,e.intervalCap),no(W7,this,e.interval),no(J7,this,new e.queueClass),no(X7,this,e.queueClass),this.concurrency=e.concurrency,this.timeout=e.timeout,no(t9,this,!0===e.throwOnTimeout),no(e9,this,!1===e.autoStart)}get concurrency(){return ro($7,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,")"));no($7,this,e),to(r9,this,d9).call(this)}async add(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t={timeout:this.timeout,throwOnTimeout:ro(t9,this),...t},new Promise(((r,n)=>{ro(J7,this).enqueue((async()=>{var i,o;no(Z7,this,(i=ro(Z7,this),i++,i)),no(j7,this,(o=ro(j7,this),o++,o));try{var s;null===(s=t.signal)||void 0===s||s.throwIfAborted();let n=e({signal:t.signal});t.timeout&&(n=q7(Promise.resolve(n),{milliseconds:t.timeout})),t.signal&&(n=Promise.race([n,to(r9,this,f9).call(this,t.signal)]));const i=await n;r(i),this.emit("completed",i)}catch(a){if(a instanceof L7&&!t.throwOnTimeout)return void r();n(a),this.emit("error",a)}finally{to(r9,this,s9).call(this)}}),t),this.emit("add"),to(r9,this,l9).call(this)}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return ro(e9,this)?(no(e9,this,!1),to(r9,this,d9).call(this),this):this}pause(){no(e9,this,!0)}clear(){no(J7,this,new(ro(X7,this)))}async onEmpty(){0!==ro(J7,this).size&&await to(r9,this,p9).call(this,"empty")}async onSizeLessThan(e){ro(J7,this).size<e||await to(r9,this,p9).call(this,"next",(()=>ro(J7,this).size<e))}async onIdle(){0===ro(Z7,this)&&0===ro(J7,this).size||await to(r9,this,p9).call(this,"idle")}get size(){return ro(J7,this).size}sizeBy(e){return ro(J7,this).filter(e).length}get pending(){return ro(Z7,this)}get isPaused(){return ro(e9,this)}}function i9(e){return ro(V7,e)||ro(j7,e)<ro(H7,e)}function o9(e){return ro(Z7,e)<ro($7,e)}function s9(){var e;no(Z7,this,(e=ro(Z7,this),e--,e)),to(r9,this,l9).call(this),this.emit("next")}function a9(){to(r9,this,h9).call(this),to(r9,this,u9).call(this),no(Q7,this,void 0)}function c9(e){const t=Date.now();if(void 0===ro(Y7,e)){const r=ro(G7,e)-t;if(!(r<0))return void 0===ro(Q7,e)&&no(Q7,e,setTimeout((()=>{to(r9,e,a9).call(e)}),r)),!0;no(j7,e,ro(K7,e)?ro(Z7,e):0)}return!1}function l9(){if(0===ro(J7,this).size)return ro(Y7,this)&&clearInterval(ro(Y7,this)),no(Y7,this,void 0),this.emit("empty"),0===ro(Z7,this)&&this.emit("idle"),!1;if(!ro(e9,this)){const e=!N7(r9,this,c9);if(N7(r9,this,i9)&&N7(r9,this,o9)){const t=ro(J7,this).dequeue();return!!t&&(this.emit("active"),t(),e&&to(r9,this,u9).call(this),!0)}}return!1}function u9(){ro(V7,this)||void 0!==ro(Y7,this)||(no(Y7,this,setInterval((()=>{to(r9,this,h9).call(this)}),ro(W7,this))),no(G7,this,Date.now()+ro(W7,this)))}function h9(){0===ro(j7,this)&&0===ro(Z7,this)&&ro(Y7,this)&&(clearInterval(ro(Y7,this)),no(Y7,this,void 0)),no(j7,this,ro(K7,this)?ro(Z7,this):0),to(r9,this,d9).call(this)}function d9(){for(;to(r9,this,l9).call(this););}async function f9(e){return new Promise(((t,r)=>{e.addEventListener("abort",(()=>{r(e.reason)}),{once:!0})}))}async function p9(e,t){return new Promise((r=>{const n=()=>{t&&!t()||(this.off(e,n),r())};this.on(e,n)}))}const g9={},b9=e=>{e.addEventListener("message",(t=>{b9.dispatchEvent("message",e,t)})),null!=e.port&&e.port.addEventListener("message",(t=>{b9.dispatchEvent("message",e,t)}))};b9.addEventListener=(e,t)=>{null==g9[e]&&(g9[e]=[]),g9[e].push(t)},b9.removeEventListener=(e,t)=>{null!=g9[e]&&(g9[e]=g9[e].filter((e=>e===t)))},b9.dispatchEvent=function(e,t,r){null!=g9[e]&&g9[e].forEach((e=>e(t,r)))};const y9=b9,m9="lock:worker:request-read",w9="lock:worker:release-read",v9="lock:master:grant-read",_9="lock:worker:request-write",E9="lock:worker:release-write",S9="lock:master:grant-write",A9=(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)}))}}}))},x9=(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)}))},k9={singleProcess:!1},C9={};let I9;async function T9(e,t){let r;const n=new Promise((e=>{r=e}));return e.add((async()=>q7((async()=>{await new Promise((e=>{r((()=>{e()}))}))})(),{milliseconds:t.timeout}))),n}const P9={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function R9(e){const t=Object.assign({},P9,e);return null==I9&&(I9=(e=>{if(e=Object.assign({},k9,e),Boolean(globalThis.document)||e.singleProcess){const e=new EventTarget;return y9.addEventListener("message",A9(e,"requestReadLock",m9,w9,v9)),y9.addEventListener("message",A9(e,"requestWriteLock",_9,E9,S9)),e}return{isWorker:!0,readLock:e=>x9(e,m9,v9,w9),writeLock:e=>x9(e,_9,S9,E9)}})(t),!0!==I9.isWorker&&(I9.addEventListener("requestReadLock",(e=>{null!=C9[e.data.name]&&C9[e.data.name].readLock().then((async t=>e.data.handler().finally((()=>{t()}))))})),I9.addEventListener("requestWriteLock",(async e=>{null!=C9[e.data.name]&&C9[e.data.name].writeLock().then((async t=>e.data.handler().finally((()=>{t()}))))})))),null==C9[t.name]&&(C9[t.name]=((e,t)=>{if(!0===I9.isWorker)return{readLock:I9.readLock(e,t),writeLock:I9.writeLock(e,t)};const r=new n9({concurrency:1});let n;return{async readLock(){if(null!=n)return T9(n,t);n=new n9({concurrency:t.concurrency,autoStart:!1});const e=n,i=T9(n,t);return r.add((async()=>{e.start(),await e.onIdle().then((()=>{n===e&&(n=null)}))})),i},writeLock:async()=>(n=null,T9(r,t))}})(t.name,t)),C9[t.name]}const D9={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS"},N9=new Float32Array([-0]),B9=new Uint8Array(N9.buffer);function L9(e,t,r){N9[0]=e,t[r]=B9[0],t[r+1]=B9[1],t[r+2]=B9[2],t[r+3]=B9[3]}const U9=new Float64Array([-0]),M9=new Uint8Array(U9.buffer);function O9(e,t,r){U9[0]=e,t[r]=M9[0],t[r+1]=M9[1],t[r+2]=M9[2],t[r+3]=M9[3],t[r+4]=M9[4],t[r+5]=M9[5],t[r+6]=M9[6],t[r+7]=M9[7]}const q9=BigInt(Number.MAX_SAFE_INTEGER),z9=BigInt(Number.MIN_SAFE_INTEGER);class F9{constructor(e,t){Ji(this,"lo",void 0),Ji(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 K9;if(e<q9&&e>z9)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>V9&&(n=0n,++r>V9&&(r=0n))),new F9(Number(n),Number(r))}static fromNumber(e){if(0===e)return K9;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 F9(r,n)}static from(e){return"number"===typeof e?F9.fromNumber(e):"bigint"===typeof e?F9.fromBigInt(e):"string"===typeof e?F9.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new F9(e.low>>>0,e.high>>>0):K9}}const K9=new F9(0,0);K9.toBigInt=function(){return 0n},K9.zzEncode=K9.zzDecode=function(){return this},K9.length=function(){return 1};const V9=4294967296n;function j9(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 H9(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function W9(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class G9{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,H9(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 H9(this,4);return W9(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw H9(this,4);return 0|W9(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw H9(this,4);const e=(t=this.buf,r=this.pos,B9[0]=t[r],B9[1]=t[r+1],B9[2]=t[r+2],B9[3]=t[r+3],N9[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw H9(this,4);const e=(t=this.buf,r=this.pos,M9[0]=t[r],M9[1]=t[r+1],M9[2]=t[r+2],M9[3]=t[r+3],M9[4]=t[r+4],M9[5]=t[r+5],M9[6]=t[r+6],M9[7]=t[r+7],U9[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 H9(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 H9(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw H9(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 F9(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw H9(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 H9(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 H9(this,8);const e=W9(this.buf,this.pos+=4),t=W9(this.buf,this.pos+=4);return new F9(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 Y9(e,t,r){const n=function(e){return new G9(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function Q9(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function J9(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 X9=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const Z9=X9;class $9{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 eee{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 ree(this,e)}}class tee{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return ree(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 ree(e,t){var r,n;return new tee({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class nee{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new $9(e,t,r),this.decoder=new eee(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function iee(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new nee(t,r,n,i)}function oee(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=Z9(n,t);return iee({prefix:r,name:t,encode:i,decode:e=>J9(o(e))})}function see(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return iee({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 aee=oee({prefix:"9",name:"base10",alphabet:"0123456789"}),cee=see({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lee=see({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),uee=see({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),hee=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"),dee=hee.reduce(((e,t,r)=>(e[r]=t,e)),[]),fee=hee.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const pee=iee({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=dee[t]),"")},decode:function(e){const t=[];for(const r of e){const e=fee[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),gee=see({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bee=see({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yee=see({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mee=see({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wee=see({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vee=see({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_ee=see({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Eee=see({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),See=see({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Aee=oee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xee=oee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),kee=oee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cee=oee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Iee=see({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tee=see({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pee=see({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ree=see({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Dee=see({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Nee=iee({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)}),Bee=new TextEncoder,Lee=new TextDecoder,Uee="json",Mee=512;function Oee(e){return Bee.encode(JSON.stringify(e))}function qee(e){return JSON.parse(Lee.decode(e))}const zee="raw",Fee=85;function Kee(e){return J9(e)}function Vee(e){return J9(e)}var jee=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Gee;)r[n++]=255&t|Hee,t/=128;for(;t&Wee;)r[n++]=255&t|Hee,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Hee=128,Wee=-128,Gee=Math.pow(2,31);var Yee=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&Jee)<<o:(n&Jee)*Math.pow(2,o),o+=7}while(n>=Qee);return e.bytes=s-r,i},Qee=128,Jee=127;var Xee=Math.pow(2,7),Zee=Math.pow(2,14),$ee=Math.pow(2,21),ete=Math.pow(2,28),tte=Math.pow(2,35),rte=Math.pow(2,42),nte=Math.pow(2,49),ite=Math.pow(2,56),ote=Math.pow(2,63);const ste={encode:jee,decode:Yee,encodingLength:function(e){return e<Xee?1:e<Zee?2:e<$ee?3:e<ete?4:e<tte?5:e<rte?6:e<nte?7:e<ite?8:e<ote?9:10}};function ate(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return ste.encode(e,t,r),t}function cte(e){return ste.encodingLength(e)}function lte(e,t){const r=t.byteLength,n=cte(e),i=n+cte(r),o=new Uint8Array(i+r);return ate(e,o,0),ate(r,o,n),o.set(t,i),new ute(e,r,t,o)}class ute{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const hte=J9;const dte={code:0,name:"identity",encode:hte,digest:function(e){return lte(0,hte(e))}};function fte(e){let{name:t,code:r,encode:n}=e;return new pte(t,r,n)}class pte{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?lte(this.code,t):t.then((e=>lte(this.code,e)))}throw Error("Unknown type, must be binary type")}}function gte(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const bte=fte({name:"sha2-256",code:18,encode:gte("SHA-256")}),yte=fte({name:"sha2-512",code:19,encode:gte("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const mte={...Ci,...vi,...ki,...mi,...wi,...Ei,...Si,...Ai,...xi,..._i};function wte(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const vte=wte("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),_te=wte("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Q9((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Ete={utf8:vte,"utf-8":vte,hex:mte.base16,latin1:_te,ascii:_te,binary:_te,...mte};class Ste{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Ate(){}class xte{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const kte=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 Q9(e);i+e>t&&(n=Q9(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class Cte{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new Ste(Ate,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Ste(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Pte((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Rte,10,F9.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=F9.fromBigInt(e);return this._push(Rte,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=F9.fromBigInt(e).zzEncode();return this._push(Rte,t.length(),t)}sint64Number(e){const t=F9.fromNumber(e).zzEncode();return this._push(Rte,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ite,1,e?1:0)}fixed32(e){return this._push(Dte,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=F9.fromBigInt(e);return this._push(Dte,4,t.lo)._push(Dte,4,t.hi)}fixed64Number(e){const t=F9.fromNumber(e);return this._push(Dte,4,t.lo)._push(Dte,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(L9,4,e)}double(e){return this._push(O9,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Ite,1,0):this.uint32(t)._push(Nte,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(j9,t,e):this._push(Ite,1,0)}fork(){return this.states=new xte(this),this.head=this.tail=new Ste(Ate,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 Ste(Ate,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?Q9(r):kte(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Ite(e,t,r){t[r]=255&e}function Tte(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Pte extends Ste{constructor(e,t){super(Tte,e,t),Ji(this,"next",void 0),this.next=void 0}}function Rte(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 Dte(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 Nte(e,t,r){t.set(e,r)}function Bte(e,t,r){t.set(e,r)}function Lte(e,t,r){e.length<40?j9(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=Ete[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function Ute(e,t){const r=new Cte;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Mte,Ote,qte,zte;function Fte(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",Mte.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Cte.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Bte,t,e),this},Cte.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Lte,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"}(Mte||(Mte={}));Error;function Kte(e,t){var r;const n=Ote.decode(t);null!=n.publicKey&&null==e.publicKey&&(e=function(e){if("RSA"===e.type)return new T7(e);if("Ed25519"===e.type)return new P7(e);if("secp256k1"===e.type)return new R7(e);throw new ly("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:gl(t),isCertified:null!==r&&void 0!==r&&r}})),metadata:n.metadata,peerRecordEnvelope:null!==(r=n.peerRecordEnvelope)&&void 0!==r?r:void 0,tags:i}}!function(e){let t,r,n;!function(e){let t;e.codec=()=>(null==t&&(t=Fte((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=>Ute(t,e.codec()),e.decode=t=>Y9(t,e.codec())}(t=e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(e){let t;e.codec=()=>(null==t&&(t=Fte((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),zte.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=zte.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Ute(t,e.codec()),e.decode=t=>Y9(t,e.codec())}(r=e.Peer$tagsEntry||(e.Peer$tagsEntry={})),e.codec=()=>(null==n&&(n=Fte((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),qte.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(qte.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=>Ute(t,e.codec()),e.decode=t=>Y9(t,e.codec())}(Ote||(Ote={})),function(e){let t;e.codec=()=>(null==t&&(t=Fte((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=>Ute(t,e.codec()),e.decode=t=>Y9(t,e.codec())}(qte||(qte={})),function(e){let t;e.codec=()=>(null==t&&(t=Fte((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=>Ute(t,e.codec()),e.decode=t=>Y9(t,e.codec())}(zte||(zte={}));const Vte="/peers/";function jte(e){if(!Zi(e)||null==e.type)throw new ly("Invalid PeerId",D9.ERR_INVALID_PARAMETERS);const t=e.toCID().toString();return new IY("".concat(Vte).concat(t))}async function Hte(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=gl(o.multiaddr)),!il(o.multiaddr))throw new ly("Multiaddr was invalid",D9.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 Wte(e,t,r,n){var i,o,s,a,c,l,u;if(null==t)throw new ly("Invalid PeerData",D9.ERR_INVALID_PARAMETERS);if(null!=t.publicKey&&null!=e.publicKey&&!ls(t.publicKey,e.publicKey))throw new ly("publicKey bytes do not match peer id publicKey bytes",D9.ERR_INVALID_PARAMETERS);const h=n.existingPeer;if(null!=h&&!e.equals(h.id))throw new ly("peer id did not match existing peer id",D9.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=Gte(t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata),{validate:Yte})}if(null!=t.tags){g=Gte(t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),{validate:Qte,map:Jte})}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=Gte([...p.entries()],{validate:Yte})}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=Gte([...r.entries()],{validate:Qte,map:Jte})}null!=t.peerRecordEnvelope&&(b=t.peerRecordEnvelope)}const y={addresses:await Hte(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!==(l=null!==(u=null===h||void 0===h?void 0:h.id.publicKey)&&void 0!==u?u:t.publicKey)&&void 0!==l?l:e.publicKey,peerRecordEnvelope:b};return"RSA"!==e.type&&delete y.publicKey,y}function Gte(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 Yte(e,t){if("string"!==typeof e)throw new ly("Metadata key must be a string",D9.ERR_INVALID_PARAMETERS);if(!(t instanceof Uint8Array))throw new ly("Metadata value must be a Uint8Array",D9.ERR_INVALID_PARAMETERS)}function Qte(e,t){if("string"!==typeof e)throw new ly("Tag name must be a string",D9.ERR_INVALID_PARAMETERS);if(null!=t.value){if(parseInt("".concat(t.value),10)!==t.value)throw new ly("Tag value must be an integer",D9.ERR_INVALID_PARAMETERS);if(t.value<0||t.value>100)throw new ly("Tag value must be between 0-100",D9.ERR_INVALID_PARAMETERS)}if(null!=t.ttl){if(parseInt("".concat(t.ttl),10)!==t.ttl)throw new ly("Tag ttl must be an integer",D9.ERR_INVALID_PARAMETERS);if(t.ttl<0)throw new ly("Tag ttl must be between greater than 0",D9.ERR_INVALID_PARAMETERS)}}function Jte(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 Xte(e,t,r){const n=e.toString().split("/")[2],i=D7(j2.decode(n)),o=r.get(i);if(null!=o)return o;const s=Kte(i,t);return r.set(i,s),s}var Zte=new WeakSet;class $te{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};nH(this,Zte),Ji(this,"peerId",void 0),Ji(this,"datastore",void 0),Ji(this,"lock",void 0),Ji(this,"addressFilter",void 0),this.peerId=e.peerId,this.datastore=e.datastore,this.addressFilter=t.addressFilter,this.lock=R9({name:"peer-store",singleProcess:!0})}async has(e){return this.datastore.has(jte(e))}async delete(e){if(this.peerId.equals(e))throw new ly("Cannot delete self peer",D9.ERR_INVALID_PARAMETERS);await this.datastore.delete(jte(e))}async load(e){return Kte(e,await this.datastore.get(jte(e)))}async save(e,t){const{existingBuf:r,existingPeer:n}=await to(Zte,this,ere).call(this,e),i=await Wte(e,t,"patch",{addressFilter:this.addressFilter});return to(Zte,this,tre).call(this,e,i,r,n)}async patch(e,t){const{existingBuf:r,existingPeer:n}=await to(Zte,this,ere).call(this,e),i=await Wte(e,t,"patch",{addressFilter:this.addressFilter,existingPeer:n});return to(Zte,this,tre).call(this,e,i,r,n)}async merge(e,t){const{existingBuf:r,existingPeer:n}=await to(Zte,this,ere).call(this,e),i=await Wte(e,t,"merge",{addressFilter:this.addressFilter,existingPeer:n});return to(Zte,this,tre).call(this,e,i,r,n)}async*all(e){const t=new hX;for await(const{key:r,value:n}of this.datastore.query(function(e,t){var r,n;return null==e?{}:{prefix:Vte,filters:(null!==(r=e.filters)&&void 0!==r?r:[]).map((e=>r=>{let{key:n,value:i}=r;return e(Xte(n,i,t))})),orders:(null!==(n=e.orders)&&void 0!==n?n:[]).map((e=>(r,n)=>e(Xte(r.key,r.value,t),Xte(n.key,n.value,t))))}}(null!==e&&void 0!==e?e:{},t))){const e=Xte(r,n,t);e.id.equals(this.peerId)||(yield e)}}}async function ere(e){try{const t=await this.datastore.get(jte(e));return{existingBuf:t,existingPeer:Kte(e,t)}}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t}return{}}async function tre(e,t,r,n){const i=Ote.encode(t);return null!=r&&ls(i,r)?{peer:Kte(e,i),previous:n,updated:!1}:(await this.datastore.put(jte(e),i),{peer:Kte(e,i),previous:n,updated:!0})}const rre=o3("libp2p:peer-store");var nre=new WeakSet;class ire{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};nH(this,nre),Ji(this,"store",void 0),Ji(this,"events",void 0),Ji(this,"peerId",void 0),this.events=e.events,this.peerId=e.peerId,this.store=new $te(e,t)}async forEach(e,t){rre.trace("forEach await read lock");const r=await this.store.lock.readLock();rre.trace("forEach got read lock");try{for await(const r of this.store.all(t))e(r)}finally{rre.trace("forEach release read lock"),r()}}async all(e){rre.trace("all await read lock");const t=await this.store.lock.readLock();rre.trace("all got read lock");try{return await Kd(this.store.all(e))}finally{rre.trace("all release read lock"),t()}}async delete(e){rre.trace("delete await write lock");const t=await this.store.lock.writeLock();rre.trace("delete got write lock");try{await this.store.delete(e)}finally{rre.trace("delete release write lock"),t()}}async has(e){rre.trace("has await read lock");const t=await this.store.lock.readLock();rre.trace("has got read lock");try{return await this.store.has(e)}finally{rre.trace("has release read lock"),t()}}async get(e){rre.trace("get await read lock");const t=await this.store.lock.readLock();rre.trace("get got read lock");try{return await this.store.load(e)}finally{rre.trace("get release read lock"),t()}}async save(e,t){rre.trace("save await write lock");const r=await this.store.lock.writeLock();rre.trace("save got write lock");try{const r=await this.store.save(e,t);return to(nre,this,ore).call(this,e,r),r.peer}finally{rre.trace("save release write lock"),r()}}async patch(e,t){rre.trace("patch await write lock");const r=await this.store.lock.writeLock();rre.trace("patch got write lock");try{const r=await this.store.patch(e,t);return to(nre,this,ore).call(this,e,r),r.peer}finally{rre.trace("patch release write lock"),r()}}async merge(e,t){rre.trace("merge await write lock");const r=await this.store.lock.writeLock();rre.trace("merge got write lock");try{const r=await this.store.merge(e,t);return to(nre,this,ore).call(this,e,r),r.peer}finally{rre.trace("merge release write lock"),r()}}async consumePeerRecord(e,t){var r;const n=await a8.openAndCertify(e,d8.DOMAIN);if(!1===(null===t||void 0===t?void 0:t.equals(n.peerId)))return rre("envelope peer id was not the expected peer id - expected: %p received: %p",t,n.peerId),!1;const i=d8.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 a8.createFromProtobuf(o.peerRecordEnvelope),t=d8.createFromProtobuf(e.payload);if(t.seqNumber>=i.seqNumber)return rre("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 ore(e,t){t.updated&&(this.peerId.equals(e)?this.events.safeDispatchEvent("self:peer:update",{detail:t}):this.events.safeDispatchEvent("peer:update",{detail:t}))}const sre=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e);})();for(const t of e);};const are=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 cre=function(e,t){if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)await t(r)&&(yield r)}();const r=are(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 lre=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){const r=await Kd(e);yield*r.sort(t)}():function*(){const r=Kd(e);yield*r.sort(t)}()};const ure=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 hre{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 sre(this.putMany(e,r)),e=[],await sre(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=cre(r,(e=>e.key.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>cre(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>lre(e,t)),r)),null!=e.offset){let t=0;const n=e.offset;r=cre(r,(()=>t++>=n))}return null!=e.limit&&(r=ure(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix){const t=e.prefix;r=cre(r,(e=>e.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>cre(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>lre(e,t)),r)),null!=e.offset){const t=e.offset;let n=0;r=cre(r,(()=>n++>=t))}return null!=e.limit&&(r=ure(r,e.limit)),r}}class dre extends hre{constructor(){super(),Ji(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"),ef(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 IY(e),value:t}}*_allKeys(){for(const e of this.data.keys())yield new IY(e)}}const fre=yQ("libp2p:address-manager"),pre=e=>e;function gre(e,t){const r=e.getPeerId();if(null!=r){DZ(r).equals(t)&&(e=e.decapsulate(gl("/p2p/".concat(t.toString()))))}return e}class bre{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ji(this,"components",void 0),Ji(this,"listen",void 0),Ji(this,"announce",void 0),Ji(this,"observed",void 0),Ji(this,"announceFilter",void 0);const{listen:n=[],announce:i=[]}=r;this.components=e,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:pre,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 gl(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=>{fre.error("error updating addresses",e)}))}getListenAddrs(){return Array.from(this.listen).map((e=>gl(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>gl(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>{let[t]=e;return gl(t)}))}addObservedAddr(e){const t=(e=gre(e,this.components.peerId)).toString();this.observed.has(t)||this.observed.set(t,{confident:!1})}confirmObservedAddr(e){var t;const r=(e=gre(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=gre(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=>gl(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 yre(e){return null!=e&&"function"===typeof e.start&&"function"===typeof e.stop}class mre{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ji(this,"components",{}),Ji(this,"_started",!1),this.components={};for(const[t,r]of Object.entries(e))this.components[t]=r;null==this.components.logger&&(this.components.logger=bQ())}isStarted(){return this._started}async _invokeStartableMethod(e){await Promise.all(Object.values(this.components).filter((e=>yre(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 wre=["metrics","connectionProtector"],vre=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];var _re=__webpack_require__(7364);const Ere="[a-fA-F\\d:]",Sre=e=>e&&e.includeBoundaries?"(?:(?<=\\s|^)(?=".concat(Ere,")|(?<=").concat(Ere,")(?=\\s|$))"):"",Are="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",xre="[a-fA-F\\d]{1,4}",kre="\n(?:\n(?:".concat(xre,":){7}(?:").concat(xre,"|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:").concat(xre,":){6}(?:").concat(Are,"|:").concat(xre,"|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:").concat(xre,":){5}(?::").concat(Are,"|(?::").concat(xre,"){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:").concat(xre,":){4}(?:(?::").concat(xre,"){0,1}:").concat(Are,"|(?::").concat(xre,"){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:").concat(xre,":){3}(?:(?::").concat(xre,"){0,2}:").concat(Are,"|(?::").concat(xre,"){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:").concat(xre,":){2}(?:(?::").concat(xre,"){0,3}:").concat(Are,"|(?::").concat(xre,"){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:").concat(xre,":){1}(?:(?::").concat(xre,"){0,4}:").concat(Are,"|(?::").concat(xre,"){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::").concat(xre,"){0,5}:").concat(Are,"|(?::").concat(xre,"){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Cre=new RegExp("(?:^".concat(Are,"$)|(?:^").concat(kre,"$)")),Ire=new RegExp("^".concat(Are,"$")),Tre=new RegExp("^".concat(kre,"$")),Pre=e=>e&&e.exact?Cre:new RegExp("(?:".concat(Sre(e)).concat(Are).concat(Sre(e),")|(?:").concat(Sre(e)).concat(kre).concat(Sre(e),")"),"g");Pre.v4=e=>e&&e.exact?Ire:new RegExp("".concat(Sre(e)).concat(Are).concat(Sre(e)),"g"),Pre.v6=e=>e&&e.exact?Tre:new RegExp("".concat(Sre(e)).concat(kre).concat(Sre(e)),"g");const Rre=Pre;var Dre=__webpack_require__(4201);const{isValid:Nre,parse:Bre}=Dre,Lre=["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 _re.Netmask(e)));function Ure(e){return/^::$/.test(e)||/^::1$/.test(e)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^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(e)||/^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(e)||/^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(e)||/^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(e)||/^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(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}const Mre=e=>{if(Nre(e)){const t=Bre(e);if("ipv4"===t.kind())return function(e){for(let t of Lre)if(t.contains(e))return!0;return!1}(t.toNormalizedString());if("ipv6"===t.kind())return Ure(e)}else if(Tc(e)&&Rre.v6().test(e))return Ure(e)};function Ore(){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{const t=e.stringTuples();return(4===t[0][0]||41===t[0][0])&&Boolean(Mre("".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]:{}}}new Uint8Array(0);var qre=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const zre=qre;class Fre{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 Kre{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 jre(this,e)}}class Vre{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return jre(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 jre(e,t){var r,n;return new Vre({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Hre{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Fre(e,t,r),this.decoder=new Kre(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Wre(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Hre(t,r,n,i)}function Gre(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=zre(n,t);return Wre({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 Yre(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Wre({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 Qre=Gre({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jre=(Gre({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Yre({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yre({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yre({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6})),Xre=(Yre({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),e=>({match:t=>!(t.length<1)&&(!!e(t[0])&&t.slice(1)),pattern:"fn"})),Zre=e=>({match:t=>Xre((t=>t===e)).match(t),pattern:e}),$re=()=>({match:e=>Xre((e=>"string"===typeof e)).match(e),pattern:"{string}"}),ene=()=>({match:e=>Xre((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),tne=()=>({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{Qre.decode("z".concat(e[1]))}catch(t){return!1}return e.slice(2)},pattern:"/p2p/{peerid}"}),rne=()=>({match:e=>{if(e.length<2)return!1;if("certhash"!==e[0])return!1;try{Jre.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),nne=e=>({match:t=>{const r=e.match(t);return!1===r?t:r},pattern:"optional(".concat(e.pattern,")")}),ine=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(", "),")")}},one=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 sne(){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 ane=one(Zre("dns4"),$re()),cne=one(Zre("dns6"),$re()),lne=one(Zre("dnsaddr"),$re()),une=one(Zre("dns"),$re()),hne=(sne(ane),sne(cne),sne(lne),sne(ine(une,lne,ane,cne)),one(Zre("ip4"),Xre(Cc))),dne=one(Zre("ip6"),Xre(Ic)),fne=ine(hne,dne),pne=ine(fne,une,ane,cne,lne),gne=sne(pne),bne=(sne(hne),sne(dne),sne(fne),one(pne,Zre("tcp"),ene())),yne=one(pne,Zre("udp"),ene()),mne=ine(bne,yne),wne=(sne(bne),sne(yne),one(yne,Zre("quic"))),vne=one(yne,Zre("quic-v1")),_ne=ine(wne,vne),Ene=(sne(wne),sne(vne),ine(pne,bne,yne,wne,vne)),Sne=ine(one(Ene,Zre("ws"),nne(tne()))),Ane=(sne(Sne),ine(one(Ene,Zre("wss"),nne(tne())),one(Ene,Zre("tls"),Zre("ws"),nne(tne())))),xne=(sne(Ane),one(mne,Zre("webrtc-direct"),rne(),nne(rne()),nne(tne()))),kne=(sne(xne),one(vne,Zre("webtransport"),rne(),rne(),nne(tne()))),Cne=(sne(kne),ine(Sne,Ane,one(bne,nne(tne())),one(_ne,nne(tne())),one(pne,nne(tne())),xne,kne,tne())),Ine=(sne(Cne),sne(one(Cne,Zre("p2p-circuit"),tne())));sne(ine(one(Cne,Zre("p2p-circuit"),Zre("webrtc"),tne()),one(Cne,Zre("webrtc"),nne(tne())),Zre("webrtc"))),sne(ine(one(pne,Zre("tcp"),ene(),Zre("http"),nne(tne())),one(pne,Zre("http"),nne(tne())))),sne(ine(one(pne,Zre("tcp"),ine(one(Zre("443"),Zre("http")),one(ene(),Zre("https"))),nne(tne())),one(pne,Zre("tls"),Zre("http"),nne(tne())),one(pne,Zre("https"),nne(tne()))));function Tne(e){try{const{address:t}=e.nodeAddress();return Boolean(Mre(t))}catch{return!0}}function Pne(e,t){const r=function(e,t){const r=Tne(e.multiaddr),n=Tne(t.multiaddr);return r&&!n?1:!r&&n?-1:0}(e,t);if(0!==r)return r;const n=function(e,t){const r=Ine.exactMatch(e.multiaddr),n=Ine.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}var Rne=__webpack_require__(8846);const Dne=globalThis.fetch,Nne=globalThis.Headers;globalThis.Request,globalThis.Response;function Bne(e,t,r){return"".concat(e,"?name=").concat(t,"&type=").concat(r)}async function Lne(e,t){const r=await Dne(e,{headers:new Nne({accept:"application/dns-json"}),signal:t});return await r.json()}function Une(e,t){return"".concat(t,"_").concat(e)}const Mne=Object.assign(yl("dns-over-http-resolver"),{error:yl("dns-over-http-resolver:error")});const One=class{constructor(){var e,t,r;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ji(this,"_cache",void 0),Ji(this,"_TXTcache",void 0),Ji(this,"_servers",void 0),Ji(this,"_request",void 0),Ji(this,"_abortControllers",void 0),this._cache=new Rne({max:null!==(e=null===n||void 0===n?void 0:n.maxCache)&&void 0!==e?e:100}),this._TXTcache=new Rne({max:null!==(t=null===n||void 0===n?void 0:n.maxCache)&&void 0!==t?t:100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=null!==(r=n.request)&&void 0!==r?r:Lne,this._abortControllers=[]}cancel(){this._abortControllers.forEach((e=>{e.abort()}))}getServers(){return this._servers}_getShuffledServers(){const e=[...this._servers];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),n=e[t];e[t]=e[r],e[r]=n}return e}setServers(e){this._servers=e}async resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"A";switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error("".concat(t," is not supported"))}}async resolve4(e){const t="A",r=this._cache.get(Une(e,t));if(null!=r)return r;let n=!1;for(const o of this._getShuffledServers()){const r=new AbortController;this._abortControllers.push(r);try{const n=await this._request(Bne(o,e,t),r.signal),i=n.Answer.map((e=>e.data)),s=Math.min(...n.Answer.map((e=>e.TTL)));return this._cache.set(Une(e,t),i,{ttl:s}),i}catch(i){r.signal.aborted&&(n=!0),Mne.error("".concat(o," could not resolve ").concat(e," record ").concat(t))}finally{this._abortControllers=this._abortControllers.filter((e=>e!==r))}}if(n)throw Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"});throw new Error("Could not resolve ".concat(e," record ").concat(t))}async resolve6(e){const t="AAAA",r=this._cache.get(Une(e,t));if(null!=r)return r;let n=!1;for(const o of this._getShuffledServers()){const r=new AbortController;this._abortControllers.push(r);try{const n=await this._request(Bne(o,e,t),r.signal),i=n.Answer.map((e=>e.data)),s=Math.min(...n.Answer.map((e=>e.TTL)));return this._cache.set(Une(e,t),i,{ttl:s}),i}catch(i){r.signal.aborted&&(n=!0),Mne.error("".concat(o," could not resolve ").concat(e," record ").concat(t))}finally{this._abortControllers=this._abortControllers.filter((e=>e!==r))}}if(n)throw Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"});throw new Error("Could not resolve ".concat(e," record ").concat(t))}async resolveTxt(e){const t="TXT",r=this._TXTcache.get(Une(e,t));if(null!=r)return r;let n=!1;for(const o of this._getShuffledServers()){const r=new AbortController;this._abortControllers.push(r);try{const n=await this._request(Bne(o,e,t),r.signal),i=n.Answer.map((e=>[e.data.replace(/['"]+/g,"")])),s=Math.min(...n.Answer.map((e=>e.TTL)));return this._TXTcache.set(Une(e,t),i,{ttl:s}),i}catch(i){r.signal.aborted&&(n=!0),Mne.error("".concat(o," could not resolve ").concat(e," record ").concat(t))}finally{this._abortControllers=this._abortControllers.filter((e=>e!==r))}}if(n)throw Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"});throw new Error("Could not resolve ".concat(e," record ").concat(t))}clearCache(){this._cache.clear(),this._TXTcache.clear()}},qne=One,{code:zne}=Mc("dnsaddr");async function Fne(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new qne;null!=r.signal&&r.signal.addEventListener("abort",(()=>{n.cancel()}));const i=e.getPeerId(),[,o]=null!==(t=e.stringTuples().find((e=>{let[t]=e;return t===zne})))&&void 0!==t?t:[];if(null==o)throw new Error("No hostname found in multiaddr");let s=(await n.resolveTxt("_dnsaddr.".concat(o))).flat().map((e=>e.split("=")[1])).filter(Boolean);return null!=i&&(s=s.filter((e=>e.includes(i)))),s}var Kne,Vne;!function(e){e.NOT_STARTED_YET="The libp2p node is not started yet",e.DHT_DISABLED="DHT is not available",e.PUBSUB_DISABLED="PubSub is not available",e.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",e.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",e.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",e.NOT_FOUND="Not found"}(Kne||(Kne={})),function(e){e.DHT_DISABLED="ERR_DHT_DISABLED",e.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",e.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",e.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",e.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",e.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",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_TIMEOUT="ERR_TIMEOUT",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_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",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"}(Vne||(Vne={}));const jne={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:Fne},addressSorter:Pne},transportManager:{faultTolerance:xk.FATAL_ALL}};const Hne=yQ("libp2p:get-peer");function Wne(e){if(Zi(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:DZ(r),e.forEach((e=>{if(!il(e))throw Hne.error("multiaddr %s was invalid",e),new ly("Invalid Multiaddr",Vne.ERR_INVALID_MULTIADDR);const r=e.getPeerId();if(null==r){if(null!=t)throw new ly("Multiaddrs must all have the same peer id or have no peer id",Vne.ERR_INVALID_PARAMETERS)}else{const e=DZ(r);if(null==t||!t.equals(e))throw new ly("Multiaddrs must all have the same peer id or have no peer id",Vne.ERR_INVALID_PARAMETERS)}}))}return{peerId:t,multiaddrs:e}}class Gne extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Yne extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Qne=e=>void 0===globalThis.DOMException?new Yne(e):new DOMException(e),Jne=e=>{const t=void 0===e.reason?Qne("This operation was aborted."):e.reason;return t instanceof Error?t:Qne(t)};var Xne,Zne=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"===typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Xne=new WeakMap;const $ne=class{constructor(){Xne.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Zne(this,Xne,"f")[this.size-1].priority>=t.priority)return void Zne(this,Xne,"f").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}(Zne(this,Xne,"f"),r,((e,t)=>t.priority-e.priority));Zne(this,Xne,"f").splice(n,0,r)}dequeue(){const e=Zne(this,Xne,"f").shift();return null===e||void 0===e?void 0:e.run}filter(e){return Zne(this,Xne,"f").filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return Zne(this,Xne,"f").length}};var eie,tie,rie,nie,iie,oie,sie,aie,cie,lie,uie,hie,die,fie,pie,gie,bie,yie,mie,wie,vie,_ie,Eie,Sie,Aie,xie,kie=function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"===typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r},Cie=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"===typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};class Iie extends Error{}tie=new WeakMap,rie=new WeakMap,nie=new WeakMap,iie=new WeakMap,oie=new WeakMap,sie=new WeakMap,aie=new WeakMap,cie=new WeakMap,lie=new WeakMap,uie=new WeakMap,hie=new WeakMap,die=new WeakMap,fie=new WeakMap,pie=new WeakMap,eie=new WeakSet,gie=function(){return Cie(this,rie,"f")||Cie(this,nie,"f")<Cie(this,iie,"f")},bie=function(){return Cie(this,hie,"f")<Cie(this,die,"f")},yie=function(){var e;kie(this,hie,(e=Cie(this,hie,"f"),--e),"f"),Cie(this,eie,"m",vie).call(this),this.emit("next")},mie=function(){Cie(this,eie,"m",Eie).call(this),Cie(this,eie,"m",_ie).call(this),kie(this,cie,void 0,"f")},wie=function(){const e=Date.now();if(void 0===Cie(this,aie,"f")){const t=Cie(this,sie,"f")-e;if(!(t<0))return void 0===Cie(this,cie,"f")&&kie(this,cie,setTimeout((()=>{Cie(this,eie,"m",mie).call(this)}),t),"f"),!0;kie(this,nie,Cie(this,tie,"f")?Cie(this,hie,"f"):0,"f")}return!1},vie=function(){if(0===Cie(this,lie,"f").size)return Cie(this,aie,"f")&&clearInterval(Cie(this,aie,"f")),kie(this,aie,void 0,"f"),this.emit("empty"),0===Cie(this,hie,"f")&&this.emit("idle"),!1;if(!Cie(this,fie,"f")){const e=!Cie(this,eie,"a",wie);if(Cie(this,eie,"a",gie)&&Cie(this,eie,"a",bie)){const t=Cie(this,lie,"f").dequeue();return!!t&&(this.emit("active"),t(),e&&Cie(this,eie,"m",_ie).call(this),!0)}}return!1},_ie=function(){Cie(this,rie,"f")||void 0!==Cie(this,aie,"f")||(kie(this,aie,setInterval((()=>{Cie(this,eie,"m",Eie).call(this)}),Cie(this,oie,"f")),"f"),kie(this,sie,Date.now()+Cie(this,oie,"f"),"f"))},Eie=function(){0===Cie(this,nie,"f")&&0===Cie(this,hie,"f")&&Cie(this,aie,"f")&&(clearInterval(Cie(this,aie,"f")),kie(this,aie,void 0,"f")),kie(this,nie,Cie(this,tie,"f")?Cie(this,hie,"f"):0,"f"),Cie(this,eie,"m",Sie).call(this)},Sie=function(){for(;Cie(this,eie,"m",vie).call(this););},Aie=async function(e){return new Promise(((t,r)=>{e.addEventListener("abort",(()=>{r(new Iie("The task was aborted."))}),{once:!0})}))},xie=async function(e,t){return new Promise((r=>{const n=()=>{t&&!t()||(this.off(e,n),r())};this.on(e,n)}))};const Tie=class extends B7{constructor(e){var t,r,n,i;if(super(),eie.add(this),tie.set(this,void 0),rie.set(this,void 0),nie.set(this,0),iie.set(this,void 0),oie.set(this,void 0),sie.set(this,0),aie.set(this,void 0),cie.set(this,void 0),lie.set(this,void 0),uie.set(this,void 0),hie.set(this,0),die.set(this,void 0),fie.set(this,void 0),pie.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"===typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:$ne,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError("Expected `intervalCap` to be a number from 1 and up, got `".concat(null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:"","` (").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!==(i=null===(n=e.interval)||void 0===n?void 0:n.toString())&&void 0!==i?i:"","` (").concat(typeof e.interval,")"));kie(this,tie,e.carryoverConcurrencyCount,"f"),kie(this,rie,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),kie(this,iie,e.intervalCap,"f"),kie(this,oie,e.interval,"f"),kie(this,lie,new e.queueClass,"f"),kie(this,uie,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,kie(this,pie,!0===e.throwOnTimeout,"f"),kie(this,fie,!1===e.autoStart,"f")}get concurrency(){return Cie(this,die,"f")}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,")"));kie(this,die,e,"f"),Cie(this,eie,"m",Sie).call(this)}async add(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t={timeout:this.timeout,throwOnTimeout:Cie(this,pie,"f"),...t},new Promise(((r,n)=>{Cie(this,lie,"f").enqueue((async()=>{var i,o,s;kie(this,hie,(o=Cie(this,hie,"f"),++o),"f"),kie(this,nie,(s=Cie(this,nie,"f"),++s),"f");try{if(null===(i=t.signal)||void 0===i?void 0:i.aborted)throw new Iie("The task was aborted.");let n=e({signal:t.signal});t.timeout&&(n=function(e,t,r,n){let i;const o=new Promise(((o,s)=>{if("number"!==typeof t||1!==Math.sign(t))throw new TypeError("Expected `milliseconds` to be a positive number, got `".concat(t,"`"));if(t!==Number.POSITIVE_INFINITY){if((n={customTimers:{setTimeout:setTimeout,clearTimeout:clearTimeout},...n}).signal){const{signal:e}=n;e.aborted&&s(Jne(e)),e.addEventListener("abort",(()=>{s(Jne(e))}))}i=n.customTimers.setTimeout.call(void 0,(()=>{if("function"===typeof r){try{o(r())}catch(a){s(a)}return}const n="string"===typeof r?r:"Promise timed out after ".concat(t," milliseconds"),i=r instanceof Error?r:new Gne(n);"function"===typeof e.cancel&&e.cancel(),s(i)}),t),(async()=>{try{o(await e)}catch(t){s(t)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()}else o(e)}));return o.clear=()=>{clearTimeout(i),i=void 0},o}(Promise.resolve(n),t.timeout)),t.signal&&(n=Promise.race([n,Cie(this,eie,"m",Aie).call(this,t.signal)]));const o=await n;r(o),this.emit("completed",o)}catch(a){if(a instanceof Gne&&!t.throwOnTimeout)return void r();n(a),this.emit("error",a)}finally{Cie(this,eie,"m",yie).call(this)}}),t),this.emit("add"),Cie(this,eie,"m",vie).call(this)}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return Cie(this,fie,"f")?(kie(this,fie,!1,"f"),Cie(this,eie,"m",Sie).call(this),this):this}pause(){kie(this,fie,!0,"f")}clear(){kie(this,lie,new(Cie(this,uie,"f")),"f")}async onEmpty(){0!==Cie(this,lie,"f").size&&await Cie(this,eie,"m",xie).call(this,"empty")}async onSizeLessThan(e){Cie(this,lie,"f").size<e||await Cie(this,eie,"m",xie).call(this,"next",(()=>Cie(this,lie,"f").size<e))}async onIdle(){0===Cie(this,hie,"f")&&0===Cie(this,lie,"f").size||await Cie(this,eie,"m",xie).call(this,"idle")}get size(){return Cie(this,lie,"f").size}sizeBy(e){return Cie(this,lie,"f").filter(e).length}get pending(){return Cie(this,hie,"f")}get isPaused(){return Cie(this,fie,"f")}};var Pie=new WeakMap;class Rie{constructor(){eo(this,Pie,[])}enqueue(e,t){var r;const n=null===t||void 0===t?void 0:t.peerId,i=null!==(r=null===t||void 0===t?void 0:t.priority)&&void 0!==r?r:0;if(null==n)throw new ly("missing peer id",Vne.ERR_INVALID_PARAMETERS);const o={priority:i,peerId:n,run:e};if(this.size>0&&ro(Pie,this)[this.size-1].priority>=i)return void ro(Pie,this).push(o);const s=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}(ro(Pie,this),o,((e,t)=>t.priority-e.priority));ro(Pie,this).splice(s,0,o)}dequeue(){const e=ro(Pie,this).shift();return null===e||void 0===e?void 0:e.run}filter(e){if(null!=e.peerId){const t=e.peerId;return ro(Pie,this).filter((e=>t.equals(e.peerId))).map((e=>e.run))}return ro(Pie,this).filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return ro(Pie,this).length}}class Die extends Tie{constructor(){super({...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},queueClass:Rie})}hasJob(e){return this.sizeBy({peerId:e})>0}}const Nie="last-dial-failure",Bie={minConnections:5,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3,autoDialPeerRetryThreshold:42e4,autoDialDiscoveredPeersDebounce:10};var Lie=new WeakMap;class Uie{constructor(e,t){var r,n,i,o,s,a,c;let l;Ji(this,"connectionManager",void 0),Ji(this,"peerStore",void 0),Ji(this,"queue",void 0),Ji(this,"minConnections",void 0),Ji(this,"autoDialPriority",void 0),Ji(this,"autoDialIntervalMs",void 0),Ji(this,"autoDialMaxQueueLength",void 0),Ji(this,"autoDialPeerRetryThresholdMs",void 0),Ji(this,"autoDialDiscoveredPeersDebounce",void 0),Ji(this,"autoDialInterval",void 0),Ji(this,"started",void 0),Ji(this,"running",void 0),eo(this,Lie,void 0),this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.minConnections=null!==(r=t.minConnections)&&void 0!==r?r:Bie.minConnections,this.autoDialPriority=null!==(n=t.autoDialPriority)&&void 0!==n?n:Bie.autoDialPriority,this.autoDialIntervalMs=null!==(i=t.autoDialInterval)&&void 0!==i?i:Bie.autoDialInterval,this.autoDialMaxQueueLength=null!==(o=t.maxQueueLength)&&void 0!==o?o:Bie.maxQueueLength,this.autoDialPeerRetryThresholdMs=null!==(s=t.autoDialPeerRetryThreshold)&&void 0!==s?s:Bie.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=null!==(a=t.autoDialDiscoveredPeersDebounce)&&void 0!==a?a:Bie.autoDialDiscoveredPeersDebounce,no(Lie,this,e.logger.forComponent("libp2p:connection-manager:auto-dial")),this.started=!1,this.running=!1,this.queue=new Die({concurrency:null!==(c=t.autoDialConcurrency)&&void 0!==c?c:Bie.autoDialConcurrency}),this.queue.addListener("error",(e=>{ro(Lie,this).error("error during auto-dial",e)})),e.events.addEventListener("connection:close",(()=>{this.autoDial().catch((e=>{ro(Lie,this).error(e)}))})),e.events.addEventListener("peer:discovery",(()=>{clearTimeout(l),l=setTimeout((()=>{this.autoDial().catch((e=>{ro(Lie,this).error(e)}))}),this.autoDialDiscoveredPeersDebounce)}))}isStarted(){return this.started}start(){this.autoDialInterval=setTimeout((()=>{this.autoDial().catch((e=>{ro(Lie,this).error("error while autodialing",e)}))}),this.autoDialIntervalMs),this.started=!0}afterStart(){this.autoDial().catch((e=>{ro(Lie,this).error("error while autodialing",e)}))}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started)return;const e=this.connectionManager.getConnectionsMap(),t=e.size;if(t>=this.minConnections)return void(this.minConnections>0&&ro(Lie,this).trace("have enough connections %d/%d",t,this.minConnections));if(this.queue.size>this.autoDialMaxQueueLength)return void ro(Lie,this).call(this,"not enough connections %d/%d but auto dial queue is full",t,this.minConnections);if(this.running)return void ro(Lie,this).call(this,"not enough connections %d/%d - but skipping autodial as it is already running",t,this.minConnections);this.running=!0,ro(Lie,this).call(this,"not enough connections %d/%d - will dial peers to increase the number of connections",t,this.minConnections);const r=new dX(this.connectionManager.getDialQueue().map((e=>e.peerId)).filter(Boolean)),n=await this.peerStore.all({filters:[t=>0===t.addresses.length?(ro(Lie,this).trace("not autodialing %p because they have no addresses",t.id),!1):e.has(t.id)?(ro(Lie,this).trace("not autodialing %p because they are already connected",t.id),!1):r.has(t.id)?(ro(Lie,this).trace("not autodialing %p because they are already being dialed",t.id),!1):!this.queue.hasJob(t.id)||(ro(Lie,this).trace("not autodialing %p because they are already being autodialed",t.id),!1)]}),i=n.sort((()=>Math.random()>.5?1:-1)),o=new hX;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(Nie);if(null==t)return!0;const r=parseInt(za(t));return!!isNaN(r)||Date.now()-r>this.autoDialPeerRetryThresholdMs}));ro(Lie,this).call(this,"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 ro(Lie,this).call(this,"got enough connections now %d/%d",e,this.minConnections),void this.queue.clear();ro(Lie,this).call(this,"connecting to a peerStore stored peer %p",a.id),await this.connectionManager.openConnection(a.id,{priority:this.autoDialPriority})}),{peerId:a.id}).catch((e=>{ro(Lie,this).error("could not connect to peerStore stored peer",e)}));this.running=!1,this.started&&(this.autoDialInterval=setTimeout((()=>{this.autoDial().catch((e=>{ro(Lie,this).error("error while autodialing",e)}))}),this.autoDialIntervalMs))}}const Mie={maxConnections:100,allow:[]};var Oie=new WeakMap;class qie{constructor(e){var t,r;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ji(this,"maxConnections",void 0),Ji(this,"connectionManager",void 0),Ji(this,"peerStore",void 0),Ji(this,"allow",void 0),Ji(this,"events",void 0),eo(this,Oie,void 0),this.maxConnections=null!==(t=n.maxConnections)&&void 0!==t?t:Mie.maxConnections,this.allow=null!==(r=n.allow)&&void 0!==r?r:Mie.allow,this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.events=e.events,no(Oie,this,e.logger.forComponent("libp2p:connection-manager:connection-pruner")),e.events.addEventListener("connection:open",(()=>{this.maybePruneConnections().catch((e=>{ro(Oie,this).error(e)}))}))}async maybePruneConnections(){const e=this.connectionManager.getConnections(),t=e.length,r=Math.max(t-this.maxConnections,0);if(ro(Oie,this).call(this,"checking max connections limit %d/%d",t,this.maxConnections),t<=this.maxConnections)return;ro(Oie,this).call(this,"max connections limit exceeded %d/%d, pruning %d connection(s)",t,this.maxConnections,r);const n=new hX;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&&ro(Oie,this).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){ro(Oie,this).call(this,"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){ro(Oie,this).error(s)}}))),this.events.safeDispatchEvent("connection:prune",{detail:o})}}function zie(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}async function Fie(e,t){if(!e.protoNames().includes("dnsaddr"))return[e];const r=await async function(e,t){try{e=gl(e.toString());return await e.resolve(t)}catch(r){return t.log.error("multiaddr ".concat(e.toString()," could not be resolved"),r),[]}}(e,t),n=(await Promise.all(r.map((async e=>Fie(e,t))))).flat().reduce(((e,t)=>(null==e.find((e=>e.equals(t)))&&e.push(t),e)),[]);return t.log("resolved %s to",e,n.map((e=>e.toString()))),n}const Kie={addressSorter:Pne,maxParallelDials:50,maxPeerAddrsToDial:25,maxParallelDialsPerPeer:1,dialTimeout:3e4,resolvers:{dnsaddr:Fne}};var Vie=new WeakMap;class jie{constructor(e){var t,r,n,i,o,s,a,c;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ji(this,"pendingDials",void 0),Ji(this,"queue",void 0),Ji(this,"peerId",void 0),Ji(this,"peerStore",void 0),Ji(this,"connectionGater",void 0),Ji(this,"transportManager",void 0),Ji(this,"addressSorter",void 0),Ji(this,"maxPeerAddrsToDial",void 0),Ji(this,"maxParallelDialsPerPeer",void 0),Ji(this,"dialTimeout",void 0),Ji(this,"inProgressDialCount",void 0),Ji(this,"pendingDialCount",void 0),Ji(this,"shutDownController",void 0),Ji(this,"connections",void 0),eo(this,Vie,void 0),this.addressSorter=null!==(t=l.addressSorter)&&void 0!==t?t:Kie.addressSorter,this.maxPeerAddrsToDial=null!==(r=l.maxPeerAddrsToDial)&&void 0!==r?r:Kie.maxPeerAddrsToDial,this.maxParallelDialsPerPeer=null!==(n=l.maxParallelDialsPerPeer)&&void 0!==n?n:Kie.maxParallelDialsPerPeer,this.dialTimeout=null!==(i=l.dialTimeout)&&void 0!==i?i:Kie.dialTimeout,this.connections=null!==(o=l.connections)&&void 0!==o?o:new hX,no(Vie,this,e.logger.forComponent("libp2p:connection-manager:dial-queue")),this.peerId=e.peerId,this.peerStore=e.peerStore,this.connectionGater=e.connectionGater,this.transportManager=e.transportManager,this.shutDownController=new AbortController,ST(1/0,this.shutDownController.signal),this.pendingDialCount=null===(s=e.metrics)||void 0===s?void 0:s.registerMetric("libp2p_dialler_pending_dials"),this.inProgressDialCount=null===(a=e.metrics)||void 0===a?void 0:a.registerMetric("libp2p_dialler_in_progress_dials"),this.pendingDials=[];for(const[h,d]of Object.entries(null!==(u=l.resolvers)&&void 0!==u?u:{})){var u;rl.set(h,d)}this.queue=new Tie({concurrency:null!==(c=l.maxParallelDials)&&void 0!==c?c:Kie.maxParallelDials}),this.queue.on("add",(()=>{var e,t;null===(e=this.pendingDialCount)||void 0===e||e.update(this.queue.size),null===(t=this.inProgressDialCount)||void 0===t||t.update(this.queue.pending)})),this.queue.on("active",(()=>{var e,t;null===(e=this.pendingDialCount)||void 0===e||e.update(this.queue.size),null===(t=this.inProgressDialCount)||void 0===t||t.update(this.queue.pending)})),this.queue.on("completed",(()=>{var e,t;null===(e=this.pendingDialCount)||void 0===e||e.update(this.queue.size),null===(t=this.inProgressDialCount)||void 0===t||t.update(this.queue.pending)})),this.queue.on("error",(e=>{var t,r;ro(Vie,this).error("error in dial queue",e),null===(t=this.pendingDialCount)||void 0===t||t.update(this.queue.size),null===(r=this.inProgressDialCount)||void 0===r||r.update(this.queue.pending)})),this.queue.on("empty",(()=>{var e,t;null===(e=this.pendingDialCount)||void 0===e||e.update(this.queue.size),null===(t=this.inProgressDialCount)||void 0===t||t.update(this.queue.pending)})),this.queue.on("idle",(()=>{var e,t;null===(e=this.pendingDialCount)||void 0===e||e.update(this.queue.size),null===(t=this.inProgressDialCount)||void 0===t||t.update(this.queue.pending)}))}stop(){this.shutDownController.abort()}async dial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{peerId:r,multiaddrs:n}=Wne(e),i=n.map((e=>({multiaddr:e,isCertified:!1}))),o=this.createDialAbortControllers(t.signal);let s;try{s=await this.calculateMultiaddrs(r,i,{...t,signal:o})}catch(h){throw o.clear(),h}let a=Array.from(this.connections.values()).flat().find((e=>!0!==t.force&&s.find((t=>t.multiaddr.equals(e.remoteAddr)))));if(null!=a)return ro(Vie,this).call(this,"already connected to %a",a.remoteAddr),a;const c=this.pendingDials.find((e=>!(null==e.peerId||null==r||!e.peerId.equals(r))||s.map((e=>{let{multiaddr:t}=e;return t.toString()})).join()===e.multiaddrs.map((e=>e.toString())).join()));if(null!=c)return ro(Vie,this).call(this,"joining existing dial target for %p",r),o.clear(),c.promise;ro(Vie,this).call(this,"creating dial target for",s.map((e=>{let{multiaddr:t}=e;return t.toString()})));const l={id:"".concat(parseInt(String(1e9*Math.random()),10).toString()).concat(Date.now()),status:"queued",peerId:r,multiaddrs:s.map((e=>{let{multiaddr:t}=e;return t}))};l.promise=this.performDial(l,{...t,signal:o}).finally((()=>{this.pendingDials=this.pendingDials.filter((e=>e.id!==l.id)),o.clear()})).catch((async e=>{if(ro(Vie,this).error("dial failed to %s",l.multiaddrs.map((e=>e.toString())).join(", "),e),null!=r)try{await this.peerStore.patch(r,{metadata:{[Nie]:kc(Date.now().toString())}})}catch(e){ro(Vie,this).error("could not update last dial failure key for %p",r,e)}if(o.aborted){throw new ly(e.message,Vne.ERR_TIMEOUT)}throw e})),this.pendingDials.push(l);const u=await l.promise;return a=Array.from(this.connections.values()).flat().find((e=>!0!==t.force&&(e.id!==u.id&&e.remoteAddr.equals(u.remoteAddr)))),null!=a?(ro(Vie,this).call(this,"already connected to %a",a.remoteAddr),await u.close(),a):(ro(Vie,this).call(this,"connection opened to %a",u.remoteAddr),u)}createDialAbortControllers(e){const t=zie([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);try{null===ST||void 0===ST||ST(1/0,t)}catch{}return t}async calculateMultiaddrs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null!=e){var n,i;if(this.peerId.equals(e))throw new ly("Tried to dial self",Vne.ERR_DIALED_SELF);if(!0===await(null===(n=(i=this.connectionGater).denyDialPeer)||void 0===n?void 0:n.call(i,e)))throw new ly("The dial request is blocked by gater.allowDialPeer",Vne.ERR_PEER_DIAL_INTERCEPTED);if(0===t.length){ro(Vie,this).call(this,"loading multiaddrs for %p",e);try{const r=await this.peerStore.get(e);t.push(...r.addresses),ro(Vie,this).call(this,"loaded multiaddrs for %p",e,t.map((e=>{let{multiaddr:t}=e;return t.toString()})))}catch(h){if(h.code!==Vne.ERR_NOT_FOUND)throw h}}}let o=(await Promise.all(t.map((async e=>{const t=await Fie(e.multiaddr,{...r,log:ro(Vie,this)});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());o=o.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 s=o.filter((t=>{if(null==this.transportManager.transportForMultiaddr(t.multiaddr))return!1;const r=t.multiaddr.getPeerId();return null==e||null==r||e.equals(r)})),a=new Map;for(const d of s){const e=d.multiaddr.toString(),t=a.get(e);null==t?a.set(e,d):t.isCertified=t.isCertified||d.isCertified||!1}const c=[...a.values()];if((0===c.length||c.length>this.maxPeerAddrsToDial)&&(ro(Vie,this).call(this,"addresses for %p before filtering",null!==e&&void 0!==e?e:"unknown peer",o.map((e=>{let{multiaddr:t}=e;return t.toString()}))),ro(Vie,this).call(this,"addresses for %p after filtering",null!==e&&void 0!==e?e:"unknown peer",c.map((e=>{let{multiaddr:t}=e;return t.toString()})))),0===c.length)throw new ly("The dial request has no valid addresses",Vne.ERR_NO_VALID_ADDRESSES);if(c.length>this.maxPeerAddrsToDial)throw new ly("dial with more addresses than allowed",Vne.ERR_TOO_MANY_ADDRESSES);const l=[];for(const d of c)null!=this.connectionGater.denyDialMultiaddr&&await this.connectionGater.denyDialMultiaddr(d.multiaddr)||l.push(d);const u=l.sort(this.addressSorter);if(0===u.length)throw new ly("The connection gater denied all addresses in the dial request",Vne.ERR_NO_VALID_ADDRESSES);return u}async performDial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=e.multiaddrs.map((()=>new AbortController));try{const n=new Tie({concurrency:this.maxParallelDialsPerPeer});n.on("error",(e=>{ro(Vie,this).error("error dialling",e)}));const i=await Promise.any(e.multiaddrs.map((async(i,o)=>{const s=r[o];if(null==s)throw new ly("dialAction did not come with an AbortController",Vne.ERR_INVALID_PARAMETERS);const a=function(){const e=[];for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];for(const o of r)null!=o&&(ST(1/0,o),e.push(o));const i=zie(e);return ST(1/0,i),i}(s.signal,t.signal);a.addEventListener("abort",(()=>{ro(Vie,this).call(this,"dial to %a aborted",i)}));const c=af();return await n.add((async()=>{if(a.aborted)return ro(Vie,this).call(this,"dial to %a was aborted before reaching the head of the peer dial queue",i),void c.reject(new cy);await this.queue.add((async()=>{try{if(a.aborted)return ro(Vie,this).call(this,"dial to %a was aborted before reaching the head of the dial queue",i),void c.reject(new cy);e.status="active";const n=await this.transportManager.dial(i,{...t,signal:a});if(s.signal.aborted)return ro(Vie,this).call(this,"multiple dials succeeded, closing superfluous connection"),n.close().catch((e=>{ro(Vie,this).error("error closing superfluous connection",e)})),void c.reject(new cy);r[o]=void 0,r.forEach((e=>{void 0!==e&&e.abort()})),ro(Vie,this).call(this,"dial to %a succeeded",i),c.resolve(n)}catch(n){ro(Vie,this).error("error during dial of %a",i,n),c.reject(n)}}),{...t,signal:a}).catch((e=>{c.reject(e)}))}),{signal:a}).catch((e=>{c.reject(e)})).finally((()=>{a.clear()})),c.promise})));if(null==i)throw new ly("successful dial led to empty object returned from peer dial queue",Vne.ERR_TRANSPORT_DIAL_FAILED);return e.status="success",i}catch(n){if(e.status="error",1===e.multiaddrs.length&&"AggregateError"===n.name)throw n.errors[0];throw n}}}const Hie=5,Wie=100,Gie=5,Yie=10,Qie=25,Jie=0,Xie=100;var Zie=new WeakMap;class $ie{constructor(e){var t,r,n,i,o,s,a,c,l,u,h,d,f,p,g;let b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ji(this,"started",void 0),Ji(this,"connections",void 0),Ji(this,"allow",void 0),Ji(this,"deny",void 0),Ji(this,"maxIncomingPendingConnections",void 0),Ji(this,"incomingPendingConnections",void 0),Ji(this,"maxConnections",void 0),Ji(this,"dialQueue",void 0),Ji(this,"autoDial",void 0),Ji(this,"connectionPruner",void 0),Ji(this,"inboundConnectionRateLimiter",void 0),Ji(this,"peerStore",void 0),Ji(this,"metrics",void 0),Ji(this,"events",void 0),eo(this,Zie,void 0),this.maxConnections=null!==(t=b.maxConnections)&&void 0!==t?t:Wie;const y=null!==(r=b.minConnections)&&void 0!==r?r:Hie;if(this.maxConnections<y)throw new ly("Connection Manager maxConnections must be greater than minConnections",Vne.ERR_INVALID_PARAMETERS);this.connections=new hX,this.started=!1,this.peerStore=e.peerStore,this.metrics=e.metrics,this.events=e.events,no(Zie,this,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=>gl(e))),this.deny=(null!==(i=b.deny)&&void 0!==i?i:[]).map((e=>gl(e))),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=null!==(o=b.maxIncomingPendingConnections)&&void 0!==o?o:Yie,this.inboundConnectionRateLimiter=new tk.RateLimiterMemory({points:null!==(s=b.inboundConnectionThreshold)&&void 0!==s?s:Gie,duration:1}),this.autoDial=new Uie({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{minConnections:y,autoDialConcurrency:null!==(a=b.autoDialConcurrency)&&void 0!==a?a:Qie,autoDialPriority:null!==(c=b.autoDialPriority)&&void 0!==c?c:Jie,maxQueueLength:null!==(l=b.autoDialMaxQueueLength)&&void 0!==l?l:Xie}),this.connectionPruner=new qie({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new jie({peerId:e.peerId,metrics:e.metrics,peerStore:e.peerStore,transportManager:e.transportManager,connectionGater:e.connectionGater,logger:e.logger},{addressSorter:null!==(u=b.addressSorter)&&void 0!==u?u:Pne,maxParallelDials:null!==(h=b.maxParallelDials)&&void 0!==h?h:50,maxPeerAddrsToDial:null!==(d=b.maxPeerAddrsToDial)&&void 0!==d?d:25,maxParallelDialsPerPeer:null!==(f=b.maxParallelDialsPerPeer)&&void 0!==f?f:1,dialTimeout:null!==(p=b.dialTimeout)&&void 0!==p?p:3e4,resolvers:null!==(g=b.resolvers)&&void 0!==g?g:{dnsaddr:Fne},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.autoDial.start(),this.started=!0,ro(Zie,this).call(this,"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=>{ro(Zie,this).error(e)}))})))})).catch((e=>{ro(Zie,this).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){ro(Zie,this).error(e)}})());ro(Zie,this).call(this,"closing %d connections",e.length),await Promise.all(e),this.connections.clear(),ro(Zie,this).call(this,"stopped")}onConnect(e){this._onConnect(e).catch((e=>{ro(Zie,this).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 ly("Not started",Vne.ERR_NODE_NOT_STARTED);null===(t=n.signal)||void 0===t||t.throwIfAborted();const{peerId:i}=Wne(e);if(null!=i&&!0!==n.force){ro(Zie,this).call(this,"dial %p",i);const e=this.getConnections(i).find((e=>!e.transient));if(null!=e)return ro(Zie,this).call(this,"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 ro(Zie,this).call(this,"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 ro(Zie,this).call(this,"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 ro(Zie,this).call(this,"connection from %a refused - inboundConnectionThreshold exceeded by host %s",e.remoteAddr,t),!1}}return this.getConnections().length<this.maxConnections?(this.incomingPendingConnections++,!0):(ro(Zie,this).call(this,"connection from %a refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}getDialQueue(){return this.dialQueue.pendingDials}}const eoe=function(e,t){if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)yield t(r)}();const r=are(e),{value:n,done:i}=r.next();if(!0===i)return function*(){}();const o=t(n);if("function"===typeof o.then)return async function*(){yield await o;for await(const e of r)yield t(e)}();const s=t;return function*(){yield o;for(const e of r)yield s(e)}()};async function*toe(e,t){yield*eoe(e,(async e=>(await t.merge(e.id,{multiaddrs:e.multiaddrs}),e)))}function roe(e){const t=new Set;return cre(e,(e=>!t.has(e.id.toString())&&(t.add(e.id.toString()),!0)))}function noe(e){try{let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return async function*(){let r=0;for await(const t of e)r++,yield t;if(r<t)throw new ly("more peers required, seen: ".concat(r," min: ").concat(t),"NOT_FOUND")}()}catch(t){return Promise.reject(t)}}class ioe{constructor(e,t){var r;Ji(this,"routers",void 0),Ji(this,"started",void 0),Ji(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 ly("No content routers available",Vne.ERR_NO_ROUTERS_AVAILABLE);yield*pf(ff(...t.routers.map((t=>t.findProviders(e,r)))),(e=>toe(e,t.components.peerStore)),(e=>roe(e)),(e=>noe(e)))}()}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 ly("No content routers available",Vne.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 ly(Kne.NOT_STARTED_YET,Vne.DHT_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 ly(Kne.NOT_STARTED_YET,Vne.DHT_NOT_STARTED);return Promise.any(this.routers.map((async r=>r.get(e,t))))}}const ooe=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e)return t})();for(const t of e)return t},soe=yQ("libp2p:peer-routing");class aoe{constructor(e,t){var r;Ji(this,"components",void 0),Ji(this,"routers",void 0),this.components=e,this.routers=null!==(r=t.routers)&&void 0!==r?r:[]}async findPeer(e,t){if(0===this.routers.length)throw new ly("No peer routers available",Vne.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.peerId.toString())throw new ly("Should not try to find self",Vne.ERR_FIND_SELF);const r=await pf(ff(...this.routers.map((r=>async function*(){try{yield await r.findPeer(e,t)}catch(n){soe.error(n)}}()))),(e=>cre(e,Boolean)),(e=>toe(e,this.components.peerStore)),(async e=>ooe(e)));if(null!=r)return r;throw new ly(Kne.NOT_FOUND,Vne.ERR_NOT_FOUND)}async*getClosestPeers(e,t){if(0===this.routers.length)throw new ly("No peer routers available",Vne.ERR_NO_ROUTERS_AVAILABLE);yield*pf(ff(...this.routers.map((r=>r.getClosestPeers(e,t)))),(e=>toe(e,this.components.peerStore)),(e=>roe(e)),(e=>noe(e)))}}const coe=yQ("libp2p:registrar");class loe{constructor(e){Ji(this,"topologies",void 0),Ji(this,"handlers",void 0),Ji(this,"components",void 0),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 ly("No handler registered for protocol ".concat(e),Vne.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 ly("Handler already registered for protocol ".concat(e),Vne.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const n=TY.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 ly("invalid topology",Vne.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!==Vne.ERR_NOT_FOUND&&coe.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 uoe extends Map{constructor(e){super(),Ji(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)}}const hoe=yQ("libp2p:transports");class doe{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ji(this,"components",void 0),Ji(this,"transports",void 0),Ji(this,"listeners",void 0),Ji(this,"faultTolerance",void 0),Ji(this,"started",void 0),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 uoe({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:xk.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw new ly("Transport must have a valid tag",Vne.ERR_INVALID_KEY);if(this.transports.has(t))throw new ly("There is already a transport with the tag ".concat(t),Vne.ERR_DUPLICATE_TRANSPORT);hoe("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(hoe("closing listeners for %s",t);r.length>0;){const t=r.pop();null!=t&&e.push(t.close())}await Promise.all(e),hoe("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 ly("No transport available for address ".concat(String(e)),Vne.ERR_TRANSPORT_UNAVAILABLE);try{return await r.dial(e,{...t,upgrader:this.components.upgrader})}catch(n){throw null==n.code&&(n.code=Vne.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 ly("Not started",Vne.ERR_NODE_NOT_STARTED);if(null==e||0===e.length)return void hoe("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;hoe("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!==xk.NO_FATAL)throw new ly("Transport (".concat(n,") could not listen on any available address"),Vne.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===xk.FATAL_ALL)throw new ly(e,Vne.ERR_NO_VALID_ADDRESSES);hoe("libp2p in dial mode only: ".concat(e))}}async remove(e){var t;const r=null!==(t=this.listeners.get(e))&&void 0!==t?t:[];hoe.trace("removing transport %s",e);const n=[];for(hoe.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)}}const foe="/multistream/1.0.0",poe=1024;var goe=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const boe=goe;new Uint8Array(0);class yoe{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 moe{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 voe(this,e)}}class woe{constructor(e){this.decoders=e}or(e){return voe(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 voe=(e,t)=>new woe({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class _oe{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new yoe(e,t,r),this.decoder=new moe(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Eoe=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new _oe(t,r,n,i)},Soe=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:o}=boe(n,r);return Eoe({prefix:t,name:r,encode:i,decode:e=>(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))})},Aoe=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Eoe({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(e,i,n,t)})},xoe=Aoe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),koe=(Aoe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Aoe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Aoe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Aoe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Aoe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Aoe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Aoe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Aoe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Soe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"})),Coe=(Soe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Aoe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}));Aoe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Aoe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Aoe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ioe(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 yl.enabled("".concat(e,":trace"))&&null!=yl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=yl("".concat(e,":trace"))),Object.assign(yl(e),{error:yl("".concat(e,":error")),trace:t})}function Toe(e){const t=hf(),r=function(e){const t=async function*(){let t=yield,r=new Jd;for await(const n of e)if(null!=t)for(r.append(n);r.length>=t;){const e=r.sublist(0,t);if(r.consume(t),t=yield e,null==t){r.length>0&&(t=yield r,r=new Jd);break}}else r.append(n),t=yield r,r=new Jd;if(null!=t)throw Object.assign(new Error("stream ended before ".concat(t," bytes became available")),{code:"ERR_UNDER_READ",buffer:r})}();return t.next(),t}(e.source),n=af();let i;const o=e.sink(async function*(){yield*t;const e=await n.promise;yield*e}());o.catch((e=>{i=e}));return{reader:r,writer:t,stream:{sink:async e=>{null==i?(n.resolve(e),await o):await Promise.reject(i)},source:r},rest:()=>t.end(),write:t.push,read:async()=>{const e=await r.next();if(null!=e.value)return e.value}}}yl.formatters.b=e=>null==e?"undefined":koe.baseEncode(e),yl.formatters.t=e=>null==e?"undefined":xoe.baseEncode(e),yl.formatters.m=e=>null==e?"undefined":Coe.baseEncode(e),yl.formatters.p=e=>null==e?"undefined":e.toString(),yl.formatters.c=e=>null==e?"undefined":e.toString(),yl.formatters.k=e=>null==e?"undefined":e.toString(),yl.formatters.a=e=>null==e?"undefined":e.toString();const Poe=Ioe("libp2p:mss"),Roe=kc("\n");function Doe(e){const t=new Jd(e,Roe);return $d.single(t)}function Noe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=Doe(t);!0===r.writeBytes?e.push(n.subarray()):e.push(n)}async function Boe(e,t){const r=await async function(e,t){let r=1;const n={[Symbol.asyncIterator]:()=>n,next:async()=>e.next(r)};let i=n;null!=(null===t||void 0===t?void 0:t.signal)&&(i=$x(n,t.signal));const o=e=>{r=e},s=await pf(i,(e=>sf(e,{onLength:o,maxDataLength:poe})),(async e=>ooe(e)));if(null==s||0===s.length)throw new ly("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(s.get(s.byteLength-1)!==Roe[0])throw Poe.error("Invalid mss message - missing newline - %s",s.subarray()),new ly("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return s.sublist(0,-1)}(e,t);return za(r.subarray())}const Loe=Ioe("libp2p:mss:select");async function Uoe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Array.isArray(t)?[...t]:[t];const{reader:n,writer:i,rest:o,stream:s}=Toe(e),a=t.shift();if(null==a)throw new Error("At least one protocol must be specified");Loe.trace('select: write ["%s", "%s"]',foe,a);!function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new Jd;for(const i of t)n.append(Doe(i));!0===r.writeBytes?e.push(n.subarray()):e.push(n)}(i,[kc(foe),kc(a)],r);let c=await Boe(n,r);if(Loe.trace('select: read "%s"',c),c===foe&&(c=await Boe(n,r),Loe.trace('select: read "%s"',c)),c===a)return o(),{stream:s,protocol:a};for(const l of t){Loe.trace('select: write "%s"',l),Noe(i,kc(l),r);const e=await Boe(n,r);if(Loe.trace('select: read "%s" for "%s"',e,l),e===l)return o(),{stream:s,protocol:l}}throw o(),new ly("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const Moe=Ioe("libp2p:mss:handle");async function Ooe(e,t,r){t=Array.isArray(t)?t:[t];const{writer:n,reader:i,rest:o,stream:s}=Toe(e);for(;;){const e=await Boe(i,r);if(Moe.trace('read "%s"',e),e!==foe){if(t.includes(e))return Noe(n,kc(e),r),Moe.trace('respond with "%s" for "%s"',e,e),o(),{stream:s,protocol:e};"ls"!==e?(Noe(n,kc("na"),r),Moe('respond with "na" for "%s"',e)):(Noe(n,new Jd(...t.map((e=>Doe(kc(e))))),r),Moe.trace('respond with "%s" for %s',t,e))}else Moe.trace('respond with "%s" for "%s"',foe,e),Noe(n,kc(foe),r)}}const qoe=Symbol.for("@libp2p/connection");var zoe=new WeakMap;class Foe{constructor(e){var t;Ji(this,"id",void 0),Ji(this,"remoteAddr",void 0),Ji(this,"remotePeer",void 0),Ji(this,"direction",void 0),Ji(this,"timeline",void 0),Ji(this,"multiplexer",void 0),Ji(this,"encryption",void 0),Ji(this,"status",void 0),Ji(this,"transient",void 0),Ji(this,"tags",void 0),Ji(this,"_newStream",void 0),Ji(this,"_close",void 0),Ji(this,"_abort",void 0),Ji(this,"_getStreams",void 0),eo(this,zoe,void 0),Ji(this,Symbol.toStringTag,"Connection"),Ji(this,qoe,!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,no(zoe,this,e.logger.forComponent("libp2p:connection")),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 ly("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if("closed"===this.status)throw new ly("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 ly("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(ro(zoe,this).call(this,"closing connection to %a",this.remoteAddr),this.status="closing",null==e.signal){const t=AbortSignal.timeout(500);ST(1/0,t),e={...e,signal:t}}try{ro(zoe,this).trace("closing all streams"),await Promise.all(this.streams.map((async t=>t.close(e)))),ro(zoe,this).trace("closing underlying transport"),await this._close(e),ro(zoe,this).trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(t){ro(zoe,this).error("error encountered during graceful close of connection to %a",this.remoteAddr,t),this.abort(t)}}}abort(e){ro(zoe,this).error("aborting connection to %a due to error",this.remoteAddr,e),this.status="closing",this.streams.forEach((t=>{t.abort(e)})),ro(zoe,this).error("all streams aborted",this.streams.length),this._abort(e),this.timeline.close=Date.now(),this.status="closed"}}function Koe(e,t,r){let n=0;return r.streams.forEach((r=>{r.direction===t&&r.protocol===e&&n++})),n}var Voe=new WeakMap;class joe{constructor(e,t){var r;Ji(this,"components",void 0),Ji(this,"connectionEncryption",void 0),Ji(this,"muxers",void 0),Ji(this,"inboundUpgradeTimeout",void 0),Ji(this,"events",void 0),eo(this,Voe,void 0),this.components=e,this.connectionEncryption=new Map,no(Voe,this,e.logger.forComponent("libp2p:upgrader")),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:3e4,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 ly("The multiaddr connection is blocked by gater.".concat(r),Vne.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new ly("connection denied",Vne.ERR_CONNECTION_DENIED);let r,n,i,o,s;const a=AbortSignal.timeout(this.inboundUpgradeTimeout),c=()=>{e.abort(new ly("inbound upgrade timeout",Vne.ERR_TIMEOUT))};a.addEventListener("abort",c,{once:!0}),ST(1/0,a);try{var l,u,h;if(!0===await(null===(l=(u=this.components.connectionGater).denyInboundConnection)||void 0===l?void 0:l.call(u,e)))throw new ly("The multiaddr connection is blocked by gater.acceptConnection",Vne.ERR_CONNECTION_INTERCEPTED);null===(h=this.components.metrics)||void 0===h||h.trackMultiaddrConnection(e),ro(Voe,this).call(this,"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&&(ro(Voe,this).call(this,"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 ly("inbound connection that skipped encryption must have a peer id",Vne.ERR_INVALID_MULTIADDR);const r=DZ(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 ro(Voe,this).error("Failed to upgrade inbound connection",d),d}return await this.shouldBlockConnection(n,e,"denyInboundUpgradedConnection"),ro(Voe,this).call(this,"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,l;null!=n&&(i=DZ(n),await this.shouldBlockConnection(i,e,"denyOutboundConnection")),null===(r=this.components.metrics)||void 0===r||r.trackMultiaddrConnection(e),ro(Voe,this).call(this,"Starting the outbound connection upgrade");let u=e;if(!0!==(null===t||void 0===t?void 0:t.skipProtection)){const t=this.components.connectionProtector;null!=t&&(u=await t.protect(e))}try{if(o=u,!0!==(null===t||void 0===t?void 0:t.skipEncryption)){({conn:o,remotePeer:s,protocol:c}=await this._encryptOutbound(u,i));const e={...u,...o};await this.shouldBlockConnection(s,e,"denyOutboundEncryptedConnection")}else{if(null==i)throw new ly("Encryption was skipped but no peer id was passed",Vne.ERR_INVALID_PEER);c="native",s=i}if(a=o,null!=(null===t||void 0===t?void 0:t.muxerFactory))l=t.muxerFactory;else if(this.muxers.size>0){const e=await this._multiplexOutbound({...u,...o},this.muxers);l=e.muxerFactory,a=e.stream}}catch(h){throw ro(Voe,this).error("Failed to upgrade outbound connection",h),await e.close(h),h}return await this.shouldBlockConnection(s,e,"denyOutboundUpgradedConnection"),ro(Voe,this).call(this,"Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:l,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:l,transient:u}=e;let h,d,f;null!=l&&(h=l.createStreamMuxer({direction:o,onIncomingStream:e=>{null!=f&&Promise.resolve().then((async()=>{var t;const r=this.components.registrar.getProtocols(),{stream:n,protocol:i}=await Ooe(e,r);if(ro(Voe,this).call(this,"%s: incoming stream opened on %s",o,i),null==f)return;const s=function(e,t){try{const{options:r}=t.getHandler(e);return r.maxInboundStreams}catch(r){if(r.code!==Vne.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return 32}(i,this.components.registrar);if(Koe(i,"inbound",f)===s){const t=new ly('Too many inbound protocol streams for protocol "'.concat(i,'" - limit ').concat(s),Vne.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw e.abort(t),t}e.source=n.source,e.sink=n.sink,e.protocol=i,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=>{ro(Voe,this).error(t),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 ly("Stream is not multiplexed",Vne.ERR_MUXER_UNAVAILABLE);ro(Voe,n).call(n,"%s-%s: starting new stream on %s",f.id,o,e);const r=await h.newStream();try{var i;if(null==t.signal){ro(Voe,n).call(n,"No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",e);const r=AbortSignal.timeout(3e4);ST(1/0,r),t={...t,signal:r}}const{stream:o,protocol:s}=await Uoe(r,e,t),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!==Vne.ERR_NO_HANDLER_FOR_PROTOCOL)throw i}return null!==(r=n.maxOutboundStreams)&&void 0!==r?r:64}(s,n.components.registrar,t);if(Koe(s,"outbound",f)>=a){const e=new ly('Too many outbound protocol streams for protocol "'.concat(s,'" - limit ').concat(a),Vne.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===(i=n.components.metrics)||void 0===i||i.trackProtocolStream(r,f),r}catch(s){if(ro(Voe,n).error("could not create new stream for protocols %s on connection with address %a",e,f.remoteAddr,s),null==r.timeline.close&&r.abort(s),null!=s.code)throw s;throw new ly(String(s),Vne.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([h.sink(a.source),a.sink(h.source)]).catch((e=>{ro(Voe,this).error(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){ro(Voe,n).error(e)}finally{n.events.safeDispatchEvent("connection:close",{detail:f})}})().catch((e=>{ro(Voe,n).error(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:u,logger:this.components.logger,newStream:null!==(r=d)&&void 0!==r?r:()=>{throw new ly("connection is not multiplexed",Vne.ERR_CONNECTION_NOT_MULTIPLEXED)},getStreams:()=>null!=h?h.streams:[],close:async e=>{null!=h&&(ro(Voe,this).trace("close muxer"),await h.close(e)),ro(Voe,this).trace("close maconn"),await s.close(e),ro(Voe,this).trace("closed maconn")},abort:e=>{s.abort(e),null!=h&&h.abort(e)}},f=new Foe(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 ly("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());ro(Voe,this).call(this,"handling inbound crypto protocol selection",t);try{const{stream:r,protocol:n}=await Ooe(e,t,{writeBytes:!0}),i=this.connectionEncryption.get(n);if(null==i)throw new Error("no crypto module found for ".concat(n));return ro(Voe,this).call(this,"encrypting inbound connection..."),{...await i.secureInbound(this.components.peerId,r),protocol:n}}catch(r){throw new ly(String(r),Vne.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){const r=Array.from(this.connectionEncryption.keys());ro(Voe,this).call(this,"selecting outbound crypto protocol",r);try{const{stream:n,protocol:i}=await Uoe(e,r,{writeBytes:!0}),o=this.connectionEncryption.get(i);if(null==o)throw new Error("no crypto module found for ".concat(i));return ro(Voe,this).call(this,"encrypting outbound connection to %p",t),{...await o.secureOutbound(this.components.peerId,n,t),protocol:i}}catch(n){throw new ly(String(n),Vne.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const r=Array.from(t.keys());ro(Voe,this).call(this,"outbound selecting muxer %s",r);try{const{stream:n,protocol:i}=await Uoe(e,r,{writeBytes:!0});ro(Voe,this).call(this,"%s selected as muxer protocol",i);return{stream:n,muxerFactory:t.get(i)}}catch(n){throw ro(Voe,this).error("error multiplexing outbound stream",n),new ly(String(n),Vne.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const r=Array.from(t.keys());ro(Voe,this).call(this,"inbound handling muxers %s",r);try{const{stream:n,protocol:i}=await Ooe(e,r,{writeBytes:!0});return{stream:n,muxerFactory:t.get(i)}}catch(n){throw ro(Voe,this).error("error multiplexing inbound stream",n),new ly(String(n),Vne.ERR_MUXER_UNAVAILABLE)}}}var Hoe=new WeakMap,Woe=new WeakMap,Goe=new WeakSet;class Yoe extends vT{constructor(e){var t,r,n,i,o,s,a;super(),nH(this,Goe),Ji(this,"peerId",void 0),Ji(this,"peerStore",void 0),Ji(this,"contentRouting",void 0),Ji(this,"peerRouting",void 0),Ji(this,"keychain",void 0),Ji(this,"metrics",void 0),Ji(this,"services",void 0),Ji(this,"logger",void 0),Ji(this,"components",void 0),eo(this,Hoe,void 0),eo(this,Woe,void 0);const c=new vT,l=c.dispatchEvent.bind(c);c.dispatchEvent=e=>{const t=l(e),r=this.dispatchEvent(new ET(e.type,{detail:e.detail}));return t||r},ST(1/0,c),no(Hoe,this,!1),this.peerId=e.peerId,this.logger=null!==(t=e.logger)&&void 0!==t?t:bQ(),no(Woe,this,this.logger.forComponent("libp2p")),this.services={};const u=this.components=function(){const e=new mre(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return new Proxy(e,{get(t,r,n){if("string"===typeof r&&!vre.includes(r)){const t=e.components[r];if(null==t&&!wre.includes(r))throw new ly("".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,logger:this.logger,events:c,datastore:null!==(r=e.datastore)&&void 0!==r?r:new dre,connectionGater:Ore(e.connectionGater)});this.peerStore=this.configureComponent("peerStore",new ire(u,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),null!=e.metrics&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),u.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)),protocols:e.detail.peer.protocols};u.events.safeDispatchEvent("peer:discovery",{detail:t})}})),null!=e.connectionProtector&&this.configureComponent("connectionProtector",e.connectionProtector(u)),this.components.upgrader=new joe(this.components,{connectionEncryption:(null!==(n=e.connectionEncryption)&&void 0!==n?n:[]).map(((e,t)=>this.configureComponent("connection-encryption-".concat(t),e(this.components)))),muxers:(null!==(i=e.streamMuxers)&&void 0!==i?i:[]).map(((e,t)=>this.configureComponent("stream-muxers-".concat(t),e(this.components)))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new doe(this.components,e.transportManager)),this.configureComponent("connectionManager",new $ie(this.components,e.connectionManager)),this.configureComponent("registrar",new loe(this.components)),this.configureComponent("addressManager",new bre(this.components,e.addresses));const h=VY.generateOptions();this.keychain=this.configureComponent("keyChain",new VY(this.components,{...h,...e.keychain}));const d=(null!==(o=e.peerRouters)&&void 0!==o?o:[]).map(((e,t)=>this.configureComponent("peer-router-".concat(t),e(this.components))));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new aoe(this.components,{routers:d}));const f=(null!==(s=e.contentRouters)&&void 0!==s?s:[]).map(((e,t)=>this.configureComponent("content-router-".concat(t),e(this.components))));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new ioe(this.components,{routers:f})),(null!==(a=e.peerDiscovery)&&void 0!==a?a:[]).forEach(((e,t)=>{this.configureComponent("peer-discovery-".concat(t),e(this.components)).addEventListener("peer",(e=>{to(Goe,this,Qoe).call(this,e)}))})),e.transports.forEach(((e,t)=>{this.components.transportManager.add(this.configureComponent("transport-".concat(t),e(this.components)))})),null!=e.services)for(const p of Object.keys(e.services)){const t=(0,e.services[p])(this.components);null!=t?(this.services[p]=t,this.configureComponent(p,t),null!=t[iH]&&(ro(Woe,this).call(this,"registering service %s for content routing",p),f.push(t[iH])),null!=t[oH]&&(ro(Woe,this).call(this,"registering service %s for peer routing",p),d.push(t[oH])),null!=t[AT]&&(ro(Woe,this).call(this,"registering service %s for peer discovery",p),t[AT].addEventListener("peer",(e=>{to(Goe,this,Qoe).call(this,e)})))):ro(Woe,this).error("service factory %s returned null or undefined instance",p)}}configureComponent(e,t){return null==t&&ro(Woe,this).error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if(ro(Hoe,this))return;no(Hoe,this,!0),ro(Woe,this).call(this,"libp2p is starting");null==(await this.keychain.listKeys()).find((e=>"self"===e.name))&&(ro(Woe,this).call(this,"importing self key into keychain"),await this.keychain.importPeer("self",this.components.peerId));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.safeDispatchEvent("start",{detail:this}),ro(Woe,this).call(this,"libp2p has started")}catch(i){throw ro(Woe,this).error("An error occurred starting libp2p",i),await this.stop(),i}}async stop(){var e,t,r,n;ro(Hoe,this)&&(ro(Woe,this).call(this,"libp2p is stopping"),no(Hoe,this,!1),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.safeDispatchEvent("stop",{detail:this}),ro(Woe,this).call(this,"libp2p has stopped"))}isStarted(){return ro(Hoe,this)}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){const e=new dX;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,t)}async dialProtocol(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==t)throw new ly("no protocols were provided to open a stream",Vne.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw new ly("no protocols were provided to open a stream",Vne.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;il(e)&&(e=DZ(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(ro(Woe,this).call(this,"getPublicKey %p",e),null!=e.publicKey)return e.publicKey;const r=await this.peerStore.get(e);if(null!=r.id.publicKey)return r.id.publicKey;const n=Fa([kc("/pk/"),e.multihash.digest]),i=await this.contentRouting.get(n,t);return y_(i),await this.peerStore.patch(e,{publicKey:i}),i}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 Qoe(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs,protocols:t.protocols}).catch((e=>{ro(Woe,this).error(e)})):ro(Woe,this).error(new Error(Vne.ERR_DISCOVERED_SELF))}async function Joe(e){if(null==e.peerId){const r=e.datastore;if(null!=r)try{const t=new VY({datastore:r},TY(VY.generateOptions(),e.keychain));e.peerId=await t.exportPeerId("self")}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t}}return null==e.peerId&&(e.peerId=await R2()),new Yoe(function(e){var t;const r=TY(jne,e);if(null==r.transports||r.transports.length<1)throw new ly(Kne.ERR_TRANSPORTS_REQUIRED,Vne.ERR_TRANSPORTS_REQUIRED);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 ly(Kne.ERR_PROTECTOR_REQUIRED,Vne.ERR_PROTECTOR_REQUIRED);return r}(e))}const Xoe="js-libp2p/".concat("0.46.21");function Zoe(e,t){const r=yp(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}const $oe=new Float32Array([-0]),ese=new Uint8Array($oe.buffer);function tse(e,t,r){$oe[0]=e,t[r]=ese[0],t[r+1]=ese[1],t[r+2]=ese[2],t[r+3]=ese[3]}const rse=new Float64Array([-0]),nse=new Uint8Array(rse.buffer);function ise(e,t,r){rse[0]=e,t[r]=nse[0],t[r+1]=nse[1],t[r+2]=nse[2],t[r+3]=nse[3],t[r+4]=nse[4],t[r+5]=nse[5],t[r+6]=nse[6],t[r+7]=nse[7]}const ose=BigInt(Number.MAX_SAFE_INTEGER),sse=BigInt(Number.MIN_SAFE_INTEGER);class ase{constructor(e,t){Ji(this,"lo",void 0),Ji(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 cse;if(e<ose&&e>sse)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>lse&&(n=0n,++r>lse&&(r=0n))),new ase(Number(n),Number(r))}static fromNumber(e){if(0===e)return cse;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 ase(r,n)}static from(e){return"number"===typeof e?ase.fromNumber(e):"bigint"===typeof e?ase.fromBigInt(e):"string"===typeof e?ase.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new ase(e.low>>>0,e.high>>>0):cse}}const cse=new ase(0,0);cse.toBigInt=function(){return 0n},cse.zzEncode=cse.zzDecode=function(){return this},cse.length=function(){return 1};const lse=4294967296n;function use(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 hse(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!==t&&void 0!==t?t:1," > ").concat(e.len))}function dse(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class fse{constructor(e){Ji(this,"buf",void 0),Ji(this,"pos",void 0),Ji(this,"len",void 0),Ji(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,hse(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 hse(this,4);return dse(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw hse(this,4);return 0|dse(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw hse(this,4);const e=(t=this.buf,r=this.pos,ese[0]=t[r],ese[1]=t[r+1],ese[2]=t[r+2],ese[3]=t[r+3],$oe[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw hse(this,4);const e=(t=this.buf,r=this.pos,nse[0]=t[r],nse[1]=t[r+1],nse[2]=t[r+2],nse[3]=t[r+3],nse[4]=t[r+4],nse[5]=t[r+5],nse[6]=t[r+6],nse[7]=t[r+7],rse[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 hse(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 hse(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw hse(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 ase(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw hse(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 hse(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 hse(this,8);const e=dse(this.buf,this.pos+=4),t=dse(this.buf,this.pos+=4);return new ase(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=Ml(this.buf,this.pos);return this.pos+=Ll(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 pse(e,t,r){const n=function(e){return new fse(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function gse(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function bse(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 yse=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),l=Math.log(a)/Math.log(256),u=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)*l+1>>>0,s=new Uint8Array(o);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=o-1;(0!==u||h<i)&&-1!==d;d--,h++)u+=a*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,l=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*l[f]>>>0,l[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===l[p];)p++;for(var g=c.repeat(r);p<s;++p)g+=e.charAt(l[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}};const mse=yse;class wse{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(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 vse{constructor(e,t,r){if(Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseDecode",void 0),Ji(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 Ese(this,e)}}class _se{constructor(e){Ji(this,"decoders",void 0),this.decoders=e}or(e){return Ese(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 Ese(e,t){var r,n;return new _se({...null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e},...null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}})}class Sse{constructor(e,t,r,n){Ji(this,"name",void 0),Ji(this,"prefix",void 0),Ji(this,"baseEncode",void 0),Ji(this,"baseDecode",void 0),Ji(this,"encoder",void 0),Ji(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new wse(e,t,r),this.decoder=new vse(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Ase(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Sse(t,r,n,i)}function xse(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:o}=mse(n,t);return Ase({prefix:r,name:t,encode:i,decode:e=>bse(o(e))})}function kse(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Ase({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 u=0;u<t.length;++u)i[t[u]]=u;let o=e.length;for(;"="===e[o-1];)--o;const s=new Uint8Array(o*r/8|0);let a=0,c=0,l=0;for(let u=0;u<o;++u){const t=i[e[u]];if(void 0===t)throw new SyntaxError("Non-".concat(n," character"));c=c<<r|t,a+=r,a>=8&&(a-=8,s[l++]=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 Cse=xse({prefix:"9",name:"base10",alphabet:"0123456789"}),Ise=kse({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Tse=kse({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Pse=kse({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Rse=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"),Dse=Rse.reduce(((e,t,r)=>(e[r]=t,e)),[]),Nse=Rse.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Bse=Ase({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Dse[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Nse[r.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(r));t.push(e)}return new Uint8Array(t)}}),Lse=kse({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Use=kse({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mse=kse({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ose=kse({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qse=kse({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),zse=kse({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fse=kse({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Kse=kse({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Vse=kse({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),jse=xse({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Hse=xse({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Wse=xse({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Gse=xse({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Yse=kse({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qse=kse({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jse=kse({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xse=kse({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Zse=kse({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),$se=Ase({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)}),eae=new TextEncoder,tae=new TextDecoder,rae="json",nae=512;function iae(e){return eae.encode(JSON.stringify(e))}function oae(e){return JSON.parse(tae.decode(e))}const sae="raw",aae=85;function cae(e){return bse(e)}function lae(e){return bse(e)}var uae=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=fae;)r[n++]=255&t|hae,t/=128;for(;t&dae;)r[n++]=255&t|hae,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},hae=128,dae=-128,fae=Math.pow(2,31);var pae=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&bae)<<o:(n&bae)*Math.pow(2,o),o+=7}while(n>=gae);return e.bytes=s-r,i},gae=128,bae=127;var yae=Math.pow(2,7),mae=Math.pow(2,14),wae=Math.pow(2,21),vae=Math.pow(2,28),_ae=Math.pow(2,35),Eae=Math.pow(2,42),Sae=Math.pow(2,49),Aae=Math.pow(2,56),xae=Math.pow(2,63);const kae={encode:uae,decode:pae,encodingLength:function(e){return e<yae?1:e<mae?2:e<wae?3:e<vae?4:e<_ae?5:e<Eae?6:e<Sae?7:e<Aae?8:e<xae?9:10}};function Cae(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return kae.encode(e,t,r),t}function Iae(e){return kae.encodingLength(e)}function Tae(e,t){const r=t.byteLength,n=Iae(e),i=n+Iae(r),o=new Uint8Array(i+r);return Cae(e,o,0),Cae(r,o,n),o.set(t,i),new Pae(e,r,t,o)}class Pae{constructor(e,t,r,n){Ji(this,"code",void 0),Ji(this,"size",void 0),Ji(this,"digest",void 0),Ji(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Rae=bse;const Dae={code:0,name:"identity",encode:Rae,digest:function(e){return Tae(0,Rae(e))}};function Nae(e){let{name:t,code:r,encode:n}=e;return new Bae(t,r,n)}class Bae{constructor(e,t,r){Ji(this,"name",void 0),Ji(this,"code",void 0),Ji(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?Tae(this.code,t):t.then((e=>Tae(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Lae(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Uae=Nae({name:"sha2-256",code:18,encode:Lae("SHA-256")}),Mae=Nae({name:"sha2-512",code:19,encode:Lae("SHA-512")});new WeakMap;Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Oae={...Fi,...Bi,...zi,...Di,...Ni,...Ui,...Mi,...Oi,...qi,...Li};function qae(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const zae=qae("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Fae=qae("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=gse((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Kae={utf8:zae,"utf-8":zae,hex:Oae.base16,latin1:Fae,ascii:Fae,binary:Fae,...Oae};class Vae{constructor(e,t,r){Ji(this,"fn",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),Ji(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function jae(){}class Hae{constructor(e){Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"len",void 0),Ji(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Wae=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 gse(e);i+e>t&&(n=gse(t),i=0);const o=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),o}}();class Gae{constructor(){Ji(this,"len",void 0),Ji(this,"head",void 0),Ji(this,"tail",void 0),Ji(this,"states",void 0),this.len=0,this.head=new Vae(jae,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Vae(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Jae((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Xae,10,ase.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=ase.fromBigInt(e);return this._push(Xae,t.length(),t)}uint64Number(e){return this._push(Ul,Ll(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=ase.fromBigInt(e).zzEncode();return this._push(Xae,t.length(),t)}sint64Number(e){const t=ase.fromNumber(e).zzEncode();return this._push(Xae,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Yae,1,e?1:0)}fixed32(e){return this._push(Zae,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=ase.fromBigInt(e);return this._push(Zae,4,t.lo)._push(Zae,4,t.hi)}fixed64Number(e){const t=ase.fromNumber(e);return this._push(Zae,4,t.lo)._push(Zae,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(tse,4,e)}double(e){return this._push(ise,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Yae,1,0):this.uint32(t)._push($ae,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(use,t,e):this._push(Yae,1,0)}fork(){return this.states=new Hae(this),this.head=this.tail=new Vae(jae,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 Vae(jae,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?gse(r):Wae(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Yae(e,t,r){t[r]=255&e}function Qae(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Jae extends Vae{constructor(e,t){super(Qae,e,t),Ji(this,"next",void 0),this.next=void 0}}function Xae(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 Zae(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 $ae(e,t,r){t.set(e,r)}function ece(e,t,r){t.set(e,r)}function tce(e,t,r){e.length<40?use(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=Kae[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}(e),r)}function rce(e,t){const r=new Gae;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var nce,ice;null!=globalThis.Buffer&&(Gae.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(ece,t,e),this},Gae.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(tce,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"}(nce||(nce={}));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",nce.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=>rce(t,e.codec()),e.decode=t=>pse(t,e.codec())}(ice||(ice={}));const oce=8192,sce={protocolPrefix:"ipfs",agentVersion:Xoe,timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1,maxObservedAddresses:10,maxIdentifyMessageSize:8192,runOnConnectionOpen:!0,runOnTransientConnection:!0};var ace=new WeakMap,cce=new WeakSet;class lce{constructor(e,t){var r,n,i,o,s,a,c,l,u,h,d,f,p;nH(this,cce),Ji(this,"identifyProtocolStr",void 0),Ji(this,"identifyPushProtocolStr",void 0),Ji(this,"host",void 0),Ji(this,"started",void 0),Ji(this,"timeout",void 0),Ji(this,"peerId",void 0),Ji(this,"peerStore",void 0),Ji(this,"registrar",void 0),Ji(this,"connectionManager",void 0),Ji(this,"addressManager",void 0),Ji(this,"maxInboundStreams",void 0),Ji(this,"maxOutboundStreams",void 0),Ji(this,"maxPushIncomingStreams",void 0),Ji(this,"maxPushOutgoingStreams",void 0),Ji(this,"maxIdentifyMessageSize",void 0),Ji(this,"maxObservedAddresses",void 0),Ji(this,"events",void 0),Ji(this,"runOnTransientConnection",void 0),eo(this,ace,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,no(ace,this,e.logger.forComponent("libp2p:identify")),this.identifyProtocolStr="/".concat(null!==(r=t.protocolPrefix)&&void 0!==r?r:sce.protocolPrefix,"/").concat("id","/").concat("1.0.0"),this.identifyPushProtocolStr="/".concat(null!==(n=t.protocolPrefix)&&void 0!==n?n:sce.protocolPrefix,"/").concat("id/push","/").concat("1.0.0"),this.timeout=null!==(i=t.timeout)&&void 0!==i?i:sce.timeout,this.maxInboundStreams=null!==(o=t.maxInboundStreams)&&void 0!==o?o:sce.maxInboundStreams,this.maxOutboundStreams=null!==(s=t.maxOutboundStreams)&&void 0!==s?s:sce.maxOutboundStreams,this.maxPushIncomingStreams=null!==(a=t.maxPushIncomingStreams)&&void 0!==a?a:sce.maxPushIncomingStreams,this.maxPushOutgoingStreams=null!==(c=t.maxPushOutgoingStreams)&&void 0!==c?c:sce.maxPushOutgoingStreams,this.maxIdentifyMessageSize=null!==(l=t.maxIdentifyMessageSize)&&void 0!==l?l:sce.maxIdentifyMessageSize,this.maxObservedAddresses=null!==(u=t.maxObservedAddresses)&&void 0!==u?u:sce.maxObservedAddresses,this.runOnTransientConnection=null!==(h=t.runOnTransientConnection)&&void 0!==h?h:sce.runOnTransientConnection,this.host={protocolVersion:"".concat(null!==(d=t.protocolPrefix)&&void 0!==d?d:sce.protocolPrefix,"/").concat("0.1.0"),agentVersion:null!==(f=t.agentVersion)&&void 0!==f?f:sce.agentVersion},(null!==(p=t.runOnConnectionOpen)&&void 0!==p?p:sce.runOnConnectionOpen)&&e.events.addEventListener("connection:open",(e=>{const t=e.detail;this.identify(t).catch((e=>{ro(ace,this).error("error during identify trigged by connection:open",e)}))})),e.events.addEventListener("self:peer:update",(e=>{this.push().catch((e=>{ro(ace,this).error(e)}))})),this.host.agentVersion===Xoe&&(RI||TI?this.host.agentVersion+=" UserAgent=".concat(globalThis.process.version):(II||DI||PI||NI)&&(this.host.agentVersion+=" UserAgent=".concat(globalThis.navigator.userAgent)))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:kc(this.host.agentVersion),ProtocolVersion:kc(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,(e=>{this._handleIdentify(e).catch((e=>{ro(ace,this).error(e)}))}),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,(e=>{this._handlePush(e).catch((e=>{ro(ace,this).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(Mc("p2p").code))),i=new d8({peerId:this.peerId,multiaddrs:n}),o=await a8.seal(i,this.peerId),s=this.registrar.getProtocols(),a=await this.peerStore.get(this.peerId),c=za(null!==(t=a.metadata.get("AgentVersion"))&&void 0!==t?t:kc(this.host.agentVersion)),l=za(null!==(r=a.metadata.get("ProtocolVersion"))&&void 0!==r?r:kc(this.host.protocolVersion)),u=e.map((async e=>{let t;const r=AbortSignal.timeout(this.timeout);ST(1/0,r);try{var i;t=await e.newStream([this.identifyPushProtocolStr],{signal:r,runOnTransientConnection:this.runOnTransientConnection});const a=Zoe(t,{maxDataLength:null!==(i=this.maxIdentifyMessageSize)&&void 0!==i?i:oce}).pb(ice);await a.write({listenAddrs:n.map((e=>e.bytes)),signedPeerRecord:o.marshal(),protocols:s,agentVersion:c,protocolVersion:l},{signal:r}),await t.close({signal:r})}catch(u){var a;ro(ace,this).error("could not push identify update to peer",u),null===(a=t)||void 0===a||a.abort(u)}}));await Promise.all(u)}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(r.code!==Vne.ERR_NOT_FOUND)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);ST(1/0,e),r={...r,signal:e}}try{var n;t=await e.newStream([this.identifyProtocolStr],{...r,runOnTransientConnection:this.runOnTransientConnection});const i=Zoe(t,{maxDataLength:null!==(n=this.maxIdentifyMessageSize)&&void 0!==n?n:oce}).pb(ice),o=await i.read(r);return await t.close(r),o}catch(o){var i;throw ro(ace,this).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 ly("public key was missing from identify message",Vne.ERR_MISSING_PUBLIC_KEY);const a=await NZ(i);if(!e.remotePeer.equals(a))throw new ly("identified peer does not match the expected peer",Vne.ERR_INVALID_PEER);if(this.peerId.equals(a))throw new ly("identified peer is our own peer id?",Vne.ERR_INVALID_PEER);const c=function(e){if(null!=e&&e.length>0)try{return gl(e)}catch{}}(s);return ro(ace,this).call(this,"identify completed for peer %p and protocols %o",a,o),ro(ace,this).call(this,"our observed address is %a",c),null!=c&&this.addressManager.getObservedAddrs().length<(null!==(t=this.maxObservedAddresses)&&void 0!==t?t:1/0)&&(ro(ace,this).call(this,"storing our observed address %a",c),this.addressManager.addObservedAddr(c)),to(cce,this,uce).call(this,e,n)}async _handleIdentify(e){const{connection:t,stream:r}=e,n=AbortSignal.timeout(this.timeout);ST(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(Mc("p2p").code)));let a=o.peerRecordEnvelope;if(s.length>0&&null==a){const e=new d8({peerId:this.peerId,multiaddrs:s});a=(await a8.seal(e,this.peerId)).marshal().subarray()}let c=t.remoteAddr.bytes;gne.matches(t.remoteAddr)||(c=void 0);const l=Zoe(r).pb(ice);await l.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){ro(ace,this).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=Zoe(r,{maxDataLength:null!==(n=this.maxIdentifyMessageSize)&&void 0!==n?n:oce}).pb(ice),o=await i.read(e);await r.close(e),await to(cce,this,uce).call(this,t,o)}catch(i){return ro(ace,this).error("received invalid message",i),void r.abort(i)}ro(ace,this).call(this,"handled push from %p",t.remotePeer)}}async function uce(e,t){if(ro(ace,this).call(this,"received identify from %p",e.remotePeer),null==t)throw new ly("message was null or undefined","ERR_INVALID_MESSAGE");const r={};if(t.listenAddrs.length>0&&(r.addresses=t.listenAddrs.map((e=>({isCertified:!1,multiaddr:gl(e)})))),t.protocols.length>0&&(r.protocols=t.protocols),null!=t.publicKey){r.publicKey=t.publicKey;if(!(await NZ(t.publicKey)).equals(e.remotePeer))throw new ly("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY")}let n;if(null!=t.signedPeerRecord){ro(ace,this).call(this,"received signedPeerRecord in push from %p",e.remotePeer);let i=t.signedPeerRecord;const s=await a8.openAndCertify(i,d8.DOMAIN);let a,c=d8.createFromProtobuf(s.payload);if(!c.peerId.equals(s.peerId))throw new ly("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!e.remotePeer.equals(c.peerId))throw new ly("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 a8.createFromProtobuf(a.peerRecordEnvelope),t=d8.createFromProtobuf(e.payload);t.seqNumber>=c.seqNumber&&(ro(ace,this).call(this,"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 ro(ace,this).call(this,"%p did not send a signed peer record",e.remotePeer);if(ro(ace,this).call(this,"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=kc(t.agentVersion)),null!=t.protocolVersion&&(r.ProtocolVersion=kc(t.protocolVersion)),ro(ace,this).call(this,"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=>gl(e))),observedAddr:null==t.observedAddr?void 0:gl(t.observedAddr),protocols:t.protocols,signedPeerRecord:n,connection:e};return this.events.safeDispatchEvent("peer:identify",{detail:i}),i}function hce(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new lce(t,e)}const dce=yQ("libp2p:ping");class fce{constructor(e,t){var r,n,i,o,s;Ji(this,"protocol",void 0),Ji(this,"components",void 0),Ji(this,"started",void 0),Ji(this,"timeout",void 0),Ji(this,"maxInboundStreams",void 0),Ji(this,"maxOutboundStreams",void 0),Ji(this,"runOnTransientConnection",void 0),this.components=e,this.started=!1,this.protocol="/".concat(null!==(r=t.protocolPrefix)&&void 0!==r?r:"ipfs","/").concat("ping","/").concat("1.0.0"),this.timeout=null!==(n=t.timeout)&&void 0!==n?n:1e4,this.maxInboundStreams=null!==(i=t.maxInboundStreams)&&void 0!==i?i:2,this.maxOutboundStreams=null!==(o=t.maxOutboundStreams)&&void 0!==o?o:1,this.runOnTransientConnection=null===(s=t.runOnTransientConnection)||void 0===s||s}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){dce("incoming ping from %p",e.connection.remotePeer);const{stream:t}=e,r=Date.now();pf(t,t).catch((t=>{dce.error("incoming ping from %p failed with error",e.connection.remotePeer,t)})).finally((()=>{const t=Date.now()-r;dce("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]:{};dce("pinging %p",e);const r=Date.now(),n=Pv(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 ly("ping timeout",Vne.ERR_TIMEOUT))},null===(a=t.signal)||void 0===a||a.addEventListener("abort",s,{once:!0});const e=await pf([n],o,(async e=>ooe(e))),c=Date.now()-r;if(null==e)throw new ly("Did not receive a ping ack after ".concat(c,"ms"),Vne.ERR_WRONG_PING_ACK);if(!ls(n,e.subarray()))throw new ly("Received wrong ping ack after ".concat(c,"ms"),Vne.ERR_WRONG_PING_ACK);return dce("ping %p complete in %dms",i.remotePeer,c),c}catch(u){var c;throw dce.error("error while pinging %p",i.remotePeer,u),null===(c=o)||void 0===c||c.abort(u),u}finally{var l;null===(l=t.signal)||void 0===l||l.removeEventListener("abort",s),null!=o&&await o.close()}}}function pce(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new fce(t,e)}const gce={lightPush:1,filter:1,store:1};async function bce(e){var t,r;const n=null!==(t=null===e||void 0===e?void 0:e.libp2p)&&void 0!==t?t:{},i=null!==(r=n.peerDiscovery)&&void 0!==r?r:[];null!==e&&void 0!==e&&e.defaultBootstrap&&(i.push(...yce()),Object.assign(n,{peerDiscovery:i}));const o=await mce(void 0,n,null===e||void 0===e?void 0:e.userAgent),s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Zf(t,e)}(e),a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Vf(t,e)}(e),c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new qf(t,e)}(e);return new Md(null!==e&&void 0!==e?e:{},o,s,a,c)}function yce(){return[lz([xT.PROD],gce),e=>new mz(e)]}async function mce(e,t,r){const n=e?{pubsub:e}:{};return async function(e){const t=await Joe(e);return!1!==e.start&&await t.start(),t}({connectionManager:{minConnections:1},transports:[yT({filter:fT})],streamMuxers:[Sk()],connectionEncryption:[Mx()],...t,services:{identify:hce({agentVersion:null!==r&&void 0!==r?r:Ld}),ping:pce(),...n,...null===t||void 0===t?void 0:t.services}})}const wce=Wi.createContext({decoder:void 0,encoder:void 0}),vce=()=>Wi.useContext(wce),_ce=e=>{const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const[r,n]=Wi.useState(Id({contentTopic:e,ephemeral:t})),[i,o]=Wi.useState(Pd(e));return Wi.useEffect((()=>{n(Id({contentTopic:e,ephemeral:t})),o(Pd(e))}),[e,t]),{encoder:r,decoder:i}}(e.contentTopic,e.ephemeral);return Wi.createElement(wce.Provider,{value:t},e.children)},Ece=e=>{const{factory:t,options:r,protocols:n=[]}=e,[i,o]=Wi.useState(void 0),[s,a]=Wi.useState(!0),[c,l]=Wi.useState(void 0);return Wi.useEffect((()=>{let e=!1;return a(!0),t(r).then((async t=>{e||(await t.start(),await ap(t,n),o(t),a(!1))})).catch((e=>{a(!1),l("Failed at creating node: ".concat((null===e||void 0===e?void 0:e.message)||"no message"))})),()=>{e=!0}}),[]),{node:i,error:c,isLoading:s}},Sce=e=>{const{node:t,encoder:r}=e,n=Wi.useCallback((e=>t.lightPush.send(r,e)),[t,r]);return t||r?{push:n}:{}},Ace=Wi.createContext({node:void 0,isLoading:!1,error:void 0}),xce=()=>Wi.useContext(Ace),kce=e=>{const t=(r={options:e.options,protocols:e.protocols},Ece({...r,factory:bce}));var r;return Wi.createElement(Ace.Provider,{value:t},e.children)};async function Cce(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=gl(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 Ice=__webpack_require__(579);function Tce(e){const t=e.messages.array.map((e=>{var t;return(0,Ice.jsxs)("div",{className:"flex flex-col p-2 border-b border-gray-200",children:[(0,Ice.jsx)("span",{className:"text-sm text-gray-500",children:e.nick}),(0,Ice.jsx)("span",{className:"text-sm text-gray-500",children:Pce(e)}),(0,Ice.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,Ice.jsxs)("div",{className:"overflow-y-auto h-full",children:[t,(0,Ice.jsx)(Rce,{messages:e.messages.array})]})}function Pce(e){return e.timestamp.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!1})}const Rce=e=>{const t=(0,Wi.useRef)(null);return(0,Wi.useEffect)((()=>{t.current&&t.current.scrollIntoView()}),[e.messages]),(0,Ice.jsx)("div",{ref:t})};function Dce(e){const{hasLightPushPeers:t}=e,{node:r}=xce(),[n,i]=(0,Wi.useState)(""),[o,s]=(0,Wi.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,Wi.useEffect)((()=>{n.startsWith("/")||t?s(!0):r&&s(!1)}),[r,n,t]),(0,Ice.jsxs)("div",{className:"flex p-2",children:[(0,Ice.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,Ice.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 Nce=__webpack_require__(3338),Bce=__webpack_require__(7707),Lce=__webpack_require__(5850),Uce=__webpack_require__(3931);__webpack_require__(1509)._configure(),Nce._configure(Bce),Lce._configure(Uce);const Mce=["uint64","int64","sint64","fixed64","sfixed64"];function Oce(e){return function(e){for(const t of Mce){if(null==e[t])continue;const r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}(new Nce(e))}function qce(){return function(e){for(const t of Mce){if(null==e[t])continue;const r=e[t];e[t]=function(e){return r.call(this,e.toString())}}return e}(Lce.create())}var zce;let Fce;!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"}(zce||(zce={})),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",zce.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=qce();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}(e,Fce.codec()),e.decode=e=>function(e,t){const r=Oce(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}(e,Fce.codec())}(Fce||(Fce={}));class Kce{constructor(e){this.proto=e}static fromUtf8String(e,t,r){const n=BigInt(Math.floor(e.valueOf()/1e3)),i=xl(r);return new Kce({timestamp:n,nick:t,payload:i})}static decode(e){const t=Fce.decode(e);return new Kce(t)}encode(){return Fce.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 Vce=__webpack_require__(9233);class jce{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=Kce.decode(e.payload);if(t)return new jce(t,e.timestamp)}catch(t){console.error("Failed to decode chat message",t)}}static fromUtf8String(e,t){const r=new Date;return new jce(Kce.fromUtf8String(r,e,t),r)}get nick(){return this.chatMessage.nick}get timestamp(){return this.chatMessage.timestamp}get payloadAsUtf8(){return this.chatMessage.payloadAsUtf8}}class Hce{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 Wce(e,t){return e?t.filter((t=>t.protocols.includes(e.multicodec))).map((e=>e.id)):[]}const Gce=e=>{const{messages:t}=(e=>{const{node:t,decoder:r}=e,[n,i]=Wi.useState(void 0),[o,s]=Wi.useState(!1),[a,c]=Wi.useState([]),l=Wi.useCallback((e=>{e&&c((t=>[...t,e]))}),[c]);return Wi.useEffect((()=>{if(!t||!r)return;let e=null;return s(!0),t.filter.subscribe([r],l).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,l,i,s]),{error:n,messages:a,isLoading:o}})(e),{messages:r}=(e=>{const{node:t,decoder:r,options:n}=e,[i,o]=Wi.useState(void 0),[s,a]=Wi.useState(!1),[c,l]=Wi.useState([]),u=Wi.useCallback((e=>{e&&e.length&&l((t=>[...t,...e]))}),[l]);return Wi.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));u(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,u,o,a]),{error:i,isLoading:s,messages:c}})(e),[n,i]=(0,Wi.useState)([]);return[Wi.useMemo((()=>{const e=new Hce(jce.cmp,jce.isEqual),i=new Date;i.setDate(i.getDate()+1);const o=[...r,...t].map(jce.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]))}]},Yce=e=>{const[t,r]=(0,Wi.useState)(new Set),[n,i]=(0,Wi.useState)(new Set),[o,s]=(0,Wi.useState)(new Set),[a,c]=(0,Wi.useState)(new Set);return(0,Wi.useEffect)((()=>{if(!e)return;const t=async t=>{(async()=>{await Jce(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 Jce(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:l,DISCOVERED:u}=await e.connectionManager.getPeersByDiscovery();i(new Set(l[cl.BOOTSTRAP].map((e=>e.id)))),c(new Set(l[cl.PEER_EXCHANGE].map((e=>e.id)))),r(new Set(u[cl.BOOTSTRAP].map((e=>e.id)))),s(new Set(u[cl.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(ll.PEER_DISCOVERY_BOOTSTRAP,t),e.connectionManager.addEventListener(ll.PEER_CONNECT_BOOTSTRAP,n),e.connectionManager.addEventListener(ll.PEER_DISCOVERY_PEER_EXCHANGE,o),e.connectionManager.addEventListener(ll.PEER_CONNECT_PEER_EXCHANGE,a)})(),()=>{e.connectionManager.removeEventListener(ll.PEER_DISCOVERY_BOOTSTRAP,t),e.connectionManager.removeEventListener(ll.PEER_CONNECT_BOOTSTRAP,n),e.connectionManager.removeEventListener(ll.PEER_DISCOVERY_PEER_EXCHANGE,o),e.connectionManager.removeEventListener(ll.PEER_CONNECT_PEER_EXCHANGE,a)}}),[e]),{discoveredBootstrapPeers:t,connectedBootstrapPeers:n,discoveredPeerExchangePeers:o,connectedPeerExchangePeers:a}},Qce=e=>{const{node:t}=e,[r,n]=Wi.useState({});return(0,Wi.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:Wce(t.store,r),filterPeers:Wce(t.filter,r),lightPushPeers:Wce(t.lightPush,r)})};return e(),t.libp2p.addEventListener("peer:identify",e),()=>{t.libp2p.removeEventListener("peer:identify",e)}}),[t,n]),r},Jce=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 Xce(t.toString())})).length},Xce=e=>e.includes("wss")||e.includes("/tls/ws");function Zce(e){const{node:t}=xce(),{encoder:r}=vce(),{push:n}=Sce({node:t,encoder:r}),{connectedBootstrapPeers:i,connectedPeerExchangePeers:o,discoveredBootstrapPeers:s,discoveredPeerExchangePeers:a}=Yce(t),{allConnected:c,storePeers:l,filterPeers:u,lightPushPeers:h}=Qce({node:t}),d=$ce(null===c||void 0===c?void 0:c.length),f=$ce(null===h||void 0===h?void 0:h.length),p=$ce(null===u||void 0===u?void 0:u.length),g=$ce(null===l||void 0===l?void 0:l.length);return(0,Ice.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,Ice.jsxs)("div",{className:"flex justify-between items-center bg-gray-800 text-white p-4",children:[(0,Ice.jsxs)("div",{children:[(0,Ice.jsxs)("div",{children:["Peers Connected: ",d]}),(0,Ice.jsxs)("div",{className:"mt-2",children:["Store: ",g]}),(0,Ice.jsxs)("div",{children:["Filter: ",p]}),(0,Ice.jsxs)("div",{children:["Light Push: ",f]})]}),(0,Ice.jsx)("div",{children:"Waku v2 Web Chat"}),(0,Ice.jsxs)("div",{children:[(0,Ice.jsxs)("div",{className:"mt-2",children:["Peers Discovered:"," ",s.size+a.size]}),(0,Ice.jsxs)("div",{children:["Bootstrap: ",s.size," Peer Exchange:"," ",a.size]}),(0,Ice.jsxs)("div",{className:"mt-2",children:["Peers Connected:"," ",i.size+o.size]}),(0,Ice.jsxs)("div",{children:["Bootstrap: ",i.size," Peer Exchange:"," ",o.size]})]})]}),(0,Ice.jsx)(Tce,{messages:e.messages}),(0,Ice.jsx)(Dce,{hasLightPushPeers:!!h,sendMessage:async t=>{if(n&&t)if(t.startsWith("/"))e.commandHandler(t);else{const r=new Date,i=Kce.fromUtf8String(r,e.nick,t).encode();await n({payload:i,timestamp:r})}}})]})}function $ce(e){return e||0}const ele=new Date;ele.setTime(Date.now()-6048e5);const tle=new Date;function rle(){const{node:e}=xce(),{decoder:t}=vce(),[r,n]=Gce({node:e,decoder:t,options:{pageSize:5,pageDirection:al.FORWARD,timeFilter:{startTime:ele,endTime:tle}}}),[i,o]=(()=>{const[e,t]=(0,Wi.useState)((()=>{const e=window.localStorage.getItem("nick");return null!==e?e:(0,Vce.c)()}));return(0,Wi.useEffect)((()=>{localStorage.setItem("nick",e)}),[e]),[e,t]})();return(0,Ice.jsx)("div",{className:"chat-app",style:{height:"100vh",width:"100vw",overflow:"hidden"},children:(0,Ice.jsx)(Zce,{nick:i,messages:r,commandHandler:t=>{Cce(t,e,o).then((e=>{let{command:t,response:r}=e;const i=r.map((e=>jce.fromUtf8String(t,e)));n(i)}))}})})}Gi.render((0,Ice.jsx)(Wi.StrictMode,{children:(0,Ice.jsx)(kce,{options:{defaultBootstrap:!0},protocols:[ol.Store,ol.Filter,ol.LightPush],children:(0,Ice.jsx)(_ce,{contentTopic:"/toy-chat/2/huilong/proto",children:(0,Ice.jsx)(rle,{})})})}),document.getElementById("root"))})()})();
//# sourceMappingURL=main.e1d0037a.js.map